NULLMGR.H 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. /*
  2. ** Command & Conquer Red Alert(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. /* $Header: /CounterStrike/NULLMGR.H 1 3/03/97 10:25a Joe_bostic $ */
  19. /***************************************************************************
  20. ** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S **
  21. ***************************************************************************
  22. * *
  23. * Project Name : Command & Conquer *
  24. * *
  25. * File Name : CONNECT.H *
  26. * *
  27. * Programmer : Bill Randolph *
  28. * *
  29. * Start Date : December 19, 1994 *
  30. * *
  31. * Last Update : April 3, 1995 [BR] *
  32. * *
  33. *-------------------------------------------------------------------------*
  34. * *
  35. * This is the Connection Manager for a NULL-Modem connection. *
  36. * *
  37. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  38. #ifndef NULLMODEM_H
  39. #define NULLMODEM_H
  40. /*
  41. ********************************* Includes **********************************
  42. */
  43. #include "nullconn.h"
  44. #include "connmgr.h"
  45. #include "commlib.h"
  46. /*
  47. ***************************** Class Declaration *****************************
  48. */
  49. class NullModemClass : public ConnManClass
  50. {
  51. /*
  52. ---------------------------- Public Interface ----------------------------
  53. */
  54. public:
  55. enum SendModemEnum {
  56. MODEM_CMD_TIMEOUT = 0,
  57. MODEM_CMD_OK,
  58. MODEM_CMD_0,
  59. MODEM_CMD_ERROR
  60. };
  61. char *BuildBuf;
  62. int MaxLen;
  63. char *EchoBuf;
  64. int EchoSize;
  65. int EchoCount;
  66. int OldIRQPri;
  67. int ModemVerboseOn;
  68. int ModemEchoOn;
  69. int ModemWaitCarrier;
  70. int ModemCarrierDetect;
  71. int ModemCarrierLoss;
  72. int ModemHangupDelay;
  73. int ModemGuardTime;
  74. char ModemEscapeCode;
  75. static void (*OrigAbortModemFunc)(int);
  76. static KeyNumType Input;
  77. static GadgetClass *Commands; // button list
  78. /*
  79. ** Constructor/destructor.
  80. */
  81. NullModemClass (int numsend, int numreceive, int maxlen, unsigned short magicnum);
  82. virtual ~NullModemClass ();
  83. /*
  84. ** This is the main initialization routine.
  85. */
  86. int Init( int port, int irq, char *dev_name, int baud, char parity, int wordlength, int stopbits, int flowcontrol );
  87. int Delete_Connection( void );
  88. virtual int Num_Connections(void);
  89. virtual int Connection_ID(int ) {return (0);}
  90. virtual int Connection_Index(int ) {return (0);}
  91. int Init_Send_Queue( void );
  92. void Shutdown( void );
  93. virtual void Set_Timing (unsigned long retrydelta,
  94. unsigned long maxretries, unsigned long timeout);
  95. /*
  96. ** This is how the application sends & receives messages.
  97. */
  98. int Send_Message (void *buf, int buflen, int ack_req = 1);
  99. int Get_Message (void *buf, int *buflen);
  100. /*
  101. ** These are for compatibility
  102. */
  103. virtual int Send_Private_Message (void *buf, int buflen,
  104. int ack_req = 1, int = CONNECTION_NONE)
  105. {return (Send_Message(buf,buflen,ack_req));}
  106. virtual int Get_Private_Message (void *buf, int *buflen, int *)
  107. {return (Get_Message(buf,buflen));}
  108. /*
  109. ** The main polling routine; should be called as often as possible.
  110. */
  111. virtual int Service (void);
  112. /*
  113. ** Queue utility routines. The application can determine how many
  114. ** messages are in the send/receive queues, and the queue's average
  115. ** response time (in clock ticks).
  116. */
  117. int Num_Send(void);
  118. int Num_Receive(void);
  119. virtual unsigned long Response_Time(void);
  120. virtual void Reset_Response_Time(void);
  121. void * Oldest_Send(void);
  122. virtual void Configure_Debug(int index, int type_offset, int type_size,
  123. char **names, int namestart, int namecount);
  124. #ifdef CHEAT_KEYS
  125. virtual void Mono_Debug_Print(int index, int refresh = 0);
  126. #endif
  127. /*
  128. ** These are for compatibility
  129. */
  130. virtual int Global_Num_Send(void) {return (Num_Send());}
  131. virtual int Global_Num_Receive(void) {return (Num_Receive());}
  132. virtual int Private_Num_Send(int = CONNECTION_NONE)
  133. {return (Num_Send());}
  134. virtual int Private_Num_Receive(int = CONNECTION_NONE)
  135. {return (Num_Receive());}
  136. DetectPortType Detect_Port( SerialSettingsType *settings );
  137. int Detect_Modem( SerialSettingsType *settings, int reconnect = 0 );
  138. DialStatusType Dial_Modem(char *string, DialMethodType method, int reconnect = 0);
  139. DialStatusType Answer_Modem(int reconnect = 0);
  140. int Hangup_Modem(void);
  141. void Setup_Modem_Echo(void (*func)(char c));
  142. void Remove_Modem_Echo(void);
  143. void Print_EchoBuf(void);
  144. void Reset_EchoBuf(void);
  145. static int Abort_Modem(PORT *);
  146. void Setup_Abort_Modem(void);
  147. void Remove_Abort_Modem(void);
  148. int Change_IRQ_Priority(int irq);
  149. int Get_Modem_Status(void);
  150. int Send_Modem_Command( char *command, char terminator, char *buffer, int buflen, int delay, int retries );
  151. int Verify_And_Convert_To_Int( char *buffer );
  152. /*
  153. ** Private Interface.
  154. */
  155. private:
  156. /*
  157. ** This is a pointer to the NULL-Modem Connection object.
  158. */
  159. NullModemConnClass *Connection;
  160. int NumConnections; // # connection objects in use
  161. #ifdef WIN32
  162. /*
  163. ** This is the Win95 port handle
  164. */
  165. HANDLE PortHandle;
  166. #else //WIN32
  167. /*
  168. ** This is the Greenleaf port handle.
  169. */
  170. PORT *Port;
  171. #endif //WIN32
  172. int NumSend;
  173. int NumReceive;
  174. unsigned short MagicNum;
  175. /*
  176. ** This is the staging buffer for parsing incoming packets.
  177. ** RXSize is the allocated size of the RX buffer.
  178. ** RXCount is the # of characters we currently have in our buffer.
  179. */
  180. char *RXBuf;
  181. int RXSize;
  182. int RXCount;
  183. /*.....................................................................
  184. Timing parameters for all connections
  185. .....................................................................*/
  186. unsigned long RetryDelta;
  187. unsigned long MaxRetries;
  188. unsigned long Timeout;
  189. /*
  190. ** Various Statistics
  191. */
  192. int SendOverflows;
  193. int ReceiveOverflows;
  194. int CRCErrors;
  195. };
  196. #endif
  197. /*************************** end of nullmgr.h ******************************/