12 Jun, 2012, dbna2 wrote in the 1st comment:
Votes: 0
I just recently installed this snippet and I don't understand the instructions for copyover system. I mainly am unsure how to copyoverSet in the copyover_recovery function. And because of this after every copyover the xterm color and mxp stop working.
13 Jun, 2012, KaVir wrote in the 2nd comment:
Votes: 0
From the README.TXT:

Quote
/******************************************************************************
All the protocol information vanishes after I do a copyover/hotreboot!
******************************************************************************/

Some muds use an exec() function to replace the current process with a new one, effectively rebooting the mud without shutting it down. The problem with this is that the client can't detect it, and because clients need to protect against negotiation loops they may end up ignoring your attempts to renegotiate.

Therefore in order to store the data across reboots, you need to save it when you do the copyover, and then load it again afterwards.

The snippet offers CopyoverSet() and CopyoverGet() functions to make this a bit easier. When writing descriptors to the temporary file in your copyover code, add an extra "%s" to each row and copy the string from CopyoverGet() into it. Then when you load the file again after the copyover, pass the string back into CopyoverSet(), and it'll restore the settings.

Note that this won't save the client name and version. It's recommend that you instead save these in the player file (this means you can grep through player files to collect client usage statistics, which can be quite useful).

If you do start saving things in the player file, once again be particularly careful about the malloc/str_dup free/free_string thing. If you mix them you may end up with some nasty bugs that are hard to track down. As I mentioned earlier, it's well worth going through the snippet and making sure it uses the same functions as the rest of your mud.

Note also that CopyoverSet() calls CompressStart(), while CopyoverGet() calls CompressEnd(). So if you're using both copyover and MCCP, you shouldn't need to manually switch compression off and back on when doing a copyover, it should be done for you automatically.


From protocol.h:

Quote
/* Function: CopyoverGet
*
* Returns the protocol values stored as a short string. If your mud uses
* copyover, you should call this for each player and insert it after their
* name in the temporary text file.
*/
const char *CopyoverGet( descriptor_t *apDescriptor );

/* Function: CopyoverSet
*
* Call this function for each player after a copyover, passing in the string
* you added to the temporary text file. This will restore their protocol
* settings, and automatically renegotiate MSDP/ATCP.
*
* Note that the client doesn't recognise a copyover, and therefore refuses to
* renegotiate certain telnet options (to avoid loops), so they really need to
* be saved. However MSDP/ATCP is handled through scripts, and we don't want
* to have to save all of the REPORT variables, so it's easier to renegotiate.
*
* Client name and version are not saved. It is recommended you save these in
* the player file, as then you can grep to collect client usage stats.
*/
void CopyoverSet( descriptor_t *apDescriptor, const char *apData );

Basically you call CopyoverGet(), passing in the character's descriptor, and it returns a string. Add that string to the line containing the copyover data for that character.

Then after the reboot, recover the string and call CopyoverSet(), passing in the character's descriptor and the string.
13 Jun, 2012, dbna2 wrote in the 3rd comment:
Votes: 0
I'm not sure what I am suppose to be passing through copyoverset I got CopyoverSet(d, ????);
13 Jun, 2012, Sharmair wrote in the 4th comment:
Votes: 0
From the instructions, it seems you would pass the string you wrote to your copyover
file (the one you got with CopyoverGet() and wrote to your copyover file). To (maybe)
clearify; You get the string for each player with CopyoverGet() and add that string to
that player's info in the copyover file before the copyover, then after the copyover when
you are reading the copyover file and rebuilding the player's descriptor_data, you read
that string in and pass it to CopyoverSet().
14 Jun, 2012, dbna2 wrote in the 5th comment:
Votes: 0
yeah I'm not sure how the copyover system works.

Here is a copy.

Quote
void do_copyover (CHAR_DATA *ch, char * argument)
{
FILE *fp;
DESCRIPTOR_DATA *d, *d_next;
char buf [100], buf2[100], buf3[100];
char arg[MAX_STRING_LENGTH];
one_argument( argument, arg );
if ( !str_cmp( arg, "warn" ) )
{

sprintf(buf, "&U&ZCopyover Warning&z!!!.&D");
talk_info(AT_WHITE, buf );
do_fullsave(ch, NULL );
return;
}
open_mud_log();
fp = Fopen (COPYOVER_FILE, "w");

if (!fp)
{
if ( ch )
send_to_char ("Copyover file not writeable, aborted.\n\r",ch);
perror ("do_copyover:Fopen");
exit(1);
return;
}

/* Consider changing all saved areas here, if you use OLC */

/* do_asave (NULL, ""); - autosave changed areas */

iscopyovering = TRUE;
do_auction( supermob, "Stop" );
/* For each playing descriptor, save its state */
for (d = first_descriptor; d ; d = d_next)
{
CHAR_DATA * och = CH (d);
d_next = d->next; /* We delete from the list , so need to save this */

if ( !d )
continue;

if (!d->character || d->connected < 0) /* drop those logging on */
{
write_to_descriptor_old (d->descriptor, "\n\rSorry, we are copyovering. Come back in a few seconds.\n\r", 0);
close_socket (d, FALSE); /* throw'em out */
}
else
{
// fprintf (fp, "%d %s %s %s\n", d->descriptor, och->name, d->host, CopyoverGet(d));
fprintf (fp, "%d %s %s\n", d->descriptor, och->name, d->host );
save_char_obj (och);
if ( och
&& och->level
&& och->level > 50 &&
och->pcdata && och->pcdata->area)
{
do_savearea(och, "" );
}
#ifdef MCCP
compressEnd( d );
#endif
}
}

fprintf (fp, "-1\n");
fclose (fp);

/* Close reserve and other always-open files and release other resources */
iscopyovering = FALSE;
fclose (fpReserve);
fclose ( fpLOG );

#ifdef IMC
imc_shutdown( FALSE );
#endif
#ifdef USE_WEBSVR
if (sysdata.webtoggle==TRUE)
{
shutdown_web();
}
#endif
#ifdef I3
if( I3_is_connected() )
{
I3_savechanlist();
I3_savemudlist();
}
#endif

/* exec - descriptors are inherited */

sprintf (buf, "%d", port);
sprintf (buf2, "%d", control);
#ifdef I3
sprintf( buf3, "%d", I3_socket );
#else
strcpy( buf3, "-1" );
#endif
execl (EXE_FILE, "smaug", buf, "copyover", buf2, buf3, (char *) NULL);

/* Failed - sucessful exec will not return */

perror ("do_copyover: execl");
if ( ch )
send_to_char ("Copyover FAILED!\n\r",ch);


/* Here you might want to reopen fpReserve */
/* Since I'm a neophyte type guy, I'll assume this is
a good idea and cut and past from main() */
if ( ( fpReserve = Fopen( NULL_FILE, "r" ) ) == NULL )
{
perror( NULL_FILE );
exit( 1 );
}
if ( ( fpLOG = Fopen( NULL_FILE, "r" ) ) == NULL )
{
perror( NULL_FILE );
exit( 1 );
}
}


this is the other part
Quote
/* Recover from a copyover - load players */

void copyover_recover ()
{
DESCRIPTOR_DATA *d;
FILE *fp;
char name [100];
char host[MAX_STRING_LENGTH];
int desc;
bool fOld;

log_printf ("Copyover recovery initiated");

fp = Fopen (COPYOVER_FILE, "r");

if (!fp) // there are some descriptors open which will hang forever then ?
{
perror ("copyover_recover:Fopen");
log_printf ("Copyover file not found. Exitting.\n\r");
exit (1);
}

unlink (COPYOVER_FILE); // In case something crashes - doesn't prevent reading

for (;;)
{
int fcheck;
fcheck =fscanf (fp, "%d %s %s\n", &desc, name, host );
if (desc == -1)
break;

// Write something, and check if it goes error-free
if (!write_to_descriptor_old (desc, " ", 1))
{
close (desc); // nope
continue;
}

CREATE( d, DESCRIPTOR_DATA, 1 );
d->host = STRALLOC( host );
init_descriptor (d,desc); // set up various stuff

LINK( d, first_descriptor, last_descriptor, next, prev );
d->connected = CON_COPYOVER_RECOVER; // -15, so close_socket frees the char

// Now, find the pfile

fOld = load_char_obj (d, name, FALSE);

if (!fOld) // Player file not found?!
{
write_to_descriptor_old (desc, "\n\rSomehow, your character was lost in the copyover. Sorry.\n\r", 0);
close_socket (d, FALSE);
}
else // ok!
{
// talk_info( AT_BLOOD, "&WCopyover Complete.&D");
// Just In Case

// Insert in the char_list
if ( IS_IMMORTAL(d->character) && d->character->pcdata->area)
do_loadarea( d->character, "" );
if( d->character->pcdata->board == NULL )
d->character->pcdata->board = &boards[DEFAULT_BOARD];
LINK( d->character, first_char, last_char,next, prev );
if (!d->character->in_room)
d->character->in_room= get_room_index (ROOM_VNUM_TEMPLE);
char_to_room(d->character, d->character->in_room);
d->connected = CON_PLAYING;
handle_hostlog( "Recovered from Hotboot", d->character );
#ifdef MCCP
write_to_descriptor( d, (char *)will_compress2_str, 0 );
#endif
}
}

adjust_global_gains(NULL,TRUE);
talk_info( AT_BLOOD, "&WCopyover Complete.&D");
fclose(fp);
}
14 Jun, 2012, KaVir wrote in the 6th comment:
Votes: 0
Uncomment this line, it's correct:

// fprintf (fp, "%d %s %s %s\n", d->descriptor, och->name, d->host, CopyoverGet(d));

Remove this line:

fprintf (fp, "%d %s %s\n", d->descriptor, och->name, d->host );

You should also remove this section:

#ifdef MCCP
compressEnd( d );
#endif


This should all be done through the CompressStart() and CompressEnd() functions in protocol.c, as explained in the README.TXT.

Then in copyover_recover() replace this:

fcheck =fscanf (fp, "%d %s %s\n", &desc, name, host );

With this:

fcheck =fscanf (fp, "%d %s %s %s\n", &desc, name, host, protocol_stuff );

You'll need to define protocol_stuff at the top of the function, up with "name".

Then replace this:

#ifdef MCCP
write_to_descriptor( d, (char *)will_compress2_str, 0 );
#endif


With this:

CopyoverSet( d, protocol_stuff )

You will need to do a proper reboot to introduce this change, rather than a copyover. But after that you can continue using copyover as normal.
14 Jun, 2012, dbna2 wrote in the 7th comment:
Votes: 0
thank you
12 Dec, 2012, Hades_Kane wrote in the 8th comment:
Votes: 0
Thank god I found this thread. I was close to beating my head against the wall.

Thanks for the thorough explanation :)
12 Dec, 2012, Hades_Kane wrote in the 9th comment:
Votes: 0
I can't seem to get it to work. It keeps crashing on copyover.

This is my gdb backtrace on the coredump, followed by some of the functions.

#0  0x080cae52 in write_to_buffer (d=0xb621e388, txt=0xbfbee110 "\033#0  0x080cae52 in write_to_buffer (d=0xb621e388, txt=0xbfbee110 "\033[1;36m", length=7) at comm.c:2159
2159 if ( d->pProtocol->WriteOOB > 0 )
(gdb) bt
#0 0x080cae52 in write_to_buffer (d=0xb621e388, txt=0xbfbee110 "\033[1;36m", length=7) at comm.c:2159
#1 0x080dd230 in send_to_char (txt=0x8213fea "", ch=0xb622041c) at comm.c:9162
#2 0x0805da60 in do_look (ch=0xb622041c, argument=0x821370f "") at act_info.c:2468
#3 0x0809d770 in copyover_recover () at act_wiz.c:6757
#4 0x080c7fcc in main (argc=4, argv=0xbfbfe714) at comm.c:464[/code]

[code]/*
* Append onto an output buffer.
*/
void write_to_buffer( DESCRIPTOR_DATA *d, const char *txt, int length )
{
txt = ProtocolOutput( d, txt, &length );
if ( d->pProtocol->WriteOOB > 0 )
–d->pProtocol->WriteOOB;

/*
* Find length in case caller didn't.
*/
if ( length <= 0 )
length = strlen(txt);

/*
* Initial \r\n if needed.
*/
//if ( d->outtop == 0 && !d->fcommand )
if ( d->outtop == 0 && !d->fcommand && !d->pProtocol->WriteOOB )
{
d->outbuf[0] = '\r';
d->outbuf[1] = '\n';
d->outtop = 2;
}

/*
* Expand the buffer as needed.
*/
while ( d->outtop + length >= d->outsize )
{
char *outbuf;

if (d->outsize >= 32000)
{
bug("Buffer overflow. Closing.\r\n",0);
close_socket(d);
return;
}
outbuf = alloc_mem( 2 * d->outsize );
strncpy( outbuf, d->outbuf, d->outtop );
free_mem( d->outbuf, d->outsize );
d->outbuf = outbuf;
d->outsize *= 2;
}

/*
* Copy.
*/
/* strcpy( d->outbuf + d->outtop, txt ); */

strncpy( d->outbuf + d->outtop, txt, length );
d->outtop += length;
return;
}[/code]

[code]/*
* Write to one char, new colour version, by Lope.
*/
void send_to_char( const char *txt, CHAR_DATA *ch )
{
const char *point;
char *point2;
char buf[ MAX_STRING_LENGTH*4 ];
int skip = 0;

if (!IS_IMMORTAL(ch) && number_range(1,1000) != 42)
dream_append(txt);

buf[0] = '\0';
point2 = buf;
if ( txt && ch->desc )
{
if ( IS_SET( ch->act, PLR_COLOUR ) )
{
for ( point = txt ; *point ; point++ )
{
if ( *point == '{' )
{
point++;
skip = colour( *point, ch, point2 );
while ( skip– > 0 )
++point2;
continue;
}
*point2 = *point;
*++point2 = '\0';
}
*point2 = '\0';
write_to_buffer( ch->desc, buf, point2 - buf );
}
else
{
for ( point = txt ; *point ; point++ )
{
if ( *point == '{' )
{
point++;
continue;
}
*point2 = *point;
*++point2 = '\0';
}
*point2 = '\0';
write_to_buffer( ch->desc, buf, point2 - buf );
}
}
return;
}[/code]

[code]/* Recover from a copyover - load players */
void copyover_recover ()
{
DESCRIPTOR_DATA *d;
FILE *fp;
char name [100];
char buf[1000];
char protocol_stuff[MSL];
char host[MSL];
int desc;
bool fOld;
extern char *help_copyover_end;

logf ("Copyover recovery initiated");

fp = fopen (COPYOVER_FILE, "r");

if (!fp) /* there are some descriptors open which will hang forever then ? */
{
perror ("copyover_recover:fopen");
logf ("Copyover file not found. Exitting.\r\n");
exit (1);
}

unlink (COPYOVER_FILE); /* In case something crashes - doesn't prevent reading */

for (;;)
{
fscanf (fp, "%d %s %s %s\n", &desc, name, host, protocol_stuff );
if (desc == -1)
break;

/* Write something, and check if it goes error-free */
if (help_copyover_end == '\0')
sprintf(buf, "\r\nRestoring from copyover…\r\n");
else
sprintf(buf, help_copyover_end);

//if (!write_to_descriptor (desc, "\r\nRestoring from copyover…\r\n",0))
if (!write_to_descriptor (desc, buf,0))
{
close (desc); /* nope */
continue;
}

d = new_descriptor();
d->descriptor = desc;

d->host = str_dup (host);
d->next = descriptor_list;
descriptor_list = d;

d->connected = CON_COPYOVER_RECOVER; /* -15, so close_socket frees the char */

/* Now, find the pfile */

fOld = load_char_obj (d, name);

if (!fOld) /* Player file not found?! */
{
write_to_descriptor (desc, "\r\nSomehow, your character was lost in the copyover. Sorry.\r\n", 0);
close_socket (d);
}
else /* ok! */
{

/* Just In Case */
if (!d->character->in_room)
d->character->in_room = get_room_index (ROOM_VNUM_TEMPLE);

/* Insert in the char_list */
d->character->next = char_list;
char_list = d->character;

char_to_room (d->character, d->character->in_room);

act ("$n materializes!", d->character, NULL, NULL, TO_ROOM);
d->connected = CON_PLAYING;
d->character->pcdata->noagg = 0;
CopyoverSet( d, protocol_stuff );
ROOM_INDEX_DATA *to_room;

if(is_room_owner(d->character,d->character->in_room) && IS_SET(d->character->in_room->croom_flag2, ROOM_SHIP))
{
if((to_room = get_room_index(d->character->pcdata->seanum)) != NULL)
{
OBJ_DATA *ship;
char buf[MSL];
char *name;

name = d->character->name;
ship = create_object(get_obj_index(OBJ_VNUM_SHIP), 0, 44);
ship->owner = str_dup(d->character->name);

ship->level = d->character->level;

sprintf( buf, ship->short_descr, name );
free_string( ship->short_descr );
ship->short_descr = str_dup( buf );

sprintf( buf, ship->description, name );
free_string( ship->description );
ship->description = str_dup( buf );
obj_to_room( ship, to_room );
}
}

do_look (d->character, "auto");
if (d->character->pet != NULL)
{
char_to_room(d->character->pet,d->character->in_room);
if (HAS_TRIGGER_MOB(d->character->pet, TRIG_PETLOG))
p_percent_trigger( d->character->pet, NULL, NULL, NULL, NULL, NULL, TRIG_PETLOG );
act("$n materializes!",d->character->pet,NULL,NULL,TO_ROOM);
}
}

}
fclose (fp);


}[/code]

I noticed that part of the error message was ""\033[1;36m" which is the protocol color code for bright cyan.

Any ideas? Also, I know this was in the SMAUG section, and I'm running ROM, but it seemed applicable as the code is very similar and would have seemed redundant to start a new thread for it.

I'm using MUSH Client and I can't seem to get the colors to show up any different either, it seems to be defaulting back to the "close enough" colors. I suspect something isn't initiating right or something and that's why it isn't (and I am assuming related to the crash). I could potentially not have something configured right, but I have MXP set to "Yes - Always" as far as using it, and not sure if there might be something else I'm doing wrong. No one else on the game currently is using a 256 color enabled client.

I'm way over my head here I feel like :(
12 Dec, 2012, Davion wrote in the 10th comment:
Votes: 0
#0  0x080cae52 in write_to_buffer (d=0xb621e388, txt=0xbfbee110 "\033
#0 0x080cae52 in write_to_buffer (d=0xb621e388, txt=0xbfbee110 "\033[1;36m", length=7) at comm.c:2159
2159 if ( d->pProtocol->WriteOOB > 0 )
(gdb) bt
#0 0x080cae52 in write_to_buffer (d=0xb621e388, txt=0xbfbee110 "\033[1;36m", length=7) at comm.c:2159
#1 0x080dd230 in send_to_char (txt=0x8213fea "", ch=0xb622041c) at comm.c:9162
#2 0x0805da60 in do_look (ch=0xb622041c, argument=0x821370f "") at act_info.c:2468
#3 0x0809d770 in copyover_recover () at act_wiz.c:6757
#4 0x080c7fcc in main (argc=4, argv=0xbfbfe714) at comm.c:464
[/code]
The reason it's crashing here is because d, or d->pProtocol is not set right. You'll need to give us the info on those. "print *d" and "print *d->pProtocol".
12 Dec, 2012, KaVir wrote in the 11th comment:
Votes: 0
Davion said:
The reason it's crashing here is because d, or d->pProtocol is not set right.

Agreed. Looks like a missing "d->pProtocol = ProtocolCreate();"

Take a look at the INSTALL_ROM.TXT where it adds the protocol data to the descriptor in the init_descriptor() function. After the "dnew = new_descriptor();" it sets some of the dnew structure elements, including dnew->pProtocol. That doesn't appear to be done after a copyover.
12 Dec, 2012, arbin wrote in the 12th comment:
Votes: 0
Im having completely different issues in comm.c and Im really rusty at coding, ive been back for maybe a month and a half after 7 years of not doin a thing:

colorgcc  -c -DMCCP -g3 -O  -w -Wuninitialized    -DSMAUG  -DTIMEFORMAT  comm.c -o o/comm.o
comm.c: In function read_from_descriptor:
comm.c:1395:27: error: expected identifier or ( before numeric constant
comm.c:1396:13: error: expected expression before
colorgcc -c -DMCCP -g3 -O -w -Wuninitialized -DSMAUG -DTIMEFORMAT comm.c -o o/comm.o
comm.c: In function read_from_descriptor:
comm.c:1395:27: error: expected identifier or ( before numeric constant
comm.c:1396:13: error: expected expression before [ token
comm.c:1407:3: error: too few arguments to function strlen
comm.c:1408:33: error: expected expression before , token
comm.c:1427:70: error: expected expression before ) token
comm.c:1427:70: error: too few arguments to function recv
/usr/include/i386-linux-gnu/bits/socket2.h:35:1: note: declared here
comm.c:1436:19: error: expected expression before [ token
comm.c:1436:51: error: expected expression before [ token
comm.c:1453:11: error: expected expression before [ token
comm.c:1454:29: error: expected expression before , token
comm.c: In function read_from_buffer:
comm.c:1480:23: error: expected expression before [ token
comm.c:1482:17: error: expected expression before [ token
comm.c:1489:30: error: expected expression before [ token
comm.c:1511:15: error: expected expression before [ token
comm.c:1512:15: error: expected expression before [ token
comm.c:1517:17: error: expected expression before [ token
comm.c:1519:36: error: expected expression before [ token
comm.c:1524:19: error: expected expression before [ token
comm.c:1526:21: error: expected expression before [ token
comm.c:1528:26: error: expected expression before [ token
comm.c:1531:24: error: expected expression before [ token
comm.c:1533:21: error: expected expression before [ token
comm.c:1535:26: error: expected expression before [ token
comm.c:1542:17: error: expected expression before [ token
comm.c:1544:14: error: expected expression before [ token
comm.c:1544:40: error: expected expression before [ token
comm.c:1545:32: error: expected expression before [ token
comm.c:1590:18: error: expected expression before [ token
comm.c:1592:25: error: expected expression before [ token
comm.c: In function nanny:
comm.c:2448:71: error: expected expression before ) token
make[1]: *** [o/comm.o] Error 1
make[1]: Leaving directory `/home/leon/code/src'
make: *** [all] Error 2
[/code]


[code]
bool read_from_descriptor( DESCRIPTOR_DATA * d )
{
int iStart, iErr;
char read_buf [MAX_PROTOCOL_BUFFER];
read_buf( [0] = '\0' );

/*
* Hold horses if pending command already.
*/
if( d->incomm[0] != '\0' )
return TRUE;

/*
* Check for overflow.
*/
iStart = strlen( read_buf );
if( iStart >= sizeof( read_buf, ) - 10 )
{
sprintf( log_buf, "%s input overflow!", d->host );
log_string( log_buf );
CHAR_DATA *ch;
if((ch = d->character) != NULL && IS_IMMORTAL(ch)){
write_to_descriptor(d->descriptor, "\n\r*** Try not to spam the same command too many times, thank you. ***\n\r", 0);
}else{
write_to_descriptor( d->descriptor,
"\n\r*** PUT A LID ON IT!!! ***\n\rYou cannot enter the same command more than 20 consecutive times!\n\r",
0 );
return FALSE;
}
}

for( ;; )
{
int nRead;

nRead = recv( d->descriptor, read_buf + iStart, sizeof( read_buf ) - 10 - iStart, 0 );
#ifdef WIN32
iErr = WSAGetLastError( );
#else
iErr = errno;
#endif
if( nRead > 0 )
{
iStart += nRead;
if( read_buf[iStart - 1] == '\n' || read_buf[iStart - 1] == '\r' )
break;
}
else if( nRead == 0 )
{
log_string_plus( "EOF encountered on read.", LOG_COMM, sysdata.log_level );
return FALSE;
}
else if( iErr == EWOULDBLOCK )
break;
else
{
perror( "Read_from_descriptor" );
return FALSE;
}
}

read_buf[iStart] = '\0';
ProtocolInput( d, read_buf, iStart, d->inbuf );
return TRUE;
}



/*
* Transfer one line from input buffer to input line.
*/
void read_from_buffer( DESCRIPTOR_DATA * d )
{
int i, j, k;

#ifdef MCCP
int iac = 0;
#endif

/*
* Hold horses if pending command already.
*/
if( d->incomm[0] != '\0' )
return;

/*
* Look for at least one new line.
*/
for( i = 0; read_buf[i] != '\n' && read_buf[i] != '\r' && i < MAX_INBUF_SIZE; i++ )
{
if( read_buf[i] == '\0' )
return;
}

/*
* Canonical input processing.
*/
for( i = 0, k = 0; read_buf[i] != '\n' && read_buf[i] != '\r'; i++ )
{
int z = 0;
if( d->connected == CON_EDITING )
z = 254;
else
z = 762;
// if ( k >= 254 ) – This was the old buffer size, new is above.
if( k >= z )
{
write_to_descriptor( d->descriptor, "Line too long.\n\r", 0 );

/*
* skip the rest of the line
*/
/*
* for ( ; read_buf[i] != '\0' || i>= MAX_INBUF_SIZE ; i++ )
* {
* if ( read_buf[i] == '\n' || read_buf[i] == '\r' )
* break;
* }
*/
read_buf[i] = '\n';
read_buf[i + 1] = '\0';
break;
}

#ifdef MCCP
if( read_buf[i] == ( signed char )IAC )
iac = 1;
else if( iac == 1 && ( read_buf[i] == ( signed char )DO || read_buf[i] == ( signed char )DONT ) )
iac = 2;
else if( iac == 2 )
{
iac = 0;
if( read_buf[i] == ( signed char )TELOPT_COMPRESS )
{
if( read_buf[i - 1] == ( signed char )DO )
compressStart( d, TELOPT_COMPRESS );
else if( read_buf[i - 1] == ( signed char )DONT )
compressEnd( d );
}
else if( read_buf[i] == ( signed char )TELOPT_COMPRESS2 )
{
if( read_buf[i - 1] == ( signed char )DO )
compressStart( d, TELOPT_COMPRESS2 );
else if( read_buf[i - 1] == ( signed char )DONT )
compressEnd( d );
}
}
else
#endif

if( read_buf[i] == '\b' && k > 0 )
–k;
else if( isascii( read_buf[i] ) && isprint( read_buf[i] ) )
d->incomm[k++] = read_buf[i];
}

/*
* Finish off the line.
*/
if( k == 0 )
d->incomm[k++] = ' ';
d->incomm[k] = '\0';

/*
* Deal with bozos with #repeat 1000 …
*/
if( k > 1 || d->incomm[0] == '!' )
{
if( d->incomm[0] != '!' && strcmp( d->incomm, d->inlast ) )
{
d->repeat = 0;
}
else
{
if( ++d->repeat >= 20 )
{
/* sprintf( log_buf, "%s input spamming!", d->host );
log_string( log_buf );
*/
write_to_descriptor( d->descriptor,
"\n\r*** PUT A LID ON IT!!! ***\n\rYou cannot enter the same command more than 20 consecutive times!\n\r",
0 );
strcpy( d->incomm, "quit" );
}
}
}

/*
* Do '!' substitution.
*/
if( d->incomm[0] == '!' )
strcpy( d->incomm, d->inlast );
else
strcpy( d->inlast, d->incomm );

/*
* Shift the input buffer.
*/
while( read_buf[i] == '\n' || read_buf[i] == '\r' )
i++;
for( j = 0; ( read_buf[j] = read_buf[i + j] ) != '\0'; j++ )
;
return;
}
[/code]
12 Dec, 2012, KaVir wrote in the 13th comment:
Votes: 0
arbin said:
Im having completely different issues in comm.c and Im really rusty at coding, ive been back for maybe a month and a half after 7 years of not doin a thing:

bool read_from_descriptor( DESCRIPTOR_DATA * d )
{
int iStart, iErr;
char read_buf [MAX_PROTOCOL_BUFFER];
read_buf( [0] = '\0' );

That should be: read_buf[0] = '\0';

I'd recommend copying and pasting the changes from the installation instructions, and it should work out-of-the-box.
12 Dec, 2012, arbin wrote in the 14th comment:
Votes: 0
Quote
arbin said:
Im having completely different issues in comm.c and Im really rusty at coding, ive been back for maybe a month and a half after 7 years of not doin a thing:

bool read_from_descriptor( DESCRIPTOR_DATA * d )
{
int iStart, iErr;
char read_buf [MAX_PROTOCOL_BUFFER];
read_buf( [0] = '\0' );

That should be: read_buf[0] = '\0';

I'd recommend copying and pasting the changes from the installation instructions, and it should work out-of-the-box.


Oh i know, the errors from the compiler don't change even if I do that, I made that change after that, tried to fix it on my own. My friend says the errors aren't normal.
12 Dec, 2012, arbin wrote in the 15th comment:
Votes: 0
Here is a list of the compiler errors with it out-of-the-box:

comm.c: In function read_from_descriptor:
comm.c:1395:17: error: expected identifier or ( before
comm.c: In function read_from_descriptor:
comm.c:1395:17: error: expected identifier or ( before [ token
comm.c:1396:11: error: expected expression before [ token
comm.c:1407:3: error: too few arguments to function strlen
comm.c:1408:33: error: expected expression before , token
comm.c:1427:70: error: expected expression before ) token
comm.c:1427:70: error: too few arguments to function recv
/usr/include/i386-linux-gnu/bits/socket2.h:35:1: note: declared here
comm.c:1436:19: error: expected expression before [ token
comm.c:1436:51: error: expected expression before [ token
comm.c:1453:11: error: expected expression before [ token
comm.c:1454:29: error: expected expression before , token
comm.c: In function read_from_buffer:
comm.c:1480:23: error: expected expression before [ token
comm.c:1482:17: error: expected expression before [ token
comm.c:1489:30: error: expected expression before [ token
comm.c:1511:15: error: expected expression before [ token
comm.c:1512:15: error: expected expression before [ token
comm.c:1517:17: error: expected expression before [ token
comm.c:1519:36: error: expected expression before [ token
comm.c:1524:19: error: expected expression before [ token
comm.c:1526:21: error: expected expression before [ token
comm.c:1528:26: error: expected expression before [ token
comm.c:1531:24: error: expected expression before [ token
comm.c:1533:21: error: expected expression before [ token
comm.c:1535:26: error: expected expression before [ token
comm.c:1542:17: error: expected expression before [ token
comm.c:1544:14: error: expected expression before [ token
comm.c:1544:40: error: expected expression before [ token
comm.c:1545:32: error: expected expression before [ token
comm.c:1590:18: error: expected expression before [ token
comm.c:1592:25: error: expected expression before [ token
comm.c: In function nanny:
comm.c:2448:71: error: expected expression before ) token
make[1]: *** [o/comm.o] Error 1
make[1]: Leaving directory `/home/leon/code/src'
make: *** [all] Error 2
[/code]
12 Dec, 2012, arbin wrote in the 16th comment:
Votes: 0
oh snap forgot one more mod i made its on line 1395

i changed:
{
int iStart, iErr;
static char read_buf [MAX_PROTOCOL_BUFFER];
read_buf[0] = '\0';


to this:
{
int iStart, iErr;
char read_buf [MAX_PROTOCOL_BUFFER];
read_buf[0] = '\0';


It didnt change my errors one bit
12 Dec, 2012, KaVir wrote in the 17th comment:
Votes: 0
If I had to guess, I'd say you'd accidently changed a macro somewhere, perhaps hit the wrong key while editing the code and added a "If I had to guess, I'd say you'd accidently changed a macro somewhere, perhaps hit the wrong key while editing the code and added a "[" character.
12 Dec, 2012, arbin wrote in the 18th comment:
Votes: 0
ok ill check into it man, i hate being on a laptop, stupid touchpad messes me up alot, but ill let you know
12 Dec, 2012, arbin wrote in the 19th comment:
Votes: 0
ive got to thinking about it, probly the best thing to do would be to replace comm.c with the backup and redo the install, didnt take me too long to do the first time
12 Dec, 2012, KaVir wrote in the 20th comment:
Votes: 0
If you've kept a backup, then that's even better. Do a diff of the two files and you'll see exactly what's changed.
0.0/67