source: trunk/dll/remap.c@ 1673

Last change on this file since 1673 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
RevLine 
[123]1
2/***********************************************************************
3
4 $Id: remap.c 1673 2012-12-30 18:51:01Z gyoung $
5
[246]6 Copyright (c) 1993, 1998 M. Kimes
[1498]7 Copyright (c) 2004, 2010 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
[1498]18 17 JAN 10 GKY Changes to get working with Watcom 1.9 Beta (1/16/10). Mostly cast CHAR CONSTANT * as CHAR *.
[123]19
20***********************************************************************/
21
[2]22#include <stdlib.h>
23#include <string.h>
24#include <share.h>
[689]25#include <io.h> // unlink
[404]26
[907]27#define INCL_DOS
28#define INCL_WIN
29#define INCL_LONGLONG // dircnrs.h
30
[1187]31#include "fm3dll.h"
[1226]32#include "fm3dll2.h" // #define's for UM_*, control id's, etc.
33#include "remap.h"
[1212]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
[2]40#include "fm3dlg.h"
41#include "fm3str.h"
[907]42#include "errutil.h" // Dos_Error...
43#include "strutil.h" // GetPString
[1082]44#include "pathutil.h" // BldFullPathName
[1187]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
[1039]51#include "fortify.h"
[2]52
53#pragma data_seg(DATA1)
[353]54
55static PSZ pszSrcFile = __FILE__;
56
[551]57typedef struct APPNOTIFY
58{
59 HAPP happ;
60 BOOL attach;
61 BOOL failedonce;
62 CHAR uncname[CCHMAXPATH];
63 CHAR device;
[2]64 struct APPNOTIFY *next;
65 struct APPNOTIFY *prev;
[551]66}
67APPNOTIFY;
[2]68
[551]69typedef struct LINKRES
70{
71 CHAR *res;
[2]72 struct LINKRES *next;
[551]73}
74LINKRES;
[2]75
[551]76static LINKRES *reshead = NULL;
77static BOOL loadedres = FALSE;
[2]78
79#define MAXNUMRES 200
80
[551]81VOID load_resources(VOID)
[353]82{
[1673]83 // load linked list of resources from RESOURCE.DAT file
[2]84
[551]85 FILE *fp;
86 LINKRES *info, *last = NULL;
87 CHAR s[CCHMAXPATH + 14];
88 INT x = 0;
[1544]89 CHAR *moder = "r";
[2]90
91 loadedres = TRUE;
[1398]92 BldFullPathName(s, pFM2SaveDirectory, PCSZ_RESOURCEDAT);
[1544]93 fp = xfsopen(s, moder, SH_DENYWR, pszSrcFile, __LINE__, TRUE);
[353]94 if (fp) {
[404]95 while (x < MAXNUMRES && !feof(fp)) {
[551]96 if (!xfgets_bstripcr(s, sizeof(s), fp, pszSrcFile, __LINE__))
97 break;
[404]98 if (*s && *s != ';') {
[551]99 info = xmalloc(sizeof(LINKRES), pszSrcFile, __LINE__);
100 if (info) {
101 info->res = xstrdup(s, pszSrcFile, __LINE__);
102 if (!info->res)
[1039]103 free(info);
[353]104 else {
[551]105 x++;
106 info->next = NULL;
107 if (!reshead)
108 reshead = info;
109 else
110 last->next = info;
111 last = info;
112 }
113 }
[2]114 }
115 }
116 fclose(fp);
117 }
118}
119
[551]120VOID save_resources(VOID)
[353]121{
[1673]122 // save linked list of resources to RESOURCE.DAT file
[2]123
124 LINKRES *info;
[551]125 FILE *fp;
126 CHAR s[CCHMAXPATH + 14];
[1544]127 CHAR *modew = "w";
[2]128
[551]129 if (!loadedres)
[2]130 return;
[1398]131 BldFullPathName(s, pFM2SaveDirectory, PCSZ_RESOURCEDAT);
[1118]132 if (CheckDriveSpaceAvail(s, ullDATFileSpaceNeeded, 1) == 2)
[1117]133 return; //already gave error msg
[551]134 if (reshead) {
[1544]135 fp = xfopen(s, modew, pszSrcFile, __LINE__, FALSE);
[353]136 if (fp) {
[551]137 fputs(GetPString(IDS_REMOTEFILETEXT), fp);
[2]138 info = reshead;
[353]139 while (info) {
[551]140 fprintf(fp, "%0.*s\n", CCHMAXPATH, info->res);
141 info = info->next;
[2]142 }
143 fclose(fp);
144 }
145 }
146 else
147 unlink(s);
148}
149
[551]150BOOL add_resource(CHAR * res)
[353]151{
[551]152 LINKRES *info, *last = NULL;
153 INT x = 0;
[2]154
[551]155 if (!res || !*res)
[2]156 return FALSE;
[551]157 if (!loadedres)
[2]158 load_resources();
159 info = reshead;
[551]160 while (info) {
161 if (!stricmp(info->res, res))
[2]162 return FALSE;
163 last = info;
164 info = info->next;
165 x++;
166 }
[551]167 info = xmalloc(sizeof(LINKRES), pszSrcFile, __LINE__);
168 if (info) {
169 info->res = xstrdup(res, pszSrcFile, __LINE__);
[353]170 if (!info->res)
[1039]171 free(info);
[353]172 else {
[2]173 info->next = NULL;
[551]174 if (!reshead)
175 reshead = info;
[2]176 else
[551]177 last->next = info;
178 if (x > MAXNUMRES) {
179 info = reshead;
180 reshead = reshead->next;
[1039]181 free(info);
[2]182 }
183 return TRUE;
184 }
185 }
186 return FALSE;
187}
188
[551]189BOOL remove_resource(CHAR * res)
[353]190{
[551]191 LINKRES *info, *last = NULL;
[2]192
[551]193 if (!res || !*res)
[2]194 return FALSE;
[551]195 if (!loadedres)
[2]196 load_resources();
197 info = reshead;
[551]198 while (info) {
199 if (!stricmp(info->res, res)) {
200 if (last)
201 last->next = info->next;
[2]202 else
[551]203 reshead = info->next;
[1009]204 xfree(info->res, pszSrcFile, __LINE__);
[1039]205 free(info);
[2]206 return TRUE;
207 }
208 last = info;
209 info = info->next;
210 }
211 return FALSE;
212}
213
[551]214VOID free_resources(VOID)
[353]215{
[551]216 LINKRES *info, *next;
[2]217
218 info = reshead;
[551]219 while (info) {
[2]220 next = info->next;
[1009]221 xfree(info->res, pszSrcFile, __LINE__);
[1039]222 free(info);
[2]223 info = next;
224 }
225 reshead = NULL;
226 DosPostEventSem(CompactSem);
227}
228
[551]229MRESULT EXPENTRY RemapDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
[353]230{
[2]231 static BOOL fRemapped;
[551]232 static APPNOTIFY *apphead = NULL, *apptail = NULL;
[2]233
[551]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;
[2]244
[551]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;
[2]252 }
[551]253 }
254 {
255 ULONG ulDriveMap, ulDriveNum, x, ulType;
256 CHAR s[3] = " :";
[2]257
[551]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';
[766]263 if (!(ulDriveMap & (1 << x)))
[551]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 }
[2]278 }
[551]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 }
[2]292 break;
[551]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];
[2]302
[551]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) {
[2]315
[551]316 CHAR buf[2048];
317 ULONG len;
318 APIRET rc;
319 FSQBUFFER2 *p2;
[2]320
[551]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) {
[2]327
[551]328 CHAR *p;
[2]329
[551]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,
[1498]338 (CHAR *) GetPString(IDS_UNKNOWNBRKTTEXT));
[551]339 }
340 else
341 WinSetDlgItemText(hwnd,
342 MAP_ATTACHTO,
[1498]343 (CHAR *) GetPString(IDS_UNKNOWNBRKTTEXT));
[551]344 }
345 }
346 }
347 break;
[2]348 }
349 break;
[551]350 }
351 break;
[2]352
[551]353 case WM_APPTERMINATENOTIFY:
354 {
355 APPNOTIFY *info;
356 SHORT x, c;
357 CHAR d[3];
358 HWND hwndList;
[2]359
[551]360 if (!mp2)
361 fRemapped = TRUE;
362 info = apphead;
363 GetRidOfIt:
364 while (info) {
365 if (info->happ == (HAPP) mp1) {
[1673]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 */
[551]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) {
[2]420
[551]421 PROGDETAILS pgd;
422 CHAR params[368], *p;
423 HAPP happ;
[2]424
[551]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;
[1394]433 pgd.pszTitle = info->attach ? (PSZ)GetPString(IDS_ATTACHREQTEXT) :
434 (PSZ)GetPString(IDS_DETACHREQTEXT);
[551]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),
[1402]458 GetPString(IDS_CANTSTARTNETUSETEXT));
[551]459 if (!mp2 || (ULONG) mp2 == 1041 || info->failedonce)
[1039]460 free(info);
[551]461 break;
462 }
463 info = info->next;
[2]464 }
[551]465 }
466 break;
[2]467
[551]468 case WM_COMMAND:
469 switch (SHORT1FROMMP(mp1)) {
470 case MAP_DELETE:
471 {
472 SHORT x;
473 CHAR resource[CCHMAXPATH];
[2]474
[551]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;
[2]509
[551]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;
[2]516
[551]517 case MAP_INFO:
518 case MAP_DETACH:
519 {
520 CHAR d[3], s[CCHMAXPATH];
521 SHORT x;
[2]522
[551]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;
[2]543
[551]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;
[1394]549 pgd.pszTitle = (PSZ)GetPString(IDS_DETACHREQTEXT);
[551]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) {
[2]563
[551]564 APPNOTIFY *info;
[2]565
[551]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 }
[353]589#ifdef NEVER // fixme to be gone?
[551]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;
[2]612
[551]613 case MAP_INFO:
614 runemf2(SEPARATEKEEP | WINDOWED | MAXIMIZED,
[888]615 hwnd, pszSrcFile, __LINE__,
[551]616 NULL, NULL, "%s /C NET USE %s", GetCmdSpec(FALSE), d);
617 break;
618 }
619 }
620 }
621 }
622 break;
[2]623
[551]624 case MAP_ATTACH:
625 {
626 CHAR d[3], s[CCHMAXPATH];
627 SHORT x;
[2]628
[551]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) {
[2]644
[551]645 PROGDETAILS pgd;
646 CHAR params[368], *p;
647 HAPP happ;
[2]648
[551]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;
[1394]654 pgd.pszTitle = (PSZ)GetPString(IDS_ATTACHREQTEXT);
[551]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) {
[2]668
[551]669 APPNOTIFY *info;
[2]670
[551]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);
[353]692#ifdef NEVER // fixme to be gone?
[551]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;
[2]719
[551]720 case IDM_HELP:
721 if (hwndHelp)
722 WinSendMsg(hwndHelp,
723 HM_DISPLAY_HELP,
724 MPFROM2SHORT(HELP_REMAP, 0), MPFROMSHORT(HM_RESOURCEID));
725 break;
[2]726
[551]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);
[2]735 }
[551]736 WinDismissDlg(hwnd, 0);
737 break;
738 }
739 return 0;
[2]740
[551]741 case WM_DESTROY:
742 if (apphead) {
[2]743
[551]744 APPNOTIFY *info, *next;
[2]745
[551]746 info = apphead;
747 while (info) {
748 next = info->next;
[1039]749 free(info);
[551]750 info = next;
[2]751 }
[551]752 apphead = apptail = NULL;
753 saymsg(MB_YESNOCANCEL,
754 HWND_DESKTOP,
755 GetPString(IDS_NOTICETITLETEXT),
[1402]756 GetPString(IDS_REMAPNOTICETEXT));
[551]757 }
758 free_resources();
759 loadedres = FALSE;
760 break;
[2]761 }
[551]762 return WinDefDlgProc(hwnd, msg, mp1, mp2);
[2]763}
[793]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.