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