3,183c3,4 < * < * $Header: /u3/bchatfie/cvsroot/inetcis/inetcisd/inetcisd.c,v 1.1.1.1 1995/08/24 14:29:52 bchatfie Exp $ < * < * Facility: < * Terminal emulator < * < * Abstract: < * Quick and dirty terminal emulator for Unix. Simply moves < * characters from TTY to the device entered on the command < * line. Three ESC's in a row exits. < * < * Environment: < * < * BSD Unix. < * < * Author: < * < * David J. Crone, Systems/Monitor Group. < * < * Revision History: < * January 6, 1992 DJC Creation < * July 1, 1993 BBIGGS Co-erced into inetcis throughput < * - speed throughput enforcement < * - disabled 3 escape exitor < * - determine tpad from tty < * January 27, 1994 BCHATFIELD Removed unavailable items < * - removed 14.4 baud option from prompt < * - removed item 5 from help menu < * - changed wording of sign-up prompt < * < * $Log: inetcisd.c,v $ < * Revision 1.1.1.1 1995/08/24 14:29:52 bchatfie < * Import of inetcis as one big module. < * < * Revision 2.4 1995/08/15 17:02:46 bchatfie < * Reworked main algorithm and added new loggin module. < * < * Revision 2.3 1995/06/20 20:09:24 bchatfie < * Added error message for user when no tpads are available. < * Added some better error processing to get_tpad.c. < * < * Revision 2.2 1995/06/20 17:13:19 bchatfie < * The get_tpad.c was changed to use 128 tpads instead of < * 256. get_tpad.c is not a part of this module, but it < * is linked to so a new version of inetcisd had to be < * created by relinking. < * < * Revision 1.1.1.1 1995/04/25 17:55:46 bchatfie < * Imported sources < * < * Revision 1.6 1994/06/01 16:06:56 bchatfie < * Temporary fix to handle text to binary mode switching problem. < * Extra NULLs are removed from the beginning of strings in < * trimlower. < * < * Revision 1.5 1994/05/16 17:07:51 bchatfie < * Fixed Host Name: prompt help code. Added code to read and display file < * inetcis.text.host_name_help when incorrect input is read at the Host Name: < * prompt. < * < * Revision 1.4 1994/05/05 15:54:13 bchatfie < * Entered code to allow it to accept baud rates of 450, 1200, 1800, 4800, < * 14400, 19200, and 38400 in addition to the ones it already accepts. < * Also removed the extra line feed before the Host Name: prompt. < * < * Revision 1.3 1994/05/05 13:33:07 bchatfie < * Fixed text directory location for test version. < * < * Revision 1.2 1994/05/05 10:16:59 bchatfie < * I inserted some carriage returns. < * < * Revision 0.11 1994/03/30 16:19:50 bchatfie < * Fixed line feed problem at the User ID prompt by turning on ONLCR in the < * c_oflag field of the DevTermios structure. < * < * Revision 0.10 1994/03/29 18:24:43 bchatfie < * This version does Control-D disconnects, User ID prompt timeout, and has < * the beta test password removed. It is the first version released to the < * public. < * < * Revision 0.9 1994/03/23 09:00:07 bchatfie < * This revision includes all the changes that have been made to the text and < * prompts that are displayed for the user before he gets the User ID prompt. < * < * Revision 0.8 1993/12/05 13:43:38 bbiggs < * fix to fgets to handle the "EOF" response properly (exits) < * < * Revision 0.7 1993/11/30 02:25:09 bbiggs < * added 2 minute timeout at Host Name prompt < * took out debug message at login < * fixed typo in one of the text files (you electronix to your electronic) < * < * Revision 0.6 1993/10/22 21:33:35 bbiggs < * Added HELP to the FIRST Host Name prompt. Changed Bit Rate to Baud Rate < * in error message. < * < * Revision 0.5 1993/10/22 20:44:58 bbiggs < * Changes for HELP in the baud rate prompt, and at the Host Name prompt < * < * Revision 0.3 1993/10/14 13:31:50 bbiggs < * Changes to the flow of the user interrogation sequences < * added speed 14400 to the list of available baud rates < * added syslog messages for connect attempts and mailings < * < * $Log: inetcisd.c,v $ < * Revision 1.1.1.1 1995/08/24 14:29:52 bchatfie < * Import of inetcis as one big module. < * < * Revision 2.4 1995/08/15 17:02:46 bchatfie < * Reworked main algorithm and added new loggin module. < * < * Revision 2.3 1995/06/20 20:09:24 bchatfie < * Added error message for user when no tpads are available. < * Added some better error processing to get_tpad.c. < * < * Revision 2.2 1995/06/20 17:13:19 bchatfie < * The get_tpad.c was changed to use 128 tpads instead of < * 256. get_tpad.c is not a part of this module, but it < * is linked to so a new version of inetcisd had to be < * created by relinking. < * < * Revision 1.1.1.1 1995/04/25 17:55:46 bchatfie < * Imported sources < * < * Revision 1.6 1994/06/01 16:06:56 bchatfie < * Temporary fix to handle text to binary mode switching problem. < * Extra NULLs are removed from the beginning of strings in < * trimlower. < * < * Revision 1.5 1994/05/16 17:07:51 bchatfie < * Fixed Host Name: prompt help code. Added code to read and display file < * inetcis.text.host_name_help when incorrect input is read at the Host Name: < * prompt. < * < * Revision 1.4 1994/05/05 15:54:13 bchatfie < * Entered code to allow it to accept baud rates of 450, 1200, 1800, 4800, < * 14400, 19200, and 38400 in addition to the ones it already accepts. < * Also removed the extra line feed before the Host Name: prompt. < * < * Revision 1.3 1994/05/05 13:33:07 bchatfie < * Fixed text directory location for test version. < * < * Revision 1.2 1994/05/05 10:16:59 bchatfie < * I inserted some carriage returns. < * < * Revision 0.11 1994/03/30 16:19:50 bchatfie < * Fixed line feed problem at the User ID prompt by turning on ONLCR in the < * c_oflag field of the DevTermios structure. < * < * Revision 0.10 1994/03/29 18:24:43 bchatfie < * This version does Control-D disconnects, User ID prompt timeout, and has < * the beta test password removed. It is the first version released to the < * public. < * < * Revision 0.9 1994/03/23 09:00:07 bchatfie < * This revision includes all the changes that have been made to the text and < * prompts that are displayed for the user before he gets the User ID prompt. < * < * Revision 0.8 1993/12/05 13:43:38 bbiggs < * fix to fgets to handle the "EOF" response properly (exits) < * < * Revision 0.7 1993/11/30 02:25:09 bbiggs < * added 2 minute timeout at Host Name prompt < * took out debug message at login < * fixed typo in one of the text files (you electronix to your electronic) < * < * Revision 0.6 1993/10/22 21:33:35 bbiggs < * Added HELP to the FIRST Host Name prompt. Changed Bit Rate to Baud Rate < * in error message. < * < * Revision 0.5 1993/10/22 20:44:58 bbiggs < * Changes for HELP in the baud rate prompt, and at the Host Name prompt < * < * Revision 0.2 1993/10/14 13:30:51 bbiggs < * Various changes of formatting. Some clean-up to the throughput < * logic. < * < * Revision 0.1 1993/09/07 14:47:58 bbiggs < * Initial checkin of software. Preceeds addition of the exponential < * averaging enforcement of the speed throughput. < * --- > * > * inetcisd.c 189,192c10,21 < #include /* for struct stat */ < #include /* for struct sockaddr */ < #include /* for struct sockaddr_in */ < #include /* for inet_ntoa() */ --- > #include /* configuration information for inetcisd */ > > #include /* for struct stat */ > #include /* for struct sockaddr */ > #include /* for struct sockaddr_in */ > #include > > #ifdef ALLOW_TCP_NODELAY > #include /* for TCP_NODELAY */ > #endif > > #include /* for inet_ntoa() */ 195,196c24,25 < #include /* for stat() */ < #include /* for MAXHOSTNAMELEN */ --- > #include /* for stat() */ > #include /* for MAXHOSTNAMELEN */ 201c30,31 < #include --- > #include /* _POSIX_SOURCE must NOT be defined to get > * B57600 */ 206,207c36,37 < #include /* for strcpy(), strcat(), ... */ < #include /* for INT_MAX */ --- > #include /* for strcpy(), strcat(), ... */ > #include /* for INT_MAX */ 209c39,40 < #include /* for CudHexStr, PPPValidateUser, PPPGetUserContext */ --- > #include /* for CudHexStr, PPPValidateUser, > * PPPGetUserContext */ 215,259c46 < #include < < /* < * Types < */ < typedef enum ConnectionType_e < { < CT_INBOUND_INTERNET, < CT_OLD_SPRY_PPP, < CT_PPP_CONNECT < } ConnectionType; < < /* < * Function prototypes < */ < void Setup (); < void Passthrough_User_ID_Prompt (); < int initial_Connect (char *, char *); < int Get_Password (); < int Get_Service (); < int Get_First_Prompt (); < int Get_Agreement (); < int Get_Help (); < int Perform_Dialogs (); < int Get_Baud (); < void Setup_X25_Device (ConnectionType, CudHexStr, int *, int); < void dumpit (FILE *, char *, int); < void Display_Help_Menu (); < void Display_Text_File (char *); < void Strip_Leading_CRs_And_LFs (char *, char *, int, int *); < void Read_Asterisk_Prompt (); < void Alarm_Signal_Handler (int); < void Write_All_Characters (FILE *, char *, char *, int); < char Read_Byte_from_Socket_and_Echo ( ); < int Read_String_from_Socket_and_Echo (char *, int); < void Write_Bytes_to_Socket (char *, int); < void Write_String_to_Socket (char *, ...); < void Get_Caller_Information (char *, ConnectionType *, CudHexStr); < char *Convert_Characters_in_String_to_ASCII_Codes (char *, char *); < void Simulate_Host_Name_Prompt (); < void Get_Baud_Rate_from_User (int *, int *, int *); < void Make_String_from_Bytes (char *, int, char *); < void Replace_NL_with_CR_NL (char *); < void cleanup (void); < void Display_Connected_Message (void); --- > #include 302a90,160 > /* > * Types > */ > typedef enum { > CT_INBOUND_INTERNET, /* normal connection from the Internet */ > CT_OLD_SPRY_PPP, /* old Spry PPP style connection */ > > /* > * A true PPP Connect for which a CUD can be retrieved from the CUD server. > */ > CT_PPP_CONNECT, > > /* > * Specification which does not differentiate between old Spry PPP and PPP > * Connect. > */ > CT_GENERIC_PPP > } > ConnectionType; > > typedef struct { > long int loop_delay; > int produce_stats; > int from_central_server; > long int x25_fd; > char x25_device_name[MAXSTRLEN + 1]; > int socket_debugging; > } > FeatureStructType; > > /* > * Function prototypes > */ > void Parse_Command_Line (int, char **); > void Bidirectional_Pipe (int, int); > void Setup (int argc, char *argv[]); > void Passthrough_User_ID_Prompt (); > int initial_Connect (char *, char *); > int Get_Password (); > int Get_Service (); > int Get_First_Prompt (); > int Get_Agreement (); > int Get_Help (); > int Perform_Dialogs (); > int Get_Baud (); > void Setup_Socket (); > void Setup_X25_Device (ConnectionType, CudHexStr, int *, int); > void dumpit (FILE *, char *, int); > void Display_Help_Menu (); > void Display_Text_File (char *); > void Strip_Leading_CRs_And_LFs (char *, char *, int, int *); > void Read_Asterisk_Prompt (int *x25_fd); > void Alarm_Signal_Handler (int); > char Read_Byte_from_Socket_and_Echo (); > int Read_String_from_Socket_and_Echo (char *, int); > void Write_Bytes_to_Socket (char *, int); > void Write_String_to_Socket (char *,...); > void Get_Caller_Information (char *, ConnectionType *, CudHexStr); > char *Convert_Characters_in_String_to_ASCII_Codes (char *, char *); > void Simulate_Host_Name_Prompt (); > void Get_Baud_Rate_from_User (int *, int *, int *); > void Make_String_from_Bytes (char *, int, char *); > void Replace_NL_with_CR_NL (char *); > void cleanup (void); > void Display_Connected_Message (void); > void Set_Command_Line_Options (); > > /* > * External variables that should have been defined in system header files. > */ > extern int h_errno; 307,327c165,185 < int Socket_Descriptor; < int MaxFd = -1; /* max of DevFd, TtyFd (used for select call)*/ < int DevFd = -1; /* Device File descriptor */ < int TtyFd = -1; /* TTY File descriptor */ < int DevCc = 0; /* Device input buffer char count */ < int TtyCc = 0; /* TTY input buffer char count */ < char *DevBufPtr; /* Device buffer pointer */ < char *TtyBufPtr; /* TTY buffer pointer */ < char DevBuf[BUFSIZE]; /* Device input buffer */ < char TtyBuf[BUFSIZE]; /* TTY input buffer */ < char DevName[128]; /* ptr to device name */ < char oDevName[128]; /* ptr to device name */ < char Program_Name[NORMAL_STRING_LENGTH]; < struct termios TtyTermios; /* working copy */ < struct termios TtySettings; /* original settings */ < struct termios DevTermios; /* working copy */ < struct termios DevSettings; /* original settings */ < char Temp_Codes[15000]; < char Temp_String[15000]; < const double TIMEOUT_VALUE = 30; /* seconds */ < jmp_buf asterisk_read_timeout; --- > int Socket_Descriptor; > int MaxFd = -1; /* max of DevFd, TtyFd (for select call) */ > int DevFd = -1; /* Device File descriptor */ > int TtyFd = -1; /* TTY File descriptor */ > int DevCc = 0; /* Device input buffer char count */ > int TtyCc = 0; /* TTY input buffer char count */ > char *DevBufPtr; /* Device buffer pointer */ > char *TtyBufPtr; /* TTY buffer pointer */ > char DevBuf[BUFSIZE];/* Device input buffer */ > char TtyBuf[BUFSIZE];/* TTY input buffer */ > char DevName[128]; /* ptr to device name */ > char oDevName[128]; /* ptr to device name */ > char Program_Name[NORMAL_STRING_LENGTH]; > struct termios TtyTermios; /* working copy */ > struct termios TtySettings; /* original settings */ > struct termios DevTermios; /* working copy */ > struct termios DevSettings; /* original settings */ > char Temp_Codes[15000]; > char Temp_String[15000]; > const double TIMEOUT_VALUE = 30; /* seconds */ > jmp_buf asterisk_read_timeout; 329,330c187,189 < (char *) NULL}; < char *IP_Address_Of_Caller; --- > (char *) NULL}; > char IP_Address_Of_Caller[MAXSTRLEN+1]; > FeatureStructType Features = {0, 0, 0, 0}; 335c194,195 < void main (int argc, char **argv) --- > void > main (int argc, char **argv) 338,340c198,202 < * < * This is the main function for inetcisd. < * --- > * > * This is the main function for inetcisd. I believe that the socket, > * Socket_Descriptor, which is STDIN_FILENO, STDOUT_FILENO, and STDERR_FILENO > * is in blocking mode. The X.25 device is opened in non-blocking mode. > * 342,344c204,206 < * < * argc and argv < * --- > * > * argc and argv > * 346c208 < * --- > * 348,350c210,212 < * < * None < * --- > * > * None > * 352c214 < * --- > * 354,371c216,232 < { < fd_set ibits, obits, xbits; < int nsel; < int cc; < int CharsIn, CharsOut; < int Baud, MaxChar=0, BaudRate=0, ReadWait; < time_t old_time, current_time; < struct timeval tv_s; < ConnectionType type_of_connection; < CudHexStr cud; < < Setup (argc, argv); < Get_Caller_Information (IP_Address_Of_Caller, &type_of_connection, cud); < Display_Connected_Message (); < Simulate_Host_Name_Prompt (); < Get_Baud_Rate_from_User (&Baud, &BaudRate, &MaxChar); < Setup_X25_Device (type_of_connection, cud, &DevFd, BaudRate); < Passthrough_User_ID_Prompt (); --- > { > ConnectionType type_of_connection; > CudHexStr cud; > int Baud, MaxChar = 0, BaudRate = 0; > > Setup (argc, argv); > Parse_Command_Line (argc, argv); > Set_Command_Line_Options (); > Get_Caller_Information (IP_Address_Of_Caller, &type_of_connection, cud); > Display_Connected_Message (); > Simulate_Host_Name_Prompt (); > Get_Baud_Rate_from_User (&Baud, &BaudRate, &MaxChar); > Setup_Socket (); > Setup_X25_Device (type_of_connection, cud, &DevFd, BaudRate); > Passthrough_User_ID_Prompt (); > Bidirectional_Pipe (BaudRate, MaxChar); > } 373,458d233 < /* < * Initialize loop variables < */ < DevBuf[0] = EOS; < TtyBuf[0] = EOS; < DevCc = 0; < TtyCc = 0; < DevBufPtr = DevBuf; < TtyBufPtr = TtyBuf; < CharsIn = 0; < CharsOut = 0; < old_time = time (NULL); < current_time = time (NULL); < tv_s.tv_sec = 120; < tv_s.tv_usec = 0; < ReadWait = 250; < MaxFd = (TtyFd > DevFd) ? TtyFd + 1 : DevFd + 1; < < < /*****************************************************************************/ < /* */ < /* Begin Main Loop */ < /* */ < /*****************************************************************************/ < < while (Socket_Is_Alive() && X25_Device_Is_Alive()) < { < FD_ZERO (&ibits); < FD_ZERO (&obits); < FD_ZERO (&xbits); < < /* < * NOTE: Slippage logic is not compiled in right now, just < * limit the user to the quantum bandwidth promised, and no < * more. Pending further testing... < */ < < /* < * Begin slippage logic: < * If, during the preceeding time quantum, we were not able < * to use all of our alotted "bandwidth", allow the amount of < * "bandwidth" this quantum to increase by the unused portion. < * However, the increase should not exceed 2x the available < * quantum size. < */ < < /* < * time is in increments of 1 second. That will be our quantum, < * strictly a convienience... < */ < current_time = time (NULL); < < if (current_time != old_time) < { < CharsIn = 0; < CharsOut = 0; < old_time = current_time; < } < < if (DevCc) /* if anything in device input buffer*/ < { < FD_SET (TtyFd, &obits); /* then request tty output */ < } < else if (CharsOut < MaxChar) < { < FD_SET (DevFd, &ibits); /* else request device input check */ < } < < if (TtyCc) /* if anything in tty input buffer */ < { < FD_SET (DevFd, &obits); /* then request device output */ < } < else if (CharsIn < MaxChar) < { < FD_SET (TtyFd, &ibits); /* else request tty input check */ < } < < nsel = select ((MaxFd + 1), &ibits, &obits, &xbits, < (struct timeval *) &tv_s); < < if (nsel == SELECT_ERROR) < { < syslog (LOG_ERR, "%s %d - err - function select caused system" < " error `%m' trying to find a ready descriptor", __FILE__, < __LINE__); < } 460,464c235,303 < #if 0 < /* < * Just pause here quietly for a moment - let the buffer fill up a bit < */ < usleep (ReadWait); --- > > > void > Parse_Command_Line (int argc, char **argv) > { > int option_char; > long int loop_delay; > char *end_ptr; > int x25_fd; > int turn_it_on = 1; > int status; > > /* > * Make sure the Features structure is initialized correctly! > */ > Features.from_central_server = 0; > Features.loop_delay = 0; > Features.produce_stats = 0; > Features.x25_fd = 0; > strcpy (Features.x25_device_name, "none"); > Features.socket_debugging = 0; > > strcpy (Program_Name, argv[0]); > > opterr = 0; /* turn off output by getopt */ > while (1) { > option_char = getopt (argc, argv, "DNcd:n:sx:"); > if (option_char == EOF) > break; > switch (option_char) { > case 'D': > /* > * This switch turns on socket debugging. > */ > errno = 0; /* reset errno */ > status = setsockopt (Socket_Descriptor, SOL_SOCKET, SO_DEBUG, > (char *) &turn_it_on, sizeof (turn_it_on)); > if (status == SETSOCKOPT_ERROR) { > Write_System_Error_To_Log (LOG_LEVEL_ERR, __FILE__, __LINE__, > errno, "socket level debugging " > "option", "setsockopt", > "SDB", > "could not set socket debugging " > "option"); > } else { > Write_Message_To_Log (LOG_LEVEL_INFO, __FILE__, __LINE__, > "SO_DEBUG turned ON"); > } > break; > #ifdef ALLOW_TCP_NODELAY > case 'N': > /* > * This switch sets the TCP_NODELAY socket option. > */ > errno = 0; /* reset errno */ > status = setsockopt (Socket_Descriptor, IPPROTO_TCP, TCP_NODELAY, > (char *) &turn_it_on, sizeof (turn_it_on)); > if (status == SETSOCKOPT_ERROR) { > Write_System_Error_To_Log (LOG_LEVEL_ERR, __FILE__, __LINE__, > errno, "tcp no delay option", > "setsockopt", > "SDB", > "could not set socket debugging " > "option"); > } else { > Write_Message_To_Log (LOG_LEVEL_INFO, __FILE__, __LINE__, > "TCP_NODELAY option turned ON"); > } > break; 466,515c305,377 < < /* < * Read from X.25 device. < */ < if ((DevCc == 0) && (FD_ISSET (DevFd, &ibits) && (MaxChar > CharsOut))) < { < DevCc = Read_from_X25_Device (DevFd, DevBuf, < ((BUFSIZE < MaxChar) ? BUFSIZE : MaxChar)); < DevBufPtr = DevBuf; < CharsOut += DevCc; < } < < /* < * Read from the socket. < */ < if ((TtyCc == 0) && FD_ISSET (TtyFd, &ibits) && (MaxChar > CharsIn)) < { < TtyCc = Read_from_Socket (TtyFd, TtyBuf, < ((BUFSIZE < MaxChar) ? BUFSIZE : MaxChar)); < TtyBufPtr = TtyBuf; < CharsIn += TtyCc; < } < < /* < * Write to X.25 device. < */ < if (TtyCc > 0) < { < cc = Write_to_X25_Device (DevFd, TtyBufPtr, < ((TtyCc > MaxChar) ? MaxChar : TtyCc)); < TtyCc -= cc; < TtyBufPtr += cc; < } < < /* < * Write to socket. < */ < if (DevCc > 0) < { < cc = Write_to_Socket (TtyFd, DevBufPtr, < (DevCc > MaxChar ? MaxChar : DevCc)); < DevCc -= cc; < DevBufPtr += cc; < } < } < /*****************************************************************************/ < /* */ < /* End Main Loop */ < /* */ < /*****************************************************************************/ --- > case 'c': > /* > * This switch signifies that inetcisd was started by inetcis.centrald. > * This means that inetcisd should not do things like become another > * user or increase the process limit. > */ > Features.from_central_server = 1; > break; > case 'd': > loop_delay = strtol (optarg, &end_ptr, 10); > if (end_ptr == optarg) { > Write_Va_Message_To_Log (LOG_LEVEL_ERR, __FILE__, __LINE__, > "invalid argument, %s, for loop " > "delay option, -d", optarg); > Features.loop_delay = 0; > } else if (loop_delay == LONG_MIN) { > Write_Va_Message_To_Log (LOG_LEVEL_ERR, __FILE__, __LINE__, > "loop delay, %s, caused " > "underflow error", optarg); > Features.loop_delay = 0; > } else if (loop_delay == LONG_MAX) { > Write_Va_Message_To_Log (LOG_LEVEL_ERR, __FILE__, __LINE__, > "loop delay, %s, caused " > "overflow error", optarg); > Features.loop_delay = 0; > } else { > Features.loop_delay = loop_delay; > Write_Va_Message_To_Log (LOG_LEVEL_INFO, __FILE__, > __LINE__, > "using loop delay of %ldus", > loop_delay); > } > break; > case 'n': > /* > * This switch specifies the name of the X.25 device. > */ > strncpy (Features.x25_device_name, optarg, MAXSTRLEN); > Features.x25_device_name[MAXSTRLEN] = 0; > break; > case 's': > Features.produce_stats = 1; > break; > case 'x': > x25_fd = strtol (optarg, &end_ptr, 10); > if (end_ptr == optarg || x25_fd == LONG_MIN > || x25_fd == LONG_MAX) { > Write_Va_Message_To_Log (LOG_LEVEL_ERR, __FILE__, __LINE__, > "invalid argument, %s, for X.25 " > "descriptor option, -x", optarg); > Features.x25_fd = 0; > } else > Features.x25_fd = x25_fd; > break; > default: > Write_Va_Message_To_Log (LOG_LEVEL_ERR, __FILE__, __LINE__, > "invaild switch, -%c", option_char); > } /* switch */ > } /* while */ > > /* > * Deal with inconsistent command line switches. > */ > if (Features.from_central_server) { > if (Features.x25_fd == 0 > || strcmp (Features.x25_device_name, "none") == 0) { > Write_Error_To_Log (LOG_LEVEL_ERR, __FILE__, __LINE__, > "command line switch", "validate", "N/A", > "did not get necessary switches for -c"); > exit (EXIT_FAILURE); > } > } > } /* Parse_Command_Line() */ 517,523d378 < /* < * Continue writting to any open descriptors < */ < if (Socket_Is_Alive() && DevCc > 0) < { < Write_All_To_Socket (TtyFd, DevBufPtr, DevCc); < } 525,528c380,415 < if (X25_Device_Is_Alive() && TtyCc > 0) < { < Write_All_To_X25_Device (DevFd, TtyBufPtr, TtyCc); < } --- > void > Bidirectional_Pipe (int BaudRate, int MaxChar) > { > fd_set ibits, obits, xbits; > int nsel; > int cc; > int CharsIn, CharsOut; > time_t old_time, current_time; > struct timeval tv_s; > int socket_ok = 1, x25_ok = 1; > > /* > * Initialize loop variables > */ > DevBuf[0] = EOS; > TtyBuf[0] = EOS; > DevCc = 0; > TtyCc = 0; > DevBufPtr = DevBuf; > TtyBufPtr = TtyBuf; > CharsIn = 0; > CharsOut = 0; > old_time = time (NULL); > current_time = time (NULL); > tv_s.tv_sec = 120; > tv_s.tv_usec = 0; > MaxFd = (TtyFd > DevFd) ? TtyFd + 1 : DevFd + 1; > > /************************************************* > * Begin Main Loop * > *************************************************/ > > while (socket_ok && x25_ok) { > FD_ZERO (&ibits); > FD_ZERO (&obits); > FD_ZERO (&xbits); 530c417 < exit (EXIT_SUCCESS); --- > current_time = time (NULL); 532,551c419,438 < } /* main */ < < void Setup (int argc, char **argv) < { < int status; < < /* open log files */ < strncpy (Program_Name, argv[0], NORMAL_STRING_LENGTH - 1); < Program_Name[NORMAL_STRING_LENGTH - 1] = EOS; < Start_Syslog_Log (Program_Name); < Start_User_Log (stderr, PROGRAM_ID_FOR_ERRORS, OUTPUT_LINE_TERMINATOR); < < /* register exit handler */ < status = atexit (cleanup); < if (status == ATEXIT_ERROR) < { < syslog (LOG_ERR, "%s %d - err - function atexit caused system error" < " `%m' trying to define exit handler cleanup", < __FILE__, __LINE__); < } --- > if (current_time != old_time) { > CharsIn = 0; > CharsOut = 0; > old_time = current_time; > } > if (DevCc) { /* if anything in device input buffer */ > FD_SET (TtyFd, &obits); /* then request tty output */ > } else if (CharsOut < MaxChar) { > FD_SET (DevFd, &ibits); /* else request device input check */ > } > if (TtyCc) { /* if anything in tty input buffer */ > FD_SET (DevFd, &obits); /* then request device output */ > } else if (CharsIn < MaxChar) { > FD_SET (TtyFd, &ibits); /* else request tty input check */ > } > if (Features.loop_delay) { > usleep (Features.loop_delay); > } > nsel = select ((MaxFd + 1), &ibits, &obits, &xbits, > (struct timeval *) &tv_s); 552a440,444 > if (nsel == SELECT_ERROR) { > syslog (LOG_ERR, "%s %d - err - function select caused system" > " error `%m' trying to find a ready descriptor", __FILE__, > __LINE__); > } 554,556c446 < * Setup signal handler for segmentation fault and SIGPIPE. A SIGPIPE is < * generated when SO_KEEPALIVE socket option facility doesn't get a < * response from the remote host. --- > * Read from X.25 device. 558,563c448,454 < (void) signal (SIGSEGV, signal_handler); < (void) signal (SIGPIPE, signal_handler); < < increase_process_limit (); < become_user (RUN_TIME_USER_NAME); < --- > if ((DevCc == 0) && (FD_ISSET (DevFd, &ibits) && (MaxChar > CharsOut))) { > x25_ok = Read_From_X25_Device (DevFd, DevBuf, > ((BUFSIZE < MaxChar) ? BUFSIZE : MaxChar), > &DevCc); > DevBufPtr = DevBuf; > CharsOut += DevCc; > } 565c456 < * Use argc. --- > * Read from the socket. 567,579c458,464 < if (argc > 1) < { < syslog (LOG_ERR, "%s %d - err - invalid number of parameters, %d", < __FILE__, __LINE__, argc - 1); < } < < Socket_Descriptor = TtyFd = 0; < Enable_Socket_Inactivity_Timeout (Socket_Descriptor); < < } /* Setup() */ < < void Passthrough_User_ID_Prompt () < { --- > if ((TtyCc == 0) && FD_ISSET (TtyFd, &ibits) && (MaxChar > CharsIn)) { > socket_ok = Read_From_Socket (TtyFd, TtyBuf, > ((BUFSIZE < MaxChar) ? BUFSIZE : MaxChar), > &TtyCc); > TtyBufPtr = TtyBuf; > CharsIn += TtyCc; > } 581,584c466 < * Set up the call the information service Use of 313299999997 < * will get the user to the "User ID" prompt, and lock them to < * that point. To release this, (e.g. to access the host name < * prompt, change the address to just 3132 --- > * Write to X.25 device. 586,593c468,474 < strcpy (TtyBuf, "313299999997\r"); < TtyCc = strlen (TtyBuf); < Write_All_To_X25_Device (DevFd, TtyBuf, TtyCc); < if (! X25_Device_Is_Alive()) < { < exit (EXIT_FAILURE); < } < --- > if (TtyCc > 0) { > x25_ok = Write_To_X25_Device (DevFd, TtyBufPtr, > ((TtyCc > MaxChar) ? MaxChar : TtyCc), > &cc); > TtyCc -= cc; > TtyBufPtr += cc; > } 595,597c476 < * A bunch of pad messages get sent back on the connection < * attempt. Rather than parse through them, we just wait for our < * confirmation prompt, and proceed from there. --- > * Write to socket. 599c478,499 < read_user_id_prompt (DevFd); --- > if (DevCc > 0) { > socket_ok = Write_To_Socket (TtyFd, DevBufPtr, > (DevCc > MaxChar ? MaxChar : DevCc), &cc); > DevCc -= cc; > DevBufPtr += cc; > } > } > /************************************************ > * End Main Loop * > ************************************************/ > > /* > * One side of the connection has gone away at this point. Continue > * writing to any open descriptors > */ > if (socket_ok && DevCc > 0) { > Write_All_To_Socket (TtyFd, DevBufPtr, DevCc); > } > if (x25_ok && TtyCc > 0) { > Write_All_To_X25_Device (DevFd, TtyBufPtr, TtyCc); > } > } /* Bidirectional_Pipe() */ 601,621d500 < /* < * The User ID prompt has successfully been read from the X.25 device. < * Display it for the user. < */ < Write_String_to_Socket ("\r\n"); < Write_String_to_Socket ("User ID: "); < } /* Passthrough_User_ID_Prompt () */ < < /* < * The contents of resp are not changed except that some of the characters may < * be lower cased and it may be shorter. Basically the contents of resp are < * no longer any good. The correct result is in the value that is returned, < * which is a pointer to a substring of resp. That result has the white space < * trimmed off the front and back and has the alphanumeric characters lower < * cased. The way this thing invalidates the contents of resp is screwey, but < * it may be dangerous to change this functionality. < */ < char *trimlower (char *resp, int len) < { < char *sp; < char *start_p = resp; 623,631d501 < /* < * I want end_p to actually point one position beyond the last character < * that is supposed to be in the string. This makes the rest of the code < * simpler to read. The value of len does not seem to account for the < * NULL character at the end of the string because trimlower is called < * with things like strlen(resp) as values for len. So, it should be safe < * to do this. < */ < char *end_p = (char *) ((unsigned int)resp + len); 633,645d502 < /* < * The following code block is a temporary fix that should deal with extra < * NULLs that are causing a problem when the system, for some unknown < * reason, prematurely goes into binary mode. This particular block < * deals with NULLs at the beginning of the string. There is already < * existing code here to deal with other NULLs. As a beginning condition, < * start_p must be at the physical beginning of the string that was passed < * in. < */ < if (start_p+1 < end_p && *start_p == '\0' && isprint(*(start_p+1))) < { < start_p++; < } 647,651c504,570 < /* < * Trim off the leading white space on the string < */ < while ((*start_p == '\t' || *start_p == ' ') && start_p != end_p ) < start_p++; --- > void > Setup (int argc, char *argv[]) > { > int status; > > /* open log files */ > strncpy (Program_Name, argv[0], NORMAL_STRING_LENGTH - 1); > Program_Name[NORMAL_STRING_LENGTH - 1] = EOS; > #ifndef NO_SYSLOG_LOGGING > Start_Syslog_Log (Program_Name); > #endif > Start_User_Log (stderr, PROGRAM_ID_FOR_ERRORS, OUTPUT_LINE_TERMINATOR); > #ifdef LOCAL_LOG_FILE_NAME > Start_Local_File_Log (LOCAL_LOG_FILE_NAME, "inetcisd"); > #endif > > /* register exit handler */ > status = atexit (cleanup); > if (status == ATEXIT_ERROR) { > syslog (LOG_ERR, "%s %d - err - function atexit caused system error" > " `%m' trying to define exit handler cleanup", > __FILE__, __LINE__); > } > /* > * Setup signal handler for segmentation fault and SIGPIPE. A SIGPIPE is > * generated when SO_KEEPALIVE socket option facility doesn't get a > * response from the remote host. > */ > #ifdef SIGSEGV_HANDLER > (void) signal (SIGSEGV, signal_handler); > #endif > (void) signal (SIGPIPE, signal_handler); > > Socket_Descriptor = TtyFd = 0; > Enable_Socket_Inactivity_Timeout (Socket_Descriptor); > > } /* Setup() */ > > > void > Passthrough_User_ID_Prompt () > { > /* > * Set up the call the information service Use of 313299999997 will get the > * user to the "User ID" prompt, and lock them to that point. To release > * this, (e.g. to access the host name prompt, change the address to just > * 3132 > */ > strcpy (TtyBuf, "313299999997\r"); > TtyCc = strlen (TtyBuf); > Write_All_To_X25_Device_EonF (DevFd, TtyBuf, TtyCc); > > /* > * A bunch of pad messages get sent back on the connection attempt. Rather > * than parse through them, we just wait for our confirmation prompt, and > * proceed from there. > */ > Read_User_ID_Prompt (DevFd); > > /* > * The User ID prompt has successfully been read from the X.25 device. > * Display it for the user. > */ > Purge_Socket_Input (Socket_Descriptor); > Write_String_to_Socket ("\r\n"); > Write_String_to_Socket ("User ID: "); > } /* Passthrough_User_ID_Prompt () */ 653,660d571 < #if 0 < /* < * This is junk code. It could result in an end_p that is less than < * start_p becuase it will decrease sp until j becomes 0. j, however, < * is going to be decresed len times. len is no longer the correct < * length of the string because we may have increased start_p beyond < * the beginning of the original string. < */ 662,663c573,617 < /* Locate the end of the string */ < sp = (char *) ( (unsigned int)resp + len - 1 ); --- > /* > * The contents of resp are not changed except that some of the characters > * may be lower cased and it may be shorter. Basically the contents of resp > * are no longer any good. The correct result is in the value that is > * returned, which is a pointer to a substring of resp. That result has the > * white space trimmed off the front and back and has the alphanumeric > * characters lower cased. The way this thing invalidates the contents of > * resp is screwey, but it may be dangerous to change this functionality. > * This function is still very poor and needs to be rewritten. The interface > * needs to be changed also, which means changing all the code that calls it. > */ > char * > trimlower (char *resp, int len) > { > char *sp; > char *start_p = resp; > > /* > * I want end_p to actually point one position beyond the last character > * that is supposed to be in the string. This makes the rest of the code > * simpler to read. The value of len does not seem to account for the NULL > * character at the end of the string because trimlower is called with > * things like strlen(resp) as values for len. So, it should be safe to do > * this. If trimlower is ever called with a string that is not NULL > * terminated this could end up going one past the end of the space > * contained by resp, which would be a bad thing. > */ > char *end_p = (char *) ((unsigned int) resp + len); > > /* > * The following code block is a temporary fix that should deal with extra > * NULLs that are causing a problem when the system, for some unknown > * reason, prematurely goes into binary mode. This particular block deals > * with NULLs at the beginning of the string. There is already existing > * code here to deal with other NULLs. As a beginning condition, start_p > * must be at the physical beginning of the string that was passed in. > */ > if (start_p + 1 < end_p && *start_p == '\0' && isprint (*(start_p + 1))) { > start_p++; > } > /* > * Trim off the leading white space on the string > */ > while (isspace(*start_p) && start_p != end_p) > start_p++; 665,670c619,635 < for (j=len;j--;j>0) < { < if (*sp == '\0' || *sp == '\n' || *sp == '\r') < end_p = sp; < sp--; < } --- > #if 0 > /* > * This is junk code. It could result in an end_p that is less than > * start_p becuase it will decrease sp until j becomes 0. j, however, is > * going to be decresed len times. len is no longer the correct length of > * the string because we may have increased start_p beyond the beginning of > * the original string. > */ > > /* Locate the end of the string */ > sp = (char *) ((unsigned int) resp + len - 1); > > for (j = len; j--; j > 0) { > if (*sp == '\0' || *sp == '\n' || *sp == '\r') > end_p = sp; > sp--; > } 673,696c638,670 < /* < * The following code is cleaner and fixes the above problem. However, < * I am still not sure whether all of it is necessary, but I will leave < * it the way it is until I figure out more. < * < * As far as I can figure, what the above code is actually doing is < * finding the FIRST (counting from the beginning up) NULL, new line, or < * cariage return in resp. It is doing it very inefficiently. I will < * attempt to do it more efficiently. < */ < sp = start_p; < while (sp != end_p && < *sp != NULL && < *sp != '\n' && < *sp != '\r') < sp++; < < /* < * At this point sp should point to a NULL, a new line, a cariage return < * or whatever end_p is pointing to. This is where we want end_p to be. < * And, no matter what this character was before it needs to be a NULL now. < */ < end_p = sp; < *end_p = NULL; --- > /* > * The following code is cleaner and fixes the above problem. However, I > * am still not sure whether all of it is necessary, but I will leave it > * the way it is until I figure out more. > * > * As far as I can figure, what the above code is actually doing is finding > * the FIRST (counting from the beginning up) NULL, new line, or cariage > * return in resp. It is doing it very inefficiently. I will attempt to > * do it more efficiently. > */ > sp = start_p; > while (sp != end_p && > *sp != NULL && > *sp != '\n' && > *sp != '\r') > sp++; > > /* > * At this point sp should point to a NULL, a new line, a cariage return or > * whatever end_p is pointing to. This is where we want end_p to be. And, > * no matter what this character was before it needs to be a NULL now. > */ > end_p = sp; > *end_p = NULL; > > /* > * Now convert all alpha's to lowercase > */ > for (sp = start_p; sp < end_p; sp++) > *sp = tolower (*sp); > > return start_p; > } 698,702d671 < /* < * Now convert all alpha's to lowercase < */ < for (sp=start_p; sp0 - 1 based index of the match found between token and < * the list array < * 0 - no match found --- > * Returns: >0 - 1 based index of the match found between token and the list > * array 0 - no match found 713,731c677,686 < int match (char *token, char **list) < { < int i=1; < while ( *list != NULL ) < { < if ( strcmp (token, *list) == 0 ) return i; < list++; < i++; < } < < return 0; < } < < void Setup_X25_Device (ConnectionType type_of_connection, < CudHexStr cud, < int *DevFd, < int BaudRate) < { < char X25_device_name[32]; --- > int > match (char *token, char **list) > { > int i = 1; > while (*list != NULL) { > if (strcmp (token, *list) == 0) > return i; > list++; > i++; > } 733,735c688,689 < /* < * Find an available X.25 device. < */ --- > return 0; > } 737d690 < *DevFd = Open_X25_Device (X25_device_name); 739,784c692,696 < /* < * *DevFd is negative if all the above attempts to find a device failed. < */ < if (*DevFd < 0) < { < Write_String_to_Socket ("? %sLNK All links to the CompuServe network " < "are in use%s", PROGRAM_ID_FOR_ERRORS, < LINE_TERMINATION_STRING); < syslog (LOG_ERR, "%s %d - err - could not open X.25 device", __FILE__, < __LINE__); < exit (EXIT_FAILURE); < } < else < { < syslog (LOG_INFO, "%s %d - info - using X.25 device %s", < __FILE__, __LINE__, X25_device_name); < } < < < if (tcgetattr (*DevFd, &DevSettings) < 0) < { < syslog (LOG_ERR, "%s %d - err - function tcgetattr caused system" < " error `%m' trying to get terminal attributes for X.25" < "device %s", __FILE__, __LINE__, X25_device_name); < exit (EXIT_FAILURE); < } < < DevTermios = DevSettings; /* make working copy of structure */ < DevTermios.c_ispeed = BaudRate; < DevTermios.c_ospeed = BaudRate; < < DevTermios.c_cflag &= ~(CSIZE | PARENB); < DevTermios.c_cflag |= (CS8); < < DevTermios.c_oflag |= ONLCR; < < DevTermios.c_cc[VMIN] = 100; /* 100 bytes minimum */ < DevTermios.c_cc[VTIME] = 50; /* wait 1 second */ < < if (tcsetattr (*DevFd, TCSANOW, &DevTermios) < 0) < { < syslog (LOG_ERR, "%s %d - err - function tcsetattr caused system" < " error `%m' trying to set terminal attributes for X.25" < " device %s", __FILE__, __LINE__, X25_device_name); < exit (EXIT_FAILURE); < } --- > void > Setup_Socket () > { > Start_Producing_Socket_Flow_Stats (); > } 786,791d697 < /* < * When a pad device is opened, it responds with an asterisk < * prompt. We need to wait for it to arrive before sending < * our connect request out. < */ < Read_Asterisk_Prompt (); 793,798d698 < /* < * Set the CompuServe extended parameter 45 to 255. This can be done now < * that the asterisk prompt has been received from the X.25 device. < */ < Write_All_To_X25_Device (*DevFd, "xset 45:255\r", 12); < Read_Asterisk_Prompt (); 800,804c700,707 < /* < * Set X.3 parameter 13 to 4 to try to stop the CRLF duplication problem. < */ < Write_All_To_X25_Device (*DevFd, "xset 13:4\r", 10); < Read_Asterisk_Prompt (); --- > void > Setup_X25_Device (ConnectionType type_of_connection, > CudHexStr cud, > int *DevFd, > int BaudRate) > { > char X25_device_name[MAXSTRLEN + 1]; > char *check_name; 806,821c709,720 < /* < * If this connection is a PPP Connect customer, then the customer < * information needs to be passed on to the X.25 device. This is done < * using the X.25 call user data field. The following command sets the < * call user data field for the upcoming X.25 connection to be the string < * that was returned by PPPGetUserContext(). < */ < if (type_of_connection == CT_PPP_CONNECT) < { < char cud_command[6 + CUDHEXSTRLEN + OUTPUT_LINE_TERMINATOR_LENGTH + 1]; < strcpy (cud_command, "cud 0x"); < strcat (cud_command, cud); < strcat (cud_command, OUTPUT_LINE_TERMINATOR); < Write_All_To_X25_Device (*DevFd, cud_command, strlen(cud_command)); < Read_Asterisk_Prompt (); < } --- > /* > * Find an available X.25 device. > */ > > if (Features.from_central_server) { > Write_Va_Message_To_Log (LOG_LEVEL_DEBUG0, __FILE__, __LINE__, > "assigning X.25 file descriptor %d, from " > "command line parameter", Features.x25_fd); > *DevFd = Features.x25_fd; > strncpy (X25_device_name, Features.x25_device_name, MAXSTRLEN); > } else { > *DevFd = Open_X25_Device (X25_device_name); 823,825c722,810 < /* < * We don't do ttys anymore! < */ --- > if (*DevFd < 0) { > Log_All_Links_In_Use_Error (__FILE__, __LINE__, "Open_X25_Device"); > exit (EXIT_FAILURE); > } > strcpy (Features.x25_device_name, X25_device_name); > Features.x25_fd = *DevFd; > } > > #ifdef USE_NEW_CENTRAL_SERVER_CODE > if (Refresh_X25_Device (DevFd, X25_device_name) == FAILURE) { > Log_All_Links_In_Use_Error (__FILE__, __LINE__, "Refresh_X25_Device"); > exit (EXIT_FAILURE); > } > #endif > > Write_Va_Message_To_Log (LOG_LEVEL_INFO, __FILE__, __LINE__, > "X.25 tpad is %s", X25_device_name); > > check_name = ttyname (*DevFd); > if (strcmp (check_name, X25_device_name) != 0) { > Write_Error_To_Log (LOG_LEVEL_WARNING, __FILE__, __LINE__, > "X.25 device name", "strcmp", "NAM", > "Device name mismatch"); > } > if (tcgetattr (*DevFd, &DevSettings) < 0) { > syslog (LOG_ERR, "%s %d - err - function tcgetattr caused system" > " error `%m' trying to get terminal attributes for X.25" > "device %s", __FILE__, __LINE__, X25_device_name); > exit (EXIT_FAILURE); > } > DevTermios = DevSettings; /* make working copy of structure */ > DevTermios.c_ispeed = BaudRate; > DevTermios.c_ospeed = BaudRate; > > DevTermios.c_cflag &= ~(CSIZE | PARENB); > DevTermios.c_cflag |= (CS8); > > DevTermios.c_oflag |= ONLCR; > > DevTermios.c_cc[VMIN] = 100; /* 100 bytes minimum */ > DevTermios.c_cc[VTIME] = 50; /* wait 1 second */ > > if (tcsetattr (*DevFd, TCSANOW, &DevTermios) < 0) { > syslog (LOG_ERR, "%s %d - err - function tcsetattr caused system" > " error `%m' trying to set terminal attributes for X.25" > " device %s", __FILE__, __LINE__, X25_device_name); > exit (EXIT_FAILURE); > } > /* > * When a pad device is opened, it responds with an asterisk prompt. We > * need to wait for it to arrive before sending our connect request out. > */ > Read_PAD_Prompt (*DevFd); > > /* > * Set the CompuServe extended parameter 45 to 255. This can be done now > * that the asterisk prompt has been received from the X.25 device. > */ > Write_All_To_X25_Device_EonF (*DevFd, "xset 45:255\r", 12); > Read_PAD_Prompt (*DevFd); > > /* > * Set X.3 parameter 13 to 4 to try to stop the CRLF duplication problem. > */ > Write_All_To_X25_Device_EonF (*DevFd, "xset 13:4\r", 10); > Read_PAD_Prompt (*DevFd); > > /* > * If this connection is a PPP Connect customer, then the customer > * information needs to be passed on to the X.25 device. This is done > * using the X.25 call user data field. The following command sets the > * call user data field for the upcoming X.25 connection to be the string > * that was returned by PPPGetUserContext() or was hardwired in the case of > * CT_PPP_GENERIC. > */ > if (type_of_connection == CT_PPP_CONNECT > || type_of_connection == CT_GENERIC_PPP) { > char cud_command[6 + CUDHEXSTRLEN + 2]; > strcpy (cud_command, "cud 0x"); > strcat (cud_command, cud); > strcat (cud_command, "\r"); > Write_All_To_X25_Device_EonF (*DevFd, cud_command, strlen (cud_command)); > Read_PAD_Prompt (*DevFd); > } > Start_Producing_X25_Flow_Stats (); > > /* > * We don't do ttys anymore! > */ 827,880c812,860 < if ((*TtyFd = open ("/dev/tty", O_RDWR)) < 0) < { < printf ("\nCould not open tty"); < fflush (stdout); < return (0); < } < < if (tcgetattr (*TtyFd, &TtySettings) < 0) < { < printf ("\nCould not get termios structure"); < fflush (stdout); < return (0); < } < < TtyTermios = TtySettings; /* make working copy of structure */ < < /* put tty in raw mode */ < TtyTermios.c_lflag &= ~(ICANON | ECHO | IEXTEN | ISIG); < TtyTermios.c_iflag &= ~(BRKINT | ICRNL | INPCK | ISTRIP | IXON); < < TtyTermios.c_cflag &= ~(CSIZE | PARENB); < TtyTermios.c_cflag |= (CS8); < < TtyTermios.c_oflag = 0; < < TtyTermios.c_cc[VMIN] = 0; /* as much as is ready */ < TtyTermios.c_cc[VTIME] = 0; /* no waiting for input */ < < /* ACK -A- HACK! */ < vdisable = _POSIX_VDISABLE; < < TtyTermios.c_cc[VDISCARD] = vdisable; < TtyTermios.c_cc[VDSUSP] = vdisable; < TtyTermios.c_cc[VEOF] = vdisable; < TtyTermios.c_cc[VEOL] = vdisable; < TtyTermios.c_cc[VEOL2] = vdisable; < TtyTermios.c_cc[VERASE] = vdisable; < TtyTermios.c_cc[VINTR] = vdisable; < TtyTermios.c_cc[VKILL] = vdisable; < TtyTermios.c_cc[VLNEXT] = vdisable; < TtyTermios.c_cc[VQUIT] = vdisable; < TtyTermios.c_cc[VREPRINT] = vdisable; < TtyTermios.c_cc[VSTART] = vdisable; < TtyTermios.c_cc[VSTATUS] = vdisable; < TtyTermios.c_cc[VSTOP] = vdisable; < TtyTermios.c_cc[VSUSP] = vdisable; < TtyTermios.c_cc[VWERASE] = vdisable; < < if (tcsetattr (*TtyFd, TCSANOW, &TtyTermios) < 0) < { < printf ("\nCould not set termios structure"); < fflush (stdout); < return (0); < } --- > if ((*TtyFd = open ("/dev/tty", O_RDWR)) < 0) { > printf ("\nCould not open tty"); > fflush (stdout); > return (0); > } > if (tcgetattr (*TtyFd, &TtySettings) < 0) { > printf ("\nCould not get termios structure"); > fflush (stdout); > return (0); > } > TtyTermios = TtySettings; /* make working copy of structure */ > > /* put tty in raw mode */ > TtyTermios.c_lflag &= ~(ICANON | ECHO | IEXTEN | ISIG); > TtyTermios.c_iflag &= ~(BRKINT | ICRNL | INPCK | ISTRIP | IXON); > > TtyTermios.c_cflag &= ~(CSIZE | PARENB); > TtyTermios.c_cflag |= (CS8); > > TtyTermios.c_oflag = 0; > > TtyTermios.c_cc[VMIN] = 0; /* as much as is ready */ > TtyTermios.c_cc[VTIME] = 0; /* no waiting for input */ > > /* ACK -A- HACK! */ > vdisable = _POSIX_VDISABLE; > > TtyTermios.c_cc[VDISCARD] = vdisable; > TtyTermios.c_cc[VDSUSP] = vdisable; > TtyTermios.c_cc[VEOF] = vdisable; > TtyTermios.c_cc[VEOL] = vdisable; > TtyTermios.c_cc[VEOL2] = vdisable; > TtyTermios.c_cc[VERASE] = vdisable; > TtyTermios.c_cc[VINTR] = vdisable; > TtyTermios.c_cc[VKILL] = vdisable; > TtyTermios.c_cc[VLNEXT] = vdisable; > TtyTermios.c_cc[VQUIT] = vdisable; > TtyTermios.c_cc[VREPRINT] = vdisable; > TtyTermios.c_cc[VSTART] = vdisable; > TtyTermios.c_cc[VSTATUS] = vdisable; > TtyTermios.c_cc[VSTOP] = vdisable; > TtyTermios.c_cc[VSUSP] = vdisable; > TtyTermios.c_cc[VWERASE] = vdisable; > > if (tcsetattr (*TtyFd, TCSANOW, &TtyTermios) < 0) { > printf ("\nCould not set termios structure"); > fflush (stdout); > return (0); > } 883,884c863,865 < } < --- > } > > 886,888c867,868 < * Functional Description: < * dumpit - displays len bytes of *ptr in hex < * --- > * Functional Description: dumpit - displays len bytes of *ptr in hex > * 890c870 < * --- > * 892,893c872,873 < * < * --- > * > * 895,896c875,876 < * < * --- > * > * 898c878 < * --- > * 901,904c881,892 < void dumpit (FILE *dev, char *ptr, int len) < { < int i; < --- > void > dumpit (FILE * dev, char *ptr, int len) > { > int i; > > fprintf (dev, "\n"); > for (i = 0; i < len; i++) { > fprintf (dev, "%02x ", abs (ptr[i])); > if ((i != 0) && ((i % 16) == 0)) > fprintf (dev, "\n"); > } > if ((i - 1) % 16 != 0) 906,914c894,925 < for (i = 0; i < len; i++) < { < fprintf (dev, "%02x ", abs (ptr[i])); < if ( (i != 0) && ((i % 16) == 0) ) < fprintf (dev, "\n"); < } < if ( (i-1)%16 != 0) < fprintf (dev, "\n"); < fflush (dev); --- > fflush (dev); > return; > } > > > > jmp_buf motdinterrupt; > > void > Display_Text_File (char *filename) > { > FILE *input_file_ptr; > sig_t oldint; > void sigint (); > char buffer[NORMAL_STRING_LENGTH]; > char complete_filename[256]; > > /* > * The following code takes the LOCATION_OF_TEXT_FILES constant, which > * holds the directory name where all the text files used in this program > * reside, and adds the actual file name to this directory name. The > * result should be a correct path and file name stored in the variable > * complete_filename. This name is then used as the file to be opened. > */ > strcpy (complete_filename, LOCATION_OF_TEXT_FILES); > strcat (complete_filename, filename); > > input_file_ptr = fopen (complete_filename, "r"); > if (input_file_ptr == (FILE *) NULL) { > syslog (LOG_ERR, "%s %d - err - function fopen caused system error" > " `%m' trying to open file %s", __FILE__, __LINE__, > complete_filename); 915a927,935 > } > oldint = signal (SIGINT, sigint); > if (setjmp (motdinterrupt) == 0) { > fgets (buffer, NORMAL_STRING_LENGTH - 1, input_file_ptr); > Replace_NL_with_CR_NL (buffer); > while (!feof (input_file_ptr)) { > Write_String_to_Socket (buffer); > fgets (buffer, NORMAL_STRING_LENGTH - 1, input_file_ptr); > Replace_NL_with_CR_NL (buffer); 917c937,940 < --- > } > (void) signal (SIGINT, oldint); > (void) fclose (input_file_ptr); > } 919d941 < jmp_buf motdinterrupt; 921,927c943,947 < void Display_Text_File (char *filename) < { < FILE *input_file_ptr; < sig_t oldint; < void sigint (); < char buffer[NORMAL_STRING_LENGTH]; < char complete_filename[256]; --- > void > sigint () > { > longjmp (motdinterrupt, 1); > } 929,938d948 < /* < * The following code takes the LOCATION_OF_TEXT_FILES constant, < * which holds the directory name where all the text files used in < * this program reside, and adds the actual file name to this < * directory name. The result should be a correct path and file < * name stored in the variable complete_filename. This name is < * then used as the file to be opened. < */ < strcpy (complete_filename, LOCATION_OF_TEXT_FILES); < strcat (complete_filename, filename); 940,970d949 < input_file_ptr = fopen (complete_filename, "r"); < if (input_file_ptr == (FILE *) NULL) < { < syslog (LOG_ERR, "%s %d - err - function fopen caused system error" < " `%m' trying to open file %s", __FILE__, __LINE__, < complete_filename); < return; < } < < oldint = signal (SIGINT, sigint); < if (setjmp (motdinterrupt) == 0) < { < fgets (buffer, NORMAL_STRING_LENGTH - 1, input_file_ptr); < Replace_NL_with_CR_NL (buffer); < while (! feof (input_file_ptr)) < { < Write_String_to_Socket (buffer); < fgets (buffer, NORMAL_STRING_LENGTH - 1, input_file_ptr); < Replace_NL_with_CR_NL (buffer); < } < } < < (void) signal (SIGINT, oldint); < (void) fclose (input_file_ptr); < } < < void sigint () < { < longjmp (motdinterrupt, 1); < } < 972,978c951,955 < * Functional Description: < * Initial_Connect < * At connect, print out some debug stuff (like where I think you're < * coming from) and map the inbound device name (ttyxx) to a pad < * device name (tpadxx). < * < * --- > * Functional Description: Initial_Connect At connect, print out some debug > * stuff (like where I think you're coming from) and map the inbound device > * name (ttyxx) to a pad device name (tpadxx). > * > * 980c957 < * --- > * 982c959 < * --- > * 984c961 < * --- > * 986c963 < * --- > * 988,999c965,978 < int Initial_Connect (char *DevName, char *oDevName) < { < showoriginip; < printf ("DevName = [%s]\noDevName = [%s]\n", DevName, oDevName); < /* < * We want to print to the user, give the lines a moment to settle down. < */ < fflush (stdout); < sleep (1); < return 0; < } < --- > int > Initial_Connect (char *DevName, char *oDevName) > { > showoriginip; > printf ("DevName = [%s]\noDevName = [%s]\n", DevName, oDevName); > /* > * We want to print to the user, give the lines a moment to settle down. > */ > fflush (stdout); > sleep (1); > return 0; > } > > 1006,1017c985,999 < int Perform_Dialogs () < { < if (!Get_First_Prompt ()) < { < sleep (1); < exit (0); < } < < Write_String_to_Socket ("\r\nPLEASE NOTE: You can skip this introductory " < "information by entering CISAGREE\r\nat the Host " < "Name prompt in the future.\r\n"); < Display_Text_File (ExplainBitRate); --- > int > Perform_Dialogs () > { > if (!Get_First_Prompt ()) { > sleep (1); > exit (0); > } > Write_String_to_Socket ("\r\nPLEASE NOTE: You can skip this introductory " > "information by entering CISAGREE\r\nat the Host " > "Name prompt in the future.\r\n"); > Display_Text_File (ExplainBitRate); > > return 0; > } > 1019,1021d1000 < return 0; < } < 1025c1004,1005 < int Get_Password () --- > int > Get_Password () 1027,1038c1007,1011 < char resp[128]; < char *sp; < int cnt = 0; < int TtyFd; < struct termios TtyTermios; < < if ((TtyFd = open ("/dev/tty", O_RDWR)) < 0) < { < printf ("\nCould not open tty"); < fflush (stdout); < exit (1); < } --- > char resp[128]; > char *sp; > int cnt = 0; > int TtyFd; > struct termios TtyTermios; 1040,1041c1013,1019 < resp[0] = '\0'; < sp = trimlower(resp, sizeof(resp)); --- > if ((TtyFd = open ("/dev/tty", O_RDWR)) < 0) { > printf ("\nCould not open tty"); > fflush (stdout); > exit (1); > } > resp[0] = '\0'; > sp = trimlower (resp, sizeof (resp)); 1043,1088c1021,1022 < while (strncmp (sp, "not a chance!", 13) && cnt < 3) < { < printf ("Please enter test password: (required only during beta test) "); < < if (tcgetattr (TtyFd, &TtySettings) < 0) < { < printf ("\nCould not start to turn off echo"); < exit (1); < } < < TtyTermios = TtySettings; /* make working copy of structure */ < TtyTermios.c_lflag &= ~ECHO; < < if (tcsetattr (TtyFd, TCSANOW, &TtyTermios) < 0) < { < printf ("\nCould not turn off echo"); < fflush (stdout); < exit (1); < } < < fflush (stdout); < < resp[0] = '\0'; < if ( NULL == fgets (resp, 128, stdin)) exit(-1); < sp = trimlower(resp, sizeof(resp)); < < if (tcgetattr (TtyFd, &TtySettings) < 0) < { < printf ("\nCould not start to turn on echo"); < fflush (stdout); < exit (1); < } < < TtyTermios = TtySettings; /* make working copy of structure */ < TtyTermios.c_lflag |= ECHO; < < if (tcsetattr (TtyFd, TCSANOW, &TtyTermios) < 0) < { < printf ("\nCould not turn on echo"); < fflush (stdout); < exit (1); < } < printf ("\n"); < fflush (stdout); < cnt++; < } --- > while (strncmp (sp, "not a chance!", 13) && cnt < 3) { > printf ("Please enter test password: (required only during beta test) "); 1090c1024,1036 < close (TtyFd); --- > if (tcgetattr (TtyFd, &TtySettings) < 0) { > printf ("\nCould not start to turn off echo"); > exit (1); > } > TtyTermios = TtySettings; /* make working copy of structure */ > TtyTermios.c_lflag &= ~ECHO; > > if (tcsetattr (TtyFd, TCSANOW, &TtyTermios) < 0) { > printf ("\nCould not turn off echo"); > fflush (stdout); > exit (1); > } > fflush (stdout); 1092,1096c1038,1059 < if (strncmp (resp, "not a chance!", 13) == 0) < { < Display_Text_File (GetPasswordGood); < return (1); < } --- > resp[0] = '\0'; > if (NULL == fgets (resp, 128, stdin)) > exit (-1); > sp = trimlower (resp, sizeof (resp)); > > if (tcgetattr (TtyFd, &TtySettings) < 0) { > printf ("\nCould not start to turn on echo"); > fflush (stdout); > exit (1); > } > TtyTermios = TtySettings; /* make working copy of structure */ > TtyTermios.c_lflag |= ECHO; > > if (tcsetattr (TtyFd, TCSANOW, &TtyTermios) < 0) { > printf ("\nCould not turn on echo"); > fflush (stdout); > exit (1); > } > printf ("\n"); > fflush (stdout); > cnt++; > } 1098c1061 < Display_Text_File (GetPasswordBad); --- > close (TtyFd); 1100c1063,1069 < return (0); --- > if (strncmp (resp, "not a chance!", 13) == 0) { > Display_Text_File (GetPasswordGood); > return (1); > } > Display_Text_File (GetPasswordBad); > > return (0); 1102c1071,1072 < --- > > 1104,1110c1074,1077 < * Functional Description: < * main < * < * Formal Parameters: < * argc < * argv < * --- > * Functional Description: main > * > * Formal Parameters: argc argv > * 1112,1113c1079,1080 < * < * --- > * > * 1115,1116c1082,1083 < * < * --- > * > * 1118c1085 < * --- > * 1121c1088,1089 < int Get_First_Prompt () --- > int > Get_First_Prompt () 1123,1130c1091,1092 < char resp[128]; < char *sp; < < /* < * This prompt is for agreement to abide by whatever policies and < * rules the orginating domain may impose on the user. < */ < Display_Text_File (GetFirstPrompt1); --- > char resp[128]; > char *sp; 1132,1135c1094,1118 < /* < * WLC: I did not put this goto here. < */ < I_Hate_Gotos: --- > /* > * This prompt is for agreement to abide by whatever policies and rules the > * orginating domain may impose on the user. > */ > Display_Text_File (GetFirstPrompt1); > > /* > * WLC: I did not put this goto here. > */ > I_Hate_Gotos: > Display_Text_File (GetFirstPrompt2); > > Write_String_to_Socket ("Enter choice (LOGON, HELP, OFF): "); > Read_String_from_Socket_and_Echo (resp, 128); > > sp = trimlower (resp, sizeof (resp)); > > while ((0 != strcmp (sp, "off")) && > (0 != strcmp (sp, "bye")) && > (0 != strcmp (sp, "exit")) && > (0 != strcmp (sp, "help")) && > (0 != strcmp (sp, "logon")) && > (0 != strcmp (sp, "?"))) { > Write_String_to_Socket ("You must enter either OFF, LOGON, or " > "HELP.\n"); 1138a1122 > 1141c1125,1126 < sp = trimlower(resp, sizeof(resp)); --- > sp = trimlower (resp, sizeof (resp)); > } 1143,1180c1128,1129 < while ( (0 != strcmp(sp, "off")) && < (0 != strcmp(sp, "bye")) && < (0 != strcmp(sp, "exit")) && < (0 != strcmp(sp, "help")) && < (0 != strcmp(sp, "logon")) && < (0 != strcmp(sp, "?"))) < { < Write_String_to_Socket ("You must enter either OFF, LOGON, or " < "HELP.\n"); < Display_Text_File (GetFirstPrompt2); < < Write_String_to_Socket ("Enter choice (LOGON, HELP, OFF): "); < < Read_String_from_Socket_and_Echo (resp, 128); < < sp = trimlower(resp, sizeof(resp)); < } < < if (0 == strcmp(sp, "logon")) < return (1); < < if (strcmp(sp, "help") && *sp != '?') < { < Write_String_to_Socket ("We are terminating the connection at this " < "time as you requested.\r\n"); < return (0); < } < < if (!Get_Help ()) < return (0); < goto I_Hate_Gotos; < < } < < int Get_Agreement_Text () < { < char resp[128]; < char *sp; --- > if (0 == strcmp (sp, "logon")) > return (1); 1182,1185c1131,1147 < /* < * This prompt is for agreement to abide by whatever policies and < * rules the orginating domain may impose on the user. < */ --- > if (strcmp (sp, "help") && *sp != '?') { > Write_String_to_Socket ("We are terminating the connection at this " > "time as you requested.\r\n"); > return (0); > } > if (!Get_Help ()) > return (0); > goto I_Hate_Gotos; > > } > > > int > Get_Agreement_Text () > { > char resp[128]; > char *sp; 1187c1149,1167 < Display_Text_File (GetAgreeText1); --- > /* > * This prompt is for agreement to abide by whatever policies and rules the > * orginating domain may impose on the user. > */ > > Display_Text_File (GetAgreeText1); > printf ("Press the Enter or Return key for more: "); > if (NULL == fgets (resp, 128, stdin)) > exit (-1); > sp = trimlower (resp, 128); > > while ((0 != strcmp (sp, "off")) && > (0 != strcmp (sp, "bye")) && > (0 != strcmp (sp, "exit")) && > (0 != strcmp (sp, "help")) && > (0 != strcmp (sp, "?")) && > (*sp != NULL)) { > printf ("Enter OFF to terminate the connection or press the Enter or Return key"); > printf ("to continue.\n\n"); 1189,1212c1169,1172 < if (NULL == fgets(resp,128,stdin)) < exit(-1); < sp = trimlower(resp,128); < < while ((0 != strcmp(sp, "off")) && < (0 != strcmp(sp, "bye")) && < (0 != strcmp(sp, "exit")) && < (0 != strcmp(sp, "help")) && < (0 != strcmp(sp, "?")) && < (*sp != NULL)) < { < printf ("Enter OFF to terminate the connection or press the Enter or Return key"); < printf ("to continue.\n\n"); < printf ("Press the Enter or Return key for more: "); < if ( NULL == fgets( resp, 128, stdin)) exit(-1); < sp = trimlower( resp, 128); < } < < if (*sp !='\0' && strcmp(sp,"help") && *sp != '?') < { < printf ("We are terminating the connection at this time as you requested.\r\n"); < fflush (stdout); < return (0); < } --- > if (NULL == fgets (resp, 128, stdin)) > exit (-1); > sp = trimlower (resp, 128); > } 1214c1174,1192 < Display_Text_File (GetAgreeText2); --- > if (*sp != '\0' && strcmp (sp, "help") && *sp != '?') { > printf ("We are terminating the connection at this time as you requested.\r\n"); > fflush (stdout); > return (0); > } > Display_Text_File (GetAgreeText2); > printf ("Press the Enter or Return key for more: "); > if (NULL == fgets (resp, 128, stdin)) > exit (-1); > sp = trimlower (resp, 128); > > while ((0 != strcmp (sp, "off")) && > (0 != strcmp (sp, "bye")) && > (0 != strcmp (sp, "exit")) && > (0 != strcmp (sp, "help")) && > (0 != strcmp (sp, "?")) && > (*sp != '\0')) { > puts ("Enter OFF to terminate the connection or press the Enter or" > " Return key\nto continue.\r\n"); 1216,1217c1194,1197 < if ( NULL == fgets( resp, 128, stdin)) exit(-1); < sp = trimlower( resp, 128); --- > if (NULL == fgets (resp, 128, stdin)) > exit (-1); > sp = trimlower (resp, 128); > } 1219,1231c1199,1206 < while ( (0 != strcmp(sp, "off")) && < (0 != strcmp(sp, "bye")) && < (0 != strcmp(sp, "exit")) && < (0 != strcmp(sp, "help")) && < (0 != strcmp(sp, "?")) && < (*sp != '\0')) < { < puts ("Enter OFF to terminate the connection or press the Enter or" < " Return key\nto continue.\r\n"); < printf ("Press the Enter or Return key for more: "); < if ( NULL == fgets( resp, 128, stdin)) exit(-1); < sp = trimlower( resp, 128); < } --- > if (*sp != '\0' && strcmp (sp, "help") && *sp != '?') { > printf ("We are terminating the connection at this time as you requested.\r\n"); > fflush (stdout); > return (0); > } > Display_Text_File (GetAgreeText3); > return (1); > } 1233,1238d1207 < if (*sp !='\0' && strcmp(sp,"help") && *sp != '?') < { < printf ("We are terminating the connection at this time as you requested.\r\n"); < fflush (stdout); < return (0); < } 1240,1243d1208 < Display_Text_File (GetAgreeText3); < return (1); < } < 1245,1251c1210,1213 < * Functional Description: < * main < * < * Formal Parameters: < * argc < * argv < * --- > * Functional Description: main > * > * Formal Parameters: argc argv > * 1253,1254c1215,1216 < * < * --- > * > * 1256,1257c1218,1219 < * < * --- > * > * 1259c1221 < * --- > * 1262c1224,1225 < int Get_Agreement () --- > int > Get_Agreement () 1264,1266c1227,1229 < char resp[128]; < char *sp; < int ic = 0; --- > char resp[128]; > char *sp; > int ic = 0; 1268,1269c1231,1235 < resp[0] = '\0'; < sp = resp; --- > resp[0] = '\0'; > sp = resp; > > if (!Get_Agreement_Text ()) > return (0); 1271c1237,1248 < if (!Get_Agreement_Text()) return(0); --- > Write_String_to_Socket ("Enter choice (AGREE or OFF): "); > Read_String_from_Socket_and_Echo (resp, 128); > sp = trimlower (resp, 128); > > while (strcmp (sp, "agree") != 0 && > strcmp (sp, "bye") != 0 && > strcmp (sp, "exit") != 0 && > strcmp (sp, "off") != 0 && > ic < 3) { > Write_String_to_Socket ("You must enter AGREE to indicate that you " > "have reviewed these terms, or\r\nelse enter " > "OFF to terminate the connection.\r\n"); 1272a1250,1251 > if (!Get_Agreement_Text ()) > return (0); 1275c1254,1256 < sp = trimlower( resp, 128); --- > sp = trimlower (resp, 128); > ic++; > } 1277,1305c1258,1272 < while (strcmp(sp,"agree") != 0 && < strcmp(sp,"bye") != 0 && < strcmp(sp,"exit") != 0 && < strcmp(sp,"off") != 0 && < ic < 3) < { < Write_String_to_Socket ("You must enter AGREE to indicate that you " < "have reviewed these terms, or\r\nelse enter " < "OFF to terminate the connection.\r\n"); < < if (!Get_Agreement_Text()) < return(0); < Write_String_to_Socket ("Enter choice (AGREE or OFF): "); < Read_String_from_Socket_and_Echo (resp, 128); < sp = trimlower( resp, 128); < ic++; < } < < if (strcmp (sp, "agree") != 0) < { < Write_String_to_Socket ("We are terminating the connection at this " < "time as you requested.\r\n"); < return (0); < } < < Write_String_to_Socket ("PLEASE NOTE: You can skip the review of these " < "precautions by entering\r\n"); < Write_String_to_Socket ("CISAGREE at the Host Name prompt in the " < "future.\r\n"); --- > if (strcmp (sp, "agree") != 0) { > Write_String_to_Socket ("We are terminating the connection at this " > "time as you requested.\r\n"); > return (0); > } > Write_String_to_Socket ("PLEASE NOTE: You can skip the review of these " > "precautions by entering\r\n"); > Write_String_to_Socket ("CISAGREE at the Host Name prompt in the " > "future.\r\n"); > > /* This is the BIT Rate Explanation */ > Display_Text_File (ExplainBitRate); > > return (1); > } 1307,1308d1273 < /* This is the BIT Rate Explanation */ < Display_Text_File (ExplainBitRate); 1310,1312d1274 < return (1); < } < 1315,1322c1277,1282 < * Functional Description: < * Put up a "menu" of informational topics that the user can request < * to have mailed to their internet mail network address. The menu < * support logic is *very* rudimentary. < * < * Formal Parameters: < * None < * --- > * Functional Description: Put up a "menu" of informational topics that the > * user can request to have mailed to their internet mail network address. > * The menu support logic is *very* rudimentary. > * > * Formal Parameters: None > * 1324,1333c1284,1290 < * < * < * Return Value: < * 1 - user wants to go back to the membership prompt < * 0 - disconnect user from this session < * < * Side Effects: < * records the origin ip address and the target mail request specified < * in the syslog facility. < * makes a system call to "/usr/bin/mail" --- > * > * > * Return Value: 1 - user wants to go back to the membership prompt 0 - > * disconnect user from this session > * > * Side Effects: records the origin ip address and the target mail request > * specified in the syslog facility. makes a system call to "/usr/bin/mail" 1335,1438c1292,1328 < int Get_Help () < { < char resp[128]; < char file[128]; < char *sp; < int mail_selection[8] = < {0, 0, 0, 0, 0, 0, 0, 0}; < int mail_selection_size = (sizeof(mail_selection)/sizeof(int)); < int i; < < /* < * Help introduction... < */ < Display_Text_File (GetHelpText1); < Display_Help_Menu (); < < resp[0] = 'x'; /* Force the next loop to execute the first time */ < sp = trimlower(resp, sizeof(resp)); < i=0; < < /* < * Process the menu request. < */ < while (*sp != '1' && strcmp(sp, "off") && < strcmp(sp, "bye") && strcmp(sp, "exit") && < *sp != '2' && *sp != '3' && < *sp != '4' && *sp != '5' && < *sp != '6' && *sp != '\0') < { < if (i > 0) < { < Write_String_to_Socket ("\nYou must enter a blank line, number(s) " < "between 1 and 6, or OFF.\r\n"); < } < < i++; < < Write_String_to_Socket (GetHelpPrompt1); < Read_String_from_Socket_and_Echo (resp, 128); < sp = trimlower(resp, sizeof(resp)); < } /* while */ < < if (*sp == '\0') < { < Write_String_to_Socket ("You have not selected any articles.\r\n"); < return 1; < } < < if (0 == strcmp(sp, "off") || < 0 == strcmp(sp,"exit") || < 0 == strcmp(sp, "bye") ) < { < Write_String_to_Socket ("We are terminating the connection at this " < "time as you requested.\r\n"); < return (0); < } < < /* Set up the list of requested entries */ < for (i = 0; i < strlen (sp); i++) < { < < if (!isdigit(sp[i])) < { < sp[i] = ' '; < } < < switch (sp[i]) < { < case ',': < case ' ': < break; < case '1': < mail_selection[1] = 1; < break; < case '2': < mail_selection[2] = 1; < break; < case '3': < mail_selection[3] = 1; < break; < case '4': < mail_selection[4] = 1; < break; < case '5': < mail_selection[5] = 1; < break; < case '6': < mail_selection[6] = 1; < break; < default: < break; < } < } < < /* < * Tell the user about our plan to internet mail the information < * to them, and then get their address < */ < Display_Text_File (GetHelpText3); < < resp[0] = '\0'; < < printf ("Enter choice (blank line, Electronic Mail Address or Off): "); < fflush (stdout); --- > int > Get_Help () > { > char resp[128]; > char file[128]; > char *sp; > int mail_selection[8] = > {0, 0, 0, 0, 0, 0, 0, 0}; > int mail_selection_size = (sizeof (mail_selection) / sizeof (int)); > int i; > > /* > * Help introduction... > */ > Display_Text_File (GetHelpText1); > Display_Help_Menu (); > > resp[0] = 'x'; /* Force the next loop to execute the first > * time */ > sp = trimlower (resp, sizeof (resp)); > i = 0; > > /* > * Process the menu request. > */ > while (*sp != '1' && strcmp (sp, "off") && > strcmp (sp, "bye") && strcmp (sp, "exit") && > *sp != '2' && *sp != '3' && > *sp != '4' && *sp != '5' && > *sp != '6' && *sp != '\0') { > if (i > 0) { > Write_String_to_Socket ("\nYou must enter a blank line, number(s) " > "between 1 and 6, or OFF.\r\n"); > } > i++; > > Write_String_to_Socket (GetHelpPrompt1); 1440,1457c1330,1331 < sp = trimlower (resp, sizeof(resp)); < < if (0 == strcmp(sp, "off") || < 0 == strcmp(sp, "exit") || < 0 == strcmp(sp, "bye")) < { < printf ("We are terminating the connection at this time as you " < "requested.\r\n"); < fflush (stdout); < return (0); < } < < if (*sp == '\0') < { < printf ("\r\nNo articles will be sent to you.\r\n"); < fflush (stdout); < return(1); < } --- > sp = trimlower (resp, sizeof (resp)); > } /* while */ 1459,1462c1333,1345 < /* < * This is where we would check for an address format if there was a < * reasonablness test available... < */ --- > if (*sp == '\0') { > Write_String_to_Socket ("You have not selected any articles.\r\n"); > return 1; > } > if (0 == strcmp (sp, "off") || > 0 == strcmp (sp, "exit") || > 0 == strcmp (sp, "bye")) { > Write_String_to_Socket ("We are terminating the connection at this " > "time as you requested.\r\n"); > return (0); > } > /* Set up the list of requested entries */ > for (i = 0; i < strlen (sp); i++) { 1464,1484c1347,1375 < for (i = 1; i < mail_selection_size; i++) < { < if (mail_selection[i]) < { < strcpy (file, LOCATION_OF_TEXT_FILES); < strcat (file, "mail_selection.0"); < file[strlen (file) - 1] = '0' + i; < { < char buf[128]; < < syslog (LOG_INFO, "%s %d - info - sending help file %d to" < " address %s", __FILE__, __LINE__, i, sp); < < sprintf (buf, "cat %s 2>/dev/null | /usr/bin/mail " < "-s \"CIS Information\" %s >/dev/null 2>&1", < file, sp); < < system (buf); < } < } < } --- > if (!isdigit (sp[i])) { > sp[i] = ' '; > } > switch (sp[i]) { > case ',': > case ' ': > break; > case '1': > mail_selection[1] = 1; > break; > case '2': > mail_selection[2] = 1; > break; > case '3': > mail_selection[3] = 1; > break; > case '4': > mail_selection[4] = 1; > break; > case '5': > mail_selection[5] = 1; > break; > case '6': > mail_selection[6] = 1; > break; > default: > break; > } > } 1486,1492c1377,1394 < Display_Text_File (GetHelpText4); < return (1); < } < < void timedout () < { < printf ("\r\n\nCannot take more than 2 minutes to Log-in\r\n\n"); --- > /* > * Tell the user about our plan to internet mail the information to them, > * and then get their address > */ > Display_Text_File (GetHelpText3); > > resp[0] = '\0'; > > printf ("Enter choice (blank line, Electronic Mail Address or Off): "); > fflush (stdout); > Read_String_from_Socket_and_Echo (resp, 128); > sp = trimlower (resp, sizeof (resp)); > > if (0 == strcmp (sp, "off") || > 0 == strcmp (sp, "exit") || > 0 == strcmp (sp, "bye")) { > printf ("We are terminating the connection at this time as you " > "requested.\r\n"); 1494c1396,1424 < exit (EXIT_FAILURE); --- > return (0); > } > if (*sp == '\0') { > printf ("\r\nNo articles will be sent to you.\r\n"); > fflush (stdout); > return (1); > } > /* > * This is where we would check for an address format if there was a > * reasonablness test available... > */ > > for (i = 1; i < mail_selection_size; i++) { > if (mail_selection[i]) { > strcpy (file, LOCATION_OF_TEXT_FILES); > strcat (file, "mail_selection.0"); > file[strlen (file) - 1] = '0' + i; > { > char buf[128]; > > syslog (LOG_INFO, "%s %d - info - sending help file %d to" > " address %s", __FILE__, __LINE__, i, sp); > > sprintf (buf, "cat %s 2>/dev/null | /usr/bin/mail " > "-s \"CIS Information\" %s >/dev/null 2>&1", > file, sp); > > system (buf); > } 1496c1426,1441 < --- > } > > Display_Text_File (GetHelpText4); > return (1); > } > > > void > timedout () > { > printf ("\r\n\nCannot take more than 2 minutes to Log-in\r\n\n"); > fflush (stdout); > exit (EXIT_FAILURE); > } > > 1498,1505c1443,1448 < * Functional Description: < * Simulate the CompuServe Network Host Name prompt. Doing so < * allows script developers to write scripts now that will still < * work if BSG access is permitted in the future. < * < * Formal Parameters: < * none < * --- > * Functional Description: Simulate the CompuServe Network Host Name prompt. > * Doing so allows script developers to write scripts now that will still > * work if BSG access is permitted in the future. > * > * Formal Parameters: none > * 1507,1516c1450,1456 < * < * < * Return Value: < * HOSTNAME_BAD - selected service is not one of: < * CIS, CPS, or CISAGREE < * HOSTNAME_CIS - user selected CIS or CPS service < * HOSTNAME_AGREE - user entered CISAGREE < * < * Side Effects: < * performs an I/O request to the user --- > * > * > * Return Value: HOSTNAME_BAD - selected service is not one of: CIS, CPS, or > * CISAGREE HOSTNAME_CIS - user selected CIS or CPS service HOSTNAME_AGREE - > * user entered CISAGREE > * > * Side Effects: performs an I/O request to the user 1519,1523c1459,1480 < int Get_Service () < { < char resp[128]; /* A response from the user. */ < char *sp; /* I suppose this stands for string pointer. */ < int service_index; /* Index to the HostNameList array. */ --- > int > Get_Service () > { > char resp[128]; /* A response from the user. */ > char *sp; /* I suppose this stands for string pointer. */ > int service_index;/* Index to the HostNameList array. */ > > /* > * Set up the signal handler function, timeout, for the signal SIGALRM, > * which will be generated if the alarm that we will set goes off. > */ > if (signal (SIGALRM, timedout) == SIG_ERR) { > syslog (LOG_ERR, "%s %d - err - function signal caused system error" > " `%m' trying to register signal handler for Host Name prompt" > " time out alarm", __FILE__, __LINE__); > exit (EXIT_FAILURE); > } > /* > * The following while loop forces the user to enter correct input at the > * "Host Name:" prompt that it displays. > */ > while (TRUE) { 1526,1527c1483,1484 < * Set up the signal handler function, timeout, for the signal SIGALRM, < * which will be generated if the alarm that we will set goes off. --- > * We are going to display a new "Host Name:" prompt so we must reset the > * timeout alarm. 1529,1535c1486,1490 < if (signal (SIGALRM, timedout) == SIG_ERR) < { < syslog (LOG_ERR, "%s %d - err - function signal caused system error" < " `%m' trying to register signal handler for Host Name prompt" < " time out alarm", __FILE__, __LINE__); < exit (EXIT_FAILURE); < } --- > alarm (120); > > Write_String_to_Socket ("Host Name: "); > > Read_String_from_Socket_and_Echo (resp, sizeof (resp)); 1538,1539c1493,1495 < * The following while loop forces the user to enter correct input at the < * "Host Name:" prompt that it displays. --- > * We recieved some input so we better turn off the alarm now. It will > * get turned back on at the top of the loop if the top of the loop is > * reached again. 1541,1542c1497 < while (TRUE) < { --- > alarm (0); 1544,1587c1499,1512 < /* < * We are going to display a new "Host Name:" prompt so we must reset < * the timeout alarm. < */ < alarm (120); < < Write_String_to_Socket ("Host Name: "); < < Read_String_from_Socket_and_Echo (resp, sizeof(resp)); < < /* < * We recieved some input so we better turn off the alarm now. It will < * get turned back on at the top of the loop if the top of the loop is < * reached again. < */ < alarm (0); < < sp = trimlower(resp, sizeof(resp)); /* resp is no longer valid */ < service_index = match(sp, HostNameList); < if (service_index) < { < /* < * A valid host name (service) was entered. < */ < signal (SIGALRM, SIG_DFL); /* reset handler before return */ < return (service_index); < } < else if (!strcmp(sp,"off") || !strcmp(sp,"exit") || !strcmp(sp,"bye")) < { < Write_String_to_Socket ("We are terminating the connection at this" < "time as you requested.\r\n"); < signal (SIGALRM, SIG_DFL); /* reset handler before return */ < return (HOSTNAME_BAD); < } < < /* < * Nothing useful was entered, so display a help message if the < * response is not null. < */ < if (strcmp(sp,"") != 0) < { < Display_Text_File ("inetcis.text.host_name_help"); < } < } /* end while */ --- > sp = trimlower (resp, sizeof (resp)); /* resp is no longer valid */ > service_index = match (sp, HostNameList); > if (service_index) { > /* > * A valid host name (service) was entered. > */ > signal (SIGALRM, SIG_DFL);/* reset handler before return */ > return (service_index); > } else if (!strcmp (sp, "off") || !strcmp (sp, "exit") > || !strcmp (sp, "bye")) { > Write_String_to_Socket ("We are terminating the connection at this" > " time as you requested.\r\n"); > signal (SIGALRM, SIG_DFL);/* reset handler before return */ > return (HOSTNAME_BAD); 1589,1590c1514,1526 < < void Display_Help_Menu () --- > /* > * Nothing useful was entered, so display a help message if the response > * is not null. > */ > if (strcmp (sp, "") != 0) { > Display_Text_File ("inetcis.text.host_name_help"); > } > } /* end while */ > } > > > void > Display_Help_Menu () 1593,1596c1529,1532 < * < * Displays the help menu, including the date and time of last < * of each of the selections. < * --- > * > * Displays the help menu, including the date and time of last of each of the > * selections. > * 1598,1600c1534,1536 < * < * none < * --- > * > * none > * 1602,1604c1538,1540 < * < * none < * --- > * > * none > * 1606,1608c1542,1544 < * < * none < * --- > * > * none > * 1610,1611c1546,1547 < * < * none --- > * > * none 1614,1684c1550,1605 < { < const char help_menu_pretext[] = "\r\nTo obtain additional information," < " select the article(s) of interest from the\r\nfollowing list and they" < " will be sent to you via electronic mail.\r\n"; < const char *help_menu_selection[] = < { < " 1 CompuServe Overview", < " 2 CompuServe Information Service Overview", < " 3 How To Obtain a CompuServe Information Service Membership", < " 4 CompuServe Information Service Rates", < " 5 Exchanging E-Mail between Internet and CompuServe", < " 6 Internet Press Release" < }; < const int number_of_selections = 6; < const char help_menu_posttext[] = < "\r\nTo select items from the menu, enter " < "one or more of the corresponding numbers\r\nseparated by commas and " < "followed by the Enter or Return key. To leave this\r\nmenu without " < "selecting any articles, simply press the Enter or Return key.\r\nTo " < "terminate your connection, enter OFF followed by the Enter or Return " < "key.\r\n"; < int i; < struct stat help_file_info; < char help_file_name[256]; < struct tm *modification_time_ptr; < char time_output_string[256]; < < Write_String_to_Socket ("%s\r\n", help_menu_pretext); < strcpy (help_file_name, LOCATION_OF_TEXT_FILES); < strcat (help_file_name, "mail_selection.0"); < for (i=1; i<=number_of_selections; i++) < { < < /* < * Convert i to a char and add it to the name of the help file. < */ < help_file_name[strlen(help_file_name) - 1] = (char) i+48; < < /* < * This is a POSIX system call that gets information about a file and < * puts it in the structure help_file_info. It is defined in < * sys/stat.h. < */ < if ( stat(help_file_name,&help_file_info) == 0 /* 0 is NO ERROR */) < { < /* < * Put the time in struct tm format instead of time_t format so the < * individual pieces can be accessed. < */ < modification_time_ptr = localtime(&help_file_info.st_mtime); < < /* < * Convert the modification time to the format that is needed for < * displaying it. < */ < strftime (time_output_string, 10, "%d-%b-%y", < modification_time_ptr); < } < else < { < strcpy (time_output_string, "not available"); < } < < /* < * Display the whole line. < */ < Write_String_to_Socket ("%s (%s)\r\n", help_menu_selection[i-1], < time_output_string); < } < < Write_String_to_Socket ("%s\r\n", help_menu_posttext); --- > { > const char help_menu_pretext[] = "\r\nTo obtain additional information," > " select the article(s) of interest from the\r\nfollowing list and they" > " will be sent to you via electronic mail.\r\n"; > const char *help_menu_selection[] = > { > " 1 CompuServe Overview", > " 2 CompuServe Information Service Overview", > " 3 How To Obtain a CompuServe Information Service Membership", > " 4 CompuServe Information Service Rates", > " 5 Exchanging E-Mail between Internet and CompuServe", > " 6 Internet Press Release" > }; > const int number_of_selections = 6; > const char help_menu_posttext[] = > "\r\nTo select items from the menu, enter " > "one or more of the corresponding numbers\r\nseparated by commas and " > "followed by the Enter or Return key. To leave this\r\nmenu without " > "selecting any articles, simply press the Enter or Return key.\r\nTo " > "terminate your connection, enter OFF followed by the Enter or Return " > "key.\r\n"; > int i; > struct stat help_file_info; > char help_file_name[256]; > struct tm *modification_time_ptr; > char time_output_string[256]; > > Write_String_to_Socket ("%s\r\n", help_menu_pretext); > strcpy (help_file_name, LOCATION_OF_TEXT_FILES); > strcat (help_file_name, "mail_selection.0"); > for (i = 1; i <= number_of_selections; i++) { > > /* > * Convert i to a char and add it to the name of the help file. > */ > help_file_name[strlen (help_file_name) - 1] = (char) i + 48; > > /* > * This is a POSIX system call that gets information about a file and > * puts it in the structure help_file_info. It is defined in sys/stat.h. > */ > if (stat (help_file_name, &help_file_info) == 0 /* 0 is NO ERROR */ ) { > /* > * Put the time in struct tm format instead of time_t format so the > * individual pieces can be accessed. > */ > modification_time_ptr = localtime (&help_file_info.st_mtime); > > /* > * Convert the modification time to the format that is needed for > * displaying it. > */ > strftime (time_output_string, 10, "%d-%b-%y", > modification_time_ptr); > } else { > strcpy (time_output_string, "not available"); 1686a1608,1613 > /* > * Display the whole line. > */ > Write_String_to_Socket ("%s (%s)\r\n", help_menu_selection[i - 1], > time_output_string); > } 1687a1615,1616 > Write_String_to_Socket ("%s\r\n", help_menu_posttext); > } 1690,1696d1618 < < void Read_Asterisk_Prompt () < { < int character_count; < int stripped_character_count; < char stripped_buffer[BUFSIZE]; < char buffer[BUFSIZE]; 1698,1701c1620,1624 < /* < * The following code sets up an alarm to interrupt the read that comes < * after it. < */ --- > /* > * Read_Asterisk_Prompt and associated functions need to be removed as > * they are not being used anymore. Just need to wait until Read_PAD_Prompt > * is tested. > */ 1703,1719d1625 < if (signal (SIGALRM, Alarm_Signal_Handler) == SIG_ERR) < { < syslog (LOG_ERR, "%s %d - err - function signal caused system" < " error `%m' trying to define signal handler" < " Alarm_Signal_Handler", __FILE__, __LINE__); < fprintf (stderr, "? %sSIG Failed to assign signal handler%s", < PROGRAM_ID_FOR_ERRORS, OUTPUT_LINE_TERMINATOR); < exit (EXIT_FAILURE); < } < if (setjmp(asterisk_read_timeout) != 0) < { < fprintf (stderr, "? %sATM Timeout waiting for response from node%s", < PROGRAM_ID_FOR_ERRORS, OUTPUT_LINE_TERMINATOR); < syslog (LOG_ERR, "%s %d - err - timed out code for reading asterisk" < " prompt invoked"); < exit (EXIT_FAILURE); < } 1721c1627 < alarm (30); --- > int number_of_timeouts = 0; 1723,1757c1629,1649 < /* < * The following reads from the X.25 device repeatedly. The device is in < * non-blocking mode, so when the read is done it will immediately return < * if there is nothing there, so it must loop until it gets something. < * The first piece of data should be the echo of the xset command done < * above, but we don't care about that. All we care about is getting the < * asterisk prompt back so we can do the following write. That is what < * the loop will wait for. If it doesn't read it in a certain amount of < * time is should interrupt itself. < */ < < stripped_character_count = 1; /* must be non-zero for first strncmp */ < strcpy (stripped_buffer, ""); < while (strncmp("*",stripped_buffer,stripped_character_count) != 0) < { < character_count = read (DevFd, buffer, BUFSIZE); < if (character_count < 0) < { < if (errno != EWOULDBLOCK) < { < syslog (LOG_ERR, "%s %d - err - function read caused" < " system error `%m' trying to read asterisk prompt" < __FILE__, __LINE__); < fprintf (stderr, "? %sREN Error reading from network%s", < PROGRAM_ID_FOR_ERRORS, OUTPUT_LINE_TERMINATOR); < exit (EXIT_FAILURE); < } < } < else < { < Strip_Leading_CRs_And_LFs (buffer, stripped_buffer, < character_count, < &stripped_character_count); < } < } /* while */ --- > void > Read_Asterisk_Prompt (int *DevFd) > { > int character_count; > int stripped_character_count; > char stripped_buffer[MAXSTRLEN + 1]; > char buffer[MAXSTRLEN + 1]; > > /* > * The following code sets up an alarm to interrupt the read that comes > * after it. > */ > if (signal (SIGALRM, Alarm_Signal_Handler) == SIG_ERR) { > syslog (LOG_ERR, "%s %d - err - function signal caused system" > " error `%m' trying to define signal handler" > " Alarm_Signal_Handler", __FILE__, __LINE__); > fprintf (stderr, "? %sSIG Failed to assign signal handler%s", > PROGRAM_ID_FOR_ERRORS, OUTPUT_LINE_TERMINATOR); > exit (EXIT_FAILURE); > } > alarm (5); 1758a1651,1701 > /* > * The following reads from the X.25 device repeatedly. The device is in > * non-blocking mode, so when the read is done it will immediately return > * if there is nothing there, so it must loop until it gets something. The > * first piece of data should be the echo of the xset command done above, > * but we don't care about that. All we care about is getting the asterisk > * prompt back so we can do the following write. That is what the loop > * will wait for. If it doesn't read it in a certain amount of time is > * should interrupt itself. > */ > > stripped_character_count = 1; /* must be non-zero for first strncmp */ > strcpy (stripped_buffer, ""); > while (strncmp ("*", stripped_buffer, stripped_character_count) != 0) { > character_count = read (*DevFd, buffer, MAXSTRLEN); > if (character_count < 0) { > switch (errno) { > case EAGAIN: > continue; > break; > case EINTR: > continue; > break; > default: > Write_System_Error_To_Log (LOG_LEVEL_ERR, __FILE__, __LINE__, > errno, "asterisk", "read", "REN", > "Error reading from network"); > exit (EXIT_FAILURE); > } > } else { > buffer[character_count] = 0; > Write_Va_Message_To_Log (LOG_LEVEL_DEBUG1, __FILE__, __LINE__, > "Read_Asterisk_Prompt read: %s", > buffer); > Strip_Leading_CRs_And_LFs (buffer, stripped_buffer, > character_count, > &stripped_character_count); > } > } /* while */ > > > alarm (0); > if (signal (SIGALRM, SIG_DFL) == SIG_ERR) { > syslog (LOG_ERR, "%s %d - err - function signal caused system error" > " `%m' trying to define signal handler SIG_DFL", > __FILE__, __LINE__); > fprintf (stderr, "? %sSG2 Failed to assign signal handler%s", > PROGRAM_ID_FOR_ERRORS, OUTPUT_LINE_TERMINATOR); > exit (EXIT_FAILURE); > } > } /* end of Read_Asterisk_Prompt */ 1760,1775c1703,1716 < alarm (0); < if (signal(SIGALRM,SIG_DFL) == SIG_ERR) < { < syslog (LOG_ERR, "%s %d - err - function signal caused system error" < " `%m' trying to define signal handler SIG_DFL", < __FILE__, __LINE__); < fprintf (stderr, "? %sSG2 Failed to assign signal handler%s", < PROGRAM_ID_FOR_ERRORS, OUTPUT_LINE_TERMINATOR); < exit (EXIT_FAILURE); < } < } /* end of Read_Asterisk_Prompt */ < < void Alarm_Signal_Handler (int signo) < { < longjmp (asterisk_read_timeout, 1); < } --- > void > Alarm_Signal_Handler (int signo) > { > if (number_of_timeouts == 1) { > Write_Error_To_Log (LOG_LEVEL_CRIT, __FILE__, __LINE__, "asterisk", > "timeout", "ATM", > "Timeout waiting for response from node"); > exit (EXIT_FAILURE); > } > Write_Error_To_Log (LOG_LEVEL_WARNING, __FILE__, __LINE__, "X.25 device", > "write", "WAK", "Attempting to wake up device"); > write (DevFd, "\r", 1); > number_of_timeouts++; > } 1777a1719,1744 > char > Read_Byte_From_Socket (void) > { > char byte_read; > int system_status; > > for (;;) { > system_status = read (Socket_Descriptor, (void *) &byte_read, > (size_t) 1); > if (system_status == READ_ERROR) { > if (errno != EAGAIN) { > Write_System_Error_To_Log (LOG_LEVEL_INFO, __FILE__, __LINE__, > errno, "byte", "read", "CHR", > "Gateway character read error"); > exit (EXIT_FAILURE); > } > } > if (system_status == READ_EOF) { > Write_Message_To_Log (LOG_LEVEL_DEBUG0, __FILE__, __LINE__, > "Read EOF from socket (client)"); > exit (EXIT_SUCCESS); > } > return byte_read; > } > } /* Read_Byte_From_Socket */ > 1783,1860c1750,1789 < char Read_Byte_from_Socket_and_Echo (char *line_terminating_character) < { < char byte_read; < static char skip_character = (char) NULL; /* undefined */ < < do < { < byte_read = fgetc (SOCKET_INPUT_FILE); < if (byte_read == EOF) < { < < /* < * Handle all possible error conditions. < */ < if (feof (SOCKET_INPUT_FILE)) < { < syslog (LOG_DEBUG, "%s %d - debug - EOF read from client" < " socket connection", __FILE__, __LINE__); < exit (EXIT_SUCCESS); < } < else if (ferror (SOCKET_INPUT_FILE)) < { < syslog (LOG_ERR, "%s %d - err - function fgetc caused system" < " error `%m' trying to read a byte", __FILE__, < __LINE__); < exit (EXIT_FAILURE); < } < else < { < syslog (LOG_ERR, "%s %d - err - function fgetc caused system" < " error `%m' trying to read a byte", __FILE__, < __LINE__); < exit (EXIT_FAILURE); < } < } < < if (*line_terminating_character == (char) NULL) < { < < /* < * Define the line terminating character. < */ < if (byte_read == 10 || byte_read == 13) < { < *line_terminating_character = byte_read; < if (*line_terminating_character == 10) < { < skip_character = 13; < } < else < { < skip_character = 10; < } < syslog (LOG_DEBUG, "%s %d - debug - Defined line terminating" < " character as %d" < " and skip character as %d", __FILE__, __LINE__, < *line_terminating_character, skip_character); < } < } < < if (byte_read == *line_terminating_character) < { < fputc ((char) 13, SOCKET_OUTPUT_FILE); < fputc ((char) 10, SOCKET_OUTPUT_FILE); < fflush (SOCKET_OUTPUT_FILE); < } < else if (byte_read == skip_character) < { < continue; < } < else < { < < /* < * Echo the character read. < */ < fputc (byte_read, SOCKET_OUTPUT_FILE); < fflush (SOCKET_OUTPUT_FILE); --- > char > Read_Byte_from_Socket_and_Echo (char *line_terminating_character) > { > char byte_read; > static char skip_character = (char) NULL; /* undefined */ > > do { > byte_read = Read_Byte_From_Socket (); > > if (*line_terminating_character == (char) NULL) { > > /* > * Define the line terminating character. > */ > if (byte_read == 10 || byte_read == 13) { > *line_terminating_character = byte_read; > if (*line_terminating_character == 10) { > skip_character = 13; > } else { > skip_character = 10; > } > Write_Va_Message_To_Log (LOG_LEVEL_DEBUG0, __FILE__, __LINE__, > "Line terminating char is %d, skip char " > "is %d", *line_terminating_character, > skip_character); > } > } > if (byte_read == *line_terminating_character) { > fputc ((char) 13, SOCKET_OUTPUT_FILE); > fputc ((char) 10, SOCKET_OUTPUT_FILE); > fflush (SOCKET_OUTPUT_FILE); > } else if (byte_read == skip_character) { > continue; > } else { > > /* > * Echo the character read. > */ > fputc (byte_read, SOCKET_OUTPUT_FILE); > fflush (SOCKET_OUTPUT_FILE); 1862,1863c1791,1792 < syslog (LOG_DEBUG, "Read and echoed byte %c ASCII code %d\n", < byte_read, byte_read); --- > syslog (LOG_DEBUG, "Read and echoed byte %c ASCII code %d\n", > byte_read, byte_read); 1865,1866c1794,1795 < } < } while (byte_read == skip_character); --- > } > } while (byte_read == skip_character); 1868,1870c1797,1798 < return byte_read; < } /* Read_Byte_from_Socket_and_Echo */ < --- > return byte_read; > } /* Read_Byte_from_Socket_and_Echo */ 1874,1921d1801 < int Read_String_from_Socket_and_Echo (char *buffer, int buffer_length) < { < char byte_read; < int number_of_bytes_put_in_buffer = 0; < bool string_complete = FALSE; < static char line_terminating_character = (char) NULL; < < while (number_of_bytes_put_in_buffer < (buffer_length - 1) && < ! string_complete) < { < byte_read = < Read_Byte_from_Socket_and_Echo (&line_terminating_character); < < if (byte_read == line_terminating_character) < { < buffer[number_of_bytes_put_in_buffer] = EOS; < string_complete = TRUE; < } < else if (byte_read == (char) 4) < { < exit (EXIT_SUCCESS); < } < else if (byte_read == (char) 8) < { < char string_to_erase_character[3] = { (char) 32, (char) 8, EOS}; < number_of_bytes_put_in_buffer--; < Write_String_to_Socket (string_to_erase_character); < } < else < { < < /* < * There is useful input! < */ < buffer[number_of_bytes_put_in_buffer] = byte_read; < number_of_bytes_put_in_buffer++; < } < } /* while */ < < /* < * Make sure there is an EOS character at the end. If it overwrites data, < * TOO BAD! The buffer should be sufficiently big. <- famous last words < */ < if (number_of_bytes_put_in_buffer >= buffer_length - 1) < { < buffer[buffer_length - 1] = EOS; < number_of_bytes_put_in_buffer = buffer_length - 1; < } 1922a1803,1843 > int > Read_String_from_Socket_and_Echo (char *buffer, int buffer_length) > { > char byte_read; > int number_of_bytes_put_in_buffer = 0; > bool string_complete = FALSE; > static char line_terminating_character = (char) NULL; > int have_printing_characters = 0; > > while (number_of_bytes_put_in_buffer < (buffer_length - 1) && > !string_complete) { > byte_read = Read_Byte_from_Socket_and_Echo (&line_terminating_character); > > /* Don't quit until we have printing characters and we get a line > terminator. */ > if (byte_read == line_terminating_character && have_printing_characters) { > buffer[number_of_bytes_put_in_buffer] = EOS; > string_complete = TRUE; > } else if (byte_read == (char) 4) { > exit (EXIT_SUCCESS); > } else if (byte_read == (char) 8) { > char string_to_erase_character[3] = {(char) 32, (char) 8, EOS}; > number_of_bytes_put_in_buffer--; > Write_String_to_Socket (string_to_erase_character); > } else { > /* There is useful input! */ > if (! isspace(byte_read)) > have_printing_characters = 1; > buffer[number_of_bytes_put_in_buffer] = byte_read; > number_of_bytes_put_in_buffer++; > } > } /* while */ > > /* > * Make sure there is an EOS character at the end. If it overwrites data, > * TOO BAD! The buffer should be sufficiently big. <- famous last words > */ > if (number_of_bytes_put_in_buffer >= buffer_length - 1) { > buffer[buffer_length - 1] = EOS; > number_of_bytes_put_in_buffer = buffer_length - 1; > } 1924c1845 < syslog (LOG_DEBUG, "read and echoed: %s\n", buffer); --- > syslog (LOG_DEBUG, "read and echoed: %s\n", buffer); 1927,1928c1848,1849 < return number_of_bytes_put_in_buffer; < } --- > return number_of_bytes_put_in_buffer; > } 1932,1935c1853,1857 < void Write_String_to_Socket (char *format_string, ...) < { < va_list argument_list; < char formatted_string[BUFSIZE]; --- > void > Write_String_to_Socket (char *format_string,...) > { > va_list argument_list; > char formatted_string[BUFSIZE]; 1937,1939c1859,1861 < va_start (argument_list, format_string); < vsprintf (formatted_string, format_string, argument_list); < va_end (argument_list); --- > va_start (argument_list, format_string); > vsprintf (formatted_string, format_string, argument_list); > va_end (argument_list); 1941,1942c1863,1864 < fprintf (SOCKET_OUTPUT_FILE, "%s", formatted_string); < fflush (SOCKET_OUTPUT_FILE); --- > fprintf (SOCKET_OUTPUT_FILE, "%s", formatted_string); > fflush (SOCKET_OUTPUT_FILE); 1945,1946c1867,1868 < { < char codes[4 * BUFSIZE + 1]; --- > { > char codes[4 * BUFSIZE + 1]; 1949,1950c1871,1872 < formatted_string, codes); < } --- > formatted_string, codes); > } 1952c1874 < } --- > } 1956,1960c1878,1883 < void Write_Bytes_to_Socket (char *buffer, int number_of_bytes_to_write) < { < fwrite (buffer, sizeof(char), number_of_bytes_to_write, < SOCKET_OUTPUT_FILE); < fflush (SOCKET_OUTPUT_FILE); --- > void > Write_Bytes_to_Socket (char *buffer, int number_of_bytes_to_write) > { > fwrite (buffer, sizeof (char), number_of_bytes_to_write, > SOCKET_OUTPUT_FILE); > fflush (SOCKET_OUTPUT_FILE); 1963,1964c1886,1887 < { < char buffer_string[1024]; --- > { > char buffer_string[1024]; 1967c1890 < } --- > } 1969,1970c1892 < } < --- > } 1975,2002d1896 < void Get_Caller_Information (char *IP_address, < ConnectionType *type_of_connection, < CudHexStr x25_call_user_data) < { < struct sockaddr_in socket_info_of_caller; < int status; < char *static_memory_IP_address; < int length_of_socket_info = sizeof(socket_info_of_caller); < CudIpStr PppdHost; < < /* < * Get the name of the caller. < */ < if ( getpeername(Socket_Descriptor, < (struct sockaddr *) &socket_info_of_caller, < &length_of_socket_info) < 0) < { < syslog (LOG_ERR, "%s %d - err - function getpeername caused system" < " error `%m' trying to get socket information about" < " connected client", __FILE__, __LINE__); < exit (EXIT_FAILURE); < } < < /* < * Convert caller name to a string. inet_ntoa returns a pointer to a < * static memory area. < */ < static_memory_IP_address = inet_ntoa (socket_info_of_caller.sin_addr); 2004,2015c1898,1919 < /* < * Move the IP address to a location we can depend on. < */ < IP_address = (char *) malloc ((strlen (static_memory_IP_address) + 1) < * sizeof (char)); < if (IP_address == NULL) < { < Write_Error_To_Log (LOG_LEVEL_CRIT, __FILE__, __LINE__, "IP address", < "malloc", "MEM", "Gateway memory error"); < exit (EXIT_FAILURE); < } < strcpy (IP_address, static_memory_IP_address); --- > void > Get_Caller_Information (char *ip_address, > ConnectionType * type_of_connection, > CudHexStr x25_call_user_data) > { > struct sockaddr_in client_socket; > int status; > char *static_memory_ip_address; > struct hostent *static_memory_host_entry; > int length_of_socket_info = sizeof (client_socket); > CudIpStr PppdHost; > > /* Get the struct sockaddr_in of the client. It goes into > client_socket. */ > > if (getpeername (Socket_Descriptor, (struct sockaddr *) &client_socket, > &length_of_socket_info) == GETPEERNAME_ERROR) { > Write_System_Error_To_Log (LOG_LEVEL_ERR, __FILE__, __LINE__, errno, > "socket", "getpeername", "GPN", > "Could not get socket information for client"); > exit (EXIT_FAILURE); > } 2017,2018c1921,1941 < syslog (LOG_INFO, "%s %d - info - connect from %s", < __FILE__, __LINE__, IP_address); --- > /* Get the hostent structure with the actual text (not numeric) name > from the name server. gethostbyaddr returns the address of a > static memory area. */ > > static_memory_host_entry = gethostbyaddr ((char *) &(client_socket.sin_addr), > sizeof (client_socket.sin_addr), > AF_INET); > if (static_memory_host_entry == GETHOSTBYADDR_ERROR) { > Write_Va_Message_To_Log (LOG_LEVEL_DEBUG0, __FILE__, __LINE__, > "Could not get struct hostent for client, " > "gethostbyaddr gave h_error value: %s", > hstrerror(h_errno)); > > /* Convert client address to a string. inet_ntoa returns a > pointer to a static memory area. */ > > static_memory_ip_address = inet_ntoa (client_socket.sin_addr); > STRNCPY(ip_address, static_memory_ip_address); > } else { > STRNCPY(ip_address, static_memory_host_entry->h_name); > } 2020c1943,1944 < status = PPPValidateUser (Socket_Descriptor, PppdHost); /* from pppcudint.h */ --- > Write_Va_Message_To_Log (LOG_LEVEL_INFO, __FILE__, __LINE__, > "Client address is %s", ip_address); 2022,2029c1946 < if (status == -1) /* Should be PPPVALIDATEUSER_ERROR */ < { < Write_Message_To_Log (LOG_LEVEL_INFO, __FILE__, __LINE__, < "connection is NOT from a PPP server - must be" < " an inbound Internet customer"); < *type_of_connection = CT_INBOUND_INTERNET; < return; < } --- > status = PPPValidateUser (Socket_Descriptor, PppdHost); 2030a1948,1952 > #ifdef IMITATE_GENERIC_PPP > Write_Message_To_Log (LOG_LEVEL_INFO, __FILE__, __LINE__, > "Imitating a generic PPP customer"); > #else > if (status == -1) { /* Should be PPPVALIDATEUSER_ERROR */ 2032c1954,1958 < "connection IS from a PPP server"); --- > "Client came from the Internet"); > *type_of_connection = CT_INBOUND_INTERNET; > return; > } > #endif 2034,2049c1960,1961 < /* < * At this point it is known that the incoming connection is < * from a CompuServe PPP server. Now the call user data needs < * to be retrieved, if there is any. < */ < < status = PPPGetUserContext (Socket_Descriptor, x25_call_user_data, PppdHost); < if (status == -1) /* Should be PPPGETUSERCONTEXT_ERROR */ < { < Write_Message_To_Log (LOG_LEVEL_INFO, __FILE__, __LINE__, < "no X.25 call user data - must be an old style" < " spry customer"); < *type_of_connection = CT_OLD_SPRY_PPP; < strcpy (x25_call_user_data, ""); < return; < } --- > Write_Message_To_Log (LOG_LEVEL_INFO, __FILE__, __LINE__, > "Client came from a PPP server"); 2051,2054c1963,1991 < /* < * At this point we have a connection coming from a PPP server that has < * an associated call user data. It must be a "PPP Connect" customer. < */ --- > /* > * We can't do this since we're using Cisco PPP servers. It'll have to be > * hardwired to CT_GENERIC_PPP. > */ > #if 0 > /* > * At this point it is known that the incoming connection is from a > * CompuServe PPP server. Now the call user data needs to be retrieved, if > * there is any. > */ > > status = PPPGetUserContext (Socket_Descriptor, x25_call_user_data, > PppdHost); > if (status == -1) { /* Should be PPPGETUSERCONTEXT_ERROR */ > Write_Message_To_Log (LOG_LEVEL_INFO, __FILE__, __LINE__, > "no X.25 call user data - must be an old style" > " spry customer"); > *type_of_connection = CT_OLD_SPRY_PPP; > strcpy (x25_call_user_data, ""); > return; > } > /* > * At this point we have a connection coming from a PPP server that has an > * associated call user data. It must be a "PPP Connect" customer. > */ > > Write_Va_Message_To_Log (LOG_LEVEL_INFO, __FILE__, __LINE__, > "cud: %s - must be a PPP Connect customer", > x25_call_user_data); 2056,2063c1993,1994 < Write_Va_Message_To_Log (LOG_LEVEL_INFO, __FILE__, __LINE__, < "cud: %s - must be a PPP Connect customer", < x25_call_user_data); < < *type_of_connection = CT_PPP_CONNECT; < < } /* Get_Caller_Information */ < --- > *type_of_connection = CT_PPP_CONNECT; > #endif 2064a1996,2000 > *type_of_connection = CT_GENERIC_PPP; > strcpy (x25_call_user_data, "01000000010000000000000000"); > Write_Va_Message_To_Log (LOG_LEVEL_INFO, __FILE__, __LINE__, > "PPP customer - using %s for CUD", > x25_call_user_data); 2065a2002 > } /* Get_Caller_Information */ 2068,2086d2004 < char *Convert_Characters_in_String_to_ASCII_Codes (char *string, < char *codes) < { < int i; < int length_of_string = strlen (string); < char temp_string[256]; < < strcpy (codes, ""); < for (i=0; i < length_of_string; i++) < { < sprintf (temp_string, "%d ", string[i]); < if (strlen (temp_string) + strlen (codes) > 256) < { < break; < } < strcat (codes, temp_string); < } < return codes; < } 2089,2091d2006 < void Simulate_Host_Name_Prompt () < { < int HnResult; 2093c2008,2025 < HnResult = Get_Service(); --- > char * > Convert_Characters_in_String_to_ASCII_Codes (char *string, > char *codes) > { > int i; > int length_of_string = strlen (string); > char temp_string[256]; > > strcpy (codes, ""); > for (i = 0; i < length_of_string; i++) { > sprintf (temp_string, "%d ", string[i]); > if (strlen (temp_string) + strlen (codes) > 256) { > break; > } > strcat (codes, temp_string); > } > return codes; > } 2095,2118d2026 < if (HnResult == HOSTNAME_BAD) < { < sleep (1); < exit (EXIT_SUCCESS); /* EXIT_SUCCESS? */ < } < else if (HnResult == HOSTNAME_CIS || HnResult == HOSTNAME_CPS) < { < /* We might not return from this! */ < Perform_Dialogs (); < } < else if (HnResult == HOSTNAME_DEBUG) < { < putchar ('\n'); < Start_Pipe_Log (PIPE_COMMAND); < } < else < { < /* < * They entered cisagree and we need to put in a new line to make the < * output look good. < */ < putchar ('\n'); < } < } /* Simulate_Host_Name_Prompt */ 2119a2028,2031 > void > Simulate_Host_Name_Prompt () > { > int HnResult; 2121,2181c2033 < void Get_Baud_Rate_from_User (int *baud, int *baud_rate, int *max_char) < { < char response[256]; < char *response_ptr; < int number_of_tries = 0; < < *baud_rate = B0; /* B0 from termios.h */ < do < { < Write_String_to_Socket("Enter choice (300, 2400, 9600, 14400, OFF): "); < Read_String_from_Socket_and_Echo (response, sizeof(response)); < response_ptr = trimlower(response, sizeof(response)); < < if ( ! strcmp (response_ptr, "300") || < ! strcmp (response_ptr, "450") || < ! strcmp (response_ptr, "1200") || < ! strcmp (response_ptr, "1800") ) < { < *baud_rate = B300; /* B300 from termios.h */ < } < else if ( ! strcmp (response_ptr, "2400") || < ! strcmp (response_ptr, "4800") ) < { < *baud_rate = B2400; /* B2400 from termios.h */ < } < else if ( ! strcmp (response_ptr, "9600") || < ! strcmp (response_ptr, "14400") || < ! strcmp (response_ptr, "19200") || < ! strcmp (response_ptr, "28800") || < ! strcmp (response_ptr, "38400") || < ! strcmp (response_ptr, "57600") || < ! strcmp (response_ptr, "115200") || < ! strcmp (response_ptr, "quick") || < ! strcmp (response_ptr, "infinity") ) < { < *baud_rate = B9600; /* B9600 from termios.h */ < } < else if ( ! strcmp (response_ptr, "off") || < ! strcmp (response_ptr, "exit") || < ! strcmp (response_ptr, "bye") ) < { < Write_String_to_Socket ("We are terminating the connection at " < "this time as you requested.\r\n"); < sleep (1); /* not completely sure why this is here */ < exit (EXIT_SUCCESS); < } < else /* bad input */ < { < Write_String_to_Socket ("You must enter either a valid baud rate " < "or OFF.\r\n"); < Display_Text_File (ExplainBitRate); < < if (++number_of_tries > 2) < { < Write_String_to_Socket ("Valid baud rate not entered. " < "Terminating connection.\r\n"); < exit (EXIT_FAILURE); < } < } < < } while (*baud_rate == B0); /* B0 from termios.h */ --- > HnResult = Get_Service (); 2182a2035,2044 > if (HnResult == HOSTNAME_BAD) { > sleep (1); > exit (EXIT_SUCCESS); /* EXIT_SUCCESS? */ > } else if (HnResult == HOSTNAME_CIS || HnResult == HOSTNAME_CPS) { > /* We might not return from this! */ > Perform_Dialogs (); > } else if (HnResult == HOSTNAME_DEBUG) { > putchar ('\n'); > Start_Pipe_Log (PIPE_COMMAND); > } else { 2184,2185c2046,2047 < * Since we are no longer doing throttling, set *max_char to a large < * number. This use to be set to *baud_rate/10. --- > * They entered cisagree and we need to put in a new line to make the > * output look good. 2187,2188c2049,2051 < < *max_char = INT_MAX; --- > putchar ('\n'); > } > } /* Simulate_Host_Name_Prompt */ 2190,2194d2052 < /* < * *baud is not being used now but I'm leaving it in for now just < * in case. < */ < *baud = (int) response_ptr[0]; 2196,2198c2054,2107 < syslog (LOG_INFO, "%s %d - info - baud rate %s reported as %d", < __FILE__, __LINE__, response_ptr, *baud_rate); < } /* Get_Baud_Rate_From_User */ --- > void > Get_Baud_Rate_from_User (int *baud, int *baud_rate, int *max_char) > { > char response[256]; > char *response_ptr; > int number_of_tries = 0; > > /* > * Even though we now report 57600 Baud for all connections, this user > * negotiation has to be here so existing scripts do not break. > */ > *baud_rate = B0; /* B0 from termios.h */ > do { > Purge_Socket_Input (Socket_Descriptor); > Write_String_to_Socket ("Enter choice (300, 2400, 9600, 14400, OFF): "); > Read_String_from_Socket_and_Echo (response, sizeof (response)); > response_ptr = trimlower (response, sizeof (response)); > > if (!strcmp (response_ptr, "300") || > !strcmp (response_ptr, "450") || > !strcmp (response_ptr, "1200") || > !strcmp (response_ptr, "1800")) { > *baud_rate = B300; /* B300 from termios.h */ > } else if (!strcmp (response_ptr, "2400") || > !strcmp (response_ptr, "4800")) { > *baud_rate = B2400; /* B2400 from termios.h */ > } else if (!strcmp (response_ptr, "9600") || > !strcmp (response_ptr, "14400") || > !strcmp (response_ptr, "19200") || > !strcmp (response_ptr, "28800") || > !strcmp (response_ptr, "38400") || > !strcmp (response_ptr, "57600") || > !strcmp (response_ptr, "115200") || > !strcmp (response_ptr, "quick") || > !strcmp (response_ptr, "infinity")) { > *baud_rate = B9600; /* B9600 from termios.h */ > } else if (!strcmp (response_ptr, "off") || > !strcmp (response_ptr, "exit") || > !strcmp (response_ptr, "bye")) { > Write_String_to_Socket ("We are terminating the connection at " > "this time as you requested.\r\n"); > sleep (1); /* not completely sure why this is here */ > exit (EXIT_SUCCESS); > } else { /* bad input */ > Write_String_to_Socket ("You must enter either a valid baud rate " > "or OFF.\r\n"); > Display_Text_File (ExplainBitRate); > > if (++number_of_tries > 2) { > Write_String_to_Socket ("Valid baud rate not entered. " > "Terminating connection.\r\n"); > exit (EXIT_FAILURE); > } > } 2199a2109 > } while (*baud_rate == B0); /* B0 from termios.h */ 2200a2111,2115 > /* > * Make all connections report 57600 Baud to the host so they can get a > * higher job class on 36-bit machines. > */ > *baud_rate = B57600; 2202,2206c2117,2120 < void Make_String_from_Bytes (char *bytes, int number_of_bytes, char *string) < { < strncpy (string, bytes, number_of_bytes); < string[number_of_bytes] = EOS; < } --- > /* > * Since we are no longer doing throttling, set *max_char to a large > * number. This use to be set to *baud_rate/10. > */ 2207a2122 > *max_char = INT_MAX; 2208a2124,2127 > /* > * *baud is not being used now but I'm leaving it in for now just in case. > */ > *baud = (int) response_ptr[0]; 2210,2212c2129,2132 < void Replace_NL_with_CR_NL (char *buffer) < { < int length = strlen (buffer); --- > Write_Va_Message_To_Log (LOG_LEVEL_DEBUG0, __FILE__, __LINE__, > "Baud rate %s reported as %d", response_ptr, > *baud_rate); > } /* Get_Baud_Rate_From_User */ 2214,2217d2133 < buffer[length - 1] = (char) 13; < buffer[length] = (char) 10; < buffer[length + 1] = EOS; < } 2220,2226c2136,2141 < void cleanup (void) < { < close (DevFd); < Write_Message_To_Log (LOG_LEVEL_DEBUG0, __FILE__, __LINE__, < "exit handler: closing log and exiting"); < Close_Log (); < } --- > void > Make_String_from_Bytes (char *bytes, int number_of_bytes, char *string) > { > strncpy (string, bytes, number_of_bytes); > string[number_of_bytes] = EOS; > } 2228,2233d2142 < void timeout (int signal_number) < { < syslog (LOG_NOTICE, "%s %d - notice - time out at Host Name prompt", < __FILE__, __LINE__); < exit (EXIT_FAILURE); < } 2235,2247d2143 < void Display_Connected_Message (void) < { < char host_name[MAXHOSTNAMELEN /* from sys/param.h */ + 1]; < int status; < < status = gethostname (host_name, MAXHOSTNAMELEN /* from sys/param.h */); < if (status == GETHOSTNAME_ERROR) < { < Write_System_Error_To_Log (LOG_LEVEL_ERR, __FILE__, __LINE__, errno, < "host name", "gethostname", "HNM", < "Could determine IP name for gateway"); < strcpy (host_name, "UNKNOWN"); < } 2248a2145,2195 > void > Replace_NL_with_CR_NL (char *buffer) > { > int length = strlen (buffer); > > buffer[length - 1] = (char) 13; > buffer[length] = (char) 10; > buffer[length + 1] = EOS; > } > > > void > cleanup (void) > { > close (DevFd); > if (Features.produce_stats) { > Log_Socket_Stats (); > Log_X25_Device_Stats (); > } > Write_Message_To_Log (LOG_LEVEL_DEBUG0, __FILE__, __LINE__, > "exit handler: closing log and exiting"); > Close_Log (); > } > > void > timeout (int signal_number) > { > syslog (LOG_NOTICE, "%s %d - notice - time out at Host Name prompt", > __FILE__, __LINE__); > exit (EXIT_FAILURE); > } > > void > Display_Connected_Message (void) > { > char host_name[MAXHOSTNAMELEN /* from sys/param.h */ + 1]; > int status; > > status = gethostname (host_name, MAXHOSTNAMELEN /* from sys/param.h */ ); > if (status == GETHOSTNAME_ERROR) { > Write_System_Error_To_Log (LOG_LEVEL_ERR, __FILE__, __LINE__, errno, > "host name", "gethostname", "HNM", > "Could determine IP name for gateway"); > strcpy (host_name, "UNKNOWN"); > } > if (Features.from_central_server == 1) > Write_String_to_Socket ("Connected to CompuServe gateway %s %s%s%s", > host_name, Features.x25_device_name, > LINE_TERMINATION_STRING, > LINE_TERMINATION_STRING); > else 2252c2199,2211 < } --- > } > > void > Set_Command_Line_Options () > { > if (!Features.from_central_server) { > increase_process_limit (); > become_user (RUN_TIME_USER_NAME); > } > } > > >