source: trunk/dll/archive.c@ 1398

Last change on this file since 1398 was 1398, checked in by Gregg Young, 17 years ago

Move embeded strings to PCSZ variables or string table; Eliminate Error2 functions Runtime_Error with NULL format string returns "No data" error. Change declares from PSZ to PCSZ in functions where the variable isn't changed. Added btm as an executable file type in several additional places. Use fProtectOnly to prevent attempt to execute Dos and Win programs on "Protect only" installs in several additional places.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 7.8 KB
Line 
1
2/***********************************************************************
3
4 $Id: archive.c 1398 2009-02-21 17:43:00Z gyoung $
5
6 Archive create/update dialog procedure
7
8 Copyright (c) 1993-98 M. Kimes
9 Copyright (c) 2004, 2008 Steven H.Levine
10
11 01 Aug 04 SHL Rework lstrip/rstrip usage
12 28 Jun 06 SHL Drop obsoletes
13 17 Jul 06 SHL Use Runtime_Error
14 22 Mar 07 GKY Use QWL_USER
15 20 Aug 07 GKY Move #pragma alloc_text to end for OpenWatcom compat
16 07 Feb 09 GKY Allow user to turn off alert and/or error beeps in settings notebook.
17
18***********************************************************************/
19
20#include <string.h>
21
22#define INCL_WIN
23#define INCL_DOS
24#define INCL_LONGLONG // dircnrs.h
25
26#include "fm3dll.h"
27#include "fm3dll2.h" // #define's for UM_*, control id's, etc.
28#include "notebook.h" // Data declaration(s)
29#include "fm3dlg.h"
30#include "fm3str.h"
31#include "strutil.h" // GetPString
32#include "errutil.h" // Runtime_Error
33#include "archive.h"
34#include "systemf.h" // ExecOnList
35#include "chklist.h" // PosOverOkay
36#include "getnames.h" // export_filename
37#include "misc.h" // PaintRecessedWindow
38#include "strips.h" // bstrip
39
40static PSZ pszSrcFile = __FILE__;
41
42MRESULT EXPENTRY ArchiveDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
43{
44 DIRCNRDATA *arcdata = NULL;
45
46 switch (msg) {
47 case WM_INITDLG:
48 WinSetWindowPtr(hwnd, QWL_USER, mp2);
49 arcdata = (DIRCNRDATA *) mp2;
50 WinSendDlgItemMsg(hwnd, ARCH_ARCNAME, EM_SETTEXTLIMIT,
51 MPFROM2SHORT(CCHMAXPATH, 0), MPVOID);
52 if (!arcdata->namecanchange) {
53 WinSendDlgItemMsg(hwnd, ARCH_ARCNAME, EM_SETREADONLY,
54 MPFROM2SHORT(TRUE, 0), MPVOID);
55 WinEnableWindow(WinWindowFromID(hwnd, ARCH_FIND), FALSE);
56 WinShowWindow(WinWindowFromID(hwnd, ARCH_FIND), FALSE);
57 }
58 WinSendDlgItemMsg(hwnd, ARCH_COMMAND, EM_SETTEXTLIMIT,
59 MPFROM2SHORT(256, 0), MPVOID);
60 WinSendDlgItemMsg(hwnd, ARCH_MASKS, EM_SETTEXTLIMIT,
61 MPFROM2SHORT(256, 0), MPVOID);
62 WinSetDlgItemText(hwnd, ARCH_ARCNAME, arcdata->arcname);
63 if (arcdata->fmoving && arcdata->info->move) {
64 WinSetDlgItemText(hwnd, ARCH_COMMAND, arcdata->info->move);
65 WinSendDlgItemMsg(hwnd, ARCH_MOVE, BM_SETCHECK,
66 MPFROM2SHORT(TRUE, 0), MPVOID);
67 }
68 else
69 WinSetDlgItemText(hwnd, ARCH_COMMAND, arcdata->info->create);
70 if (!arcdata->info->createrecurse)
71 WinEnableWindow(WinWindowFromID(hwnd, ARCH_RECURSE), FALSE);
72 if (!arcdata->info->move && !arcdata->info->movewdirs)
73 WinEnableWindow(WinWindowFromID(hwnd, ARCH_MOVE), FALSE);
74 if (!arcdata->info->createwdirs && !arcdata->info->movewdirs)
75 WinEnableWindow(WinWindowFromID(hwnd, ARCH_INCLPATH), FALSE);
76 *arcdata->command = 0;
77 PosOverOkay(hwnd);
78 break;
79
80 case WM_ADJUSTWINDOWPOS:
81 PostMsg(hwnd, UM_SETDIR, MPVOID, MPVOID);
82 break;
83
84 case UM_SETDIR:
85 PaintRecessedWindow(WinWindowFromID(hwnd, ARCH_HELP), (HPS) 0, FALSE,
86 TRUE);
87 return 0;
88
89 case WM_CONTROL:
90 arcdata = (DIRCNRDATA *) WinQueryWindowPtr(hwnd, QWL_USER);
91 switch (SHORT1FROMMP(mp1)) {
92 case ARCH_ARCNAME:
93 if (SHORT2FROMMP(mp1) == EN_KILLFOCUS)
94 WinSetDlgItemText(hwnd, ARCH_HELP,
95 GetPString(IDS_ARCDEFAULTHELPTEXT));
96 if (SHORT2FROMMP(mp1) == EN_SETFOCUS)
97 WinSetDlgItemText(hwnd, ARCH_HELP,
98 GetPString(IDS_ARCARCNAMEHELPTEXT));
99 break;
100
101 case ARCH_COMMAND:
102 if (SHORT2FROMMP(mp1) == EN_KILLFOCUS)
103 WinSetDlgItemText(hwnd, ARCH_HELP,
104 GetPString(IDS_ARCDEFAULTHELPTEXT));
105 if (SHORT2FROMMP(mp1) == EN_SETFOCUS)
106 WinSetDlgItemText(hwnd, ARCH_HELP, GetPString(IDS_ARCCMDHELPTEXT));
107 break;
108
109 case ARCH_MASKS:
110 if (SHORT2FROMMP(mp1) == EN_KILLFOCUS)
111 WinSetDlgItemText(hwnd, ARCH_HELP,
112 GetPString(IDS_ARCDEFAULTHELPTEXT));
113 if (SHORT2FROMMP(mp1) == EN_SETFOCUS)
114 WinSetDlgItemText(hwnd, ARCH_HELP, GetPString(IDS_ARCMASKHELPTEXT));
115
116 break;
117
118 case ARCH_INCLPATH:
119 case ARCH_RECURSE:
120 case ARCH_MOVE:
121 {
122 BOOL fRecurse = FALSE, fMove = FALSE, fInclDirs = FALSE;
123 CHAR *cmd;
124
125 if ((BOOL) WinSendDlgItemMsg(hwnd, ARCH_RECURSE, BM_QUERYCHECK,
126 MPVOID, MPVOID)) {
127 fRecurse = TRUE;
128 if (SHORT1FROMMP(mp1) == ARCH_RECURSE) {
129 if (arcdata->info->createrecurse && *arcdata->info->createrecurse) {
130 fMove = FALSE;
131 fInclDirs = FALSE;
132 WinSendDlgItemMsg(hwnd, ARCH_INCLPATH, BM_SETCHECK,
133 MPVOID, MPVOID);
134 WinSendDlgItemMsg(hwnd, ARCH_MOVE, BM_SETCHECK, MPVOID, MPVOID);
135 }
136 else {
137 fRecurse = FALSE;
138 WinSendDlgItemMsg(hwnd, ARCH_RECURSE, BM_SETCHECK,
139 MPVOID, MPVOID);
140 }
141 }
142 }
143 else
144 fRecurse = FALSE;
145 if ((BOOL) WinSendDlgItemMsg(hwnd, ARCH_MOVE, BM_QUERYCHECK,
146 MPVOID, MPVOID)) {
147 fMove = TRUE;
148 fRecurse = FALSE;
149 WinSendDlgItemMsg(hwnd, ARCH_RECURSE, BM_SETCHECK, MPVOID, MPVOID);
150 }
151 else
152 fMove = FALSE;
153 if ((BOOL) WinSendDlgItemMsg(hwnd, ARCH_INCLPATH, BM_QUERYCHECK,
154 MPVOID, MPVOID)) {
155 fInclDirs = TRUE;
156 fRecurse = FALSE;
157 WinSendDlgItemMsg(hwnd, ARCH_RECURSE, BM_SETCHECK, MPVOID, MPVOID);
158 }
159 else
160 fInclDirs = FALSE;
161 cmd = NULL;
162 if (fMove) {
163 if (fInclDirs || fRecurse)
164 cmd = arcdata->info->movewdirs;
165 else
166 cmd = arcdata->info->move;
167 if (!cmd || !*cmd)
168 cmd = arcdata->info->move;
169 }
170 if (!cmd || !*cmd) {
171 if (fInclDirs) {
172 cmd = arcdata->info->createwdirs;
173 if (!cmd || !*cmd)
174 cmd = arcdata->info->createrecurse;
175 }
176 else if (fRecurse) {
177 cmd = arcdata->info->createrecurse;
178 if (!cmd || !*cmd)
179 cmd = arcdata->info->createwdirs;
180 }
181 if (!cmd || !*cmd)
182 cmd = arcdata->info->create;
183 }
184 if (cmd)
185 WinSetDlgItemText(hwnd, ARCH_COMMAND, cmd);
186 }
187 break;
188 }
189 return 0;
190
191 case WM_COMMAND:
192 arcdata = (DIRCNRDATA *) WinQueryWindowPtr(hwnd, QWL_USER);
193 if (!arcdata) {
194 Runtime_Error(pszSrcFile, __LINE__, NULL);
195 return 0;
196 }
197 switch (SHORT1FROMMP(mp1)) {
198 case DID_CANCEL:
199 WinDismissDlg(hwnd, 0);
200 break;
201 case DID_OK:
202 {
203 CHAR s[CCHMAXPATH + 1];
204
205 *s = 0;
206 WinQueryDlgItemText(hwnd, ARCH_ARCNAME, CCHMAXPATH, s);
207 bstrip(s);
208 if (*s) {
209 if (DosQueryPathInfo(s,
210 FIL_QUERYFULLNAME,
211 arcdata->arcname, CCHMAXPATH))
212 strcpy(arcdata->arcname, s);
213 *s = 0;
214 WinQueryDlgItemText(hwnd, ARCH_COMMAND, 256, s);
215 if (*s) {
216 strcpy(arcdata->command, s);
217 *s = 0;
218 WinQueryDlgItemText(hwnd, ARCH_MASKS, 256, s);
219 *arcdata->mask.szMask = 0;
220 strcpy(arcdata->mask.szMask, s);
221 WinDismissDlg(hwnd, 1);
222 break;
223 }
224 }
225 }
226 if (!fAlertBeepOff)
227 DosBeep(50, 100);
228 break;
229
230 case IDM_HELP:
231 if (hwndHelp)
232 WinSendMsg(hwndHelp,
233 HM_DISPLAY_HELP,
234 MPFROM2SHORT(HELP_ARCHIVE, 0), MPFROMSHORT(HM_RESOURCEID));
235 break;
236
237 case ARCH_FIND:
238 if (arcdata->namecanchange) {
239
240 CHAR arcname[CCHMAXPATH], s[CCHMAXPATH], *p;
241
242 *s = 0;
243 WinQueryDlgItemText(hwnd, ARCH_ARCNAME, CCHMAXPATH, s);
244 bstrip(s);
245 if (DosQueryPathInfo(s, FIL_QUERYFULLNAME, arcname, CCHMAXPATH))
246 strcpy(arcname, s);
247 p = strrchr(arcname, '\\');
248 if (p) {
249 p++;
250 p = strrchr(arcname, '.');
251 }
252 if (!p && arcdata->info->ext && *arcdata->info->ext) {
253 strcat(arcname, "*.");
254 strcat(arcname, arcdata->info->ext);
255 }
256 if (export_filename(hwnd, arcname, FALSE))
257 WinSetDlgItemText(hwnd, ARCH_ARCNAME, arcname);
258 }
259 break;
260
261 case ARCH_SEE:
262 {
263 CHAR s[1001], *p;
264
265 *s = 0;
266 WinQueryDlgItemText(hwnd, ARCH_COMMAND, 256, s);
267 bstrip(s);
268 if (*s) {
269 p = strchr(s, ' ');
270 if (p)
271 *p = 0;
272 ExecOnList(hwnd, s, WINDOWED | SEPARATEKEEP | MAXIMIZED | PROMPT,
273 NULL, NULL, GetPString(IDS_ARCEXECHELPTEXT),
274 pszSrcFile, __LINE__);
275 }
276 else if (!fErrorBeepOff)
277 DosBeep(50, 100);
278 }
279 break;
280 }
281 return 0;
282
283 case WM_CLOSE:
284 break;
285 }
286 return WinDefDlgProc(hwnd, msg, mp1, mp2);
287}
288
289#pragma alloc_text(FMARCHIVE,ArchiveDlgProc)
Note: See TracBrowser for help on using the repository browser.