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