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