source: trunk/dll/avl.c@ 1544

Last change on this file since 1544 was 1544, checked in by Gregg Young, 15 years ago

Changes to fopen and _fsopen to allow FM2 to be loaded in high memory

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 35.2 KB
Line 
1
2/***********************************************************************
3
4 $Id: avl.c 1544 2010-09-30 13:00:59Z gyoung $
5
6 archiver.bb2 search, load, save and date parse
7
8 Copyright (c) 1993, 1998 M. Kimes
9 Copyright (c) 2004, 2008 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 13 Aug 05 SHL SBoxDlgProc: avoid dereferencing NULL signature
15 18 Aug 05 SHL Comments
16 31 Dec 05 SHL indent -i2
17 08 Dec 05 SHL load_archivers: allow empty startlist
18 30 Dec 05 SHL load_archivers: use get_archiver_line?(), clean nits
19 29 May 06 SHL SBoxDlgProc: support move, add, delete
20 30 May 06 SHL load_archivers: add reload support
21 16 Jun 06 SHL load_archivers: support signatures containing 0s
22 26 Jun 06 SHL load_archivers: remember where comments are
23 14 Jul 06 SHL Use Runtime_Error
24 29 Jul 06 SHL Use xfgets, xfgets_bstripcr
25 15 Aug 06 SHL Use Runtime_Error more
26 01 Nov 06 SHL Turn off leftover debug code
27 06 Apr 07 GKY Work around PM DragInfo and DrgFreeDISH limit
28 19 Apr 07 SHL Use FreeDragInfoData
29 19 Apr 07 SHL Add more drag/drop error checking
30 20 Aug 07 GKY Move #pragma alloc_text to end for OpenWatcom compat
31 25 Aug 07 SHL load_archivers: add missing close on error path
32 29 Feb 08 GKY Use xfree where appropriate
33 22 Jun 08 GKY Added free_archivers for fortify checking
34 19 Jul 08 GKY ifdef Fortify free_archivers
35 29 Nov 08 GKY Add ini entry for LastArchiver so the previous archiver is selected in the
36 Select archive dialog if no default is provided.
37 29 Nov 08 GKY Remove or replace with a mutex semaphore DosEnterCriSec where appropriate.
38 11 Jan 08 GKY Replace "ARCHIVER.BB2" in string file with global set at compile in init.c
39 08 Mar 09 GKY Additional strings move to PCSZs in init.c
40
41***********************************************************************/
42
43#include <stdlib.h>
44#include <string.h>
45#include <ctype.h>
46#include <share.h>
47
48#define INCL_DOS
49#define INCL_WIN
50#define INCL_WINSTDDRAG
51#define INCL_LONGLONG
52
53#include "fm3dll.h"
54#include "fm3dll2.h" // #define's for UM_*, control id's, etc.
55#include "notebook.h" // Data declaration(s)
56#include "init.h" // Data declaration(s)
57#include "valid.h" // Data declaration(s)
58#include "mainwnd.h" // Data declaration(s)
59#include "fm3dlg.h"
60#include "fm3str.h"
61#include "avl.h"
62#include "strutil.h" // GetPString
63#include "errutil.h" // Runtime_Error
64#include "avv.h" // ArcReviewDlgProc, rewrite_archiverbb2
65#include "droplist.h" // DropHelp, FullDrgName
66#include "misc.h" // DrawTargetEmphasis
67#include "draglist.h" // FreeDragInfoData
68#include "chklist.h" // PosOverOkay
69#include "literal.h" // literal
70#include "wrappers.h" // xfgets
71#include "strips.h" // bstrip
72#include "srchpath.h" // searchpath
73#include "stristr.h" // stristr
74#include "delims.h" // to_delim
75#include "fortify.h"
76
77// Data definitions
78static PSZ pszSrcFile = __FILE__;
79static void fill_listbox(HWND hwnd, BOOL fShowAll, SHORT sOldSelect);
80
81#pragma data_seg(GLOBAL1)
82ARC_TYPE *arcsighead;
83UINT arcsigs_header_lines; // Header comments line count in archiver.bb2
84UINT arcsigs_trailer_line_num; // Trailer comments start line number (1..n)
85BOOL arcsigsloaded;
86BOOL arcsigsmodified;
87
88#define ARCHIVER_LINE_BYTES 256
89
90//=== quick_find_type() ===
91ARC_TYPE *quick_find_type(CHAR * filespec, ARC_TYPE * topsig)
92{
93 ARC_TYPE *info, *found = NULL;
94 CHAR *p;
95
96 if (!arcsigsloaded)
97 load_archivers();
98 p = strrchr(filespec, '.');
99 if (p) {
100 p++;
101 info = (topsig) ? topsig : arcsighead;
102 while (info) {
103 if (info->ext && *(info->ext) && !stricmp(p, info->ext)) {
104 found = find_type(filespec, topsig);
105 break;
106 }
107 info = info->next;
108 }
109 }
110 return found;
111}
112
113//=== fill_listbox() fill or refill listbox from current archiver definitions ===
114
115static VOID fill_listbox(HWND hwnd, BOOL fShowAll, SHORT sOldSelect)
116{
117 ARC_TYPE *pat;
118 BOOL found = FALSE;
119 SHORT sSelect;
120
121 WinSendDlgItemMsg(hwnd, ASEL_LISTBOX, LM_DELETEALL, MPVOID, MPVOID);
122
123 for (pat = arcsighead; pat; pat = pat->next) {
124 /*
125 * this inner loop tests for a dup signature entry and assures
126 * that only the entry at the top of the list gets used for
127 * conversion; editing any is okay
128 */
129 if (!fShowAll) {
130 ARC_TYPE *pat2;
131 BOOL isDup = FALSE;
132
133 for (pat2 = arcsighead;
134 pat2 && pat->siglen && pat2 != pat && !isDup; pat2 = pat2->next) {
135 isDup = pat2->siglen == pat->siglen &&
136 !memcmp(pat2->signature, pat->signature, pat->siglen);
137 } // for
138 if (isDup)
139 continue;
140 }
141
142 // If caller is editing archivers or entry useful to caller, show in listbox
143 if (fShowAll || (pat->id && pat->extract && pat->create)) {
144 sSelect = (SHORT) WinSendDlgItemMsg(hwnd, ASEL_LISTBOX, LM_INSERTITEM,
145 MPFROM2SHORT(LIT_END, 0),
146 MPFROMP(pat->id ? pat->id : "?"));
147 if (!found && *szDefArc && pat->id && !strcmp(szDefArc, pat->id)) {
148 // Highlight default
149 WinSendDlgItemMsg(hwnd, ASEL_LISTBOX, LM_SELECTITEM,
150 MPFROMSHORT(sSelect), MPFROMSHORT(TRUE));
151 found = TRUE;
152 }
153 }
154 else {
155 // Complain about odd entry
156 if (!pat->id || !*pat->id) {
157 WinSendDlgItemMsg(hwnd, ASEL_LISTBOX, LM_INSERTITEM,
158 MPFROM2SHORT(LIT_END, 0),
159 MPFROMP(GetPString(IDS_UNKNOWNUNUSABLETEXT)));
160 }
161 else {
162 CHAR s[81];
163
164 sprintf(s, "%0.12s %s", pat->id, GetPString(IDS_UNUSABLETEXT));
165 WinSendDlgItemMsg(hwnd, ASEL_LISTBOX, LM_INSERTITEM,
166 MPFROM2SHORT(LIT_END, 0), MPFROMP(s));
167 }
168 }
169 } // while scanning
170
171 // Try to reselect last selection unless user wants default selection
172 if (sOldSelect == LIT_NONE) {
173 ULONG size = sizeof(SHORT);
174
175 PrfQueryProfileData(fmprof, appname, "LastArchiver", &sOldSelect, &size);
176 }
177 if (sOldSelect != LIT_NONE && !found) {
178 SHORT sItemCount =
179 (SHORT) WinSendDlgItemMsg(hwnd, ASEL_LISTBOX, LM_QUERYITEMCOUNT,
180 MPVOID, MPVOID);
181
182 if (sOldSelect >= sItemCount)
183 sOldSelect = sItemCount - 1;
184 if (sOldSelect >= 0) {
185 WinSendDlgItemMsg(hwnd, ASEL_LISTBOX, LM_SELECTITEM,
186 MPFROMSHORT(sOldSelect), MPFROMSHORT(TRUE));
187 }
188 }
189
190 if (found)
191 PosOverOkay(hwnd);
192}
193
194ARC_TYPE *find_type(CHAR * filespec, ARC_TYPE * topsig)
195{
196 HFILE handle;
197 ULONG action;
198 ULONG len;
199 ULONG l;
200 ARC_TYPE *info;
201 CHAR *p;
202 CHAR buffer[4096]; // 06 Oct 07 SHL Protect against NTFS defect
203
204 if (!arcsigsloaded)
205 load_archivers();
206 if (!topsig)
207 topsig = arcsighead;
208 DosError(FERR_DISABLEHARDERR);
209 if (DosOpen(filespec,
210 &handle,
211 &action,
212 0,
213 0,
214 OPEN_ACTION_FAIL_IF_NEW |
215 OPEN_ACTION_OPEN_IF_EXISTS,
216 OPEN_FLAGS_FAIL_ON_ERROR |
217 OPEN_FLAGS_NOINHERIT |
218 OPEN_FLAGS_RANDOMSEQUENTIAL |
219 OPEN_SHARE_DENYNONE | OPEN_ACCESS_READONLY, 0))
220 return NULL;
221 // Scan signatures
222 for (info = topsig; info; info = info->next) {
223 if (info->siglen == 0) {
224 // No signature -- check extension
225 p = strrchr(filespec, '.');
226 if (p) {
227 p++;
228 if (info->ext && *(info->ext) && !stricmp(p, info->ext))
229 break; // Matched
230
231 }
232 continue; // Next sig
233
234 }
235 // Try signature match
236 l = info->siglen;
237 l = min(l, 79);
238 if (!DosChgFilePtr(handle,
239 abs(info->file_offset),
240 (info->file_offset >= 0) ?
241 FILE_BEGIN : FILE_END, &len)) {
242 if (!DosRead(handle, buffer, l, &len) && len == l) {
243 if (!memcmp(info->signature, buffer, l))
244 break; // Matched
245
246 }
247 }
248 } // for
249
250 DosClose(handle); /* Either way, we're done for now */
251 return info; /* Return signature, if any */
252}
253
254# ifdef FORTIFY
255
256VOID free_archivers(VOID)
257{
258 ARC_TYPE *pat, *next;
259
260 pat = arcsighead;
261 while (pat) {
262 next = pat->next;
263 xfree(pat->id, pszSrcFile, __LINE__);
264 xfree(pat->ext, pszSrcFile, __LINE__);
265 xfree(pat->list, pszSrcFile, __LINE__);
266 xfree(pat->extract, pszSrcFile, __LINE__);
267 xfree(pat->create, pszSrcFile, __LINE__);
268 xfree(pat->move, pszSrcFile, __LINE__);
269 xfree(pat->delete, pszSrcFile, __LINE__);
270 xfree(pat->signature, pszSrcFile, __LINE__);
271 xfree(pat->startlist, pszSrcFile, __LINE__);
272 xfree(pat->endlist, pszSrcFile, __LINE__);
273 xfree(pat->exwdirs, pszSrcFile, __LINE__);
274 xfree(pat->test, pszSrcFile, __LINE__);
275 xfree(pat->createrecurse, pszSrcFile, __LINE__);
276 xfree(pat->createwdirs, pszSrcFile, __LINE__);
277 xfree(pat->movewdirs, pszSrcFile, __LINE__);
278 xfree(pat, pszSrcFile, __LINE__);
279 pat = next;
280 }
281 arcsighead = NULL;
282}
283
284//=== free_arc_type() free allocated ARC_TYPE ===
285
286# endif
287
288VOID free_arc_type(ARC_TYPE * pat)
289{
290 if (pat) {
291 xfree(pat->id, pszSrcFile, __LINE__);
292 xfree(pat->ext, pszSrcFile, __LINE__);
293 xfree(pat->list, pszSrcFile, __LINE__);
294 xfree(pat->extract, pszSrcFile, __LINE__);
295 xfree(pat->create, pszSrcFile, __LINE__);
296 xfree(pat->move, pszSrcFile, __LINE__);
297 xfree(pat->delete, pszSrcFile, __LINE__);
298 xfree(pat->signature, pszSrcFile, __LINE__);
299 xfree(pat->startlist, pszSrcFile, __LINE__);
300 xfree(pat->endlist, pszSrcFile, __LINE__);
301 xfree(pat->exwdirs, pszSrcFile, __LINE__);
302 xfree(pat->test, pszSrcFile, __LINE__);
303 xfree(pat->createrecurse, pszSrcFile, __LINE__);
304 xfree(pat->createwdirs, pszSrcFile, __LINE__);
305 xfree(pat->movewdirs, pszSrcFile, __LINE__);
306 free(pat);
307 }
308}
309
310static UINT cur_line_num; // Input file line counter
311
312//=== get_line_strip_comments() read line, strip comments and whitespace ===
313
314static PSZ get_line_strip_comments(PSZ pszIn, FILE * fp)
315{
316 PSZ psz = xfgets(pszIn, ARCHIVER_LINE_BYTES, fp, pszSrcFile, __LINE__);
317 PSZ psz2;
318
319 if (psz) {
320 cur_line_num++;
321 psz2 = strchr(pszIn, ';');
322 if (psz2)
323 *psz2 = 0; // Chop comment
324 bstripcr(pszIn); // Strip leading white and trailing white and CR/LF
325
326 }
327 return psz;
328}
329
330//=== get_line_strip_white() read line, strip whitespace ===
331
332static PSZ get_line_strip_white(PSZ pszIn, FILE * fp)
333{
334 PSZ psz =
335 xfgets_bstripcr(pszIn, ARCHIVER_LINE_BYTES, fp, pszSrcFile, __LINE__);
336
337 if (psz)
338 cur_line_num++;
339
340 return psz;
341}
342
343//=== load_archivers() load or reload archive definitions from archiver.bb2 ===
344
345INT load_archivers(VOID)
346{
347 FILE *fp;
348 CHAR sz[ARCHIVER_LINE_BYTES + 1];
349 CHAR *psz;
350 ARC_TYPE *pat = NULL;
351 ARC_TYPE *patLast = NULL;
352 UINT lines_per_arcsig = LINES_PER_ARCSIG;
353 UINT per_sig_comment_line_num = 0;
354 INT i;
355 CHAR *moder = "r";
356
357 // Free current signatures
358 if (arcsighead) {
359 for (pat = arcsighead; pat;) {
360 patLast = pat;
361 pat = pat->next;
362 free_arc_type(patLast);
363 }
364 arcsighead = NULL;
365 }
366
367 arcsigsmodified = FALSE;
368 arcsigs_header_lines = 0;
369 arcsigs_trailer_line_num = 0;
370
371 //DosEnterCritSec(); //GKY 11-29-08
372 DosRequestMutexSem(hmtxFM2Globals, SEM_INDEFINITE_WAIT);
373 psz = searchpath(PCSZ_ARCHIVERBB2);
374 if (!psz || !*psz) {
375 DosReleaseMutexSem(hmtxFM2Globals);
376 //DosExitCritSec();
377 return -1;
378 }
379 fp = xfsopen(psz, moder, SH_DENYWR, pszSrcFile, __LINE__, TRUE);
380 DosReleaseMutexSem(hmtxFM2Globals);
381 //DosExitCritSec();
382 if (!fp)
383 return -2;
384 strcpy(archiverbb2, psz); // Remember full path
385
386 cur_line_num = 0;
387
388 // Line 1 must contain number of lines per signature definition
389 if (!get_line_strip_comments(sz, fp)) {
390 fclose(fp);
391 return -3;
392 }
393 if (*sz)
394 lines_per_arcsig = atoi(sz);
395 if (!*sz || lines_per_arcsig < LINES_PER_ARCSIG) {
396 fclose(fp); // 25 Aug 07 SHL
397 return -3;
398 }
399
400 // Parse rest of file
401 // 1st non-blank line starts definition
402 // Need to determine header size and start of trailer
403
404 while (!feof(fp)) {
405 // If reading header
406 if (!arcsigs_header_lines) {
407 // Reading header - find header size and start of signtures
408 if (!get_line_strip_white(sz, fp))
409 break; // Unexpected EOF
410 if (stristr(sz, "-- Current Archivers --")) {
411 arcsigs_header_lines = cur_line_num;
412 continue;
413 }
414 if (!*sz || *sz == ';')
415 continue; // Header comment or blank line
416 else {
417 // Not a comment, must be start of signatures
418 PSZ psz2 = strchr(sz, ';');
419
420 if (psz2) {
421 *psz2 = 0; // Chop trailing comment
422 bstripcr(sz); // Strip leading white and trailing white and CR/LF
423 }
424 arcsigs_header_lines = cur_line_num - 1;
425 }
426 }
427 else {
428 // Reading defintiions
429 if (!get_line_strip_comments(sz, fp))
430 break; // EOF
431 }
432
433 // fixme to avoid allocating empty fields
434
435 // Remember start of per sig comments for next definition
436 if (per_sig_comment_line_num == 0)
437 per_sig_comment_line_num = cur_line_num;
438
439 if (*sz) {
440 // At start of defintion
441
442 pat = xmallocz(sizeof(ARC_TYPE), pszSrcFile, __LINE__);
443 if (!pat)
444 break;
445 pat->id = xstrdup(sz, pszSrcFile, __LINE__);
446
447 pat->comment_line_num = per_sig_comment_line_num;
448 pat->defn_line_num = cur_line_num;
449
450 if (!get_line_strip_comments(sz, fp)) // line 2 - extension
451 break;
452 if (*sz)
453 pat->ext = xstrdup(sz, pszSrcFile, __LINE__);
454 else
455 pat->ext = NULL;
456 if (!get_line_strip_comments(sz, fp)) // line 3 - offset to signature
457 break;
458 pat->file_offset = atol(sz);
459 if (!get_line_strip_comments(sz, fp)) // line 4 - list command
460 break;
461 if (*sz)
462 pat->list = xstrdup(sz, pszSrcFile, __LINE__);
463 else
464 pat->list = NULL;
465 if (!pat->list)
466 break; // Must have list command - fixme to complain
467 if (!get_line_strip_comments(sz, fp)) // line 5
468 break;
469 if (*sz)
470 pat->extract = xstrdup(sz, pszSrcFile, __LINE__);
471 else
472 pat->extract = NULL;
473 if (!get_line_strip_comments(sz, fp)) // line 6
474 break;
475 if (*sz)
476 pat->exwdirs = xstrdup(sz, pszSrcFile, __LINE__);
477 else
478 pat->exwdirs = NULL;
479 if (!get_line_strip_comments(sz, fp)) // line 7
480 break;
481 if (*sz)
482 pat->test = xstrdup(sz, pszSrcFile, __LINE__);
483 else
484 pat->test = NULL;
485 if (!get_line_strip_comments(sz, fp)) // line 8
486 break;
487 if (*sz)
488 pat->create = xstrdup(sz, pszSrcFile, __LINE__);
489 else
490 pat->create = NULL;
491 if (!get_line_strip_comments(sz, fp)) // line 9
492 break;
493 if (*sz)
494 pat->createwdirs = xstrdup(sz, pszSrcFile, __LINE__);
495 else
496 pat->createwdirs = NULL;
497 if (!get_line_strip_comments(sz, fp)) // line 10
498 break;
499 if (*sz)
500 pat->createrecurse = xstrdup(sz, pszSrcFile, __LINE__);
501 else
502 pat->createrecurse = NULL;
503 if (!get_line_strip_comments(sz, fp)) // line 11
504 break;
505 if (*sz)
506 pat->move = xstrdup(sz, pszSrcFile, __LINE__);
507 else
508 pat->move = NULL;
509 if (!get_line_strip_comments(sz, fp)) // line 12
510 break;
511 if (*sz)
512 pat->movewdirs = xstrdup(sz, pszSrcFile, __LINE__);
513 else
514 pat->movewdirs = NULL;
515 if (!get_line_strip_comments(sz, fp)) // line 13
516 break;
517 if (*sz)
518 pat->delete = xstrdup(sz, pszSrcFile, __LINE__);
519 else
520 pat->delete = NULL;
521 if (!get_line_strip_white(sz, fp)) // line 14
522 break;
523 i = literal(sz); // Translate \ escapes
524 if (i) {
525 pat->siglen = i;
526 pat->signature = xmalloc(i, pszSrcFile, __LINE__);
527 if (!pat->signature)
528 break;
529 memcpy(pat->signature, sz, i); // signature may not be a string
530 }
531 else {
532 pat->siglen = 0;
533 pat->signature = NULL;
534 }
535 if (!get_line_strip_white(sz, fp)) // line 15
536 break;
537 if (*sz)
538 pat->startlist = xstrdup(sz, pszSrcFile, __LINE__);
539 else
540 pat->startlist = NULL;
541 if (!get_line_strip_white(sz, fp)) // line 16
542 break;
543 if (*sz)
544 pat->endlist = xstrdup(sz, pszSrcFile, __LINE__);
545 else
546 pat->endlist = NULL;
547 if (!get_line_strip_comments(sz, fp)) // line 17
548 break;
549 pat->osizepos = atoi(sz);
550 if (!get_line_strip_comments(sz, fp)) // line 18
551 break;
552 pat->nsizepos = atoi(sz);
553 if (!get_line_strip_comments(sz, fp)) // line 19
554 break;
555 pat->fdpos = atoi(sz);
556 psz = strchr(sz, ',');
557 if (psz) {
558 psz++;
559 pat->datetype = atoi(psz);
560 }
561 if (!get_line_strip_comments(sz, fp)) // line 20
562 break;
563 pat->fdflds = atoi(sz);
564 if (!get_line_strip_comments(sz, fp)) // line 21
565 break;
566 pat->fnpos = atoi(sz);
567 psz = strchr(sz, ',');
568 if (psz) {
569 psz++;
570 pat->nameislast = (BOOL) (*psz && atol(psz) == 0) ? FALSE : TRUE;
571 psz = strchr(psz, ',');
572 if (psz) {
573 psz++;
574 pat->nameisnext = (BOOL) (*psz && atol(psz) == 0) ? FALSE : TRUE;
575 psz = strchr(psz, ',');
576 if (psz) {
577 psz++;
578 pat->nameisfirst = (BOOL) (*psz && atol(psz) == 0) ? FALSE : TRUE;
579 }
580 }
581 }
582 // Ignore unknown lines - must be newer file format
583 for (i = LINES_PER_ARCSIG; i < lines_per_arcsig; i++) {
584 if (!get_line_strip_comments(sz, fp))
585 break; // Unexpected EOF - fixme to complain
586 }
587
588 // Add to list, assume next and prev already NULL
589 if (!arcsighead)
590 arcsighead = patLast = pat;
591 else {
592 patLast->next = pat;
593 pat->prev = patLast;
594 patLast = pat;
595 }
596 pat = NULL; // Done with this defintion
597
598 arcsigs_trailer_line_num = cur_line_num + 1; // In case this is last defintion
599 per_sig_comment_line_num = 0;
600 } // if got definition
601
602 } // while more lines
603
604 fclose(fp);
605
606 free_arc_type(pat); // In case partial definition in progress
607
608 if (!arcsighead)
609 return -4;
610
611 arcsigsloaded = TRUE;
612
613 return 0;
614}
615
616#define TEST_DRAG 0 // fixme to be gone or to work
617
618static MRESULT EXPENTRY SDlgListboxSubclassProc(HWND hwnd, ULONG msg,
619 MPARAM mp1, MPARAM mp2)
620{
621 PFNWP pfnOldProc = (PFNWP) WinQueryWindowPtr(hwnd, QWL_USER);
622
623 PDRAGITEM pDItem;
624 PDRAGINFO pDInfo;
625 BOOL ok;
626
627 static BOOL emphasized = FALSE;
628 static PSZ DRMDRF_LBOX = "<DRM_LBOX,DRF_UNKNOWN>";
629 static PSZ DRM_LBOX = "DRM_LBOX";
630
631 switch (msg) {
632 case WM_BEGINDRAG:
633 {
634 LONG cur_ndx;
635 DRAGITEM ditem;
636 DRAGIMAGE dimage;
637 HWND hwndDrop;
638
639 // fprintf(stderr, "SDlgListboxSubclassProc: BEGINDRAG\n");
640 cur_ndx = WinQueryLboxSelectedItem(hwnd);
641
642 if (cur_ndx != LIT_NONE) {
643 pDInfo = DrgAllocDraginfo(1);
644 if (pDInfo) {
645 pDInfo->usOperation = DO_DEFAULT;
646 pDInfo->hwndSource = hwnd;
647
648 memset(&ditem, 0, sizeof(DRAGITEM));
649 ditem.hwndItem = hwnd;
650 ditem.ulItemID = 1;
651 ditem.hstrType = DrgAddStrHandle(DRT_UNKNOWN);
652 ditem.hstrRMF = DrgAddStrHandle(DRMDRF_LBOX);
653 ditem.hstrContainerName = DrgAddStrHandle(NullStr);
654 ditem.hstrSourceName = DrgAddStrHandle(NullStr);
655 ditem.hstrTargetName = DrgAddStrHandle(NullStr);
656 // ditem.fsControl = 0;
657 ditem.fsSupportedOps = DO_MOVEABLE;
658
659 memset(&dimage, 0, sizeof(DRAGIMAGE));
660 dimage.cb = sizeof(DRAGIMAGE);
661 dimage.hImage = hptrFile;
662 dimage.cptl = 0;
663 dimage.fl = DRG_ICON;
664 dimage.sizlStretch.cx = 32;
665 dimage.sizlStretch.cy = 32;
666 dimage.cxOffset = -16;
667 dimage.cyOffset = 0;
668 DrgSetDragitem(pDInfo, &ditem, sizeof(DRAGITEM), 0); /* Index of DRAGITEM */
669 hwndDrop = DrgDrag(hwnd, pDInfo, &dimage, 1, /* One DRAGIMAGE */
670 VK_ENDDRAG, NULL);
671 if (!hwndDrop)
672 Win_Error(hwnd, hwnd, pszSrcFile, __LINE__, "DrgDrag");
673
674 DrgFreeDraginfo(pDInfo);
675 // WinSetWindowPos(hwnd,HWND_TOP,0,0,0,0,SWP_ACTIVATE);
676 }
677 }
678 break;
679 }
680
681 case DM_DRAGOVER:
682 ok = FALSE;
683 if (!emphasized) {
684 POINTL ptl;
685 POINTL ptl2;
686
687 emphasized = TRUE;
688 ptl.x = SHORT1FROMMP(mp2);
689 ptl.y = SHORT2FROMMP(mp2);
690 ptl2 = ptl;
691 WinMapWindowPoints(HWND_DESKTOP, hwnd, &ptl2, 1);
692 // fprintf(stderr, "DRAGOVER mapped x y %d %d to %d %d\n", ptl.x, ptl.y, ptl2.x, ptl2.y);
693 WinPostMsg(hwnd, WM_BUTTON1CLICK,
694 MPFROM2SHORT((SHORT) ptl2.x, (SHORT) ptl2.y),
695 MPFROM2SHORT(HT_NORMAL, KC_NONE));
696 // fprintf(stderr, "DRAGOVER posted 0x%x WM_BUTTON1CLICK x y %d %d\n", hwnd, ptl2.x, ptl2.y);
697 }
698 pDInfo = (PDRAGINFO) mp1; /* Get DRAGINFO pointer */
699 if (pDInfo) {
700 if (!DrgAccessDraginfo(pDInfo)) {
701 Win_Error(HWND_DESKTOP, HWND_DESKTOP, pszSrcFile, __LINE__,
702 PCSZ_DRGACCESSDRAGINFO);
703 }
704 else {
705 pDItem = DrgQueryDragitemPtr(pDInfo, 0);
706 /* Check valid rendering mechanisms and data format */
707 ok = DrgVerifyRMF(pDItem, DRM_LBOX, NULL);
708 DrgFreeDraginfo(pDInfo);
709 }
710 }
711 return ok ? MRFROM2SHORT(DOR_DROP, DO_MOVE) :
712 MRFROM2SHORT(DOR_NEVERDROP, 0);
713
714 case DM_DRAGLEAVE:
715 if (emphasized) {
716 emphasized = FALSE;
717 // fixme to draw listbox item emphasized
718 // DrawTargetEmphasis(hwnd, emphasized);
719 // fprintf(stderr, "DRAGLEAVE\n");
720 fflush(stderr);
721 }
722 return 0;
723
724 case DM_DROPHELP:
725 DropHelp(mp1, mp2, hwnd, "fixme to give some help");
726 return 0;
727
728 case DM_DROP:
729 ok = FALSE;
730 if (emphasized) {
731 emphasized = FALSE;
732 // DrawTargetEmphasis(hwnd, emphasized);
733 }
734 pDInfo = (PDRAGINFO) mp1; /* Get DRAGINFO pointer */
735 if (pDInfo) {
736 if (!DrgAccessDraginfo(pDInfo)) {
737 Win_Error(HWND_DESKTOP, HWND_DESKTOP, pszSrcFile, __LINE__,
738 PCSZ_DRGACCESSDRAGINFO);
739 }
740 else {
741 pDItem = DrgQueryDragitemPtr(pDInfo, 0);
742 if (!pDItem)
743 Win_Error(hwnd, hwnd, pszSrcFile, __LINE__, "DM_DROP");
744 /* Check valid rendering mechanisms and data */
745 ok = DrgVerifyRMF(pDItem, DRM_LBOX, NULL)
746 && ~pDItem->fsControl & DC_PREPARE;
747 if (ok) {
748 // ret = FullDrgName(pDItem,buffer,buflen);
749 /* note: targetfail is returned to source for all items */
750 DrgSendTransferMsg(pDInfo->hwndSource, DM_ENDCONVERSATION,
751 MPFROMLONG(pDItem->ulItemID),
752 MPFROMLONG(DMFL_TARGETSUCCESSFUL));
753 }
754 FreeDragInfoData(hwnd, pDInfo);
755 }
756 }
757 return 0;
758 } // switch
759 return pfnOldProc ? pfnOldProc(hwnd, msg, mp1, mp2) :
760 WinDefWindowProc(hwnd, msg, mp1, mp2);
761}
762
763//=== SBoxDlgProc() Select archiver to use or edit, supports list reorder too ===
764
765static PSZ pszCantFindMsg = "Can't find item %d";
766
767MRESULT EXPENTRY SBoxDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
768{
769 ARC_TYPE **ppatReturn; // Where to return selected archiver
770 ARC_TYPE *pat;
771 SHORT sSelect;
772 SHORT sItemCount;
773 CHAR szItemText[256];
774 CHAR szPCItemText[256]; // Parent or child item text
775 SHORT i;
776 BOOL fShowAll;
777
778 static SHORT sLastSelect = LIT_NONE;
779
780 switch (msg) {
781 case WM_INITDLG:
782 if (!arcsigsloaded)
783 load_archivers();
784 if (!(ARC_TYPE **) mp2) {
785 Runtime_Error(pszSrcFile, __LINE__, NULL);
786 WinDismissDlg(hwnd, 0);
787 break;
788 }
789 /* Passed arg points to where to return selected archiver definition
790 * On input arg value controls selection list content
791 * If non-NULL, dup names are suppressed
792 * If NULL, all definitions are shown
793 */
794 ppatReturn = (ARC_TYPE **) mp2;
795 fShowAll = *ppatReturn == NULL;
796 if (*ppatReturn)
797 *ppatReturn = arcsighead; // Preset to first
798 WinSetWindowPtr(hwnd, QWL_USER, (PVOID) ppatReturn);
799 fill_listbox(hwnd, fShowAll, sLastSelect);
800
801#ifdef TEST_DRAG // fixme
802 {
803 HWND hwnd2 = WinWindowFromID(hwnd, ASEL_LISTBOX);
804 PFNWP pfn = WinSubclassWindow(hwnd2,
805 SDlgListboxSubclassProc);
806
807 WinSetWindowPtr(hwnd2, QWL_USER, (PVOID) pfn);
808 }
809#endif // TEST_DRAG fixme
810
811 break;
812
813 case WM_COMMAND:
814 ppatReturn = (ARC_TYPE **) WinQueryWindowPtr(hwnd, QWL_USER);
815 switch (SHORT1FROMMP(mp1)) {
816 case DID_OK:
817 sSelect = (SHORT) WinSendDlgItemMsg(hwnd,
818 ASEL_LISTBOX,
819 LM_QUERYSELECTION,
820 MPFROMSHORT(LIT_FIRST), MPVOID);
821 if (sSelect == LIT_NONE) {
822 Runtime_Error(pszSrcFile, __LINE__, "list empty");
823 return 0;
824 }
825 pat = arcsighead;
826 if (*ppatReturn) {
827 // If dups hidden, find archiver with matching id
828 *szItemText = 0;
829 WinSendDlgItemMsg(hwnd, ASEL_LISTBOX, LM_QUERYITEMTEXT,
830 MPFROM2SHORT(sSelect, 255), MPFROMP(szItemText));
831 if (!*szItemText)
832 pat = NULL;
833 else {
834 for (; pat; pat = pat->next) {
835 if (pat->id && !strcmp(szItemText, pat->id))
836 break; // Found it
837 }
838 }
839 }
840 else {
841 // If dups not hidden, lookup by count
842 for (i = 0; pat && i < sSelect; i++, pat = pat->next) ; // Scan
843 }
844 if (pat && (!*ppatReturn || (pat->id && pat->extract && pat->create))) {
845 *ppatReturn = pat;
846 }
847 else {
848 Runtime_Error(pszSrcFile, __LINE__, "no match");
849 // Refuse to select
850 WinSendDlgItemMsg(hwnd, ASEL_LISTBOX, LM_SELECTITEM,
851 MPFROMSHORT(LIT_NONE), FALSE);
852 return 0;
853 }
854 PrfWriteProfileData(fmprof, appname, "LastArchiver", &sSelect, sizeof(SHORT));
855 sLastSelect = sSelect;
856 WinDismissDlg(hwnd, TRUE);
857 return 0;
858
859 case DID_CANCEL:
860 if (arcsigsmodified) {
861 if (saymsg(MB_YESNO,
862 hwnd,
863 GetPString(IDS_ADCHANGESINMEMTEXT),
864 GetPString(IDS_ADREWRITETEXT), NullStr) == MBID_YES) {
865 PSZ ab2 = searchpath(PCSZ_ARCHIVERBB2); // Rewrite without prompting
866
867 rewrite_archiverbb2(ab2);
868 }
869 }
870 sSelect = (SHORT) WinSendDlgItemMsg(hwnd,
871 ASEL_LISTBOX,
872 LM_QUERYSELECTION,
873 MPFROMSHORT(LIT_FIRST), MPVOID);
874 if (sSelect != LIT_NONE) {
875 sLastSelect = sSelect;
876 PrfWriteProfileData(fmprof, appname, "LastArchiver", &sSelect, sizeof(SHORT));
877 }
878 *ppatReturn = NULL;
879 PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID); // fixme to understand why needed
880 return 0;
881
882 case ASEL_PB_ADD:
883 sSelect = (SHORT) WinSendDlgItemMsg(hwnd,
884 ASEL_LISTBOX,
885 LM_QUERYSELECTION,
886 MPFROMSHORT(LIT_FIRST), MPVOID);
887 if (sSelect != LIT_NONE) {
888 ARCDUMP ad;
889
890 memset(&ad, 0, sizeof(ARCDUMP));
891 ad.info = xmallocz(sizeof(ARC_TYPE), pszSrcFile, __LINE__);
892 if (ad.info) {
893 if (!WinDlgBox(HWND_DESKTOP,
894 hwnd,
895 ArcReviewDlgProc,
896 FM3ModHandle, AD_FRAME, MPFROMP(&ad))) {
897 free(ad.info);
898 }
899 else {
900 // Find self - assume all archivers listed since we are editing
901 for (i = 0, pat = arcsighead; pat && i < sSelect; pat = pat->next, i++) ; // Find self
902
903 if (!pat) {
904 if (arcsighead)
905 Runtime_Error(pszSrcFile, __LINE__, pszCantFindMsg, sSelect);
906 else
907 arcsighead = ad.info;
908 }
909 else {
910 // Insert before
911 if (pat->prev) {
912 ad.info->next = pat;
913 ad.info->prev = pat->prev;
914 pat->prev->next = ad.info;
915 pat->prev = ad.info;
916 }
917 else {
918 arcsighead = ad.info;
919 ad.info->next = pat;
920 pat->prev = ad.info;
921 }
922 }
923 WinSendDlgItemMsg(hwnd, ASEL_LISTBOX, LM_INSERTITEM,
924 MPFROM2SHORT(sSelect, 0),
925 MPFROMP(ad.info->id ? ad.info->id : "?"));
926 WinSendDlgItemMsg(hwnd, ASEL_LISTBOX, LM_SELECTITEM,
927 MPFROMSHORT(sSelect - 1), MPFROMSHORT(TRUE));
928 arcsigsmodified = TRUE;
929 }
930 }
931 }
932 return 0;
933 case ASEL_PB_DELETE:
934 sSelect = (SHORT) WinSendDlgItemMsg(hwnd,
935 ASEL_LISTBOX,
936 LM_QUERYSELECTION,
937 MPFROMSHORT(LIT_FIRST), MPVOID);
938 if (sSelect != LIT_NONE) {
939 // Find self - assume all archivers listed since we are editing
940 for (i = 0, pat = arcsighead; pat && i < sSelect; pat = pat->next, i++) ; // Find self
941
942 if (!pat)
943 Runtime_Error(pszSrcFile, __LINE__, pszCantFindMsg, sSelect);
944 else {
945 // Delete current
946 if (pat->prev) {
947 pat->prev->next = pat->next;
948 if (pat->next)
949 pat->next->prev = pat->prev;
950 }
951 else {
952 arcsighead = pat->next;
953 if (pat->next)
954 pat->next->prev = pat->prev;
955 }
956 }
957 free_arc_type(pat);
958 arcsigsmodified = TRUE;
959 WinSendDlgItemMsg(hwnd, ASEL_LISTBOX, LM_DELETEITEM,
960 MPFROM2SHORT(sSelect, 0), MPVOID);
961 sItemCount =
962 (SHORT) WinSendDlgItemMsg(hwnd, ASEL_LISTBOX, LM_QUERYITEMCOUNT,
963 MPVOID, MPVOID);
964 if (sSelect >= sItemCount)
965 sSelect--;
966 if (sSelect >= 0) {
967 WinSendDlgItemMsg(hwnd, ASEL_LISTBOX, LM_SELECTITEM,
968 MPFROMSHORT(sSelect), MPFROMSHORT(TRUE));
969 }
970 }
971 return 0;
972 case ASEL_PB_UP:
973 sSelect = (SHORT) WinSendDlgItemMsg(hwnd,
974 ASEL_LISTBOX,
975 LM_QUERYSELECTION,
976 MPFROMSHORT(LIT_FIRST), MPVOID);
977 if (sSelect != LIT_NONE && sSelect > 0) {
978 // Find self - assume all archivers listed since we are editing
979 for (i = 0, pat = arcsighead; pat && i < sSelect; pat = pat->next, i++) ; // Find self
980 if (!pat || !pat->prev)
981 Runtime_Error(pszSrcFile, __LINE__, pszCantFindMsg, sSelect);
982 else {
983 ARC_TYPE *patGDad;
984 ARC_TYPE *patDad;
985 ARC_TYPE *patChild;
986
987 patChild = pat->next;
988 patDad = pat->prev;
989 patGDad = patDad->prev;
990 patDad->next = patChild;
991 if (patChild)
992 patChild->prev = patDad;
993 patDad->prev = pat;
994 pat->next = patDad;
995 if (patGDad) {
996 patGDad->next = pat;
997 pat->prev = patGDad;
998 }
999 else {
1000 arcsighead = pat;
1001 pat->prev = NULL;
1002 }
1003
1004 WinSendDlgItemMsg(hwnd, ASEL_LISTBOX, LM_QUERYITEMTEXT,
1005 MPFROM2SHORT(sSelect, 255), MPFROMP(szItemText));
1006 WinSendDlgItemMsg(hwnd, ASEL_LISTBOX, LM_QUERYITEMTEXT,
1007 MPFROM2SHORT(sSelect - 1, 255),
1008 MPFROMP(szPCItemText));
1009 WinSendDlgItemMsg(hwnd, ASEL_LISTBOX, LM_SETITEMTEXT,
1010 MPFROMSHORT(sSelect), MPFROMP(szPCItemText));
1011 WinSendDlgItemMsg(hwnd, ASEL_LISTBOX, LM_SETITEMTEXT,
1012 MPFROMSHORT(sSelect - 1), MPFROMP(szItemText));
1013 WinSendDlgItemMsg(hwnd, ASEL_LISTBOX, LM_SELECTITEM,
1014 MPFROMSHORT(sSelect - 1), MPFROMSHORT(TRUE));
1015 arcsigsmodified = TRUE;
1016 }
1017 }
1018 return 0;
1019 case ASEL_PB_DOWN:
1020 sSelect =
1021 (SHORT) WinSendDlgItemMsg(hwnd, ASEL_LISTBOX, LM_QUERYSELECTION,
1022 MPFROMSHORT(LIT_FIRST), MPVOID);
1023 sItemCount =
1024 (SHORT) WinSendDlgItemMsg(hwnd, ASEL_LISTBOX, LM_QUERYITEMCOUNT,
1025 MPVOID, MPVOID);
1026 if (sSelect != LIT_NONE && sSelect < sItemCount - 1) {
1027 // Find self - assume all archivers listed since we are editing
1028 for (i = 0, pat = arcsighead; pat && i < sSelect; pat = pat->next, i++) ; // Find self
1029 if (!pat || !pat->next)
1030 Runtime_Error(pszSrcFile, __LINE__, "Can't find item %d of %d",
1031 sSelect, sItemCount);
1032 else {
1033 ARC_TYPE *patDad;
1034 ARC_TYPE *patChild;
1035
1036 patDad = pat->prev;
1037 patChild = pat->next;
1038 pat->next = patChild->next;
1039 patChild->next = pat;
1040 pat->prev = patChild;
1041 patChild->prev = patDad;
1042 if (patDad) {
1043 patDad->next = patChild;
1044 patChild->prev = patDad;
1045 }
1046 else {
1047 arcsighead = patChild;
1048 patChild->prev = NULL;
1049 }
1050
1051 WinSendDlgItemMsg(hwnd, ASEL_LISTBOX, LM_QUERYITEMTEXT,
1052 MPFROM2SHORT(sSelect, 255), MPFROMP(szItemText));
1053 WinSendDlgItemMsg(hwnd, ASEL_LISTBOX, LM_QUERYITEMTEXT,
1054 MPFROM2SHORT(sSelect + 1, 255),
1055 MPFROMP(szPCItemText));
1056 WinSendDlgItemMsg(hwnd, ASEL_LISTBOX, LM_SETITEMTEXT,
1057 MPFROMSHORT(sSelect), MPFROMP(szPCItemText));
1058 WinSendDlgItemMsg(hwnd, ASEL_LISTBOX, LM_SETITEMTEXT,
1059 MPFROMSHORT(sSelect + 1), MPFROMP(szItemText));
1060 WinSendDlgItemMsg(hwnd, ASEL_LISTBOX, LM_SELECTITEM,
1061 MPFROMSHORT(sSelect + 1), MPFROMSHORT(TRUE));
1062 arcsigsmodified = TRUE;
1063 }
1064 }
1065 return 0;
1066
1067 case ASEL_PB_REVERT:
1068 // Reload without checking in case changed outside
1069 sSelect =
1070 (SHORT) WinSendDlgItemMsg(hwnd, ASEL_LISTBOX, LM_QUERYSELECTION,
1071 MPFROMSHORT(LIT_FIRST), MPVOID);
1072 load_archivers();
1073 fill_listbox(hwnd, TRUE, sSelect);
1074 return 0;
1075
1076 case IDM_HELP:
1077 if (hwndHelp) {
1078 WinSendMsg(hwndHelp, HM_DISPLAY_HELP, MPFROM2SHORT(HELP_EDITARC, 0), // fixme to be HELP_SELARC
1079 MPFROMSHORT(HM_RESOURCEID));
1080 }
1081 }
1082 return 0; // WM_COMMAND
1083
1084 case WM_CONTROL:
1085 if (SHORT1FROMMP(mp1) == ASEL_LISTBOX && SHORT2FROMMP(mp1) == LN_ENTER)
1086 PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(DID_OK, 0), MPVOID);
1087 return 0;
1088
1089 case WM_CLOSE:
1090 WinDismissDlg(hwnd, FALSE);
1091 return 0;
1092
1093 default:
1094 break;
1095 }
1096 return WinDefDlgProc(hwnd, msg, mp1, mp2);
1097}
1098
1099/*
1100 see archiver.tmp
1101 02-08-96 23:55 1
1102 8 Feb 96 23:55:32 2
1103 8 Feb 96 11:55p 3
1104 96-02-08 23:55:32 4
1105 31-02-98 23:55 5
1106 */
1107
1108BOOL ArcDateTime(CHAR * dt, INT type, CDATE * cdate, CTIME * ctime)
1109{
1110 INT x;
1111 BOOL ret = FALSE;
1112 CHAR *p, *pp, *pd;
1113
1114 if (dt && cdate && ctime) {
1115 memset(cdate, 0, sizeof(CDATE));
1116 memset(ctime, 0, sizeof(CTIME));
1117 if (type) {
1118 p = dt;
1119 while (*p && *p == ' ')
1120 p++;
1121 pd = dt;
1122 switch (type) {
1123 case 1:
1124 cdate->month = atoi(pd);
1125 p = to_delim(pd, "-/.");
1126 if (p) {
1127 p++;
1128 cdate->day = atoi(p);
1129 pd = p;
1130 p = to_delim(pd, "-/.");
1131 if (p) {
1132 p++;
1133 cdate->year = atoi(p);
1134 if (cdate->year > 80 && cdate->year < 1900)
1135 cdate->year += 1900;
1136 else if (cdate->year < 1900)
1137 cdate->year += 2000;
1138 ret = TRUE;
1139 p = strchr(p, ' ');
1140 if (p) {
1141 while (*p && *p == ' ')
1142 p++;
1143 ctime->hours = atoi(p);
1144 p = to_delim(pd, ":.");
1145 if (p) {
1146 p++;
1147 ctime->minutes = atoi(p);
1148 p = to_delim(pd, ":.");
1149 if (p) {
1150 p++;
1151 ctime->seconds = atoi(p);
1152 }
1153 }
1154 }
1155 }
1156 }
1157 break;
1158
1159 case 2:
1160 cdate->day = atoi(p);
1161 p = strchr(p, ' ');
1162 if (p) {
1163 p++;
1164 for (x = 0; x < 12; x++) {
1165 if (!strnicmp(p, GetPString(IDS_JANUARY + x), 3))
1166 break;
1167 }
1168 if (x < 12) {
1169 cdate->month = x;
1170 p = strchr(p, ' ');
1171 if (p) {
1172 p++;
1173 cdate->year = atoi(p);
1174 if (cdate->year > 80 && cdate->year < 1900)
1175 cdate->year += 1900;
1176 else if (cdate->year < 1900)
1177 cdate->year += 2000;
1178 ret = TRUE;
1179 p = strchr(p, ' ');
1180 if (p) {
1181 while (*p && *p == ' ')
1182 p++;
1183 ctime->hours = atoi(p);
1184 p = to_delim(pd, ":.");
1185 if (p) {
1186 p++;
1187 ctime->minutes = atoi(p);
1188 p = to_delim(pd, ":.");
1189 if (p) {
1190 p++;
1191 ctime->seconds = atoi(p);
1192 }
1193 }
1194 }
1195 }
1196 }
1197 }
1198 break;
1199
1200 case 3:
1201 cdate->day = atoi(p);
1202 p = strchr(p, ' ');
1203 if (p) {
1204 p++;
1205 for (x = 0; x < 12; x++) {
1206 if (!strnicmp(p, GetPString(IDS_JANUARY + x), 3))
1207 break;
1208 }
1209 if (x < 12) {
1210 cdate->month = x;
1211 p = strchr(p, ' ');
1212 if (p) {
1213 p++;
1214 cdate->year = atoi(p);
1215 if (cdate->year > 80 && cdate->year < 1900)
1216 cdate->year += 1900;
1217 else if (cdate->year < 1900)
1218 cdate->year += 2000;
1219 ret = TRUE;
1220 p = strchr(p, ' ');
1221 if (p) {
1222 while (*p && *p == ' ')
1223 p++;
1224 ctime->hours = atoi(p);
1225 p = to_delim(pd, ":.");
1226 if (p) {
1227 p++;
1228 pp = p;
1229 ctime->minutes = atoi(p);
1230 p = to_delim(pd, ":.");
1231 if (p) {
1232 p++;
1233 ctime->seconds = atoi(p);
1234 p += 2;
1235 if (toupper(*p) == 'P')
1236 ctime->hours += 12;
1237 }
1238 else {
1239 p = pp;
1240 p += 2;
1241 if (toupper(*p) == 'P')
1242 ctime->hours += 12;
1243 }
1244 }
1245 }
1246 }
1247 }
1248 }
1249 break;
1250
1251 case 4:
1252 cdate->year = atoi(p);
1253 if (cdate->year > 80 && cdate->year < 1900)
1254 cdate->year += 1900;
1255 else if (cdate->year < 1900)
1256 cdate->year += 2000;
1257 p = to_delim(pd, "-/.");
1258 if (p) {
1259 p++;
1260 cdate->month = atoi(p);
1261 pd = p;
1262 p = to_delim(pd, "-/.");
1263 if (p) {
1264 p++;
1265 cdate->day = atoi(p);
1266 ret = TRUE;
1267 p = strchr(p, ' ');
1268 if (p) {
1269 while (*p && *p == ' ')
1270 p++;
1271 ctime->hours = atoi(p);
1272 p = to_delim(pd, ":.");
1273 if (p) {
1274 p++;
1275 ctime->minutes = atoi(p);
1276 p = to_delim(pd, ":.");
1277 if (p) {
1278 p++;
1279 ctime->seconds = atoi(p);
1280 }
1281 }
1282 }
1283 }
1284 }
1285 break;
1286
1287 case 5:
1288 cdate->day = atoi(pd);
1289 p = to_delim(pd, "-/.");
1290 if (p) {
1291 p++;
1292 cdate->month = atoi(p);
1293 pd = p;
1294 p = to_delim(pd, "-/.");
1295 if (p) {
1296 p++;
1297 cdate->year = atoi(p);
1298 if (cdate->year > 80 && cdate->year < 1900)
1299 cdate->year += 1900;
1300 else if (cdate->year < 1900)
1301 cdate->year += 2000;
1302 ret = TRUE;
1303 p = strchr(p, ' ');
1304 if (p) {
1305 while (*p && *p == ' ')
1306 p++;
1307 ctime->hours = atoi(p);
1308 p = to_delim(pd, ":.");
1309 if (p) {
1310 p++;
1311 ctime->minutes = atoi(p);
1312 p = to_delim(pd, ":.");
1313 if (p) {
1314 p++;
1315 ctime->seconds = atoi(p);
1316 }
1317 }
1318 }
1319 }
1320 }
1321 break;
1322
1323 default:
1324 break;
1325 }
1326 }
1327 }
1328 return ret;
1329}
1330
1331#pragma alloc_text(MISC9,quick_find_type,find_type)
1332#pragma alloc_text(AVL,load_archivers, get_line_strip_comments, get_line_strip_white, free_archivers)
1333#pragma alloc_text(FMARCHIVE,SBoxDlgProc,SDlgListboxSubclassProc)
1334#pragma alloc_text(ARCCNRS,ArcDateTime)
Note: See TracBrowser for help on using the repository browser.