source: trunk/dll/remap.c@ 1187

Last change on this file since 1187 was 1187, checked in by John Small, 17 years ago

Ticket 187: Draft 2: Move remaining function declarations

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