CnC_Remastered_Collection

Command and Conquer: Red Alert
Log | Files | Refs | README | LICENSE

NULLMGR.H (7333B)


      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: /CounterStrike/NULLMGR.H 1     3/03/97 10:25a 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 		int ModemVerboseOn;
     74 		int 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 type_offset, int type_size,
    137 			char **names, int namestart, int namecount);
    138 #ifdef CHEAT_KEYS
    139 		virtual void Mono_Debug_Print(int index, int refresh = 0);
    140 #endif
    141 
    142 		/*
    143 		** These are for compatibility
    144 		*/
    145 		virtual int Global_Num_Send(void) {return (Num_Send());}
    146 		virtual int Global_Num_Receive(void) {return (Num_Receive());}
    147 		virtual int Private_Num_Send(int = CONNECTION_NONE)
    148 			{return (Num_Send());}
    149 		virtual int Private_Num_Receive(int = CONNECTION_NONE)
    150 			{return (Num_Receive());}
    151 
    152 		DetectPortType Detect_Port( SerialSettingsType *settings );
    153 		int Detect_Modem( SerialSettingsType *settings, int reconnect = 0 );
    154 		DialStatusType Dial_Modem(char *string, DialMethodType method, int reconnect = 0);
    155 		DialStatusType Answer_Modem(int reconnect = 0);
    156 		int Hangup_Modem(void);
    157 		void Setup_Modem_Echo(void (*func)(char c));
    158 		void Remove_Modem_Echo(void);
    159 		void Print_EchoBuf(void);
    160 		void Reset_EchoBuf(void);
    161 		static int Abort_Modem(PORT *);
    162 		void Setup_Abort_Modem(void);
    163 		void Remove_Abort_Modem(void);
    164 
    165 		int Change_IRQ_Priority(int irq);
    166 		int Get_Modem_Status(void);
    167 		int Send_Modem_Command( char *command, char terminator, char *buffer, int buflen, int delay, int retries );
    168 		int Verify_And_Convert_To_Int( char *buffer );
    169 
    170 	/*
    171 	**	Private Interface.
    172 	*/
    173 	private:
    174 
    175 		/*
    176 		**	This is a pointer to the NULL-Modem Connection object.
    177 		*/
    178 		NullModemConnClass *Connection;
    179 		int NumConnections;						// # connection objects in use
    180 
    181 #ifdef WIN32
    182 		/*
    183 		** This is the Win95 port handle
    184 		*/
    185 		HANDLE	PortHandle;
    186 #else	//WIN32
    187 		/*
    188 		**	This is the Greenleaf port handle.
    189 		*/
    190 		PORT *Port;
    191 #endif	//WIN32
    192 
    193 		int NumSend;
    194 		int NumReceive;
    195 		unsigned short MagicNum;
    196 
    197 		/*
    198 		**	This is the staging buffer for parsing incoming packets.
    199 		**	RXSize is the allocated size of the RX buffer.
    200 		**	RXCount is the # of characters we currently have in our buffer.
    201 		*/
    202 		char *RXBuf;
    203 		int RXSize;
    204 		int RXCount;
    205 
    206 		/*.....................................................................
    207 		Timing parameters for all connections
    208 		.....................................................................*/
    209 		unsigned long RetryDelta;
    210 		unsigned long MaxRetries;
    211 		unsigned long Timeout;
    212 
    213 		/*
    214 		**	Various Statistics
    215 		*/
    216 		int SendOverflows;
    217 		int ReceiveOverflows;
    218 		int CRCErrors;
    219 };
    220 
    221 #endif
    222 
    223 /*************************** end of nullmgr.h ******************************/