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