source: trunk/dll/remap.c@ 1844

Last change on this file since 1844 was 1673, checked in by Gregg Young, 13 years ago

Update to Doxygen comment style Ticket 55. Also some minor code cleanup.

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