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