| [907] | 1 | 
 | 
|---|
 | 2 | /***********************************************************************
 | 
|---|
 | 3 | 
 | 
|---|
 | 4 |   $Id: fm3.c 1215 2008-09-13 06:54:03Z jbs $
 | 
|---|
 | 5 | 
 | 
|---|
 | 6 |   fm/2 starter
 | 
|---|
 | 7 | 
 | 
|---|
 | 8 |   Copyright (c) 1993-98 M. Kimes
 | 
|---|
 | 9 |   Copyright (c) 2008 Steven H.Levine
 | 
|---|
 | 10 | 
 | 
|---|
 | 11 |   05 Jan 08 SHL Sync
 | 
|---|
| [1077] | 12 |   18 Jul 08 SHL Add Fortify support
 | 
|---|
| [907] | 13 | 
 | 
|---|
 | 14 | ***********************************************************************/
 | 
|---|
 | 15 | 
 | 
|---|
 | 16 | #include <string.h>
 | 
|---|
 | 17 | 
 | 
|---|
| [2] | 18 | #define INCL_DOS
 | 
|---|
 | 19 | #define INCL_WIN
 | 
|---|
| [907] | 20 | #define INCL_LONGLONG
 | 
|---|
| [2] | 21 | 
 | 
|---|
| [1215] | 22 | #include "dll\fm3dll.h"
 | 
|---|
 | 23 | #include "dll\mainwnd.h"                        // Data declaration(s)
 | 
|---|
| [2] | 24 | #include "dll\tools.h"
 | 
|---|
 | 25 | #include "dll\version.h"
 | 
|---|
| [1078] | 26 | #include "dll\errutil.h"
 | 
|---|
| [1077] | 27 | #include "dll\fortify.h"
 | 
|---|
| [1164] | 28 | #include "dll\init.h"                   // StartFM3
 | 
|---|
| [1215] | 29 | #include "dll\notebook.h"               // Data declaration(s)
 | 
|---|
| [2] | 30 | 
 | 
|---|
| [551] | 31 | int main(int argc, char *argv[])
 | 
|---|
 | 32 | {
 | 
|---|
 | 33 |   HAB hab;
 | 
|---|
 | 34 |   HMQ hmq;
 | 
|---|
 | 35 |   QMSG qmsg;
 | 
|---|
 | 36 |   HWND hwndFrame;
 | 
|---|
| [2] | 37 | 
 | 
|---|
| [551] | 38 |   strcpy(appname, "FM/3");
 | 
|---|
| [2] | 39 |   DosError(FERR_DISABLEHARDERR);
 | 
|---|
 | 40 |   hab = WinInitialize(0);
 | 
|---|
| [551] | 41 |   if (hab) {
 | 
|---|
 | 42 |     hmq = WinCreateMsgQueue(hab, 2048);
 | 
|---|
 | 43 |     if (hmq) {
 | 
|---|
 | 44 |       if (InitFM3DLL(hab, argc, argv)) {
 | 
|---|
 | 45 |         if (CheckVersion(VERMAJOR, VERMINOR)) {
 | 
|---|
| [1077] | 46 | #         ifdef FORTIFY
 | 
|---|
 | 47 |           Fortify_EnterScope();
 | 
|---|
 | 48 | #         endif
 | 
|---|
| [551] | 49 |           hwndFrame = StartFM3(hab, argc, argv);
 | 
|---|
 | 50 |           if (hwndFrame != (HWND) 0) {
 | 
|---|
 | 51 |             for (;;) {
 | 
|---|
 | 52 |               if (!WinGetMsg(hab, &qmsg, (HWND) 0, 0, 0)) {
 | 
|---|
 | 53 |                 if (qmsg.hwnd)
 | 
|---|
 | 54 |                   qmsg.msg = WM_CLOSE;
 | 
|---|
 | 55 |                 else
 | 
|---|
 | 56 |                   break;
 | 
|---|
 | 57 |               }
 | 
|---|
 | 58 |               if (hwndBubble &&
 | 
|---|
 | 59 |                   ((qmsg.msg > (WM_BUTTON1DOWN - 1) &&
 | 
|---|
 | 60 |                     qmsg.msg < (WM_BUTTON3DBLCLK + 1)) ||
 | 
|---|
 | 61 |                    (qmsg.msg > (WM_CHORD - 1) &&
 | 
|---|
 | 62 |                     qmsg.msg < (WM_BUTTON3CLICK + 1))) &&
 | 
|---|
 | 63 |                   WinIsWindowVisible(hwndBubble))
 | 
|---|
 | 64 |                 WinShowWindow(hwndBubble, FALSE);
 | 
|---|
 | 65 |               WinDispatchMsg(hab, &qmsg);
 | 
|---|
 | 66 |             }
 | 
|---|
 | 67 |             if (WinIsWindow(hab, WinWindowFromID(hwndFrame, FID_CLIENT)))
 | 
|---|
 | 68 |               WinSendMsg(WinWindowFromID(hwndFrame, FID_CLIENT), WM_CLOSE,
 | 
|---|
 | 69 |                          MPVOID, MPVOID);
 | 
|---|
 | 70 |           }
 | 
|---|
| [1077] | 71 | #         ifdef FORTIFY
 | 
|---|
| [1078] | 72 |           for (;;) {
 | 
|---|
 | 73 |             UCHAR scope = Fortify_LeaveScope();
 | 
|---|
 | 74 |             if ((CHAR)scope == 0)
 | 
|---|
 | 75 |               break;
 | 
|---|
 | 76 |             Runtime_Error(__FILE__, __LINE__, "Attempting to exit thread with scope non-zero (%u)", scope);
 | 
|---|
 | 77 |             if ((CHAR)scope < 0)
 | 
|---|
 | 78 |               break;
 | 
|---|
 | 79 |           }
 | 
|---|
| [1077] | 80 | #         endif
 | 
|---|
| [551] | 81 |         }
 | 
|---|
| [2] | 82 |       }
 | 
|---|
 | 83 |       DosSleep(250L);
 | 
|---|
 | 84 |       WinDestroyMsgQueue(hmq);
 | 
|---|
 | 85 |     }
 | 
|---|
 | 86 |     WinTerminate(hab);
 | 
|---|
 | 87 |   }
 | 
|---|
 | 88 |   return 0;
 | 
|---|
 | 89 | }
 | 
|---|