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