1 |
|
---|
2 | /***********************************************************************
|
---|
3 |
|
---|
4 | $Id: avv.c 1039 2008-07-05 22:16:21Z gyoung $
|
---|
5 |
|
---|
6 | archiver.bb2 editor
|
---|
7 |
|
---|
8 | Copyright (c) 1993-98 M. Kimes
|
---|
9 | Copyright (c) 2004, 2007 Steven H.Levine
|
---|
10 |
|
---|
11 | 31 Jul 04 SHL ArcReviewDlgProc: correct nameis... decodes
|
---|
12 | 01 Aug 04 SHL Localize functions
|
---|
13 | 01 Aug 04 SHL Rework fixup usage
|
---|
14 | 06 Jun 05 SHL Drop unused
|
---|
15 | 14 Aug 05 SHL rewrite_archiverbb2: avoid dereferencing null signature
|
---|
16 | 14 Aug 05 SHL ArcReviewDlgProc: ensure signature allocated
|
---|
17 | 29 May 06 SHL EditArchiverDefinition: rework
|
---|
18 | 26 Jun 06 SHL rewrite_archiverbb2: include user comments
|
---|
19 | 14 Jul 06 SHL Use Runtime_Error
|
---|
20 | 29 Jul 06 SHL Use xfgets
|
---|
21 | 30 Jul 06 SHL Avoid warnings when editing new definition
|
---|
22 | 22 Mar 07 GKY Use QWL_USER
|
---|
23 | 16 Jun 07 SHL Update for OpenWatcom
|
---|
24 | 20 Aug 07 GKY Move #pragma alloc_text to end for OpenWatcom compat
|
---|
25 | 06 Jan 08 GKY Use NormalizeCmdLine to check program strings on entry
|
---|
26 | 29 Feb 08 GKY Changes to enable user settable command line length
|
---|
27 |
|
---|
28 | ***********************************************************************/
|
---|
29 |
|
---|
30 | #include <stdlib.h>
|
---|
31 | #include <string.h>
|
---|
32 |
|
---|
33 | #define INCL_DOS
|
---|
34 | #define INCL_WIN
|
---|
35 | #define INCL_LONGLONG // dircnrs.h
|
---|
36 |
|
---|
37 | #include "fm3dlg.h"
|
---|
38 | #include "version.h"
|
---|
39 | #include "fm3str.h"
|
---|
40 | #include "strutil.h" // GetPString
|
---|
41 | #include "errutil.h" // Runtime_Error
|
---|
42 | #include "fm3dll.h"
|
---|
43 | #include "pathutil.h" // NormalizeCmdLine
|
---|
44 | #include "fortify.h"
|
---|
45 |
|
---|
46 | #pragma data_seg(DATA1)
|
---|
47 |
|
---|
48 | static PSZ pszSrcFile = __FILE__;
|
---|
49 |
|
---|
50 | static PSZ checkfile(PSZ file, INT * error);
|
---|
51 | static BOOL check_archiver(HWND hwnd, ARC_TYPE * info);
|
---|
52 | static INT get_int_from_window(HWND hwnd, USHORT id);
|
---|
53 | static LONG get_long_from_window(HWND hwnd, USHORT id);
|
---|
54 | static PSZ nonull(PSZ a);
|
---|
55 | static PSZ free_and_strdup_from_window(HWND hwnd, USHORT id, PSZ pszDest);
|
---|
56 | static PSZ free_and_strdup_quoted_from_window(HWND hwnd, USHORT id, PSZ pszDest);
|
---|
57 |
|
---|
58 | //=== EditArchiverDefinition() Select archiver to edit definition ===
|
---|
59 |
|
---|
60 | VOID EditArchiverDefinition(HWND hwnd)
|
---|
61 | {
|
---|
62 | ARCDUMP ad;
|
---|
63 | ARC_TYPE *pat;
|
---|
64 |
|
---|
65 | // Allow multiple edits
|
---|
66 | for (;;) {
|
---|
67 | pat = NULL; // Do not hide dups
|
---|
68 | if (!WinDlgBox(HWND_DESKTOP,
|
---|
69 | hwnd,
|
---|
70 | SBoxDlgProc,
|
---|
71 | FM3ModHandle, ASEL_EDIT_FRAME, (PVOID) & pat) || !pat) {
|
---|
72 | break; // we are done
|
---|
73 | }
|
---|
74 |
|
---|
75 | memset(&ad, 0, sizeof(ARCDUMP));
|
---|
76 | ad.info = pat;
|
---|
77 | WinDlgBox(HWND_DESKTOP,
|
---|
78 | hwnd, ArcReviewDlgProc, FM3ModHandle, AD_FRAME, MPFROMP(&ad));
|
---|
79 | } // for
|
---|
80 | }
|
---|
81 |
|
---|
82 | static PSZ free_and_strdup_from_window(HWND hwnd, USHORT id, PSZ pszDest)
|
---|
83 | {
|
---|
84 | CHAR sz[256];
|
---|
85 |
|
---|
86 | xfree(pszDest, pszSrcFile, __LINE__);
|
---|
87 | WinQueryDlgItemText(hwnd, id, sizeof(sz), sz);
|
---|
88 | if (*sz)
|
---|
89 | pszDest = xstrdup(sz, pszSrcFile, __LINE__);
|
---|
90 | else
|
---|
91 | pszDest = NULL;
|
---|
92 | return pszDest;
|
---|
93 | }
|
---|
94 |
|
---|
95 | static PSZ free_and_strdup_quoted_from_window(HWND hwnd, USHORT id, PSZ pszDest)
|
---|
96 | { // fixme for command line limit
|
---|
97 | CHAR *szCmdLine;
|
---|
98 | PSZ pszWorkBuf;
|
---|
99 |
|
---|
100 | szCmdLine = xmalloc(MaxComLineStrg, pszSrcFile, __LINE__);
|
---|
101 | if (szCmdLine) {
|
---|
102 | xfree(pszDest, pszSrcFile, __LINE__);
|
---|
103 | WinQueryDlgItemText(hwnd, id, sizeof(szCmdLine), szCmdLine);
|
---|
104 | pszWorkBuf = xmalloc(MaxComLineStrg, pszSrcFile, __LINE__);
|
---|
105 | if (pszWorkBuf) {
|
---|
106 | NormalizeCmdLine(pszWorkBuf, szCmdLine);
|
---|
107 | pszDest = xstrdup(pszWorkBuf, pszSrcFile, __LINE__);
|
---|
108 | free(pszWorkBuf);
|
---|
109 | }
|
---|
110 | else
|
---|
111 | pszDest = xstrdup(szCmdLine, pszSrcFile, __LINE__); // return the unexamined input on failure
|
---|
112 | free(szCmdLine);
|
---|
113 | }
|
---|
114 | else
|
---|
115 | pszDest = NULL;
|
---|
116 | return pszDest;
|
---|
117 | }
|
---|
118 |
|
---|
119 | static INT get_int_from_window(HWND hwnd, USHORT id)
|
---|
120 | {
|
---|
121 | CHAR s[256];
|
---|
122 |
|
---|
123 | WinQueryDlgItemText(hwnd, id, sizeof(s), s);
|
---|
124 | return atoi(s);
|
---|
125 | }
|
---|
126 |
|
---|
127 | static INT get_int2_from_window(HWND hwnd, USHORT id)
|
---|
128 | {
|
---|
129 | CHAR s[256];
|
---|
130 | PSZ p;
|
---|
131 |
|
---|
132 | WinQueryDlgItemText(hwnd, id, sizeof(s), s);
|
---|
133 | p = strchr(s, ',');
|
---|
134 | if (p)
|
---|
135 | p++;
|
---|
136 | return p ? atoi(p) : 0;
|
---|
137 | }
|
---|
138 |
|
---|
139 | INT get_int3_from_window(HWND hwnd, USHORT id)
|
---|
140 | {
|
---|
141 | CHAR s[256];
|
---|
142 | PSZ p;
|
---|
143 |
|
---|
144 | WinQueryDlgItemText(hwnd, id, sizeof(s), s);
|
---|
145 | p = strchr(s, ',');
|
---|
146 | if (p) {
|
---|
147 | p++;
|
---|
148 | p = strchr(p, ',');
|
---|
149 | if (p)
|
---|
150 | p++;
|
---|
151 | }
|
---|
152 | return p ? atoi(p) : 0;
|
---|
153 | }
|
---|
154 |
|
---|
155 | INT get_int4_from_window(HWND hwnd, USHORT id)
|
---|
156 | {
|
---|
157 | CHAR s[256];
|
---|
158 | PSZ p;
|
---|
159 |
|
---|
160 | WinQueryDlgItemText(hwnd, id, sizeof(s), s);
|
---|
161 | p = strchr(s, ',');
|
---|
162 | if (p) {
|
---|
163 | p++;
|
---|
164 | p = strchr(p, ',');
|
---|
165 | if (p) {
|
---|
166 | p++;
|
---|
167 | p = strchr(p, ',');
|
---|
168 | if (p)
|
---|
169 | p++;
|
---|
170 | }
|
---|
171 | }
|
---|
172 | return p ? atoi(p) : 0;
|
---|
173 | }
|
---|
174 |
|
---|
175 | LONG get_long_from_window(HWND hwnd, USHORT id)
|
---|
176 | {
|
---|
177 | CHAR s[256];
|
---|
178 |
|
---|
179 | WinQueryDlgItemText(hwnd, id, sizeof(s), s);
|
---|
180 | return atol(s);
|
---|
181 | }
|
---|
182 |
|
---|
183 | #pragma alloc_text (AVV2,nonull,rewrite_archiverbb2,checkfile)
|
---|
184 |
|
---|
185 | // nonull - convert NULL pointer to empty string
|
---|
186 |
|
---|
187 | static PSZ nonull(PSZ psz)
|
---|
188 | {
|
---|
189 | if (!psz)
|
---|
190 | psz = NullStr;
|
---|
191 | return psz;
|
---|
192 | }
|
---|
193 |
|
---|
194 | //=== rewrite_archiverbb2() rewrite archiver.bb2, prompt if arg NULL, merge comments ===
|
---|
195 |
|
---|
196 | VOID rewrite_archiverbb2(PSZ archiverbb2)
|
---|
197 | {
|
---|
198 | FILE *fpNew;
|
---|
199 | FILE *fpOld = NULL;
|
---|
200 | UINT entry_num = 0; // Definition counter
|
---|
201 | UINT input_line_num = 0; // Input file line counter
|
---|
202 | ARC_TYPE *pat;
|
---|
203 | CHAR sz[258];
|
---|
204 | CHAR *psz;
|
---|
205 | BOOL needEntryNumber;
|
---|
206 | BOOL needReload = FALSE; // Because line numbers changed
|
---|
207 | time_t t;
|
---|
208 | struct tm *tm;
|
---|
209 | CHAR ch;
|
---|
210 |
|
---|
211 | arcsigsmodified = FALSE;
|
---|
212 |
|
---|
213 | if (!arcsighead) {
|
---|
214 | saymsg(MB_CANCEL | MB_ICONEXCLAMATION,
|
---|
215 | HWND_DESKTOP,
|
---|
216 | GetPString(IDS_SAYWHATTEXT), GetPString(IDS_NOINFOTOSAVETEXT));
|
---|
217 | return;
|
---|
218 | }
|
---|
219 | // Alert unless file name passed
|
---|
220 | if (!archiverbb2 || !*archiverbb2) {
|
---|
221 | saymsg(MB_ENTER | MB_ICONASTERISK,
|
---|
222 | HWND_DESKTOP,
|
---|
223 | GetPString(IDS_NOTETEXT), GetPString(IDS_SAVEARCBB2TEXT));
|
---|
224 | archiverbb2 = GetPString(IDS_ARCHIVERBB2);
|
---|
225 | }
|
---|
226 |
|
---|
227 | /* save a backup */
|
---|
228 | psz = strrchr(archiverbb2, '.');
|
---|
229 | if (psz && !stricmp(psz, ".BB2")) {
|
---|
230 | strcpy(psz, ".BAK");
|
---|
231 | DosDelete(archiverbb2);
|
---|
232 | strcpy(sz, archiverbb2);
|
---|
233 | strcpy(psz, ".BB2");
|
---|
234 | DosMove(archiverbb2, sz);
|
---|
235 | fpOld = fopen(sz, "r"); // OK for file not to exist
|
---|
236 | }
|
---|
237 |
|
---|
238 | fpNew = fopen(archiverbb2, "w");
|
---|
239 |
|
---|
240 | if (fpNew) {
|
---|
241 |
|
---|
242 | fprintf(fpNew, "%u\n", LINES_PER_ARCSIG);
|
---|
243 | t = time(NULL);
|
---|
244 | tm = localtime(&t);
|
---|
245 |
|
---|
246 | fprintf(fpNew,
|
---|
247 | ";\n; %s file written by FM/2 v%d.%02d on %u/%u/%u %u:%02u:%02u\n;\n",
|
---|
248 | GetPString(IDS_ARCHIVERBB2),
|
---|
249 | VERMAJOR, VERMINOR,
|
---|
250 | tm->tm_mon + 1, tm->tm_mday, tm->tm_year + 1900,
|
---|
251 | tm->tm_hour, tm->tm_min, tm->tm_sec);
|
---|
252 | // Rewrite header if known
|
---|
253 | if (fpOld && arcsigs_header_lines) {
|
---|
254 | needReload = TRUE;
|
---|
255 | while (input_line_num < arcsigs_header_lines) {
|
---|
256 | psz = xfgets(sz, sizeof(sz), fpOld, pszSrcFile, __LINE__);
|
---|
257 | if (!psz)
|
---|
258 | break;
|
---|
259 | input_line_num++;
|
---|
260 | if (input_line_num == 1)
|
---|
261 | continue; // Bypass sig count
|
---|
262 | fputs(sz, fpNew);
|
---|
263 | }
|
---|
264 | }
|
---|
265 | else {
|
---|
266 | // Write default header
|
---|
267 | fputs(GetPString(IDS_ARCHIVERBB2TEXT), fpNew);
|
---|
268 | }
|
---|
269 | pat = arcsighead;
|
---|
270 | while (pat) {
|
---|
271 | needEntryNumber = TRUE;
|
---|
272 | // Rewrite per sig header comments if any exist
|
---|
273 | if (fpOld && pat->comment_line_num) {
|
---|
274 | needReload = TRUE; // fixme to optimize
|
---|
275 | // Definitions reordered - need to rewind
|
---|
276 | if (input_line_num > pat->comment_line_num) {
|
---|
277 | fseek(fpOld, 0, SEEK_SET);
|
---|
278 | input_line_num = 0;
|
---|
279 | }
|
---|
280 | while (input_line_num + 1 < pat->defn_line_num) {
|
---|
281 | psz = xfgets(sz, sizeof(sz), fpOld, pszSrcFile, __LINE__);
|
---|
282 | if (!psz)
|
---|
283 | break; // Unexpected EOF
|
---|
284 | input_line_num++;
|
---|
285 | if (input_line_num < pat->comment_line_num)
|
---|
286 | continue;
|
---|
287 | if (needEntryNumber && strnicmp(sz, "; Entry #", 9) == 0) {
|
---|
288 | // Rewrite entry count comment
|
---|
289 | needEntryNumber = FALSE;
|
---|
290 | for (psz = sz + 9; *psz == ' '; psz++) ; // Find non-blank
|
---|
291 | for (; (ch = *psz) >= '0' && ch <= '9'; psz++) ; // Find end of entry#
|
---|
292 | fprintf(fpNew, GetPString(IDS_ENTRYCNTRTEXT), ++entry_num);
|
---|
293 | fputs(psz, fpNew);
|
---|
294 | }
|
---|
295 | else {
|
---|
296 | fputs(sz, fpNew);
|
---|
297 | }
|
---|
298 | }
|
---|
299 | }
|
---|
300 |
|
---|
301 | if (needEntryNumber) {
|
---|
302 | fputs(";\n", fpNew);
|
---|
303 | fprintf(fpNew, GetPString(IDS_ENTRYCNTRTEXT), ++entry_num);
|
---|
304 | if (pat->id)
|
---|
305 | fprintf(fpNew, " (%s)", pat->id);
|
---|
306 | fputs("\n;\n", fpNew);
|
---|
307 | }
|
---|
308 |
|
---|
309 | fprintf(fpNew,
|
---|
310 | "%s\n%s\n%ld\n%s\n",
|
---|
311 | nonull(pat->id),
|
---|
312 | nonull(pat->ext), pat->file_offset, nonull(pat->list));
|
---|
313 | fprintf(fpNew,
|
---|
314 | "%s\n%s\n%s\n%s\n%s\n%s\n",
|
---|
315 | nonull(pat->extract),
|
---|
316 | nonull(pat->exwdirs),
|
---|
317 | nonull(pat->test),
|
---|
318 | nonull(pat->create),
|
---|
319 | nonull(pat->createwdirs), nonull(pat->createrecurse));
|
---|
320 | fprintf(fpNew,
|
---|
321 | "%s\n%s\n%s\n",
|
---|
322 | nonull(pat->move), nonull(pat->movewdirs), nonull(pat->delete));
|
---|
323 | fprintf(fpNew,
|
---|
324 | "%s\n%s\n%s\n%d\n%d\n%d,%d\n%d\n%d,%lu,%lu,%lu\n",
|
---|
325 | fixup(pat->signature,
|
---|
326 | sz,
|
---|
327 | sizeof(sz),
|
---|
328 | pat->siglen),
|
---|
329 | nonull(pat->startlist),
|
---|
330 | nonull(pat->endlist),
|
---|
331 | pat->osizepos,
|
---|
332 | pat->nsizepos,
|
---|
333 | pat->fdpos,
|
---|
334 | pat->datetype,
|
---|
335 | pat->fdflds,
|
---|
336 | pat->fnpos, pat->nameislast, pat->nameisnext, pat->nameisfirst);
|
---|
337 | pat = pat->next;
|
---|
338 | } // while more sigs
|
---|
339 |
|
---|
340 | // Rewrite trailer comments if known
|
---|
341 | if (fpOld && arcsigs_trailer_line_num) {
|
---|
342 | for (;;) {
|
---|
343 | psz = xfgets(sz, sizeof(sz), fpOld, pszSrcFile, __LINE__);
|
---|
344 | if (!psz)
|
---|
345 | break;
|
---|
346 | input_line_num++;
|
---|
347 | if (input_line_num < arcsigs_trailer_line_num)
|
---|
348 | continue; // Bypass sig count
|
---|
349 | fputs(sz, fpNew);
|
---|
350 | }
|
---|
351 | }
|
---|
352 |
|
---|
353 | fclose(fpNew);
|
---|
354 |
|
---|
355 | } // if fpNew open OK
|
---|
356 |
|
---|
357 | if (fpOld)
|
---|
358 | fclose(fpOld);
|
---|
359 |
|
---|
360 | if (needReload)
|
---|
361 | load_archivers(); // Resync commend line numbers
|
---|
362 | }
|
---|
363 |
|
---|
364 | static PSZ checkfile(PSZ file, INT * error)
|
---|
365 | {
|
---|
366 | CHAR *p, *pp = NULL;
|
---|
367 | INT ret;
|
---|
368 | ULONG apptype;
|
---|
369 |
|
---|
370 | if (!file || !*file) {
|
---|
371 | *error = 3;
|
---|
372 | return NULL;
|
---|
373 | }
|
---|
374 | pp = strchr(file, ' ');
|
---|
375 | if (pp)
|
---|
376 | *pp = 0;
|
---|
377 | p = searchpath(file);
|
---|
378 | if (!p || !*p)
|
---|
379 | *error = 1;
|
---|
380 | else {
|
---|
381 | ret = (INT) DosQueryAppType(p, &apptype);
|
---|
382 | if (ret)
|
---|
383 | *error = -1;
|
---|
384 | else {
|
---|
385 | apptype &= (~FAPPTYP_32BIT);
|
---|
386 | if (!apptype ||
|
---|
387 | (apptype == FAPPTYP_NOTWINDOWCOMPAT) ||
|
---|
388 | (apptype == FAPPTYP_WINDOWCOMPAT) ||
|
---|
389 | (apptype & FAPPTYP_BOUND) ||
|
---|
390 | (apptype & FAPPTYP_WINDOWAPI) || (apptype & FAPPTYP_DOS)) {
|
---|
391 | *error = 0;
|
---|
392 | }
|
---|
393 | else
|
---|
394 | *error = 2;
|
---|
395 | }
|
---|
396 | }
|
---|
397 | if (pp)
|
---|
398 | *pp = ' ';
|
---|
399 | return p;
|
---|
400 | }
|
---|
401 |
|
---|
402 | #pragma alloc_text (AVV3,check_archiver,ArcReviewDlgProc)
|
---|
403 |
|
---|
404 | static BOOL check_archiver(HWND hwnd, ARC_TYPE * info)
|
---|
405 | {
|
---|
406 | BOOL noStart = FALSE, noEnd = FALSE, badPos = FALSE;
|
---|
407 | INT badList = 0, badCreate = 0, badExtract = 0;
|
---|
408 | static PSZ aerrors[3];
|
---|
409 |
|
---|
410 | aerrors[0] = GetPString(IDS_STARTLISTEMPTYTEXT);
|
---|
411 | aerrors[1] = GetPString(IDS_ENDLISTEMPTYTEXT);
|
---|
412 | aerrors[2] = GetPString(IDS_BOGUSNAMETEXT);
|
---|
413 | if (!info->startlist || !*info->startlist)
|
---|
414 | noStart = TRUE;
|
---|
415 | if (!info->endlist || !*info->endlist)
|
---|
416 | noEnd = TRUE;
|
---|
417 | if (info->fnpos > 50 || info->fnpos < -1)
|
---|
418 | badPos = TRUE;
|
---|
419 | checkfile(info->list, &badList);
|
---|
420 | checkfile(info->create, &badCreate);
|
---|
421 | checkfile(info->extract, &badExtract);
|
---|
422 | if (!noStart && !noEnd && !badPos && !badList && !badCreate && !badExtract)
|
---|
423 | return TRUE; // OK
|
---|
424 | if (!info->id)
|
---|
425 | return FALSE; // Assume new if no id
|
---|
426 | saymsg(MB_ENTER | MB_ICONASTERISK,
|
---|
427 | hwnd,
|
---|
428 | GetPString(IDS_WARNINGSTEXT),
|
---|
429 | GetPString(IDS_AVVCHK1TEXT),
|
---|
430 | noStart ? aerrors[0] : NullStr,
|
---|
431 | noEnd ? aerrors[1] : NullStr,
|
---|
432 | badPos ? aerrors[2] : NullStr,
|
---|
433 | badList == 1 ?
|
---|
434 | GetPString(IDS_AVVCHK2TEXT) :
|
---|
435 | badList == -1 ?
|
---|
436 | GetPString(IDS_AVVCHK3TEXT) :
|
---|
437 | badList == 2 ?
|
---|
438 | GetPString(IDS_AVVCHK4TEXT) :
|
---|
439 | badList == 3 ?
|
---|
440 | GetPString(IDS_AVVCHK5TEXT) :
|
---|
441 | NullStr,
|
---|
442 | badCreate == 1 ?
|
---|
443 | GetPString(IDS_AVVCHK6TEXT) :
|
---|
444 | badCreate == -1 ?
|
---|
445 | GetPString(IDS_AVVCHK7TEXT) :
|
---|
446 | badCreate == 2 ?
|
---|
447 | GetPString(IDS_AVVCHK8TEXT) :
|
---|
448 | badCreate == 3 ?
|
---|
449 | GetPString(IDS_AVVCHK9TEXT) :
|
---|
450 | NullStr,
|
---|
451 | badExtract == 1 ?
|
---|
452 | GetPString(IDS_AVVCHK10TEXT) :
|
---|
453 | badExtract == -1 ?
|
---|
454 | GetPString(IDS_AVVCHK11TEXT) :
|
---|
455 | badExtract == 2 ?
|
---|
456 | GetPString(IDS_AVVCHK12TEXT) :
|
---|
457 | badExtract == 3 ? GetPString(IDS_AVVCHK13TEXT) : NullStr);
|
---|
458 | if (badList || badExtract)
|
---|
459 | return FALSE; // Problems
|
---|
460 | return TRUE; // OK
|
---|
461 | }
|
---|
462 |
|
---|
463 | //=== ArcReviewDlgProc() View/edit single archiver.bb2 setup ===
|
---|
464 |
|
---|
465 | MRESULT EXPENTRY ArcReviewDlgProc(HWND hwnd, ULONG msg, MPARAM mp1,
|
---|
466 | MPARAM mp2)
|
---|
467 | {
|
---|
468 | ARCDUMP *admp;
|
---|
469 | CHAR s[256];
|
---|
470 | SHORT sSelect;
|
---|
471 |
|
---|
472 | if (msg != WM_INITDLG)
|
---|
473 | admp = (ARCDUMP *) WinQueryWindowPtr(hwnd, QWL_USER);
|
---|
474 |
|
---|
475 | switch (msg) {
|
---|
476 | case WM_INITDLG:
|
---|
477 | admp = (ARCDUMP *) mp2;
|
---|
478 | if (!admp || !admp->info) {
|
---|
479 | WinDismissDlg(hwnd, 0);
|
---|
480 | return 0;
|
---|
481 | }
|
---|
482 |
|
---|
483 | WinSetWindowPtr(hwnd, QWL_USER, mp2);
|
---|
484 |
|
---|
485 | WinSendDlgItemMsg(hwnd, AD_LISTBOX, LM_DELETEALL, MPVOID, MPVOID);
|
---|
486 | for (sSelect = AD_ID; sSelect < AD_ADDWPATHS + 1; sSelect++) {
|
---|
487 | WinSendDlgItemMsg(hwnd,
|
---|
488 | sSelect,
|
---|
489 | EM_SETTEXTLIMIT,
|
---|
490 | MPFROM2SHORT(sizeof(s) - 1, 0), MPVOID);
|
---|
491 | }
|
---|
492 | if (admp->info->id)
|
---|
493 | WinSetDlgItemText(hwnd, AD_ID, admp->info->id);
|
---|
494 | if (admp->info->ext)
|
---|
495 | WinSetDlgItemText(hwnd, AD_EXT, admp->info->ext);
|
---|
496 | sprintf(s, "%ld", admp->info->file_offset);
|
---|
497 | WinSetDlgItemText(hwnd, AD_SIGPOS, s);
|
---|
498 | if (admp->info->siglen) {
|
---|
499 | WinSetDlgItemText(hwnd,
|
---|
500 | AD_SIG,
|
---|
501 | fixup(admp->info->signature,
|
---|
502 | s, sizeof(s), admp->info->siglen));
|
---|
503 | }
|
---|
504 | if (admp->info->startlist)
|
---|
505 | WinSetDlgItemText(hwnd, AD_STARTLIST, admp->info->startlist);
|
---|
506 | if (admp->info->endlist)
|
---|
507 | WinSetDlgItemText(hwnd, AD_ENDLIST, admp->info->endlist);
|
---|
508 | if (admp->info->list)
|
---|
509 | WinSetDlgItemText(hwnd, AD_LIST, admp->info->list);
|
---|
510 | sprintf(s,
|
---|
511 | "%d,%d,%d,%d",
|
---|
512 | admp->info->fnpos,
|
---|
513 | admp->info->nameislast,
|
---|
514 | admp->info->nameisnext, admp->info->nameisfirst);
|
---|
515 | WinSetDlgItemText(hwnd, AD_FNAMEPOS, s);
|
---|
516 | sprintf(s, "%d", admp->info->osizepos);
|
---|
517 | WinSetDlgItemText(hwnd, AD_OLDSZ, s);
|
---|
518 | sprintf(s, "%d", admp->info->nsizepos);
|
---|
519 | WinSetDlgItemText(hwnd, AD_NEWSZ, s);
|
---|
520 | sprintf(s, "%d,%d", admp->info->fdpos, admp->info->datetype);
|
---|
521 | WinSetDlgItemText(hwnd, AD_DATEPOS, s);
|
---|
522 | sprintf(s, "%d", admp->info->fdflds);
|
---|
523 | WinSetDlgItemText(hwnd, AD_NUMDATEFLDS, s);
|
---|
524 | if (admp->info->extract)
|
---|
525 | WinSetDlgItemText(hwnd, AD_EXTRACT, admp->info->extract);
|
---|
526 | if (admp->info->exwdirs)
|
---|
527 | WinSetDlgItemText(hwnd, AD_WDIRS, admp->info->exwdirs);
|
---|
528 | if (admp->info->test)
|
---|
529 | WinSetDlgItemText(hwnd, AD_TEST, admp->info->test);
|
---|
530 | if (admp->info->create)
|
---|
531 | WinSetDlgItemText(hwnd, AD_ADD, admp->info->create);
|
---|
532 | if (admp->info->move)
|
---|
533 | WinSetDlgItemText(hwnd, AD_MOVE, admp->info->move);
|
---|
534 | if (admp->info->delete)
|
---|
535 | WinSetDlgItemText(hwnd, AD_DELETE, admp->info->delete);
|
---|
536 | if (admp->info->createrecurse)
|
---|
537 | WinSetDlgItemText(hwnd, AD_ADDRECURSE, admp->info->createrecurse);
|
---|
538 | if (admp->info->createwdirs)
|
---|
539 | WinSetDlgItemText(hwnd, AD_ADDWPATHS, admp->info->createwdirs);
|
---|
540 | if (admp->info->movewdirs)
|
---|
541 | WinSetDlgItemText(hwnd, AD_MOVEWPATHS, admp->info->movewdirs);
|
---|
542 |
|
---|
543 | PostMsg(hwnd, UM_SETUP, MPVOID, MPVOID);
|
---|
544 | break; // WM_INITDLG
|
---|
545 |
|
---|
546 | case UM_SETUP:
|
---|
547 | if (admp->listname && *admp->listname) {
|
---|
548 |
|
---|
549 | FILE *fp = fopen(admp->listname, "r");
|
---|
550 |
|
---|
551 | if (!fp) {
|
---|
552 | WinSendDlgItemMsg(hwnd,
|
---|
553 | AD_LISTBOX,
|
---|
554 | LM_INSERTITEM,
|
---|
555 | MPFROM2SHORT(LIT_END, 0),
|
---|
556 | MPFROMP(GetPString(IDS_CANTOPENFILETEXT)));
|
---|
557 | }
|
---|
558 | else {
|
---|
559 | while (!feof(fp)) {
|
---|
560 | if (!xfgets(s, sizeof(s), fp, pszSrcFile, __LINE__))
|
---|
561 | break;
|
---|
562 | stripcr(s);
|
---|
563 | WinSendDlgItemMsg(hwnd,
|
---|
564 | AD_LISTBOX,
|
---|
565 | LM_INSERTITEM,
|
---|
566 | MPFROM2SHORT(LIT_END, 0), MPFROMP(s));
|
---|
567 | }
|
---|
568 | fclose(fp);
|
---|
569 | }
|
---|
570 | }
|
---|
571 | else {
|
---|
572 | WinSendDlgItemMsg(hwnd,
|
---|
573 | AD_LISTBOX,
|
---|
574 | LM_INSERTITEM,
|
---|
575 | MPFROM2SHORT(LIT_END, 0),
|
---|
576 | MPFROMP(GetPString(IDS_NOTAPPLICABLETEXT)));
|
---|
577 | }
|
---|
578 | check_archiver(hwnd, admp->info);
|
---|
579 | return 0;
|
---|
580 |
|
---|
581 | case WM_ADJUSTWINDOWPOS:
|
---|
582 | PostMsg(hwnd, UM_SETDIR, MPVOID, MPVOID);
|
---|
583 | break;
|
---|
584 |
|
---|
585 | case UM_SETDIR:
|
---|
586 | PaintRecessedWindow(WinWindowFromID(hwnd, AD_HELP), (HPS) 0, FALSE, TRUE);
|
---|
587 | return 0;
|
---|
588 |
|
---|
589 | case WM_CONTROL:
|
---|
590 | switch (SHORT1FROMMP(mp1)) {
|
---|
591 | case AD_LISTBOX:
|
---|
592 | switch (SHORT2FROMMP(mp1)) {
|
---|
593 | case LN_ENTER:
|
---|
594 | for (sSelect = 0; sSelect < 10; sSelect++)
|
---|
595 | WinSetDlgItemText(hwnd, AD_FLD1 + sSelect, NullStr);
|
---|
596 | if (!admp->listname)
|
---|
597 | Runtime_Error(pszSrcFile, __LINE__, "no listname");
|
---|
598 | else {
|
---|
599 | sSelect = (SHORT) WinSendDlgItemMsg(hwnd,
|
---|
600 | AD_LISTBOX,
|
---|
601 | LM_QUERYSELECTION,
|
---|
602 | MPVOID, MPVOID);
|
---|
603 | WinSendDlgItemMsg(hwnd,
|
---|
604 | AD_LISTBOX,
|
---|
605 | LM_QUERYITEMTEXT,
|
---|
606 | MPFROM2SHORT(sSelect, 255), MPFROMP(s));
|
---|
607 | if (!*s)
|
---|
608 | Runtime_Error(pszSrcFile, __LINE__, "no text");
|
---|
609 | else {
|
---|
610 | PSZ p;
|
---|
611 | PSZ pp;
|
---|
612 |
|
---|
613 | p = s;
|
---|
614 | for (sSelect = 0; sSelect < 10; sSelect++) {
|
---|
615 | pp = p;
|
---|
616 | while (*pp == ' ' || *pp == '\t')
|
---|
617 | pp++;
|
---|
618 | if (!*pp)
|
---|
619 | break;
|
---|
620 | p = pp;
|
---|
621 | while (*p && (*p != ' ' && *p != '\t'))
|
---|
622 | p++;
|
---|
623 | if (*p)
|
---|
624 | *p++ = 0;
|
---|
625 | WinSetDlgItemText(hwnd, AD_FLD1 + sSelect, pp);
|
---|
626 | }
|
---|
627 | }
|
---|
628 | }
|
---|
629 | break;
|
---|
630 |
|
---|
631 | case LN_KILLFOCUS:
|
---|
632 | WinSetDlgItemText(hwnd, AD_HELP, NullStr);
|
---|
633 | break;
|
---|
634 |
|
---|
635 | case LN_SETFOCUS:
|
---|
636 | WinSetDlgItemText(hwnd, AD_HELP, GetPString(IDS_TEXTARCPRODUCEDTEXT));
|
---|
637 | break;
|
---|
638 | }
|
---|
639 | break;
|
---|
640 |
|
---|
641 | case AD_ID:
|
---|
642 | if (SHORT2FROMMP(mp1) == EN_KILLFOCUS)
|
---|
643 | WinSetDlgItemText(hwnd, AD_HELP, NullStr);
|
---|
644 | if (SHORT2FROMMP(mp1) == EN_SETFOCUS)
|
---|
645 | WinSetDlgItemText(hwnd, AD_HELP, GetPString(IDS_ADIDTEXT));
|
---|
646 | break;
|
---|
647 |
|
---|
648 | case AD_ADD:
|
---|
649 | if (SHORT2FROMMP(mp1) == EN_KILLFOCUS)
|
---|
650 | WinSetDlgItemText(hwnd, AD_HELP, NullStr);
|
---|
651 | if (SHORT2FROMMP(mp1) == EN_SETFOCUS)
|
---|
652 | WinSetDlgItemText(hwnd, AD_HELP, GetPString(IDS_ADADDTEXT));
|
---|
653 | break;
|
---|
654 |
|
---|
655 | case AD_MOVE:
|
---|
656 | if (SHORT2FROMMP(mp1) == EN_KILLFOCUS)
|
---|
657 | WinSetDlgItemText(hwnd, AD_HELP, NullStr);
|
---|
658 | if (SHORT2FROMMP(mp1) == EN_SETFOCUS)
|
---|
659 | WinSetDlgItemText(hwnd, AD_HELP, GetPString(IDS_ADMOVETEXT));
|
---|
660 | break;
|
---|
661 |
|
---|
662 | case AD_EXT:
|
---|
663 | if (SHORT2FROMMP(mp1) == EN_KILLFOCUS)
|
---|
664 | WinSetDlgItemText(hwnd, AD_HELP, NullStr);
|
---|
665 | if (SHORT2FROMMP(mp1) == EN_SETFOCUS)
|
---|
666 | WinSetDlgItemText(hwnd, AD_HELP, GetPString(IDS_ADEXTTEXT));
|
---|
667 | break;
|
---|
668 |
|
---|
669 | case AD_EXTRACT:
|
---|
670 | if (SHORT2FROMMP(mp1) == EN_KILLFOCUS)
|
---|
671 | WinSetDlgItemText(hwnd, AD_HELP, NullStr);
|
---|
672 | if (SHORT2FROMMP(mp1) == EN_SETFOCUS)
|
---|
673 | WinSetDlgItemText(hwnd, AD_HELP, GetPString(IDS_ADEXTRACTTEXT));
|
---|
674 | break;
|
---|
675 |
|
---|
676 | case AD_WDIRS:
|
---|
677 | if (SHORT2FROMMP(mp1) == EN_KILLFOCUS)
|
---|
678 | WinSetDlgItemText(hwnd, AD_HELP, NullStr);
|
---|
679 | if (SHORT2FROMMP(mp1) == EN_SETFOCUS)
|
---|
680 | WinSetDlgItemText(hwnd, AD_HELP, GetPString(IDS_ADWDIRSTEXT));
|
---|
681 | break;
|
---|
682 |
|
---|
683 | case AD_SIG:
|
---|
684 | if (SHORT2FROMMP(mp1) == EN_KILLFOCUS)
|
---|
685 | WinSetDlgItemText(hwnd, AD_HELP, NullStr);
|
---|
686 | if (SHORT2FROMMP(mp1) == EN_SETFOCUS)
|
---|
687 | WinSetDlgItemText(hwnd, AD_HELP, GetPString(IDS_ADSIGTEXT));
|
---|
688 | break;
|
---|
689 |
|
---|
690 | case AD_LIST:
|
---|
691 | if (SHORT2FROMMP(mp1) == EN_KILLFOCUS)
|
---|
692 | WinSetDlgItemText(hwnd, AD_HELP, NullStr);
|
---|
693 | if (SHORT2FROMMP(mp1) == EN_SETFOCUS)
|
---|
694 | WinSetDlgItemText(hwnd, AD_HELP, GetPString(IDS_ADLISTTEXT));
|
---|
695 | break;
|
---|
696 |
|
---|
697 | case AD_TEST:
|
---|
698 | if (SHORT2FROMMP(mp1) == EN_KILLFOCUS)
|
---|
699 | WinSetDlgItemText(hwnd, AD_HELP, NullStr);
|
---|
700 | if (SHORT2FROMMP(mp1) == EN_SETFOCUS)
|
---|
701 | WinSetDlgItemText(hwnd, AD_HELP, GetPString(IDS_ADTESTTEXT));
|
---|
702 | break;
|
---|
703 |
|
---|
704 | case AD_ADDWPATHS:
|
---|
705 | if (SHORT2FROMMP(mp1) == EN_KILLFOCUS)
|
---|
706 | WinSetDlgItemText(hwnd, AD_HELP, NullStr);
|
---|
707 | if (SHORT2FROMMP(mp1) == EN_SETFOCUS)
|
---|
708 | WinSetDlgItemText(hwnd, AD_HELP, GetPString(IDS_ADADDWPATHSTEXT));
|
---|
709 | break;
|
---|
710 |
|
---|
711 | case AD_MOVEWPATHS:
|
---|
712 | if (SHORT2FROMMP(mp1) == EN_KILLFOCUS)
|
---|
713 | WinSetDlgItemText(hwnd, AD_HELP, NullStr);
|
---|
714 | if (SHORT2FROMMP(mp1) == EN_SETFOCUS)
|
---|
715 | WinSetDlgItemText(hwnd, AD_HELP, GetPString(IDS_ADMOVEWPATHSTEXT));
|
---|
716 | break;
|
---|
717 |
|
---|
718 | case AD_ADDRECURSE:
|
---|
719 | if (SHORT2FROMMP(mp1) == EN_KILLFOCUS)
|
---|
720 | WinSetDlgItemText(hwnd, AD_HELP, NullStr);
|
---|
721 | if (SHORT2FROMMP(mp1) == EN_SETFOCUS)
|
---|
722 | WinSetDlgItemText(hwnd, AD_HELP, GetPString(IDS_ADADDRECURSETEXT));
|
---|
723 | break;
|
---|
724 |
|
---|
725 | case AD_DELETE:
|
---|
726 | if (SHORT2FROMMP(mp1) == EN_KILLFOCUS)
|
---|
727 | WinSetDlgItemText(hwnd, AD_HELP, NullStr);
|
---|
728 | if (SHORT2FROMMP(mp1) == EN_SETFOCUS)
|
---|
729 | WinSetDlgItemText(hwnd, AD_HELP, GetPString(IDS_ADDELETETEXT));
|
---|
730 | break;
|
---|
731 |
|
---|
732 | case AD_SIGPOS:
|
---|
733 | if (SHORT2FROMMP(mp1) == EN_KILLFOCUS)
|
---|
734 | WinSetDlgItemText(hwnd, AD_HELP, NullStr);
|
---|
735 | if (SHORT2FROMMP(mp1) == EN_SETFOCUS)
|
---|
736 | WinSetDlgItemText(hwnd, AD_HELP, GetPString(IDS_ADSIGPOSTEXT));
|
---|
737 | break;
|
---|
738 |
|
---|
739 | case AD_FNAMEPOS:
|
---|
740 | if (SHORT2FROMMP(mp1) == EN_KILLFOCUS)
|
---|
741 | WinSetDlgItemText(hwnd, AD_HELP, NullStr);
|
---|
742 | if (SHORT2FROMMP(mp1) == EN_SETFOCUS)
|
---|
743 | WinSetDlgItemText(hwnd, AD_HELP, GetPString(IDS_ADFNAMEPOSTEXT));
|
---|
744 | break;
|
---|
745 |
|
---|
746 | case AD_OLDSZ:
|
---|
747 | if (SHORT2FROMMP(mp1) == EN_KILLFOCUS)
|
---|
748 | WinSetDlgItemText(hwnd, AD_HELP, NullStr);
|
---|
749 | if (SHORT2FROMMP(mp1) == EN_SETFOCUS)
|
---|
750 | WinSetDlgItemText(hwnd, AD_HELP, GetPString(IDS_ADOLDSZTEXT));
|
---|
751 | break;
|
---|
752 |
|
---|
753 | case AD_NUMDATEFLDS:
|
---|
754 | if (SHORT2FROMMP(mp1) == EN_KILLFOCUS)
|
---|
755 | WinSetDlgItemText(hwnd, AD_HELP, NullStr);
|
---|
756 | if (SHORT2FROMMP(mp1) == EN_SETFOCUS)
|
---|
757 | WinSetDlgItemText(hwnd, AD_HELP, GetPString(IDS_ADNUMDATEFLDSTEXT));
|
---|
758 | break;
|
---|
759 |
|
---|
760 | case AD_DATEPOS:
|
---|
761 | if (SHORT2FROMMP(mp1) == EN_KILLFOCUS)
|
---|
762 | WinSetDlgItemText(hwnd, AD_HELP, NullStr);
|
---|
763 | if (SHORT2FROMMP(mp1) == EN_SETFOCUS)
|
---|
764 | WinSetDlgItemText(hwnd, AD_HELP, GetPString(IDS_ADDATEPOSTEXT));
|
---|
765 | break;
|
---|
766 |
|
---|
767 | case AD_NEWSZ:
|
---|
768 | if (SHORT2FROMMP(mp1) == EN_KILLFOCUS)
|
---|
769 | WinSetDlgItemText(hwnd, AD_HELP, NullStr);
|
---|
770 | if (SHORT2FROMMP(mp1) == EN_SETFOCUS)
|
---|
771 | WinSetDlgItemText(hwnd, AD_HELP, GetPString(IDS_ADNEWSZTEXT));
|
---|
772 | break;
|
---|
773 |
|
---|
774 | case AD_STARTLIST:
|
---|
775 | if (SHORT2FROMMP(mp1) == EN_KILLFOCUS)
|
---|
776 | WinSetDlgItemText(hwnd, AD_HELP, NullStr);
|
---|
777 | if (SHORT2FROMMP(mp1) == EN_SETFOCUS)
|
---|
778 | WinSetDlgItemText(hwnd, AD_HELP, GetPString(IDS_ADSTARTLISTTEXT));
|
---|
779 | break;
|
---|
780 |
|
---|
781 | case AD_ENDLIST:
|
---|
782 | if (SHORT2FROMMP(mp1) == EN_KILLFOCUS)
|
---|
783 | WinSetDlgItemText(hwnd, AD_HELP, NullStr);
|
---|
784 | if (SHORT2FROMMP(mp1) == EN_SETFOCUS)
|
---|
785 | WinSetDlgItemText(hwnd, AD_HELP, GetPString(IDS_ADENDLISTTEXT));
|
---|
786 | break;
|
---|
787 |
|
---|
788 | }
|
---|
789 | return 0;
|
---|
790 |
|
---|
791 | case WM_COMMAND:
|
---|
792 | switch (SHORT1FROMMP(mp1)) {
|
---|
793 | case AD_SEEEXTRACTOR:
|
---|
794 | case AD_SEEADDER:
|
---|
795 | {
|
---|
796 | static CHAR tempargs[1026];
|
---|
797 |
|
---|
798 | *tempargs = 0;
|
---|
799 | if (SHORT1FROMMP(mp1) == AD_SEEADDER)
|
---|
800 | WinQueryDlgItemText(hwnd, AD_ADD, 255, tempargs);
|
---|
801 | else
|
---|
802 | WinQueryDlgItemText(hwnd, AD_EXTRACT, 255, tempargs);
|
---|
803 | if (!*tempargs)
|
---|
804 | saymsg(MB_CANCEL,
|
---|
805 | hwnd,
|
---|
806 | GetPString(IDS_BZZZTTEXT), GetPString(IDS_NEEDENTRYTEXT));
|
---|
807 | else {
|
---|
808 |
|
---|
809 | PSZ p;
|
---|
810 |
|
---|
811 | lstrip(tempargs);
|
---|
812 | p = strchr(tempargs, ' ');
|
---|
813 | if (p)
|
---|
814 | *p = 0;
|
---|
815 | {
|
---|
816 | EXECARGS ex;
|
---|
817 |
|
---|
818 | ex.flags = SEPARATEKEEP | WINDOWED | MAXIMIZED;
|
---|
819 | ex.commandline = tempargs;
|
---|
820 | *ex.path = 0;
|
---|
821 | *ex.environment = 0;
|
---|
822 | if (WinDlgBox(HWND_DESKTOP,
|
---|
823 | hwnd,
|
---|
824 | CmdLineDlgProc, FM3ModHandle, EXEC_FRAME, &ex) == 1)
|
---|
825 | runemf2(ex.flags,
|
---|
826 | hwnd, pszSrcFile, __LINE__,
|
---|
827 | NULL,
|
---|
828 | (*ex.environment) ? ex.environment : NULL,
|
---|
829 | "%s", tempargs);
|
---|
830 | }
|
---|
831 | }
|
---|
832 | }
|
---|
833 | return 0;
|
---|
834 |
|
---|
835 | case DID_OK:
|
---|
836 | // fixme to avoid creating empty strings for startlist and endlist
|
---|
837 | admp->info->startlist =
|
---|
838 | free_and_strdup_from_window(hwnd, AD_STARTLIST,
|
---|
839 | admp->info->startlist);
|
---|
840 | admp->info->endlist =
|
---|
841 | free_and_strdup_from_window(hwnd, AD_ENDLIST, admp->info->endlist);
|
---|
842 | admp->info->id =
|
---|
843 | free_and_strdup_from_window(hwnd, AD_ID, admp->info->id);
|
---|
844 | admp->info->create =
|
---|
845 | free_and_strdup_quoted_from_window(hwnd, AD_ADD, admp->info->create);
|
---|
846 | admp->info->createwdirs =
|
---|
847 | free_and_strdup_quoted_from_window(hwnd, AD_ADDWPATHS,
|
---|
848 | admp->info->createwdirs);
|
---|
849 | admp->info->createrecurse =
|
---|
850 | free_and_strdup_quoted_from_window(hwnd, AD_ADDRECURSE,
|
---|
851 | admp->info->createrecurse);
|
---|
852 | admp->info->movewdirs =
|
---|
853 | free_and_strdup_quoted_from_window(hwnd, AD_MOVEWPATHS,
|
---|
854 | admp->info->movewdirs);
|
---|
855 | admp->info->move =
|
---|
856 | free_and_strdup_quoted_from_window(hwnd, AD_MOVE, admp->info->move);
|
---|
857 | admp->info->delete =
|
---|
858 | free_and_strdup_quoted_from_window(hwnd, AD_DELETE, admp->info->delete);
|
---|
859 | admp->info->test =
|
---|
860 | free_and_strdup_quoted_from_window(hwnd, AD_TEST, admp->info->test);
|
---|
861 | admp->info->extract =
|
---|
862 | free_and_strdup_quoted_from_window(hwnd, AD_EXTRACT, admp->info->extract);
|
---|
863 | admp->info->exwdirs =
|
---|
864 | free_and_strdup_quoted_from_window(hwnd, AD_WDIRS, admp->info->exwdirs);
|
---|
865 | admp->info->ext =
|
---|
866 | free_and_strdup_from_window(hwnd, AD_EXT, admp->info->ext);
|
---|
867 | admp->info->signature =
|
---|
868 | free_and_strdup_from_window(hwnd, AD_SIG, admp->info->signature);
|
---|
869 | admp->info->siglen = literal(admp->info->signature);
|
---|
870 | admp->info->list = free_and_strdup_quoted_from_window(hwnd,
|
---|
871 | AD_LIST,
|
---|
872 | admp->info->list);
|
---|
873 | admp->info->file_offset = get_long_from_window(hwnd, AD_SIGPOS);
|
---|
874 | admp->info->osizepos = get_int_from_window(hwnd, AD_OLDSZ);
|
---|
875 | admp->info->nsizepos = get_int_from_window(hwnd, AD_NEWSZ);
|
---|
876 | admp->info->fdpos = get_int_from_window(hwnd, AD_DATEPOS);
|
---|
877 | admp->info->datetype = get_int2_from_window(hwnd, AD_DATEPOS);
|
---|
878 | admp->info->fdflds = get_int_from_window(hwnd, AD_NUMDATEFLDS);
|
---|
879 | admp->info->fnpos = get_int_from_window(hwnd, AD_FNAMEPOS);
|
---|
880 | admp->info->nameislast =
|
---|
881 | (get_int2_from_window(hwnd, AD_FNAMEPOS)) ? TRUE : FALSE;
|
---|
882 | admp->info->nameisnext =
|
---|
883 | (get_int3_from_window(hwnd, AD_FNAMEPOS)) ? TRUE : FALSE;
|
---|
884 | admp->info->nameisfirst =
|
---|
885 | (get_int4_from_window(hwnd, AD_FNAMEPOS)) ? TRUE : FALSE;
|
---|
886 | {
|
---|
887 | INT ok = check_archiver(hwnd, admp->info);
|
---|
888 |
|
---|
889 | if (saymsg(MB_YESNO,
|
---|
890 | hwnd,
|
---|
891 | GetPString(IDS_ADCHANGESINMEMTEXT),
|
---|
892 | GetPString(IDS_ADREWRITETEXT),
|
---|
893 | !ok ? GetPString(IDS_NOTRECOMMENDTEXT) : NullStr) ==
|
---|
894 | MBID_YES) {
|
---|
895 |
|
---|
896 | PSZ ab2;
|
---|
897 |
|
---|
898 | ab2 = searchpath(GetPString(IDS_ARCHIVERBB2)); // Rewrite without alerting
|
---|
899 | rewrite_archiverbb2(ab2);
|
---|
900 | }
|
---|
901 | }
|
---|
902 | WinDismissDlg(hwnd, TRUE);
|
---|
903 | return 0;
|
---|
904 |
|
---|
905 | case IDM_HELP:
|
---|
906 | if (hwndHelp)
|
---|
907 | WinSendMsg(hwndHelp,
|
---|
908 | HM_DISPLAY_HELP,
|
---|
909 | MPFROM2SHORT(HELP_EDITARC, 0), MPFROMSHORT(HM_RESOURCEID));
|
---|
910 | break;
|
---|
911 |
|
---|
912 | case DID_CANCEL:
|
---|
913 | WinDismissDlg(hwnd, FALSE);
|
---|
914 | return 0;
|
---|
915 |
|
---|
916 | case AD_TOSTART:
|
---|
917 | if (!admp->listname)
|
---|
918 | Runtime_Error(pszSrcFile, __LINE__, "no listname");
|
---|
919 | else {
|
---|
920 | sSelect = (SHORT) WinSendDlgItemMsg(hwnd,
|
---|
921 | AD_LISTBOX,
|
---|
922 | LM_QUERYSELECTION,
|
---|
923 | MPVOID, MPVOID);
|
---|
924 | WinSendDlgItemMsg(hwnd,
|
---|
925 | AD_LISTBOX,
|
---|
926 | LM_QUERYITEMTEXT,
|
---|
927 | MPFROM2SHORT(sSelect, 255), MPFROMP(s));
|
---|
928 | if (*s)
|
---|
929 | WinSetDlgItemText(hwnd, AD_STARTLIST, s);
|
---|
930 | else
|
---|
931 | BooBoo:
|
---|
932 | saymsg(MB_ENTER,
|
---|
933 | hwnd,
|
---|
934 | GetPString(IDS_OOPSTEXT),
|
---|
935 | GetPString(IDS_SELECTFROMLISTTEXT));
|
---|
936 | }
|
---|
937 | return 0;
|
---|
938 |
|
---|
939 | case AD_TOEND:
|
---|
940 | if (!admp->listname)
|
---|
941 | Runtime_Error(pszSrcFile, __LINE__, "no listname");
|
---|
942 | else {
|
---|
943 | sSelect = (SHORT) WinSendDlgItemMsg(hwnd,
|
---|
944 | AD_LISTBOX,
|
---|
945 | LM_QUERYSELECTION,
|
---|
946 | MPVOID, MPVOID);
|
---|
947 | WinSendDlgItemMsg(hwnd,
|
---|
948 | AD_LISTBOX,
|
---|
949 | LM_QUERYITEMTEXT,
|
---|
950 | MPFROM2SHORT(sSelect, 255), MPFROMP(s));
|
---|
951 | if (*s)
|
---|
952 | WinSetDlgItemText(hwnd, AD_ENDLIST, s);
|
---|
953 | else
|
---|
954 | goto BooBoo;
|
---|
955 | }
|
---|
956 | return 0;
|
---|
957 | }
|
---|
958 | return 0;
|
---|
959 | }
|
---|
960 | return WinDefDlgProc(hwnd, msg, mp1, mp2);
|
---|
961 | }
|
---|
962 |
|
---|
963 | #pragma alloc_text(AVV,EditArchiverDefinition,free_and_strdup_from_window)
|
---|
964 | #pragma alloc_text(AVV,get_int_from_window,get_int2_from_window)
|
---|
965 | #pragma alloc_text(AVV,get_long_from_window,get_int3_from_window)
|
---|
966 | #pragma alloc_text(AVV,get_int4_from_window,free_and_strdup_quoted_from_window)
|
---|