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