source: trunk/dll/archive.c@ 1498

Last change on this file since 1498 was 1498, checked in by Gregg Young, 16 years ago

Changes to get FM2 to compile with the latest watcom 1.9 beta (mostly type casts of CHAR CONSTANT * to CHAR *). Changes to get the environment settings working everywhere again (broken by the change that moved commands to the INI); Added an environment size variable (set to 2048 which was the largest I found hard coded). Still need to find everywhere the environment size is set and use this variable.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 7.9 KB
Line 
1
2/***********************************************************************
3
4 $Id: archive.c 1498 2010-01-18 00:57:01Z gyoung $
5
6 Archive create/update dialog procedure
7
8 Copyright (c) 1993-98 M. Kimes
9 Copyright (c) 2004, 2010 Steven H.Levine
10
11 01 Aug 04 SHL Rework lstrip/rstrip usage
12 28 Jun 06 SHL Drop obsoletes
13 17 Jul 06 SHL Use Runtime_Error
14 22 Mar 07 GKY Use QWL_USER
15 20 Aug 07 GKY Move #pragma alloc_text to end for OpenWatcom compat
16 07 Feb 09 GKY Allow user to turn off alert and/or error beeps in settings notebook.
17 17 JAN 10 GKY Changes to get working with Watcom 1.9 Beta (1/16/10). Mostly cast CHAR CONSTANT * as CHAR *.
18
19***********************************************************************/
20
21#include <string.h>
22
23#define INCL_WIN
24#define INCL_DOS
25#define INCL_LONGLONG // dircnrs.h
26
27#include "fm3dll.h"
28#include "fm3dll2.h" // #define's for UM_*, control id's, etc.
29#include "notebook.h" // Data declaration(s)
30#include "fm3dlg.h"
31#include "fm3str.h"
32#include "strutil.h" // GetPString
33#include "errutil.h" // Runtime_Error
34#include "archive.h"
35#include "systemf.h" // ExecOnList
36#include "chklist.h" // PosOverOkay
37#include "getnames.h" // export_filename
38#include "misc.h" // PaintRecessedWindow
39#include "strips.h" // bstrip
40
41static PSZ pszSrcFile = __FILE__;
42
43MRESULT EXPENTRY ArchiveDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
44{
45 DIRCNRDATA *arcdata = NULL;
46
47 switch (msg) {
48 case WM_INITDLG:
49 WinSetWindowPtr(hwnd, QWL_USER, mp2);
50 arcdata = (DIRCNRDATA *) mp2;
51 WinSendDlgItemMsg(hwnd, ARCH_ARCNAME, EM_SETTEXTLIMIT,
52 MPFROM2SHORT(CCHMAXPATH, 0), MPVOID);
53 if (!arcdata->namecanchange) {
54 WinSendDlgItemMsg(hwnd, ARCH_ARCNAME, EM_SETREADONLY,
55 MPFROM2SHORT(TRUE, 0), MPVOID);
56 WinEnableWindow(WinWindowFromID(hwnd, ARCH_FIND), FALSE);
57 WinShowWindow(WinWindowFromID(hwnd, ARCH_FIND), FALSE);
58 }
59 WinSendDlgItemMsg(hwnd, ARCH_COMMAND, EM_SETTEXTLIMIT,
60 MPFROM2SHORT(256, 0), MPVOID);
61 WinSendDlgItemMsg(hwnd, ARCH_MASKS, EM_SETTEXTLIMIT,
62 MPFROM2SHORT(256, 0), MPVOID);
63 WinSetDlgItemText(hwnd, ARCH_ARCNAME, arcdata->arcname);
64 if (arcdata->fmoving && arcdata->info->move) {
65 WinSetDlgItemText(hwnd, ARCH_COMMAND, arcdata->info->move);
66 WinSendDlgItemMsg(hwnd, ARCH_MOVE, BM_SETCHECK,
67 MPFROM2SHORT(TRUE, 0), MPVOID);
68 }
69 else
70 WinSetDlgItemText(hwnd, ARCH_COMMAND, arcdata->info->create);
71 if (!arcdata->info->createrecurse)
72 WinEnableWindow(WinWindowFromID(hwnd, ARCH_RECURSE), FALSE);
73 if (!arcdata->info->move && !arcdata->info->movewdirs)
74 WinEnableWindow(WinWindowFromID(hwnd, ARCH_MOVE), FALSE);
75 if (!arcdata->info->createwdirs && !arcdata->info->movewdirs)
76 WinEnableWindow(WinWindowFromID(hwnd, ARCH_INCLPATH), FALSE);
77 *arcdata->command = 0;
78 PosOverOkay(hwnd);
79 break;
80
81 case WM_ADJUSTWINDOWPOS:
82 PostMsg(hwnd, UM_SETDIR, MPVOID, MPVOID);
83 break;
84
85 case UM_SETDIR:
86 PaintRecessedWindow(WinWindowFromID(hwnd, ARCH_HELP), (HPS) 0, FALSE,
87 TRUE);
88 return 0;
89
90 case WM_CONTROL:
91 arcdata = (DIRCNRDATA *) WinQueryWindowPtr(hwnd, QWL_USER);
92 switch (SHORT1FROMMP(mp1)) {
93 case ARCH_ARCNAME:
94 if (SHORT2FROMMP(mp1) == EN_KILLFOCUS)
95 WinSetDlgItemText(hwnd, ARCH_HELP,
96 (CHAR *) GetPString(IDS_ARCDEFAULTHELPTEXT));
97 if (SHORT2FROMMP(mp1) == EN_SETFOCUS)
98 WinSetDlgItemText(hwnd, ARCH_HELP,
99 (CHAR *) GetPString(IDS_ARCARCNAMEHELPTEXT));
100 break;
101
102 case ARCH_COMMAND:
103 if (SHORT2FROMMP(mp1) == EN_KILLFOCUS)
104 WinSetDlgItemText(hwnd, ARCH_HELP,
105 (CHAR *) GetPString(IDS_ARCDEFAULTHELPTEXT));
106 if (SHORT2FROMMP(mp1) == EN_SETFOCUS)
107 WinSetDlgItemText(hwnd, ARCH_HELP, (CHAR *) GetPString(IDS_ARCCMDHELPTEXT));
108 break;
109
110 case ARCH_MASKS:
111 if (SHORT2FROMMP(mp1) == EN_KILLFOCUS)
112 WinSetDlgItemText(hwnd, ARCH_HELP,
113 (CHAR *) GetPString(IDS_ARCDEFAULTHELPTEXT));
114 if (SHORT2FROMMP(mp1) == EN_SETFOCUS)
115 WinSetDlgItemText(hwnd, ARCH_HELP, (CHAR *) GetPString(IDS_ARCMASKHELPTEXT));
116
117 break;
118
119 case ARCH_INCLPATH:
120 case ARCH_RECURSE:
121 case ARCH_MOVE:
122 {
123 BOOL fRecurse = FALSE, fMove = FALSE, fInclDirs = FALSE;
124 CHAR *cmd;
125
126 if ((BOOL) WinSendDlgItemMsg(hwnd, ARCH_RECURSE, BM_QUERYCHECK,
127 MPVOID, MPVOID)) {
128 fRecurse = TRUE;
129 if (SHORT1FROMMP(mp1) == ARCH_RECURSE) {
130 if (arcdata->info->createrecurse && *arcdata->info->createrecurse) {
131 fMove = FALSE;
132 fInclDirs = FALSE;
133 WinSendDlgItemMsg(hwnd, ARCH_INCLPATH, BM_SETCHECK,
134 MPVOID, MPVOID);
135 WinSendDlgItemMsg(hwnd, ARCH_MOVE, BM_SETCHECK, MPVOID, MPVOID);
136 }
137 else {
138 fRecurse = FALSE;
139 WinSendDlgItemMsg(hwnd, ARCH_RECURSE, BM_SETCHECK,
140 MPVOID, MPVOID);
141 }
142 }
143 }
144 else
145 fRecurse = FALSE;
146 if ((BOOL) WinSendDlgItemMsg(hwnd, ARCH_MOVE, BM_QUERYCHECK,
147 MPVOID, MPVOID)) {
148 fMove = TRUE;
149 fRecurse = FALSE;
150 WinSendDlgItemMsg(hwnd, ARCH_RECURSE, BM_SETCHECK, MPVOID, MPVOID);
151 }
152 else
153 fMove = FALSE;
154 if ((BOOL) WinSendDlgItemMsg(hwnd, ARCH_INCLPATH, BM_QUERYCHECK,
155 MPVOID, MPVOID)) {
156 fInclDirs = TRUE;
157 fRecurse = FALSE;
158 WinSendDlgItemMsg(hwnd, ARCH_RECURSE, BM_SETCHECK, MPVOID, MPVOID);
159 }
160 else
161 fInclDirs = FALSE;
162 cmd = NULL;
163 if (fMove) {
164 if (fInclDirs || fRecurse)
165 cmd = arcdata->info->movewdirs;
166 else
167 cmd = arcdata->info->move;
168 if (!cmd || !*cmd)
169 cmd = arcdata->info->move;
170 }
171 if (!cmd || !*cmd) {
172 if (fInclDirs) {
173 cmd = arcdata->info->createwdirs;
174 if (!cmd || !*cmd)
175 cmd = arcdata->info->createrecurse;
176 }
177 else if (fRecurse) {
178 cmd = arcdata->info->createrecurse;
179 if (!cmd || !*cmd)
180 cmd = arcdata->info->createwdirs;
181 }
182 if (!cmd || !*cmd)
183 cmd = arcdata->info->create;
184 }
185 if (cmd)
186 WinSetDlgItemText(hwnd, ARCH_COMMAND, cmd);
187 }
188 break;
189 }
190 return 0;
191
192 case WM_COMMAND:
193 arcdata = (DIRCNRDATA *) WinQueryWindowPtr(hwnd, QWL_USER);
194 if (!arcdata) {
195 Runtime_Error(pszSrcFile, __LINE__, NULL);
196 return 0;
197 }
198 switch (SHORT1FROMMP(mp1)) {
199 case DID_CANCEL:
200 WinDismissDlg(hwnd, 0);
201 break;
202 case DID_OK:
203 {
204 CHAR s[CCHMAXPATH + 1];
205
206 *s = 0;
207 WinQueryDlgItemText(hwnd, ARCH_ARCNAME, CCHMAXPATH, s);
208 bstrip(s);
209 if (*s) {
210 if (DosQueryPathInfo(s,
211 FIL_QUERYFULLNAME,
212 arcdata->arcname, CCHMAXPATH))
213 strcpy(arcdata->arcname, s);
214 *s = 0;
215 WinQueryDlgItemText(hwnd, ARCH_COMMAND, 256, s);
216 if (*s) {
217 strcpy(arcdata->command, s);
218 *s = 0;
219 WinQueryDlgItemText(hwnd, ARCH_MASKS, 256, s);
220 *arcdata->mask.szMask = 0;
221 strcpy(arcdata->mask.szMask, s);
222 WinDismissDlg(hwnd, 1);
223 break;
224 }
225 }
226 }
227 if (!fAlertBeepOff)
228 DosBeep(50, 100);
229 break;
230
231 case IDM_HELP:
232 if (hwndHelp)
233 WinSendMsg(hwndHelp,
234 HM_DISPLAY_HELP,
235 MPFROM2SHORT(HELP_ARCHIVE, 0), MPFROMSHORT(HM_RESOURCEID));
236 break;
237
238 case ARCH_FIND:
239 if (arcdata->namecanchange) {
240
241 CHAR arcname[CCHMAXPATH], s[CCHMAXPATH], *p;
242
243 *s = 0;
244 WinQueryDlgItemText(hwnd, ARCH_ARCNAME, CCHMAXPATH, s);
245 bstrip(s);
246 if (DosQueryPathInfo(s, FIL_QUERYFULLNAME, arcname, CCHMAXPATH))
247 strcpy(arcname, s);
248 p = strrchr(arcname, '\\');
249 if (p) {
250 p++;
251 p = strrchr(arcname, '.');
252 }
253 if (!p && arcdata->info->ext && *arcdata->info->ext) {
254 strcat(arcname, "*.");
255 strcat(arcname, arcdata->info->ext);
256 }
257 if (export_filename(hwnd, arcname, FALSE))
258 WinSetDlgItemText(hwnd, ARCH_ARCNAME, arcname);
259 }
260 break;
261
262 case ARCH_SEE:
263 {
264 CHAR s[1001], *p;
265
266 *s = 0;
267 WinQueryDlgItemText(hwnd, ARCH_COMMAND, 256, s);
268 bstrip(s);
269 if (*s) {
270 p = strchr(s, ' ');
271 if (p)
272 *p = 0;
273 ExecOnList(hwnd, s, WINDOWED | SEPARATEKEEP | MAXIMIZED | PROMPT,
274 NULL, NULL, NULL, GetPString(IDS_ARCEXECHELPTEXT),
275 pszSrcFile, __LINE__);
276 }
277 else if (!fErrorBeepOff)
278 DosBeep(50, 100);
279 }
280 break;
281 }
282 return 0;
283
284 case WM_CLOSE:
285 break;
286 }
287 return WinDefDlgProc(hwnd, msg, mp1, mp2);
288}
289
290#pragma alloc_text(FMARCHIVE,ArchiveDlgProc)
Note: See TracBrowser for help on using the repository browser.