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