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