home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c070 / 1.ddi / TOOLS.1 / INCLUDE / BINTERV.H < prev    next >
Encoding:
C/C++ Source or Header  |  1989-03-31  |  10.0 KB  |  236 lines

  1. /**
  2. *
  3. *  BINTERV.H   Header file for TURBO C TOOLS Intervention Functions
  4. *
  5. *  Version 6.00  (C)Copyright Blaise Computing Inc.  1987, 1989
  6. *
  7. **/
  8.  
  9. #ifndef DEF_BINTERV              /* Prevent redefinition.          */
  10.  
  11. typedef struct              /* IV_KEY:  Specifies one hot key.      */
  12. {                  /*                      */
  13.     char ch;              /* Character value.              */
  14.     char keycode;          /* Key code (pseudo-scan code).          */
  15.     int  action;          /* Action to be taken when this key is  */
  16.                   /*  detected (see possibilities below). */
  17. } IV_KEY;
  18.  
  19.                   /* Key actions                  */
  20.                   /*                      */
  21. #define IV_KY_NONE      0   /* No hot key pressed.              */
  22. #define IV_KY_SERVICE      1   /* Invoke intervention function.          */
  23. #define IV_KY_SLEEP      2   /* Put intervention function to sleep.  */
  24. #define IV_KY_WAKE      3   /* Awaken intervention function.          */
  25.  
  26. typedef struct              /* IV_TIME:  Specifies time of day or   */
  27. {                  /*  time interval for intervention code.*/
  28.                   /*                      */
  29.     long ticks;           /* Clock ticks since midnight or          */
  30.                   /*  between invocations.              */
  31.     int  action;          /* Type of time event (moment or          */
  32.                   /*  interval).                  */
  33. } IV_TIME;
  34.  
  35.                   /* Time actions                  */
  36.                   /*                      */
  37. #define IV_TM_NONE      0   /* No time event occurred.          */
  38. #define IV_TM_INTERVAL      1   /* Regular interval between invocations.*/
  39. #define IV_TM_MOMENT      2   /* Time of day.                  */
  40.  
  41. typedef struct              /* IV_EVENT:  Event that triggered the  */
  42. {                  /*  intervention function.          */
  43.                   /*                      */
  44.     IV_KEY key;           /* Hot key found, if any.           */
  45.                   /*                      */
  46.     int  time_action;          /* Type of timer event (moment or       */
  47.                   /*  interval), if any.              */
  48.     int  time_index;          /* Index of timer event in table.       */
  49.     long time;              /* Current time of day, measured in     */
  50.                   /*  clock ticks since midnight.          */
  51. } IV_EVENT;
  52.  
  53. typedef struct              /* IV_VECTORS:  set of interrupt          */
  54. {                  /*  vectors used by intervention code.  */
  55.                   /*                      */
  56.     const void far *ptimer;   /* INT 08h:  Timer tick.              */
  57.     const void far *pkeybd;   /* INT 09h:  Keystroke.              */
  58.     const void far *pdisk;    /* INT 13h:  BIOS disk services.          */
  59.     const void far *pdos;     /* INT 21h:  DOS functions.          */
  60.     const void far *pidle;    /* INT 28h:  DOS idle.              */
  61.                   /*                      */
  62.     const void far *pcom1;    /* INT 0ch:  Comm port 1 hardware event.*/
  63.     const void far *pcom2;    /* INT 0bh:  Comm port 2 hardware event.*/
  64. } IV_VECTORS;
  65.  
  66. typedef struct              /* IV_CTRL:  intervention control block */
  67. {                  /*                      */
  68.     unsigned int signature;   /* Signature identifying this structure.*/
  69.     unsigned int sign2;       /* One's complement of "signature".     */
  70.     char     ident[16];   /* Identifying name.              */
  71.     unsigned int psp;          /* PSP of this program.              */
  72.     int      enabled;     /* Nonzero if enabled (this prevents the*/
  73.                   /*  filters from being installed twice).*/
  74.     void   far    *pgate;       /* Gateway for invoking this program    */
  75.                   /*  from outside.               */
  76.     IV_VECTORS    prev_vec;     /* Previous values of interrupt vectors.*/
  77.                   /*                      */
  78.     char   dos_need;          /* Nonzero if intervention function     */
  79.                   /*  uses DOS services.              */
  80.     char   dkey_need;          /* Nonzero if intervention function     */
  81.                   /*  uses DOS functions 1-12.          */
  82.                   /*                      */
  83.     IV_KEY far *pkeytab;      /* Table of hot keys.              */
  84.     int    ktsize;          /* Size of hot key table.           */
  85.                   /*                      */
  86.     IV_KEY key_event;          /* Found key, if any.              */
  87.                   /*                      */
  88.                   /* Internal state of filters:          */
  89.                   /*                      */
  90.     char   wait;          /* Nonzero if INT 21h or INT 28h filter */
  91.                   /*  is cycling, waiting for the          */
  92.                   /*  intervention function to be invoked.*/
  93.     char   req;           /* Nonzero if intervention function     */
  94.                   /*  needs invocation.              */
  95.     char   awake;          /* Zero if intervention function is     */
  96.                   /*  asleep.                  */
  97.  
  98.                   /* Busy flags:                  */
  99.     char   timer_busy;          /*  INT 08h filter.              */
  100.     char   kb_busy;          /*  INT 09h filter.              */
  101.     char   com2_busy;          /*  INT 0bh filter.              */
  102.     char   com1_busy;          /*  INT 0ch filter.              */
  103.     char   disk_busy;          /*  INT 13h filter.              */
  104.     char   idle_busy;          /*  INT 28h filter.              */
  105.                   /*                      */
  106.     char   idle_safe;          /* Nonzero if INT 0x28 is in progress   */
  107.                   /*  and DOS functions are available     */
  108.                   /*  (but not functions 1-12).          */
  109.                   /*                      */
  110.     void   far *pschedblk;    /* Entry point into scheduler's ISR     */
  111.                   /*  control block.              */
  112.                   /*                      */
  113.     const volatile unsigned   /* Address of DOS critical section flag */
  114.      char far *pdos_crit; /*  (busy flag).                  */
  115.                   /*                      */
  116.     const void far *          /* Address of previous interrupt 0x16   */
  117.            prev_16h_vec;  /*  handler (if replaced).          */
  118.                   /*                      */
  119.     char   cbreak;          /* Nonzero if Ctrl-C or Ctrl-Break      */
  120.                   /*  detected during this invocation of  */
  121.                   /*  the intervention function.          */
  122.                   /*                      */
  123.     unsigned char no_call;    /* Nonzero if user wants to prevent     */
  124.                   /*  invocation of intervention function.*/
  125.                   /*                      */
  126.     unsigned filter_mask;     /* Bit map of installed filters.          */
  127.                   /*                      */
  128.     unsigned char kb_ext;     /* Nonzero if extended BIOS keyboard    */
  129.                   /*  services to be used.              */
  130.                   /*                      */
  131.     char   _res0;          /* Reserved for future use.          */
  132.                   /*                      */
  133.     char   _reserved[8];      /* Reserved for future use.          */
  134. } IV_CTRL;
  135.  
  136. #define IV_SIGNATURE   (('2' << 8) | 'B')   /* "B2"                   */
  137.  
  138.     /* Option values for IVINSTAL.                      */
  139.  
  140. #define IV_DOS_NEED     1    /* Intervention function uses DOS.      */
  141. #define IV_NO_DOS_NEED     0    /* Intervention function doesn't use    */
  142.                   /*  DOS.                      */
  143.  
  144. #define IV_DKEY_NEED     2    /* Intervention function uses DOS       */
  145.                   /*  functions 1-12.              */
  146. #define IV_NO_DKEY_NEED  0    /* Intervention function doesn't use    */
  147.                   /*  DOS functions 1-12.              */
  148.  
  149. #define IV_FLOAT_NEED     4    /* Intervention function uses floating  */
  150.                   /*  point interrupt vectors while other */
  151.                   /*  programs do so also.              */
  152. #define IV_NO_FLOAT_NEED 0    /*                      */
  153.  
  154. #define IV_DAILY     8    /* "Moment" events to recur daily.      */
  155.  
  156.     /* Option values for IVVECS.                      */
  157.  
  158. #define  IV_RETVEC  1          /* Return current values of interrupt   */
  159.                   /*  vectors.                  */
  160. #define  IV_SETVEC  0          /* Set interrupt vectors.           */
  161.  
  162.     /* Symbols for error codes                          */
  163.  
  164. #define  IV_NO_ERROR       0
  165. #define  IV_NOT_ENABLED    1
  166. #define  IV_NOT_INSTALLED  2
  167. #define  IV_NULL_POINTER   3
  168. #define  IV_BAD_OPT       4
  169. #define  IV_INSTALLED       5
  170. #define  IV_PART_COVERED   6
  171. #define  IV_NOT_FOUND       7
  172.  
  173.     /* Symbols for intervention filters (used for filter_mask).       */
  174.  
  175. #define  IV_F_TIMER    0x0001          /* INT 08h:  Timer tick.          */
  176. #define  IV_F_KEYSTROKE 0x0002          /* INT 09h:  Keystroke.          */
  177. #define  IV_F_DISK    0x0004          /* INT 13h:  BIOS disk services.*/
  178. #define  IV_F_DOS    0x0008          /* INT 21h:  DOS functions.     */
  179. #define  IV_F_IDLE    0x0010          /* INT 28h:  DOS idle.          */
  180. #define  IV_F_2COM    0x0020          /* INT 0ch:  Comm port 1          */
  181. #define  IV_F_1COM    0x0040          /* INT 0bh:  Comm port 2          */
  182.  
  183. #define  IV_STD_FILTERS                         \
  184.     (IV_F_TIMER | IV_F_KEYSTROKE | IV_F_DISK | IV_F_DOS | IV_F_IDLE)
  185. #define  IV_COM_FILTERS   (IV_F_2COM | IV_F_1COM)
  186.  
  187.     /* Internal symbols                           */
  188.  
  189. #define  IV_RESCHED    0x40000000L   /* Mask for rescheduling          */
  190.                       /*  "moment" events.            */
  191.  
  192.     /* Global variables.                          */
  193.  
  194. extern int b_ivusex;              /* Whether to use extended      */
  195.                       /*  keyboard services when      */
  196.                       /*  testing for hot keys:       */
  197.                       /*  KB_USE_EXTEND or          */
  198.                       /*  KB_USE_NORMAL.          */
  199.  
  200. extern unsigned b_ivmask;          /* Mask indicating which          */
  201.                       /* intervention filters to use. */
  202.  
  203.     /* Function declarations                          */
  204.  
  205.                       /* Install intervention function*/
  206. int cdecl ivinstal(void (*)(IV_EVENT *),
  207.            const char *,      /*                  */
  208.            char *,int,          /*                  */
  209.            IV_KEY *,int,      /*                  */
  210.            IV_TIME *,int,     /*                  */
  211.            int);          /*                  */
  212.                       /*                  */
  213. int cdecl ivdetect(              /* Detect presence of possibly  */
  214.     const IV_VECTORS far *,          /* obscured intervention          */
  215.     const char far *,              /* function.              */
  216.     IV_CTRL far **,unsigned far *);   /*                  */
  217.                       /*                  */
  218. IV_CTRL far * cdecl ivsense(          /* Detect presence of removable */
  219.     const IV_VECTORS far *,          /* intervention function.       */
  220.     const char far *);              /*                  */
  221.                       /*                  */
  222. int cdecl ivdisabl(IV_CTRL far *);    /* Disable intervention function*/
  223.                       /*                  */
  224. int cdecl ivvecs(int,              /* Set or return interrupt      */
  225.          IV_VECTORS far *);   /* vectors used by the          */
  226.                       /* intervention filters.          */
  227.                       /*                  */
  228. IV_CTRL far * cdecl ivctrl(void);     /* Return address of this       */
  229.                       /* program's intervention       */
  230.                       /* control block.           */
  231.  
  232. #define DEF_BINTERV     1          /* Prevent second reading of    */
  233.                       /* these definitions.          */
  234.  
  235. #endif                      /* Ends "#ifndef DEF_BINTERV"   */
  236.