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