| 1 | 
 | 
|---|
| 2 | /***********************************************************************
 | 
|---|
| 3 | 
 | 
|---|
| 4 |   $Id: extract.c 1717 2014-02-15 23:06:47Z gyoung $
 | 
|---|
| 5 | 
 | 
|---|
| 6 |   Copyright (c) 1993-98 M. Kimes
 | 
|---|
| 7 |   Copyright (c) 2004, 2013 Steven H. Levine
 | 
|---|
| 8 | 
 | 
|---|
| 9 |   01 Aug 04 SHL Rework lstrip/rstrip usage
 | 
|---|
| 10 |   05 Jun 05 SHL Use QWL_USER
 | 
|---|
| 11 |   17 Jul 06 SHL Use Runtime_Error
 | 
|---|
| 12 |   20 Dec 06 GKY Added checkbox to make default extract with directories
 | 
|---|
| 13 |   22 Mar 07 GKY Use QWL_USER
 | 
|---|
| 14 |   19 Apr 07 SHL Sync with AcceptOneDrop GetOneDrop mods
 | 
|---|
| 15 |   20 Aug 07 GKY Move #pragma alloc_text to end for OpenWatcom compat
 | 
|---|
| 16 |   19 Jul 08 GKY Replace save_dir2(dir) with pFM2SaveDirectory
 | 
|---|
| 17 |   29 Nov 08 GKY Add the option of creating a subdirectory from the arcname
 | 
|---|
| 18 |                 for the extract path.
 | 
|---|
| 19 |   07 Feb 09 GKY Allow user to turn off alert and/or error beeps in settings notebook.
 | 
|---|
| 20 |   17 Jan 10 GKY Changes to get working with Watcom 1.9 Beta (1/16/10). Mostly cast CHAR CONSTANT * as CHAR *.
 | 
|---|
| 21 |   23 Oct 10 GKY Changes to populate and utilize a HELPTABLE for context specific help
 | 
|---|
| 22 |   11 Aug 13 GKY Fix directory create failure on extract to directory based on archive name
 | 
|---|
| 23 |                 if the name needed quoting.
 | 
|---|
| 24 |   15 Feb 14 GKY Assure the title is blank on the execute dialog call with the "see" button
 | 
|---|
| 25 | 
 | 
|---|
| 26 | ***********************************************************************/
 | 
|---|
| 27 | 
 | 
|---|
| 28 | #include <string.h>
 | 
|---|
| 29 | #include <ctype.h>
 | 
|---|
| 30 | 
 | 
|---|
| 31 | #define INCL_WIN
 | 
|---|
| 32 | #define INCL_DOS
 | 
|---|
| 33 | #define INCL_LONGLONG                   // dircnrs.h
 | 
|---|
| 34 | 
 | 
|---|
| 35 | #include "fm3dll.h"
 | 
|---|
| 36 | #include "fm3dll2.h"                    // #define's for UM_*, control id's, etc.
 | 
|---|
| 37 | #include "init.h"                       // Data declaration(s)
 | 
|---|
| 38 | #include "arccnrs.h"                    // Data declaration(s)
 | 
|---|
| 39 | #include "notebook.h"                   // Data declaration(s)
 | 
|---|
| 40 | #include "mainwnd.h"                    // Data declaration(s)
 | 
|---|
| 41 | #include "fm3dlg.h"
 | 
|---|
| 42 | #include "fm3str.h"
 | 
|---|
| 43 | #include "errutil.h"                    // Dos_Error...
 | 
|---|
| 44 | #include "strutil.h"                    // GetPString
 | 
|---|
| 45 | #include "cmdline.h"                    // CmdLineDlgProc
 | 
|---|
| 46 | #include "extract.h"
 | 
|---|
| 47 | #include "walkem.h"                     // WalkExtractDlgProc
 | 
|---|
| 48 | #include "droplist.h"                   // AcceptOneDrop, DropHelp, GetOneDrop
 | 
|---|
| 49 | #include "misc.h"                       // DrawTargetEmphasis
 | 
|---|
| 50 | #include "chklist.h"                    // PosOverOkay
 | 
|---|
| 51 | #include "mkdir.h"                      // SetDir
 | 
|---|
| 52 | #include "valid.h"                      // MakeValidDir
 | 
|---|
| 53 | #include "systemf.h"                    // runemf2
 | 
|---|
| 54 | #include "dirs.h"                       // save_dir2
 | 
|---|
| 55 | #include "strips.h"                     // bstrip
 | 
|---|
| 56 | 
 | 
|---|
| 57 | #pragma data_seg(DATA1)
 | 
|---|
| 58 | 
 | 
|---|
| 59 | static PSZ pszSrcFile = __FILE__;
 | 
|---|
| 60 | 
 | 
|---|
| 61 | MRESULT EXPENTRY ExtractTextProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
 | 
|---|
| 62 | {
 | 
|---|
| 63 |   PFNWP oldproc = (PFNWP) WinQueryWindowPtr(hwnd, QWL_USER);
 | 
|---|
| 64 |   static BOOL emphasized = FALSE;
 | 
|---|
| 65 | 
 | 
|---|
| 66 |   switch (msg) {
 | 
|---|
| 67 |   case DM_DRAGOVER:
 | 
|---|
| 68 |     if (!emphasized) {
 | 
|---|
| 69 |       emphasized = TRUE;
 | 
|---|
| 70 |       DrawTargetEmphasis(hwnd, emphasized);
 | 
|---|
| 71 |     }
 | 
|---|
| 72 |     if (AcceptOneDrop(hwnd, mp1, mp2))
 | 
|---|
| 73 |       return MRFROM2SHORT(DOR_DROP, DO_MOVE);
 | 
|---|
| 74 |     return MRFROM2SHORT(DOR_NEVERDROP, 0);
 | 
|---|
| 75 | 
 | 
|---|
| 76 |   case DM_DRAGLEAVE:
 | 
|---|
| 77 |     if (emphasized) {
 | 
|---|
| 78 |       emphasized = FALSE;
 | 
|---|
| 79 |       DrawTargetEmphasis(hwnd, emphasized);
 | 
|---|
| 80 |     }
 | 
|---|
| 81 |     break;
 | 
|---|
| 82 | 
 | 
|---|
| 83 |   case DM_DROPHELP:
 | 
|---|
| 84 |     DropHelp(mp1, mp2, hwnd, GetPString(IDS_EXTDROPHELPTEXT));
 | 
|---|
| 85 |     return 0;
 | 
|---|
| 86 | 
 | 
|---|
| 87 |   case DM_DROP:
 | 
|---|
| 88 |     {
 | 
|---|
| 89 |       char szFrom[CCHMAXPATH + 2];
 | 
|---|
| 90 | 
 | 
|---|
| 91 |       if (emphasized) {
 | 
|---|
| 92 |         emphasized = FALSE;
 | 
|---|
| 93 |         DrawTargetEmphasis(hwnd, emphasized);
 | 
|---|
| 94 |       }
 | 
|---|
| 95 |       if (GetOneDrop(hwnd, mp1, mp2, szFrom, sizeof(szFrom)))
 | 
|---|
| 96 |         WinSendMsg(WinQueryWindow(hwnd, QW_PARENT), WM_COMMAND,
 | 
|---|
| 97 |                    MPFROM2SHORT(IDM_SWITCH, 0), MPFROMP(szFrom));
 | 
|---|
| 98 |     }
 | 
|---|
| 99 |     return 0;
 | 
|---|
| 100 |   }
 | 
|---|
| 101 |   return (oldproc) ? oldproc(hwnd, msg, mp1, mp2) :
 | 
|---|
| 102 |     WinDefWindowProc(hwnd, msg, mp1, mp2);
 | 
|---|
| 103 | }
 | 
|---|
| 104 | 
 | 
|---|
| 105 | MRESULT EXPENTRY ExtractDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
 | 
|---|
| 106 | {
 | 
|---|
| 107 |   EXTRDATA *arcdata = NULL;
 | 
|---|
| 108 |   ULONG size;
 | 
|---|
| 109 |   BOOL fFileNameExtPath;
 | 
|---|
| 110 | 
 | 
|---|
| 111 |   switch (msg) {
 | 
|---|
| 112 |   case WM_INITDLG:
 | 
|---|
| 113 |     WinSetWindowPtr(hwnd, QWL_USER, mp2);
 | 
|---|
| 114 |     arcdata = (EXTRDATA *) mp2;
 | 
|---|
| 115 |     {
 | 
|---|
| 116 |       BOOL fDirectory = FALSE;
 | 
|---|
| 117 |       BOOL fRemember = FALSE;
 | 
|---|
| 118 |       PFNWP oldproc;
 | 
|---|
| 119 | 
 | 
|---|
| 120 |       fFileNameExtPath = FALSE;
 | 
|---|
| 121 |       oldproc = WinSubclassWindow(WinWindowFromID(hwnd, EXT_DIRECTORY),
 | 
|---|
| 122 |                                   (PFNWP) ExtractTextProc);
 | 
|---|
| 123 |       if (oldproc)
 | 
|---|
| 124 |         WinSetWindowPtr(WinWindowFromID(hwnd, EXT_DIRECTORY),
 | 
|---|
| 125 |                         QWL_USER, (PVOID) oldproc);
 | 
|---|
| 126 |       size = sizeof(BOOL);
 | 
|---|
| 127 |       PrfQueryProfileData(fmprof, FM3Str, "RememberExt",
 | 
|---|
| 128 |                           (PVOID) & fRemember, &size);
 | 
|---|
| 129 |       size = sizeof(BOOL);
 | 
|---|
| 130 |       PrfQueryProfileData(fmprof, FM3Str, "DirectoryExt",
 | 
|---|
| 131 |                           (PVOID) & fDirectory, &size);
 | 
|---|
| 132 |       size = sizeof(BOOL);
 | 
|---|
| 133 |       PrfQueryProfileData(fmprof, FM3Str, "FileNamePathExt",
 | 
|---|
| 134 |                           (PVOID) & fFileNameExtPath, &size);
 | 
|---|
| 135 |       WinCheckButton(hwnd, EXT_REMEMBER, fRemember);
 | 
|---|
| 136 |       WinCheckButton(hwnd, EXT_AWDIRS, fDirectory);
 | 
|---|
| 137 |       WinCheckButton(hwnd, EXT_FILENAMEEXT, fFileNameExtPath);
 | 
|---|
| 138 |       WinSendDlgItemMsg(hwnd, EXT_DIRECTORY, EM_SETTEXTLIMIT,
 | 
|---|
| 139 |                         MPFROM2SHORT(CCHMAXPATH, 0), MPVOID);
 | 
|---|
| 140 |       WinSendDlgItemMsg(hwnd, EXT_COMMAND, EM_SETTEXTLIMIT,
 | 
|---|
| 141 |                         MPFROM2SHORT(256, 0), MPVOID);
 | 
|---|
| 142 |       WinSendDlgItemMsg(hwnd, EXT_MASK, EM_SETTEXTLIMIT,
 | 
|---|
| 143 |                         MPFROM2SHORT(256, 0), MPVOID);
 | 
|---|
| 144 |       WinSendDlgItemMsg(hwnd, EXT_FILENAME, EM_SETTEXTLIMIT,
 | 
|---|
| 145 |                         MPFROM2SHORT(CCHMAXPATH, 0), MPVOID);
 | 
|---|
| 146 |       if (arcdata->arcname && *arcdata->arcname)
 | 
|---|
| 147 |         WinSetDlgItemText(hwnd, EXT_FILENAME, arcdata->arcname);
 | 
|---|
| 148 |       else
 | 
|---|
| 149 |         WinSetDlgItemText(hwnd, EXT_FILENAME, (CHAR *) GetPString(IDS_EXTVARIOUSTEXT));
 | 
|---|
| 150 | 
 | 
|---|
| 151 |       if (fFileNameExtPath && arcdata->arcname) {
 | 
|---|
| 152 | 
 | 
|---|
| 153 |         CHAR FileName[CCHMAXPATH];
 | 
|---|
| 154 |         PSZ p;
 | 
|---|
| 155 | 
 | 
|---|
| 156 |         strcpy(FileName, arcdata->arcname);
 | 
|---|
| 157 |         p = strrchr(FileName, '.');
 | 
|---|
| 158 |         if (p) {
 | 
|---|
| 159 |           *p = 0;
 | 
|---|
| 160 |           if (strchr(FileName, '\"'))
 | 
|---|
| 161 |             memmove(FileName, FileName + 1, strlen(FileName) + 1);
 | 
|---|
| 162 |         }
 | 
|---|
| 163 |         else {
 | 
|---|
| 164 |           p = FileName + strlen(arcdata->arcname);
 | 
|---|
| 165 |           p--;
 | 
|---|
| 166 |           *p = 0;
 | 
|---|
| 167 |           if (strchr(FileName, '\"'))
 | 
|---|
| 168 |             memmove(FileName , FileName + 1, strlen(FileName) + 1);
 | 
|---|
| 169 |         }
 | 
|---|
| 170 |         strcpy(arcdata->extractdir, FileName);
 | 
|---|
| 171 |         WinSetDlgItemText(hwnd, EXT_DIRECTORY, arcdata->extractdir);
 | 
|---|
| 172 |       }
 | 
|---|
| 173 |       if (fDirectory) {
 | 
|---|
| 174 |         WinSendDlgItemMsg(hwnd, EXT_WDIRS, BM_SETCHECK,
 | 
|---|
| 175 |                           MPFROM2SHORT(TRUE, 0), MPVOID);
 | 
|---|
| 176 |         WinSetDlgItemText(hwnd, EXT_COMMAND, arcdata->info->exwdirs);
 | 
|---|
| 177 |       }
 | 
|---|
| 178 |       else {
 | 
|---|
| 179 |         WinSendDlgItemMsg(hwnd, EXT_NORMAL, BM_SETCHECK,
 | 
|---|
| 180 |                           MPFROM2SHORT(TRUE, 0), MPVOID);
 | 
|---|
| 181 |         WinSetDlgItemText(hwnd, EXT_COMMAND, arcdata->info->extract);
 | 
|---|
| 182 | 
 | 
|---|
| 183 |       }
 | 
|---|
| 184 |       if (fRemember) {
 | 
|---|
| 185 | 
 | 
|---|
| 186 |         CHAR textdir[CCHMAXPATH];
 | 
|---|
| 187 | 
 | 
|---|
| 188 |         PrfQueryProfileString(fmprof, FM3Str, "Ext_ExtractDir", NULL, textdir, sizeof(textdir));
 | 
|---|
| 189 |         if (*textdir && !IsFile(textdir))
 | 
|---|
| 190 |           strcpy(arcdata->extractdir, textdir);
 | 
|---|
| 191 |         PrfQueryProfileString(fmprof, FM3Str, "Ext_Mask", NULL, textdir, sizeof(textdir));
 | 
|---|
| 192 |         WinSetDlgItemText(hwnd, EXT_MASK, textdir);
 | 
|---|
| 193 |       }
 | 
|---|
| 194 |       if (*extractpath && (!fRemember || !*arcdata->extractdir)) {
 | 
|---|
| 195 |         if (arcdata->arcname && *arcdata->arcname &&
 | 
|---|
| 196 |             !strcmp(extractpath, "*")) {
 | 
|---|
| 197 | 
 | 
|---|
| 198 |           CHAR *p;
 | 
|---|
| 199 | 
 | 
|---|
| 200 |           strcpy(arcdata->extractdir, arcdata->arcname);
 | 
|---|
| 201 |           p = strrchr(arcdata->extractdir, '\\');
 | 
|---|
| 202 |           if (p) {
 | 
|---|
| 203 |             if (p < arcdata->extractdir + 3)
 | 
|---|
| 204 |               p++;
 | 
|---|
| 205 |             *p = 0;
 | 
|---|
| 206 |           }
 | 
|---|
| 207 |         }
 | 
|---|
| 208 |         else
 | 
|---|
| 209 |           strcpy(arcdata->extractdir, extractpath);
 | 
|---|
| 210 |       }
 | 
|---|
| 211 |       if (!*arcdata->extractdir) {
 | 
|---|
| 212 |         if (*lastextractpath)
 | 
|---|
| 213 |           strcpy(arcdata->extractdir, lastextractpath);
 | 
|---|
| 214 |         else if (arcdata->arcname && *arcdata->arcname) {
 | 
|---|
| 215 | 
 | 
|---|
| 216 |           CHAR *p;
 | 
|---|
| 217 | 
 | 
|---|
| 218 |           strcpy(arcdata->extractdir, arcdata->arcname);
 | 
|---|
| 219 |           p = strrchr(arcdata->extractdir, '\\');
 | 
|---|
| 220 |           if (p) {
 | 
|---|
| 221 |             if (p < arcdata->extractdir + 3)
 | 
|---|
| 222 |               p++;
 | 
|---|
| 223 |             *p = 0;
 | 
|---|
| 224 |           }
 | 
|---|
| 225 |         }
 | 
|---|
| 226 |         if (!*arcdata->extractdir)
 | 
|---|
| 227 |           strcpy(arcdata->extractdir, pFM2SaveDirectory);
 | 
|---|
| 228 |       }
 | 
|---|
| 229 |       WinSetDlgItemText(hwnd, EXT_DIRECTORY, arcdata->extractdir);
 | 
|---|
| 230 |       if (!arcdata->info->exwdirs)
 | 
|---|
| 231 |         WinEnableWindow(WinWindowFromID(hwnd, EXT_WDIRS), FALSE);
 | 
|---|
| 232 |       else if (fRemember) {
 | 
|---|
| 233 |         fRemember = FALSE;
 | 
|---|
| 234 |         size = sizeof(BOOL);
 | 
|---|
| 235 |         PrfQueryProfileData(fmprof, FM3Str, "Ext_WDirs",
 | 
|---|
| 236 |                             (PVOID) &fRemember, &size);
 | 
|---|
| 237 |         if (fRemember)
 | 
|---|
| 238 |           PostMsg(WinWindowFromID(hwnd, EXT_WDIRS), BM_CLICK, MPVOID, MPVOID);
 | 
|---|
| 239 |       }
 | 
|---|
| 240 |     }
 | 
|---|
| 241 |     *arcdata->command = 0;
 | 
|---|
| 242 |     PosOverOkay(hwnd);
 | 
|---|
| 243 |     break;
 | 
|---|
| 244 | 
 | 
|---|
| 245 |   case WM_ADJUSTWINDOWPOS:
 | 
|---|
| 246 |     PostMsg(hwnd, UM_SETDIR, MPVOID, MPVOID);
 | 
|---|
| 247 |     break;
 | 
|---|
| 248 | 
 | 
|---|
| 249 |   case UM_SETDIR:
 | 
|---|
| 250 |     PaintRecessedWindow(WinWindowFromID(hwnd, EXT_HELP), (HPS) 0, FALSE,
 | 
|---|
| 251 |                         TRUE);
 | 
|---|
| 252 |     return 0;
 | 
|---|
| 253 | 
 | 
|---|
| 254 |   case WM_CONTROL:
 | 
|---|
| 255 |     arcdata = (EXTRDATA *) WinQueryWindowPtr(hwnd, QWL_USER);
 | 
|---|
| 256 |     switch (SHORT1FROMMP(mp1)) {
 | 
|---|
| 257 |     case EXT_REMEMBER:
 | 
|---|
| 258 |       {
 | 
|---|
| 259 |         BOOL fRemember = WinQueryButtonCheckstate(hwnd, EXT_REMEMBER);
 | 
|---|
| 260 |         size = sizeof(BOOL);
 | 
|---|
| 261 |         PrfWriteProfileData(fmprof, FM3Str, "RememberExt",
 | 
|---|
| 262 |                             (PVOID) &fRemember, size);
 | 
|---|
| 263 |         WinSendDlgItemMsg(hwnd, EXT_FILENAMEEXT, BM_SETCHECK,
 | 
|---|
| 264 |                             MPFROM2SHORT(FALSE, 0), MPVOID);
 | 
|---|
| 265 |       }
 | 
|---|
| 266 |       break;
 | 
|---|
| 267 | 
 | 
|---|
| 268 |     case EXT_AWDIRS:
 | 
|---|
| 269 |       {
 | 
|---|
| 270 |         BOOL fDirectory = WinQueryButtonCheckstate(hwnd, EXT_AWDIRS);
 | 
|---|
| 271 |         size = sizeof(BOOL);
 | 
|---|
| 272 |         PrfWriteProfileData(fmprof, FM3Str, "DirectoryExt",
 | 
|---|
| 273 |                             (PVOID) &fDirectory, size);
 | 
|---|
| 274 | 
 | 
|---|
| 275 |         if (fDirectory) {
 | 
|---|
| 276 |           WinSendDlgItemMsg(hwnd, EXT_WDIRS, BM_SETCHECK,
 | 
|---|
| 277 |                             MPFROM2SHORT(TRUE, 0), MPVOID);
 | 
|---|
| 278 |           WinSetDlgItemText(hwnd, EXT_COMMAND, arcdata->info->exwdirs);
 | 
|---|
| 279 |         }
 | 
|---|
| 280 |         else {
 | 
|---|
| 281 |           WinSendDlgItemMsg(hwnd, EXT_NORMAL, BM_SETCHECK,
 | 
|---|
| 282 |                             MPFROM2SHORT(TRUE, 0), MPVOID);
 | 
|---|
| 283 |           WinSetDlgItemText(hwnd, EXT_COMMAND, arcdata->info->extract);
 | 
|---|
| 284 |         }
 | 
|---|
| 285 |       }
 | 
|---|
| 286 |       break;
 | 
|---|
| 287 | 
 | 
|---|
| 288 |     case EXT_FILENAMEEXT:
 | 
|---|
| 289 |       {
 | 
|---|
| 290 |         BOOL fFileNameExtPath = WinQueryButtonCheckstate(hwnd, EXT_FILENAMEEXT);
 | 
|---|
| 291 |         BOOL fRemember = WinQueryButtonCheckstate(hwnd, EXT_REMEMBER);
 | 
|---|
| 292 |         size = sizeof(BOOL);
 | 
|---|
| 293 |         PrfWriteProfileData(fmprof, FM3Str, "FileNamePathExt",
 | 
|---|
| 294 |                             fRemember ? FALSE : (PVOID) &fFileNameExtPath, size);
 | 
|---|
| 295 |         if (fRemember) {
 | 
|---|
| 296 |           WinSendDlgItemMsg(hwnd, EXT_FILENAMEEXT, BM_SETCHECK,
 | 
|---|
| 297 |                             MPFROM2SHORT(FALSE, 0), MPVOID);
 | 
|---|
| 298 |           break;
 | 
|---|
| 299 |         }
 | 
|---|
| 300 |         if (fFileNameExtPath && arcdata->arcname) {
 | 
|---|
| 301 |           CHAR FileName[CCHMAXPATH];
 | 
|---|
| 302 |           PSZ p;
 | 
|---|
| 303 | 
 | 
|---|
| 304 |           strcpy(FileName, arcdata->arcname);
 | 
|---|
| 305 |           p = strrchr(FileName, '.');
 | 
|---|
| 306 |           if (p) {
 | 
|---|
| 307 |             *p = 0;
 | 
|---|
| 308 |             if (strchr(FileName, '\"'))
 | 
|---|
| 309 |             memmove(FileName, FileName + 1, strlen(FileName) + 1);
 | 
|---|
| 310 |           }
 | 
|---|
| 311 |           else {
 | 
|---|
| 312 |             p = FileName + strlen(arcdata->arcname);
 | 
|---|
| 313 |             p--;
 | 
|---|
| 314 |             *p = 0;
 | 
|---|
| 315 |             if (strchr(FileName, '\"'))
 | 
|---|
| 316 |             memmove(FileName, FileName + 1, strlen(FileName) + 1);
 | 
|---|
| 317 |           }
 | 
|---|
| 318 |           strcpy(arcdata->extractdir, FileName);
 | 
|---|
| 319 |           WinSetDlgItemText(hwnd, EXT_DIRECTORY, arcdata->extractdir);
 | 
|---|
| 320 |         }
 | 
|---|
| 321 |         else {
 | 
|---|
| 322 |           *arcdata->extractdir = 0;
 | 
|---|
| 323 |           if (*extractpath) {
 | 
|---|
| 324 |             if (arcdata->arcname && *arcdata->arcname &&
 | 
|---|
| 325 |                 !strcmp(extractpath, "*")) {
 | 
|---|
| 326 | 
 | 
|---|
| 327 |               CHAR *p;
 | 
|---|
| 328 | 
 | 
|---|
| 329 |               strcpy(arcdata->extractdir, arcdata->arcname);
 | 
|---|
| 330 |               p = strrchr(arcdata->extractdir, '\\');
 | 
|---|
| 331 |               if (p) {
 | 
|---|
| 332 |                 if (p < arcdata->extractdir + 3)
 | 
|---|
| 333 |                   p++;
 | 
|---|
| 334 |                 *p = 0;
 | 
|---|
| 335 |               }
 | 
|---|
| 336 |             }
 | 
|---|
| 337 |             else
 | 
|---|
| 338 |               strcpy(arcdata->extractdir, extractpath);
 | 
|---|
| 339 |           }
 | 
|---|
| 340 |           if (!*arcdata->extractdir) {
 | 
|---|
| 341 |             if (arcdata->arcname && *arcdata->arcname) {
 | 
|---|
| 342 | 
 | 
|---|
| 343 |               CHAR *p;
 | 
|---|
| 344 | 
 | 
|---|
| 345 |               strcpy(arcdata->extractdir, arcdata->arcname);
 | 
|---|
| 346 |               p = strrchr(arcdata->extractdir, '\\');
 | 
|---|
| 347 |               if (p) {
 | 
|---|
| 348 |                 if (p < arcdata->extractdir + 3)
 | 
|---|
| 349 |                   p++;
 | 
|---|
| 350 |                 *p = 0;
 | 
|---|
| 351 |               }
 | 
|---|
| 352 |             }
 | 
|---|
| 353 |             if (!*arcdata->extractdir)
 | 
|---|
| 354 |               strcpy(arcdata->extractdir, pFM2SaveDirectory);
 | 
|---|
| 355 |           }
 | 
|---|
| 356 |           WinSetDlgItemText(hwnd, EXT_DIRECTORY, arcdata->extractdir);
 | 
|---|
| 357 |         }
 | 
|---|
| 358 |       }
 | 
|---|
| 359 |       break;
 | 
|---|
| 360 | 
 | 
|---|
| 361 |     case EXT_FILENAME:
 | 
|---|
| 362 |       if (SHORT2FROMMP(mp1) == EN_KILLFOCUS)
 | 
|---|
| 363 |         WinSetDlgItemText(hwnd, EXT_HELP, (CHAR *) GetPString(IDS_ARCDEFAULTHELPTEXT));
 | 
|---|
| 364 |       if (SHORT2FROMMP(mp1) == EN_SETFOCUS)
 | 
|---|
| 365 |         WinSetDlgItemText(hwnd, EXT_HELP, (CHAR *) GetPString(IDS_ARCARCNAMEHELPTEXT));
 | 
|---|
| 366 |       break;
 | 
|---|
| 367 | 
 | 
|---|
| 368 |     case EXT_DIRECTORY:
 | 
|---|
| 369 |       if (SHORT2FROMMP(mp1) == EN_KILLFOCUS)
 | 
|---|
| 370 |         WinSetDlgItemText(hwnd, EXT_HELP, (CHAR *) GetPString(IDS_ARCDEFAULTHELPTEXT));
 | 
|---|
| 371 |       if (SHORT2FROMMP(mp1) == EN_SETFOCUS)
 | 
|---|
| 372 |         WinSetDlgItemText(hwnd, EXT_HELP, (CHAR *) GetPString(IDS_EXTEXTRACTDIRHELPTEXT));
 | 
|---|
| 373 |       break;
 | 
|---|
| 374 | 
 | 
|---|
| 375 |     case EXT_COMMAND:
 | 
|---|
| 376 |       if (SHORT2FROMMP(mp1) == EN_KILLFOCUS)
 | 
|---|
| 377 |         WinSetDlgItemText(hwnd, EXT_HELP, (CHAR *) GetPString(IDS_ARCDEFAULTHELPTEXT));
 | 
|---|
| 378 |       if (SHORT2FROMMP(mp1) == EN_SETFOCUS)
 | 
|---|
| 379 |         WinSetDlgItemText(hwnd, EXT_HELP, (CHAR *) GetPString(IDS_ARCCMDHELPTEXT));
 | 
|---|
| 380 |       break;
 | 
|---|
| 381 | 
 | 
|---|
| 382 |     case EXT_MASK:
 | 
|---|
| 383 |       if (SHORT2FROMMP(mp1) == EN_KILLFOCUS)
 | 
|---|
| 384 |         WinSetDlgItemText(hwnd, EXT_HELP, (CHAR *) GetPString(IDS_ARCDEFAULTHELPTEXT));
 | 
|---|
| 385 |       if (SHORT2FROMMP(mp1) == EN_SETFOCUS)
 | 
|---|
| 386 |         WinSetDlgItemText(hwnd, EXT_HELP, (CHAR *) GetPString(IDS_ARCMASKHELPTEXT));
 | 
|---|
| 387 |       break;
 | 
|---|
| 388 | 
 | 
|---|
| 389 |     case EXT_NORMAL:
 | 
|---|
| 390 |       if ((BOOL) WinSendDlgItemMsg(hwnd, EXT_NORMAL, BM_QUERYCHECK,
 | 
|---|
| 391 |                                    MPVOID, MPVOID))
 | 
|---|
| 392 |         WinSetDlgItemText(hwnd, EXT_COMMAND, arcdata->info->extract);
 | 
|---|
| 393 |       break;
 | 
|---|
| 394 | 
 | 
|---|
| 395 |     case EXT_WDIRS:
 | 
|---|
| 396 |       if (arcdata->info->exwdirs) {
 | 
|---|
| 397 |         if ((BOOL) WinSendDlgItemMsg(hwnd, EXT_WDIRS, BM_QUERYCHECK,
 | 
|---|
| 398 |                                      MPVOID, MPVOID))
 | 
|---|
| 399 |           WinSetDlgItemText(hwnd, EXT_COMMAND, arcdata->info->exwdirs);
 | 
|---|
| 400 |       }
 | 
|---|
| 401 |       break;
 | 
|---|
| 402 |     }
 | 
|---|
| 403 |     return 0;
 | 
|---|
| 404 | 
 | 
|---|
| 405 |   case WM_COMMAND:
 | 
|---|
| 406 |     arcdata = (EXTRDATA *) WinQueryWindowPtr(hwnd, QWL_USER);
 | 
|---|
| 407 |     switch (SHORT1FROMMP(mp1)) {
 | 
|---|
| 408 |     case IDM_SWITCH:
 | 
|---|
| 409 |       if (mp2) {
 | 
|---|
| 410 | 
 | 
|---|
| 411 |         CHAR tdir[CCHMAXPATH];
 | 
|---|
| 412 | 
 | 
|---|
| 413 |         strcpy(tdir, (CHAR *) mp2);
 | 
|---|
| 414 |         MakeValidDir(tdir);
 | 
|---|
| 415 |         WinSetDlgItemText(hwnd, EXT_DIRECTORY, tdir);
 | 
|---|
| 416 |       }
 | 
|---|
| 417 |       break;
 | 
|---|
| 418 | 
 | 
|---|
| 419 |     case DID_CANCEL:
 | 
|---|
| 420 |       arcdata->ret = 0;
 | 
|---|
| 421 |       WinDismissDlg(hwnd, 0);
 | 
|---|
| 422 |       break;
 | 
|---|
| 423 |     case DID_OK:
 | 
|---|
| 424 |       {
 | 
|---|
| 425 |         CHAR s[CCHMAXPATH + 1];
 | 
|---|
| 426 |         BOOL fRemember;
 | 
|---|
| 427 | 
 | 
|---|
| 428 |         fRemember = WinQueryButtonCheckstate(hwnd, EXT_REMEMBER);
 | 
|---|
| 429 |         *s = 0;
 | 
|---|
| 430 |         WinQueryDlgItemText(hwnd, EXT_DIRECTORY, CCHMAXPATH, s);
 | 
|---|
| 431 |         bstrip(s);
 | 
|---|
| 432 |         if (*s) {
 | 
|---|
| 433 |           if (!SetDir(WinQueryWindow(WinQueryWindow(hwnd, QW_PARENT),
 | 
|---|
| 434 |                                      QW_OWNER), hwnd, s, fFileNameExtPath ? 1:0)) {
 | 
|---|
| 435 |             strcpy(arcdata->extractdir, s);
 | 
|---|
| 436 |             WinSetDlgItemText(hwnd, EXT_DIRECTORY, s);
 | 
|---|
| 437 |             if ((!isalpha(*s) || s[1] != ':') && *s != '.')
 | 
|---|
| 438 |               saymsg(MB_ENTER, hwnd,
 | 
|---|
| 439 |                      GetPString(IDS_WARNINGTEXT),
 | 
|---|
| 440 |                      GetPString(IDS_SPECIFYDRIVETEXT));
 | 
|---|
| 441 |           }
 | 
|---|
| 442 |           else
 | 
|---|
| 443 |             break;
 | 
|---|
| 444 |           strcpy(lastextractpath, s);
 | 
|---|
| 445 |           if (fRemember) {
 | 
|---|
| 446 |             PrfWriteProfileString(fmprof, FM3Str, "Ext_ExtractDir", s);
 | 
|---|
| 447 |             fRemember = WinQueryButtonCheckstate(hwnd, EXT_WDIRS);
 | 
|---|
| 448 |             size = sizeof(BOOL);
 | 
|---|
| 449 |             PrfWriteProfileData(fmprof, FM3Str, "Ext_WDirs",
 | 
|---|
| 450 |                                 (PVOID) &fRemember, size);
 | 
|---|
| 451 |             fRemember = TRUE;
 | 
|---|
| 452 |           }
 | 
|---|
| 453 |           *s = 0;
 | 
|---|
| 454 |           WinQueryDlgItemText(hwnd, EXT_COMMAND, 256, s);
 | 
|---|
| 455 |           if (*s) {
 | 
|---|
| 456 |             strcpy(arcdata->command, s);
 | 
|---|
| 457 |             *s = 0;
 | 
|---|
| 458 |             WinQueryDlgItemText(hwnd, EXT_MASK, 256, s);
 | 
|---|
| 459 |             *arcdata->masks = 0;
 | 
|---|
| 460 |             strcpy(arcdata->masks, s);
 | 
|---|
| 461 |             if (fRemember)
 | 
|---|
| 462 |               PrfWriteProfileString(fmprof, FM3Str, "Ext_Mask", s);
 | 
|---|
| 463 |             arcdata->ret = 1;
 | 
|---|
| 464 |             WinDismissDlg(hwnd, 1);
 | 
|---|
| 465 |             break;
 | 
|---|
| 466 |           }
 | 
|---|
| 467 |         }
 | 
|---|
| 468 |       }
 | 
|---|
| 469 |       if (!fErrorBeepOff)
 | 
|---|
| 470 |         DosBeep(50, 100);                       // Complain a refuse to quit
 | 
|---|
| 471 |       break;
 | 
|---|
| 472 | 
 | 
|---|
| 473 |     case IDM_HELP:
 | 
|---|
| 474 |     case WM_HELP:
 | 
|---|
| 475 |       if (hwndHelp)
 | 
|---|
| 476 |         WinSendMsg(hwndHelp, HM_DISPLAY_HELP,
 | 
|---|
| 477 |                    MPFROM2SHORT(HELP_EXTRACT, 0), MPFROMSHORT(HM_RESOURCEID));
 | 
|---|
| 478 |       break;
 | 
|---|
| 479 | 
 | 
|---|
| 480 |     case EXT_WALK:
 | 
|---|
| 481 |       {
 | 
|---|
| 482 |         CHAR temp[CCHMAXPATH + 1];
 | 
|---|
| 483 | 
 | 
|---|
| 484 |         strcpy(temp, arcdata->extractdir);
 | 
|---|
| 485 |         if (WinDlgBox(HWND_DESKTOP, WinQueryWindow(WinQueryWindow(hwnd,
 | 
|---|
| 486 |                                                                   QW_PARENT),
 | 
|---|
| 487 |                                                    QW_OWNER),
 | 
|---|
| 488 |                       WalkExtractDlgProc, FM3ModHandle, WALK_FRAME,
 | 
|---|
| 489 |                       (PVOID) temp)) {
 | 
|---|
| 490 |           if (*temp && stricmp(temp, arcdata->extractdir)) {
 | 
|---|
| 491 |             strcpy(arcdata->extractdir, temp);
 | 
|---|
| 492 |           }
 | 
|---|
| 493 |         }
 | 
|---|
| 494 |         WinSetDlgItemText(hwnd, EXT_DIRECTORY, arcdata->extractdir);
 | 
|---|
| 495 |       }
 | 
|---|
| 496 |       break;
 | 
|---|
| 497 | 
 | 
|---|
| 498 |     case EXT_SEE:
 | 
|---|
| 499 |       {
 | 
|---|
| 500 |         CHAR s[1001], *p;
 | 
|---|
| 501 |         EXECARGS ex;
 | 
|---|
| 502 | 
 | 
|---|
| 503 |         WinQueryDlgItemText(hwnd, EXT_COMMAND, 256, s);
 | 
|---|
| 504 |         lstrip(s);
 | 
|---|
| 505 |         if (!*s)
 | 
|---|
| 506 |           Runtime_Error(pszSrcFile, __LINE__, "no command");
 | 
|---|
| 507 |         else {
 | 
|---|
| 508 |           p = strchr(s, ' ');
 | 
|---|
| 509 |           if (p)
 | 
|---|
| 510 |             *p = 0;                     // Drop options
 | 
|---|
| 511 |           memset(&ex, 0, sizeof(EXECARGS));
 | 
|---|
| 512 |           ex.commandline = s;
 | 
|---|
| 513 |           ex.flags = WINDOWED | SEPARATEKEEP | MAXIMIZED;
 | 
|---|
| 514 |           *ex.path = 0;
 | 
|---|
| 515 |           *ex.environment = 0;
 | 
|---|
| 516 |           *ex.title = 0;
 | 
|---|
| 517 |           if (WinDlgBox(HWND_DESKTOP,
 | 
|---|
| 518 |                         hwnd,
 | 
|---|
| 519 |                         CmdLineDlgProc,
 | 
|---|
| 520 |                         FM3ModHandle, EXEC_FRAME, MPFROMP(&ex)) && *s) {
 | 
|---|
| 521 |             runemf2(ex.flags,
 | 
|---|
| 522 |                     hwnd, pszSrcFile, __LINE__,
 | 
|---|
| 523 |                     NULL, (*ex.environment) ? ex.environment : NULL, "%s", s);
 | 
|---|
| 524 |           }
 | 
|---|
| 525 |         }
 | 
|---|
| 526 |       }
 | 
|---|
| 527 |       break;
 | 
|---|
| 528 |     }
 | 
|---|
| 529 |     return 0;
 | 
|---|
| 530 | 
 | 
|---|
| 531 |   case WM_CLOSE:
 | 
|---|
| 532 |     break;
 | 
|---|
| 533 |   }
 | 
|---|
| 534 |   return WinDefDlgProc(hwnd, msg, mp1, mp2);
 | 
|---|
| 535 | }
 | 
|---|
| 536 | 
 | 
|---|
| 537 | #pragma alloc_text(FMEXTRACT,ExtractTextProc,ExtractDlgProc)
 | 
|---|