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