[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 |
|
---|
| 16 |
|
---|
| 17 | VOID APIENTRY deinit (ULONG why) {
|
---|
| 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 = 1L;
|
---|
| 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),
|
---|
| 46 | &num_matches,
|
---|
| 47 | FIL_STANDARD)) {
|
---|
| 48 | do {
|
---|
| 49 | strcpy(enddir,f.achName);
|
---|
| 50 | if(f.attrFile & FILE_DIRECTORY) {
|
---|
| 51 | wipeallf("%s\\*",s);
|
---|
| 52 | DosDeleteDir(s);
|
---|
| 53 | }
|
---|
| 54 | else
|
---|
| 55 | unlinkf("%s",s);
|
---|
| 56 | } while(!DosFindNext(search_handle,
|
---|
| 57 | &f,
|
---|
| 58 | sizeof(FILEFINDBUF3),
|
---|
| 59 | &num_matches));
|
---|
| 60 | DosFindClose(search_handle);
|
---|
| 61 | }
|
---|
| 62 | }
|
---|
| 63 | }
|
---|
| 64 | else
|
---|
| 65 | DosCloseMutexSem(av2Sem);
|
---|
| 66 |
|
---|
| 67 | DosExitList(EXLST_REMOVE,deinit);
|
---|
| 68 | }
|
---|
| 69 |
|
---|
| 70 |
|
---|
| 71 | int main (int argc,char *argv[]) {
|
---|
| 72 |
|
---|
| 73 | HAB hab;
|
---|
| 74 | HMQ hmq;
|
---|
| 75 | QMSG qmsg;
|
---|
| 76 | HWND hwndFrame = (HWND)0;
|
---|
| 77 | static CHAR fullname[CCHMAXPATH];
|
---|
| 78 | CHAR *thisarg = NULL;
|
---|
| 79 | INT x;
|
---|
| 80 |
|
---|
| 81 | *fullname = 0;
|
---|
| 82 | strcpy(appname,"AV/2");
|
---|
| 83 | fAmAV2 = TRUE;
|
---|
| 84 | DosError(FERR_DISABLEHARDERR);
|
---|
| 85 | for(x = 1;x < argc;x++) {
|
---|
| 86 | if(!strchr("/;,`\'",*argv[x]) &&
|
---|
| 87 | !thisarg &&
|
---|
| 88 | (IsFile(argv[x]) == 1 ||
|
---|
| 89 | (strchr(argv[x],'?') || strchr(argv[x],'*') ||
|
---|
| 90 | !strchr(argv[x],'.')))) {
|
---|
| 91 | thisarg = argv[x];
|
---|
| 92 | break;
|
---|
| 93 | }
|
---|
| 94 | }
|
---|
| 95 | DosExitList(EXLST_ADD,deinit);
|
---|
| 96 | if(DosOpenMutexSem("\\SEM32\\AV2",
|
---|
| 97 | &av2Sem))
|
---|
| 98 | DosCreateMutexSem("\\SEM32\\AV2",
|
---|
| 99 | &av2Sem,
|
---|
| 100 | DC_SEM_SHARED,
|
---|
| 101 | FALSE);
|
---|
| 102 | if(thisarg) {
|
---|
| 103 | if(DosQueryPathInfo(thisarg,
|
---|
| 104 | FIL_QUERYFULLNAME,
|
---|
| 105 | fullname,
|
---|
| 106 | sizeof(fullname)))
|
---|
| 107 | strcpy(fullname,thisarg);
|
---|
| 108 | if(*fullname && (strchr(fullname,'?') ||
|
---|
| 109 | strchr(fullname,'*') ||
|
---|
| 110 | !strchr(fullname,'.'))) {
|
---|
| 111 |
|
---|
| 112 | static FILEFINDBUF3 ffb;
|
---|
| 113 | ULONG nm;
|
---|
| 114 | HDIR hdir;
|
---|
| 115 | CHAR *enddir;
|
---|
| 116 |
|
---|
| 117 | if(!strchr(fullname,'.'))
|
---|
| 118 | strcat(fullname,".*");
|
---|
| 119 | enddir = strrchr(fullname,'\\');
|
---|
| 120 | if(enddir) {
|
---|
| 121 | enddir++;
|
---|
| 122 | hdir = HDIR_CREATE;
|
---|
| 123 | nm = 1L;
|
---|
| 124 | if(!DosFindFirst(fullname,
|
---|
| 125 | &hdir,
|
---|
| 126 | FILE_NORMAL | FILE_SYSTEM |
|
---|
| 127 | FILE_READONLY | FILE_HIDDEN | FILE_ARCHIVED,
|
---|
| 128 | &ffb,
|
---|
| 129 | sizeof(FILEFINDBUF3),
|
---|
| 130 | &nm,
|
---|
| 131 | FIL_STANDARD)) {
|
---|
| 132 | strcpy(enddir,ffb.achName);
|
---|
| 133 | DosFindClose(hdir);
|
---|
| 134 | }
|
---|
| 135 | }
|
---|
| 136 | }
|
---|
| 137 | }
|
---|
| 138 | hab = WinInitialize(0);
|
---|
| 139 | if(hab) {
|
---|
| 140 | hmq = WinCreateMsgQueue(hab,1024);
|
---|
| 141 | if(hmq) {
|
---|
| 142 | {
|
---|
| 143 | static CHAR path[CCHMAXPATH];
|
---|
| 144 | CHAR *env;
|
---|
| 145 | FILESTATUS3 fs;
|
---|
| 146 |
|
---|
| 147 | env = getenv("FM3INI");
|
---|
| 148 | if(env && *env) {
|
---|
| 149 | DosError(FERR_DISABLEHARDERR);
|
---|
| 150 | if(!DosQueryPathInfo(env,
|
---|
| 151 | FIL_QUERYFULLNAME,
|
---|
| 152 | path,
|
---|
| 153 | sizeof(path))) {
|
---|
| 154 | DosError(FERR_DISABLEHARDERR);
|
---|
| 155 | if(!DosQueryPathInfo(path,
|
---|
| 156 | FIL_STANDARD,
|
---|
| 157 | &fs,
|
---|
| 158 | (ULONG)sizeof(fs))) {
|
---|
| 159 | if(!(fs.attrFile & FILE_DIRECTORY)) {
|
---|
| 160 | env = strrchr(path,'\\');
|
---|
| 161 | if(env)
|
---|
| 162 | *env = 0;
|
---|
| 163 | }
|
---|
| 164 | DosError(FERR_DISABLEHARDERR);
|
---|
| 165 | if(!DosQueryPathInfo(path,
|
---|
| 166 | FIL_STANDARD,
|
---|
| 167 | &fs,
|
---|
| 168 | (ULONG)sizeof(fs))) {
|
---|
| 169 | if(fs.attrFile & FILE_DIRECTORY)
|
---|
| 170 | switch_to(path);
|
---|
| 171 | }
|
---|
| 172 | }
|
---|
| 173 | }
|
---|
| 174 | }
|
---|
| 175 | }
|
---|
| 176 | if(InitFM3DLL(hab,argc,argv)) {
|
---|
| 177 | if(CheckVersion(VERMAJOR,VERMINOR)) {
|
---|
| 178 | fAmAV2 = TRUE;
|
---|
| 179 | if(!*fullname) {
|
---|
| 180 | strcpy(fullname,"*");
|
---|
| 181 | if(!insert_filename(HWND_DESKTOP,
|
---|
| 182 | fullname,
|
---|
| 183 | TRUE,
|
---|
| 184 | FALSE) ||
|
---|
| 185 | !*fullname || *fullname == '*')
|
---|
| 186 | goto Abort;
|
---|
| 187 | }
|
---|
| 188 | if(*fullname) {
|
---|
| 189 | if(ExecAssociation(HWND_DESKTOP,fullname) == -1) {
|
---|
| 190 | hwndFrame = StartArcCnr(HWND_DESKTOP,
|
---|
| 191 | (HWND)0,
|
---|
| 192 | fullname,
|
---|
| 193 | 0,
|
---|
| 194 | NULL);
|
---|
| 195 | if(!hwndFrame) {
|
---|
| 196 |
|
---|
| 197 | CHAR *p = strrchr(fullname,'.');
|
---|
| 198 |
|
---|
| 199 | if(p) {
|
---|
| 200 | if(!stricmp(p,".INI"))
|
---|
| 201 | hwndFrame = StartIniEditor(HWND_DESKTOP,
|
---|
| 202 | fullname,
|
---|
| 203 | 0);
|
---|
| 204 | }
|
---|
| 205 | if(!ShowMultimedia(fullname))
|
---|
| 206 | hwndFrame = StartMLEEditor(HWND_DESKTOP,
|
---|
| 207 | 1,
|
---|
| 208 | ((*fullname) ?
|
---|
| 209 | fullname :
|
---|
| 210 | NULL),
|
---|
| 211 | (HWND)0);
|
---|
| 212 | }
|
---|
| 213 | if(hwndFrame && WinIsWindow(hab,hwndFrame)) {
|
---|
| 214 | if(hwndHelp)
|
---|
| 215 | WinAssociateHelpInstance(hwndHelp,hwndFrame);
|
---|
| 216 | for(;;) {
|
---|
| 217 | if(!WinGetMsg(hab,&qmsg,(HWND)0,0,0)) {
|
---|
| 218 | if(!WinIsWindow(hab,hwndFrame))
|
---|
| 219 | break;
|
---|
| 220 | if(qmsg.hwnd)
|
---|
| 221 | qmsg.msg = WM_CLOSE;
|
---|
| 222 | else
|
---|
| 223 | break;
|
---|
| 224 | }
|
---|
| 225 | if(hwndBubble &&
|
---|
| 226 | ((qmsg.msg > (WM_BUTTON1DOWN - 1) &&
|
---|
| 227 | qmsg.msg < (WM_BUTTON3DBLCLK + 1)) ||
|
---|
| 228 | (qmsg.msg > (WM_CHORD - 1) &&
|
---|
| 229 | qmsg.msg < (WM_BUTTON3CLICK + 1))) &&
|
---|
| 230 | WinIsWindowVisible(hwndBubble))
|
---|
| 231 | WinShowWindow(hwndBubble,FALSE);
|
---|
| 232 | WinDispatchMsg(hab,&qmsg);
|
---|
| 233 | }
|
---|
| 234 | DosSleep(125L);
|
---|
| 235 | }
|
---|
| 236 | }
|
---|
| 237 | }
|
---|
| 238 | }
|
---|
| 239 | }
|
---|
| 240 | Abort:
|
---|
| 241 | DosSleep(125L);
|
---|
| 242 | WinDestroyMsgQueue(hmq);
|
---|
| 243 | }
|
---|
| 244 | WinTerminate(hab);
|
---|
| 245 | }
|
---|
| 246 | return 0;
|
---|
| 247 | }
|
---|
| 248 |
|
---|