source: trunk/dll/remap.c@ 1505

Last change on this file since 1505 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: 17.8 KB
Line 
1
2/***********************************************************************
3
4 $Id: remap.c 1498 2010-01-18 00:57:01Z gyoung $
5
6 Copyright (c) 1993, 1998 M. Kimes
7 Copyright (c) 2004, 2010 Steven H.Levine
8
9 01 Aug 04 SHL Rework lstrip/rstrip usage
10 06 Aug 05 SHL Renames
11 22 Jul 06 SHL Check more run time errors
12 29 Jul 06 SHL Use xfgets
13 31 Aug 06 SHL Use _fsopen to avoid noise complaints
14 20 Aug 07 GKY Move #pragma alloc_text to end for OpenWatcom compat
15 29 Feb 08 GKY Use xfree where appropriate
16 19 Jul 08 GKY Replace save_dir2(dir) with pFM2SaveDirectory and use BldFullPathName
17 24 Aug 08 GKY Warn full drive on save of .DAT file; prevent loss of existing file
18 17 JAN 10 GKY Changes to get working with Watcom 1.9 Beta (1/16/10). Mostly cast CHAR CONSTANT * as CHAR *.
19
20***********************************************************************/
21
22#include <stdlib.h>
23#include <string.h>
24#include <share.h>
25#include <io.h> // unlink
26
27#define INCL_DOS
28#define INCL_WIN
29#define INCL_LONGLONG // dircnrs.h
30
31#include "fm3dll.h"
32#include "fm3dll2.h" // #define's for UM_*, control id's, etc.
33#include "remap.h"
34#include "arccnrs.h" // Data declaration(s)
35#include "mainwnd.h" // Data declaration(s)
36#include "notebook.h" // Data declaration(s)
37#include "info.h" // Data declaration(s)
38#include "init.h" // Data declaration(s)
39#include "newview.h" // Data declarations
40#include "fm3dlg.h"
41#include "fm3str.h"
42#include "errutil.h" // Dos_Error...
43#include "strutil.h" // GetPString
44#include "pathutil.h" // BldFullPathName
45#include "valid.h" // CheckDrive, FillInDriveFlags
46#include "wrappers.h" // xfgets
47#include "strips.h" // bstrip
48#include "misc.h" // CheckDriveSpaceAvail
49#include "systemf.h" // runemf2
50#include "dirs.h" // save_dir2
51#include "fortify.h"
52
53#pragma data_seg(DATA1)
54
55static PSZ pszSrcFile = __FILE__;
56
57typedef struct APPNOTIFY
58{
59 HAPP happ;
60 BOOL attach;
61 BOOL failedonce;
62 CHAR uncname[CCHMAXPATH];
63 CHAR device;
64 struct APPNOTIFY *next;
65 struct APPNOTIFY *prev;
66}
67APPNOTIFY;
68
69typedef struct LINKRES
70{
71 CHAR *res;
72 struct LINKRES *next;
73}
74LINKRES;
75
76static LINKRES *reshead = NULL;
77static BOOL loadedres = FALSE;
78
79#define MAXNUMRES 200
80
81VOID load_resources(VOID)
82{
83 /* load linked list of resources from RESOURCE.DAT file */
84
85 FILE *fp;
86 LINKRES *info, *last = NULL;
87 CHAR s[CCHMAXPATH + 14];
88 INT x = 0;
89
90 loadedres = TRUE;
91 BldFullPathName(s, pFM2SaveDirectory, PCSZ_RESOURCEDAT);
92 fp = _fsopen(s, "r", SH_DENYWR);
93 if (fp) {
94 while (x < MAXNUMRES && !feof(fp)) {
95 if (!xfgets_bstripcr(s, sizeof(s), fp, pszSrcFile, __LINE__))
96 break;
97 if (*s && *s != ';') {
98 info = xmalloc(sizeof(LINKRES), pszSrcFile, __LINE__);
99 if (info) {
100 info->res = xstrdup(s, pszSrcFile, __LINE__);
101 if (!info->res)
102 free(info);
103 else {
104 x++;
105 info->next = NULL;
106 if (!reshead)
107 reshead = info;
108 else
109 last->next = info;
110 last = info;
111 }
112 }
113 }
114 }
115 fclose(fp);
116 }
117}
118
119VOID save_resources(VOID)
120{
121 /* save linked list of resources to RESOURCE.DAT file */
122
123 LINKRES *info;
124 FILE *fp;
125 CHAR s[CCHMAXPATH + 14];
126
127 if (!loadedres)
128 return;
129 BldFullPathName(s, pFM2SaveDirectory, PCSZ_RESOURCEDAT);
130 if (CheckDriveSpaceAvail(s, ullDATFileSpaceNeeded, 1) == 2)
131 return; //already gave error msg
132 if (reshead) {
133 fp = xfopen(s, "w", pszSrcFile, __LINE__);
134 if (fp) {
135 fputs(GetPString(IDS_REMOTEFILETEXT), fp);
136 info = reshead;
137 while (info) {
138 fprintf(fp, "%0.*s\n", CCHMAXPATH, info->res);
139 info = info->next;
140 }
141 fclose(fp);
142 }
143 }
144 else
145 unlink(s);
146}
147
148BOOL add_resource(CHAR * res)
149{
150 LINKRES *info, *last = NULL;
151 INT x = 0;
152
153 if (!res || !*res)
154 return FALSE;
155 if (!loadedres)
156 load_resources();
157 info = reshead;
158 while (info) {
159 if (!stricmp(info->res, res))
160 return FALSE;
161 last = info;
162 info = info->next;
163 x++;
164 }
165 info = xmalloc(sizeof(LINKRES), pszSrcFile, __LINE__);
166 if (info) {
167 info->res = xstrdup(res, pszSrcFile, __LINE__);
168 if (!info->res)
169 free(info);
170 else {
171 info->next = NULL;
172 if (!reshead)
173 reshead = info;
174 else
175 last->next = info;
176 if (x > MAXNUMRES) {
177 info = reshead;
178 reshead = reshead->next;
179 free(info);
180 }
181 return TRUE;
182 }
183 }
184 return FALSE;
185}
186
187BOOL remove_resource(CHAR * res)
188{
189 LINKRES *info, *last = NULL;
190
191 if (!res || !*res)
192 return FALSE;
193 if (!loadedres)
194 load_resources();
195 info = reshead;
196 while (info) {
197 if (!stricmp(info->res, res)) {
198 if (last)
199 last->next = info->next;
200 else
201 reshead = info->next;
202 xfree(info->res, pszSrcFile, __LINE__);
203 free(info);
204 return TRUE;
205 }
206 last = info;
207 info = info->next;
208 }
209 return FALSE;
210}
211
212VOID free_resources(VOID)
213{
214 LINKRES *info, *next;
215
216 info = reshead;
217 while (info) {
218 next = info->next;
219 xfree(info->res, pszSrcFile, __LINE__);
220 free(info);
221 info = next;
222 }
223 reshead = NULL;
224 DosPostEventSem(CompactSem);
225}
226
227MRESULT EXPENTRY RemapDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
228{
229 static BOOL fRemapped;
230 static APPNOTIFY *apphead = NULL, *apptail = NULL;
231
232 switch (msg) {
233 case WM_INITDLG:
234 WinSendDlgItemMsg(hwnd,
235 MAP_ATTACHTO,
236 EM_SETTEXTLIMIT, MPFROM2SHORT(CCHMAXPATH, 0), MPVOID);
237 fRemapped = FALSE;
238 if (!loadedres)
239 load_resources();
240 {
241 LINKRES *info;
242
243 info = reshead;
244 while (info) {
245 WinSendDlgItemMsg(hwnd,
246 MAP_ATTACHTO,
247 LM_INSERTITEM,
248 MPFROM2SHORT(LIT_END, 0), MPFROMP(info->res));
249 info = info->next;
250 }
251 }
252 {
253 ULONG ulDriveMap, ulDriveNum, x, ulType;
254 CHAR s[3] = " :";
255
256 DosError(FERR_DISABLEHARDERR);
257 if (!DosQCurDisk(&ulDriveNum, &ulDriveMap)) {
258 for (x = 0; x < 26; x++) {
259 if (!(driveflags[x] & DRIVE_IGNORE)) {
260 *s = (CHAR) x + 'A';
261 if (!(ulDriveMap & (1 << x)))
262 WinSendDlgItemMsg(hwnd,
263 MAP_ATTACHLIST,
264 LM_INSERTITEM,
265 MPFROM2SHORT(LIT_END, 0), MPFROMP(s));
266 else {
267 CheckDrive((CHAR) x + 'A', NULL, &ulType);
268 if (ulType & DRIVE_REMOTE)
269 WinSendDlgItemMsg(hwnd,
270 MAP_DETACHLIST,
271 LM_INSERTITEM,
272 MPFROM2SHORT(LIT_END, 0), MPFROMP(s));
273 }
274 }
275 }
276 }
277 else
278 WinDismissDlg(hwnd, 0);
279 }
280 break;
281
282 case WM_CONTROL:
283 switch (SHORT1FROMMP(mp1)) {
284 case MAP_ATTACHLIST:
285 switch (SHORT2FROMMP(mp1)) {
286 case LN_ENTER:
287 PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(MAP_ATTACH, 0), MPVOID);
288 break;
289 }
290 break;
291 case MAP_DETACHLIST:
292 switch (SHORT2FROMMP(mp1)) {
293 case LN_ENTER:
294 PostMsg(hwnd, WM_COMMAND, MPFROM2SHORT(MAP_DETACH, 0), MPVOID);
295 break;
296 case LN_SELECT:
297 {
298 SHORT x;
299 CHAR d[3];
300
301 WinSetDlgItemText(hwnd, MAP_ATTACHTO, NullStr);
302 x = (SHORT) WinSendDlgItemMsg(hwnd,
303 MAP_DETACHLIST,
304 LM_QUERYSELECTION,
305 MPFROMSHORT(LIT_FIRST), MPVOID);
306 if (x >= 0) {
307 *d = 0;
308 WinSendDlgItemMsg(hwnd,
309 MAP_DETACHLIST,
310 LM_QUERYITEMTEXT,
311 MPFROM2SHORT(x, sizeof(d)), MPFROMP(d));
312 if (*d) {
313
314 CHAR buf[2048];
315 ULONG len;
316 APIRET rc;
317 FSQBUFFER2 *p2;
318
319 memset(buf, 0, sizeof(buf));
320 len = sizeof(buf);
321 p2 = (FSQBUFFER2 *) buf;
322 DosError(FERR_DISABLEHARDERR);
323 rc = DosQueryFSAttach(d, 0, FSAIL_QUERYNAME, p2, &len);
324 if (!rc) {
325
326 CHAR *p;
327
328 p = (char *)p2->szName;
329 p += p2->cbName + 1;
330 p += p2->cbFSDName + 1;
331 if (p2->cbFSAData)
332 WinSetDlgItemText(hwnd, MAP_ATTACHTO, p);
333 else
334 WinSetDlgItemText(hwnd,
335 MAP_ATTACHTO,
336 (CHAR *) GetPString(IDS_UNKNOWNBRKTTEXT));
337 }
338 else
339 WinSetDlgItemText(hwnd,
340 MAP_ATTACHTO,
341 (CHAR *) GetPString(IDS_UNKNOWNBRKTTEXT));
342 }
343 }
344 }
345 break;
346 }
347 break;
348 }
349 break;
350
351 case WM_APPTERMINATENOTIFY:
352 {
353 APPNOTIFY *info;
354 SHORT x, c;
355 CHAR d[3];
356 HWND hwndList;
357
358 if (!mp2)
359 fRemapped = TRUE;
360 info = apphead;
361 GetRidOfIt:
362 while (info) {
363 if (info->happ == (HAPP) mp1) {
364/* Note: if this next line is removed, FM/2 will start the attach/detach
365 * request again, once for each request, to see if it might succeed and to
366 * ensure the request is seen by the user in case interaction is required.
367 */
368 info->failedonce = TRUE;
369 hwndList = WinWindowFromID(hwnd,
370 (info->attach) ?
371 MAP_ATTACHLIST : MAP_DETACHLIST);
372 if (!mp2 || (ULONG) mp2 == 1041 || info->failedonce) {
373 if (info->prev)
374 info->prev->next = info->next;
375 if (info->next)
376 info->next->prev = info->prev;
377 if (apphead == info)
378 apphead = info->next;
379 if (apptail == info)
380 apptail = info->prev;
381 }
382 if (!mp2) {
383 if (*info->uncname &&
384 stricmp(info->uncname, GetPString(IDS_UNKNOWNBRKTTEXT)) &&
385 add_resource(info->uncname)) {
386 save_resources();
387 WinSendDlgItemMsg(hwnd,
388 MAP_ATTACHTO,
389 LM_INSERTITEM,
390 MPFROM2SHORT(LIT_END, 0),
391 MPFROMP(info->uncname));
392 }
393 c = (SHORT) WinSendMsg(hwndList,
394 LM_QUERYITEMCOUNT, MPVOID, MPVOID);
395 if (c > 0) {
396 for (x = 0; x < c; x++) {
397 *d = 0;
398 WinSendMsg(hwndList,
399 LM_QUERYITEMTEXT,
400 MPFROM2SHORT(x, sizeof(d)), MPFROMP(d));
401 if (*d == info->device) {
402 WinSendMsg(hwndList, LM_DELETEITEM, MPFROMSHORT(x), MPVOID);
403 hwndList = WinWindowFromID(hwnd,
404 (info->attach) ?
405 MAP_DETACHLIST : MAP_ATTACHLIST);
406 d[1] = ':';
407 d[2] = 0;
408 WinSendMsg(hwndList,
409 LM_INSERTITEM,
410 MPFROM2SHORT(LIT_SORTASCENDING, 0), MPFROMP(d));
411 break;
412 }
413 }
414 }
415 }
416 else if ((ULONG) mp2 != 1041 && !info->failedonce) {
417
418 PROGDETAILS pgd;
419 CHAR params[368], *p;
420 HAPP happ;
421
422 *d = info->device;
423 d[1] = ':';
424 d[2] = 0;
425 p = GetCmdSpec(FALSE);
426 memset(&pgd, 0, sizeof(pgd));
427 pgd.Length = sizeof(pgd);
428 pgd.progt.progc = PROG_WINDOWABLEVIO;
429 pgd.progt.fbVisible = SHE_VISIBLE;
430 pgd.pszTitle = info->attach ? (PSZ)GetPString(IDS_ATTACHREQTEXT) :
431 (PSZ)GetPString(IDS_DETACHREQTEXT);
432 pgd.pszExecutable = p;
433 pgd.pszParameters = params;
434 pgd.pszStartupDir = NULL;
435 pgd.pszIcon = NULL;
436 pgd.pszEnvironment = NULL;
437 pgd.swpInitial.hwndInsertBehind = HWND_TOP;
438 pgd.swpInitial.hwnd = hwnd;
439 pgd.swpInitial.fl = SWP_SHOW | SWP_ACTIVATE;
440 if (info->attach)
441 sprintf(params, "/C NET USE %s \"%s\"", d, info->uncname);
442 else
443 sprintf(params, "/C NET USE %s /D", d);
444 info->failedonce = TRUE;
445 happ = WinStartApp(hwnd, &pgd, pgd.pszParameters,
446 NULL, SAF_MAXIMIZED);
447 if (!happ)
448 goto GetRidOfIt;
449 info->happ = happ;
450 break;
451 }
452 else if ((ULONG) mp2 == 1041)
453 saymsg(MB_CANCEL | MB_ICONEXCLAMATION, hwnd,
454 GetPString(IDS_ERRORTEXT),
455 GetPString(IDS_CANTSTARTNETUSETEXT));
456 if (!mp2 || (ULONG) mp2 == 1041 || info->failedonce)
457 free(info);
458 break;
459 }
460 info = info->next;
461 }
462 }
463 break;
464
465 case WM_COMMAND:
466 switch (SHORT1FROMMP(mp1)) {
467 case MAP_DELETE:
468 {
469 SHORT x;
470 CHAR resource[CCHMAXPATH];
471
472 x = (SHORT) WinSendDlgItemMsg(hwnd,
473 MAP_ATTACHTO,
474 LM_QUERYSELECTION,
475 MPFROMSHORT(LIT_FIRST), MPVOID);
476 if (x >= 0) {
477 *resource = 0;
478 WinSendDlgItemMsg(hwnd,
479 MAP_ATTACHTO,
480 LM_QUERYITEMTEXT,
481 MPFROM2SHORT(x, sizeof(resource)),
482 MPFROMP(resource));
483 bstrip(resource);
484 if (*resource) {
485 if (remove_resource(resource)) {
486 save_resources();
487 WinSendDlgItemMsg(hwnd,
488 MAP_ATTACHTO,
489 LM_DELETEITEM, MPFROMSHORT(x), MPVOID);
490 if (x)
491 x--;
492 WinSendDlgItemMsg(hwnd,
493 MAP_ATTACHTO,
494 LM_SELECTITEM,
495 MPFROMSHORT(x), MPFROMSHORT(TRUE));
496 if (!(SHORT) WinSendDlgItemMsg(hwnd,
497 MAP_ATTACHTO,
498 LM_QUERYITEMCOUNT,
499 MPVOID, MPVOID))
500 WinSetDlgItemText(hwnd, MAP_ATTACHTO, NullStr);
501 }
502 }
503 }
504 }
505 break;
506
507 case MAP_CLEAR:
508 free_resources();
509 save_resources();
510 WinSendDlgItemMsg(hwnd, MAP_ATTACHTO, LM_DELETEALL, MPVOID, MPVOID);
511 WinSetDlgItemText(hwnd, MAP_ATTACHTO, NullStr);
512 break;
513
514 case MAP_INFO:
515 case MAP_DETACH:
516 {
517 CHAR d[3], s[CCHMAXPATH];
518 SHORT x;
519
520 *s = 0;
521 WinQueryDlgItemText(hwnd, MAP_ATTACHTO, sizeof(s), s);
522 bstrip(s);
523 x = (SHORT) WinSendDlgItemMsg(hwnd,
524 MAP_DETACHLIST,
525 LM_QUERYSELECTION,
526 MPFROMSHORT(LIT_FIRST), MPVOID);
527 if (x >= 0) {
528 *d = 0;
529 WinSendDlgItemMsg(hwnd,
530 MAP_DETACHLIST,
531 LM_QUERYITEMTEXT,
532 MPFROM2SHORT(x, sizeof(d)), MPFROMP(d));
533 if (*d) {
534 switch (SHORT1FROMMP(mp1)) {
535 case MAP_DETACH:
536 {
537 PROGDETAILS pgd;
538 CHAR params[368], *p;
539 HAPP happ;
540
541 p = GetCmdSpec(FALSE);
542 memset(&pgd, 0, sizeof(pgd));
543 pgd.Length = sizeof(pgd);
544 pgd.progt.progc = PROG_WINDOWABLEVIO;
545 pgd.progt.fbVisible = SHE_VISIBLE;
546 pgd.pszTitle = (PSZ)GetPString(IDS_DETACHREQTEXT);
547 pgd.pszExecutable = p;
548 pgd.pszParameters = params;
549 pgd.pszStartupDir = NULL;
550 pgd.pszIcon = NULL;
551 pgd.pszEnvironment = NULL;
552 pgd.swpInitial.hwndInsertBehind = HWND_TOP;
553 pgd.swpInitial.hwnd = hwnd;
554 pgd.swpInitial.fl = SWP_SHOW | SWP_ACTIVATE;
555 sprintf(params, "/C NET USE %s /D", d);
556 happ = WinStartApp(hwnd,
557 &pgd,
558 pgd.pszParameters, NULL, SAF_MAXIMIZED);
559 if (happ) {
560
561 APPNOTIFY *info;
562
563 WinSetDlgItemText(hwnd, MAP_ATTACHTO, NullStr);
564 info = xmallocz(sizeof(APPNOTIFY), pszSrcFile, __LINE__);
565 if (info) {
566 info->happ = happ;
567 info->attach = FALSE;
568 info->failedonce = FALSE;
569 strcpy(info->uncname, s);
570 info->device = *d;
571 if (!apphead)
572 apphead = info;
573 else {
574 apptail->next = info;
575 info->prev = apptail;
576 }
577 apptail = info;
578 }
579 }
580 else
581 saymsg(MB_CANCEL | MB_ICONEXCLAMATION,
582 hwnd,
583 GetPString(IDS_ERRORTEXT),
584 GetPString(IDS_CANTSTARTTEXT), p, params);
585 }
586#ifdef NEVER // fixme to be gone?
587 DosError(FERR_DISABLEHARDERR);
588 rc = DosFSAttach(d, s, d, strlen(d) + 1, FS_DETACH);
589 if (rc) {
590 Dos_Error(MB_CANCEL,
591 rc,
592 hwnd,
593 pszSrcFile,
594 __LINE__, GetPString(IDS_DETACHFAILEDTEXT), d, s);
595 }
596 else {
597 fRemapped = TRUE;
598 WinSendDlgItemMsg(hwnd,
599 MAP_DETACHLIST,
600 LM_DELETEITEM, MPFROMSHORT(x), MPVOID);
601 WinSendDlgItemMsg(hwnd,
602 MAP_ATTACHLIST,
603 LM_INSERTITEM,
604 MPFROM2SHORT(LIT_SORTASCENDING, 0),
605 MPFROMP(d));
606 }
607#endif // fixme to be gone?
608 break;
609
610 case MAP_INFO:
611 runemf2(SEPARATEKEEP | WINDOWED | MAXIMIZED,
612 hwnd, pszSrcFile, __LINE__,
613 NULL, NULL, "%s /C NET USE %s", GetCmdSpec(FALSE), d);
614 break;
615 }
616 }
617 }
618 }
619 break;
620
621 case MAP_ATTACH:
622 {
623 CHAR d[3], s[CCHMAXPATH];
624 SHORT x;
625
626 *s = 0;
627 WinQueryDlgItemText(hwnd, MAP_ATTACHTO, sizeof(s), s);
628 bstrip(s);
629 if (*s) {
630 x = (SHORT) WinSendDlgItemMsg(hwnd,
631 MAP_ATTACHLIST,
632 LM_QUERYSELECTION,
633 MPFROMSHORT(LIT_FIRST), MPVOID);
634 if (x >= 0) {
635 *d = 0;
636 WinSendDlgItemMsg(hwnd,
637 MAP_ATTACHLIST,
638 LM_QUERYITEMTEXT,
639 MPFROM2SHORT(x, sizeof(d)), MPFROMP(d));
640 if (*d) {
641
642 PROGDETAILS pgd;
643 CHAR params[368], *p;
644 HAPP happ;
645
646 p = GetCmdSpec(FALSE);
647 memset(&pgd, 0, sizeof(pgd));
648 pgd.Length = sizeof(pgd);
649 pgd.progt.progc = PROG_WINDOWABLEVIO;
650 pgd.progt.fbVisible = SHE_VISIBLE;
651 pgd.pszTitle = (PSZ)GetPString(IDS_ATTACHREQTEXT);
652 pgd.pszExecutable = p;
653 pgd.pszParameters = params;
654 pgd.pszStartupDir = NULL;
655 pgd.pszIcon = NULL;
656 pgd.pszEnvironment = NULL;
657 pgd.swpInitial.hwndInsertBehind = HWND_TOP;
658 pgd.swpInitial.hwnd = hwnd;
659 pgd.swpInitial.fl = SWP_SHOW | SWP_ACTIVATE;
660 sprintf(params, "/C NET USE %s \"%s\"", d, s);
661 happ = WinStartApp(hwnd,
662 &pgd,
663 pgd.pszParameters, NULL, SAF_MAXIMIZED);
664 if (happ) {
665
666 APPNOTIFY *info;
667
668 info = xmallocz(sizeof(APPNOTIFY), pszSrcFile, __LINE__);
669 if (info) {
670 info->happ = happ;
671 info->attach = TRUE;
672 info->failedonce = FALSE;
673 strcpy(info->uncname, s);
674 info->device = *d;
675 if (!apphead)
676 apphead = info;
677 else {
678 apptail->next = info;
679 info->prev = apptail;
680 }
681 apptail = info;
682 }
683 }
684 else
685 saymsg(MB_CANCEL | MB_ICONEXCLAMATION,
686 hwnd,
687 GetPString(IDS_ERRORTEXT),
688 GetPString(IDS_CANTSTARTTEXT), p, params);
689#ifdef NEVER // fixme to be gone?
690 DosError(FERR_DISABLEHARDERR);
691 rc = DosFSAttach(d, s, s, strlen(s) + 1, FS_ATTACH);
692 if (rc) {
693 Dos_Error(MB_CANCEL,
694 rc,
695 hwnd,
696 pszSrcFile,
697 __LINE__, GetPString(IDS_ATTACHFAILEDTEXT), s, d);
698 }
699 else {
700 fRemapped = TRUE;
701 WinSendDlgItemMsg(hwnd,
702 MAP_ATTACHLIST,
703 LM_DELETEITEM, MPFROMSHORT(x), MPVOID);
704 WinSendDlgItemMsg(hwnd,
705 MAP_DETACHLIST,
706 LM_INSERTITEM,
707 MPFROM2SHORT(LIT_SORTASCENDING, 0),
708 MPFROMP(d));
709 }
710#endif // fixme to be gone?
711 }
712 }
713 }
714 }
715 break;
716
717 case IDM_HELP:
718 if (hwndHelp)
719 WinSendMsg(hwndHelp,
720 HM_DISPLAY_HELP,
721 MPFROM2SHORT(HELP_REMAP, 0), MPFROMSHORT(HM_RESOURCEID));
722 break;
723
724 case DID_CANCEL:
725 if (fRemapped) {
726 if (hwndTree)
727 PostMsg(hwndTree, WM_COMMAND, MPFROM2SHORT(IDM_RESCAN, 0), MPVOID);
728 else
729 FillInDriveFlags(NULL);
730 if (hwndMain)
731 PostMsg(hwndMain, UM_BUILDDRIVEBAR, MPVOID, MPVOID);
732 }
733 WinDismissDlg(hwnd, 0);
734 break;
735 }
736 return 0;
737
738 case WM_DESTROY:
739 if (apphead) {
740
741 APPNOTIFY *info, *next;
742
743 info = apphead;
744 while (info) {
745 next = info->next;
746 free(info);
747 info = next;
748 }
749 apphead = apptail = NULL;
750 saymsg(MB_YESNOCANCEL,
751 HWND_DESKTOP,
752 GetPString(IDS_NOTICETITLETEXT),
753 GetPString(IDS_REMAPNOTICETEXT));
754 }
755 free_resources();
756 loadedres = FALSE;
757 break;
758 }
759 return WinDefDlgProc(hwnd, msg, mp1, mp2);
760}
761
762#pragma alloc_text(FMREMAP,RemapDlgProc,load_resources,save_resources)
763#pragma alloc_text(FMREMAP,add_resource,remove_resource,free_resources)
Note: See TracBrowser for help on using the repository browser.