home *** CD-ROM | disk | FTP | other *** search
/ Best Objectech Shareware Selections / UNTITLED.iso / boss / word / text / 001 / api.c next >
Encoding:
C/C++ Source or Header  |  1990-04-12  |  6.0 KB  |  185 lines

  1. /******************************************************************************/
  2. /* E! API management functions                                                */
  3. /******************************************************************************/
  4.  
  5. #include <dos.h>
  6. #include <stdio.h>
  7. #include "api.h"
  8.  
  9. /******************************************************************************/
  10. /*  This global variable is initialized to the default value used by E! to    */
  11. /*  install the API interrupt handler. This value may be changed dynamical-   */
  12. /*  ly using a Profile. So the API program must also change the interrupt     */
  13. /*  number.                                                                   */
  14. /******************************************************************************/
  15. int E_Vec = 0xC0;
  16.  
  17. /**************************************************/
  18. /* Call E! function #funcno and return error code */
  19. /**************************************************/
  20. char   Call_E_Function ( unsigned funcno )
  21.  
  22. {
  23.  union REGS regs;
  24.  
  25.   regs.h.ah = 0;
  26.   regs.x.bx = funcno;
  27.   int86(E_Vec, ®s, ®s);
  28.   return ( regs.h.al );
  29. }
  30.  
  31. /******************************************************************************/
  32. /*       Returns a FAR pointer to the requested variables block               */
  33. /******************************************************************************/
  34. void far *Request_E_Address ( char request_name )
  35.  
  36. {
  37.  union  REGS  regs;
  38.  struct SREGS sregs;
  39.  
  40.  if ((request_name < 1) || (request_name > 7))
  41.     return (NULL);
  42.   regs.h.ah = request_name;
  43.   int86x(E_Vec, ®s, ®s, &sregs);
  44.   return ( MK_FP (sregs.es, regs.x.bx) );
  45. }
  46.  
  47. /******************************************************************************/
  48. /*              Loads status members with appropriate values                  */
  49. /******************************************************************************/
  50. void   Get_E_Status ( STATUSRECORD *status)
  51.  
  52. {
  53.  union REGS regs;
  54.  
  55.  regs.h.ah = STATUS_REQUEST;
  56.  int86(E_Vec, ®s, ®s);
  57.  status->linenum = regs.x.cx;
  58.  status->line    = regs.x.dx;
  59.  status->col     = regs.h.ah;
  60.  status->firstcol= regs.h.al;
  61.  status->lower   = regs.h.bh;
  62.  status->nbwin   = regs.h.bl;
  63. }
  64.  
  65. /******************************************************************************/
  66. /*                Request a special E! API service                            */
  67. /******************************************************************************/
  68. void   Request_E_Service ( char service)
  69.  
  70. {
  71.  union REGS regs;
  72.  
  73.  regs.h.ah = service;
  74.  int86(E_Vec, ®s, ®s);
  75. }
  76.  
  77. /******************************************************************************/
  78. /*                   Get E! version number                                    */
  79. /******************************************************************************/
  80. void   Get_E_Version ( char *major, char *minor)
  81.  
  82. {
  83.  union REGS regs;
  84.  
  85.  regs.h.ah = VERSION_SERVICE;
  86.  int86(E_Vec, ®s, ®s);
  87.  *major = regs.h.ah;
  88.  *minor = regs.h.al;
  89. }
  90.  
  91. /******************************************************************************/
  92. /*                Instruct E! to execute a command on return                  */
  93. /******************************************************************************/
  94. void   RegisterCommand ( commandline commandstr )
  95.  
  96. {
  97.  union  REGS  regs;
  98.  struct SREGS sregs;
  99.  
  100.  regs.h.ah = REGISTER_SERVICE;
  101.  sregs.es  = FP_SEG ( commandstr );
  102.  regs.x.bx = FP_OFF ( commandstr );
  103.  int86x(E_Vec, ®s, ®s, &sregs);
  104. }
  105.  
  106. /******************************************************************************/
  107. /*                Call E! seek function and return error code                 */
  108. /******************************************************************************/
  109.  
  110. char   Seek_E_Line ( unsigned line, char curpos)
  111.  
  112. {
  113.  union REGS regs;
  114.  
  115.  regs.h.ah = SEEK_SERVICE;
  116.  regs.x.bx = line;
  117.  regs.h.al = curpos;
  118.  int86(E_Vec, ®s, ®s);
  119.  return (regs.h.al);
  120. }
  121.  
  122. /******************************************************************************/
  123. /*       Instruct E! to allocate memory on its own heap for the program.      */
  124. /******************************************************************************/
  125. BOOL   Get_E_Memory( unsigned paragraphs,
  126.                      unsigned memID,
  127.                      void **blockptr, /* blockptr is a pointer to a far pointer   */
  128.                      BOOL *firsttime) /* that is, it's the address of the pointer */
  129.                                       /* to the variables block.                  */
  130.  
  131. {
  132.  union  REGS  regs;
  133.  struct SREGS sregs;
  134.  
  135.  regs.h.ah = GETMEM_SERVICE;
  136.  regs.x.dx = memID;
  137.  regs.x.cx = paragraphs;
  138.  int86x(E_Vec, ®s, ®s, &sregs);
  139.  *blockptr = regs.h.al == 0 ? MK_FP (sregs.es, regs.x.bx) : NULL;
  140.  *firsttime = regs.h.ah;
  141.  return (regs.h.al ^ 0xff);
  142. }
  143.  
  144. /******************************************************************************/
  145. /*                       Free memory on E! heap                               */
  146. /******************************************************************************/
  147. BOOL   Free_E_Memory ( unsigned memID )
  148.  
  149. {
  150.  union REGS regs;
  151.  
  152.  regs.h.ah = FREEMEM_SERVICE;
  153.  regs.x.dx = memID;
  154.  int86(E_Vec, ®s, ®s);
  155.  return (regs.h.al ^ 0xff);
  156. }
  157.  
  158. BOOL   getflagstatus (unsigned flagid)
  159.  
  160. {
  161.  union REGS regs;
  162.  
  163.  regs.h.ah = flagid;
  164.  int86(E_Vec, ®s, ®s);
  165.  return (regs.h.al);
  166. }
  167.  
  168. /******************************************************************************/
  169. /*                           Is E! idle ?                                     */
  170. /******************************************************************************/
  171. BOOL   Is_E_Idle ()
  172.  
  173. {
  174.  return ( getflagstatus (E_IDLE_SERVICE) );
  175. }
  176.  
  177. /******************************************************************************/
  178. /*                        Was the file modified ?                             */
  179. /******************************************************************************/
  180. BOOL   Is_File_Modified ()
  181.  
  182. {
  183.  return ( getflagstatus (MODIF_SERVICE) );
  184. }
  185.