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