version 1.36 | | version 1.37 |
---|
| | |
| | |
/* | | /* |
* static char *rcsid_loop_c = | | * static char *rcsid_loop_c = |
* "$Id: loop.c,v 1.36 2005/12/07 18:25:56 akirschbaum Exp $"; | | * "$Id: loop.c,v 1.37 2005/12/11 19:11:32 akirschbaum Exp $"; |
*/ | | */ |
| | |
/* | | /* |
| | |
* or no more characters to read. | | * or no more characters to read. |
*/ | | */ |
do { | | do { |
| | if (ns->inbuf.len >= MAXSOCKBUF-1) { |
| | ns->status = Ns_Dead; |
| | LOG(llevDebug, "Old input socket sent too much data without newline\n"); |
| | return; |
| | } |
#ifdef WIN32 /* ***win32: change oldsocket read() to recv() */ | | #ifdef WIN32 /* ***win32: change oldsocket read() to recv() */ |
stat = recv(ns->fd, ns->inbuf.buf + ns->inbuf.len, 1,0); | | stat = recv(ns->fd, ns->inbuf.buf + ns->inbuf.len, 1,0); |
| | |
| | |
return; | | return; |
} | | } |
if (stat == 0) return; | | if (stat == 0) return; |
if (stat == MAXSOCKBUF-1) { | | |
ns->status = Ns_Dead; | | |
LOG(llevDebug, "Old input socket sent too much data without newline\n"); | | |
return; | | |
} | | |
} while (ns->inbuf.buf[ns->inbuf.len++]!='\n'); | | } while (ns->inbuf.buf[ns->inbuf.len++]!='\n'); |
| | |
ns->inbuf.buf[ns->inbuf.len]=0; | | ns->inbuf.buf[ns->inbuf.len]=0; |
| | |
return; | | return; |
} | | } |
if (!strcasecmp(ns->inbuf.buf, "listen")) { | | if (!strcasecmp(ns->inbuf.buf, "listen")) { |
if (ns->comment) free(ns->comment); | | |
if (cp) { | | if (cp) { |
char *buf="Socket switched to listen mode\n"; | | char *buf="Socket switched to listen mode\n"; |
| | |
| | free(ns->comment); |
ns->comment = strdup_local(cp); | | ns->comment = strdup_local(cp); |
ns->old_mode = Old_Listen; | | ns->old_mode = Old_Listen; |
cs_write_string(ns, buf, strlen(buf)); | | cs_write_string(ns, buf, strlen(buf)); |
| | |
| | |
if (!verify_player(cp, cp1)) { | | if (!verify_player(cp, cp1)) { |
char *buf="Welcome back\n"; | | char *buf="Welcome back\n"; |
if (ns->comment) free(ns->comment); | | free(ns->comment); |
ns->comment = strdup_local(cp); | | ns->comment = strdup_local(cp); |
ns->old_mode = Old_Player; | | ns->old_mode = Old_Player; |
cs_write_string(ns, buf, strlen(buf)); | | cs_write_string(ns, buf, strlen(buf)); |
| | |
command = find_oldsocket_command2(ns->inbuf.buf); | | command = find_oldsocket_command2(ns->inbuf.buf); |
} | | } |
if (!command) { | | if (!command) { |
sprintf(buf,"Could not find command: %s\n", ns->inbuf.buf); | | snprintf(buf, sizeof(buf), "Could not find command: %s\n", ns->inbuf.buf); |
cs_write_string(ns, buf, strlen(buf)); | | cs_write_string(ns, buf, strlen(buf)); |
return; | | return; |
} | | } |