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