From 41eb9b82fcac50c94a524a6e8e55000126558fa7 Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Tue, 8 Feb 2005 03:33:49 +0000 Subject: [PATCH] * client_gets(char *buf) has been replaced by client_getln(char *buf, int maxbytes) --- citadel/ChangeLog | 5 +- citadel/citserver.c | 4 +- citadel/control.c | 2 +- citadel/imap_misc.c | 4 +- citadel/msgbase.c | 4 +- citadel/room_ops.c | 2 +- citadel/serv_bio.c | 2 +- citadel/serv_chat.c | 3 +- citadel/serv_imap.c | 2 +- citadel/serv_network.c | 2 +- citadel/serv_pop3.c | 2 +- citadel/serv_smtp.c | 2 +- citadel/serv_vandelay.c | 190 ++++++++++++++++++++-------------------- citadel/serv_vcard.c | 2 +- citadel/sysdep.c | 8 +- citadel/sysdep_decls.h | 2 +- 16 files changed, 119 insertions(+), 117 deletions(-) diff --git a/citadel/ChangeLog b/citadel/ChangeLog index 474a6f131..93c1d9e37 100644 --- a/citadel/ChangeLog +++ b/citadel/ChangeLog @@ -1,4 +1,8 @@ $Log$ + Revision 630.15 2005/02/08 03:33:49 ajc + * client_gets(char *buf) has been replaced by + client_getln(char *buf, int maxbytes) + Revision 630.14 2005/02/05 22:56:31 ajc * More reliable handling of conversion of vCard UID to Citadel Extended ID (necessary for GroupDAV URL's to be generated properly in WebCit) @@ -6356,4 +6360,3 @@ Sat Jul 11 00:20:48 EDT 1998 Nathan Bryant Fri Jul 10 1998 Art Cancro * Initial CVS import - diff --git a/citadel/citserver.c b/citadel/citserver.c index 10fc7be92..ffeea2170 100644 --- a/citadel/citserver.c +++ b/citadel/citserver.c @@ -622,7 +622,7 @@ void cmd_emsg(char *mname) } cprintf("%d %s\n", SEND_LISTING, targ); - while (client_gets(buf), strcmp(buf, "000")) { + while (client_getln(buf, sizeof buf), strcmp(buf, "000")) { fprintf(mfp, "%s\n", buf); } @@ -944,7 +944,7 @@ void do_command_loop(void) { time(&CC->lastcmd); memset(cmdbuf, 0, sizeof cmdbuf); /* Clear it, just in case */ - if (client_gets(cmdbuf) < 1) { + if (client_getln(cmdbuf, sizeof cmdbuf) < 1) { lprintf(CTDL_ERR, "Client socket is broken; ending session\n"); CC->kill_me = 1; return; diff --git a/citadel/control.c b/citadel/control.c index ef507f6f3..9cd1128e7 100644 --- a/citadel/control.c +++ b/citadel/control.c @@ -218,7 +218,7 @@ void cmd_conf(char *argbuf) unbuffer_output(); cprintf("%d Send configuration...\n", SEND_LISTING); a = 0; - while (client_gets(buf), strcmp(buf, "000")) { + while (client_getln(buf, sizeof buf), strcmp(buf, "000")) { switch (a) { case 0: safestrncpy(config.c_nodename, buf, diff --git a/citadel/imap_misc.c b/citadel/imap_misc.c index 5bf63ff6b..74057e8c6 100644 --- a/citadel/imap_misc.c +++ b/citadel/imap_misc.c @@ -283,10 +283,10 @@ void imap_append(int num_parms, char *parms[]) { /* I think there's supposed to be a trailing CRLF after the * literal (the message text) is received. This call to - * client_gets() absorbs it. + * client_getln() absorbs it. */ flush_output(); - client_gets(buf); + client_getln(buf, sizeof buf); lprintf(CTDL_DEBUG, "Trailing CRLF: %s\n", buf); /* Convert RFC822 newlines (CRLF) to Unix newlines (LF) */ diff --git a/citadel/msgbase.c b/citadel/msgbase.c index 8f1849e08..956ea3d6a 100644 --- a/citadel/msgbase.c +++ b/citadel/msgbase.c @@ -568,7 +568,7 @@ void cmd_msgs(char *cmdbuf) template = (struct CtdlMessage *) malloc(sizeof(struct CtdlMessage)); memset(template, 0, sizeof(struct CtdlMessage)); - while(client_gets(buf), strcmp(buf,"000")) { + while(client_getln(buf, sizeof buf), strcmp(buf,"000")) { extract(tfield, buf, 0); extract(tvalue, buf, 1); for (i='A'; i<='Z'; ++i) if (msgkeys[i]!=NULL) { @@ -2254,7 +2254,7 @@ char *CtdlReadMessageBody(char *terminator, /* token signalling EOT */ /* read in the lines of message text one by one */ do { - if (client_gets(buf) < 1) finished = 1; + if (client_getln(buf, sizeof buf) < 1) finished = 1; if (!strcmp(buf, terminator)) finished = 1; if (crlf) { strcat(buf, "\r\n"); diff --git a/citadel/room_ops.c b/citadel/room_ops.c index 1b00fe485..7a1eed03f 100644 --- a/citadel/room_ops.c +++ b/citadel/room_ops.c @@ -1841,7 +1841,7 @@ void cmd_einf(char *ok) cprintf("%d Send info...\n", SEND_LISTING); do { - client_gets(buf); + client_getln(buf, sizeof buf); if (strcmp(buf, "000")) fprintf(fp, "%s\n", buf); } while (strcmp(buf, "000")); diff --git a/citadel/serv_bio.c b/citadel/serv_bio.c index 788693bdf..987e1df78 100644 --- a/citadel/serv_bio.c +++ b/citadel/serv_bio.c @@ -70,7 +70,7 @@ void cmd_ebio(char *cmdbuf) { return; } cprintf("%d \n",SEND_LISTING); - while(client_gets(buf), strcmp(buf,"000")) { + while(client_getln(buf, sizeof buf), strcmp(buf,"000")) { if (ftell(fp) < config.c_maxmsglen) { fprintf(fp,"%s\n",buf); } diff --git a/citadel/serv_chat.c b/citadel/serv_chat.c index 0c2e9135b..f03e4e00b 100644 --- a/citadel/serv_chat.c +++ b/citadel/serv_chat.c @@ -713,7 +713,8 @@ void cmd_sexp(char *argbuf) SEND_LISTING, message_sent); x_big_msgbuf = malloc(SIZ); memset(x_big_msgbuf, 0, SIZ); - while (client_gets(x_msg), strcmp(x_msg, "000")) { + while (client_getln(x_msg, sizeof x_msg), + strcmp(x_msg, "000")) { x_big_msgbuf = realloc(x_big_msgbuf, strlen(x_big_msgbuf) + strlen(x_msg) + 4); if (strlen(x_big_msgbuf) > 0) diff --git a/citadel/serv_imap.c b/citadel/serv_imap.c index aabf7ba17..d9402ef35 100644 --- a/citadel/serv_imap.c +++ b/citadel/serv_imap.c @@ -1260,7 +1260,7 @@ void imap_command_loop(void) CC->lastcmd = time(NULL); memset(cmdbuf, 0, sizeof cmdbuf); /* Clear it, just in case */ flush_output(); - if (client_gets(cmdbuf) < 1) { + if (client_getln(cmdbuf, sizeof cmdbuf) < 1) { lprintf(CTDL_ERR, "IMAP socket is broken. Ending session.\r\n"); CC->kill_me = 1; return; diff --git a/citadel/serv_network.c b/citadel/serv_network.c index f32bc78d6..66fe1c864 100644 --- a/citadel/serv_network.c +++ b/citadel/serv_network.c @@ -395,7 +395,7 @@ void cmd_snet(char *argbuf) { } cprintf("%d %s\n", SEND_LISTING, tempfilename); - while (client_gets(buf), strcmp(buf, "000")) { + while (client_getln(buf, sizeof buf), strcmp(buf, "000")) { fprintf(fp, "%s\n", buf); } fclose(fp); diff --git a/citadel/serv_pop3.c b/citadel/serv_pop3.c index 8e10bbf1f..46f2d7f2b 100644 --- a/citadel/serv_pop3.c +++ b/citadel/serv_pop3.c @@ -567,7 +567,7 @@ void pop3_command_loop(void) { time(&CC->lastcmd); memset(cmdbuf, 0, sizeof cmdbuf); /* Clear it, just in case */ - if (client_gets(cmdbuf) < 1) { + if (client_getln(cmdbuf, sizeof cmdbuf) < 1) { lprintf(CTDL_ERR, "POP3 socket is broken. Ending session.\r\n"); CC->kill_me = 1; return; diff --git a/citadel/serv_smtp.c b/citadel/serv_smtp.c index 03c3e1251..5c0767acd 100644 --- a/citadel/serv_smtp.c +++ b/citadel/serv_smtp.c @@ -783,7 +783,7 @@ void smtp_command_loop(void) { time(&CC->lastcmd); memset(cmdbuf, 0, sizeof cmdbuf); /* Clear it, just in case */ - if (client_gets(cmdbuf) < 1) { + if (client_getln(cmdbuf, sizeof cmdbuf) < 1) { lprintf(CTDL_CRIT, "SMTP socket is broken. Ending session.\n"); CC->kill_me = 1; return; diff --git a/citadel/serv_vandelay.c b/citadel/serv_vandelay.c index 272476a45..372b1e255 100644 --- a/citadel/serv_vandelay.c +++ b/citadel/serv_vandelay.c @@ -324,47 +324,45 @@ void artv_import_config(void) { char buf[SIZ]; lprintf(CTDL_DEBUG, "Importing config file\n"); - client_gets(config.c_nodename); - lprintf(CTDL_DEBUG, "c_nodename = %s\n", config.c_nodename); - client_gets(config.c_fqdn); - client_gets(config.c_humannode); - client_gets(config.c_phonenum); - client_gets(buf); config.c_bbsuid = atoi(buf); - client_gets(buf); config.c_creataide = atoi(buf); - client_gets(buf); config.c_sleeping = atoi(buf); - client_gets(buf); config.c_initax = atoi(buf); - client_gets(buf); config.c_regiscall = atoi(buf); - client_gets(buf); config.c_twitdetect = atoi(buf); - client_gets(config.c_twitroom); - client_gets(config.c_moreprompt); - client_gets(buf); config.c_restrict = atoi(buf); - client_gets(config.c_bbs_city); - client_gets(config.c_sysadm); - lprintf(CTDL_DEBUG, "c_sysadm = %s\n", config.c_sysadm); - client_gets(buf); config.c_setup_level = atoi(buf); - client_gets(buf); config.c_maxsessions = atoi(buf); - client_gets(buf); config.c_port_number = atoi(buf); - client_gets(buf); config.c_ep.expire_mode = atoi(buf); - client_gets(buf); config.c_ep.expire_value = atoi(buf); - client_gets(buf); config.c_userpurge = atoi(buf); - client_gets(buf); config.c_roompurge = atoi(buf); - client_gets(config.c_logpages); - client_gets(buf); config.c_createax = atoi(buf); - client_gets(buf); config.c_maxmsglen = atol(buf); - client_gets(buf); config.c_min_workers = atoi(buf); - client_gets(buf); config.c_max_workers = atoi(buf); - client_gets(buf); config.c_pop3_port = atoi(buf); - client_gets(buf); config.c_smtp_port = atoi(buf); - client_gets(buf); config.c_purge_hour = atoi(buf); - client_gets(buf); config.c_mbxep.expire_mode = atoi(buf); - client_gets(buf); config.c_mbxep.expire_value = atoi(buf); - client_gets(config.c_ldap_host); - client_gets(buf); config.c_ldap_port = atoi(buf); - client_gets(config.c_ldap_base_dn); - client_gets(config.c_ldap_bind_dn); - client_gets(config.c_ldap_bind_pw); - client_gets(config.c_ip_addr); - client_gets(buf); config.c_msa_port = atoi(buf); + client_getln(config.c_nodename, sizeof config.c_nodename); + client_getln(config.c_fqdn, sizeof config.c_fqdn); + client_getln(config.c_humannode, sizeof config.c_humannode); + client_getln(config.c_phonenum, sizeof config.c_phonenum); + client_getln(buf, sizeof buf); config.c_bbsuid = atoi(buf); + client_getln(buf, sizeof buf); config.c_creataide = atoi(buf); + client_getln(buf, sizeof buf); config.c_sleeping = atoi(buf); + client_getln(buf, sizeof buf); config.c_initax = atoi(buf); + client_getln(buf, sizeof buf); config.c_regiscall = atoi(buf); + client_getln(buf, sizeof buf); config.c_twitdetect = atoi(buf); + client_getln(config.c_twitroom, sizeof config.c_twitroom); + client_getln(config.c_moreprompt, sizeof config.c_moreprompt); + client_getln(buf, sizeof buf); config.c_restrict = atoi(buf); + client_getln(config.c_bbs_city, sizeof config.c_bbs_city); + client_getln(config.c_sysadm, sizeof config.c_sysadm); + client_getln(buf, sizeof buf); config.c_setup_level = atoi(buf); + client_getln(buf, sizeof buf); config.c_maxsessions = atoi(buf); + client_getln(buf, sizeof buf); config.c_port_number = atoi(buf); + client_getln(buf, sizeof buf); config.c_ep.expire_mode = atoi(buf); + client_getln(buf, sizeof buf); config.c_ep.expire_value = atoi(buf); + client_getln(buf, sizeof buf); config.c_userpurge = atoi(buf); + client_getln(buf, sizeof buf); config.c_roompurge = atoi(buf); + client_getln(config.c_logpages, sizeof config.c_logpages); + client_getln(buf, sizeof buf); config.c_createax = atoi(buf); + client_getln(buf, sizeof buf); config.c_maxmsglen = atol(buf); + client_getln(buf, sizeof buf); config.c_min_workers = atoi(buf); + client_getln(buf, sizeof buf); config.c_max_workers = atoi(buf); + client_getln(buf, sizeof buf); config.c_pop3_port = atoi(buf); + client_getln(buf, sizeof buf); config.c_smtp_port = atoi(buf); + client_getln(buf, sizeof buf); config.c_purge_hour = atoi(buf); + client_getln(buf, sizeof buf); config.c_mbxep.expire_mode = atoi(buf); + client_getln(buf, sizeof buf); config.c_mbxep.expire_value = atoi(buf); + client_getln(config.c_ldap_host, sizeof config.c_ldap_host); + client_getln(buf, sizeof buf); config.c_ldap_port = atoi(buf); + client_getln(config.c_ldap_base_dn, sizeof config.c_ldap_base_dn); + client_getln(config.c_ldap_bind_dn, sizeof config.c_ldap_bind_dn); + client_getln(config.c_ldap_bind_pw, sizeof config.c_ldap_bind_pw); + client_getln(config.c_ip_addr, sizeof config.c_ip_addr); + client_getln(buf, sizeof buf); config.c_msa_port = atoi(buf); put_config(); lprintf(CTDL_INFO, "Imported config file\n"); } @@ -375,11 +373,11 @@ void artv_import_control(void) { char buf[SIZ]; lprintf(CTDL_DEBUG, "Importing control file\n"); - client_gets(buf); CitControl.MMhighest = atol(buf); - client_gets(buf); CitControl.MMflags = atoi(buf); - client_gets(buf); CitControl.MMnextuser = atol(buf); - client_gets(buf); CitControl.MMnextroom = atol(buf); - client_gets(buf); CitControl.version = atoi(buf); + client_getln(buf, sizeof buf); CitControl.MMhighest = atol(buf); + client_getln(buf, sizeof buf); CitControl.MMflags = atoi(buf); + client_getln(buf, sizeof buf); CitControl.MMnextuser = atol(buf); + client_getln(buf, sizeof buf); CitControl.MMnextroom = atol(buf); + client_getln(buf, sizeof buf); CitControl.version = atoi(buf); put_control(); lprintf(CTDL_INFO, "Imported control file\n"); } @@ -389,19 +387,19 @@ void artv_import_user(void) { char buf[SIZ]; struct ctdluser usbuf; - client_gets(buf); usbuf.version = atoi(buf); - client_gets(buf); usbuf.uid = atoi(buf); - client_gets(usbuf.password); - client_gets(buf); usbuf.flags = atoi(buf); - client_gets(buf); usbuf.timescalled = atol(buf); - client_gets(buf); usbuf.posted = atol(buf); - client_gets(buf); usbuf.axlevel = atoi(buf); - client_gets(buf); usbuf.usernum = atol(buf); - client_gets(buf); usbuf.lastcall = atol(buf); - client_gets(buf); usbuf.USuserpurge = atoi(buf); - client_gets(usbuf.fullname); - client_gets(buf); usbuf.USscreenwidth = atoi(buf); - client_gets(buf); usbuf.USscreenheight = atoi(buf); + client_getln(buf, sizeof buf); usbuf.version = atoi(buf); + client_getln(buf, sizeof buf); usbuf.uid = atoi(buf); + client_getln(usbuf.password, sizeof usbuf.password); + client_getln(buf, sizeof buf); usbuf.flags = atoi(buf); + client_getln(buf, sizeof buf); usbuf.timescalled = atol(buf); + client_getln(buf, sizeof buf); usbuf.posted = atol(buf); + client_getln(buf, sizeof buf); usbuf.axlevel = atoi(buf); + client_getln(buf, sizeof buf); usbuf.usernum = atol(buf); + client_getln(buf, sizeof buf); usbuf.lastcall = atol(buf); + client_getln(buf, sizeof buf); usbuf.USuserpurge = atoi(buf); + client_getln(usbuf.fullname, sizeof usbuf.fullname); + client_getln(buf, sizeof buf); usbuf.USscreenwidth = atoi(buf); + client_getln(buf, sizeof buf); usbuf.USscreenheight = atoi(buf); putuser(&usbuf); } @@ -412,28 +410,28 @@ void artv_import_room(void) { long msgnum; int msgcount = 0; - client_gets(qrbuf.QRname); - client_gets(qrbuf.QRpasswd); - client_gets(buf); qrbuf.QRroomaide = atol(buf); - client_gets(buf); qrbuf.QRhighest = atol(buf); - client_gets(buf); qrbuf.QRgen = atol(buf); - client_gets(buf); qrbuf.QRflags = atoi(buf); - client_gets(qrbuf.QRdirname); - client_gets(buf); qrbuf.QRinfo = atol(buf); - client_gets(buf); qrbuf.QRfloor = atoi(buf); - client_gets(buf); qrbuf.QRmtime = atol(buf); - client_gets(buf); qrbuf.QRep.expire_mode = atoi(buf); - client_gets(buf); qrbuf.QRep.expire_value = atoi(buf); - client_gets(buf); qrbuf.QRnumber = atol(buf); - client_gets(buf); qrbuf.QRorder = atoi(buf); - client_gets(buf); qrbuf.QRflags2 = atoi(buf); - client_gets(buf); qrbuf.QRdefaultview = atoi(buf); + client_getln(qrbuf.QRname, sizeof qrbuf.QRname); + client_getln(qrbuf.QRpasswd, sizeof qrbuf.QRpasswd); + client_getln(buf, sizeof buf); qrbuf.QRroomaide = atol(buf); + client_getln(buf, sizeof buf); qrbuf.QRhighest = atol(buf); + client_getln(buf, sizeof buf); qrbuf.QRgen = atol(buf); + client_getln(buf, sizeof buf); qrbuf.QRflags = atoi(buf); + client_getln(qrbuf.QRdirname, sizeof qrbuf.QRdirname); + client_getln(buf, sizeof buf); qrbuf.QRinfo = atol(buf); + client_getln(buf, sizeof buf); qrbuf.QRfloor = atoi(buf); + client_getln(buf, sizeof buf); qrbuf.QRmtime = atol(buf); + client_getln(buf, sizeof buf); qrbuf.QRep.expire_mode = atoi(buf); + client_getln(buf, sizeof buf); qrbuf.QRep.expire_value = atoi(buf); + client_getln(buf, sizeof buf); qrbuf.QRnumber = atol(buf); + client_getln(buf, sizeof buf); qrbuf.QRorder = atoi(buf); + client_getln(buf, sizeof buf); qrbuf.QRflags2 = atoi(buf); + client_getln(buf, sizeof buf); qrbuf.QRdefaultview = atoi(buf); putroom(&qrbuf); lprintf(CTDL_INFO, "Imported room <%s>\n", qrbuf.QRname); /* format of message list export is all message numbers output * one per line terminated by a 0. */ - while (client_gets(buf), msgnum = atol(buf), msgnum > 0) { + while (client_getln(buf, sizeof buf), msgnum = atol(buf), msgnum > 0) { CtdlSaveMsgPointerInRoom(qrbuf.QRname, msgnum, 0); ++msgcount; } @@ -446,12 +444,12 @@ void artv_import_floor(void) { int i; char buf[SIZ]; - client_gets(buf); i = atoi(buf); - client_gets(buf); flbuf.f_flags = atoi(buf); - client_gets(flbuf.f_name); - client_gets(buf); flbuf.f_ref_count = atoi(buf); - client_gets(buf); flbuf.f_ep.expire_mode = atoi(buf); - client_gets(buf); flbuf.f_ep.expire_value = atoi(buf); + client_getln(buf, sizeof buf); i = atoi(buf); + client_getln(buf, sizeof buf); flbuf.f_flags = atoi(buf); + client_getln(flbuf.f_name, sizeof flbuf.f_name); + client_getln(buf, sizeof buf); flbuf.f_ref_count = atoi(buf); + client_getln(buf, sizeof buf); flbuf.f_ep.expire_mode = atoi(buf); + client_getln(buf, sizeof buf); flbuf.f_ep.expire_value = atoi(buf); putfloor(&flbuf, i); lprintf(CTDL_INFO, "Imported floor #%d (%s)\n", i, flbuf.f_name); } @@ -465,18 +463,18 @@ void artv_import_visit(void) { int i; int is_textual_seen = 0; - client_gets(buf); vbuf.v_roomnum = atol(buf); - client_gets(buf); vbuf.v_roomgen = atol(buf); - client_gets(buf); vbuf.v_usernum = atol(buf); + client_getln(buf, sizeof buf); vbuf.v_roomnum = atol(buf); + client_getln(buf, sizeof buf); vbuf.v_roomgen = atol(buf); + client_getln(buf, sizeof buf); vbuf.v_usernum = atol(buf); - client_gets(buf); + client_getln(buf, sizeof buf); vbuf.v_lastseen = atol(buf); for (i=0; i%s", tempfile); fp = popen(buf, "w"); - while (client_gets(buf), strcasecmp(buf, END_OF_MESSAGE)) { + while (client_getln(buf, sizeof buf), strcasecmp(buf, END_OF_MESSAGE)) { fprintf(fp, "%s\n", buf); } pclose(fp); @@ -540,12 +538,12 @@ void artv_do_import(void) { unbuffer_output(); cprintf("%d sock it to me\n", SEND_LISTING); - while (client_gets(buf), strcmp(buf, "000")) { + while (client_getln(buf, sizeof buf), strcmp(buf, "000")) { lprintf(CTDL_DEBUG, "import keyword: <%s>\n", buf); if (!strcasecmp(buf, "version")) { - client_gets(s_version); + client_getln(s_version, sizeof s_version); version = atoi(s_version); if ((versionREV_LEVEL)) { lprintf(CTDL_ERR, "Version mismatch in ARTV import; aborting\n"); @@ -563,7 +561,7 @@ void artv_do_import(void) { } lprintf(CTDL_INFO, "Invalid keyword <%s>. Flushing input.\n", buf); - while (client_gets(buf), strcmp(buf, "000")) ;; + while (client_getln(buf, sizeof buf), strcmp(buf, "000")) ;; } diff --git a/citadel/serv_vcard.c b/citadel/serv_vcard.c index f1b16f7e9..8500c9c19 100644 --- a/citadel/serv_vcard.c +++ b/citadel/serv_vcard.c @@ -604,7 +604,7 @@ void cmd_regi(char *argbuf) { cprintf("%d Send registration...\n", SEND_LISTING); a=0; - while (client_gets(buf), strcmp(buf,"000")) { + while (client_getln(buf, sizeof buf), strcmp(buf,"000")) { if (a==0) vcard_set_prop(my_vcard, "n", buf, 0); if (a==1) strcpy(tmpaddr, buf); if (a==2) strcpy(tmpcity, buf); diff --git a/citadel/sysdep.c b/citadel/sysdep.c index 7a0d5b0d1..61f7c363b 100644 --- a/citadel/sysdep.c +++ b/citadel/sysdep.c @@ -612,11 +612,11 @@ INLINE int client_read(char *buf, int bytes) /* - * client_gets() ... Get a LF-terminated line of text from the client. + * client_getln() ... Get a LF-terminated line of text from the client. * (This is implemented in terms of client_read() and could be * justifiably moved out of sysdep.c) */ -int client_gets(char *buf) +int client_getln(char *buf, int bufsize) { int i, retval; @@ -624,13 +624,13 @@ int client_gets(char *buf) */ for (i = 0;;i++) { retval = client_read(&buf[i], 1); - if (retval != 1 || buf[i] == '\n' || i == (SIZ-1)) + if (retval != 1 || buf[i] == '\n' || i == (bufsize-1)) break; } /* If we got a long line, discard characters until the newline. */ - if (i == (SIZ-1)) + if (i == (bufsize-1)) while (buf[i] != '\n' && retval == 1) retval = client_read(&buf[i], 1); diff --git a/citadel/sysdep_decls.h b/citadel/sysdep_decls.h index 94d98d5da..191be0f5e 100644 --- a/citadel/sysdep_decls.h +++ b/citadel/sysdep_decls.h @@ -55,7 +55,7 @@ void flush_output(void); void client_write (char *buf, int nbytes); int client_read_to (char *buf, int bytes, int timeout); int client_read (char *buf, int bytes); -int client_gets (char *buf); +int client_getln (char *buf, int maxbytes); void sysdep_master_cleanup (void); void kill_session (int session_to_kill); void *sd_context_loop (struct CitContext *con); -- 2.39.2