]> code.citadel.org Git - citadel.git/blobdiff - citadel/citadel_ipc.c
* Renamed "struct user" to "struct ctdluser"
[citadel.git] / citadel / citadel_ipc.c
index c4feabae6085761240c62f64337fcaa1385f1b4a..f69d4be05f751864ab304068265daa89f0a86f2a 100644 (file)
@@ -1,7 +1,11 @@
 /* $Id$ */
 
 #define        UDS                     "_UDS_"
+#ifdef __CYGWIN__
+#define DEFAULT_HOST           "localhost"
+#else
 #define DEFAULT_HOST           UDS
+#endif
 #define DEFAULT_PORT           "citadel"
 
 #include "sysdep.h"
@@ -324,14 +328,14 @@ int CtdlIPCKnownRooms(CtdlIPC *ipc, enum RoomList which, int floor, struct march
 
 
 /* GETU */
-/* Caller must free the struct usersupp; caller may pass an existing one */
-int CtdlIPCGetConfig(CtdlIPC *ipc, struct usersupp **uret, char *cret)
+/* Caller must free the struct ctdluser; caller may pass an existing one */
+int CtdlIPCGetConfig(CtdlIPC *ipc, struct ctdluser **uret, char *cret)
 {
        register int ret;
 
        if (!cret) return -2;
        if (!uret) return -2;
-       if (!*uret) *uret = (struct usersupp *)calloc(1, sizeof (struct usersupp));
+       if (!*uret) *uret = (struct ctdluser *)calloc(1, sizeof (struct ctdluser));
        if (!*uret) return -1;
 
        ret = CtdlIPCGenericCommand(ipc, "GETU", NULL, 0, NULL, NULL, cret);
@@ -345,7 +349,7 @@ int CtdlIPCGetConfig(CtdlIPC *ipc, struct usersupp **uret, char *cret)
 
 
 /* SETU */
-int CtdlIPCSetConfig(CtdlIPC *ipc, struct usersupp *uret, char *cret)
+int CtdlIPCSetConfig(CtdlIPC *ipc, struct ctdluser *uret, char *cret)
 {
        char aaa[48];
 
@@ -732,13 +736,13 @@ int CtdlIPCKickoutUserFromRoom(CtdlIPC *ipc, const char *username, char *cret)
 
 
 /* GETR */
-int CtdlIPCGetRoomAttributes(CtdlIPC *ipc, struct quickroom **qret, char *cret)
+int CtdlIPCGetRoomAttributes(CtdlIPC *ipc, struct ctdlroom **qret, char *cret)
 {
        register int ret;
 
        if (!cret) return -2;
        if (!qret) return -2;
-       if (!*qret) *qret = (struct quickroom *)calloc(1, sizeof (struct quickroom));
+       if (!*qret) *qret = (struct ctdlroom *)calloc(1, sizeof (struct ctdlroom));
        if (!*qret) return -1;
 
        ret = CtdlIPCGenericCommand(ipc, "GETR", NULL, 0, NULL, NULL, cret);
@@ -758,7 +762,7 @@ int CtdlIPCGetRoomAttributes(CtdlIPC *ipc, struct quickroom **qret, char *cret)
 
 /* SETR */
 /* set forget to kick all users out of room */
-int CtdlIPCSetRoomAttributes(CtdlIPC *ipc, int forget, struct quickroom *qret, char *cret)
+int CtdlIPCSetRoomAttributes(CtdlIPC *ipc, int forget, struct ctdlroom *qret, char *cret)
 {
        register int ret;
        char *aaa;
@@ -1659,14 +1663,14 @@ time_t CtdlIPCServerTime(CtdlIPC *ipc, char *cret)
 
 /* AGUP */
 int CtdlIPCAideGetUserParameters(CtdlIPC *ipc, const char *who,
-                                struct usersupp **uret, char *cret)
+                                struct ctdluser **uret, char *cret)
 {
        register int ret;
        char aaa[SIZ];
 
        if (!cret) return -2;
        if (!uret) return -2;
-       if (!*uret) *uret = (struct usersupp *)calloc(1, sizeof(struct usersupp));
+       if (!*uret) *uret = (struct ctdluser *)calloc(1, sizeof(struct ctdluser));
        if (!*uret) return -1;
 
        sprintf(aaa, "AGUP %s", who);
@@ -1688,7 +1692,7 @@ int CtdlIPCAideGetUserParameters(CtdlIPC *ipc, const char *who,
 
 
 /* ASUP */
-int CtdlIPCAideSetUserParameters(CtdlIPC *ipc, const struct usersupp *uret, char *cret)
+int CtdlIPCAideSetUserParameters(CtdlIPC *ipc, const struct ctdluser *uret, char *cret)
 {
        register int ret;
        char *aaa;
@@ -2487,6 +2491,7 @@ static int connectsock(char *host, char *service, char *protocol, int defaultPor
        }
 
        if (connect(s, (struct sockaddr *) &sin, sizeof(sin)) < 0) {
+               close(s);
                return -1;
        }
 
@@ -2508,6 +2513,7 @@ static int uds_connectsock(int *isLocal, char *sockpath)
        }
 
        if (connect(s, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
+               close(s);
                return -1;
        }
 
@@ -2818,6 +2824,13 @@ CtdlIPC* CtdlIPC_new(int argc, char **argv, char *hostbuf, char *portbuf)
        strcpy(cithost, DEFAULT_HOST);  /* default host */
        strcpy(citport, DEFAULT_PORT);  /* default port */
 
+       /* Allow caller to supply our values (Windows) */
+       if (hostbuf && strlen(hostbuf) > 0)
+               strcpy(cithost, hostbuf);
+       if (portbuf && strlen(portbuf) > 0)
+               strcpy(citport, portbuf);
+
+       /* Read host/port from command line if present */
        for (a = 0; a < argc; ++a) {
                if (a == 0) {
                        /* do nothing */