source: trunk/dll/avl.c@ 1616

Last change on this file since 1616 was 1616, checked in by Gregg Young, 14 years ago

Updated a*.c files to Doxygen commenting style. (Ticket 55)

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