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