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