source: trunk/dll/instant.c@ 1480

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

Fix failure to correctly check for large file support in FindSwapperDat fall back code minor streamling. Add LVM.EXE to partition submenu. Stop using xDosQueryAppType where the file name it is passed is already a local stack variable. Correct a typo in several file header comments.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.2 KB
Line 
1
2/***********************************************************************
3
4 $Id: instant.c 1480 2009-11-22 22:58:49Z gyoung $
5
6 Instant command
7
8 Copyright (c) 1993-98 M. Kimes
9 Copyright (c) 2004, 2008 Steven H.Levine
10
11 01 Aug 04 SHL Rework lstrip/rstrip usage
12 14 Jul 06 SHL Use Runtime_Error
13 22 Mar 07 GKY Use QWL_USER
14 20 Aug 07 GKY Move #pragma alloc_text to end for OpenWatcom compat
15 12 Jul 09 GKY Add xDosQueryAppType and xDosAlloc... to allow FM/2 to load in high memory
16
17***********************************************************************/
18
19#include <string.h>
20#include <ctype.h>
21
22#define INCL_DOS
23#define INCL_WIN
24#define INCL_LONGLONG // dircnrs.h
25
26#include "fm3dll.h"
27#include "fm3dll2.h" // #define's for UM_*, control id's, etc.
28#include "fm3dlg.h"
29#include "fm3str.h"
30#include "mle.h"
31#include "errutil.h" // Dos_Error...
32#include "strutil.h" // GetPString
33#include "instant.h"
34#include "misc.h" // GetCmdSpec
35#include "systemf.h" // runemf2
36#include "strips.h" // bstrip
37#include "wrappers.h" // xDosAllocMem
38#include "init.h" // Strings
39
40#pragma data_seg(DATA1)
41
42static PSZ pszSrcFile = __FILE__;
43
44#define hwndMLE WinWindowFromID(hwnd,BAT_MLE)
45
46static INT batches = 0;
47
48MRESULT EXPENTRY InstantDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
49{
50 CHAR *path;
51 APIRET rc;
52 static CHAR *bat = NULL;
53 static HWND myhwnd = (HWND) 0;
54
55 switch (msg) {
56 case WM_INITDLG:
57 if (myhwnd) {
58 Runtime_Error(pszSrcFile, __LINE__, "busy");
59 WinSendMsg(myhwnd, WM_SYSCOMMAND, MPFROM2SHORT(SC_RESTORE, 0), MPVOID);
60 WinSetActiveWindow(HWND_DESKTOP, myhwnd);
61 WinDismissDlg(hwnd, 0);
62 break;
63 }
64 if (!mp2) {
65 Runtime_Error(pszSrcFile, __LINE__, NULL);
66 WinDismissDlg(hwnd, 0);
67 break;
68 }
69 WinSetWindowPtr(hwnd, QWL_USER, mp2);
70 path = (CHAR *) mp2;
71 {
72 CHAR s[CCHMAXPATH + 81];
73
74 sprintf(s, GetPString(IDS_INSTANTTITLETEXT), path);
75 WinSetWindowText(hwnd, s);
76 }
77 WinSendMsg(hwndMLE,
78 MLM_SETTEXTLIMIT, MPFROMLONG((LONG) (10240L)), MPVOID);
79 WinSendMsg(hwndMLE, MLM_FORMAT, MPFROM2SHORT(MLFIE_NOTRANS, 0), MPVOID);
80 if (bat) {
81
82 ULONG tlen = strlen(bat);
83 IPT iptOffset = 0L;
84
85 WinSendMsg(hwndMLE, MLM_SETIMPORTEXPORT,
86 MPFROMP(bat), MPFROMLONG(12287L));
87 WinSendMsg(hwndMLE, MLM_IMPORT, MPFROMP(&iptOffset), MPFROMP(tlen));
88 DosFreeMem(bat);
89 bat = NULL;
90 }
91 break;
92
93 case WM_COMMAND:
94 switch (SHORT1FROMMP(mp1)) {
95 case DID_OK:
96 path = (CHAR *) WinQueryWindowPtr(hwnd, QWL_USER);
97 {
98 CHAR s[CCHMAXPATH + 1];
99 FILE *fp;
100 IPT iptOffset = 0L;
101 LONG len, tlen, mem;
102 CHAR *rexx = "";
103
104 mem = MLEgetlen(hwndMLE);
105 if (mem) {
106 rc = xDosAllocMem((PVOID) & bat, mem,
107 PAG_COMMIT | PAG_READ | PAG_WRITE, pszSrcFile, __LINE__);
108 if (rc || !bat) {
109 Dos_Error(MB_CANCEL, rc, HWND_DESKTOP, pszSrcFile, __LINE__,
110 GetPString(IDS_OUTOFMEMORY));
111 WinDismissDlg(hwnd, 0);
112 break;
113 }
114 tlen =
115 (LONG) WinSendMsg(hwndMLE, MLM_QUERYTEXTLENGTH, MPVOID, MPVOID);
116 if (!tlen)
117 Runtime_Error(pszSrcFile, __LINE__, NULL);
118 else {
119 WinSendMsg(hwndMLE, MLM_SETIMPORTEXPORT,
120 MPFROMP(bat), MPFROMLONG(mem));
121 len = (LONG) WinSendMsg(hwndMLE, MLM_EXPORT,
122 MPFROMP(&iptOffset), MPFROMP(&tlen));
123 bat[len] = 0;
124 lstrip(bat);
125 while (strlen(bat) && bat[strlen(bat) - 1] == '\n' ||
126 bat[strlen(bat) - 1] == ' ') {
127 // fixme to understand
128 stripcr(bat);
129 rstrip(bat);
130 stripcr(bat);
131 rstrip(bat);
132 }
133 if (!*bat)
134 Runtime_Error(pszSrcFile, __LINE__, NULL);
135 else {
136 sprintf(s, "%s%sFMTMP%d.CMD", path,
137 (path[strlen(path) - 1] == '\\') ? NullStr : PCSZ_BACKSLASH,
138 batches++);
139 fp = fopen(s, "w");
140 if (!fp)
141 Runtime_Error(pszSrcFile, __LINE__, "fopen");
142 else {
143 if (!strncmp(bat, "/*", 2)) {
144 rexx = "'";
145 fprintf(fp, "%s\n", GetPString(IDS_REXXCOMMENT));
146 }
147 fprintf(fp, "%s%c:%s\n", rexx, toupper(*path), rexx);
148 fprintf(fp, "%sCD \"%s%s\"%s\n", rexx, path,
149 (strlen(path) < 3) ? PCSZ_BACKSLASH : NullStr, rexx);
150 fprintf(fp, "%s", bat);
151 fprintf(fp, "\n%sDEL \"%s\"%s\n", rexx, s, rexx);
152 fclose(fp);
153 runemf2(WINDOWED | SEPARATE,
154 hwnd, pszSrcFile, __LINE__,
155 path, NULL, "%s /C \"%s\"", GetCmdSpec(FALSE), s);
156 }
157 }
158 }
159 }
160 }
161 WinDismissDlg(hwnd, 0);
162 break;
163
164 case DID_CANCEL:
165 WinDismissDlg(hwnd, 0);
166 break;
167
168 case IDM_HELP:
169 path = WinQueryWindowPtr(hwnd, QWL_USER);
170 rc = saymsg(MB_YESNOCANCEL,
171 hwnd,
172 GetPString(IDS_INSTANTHELPTITLETEXT),
173 GetPString(IDS_INSTANTHELPTEXT),
174 path, (strlen(path) < 3) ? PCSZ_BACKSLASH : NullStr, path,
175 (path[strlen(path) - 1] == '\\') ? NullStr : PCSZ_BACKSLASH, batches);
176 if (rc == MBID_YES)
177 runemf2(WINDOWED | INVISIBLE | BACKGROUND,
178 hwnd, pszSrcFile, __LINE__, NULL, NULL,
179 "%s /C HELP BATCH", GetCmdSpec(FALSE));
180 else if (rc == MBID_CANCEL)
181 WinDismissDlg(hwnd, 0);
182 break;
183 }
184 return 0;
185
186 case WM_CLOSE:
187 case WM_DESTROY:
188 myhwnd = (HWND) 0;
189 break;
190 }
191 return WinDefDlgProc(hwnd, msg, mp1, mp2);
192}
193
194#pragma alloc_text(INSTANT,InstantDlgProc)
Note: See TracBrowser for help on using the repository browser.