NULLMGR.H 7.2 KB

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