| 1 |
|
|---|
| 2 | /***********************************************************************
|
|---|
| 3 |
|
|---|
| 4 | $Id: eas.c 1341 2008-12-14 22:18:26Z stevenhl $
|
|---|
| 5 |
|
|---|
| 6 | EA viewer applet
|
|---|
| 7 |
|
|---|
| 8 | Copyright (c) 1993-98 M. Kimes
|
|---|
| 9 | Copyright (c) 2002, 2008 Steven H.Levine
|
|---|
| 10 |
|
|---|
| 11 | 16 Oct 02 SHL Reformat
|
|---|
| 12 | 08 Feb 03 SHL Free list with free() since we don't
|
|---|
| 13 | allocate list contents
|
|---|
| 14 | 08 Apr 07 SHL Minor reformat
|
|---|
| 15 | 10 May 08 SHL Correct compare typo
|
|---|
| 16 | 14 Dec 08 SHL Add exception handler support
|
|---|
| 17 |
|
|---|
| 18 | ***********************************************************************/
|
|---|
| 19 |
|
|---|
| 20 | #include <string.h>
|
|---|
| 21 |
|
|---|
| 22 | #define INCL_DOS
|
|---|
| 23 | #define INCL_WIN
|
|---|
| 24 | #define INCL_DOSEXCEPTIONS // XCTP_...
|
|---|
| 25 | #define INCL_DOSERRORS // NO_ERROR
|
|---|
| 26 |
|
|---|
| 27 | #include "dll\fm3dll.h"
|
|---|
| 28 | #include "dll\mainwnd.h" // FM3ModHandle
|
|---|
| 29 | #include "dll\fm3dlg.h"
|
|---|
| 30 | #include "dll\makelist.h" // AddToList
|
|---|
| 31 | #include "dll\eas.h" // DisplayEAsProc
|
|---|
| 32 | #include "dll\init.h" // InitFM3DLL
|
|---|
| 33 | #include "dll\valid.h" // IsFile
|
|---|
| 34 | #include "dll\wrappers.h" // xfree
|
|---|
| 35 | #include "dll\getnames.h" // insert_filename
|
|---|
| 36 | #include "dll\errutil.h" // Error reporting
|
|---|
| 37 | #include "dll\excputil.h" // Exception handlers
|
|---|
| 38 |
|
|---|
| 39 | static PSZ pszSrcFile = __FILE__;
|
|---|
| 40 |
|
|---|
| 41 | int main (int argc,char *argv[])
|
|---|
| 42 | {
|
|---|
| 43 | HAB hab;
|
|---|
| 44 | HMQ hmq;
|
|---|
| 45 | CHAR fullname[CCHMAXPATH];
|
|---|
| 46 | CHAR **list = NULL;
|
|---|
| 47 | UINT x;
|
|---|
| 48 | UINT numfiles = 0;
|
|---|
| 49 | UINT numalloc = 0;
|
|---|
| 50 | APIRET regRet;
|
|---|
| 51 | EXCEPTIONREGISTRATIONRECORD regRec = { NULL, NULL };
|
|---|
| 52 |
|
|---|
| 53 | DosError(FERR_DISABLEHARDERR);
|
|---|
| 54 |
|
|---|
| 55 | regRec.ExceptionHandler = HandleException;
|
|---|
| 56 | regRet = DosSetExceptionHandler(®Rec);
|
|---|
| 57 | if (regRet != NO_ERROR) {
|
|---|
| 58 | DbgMsg(pszSrcFile, __LINE__,
|
|---|
| 59 | "DosSetExceptionHandler failed with error %u", regRet);
|
|---|
| 60 | }
|
|---|
| 61 |
|
|---|
| 62 | for(x = 1; x < argc; x++) {
|
|---|
| 63 | if (!strchr("/;,`\'",*argv[x]) && IsFile(argv[x]) != -1) {
|
|---|
| 64 | if (DosQueryPathInfo(argv[x],
|
|---|
| 65 | FIL_QUERYFULLNAME,fullname,
|
|---|
| 66 | sizeof(fullname)))
|
|---|
| 67 | strcpy(fullname, argv[x]);
|
|---|
| 68 | AddToList(fullname,&list,&numfiles,&numalloc);
|
|---|
| 69 | }
|
|---|
| 70 | }
|
|---|
| 71 |
|
|---|
| 72 | hab = WinInitialize(0);
|
|---|
| 73 | if (hab) {
|
|---|
| 74 | hmq = WinCreateMsgQueue(hab,384);
|
|---|
| 75 | if (hmq) {
|
|---|
| 76 | if (InitFM3DLL(hab,argc,argv)) {
|
|---|
| 77 | if (!list) {
|
|---|
| 78 | strcpy(fullname, "*");
|
|---|
| 79 | list = xmalloc(sizeof(CHAR *) * 2, pszSrcFile, __LINE__);
|
|---|
| 80 | if (list &&
|
|---|
| 81 | insert_filename(HWND_DESKTOP,fullname,TRUE,FALSE) &&
|
|---|
| 82 | *fullname && *fullname != '*') {
|
|---|
| 83 | list[0] = fullname;
|
|---|
| 84 | list[1] = NULL;
|
|---|
| 85 | }
|
|---|
| 86 | }
|
|---|
| 87 | if (list) {
|
|---|
| 88 | WinDlgBox(HWND_DESKTOP,
|
|---|
| 89 | HWND_DESKTOP,
|
|---|
| 90 | DisplayEAsProc,
|
|---|
| 91 | FM3ModHandle,
|
|---|
| 92 | EA_FRAME,
|
|---|
| 93 | (PVOID)list);
|
|---|
| 94 | }
|
|---|
| 95 | }
|
|---|
| 96 | WinDestroyMsgQueue(hmq);
|
|---|
| 97 | }
|
|---|
| 98 | WinTerminate(hab);
|
|---|
| 99 | }
|
|---|
| 100 | xfree(list, pszSrcFile, __LINE__);
|
|---|
| 101 | return 0;
|
|---|
| 102 | }
|
|---|
| 103 |
|
|---|