1 |
|
---|
2 | /***********************************************************************
|
---|
3 |
|
---|
4 | $Id: avl.c 248 2005-08-13 23:32:09Z root $
|
---|
5 |
|
---|
6 | archiver.bb2 loader and utilities
|
---|
7 |
|
---|
8 | Copyright (c) 1993-98 M. Kimes
|
---|
9 | Copyright (c) 2004, 2005 Steven H.Levine
|
---|
10 |
|
---|
11 | 01 Aug 04 SHL Rework lstrip/rstrip usage
|
---|
12 | 13 Aug 05 SHL Beautify with indent
|
---|
13 | 13 Aug 05 SHL find_type: correct no sig exists bypass logic
|
---|
14 |
|
---|
15 | ***********************************************************************/
|
---|
16 |
|
---|
17 | #define INCL_WIN
|
---|
18 | #define INCL_DOS
|
---|
19 |
|
---|
20 | #include <os2.h>
|
---|
21 | #include <stdlib.h>
|
---|
22 | #include <stdio.h>
|
---|
23 | #include <string.h>
|
---|
24 | #include <share.h>
|
---|
25 | #include <ctype.h>
|
---|
26 | #include "fm3dll.h"
|
---|
27 | #include "fm3dlg.h"
|
---|
28 | #include "fm3str.h"
|
---|
29 |
|
---|
30 | BOOL loadedarcs = FALSE;
|
---|
31 |
|
---|
32 | #pragma alloc_text(MISC9,quick_find_type,find_type)
|
---|
33 |
|
---|
34 | ARC_TYPE *quick_find_type(CHAR * filespec, ARC_TYPE * topsig)
|
---|
35 | {
|
---|
36 | ARC_TYPE *info, *found = NULL;
|
---|
37 | CHAR *p;
|
---|
38 |
|
---|
39 | if (!loadedarcs)
|
---|
40 | load_archivers();
|
---|
41 | p = strrchr(filespec, '.');
|
---|
42 | if (p)
|
---|
43 | {
|
---|
44 | p++;
|
---|
45 | info = (topsig) ? topsig : arcsighead;
|
---|
46 | while (info)
|
---|
47 | {
|
---|
48 | if (info -> ext &&
|
---|
49 | *(info -> ext) &&
|
---|
50 | !stricmp(p, info -> ext))
|
---|
51 | {
|
---|
52 | found = find_type(filespec, topsig);
|
---|
53 | break;
|
---|
54 | }
|
---|
55 | info = info -> next;
|
---|
56 | }
|
---|
57 | }
|
---|
58 | return found;
|
---|
59 | }
|
---|
60 |
|
---|
61 | ARC_TYPE *find_type(CHAR * filespec, ARC_TYPE * topsig)
|
---|
62 | {
|
---|
63 | HFILE handle;
|
---|
64 | ULONG action;
|
---|
65 | ULONG len;
|
---|
66 | ULONG l;
|
---|
67 | ARC_TYPE *info;
|
---|
68 | CHAR *p;
|
---|
69 | CHAR buffer[80];
|
---|
70 |
|
---|
71 | if (!loadedarcs)
|
---|
72 | load_archivers();
|
---|
73 | if (!topsig)
|
---|
74 | topsig = arcsighead;
|
---|
75 | DosError(FERR_DISABLEHARDERR);
|
---|
76 | if (DosOpen(filespec,
|
---|
77 | &handle,
|
---|
78 | &action,
|
---|
79 | 0L,
|
---|
80 | 0L,
|
---|
81 | OPEN_ACTION_FAIL_IF_NEW |
|
---|
82 | OPEN_ACTION_OPEN_IF_EXISTS,
|
---|
83 | OPEN_FLAGS_FAIL_ON_ERROR |
|
---|
84 | OPEN_FLAGS_NOINHERIT |
|
---|
85 | OPEN_FLAGS_RANDOMSEQUENTIAL |
|
---|
86 | OPEN_SHARE_DENYNONE |
|
---|
87 | OPEN_ACCESS_READONLY,
|
---|
88 | 0L))
|
---|
89 | return NULL;
|
---|
90 | // Scan signatures
|
---|
91 | for (info = topsig; info; info = info -> next)
|
---|
92 | {
|
---|
93 | if (!info -> signature || !*info -> signature)
|
---|
94 | {
|
---|
95 | // No signature -- check extension
|
---|
96 | p = strrchr(filespec, '.');
|
---|
97 | if (p)
|
---|
98 | {
|
---|
99 | p++;
|
---|
100 | if (info -> ext &&
|
---|
101 | *(info -> ext) &&
|
---|
102 | !stricmp(p, info -> ext))
|
---|
103 | break; // Matched
|
---|
104 | }
|
---|
105 | continue; // Next sig
|
---|
106 | }
|
---|
107 | // Try signature match
|
---|
108 | l = strlen(info -> signature);
|
---|
109 | l = min(l, 79);
|
---|
110 | if (!DosChgFilePtr(handle,
|
---|
111 | abs(info -> file_offset),
|
---|
112 | (info -> file_offset >= 0L) ?
|
---|
113 | FILE_BEGIN :
|
---|
114 | FILE_END,
|
---|
115 | &len))
|
---|
116 | {
|
---|
117 | if (!DosRead(handle,
|
---|
118 | buffer,
|
---|
119 | l,
|
---|
120 | &len) &&
|
---|
121 | len == l)
|
---|
122 | {
|
---|
123 | if (!memcmp(info -> signature,
|
---|
124 | buffer,
|
---|
125 | l))
|
---|
126 | break; // Matched
|
---|
127 | }
|
---|
128 | }
|
---|
129 | } // for
|
---|
130 | DosClose(handle); /* Either way, we're done for now */
|
---|
131 | return info; /* return signature, if any */
|
---|
132 | }
|
---|
133 |
|
---|
134 | #pragma alloc_text(AVL,load_archivers)
|
---|
135 |
|
---|
136 | INT load_archivers(VOID)
|
---|
137 | {
|
---|
138 | FILE *handle;
|
---|
139 | CHAR s[257], *p;
|
---|
140 | ARC_TYPE *info = NULL, *last = NULL;
|
---|
141 | INT numlines = NUMLINES, x;
|
---|
142 |
|
---|
143 | loadedarcs = TRUE;
|
---|
144 | DosEnterCritSec();
|
---|
145 | p = searchpath(GetPString(IDS_ARCHIVERBB2));
|
---|
146 | if (!p || !*p)
|
---|
147 | {
|
---|
148 | DosExitCritSec();
|
---|
149 | return -1;
|
---|
150 | }
|
---|
151 | handle = _fsopen(p, "r", SH_DENYWR);
|
---|
152 | DosExitCritSec();
|
---|
153 | if (!handle)
|
---|
154 | return -2;
|
---|
155 | strcpy(archiverbb2, p);
|
---|
156 | if (!fgets(s, 256, handle))
|
---|
157 | {
|
---|
158 | fclose(handle);
|
---|
159 | return -3;
|
---|
160 | }
|
---|
161 | p = strchr(s, ';');
|
---|
162 | if (p)
|
---|
163 | *p = 0;
|
---|
164 | bstripcr(s);
|
---|
165 | if (*s)
|
---|
166 | numlines = atoi(s);
|
---|
167 | if (!*s || numlines < NUMLINES)
|
---|
168 | return -3;
|
---|
169 | while (!feof(handle))
|
---|
170 | {
|
---|
171 | if (!fgets(s, 256, handle))
|
---|
172 | break;
|
---|
173 | p = strchr(s, ';');
|
---|
174 | if (p)
|
---|
175 | *p = 0; // Chop comment
|
---|
176 |
|
---|
177 | bstripcr(s);
|
---|
178 | if (*s)
|
---|
179 | {
|
---|
180 | info = malloc(sizeof(ARC_TYPE));
|
---|
181 | if (!info)
|
---|
182 | break;
|
---|
183 | memset(info, 0, sizeof(ARC_TYPE));
|
---|
184 | if (*s)
|
---|
185 | info -> id = strdup(s);
|
---|
186 | else
|
---|
187 | info -> id = NULL;
|
---|
188 | if (!fgets(s, 256, handle))
|
---|
189 | break;
|
---|
190 | p = strchr(s, ';');
|
---|
191 | if (p)
|
---|
192 | *p = 0;
|
---|
193 | bstripcr(s);
|
---|
194 | if (*s)
|
---|
195 | info -> ext = strdup(s);
|
---|
196 | else
|
---|
197 | info -> ext = NULL;
|
---|
198 | if (!fgets(s, 256, handle))
|
---|
199 | break;
|
---|
200 | p = strchr(s, ';');
|
---|
201 | if (p)
|
---|
202 | *p = 0;
|
---|
203 | info -> file_offset = atol(s);
|
---|
204 | if (!fgets(s, 256, handle))
|
---|
205 | break;
|
---|
206 | p = strchr(s, ';');
|
---|
207 | if (p)
|
---|
208 | *p = 0;
|
---|
209 | bstripcr(s);
|
---|
210 | if (*s)
|
---|
211 | info -> list = strdup(s);
|
---|
212 | else
|
---|
213 | info -> list = NULL;
|
---|
214 | if (!info -> list)
|
---|
215 | break;
|
---|
216 | if (!fgets(s, 256, handle))
|
---|
217 | break;
|
---|
218 | p = strchr(s, ';');
|
---|
219 | if (p)
|
---|
220 | *p = 0;
|
---|
221 | bstripcr(s);
|
---|
222 | if (*s)
|
---|
223 | info -> extract = strdup(s);
|
---|
224 | else
|
---|
225 | info -> extract = NULL;
|
---|
226 | if (!fgets(s, 256, handle))
|
---|
227 | break;
|
---|
228 | p = strchr(s, ';');
|
---|
229 | if (p)
|
---|
230 | *p = 0;
|
---|
231 | bstripcr(s);
|
---|
232 | if (*s)
|
---|
233 | info -> exwdirs = strdup(s);
|
---|
234 | else
|
---|
235 | info -> exwdirs = NULL;
|
---|
236 | if (!fgets(s, 256, handle))
|
---|
237 | break;
|
---|
238 | p = strchr(s, ';');
|
---|
239 | if (p)
|
---|
240 | *p = 0;
|
---|
241 | bstripcr(s);
|
---|
242 | if (*s)
|
---|
243 | info -> test = strdup(s);
|
---|
244 | else
|
---|
245 | info -> test = NULL;
|
---|
246 | if (!fgets(s, 256, handle))
|
---|
247 | break;
|
---|
248 | p = strchr(s, ';');
|
---|
249 | if (p)
|
---|
250 | *p = 0;
|
---|
251 | bstripcr(s);
|
---|
252 | if (*s)
|
---|
253 | info -> create = strdup(s);
|
---|
254 | else
|
---|
255 | info -> create = NULL;
|
---|
256 | if (!fgets(s, 256, handle))
|
---|
257 | break;
|
---|
258 | p = strchr(s, ';');
|
---|
259 | if (p)
|
---|
260 | *p = 0; // Chop comment
|
---|
261 |
|
---|
262 | bstripcr(s);
|
---|
263 | if (*s)
|
---|
264 | info -> createwdirs = strdup(s);
|
---|
265 | else
|
---|
266 | info -> createwdirs = NULL;
|
---|
267 | if (!fgets(s, 256, handle))
|
---|
268 | break;
|
---|
269 | p = strchr(s, ';');
|
---|
270 | if (p)
|
---|
271 | *p = 0;
|
---|
272 | bstripcr(s);
|
---|
273 | if (*s)
|
---|
274 | info -> createrecurse = strdup(s);
|
---|
275 | else
|
---|
276 | info -> createrecurse = NULL;
|
---|
277 | if (!fgets(s, 256, handle))
|
---|
278 | break;
|
---|
279 | p = strchr(s, ';');
|
---|
280 | if (p)
|
---|
281 | *p = 0;
|
---|
282 | bstripcr(s);
|
---|
283 | if (*s)
|
---|
284 | info -> move = strdup(s);
|
---|
285 | else
|
---|
286 | info -> move = NULL;
|
---|
287 | if (!fgets(s, 256, handle))
|
---|
288 | break;
|
---|
289 | p = strchr(s, ';');
|
---|
290 | if (p)
|
---|
291 | *p = 0;
|
---|
292 | bstripcr(s);
|
---|
293 | if (*s)
|
---|
294 | info -> movewdirs = strdup(s);
|
---|
295 | else
|
---|
296 | info -> movewdirs = NULL;
|
---|
297 | if (!fgets(s, 256, handle))
|
---|
298 | break;
|
---|
299 | p = strchr(s, ';');
|
---|
300 | if (p)
|
---|
301 | *p = 0;
|
---|
302 | bstripcr(s);
|
---|
303 | info -> delete = strdup(s);
|
---|
304 | if (!fgets(s, 256, handle))
|
---|
305 | break;
|
---|
306 | stripcr(s);
|
---|
307 | literal(s);
|
---|
308 | if (*s)
|
---|
309 | {
|
---|
310 | info -> signature = strdup(s);
|
---|
311 | if (!info -> signature)
|
---|
312 | break;
|
---|
313 | }
|
---|
314 | else
|
---|
315 | info -> signature = NULL;
|
---|
316 | if (!fgets(s, 256, handle))
|
---|
317 | break;
|
---|
318 | stripcr(s);
|
---|
319 | info -> startlist = strdup(s);
|
---|
320 | if (!fgets(s, 256, handle))
|
---|
321 | break;
|
---|
322 | stripcr(s);
|
---|
323 | if (*s)
|
---|
324 | info -> endlist = strdup(s);
|
---|
325 | else
|
---|
326 | info -> endlist = NULL;
|
---|
327 | if (!fgets(s, 256, handle))
|
---|
328 | break;
|
---|
329 | p = strchr(s, ';');
|
---|
330 | if (p)
|
---|
331 | *p = 0;
|
---|
332 | info -> osizepos = atoi(s);
|
---|
333 | if (!fgets(s, 256, handle))
|
---|
334 | break;
|
---|
335 | p = strchr(s, ';');
|
---|
336 | if (p)
|
---|
337 | *p = 0;
|
---|
338 | info -> nsizepos = atoi(s);
|
---|
339 | if (!fgets(s, 256, handle))
|
---|
340 | break;
|
---|
341 | p = strchr(s, ';');
|
---|
342 | if (p)
|
---|
343 | *p = 0;
|
---|
344 | info -> fdpos = atoi(s);
|
---|
345 | p = strchr(s, ',');
|
---|
346 | if (p)
|
---|
347 | {
|
---|
348 | p++;
|
---|
349 | info -> datetype = atoi(p);
|
---|
350 | }
|
---|
351 | if (!fgets(s, 256, handle))
|
---|
352 | break;
|
---|
353 | p = strchr(s, ';');
|
---|
354 | if (p)
|
---|
355 | *p = 0;
|
---|
356 | info -> fdflds = atoi(s);
|
---|
357 | if (!fgets(s, 256, handle))
|
---|
358 | break;
|
---|
359 | p = strchr(s, ';');
|
---|
360 | if (p)
|
---|
361 | *p = 0;
|
---|
362 | info -> fnpos = atoi(s);
|
---|
363 | p = strchr(s, ',');
|
---|
364 | if (p)
|
---|
365 | {
|
---|
366 | p++;
|
---|
367 | info -> nameislast = (BOOL) (*p && atol(p) == 0) ? FALSE : TRUE;
|
---|
368 | p = strchr(p, ',');
|
---|
369 | if (p)
|
---|
370 | {
|
---|
371 | p++;
|
---|
372 | info -> nameisnext = (BOOL) (*p && atol(p) == 0) ? FALSE : TRUE;
|
---|
373 | p = strchr(p, ',');
|
---|
374 | if (p)
|
---|
375 | {
|
---|
376 | p++;
|
---|
377 | info -> nameisfirst = (BOOL) (*p && atol(p) == 0) ? FALSE : TRUE;
|
---|
378 | }
|
---|
379 | }
|
---|
380 | }
|
---|
381 | for (x = NUMLINES; x < numlines; x++)
|
---|
382 | {
|
---|
383 | if (!fgets(s, 256, handle))
|
---|
384 | break;
|
---|
385 | }
|
---|
386 | info -> next = NULL;
|
---|
387 | if (!arcsighead)
|
---|
388 | {
|
---|
389 | arcsighead = last = info;
|
---|
390 | info -> prev = NULL;
|
---|
391 | }
|
---|
392 | else
|
---|
393 | {
|
---|
394 | last -> next = info;
|
---|
395 | info -> prev = last;
|
---|
396 | last = info;
|
---|
397 | }
|
---|
398 | if (info -> extract &&
|
---|
399 | !*info -> extract)
|
---|
400 | {
|
---|
401 | free(info -> extract);
|
---|
402 | info -> extract = NULL;
|
---|
403 | }
|
---|
404 | }
|
---|
405 | info = NULL;
|
---|
406 | }
|
---|
407 | fclose(handle);
|
---|
408 | if (info)
|
---|
409 | {
|
---|
410 | if (info -> id)
|
---|
411 | free(info -> id);
|
---|
412 | if (info -> ext)
|
---|
413 | free(info -> ext);
|
---|
414 | if (info -> list)
|
---|
415 | free(info -> list);
|
---|
416 | if (info -> extract)
|
---|
417 | free(info -> extract);
|
---|
418 | if (info -> create)
|
---|
419 | free(info -> create);
|
---|
420 | if (info -> move)
|
---|
421 | free(info -> move);
|
---|
422 | if (info -> delete)
|
---|
423 | free(info -> delete);
|
---|
424 | if (info -> signature)
|
---|
425 | free(info -> signature);
|
---|
426 | if (info -> startlist)
|
---|
427 | free(info -> startlist);
|
---|
428 | if (info -> endlist)
|
---|
429 | free(info -> endlist);
|
---|
430 | if (info -> exwdirs)
|
---|
431 | free(info -> exwdirs);
|
---|
432 | if (info -> test)
|
---|
433 | free(info -> test);
|
---|
434 | if (info -> createrecurse)
|
---|
435 | free(info -> createrecurse);
|
---|
436 | if (info -> createwdirs)
|
---|
437 | free(info -> createwdirs);
|
---|
438 | if (info -> movewdirs)
|
---|
439 | free(info -> movewdirs);
|
---|
440 | }
|
---|
441 | if (!arcsighead)
|
---|
442 | return -4;
|
---|
443 | return 0;
|
---|
444 | }
|
---|
445 |
|
---|
446 | #pragma alloc_text(FMARCHIVE,SBoxDlgProc)
|
---|
447 |
|
---|
448 | MRESULT EXPENTRY SBoxDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
---|
449 | {
|
---|
450 | /* dlg proc that allows selecting an archiver entry */
|
---|
451 |
|
---|
452 | ARC_TYPE **info, *temp, *test;
|
---|
453 | SHORT sSelect, x;
|
---|
454 | CHAR text[256];
|
---|
455 |
|
---|
456 | switch (msg)
|
---|
457 | {
|
---|
458 | case WM_INITDLG:
|
---|
459 | if (!loadedarcs)
|
---|
460 | load_archivers();
|
---|
461 | if (!(ARC_TYPE **) mp2)
|
---|
462 | {
|
---|
463 | DosBeep(100, 100);
|
---|
464 | WinDismissDlg(hwnd, 0);
|
---|
465 | break;
|
---|
466 | }
|
---|
467 | info = (ARC_TYPE **) mp2;
|
---|
468 | if (*info)
|
---|
469 | *info = arcsighead;
|
---|
470 | WinSetWindowPtr(hwnd, 0L, (PVOID) info);
|
---|
471 | temp = arcsighead;
|
---|
472 | WinSendDlgItemMsg(hwnd, ASEL_LISTBOX, LM_DELETEALL, MPVOID, MPVOID);
|
---|
473 | /* this loop fills the listbox */
|
---|
474 | {
|
---|
475 | BOOL found = FALSE;
|
---|
476 |
|
---|
477 | while (temp)
|
---|
478 | {
|
---|
479 | /*
|
---|
480 | * this inner loop tests for a dupe signature entry and assures
|
---|
481 | * that only the entry at the top of the list gets used for
|
---|
482 | * conversion; editing any is okay
|
---|
483 | */
|
---|
484 | if (*info)
|
---|
485 | {
|
---|
486 | test = arcsighead;
|
---|
487 | while (test && test != temp)
|
---|
488 | {
|
---|
489 | if (!strcmp(test -> signature, temp -> signature))
|
---|
490 | goto ContinueHere;
|
---|
491 | test = test -> next;
|
---|
492 | }
|
---|
493 | }
|
---|
494 |
|
---|
495 | if (!*info || (temp -> id && temp -> extract && temp -> create))
|
---|
496 | {
|
---|
497 | sSelect = (SHORT) WinSendDlgItemMsg(hwnd, ASEL_LISTBOX, LM_INSERTITEM,
|
---|
498 | MPFROM2SHORT(LIT_END, 0),
|
---|
499 | MPFROMP((temp -> id) ?
|
---|
500 | temp -> id : "?"));
|
---|
501 | if (!found && *szDefArc && temp -> id && !strcmp(szDefArc, temp -> id))
|
---|
502 | {
|
---|
503 | WinSendDlgItemMsg(hwnd, ASEL_LISTBOX, LM_SELECTITEM,
|
---|
504 | MPFROMSHORT(sSelect), MPFROMSHORT(TRUE));
|
---|
505 | found = TRUE;
|
---|
506 | }
|
---|
507 | }
|
---|
508 | else
|
---|
509 | {
|
---|
510 | if (!temp -> id || !*temp -> id)
|
---|
511 | WinSendDlgItemMsg(hwnd, ASEL_LISTBOX, LM_INSERTITEM,
|
---|
512 | MPFROM2SHORT(LIT_END, 0),
|
---|
513 | MPFROMP(GetPString(IDS_UNKNOWNUNUSABLETEXT)));
|
---|
514 | else
|
---|
515 | {
|
---|
516 | CHAR s[81];
|
---|
517 |
|
---|
518 | sprintf(s, "%0.12s %s",
|
---|
519 | temp -> id,
|
---|
520 | GetPString(IDS_UNUSABLETEXT));
|
---|
521 | WinSendDlgItemMsg(hwnd, ASEL_LISTBOX, LM_INSERTITEM,
|
---|
522 | MPFROM2SHORT(LIT_END, 0),
|
---|
523 | MPFROMP(s));
|
---|
524 | }
|
---|
525 | }
|
---|
526 |
|
---|
527 | ContinueHere:
|
---|
528 |
|
---|
529 | temp = temp -> next;
|
---|
530 | }
|
---|
531 | if (found)
|
---|
532 | PosOverOkay(hwnd);
|
---|
533 | }
|
---|
534 | break;
|
---|
535 |
|
---|
536 | case WM_COMMAND:
|
---|
537 | info = (ARC_TYPE **) WinQueryWindowPtr(hwnd, 0L);
|
---|
538 | switch (SHORT1FROMMP(mp1))
|
---|
539 | {
|
---|
540 | case DID_OK:
|
---|
541 | sSelect = (SHORT) WinSendDlgItemMsg(hwnd,
|
---|
542 | ASEL_LISTBOX,
|
---|
543 | LM_QUERYSELECTION,
|
---|
544 | MPFROMSHORT(LIT_FIRST),
|
---|
545 | MPVOID);
|
---|
546 | if (sSelect >= 0)
|
---|
547 | {
|
---|
548 | temp = arcsighead;
|
---|
549 | if (*info)
|
---|
550 | {
|
---|
551 | *text = 0;
|
---|
552 | WinSendDlgItemMsg(hwnd, ASEL_LISTBOX, LM_QUERYITEMTEXT,
|
---|
553 | MPFROM2SHORT(sSelect, 255), MPFROMP(text));
|
---|
554 | if (*text)
|
---|
555 | {
|
---|
556 | while (temp)
|
---|
557 | {
|
---|
558 | if (temp -> id)
|
---|
559 | {
|
---|
560 | if (!strcmp(text, temp -> id))
|
---|
561 | break;
|
---|
562 | }
|
---|
563 | temp = temp -> next;
|
---|
564 | }
|
---|
565 | }
|
---|
566 | else
|
---|
567 | temp = NULL;
|
---|
568 | }
|
---|
569 | else
|
---|
570 | {
|
---|
571 | x = 0;
|
---|
572 | while (temp)
|
---|
573 | {
|
---|
574 | if (x >= sSelect)
|
---|
575 | break;
|
---|
576 | x++;
|
---|
577 | temp = temp -> next;
|
---|
578 | }
|
---|
579 | }
|
---|
580 | if (temp && (!*info || (temp -> id && temp -> extract &&
|
---|
581 | temp -> create)))
|
---|
582 | {
|
---|
583 | *info = temp;
|
---|
584 | }
|
---|
585 | else
|
---|
586 | {
|
---|
587 | WinSendDlgItemMsg(hwnd, ASEL_LISTBOX, LM_SELECTITEM,
|
---|
588 | MPFROMSHORT(LIT_NONE), FALSE);
|
---|
589 | DosBeep(100, 100);
|
---|
590 | temp = NULL;
|
---|
591 | return 0;
|
---|
592 | }
|
---|
593 | }
|
---|
594 | else
|
---|
595 | {
|
---|
596 | DosBeep(100, 100);
|
---|
597 | return 0;
|
---|
598 | }
|
---|
599 | WinDismissDlg(hwnd, TRUE);
|
---|
600 | return 0;
|
---|
601 |
|
---|
602 | case DID_CANCEL:
|
---|
603 | *info = NULL;
|
---|
604 | PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);
|
---|
605 | break;
|
---|
606 |
|
---|
607 | default:
|
---|
608 | break;
|
---|
609 | }
|
---|
610 | return 0;
|
---|
611 |
|
---|
612 | case WM_CONTROL:
|
---|
613 | if (SHORT1FROMMP(mp1) == ASEL_LISTBOX && SHORT2FROMMP(mp1) == LN_ENTER)
|
---|
614 | PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(DID_OK, 0), MPVOID);
|
---|
615 | return 0;
|
---|
616 |
|
---|
617 | case WM_CLOSE:
|
---|
618 | WinDismissDlg(hwnd, FALSE);
|
---|
619 | return 0;
|
---|
620 |
|
---|
621 | default:
|
---|
622 | break;
|
---|
623 | }
|
---|
624 | return WinDefDlgProc(hwnd, msg, mp1, mp2);
|
---|
625 | }
|
---|
626 |
|
---|
627 | /*
|
---|
628 | 02-08-96 23:55 1
|
---|
629 | 8 Feb 96 23:55:32 2
|
---|
630 | 8 Feb 96 11:55p 3
|
---|
631 | 96-02-08 23:55:32 4
|
---|
632 | */
|
---|
633 |
|
---|
634 | #pragma alloc_text(ARCCNRS,ArcDateTime)
|
---|
635 |
|
---|
636 | BOOL ArcDateTime(CHAR * dt, INT type, CDATE * cdate, CTIME * ctime)
|
---|
637 | {
|
---|
638 | INT x;
|
---|
639 | BOOL ret = FALSE;
|
---|
640 | CHAR *p, *pp, *pd;
|
---|
641 |
|
---|
642 | if (dt && cdate && ctime)
|
---|
643 | {
|
---|
644 | memset(cdate, 0, sizeof(CDATE));
|
---|
645 | memset(ctime, 0, sizeof(CTIME));
|
---|
646 | if (type)
|
---|
647 | {
|
---|
648 | p = dt;
|
---|
649 | while (*p && *p == ' ')
|
---|
650 | p++;
|
---|
651 | pd = dt;
|
---|
652 | switch (type)
|
---|
653 | {
|
---|
654 | case 1:
|
---|
655 | cdate -> month = atoi(pd);
|
---|
656 | p = to_delim(pd, "-/.");
|
---|
657 | if (p)
|
---|
658 | {
|
---|
659 | p++;
|
---|
660 | cdate -> day = atoi(p);
|
---|
661 | pd = p;
|
---|
662 | p = to_delim(pd, "-/.");
|
---|
663 | if (p)
|
---|
664 | {
|
---|
665 | p++;
|
---|
666 | cdate -> year = atoi(p);
|
---|
667 | if (cdate -> year > 80 && cdate -> year < 1900)
|
---|
668 | cdate -> year += 1900;
|
---|
669 | else if (cdate -> year < 1900)
|
---|
670 | cdate -> year += 2000;
|
---|
671 | ret = TRUE;
|
---|
672 | p = strchr(p, ' ');
|
---|
673 | if (p)
|
---|
674 | {
|
---|
675 | while (*p && *p == ' ')
|
---|
676 | p++;
|
---|
677 | ctime -> hours = atoi(p);
|
---|
678 | p = to_delim(pd, ":.");
|
---|
679 | if (p)
|
---|
680 | {
|
---|
681 | p++;
|
---|
682 | ctime -> minutes = atoi(p);
|
---|
683 | p = to_delim(pd, ":.");
|
---|
684 | if (p)
|
---|
685 | {
|
---|
686 | p++;
|
---|
687 | ctime -> seconds = atoi(p);
|
---|
688 | }
|
---|
689 | }
|
---|
690 | }
|
---|
691 | }
|
---|
692 | }
|
---|
693 | break;
|
---|
694 |
|
---|
695 | case 2:
|
---|
696 | cdate -> day = atoi(p);
|
---|
697 | p = strchr(p, ' ');
|
---|
698 | if (p)
|
---|
699 | {
|
---|
700 | p++;
|
---|
701 | for (x = 0; x < 12; x++)
|
---|
702 | {
|
---|
703 | if (!strnicmp(p, GetPString(IDS_JANUARY + x), 3))
|
---|
704 | break;
|
---|
705 | }
|
---|
706 | if (x < 12)
|
---|
707 | {
|
---|
708 | cdate -> month = x;
|
---|
709 | p = strchr(p, ' ');
|
---|
710 | if (p)
|
---|
711 | {
|
---|
712 | p++;
|
---|
713 | cdate -> year = atoi(p);
|
---|
714 | if (cdate -> year > 80 && cdate -> year < 1900)
|
---|
715 | cdate -> year += 1900;
|
---|
716 | else if (cdate -> year < 1900)
|
---|
717 | cdate -> year += 2000;
|
---|
718 | ret = TRUE;
|
---|
719 | p = strchr(p, ' ');
|
---|
720 | if (p)
|
---|
721 | {
|
---|
722 | while (*p && *p == ' ')
|
---|
723 | p++;
|
---|
724 | ctime -> hours = atoi(p);
|
---|
725 | p = to_delim(pd, ":.");
|
---|
726 | if (p)
|
---|
727 | {
|
---|
728 | p++;
|
---|
729 | ctime -> minutes = atoi(p);
|
---|
730 | p = to_delim(pd, ":.");
|
---|
731 | if (p)
|
---|
732 | {
|
---|
733 | p++;
|
---|
734 | ctime -> seconds = atoi(p);
|
---|
735 | }
|
---|
736 | }
|
---|
737 | }
|
---|
738 | }
|
---|
739 | }
|
---|
740 | }
|
---|
741 | break;
|
---|
742 |
|
---|
743 | case 3:
|
---|
744 | cdate -> day = atoi(p);
|
---|
745 | p = strchr(p, ' ');
|
---|
746 | if (p)
|
---|
747 | {
|
---|
748 | p++;
|
---|
749 | for (x = 0; x < 12; x++)
|
---|
750 | {
|
---|
751 | if (!strnicmp(p, GetPString(IDS_JANUARY + x), 3))
|
---|
752 | break;
|
---|
753 | }
|
---|
754 | if (x < 12)
|
---|
755 | {
|
---|
756 | cdate -> month = x;
|
---|
757 | p = strchr(p, ' ');
|
---|
758 | if (p)
|
---|
759 | {
|
---|
760 | p++;
|
---|
761 | cdate -> year = atoi(p);
|
---|
762 | if (cdate -> year > 80 && cdate -> year < 1900)
|
---|
763 | cdate -> year += 1900;
|
---|
764 | else if (cdate -> year < 1900)
|
---|
765 | cdate -> year += 2000;
|
---|
766 | ret = TRUE;
|
---|
767 | p = strchr(p, ' ');
|
---|
768 | if (p)
|
---|
769 | {
|
---|
770 | while (*p && *p == ' ')
|
---|
771 | p++;
|
---|
772 | ctime -> hours = atoi(p);
|
---|
773 | p = to_delim(pd, ":.");
|
---|
774 | if (p)
|
---|
775 | {
|
---|
776 | p++;
|
---|
777 | pp = p;
|
---|
778 | ctime -> minutes = atoi(p);
|
---|
779 | p = to_delim(pd, ":.");
|
---|
780 | if (p)
|
---|
781 | {
|
---|
782 | p++;
|
---|
783 | ctime -> seconds = atoi(p);
|
---|
784 | p += 2;
|
---|
785 | if (toupper(*p) == 'P')
|
---|
786 | ctime -> hours += 12;
|
---|
787 | }
|
---|
788 | else
|
---|
789 | {
|
---|
790 | p = pp;
|
---|
791 | p += 2;
|
---|
792 | if (toupper(*p) == 'P')
|
---|
793 | ctime -> hours += 12;
|
---|
794 | }
|
---|
795 | }
|
---|
796 | }
|
---|
797 | }
|
---|
798 | }
|
---|
799 | }
|
---|
800 | break;
|
---|
801 |
|
---|
802 | case 4:
|
---|
803 | cdate -> year = atoi(p);
|
---|
804 | if (cdate -> year > 80 && cdate -> year < 1900)
|
---|
805 | cdate -> year += 1900;
|
---|
806 | else if (cdate -> year < 1900)
|
---|
807 | cdate -> year += 2000;
|
---|
808 | p = to_delim(pd, "-/.");
|
---|
809 | if (p)
|
---|
810 | {
|
---|
811 | p++;
|
---|
812 | cdate -> month = atoi(p);
|
---|
813 | pd = p;
|
---|
814 | p = to_delim(pd, "-/.");
|
---|
815 | if (p)
|
---|
816 | {
|
---|
817 | p++;
|
---|
818 | cdate -> day = atoi(p);
|
---|
819 | ret = TRUE;
|
---|
820 | p = strchr(p, ' ');
|
---|
821 | if (p)
|
---|
822 | {
|
---|
823 | while (*p && *p == ' ')
|
---|
824 | p++;
|
---|
825 | ctime -> hours = atoi(p);
|
---|
826 | p = to_delim(pd, ":.");
|
---|
827 | if (p)
|
---|
828 | {
|
---|
829 | p++;
|
---|
830 | ctime -> minutes = atoi(p);
|
---|
831 | p = to_delim(pd, ":.");
|
---|
832 | if (p)
|
---|
833 | {
|
---|
834 | p++;
|
---|
835 | ctime -> seconds = atoi(p);
|
---|
836 | }
|
---|
837 | }
|
---|
838 | }
|
---|
839 | }
|
---|
840 | }
|
---|
841 | break;
|
---|
842 |
|
---|
843 | case 5:
|
---|
844 | cdate -> day = atoi(pd);
|
---|
845 | p = to_delim(pd, "-/.");
|
---|
846 | if (p)
|
---|
847 | {
|
---|
848 | p++;
|
---|
849 | cdate -> month = atoi(p);
|
---|
850 | pd = p;
|
---|
851 | p = to_delim(pd, "-/.");
|
---|
852 | if (p)
|
---|
853 | {
|
---|
854 | p++;
|
---|
855 | cdate -> year = atoi(p);
|
---|
856 | if (cdate -> year > 80 && cdate -> year < 1900)
|
---|
857 | cdate -> year += 1900;
|
---|
858 | else if (cdate -> year < 1900)
|
---|
859 | cdate -> year += 2000;
|
---|
860 | ret = TRUE;
|
---|
861 | p = strchr(p, ' ');
|
---|
862 | if (p)
|
---|
863 | {
|
---|
864 | while (*p && *p == ' ')
|
---|
865 | p++;
|
---|
866 | ctime -> hours = atoi(p);
|
---|
867 | p = to_delim(pd, ":.");
|
---|
868 | if (p)
|
---|
869 | {
|
---|
870 | p++;
|
---|
871 | ctime -> minutes = atoi(p);
|
---|
872 | p = to_delim(pd, ":.");
|
---|
873 | if (p)
|
---|
874 | {
|
---|
875 | p++;
|
---|
876 | ctime -> seconds = atoi(p);
|
---|
877 | }
|
---|
878 | }
|
---|
879 | }
|
---|
880 | }
|
---|
881 | }
|
---|
882 | break;
|
---|
883 |
|
---|
884 | default:
|
---|
885 | break;
|
---|
886 | }
|
---|
887 | }
|
---|
888 | }
|
---|
889 | return ret;
|
---|
890 | }
|
---|