Small changes to formatting, and to input handling
This commit is contained in:
24
src/comm.c
24
src/comm.c
@@ -1556,11 +1556,8 @@ static int process_output(struct descriptor_data *t)
|
||||
if (STATE(t) == CON_PLAYING && t->character && !IS_NPC(t->character) && !PRF_FLAGGED(t->character, PRF_COMPACT))
|
||||
strcat(osb, "\r\n"); /* strcpy: OK (osb:MAX_SOCK_BUF-2 reserves space) */
|
||||
|
||||
if (!t->pProtocol->WriteOOB)
|
||||
{
|
||||
/* add a prompt */
|
||||
if (!t->pProtocol->WriteOOB) /* add a prompt */
|
||||
strcat(i, make_prompt(t)); /* strcpy: OK (i:MAX_SOCK_BUF reserves space) */
|
||||
}
|
||||
|
||||
/* now, send the output. If this is an 'interruption', use the prepended
|
||||
* CRLF, otherwise send the straight output sans CRLF. */
|
||||
@@ -1814,9 +1811,7 @@ static int process_input(struct descriptor_data *t)
|
||||
size_t space_left;
|
||||
char *ptr, *read_point, *write_point, *nl_pos = NULL;
|
||||
char tmp[MAX_INPUT_LENGTH];
|
||||
|
||||
static char read_buf[MAX_PROTOCOL_BUFFER]; /* KaVir's plugin */
|
||||
read_buf[0] = '\0'; /* KaVir's plugin */
|
||||
static char read_buf[MAX_PROTOCOL_BUFFER] = { '\0' }; /* KaVir's plugin */
|
||||
|
||||
/* first, find the point where we left off reading data */
|
||||
buf_length = strlen(t->inbuf);
|
||||
@@ -1829,14 +1824,15 @@ static int process_input(struct descriptor_data *t)
|
||||
return (-1);
|
||||
}
|
||||
|
||||
bytes_read = perform_socket_read(t->descriptor, read_buf, space_left);
|
||||
|
||||
if ( bytes_read >= 0 )
|
||||
{
|
||||
/* Read # of "bytes_read" from socket, and if we have something, mark the sizeof data
|
||||
* in the read_buf array as NULL */
|
||||
if ((bytes_read = perform_socket_read(t->descriptor, read_buf, space_left)) > 0)
|
||||
read_buf[bytes_read] = '\0';
|
||||
ProtocolInput( t, read_buf, bytes_read, t->inbuf );
|
||||
bytes_read = strlen(t->inbuf);
|
||||
}
|
||||
|
||||
/* Since we have recieved atleast 1 byte of data from the socket, lets run it through
|
||||
* ProtocolInput() and rip out anything that is Out Of Band */
|
||||
if ( bytes_read > 0 )
|
||||
bytes_read = ProtocolInput( t, read_buf, bytes_read, t->inbuf );
|
||||
|
||||
if (bytes_read < 0) /* Error, disconnect them. */
|
||||
return (-1);
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
******************************************************************************/
|
||||
|
||||
#include <arpa/telnet.h>
|
||||
#include <sys/types.h>
|
||||
#include "protocol.h"
|
||||
|
||||
/******************************************************************************
|
||||
@@ -349,13 +350,13 @@ void ProtocolDestroy( protocol_t *apProtocol )
|
||||
free(apProtocol);
|
||||
}
|
||||
|
||||
void ProtocolInput( descriptor_t *apDescriptor, char *apData, int aSize, char *apOut )
|
||||
ssize_t ProtocolInput( descriptor_t *apDescriptor, char *apData, int aSize, char *apOut )
|
||||
{
|
||||
static char CmdBuf[MAX_PROTOCOL_BUFFER+1];
|
||||
static char IacBuf[MAX_PROTOCOL_BUFFER+1];
|
||||
int CmdIndex = 0;
|
||||
int IacIndex = 0;
|
||||
int Index;
|
||||
ssize_t CmdIndex = 0;
|
||||
ssize_t IacIndex = 0;
|
||||
ssize_t Index;
|
||||
|
||||
protocol_t *pProtocol = apDescriptor ? apDescriptor->pProtocol : NULL;
|
||||
|
||||
@@ -365,7 +366,7 @@ void ProtocolInput( descriptor_t *apDescriptor, char *apData, int aSize, char *a
|
||||
if ( CmdIndex >= MAX_PROTOCOL_BUFFER || IacIndex >= MAX_PROTOCOL_BUFFER )
|
||||
{
|
||||
ReportBug("ProtocolInput: Too much incoming data to store in the buffer.\n");
|
||||
return;
|
||||
return (-1);
|
||||
}
|
||||
|
||||
/* IAC IAC is treated as a single value of 255 */
|
||||
@@ -513,6 +514,7 @@ void ProtocolInput( descriptor_t *apDescriptor, char *apData, int aSize, char *a
|
||||
|
||||
/* Copy the input buffer back to the player. */
|
||||
strcat( apOut, CmdBuf );
|
||||
return (CmdIndex);
|
||||
}
|
||||
|
||||
const char *ProtocolOutput( descriptor_t *apDescriptor, const char *apData, int *apLength )
|
||||
|
||||
@@ -250,7 +250,7 @@ void ProtocolNegotiate( descriptor_t *apDescriptor );
|
||||
* whatever is left for the mud to parse normally. Call this after data has
|
||||
* been read into the input buffer, before it is used for anything else.
|
||||
*/
|
||||
void ProtocolInput( descriptor_t *apDescriptor, char *apData, int aSize, char *apOut );
|
||||
ssize_t ProtocolInput( descriptor_t *apDescriptor, char *apData, int aSize, char *apOut );
|
||||
|
||||
/* Function: ProtocolOutput
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user