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