X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=ctdlsh%2Fsockets.c;h=cb61c5339041c39b19bf0a8bc18bbfec26c59fd4;hb=HEAD;hp=3aaf7714064666dd55c79edf46462ffd2a5029e2;hpb=81ba4a49cd384ff484f6006fb508fc900d33a1af;p=citadel.git diff --git a/ctdlsh/sockets.c b/ctdlsh/sockets.c index 3aaf77140..cb61c5339 100644 --- a/ctdlsh/sockets.c +++ b/ctdlsh/sockets.c @@ -22,13 +22,13 @@ int uds_connectsock(char *sockpath) s = socket(AF_UNIX, SOCK_STREAM, 0); if (s < 0) { fprintf(stderr, "Can't create socket[%s]: %s\n", sockpath, strerror(errno)); - return(-1); + return (-1); } if (connect(s, (struct sockaddr *) &addr, sizeof(addr)) < 0) { fprintf(stderr, "Can't connect [%s]: %s\n", sockpath, strerror(errno)); close(s); - return(-1); + return (-1); } return s; @@ -42,35 +42,35 @@ int uds_connectsock(char *sockpath) */ int sock_read_to(int sock, char *buf, int bytes, int timeout, int keep_reading_until_full) { - int len,rlen; + int len, rlen; fd_set rfds; struct timeval tv; int retval; len = 0; - while (len 0) - && ( (buf[i - 1]==13) - || ( buf[i - 1]==10)) ) { + while ((i > 0) + && ((buf[i - 1] == 13) + || (buf[i - 1] == 10))) { i--; buf[i] = 0; } - return(i); + return (i); } @@ -148,17 +149,19 @@ int sock_puts(int sock, char *buf) int i, j; i = sock_write(sock, buf, strlen(buf)); - if (i<0) return(i); + if (i < 0) + return (i); j = sock_write(sock, "\n", 1); - if (j<0) return(j); - return(i+j); + if (j < 0) + return (j); + return (i + j); } /* * Write a formatted string to the server - implemented in terms of sock_write() */ -void sock_printf(int sock, const char *format,...) +void sock_printf(int sock, const char *format, ...) { va_list arg_ptr; char buf[4096];