/* $Id$ */
#define UDS "_UDS_"
+#ifdef __CYGWIN__
+#define DEFAULT_HOST "localhost"
+#else
#define DEFAULT_HOST UDS
+#endif
#define DEFAULT_PORT "citadel"
#include "sysdep.h"
mptr->march_flags = (unsigned int) extract_int(aaa, 1);
mptr->march_floor = (char) extract_int(aaa, 2);
mptr->march_order = (char) extract_int(aaa, 3);
+ mptr->march_flags2 = (unsigned int) extract_int(aaa, 4);
+ mptr->march_access = (char) extract_int(aaa, 5);
if (march == NULL)
march = mptr;
else {
/* 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);
/* SETU */
-int CtdlIPCSetConfig(CtdlIPC *ipc, struct usersupp *uret, char *cret)
+int CtdlIPCSetConfig(CtdlIPC *ipc, struct ctdluser *uret, char *cret)
{
char aaa[48];
}
remove_token(bbb, 0, '\n');
} while ((bbb[0] != 0) && (bbb[0] != '\n'));
- /*ooga*/ remove_token(bbb, 0, '\n');
+ remove_token(bbb, 0, '\n');
}
/* 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);
/* 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;
int CtdlIPCPostMessage(CtdlIPC *ipc, int flag, const struct ctdlipcmessage *mr, char *cret)
{
register int ret;
- char *aaa;
+ char cmd[SIZ];
if (!cret) return -2;
if (!mr) return -2;
- aaa = (char *)malloc(strlen(mr->recipient) + strlen(mr->author) + 40);
- if (!aaa) return -1;
-
- sprintf(aaa, "ENT0 %d|%s|%d|%d|%s|%s", flag, mr->recipient,
+ snprintf(cmd, sizeof cmd,
+ "ENT0 %d|%s|%d|%d|%s|%s", flag, mr->recipient,
mr->anonymous, mr->type, mr->subject, mr->author);
- ret = CtdlIPCGenericCommand(ipc, aaa, mr->text, strlen(mr->text), NULL,
+ ret = CtdlIPCGenericCommand(ipc, cmd, mr->text, strlen(mr->text), NULL,
NULL, cret);
- free(aaa);
return ret;
}
time_t last_mod;
char filename[SIZ];
char mimetype[SIZ];
- char *aaa;
+ char aaa[SIZ];
if (!cret) return -2;
if (!buf) return -2;
if (!msgnum) return -2;
if (ipc->downloading) return -2;
- aaa = (char *)malloc(strlen(part) + 17);
- if (!aaa) return -1;
-
sprintf(aaa, "OPNA %ld|%s", msgnum, part);
ret = CtdlIPCGenericCommand(ipc, aaa, NULL, 0, NULL, NULL, cret);
- free(aaa);
if (ret / 100 == 2) {
ipc->downloading = 1;
bytes = extract_long(cret, 0);
last_mod = extract_int(cret, 1);
- extract(mimetype, cret, 2);
-/* ret = CtdlIPCReadDownload(ipc, buf, bytes, 0, progress_gauge_callback, cret); */
+ extract(filename, cret, 2);
+ extract(mimetype, cret, 3);
+ /* ret = CtdlIPCReadDownload(ipc, buf, bytes, 0, progress_gauge_callback, cret); */
ret = CtdlIPCHighSpeedReadDownload(ipc, buf, bytes, 0, progress_gauge_callback, cret);
ret = CtdlIPCEndDownload(ipc, cret);
if (ret / 100 == 2)
int CtdlIPCCreateFloor(CtdlIPC *ipc, int for_real, const char *name, char *cret)
{
register int ret;
- char *aaa;
+ char aaa[SIZ];
if (!cret) return -2;
if (!name) return -2;
- if (!*name) return -2;
-
- aaa = (char *)malloc(strlen(name) + 17);
- if (!aaa) return -1;
sprintf(aaa, "CFLR %s|%d", name, for_real);
ret = CtdlIPCGenericCommand(ipc, aaa, NULL, 0, NULL, NULL, cret);
- free(aaa);
return ret;
}
/* KFLR */
int CtdlIPCDeleteFloor(CtdlIPC *ipc, int for_real, int floornum, char *cret)
{
- char aaa[27];
+ char aaa[SIZ];
if (!cret) return -1;
if (floornum < 0) return -1;
int CtdlIPCEditFloor(CtdlIPC *ipc, int floornum, const char *floorname, char *cret)
{
register int ret;
- char *aaa;
+ char aaa[SIZ];
if (!cret) return -2;
if (!floorname) return -2;
if (floornum < 0) return -2;
- aaa = (char *)malloc(strlen(floorname) + 17);
- if (!aaa) return -1;
-
sprintf(aaa, "EFLR %d|%s", floornum, floorname);
ret = CtdlIPCGenericCommand(ipc, aaa, NULL, 0, NULL, NULL, cret);
- free(aaa);
return ret;
}
/* 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);
/* 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;
return len;
}
-
/* READ - pipelined */
int CtdlIPCHighSpeedReadDownload(CtdlIPC *ipc, void **buf, size_t bytes,
size_t resume,
}
if (connect(s, (struct sockaddr *) &sin, sizeof(sin)) < 0) {
+ close(s);
return -1;
}
}
if (connect(s, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
+ close(s);
return -1;
}
}
error_printf("SSL_read in serv_read:\n");
ERR_print_errors_fp(stderr);
- connection_died(NULL);
+ connection_died(ipc);
return;
}
len += rlen;
}
error_printf("SSL_write in serv_write:\n");
ERR_print_errors_fp(stderr);
- connection_died(NULL);
+ connection_died(ipc);
return;
}
bytes_written += retval;
while (buf[i] != '\n')
serv_read(ipc, &buf[i], 1);
- /* Strip the trailing newline.
- */
- buf[i] = 0;
+ /* Strip the trailing newline (and carriage return, if present) */
+ if (buf[i] == 10) buf[i--] = 0;
+ if (buf[i] == 13) buf[i--] = 0;
}
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 */