[123] | 1 |
|
---|
| 2 | /***********************************************************************
|
---|
| 3 |
|
---|
| 4 | $Id: avl.c 1302 2008-11-30 05:28:52Z 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.
|
---|
[123] | 38 |
|
---|
| 39 | ***********************************************************************/
|
---|
| 40 |
|
---|
[907] | 41 | #include <stdlib.h>
|
---|
| 42 | #include <string.h>
|
---|
| 43 | #include <ctype.h>
|
---|
| 44 | #include <share.h>
|
---|
| 45 |
|
---|
| 46 | #define INCL_DOS
|
---|
[2] | 47 | #define INCL_WIN
|
---|
[306] | 48 | #define INCL_WINSTDDRAG
|
---|
[841] | 49 | #define INCL_LONGLONG
|
---|
[2] | 50 |
|
---|
[1180] | 51 | #include "fm3dll.h"
|
---|
[1220] | 52 | #include "fm3dll2.h" // #define's for UM_*, control id's, etc.
|
---|
[1204] | 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)
|
---|
[2] | 57 | #include "fm3dlg.h"
|
---|
| 58 | #include "fm3str.h"
|
---|
[907] | 59 | #include "avl.h"
|
---|
| 60 | #include "strutil.h" // GetPString
|
---|
| 61 | #include "errutil.h" // Runtime_Error
|
---|
[1158] | 62 | #include "avv.h" // ArcReviewDlgProc, rewrite_archiverbb2
|
---|
[1180] | 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
|
---|
[1039] | 73 | #include "fortify.h"
|
---|
[2] | 74 |
|
---|
[1204] | 75 | // Data definitions
|
---|
[342] | 76 | static PSZ pszSrcFile = __FILE__;
|
---|
[306] | 77 | static void fill_listbox(HWND hwnd, BOOL fShowAll, SHORT sOldSelect);
|
---|
| 78 |
|
---|
[1204] | 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 |
|
---|
[1302] | 86 | #define ARCHIVER_LINE_BYTES 256
|
---|
| 87 |
|
---|
[306] | 88 | //=== quick_find_type() ===
|
---|
[551] | 89 | ARC_TYPE *quick_find_type(CHAR * filespec, ARC_TYPE * topsig)
|
---|
[247] | 90 | {
|
---|
[287] | 91 | ARC_TYPE *info, *found = NULL;
|
---|
| 92 | CHAR *p;
|
---|
[2] | 93 |
|
---|
[306] | 94 | if (!arcsigsloaded)
|
---|
[287] | 95 | load_archivers();
|
---|
| 96 | p = strrchr(filespec, '.');
|
---|
[551] | 97 | if (p) {
|
---|
[287] | 98 | p++;
|
---|
| 99 | info = (topsig) ? topsig : arcsighead;
|
---|
[551] | 100 | while (info) {
|
---|
| 101 | if (info->ext && *(info->ext) && !stricmp(p, info->ext)) {
|
---|
[287] | 102 | found = find_type(filespec, topsig);
|
---|
| 103 | break;
|
---|
| 104 | }
|
---|
[551] | 105 | info = info->next;
|
---|
[2] | 106 | }
|
---|
[287] | 107 | }
|
---|
| 108 | return found;
|
---|
[2] | 109 | }
|
---|
| 110 |
|
---|
[306] | 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 |
|
---|
[551] | 121 | for (pat = arcsighead; pat; pat = pat->next) {
|
---|
[306] | 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 | */
|
---|
[551] | 127 | if (!fShowAll) {
|
---|
[306] | 128 | ARC_TYPE *pat2;
|
---|
| 129 | BOOL isDup = FALSE;
|
---|
[551] | 130 |
|
---|
[306] | 131 | for (pat2 = arcsighead;
|
---|
[551] | 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
|
---|
[306] | 136 | if (isDup)
|
---|
| 137 | continue;
|
---|
| 138 | }
|
---|
| 139 |
|
---|
| 140 | // If caller is editing archivers or entry useful to caller, show in listbox
|
---|
[551] | 141 | if (fShowAll || (pat->id && pat->extract && pat->create)) {
|
---|
[306] | 142 | sSelect = (SHORT) WinSendDlgItemMsg(hwnd, ASEL_LISTBOX, LM_INSERTITEM,
|
---|
| 143 | MPFROM2SHORT(LIT_END, 0),
|
---|
[551] | 144 | MPFROMP(pat->id ? pat->id : "?"));
|
---|
| 145 | if (!found && *szDefArc && pat->id && !strcmp(szDefArc, pat->id)) {
|
---|
[306] | 146 | // Highlight default
|
---|
| 147 | WinSendDlgItemMsg(hwnd, ASEL_LISTBOX, LM_SELECTITEM,
|
---|
| 148 | MPFROMSHORT(sSelect), MPFROMSHORT(TRUE));
|
---|
| 149 | found = TRUE;
|
---|
| 150 | }
|
---|
| 151 | }
|
---|
[551] | 152 | else {
|
---|
[306] | 153 | // Complain about odd entry
|
---|
[551] | 154 | if (!pat->id || !*pat->id) {
|
---|
[306] | 155 | WinSendDlgItemMsg(hwnd, ASEL_LISTBOX, LM_INSERTITEM,
|
---|
| 156 | MPFROM2SHORT(LIT_END, 0),
|
---|
| 157 | MPFROMP(GetPString(IDS_UNKNOWNUNUSABLETEXT)));
|
---|
| 158 | }
|
---|
[551] | 159 | else {
|
---|
[306] | 160 | CHAR s[81];
|
---|
[551] | 161 |
|
---|
| 162 | sprintf(s, "%0.12s %s", pat->id, GetPString(IDS_UNUSABLETEXT));
|
---|
[306] | 163 | WinSendDlgItemMsg(hwnd, ASEL_LISTBOX, LM_INSERTITEM,
|
---|
[551] | 164 | MPFROM2SHORT(LIT_END, 0), MPFROMP(s));
|
---|
[306] | 165 | }
|
---|
| 166 | }
|
---|
[551] | 167 | } // while scanning
|
---|
[306] | 168 |
|
---|
| 169 | // Try to reselect last selection unless user wants default selection
|
---|
[1302] | 170 | if (sOldSelect == LIT_NONE) {
|
---|
| 171 | ULONG size = sizeof(SHORT);
|
---|
| 172 |
|
---|
| 173 | PrfQueryProfileData(fmprof, appname, "LastArchiver", &sOldSelect, &size);
|
---|
| 174 | }
|
---|
[306] | 175 | if (sOldSelect != LIT_NONE && !found) {
|
---|
[551] | 176 | SHORT sItemCount =
|
---|
| 177 | (SHORT) WinSendDlgItemMsg(hwnd, ASEL_LISTBOX, LM_QUERYITEMCOUNT,
|
---|
| 178 | MPVOID, MPVOID);
|
---|
| 179 |
|
---|
[306] | 180 | if (sOldSelect >= sItemCount)
|
---|
| 181 | sOldSelect = sItemCount - 1;
|
---|
| 182 | if (sOldSelect >= 0) {
|
---|
| 183 | WinSendDlgItemMsg(hwnd, ASEL_LISTBOX, LM_SELECTITEM,
|
---|
[551] | 184 | MPFROMSHORT(sOldSelect), MPFROMSHORT(TRUE));
|
---|
[306] | 185 | }
|
---|
| 186 | }
|
---|
| 187 |
|
---|
| 188 | if (found)
|
---|
| 189 | PosOverOkay(hwnd);
|
---|
| 190 | }
|
---|
| 191 |
|
---|
[551] | 192 | ARC_TYPE *find_type(CHAR * filespec, ARC_TYPE * topsig)
|
---|
[247] | 193 | {
|
---|
[287] | 194 | HFILE handle;
|
---|
| 195 | ULONG action;
|
---|
| 196 | ULONG len;
|
---|
| 197 | ULONG l;
|
---|
| 198 | ARC_TYPE *info;
|
---|
| 199 | CHAR *p;
|
---|
[850] | 200 | // CHAR buffer[80];
|
---|
| 201 | CHAR buffer[4096]; // 06 Oct 07 SHL Protect against NTFS defect
|
---|
[2] | 202 |
|
---|
[306] | 203 | if (!arcsigsloaded)
|
---|
[287] | 204 | load_archivers();
|
---|
| 205 | if (!topsig)
|
---|
| 206 | topsig = arcsighead;
|
---|
| 207 | DosError(FERR_DISABLEHARDERR);
|
---|
[844] | 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))
|
---|
[287] | 219 | return NULL;
|
---|
| 220 | // Scan signatures
|
---|
[551] | 221 | for (info = topsig; info; info = info->next) {
|
---|
| 222 | if (info->siglen == 0) {
|
---|
[287] | 223 | // No signature -- check extension
|
---|
| 224 | p = strrchr(filespec, '.');
|
---|
[551] | 225 | if (p) {
|
---|
[287] | 226 | p++;
|
---|
[551] | 227 | if (info->ext && *(info->ext) && !stricmp(p, info->ext))
|
---|
[287] | 228 | break; // Matched
|
---|
| 229 |
|
---|
| 230 | }
|
---|
| 231 | continue; // Next sig
|
---|
| 232 |
|
---|
| 233 | }
|
---|
| 234 | // Try signature match
|
---|
[551] | 235 | l = info->siglen;
|
---|
[287] | 236 | l = min(l, 79);
|
---|
| 237 | if (!DosChgFilePtr(handle,
|
---|
[551] | 238 | abs(info->file_offset),
|
---|
[832] | 239 | (info->file_offset >= 0) ?
|
---|
[551] | 240 | FILE_BEGIN : FILE_END, &len)) {
|
---|
| 241 | if (!DosRead(handle, buffer, l, &len) && len == l) {
|
---|
| 242 | if (!memcmp(info->signature, buffer, l))
|
---|
[287] | 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 */
|
---|
[2] | 251 | }
|
---|
| 252 |
|
---|
[1082] | 253 | # ifdef FORTIFY
|
---|
| 254 |
|
---|
[1029] | 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 |
|
---|
[306] | 283 | //=== free_arc_type() free allocated ARC_TYPE ===
|
---|
[2] | 284 |
|
---|
[1082] | 285 | # endif
|
---|
| 286 |
|
---|
[1029] | 287 | VOID free_arc_type(ARC_TYPE * pat)
|
---|
[306] | 288 | {
|
---|
[551] | 289 | if (pat) {
|
---|
[1009] | 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__);
|
---|
[1039] | 305 | free(pat);
|
---|
[306] | 306 | }
|
---|
| 307 | }
|
---|
| 308 |
|
---|
[551] | 309 | static UINT cur_line_num; // Input file line counter
|
---|
[306] | 310 |
|
---|
[312] | 311 | //=== get_line_strip_comments() read line, strip comments and whitespace ===
|
---|
| 312 |
|
---|
[551] | 313 | static PSZ get_line_strip_comments(PSZ pszIn, FILE * fp)
|
---|
[306] | 314 | {
|
---|
[405] | 315 | PSZ psz = xfgets(pszIn, ARCHIVER_LINE_BYTES, fp, pszSrcFile, __LINE__);
|
---|
[306] | 316 | PSZ psz2;
|
---|
| 317 |
|
---|
[312] | 318 | if (psz) {
|
---|
| 319 | cur_line_num++;
|
---|
[306] | 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 |
|
---|
[312] | 329 | //=== get_line_strip_white() read line, strip whitespace ===
|
---|
[306] | 330 |
|
---|
[551] | 331 | static PSZ get_line_strip_white(PSZ pszIn, FILE * fp)
|
---|
[306] | 332 | {
|
---|
[551] | 333 | PSZ psz =
|
---|
| 334 | xfgets_bstripcr(pszIn, ARCHIVER_LINE_BYTES, fp, pszSrcFile, __LINE__);
|
---|
[306] | 335 |
|
---|
[405] | 336 | if (psz)
|
---|
[312] | 337 | cur_line_num++;
|
---|
[306] | 338 |
|
---|
| 339 | return psz;
|
---|
| 340 | }
|
---|
| 341 |
|
---|
| 342 | //=== load_archivers() load or reload archive definitions from archiver.bb2 ===
|
---|
| 343 |
|
---|
[247] | 344 | INT load_archivers(VOID)
|
---|
| 345 | {
|
---|
[312] | 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;
|
---|
[306] | 353 | INT i;
|
---|
[2] | 354 |
|
---|
[312] | 355 | // Free current signatures
|
---|
[306] | 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;
|
---|
[312] | 366 | arcsigs_header_lines = 0;
|
---|
| 367 | arcsigs_trailer_line_num = 0;
|
---|
[306] | 368 |
|
---|
[1302] | 369 | //DosEnterCritSec(); //GKY 11-29-08
|
---|
| 370 | DosRequestMutexSem(hmtxFM2Globals, SEM_INDEFINITE_WAIT);
|
---|
[312] | 371 | psz = searchpath(GetPString(IDS_ARCHIVERBB2));
|
---|
[551] | 372 | if (!psz || !*psz) {
|
---|
[1302] | 373 | DosReleaseMutexSem(hmtxFM2Globals);
|
---|
| 374 | //DosExitCritSec();
|
---|
[287] | 375 | return -1;
|
---|
| 376 | }
|
---|
[312] | 377 | fp = _fsopen(psz, "r", SH_DENYWR);
|
---|
[1302] | 378 | DosReleaseMutexSem(hmtxFM2Globals);
|
---|
| 379 | //DosExitCritSec();
|
---|
[312] | 380 | if (!fp)
|
---|
[287] | 381 | return -2;
|
---|
[312] | 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
|
---|
[551] | 387 | if (!get_line_strip_comments(sz, fp)) {
|
---|
[312] | 388 | fclose(fp);
|
---|
[287] | 389 | return -3;
|
---|
| 390 | }
|
---|
[312] | 391 | if (*sz)
|
---|
| 392 | lines_per_arcsig = atoi(sz);
|
---|
[806] | 393 | if (!*sz || lines_per_arcsig < LINES_PER_ARCSIG) {
|
---|
| 394 | fclose(fp); // 25 Aug 07 SHL
|
---|
[287] | 395 | return -3;
|
---|
[806] | 396 | }
|
---|
[312] | 397 |
|
---|
| 398 | // Parse rest of file
|
---|
| 399 | // 1st non-blank line starts definition
|
---|
| 400 | // Need to determine header size and start of trailer
|
---|
| 401 |
|
---|
[551] | 402 | while (!feof(fp)) {
|
---|
[312] | 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, ';');
|
---|
[551] | 417 |
|
---|
| 418 | if (psz2) {
|
---|
| 419 | *psz2 = 0; // Chop trailing comment
|
---|
| 420 | bstripcr(sz); // Strip leading white and trailing white and CR/LF
|
---|
[312] | 421 | }
|
---|
[551] | 422 | arcsigs_header_lines = cur_line_num - 1;
|
---|
[312] | 423 | }
|
---|
| 424 | }
|
---|
| 425 | else {
|
---|
| 426 | // Reading defintiions
|
---|
| 427 | if (!get_line_strip_comments(sz, fp))
|
---|
[551] | 428 | break; // EOF
|
---|
[312] | 429 | }
|
---|
| 430 |
|
---|
[287] | 431 | // fixme to avoid allocating empty fields
|
---|
[306] | 432 |
|
---|
[312] | 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 |
|
---|
[551] | 437 | if (*sz) {
|
---|
[312] | 438 | // At start of defintion
|
---|
| 439 |
|
---|
[551] | 440 | pat = xmallocz(sizeof(ARC_TYPE), pszSrcFile, __LINE__);
|
---|
[306] | 441 | if (!pat)
|
---|
[342] | 442 | break;
|
---|
[551] | 443 | pat->id = xstrdup(sz, pszSrcFile, __LINE__);
|
---|
[287] | 444 |
|
---|
[551] | 445 | pat->comment_line_num = per_sig_comment_line_num;
|
---|
| 446 | pat->defn_line_num = cur_line_num;
|
---|
[312] | 447 |
|
---|
| 448 | if (!get_line_strip_comments(sz, fp)) // line 2 - extension
|
---|
[287] | 449 | break;
|
---|
[312] | 450 | if (*sz)
|
---|
[551] | 451 | pat->ext = xstrdup(sz, pszSrcFile, __LINE__);
|
---|
[287] | 452 | else
|
---|
[551] | 453 | pat->ext = NULL;
|
---|
[312] | 454 | if (!get_line_strip_comments(sz, fp)) // line 3 - offset to signature
|
---|
[287] | 455 | break;
|
---|
[551] | 456 | pat->file_offset = atol(sz);
|
---|
[312] | 457 | if (!get_line_strip_comments(sz, fp)) // line 4 - list command
|
---|
[287] | 458 | break;
|
---|
[312] | 459 | if (*sz)
|
---|
[551] | 460 | pat->list = xstrdup(sz, pszSrcFile, __LINE__);
|
---|
[287] | 461 | else
|
---|
[551] | 462 | pat->list = NULL;
|
---|
| 463 | if (!pat->list)
|
---|
[312] | 464 | break; // Must have list command - fixme to complain
|
---|
| 465 | if (!get_line_strip_comments(sz, fp)) // line 5
|
---|
[287] | 466 | break;
|
---|
[312] | 467 | if (*sz)
|
---|
[551] | 468 | pat->extract = xstrdup(sz, pszSrcFile, __LINE__);
|
---|
[287] | 469 | else
|
---|
[551] | 470 | pat->extract = NULL;
|
---|
[312] | 471 | if (!get_line_strip_comments(sz, fp)) // line 6
|
---|
[287] | 472 | break;
|
---|
[312] | 473 | if (*sz)
|
---|
[551] | 474 | pat->exwdirs = xstrdup(sz, pszSrcFile, __LINE__);
|
---|
[287] | 475 | else
|
---|
[551] | 476 | pat->exwdirs = NULL;
|
---|
[312] | 477 | if (!get_line_strip_comments(sz, fp)) // line 7
|
---|
[287] | 478 | break;
|
---|
[312] | 479 | if (*sz)
|
---|
[551] | 480 | pat->test = xstrdup(sz, pszSrcFile, __LINE__);
|
---|
[287] | 481 | else
|
---|
[551] | 482 | pat->test = NULL;
|
---|
[312] | 483 | if (!get_line_strip_comments(sz, fp)) // line 8
|
---|
[287] | 484 | break;
|
---|
[312] | 485 | if (*sz)
|
---|
[551] | 486 | pat->create = xstrdup(sz, pszSrcFile, __LINE__);
|
---|
[287] | 487 | else
|
---|
[551] | 488 | pat->create = NULL;
|
---|
[312] | 489 | if (!get_line_strip_comments(sz, fp)) // line 9
|
---|
[287] | 490 | break;
|
---|
[312] | 491 | if (*sz)
|
---|
[551] | 492 | pat->createwdirs = xstrdup(sz, pszSrcFile, __LINE__);
|
---|
[287] | 493 | else
|
---|
[551] | 494 | pat->createwdirs = NULL;
|
---|
[312] | 495 | if (!get_line_strip_comments(sz, fp)) // line 10
|
---|
[287] | 496 | break;
|
---|
[312] | 497 | if (*sz)
|
---|
[551] | 498 | pat->createrecurse = xstrdup(sz, pszSrcFile, __LINE__);
|
---|
[287] | 499 | else
|
---|
[551] | 500 | pat->createrecurse = NULL;
|
---|
[312] | 501 | if (!get_line_strip_comments(sz, fp)) // line 11
|
---|
[287] | 502 | break;
|
---|
[312] | 503 | if (*sz)
|
---|
[551] | 504 | pat->move = xstrdup(sz, pszSrcFile, __LINE__);
|
---|
[287] | 505 | else
|
---|
[551] | 506 | pat->move = NULL;
|
---|
[312] | 507 | if (!get_line_strip_comments(sz, fp)) // line 12
|
---|
[287] | 508 | break;
|
---|
[312] | 509 | if (*sz)
|
---|
[551] | 510 | pat->movewdirs = xstrdup(sz, pszSrcFile, __LINE__);
|
---|
[287] | 511 | else
|
---|
[551] | 512 | pat->movewdirs = NULL;
|
---|
[312] | 513 | if (!get_line_strip_comments(sz, fp)) // line 13
|
---|
[287] | 514 | break;
|
---|
[312] | 515 | if (*sz)
|
---|
[551] | 516 | pat->delete = xstrdup(sz, pszSrcFile, __LINE__);
|
---|
[312] | 517 | else
|
---|
[551] | 518 | pat->delete = NULL;
|
---|
[312] | 519 | if (!get_line_strip_white(sz, fp)) // line 14
|
---|
[287] | 520 | break;
|
---|
[312] | 521 | i = literal(sz); // Translate \ escapes
|
---|
[551] | 522 | if (i) {
|
---|
| 523 | pat->siglen = i;
|
---|
| 524 | pat->signature = xmalloc(i, pszSrcFile, __LINE__);
|
---|
| 525 | if (!pat->signature)
|
---|
[287] | 526 | break;
|
---|
[551] | 527 | memcpy(pat->signature, sz, i); // signature may not be a string
|
---|
[287] | 528 | }
|
---|
[306] | 529 | else {
|
---|
[551] | 530 | pat->siglen = 0;
|
---|
| 531 | pat->signature = NULL;
|
---|
[306] | 532 | }
|
---|
[312] | 533 | if (!get_line_strip_white(sz, fp)) // line 15
|
---|
[306] | 534 | break;
|
---|
[312] | 535 | if (*sz)
|
---|
[551] | 536 | pat->startlist = xstrdup(sz, pszSrcFile, __LINE__);
|
---|
[287] | 537 | else
|
---|
[551] | 538 | pat->startlist = NULL;
|
---|
[312] | 539 | if (!get_line_strip_white(sz, fp)) // line 16
|
---|
[287] | 540 | break;
|
---|
[312] | 541 | if (*sz)
|
---|
[551] | 542 | pat->endlist = xstrdup(sz, pszSrcFile, __LINE__);
|
---|
[287] | 543 | else
|
---|
[551] | 544 | pat->endlist = NULL;
|
---|
[312] | 545 | if (!get_line_strip_comments(sz, fp)) // line 17
|
---|
[287] | 546 | break;
|
---|
[551] | 547 | pat->osizepos = atoi(sz);
|
---|
[312] | 548 | if (!get_line_strip_comments(sz, fp)) // line 18
|
---|
[287] | 549 | break;
|
---|
[551] | 550 | pat->nsizepos = atoi(sz);
|
---|
[312] | 551 | if (!get_line_strip_comments(sz, fp)) // line 19
|
---|
[287] | 552 | break;
|
---|
[551] | 553 | pat->fdpos = atoi(sz);
|
---|
[312] | 554 | psz = strchr(sz, ',');
|
---|
[551] | 555 | if (psz) {
|
---|
[312] | 556 | psz++;
|
---|
[551] | 557 | pat->datetype = atoi(psz);
|
---|
[287] | 558 | }
|
---|
[312] | 559 | if (!get_line_strip_comments(sz, fp)) // line 20
|
---|
[287] | 560 | break;
|
---|
[551] | 561 | pat->fdflds = atoi(sz);
|
---|
[312] | 562 | if (!get_line_strip_comments(sz, fp)) // line 21
|
---|
[287] | 563 | break;
|
---|
[551] | 564 | pat->fnpos = atoi(sz);
|
---|
[312] | 565 | psz = strchr(sz, ',');
|
---|
[551] | 566 | if (psz) {
|
---|
[312] | 567 | psz++;
|
---|
[551] | 568 | pat->nameislast = (BOOL) (*psz && atol(psz) == 0) ? FALSE : TRUE;
|
---|
[312] | 569 | psz = strchr(psz, ',');
|
---|
[551] | 570 | if (psz) {
|
---|
[312] | 571 | psz++;
|
---|
[551] | 572 | pat->nameisnext = (BOOL) (*psz && atol(psz) == 0) ? FALSE : TRUE;
|
---|
[312] | 573 | psz = strchr(psz, ',');
|
---|
[551] | 574 | if (psz) {
|
---|
[312] | 575 | psz++;
|
---|
[551] | 576 | pat->nameisfirst = (BOOL) (*psz && atol(psz) == 0) ? FALSE : TRUE;
|
---|
[287] | 577 | }
|
---|
| 578 | }
|
---|
| 579 | }
|
---|
| 580 | // Ignore unknown lines - must be newer file format
|
---|
[551] | 581 | for (i = LINES_PER_ARCSIG; i < lines_per_arcsig; i++) {
|
---|
[312] | 582 | if (!get_line_strip_comments(sz, fp))
|
---|
| 583 | break; // Unexpected EOF - fixme to complain
|
---|
[287] | 584 | }
|
---|
[247] | 585 |
|
---|
[312] | 586 | // Add to list, assume next and prev already NULL
|
---|
[287] | 587 | if (!arcsighead)
|
---|
[306] | 588 | arcsighead = patLast = pat;
|
---|
[551] | 589 | else {
|
---|
| 590 | patLast->next = pat;
|
---|
| 591 | pat->prev = patLast;
|
---|
[306] | 592 | patLast = pat;
|
---|
[287] | 593 | }
|
---|
[551] | 594 | pat = NULL; // Done with this defintion
|
---|
[312] | 595 |
|
---|
| 596 | arcsigs_trailer_line_num = cur_line_num + 1; // In case this is last defintion
|
---|
| 597 | per_sig_comment_line_num = 0;
|
---|
[551] | 598 | } // if got definition
|
---|
[279] | 599 |
|
---|
[551] | 600 | } // while more lines
|
---|
[306] | 601 |
|
---|
[312] | 602 | fclose(fp);
|
---|
[306] | 603 |
|
---|
[551] | 604 | free_arc_type(pat); // In case partial definition in progress
|
---|
[312] | 605 |
|
---|
[287] | 606 | if (!arcsighead)
|
---|
| 607 | return -4;
|
---|
[306] | 608 |
|
---|
| 609 | arcsigsloaded = TRUE;
|
---|
| 610 |
|
---|
[287] | 611 | return 0;
|
---|
[2] | 612 | }
|
---|
| 613 |
|
---|
[342] | 614 | #define TEST_DRAG 0 // fixme to be gone or to work
|
---|
[2] | 615 |
|
---|
[551] | 616 | static MRESULT EXPENTRY SDlgListboxSubclassProc(HWND hwnd, ULONG msg,
|
---|
| 617 | MPARAM mp1, MPARAM mp2)
|
---|
[306] | 618 | {
|
---|
[551] | 619 | PFNWP pfnOldProc = (PFNWP) WinQueryWindowPtr(hwnd, QWL_USER);
|
---|
[306] | 620 |
|
---|
[618] | 621 | PDRAGITEM pDItem;
|
---|
| 622 | PDRAGINFO pDInfo;
|
---|
[306] | 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 |
|
---|
[551] | 629 | switch (msg) {
|
---|
[306] | 630 | case WM_BEGINDRAG:
|
---|
| 631 | {
|
---|
| 632 | LONG cur_ndx;
|
---|
| 633 | DRAGITEM ditem;
|
---|
| 634 | DRAGIMAGE dimage;
|
---|
| 635 | HWND hwndDrop;
|
---|
| 636 |
|
---|
[537] | 637 | // fprintf(stderr, "SDlgListboxSubclassProc: BEGINDRAG\n");
|
---|
[306] | 638 | cur_ndx = WinQueryLboxSelectedItem(hwnd);
|
---|
| 639 |
|
---|
| 640 | if (cur_ndx != LIT_NONE) {
|
---|
[618] | 641 | pDInfo = DrgAllocDraginfo(1);
|
---|
| 642 | if (pDInfo) {
|
---|
| 643 | pDInfo->usOperation = DO_DEFAULT;
|
---|
| 644 | pDInfo->hwndSource = hwnd;
|
---|
[306] | 645 |
|
---|
[551] | 646 | memset(&ditem, 0, sizeof(DRAGITEM));
|
---|
[306] | 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 |
|
---|
[551] | 657 | memset(&dimage, 0, sizeof(DRAGIMAGE));
|
---|
[306] | 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;
|
---|
[618] | 666 | DrgSetDragitem(pDInfo, &ditem, sizeof(DRAGITEM), 0); /* Index of DRAGITEM */
|
---|
| 667 | hwndDrop = DrgDrag(hwnd, pDInfo, &dimage, 1, /* One DRAGIMAGE */
|
---|
[551] | 668 | VK_ENDDRAG, NULL);
|
---|
[342] | 669 | if (!hwndDrop)
|
---|
[551] | 670 | Win_Error(hwnd, hwnd, pszSrcFile, __LINE__, "DrgDrag");
|
---|
[306] | 671 |
|
---|
[618] | 672 | DrgFreeDraginfo(pDInfo);
|
---|
[306] | 673 | // WinSetWindowPos(hwnd,HWND_TOP,0,0,0,0,SWP_ACTIVATE);
|
---|
| 674 | }
|
---|
| 675 | }
|
---|
| 676 | break;
|
---|
| 677 | }
|
---|
| 678 |
|
---|
| 679 | case DM_DRAGOVER:
|
---|
| 680 | ok = FALSE;
|
---|
[551] | 681 | if (!emphasized) {
|
---|
[306] | 682 | POINTL ptl;
|
---|
| 683 | POINTL ptl2;
|
---|
[551] | 684 |
|
---|
[306] | 685 | emphasized = TRUE;
|
---|
| 686 | ptl.x = SHORT1FROMMP(mp2);
|
---|
| 687 | ptl.y = SHORT2FROMMP(mp2);
|
---|
| 688 | ptl2 = ptl;
|
---|
| 689 | WinMapWindowPoints(HWND_DESKTOP, hwnd, &ptl2, 1);
|
---|
[537] | 690 | // fprintf(stderr, "DRAGOVER mapped x y %d %d to %d %d\n", ptl.x, ptl.y, ptl2.x, ptl2.y);
|
---|
[306] | 691 | WinPostMsg(hwnd, WM_BUTTON1CLICK,
|
---|
[551] | 692 | MPFROM2SHORT((SHORT) ptl2.x, (SHORT) ptl2.y),
|
---|
[306] | 693 | MPFROM2SHORT(HT_NORMAL, KC_NONE));
|
---|
[537] | 694 | // fprintf(stderr, "DRAGOVER posted 0x%x WM_BUTTON1CLICK x y %d %d\n", hwnd, ptl2.x, ptl2.y);
|
---|
[306] | 695 | }
|
---|
[618] | 696 | pDInfo = (PDRAGINFO) mp1; /* Get DRAGINFO pointer */
|
---|
| 697 | if (pDInfo) {
|
---|
| 698 | if (!DrgAccessDraginfo(pDInfo)) {
|
---|
[806] | 699 | Win_Error(HWND_DESKTOP, HWND_DESKTOP, pszSrcFile, __LINE__,
|
---|
| 700 | "DrgAccessDraginfo");
|
---|
[306] | 701 | }
|
---|
[618] | 702 | else {
|
---|
[806] | 703 | pDItem = DrgQueryDragitemPtr(pDInfo, 0);
|
---|
| 704 | /* Check valid rendering mechanisms and data format */
|
---|
| 705 | ok = DrgVerifyRMF(pDItem, DRM_LBOX, NULL);
|
---|
| 706 | DrgFreeDraginfo(pDInfo);
|
---|
[618] | 707 | }
|
---|
[306] | 708 | }
|
---|
[618] | 709 | return ok ? MRFROM2SHORT(DOR_DROP, DO_MOVE) :
|
---|
[806] | 710 | MRFROM2SHORT(DOR_NEVERDROP, 0);
|
---|
[306] | 711 |
|
---|
| 712 | case DM_DRAGLEAVE:
|
---|
[551] | 713 | if (emphasized) {
|
---|
[306] | 714 | emphasized = FALSE;
|
---|
| 715 | // fixme to draw listbox item emphasized
|
---|
| 716 | // DrawTargetEmphasis(hwnd, emphasized);
|
---|
[537] | 717 | // fprintf(stderr, "DRAGLEAVE\n");
|
---|
[306] | 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;
|
---|
[551] | 728 | if (emphasized) {
|
---|
[306] | 729 | emphasized = FALSE;
|
---|
| 730 | // DrawTargetEmphasis(hwnd, emphasized);
|
---|
| 731 | }
|
---|
[618] | 732 | pDInfo = (PDRAGINFO) mp1; /* Get DRAGINFO pointer */
|
---|
| 733 | if (pDInfo) {
|
---|
| 734 | if (!DrgAccessDraginfo(pDInfo)) {
|
---|
[806] | 735 | Win_Error(HWND_DESKTOP, HWND_DESKTOP, pszSrcFile, __LINE__,
|
---|
| 736 | "DrgAccessDraginfo");
|
---|
[306] | 737 | }
|
---|
[618] | 738 | else {
|
---|
[806] | 739 | pDItem = DrgQueryDragitemPtr(pDInfo, 0);
|
---|
| 740 | if (!pDItem)
|
---|
[618] | 741 | Win_Error(hwnd, hwnd, pszSrcFile, __LINE__, "DM_DROP");
|
---|
[806] | 742 | /* Check valid rendering mechanisms and data */
|
---|
| 743 | ok = DrgVerifyRMF(pDItem, DRM_LBOX, NULL)
|
---|
| 744 | && ~pDItem->fsControl & DC_PREPARE;
|
---|
| 745 | if (ok) {
|
---|
[618] | 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));
|
---|
[806] | 751 | }
|
---|
| 752 | FreeDragInfoData(hwnd, pDInfo);
|
---|
[618] | 753 | }
|
---|
[306] | 754 | }
|
---|
| 755 | return 0;
|
---|
[618] | 756 | } // switch
|
---|
[306] | 757 | return pfnOldProc ? pfnOldProc(hwnd, msg, mp1, mp2) :
|
---|
[551] | 758 | WinDefWindowProc(hwnd, msg, mp1, mp2);
|
---|
[306] | 759 | }
|
---|
| 760 |
|
---|
| 761 | //=== SBoxDlgProc() Select archiver to use or edit, supports list reorder too ===
|
---|
| 762 |
|
---|
[439] | 763 | static PSZ pszCantFindMsg = "Can't find item %d";
|
---|
| 764 |
|
---|
[247] | 765 | MRESULT EXPENTRY SBoxDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
---|
| 766 | {
|
---|
[551] | 767 | ARC_TYPE **ppatReturn; // Where to return selected archiver
|
---|
[306] | 768 | ARC_TYPE *pat;
|
---|
| 769 | SHORT sSelect;
|
---|
| 770 | SHORT sItemCount;
|
---|
| 771 | CHAR szItemText[256];
|
---|
[551] | 772 | CHAR szPCItemText[256]; // Parent or child item text
|
---|
[306] | 773 | SHORT i;
|
---|
| 774 | BOOL fShowAll;
|
---|
[2] | 775 |
|
---|
[306] | 776 | static SHORT sLastSelect = LIT_NONE;
|
---|
[2] | 777 |
|
---|
[551] | 778 | switch (msg) {
|
---|
[287] | 779 | case WM_INITDLG:
|
---|
[306] | 780 | if (!arcsigsloaded)
|
---|
[287] | 781 | load_archivers();
|
---|
[551] | 782 | if (!(ARC_TYPE **) mp2) {
|
---|
[378] | 783 | Runtime_Error2(pszSrcFile, __LINE__, IDS_NODATATEXT);
|
---|
[287] | 784 | WinDismissDlg(hwnd, 0);
|
---|
| 785 | break;
|
---|
| 786 | }
|
---|
[306] | 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 | */
|
---|
[551] | 792 | ppatReturn = (ARC_TYPE **) mp2;
|
---|
[306] | 793 | fShowAll = *ppatReturn == NULL;
|
---|
| 794 | if (*ppatReturn)
|
---|
| 795 | *ppatReturn = arcsighead; // Preset to first
|
---|
[551] | 796 | WinSetWindowPtr(hwnd, QWL_USER, (PVOID) ppatReturn);
|
---|
[306] | 797 | fill_listbox(hwnd, fShowAll, sLastSelect);
|
---|
| 798 |
|
---|
| 799 | #ifdef TEST_DRAG // fixme
|
---|
[287] | 800 | {
|
---|
[306] | 801 | HWND hwnd2 = WinWindowFromID(hwnd, ASEL_LISTBOX);
|
---|
| 802 | PFNWP pfn = WinSubclassWindow(hwnd2,
|
---|
| 803 | SDlgListboxSubclassProc);
|
---|
[551] | 804 |
|
---|
[306] | 805 | WinSetWindowPtr(hwnd2, QWL_USER, (PVOID) pfn);
|
---|
| 806 | }
|
---|
| 807 | #endif // TEST_DRAG fixme
|
---|
[287] | 808 |
|
---|
[306] | 809 | break;
|
---|
| 810 |
|
---|
| 811 | case WM_COMMAND:
|
---|
| 812 | ppatReturn = (ARC_TYPE **) WinQueryWindowPtr(hwnd, QWL_USER);
|
---|
[551] | 813 | switch (SHORT1FROMMP(mp1)) {
|
---|
[306] | 814 | case DID_OK:
|
---|
[551] | 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");
|
---|
[306] | 821 | return 0;
|
---|
| 822 | }
|
---|
| 823 | pat = arcsighead;
|
---|
[551] | 824 | if (*ppatReturn) {
|
---|
[306] | 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;
|
---|
[1302] | 831 | else {
|
---|
[551] | 832 | for (; pat; pat = pat->next) {
|
---|
| 833 | if (pat->id && !strcmp(szItemText, pat->id))
|
---|
| 834 | break; // Found it
|
---|
[287] | 835 | }
|
---|
| 836 | }
|
---|
[306] | 837 | }
|
---|
[551] | 838 | else {
|
---|
[306] | 839 | // If dups not hidden, lookup by count
|
---|
[551] | 840 | for (i = 0; pat && i < sSelect; i++, pat = pat->next) ; // Scan
|
---|
[306] | 841 | }
|
---|
[551] | 842 | if (pat && (!*ppatReturn || (pat->id && pat->extract && pat->create))) {
|
---|
[306] | 843 | *ppatReturn = pat;
|
---|
| 844 | }
|
---|
[551] | 845 | else {
|
---|
| 846 | Runtime_Error(pszSrcFile, __LINE__, "no match");
|
---|
[306] | 847 | // Refuse to select
|
---|
| 848 | WinSendDlgItemMsg(hwnd, ASEL_LISTBOX, LM_SELECTITEM,
|
---|
| 849 | MPFROMSHORT(LIT_NONE), FALSE);
|
---|
| 850 | return 0;
|
---|
| 851 | }
|
---|
[1302] | 852 | PrfWriteProfileData(fmprof, appname, "LastArchiver", &sSelect, sizeof(SHORT));
|
---|
[306] | 853 | sLastSelect = sSelect;
|
---|
| 854 | WinDismissDlg(hwnd, TRUE);
|
---|
| 855 | return 0;
|
---|
[2] | 856 |
|
---|
[306] | 857 | case DID_CANCEL:
|
---|
| 858 | if (arcsigsmodified) {
|
---|
| 859 | if (saymsg(MB_YESNO,
|
---|
| 860 | hwnd,
|
---|
| 861 | GetPString(IDS_ADCHANGESINMEMTEXT),
|
---|
[551] | 862 | GetPString(IDS_ADREWRITETEXT), NullStr) == MBID_YES) {
|
---|
[306] | 863 | PSZ ab2 = searchpath(GetPString(IDS_ARCHIVERBB2)); // Rewrite without prompting
|
---|
[551] | 864 |
|
---|
[306] | 865 | rewrite_archiverbb2(ab2);
|
---|
| 866 | }
|
---|
| 867 | }
|
---|
[551] | 868 | sSelect = (SHORT) WinSendDlgItemMsg(hwnd,
|
---|
| 869 | ASEL_LISTBOX,
|
---|
| 870 | LM_QUERYSELECTION,
|
---|
| 871 | MPFROMSHORT(LIT_FIRST), MPVOID);
|
---|
[1302] | 872 | if (sSelect != LIT_NONE) {
|
---|
| 873 | sLastSelect = sSelect;
|
---|
| 874 | PrfWriteProfileData(fmprof, appname, "LastArchiver", &sSelect, sizeof(SHORT));
|
---|
| 875 | }
|
---|
[306] | 876 | *ppatReturn = NULL;
|
---|
| 877 | PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID); // fixme to understand why needed
|
---|
| 878 | return 0;
|
---|
| 879 |
|
---|
| 880 | case ASEL_PB_ADD:
|
---|
[551] | 881 | sSelect = (SHORT) WinSendDlgItemMsg(hwnd,
|
---|
| 882 | ASEL_LISTBOX,
|
---|
| 883 | LM_QUERYSELECTION,
|
---|
| 884 | MPFROMSHORT(LIT_FIRST), MPVOID);
|
---|
[306] | 885 | if (sSelect != LIT_NONE) {
|
---|
| 886 | ARCDUMP ad;
|
---|
[551] | 887 |
|
---|
| 888 | memset(&ad, 0, sizeof(ARCDUMP));
|
---|
| 889 | ad.info = xmallocz(sizeof(ARC_TYPE), pszSrcFile, __LINE__);
|
---|
[306] | 890 | if (ad.info) {
|
---|
| 891 | if (!WinDlgBox(HWND_DESKTOP,
|
---|
| 892 | hwnd,
|
---|
| 893 | ArcReviewDlgProc,
|
---|
[551] | 894 | FM3ModHandle, AD_FRAME, MPFROMP(&ad))) {
|
---|
[1039] | 895 | free(ad.info);
|
---|
[287] | 896 | }
|
---|
[306] | 897 | else {
|
---|
| 898 | // Find self - assume all archivers listed since we are editing
|
---|
[551] | 899 | for (i = 0, pat = arcsighead; pat && i < sSelect; pat = pat->next, i++) ; // Find self
|
---|
[2] | 900 |
|
---|
[306] | 901 | if (!pat) {
|
---|
| 902 | if (arcsighead)
|
---|
[551] | 903 | Runtime_Error(pszSrcFile, __LINE__, pszCantFindMsg, sSelect);
|
---|
[306] | 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 | }
|
---|
[287] | 921 | WinSendDlgItemMsg(hwnd, ASEL_LISTBOX, LM_INSERTITEM,
|
---|
[306] | 922 | MPFROM2SHORT(sSelect, 0),
|
---|
[551] | 923 | MPFROMP(ad.info->id ? ad.info->id : "?"));
|
---|
[306] | 924 | WinSendDlgItemMsg(hwnd, ASEL_LISTBOX, LM_SELECTITEM,
|
---|
| 925 | MPFROMSHORT(sSelect - 1), MPFROMSHORT(TRUE));
|
---|
| 926 | arcsigsmodified = TRUE;
|
---|
[287] | 927 | }
|
---|
| 928 | }
|
---|
| 929 | }
|
---|
[306] | 930 | return 0;
|
---|
| 931 | case ASEL_PB_DELETE:
|
---|
[551] | 932 | sSelect = (SHORT) WinSendDlgItemMsg(hwnd,
|
---|
| 933 | ASEL_LISTBOX,
|
---|
| 934 | LM_QUERYSELECTION,
|
---|
| 935 | MPFROMSHORT(LIT_FIRST), MPVOID);
|
---|
[306] | 936 | if (sSelect != LIT_NONE) {
|
---|
| 937 | // Find self - assume all archivers listed since we are editing
|
---|
[551] | 938 | for (i = 0, pat = arcsighead; pat && i < sSelect; pat = pat->next, i++) ; // Find self
|
---|
[2] | 939 |
|
---|
[439] | 940 | if (!pat)
|
---|
[551] | 941 | Runtime_Error(pszSrcFile, __LINE__, pszCantFindMsg, sSelect);
|
---|
[306] | 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;
|
---|
[287] | 948 | }
|
---|
[306] | 949 | else {
|
---|
| 950 | arcsighead = pat->next;
|
---|
| 951 | if (pat->next)
|
---|
| 952 | pat->next->prev = pat->prev;
|
---|
| 953 | }
|
---|
[247] | 954 | }
|
---|
[306] | 955 | free_arc_type(pat);
|
---|
| 956 | arcsigsmodified = TRUE;
|
---|
| 957 | WinSendDlgItemMsg(hwnd, ASEL_LISTBOX, LM_DELETEITEM,
|
---|
[551] | 958 | MPFROM2SHORT(sSelect, 0), MPVOID);
|
---|
| 959 | sItemCount =
|
---|
| 960 | (SHORT) WinSendDlgItemMsg(hwnd, ASEL_LISTBOX, LM_QUERYITEMCOUNT,
|
---|
| 961 | MPVOID, MPVOID);
|
---|
[306] | 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:
|
---|
[551] | 971 | sSelect = (SHORT) WinSendDlgItemMsg(hwnd,
|
---|
| 972 | ASEL_LISTBOX,
|
---|
| 973 | LM_QUERYSELECTION,
|
---|
| 974 | MPFROMSHORT(LIT_FIRST), MPVOID);
|
---|
[306] | 975 | if (sSelect != LIT_NONE && sSelect > 0) {
|
---|
| 976 | // Find self - assume all archivers listed since we are editing
|
---|
[551] | 977 | for (i = 0, pat = arcsighead; pat && i < sSelect; pat = pat->next, i++) ; // Find self
|
---|
[439] | 978 | if (!pat || !pat->prev)
|
---|
[551] | 979 | Runtime_Error(pszSrcFile, __LINE__, pszCantFindMsg, sSelect);
|
---|
[306] | 980 | else {
|
---|
| 981 | ARC_TYPE *patGDad;
|
---|
| 982 | ARC_TYPE *patDad;
|
---|
| 983 | ARC_TYPE *patChild;
|
---|
[551] | 984 |
|
---|
[306] | 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;
|
---|
[287] | 996 | }
|
---|
[306] | 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,
|
---|
[551] | 1005 | MPFROM2SHORT(sSelect - 1, 255),
|
---|
| 1006 | MPFROMP(szPCItemText));
|
---|
[306] | 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;
|
---|
[287] | 1014 | }
|
---|
[306] | 1015 | }
|
---|
| 1016 | return 0;
|
---|
| 1017 | case ASEL_PB_DOWN:
|
---|
[551] | 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);
|
---|
[306] | 1024 | if (sSelect != LIT_NONE && sSelect < sItemCount - 1) {
|
---|
| 1025 | // Find self - assume all archivers listed since we are editing
|
---|
[551] | 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);
|
---|
[306] | 1030 | else {
|
---|
| 1031 | ARC_TYPE *patDad;
|
---|
| 1032 | ARC_TYPE *patChild;
|
---|
[551] | 1033 |
|
---|
[306] | 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;
|
---|
[551] | 1042 | patChild->prev = patDad;
|
---|
[306] | 1043 | }
|
---|
| 1044 | else {
|
---|
| 1045 | arcsighead = patChild;
|
---|
[551] | 1046 | patChild->prev = NULL;
|
---|
[306] | 1047 | }
|
---|
| 1048 |
|
---|
| 1049 | WinSendDlgItemMsg(hwnd, ASEL_LISTBOX, LM_QUERYITEMTEXT,
|
---|
| 1050 | MPFROM2SHORT(sSelect, 255), MPFROMP(szItemText));
|
---|
| 1051 | WinSendDlgItemMsg(hwnd, ASEL_LISTBOX, LM_QUERYITEMTEXT,
|
---|
[551] | 1052 | MPFROM2SHORT(sSelect + 1, 255),
|
---|
| 1053 | MPFROMP(szPCItemText));
|
---|
[306] | 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));
|
---|
[287] | 1058 | WinSendDlgItemMsg(hwnd, ASEL_LISTBOX, LM_SELECTITEM,
|
---|
[306] | 1059 | MPFROMSHORT(sSelect + 1), MPFROMSHORT(TRUE));
|
---|
| 1060 | arcsigsmodified = TRUE;
|
---|
[287] | 1061 | }
|
---|
| 1062 | }
|
---|
| 1063 | return 0;
|
---|
[2] | 1064 |
|
---|
[306] | 1065 | case ASEL_PB_REVERT:
|
---|
| 1066 | // Reload without checking in case changed outside
|
---|
[551] | 1067 | sSelect =
|
---|
| 1068 | (SHORT) WinSendDlgItemMsg(hwnd, ASEL_LISTBOX, LM_QUERYSELECTION,
|
---|
| 1069 | MPFROMSHORT(LIT_FIRST), MPVOID);
|
---|
[306] | 1070 | load_archivers();
|
---|
| 1071 | fill_listbox(hwnd, TRUE, sSelect);
|
---|
| 1072 | return 0;
|
---|
[2] | 1073 |
|
---|
[306] | 1074 | case IDM_HELP:
|
---|
| 1075 | if (hwndHelp) {
|
---|
[551] | 1076 | WinSendMsg(hwndHelp, HM_DISPLAY_HELP, MPFROM2SHORT(HELP_EDITARC, 0), // fixme to be HELP_SELARC
|
---|
| 1077 | MPFROMSHORT(HM_RESOURCEID));
|
---|
[306] | 1078 | }
|
---|
[247] | 1079 | }
|
---|
[306] | 1080 | return 0; // WM_COMMAND
|
---|
[287] | 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);
|
---|
[2] | 1095 | }
|
---|
| 1096 |
|
---|
| 1097 | /*
|
---|
[306] | 1098 | see archiver.tmp
|
---|
| 1099 | 02-08-96 23:55 1
|
---|
[247] | 1100 | 8 Feb 96 23:55:32 2
|
---|
| 1101 | 8 Feb 96 11:55p 3
|
---|
[306] | 1102 | 96-02-08 23:55:32 4
|
---|
| 1103 | 31-02-98 23:55 5
|
---|
[247] | 1104 | */
|
---|
[2] | 1105 |
|
---|
[551] | 1106 | BOOL ArcDateTime(CHAR * dt, INT type, CDATE * cdate, CTIME * ctime)
|
---|
[247] | 1107 | {
|
---|
[287] | 1108 | INT x;
|
---|
| 1109 | BOOL ret = FALSE;
|
---|
| 1110 | CHAR *p, *pp, *pd;
|
---|
[2] | 1111 |
|
---|
[551] | 1112 | if (dt && cdate && ctime) {
|
---|
[287] | 1113 | memset(cdate, 0, sizeof(CDATE));
|
---|
| 1114 | memset(ctime, 0, sizeof(CTIME));
|
---|
[551] | 1115 | if (type) {
|
---|
[287] | 1116 | p = dt;
|
---|
| 1117 | while (*p && *p == ' ')
|
---|
| 1118 | p++;
|
---|
| 1119 | pd = dt;
|
---|
[551] | 1120 | switch (type) {
|
---|
[287] | 1121 | case 1:
|
---|
[551] | 1122 | cdate->month = atoi(pd);
|
---|
[287] | 1123 | p = to_delim(pd, "-/.");
|
---|
[551] | 1124 | if (p) {
|
---|
[287] | 1125 | p++;
|
---|
[551] | 1126 | cdate->day = atoi(p);
|
---|
[287] | 1127 | pd = p;
|
---|
| 1128 | p = to_delim(pd, "-/.");
|
---|
[551] | 1129 | if (p) {
|
---|
[287] | 1130 | p++;
|
---|
[551] | 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;
|
---|
[287] | 1136 | ret = TRUE;
|
---|
| 1137 | p = strchr(p, ' ');
|
---|
[551] | 1138 | if (p) {
|
---|
[287] | 1139 | while (*p && *p == ' ')
|
---|
[247] | 1140 | p++;
|
---|
[551] | 1141 | ctime->hours = atoi(p);
|
---|
[287] | 1142 | p = to_delim(pd, ":.");
|
---|
[551] | 1143 | if (p) {
|
---|
[287] | 1144 | p++;
|
---|
[551] | 1145 | ctime->minutes = atoi(p);
|
---|
[287] | 1146 | p = to_delim(pd, ":.");
|
---|
[551] | 1147 | if (p) {
|
---|
[287] | 1148 | p++;
|
---|
[551] | 1149 | ctime->seconds = atoi(p);
|
---|
[247] | 1150 | }
|
---|
[287] | 1151 | }
|
---|
| 1152 | }
|
---|
| 1153 | }
|
---|
| 1154 | }
|
---|
| 1155 | break;
|
---|
[2] | 1156 |
|
---|
[287] | 1157 | case 2:
|
---|
[551] | 1158 | cdate->day = atoi(p);
|
---|
[287] | 1159 | p = strchr(p, ' ');
|
---|
[551] | 1160 | if (p) {
|
---|
[287] | 1161 | p++;
|
---|
[551] | 1162 | for (x = 0; x < 12; x++) {
|
---|
[287] | 1163 | if (!strnicmp(p, GetPString(IDS_JANUARY + x), 3))
|
---|
| 1164 | break;
|
---|
| 1165 | }
|
---|
[551] | 1166 | if (x < 12) {
|
---|
| 1167 | cdate->month = x;
|
---|
[287] | 1168 | p = strchr(p, ' ');
|
---|
[551] | 1169 | if (p) {
|
---|
[287] | 1170 | p++;
|
---|
[551] | 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;
|
---|
[287] | 1176 | ret = TRUE;
|
---|
| 1177 | p = strchr(p, ' ');
|
---|
[551] | 1178 | if (p) {
|
---|
[287] | 1179 | while (*p && *p == ' ')
|
---|
| 1180 | p++;
|
---|
[551] | 1181 | ctime->hours = atoi(p);
|
---|
[287] | 1182 | p = to_delim(pd, ":.");
|
---|
[551] | 1183 | if (p) {
|
---|
[287] | 1184 | p++;
|
---|
[551] | 1185 | ctime->minutes = atoi(p);
|
---|
[287] | 1186 | p = to_delim(pd, ":.");
|
---|
[551] | 1187 | if (p) {
|
---|
[247] | 1188 | p++;
|
---|
[551] | 1189 | ctime->seconds = atoi(p);
|
---|
[287] | 1190 | }
|
---|
[247] | 1191 | }
|
---|
[287] | 1192 | }
|
---|
| 1193 | }
|
---|
| 1194 | }
|
---|
| 1195 | }
|
---|
| 1196 | break;
|
---|
[2] | 1197 |
|
---|
[287] | 1198 | case 3:
|
---|
[551] | 1199 | cdate->day = atoi(p);
|
---|
[287] | 1200 | p = strchr(p, ' ');
|
---|
[551] | 1201 | if (p) {
|
---|
[287] | 1202 | p++;
|
---|
[551] | 1203 | for (x = 0; x < 12; x++) {
|
---|
[287] | 1204 | if (!strnicmp(p, GetPString(IDS_JANUARY + x), 3))
|
---|
| 1205 | break;
|
---|
| 1206 | }
|
---|
[551] | 1207 | if (x < 12) {
|
---|
| 1208 | cdate->month = x;
|
---|
[287] | 1209 | p = strchr(p, ' ');
|
---|
[551] | 1210 | if (p) {
|
---|
[287] | 1211 | p++;
|
---|
[551] | 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;
|
---|
[287] | 1217 | ret = TRUE;
|
---|
| 1218 | p = strchr(p, ' ');
|
---|
[551] | 1219 | if (p) {
|
---|
[287] | 1220 | while (*p && *p == ' ')
|
---|
| 1221 | p++;
|
---|
[551] | 1222 | ctime->hours = atoi(p);
|
---|
[287] | 1223 | p = to_delim(pd, ":.");
|
---|
[551] | 1224 | if (p) {
|
---|
[287] | 1225 | p++;
|
---|
| 1226 | pp = p;
|
---|
[551] | 1227 | ctime->minutes = atoi(p);
|
---|
[287] | 1228 | p = to_delim(pd, ":.");
|
---|
[551] | 1229 | if (p) {
|
---|
[247] | 1230 | p++;
|
---|
[551] | 1231 | ctime->seconds = atoi(p);
|
---|
[287] | 1232 | p += 2;
|
---|
| 1233 | if (toupper(*p) == 'P')
|
---|
[551] | 1234 | ctime->hours += 12;
|
---|
[287] | 1235 | }
|
---|
[551] | 1236 | else {
|
---|
[287] | 1237 | p = pp;
|
---|
| 1238 | p += 2;
|
---|
| 1239 | if (toupper(*p) == 'P')
|
---|
[551] | 1240 | ctime->hours += 12;
|
---|
[287] | 1241 | }
|
---|
[247] | 1242 | }
|
---|
[287] | 1243 | }
|
---|
| 1244 | }
|
---|
| 1245 | }
|
---|
| 1246 | }
|
---|
| 1247 | break;
|
---|
[2] | 1248 |
|
---|
[287] | 1249 | case 4:
|
---|
[551] | 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;
|
---|
[287] | 1255 | p = to_delim(pd, "-/.");
|
---|
[551] | 1256 | if (p) {
|
---|
[287] | 1257 | p++;
|
---|
[551] | 1258 | cdate->month = atoi(p);
|
---|
[287] | 1259 | pd = p;
|
---|
| 1260 | p = to_delim(pd, "-/.");
|
---|
[551] | 1261 | if (p) {
|
---|
[287] | 1262 | p++;
|
---|
[551] | 1263 | cdate->day = atoi(p);
|
---|
[287] | 1264 | ret = TRUE;
|
---|
| 1265 | p = strchr(p, ' ');
|
---|
[551] | 1266 | if (p) {
|
---|
[287] | 1267 | while (*p && *p == ' ')
|
---|
| 1268 | p++;
|
---|
[551] | 1269 | ctime->hours = atoi(p);
|
---|
[287] | 1270 | p = to_delim(pd, ":.");
|
---|
[551] | 1271 | if (p) {
|
---|
[287] | 1272 | p++;
|
---|
[551] | 1273 | ctime->minutes = atoi(p);
|
---|
[287] | 1274 | p = to_delim(pd, ":.");
|
---|
[551] | 1275 | if (p) {
|
---|
[287] | 1276 | p++;
|
---|
[551] | 1277 | ctime->seconds = atoi(p);
|
---|
[247] | 1278 | }
|
---|
[287] | 1279 | }
|
---|
| 1280 | }
|
---|
| 1281 | }
|
---|
| 1282 | }
|
---|
| 1283 | break;
|
---|
[2] | 1284 |
|
---|
[287] | 1285 | case 5:
|
---|
[551] | 1286 | cdate->day = atoi(pd);
|
---|
[287] | 1287 | p = to_delim(pd, "-/.");
|
---|
[551] | 1288 | if (p) {
|
---|
[287] | 1289 | p++;
|
---|
[551] | 1290 | cdate->month = atoi(p);
|
---|
[287] | 1291 | pd = p;
|
---|
| 1292 | p = to_delim(pd, "-/.");
|
---|
[551] | 1293 | if (p) {
|
---|
[287] | 1294 | p++;
|
---|
[551] | 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;
|
---|
[287] | 1300 | ret = TRUE;
|
---|
| 1301 | p = strchr(p, ' ');
|
---|
[551] | 1302 | if (p) {
|
---|
[287] | 1303 | while (*p && *p == ' ')
|
---|
| 1304 | p++;
|
---|
[551] | 1305 | ctime->hours = atoi(p);
|
---|
[287] | 1306 | p = to_delim(pd, ":.");
|
---|
[551] | 1307 | if (p) {
|
---|
[287] | 1308 | p++;
|
---|
[551] | 1309 | ctime->minutes = atoi(p);
|
---|
[287] | 1310 | p = to_delim(pd, ":.");
|
---|
[551] | 1311 | if (p) {
|
---|
[287] | 1312 | p++;
|
---|
[551] | 1313 | ctime->seconds = atoi(p);
|
---|
[247] | 1314 | }
|
---|
[287] | 1315 | }
|
---|
[247] | 1316 | }
|
---|
[287] | 1317 | }
|
---|
[247] | 1318 | }
|
---|
[287] | 1319 | break;
|
---|
| 1320 |
|
---|
| 1321 | default:
|
---|
| 1322 | break;
|
---|
| 1323 | }
|
---|
[2] | 1324 | }
|
---|
[287] | 1325 | }
|
---|
| 1326 | return ret;
|
---|
[2] | 1327 | }
|
---|
[793] | 1328 |
|
---|
| 1329 | #pragma alloc_text(MISC9,quick_find_type,find_type)
|
---|
[1029] | 1330 | #pragma alloc_text(AVL,load_archivers, get_line_strip_comments, get_line_strip_white, free_archivers)
|
---|
[793] | 1331 | #pragma alloc_text(FMARCHIVE,SBoxDlgProc,SDlgListboxSubclassProc)
|
---|
| 1332 | #pragma alloc_text(ARCCNRS,ArcDateTime)
|
---|