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