[2] | 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 |
|
---|
[551] | 16 | VOID APIENTRY deinit(ULONG why)
|
---|
| 17 | {
|
---|
[2] | 18 |
|
---|
| 19 | /* cleanup */
|
---|
| 20 |
|
---|
| 21 | DosCloseMutexSem(av2Sem);
|
---|
[551] | 22 | if (DosOpenMutexSem("\\SEM32\\AV2", &av2Sem)) {
|
---|
[2] | 23 |
|
---|
[551] | 24 | static CHAR s[CCHMAXPATH];
|
---|
| 25 | CHAR *enddir;
|
---|
| 26 | HDIR search_handle;
|
---|
| 27 | ULONG num_matches;
|
---|
[844] | 28 | static FILEFINDBUF3 f;
|
---|
[2] | 29 |
|
---|
| 30 | save_dir(s);
|
---|
[551] | 31 | if (s[strlen(s) - 1] != '\\')
|
---|
| 32 | strcat(s, "\\");
|
---|
[2] | 33 | enddir = &s[strlen(s)];
|
---|
[551] | 34 | if (*ArcTempRoot) {
|
---|
| 35 | strcat(s, ArcTempRoot);
|
---|
| 36 | strcat(s, "*");
|
---|
[2] | 37 | search_handle = HDIR_CREATE;
|
---|
[841] | 38 | num_matches = 1;
|
---|
[844] | 39 | if (!DosFindFirst(s,
|
---|
[551] | 40 | &search_handle,
|
---|
| 41 | FILE_NORMAL | FILE_DIRECTORY |
|
---|
| 42 | FILE_SYSTEM | FILE_READONLY | FILE_HIDDEN |
|
---|
| 43 | FILE_ARCHIVED,
|
---|
| 44 | &f,
|
---|
[844] | 45 | sizeof(FILEFINDBUF3), &num_matches, FIL_STANDARD)) {
|
---|
[551] | 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);
|
---|
[844] | 54 | } while (!DosFindNext(search_handle,
|
---|
| 55 | &f, sizeof(FILEFINDBUF3), &num_matches));
|
---|
[551] | 56 | DosFindClose(search_handle);
|
---|
[2] | 57 | }
|
---|
| 58 | }
|
---|
| 59 | }
|
---|
| 60 | else
|
---|
| 61 | DosCloseMutexSem(av2Sem);
|
---|
| 62 |
|
---|
[551] | 63 | DosExitList(EXLST_REMOVE, deinit);
|
---|
[2] | 64 | }
|
---|
| 65 |
|
---|
[551] | 66 | int main(int argc, char *argv[])
|
---|
| 67 | {
|
---|
[2] | 68 |
|
---|
[551] | 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;
|
---|
[2] | 76 |
|
---|
| 77 | *fullname = 0;
|
---|
[551] | 78 | strcpy(appname, "AV/2");
|
---|
[2] | 79 | fAmAV2 = TRUE;
|
---|
| 80 | DosError(FERR_DISABLEHARDERR);
|
---|
[551] | 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], '.')))) {
|
---|
[2] | 87 | thisarg = argv[x];
|
---|
| 88 | break;
|
---|
| 89 | }
|
---|
| 90 | }
|
---|
[551] | 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, '.'))) {
|
---|
[2] | 100 |
|
---|
[844] | 101 | static FILEFINDBUF3 ffb;
|
---|
[551] | 102 | ULONG nm;
|
---|
| 103 | HDIR hdir;
|
---|
| 104 | CHAR *enddir;
|
---|
[2] | 105 |
|
---|
[551] | 106 | if (!strchr(fullname, '.'))
|
---|
| 107 | strcat(fullname, ".*");
|
---|
| 108 | enddir = strrchr(fullname, '\\');
|
---|
| 109 | if (enddir) {
|
---|
| 110 | enddir++;
|
---|
| 111 | hdir = HDIR_CREATE;
|
---|
[841] | 112 | nm = 1;
|
---|
[844] | 113 | if (!DosFindFirst(fullname,
|
---|
[551] | 114 | &hdir,
|
---|
| 115 | FILE_NORMAL | FILE_SYSTEM |
|
---|
| 116 | FILE_READONLY | FILE_HIDDEN | FILE_ARCHIVED,
|
---|
[844] | 117 | &ffb, sizeof(FILEFINDBUF3), &nm, FIL_STANDARD)) {
|
---|
[551] | 118 | strcpy(enddir, ffb.achName);
|
---|
| 119 | DosFindClose(hdir);
|
---|
| 120 | }
|
---|
[2] | 121 | }
|
---|
| 122 | }
|
---|
| 123 | }
|
---|
| 124 | hab = WinInitialize(0);
|
---|
[551] | 125 | if (hab) {
|
---|
| 126 | hmq = WinCreateMsgQueue(hab, 1024);
|
---|
| 127 | if (hmq) {
|
---|
[2] | 128 | {
|
---|
[551] | 129 | static CHAR path[CCHMAXPATH];
|
---|
| 130 | CHAR *env;
|
---|
[844] | 131 | FILESTATUS3 fs;
|
---|
[2] | 132 |
|
---|
[551] | 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,
|
---|
[844] | 139 | FIL_STANDARD, &fs, (ULONG) sizeof(fs))) {
|
---|
[551] | 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,
|
---|
[844] | 147 | FIL_STANDARD, &fs, (ULONG) sizeof(fs))) {
|
---|
[551] | 148 | if (fs.attrFile & FILE_DIRECTORY)
|
---|
| 149 | switch_to(path);
|
---|
| 150 | }
|
---|
| 151 | }
|
---|
| 152 | }
|
---|
| 153 | }
|
---|
[2] | 154 | }
|
---|
[551] | 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) {
|
---|
[2] | 171 |
|
---|
[551] | 172 | CHAR *p = strrchr(fullname, '.');
|
---|
[2] | 173 |
|
---|
[551] | 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 | }
|
---|
[844] | 205 | DosSleep(125);
|
---|
[551] | 206 | }
|
---|
| 207 | }
|
---|
| 208 | }
|
---|
| 209 | }
|
---|
[2] | 210 | }
|
---|
[551] | 211 | Abort:
|
---|
[844] | 212 | DosSleep(125);
|
---|
[2] | 213 | WinDestroyMsgQueue(hmq);
|
---|
| 214 | }
|
---|
| 215 | WinTerminate(hab);
|
---|
| 216 | }
|
---|
| 217 | return 0;
|
---|
| 218 | }
|
---|