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