| 1 |
|
|---|
| 2 | /***********************************************************************
|
|---|
| 3 |
|
|---|
| 4 | $Id: avl.c 1879 2015-10-11 23:49:35Z gyoung $
|
|---|
| 5 |
|
|---|
| 6 | archiver.bb2 search, load, save and date parse
|
|---|
| 7 |
|
|---|
| 8 | Copyright (c) 1993, 1998 M. Kimes
|
|---|
| 9 | Copyright (c) 2004, 2008 Steven H.Levine
|
|---|
| 10 |
|
|---|
| 11 | 01 Aug 04 SHL Rework lstrip/rstrip usage
|
|---|
| 12 | 13 Aug 05 SHL Beautify with indent
|
|---|
| 13 | 13 Aug 05 SHL find_type: correct no sig exists bypass logic
|
|---|
| 14 | 13 Aug 05 SHL SBoxDlgProc: avoid dereferencing NULL signature
|
|---|
| 15 | 18 Aug 05 SHL Comments
|
|---|
| 16 | 31 Dec 05 SHL indent -i2
|
|---|
| 17 | 08 Dec 05 SHL load_archivers: allow empty startlist
|
|---|
| 18 | 30 Dec 05 SHL load_archivers: use get_archiver_line?(), clean nits
|
|---|
| 19 | 29 May 06 SHL SBoxDlgProc: support move, add, delete
|
|---|
| 20 | 30 May 06 SHL load_archivers: add reload support
|
|---|
| 21 | 16 Jun 06 SHL load_archivers: support signatures containing 0s
|
|---|
| 22 | 26 Jun 06 SHL load_archivers: remember where comments are
|
|---|
| 23 | 14 Jul 06 SHL Use Runtime_Error
|
|---|
| 24 | 29 Jul 06 SHL Use xfgets, xfgets_bstripcr
|
|---|
| 25 | 15 Aug 06 SHL Use Runtime_Error more
|
|---|
| 26 | 01 Nov 06 SHL Turn off leftover debug code
|
|---|
| 27 | 06 Apr 07 GKY Work around PM DragInfo and DrgFreeDISH limit
|
|---|
| 28 | 19 Apr 07 SHL Use FreeDragInfoData
|
|---|
| 29 | 19 Apr 07 SHL Add more drag/drop error checking
|
|---|
| 30 | 20 Aug 07 GKY Move #pragma alloc_text to end for OpenWatcom compat
|
|---|
| 31 | 25 Aug 07 SHL load_archivers: add missing close on error path
|
|---|
| 32 | 29 Feb 08 GKY Use xfree where appropriate
|
|---|
| 33 | 22 Jun 08 GKY Added free_archivers for fortify checking
|
|---|
| 34 | 19 Jul 08 GKY ifdef Fortify free_archivers
|
|---|
| 35 | 29 Nov 08 GKY Add ini entry for LastArchiver so the previous archiver is selected in the
|
|---|
| 36 | Select archive dialog if no default is provided.
|
|---|
| 37 | 29 Nov 08 GKY Remove or replace with a mutex semaphore DosEnterCriSec where appropriate.
|
|---|
| 38 | 11 Jan 08 GKY Replace "ARCHIVER.BB2" in string file with global set at compile in init.c
|
|---|
| 39 | 08 Mar 09 GKY Additional strings move to PCSZs in init.c
|
|---|
| 40 | 23 Oct 10 GKY Changes to populate and utilize a HELPTABLE for context specific help
|
|---|
| 41 | 21 Nov 10 GKY Check if archiver.bb2 has been changed on disk before editing
|
|---|
| 42 | 13 Aug 11 GKY Change to Doxygen comment format
|
|---|
| 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+
|
|---|
| 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.
|
|---|
| 47 |
|
|---|
| 48 | ***********************************************************************/
|
|---|
| 49 |
|
|---|
| 50 | #include <stdlib.h>
|
|---|
| 51 | #include <string.h>
|
|---|
| 52 | #include <ctype.h>
|
|---|
| 53 | #include <share.h>
|
|---|
| 54 | #include <sys/stat.h>
|
|---|
| 55 |
|
|---|
| 56 | #define INCL_DOS
|
|---|
| 57 | #define INCL_WIN
|
|---|
| 58 | #define INCL_WINSTDDRAG
|
|---|
| 59 | #define INCL_LONGLONG
|
|---|
| 60 |
|
|---|
| 61 | #include "fm3dll.h"
|
|---|
| 62 | #include "fm3dll2.h" // #define's for UM_*, control id's, etc.
|
|---|
| 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)
|
|---|
| 67 | #include "fm3dlg.h"
|
|---|
| 68 | #include "fm3str.h"
|
|---|
| 69 | #include "avl.h"
|
|---|
| 70 | #include "strutil.h" // GetPString
|
|---|
| 71 | #include "errutil.h" // Runtime_Error
|
|---|
| 72 | #include "avv.h" // ArcReviewDlgProc, rewrite_archiverbb2
|
|---|
| 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
|
|---|
| 80 | #include "srchpath.h" // Search*Path*ForFile
|
|---|
| 81 | #include "stristr.h" // stristr
|
|---|
| 82 | #include "delims.h" // to_delim
|
|---|
| 83 | #include "fortify.h"
|
|---|
| 84 |
|
|---|
| 85 | // Data definitions
|
|---|
| 86 | static PSZ pszSrcFile = __FILE__;
|
|---|
| 87 | static void fill_listbox(HWND hwnd, BOOL fShowAll, SHORT sOldSelect);
|
|---|
| 88 |
|
|---|
| 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;
|
|---|
| 95 | static struct stat Archiverbb2Stats;
|
|---|
| 96 |
|
|---|
| 97 | #define ARCHIVER_LINE_BYTES 256
|
|---|
| 98 |
|
|---|
| 99 | //=== quick_find_type() ===
|
|---|
| 100 | ARC_TYPE *quick_find_type(CHAR * filespec, ARC_TYPE * topsig)
|
|---|
| 101 | {
|
|---|
| 102 | ARC_TYPE *info, *found = NULL;
|
|---|
| 103 | CHAR *p;
|
|---|
| 104 |
|
|---|
| 105 | if (!arcsigsloaded)
|
|---|
| 106 | load_archivers();
|
|---|
| 107 | p = strrchr(filespec, '.');
|
|---|
| 108 | if (p) {
|
|---|
| 109 | p++;
|
|---|
| 110 | info = (topsig) ? topsig : arcsighead;
|
|---|
| 111 | while (info) {
|
|---|
| 112 | if (info->ext && *(info->ext) && !stricmp(p, info->ext)) {
|
|---|
| 113 | found = find_type(filespec, topsig);
|
|---|
| 114 | break;
|
|---|
| 115 | }
|
|---|
| 116 | info = info->next;
|
|---|
| 117 | }
|
|---|
| 118 | }
|
|---|
| 119 | return found;
|
|---|
| 120 | }
|
|---|
| 121 |
|
|---|
| 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 |
|
|---|
| 132 | for (pat = arcsighead; pat; pat = pat->next) {
|
|---|
| 133 | /**
|
|---|
| 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 | */
|
|---|
| 138 | if (!fShowAll) {
|
|---|
| 139 | ARC_TYPE *pat2;
|
|---|
| 140 | BOOL isDup = FALSE;
|
|---|
| 141 |
|
|---|
| 142 | for (pat2 = arcsighead;
|
|---|
| 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
|
|---|
| 147 | if (isDup)
|
|---|
| 148 | continue;
|
|---|
| 149 | }
|
|---|
| 150 |
|
|---|
| 151 | // If caller is editing archivers or entry useful to caller, show in listbox
|
|---|
| 152 | if (fShowAll || (pat->id && pat->extract && pat->create)) {
|
|---|
| 153 | sSelect = (SHORT) WinSendDlgItemMsg(hwnd, ASEL_LISTBOX, LM_INSERTITEM,
|
|---|
| 154 | MPFROM2SHORT(LIT_END, 0),
|
|---|
| 155 | MPFROMP(pat->id ? pat->id : "?"));
|
|---|
| 156 | if (!found && *szDefArc && pat->id && !strcmp(szDefArc, pat->id)) {
|
|---|
| 157 | // Highlight default
|
|---|
| 158 | WinSendDlgItemMsg(hwnd, ASEL_LISTBOX, LM_SELECTITEM,
|
|---|
| 159 | MPFROMSHORT(sSelect), MPFROMSHORT(TRUE));
|
|---|
| 160 | found = TRUE;
|
|---|
| 161 | }
|
|---|
| 162 | }
|
|---|
| 163 | else {
|
|---|
| 164 | // Complain about odd entry
|
|---|
| 165 | if (!pat->id || !*pat->id) {
|
|---|
| 166 | WinSendDlgItemMsg(hwnd, ASEL_LISTBOX, LM_INSERTITEM,
|
|---|
| 167 | MPFROM2SHORT(LIT_END, 0),
|
|---|
| 168 | MPFROMP(GetPString(IDS_UNKNOWNUNUSABLETEXT)));
|
|---|
| 169 | }
|
|---|
| 170 | else {
|
|---|
| 171 | CHAR s[81];
|
|---|
| 172 |
|
|---|
| 173 | sprintf(s, "%0.12s %s", pat->id, GetPString(IDS_UNUSABLETEXT));
|
|---|
| 174 | WinSendDlgItemMsg(hwnd, ASEL_LISTBOX, LM_INSERTITEM,
|
|---|
| 175 | MPFROM2SHORT(LIT_END, 0), MPFROMP(s));
|
|---|
| 176 | }
|
|---|
| 177 | }
|
|---|
| 178 | } // while scanning
|
|---|
| 179 |
|
|---|
| 180 | // Try to reselect last selection unless user wants default selection
|
|---|
| 181 | if (sOldSelect == LIT_NONE) {
|
|---|
| 182 | ULONG size = sizeof(SHORT);
|
|---|
| 183 |
|
|---|
| 184 | PrfQueryProfileData(fmprof, appname, "LastArchiver", &sOldSelect, &size);
|
|---|
| 185 | }
|
|---|
| 186 | if (sOldSelect != LIT_NONE && !found) {
|
|---|
| 187 | SHORT sItemCount =
|
|---|
| 188 | (SHORT) WinSendDlgItemMsg(hwnd, ASEL_LISTBOX, LM_QUERYITEMCOUNT,
|
|---|
| 189 | MPVOID, MPVOID);
|
|---|
| 190 |
|
|---|
| 191 | if (sOldSelect >= sItemCount)
|
|---|
| 192 | sOldSelect = sItemCount - 1;
|
|---|
| 193 | if (sOldSelect >= 0) {
|
|---|
| 194 | WinSendDlgItemMsg(hwnd, ASEL_LISTBOX, LM_SELECTITEM,
|
|---|
| 195 | MPFROMSHORT(sOldSelect), MPFROMSHORT(TRUE));
|
|---|
| 196 | }
|
|---|
| 197 | }
|
|---|
| 198 |
|
|---|
| 199 | if (found)
|
|---|
| 200 | PosOverOkay(hwnd);
|
|---|
| 201 | }
|
|---|
| 202 |
|
|---|
| 203 | ARC_TYPE *find_type(CHAR * filespec, ARC_TYPE * topsig)
|
|---|
| 204 | {
|
|---|
| 205 | HFILE handle;
|
|---|
| 206 | ULONG action;
|
|---|
| 207 | ULONG len;
|
|---|
| 208 | ULONG l;
|
|---|
| 209 | ARC_TYPE *info;
|
|---|
| 210 | CHAR *p;
|
|---|
| 211 | CHAR buffer[4096]; // 06 Oct 07 SHL Protect against NTFS defect
|
|---|
| 212 |
|
|---|
| 213 | if (!arcsigsloaded)
|
|---|
| 214 | load_archivers();
|
|---|
| 215 | if (!topsig)
|
|---|
| 216 | topsig = arcsighead;
|
|---|
| 217 | DosError(FERR_DISABLEHARDERR);
|
|---|
| 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))
|
|---|
| 229 | return NULL;
|
|---|
| 230 | // Scan signatures
|
|---|
| 231 | for (info = topsig; info; info = info->next) {
|
|---|
| 232 | if (info->siglen == 0) {
|
|---|
| 233 | // No signature -- check extension
|
|---|
| 234 | p = strrchr(filespec, '.');
|
|---|
| 235 | if (p) {
|
|---|
| 236 | p++;
|
|---|
| 237 | if (info->ext && *(info->ext) && !stricmp(p, info->ext))
|
|---|
| 238 | break; // Matched
|
|---|
| 239 |
|
|---|
| 240 | }
|
|---|
| 241 | continue; // Next sig
|
|---|
| 242 |
|
|---|
| 243 | }
|
|---|
| 244 | // Try signature match
|
|---|
| 245 | l = info->siglen;
|
|---|
| 246 | l = min(l, 79);
|
|---|
| 247 | if (!DosChgFilePtr(handle,
|
|---|
| 248 | abs(info->file_offset),
|
|---|
| 249 | (info->file_offset >= 0) ? FILE_BEGIN : FILE_END,
|
|---|
| 250 | &len)) {
|
|---|
| 251 | if (!DosRead(handle, buffer, l, &len) && len == l) {
|
|---|
| 252 | if (!memcmp(info->signature, buffer, l))
|
|---|
| 253 | break; // Matched
|
|---|
| 254 |
|
|---|
| 255 | }
|
|---|
| 256 | }
|
|---|
| 257 | } // for
|
|---|
| 258 |
|
|---|
| 259 | DosClose(handle); // Either way, we're done for now
|
|---|
| 260 | return info; // Return signature, if any
|
|---|
| 261 | }
|
|---|
| 262 |
|
|---|
| 263 | # ifdef FORTIFY
|
|---|
| 264 |
|
|---|
| 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 |
|
|---|
| 293 | //=== free_arc_type() free allocated ARC_TYPE ===
|
|---|
| 294 |
|
|---|
| 295 | # endif
|
|---|
| 296 |
|
|---|
| 297 | VOID free_arc_type(ARC_TYPE * pat)
|
|---|
| 298 | {
|
|---|
| 299 | if (pat) {
|
|---|
| 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__);
|
|---|
| 315 | free(pat);
|
|---|
| 316 | }
|
|---|
| 317 | }
|
|---|
| 318 |
|
|---|
| 319 | static UINT cur_line_num; // Input file line counter
|
|---|
| 320 |
|
|---|
| 321 | //=== get_line_strip_comments() read line, strip comments and whitespace ===
|
|---|
| 322 |
|
|---|
| 323 | static PSZ get_line_strip_comments(PSZ pszIn, FILE * fp)
|
|---|
| 324 | {
|
|---|
| 325 | PSZ psz = xfgets(pszIn, ARCHIVER_LINE_BYTES, fp, pszSrcFile, __LINE__);
|
|---|
| 326 | PSZ psz2;
|
|---|
| 327 |
|
|---|
| 328 | if (psz) {
|
|---|
| 329 | cur_line_num++;
|
|---|
| 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 |
|
|---|
| 339 | //=== get_line_strip_white() read line, strip whitespace ===
|
|---|
| 340 |
|
|---|
| 341 | static PSZ get_line_strip_white(PSZ pszIn, FILE * fp)
|
|---|
| 342 | {
|
|---|
| 343 | PSZ psz =
|
|---|
| 344 | xfgets_bstripcr(pszIn, ARCHIVER_LINE_BYTES, fp, pszSrcFile, __LINE__);
|
|---|
| 345 |
|
|---|
| 346 | if (psz)
|
|---|
| 347 | cur_line_num++;
|
|---|
| 348 |
|
|---|
| 349 | return psz;
|
|---|
| 350 | }
|
|---|
| 351 |
|
|---|
| 352 | //=== load_archivers() load or reload archive definitions from archiver.bb2 ===
|
|---|
| 353 |
|
|---|
| 354 | INT load_archivers(VOID)
|
|---|
| 355 | {
|
|---|
| 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;
|
|---|
| 363 | INT i;
|
|---|
| 364 | CHAR *moder = "r";
|
|---|
| 365 |
|
|---|
| 366 | // Free current signatures
|
|---|
| 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;
|
|---|
| 377 | arcsigs_header_lines = 0;
|
|---|
| 378 | arcsigs_trailer_line_num = 0;
|
|---|
| 379 |
|
|---|
| 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);
|
|---|
| 390 | DosReleaseMutexSem(hmtxFM2Globals);
|
|---|
| 391 | if (!fp)
|
|---|
| 392 | return -2;
|
|---|
| 393 | strcpy(archiverbb2, szFullFilename); // Remember full path
|
|---|
| 394 | }
|
|---|
| 395 |
|
|---|
| 396 | cur_line_num = 0;
|
|---|
| 397 |
|
|---|
| 398 | // Line 1 must contain number of lines per signature definition
|
|---|
| 399 | if (!get_line_strip_comments(sz, fp)) {
|
|---|
| 400 | fclose(fp);
|
|---|
| 401 | return -3;
|
|---|
| 402 | }
|
|---|
| 403 | if (*sz)
|
|---|
| 404 | lines_per_arcsig = atoi(sz);
|
|---|
| 405 | if (!*sz || lines_per_arcsig < LINES_PER_ARCSIG) {
|
|---|
| 406 | fclose(fp); // 25 Aug 07 SHL
|
|---|
| 407 | return -3;
|
|---|
| 408 | }
|
|---|
| 409 |
|
|---|
| 410 | // Parse rest of file
|
|---|
| 411 | // 1st non-blank line starts definition
|
|---|
| 412 | // Need to determine header size and start of trailer
|
|---|
| 413 |
|
|---|
| 414 | while (!feof(fp)) {
|
|---|
| 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, ';');
|
|---|
| 429 |
|
|---|
| 430 | if (psz2) {
|
|---|
| 431 | *psz2 = 0; // Chop trailing comment
|
|---|
| 432 | bstripcr(sz); // Strip leading white and trailing white and CR/LF
|
|---|
| 433 | }
|
|---|
| 434 | arcsigs_header_lines = cur_line_num - 1;
|
|---|
| 435 | }
|
|---|
| 436 | }
|
|---|
| 437 | else {
|
|---|
| 438 | // Reading defintiions
|
|---|
| 439 | if (!get_line_strip_comments(sz, fp))
|
|---|
| 440 | break; // EOF
|
|---|
| 441 | }
|
|---|
| 442 |
|
|---|
| 443 | // fixme to avoid allocating empty fields
|
|---|
| 444 |
|
|---|
| 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 |
|
|---|
| 449 | if (*sz) {
|
|---|
| 450 | // At start of defintion
|
|---|
| 451 |
|
|---|
| 452 | pat = xmallocz(sizeof(ARC_TYPE), pszSrcFile, __LINE__);
|
|---|
| 453 | if (!pat)
|
|---|
| 454 | break;
|
|---|
| 455 | pat->id = xstrdup(sz, pszSrcFile, __LINE__);
|
|---|
| 456 |
|
|---|
| 457 | pat->comment_line_num = per_sig_comment_line_num;
|
|---|
| 458 | pat->defn_line_num = cur_line_num;
|
|---|
| 459 |
|
|---|
| 460 | if (!get_line_strip_comments(sz, fp)) // line 2 - extension
|
|---|
| 461 | break;
|
|---|
| 462 | if (*sz)
|
|---|
| 463 | pat->ext = xstrdup(sz, pszSrcFile, __LINE__);
|
|---|
| 464 | else
|
|---|
| 465 | pat->ext = NULL;
|
|---|
| 466 | if (!get_line_strip_comments(sz, fp)) // line 3 - offset to signature
|
|---|
| 467 | break;
|
|---|
| 468 | pat->file_offset = atol(sz);
|
|---|
| 469 | if (!get_line_strip_comments(sz, fp)) // line 4 - list command
|
|---|
| 470 | break;
|
|---|
| 471 | if (*sz)
|
|---|
| 472 | pat->list = xstrdup(sz, pszSrcFile, __LINE__);
|
|---|
| 473 | else
|
|---|
| 474 | pat->list = NULL;
|
|---|
| 475 | if (!pat->list)
|
|---|
| 476 | break; // Must have list command - fixme to complain
|
|---|
| 477 | if (!get_line_strip_comments(sz, fp)) // line 5
|
|---|
| 478 | break;
|
|---|
| 479 | if (*sz)
|
|---|
| 480 | pat->extract = xstrdup(sz, pszSrcFile, __LINE__);
|
|---|
| 481 | else
|
|---|
| 482 | pat->extract = NULL;
|
|---|
| 483 | if (!get_line_strip_comments(sz, fp)) // line 6
|
|---|
| 484 | break;
|
|---|
| 485 | if (*sz)
|
|---|
| 486 | pat->exwdirs = xstrdup(sz, pszSrcFile, __LINE__);
|
|---|
| 487 | else
|
|---|
| 488 | pat->exwdirs = NULL;
|
|---|
| 489 | if (!get_line_strip_comments(sz, fp)) // line 7
|
|---|
| 490 | break;
|
|---|
| 491 | if (*sz)
|
|---|
| 492 | pat->test = xstrdup(sz, pszSrcFile, __LINE__);
|
|---|
| 493 | else
|
|---|
| 494 | pat->test = NULL;
|
|---|
| 495 | if (!get_line_strip_comments(sz, fp)) // line 8
|
|---|
| 496 | break;
|
|---|
| 497 | if (*sz)
|
|---|
| 498 | pat->create = xstrdup(sz, pszSrcFile, __LINE__);
|
|---|
| 499 | else
|
|---|
| 500 | pat->create = NULL;
|
|---|
| 501 | if (!get_line_strip_comments(sz, fp)) // line 9
|
|---|
| 502 | break;
|
|---|
| 503 | if (*sz)
|
|---|
| 504 | pat->createwdirs = xstrdup(sz, pszSrcFile, __LINE__);
|
|---|
| 505 | else
|
|---|
| 506 | pat->createwdirs = NULL;
|
|---|
| 507 | if (!get_line_strip_comments(sz, fp)) // line 10
|
|---|
| 508 | break;
|
|---|
| 509 | if (*sz)
|
|---|
| 510 | pat->createrecurse = xstrdup(sz, pszSrcFile, __LINE__);
|
|---|
| 511 | else
|
|---|
| 512 | pat->createrecurse = NULL;
|
|---|
| 513 | if (!get_line_strip_comments(sz, fp)) // line 11
|
|---|
| 514 | break;
|
|---|
| 515 | if (*sz)
|
|---|
| 516 | pat->move = xstrdup(sz, pszSrcFile, __LINE__);
|
|---|
| 517 | else
|
|---|
| 518 | pat->move = NULL;
|
|---|
| 519 | if (!get_line_strip_comments(sz, fp)) // line 12
|
|---|
| 520 | break;
|
|---|
| 521 | if (*sz)
|
|---|
| 522 | pat->movewdirs = xstrdup(sz, pszSrcFile, __LINE__);
|
|---|
| 523 | else
|
|---|
| 524 | pat->movewdirs = NULL;
|
|---|
| 525 | if (!get_line_strip_comments(sz, fp)) // line 13
|
|---|
| 526 | break;
|
|---|
| 527 | if (*sz)
|
|---|
| 528 | pat->delete = xstrdup(sz, pszSrcFile, __LINE__);
|
|---|
| 529 | else
|
|---|
| 530 | pat->delete = NULL;
|
|---|
| 531 | if (!get_line_strip_white(sz, fp)) // line 14
|
|---|
| 532 | break;
|
|---|
| 533 | i = literal(sz); // Translate \ escapes
|
|---|
| 534 | if (i) {
|
|---|
| 535 | pat->siglen = i;
|
|---|
| 536 | pat->signature = xmalloc(i, pszSrcFile, __LINE__);
|
|---|
| 537 | if (!pat->signature)
|
|---|
| 538 | break;
|
|---|
| 539 | memcpy(pat->signature, sz, i); // signature may not be a string
|
|---|
| 540 | }
|
|---|
| 541 | else {
|
|---|
| 542 | pat->siglen = 0;
|
|---|
| 543 | pat->signature = NULL;
|
|---|
| 544 | }
|
|---|
| 545 | if (!get_line_strip_white(sz, fp)) // line 15
|
|---|
| 546 | break;
|
|---|
| 547 | if (*sz)
|
|---|
| 548 | pat->startlist = xstrdup(sz, pszSrcFile, __LINE__);
|
|---|
| 549 | else
|
|---|
| 550 | pat->startlist = NULL;
|
|---|
| 551 | if (!get_line_strip_white(sz, fp)) // line 16
|
|---|
| 552 | break;
|
|---|
| 553 | if (*sz)
|
|---|
| 554 | pat->endlist = xstrdup(sz, pszSrcFile, __LINE__);
|
|---|
| 555 | else
|
|---|
| 556 | pat->endlist = NULL;
|
|---|
| 557 | if (!get_line_strip_comments(sz, fp)) // line 17
|
|---|
| 558 | break;
|
|---|
| 559 | pat->osizepos = atoi(sz);
|
|---|
| 560 | if (!get_line_strip_comments(sz, fp)) // line 18
|
|---|
| 561 | break;
|
|---|
| 562 | pat->nsizepos = atoi(sz);
|
|---|
| 563 | if (!get_line_strip_comments(sz, fp)) // line 19
|
|---|
| 564 | break;
|
|---|
| 565 | pat->fdpos = atoi(sz);
|
|---|
| 566 | psz = strchr(sz, ',');
|
|---|
| 567 | if (psz) {
|
|---|
| 568 | psz++;
|
|---|
| 569 | pat->datetype = atoi(psz);
|
|---|
| 570 | }
|
|---|
| 571 | if (!get_line_strip_comments(sz, fp)) // line 20
|
|---|
| 572 | break;
|
|---|
| 573 | pat->fdflds = atoi(sz);
|
|---|
| 574 | if (!get_line_strip_comments(sz, fp)) // line 21
|
|---|
| 575 | break;
|
|---|
| 576 | pat->fnpos = atoi(sz);
|
|---|
| 577 | psz = strchr(sz, ',');
|
|---|
| 578 | if (psz) {
|
|---|
| 579 | psz++;
|
|---|
| 580 | pat->nameislast = (BOOL) (*psz && atol(psz) == 0) ? FALSE : TRUE;
|
|---|
| 581 | psz = strchr(psz, ',');
|
|---|
| 582 | if (psz) {
|
|---|
| 583 | psz++;
|
|---|
| 584 | pat->nameisnext = (BOOL) (*psz && atol(psz) == 0) ? FALSE : TRUE;
|
|---|
| 585 | psz = strchr(psz, ',');
|
|---|
| 586 | if (psz) {
|
|---|
| 587 | psz++;
|
|---|
| 588 | pat->nameisfirst = (BOOL) (*psz && atol(psz) == 0) ? FALSE : TRUE;
|
|---|
| 589 | }
|
|---|
| 590 | }
|
|---|
| 591 | }
|
|---|
| 592 | // Ignore unknown lines - must be newer file format
|
|---|
| 593 | for (i = LINES_PER_ARCSIG; i < lines_per_arcsig; i++) {
|
|---|
| 594 | if (!get_line_strip_comments(sz, fp))
|
|---|
| 595 | break; // Unexpected EOF - fixme to complain
|
|---|
| 596 | }
|
|---|
| 597 |
|
|---|
| 598 | // Add to list, assume next and prev already NULL
|
|---|
| 599 | if (!arcsighead)
|
|---|
| 600 | arcsighead = patLast = pat;
|
|---|
| 601 | else {
|
|---|
| 602 | patLast->next = pat;
|
|---|
| 603 | pat->prev = patLast;
|
|---|
| 604 | patLast = pat;
|
|---|
| 605 | }
|
|---|
| 606 | pat = NULL; // Done with this defintion
|
|---|
| 607 |
|
|---|
| 608 | arcsigs_trailer_line_num = cur_line_num + 1; // In case this is last defintion
|
|---|
| 609 | per_sig_comment_line_num = 0;
|
|---|
| 610 | } // if got definition
|
|---|
| 611 |
|
|---|
| 612 | } // while more lines
|
|---|
| 613 |
|
|---|
| 614 | fclose(fp);
|
|---|
| 615 |
|
|---|
| 616 | free_arc_type(pat); // In case partial definition in progress
|
|---|
| 617 |
|
|---|
| 618 | if (!arcsighead)
|
|---|
| 619 | return -4;
|
|---|
| 620 |
|
|---|
| 621 | arcsigsloaded = TRUE;
|
|---|
| 622 |
|
|---|
| 623 | return 0;
|
|---|
| 624 | }
|
|---|
| 625 |
|
|---|
| 626 | #define TEST_DRAG 0 // fixme to be gone or to work
|
|---|
| 627 |
|
|---|
| 628 | static MRESULT EXPENTRY SDlgListboxSubclassProc(HWND hwnd, ULONG msg,
|
|---|
| 629 | MPARAM mp1, MPARAM mp2)
|
|---|
| 630 | {
|
|---|
| 631 | PFNWP pfnOldProc = (PFNWP) WinQueryWindowPtr(hwnd, QWL_USER);
|
|---|
| 632 |
|
|---|
| 633 | PDRAGITEM pDItem;
|
|---|
| 634 | PDRAGINFO pDInfo;
|
|---|
| 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 |
|
|---|
| 641 | switch (msg) {
|
|---|
| 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) {
|
|---|
| 652 | pDInfo = DrgAllocDraginfo(1);
|
|---|
| 653 | if (pDInfo) {
|
|---|
| 654 | pDInfo->usOperation = DO_DEFAULT;
|
|---|
| 655 | pDInfo->hwndSource = hwnd;
|
|---|
| 656 |
|
|---|
| 657 | memset(&ditem, 0, sizeof(DRAGITEM));
|
|---|
| 658 | ditem.hwndItem = hwnd;
|
|---|
| 659 | ditem.ulItemID = 1;
|
|---|
| 660 | ditem.hstrType = DrgAddStrHandle(DRT_UNKNOWN);
|
|---|
| 661 | ditem.hstrRMF = DrgAddStrHandle(DRMDRF_LBOX);
|
|---|
| 662 | ditem.hstrContainerName = DrgAddStrHandle(NullStr);
|
|---|
| 663 | ditem.hstrSourceName = DrgAddStrHandle(NullStr);
|
|---|
| 664 | ditem.hstrTargetName = DrgAddStrHandle(NullStr);
|
|---|
| 665 | ditem.fsSupportedOps = DO_MOVEABLE;
|
|---|
| 666 |
|
|---|
| 667 | memset(&dimage, 0, sizeof(DRAGIMAGE));
|
|---|
| 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;
|
|---|
| 676 | DrgSetDragitem(pDInfo, &ditem, sizeof(DRAGITEM), 0); // Index of DRAGITEM
|
|---|
| 677 | hwndDrop = DrgDrag(hwnd, pDInfo, &dimage, 1, // One DRAGIMAGE
|
|---|
| 678 | VK_ENDDRAG, NULL);
|
|---|
| 679 | if (!hwndDrop)
|
|---|
| 680 | Win_Error(hwnd, hwnd, pszSrcFile, __LINE__, "DrgDrag");
|
|---|
| 681 |
|
|---|
| 682 | DrgFreeDraginfo(pDInfo);
|
|---|
| 683 | }
|
|---|
| 684 | }
|
|---|
| 685 | break;
|
|---|
| 686 | }
|
|---|
| 687 |
|
|---|
| 688 | case DM_DRAGOVER:
|
|---|
| 689 | ok = FALSE;
|
|---|
| 690 | if (!emphasized) {
|
|---|
| 691 | POINTL ptl;
|
|---|
| 692 | POINTL ptl2;
|
|---|
| 693 |
|
|---|
| 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,
|
|---|
| 700 | MPFROM2SHORT((SHORT) ptl2.x, (SHORT) ptl2.y),
|
|---|
| 701 | MPFROM2SHORT(HT_NORMAL, KC_NONE));
|
|---|
| 702 | }
|
|---|
| 703 | pDInfo = (PDRAGINFO) mp1; // Get DRAGINFO pointer
|
|---|
| 704 | if (pDInfo) {
|
|---|
| 705 | if (!DrgAccessDraginfo(pDInfo)) {
|
|---|
| 706 | Win_Error(HWND_DESKTOP, HWND_DESKTOP, pszSrcFile, __LINE__,
|
|---|
| 707 | PCSZ_DRGACCESSDRAGINFO);
|
|---|
| 708 | }
|
|---|
| 709 | else {
|
|---|
| 710 | pDItem = DrgQueryDragitemPtr(pDInfo, 0);
|
|---|
| 711 | // Check valid rendering mechanisms and data format
|
|---|
| 712 | ok = DrgVerifyRMF(pDItem, DRM_LBOX, NULL);
|
|---|
| 713 | DrgFreeDraginfo(pDInfo);
|
|---|
| 714 | }
|
|---|
| 715 | }
|
|---|
| 716 | return ok ? MRFROM2SHORT(DOR_DROP, DO_MOVE) :
|
|---|
| 717 | MRFROM2SHORT(DOR_NEVERDROP, 0);
|
|---|
| 718 |
|
|---|
| 719 | case DM_DRAGLEAVE:
|
|---|
| 720 | if (emphasized) {
|
|---|
| 721 | emphasized = FALSE;
|
|---|
| 722 | // fixme to draw listbox item emphasized
|
|---|
| 723 | // DrawTargetEmphasis(hwnd, emphasized);
|
|---|
| 724 | }
|
|---|
| 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;
|
|---|
| 733 | if (emphasized) {
|
|---|
| 734 | emphasized = FALSE;
|
|---|
| 735 | // DrawTargetEmphasis(hwnd, emphasized);
|
|---|
| 736 | }
|
|---|
| 737 | pDInfo = (PDRAGINFO) mp1; // Get DRAGINFO pointer
|
|---|
| 738 | if (pDInfo) {
|
|---|
| 739 | if (!DrgAccessDraginfo(pDInfo)) {
|
|---|
| 740 | Win_Error(HWND_DESKTOP, HWND_DESKTOP, pszSrcFile, __LINE__,
|
|---|
| 741 | PCSZ_DRGACCESSDRAGINFO);
|
|---|
| 742 | }
|
|---|
| 743 | else {
|
|---|
| 744 | pDItem = DrgQueryDragitemPtr(pDInfo, 0);
|
|---|
| 745 | if (!pDItem)
|
|---|
| 746 | Win_Error(hwnd, hwnd, pszSrcFile, __LINE__, "DM_DROP");
|
|---|
| 747 | // Check valid rendering mechanisms and data
|
|---|
| 748 | ok = DrgVerifyRMF(pDItem, DRM_LBOX, NULL)
|
|---|
| 749 | && ~pDItem->fsControl & DC_PREPARE;
|
|---|
| 750 | if (ok) {
|
|---|
| 751 | // note: targetfail is returned to source for all items
|
|---|
| 752 | DrgSendTransferMsg(pDInfo->hwndSource, DM_ENDCONVERSATION,
|
|---|
| 753 | MPFROMLONG(pDItem->ulItemID),
|
|---|
| 754 | MPFROMLONG(DMFL_TARGETSUCCESSFUL));
|
|---|
| 755 | }
|
|---|
| 756 | FreeDragInfoData(hwnd, pDInfo);
|
|---|
| 757 | }
|
|---|
| 758 | }
|
|---|
| 759 | return 0;
|
|---|
| 760 | } // switch
|
|---|
| 761 | return pfnOldProc ? pfnOldProc(hwnd, msg, mp1, mp2) :
|
|---|
| 762 | WinDefWindowProc(hwnd, msg, mp1, mp2);
|
|---|
| 763 | }
|
|---|
| 764 |
|
|---|
| 765 | //=== SBoxDlgProc() Select archiver to use or edit, supports list reorder too ===
|
|---|
| 766 |
|
|---|
| 767 | static PSZ pszCantFindMsg = "Can't find item %d";
|
|---|
| 768 |
|
|---|
| 769 | MRESULT EXPENTRY SBoxDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
|---|
| 770 | {
|
|---|
| 771 | ARC_TYPE **ppatReturn; // Where to return selected archiver
|
|---|
| 772 | ARC_TYPE *pat;
|
|---|
| 773 | SHORT sSelect;
|
|---|
| 774 | SHORT sItemCount;
|
|---|
| 775 | CHAR szItemText[256];
|
|---|
| 776 | CHAR szPCItemText[256]; // Parent or child item text
|
|---|
| 777 | SHORT i;
|
|---|
| 778 | BOOL fShowAll;
|
|---|
| 779 |
|
|---|
| 780 | static SHORT sLastSelect = LIT_NONE;
|
|---|
| 781 |
|
|---|
| 782 | switch (msg) {
|
|---|
| 783 | case WM_INITDLG:
|
|---|
| 784 | if (!arcsigsloaded)
|
|---|
| 785 | load_archivers();
|
|---|
| 786 | else {
|
|---|
| 787 | struct stat Buffer;
|
|---|
| 788 |
|
|---|
| 789 | stat(archiverbb2, &Buffer); // jbs: Re-use full name set by load_achivers
|
|---|
| 790 | if (Archiverbb2Stats.st_size != Buffer.st_size ||
|
|---|
| 791 | Archiverbb2Stats.st_mtime != Buffer.st_mtime)
|
|---|
| 792 | if (saymsg(MB_YESNO,
|
|---|
| 793 | hwnd,
|
|---|
| 794 | GetPString(IDS_ADCHANGESONDISKTEXT),
|
|---|
| 795 | GetPString(IDS_ADRELOADMEMTEXT)) == MBID_YES)
|
|---|
| 796 | load_archivers();
|
|---|
| 797 | }
|
|---|
| 798 | if (!(ARC_TYPE **) mp2) {
|
|---|
| 799 | Runtime_Error(pszSrcFile, __LINE__, NULL);
|
|---|
| 800 | WinDismissDlg(hwnd, 0);
|
|---|
| 801 | break;
|
|---|
| 802 | }
|
|---|
| 803 | /** Passed arg points to where to return selected archiver definition
|
|---|
| 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 | */
|
|---|
| 808 | ppatReturn = (ARC_TYPE **) mp2;
|
|---|
| 809 | fShowAll = *ppatReturn == NULL;
|
|---|
| 810 | if (*ppatReturn)
|
|---|
| 811 | *ppatReturn = arcsighead; // Preset to first
|
|---|
| 812 | WinSetWindowPtr(hwnd, QWL_USER, (PVOID) ppatReturn);
|
|---|
| 813 | fill_listbox(hwnd, fShowAll, sLastSelect);
|
|---|
| 814 |
|
|---|
| 815 | #ifdef TEST_DRAG // fixme
|
|---|
| 816 | {
|
|---|
| 817 | HWND hwnd2 = WinWindowFromID(hwnd, ASEL_LISTBOX);
|
|---|
| 818 | PFNWP pfn = WinSubclassWindow(hwnd2,
|
|---|
| 819 | SDlgListboxSubclassProc);
|
|---|
| 820 |
|
|---|
| 821 | WinSetWindowPtr(hwnd2, QWL_USER, (PVOID) pfn);
|
|---|
| 822 | }
|
|---|
| 823 | #endif // TEST_DRAG fixme
|
|---|
| 824 |
|
|---|
| 825 | break;
|
|---|
| 826 |
|
|---|
| 827 | case WM_HELP:
|
|---|
| 828 | if (hwndHelp)
|
|---|
| 829 | WinSendMsg(hwndHelp,
|
|---|
| 830 | HM_DISPLAY_HELP,
|
|---|
| 831 | MPFROMSHORT(1), MPFROMSHORT(HM_RESOURCEID));
|
|---|
| 832 | break;
|
|---|
| 833 |
|
|---|
| 834 | case WM_COMMAND:
|
|---|
| 835 | ppatReturn = (ARC_TYPE **) WinQueryWindowPtr(hwnd, QWL_USER);
|
|---|
| 836 | switch (SHORT1FROMMP(mp1)) {
|
|---|
| 837 | case DID_OK:
|
|---|
| 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");
|
|---|
| 844 | return 0;
|
|---|
| 845 | }
|
|---|
| 846 | pat = arcsighead;
|
|---|
| 847 | if (*ppatReturn) {
|
|---|
| 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;
|
|---|
| 854 | else {
|
|---|
| 855 | for (; pat; pat = pat->next) {
|
|---|
| 856 | if (pat->id && !strcmp(szItemText, pat->id))
|
|---|
| 857 | break; // Found it
|
|---|
| 858 | }
|
|---|
| 859 | }
|
|---|
| 860 | }
|
|---|
| 861 | else {
|
|---|
| 862 | // If dups not hidden, lookup by count
|
|---|
| 863 | for (i = 0; pat && i < sSelect; i++, pat = pat->next) ; // Scan
|
|---|
| 864 | }
|
|---|
| 865 | if (pat && (!*ppatReturn || (pat->id && pat->extract && pat->create))) {
|
|---|
| 866 | *ppatReturn = pat;
|
|---|
| 867 | }
|
|---|
| 868 | else {
|
|---|
| 869 | Runtime_Error(pszSrcFile, __LINE__, "no match");
|
|---|
| 870 | // Refuse to select
|
|---|
| 871 | WinSendDlgItemMsg(hwnd, ASEL_LISTBOX, LM_SELECTITEM,
|
|---|
| 872 | MPFROMSHORT(LIT_NONE), FALSE);
|
|---|
| 873 | return 0;
|
|---|
| 874 | }
|
|---|
| 875 | PrfWriteProfileData(fmprof, appname, "LastArchiver", &sSelect, sizeof(SHORT));
|
|---|
| 876 | sLastSelect = sSelect;
|
|---|
| 877 | WinDismissDlg(hwnd, TRUE);
|
|---|
| 878 | return 0;
|
|---|
| 879 |
|
|---|
| 880 | case DID_CANCEL:
|
|---|
| 881 | if (arcsigsmodified) {
|
|---|
| 882 | if (saymsg(MB_YESNO,
|
|---|
| 883 | hwnd,
|
|---|
| 884 | GetPString(IDS_ADCHANGESINMEMTEXT),
|
|---|
| 885 | GetPString(IDS_ADREWRITETEXT), NullStr) == MBID_YES)
|
|---|
| 886 | rewrite_archiverbb2(archiverbb2);
|
|---|
| 887 | }
|
|---|
| 888 | sSelect = (SHORT) WinSendDlgItemMsg(hwnd,
|
|---|
| 889 | ASEL_LISTBOX,
|
|---|
| 890 | LM_QUERYSELECTION,
|
|---|
| 891 | MPFROMSHORT(LIT_FIRST), MPVOID);
|
|---|
| 892 | if (sSelect != LIT_NONE) {
|
|---|
| 893 | sLastSelect = sSelect;
|
|---|
| 894 | PrfWriteProfileData(fmprof, appname, "LastArchiver", &sSelect, sizeof(SHORT));
|
|---|
| 895 | }
|
|---|
| 896 | *ppatReturn = NULL;
|
|---|
| 897 | PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID); // fixme to understand why needed
|
|---|
| 898 | return 0;
|
|---|
| 899 |
|
|---|
| 900 | case ASEL_PB_ADD:
|
|---|
| 901 | sSelect = (SHORT) WinSendDlgItemMsg(hwnd,
|
|---|
| 902 | ASEL_LISTBOX,
|
|---|
| 903 | LM_QUERYSELECTION,
|
|---|
| 904 | MPFROMSHORT(LIT_FIRST), MPVOID);
|
|---|
| 905 | if (sSelect != LIT_NONE) {
|
|---|
| 906 | ARCDUMP ad;
|
|---|
| 907 |
|
|---|
| 908 | memset(&ad, 0, sizeof(ARCDUMP));
|
|---|
| 909 | ad.info = xmallocz(sizeof(ARC_TYPE), pszSrcFile, __LINE__);
|
|---|
| 910 | if (ad.info) {
|
|---|
| 911 | if (!WinDlgBox(HWND_DESKTOP,
|
|---|
| 912 | hwnd,
|
|---|
| 913 | ArcReviewDlgProc,
|
|---|
| 914 | FM3ModHandle, AD_FRAME, MPFROMP(&ad))) {
|
|---|
| 915 | free(ad.info);
|
|---|
| 916 | }
|
|---|
| 917 | else {
|
|---|
| 918 | // Find self - assume all archivers listed since we are editing
|
|---|
| 919 | for (i = 0, pat = arcsighead; pat && i < sSelect; pat = pat->next, i++) ; // Find self
|
|---|
| 920 |
|
|---|
| 921 | if (!pat) {
|
|---|
| 922 | if (arcsighead)
|
|---|
| 923 | Runtime_Error(pszSrcFile, __LINE__, pszCantFindMsg, sSelect);
|
|---|
| 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 | }
|
|---|
| 941 | WinSendDlgItemMsg(hwnd, ASEL_LISTBOX, LM_INSERTITEM,
|
|---|
| 942 | MPFROM2SHORT(sSelect, 0),
|
|---|
| 943 | MPFROMP(ad.info->id ? ad.info->id : "?"));
|
|---|
| 944 | WinSendDlgItemMsg(hwnd, ASEL_LISTBOX, LM_SELECTITEM,
|
|---|
| 945 | MPFROMSHORT(sSelect - 1), MPFROMSHORT(TRUE));
|
|---|
| 946 | arcsigsmodified = TRUE;
|
|---|
| 947 | }
|
|---|
| 948 | }
|
|---|
| 949 | }
|
|---|
| 950 | return 0;
|
|---|
| 951 | case ASEL_PB_DELETE:
|
|---|
| 952 | sSelect = (SHORT) WinSendDlgItemMsg(hwnd,
|
|---|
| 953 | ASEL_LISTBOX,
|
|---|
| 954 | LM_QUERYSELECTION,
|
|---|
| 955 | MPFROMSHORT(LIT_FIRST), MPVOID);
|
|---|
| 956 | if (sSelect != LIT_NONE) {
|
|---|
| 957 | // Find self - assume all archivers listed since we are editing
|
|---|
| 958 | for (i = 0, pat = arcsighead; pat && i < sSelect; pat = pat->next, i++) ; // Find self
|
|---|
| 959 |
|
|---|
| 960 | if (!pat)
|
|---|
| 961 | Runtime_Error(pszSrcFile, __LINE__, pszCantFindMsg, sSelect);
|
|---|
| 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;
|
|---|
| 968 | }
|
|---|
| 969 | else {
|
|---|
| 970 | arcsighead = pat->next;
|
|---|
| 971 | if (pat->next)
|
|---|
| 972 | pat->next->prev = pat->prev;
|
|---|
| 973 | }
|
|---|
| 974 | }
|
|---|
| 975 | free_arc_type(pat);
|
|---|
| 976 | arcsigsmodified = TRUE;
|
|---|
| 977 | WinSendDlgItemMsg(hwnd, ASEL_LISTBOX, LM_DELETEITEM,
|
|---|
| 978 | MPFROM2SHORT(sSelect, 0), MPVOID);
|
|---|
| 979 | sItemCount =
|
|---|
| 980 | (SHORT) WinSendDlgItemMsg(hwnd, ASEL_LISTBOX, LM_QUERYITEMCOUNT,
|
|---|
| 981 | MPVOID, MPVOID);
|
|---|
| 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:
|
|---|
| 991 | sSelect = (SHORT) WinSendDlgItemMsg(hwnd,
|
|---|
| 992 | ASEL_LISTBOX,
|
|---|
| 993 | LM_QUERYSELECTION,
|
|---|
| 994 | MPFROMSHORT(LIT_FIRST), MPVOID);
|
|---|
| 995 | if (sSelect != LIT_NONE && sSelect > 0) {
|
|---|
| 996 | // Find self - assume all archivers listed since we are editing
|
|---|
| 997 | for (i = 0, pat = arcsighead; pat && i < sSelect; pat = pat->next, i++) ; // Find self
|
|---|
| 998 | if (!pat || !pat->prev)
|
|---|
| 999 | Runtime_Error(pszSrcFile, __LINE__, pszCantFindMsg, sSelect);
|
|---|
| 1000 | else {
|
|---|
| 1001 | ARC_TYPE *patGDad;
|
|---|
| 1002 | ARC_TYPE *patDad;
|
|---|
| 1003 | ARC_TYPE *patChild;
|
|---|
| 1004 |
|
|---|
| 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;
|
|---|
| 1016 | }
|
|---|
| 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,
|
|---|
| 1025 | MPFROM2SHORT(sSelect - 1, 255),
|
|---|
| 1026 | MPFROMP(szPCItemText));
|
|---|
| 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;
|
|---|
| 1034 | }
|
|---|
| 1035 | }
|
|---|
| 1036 | return 0;
|
|---|
| 1037 | case ASEL_PB_DOWN:
|
|---|
| 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);
|
|---|
| 1044 | if (sSelect != LIT_NONE && sSelect < sItemCount - 1) {
|
|---|
| 1045 | // Find self - assume all archivers listed since we are editing
|
|---|
| 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);
|
|---|
| 1050 | else {
|
|---|
| 1051 | ARC_TYPE *patDad;
|
|---|
| 1052 | ARC_TYPE *patChild;
|
|---|
| 1053 |
|
|---|
| 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;
|
|---|
| 1062 | patChild->prev = patDad;
|
|---|
| 1063 | }
|
|---|
| 1064 | else {
|
|---|
| 1065 | arcsighead = patChild;
|
|---|
| 1066 | patChild->prev = NULL;
|
|---|
| 1067 | }
|
|---|
| 1068 |
|
|---|
| 1069 | WinSendDlgItemMsg(hwnd, ASEL_LISTBOX, LM_QUERYITEMTEXT,
|
|---|
| 1070 | MPFROM2SHORT(sSelect, 255), MPFROMP(szItemText));
|
|---|
| 1071 | WinSendDlgItemMsg(hwnd, ASEL_LISTBOX, LM_QUERYITEMTEXT,
|
|---|
| 1072 | MPFROM2SHORT(sSelect + 1, 255),
|
|---|
| 1073 | MPFROMP(szPCItemText));
|
|---|
| 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));
|
|---|
| 1078 | WinSendDlgItemMsg(hwnd, ASEL_LISTBOX, LM_SELECTITEM,
|
|---|
| 1079 | MPFROMSHORT(sSelect + 1), MPFROMSHORT(TRUE));
|
|---|
| 1080 | arcsigsmodified = TRUE;
|
|---|
| 1081 | }
|
|---|
| 1082 | }
|
|---|
| 1083 | return 0;
|
|---|
| 1084 |
|
|---|
| 1085 | case ASEL_PB_REVERT:
|
|---|
| 1086 | // Reload without checking in case changed outside
|
|---|
| 1087 | sSelect =
|
|---|
| 1088 | (SHORT) WinSendDlgItemMsg(hwnd, ASEL_LISTBOX, LM_QUERYSELECTION,
|
|---|
| 1089 | MPFROMSHORT(LIT_FIRST), MPVOID);
|
|---|
| 1090 | load_archivers();
|
|---|
| 1091 | fill_listbox(hwnd, TRUE, sSelect);
|
|---|
| 1092 | return 0;
|
|---|
| 1093 |
|
|---|
| 1094 | case IDM_HELP:
|
|---|
| 1095 | if (hwndHelp) {
|
|---|
| 1096 | WinSendMsg(hwndHelp, HM_DISPLAY_HELP, MPFROM2SHORT(HELP_EDITARC, 0), // fixme to be HELP_SELARC
|
|---|
| 1097 | MPFROMSHORT(HM_RESOURCEID));
|
|---|
| 1098 | }
|
|---|
| 1099 | }
|
|---|
| 1100 | return 0; // WM_COMMAND
|
|---|
| 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);
|
|---|
| 1115 | }
|
|---|
| 1116 |
|
|---|
| 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
|
|---|
| 1124 | * Aug 21 23:55 2011 6 Fixes tar.gz date/time formatting when using tar 1..15+
|
|---|
| 1125 | */
|
|---|
| 1126 |
|
|---|
| 1127 | BOOL ArcDateTime(CHAR * dt, INT type, CDATE * cdate, CTIME * ctime)
|
|---|
| 1128 | {
|
|---|
| 1129 | INT x;
|
|---|
| 1130 | BOOL ret = FALSE;
|
|---|
| 1131 | CHAR *p, *pp, *pd;
|
|---|
| 1132 |
|
|---|
| 1133 | if (dt && cdate && ctime) {
|
|---|
| 1134 | memset(cdate, 0, sizeof(CDATE));
|
|---|
| 1135 | memset(ctime, 0, sizeof(CTIME));
|
|---|
| 1136 | if (type) {
|
|---|
| 1137 | p = dt;
|
|---|
| 1138 | while (*p && *p == ' ')
|
|---|
| 1139 | p++;
|
|---|
| 1140 | pd = dt;
|
|---|
| 1141 | switch (type) {
|
|---|
| 1142 | case 1:
|
|---|
| 1143 | cdate->month = atoi(pd);
|
|---|
| 1144 | p = to_delim(pd, "-/.");
|
|---|
| 1145 | if (p) {
|
|---|
| 1146 | p++;
|
|---|
| 1147 | cdate->day = atoi(p);
|
|---|
| 1148 | pd = p;
|
|---|
| 1149 | p = to_delim(pd, "-/.");
|
|---|
| 1150 | if (p) {
|
|---|
| 1151 | p++;
|
|---|
| 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;
|
|---|
| 1157 | ret = TRUE;
|
|---|
| 1158 | p = strchr(p, ' ');
|
|---|
| 1159 | if (p) {
|
|---|
| 1160 | while (*p && *p == ' ')
|
|---|
| 1161 | p++;
|
|---|
| 1162 | ctime->hours = atoi(p);
|
|---|
| 1163 | p = to_delim(pd, ":.");
|
|---|
| 1164 | if (p) {
|
|---|
| 1165 | p++;
|
|---|
| 1166 | ctime->minutes = atoi(p);
|
|---|
| 1167 | p = to_delim(pd, ":.");
|
|---|
| 1168 | if (p) {
|
|---|
| 1169 | p++;
|
|---|
| 1170 | ctime->seconds = atoi(p);
|
|---|
| 1171 | }
|
|---|
| 1172 | }
|
|---|
| 1173 | }
|
|---|
| 1174 | }
|
|---|
| 1175 | }
|
|---|
| 1176 | break;
|
|---|
| 1177 |
|
|---|
| 1178 | case 2:
|
|---|
| 1179 | cdate->day = atoi(p);
|
|---|
| 1180 | p = strchr(p, ' ');
|
|---|
| 1181 | if (p) {
|
|---|
| 1182 | p++;
|
|---|
| 1183 | for (x = 0; x < 12; x++) {
|
|---|
| 1184 | if (!strnicmp(p, GetPString(IDS_JANUARY + x), 3))
|
|---|
| 1185 | break;
|
|---|
| 1186 | }
|
|---|
| 1187 | if (x < 12) {
|
|---|
| 1188 | cdate->month = x + 1;
|
|---|
| 1189 | p = strchr(p, ' ');
|
|---|
| 1190 | if (p) {
|
|---|
| 1191 | p++;
|
|---|
| 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;
|
|---|
| 1197 | ret = TRUE;
|
|---|
| 1198 | p = strchr(p, ' ');
|
|---|
| 1199 | if (p) {
|
|---|
| 1200 | while (*p && *p == ' ')
|
|---|
| 1201 | p++;
|
|---|
| 1202 | ctime->hours = atoi(p);
|
|---|
| 1203 | p = to_delim(pd, ":.");
|
|---|
| 1204 | if (p) {
|
|---|
| 1205 | p++;
|
|---|
| 1206 | ctime->minutes = atoi(p);
|
|---|
| 1207 | p = to_delim(pd, ":.");
|
|---|
| 1208 | if (p) {
|
|---|
| 1209 | p++;
|
|---|
| 1210 | ctime->seconds = atoi(p);
|
|---|
| 1211 | }
|
|---|
| 1212 | }
|
|---|
| 1213 | }
|
|---|
| 1214 | }
|
|---|
| 1215 | }
|
|---|
| 1216 | }
|
|---|
| 1217 | break;
|
|---|
| 1218 |
|
|---|
| 1219 | case 3:
|
|---|
| 1220 | cdate->day = atoi(p);
|
|---|
| 1221 | p = strchr(p, ' ');
|
|---|
| 1222 | if (p) {
|
|---|
| 1223 | p++;
|
|---|
| 1224 | for (x = 0; x < 12; x++) {
|
|---|
| 1225 | if (!strnicmp(p, GetPString(IDS_JANUARY + x), 3))
|
|---|
| 1226 | break;
|
|---|
| 1227 | }
|
|---|
| 1228 | if (x < 12) {
|
|---|
| 1229 | cdate->month = x + 1;
|
|---|
| 1230 | p = strchr(p, ' ');
|
|---|
| 1231 | if (p) {
|
|---|
| 1232 | p++;
|
|---|
| 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;
|
|---|
| 1238 | ret = TRUE;
|
|---|
| 1239 | p = strchr(p, ' ');
|
|---|
| 1240 | if (p) {
|
|---|
| 1241 | while (*p && *p == ' ')
|
|---|
| 1242 | p++;
|
|---|
| 1243 | ctime->hours = atoi(p);
|
|---|
| 1244 | p = to_delim(pd, ":.");
|
|---|
| 1245 | if (p) {
|
|---|
| 1246 | p++;
|
|---|
| 1247 | pp = p;
|
|---|
| 1248 | ctime->minutes = atoi(p);
|
|---|
| 1249 | p = to_delim(pd, ":.");
|
|---|
| 1250 | if (p) {
|
|---|
| 1251 | p++;
|
|---|
| 1252 | ctime->seconds = atoi(p);
|
|---|
| 1253 | p += 2;
|
|---|
| 1254 | if (toupper(*p) == 'P')
|
|---|
| 1255 | ctime->hours += 12;
|
|---|
| 1256 | }
|
|---|
| 1257 | else {
|
|---|
| 1258 | p = pp;
|
|---|
| 1259 | p += 2;
|
|---|
| 1260 | if (toupper(*p) == 'P')
|
|---|
| 1261 | ctime->hours += 12;
|
|---|
| 1262 | }
|
|---|
| 1263 | }
|
|---|
| 1264 | }
|
|---|
| 1265 | }
|
|---|
| 1266 | }
|
|---|
| 1267 | }
|
|---|
| 1268 | break;
|
|---|
| 1269 |
|
|---|
| 1270 | case 4:
|
|---|
| 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;
|
|---|
| 1276 | p = to_delim(pd, "-/.");
|
|---|
| 1277 | if (p) {
|
|---|
| 1278 | p++;
|
|---|
| 1279 | cdate->month = atoi(p);
|
|---|
| 1280 | pd = p;
|
|---|
| 1281 | p = to_delim(pd, "-/.");
|
|---|
| 1282 | if (p) {
|
|---|
| 1283 | p++;
|
|---|
| 1284 | cdate->day = atoi(p);
|
|---|
| 1285 | ret = TRUE;
|
|---|
| 1286 | p = strchr(p, ' ');
|
|---|
| 1287 | if (p) {
|
|---|
| 1288 | while (*p && *p == ' ')
|
|---|
| 1289 | p++;
|
|---|
| 1290 | ctime->hours = atoi(p);
|
|---|
| 1291 | p = to_delim(pd, ":.");
|
|---|
| 1292 | if (p) {
|
|---|
| 1293 | p++;
|
|---|
| 1294 | ctime->minutes = atoi(p);
|
|---|
| 1295 | p = to_delim(pd, ":.");
|
|---|
| 1296 | if (p) {
|
|---|
| 1297 | p++;
|
|---|
| 1298 | ctime->seconds = atoi(p);
|
|---|
| 1299 | }
|
|---|
| 1300 | }
|
|---|
| 1301 | }
|
|---|
| 1302 | }
|
|---|
| 1303 | }
|
|---|
| 1304 | break;
|
|---|
| 1305 |
|
|---|
| 1306 | case 5:
|
|---|
| 1307 | cdate->day = atoi(pd);
|
|---|
| 1308 | p = to_delim(pd, "-/.");
|
|---|
| 1309 | if (p) {
|
|---|
| 1310 | p++;
|
|---|
| 1311 | cdate->month = atoi(p);
|
|---|
| 1312 | pd = p;
|
|---|
| 1313 | p = to_delim(pd, "-/.");
|
|---|
| 1314 | if (p) {
|
|---|
| 1315 | p++;
|
|---|
| 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;
|
|---|
| 1321 | ret = TRUE;
|
|---|
| 1322 | p = strchr(p, ' ');
|
|---|
| 1323 | if (p) {
|
|---|
| 1324 | while (*p && *p == ' ')
|
|---|
| 1325 | p++;
|
|---|
| 1326 | ctime->hours = atoi(p);
|
|---|
| 1327 | p = to_delim(pd, ":.");
|
|---|
| 1328 | if (p) {
|
|---|
| 1329 | p++;
|
|---|
| 1330 | ctime->minutes = atoi(p);
|
|---|
| 1331 | p = to_delim(pd, ":.");
|
|---|
| 1332 | if (p) {
|
|---|
| 1333 | p++;
|
|---|
| 1334 | ctime->seconds = atoi(p);
|
|---|
| 1335 | }
|
|---|
| 1336 | }
|
|---|
| 1337 | }
|
|---|
| 1338 | }
|
|---|
| 1339 | }
|
|---|
| 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;
|
|---|
| 1376 | default:
|
|---|
| 1377 | break;
|
|---|
| 1378 | }
|
|---|
| 1379 | }
|
|---|
| 1380 | }
|
|---|
| 1381 | return ret;
|
|---|
| 1382 | }
|
|---|
| 1383 |
|
|---|
| 1384 | #pragma alloc_text(MISC9,quick_find_type,find_type)
|
|---|
| 1385 | #pragma alloc_text(AVL,load_archivers, get_line_strip_comments, get_line_strip_white, free_archivers)
|
|---|
| 1386 | #pragma alloc_text(FMARCHIVE,SBoxDlgProc,SDlgListboxSubclassProc)
|
|---|
| 1387 | #pragma alloc_text(ARCCNRS,ArcDateTime)
|
|---|