]> code.citadel.org Git - citadel.git/blobdiff - citadel/ipc_c_tcp.c
Fixes for Cygwin (see ChangeLog)
[citadel.git] / citadel / ipc_c_tcp.c
index 53609d48e723bf89312faf3d978fad7e1db481f3..7f99b246403079c016b87eef6da67a440b16cf27 100644 (file)
@@ -3,7 +3,7 @@
  * 
  * Citadel/UX client/server IPC - client module using TCP/IP
  *
- * version 1.3
+ * version 1.3 $Id$
  *
  */
 
 #include <string.h>
 #include <pwd.h>
 #include <errno.h>
+#include <stdarg.h>
+#include "citadel.h"
 #include "citadel_decls.h"
 #include "ipc.h"
+#ifndef HAVE_SNPRINTF
+#include "snprintf.h"
+#endif
 
 /*
  * If server_is_local is set to nonzero, the client assumes that it is running
@@ -59,7 +64,7 @@ int connectsock(char *host, char *service, char *protocol)
        struct sockaddr_in sin;
        int s,type;
 
-       bzero((char *)&sin,sizeof(sin));
+       memset(&sin,0,sizeof(sin));
        sin.sin_family = AF_INET;
 
        pse=getservbyname(service,protocol);
@@ -127,7 +132,7 @@ void numericize(char *buf, char *host, char *service, char *protocol)
        struct servent *pse;
        struct sockaddr_in sin;
 
-       bzero((char *)&sin,sizeof(sin));
+       memset(&sin,0,sizeof(sin));
        sin.sin_family = AF_INET;
 
        pse=getservbyname(service,protocol);
@@ -169,8 +174,8 @@ void serv_read(char *buf, int bytes)
        while(len<bytes) {
                rlen = read(serv_sock,&buf[len],bytes-len);
                if (rlen<1) {
-                       printf("\rNetwork error - connection terminated.\n");
-                       printf("%s\n", strerror(errno));
+                       /* printf("\rNetwork error - connection terminated.\n");
+                       printf("%s\n", strerror(errno)); */
                        logoff(3);
                        }
                len = len + rlen;
@@ -189,8 +194,9 @@ void serv_write(char *buf, int nbytes)
                retval = write(serv_sock, &buf[bytes_written],
                        nbytes - bytes_written);
                if (retval < 1) {
+                       /*
                        printf("\rNetwork error - connection terminated.\n");
-                       printf("%s\n", strerror(errno));
+                       printf("%s\n", strerror(errno)); */
                        logoff(3);
                        }
                bytes_written = bytes_written + retval;
@@ -295,7 +301,7 @@ void attach_to_server(int argc, char **argv)
        printf("Attaching to server...\r");
        fflush(stdout);
 
-       sprintf(buf,"%c%c",
+       snprintf(buf,sizeof buf,"%c%c",
                4,                      /* version 4 */
                1);                     /* method = connect */
        serv_write(buf,2);