source: trunk/dll/remap.c@ 1082

Last change on this file since 1082 was 1082, checked in by Gregg Young, 17 years ago

Changes so FM2 will use TMP/TEMP directory for all temp files; Replaced save_dir2 with global variable so BldFullPathName could easily replace code that performed the same function; Added #ifdef FORTIFY to free_ function that are only used when fortified.

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