1 | #define INCL_DOS
|
---|
2 | #define INCL_WIN
|
---|
3 |
|
---|
4 | #include <os2.h>
|
---|
5 | #include <stdarg.h>
|
---|
6 | #include <stdio.h>
|
---|
7 | #include <stdlib.h>
|
---|
8 | #include <string.h>
|
---|
9 | #include <ctype.h>
|
---|
10 | #include "dll\fm3dll.h"
|
---|
11 | #include "dll\version.h"
|
---|
12 | #include "dll\fm3str.h"
|
---|
13 |
|
---|
14 | HMTX av2Sem;
|
---|
15 |
|
---|
16 | VOID APIENTRY deinit(ULONG why)
|
---|
17 | {
|
---|
18 |
|
---|
19 | /* cleanup */
|
---|
20 |
|
---|
21 | DosCloseMutexSem(av2Sem);
|
---|
22 | if (DosOpenMutexSem("\\SEM32\\AV2", &av2Sem)) {
|
---|
23 |
|
---|
24 | static CHAR s[CCHMAXPATH];
|
---|
25 | CHAR *enddir;
|
---|
26 | HDIR search_handle;
|
---|
27 | ULONG num_matches;
|
---|
28 | static FILEFINDBUF3 f;
|
---|
29 |
|
---|
30 | save_dir(s);
|
---|
31 | if (s[strlen(s) - 1] != '\\')
|
---|
32 | strcat(s, "\\");
|
---|
33 | enddir = &s[strlen(s)];
|
---|
34 | if (*ArcTempRoot) {
|
---|
35 | strcat(s, ArcTempRoot);
|
---|
36 | strcat(s, "*");
|
---|
37 | search_handle = HDIR_CREATE;
|
---|
38 | num_matches = 1;
|
---|
39 | if (!DosFindFirst(s,
|
---|
40 | &search_handle,
|
---|
41 | FILE_NORMAL | FILE_DIRECTORY |
|
---|
42 | FILE_SYSTEM | FILE_READONLY | FILE_HIDDEN |
|
---|
43 | FILE_ARCHIVED,
|
---|
44 | &f,
|
---|
45 | sizeof(FILEFINDBUF3), &num_matches, FIL_STANDARD)) {
|
---|
46 | do {
|
---|
47 | strcpy(enddir, f.achName);
|
---|
48 | if (f.attrFile & FILE_DIRECTORY) {
|
---|
49 | wipeallf("%s\\*", s);
|
---|
50 | DosDeleteDir(s);
|
---|
51 | }
|
---|
52 | else
|
---|
53 | unlinkf("%s", s);
|
---|
54 | } while (!DosFindNext(search_handle,
|
---|
55 | &f, sizeof(FILEFINDBUF3), &num_matches));
|
---|
56 | DosFindClose(search_handle);
|
---|
57 | }
|
---|
58 | }
|
---|
59 | }
|
---|
60 | else
|
---|
61 | DosCloseMutexSem(av2Sem);
|
---|
62 |
|
---|
63 | DosExitList(EXLST_REMOVE, deinit);
|
---|
64 | }
|
---|
65 |
|
---|
66 | int main(int argc, char *argv[])
|
---|
67 | {
|
---|
68 |
|
---|
69 | HAB hab;
|
---|
70 | HMQ hmq;
|
---|
71 | QMSG qmsg;
|
---|
72 | HWND hwndFrame = (HWND) 0;
|
---|
73 | static CHAR fullname[CCHMAXPATH];
|
---|
74 | CHAR *thisarg = NULL;
|
---|
75 | INT x;
|
---|
76 |
|
---|
77 | *fullname = 0;
|
---|
78 | strcpy(appname, "AV/2");
|
---|
79 | fAmAV2 = TRUE;
|
---|
80 | DosError(FERR_DISABLEHARDERR);
|
---|
81 | for (x = 1; x < argc; x++) {
|
---|
82 | if (!strchr("/;,`\'", *argv[x]) &&
|
---|
83 | !thisarg &&
|
---|
84 | (IsFile(argv[x]) == 1 ||
|
---|
85 | (strchr(argv[x], '?') || strchr(argv[x], '*') ||
|
---|
86 | !strchr(argv[x], '.')))) {
|
---|
87 | thisarg = argv[x];
|
---|
88 | break;
|
---|
89 | }
|
---|
90 | }
|
---|
91 | DosExitList(EXLST_ADD, deinit);
|
---|
92 | if (DosOpenMutexSem("\\SEM32\\AV2", &av2Sem))
|
---|
93 | DosCreateMutexSem("\\SEM32\\AV2", &av2Sem, DC_SEM_SHARED, FALSE);
|
---|
94 | if (thisarg) {
|
---|
95 | if (DosQueryPathInfo(thisarg,
|
---|
96 | FIL_QUERYFULLNAME, fullname, sizeof(fullname)))
|
---|
97 | strcpy(fullname, thisarg);
|
---|
98 | if (*fullname && (strchr(fullname, '?') ||
|
---|
99 | strchr(fullname, '*') || !strchr(fullname, '.'))) {
|
---|
100 |
|
---|
101 | static FILEFINDBUF3 ffb;
|
---|
102 | ULONG nm;
|
---|
103 | HDIR hdir;
|
---|
104 | CHAR *enddir;
|
---|
105 |
|
---|
106 | if (!strchr(fullname, '.'))
|
---|
107 | strcat(fullname, ".*");
|
---|
108 | enddir = strrchr(fullname, '\\');
|
---|
109 | if (enddir) {
|
---|
110 | enddir++;
|
---|
111 | hdir = HDIR_CREATE;
|
---|
112 | nm = 1;
|
---|
113 | if (!DosFindFirst(fullname,
|
---|
114 | &hdir,
|
---|
115 | FILE_NORMAL | FILE_SYSTEM |
|
---|
116 | FILE_READONLY | FILE_HIDDEN | FILE_ARCHIVED,
|
---|
117 | &ffb, sizeof(FILEFINDBUF3), &nm, FIL_STANDARD)) {
|
---|
118 | strcpy(enddir, ffb.achName);
|
---|
119 | DosFindClose(hdir);
|
---|
120 | }
|
---|
121 | }
|
---|
122 | }
|
---|
123 | }
|
---|
124 | hab = WinInitialize(0);
|
---|
125 | if (hab) {
|
---|
126 | hmq = WinCreateMsgQueue(hab, 1024);
|
---|
127 | if (hmq) {
|
---|
128 | {
|
---|
129 | static CHAR path[CCHMAXPATH];
|
---|
130 | CHAR *env;
|
---|
131 | FILESTATUS3 fs;
|
---|
132 |
|
---|
133 | env = getenv("FM3INI");
|
---|
134 | if (env && *env) {
|
---|
135 | DosError(FERR_DISABLEHARDERR);
|
---|
136 | if (!DosQueryPathInfo(env, FIL_QUERYFULLNAME, path, sizeof(path))) {
|
---|
137 | DosError(FERR_DISABLEHARDERR);
|
---|
138 | if (!DosQueryPathInfo(path,
|
---|
139 | FIL_STANDARD, &fs, (ULONG) sizeof(fs))) {
|
---|
140 | if (!(fs.attrFile & FILE_DIRECTORY)) {
|
---|
141 | env = strrchr(path, '\\');
|
---|
142 | if (env)
|
---|
143 | *env = 0;
|
---|
144 | }
|
---|
145 | DosError(FERR_DISABLEHARDERR);
|
---|
146 | if (!DosQueryPathInfo(path,
|
---|
147 | FIL_STANDARD, &fs, (ULONG) sizeof(fs))) {
|
---|
148 | if (fs.attrFile & FILE_DIRECTORY)
|
---|
149 | switch_to(path);
|
---|
150 | }
|
---|
151 | }
|
---|
152 | }
|
---|
153 | }
|
---|
154 | }
|
---|
155 | if (InitFM3DLL(hab, argc, argv)) {
|
---|
156 | if (CheckVersion(VERMAJOR, VERMINOR)) {
|
---|
157 | fAmAV2 = TRUE;
|
---|
158 | if (!*fullname) {
|
---|
159 | strcpy(fullname, "*");
|
---|
160 | if (!insert_filename(HWND_DESKTOP,
|
---|
161 | fullname,
|
---|
162 | TRUE,
|
---|
163 | FALSE) || !*fullname || *fullname == '*')
|
---|
164 | goto Abort;
|
---|
165 | }
|
---|
166 | if (*fullname) {
|
---|
167 | if (ExecAssociation(HWND_DESKTOP, fullname) == -1) {
|
---|
168 | hwndFrame = StartArcCnr(HWND_DESKTOP,
|
---|
169 | (HWND) 0, fullname, 0, NULL);
|
---|
170 | if (!hwndFrame) {
|
---|
171 |
|
---|
172 | CHAR *p = strrchr(fullname, '.');
|
---|
173 |
|
---|
174 | if (p) {
|
---|
175 | if (!stricmp(p, ".INI"))
|
---|
176 | hwndFrame = StartIniEditor(HWND_DESKTOP, fullname, 0);
|
---|
177 | }
|
---|
178 | if (!ShowMultimedia(fullname))
|
---|
179 | hwndFrame = StartMLEEditor(HWND_DESKTOP,
|
---|
180 | 1,
|
---|
181 | ((*fullname) ?
|
---|
182 | fullname : NULL), (HWND) 0);
|
---|
183 | }
|
---|
184 | if (hwndFrame && WinIsWindow(hab, hwndFrame)) {
|
---|
185 | if (hwndHelp)
|
---|
186 | WinAssociateHelpInstance(hwndHelp, hwndFrame);
|
---|
187 | for (;;) {
|
---|
188 | if (!WinGetMsg(hab, &qmsg, (HWND) 0, 0, 0)) {
|
---|
189 | if (!WinIsWindow(hab, hwndFrame))
|
---|
190 | break;
|
---|
191 | if (qmsg.hwnd)
|
---|
192 | qmsg.msg = WM_CLOSE;
|
---|
193 | else
|
---|
194 | break;
|
---|
195 | }
|
---|
196 | if (hwndBubble &&
|
---|
197 | ((qmsg.msg > (WM_BUTTON1DOWN - 1) &&
|
---|
198 | qmsg.msg < (WM_BUTTON3DBLCLK + 1)) ||
|
---|
199 | (qmsg.msg > (WM_CHORD - 1) &&
|
---|
200 | qmsg.msg < (WM_BUTTON3CLICK + 1))) &&
|
---|
201 | WinIsWindowVisible(hwndBubble))
|
---|
202 | WinShowWindow(hwndBubble, FALSE);
|
---|
203 | WinDispatchMsg(hab, &qmsg);
|
---|
204 | }
|
---|
205 | DosSleep(125);
|
---|
206 | }
|
---|
207 | }
|
---|
208 | }
|
---|
209 | }
|
---|
210 | }
|
---|
211 | Abort:
|
---|
212 | DosSleep(125);
|
---|
213 | WinDestroyMsgQueue(hmq);
|
---|
214 | }
|
---|
215 | WinTerminate(hab);
|
---|
216 | }
|
---|
217 | return 0;
|
---|
218 | }
|
---|