/*
- * ipc_c_tcp.c
+ * $Id$
*
- * Citadel/UX client/server IPC - client module using TCP/IP
- *
- * version 1.3 $Id$
+ * Client-side IPC functions
*
*/
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);
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 */
/* 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... */