source: trunk/av2.c@ 1203

Last change on this file since 1203 was 1203, checked in by John Small, 17 years ago

Ticket 187: Move datadevlarations/definitions out of fm3dll.h

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.8 KB
RevLine 
[2]1
[873]2/***********************************************************************
3
4 $Id: av2.c 1203 2008-09-13 06:46:02Z jbs $
5
6 Archive viewer applet
7
8 Copyright (c) 1993-98 M. Kimes
[1082]9 Copyright (c) 2007, 2008 Steven H. Levine
[873]10
11 23 Sep 07 SHL Sync with standards
12 23 Sep 07 SHL Get rid of statics
13
14***********************************************************************/
15
[2]16#include <stdlib.h>
17#include <string.h>
[873]18
19#define INCL_DOS
20#define INCL_WIN
[907]21#define INCL_LONGLONG
[873]22
[1176]23#include "dll\fm3dll.h"
[1203]24#include "dll\mainwnd.h" // Data declaration(s)
25#include "dll\init.h" // Data declaration(s)
26#include "dll\notebook.h" // Data declaration(s)
27#include "dll\arccnrs.h"
[1176]28#include "dll\fm3str.h"
[2]29#include "dll\version.h"
[907]30#include "dll\arccnrs.h"
[1155]31#include "dll\assoc.h" // ExecAssociation
32#include "dll\defview.h" // ShowMultimedia
33#include "dll\inis.h" // StartIniEditor
34#include "dll\dirs.h" // switch_to
[1176]35#include "dll\viewer.h" // StartMLEEditor
36#include "dll\getnames.h" // insert_filename
37#include "dll\copyf.h" // unlinkf
38#include "dll\init.h" // InitFM3DLL
39#include "dll\valid.h" // IsFile
[2]40
41HMTX av2Sem;
42
[551]43VOID APIENTRY deinit(ULONG why)
44{
[873]45 /* cleanup before exiting */
[2]46
47 DosCloseMutexSem(av2Sem);
[551]48 if (DosOpenMutexSem("\\SEM32\\AV2", &av2Sem)) {
[873]49 CHAR s[CCHMAXPATH]; // 23 Sep 07 SHL
[551]50 CHAR *enddir;
51 HDIR search_handle;
52 ULONG num_matches;
[873]53 FILEFINDBUF3 ffb3;
[2]54
55 save_dir(s);
[551]56 if (s[strlen(s) - 1] != '\\')
57 strcat(s, "\\");
[2]58 enddir = &s[strlen(s)];
[551]59 if (*ArcTempRoot) {
60 strcat(s, ArcTempRoot);
61 strcat(s, "*");
[2]62 search_handle = HDIR_CREATE;
[841]63 num_matches = 1;
[844]64 if (!DosFindFirst(s,
[551]65 &search_handle,
[873]66 FILE_NORMAL | FILE_DIRECTORY | FILE_SYSTEM |
67 FILE_READONLY | FILE_HIDDEN | FILE_ARCHIVED,
68 &ffb3,
69 sizeof(ffb3),
70 &num_matches,
71 FIL_STANDARD)) {
[551]72 do {
[873]73 strcpy(enddir, ffb3.achName);
74 if (ffb3.attrFile & FILE_DIRECTORY) {
[551]75 wipeallf("%s\\*", s);
76 DosDeleteDir(s);
77 }
78 else
79 unlinkf("%s", s);
[844]80 } while (!DosFindNext(search_handle,
[873]81 &ffb3, sizeof(FILEFINDBUF3), &num_matches));
[551]82 DosFindClose(search_handle);
[2]83 }
84 }
85 }
86 else
87 DosCloseMutexSem(av2Sem);
88
[551]89 DosExitList(EXLST_REMOVE, deinit);
[2]90}
91
[551]92int main(int argc, char *argv[])
93{
94 HAB hab;
95 HMQ hmq;
96 QMSG qmsg;
97 HWND hwndFrame = (HWND) 0;
[873]98 static CHAR fullname[CCHMAXPATH]; // 23 Sep 07 SHL fixme to not be static
[551]99 CHAR *thisarg = NULL;
100 INT x;
[2]101
102 *fullname = 0;
[551]103 strcpy(appname, "AV/2");
[2]104 fAmAV2 = TRUE;
105 DosError(FERR_DISABLEHARDERR);
[551]106 for (x = 1; x < argc; x++) {
107 if (!strchr("/;,`\'", *argv[x]) &&
108 !thisarg &&
109 (IsFile(argv[x]) == 1 ||
110 (strchr(argv[x], '?') || strchr(argv[x], '*') ||
111 !strchr(argv[x], '.')))) {
[2]112 thisarg = argv[x];
113 break;
114 }
115 }
[551]116 DosExitList(EXLST_ADD, deinit);
117 if (DosOpenMutexSem("\\SEM32\\AV2", &av2Sem))
118 DosCreateMutexSem("\\SEM32\\AV2", &av2Sem, DC_SEM_SHARED, FALSE);
119 if (thisarg) {
120 if (DosQueryPathInfo(thisarg,
121 FIL_QUERYFULLNAME, fullname, sizeof(fullname)))
122 strcpy(fullname, thisarg);
123 if (*fullname && (strchr(fullname, '?') ||
124 strchr(fullname, '*') || !strchr(fullname, '.'))) {
[2]125
[873]126 FILEFINDBUF3 ffb3;
[551]127 ULONG nm;
128 HDIR hdir;
129 CHAR *enddir;
[2]130
[551]131 if (!strchr(fullname, '.'))
132 strcat(fullname, ".*");
133 enddir = strrchr(fullname, '\\');
134 if (enddir) {
135 enddir++;
136 hdir = HDIR_CREATE;
[841]137 nm = 1;
[844]138 if (!DosFindFirst(fullname,
[551]139 &hdir,
140 FILE_NORMAL | FILE_SYSTEM |
141 FILE_READONLY | FILE_HIDDEN | FILE_ARCHIVED,
[873]142 &ffb3, sizeof(FILEFINDBUF3), &nm, FIL_STANDARD)) {
143 strcpy(enddir, ffb3.achName);
[551]144 DosFindClose(hdir);
145 }
[2]146 }
147 }
148 }
149 hab = WinInitialize(0);
[551]150 if (hab) {
151 hmq = WinCreateMsgQueue(hab, 1024);
152 if (hmq) {
[2]153 {
[873]154 CHAR path[CCHMAXPATH];
[551]155 CHAR *env;
[844]156 FILESTATUS3 fs;
[2]157
[551]158 env = getenv("FM3INI");
159 if (env && *env) {
160 DosError(FERR_DISABLEHARDERR);
161 if (!DosQueryPathInfo(env, FIL_QUERYFULLNAME, path, sizeof(path))) {
162 DosError(FERR_DISABLEHARDERR);
[873]163 if (!DosQueryPathInfo(path, FIL_STANDARD, &fs, sizeof(fs))) {
[551]164 if (!(fs.attrFile & FILE_DIRECTORY)) {
165 env = strrchr(path, '\\');
166 if (env)
167 *env = 0;
168 }
169 DosError(FERR_DISABLEHARDERR);
[873]170 if (!DosQueryPathInfo(path, FIL_STANDARD, &fs, sizeof(fs))) {
[551]171 if (fs.attrFile & FILE_DIRECTORY)
172 switch_to(path);
173 }
174 }
175 }
176 }
[2]177 }
[551]178 if (InitFM3DLL(hab, argc, argv)) {
179 if (CheckVersion(VERMAJOR, VERMINOR)) {
180 fAmAV2 = TRUE;
181 if (!*fullname) {
182 strcpy(fullname, "*");
183 if (!insert_filename(HWND_DESKTOP,
184 fullname,
185 TRUE,
186 FALSE) || !*fullname || *fullname == '*')
187 goto Abort;
188 }
189 if (*fullname) {
190 if (ExecAssociation(HWND_DESKTOP, fullname) == -1) {
191 hwndFrame = StartArcCnr(HWND_DESKTOP,
192 (HWND) 0, fullname, 0, NULL);
193 if (!hwndFrame) {
[2]194
[551]195 CHAR *p = strrchr(fullname, '.');
[2]196
[551]197 if (p) {
198 if (!stricmp(p, ".INI"))
199 hwndFrame = StartIniEditor(HWND_DESKTOP, fullname, 0);
200 }
201 if (!ShowMultimedia(fullname))
202 hwndFrame = StartMLEEditor(HWND_DESKTOP,
203 1,
204 ((*fullname) ?
205 fullname : NULL), (HWND) 0);
206 }
207 if (hwndFrame && WinIsWindow(hab, hwndFrame)) {
208 if (hwndHelp)
209 WinAssociateHelpInstance(hwndHelp, hwndFrame);
210 for (;;) {
211 if (!WinGetMsg(hab, &qmsg, (HWND) 0, 0, 0)) {
212 if (!WinIsWindow(hab, hwndFrame))
213 break;
214 if (qmsg.hwnd)
215 qmsg.msg = WM_CLOSE;
216 else
217 break;
218 }
219 if (hwndBubble &&
220 ((qmsg.msg > (WM_BUTTON1DOWN - 1) &&
221 qmsg.msg < (WM_BUTTON3DBLCLK + 1)) ||
222 (qmsg.msg > (WM_CHORD - 1) &&
223 qmsg.msg < (WM_BUTTON3CLICK + 1))) &&
224 WinIsWindowVisible(hwndBubble))
225 WinShowWindow(hwndBubble, FALSE);
226 WinDispatchMsg(hab, &qmsg);
227 }
[844]228 DosSleep(125);
[551]229 }
230 }
231 }
232 }
[2]233 }
[551]234 Abort:
[844]235 DosSleep(125);
[2]236 WinDestroyMsgQueue(hmq);
237 }
238 WinTerminate(hab);
239 }
240 return 0;
241}
Note: See TracBrowser for help on using the repository browser.