home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 11 Util / 11-Util.zip / TIMEXSRC.ZIP / UA_MAIN.C < prev    next >
C/C++ Source or Header  |  1990-03-29  |  3KB  |  114 lines

  1. /* ua_main.c -- Main routine of the TIMEX user agent
  2.  
  3.     February 1990    Mark E. Mallett, Personal Workstation Magazine
  4.  
  5. This is the main module of TIMEXUA, the TIMEX user agent
  6.  
  7. Included are the following routines:
  8.  
  9.     main        Main routine
  10.  
  11. */
  12.  
  13. #define    INCL_WIN
  14.  
  15. #include <stdio.h>
  16. #include <os2.h>
  17.  
  18. #include "errhand.h"
  19. #include "timex.h"
  20. #include "ua_timex.h"
  21. #include "ua_pm.h"
  22.  
  23.  
  24. /* Local definitions */
  25.  
  26.  
  27. /* External data referenced */
  28.  
  29. extern  HWND    CurwinH;        /* Currently active window */
  30. extern    HWND    EvlistH;    /* Event list window handle */
  31. extern    HWND    MainwinH;    /* Main window handle */
  32. extern  ERRLIST *Werdisp;       /* Wild-all error intercept list */
  33.  
  34. /* External routines used */
  35.  
  36. extern  void                    err_report( int code, char *msgP );
  37. extern  void                    get_events( void );
  38. extern  MRESULT EXPENTRY        main_winproc();
  39.  
  40.  
  41. /* Local data publicly available */
  42.  
  43.  
  44. /* Local routines and forward declarations */
  45.  
  46. static  int     main1( void );          /* First continuation of main() */
  47.  
  48. /* Private data */
  49.  
  50. static  int     ArgC;                   /* Copy of argc */
  51. static  char    **ArgV;                 /* Copy of argv */
  52.  
  53. main(
  54.     int        argc,        /* Argument count */
  55.     char        **argv        /* Argument vector */
  56. ) {
  57.  
  58.     /* Save the command line arg vector parms */
  59.     ArgC = argc;
  60.     ArgV = argv;
  61.  
  62.     /* Create a universal warning interception list */
  63.     Werdisp = condition_list( 0, CTINTCEPT );
  64.     any_condition( Werdisp, TRUE, err_report );
  65.  
  66.     /* Activate the list and continue to main1() */
  67.     intercept_error( main1, (void *)NULL, Werdisp );
  68.  
  69.     return( 0 );
  70. }
  71.  
  72. static int
  73. main1( void ) {
  74.  
  75.     HAB        ab;        /* Application anchor block */
  76.     HMQ        mq;        /* Message queue */
  77.     QMSG        qmsg;        /* Message from event queue */
  78.  
  79.     /* Init the application */
  80.     ab = WinInitialize( 0 );
  81.     mq = WinCreateMsgQueue( ab, 0 );
  82.  
  83.     /* Create the window classes used */
  84.     WinRegisterClass( ab, WCMAIN, main_winproc, 0L, 0 );
  85. /*    WinRegisterClass( ab, WCEVENT, event_winproc, 0L, 0 ); */
  86.  
  87.     /* Load and init the main window */
  88.     MainwinH = WinLoadDlg( HWND_DESKTOP, HWND_DESKTOP, NULL, NULL,
  89.                 WID_MAIN, NULL );
  90.  
  91.     /* Because of problems generalizing an error window interface,
  92.        which must MANUALLY be attached to the current window (ugh),
  93.        and because it's not possible to get OS2 to tell you what that
  94.        current window IS, we keep track of the current major dialog
  95.        window in a global location.  ugh. */
  96.     CurwinH = MainwinH;
  97.  
  98.     /* Give it input focus since we just started */
  99.     WinSetFocus( HWND_DESKTOP, WinWindowFromID( MainwinH, FID_CLIENT ) );
  100.  
  101.     /* Fetch the list of events from the background agent */
  102.     get_events();
  103.  
  104.     /* Loop processing events */
  105.     while( WinGetMsg( ab, &qmsg, NULL, 0, 0 ) )
  106.     WinDispatchMsg( ab, &qmsg );
  107.  
  108.     /* All done */
  109.     WinDestroyWindow( MainwinH );
  110.     WinDestroyMsgQueue( mq );
  111.     WinTerminate( ab );
  112.     return( 0 );
  113. }
  114.