source: branches/ticket_150/dll/archive.c@ 869

Last change on this file since 869 was 793, checked in by Gregg Young, 18 years ago

Move #pragma alloc_text to end for OpenWatcom compat

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