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