home *** CD-ROM | disk | FTP | other *** search
/ Media Share 9 / MEDIASHARE_09.ISO / comm / ykh121.zip / YKHSRC.ZIP / CTERM.C < prev    next >
C/C++ Source or Header  |  1993-03-27  |  2KB  |  105 lines

  1. #pragma inline
  2.  
  3. #include <stdlib.h>
  4. #include "cterm.h"
  5.  
  6. #define CTERM             0x69
  7. #define FC_INSTALL_CHECK  0x100
  8. #define FC_SEND_DATA      0x101
  9. #define FC_READ_DATA      0x102
  10. #define FC_STATUS         0x103
  11. #define FC_DECNET_STATUS  0x104
  12. #define FC_OPEN_SESSION   0x105
  13. #define FC_CLOSE_SESSION  0x106
  14. #define FC_CTERM_SCB_SIZE 0x10a
  15. #define FC_SOCKET         0x10b
  16. #define FC_DEINSTALL      0x10f
  17.  
  18. static int cterm_handle;
  19. static unsigned int ch;
  20. static char *cterm_scb;
  21.  
  22. unsigned cterm_presence(void)
  23. {
  24. unsigned check;
  25.  
  26. asm mov ax,FC_INSTALL_CHECK;
  27. asm int CTERM;
  28. asm mov check,ax;
  29.  
  30. if (check==FC_INSTALL_CHECK) return -1;
  31. return 0;
  32. }
  33.  
  34.  
  35. unsigned cterm_open (unsigned char *service)
  36. {
  37. unsigned size;
  38.  
  39. asm mov ax,FC_CTERM_SCB_SIZE;
  40. asm int CTERM;
  41. asm mov size,ax;
  42.  
  43. if ((cterm_scb=(char *)malloc(size))==NULL)
  44.   return -1;
  45.  
  46. asm push es;
  47. asm push ds;
  48. asm pop es;
  49. asm mov ax,FC_OPEN_SESSION;
  50. asm mov bx,service;
  51. asm mov dx,cterm_scb;
  52. asm int CTERM;
  53. asm mov cterm_handle,ax;
  54. asm pop es;
  55.  
  56. if (cterm_handle<0)
  57.   {
  58.   cterm_close();
  59.   return -1;
  60.   }
  61. return 0;
  62. }
  63.  
  64. void cterm_close (void)
  65. {
  66. asm mov ax,FC_CLOSE_SESSION;
  67. asm mov dx,cterm_handle;
  68. asm int CTERM;
  69.  
  70. free(cterm_scb);
  71. }
  72.  
  73. unsigned cterm_send (char c)
  74. {
  75. asm mov ax,FC_SEND_DATA;
  76. asm mov bl,c;
  77. asm mov dx,cterm_handle;
  78. asm int CTERM;
  79. asm mov al,ah;
  80. asm xor ah,ah;
  81. }
  82.  
  83. unsigned cterm_ready(void)
  84. {
  85. if (cterm_status()&1)
  86.   return 1;
  87. return 0;
  88. }
  89.  
  90. char cterm_get(void)
  91. {
  92. asm mov ax,FC_READ_DATA;
  93. asm mov dx,cterm_handle;
  94. asm int CTERM;
  95. }
  96.  
  97. char cterm_status(void)
  98. {
  99. asm mov ax,FC_STATUS;
  100. asm mov dx,cterm_handle;
  101. asm int CTERM;
  102. asm mov al,ah;
  103. asm xor ah,ah;
  104. }
  105.