home *** CD-ROM | disk | FTP | other *** search
/ Stars of Shareware: Programmierung / SOURCE.mdf / programm / msdos / pascal / ipxlib / ipxtest.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-06-01  |  12.5 KB  |  246 lines

  1. // IPXTEST.H -- Defines for IPXtest, a demo program for the IPX routines
  2. // by Allen Brunson  06/01/94
  3.  
  4.  
  5. #ifdef _MSC_VER                  // If a Microsoft compiler
  6. #pragma warning (disable:4018)   // Disable erroneous signed/unsigned warning
  7. #ifndef M_I86SM                  // If not small model
  8. #error IPXtest designed for the SMALL memory model
  9. #endif
  10. #endif
  11.  
  12. #ifdef __TURBOC__                // If a Borland compiler
  13. #ifndef __SMALL__                // If not small model
  14. #error IPXtest designed for the SMALL memory model
  15. #endif
  16. #endif
  17.  
  18. #include "ipx.h"                 // IPXLIB defines
  19. #include "ipxcfg.h"              // IPXLIB configuration defines
  20.  
  21.  
  22. /****************************************************************************/
  23. /*                                                                          */
  24. /***  General definitions                                                 ***/
  25. /*                                                                          */
  26. /****************************************************************************/
  27.  
  28. #ifndef  TRUEFALSE                                 // If TRUEFALSE not set
  29. #define  TRUEFALSE                                 // Define it
  30. #define  FALSE               0                     // Boolean false
  31. #define  OFF                 0                     //  defines
  32. #define  NO                  0
  33. #define  TRUE                1                     // Boolean true
  34. #define  ON                  1                     //  defines
  35. #define  YES                 1
  36. #endif
  37.  
  38. #ifndef  BYTE                                      // If BYTE not yet defined
  39. #define  BYTE                                      // Set definition
  40. typedef  unsigned char byte;                       // Typedef byte type
  41. #endif
  42. #ifndef  WORD                                      // If WORD not yet defined
  43. #define  WORD                                      // Set definition
  44. typedef  unsigned int  word;                       // Typedef word type
  45. #endif
  46.  
  47.  
  48. //#define  DEBUG                                   // Un-comment for DEBUG
  49.  
  50.  
  51. /****************************************************************************/
  52. /*                                                                          */
  53. /***  Macros                                                              ***/
  54. /*                                                                          */
  55. /****************************************************************************/
  56.  
  57. #ifdef _MSC_VER                                    // If a Microsoft compiler
  58. #define  cursorOn()  _settextcursor(0x0707)        // Turn cursor on
  59. #define  cursorOff() _settextcursor(0x2000)        // Turn cursor off
  60. #define gotoxy(col, row) \
  61.   _settextposition((int) row, (int) col)           // gotoxy() macro
  62. #else                                              // If a Borland compiler
  63. #define  cursorOn()  _setcursortype(_NORMALCURSOR) // Turn cursor on
  64. #define  cursorOff() _setcursortype(_NOCURSOR)     // Turn cursor off
  65. #endif
  66.  
  67.  
  68. /****************************************************************************/
  69. /*                                                                          */
  70. /***  Network data definitions                                            ***/
  71. /*                                                                          */
  72. /****************************************************************************/
  73.  
  74. #define NAMELEN            12                       // Length of name string
  75. #define MSGLEN             70                       // Max message length
  76. #define USERTOTAL          30                       // Total users
  77.  
  78. #define SIGNATURE      0x913F                       // Packet signature
  79.  
  80. #define pPING          0x3001                       // Ping packet
  81. #define pPINGRESPONSE  0x3002                       // Ping response
  82. #define pBROADCAST     0x3003                       // Broadcast message
  83. #define pMESSAGE       0x3004                       // Directed message
  84. #define pFLURRY        0x3005                       // Flurry packet
  85.  
  86. struct IPXTESTPKT                                   // IPXTEST packet
  87.   {
  88.     word signature;                                 // Signature word
  89.     word type;                                      // Packet type
  90.     word ipxRecvMax;                                // Receive ECB stat
  91.     word ipxSendMax;                                // Send ECB stat
  92.     char name[NAMELEN + 1];                         // Name string
  93.     char msg[MSGLEN + 1];                           // Message string
  94.   };
  95.  
  96. struct USER                                         // Info on one user
  97.   {
  98.     byte inUse;                                     // struct in use or not
  99.     word ipxRecvMax;                                // Receive ECB stat
  100.     word ipxSendMax;                                // Send ECB stat
  101.     struct IPXADDRFULL addr;                        // Address of user
  102.     char name[NAMELEN + 1];                         // Name of user
  103.   };
  104.  
  105.  
  106. /****************************************************************************/
  107. /*                                                                          */
  108. /***  Network data structure                                              ***/
  109. /*                                                                          */
  110. /****************************************************************************
  111.  
  112. If the define DEBUG at the top of this file is TRUE, then IPXTEST will use
  113. the following structure as the IPXLIB memory block.  This is useful for
  114. viewing the contents of IPX structures during debugging.  If DEBUG is
  115. FALSE, then a block of malloc()'ed memory will be used instead.             */
  116.  
  117. struct IPXDATA                                     // IPX data structure
  118.   {
  119.     #if    IPXRECVCNT                              // If receive count >= 1
  120.     struct ECB         recvECB[IPXRECVCNT];        // Receive ECBs
  121.     struct IPXPKTHDR   recvHdr[IPXRECVCNT];        // Receive packet headers
  122.     #if    IPXDATASIZE                             // If IPXDATASIZE >= 1
  123.     byte   recvBuf[IPXRECVCNT][IPXDATASIZE];       // Receive buffers
  124.     #endif
  125.     struct IPXEVENT    recvQueue[IPXRECVCNT];      // Receive event queue
  126.     #endif
  127.     #if    IPXSENDCNT                              // If send count >= 1
  128.     struct ECB         sendECB[IPXSENDCNT];        // Send ECBs
  129.     struct IPXPKTHDR   sendHdr[IPXSENDCNT];        // Send packet headers
  130.     #if    IPXDATASIZE                             // If IPXDATASIZE >= 1
  131.     byte   sendBuf[IPXSENDCNT][IPXDATASIZE];       // Send buffers
  132.     #endif
  133.     struct IPXEVENT    sendQueue[IPXSENDCNT];      // Send event queue
  134.     #endif
  135.   };
  136.  
  137.  
  138. /****************************************************************************/
  139. /*                                                                          */
  140. /***  Command definitions                                                 ***/
  141. /*                                                                          */
  142. /****************************************************************************/
  143.  
  144. #define CMDTOTAL    19                             // Cmd total, plus dupes
  145.  
  146. #define cBROADCAST   1                             // Broadcast message
  147. #define cCLS         2                             // Clears the screen
  148. #define cDISPLAY     3                             // Displays known users
  149. #define cFLURRY      4                             // Flurry mode
  150. #define cHELP        5                             // Help
  151. #define cMESSAGE     6                             // Targeted message
  152. #define cNAME        7                             // Set name
  153. #define cPING        8                             // Send ping packet
  154. #define cSTAT        9                             // Statistics
  155. #define cQUIT       10                             // Quit program
  156.  
  157. struct COMMAND                                     // Command structure
  158.   {
  159.     char *str;                                     // Command string
  160.     word code;                                     // Command code
  161.   };
  162.  
  163.  
  164. /****************************************************************************/
  165. /*                                                                          */
  166. /***  Color and screen definitions                                        ***/
  167. /*                                                                          */
  168. /****************************************************************************/
  169.  
  170.  
  171. #define  cBACKGRND      1                          // Background color
  172. #define  cFOREGRND      7                          // Foreground color
  173.  
  174. #define  MAXCOLS 100                               // Max screen columns
  175.  
  176.  
  177. /****************************************************************************/
  178. /*                                                                          */
  179. /***  Global data definitions                                             ***/
  180. /*                                                                          */
  181. /****************************************************************************/
  182.  
  183. extern byte endProgram;                            // End program flag
  184. extern char str[100];                              // Scratch string
  185.  
  186. extern char cmdStr[MAXCOLS];                       // Command string
  187. extern byte inputFlag;                             // End of input flag
  188.  
  189. extern byte cols, rows;                            // Screen size
  190. extern byte iCol, iRow;                            // Input window cursor pos
  191. extern byte mCol, mRow;                            // Main window cursor pos
  192. extern char strBlank[MAXCOLS + 1];                 // Blank line string
  193.  
  194. extern struct USER user[USERTOTAL];                // User info
  195.  
  196.  
  197. /****************************************************************************/
  198. /*                                                                          */
  199. /***  Function declarations                                               ***/
  200. /*                                                                          */
  201. /****************************************************************************/
  202.  
  203. // INPUT.C                                         // Input processing
  204.  
  205. void cmdHelp(void);                                // Displays help message
  206. void cmdProcess(void);                             // Processes commands
  207. void getKeys(void);                                // Collects keyboard input
  208.  
  209.  
  210. // NETWORK.C                                       // High-level IPX funcs
  211.  
  212. void netStart(void);                               // Sets up network stuff
  213. void netStop(void);                                // Stops network stuff
  214. void recvBroadcast(void);                          // Processes broadcasts
  215. void recvMessage(void);                            // Processes messages
  216. void recvPacket(void);                             // Processes incoming pkts
  217. void recvPing(void);                               // Processes pings
  218. void recvPingResponse(void);                       // Processes ping response
  219. void sendBroadcast(void);                          // Sends broadcast
  220. void sendErr(void);                                // Checks for send errors
  221. void sendFlurry(void);                             // Sends "flurry" packets
  222. void sendFlurryMode(void);                         // Sets flurry mode
  223. void sendMessage(void);                            // Sends message
  224. void sendPing(void);                               // Sends ping packet
  225. void setName(void);                                // Sets user name
  226. void statDisplay(void);                            // Displays statistics
  227. void userClear(void);                              // Clears user table
  228. void userDisplay(void);                            // Displays known users
  229. void userSave(void);                               // Saves info on user
  230.  
  231.  
  232. // PROCESS.C                                       // Misc processing
  233.  
  234. void demoStart(void);                              // Starts up subsystems
  235. void demoStop(void);                               // Stops subsystems
  236. word err(word error);                              // Displays error messages
  237.  
  238.  
  239. // VIDEO.C                                         // Video routines
  240.  
  241. void message(char *str);                           // Displays screen message
  242. void vidCLS(void);                                 // Clears the screen
  243. void vidScroll(void);                              // Scrolls main window
  244. void vidStart(void);                               // Starts up video stuff
  245. void vidStop(void);                                // Stops video stuff
  246.