]> code.citadel.org Git - citadel.git/blobdiff - citadel/ipc_c_tcp.c
* The size constant "256" which shows up everywhere as a buffer size has now
[citadel.git] / citadel / ipc_c_tcp.c
index 844b21f655478ec7df0f51cb253e33f049e2676e..b49c6f1f2f5cf47074edd473486a32930fee8bb4 100644 (file)
@@ -1,9 +1,7 @@
 /*
- * ipc_c_tcp.c
+ * $Id$
  * 
- * Citadel/UX client/server IPC - client module using TCP/IP
- *
- * version 1.3 $Id$
+ * Client-side IPC functions
  *
  */
 
@@ -131,6 +129,7 @@ int uds_connectsock(char *sockpath)
        struct sockaddr_un addr;
        int s;
 
+
        memset(&addr, 0, sizeof(addr));
        addr.sun_family = AF_UNIX;
        strncpy(addr.sun_path, sockpath, sizeof addr.sun_path);
@@ -273,19 +272,20 @@ void serv_puts(char *buf)
 void attach_to_server(int argc, char **argv, char *hostbuf, char *portbuf)
 {
        int a;
-       char cithost[256];
+       char cithost[SIZ];
        int host_copied = 0;
-       char citport[256];
+       char citport[SIZ];
        int port_copied = 0;
-       char socks4[256];
-       char buf[256];
+       char socks4[SIZ];
+       char buf[SIZ];
        struct passwd *p;
-       char sockpath[256];
+       char sockpath[SIZ];
 
        strcpy(cithost, DEFAULT_HOST);  /* default host */
        strcpy(citport, DEFAULT_PORT);  /* default port */
        strcpy(socks4, "");     /* SOCKS v4 server */
 
+
        for (a = 0; a < argc; ++a) {
                if (a == 0) {
                        /* do nothing */
@@ -314,18 +314,18 @@ void attach_to_server(int argc, char **argv, char *hostbuf, char *portbuf)
 
        /* If we're using a unix domain socket we can do a bunch of stuff */
        if (!strcmp(cithost, UDS)) {
-               sprintf(sockpath, "%s/citadel.socket", BBSDIR);
+               sprintf(sockpath, "citadel.socket");
                serv_sock = uds_connectsock(sockpath);
-               strcpy(hostbuf, cithost);
-               strcpy(portbuf, sockpath);
+               if (hostbuf != NULL) strcpy(hostbuf, cithost);
+               if (portbuf != NULL) strcpy(portbuf, sockpath);
                return;
        }
 
        /* if not using a SOCKS proxy server, make the connection directly */
        if (strlen(socks4) == 0) {
                serv_sock = connectsock(cithost, citport, "tcp");
-               strcpy(hostbuf, cithost);
-               strcpy(portbuf, citport);
+               if (hostbuf != NULL) strcpy(hostbuf, cithost);
+               if (portbuf != NULL) strcpy(portbuf, citport);
                return;
        }
        /* if using SOCKS, connect first to the proxy... */