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