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

  1. /* ua_misc.c -- Miscellaneous routines for TIMEXUA
  2.  
  3.     February 1990    Mark E. Mallett, Personal Workstation Magazine
  4.  
  5. This file contains miscellaneous routines for TIMEXUA, including:
  6.  
  7.         err_report      Error report routine for errhand stuff
  8.     get_events    Get list of events from TIMEXBA
  9.  
  10. */
  11.  
  12. #define    INCL_WIN
  13.  
  14. #include <stdio.h>
  15. #include <string.h>
  16. #include <malloc.h>
  17. #include <os2.h>
  18.  
  19. #include "timex.h"
  20. #include "ua_timex.h"
  21. #include "ua_pm.h"
  22. #include "ua_baif.h"
  23.  
  24. /* Local definitions */
  25.  
  26.  
  27. /* External data referenced */
  28.  
  29. extern  HWND    CurwinH;                /* Keeps track of current win */
  30. extern    HWND    EvlistH;        /* Event list handle */
  31. extern    HWND    MainwinH;        /* Main window handle */
  32.  
  33. /* External routines used */
  34.  
  35.  
  36. /* Local data publicly available */
  37.  
  38.  
  39. /* Local routines and forward declarations */
  40.  
  41.  
  42.  
  43. /* Private data */
  44.  
  45. /*
  46.  
  47.  
  48. *//* get_events()
  49.  
  50.     Get events from the background server
  51.  
  52. Accepts :
  53.  
  54.  
  55. Returns :
  56.  
  57.  
  58. */
  59.  
  60. void
  61. get_events( void )
  62. {
  63.         EVENT           *eventP;        /* Ptr to an event */
  64.         char            evname[100];    /* "Current" event name */
  65.  
  66.  
  67.     /* Init to first event */
  68.     evname[0] = '\0';
  69.  
  70.     /* Clear the list box */
  71.     WinSendMsg( EvlistH, LM_DELETEALL, NULL, NULL );
  72.  
  73.     /* Get events from the background agent */
  74.     for( ; ; ) {
  75.         eventP = ba_getnext( &evname[0] );
  76.         if( eventP == NULL )
  77.             break;
  78.  
  79.         /* Add the event name to the list box */
  80.         WinSendMsg( EvlistH, LM_INSERTITEM,
  81.             MPFROM2SHORT( LIT_SORTASCENDING, 0 ),
  82.                         MPFROMP( eventP->ev_nameP ) );
  83.  
  84.         /* Remember last name for next "get" */
  85.         strcpy( &evname[0], eventP->ev_nameP );
  86.  
  87.         /* Delete event */
  88.         free( eventP );
  89.     }
  90. }
  91. /*
  92.  
  93. *//* err_report( cond, msgP )
  94.  
  95.         Print an error message on behalf of intercept_error.
  96.  
  97. Accepts :
  98.  
  99.         code            Error code reported
  100.         msgP            Error message given.
  101.  
  102. Returns :
  103.  
  104.         0
  105.  
  106. */
  107.  
  108. void
  109. err_report(
  110.         int             code,           /* Error code */
  111.         char            *msgP           /* Message text */
  112.           ) {
  113.  
  114.         HWND            fwinH;          /* Handle of window w/ focus */
  115.  
  116.  
  117.     fprintf( stderr, "timex(%d): %s\n", code, msgP );
  118.  
  119. #if     0
  120.  
  121.     /* This seemed like a reasonable approach according to the
  122.        docs, but the function doesn't exist in the library... */
  123.     fwinH = WinQueryFocus( HWND_DESKTOP, FALSE );
  124. #else
  125.     /* So we have to clumsily keep track of the current window. */
  126.     fwinH = CurwinH;
  127. #endif
  128.  
  129.     WinMessageBox( fwinH, fwinH, msgP, "Warning", 0,
  130.                         MB_OK | MB_ICONASTERISK | MB_APPLMODAL );
  131. }
  132.  
  133.