home *** CD-ROM | disk | FTP | other *** search
/ Garbo / Garbo.cdr / mac / comm / revrdist.sit / RevRdist / headers / dispatch.h next >
Encoding:
C/C++ Source or Header  |  1989-10-28  |  1.6 KB  |  67 lines  |  [TEXT/KAHL]

  1. /*
  2.  * dispatch.h - structures and values associated with routine dispatcher
  3.  */
  4.  
  5. #include <C_config.h>
  6.  
  7. typedef    short        (*dispProcPtr)();
  8.  
  9. struct    frame
  10. {
  11.     struct    frame    **link;            /* link to (suspended) caller frame */
  12.     dispProcPtr        proc;            /* routine */
  13.     short            state;            /* routine state variable */
  14.     /*
  15.      * Each routine embeds this structure in a larger structure private
  16.      * to itself
  17.      */
  18. };
  19. typedef    struct frame    frame_t;
  20. typedef    frame_t            *framePtr;
  21. typedef    framePtr        *frameHdl;
  22.  
  23. /*
  24.  * Routine request options, which are also used as return values
  25.  */
  26. enum
  27. {
  28.      R_CONT                        /* continue per state variable */
  29.     ,R_INIT                        /* initial call to routine at this stack
  30.                                   * level */
  31.     ,R_BACKOUT                    /* routine should do whatever is necessary
  32.                                  * to cleanly abandon what it is doing */
  33.     ,R_QUIT                        /* application is terminating. */
  34. };
  35. #define    R_ERROR        R_INIT        /* when used as return value */
  36.  
  37. /*
  38.  * Macro to declare routines called via dispatch ()
  39.  */
  40.  
  41. #define    DISPATCHED(func_name) \
  42. short func_name (fh, request, argv) \
  43.     frameHdl fh; \
  44.     short request; \
  45.     Ptr *argv;
  46.  
  47. #define DISPATCHPROTO(func_name) \
  48. extern short func_name (frameHdl, short, Ptr *)
  49.  
  50. /*
  51.  * prototypes for dispatcher related functions
  52.  */
  53.  
  54. extern void            dispatch (void);
  55. extern Integer        popCall (short, Ptr *);
  56. extern Integer        pushCall (dispProcPtr, Ptr *);
  57. extern OSErr        resizeFrame (frameHdl, Size);
  58.  
  59. /*
  60.  * prototypes for the dispatched routines
  61.  */
  62. DISPATCHPROTO (cleanJunk);
  63. DISPATCHPROTO (copyFile);
  64. DISPATCHPROTO (emptyFolder);
  65. DISPATCHPROTO (idle);
  66. DISPATCHPROTO (matchFolder);
  67. DISPATCHPROTO (parseDistFile);