source: trunk/dll/remap.c@ 1402

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

Remove variable aurgs from docopy & unlinkf (not used); Move more strings to PCSZs and string table; Move PCSZs to compile time initialization; Fix hang on startup caused by a drive scan and a dircnr scan trying to update a drive in the tree at the same time (related to the "treeswitch options); Code cleanup mainly removal of old printfs, SayMsgs, DbgMsg and unneeded %s.

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