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