home *** CD-ROM | disk | FTP | other *** search
/ Microsoft Programmer's Library 1.3 / Microsoft-Programers-Library-v1.3.iso / sampcode / os2sdk / os2sdk10 / apps / terminal / term.h < prev    next >
Encoding:
C/C++ Source or Header  |  1988-08-11  |  6.6 KB  |  204 lines

  1. /*  term.h 
  2.  */
  3.  
  4. /* index definitions for error messages array */
  5. #define    ERR_VIOGETCONFIG    0
  6. #define    ERR_KBDSETSTATUS    1
  7. #define ERR_OUTOFMEMORY        2
  8. #define ERR_DOSCREATETHREAD     3
  9. #define ERR_DOSCLOSECOMPORT     4
  10. #define    ERR_IOCTLSETDCB        5
  11. #define ERR_DOSREAD        6
  12. #define ERR_VIOWRTTTY        7
  13. #define    ERR_DOSOPEN        8
  14. #define ERR_IOCTLSETBAUD    9
  15. #define    ERR_IOCTLSETLINECHAR   10
  16. #define ERR_IOCTLGETDCB           11
  17. #define ERR_KBDCHARIN           12
  18. #define    ERR_DOSWRITE           13
  19. #define ERR_VIOWRTCHARSTRATT   14
  20. #define ERR_VIOWRTNCELL        15
  21. #define ERR_DOSEXITLIST        16
  22. #define ERR_VIOSETCURPOS       17
  23. #define ERR_VIOGETMODE         18
  24. #define ERR_IOCTLFLUSHQUE      19    
  25. #define ERR_IOCTLGETCOMERROR   20 
  26. #define ERR_DOSSETSIGHANDLER   21
  27. #define ERR_IOCTLSETBREAKON    22
  28. #define ERR_IOCTLSETBREAKOFF   23
  29. #define ERR_INVALIDSIGNAL      24
  30. #define ERR_DO_OPT_INVOPT      25
  31. #define ERR_MOD_OPT_INVOPT     26
  32. #define ERR_SHOW_OPT_INVOPT    27
  33.  
  34. #define NUM_MSG               28    /* total number of error messages */
  35.  
  36. #define NO_RETCODE           -1    /* indicate no returncode */
  37. /* keyboard definitions */
  38. #define    ENTER_KEY    0x0D00
  39. #define    UP_KEY        0x0048
  40. #define    DOWN_KEY    0x0050
  41. #define    LEFT_KEY    0x004B
  42. #define    RIGHT_KEY    0x004D
  43. #define    DEL_KEY        0x0053
  44. #define    BKSP_KEY    0x0800
  45. #define    HOME_KEY    0x0047
  46. #define DEL_SCAN    83    /* scan code DELETE key */
  47. #define DEL_ASCII    127     /* ascii code for DELETE */
  48. #define ALT_F1        104    /* scan code for ALT F1 */
  49.  
  50. /* attribute definitions */
  51. #define BLACK        0
  52. #define BLUE        1
  53. #define GREEN        2
  54. #define CYAN        3
  55. #define RED        4
  56. #define MAGENTA        5
  57. #define YELLOW        6
  58. #define WHITE        7
  59. #define BRIGHT        8
  60.  
  61. /* attr - compute a character attribute
  62.  * ENTRY:    f = foreground attribute
  63.  *        b = backround attribute
  64.  * EXIT:    returns combined  attribute
  65.  */
  66.  
  67. #define ATTR(f,b)  ((b)<<4) + (f)
  68.  
  69. #define COLOR_PANEL  ATTR(BLUE,WHITE)
  70. #define COLOR_OPTION ATTR(RED,WHITE)
  71. #define COLOR_CURSOR ATTR(WHITE,RED)
  72.  
  73. #define MONO_PANEL   0x70
  74. #define MONO_OPTION  0x70
  75. #define MONO_CURSOR  0x07
  76.  
  77. /* index values for the option array */
  78. #define    PORT_NAME    0
  79. #define BAUD_RATE    1
  80. #define    DATA_BITS    2
  81. #define    STOP_BITS    3
  82. #define    PARITY        4
  83. #define    CONNECT        5
  84. #define    DIAL_TYPE    6
  85. #define    WAIT_TONE    7
  86. #define    WAIT_CARRIER    8
  87. #define    PHONE_NUMBER    9
  88. #define    SETUP_FILE    10
  89.  
  90. /* IOCTL category and functions */
  91. #define SERIAL            1    /* category: serial device control */
  92. #define SETBAUD        0x41    /* function: set baud rate */
  93. #define SETLINECHAR     0x42    /* function: set line characteristics */
  94. #define GETDCB        0x73    /* function: get device control block */
  95. #define SETDCB        0x53    /* function: set device control block */
  96. #define ENBL_XON_XOFF   0x03    /* enable auto transmit & receive flow cntl */
  97. #define    GENERIC        11    /* category: generic device control commands */
  98. #define GETCOMERROR     0x6d    /* function: retrieve & clear COM error info */
  99. #define FLUSHINPUT    1    /* function: flush input buffer */
  100. #define FLUSHOUTPUT    2    /* function: flush output buffer */
  101. #define GETNUMCHARS     0x68    /* function: get number of chars in recv que */
  102. #define FLUSH_CMDINFO   0    /* command information for FLUSH INPUT/OUTPUT*/
  103. #define SETBREAKON      0x4b    /* function: set break on */
  104. #define SETBREAKOFF     0x45    /* function: set break off */
  105.  
  106. /* miscelaneous definitions */
  107. #define    TRUE        1
  108. #define    FALSE        0
  109. #define RESERVED    0    /* reserved word */
  110. #define MONOCHROME    0    /* monochrome adapter, monochrome display */
  111. #define STACKSIZE    4096    /* size of stack to allocate for threads */
  112. #define    IOWAIT        0    /* wait */
  113. #define KBD_BITMASK     0x0006    /* bit mask for the KbdSetStatus call */
  114. #define INBUFLENGTH    2048    /* length of input buffer */
  115. #define BREAK        4    /* signal number for BREAK signal */
  116. #define RECV_CTRL       2    /* signal handler should receive control */
  117. #define READTIMEOUT     4000    /* time out for com port in .01 sec units */
  118. #define DISABLE_SIGNALS 1    /* disable signals */
  119. #define ENABLE_SIGNALS  0       /* enable signals */
  120. #define ADD_ADDR        1       /* DOSEXITLIST function request code */
  121. #define XFER        3    /* DOSEXITLIST function request code */
  122.  
  123. /* modem related definitions */
  124.  
  125. #define    NUM_RETRY    1    /* no. times to retry modem connection */
  126.  
  127. /* modem commands */
  128. #define MC_INIT         0
  129. #define MC_ATTN         1
  130. #define MC_ESC          2
  131. #define MC_ONHOOK       3
  132. #define MC_OFFHOOK      4
  133. #define MC_RESET        5
  134. #define MC_DIAL       128       /* special command for dialing */
  135.  
  136. #define B_PAUSE       0x20      /* a pause in a modem command */
  137.  
  138. /* modem status values */
  139. #define MS_OK           0       /* modem operation was successful */
  140. #define MS_CONNECT      1       /* a connection was made */
  141. #define MS_RING         2       /* a ring was detected */
  142. #define MS_NOCARRIER    3       /* no carrier was detected */
  143. #define MS_ERROR        4       /* a command error was detected */
  144. #define MS_CONNECT1200  5       /* a connection was established at 1200bps*/
  145. #define MS_NODIALTONE   6    /*dialtone not detected within time in reg S7*/
  146. #define MS_BUSY        7    /* a busy signal was detected */
  147.  
  148. #define MS_NOREPLY      8       /* no reply was recieved from the modem */
  149. #define OT_FAILURE      9    /* other modem connection failure */
  150.  
  151. /* connection: modem/computer */
  152. #define MODEM          1
  153. #define COMPUTER      2
  154.  
  155. /* dial type: tone/pulse */
  156. #define TONE        1
  157. #define PULSE       2
  158.  
  159. /* parity: even/odd/none */
  160. #define EVEN        2
  161. #define ODD         1
  162. #define NONE        0
  163.  
  164.  
  165. /*** type definitions ***/
  166.  
  167. typedef struct {
  168.   unsigned char   ch;     /* character */
  169.   unsigned char   at;     /* attribute */
  170. } Cell;
  171.  
  172. typedef struct LineChar {            /* line characteristics */
  173.   unsigned char    DataBits;
  174.   unsigned char    Parity;
  175.   unsigned char    StopBits;
  176. } structLineChar;
  177.  
  178. typedef    struct DCB {        /* device control block information */
  179.   unsigned    WriteTimeOut;
  180.   unsigned    ReadTimeOut;
  181.   unsigned char Flags1;
  182.   unsigned char    Flags2;
  183.   unsigned char    Flags3;
  184.   char        ErrRepChar;
  185.   char        BrkRepChar;
  186.   char        XONchar;
  187.   char        XOFFchar;
  188. } structDCB;
  189.  
  190. typedef    struct ComOptions {        /* structure to hold com port options */
  191.   char        *pPortName;    /* port name char-string */
  192.   int        iBaudRate;    /* baud rte */
  193.   char            chDataBits,    /* number of databits */
  194.           chStopBits,    /* number of stopbits */
  195.         chParity;    /* parity */
  196. } structComOptions;
  197.  
  198. typedef struct ModemOptions {        /* structure to hold modem options */
  199.   unsigned char chDialType;    /* dial type */
  200.   int        iWaitTone,    /* seconds modem should wait for dial tone */
  201.           iWaitCarrier;    /* seconds modem should wait for carrier */
  202.   char        *pPhoneNumber;  /* phone number char-string */
  203. } structModemOptions;
  204.