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