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