| [123] | 1 |  | 
|---|
|  | 2 | /*********************************************************************** | 
|---|
|  | 3 |  | 
|---|
|  | 4 | $Id: avl.c 1787 2014-08-30 21:58:53Z 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 | 
|---|
| [1616] | 42 | 13 Aug 11 GKY Change to Doxygen comment format | 
|---|
| [1625] | 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+ | 
|---|
| [1750] | 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. | 
|---|
| [123] | 47 |  | 
|---|
|  | 48 | ***********************************************************************/ | 
|---|
|  | 49 |  | 
|---|
| [907] | 50 | #include <stdlib.h> | 
|---|
|  | 51 | #include <string.h> | 
|---|
|  | 52 | #include <ctype.h> | 
|---|
|  | 53 | #include <share.h> | 
|---|
| [1556] | 54 | #include <sys/stat.h> | 
|---|
| [907] | 55 |  | 
|---|
|  | 56 | #define INCL_DOS | 
|---|
| [2] | 57 | #define INCL_WIN | 
|---|
| [306] | 58 | #define INCL_WINSTDDRAG | 
|---|
| [841] | 59 | #define INCL_LONGLONG | 
|---|
| [2] | 60 |  | 
|---|
| [1180] | 61 | #include "fm3dll.h" | 
|---|
| [1220] | 62 | #include "fm3dll2.h"                    // #define's for UM_*, control id's, etc. | 
|---|
| [1204] | 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) | 
|---|
| [2] | 67 | #include "fm3dlg.h" | 
|---|
|  | 68 | #include "fm3str.h" | 
|---|
| [907] | 69 | #include "avl.h" | 
|---|
|  | 70 | #include "strutil.h"                    // GetPString | 
|---|
|  | 71 | #include "errutil.h"                    // Runtime_Error | 
|---|
| [1158] | 72 | #include "avv.h"                        // ArcReviewDlgProc, rewrite_archiverbb2 | 
|---|
| [1180] | 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 | 
|---|
| [1750] | 80 | #include "srchpath.h"                   // Search*Path*ForFile | 
|---|
| [1180] | 81 | #include "stristr.h"                    // stristr | 
|---|
|  | 82 | #include "delims.h"                     // to_delim | 
|---|
| [1039] | 83 | #include "fortify.h" | 
|---|
| [2] | 84 |  | 
|---|
| [1204] | 85 | // Data definitions | 
|---|
| [342] | 86 | static PSZ pszSrcFile = __FILE__; | 
|---|
| [306] | 87 | static void fill_listbox(HWND hwnd, BOOL fShowAll, SHORT sOldSelect); | 
|---|
|  | 88 |  | 
|---|
| [1204] | 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; | 
|---|
| [1556] | 95 | static struct stat Archiverbb2Stats; | 
|---|
| [1204] | 96 |  | 
|---|
| [1302] | 97 | #define ARCHIVER_LINE_BYTES     256 | 
|---|
|  | 98 |  | 
|---|
| [306] | 99 | //=== quick_find_type() === | 
|---|
| [551] | 100 | ARC_TYPE *quick_find_type(CHAR * filespec, ARC_TYPE * topsig) | 
|---|
| [247] | 101 | { | 
|---|
| [287] | 102 | ARC_TYPE *info, *found = NULL; | 
|---|
|  | 103 | CHAR *p; | 
|---|
| [2] | 104 |  | 
|---|
| [306] | 105 | if (!arcsigsloaded) | 
|---|
| [287] | 106 | load_archivers(); | 
|---|
|  | 107 | p = strrchr(filespec, '.'); | 
|---|
| [551] | 108 | if (p) { | 
|---|
| [287] | 109 | p++; | 
|---|
|  | 110 | info = (topsig) ? topsig : arcsighead; | 
|---|
| [551] | 111 | while (info) { | 
|---|
|  | 112 | if (info->ext && *(info->ext) && !stricmp(p, info->ext)) { | 
|---|
| [287] | 113 | found = find_type(filespec, topsig); | 
|---|
|  | 114 | break; | 
|---|
|  | 115 | } | 
|---|
| [551] | 116 | info = info->next; | 
|---|
| [2] | 117 | } | 
|---|
| [287] | 118 | } | 
|---|
|  | 119 | return found; | 
|---|
| [2] | 120 | } | 
|---|
|  | 121 |  | 
|---|
| [306] | 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 |  | 
|---|
| [551] | 132 | for (pat = arcsighead; pat; pat = pat->next) { | 
|---|
| [1616] | 133 | /** | 
|---|
| [306] | 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 | */ | 
|---|
| [551] | 138 | if (!fShowAll) { | 
|---|
| [306] | 139 | ARC_TYPE *pat2; | 
|---|
|  | 140 | BOOL isDup = FALSE; | 
|---|
| [551] | 141 |  | 
|---|
| [306] | 142 | for (pat2 = arcsighead; | 
|---|
| [551] | 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 | 
|---|
| [306] | 147 | if (isDup) | 
|---|
|  | 148 | continue; | 
|---|
|  | 149 | } | 
|---|
|  | 150 |  | 
|---|
|  | 151 | // If caller is editing archivers or entry useful to caller, show in listbox | 
|---|
| [551] | 152 | if (fShowAll || (pat->id && pat->extract && pat->create)) { | 
|---|
| [306] | 153 | sSelect = (SHORT) WinSendDlgItemMsg(hwnd, ASEL_LISTBOX, LM_INSERTITEM, | 
|---|
|  | 154 | MPFROM2SHORT(LIT_END, 0), | 
|---|
| [551] | 155 | MPFROMP(pat->id ? pat->id : "?")); | 
|---|
|  | 156 | if (!found && *szDefArc && pat->id && !strcmp(szDefArc, pat->id)) { | 
|---|
| [306] | 157 | // Highlight default | 
|---|
|  | 158 | WinSendDlgItemMsg(hwnd, ASEL_LISTBOX, LM_SELECTITEM, | 
|---|
|  | 159 | MPFROMSHORT(sSelect), MPFROMSHORT(TRUE)); | 
|---|
|  | 160 | found = TRUE; | 
|---|
|  | 161 | } | 
|---|
|  | 162 | } | 
|---|
| [551] | 163 | else { | 
|---|
| [306] | 164 | // Complain about odd entry | 
|---|
| [551] | 165 | if (!pat->id || !*pat->id) { | 
|---|
| [306] | 166 | WinSendDlgItemMsg(hwnd, ASEL_LISTBOX, LM_INSERTITEM, | 
|---|
|  | 167 | MPFROM2SHORT(LIT_END, 0), | 
|---|
|  | 168 | MPFROMP(GetPString(IDS_UNKNOWNUNUSABLETEXT))); | 
|---|
|  | 169 | } | 
|---|
| [551] | 170 | else { | 
|---|
| [306] | 171 | CHAR s[81]; | 
|---|
| [551] | 172 |  | 
|---|
|  | 173 | sprintf(s, "%0.12s %s", pat->id, GetPString(IDS_UNUSABLETEXT)); | 
|---|
| [306] | 174 | WinSendDlgItemMsg(hwnd, ASEL_LISTBOX, LM_INSERTITEM, | 
|---|
| [551] | 175 | MPFROM2SHORT(LIT_END, 0), MPFROMP(s)); | 
|---|
| [306] | 176 | } | 
|---|
|  | 177 | } | 
|---|
| [551] | 178 | }                                     // while scanning | 
|---|
| [306] | 179 |  | 
|---|
|  | 180 | // Try to reselect last selection unless user wants default selection | 
|---|
| [1302] | 181 | if (sOldSelect == LIT_NONE) { | 
|---|
|  | 182 | ULONG size = sizeof(SHORT); | 
|---|
|  | 183 |  | 
|---|
|  | 184 | PrfQueryProfileData(fmprof, appname, "LastArchiver", &sOldSelect, &size); | 
|---|
|  | 185 | } | 
|---|
| [306] | 186 | if (sOldSelect != LIT_NONE && !found) { | 
|---|
| [551] | 187 | SHORT sItemCount = | 
|---|
|  | 188 | (SHORT) WinSendDlgItemMsg(hwnd, ASEL_LISTBOX, LM_QUERYITEMCOUNT, | 
|---|
|  | 189 | MPVOID, MPVOID); | 
|---|
|  | 190 |  | 
|---|
| [306] | 191 | if (sOldSelect >= sItemCount) | 
|---|
|  | 192 | sOldSelect = sItemCount - 1; | 
|---|
|  | 193 | if (sOldSelect >= 0) { | 
|---|
|  | 194 | WinSendDlgItemMsg(hwnd, ASEL_LISTBOX, LM_SELECTITEM, | 
|---|
| [551] | 195 | MPFROMSHORT(sOldSelect), MPFROMSHORT(TRUE)); | 
|---|
| [306] | 196 | } | 
|---|
|  | 197 | } | 
|---|
|  | 198 |  | 
|---|
|  | 199 | if (found) | 
|---|
|  | 200 | PosOverOkay(hwnd); | 
|---|
|  | 201 | } | 
|---|
|  | 202 |  | 
|---|
| [551] | 203 | ARC_TYPE *find_type(CHAR * filespec, ARC_TYPE * topsig) | 
|---|
| [247] | 204 | { | 
|---|
| [287] | 205 | HFILE handle; | 
|---|
|  | 206 | ULONG action; | 
|---|
|  | 207 | ULONG len; | 
|---|
|  | 208 | ULONG l; | 
|---|
|  | 209 | ARC_TYPE *info; | 
|---|
|  | 210 | CHAR *p; | 
|---|
| [850] | 211 | CHAR buffer[4096];                    // 06 Oct 07 SHL Protect against NTFS defect | 
|---|
| [2] | 212 |  | 
|---|
| [306] | 213 | if (!arcsigsloaded) | 
|---|
| [287] | 214 | load_archivers(); | 
|---|
|  | 215 | if (!topsig) | 
|---|
|  | 216 | topsig = arcsighead; | 
|---|
|  | 217 | DosError(FERR_DISABLEHARDERR); | 
|---|
| [844] | 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)) | 
|---|
| [287] | 229 | return NULL; | 
|---|
|  | 230 | // Scan signatures | 
|---|
| [551] | 231 | for (info = topsig; info; info = info->next) { | 
|---|
|  | 232 | if (info->siglen == 0) { | 
|---|
| [287] | 233 | // No signature -- check extension | 
|---|
|  | 234 | p = strrchr(filespec, '.'); | 
|---|
| [551] | 235 | if (p) { | 
|---|
| [287] | 236 | p++; | 
|---|
| [551] | 237 | if (info->ext && *(info->ext) && !stricmp(p, info->ext)) | 
|---|
| [287] | 238 | break;                        // Matched | 
|---|
|  | 239 |  | 
|---|
|  | 240 | } | 
|---|
|  | 241 | continue;                         // Next sig | 
|---|
|  | 242 |  | 
|---|
|  | 243 | } | 
|---|
|  | 244 | // Try signature match | 
|---|
| [551] | 245 | l = info->siglen; | 
|---|
| [287] | 246 | l = min(l, 79); | 
|---|
|  | 247 | if (!DosChgFilePtr(handle, | 
|---|
| [551] | 248 | abs(info->file_offset), | 
|---|
| [1616] | 249 | (info->file_offset >= 0) ? FILE_BEGIN : FILE_END, | 
|---|
|  | 250 | &len)) { | 
|---|
| [551] | 251 | if (!DosRead(handle, buffer, l, &len) && len == l) { | 
|---|
|  | 252 | if (!memcmp(info->signature, buffer, l)) | 
|---|
| [287] | 253 | break;                        // Matched | 
|---|
|  | 254 |  | 
|---|
|  | 255 | } | 
|---|
|  | 256 | } | 
|---|
|  | 257 | }                                     // for | 
|---|
|  | 258 |  | 
|---|
| [1616] | 259 | DosClose(handle);                     // Either way, we're done for now | 
|---|
|  | 260 | return info;                          // Return signature, if any | 
|---|
| [2] | 261 | } | 
|---|
|  | 262 |  | 
|---|
| [1082] | 263 | # ifdef FORTIFY | 
|---|
|  | 264 |  | 
|---|
| [1029] | 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 |  | 
|---|
| [306] | 293 | //=== free_arc_type() free allocated ARC_TYPE === | 
|---|
| [2] | 294 |  | 
|---|
| [1082] | 295 | # endif | 
|---|
|  | 296 |  | 
|---|
| [1029] | 297 | VOID free_arc_type(ARC_TYPE * pat) | 
|---|
| [306] | 298 | { | 
|---|
| [551] | 299 | if (pat) { | 
|---|
| [1009] | 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__); | 
|---|
| [1039] | 315 | free(pat); | 
|---|
| [306] | 316 | } | 
|---|
|  | 317 | } | 
|---|
|  | 318 |  | 
|---|
| [551] | 319 | static UINT cur_line_num;       // Input file line counter | 
|---|
| [306] | 320 |  | 
|---|
| [312] | 321 | //=== get_line_strip_comments() read line, strip comments and whitespace === | 
|---|
|  | 322 |  | 
|---|
| [551] | 323 | static PSZ get_line_strip_comments(PSZ pszIn, FILE * fp) | 
|---|
| [306] | 324 | { | 
|---|
| [405] | 325 | PSZ psz = xfgets(pszIn, ARCHIVER_LINE_BYTES, fp, pszSrcFile, __LINE__); | 
|---|
| [306] | 326 | PSZ psz2; | 
|---|
|  | 327 |  | 
|---|
| [312] | 328 | if (psz) { | 
|---|
|  | 329 | cur_line_num++; | 
|---|
| [306] | 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 |  | 
|---|
| [312] | 339 | //=== get_line_strip_white() read line, strip whitespace === | 
|---|
| [306] | 340 |  | 
|---|
| [551] | 341 | static PSZ get_line_strip_white(PSZ pszIn, FILE * fp) | 
|---|
| [306] | 342 | { | 
|---|
| [551] | 343 | PSZ psz = | 
|---|
|  | 344 | xfgets_bstripcr(pszIn, ARCHIVER_LINE_BYTES, fp, pszSrcFile, __LINE__); | 
|---|
| [306] | 345 |  | 
|---|
| [405] | 346 | if (psz) | 
|---|
| [312] | 347 | cur_line_num++; | 
|---|
| [306] | 348 |  | 
|---|
|  | 349 | return psz; | 
|---|
|  | 350 | } | 
|---|
|  | 351 |  | 
|---|
|  | 352 | //=== load_archivers() load or reload archive definitions from archiver.bb2 === | 
|---|
|  | 353 |  | 
|---|
| [247] | 354 | INT load_archivers(VOID) | 
|---|
|  | 355 | { | 
|---|
| [312] | 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; | 
|---|
| [306] | 363 | INT i; | 
|---|
| [1544] | 364 | CHAR *moder = "r"; | 
|---|
| [2] | 365 |  | 
|---|
| [312] | 366 | // Free current signatures | 
|---|
| [306] | 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; | 
|---|
| [312] | 377 | arcsigs_header_lines = 0; | 
|---|
|  | 378 | arcsigs_trailer_line_num = 0; | 
|---|
| [306] | 379 |  | 
|---|
| [1750] | 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); | 
|---|
| [1302] | 390 | DosReleaseMutexSem(hmtxFM2Globals); | 
|---|
| [1750] | 391 | if (!fp) | 
|---|
|  | 392 | return -2; | 
|---|
|  | 393 | strcpy(archiverbb2, szFullFilename);                // Remember full path | 
|---|
| [287] | 394 | } | 
|---|
| [312] | 395 |  | 
|---|
|  | 396 | cur_line_num = 0; | 
|---|
|  | 397 |  | 
|---|
|  | 398 | // Line 1 must contain number of lines per signature definition | 
|---|
| [551] | 399 | if (!get_line_strip_comments(sz, fp)) { | 
|---|
| [312] | 400 | fclose(fp); | 
|---|
| [287] | 401 | return -3; | 
|---|
|  | 402 | } | 
|---|
| [312] | 403 | if (*sz) | 
|---|
|  | 404 | lines_per_arcsig = atoi(sz); | 
|---|
| [806] | 405 | if (!*sz || lines_per_arcsig < LINES_PER_ARCSIG) { | 
|---|
|  | 406 | fclose(fp);                         // 25 Aug 07 SHL | 
|---|
| [287] | 407 | return -3; | 
|---|
| [806] | 408 | } | 
|---|
| [312] | 409 |  | 
|---|
|  | 410 | // Parse rest of file | 
|---|
|  | 411 | // 1st non-blank line starts definition | 
|---|
|  | 412 | // Need to determine header size and start of trailer | 
|---|
|  | 413 |  | 
|---|
| [551] | 414 | while (!feof(fp)) { | 
|---|
| [312] | 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, ';'); | 
|---|
| [551] | 429 |  | 
|---|
|  | 430 | if (psz2) { | 
|---|
|  | 431 | *psz2 = 0;                    // Chop trailing comment | 
|---|
|  | 432 | bstripcr(sz);                 // Strip leading white and trailing white and CR/LF | 
|---|
| [312] | 433 | } | 
|---|
| [551] | 434 | arcsigs_header_lines = cur_line_num - 1; | 
|---|
| [312] | 435 | } | 
|---|
|  | 436 | } | 
|---|
|  | 437 | else { | 
|---|
|  | 438 | // Reading defintiions | 
|---|
|  | 439 | if (!get_line_strip_comments(sz, fp)) | 
|---|
| [551] | 440 | break;                          // EOF | 
|---|
| [312] | 441 | } | 
|---|
|  | 442 |  | 
|---|
| [287] | 443 | // fixme to avoid allocating empty fields | 
|---|
| [306] | 444 |  | 
|---|
| [312] | 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 |  | 
|---|
| [551] | 449 | if (*sz) { | 
|---|
| [312] | 450 | // At start of defintion | 
|---|
|  | 451 |  | 
|---|
| [551] | 452 | pat = xmallocz(sizeof(ARC_TYPE), pszSrcFile, __LINE__); | 
|---|
| [306] | 453 | if (!pat) | 
|---|
| [342] | 454 | break; | 
|---|
| [551] | 455 | pat->id = xstrdup(sz, pszSrcFile, __LINE__); | 
|---|
| [287] | 456 |  | 
|---|
| [551] | 457 | pat->comment_line_num = per_sig_comment_line_num; | 
|---|
|  | 458 | pat->defn_line_num = cur_line_num; | 
|---|
| [312] | 459 |  | 
|---|
|  | 460 | if (!get_line_strip_comments(sz, fp))     // line 2 - extension | 
|---|
| [287] | 461 | break; | 
|---|
| [312] | 462 | if (*sz) | 
|---|
| [551] | 463 | pat->ext = xstrdup(sz, pszSrcFile, __LINE__); | 
|---|
| [287] | 464 | else | 
|---|
| [551] | 465 | pat->ext = NULL; | 
|---|
| [312] | 466 | if (!get_line_strip_comments(sz, fp))     // line 3 - offset to signature | 
|---|
| [287] | 467 | break; | 
|---|
| [551] | 468 | pat->file_offset = atol(sz); | 
|---|
| [312] | 469 | if (!get_line_strip_comments(sz, fp))     // line 4 - list command | 
|---|
| [287] | 470 | break; | 
|---|
| [312] | 471 | if (*sz) | 
|---|
| [551] | 472 | pat->list = xstrdup(sz, pszSrcFile, __LINE__); | 
|---|
| [287] | 473 | else | 
|---|
| [551] | 474 | pat->list = NULL; | 
|---|
|  | 475 | if (!pat->list) | 
|---|
| [312] | 476 | break;                          // Must have list command - fixme to complain | 
|---|
|  | 477 | if (!get_line_strip_comments(sz, fp))     // line 5 | 
|---|
| [287] | 478 | break; | 
|---|
| [312] | 479 | if (*sz) | 
|---|
| [551] | 480 | pat->extract = xstrdup(sz, pszSrcFile, __LINE__); | 
|---|
| [287] | 481 | else | 
|---|
| [551] | 482 | pat->extract = NULL; | 
|---|
| [312] | 483 | if (!get_line_strip_comments(sz, fp))     // line 6 | 
|---|
| [287] | 484 | break; | 
|---|
| [312] | 485 | if (*sz) | 
|---|
| [551] | 486 | pat->exwdirs = xstrdup(sz, pszSrcFile, __LINE__); | 
|---|
| [287] | 487 | else | 
|---|
| [551] | 488 | pat->exwdirs = NULL; | 
|---|
| [312] | 489 | if (!get_line_strip_comments(sz, fp))     // line 7 | 
|---|
| [287] | 490 | break; | 
|---|
| [312] | 491 | if (*sz) | 
|---|
| [551] | 492 | pat->test = xstrdup(sz, pszSrcFile, __LINE__); | 
|---|
| [287] | 493 | else | 
|---|
| [551] | 494 | pat->test = NULL; | 
|---|
| [312] | 495 | if (!get_line_strip_comments(sz, fp))     // line 8 | 
|---|
| [287] | 496 | break; | 
|---|
| [312] | 497 | if (*sz) | 
|---|
| [551] | 498 | pat->create = xstrdup(sz, pszSrcFile, __LINE__); | 
|---|
| [287] | 499 | else | 
|---|
| [551] | 500 | pat->create = NULL; | 
|---|
| [312] | 501 | if (!get_line_strip_comments(sz, fp))     // line 9 | 
|---|
| [287] | 502 | break; | 
|---|
| [312] | 503 | if (*sz) | 
|---|
| [551] | 504 | pat->createwdirs = xstrdup(sz, pszSrcFile, __LINE__); | 
|---|
| [287] | 505 | else | 
|---|
| [551] | 506 | pat->createwdirs = NULL; | 
|---|
| [312] | 507 | if (!get_line_strip_comments(sz, fp))     // line 10 | 
|---|
| [287] | 508 | break; | 
|---|
| [312] | 509 | if (*sz) | 
|---|
| [551] | 510 | pat->createrecurse = xstrdup(sz, pszSrcFile, __LINE__); | 
|---|
| [287] | 511 | else | 
|---|
| [551] | 512 | pat->createrecurse = NULL; | 
|---|
| [312] | 513 | if (!get_line_strip_comments(sz, fp))     // line 11 | 
|---|
| [287] | 514 | break; | 
|---|
| [312] | 515 | if (*sz) | 
|---|
| [551] | 516 | pat->move = xstrdup(sz, pszSrcFile, __LINE__); | 
|---|
| [287] | 517 | else | 
|---|
| [551] | 518 | pat->move = NULL; | 
|---|
| [312] | 519 | if (!get_line_strip_comments(sz, fp))     // line 12 | 
|---|
| [287] | 520 | break; | 
|---|
| [312] | 521 | if (*sz) | 
|---|
| [551] | 522 | pat->movewdirs = xstrdup(sz, pszSrcFile, __LINE__); | 
|---|
| [287] | 523 | else | 
|---|
| [551] | 524 | pat->movewdirs = NULL; | 
|---|
| [312] | 525 | if (!get_line_strip_comments(sz, fp))     // line 13 | 
|---|
| [287] | 526 | break; | 
|---|
| [312] | 527 | if (*sz) | 
|---|
| [551] | 528 | pat->delete = xstrdup(sz, pszSrcFile, __LINE__); | 
|---|
| [312] | 529 | else | 
|---|
| [551] | 530 | pat->delete = NULL; | 
|---|
| [312] | 531 | if (!get_line_strip_white(sz, fp))        // line 14 | 
|---|
| [287] | 532 | break; | 
|---|
| [312] | 533 | i = literal(sz);                  // Translate \ escapes | 
|---|
| [551] | 534 | if (i) { | 
|---|
|  | 535 | pat->siglen = i; | 
|---|
|  | 536 | pat->signature = xmalloc(i, pszSrcFile, __LINE__); | 
|---|
|  | 537 | if (!pat->signature) | 
|---|
| [287] | 538 | break; | 
|---|
| [551] | 539 | memcpy(pat->signature, sz, i);  // signature may not be a string | 
|---|
| [287] | 540 | } | 
|---|
| [306] | 541 | else { | 
|---|
| [551] | 542 | pat->siglen = 0; | 
|---|
|  | 543 | pat->signature = NULL; | 
|---|
| [306] | 544 | } | 
|---|
| [312] | 545 | if (!get_line_strip_white(sz, fp))        // line 15 | 
|---|
| [306] | 546 | break; | 
|---|
| [312] | 547 | if (*sz) | 
|---|
| [551] | 548 | pat->startlist = xstrdup(sz, pszSrcFile, __LINE__); | 
|---|
| [287] | 549 | else | 
|---|
| [551] | 550 | pat->startlist = NULL; | 
|---|
| [312] | 551 | if (!get_line_strip_white(sz, fp))        // line 16 | 
|---|
| [287] | 552 | break; | 
|---|
| [312] | 553 | if (*sz) | 
|---|
| [551] | 554 | pat->endlist = xstrdup(sz, pszSrcFile, __LINE__); | 
|---|
| [287] | 555 | else | 
|---|
| [551] | 556 | pat->endlist = NULL; | 
|---|
| [312] | 557 | if (!get_line_strip_comments(sz, fp))     // line 17 | 
|---|
| [287] | 558 | break; | 
|---|
| [551] | 559 | pat->osizepos = atoi(sz); | 
|---|
| [312] | 560 | if (!get_line_strip_comments(sz, fp))     // line 18 | 
|---|
| [287] | 561 | break; | 
|---|
| [551] | 562 | pat->nsizepos = atoi(sz); | 
|---|
| [312] | 563 | if (!get_line_strip_comments(sz, fp))     // line 19 | 
|---|
| [287] | 564 | break; | 
|---|
| [551] | 565 | pat->fdpos = atoi(sz); | 
|---|
| [312] | 566 | psz = strchr(sz, ','); | 
|---|
| [551] | 567 | if (psz) { | 
|---|
| [312] | 568 | psz++; | 
|---|
| [551] | 569 | pat->datetype = atoi(psz); | 
|---|
| [287] | 570 | } | 
|---|
| [312] | 571 | if (!get_line_strip_comments(sz, fp))     // line 20 | 
|---|
| [287] | 572 | break; | 
|---|
| [551] | 573 | pat->fdflds = atoi(sz); | 
|---|
| [312] | 574 | if (!get_line_strip_comments(sz, fp))     // line 21 | 
|---|
| [287] | 575 | break; | 
|---|
| [551] | 576 | pat->fnpos = atoi(sz); | 
|---|
| [312] | 577 | psz = strchr(sz, ','); | 
|---|
| [551] | 578 | if (psz) { | 
|---|
| [312] | 579 | psz++; | 
|---|
| [551] | 580 | pat->nameislast = (BOOL) (*psz && atol(psz) == 0) ? FALSE : TRUE; | 
|---|
| [312] | 581 | psz = strchr(psz, ','); | 
|---|
| [551] | 582 | if (psz) { | 
|---|
| [312] | 583 | psz++; | 
|---|
| [551] | 584 | pat->nameisnext = (BOOL) (*psz && atol(psz) == 0) ? FALSE : TRUE; | 
|---|
| [312] | 585 | psz = strchr(psz, ','); | 
|---|
| [551] | 586 | if (psz) { | 
|---|
| [312] | 587 | psz++; | 
|---|
| [551] | 588 | pat->nameisfirst = (BOOL) (*psz && atol(psz) == 0) ? FALSE : TRUE; | 
|---|
| [287] | 589 | } | 
|---|
|  | 590 | } | 
|---|
|  | 591 | } | 
|---|
|  | 592 | // Ignore unknown lines - must be newer file format | 
|---|
| [551] | 593 | for (i = LINES_PER_ARCSIG; i < lines_per_arcsig; i++) { | 
|---|
| [312] | 594 | if (!get_line_strip_comments(sz, fp)) | 
|---|
|  | 595 | break;                        // Unexpected EOF - fixme to complain | 
|---|
| [287] | 596 | } | 
|---|
| [247] | 597 |  | 
|---|
| [312] | 598 | // Add to list, assume next and prev already NULL | 
|---|
| [287] | 599 | if (!arcsighead) | 
|---|
| [306] | 600 | arcsighead = patLast = pat; | 
|---|
| [551] | 601 | else { | 
|---|
|  | 602 | patLast->next = pat; | 
|---|
|  | 603 | pat->prev = patLast; | 
|---|
| [306] | 604 | patLast = pat; | 
|---|
| [287] | 605 | } | 
|---|
| [551] | 606 | pat = NULL;                       // Done with this defintion | 
|---|
| [312] | 607 |  | 
|---|
|  | 608 | arcsigs_trailer_line_num = cur_line_num + 1;      // In case this is last defintion | 
|---|
|  | 609 | per_sig_comment_line_num = 0; | 
|---|
| [551] | 610 | }                                   // if got definition | 
|---|
| [279] | 611 |  | 
|---|
| [551] | 612 | }                                     // while more lines | 
|---|
| [306] | 613 |  | 
|---|
| [312] | 614 | fclose(fp); | 
|---|
| [306] | 615 |  | 
|---|
| [551] | 616 | free_arc_type(pat);                   // In case partial definition in progress | 
|---|
| [312] | 617 |  | 
|---|
| [287] | 618 | if (!arcsighead) | 
|---|
|  | 619 | return -4; | 
|---|
| [306] | 620 |  | 
|---|
|  | 621 | arcsigsloaded = TRUE; | 
|---|
|  | 622 |  | 
|---|
| [287] | 623 | return 0; | 
|---|
| [2] | 624 | } | 
|---|
|  | 625 |  | 
|---|
| [342] | 626 | #define TEST_DRAG 0                     // fixme to be gone or to work | 
|---|
| [2] | 627 |  | 
|---|
| [551] | 628 | static MRESULT EXPENTRY SDlgListboxSubclassProc(HWND hwnd, ULONG msg, | 
|---|
|  | 629 | MPARAM mp1, MPARAM mp2) | 
|---|
| [306] | 630 | { | 
|---|
| [551] | 631 | PFNWP pfnOldProc = (PFNWP) WinQueryWindowPtr(hwnd, QWL_USER); | 
|---|
| [306] | 632 |  | 
|---|
| [618] | 633 | PDRAGITEM pDItem; | 
|---|
|  | 634 | PDRAGINFO pDInfo; | 
|---|
| [306] | 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 |  | 
|---|
| [551] | 641 | switch (msg) { | 
|---|
| [306] | 642 | case WM_BEGINDRAG: | 
|---|
|  | 643 | { | 
|---|
|  | 644 | LONG cur_ndx; | 
|---|
|  | 645 | DRAGITEM ditem; | 
|---|
|  | 646 | DRAGIMAGE dimage; | 
|---|
|  | 647 | HWND hwndDrop; | 
|---|
|  | 648 |  | 
|---|
| [537] | 649 | // fprintf(stderr, "SDlgListboxSubclassProc: BEGINDRAG\n"); | 
|---|
| [306] | 650 | cur_ndx = WinQueryLboxSelectedItem(hwnd); | 
|---|
|  | 651 |  | 
|---|
|  | 652 | if (cur_ndx != LIT_NONE) { | 
|---|
| [618] | 653 | pDInfo = DrgAllocDraginfo(1); | 
|---|
|  | 654 | if (pDInfo) { | 
|---|
|  | 655 | pDInfo->usOperation = DO_DEFAULT; | 
|---|
|  | 656 | pDInfo->hwndSource = hwnd; | 
|---|
| [306] | 657 |  | 
|---|
| [551] | 658 | memset(&ditem, 0, sizeof(DRAGITEM)); | 
|---|
| [306] | 659 | ditem.hwndItem = hwnd; | 
|---|
|  | 660 | ditem.ulItemID = 1; | 
|---|
|  | 661 | ditem.hstrType = DrgAddStrHandle(DRT_UNKNOWN); | 
|---|
|  | 662 | ditem.hstrRMF = DrgAddStrHandle(DRMDRF_LBOX); | 
|---|
| [1438] | 663 | ditem.hstrContainerName = DrgAddStrHandle(NullStr); | 
|---|
|  | 664 | ditem.hstrSourceName = DrgAddStrHandle(NullStr); | 
|---|
|  | 665 | ditem.hstrTargetName = DrgAddStrHandle(NullStr); | 
|---|
| [306] | 666 | ditem.fsSupportedOps = DO_MOVEABLE; | 
|---|
|  | 667 |  | 
|---|
| [551] | 668 | memset(&dimage, 0, sizeof(DRAGIMAGE)); | 
|---|
| [306] | 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; | 
|---|
| [1616] | 677 | DrgSetDragitem(pDInfo, &ditem, sizeof(DRAGITEM), 0);  // Index of DRAGITEM | 
|---|
|  | 678 | hwndDrop = DrgDrag(hwnd, pDInfo, &dimage, 1,  // One DRAGIMAGE | 
|---|
| [551] | 679 | VK_ENDDRAG, NULL); | 
|---|
| [342] | 680 | if (!hwndDrop) | 
|---|
| [551] | 681 | Win_Error(hwnd, hwnd, pszSrcFile, __LINE__, "DrgDrag"); | 
|---|
| [306] | 682 |  | 
|---|
| [618] | 683 | DrgFreeDraginfo(pDInfo); | 
|---|
| [306] | 684 | } | 
|---|
|  | 685 | } | 
|---|
|  | 686 | break; | 
|---|
|  | 687 | } | 
|---|
|  | 688 |  | 
|---|
|  | 689 | case DM_DRAGOVER: | 
|---|
|  | 690 | ok = FALSE; | 
|---|
| [551] | 691 | if (!emphasized) { | 
|---|
| [306] | 692 | POINTL ptl; | 
|---|
|  | 693 | POINTL ptl2; | 
|---|
| [551] | 694 |  | 
|---|
| [306] | 695 | emphasized = TRUE; | 
|---|
|  | 696 | ptl.x = SHORT1FROMMP(mp2); | 
|---|
|  | 697 | ptl.y = SHORT2FROMMP(mp2); | 
|---|
|  | 698 | ptl2 = ptl; | 
|---|
|  | 699 | WinMapWindowPoints(HWND_DESKTOP, hwnd, &ptl2, 1); | 
|---|
| [537] | 700 | // fprintf(stderr, "DRAGOVER mapped x y %d %d to %d %d\n", ptl.x, ptl.y, ptl2.x, ptl2.y); | 
|---|
| [306] | 701 | WinPostMsg(hwnd, WM_BUTTON1CLICK, | 
|---|
| [551] | 702 | MPFROM2SHORT((SHORT) ptl2.x, (SHORT) ptl2.y), | 
|---|
| [306] | 703 | MPFROM2SHORT(HT_NORMAL, KC_NONE)); | 
|---|
| [537] | 704 | // fprintf(stderr, "DRAGOVER posted 0x%x WM_BUTTON1CLICK x y %d %d\n", hwnd, ptl2.x, ptl2.y); | 
|---|
| [306] | 705 | } | 
|---|
| [1616] | 706 | pDInfo = (PDRAGINFO) mp1;           // Get DRAGINFO pointer | 
|---|
| [618] | 707 | if (pDInfo) { | 
|---|
|  | 708 | if (!DrgAccessDraginfo(pDInfo)) { | 
|---|
| [806] | 709 | Win_Error(HWND_DESKTOP, HWND_DESKTOP, pszSrcFile, __LINE__, | 
|---|
| [1402] | 710 | PCSZ_DRGACCESSDRAGINFO); | 
|---|
| [306] | 711 | } | 
|---|
| [618] | 712 | else { | 
|---|
| [806] | 713 | pDItem = DrgQueryDragitemPtr(pDInfo, 0); | 
|---|
| [1616] | 714 | // Check valid rendering mechanisms and data format | 
|---|
| [806] | 715 | ok = DrgVerifyRMF(pDItem, DRM_LBOX, NULL); | 
|---|
|  | 716 | DrgFreeDraginfo(pDInfo); | 
|---|
| [618] | 717 | } | 
|---|
| [306] | 718 | } | 
|---|
| [618] | 719 | return ok ? MRFROM2SHORT(DOR_DROP, DO_MOVE) : | 
|---|
| [806] | 720 | MRFROM2SHORT(DOR_NEVERDROP, 0); | 
|---|
| [306] | 721 |  | 
|---|
|  | 722 | case DM_DRAGLEAVE: | 
|---|
| [551] | 723 | if (emphasized) { | 
|---|
| [306] | 724 | emphasized = FALSE; | 
|---|
|  | 725 | // fixme to draw listbox item emphasized | 
|---|
|  | 726 | // DrawTargetEmphasis(hwnd, emphasized); | 
|---|
| [537] | 727 | // fprintf(stderr, "DRAGLEAVE\n"); | 
|---|
| [1787] | 728 | // fflush(stderr); | 
|---|
| [306] | 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; | 
|---|
| [551] | 738 | if (emphasized) { | 
|---|
| [306] | 739 | emphasized = FALSE; | 
|---|
|  | 740 | // DrawTargetEmphasis(hwnd, emphasized); | 
|---|
|  | 741 | } | 
|---|
| [1616] | 742 | pDInfo = (PDRAGINFO) mp1;           // Get DRAGINFO pointer | 
|---|
| [618] | 743 | if (pDInfo) { | 
|---|
|  | 744 | if (!DrgAccessDraginfo(pDInfo)) { | 
|---|
| [806] | 745 | Win_Error(HWND_DESKTOP, HWND_DESKTOP, pszSrcFile, __LINE__, | 
|---|
| [1402] | 746 | PCSZ_DRGACCESSDRAGINFO); | 
|---|
| [306] | 747 | } | 
|---|
| [618] | 748 | else { | 
|---|
| [806] | 749 | pDItem = DrgQueryDragitemPtr(pDInfo, 0); | 
|---|
|  | 750 | if (!pDItem) | 
|---|
| [618] | 751 | Win_Error(hwnd, hwnd, pszSrcFile, __LINE__, "DM_DROP"); | 
|---|
| [1616] | 752 | // Check valid rendering mechanisms and data | 
|---|
| [806] | 753 | ok = DrgVerifyRMF(pDItem, DRM_LBOX, NULL) | 
|---|
|  | 754 | && ~pDItem->fsControl & DC_PREPARE; | 
|---|
|  | 755 | if (ok) { | 
|---|
| [1616] | 756 | // note: targetfail is returned to source for all items | 
|---|
| [618] | 757 | DrgSendTransferMsg(pDInfo->hwndSource, DM_ENDCONVERSATION, | 
|---|
|  | 758 | MPFROMLONG(pDItem->ulItemID), | 
|---|
|  | 759 | MPFROMLONG(DMFL_TARGETSUCCESSFUL)); | 
|---|
| [806] | 760 | } | 
|---|
|  | 761 | FreeDragInfoData(hwnd, pDInfo); | 
|---|
| [618] | 762 | } | 
|---|
| [306] | 763 | } | 
|---|
|  | 764 | return 0; | 
|---|
| [618] | 765 | } // switch | 
|---|
| [306] | 766 | return pfnOldProc ? pfnOldProc(hwnd, msg, mp1, mp2) : | 
|---|
| [551] | 767 | WinDefWindowProc(hwnd, msg, mp1, mp2); | 
|---|
| [306] | 768 | } | 
|---|
|  | 769 |  | 
|---|
|  | 770 | //=== SBoxDlgProc() Select archiver to use or edit, supports list reorder too === | 
|---|
|  | 771 |  | 
|---|
| [439] | 772 | static PSZ pszCantFindMsg = "Can't find item %d"; | 
|---|
|  | 773 |  | 
|---|
| [247] | 774 | MRESULT EXPENTRY SBoxDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) | 
|---|
|  | 775 | { | 
|---|
| [551] | 776 | ARC_TYPE **ppatReturn;        // Where to return selected archiver | 
|---|
| [306] | 777 | ARC_TYPE *pat; | 
|---|
|  | 778 | SHORT sSelect; | 
|---|
|  | 779 | SHORT sItemCount; | 
|---|
|  | 780 | CHAR szItemText[256]; | 
|---|
| [551] | 781 | CHAR szPCItemText[256];       // Parent or child item text | 
|---|
| [306] | 782 | SHORT i; | 
|---|
|  | 783 | BOOL fShowAll; | 
|---|
| [2] | 784 |  | 
|---|
| [306] | 785 | static SHORT sLastSelect = LIT_NONE; | 
|---|
| [2] | 786 |  | 
|---|
| [551] | 787 | switch (msg) { | 
|---|
| [287] | 788 | case WM_INITDLG: | 
|---|
| [306] | 789 | if (!arcsigsloaded) | 
|---|
| [287] | 790 | load_archivers(); | 
|---|
| [1556] | 791 | else { | 
|---|
|  | 792 | struct stat Buffer; | 
|---|
|  | 793 |  | 
|---|
| [1750] | 794 | stat(archiverbb2, &Buffer);   // jbs: Re-use full name set by load_achivers | 
|---|
| [1556] | 795 | if (Archiverbb2Stats.st_size != Buffer.st_size || | 
|---|
| [1750] | 796 | Archiverbb2Stats.st_mtime != Buffer.st_mtime) | 
|---|
|  | 797 | if (saymsg(MB_YESNO, | 
|---|
| [1556] | 798 | hwnd, | 
|---|
|  | 799 | GetPString(IDS_ADCHANGESONDISKTEXT), | 
|---|
|  | 800 | GetPString(IDS_ADRELOADMEMTEXT)) == MBID_YES) | 
|---|
|  | 801 | load_archivers(); | 
|---|
|  | 802 | } | 
|---|
| [551] | 803 | if (!(ARC_TYPE **) mp2) { | 
|---|
| [1398] | 804 | Runtime_Error(pszSrcFile, __LINE__, NULL); | 
|---|
| [287] | 805 | WinDismissDlg(hwnd, 0); | 
|---|
|  | 806 | break; | 
|---|
|  | 807 | } | 
|---|
| [1616] | 808 | /** Passed arg points to where to return selected archiver definition | 
|---|
| [306] | 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 | */ | 
|---|
| [551] | 813 | ppatReturn = (ARC_TYPE **) mp2; | 
|---|
| [306] | 814 | fShowAll = *ppatReturn == NULL; | 
|---|
|  | 815 | if (*ppatReturn) | 
|---|
|  | 816 | *ppatReturn = arcsighead;         // Preset to first | 
|---|
| [551] | 817 | WinSetWindowPtr(hwnd, QWL_USER, (PVOID) ppatReturn); | 
|---|
| [306] | 818 | fill_listbox(hwnd, fShowAll, sLastSelect); | 
|---|
|  | 819 |  | 
|---|
|  | 820 | #ifdef TEST_DRAG                        // fixme | 
|---|
| [287] | 821 | { | 
|---|
| [306] | 822 | HWND hwnd2 = WinWindowFromID(hwnd, ASEL_LISTBOX); | 
|---|
|  | 823 | PFNWP pfn = WinSubclassWindow(hwnd2, | 
|---|
|  | 824 | SDlgListboxSubclassProc); | 
|---|
| [551] | 825 |  | 
|---|
| [306] | 826 | WinSetWindowPtr(hwnd2, QWL_USER, (PVOID) pfn); | 
|---|
|  | 827 | } | 
|---|
|  | 828 | #endif // TEST_DRAG fixme | 
|---|
| [287] | 829 |  | 
|---|
| [306] | 830 | break; | 
|---|
|  | 831 |  | 
|---|
| [1546] | 832 | case WM_HELP: | 
|---|
|  | 833 | if (hwndHelp) | 
|---|
|  | 834 | WinSendMsg(hwndHelp, | 
|---|
|  | 835 | HM_DISPLAY_HELP, | 
|---|
|  | 836 | MPFROMSHORT(1), MPFROMSHORT(HM_RESOURCEID)); | 
|---|
|  | 837 | break; | 
|---|
|  | 838 |  | 
|---|
| [306] | 839 | case WM_COMMAND: | 
|---|
|  | 840 | ppatReturn = (ARC_TYPE **) WinQueryWindowPtr(hwnd, QWL_USER); | 
|---|
| [551] | 841 | switch (SHORT1FROMMP(mp1)) { | 
|---|
| [306] | 842 | case DID_OK: | 
|---|
| [551] | 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"); | 
|---|
| [306] | 849 | return 0; | 
|---|
|  | 850 | } | 
|---|
|  | 851 | pat = arcsighead; | 
|---|
| [551] | 852 | if (*ppatReturn) { | 
|---|
| [306] | 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; | 
|---|
| [1302] | 859 | else { | 
|---|
| [551] | 860 | for (; pat; pat = pat->next) { | 
|---|
|  | 861 | if (pat->id && !strcmp(szItemText, pat->id)) | 
|---|
|  | 862 | break;                    // Found it | 
|---|
| [287] | 863 | } | 
|---|
|  | 864 | } | 
|---|
| [306] | 865 | } | 
|---|
| [551] | 866 | else { | 
|---|
| [306] | 867 | // If dups not hidden, lookup by count | 
|---|
| [551] | 868 | for (i = 0; pat && i < sSelect; i++, pat = pat->next) ; // Scan | 
|---|
| [306] | 869 | } | 
|---|
| [551] | 870 | if (pat && (!*ppatReturn || (pat->id && pat->extract && pat->create))) { | 
|---|
| [306] | 871 | *ppatReturn = pat; | 
|---|
|  | 872 | } | 
|---|
| [551] | 873 | else { | 
|---|
|  | 874 | Runtime_Error(pszSrcFile, __LINE__, "no match"); | 
|---|
| [306] | 875 | // Refuse to select | 
|---|
|  | 876 | WinSendDlgItemMsg(hwnd, ASEL_LISTBOX, LM_SELECTITEM, | 
|---|
|  | 877 | MPFROMSHORT(LIT_NONE), FALSE); | 
|---|
|  | 878 | return 0; | 
|---|
|  | 879 | } | 
|---|
| [1302] | 880 | PrfWriteProfileData(fmprof, appname, "LastArchiver", &sSelect, sizeof(SHORT)); | 
|---|
| [306] | 881 | sLastSelect = sSelect; | 
|---|
|  | 882 | WinDismissDlg(hwnd, TRUE); | 
|---|
|  | 883 | return 0; | 
|---|
| [2] | 884 |  | 
|---|
| [306] | 885 | case DID_CANCEL: | 
|---|
|  | 886 | if (arcsigsmodified) { | 
|---|
|  | 887 | if (saymsg(MB_YESNO, | 
|---|
|  | 888 | hwnd, | 
|---|
|  | 889 | GetPString(IDS_ADCHANGESINMEMTEXT), | 
|---|
| [1751] | 890 | GetPString(IDS_ADREWRITETEXT), NullStr) == MBID_YES) | 
|---|
|  | 891 | rewrite_archiverbb2(archiverbb2); | 
|---|
| [306] | 892 | } | 
|---|
| [551] | 893 | sSelect = (SHORT) WinSendDlgItemMsg(hwnd, | 
|---|
|  | 894 | ASEL_LISTBOX, | 
|---|
|  | 895 | LM_QUERYSELECTION, | 
|---|
|  | 896 | MPFROMSHORT(LIT_FIRST), MPVOID); | 
|---|
| [1302] | 897 | if (sSelect != LIT_NONE) { | 
|---|
|  | 898 | sLastSelect = sSelect; | 
|---|
|  | 899 | PrfWriteProfileData(fmprof, appname, "LastArchiver", &sSelect, sizeof(SHORT)); | 
|---|
|  | 900 | } | 
|---|
| [306] | 901 | *ppatReturn = NULL; | 
|---|
|  | 902 | PostMsg(hwnd, WM_CLOSE, MPVOID, MPVOID);  // fixme to understand why needed | 
|---|
|  | 903 | return 0; | 
|---|
|  | 904 |  | 
|---|
|  | 905 | case ASEL_PB_ADD: | 
|---|
| [551] | 906 | sSelect = (SHORT) WinSendDlgItemMsg(hwnd, | 
|---|
|  | 907 | ASEL_LISTBOX, | 
|---|
|  | 908 | LM_QUERYSELECTION, | 
|---|
|  | 909 | MPFROMSHORT(LIT_FIRST), MPVOID); | 
|---|
| [306] | 910 | if (sSelect != LIT_NONE) { | 
|---|
|  | 911 | ARCDUMP ad; | 
|---|
| [551] | 912 |  | 
|---|
|  | 913 | memset(&ad, 0, sizeof(ARCDUMP)); | 
|---|
|  | 914 | ad.info = xmallocz(sizeof(ARC_TYPE), pszSrcFile, __LINE__); | 
|---|
| [306] | 915 | if (ad.info) { | 
|---|
|  | 916 | if (!WinDlgBox(HWND_DESKTOP, | 
|---|
|  | 917 | hwnd, | 
|---|
|  | 918 | ArcReviewDlgProc, | 
|---|
| [551] | 919 | FM3ModHandle, AD_FRAME, MPFROMP(&ad))) { | 
|---|
| [1039] | 920 | free(ad.info); | 
|---|
| [287] | 921 | } | 
|---|
| [306] | 922 | else { | 
|---|
|  | 923 | // Find self - assume all archivers listed since we are editing | 
|---|
| [551] | 924 | for (i = 0, pat = arcsighead; pat && i < sSelect; pat = pat->next, i++) ;   // Find self | 
|---|
| [2] | 925 |  | 
|---|
| [306] | 926 | if (!pat) { | 
|---|
|  | 927 | if (arcsighead) | 
|---|
| [551] | 928 | Runtime_Error(pszSrcFile, __LINE__, pszCantFindMsg, sSelect); | 
|---|
| [306] | 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 | } | 
|---|
| [287] | 946 | WinSendDlgItemMsg(hwnd, ASEL_LISTBOX, LM_INSERTITEM, | 
|---|
| [306] | 947 | MPFROM2SHORT(sSelect, 0), | 
|---|
| [551] | 948 | MPFROMP(ad.info->id ? ad.info->id : "?")); | 
|---|
| [306] | 949 | WinSendDlgItemMsg(hwnd, ASEL_LISTBOX, LM_SELECTITEM, | 
|---|
|  | 950 | MPFROMSHORT(sSelect - 1), MPFROMSHORT(TRUE)); | 
|---|
|  | 951 | arcsigsmodified = TRUE; | 
|---|
| [287] | 952 | } | 
|---|
|  | 953 | } | 
|---|
|  | 954 | } | 
|---|
| [306] | 955 | return 0; | 
|---|
|  | 956 | case ASEL_PB_DELETE: | 
|---|
| [551] | 957 | sSelect = (SHORT) WinSendDlgItemMsg(hwnd, | 
|---|
|  | 958 | ASEL_LISTBOX, | 
|---|
|  | 959 | LM_QUERYSELECTION, | 
|---|
|  | 960 | MPFROMSHORT(LIT_FIRST), MPVOID); | 
|---|
| [306] | 961 | if (sSelect != LIT_NONE) { | 
|---|
|  | 962 | // Find self - assume all archivers listed since we are editing | 
|---|
| [551] | 963 | for (i = 0, pat = arcsighead; pat && i < sSelect; pat = pat->next, i++) ;       // Find self | 
|---|
| [2] | 964 |  | 
|---|
| [439] | 965 | if (!pat) | 
|---|
| [551] | 966 | Runtime_Error(pszSrcFile, __LINE__, pszCantFindMsg, sSelect); | 
|---|
| [306] | 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; | 
|---|
| [287] | 973 | } | 
|---|
| [306] | 974 | else { | 
|---|
|  | 975 | arcsighead = pat->next; | 
|---|
|  | 976 | if (pat->next) | 
|---|
|  | 977 | pat->next->prev = pat->prev; | 
|---|
|  | 978 | } | 
|---|
| [247] | 979 | } | 
|---|
| [306] | 980 | free_arc_type(pat); | 
|---|
|  | 981 | arcsigsmodified = TRUE; | 
|---|
|  | 982 | WinSendDlgItemMsg(hwnd, ASEL_LISTBOX, LM_DELETEITEM, | 
|---|
| [551] | 983 | MPFROM2SHORT(sSelect, 0), MPVOID); | 
|---|
|  | 984 | sItemCount = | 
|---|
|  | 985 | (SHORT) WinSendDlgItemMsg(hwnd, ASEL_LISTBOX, LM_QUERYITEMCOUNT, | 
|---|
|  | 986 | MPVOID, MPVOID); | 
|---|
| [306] | 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: | 
|---|
| [551] | 996 | sSelect = (SHORT) WinSendDlgItemMsg(hwnd, | 
|---|
|  | 997 | ASEL_LISTBOX, | 
|---|
|  | 998 | LM_QUERYSELECTION, | 
|---|
|  | 999 | MPFROMSHORT(LIT_FIRST), MPVOID); | 
|---|
| [306] | 1000 | if (sSelect != LIT_NONE && sSelect > 0) { | 
|---|
|  | 1001 | // Find self - assume all archivers listed since we are editing | 
|---|
| [551] | 1002 | for (i = 0, pat = arcsighead; pat && i < sSelect; pat = pat->next, i++) ;       // Find self | 
|---|
| [439] | 1003 | if (!pat || !pat->prev) | 
|---|
| [551] | 1004 | Runtime_Error(pszSrcFile, __LINE__, pszCantFindMsg, sSelect); | 
|---|
| [306] | 1005 | else { | 
|---|
|  | 1006 | ARC_TYPE *patGDad; | 
|---|
|  | 1007 | ARC_TYPE *patDad; | 
|---|
|  | 1008 | ARC_TYPE *patChild; | 
|---|
| [551] | 1009 |  | 
|---|
| [306] | 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; | 
|---|
| [287] | 1021 | } | 
|---|
| [306] | 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, | 
|---|
| [551] | 1030 | MPFROM2SHORT(sSelect - 1, 255), | 
|---|
|  | 1031 | MPFROMP(szPCItemText)); | 
|---|
| [306] | 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; | 
|---|
| [287] | 1039 | } | 
|---|
| [306] | 1040 | } | 
|---|
|  | 1041 | return 0; | 
|---|
|  | 1042 | case ASEL_PB_DOWN: | 
|---|
| [551] | 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); | 
|---|
| [306] | 1049 | if (sSelect != LIT_NONE && sSelect < sItemCount - 1) { | 
|---|
|  | 1050 | // Find self - assume all archivers listed since we are editing | 
|---|
| [551] | 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); | 
|---|
| [306] | 1055 | else { | 
|---|
|  | 1056 | ARC_TYPE *patDad; | 
|---|
|  | 1057 | ARC_TYPE *patChild; | 
|---|
| [551] | 1058 |  | 
|---|
| [306] | 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; | 
|---|
| [551] | 1067 | patChild->prev = patDad; | 
|---|
| [306] | 1068 | } | 
|---|
|  | 1069 | else { | 
|---|
|  | 1070 | arcsighead = patChild; | 
|---|
| [551] | 1071 | patChild->prev = NULL; | 
|---|
| [306] | 1072 | } | 
|---|
|  | 1073 |  | 
|---|
|  | 1074 | WinSendDlgItemMsg(hwnd, ASEL_LISTBOX, LM_QUERYITEMTEXT, | 
|---|
|  | 1075 | MPFROM2SHORT(sSelect, 255), MPFROMP(szItemText)); | 
|---|
|  | 1076 | WinSendDlgItemMsg(hwnd, ASEL_LISTBOX, LM_QUERYITEMTEXT, | 
|---|
| [551] | 1077 | MPFROM2SHORT(sSelect + 1, 255), | 
|---|
|  | 1078 | MPFROMP(szPCItemText)); | 
|---|
| [306] | 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)); | 
|---|
| [287] | 1083 | WinSendDlgItemMsg(hwnd, ASEL_LISTBOX, LM_SELECTITEM, | 
|---|
| [306] | 1084 | MPFROMSHORT(sSelect + 1), MPFROMSHORT(TRUE)); | 
|---|
|  | 1085 | arcsigsmodified = TRUE; | 
|---|
| [287] | 1086 | } | 
|---|
|  | 1087 | } | 
|---|
|  | 1088 | return 0; | 
|---|
| [2] | 1089 |  | 
|---|
| [306] | 1090 | case ASEL_PB_REVERT: | 
|---|
|  | 1091 | // Reload without checking in case changed outside | 
|---|
| [551] | 1092 | sSelect = | 
|---|
|  | 1093 | (SHORT) WinSendDlgItemMsg(hwnd, ASEL_LISTBOX, LM_QUERYSELECTION, | 
|---|
|  | 1094 | MPFROMSHORT(LIT_FIRST), MPVOID); | 
|---|
| [306] | 1095 | load_archivers(); | 
|---|
|  | 1096 | fill_listbox(hwnd, TRUE, sSelect); | 
|---|
|  | 1097 | return 0; | 
|---|
| [2] | 1098 |  | 
|---|
| [306] | 1099 | case IDM_HELP: | 
|---|
|  | 1100 | if (hwndHelp) { | 
|---|
| [551] | 1101 | WinSendMsg(hwndHelp, HM_DISPLAY_HELP, MPFROM2SHORT(HELP_EDITARC, 0),    // fixme to be HELP_SELARC | 
|---|
|  | 1102 | MPFROMSHORT(HM_RESOURCEID)); | 
|---|
| [306] | 1103 | } | 
|---|
| [247] | 1104 | } | 
|---|
| [306] | 1105 | return 0;                           // WM_COMMAND | 
|---|
| [287] | 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); | 
|---|
| [2] | 1120 | } | 
|---|
|  | 1121 |  | 
|---|
| [1616] | 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 | 
|---|
| [1625] | 1129 | *  Aug 21 23:55 2011            6 Fixes tar.gz date/time formatting when using tar 1..15+ | 
|---|
| [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) { | 
|---|
| [1625] | 1193 | cdate->month = x + 1; | 
|---|
| [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) { | 
|---|
| [1625] | 1234 | cdate->month = x + 1; | 
|---|
| [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 | } | 
|---|
| [1625] | 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; | 
|---|
| [287] | 1381 | default: | 
|---|
|  | 1382 | break; | 
|---|
|  | 1383 | } | 
|---|
| [2] | 1384 | } | 
|---|
| [287] | 1385 | } | 
|---|
|  | 1386 | return ret; | 
|---|
| [2] | 1387 | } | 
|---|
| [793] | 1388 |  | 
|---|
|  | 1389 | #pragma alloc_text(MISC9,quick_find_type,find_type) | 
|---|
| [1029] | 1390 | #pragma alloc_text(AVL,load_archivers, get_line_strip_comments, get_line_strip_white, free_archivers) | 
|---|
| [793] | 1391 | #pragma alloc_text(FMARCHIVE,SBoxDlgProc,SDlgListboxSubclassProc) | 
|---|
|  | 1392 | #pragma alloc_text(ARCCNRS,ArcDateTime) | 
|---|