home *** CD-ROM | disk | FTP | other *** search
/ Dream 48 / Amiga_Dream_48.iso / Atari / c / libs / xaes_new.lzh / CALLBACK.C < prev    next >
C/C++ Source or Header  |  1994-12-27  |  2KB  |  82 lines

  1. /********************************************************************
  2.  *                                                                0.01*
  3.  *    XAES: Callback routine definitions                                *
  4.  *    by Ken Hollis                                                    *
  5.  *                                                                    *
  6.  *    Copyright (C) 1994, Bitgate Software.                            *
  7.  *                                                                    *
  8.  ********************************************************************/
  9.  
  10. #include <stdlib.h>
  11. #include "xaes.h"
  12.  
  13. INITS GlobInits;
  14.  
  15. /*
  16.  *    Set GLOBAL (Yes, this means PROGRAM-WIDE) callback routines for
  17.  *    initialization, and whatever the hell else I came up with
  18.  */
  19. GLOBAL void WSetCallback(int CBType, void *CallBackRout)
  20. {
  21.     switch(CBType) {
  22.         case XC_INITIALIZE:
  23.             GlobInits.Initialize = malloc(sizeof(CallBackRout));
  24.             GlobInits.Initialize = CallBackRout;
  25.             break;
  26.  
  27.         case XC_DEINITIALIZE:
  28.             GlobInits.Deinitialize = malloc(sizeof(CallBackRout));
  29.             GlobInits.Deinitialize = CallBackRout;
  30.             break;
  31.  
  32.         case XC_STARTUP:
  33.             GlobInits.Startup = malloc(sizeof(CallBackRout));
  34.             GlobInits.Startup = CallBackRout;
  35.             break;
  36.  
  37.         case XC_EXIT:
  38.             GlobInits.Exit = malloc(sizeof(CallBackRout));
  39.             GlobInits.Exit = CallBackRout;
  40.             break;
  41.     }
  42. }
  43.  
  44. /*
  45.  *    This actually CALLS the callback routine.  I thought that since
  46.  *    I made everything lazy-and-painless, I'd make this one the same.
  47.  */
  48. GLOBAL void DoCallback(int CBType)
  49. {
  50.     switch(CBType) {
  51.         case XC_INITIALIZE:
  52.             if (GlobInits.Initialize != NULL)
  53.                 GlobInits.Initialize();
  54.             break;
  55.  
  56.         case XC_DEINITIALIZE:
  57.             if (GlobInits.Deinitialize != NULL)
  58.                 GlobInits.Deinitialize();
  59.             break;
  60.  
  61.         case XC_STARTUP:
  62.             if (GlobInits.Startup != NULL)
  63.                 GlobInits.Startup();
  64.             break;
  65.  
  66.         case XC_EXIT:
  67.             if (GlobInits.Exit != NULL)
  68.                 GlobInits.Exit();
  69.             break;
  70.     }
  71. }
  72.  
  73. /*
  74.  *    Gee, I wonder what this one does.
  75.  */
  76. GLOBAL void ClearCallbacks(void)
  77. {
  78.     if (GlobInits.Initialize != NULL)    free(GlobInits.Initialize);
  79.     if (GlobInits.Deinitialize != NULL)    free(GlobInits.Deinitialize);
  80.     if (GlobInits.Startup != NULL)        free(GlobInits.Startup);
  81.     if (GlobInits.Exit != NULL)            free(GlobInits.Exit);
  82. }