X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=textclient%2Fcitadel_ipc.c;h=3b3cb45939e4aab085fb14f92f786734643b1e58;hb=HEAD;hp=f810edf001b4bec57052946659a45637787e25a9;hpb=25220160fc09e185bbf9f13f7565bb568cc5a463;p=citadel.git diff --git a/textclient/citadel_ipc.c b/textclient/citadel_ipc.c index f810edf00..3b3cb4593 100644 --- a/textclient/citadel_ipc.c +++ b/textclient/citadel_ipc.c @@ -1,14 +1,6 @@ -/* - * Copyright (c) 1987-2019 by the citadel.org team - * - * This program is open source software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 3. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ +// Copyright (c) 1987-2022 by the citadel.org team +// +// This program is open source software. Use, duplication, or disclosure is subject to the GNU General Public License version 3. #include "textclient.h" @@ -16,14 +8,13 @@ static SSL_CTX *ssl_ctx; char arg_encrypt; char rc_encrypt; - #endif /* HAVE_OPENSSL */ #ifndef INADDR_NONE #define INADDR_NONE 0xffffffff #endif -static void (*status_hook) (char *s) = NULL; +static void (*status_hook)(char *s) = NULL; char ctdl_autoetc_dir[PATH_MAX] = ""; char file_citadel_rc[PATH_MAX] = ""; char ctdl_run_dir[PATH_MAX] = ""; @@ -44,35 +35,30 @@ char *axdefs[] = { "New User", "Problem User", "Local User", - "Network User", + "Normal User", "Preferred User", "Admin", "Admin" }; -void CtdlIPC_lock(CtdlIPC * ipc) -{ +void CtdlIPC_lock(CtdlIPC * ipc) { if (ipc->network_status_cb) ipc->network_status_cb(1); } -void CtdlIPC_unlock(CtdlIPC * ipc) -{ +void CtdlIPC_unlock(CtdlIPC * ipc) { if (ipc->network_status_cb) ipc->network_status_cb(0); } -char *libcitadelclient_version_string(void) -{ +char *libcitadelclient_version_string(void) { return "libcitadelclient(unnumbered)"; } - - #define COMPUTE_DIRECTORY(SUBDIR) memcpy(dirbuffer,SUBDIR, sizeof dirbuffer);\ snprintf(SUBDIR,sizeof SUBDIR, "%s%s%s%s%s%s%s", \ (home&!relh)?ctdl_home_directory:basedir, \ @@ -86,8 +72,7 @@ char *libcitadelclient_version_string(void) #define DBG_PRINT(A) if (dbg==1) fprintf (stderr,"%s : %s \n", #A, A) -void calc_dirs_n_files(int relh, int home, const char *relhome, char *ctdldir, int dbg) -{ +void calc_dirs_n_files(int relh, int home, const char *relhome, char *ctdldir, int dbg) { const char *basedir = ""; char dirbuffer[PATH_MAX] = ""; @@ -133,13 +118,11 @@ void calc_dirs_n_files(int relh, int home, const char *relhome, char *ctdldir, i DBG_PRINT(file_citadel_rc); } -void setCryptoStatusHook(void (*hook) (char *s)) -{ +void setCryptoStatusHook(void (*hook)(char *s)) { status_hook = hook; } -void CtdlIPC_SetNetworkStatusCallback(CtdlIPC * ipc, void (*hook) (int state)) -{ +void CtdlIPC_SetNetworkStatusCallback(CtdlIPC * ipc, void (*hook)(int state)) { ipc->network_status_cb = hook; } @@ -164,8 +147,7 @@ const char *svn_revision(void); /* * Does nothing. The server should always return 200. */ -int CtdlIPCNoop(CtdlIPC * ipc) -{ +int CtdlIPCNoop(CtdlIPC * ipc) { char aaa[128]; return CtdlIPCGenericCommand(ipc, "NOOP", NULL, 0, NULL, NULL, aaa); @@ -176,8 +158,7 @@ int CtdlIPCNoop(CtdlIPC * ipc) * Does nothing interesting. The server should always return 200 * along with your string. */ -int CtdlIPCEcho(CtdlIPC * ipc, const char *arg, char *cret) -{ +int CtdlIPCEcho(CtdlIPC * ipc, const char *arg, char *cret) { int ret; char *aaa; @@ -201,8 +182,7 @@ int CtdlIPCEcho(CtdlIPC * ipc, const char *arg, char *cret) * Asks the server to close the connecction. * Should always return 200. */ -int CtdlIPCQuit(CtdlIPC * ipc) -{ +int CtdlIPCQuit(CtdlIPC * ipc) { int ret = 221; /* Default to successful quit */ char aaa[SIZ]; @@ -229,8 +209,7 @@ int CtdlIPCQuit(CtdlIPC * ipc) * Asks the server to log out. Should always return 200, even if no user * was logged in. The user will not be logged in after this! */ -int CtdlIPCLogout(CtdlIPC * ipc) -{ +int CtdlIPCLogout(CtdlIPC * ipc) { int ret; char aaa[SIZ]; @@ -248,8 +227,7 @@ int CtdlIPCLogout(CtdlIPC * ipc) * username is able to log in, with the username correctly spelled in cret. * Returns various 500 error codes if the user doesn't exist, etc. */ -int CtdlIPCTryLogin(CtdlIPC * ipc, const char *username, char *cret) -{ +int CtdlIPCTryLogin(CtdlIPC * ipc, const char *username, char *cret) { int ret; char *aaa; @@ -273,8 +251,7 @@ int CtdlIPCTryLogin(CtdlIPC * ipc, const char *username, char *cret) * Second stage of authentication - provide password. The server returns * 200 and several arguments in cret relating to the user's account. */ -int CtdlIPCTryPassword(CtdlIPC * ipc, const char *passwd, char *cret) -{ +int CtdlIPCTryPassword(CtdlIPC * ipc, const char *passwd, char *cret) { int ret; char *aaa; @@ -294,31 +271,6 @@ int CtdlIPCTryPassword(CtdlIPC * ipc, const char *passwd, char *cret) } -/* - * Second stage of authentication - provide password. The server returns - * 200 and several arguments in cret relating to the user's account. - */ -int CtdlIPCTryApopPassword(CtdlIPC * ipc, const char *response, char *cret) -{ - int ret; - char *aaa; - - if (!response) - return -2; - if (!cret) - return -2; - - aaa = (char *) malloc((size_t) (strlen(response) + 6)); - if (!aaa) - return -1; - - sprintf(aaa, "PAS2 %s", response); - ret = CtdlIPCGenericCommand(ipc, aaa, NULL, 0, NULL, NULL, cret); - free(aaa); - return ret; -} - - /* * Create a new user. This returns 200 plus the same arguments as TryPassword * if selfservice is nonzero, unless there was a problem creating the account. @@ -326,8 +278,7 @@ int CtdlIPCTryApopPassword(CtdlIPC * ipc, const char *response, char *cret) * user - intended for use by system administrators to create accounts on * behalf of other users. */ -int CtdlIPCCreateUser(CtdlIPC * ipc, const char *username, int selfservice, char *cret) -{ +int CtdlIPCCreateUser(CtdlIPC * ipc, const char *username, int selfservice, char *cret) { int ret; char *aaa; @@ -350,8 +301,7 @@ int CtdlIPCCreateUser(CtdlIPC * ipc, const char *username, int selfservice, char /* * Changes the user's password. Returns 200 if changed, errors otherwise. */ -int CtdlIPCChangePassword(CtdlIPC * ipc, const char *passwd, char *cret) -{ +int CtdlIPCChangePassword(CtdlIPC * ipc, const char *passwd, char *cret) { int ret; char *aaa; @@ -372,11 +322,13 @@ int CtdlIPCChangePassword(CtdlIPC * ipc, const char *passwd, char *cret) /* LKRN */ + /* Caller must free the march list */ + /* Room types are defined in enum RoomList; keep these in sync! */ + /* floor is -1 for all, or floornum */ -int CtdlIPCKnownRooms(CtdlIPC * ipc, enum RoomList which, int floor, struct march **listing, char *cret) -{ +int CtdlIPCKnownRooms(CtdlIPC * ipc, enum RoomList which, int floor, struct march **listing, char *cret) { int ret; struct march *march = NULL; static char *proto[] = { "LKRA", "LKRN", "LKRO", "LZRM", "LRMS", "LPRM" }; @@ -435,9 +387,9 @@ int CtdlIPCKnownRooms(CtdlIPC * ipc, enum RoomList which, int floor, struct marc /* GETU */ + /* Caller must free the struct ctdluser; caller may pass an existing one */ -int CtdlIPCGetConfig(CtdlIPC * ipc, struct ctdluser **uret, char *cret) -{ +int CtdlIPCGetConfig(CtdlIPC * ipc, struct ctdluser **uret, char *cret) { int ret; if (!cret) @@ -458,8 +410,7 @@ int CtdlIPCGetConfig(CtdlIPC * ipc, struct ctdluser **uret, char *cret) /* SETU */ -int CtdlIPCSetConfig(CtdlIPC * ipc, struct ctdluser *uret, char *cret) -{ +int CtdlIPCSetConfig(CtdlIPC * ipc, struct ctdluser *uret, char *cret) { char aaa[48]; if (!uret) @@ -473,8 +424,7 @@ int CtdlIPCSetConfig(CtdlIPC * ipc, struct ctdluser *uret, char *cret) /* RENU */ -int CtdlIPCRenameUser(CtdlIPC * ipc, char *oldname, char *newname, char *cret) -{ +int CtdlIPCRenameUser(CtdlIPC * ipc, char *oldname, char *newname, char *cret) { int ret; char cmd[256]; @@ -492,8 +442,7 @@ int CtdlIPCRenameUser(CtdlIPC * ipc, char *oldname, char *newname, char *cret) /* GOTO */ -int CtdlIPCGotoRoom(CtdlIPC * ipc, const char *room, const char *passwd, struct ctdlipcroom **rret, char *cret) -{ +int CtdlIPCGotoRoom(CtdlIPC * ipc, const char *room, const char *passwd, struct ctdlipcroom **rret, char *cret) { int ret; char *aaa; @@ -513,7 +462,8 @@ int CtdlIPCGotoRoom(CtdlIPC * ipc, const char *room, const char *passwd, struct return -1; } sprintf(aaa, "GOTO %s|%s", room, passwd); - } else { + } + else { aaa = (char *) malloc(strlen(room) + 6); if (!aaa) { free(*rret); @@ -532,13 +482,14 @@ int CtdlIPCGotoRoom(CtdlIPC * ipc, const char *room, const char *passwd, struct rret[0]->RRlastread = extract_long(cret, 6); rret[0]->RRismailbox = extract_int(cret, 7); rret[0]->RRaide = extract_int(cret, 8); - rret[0]->RRnewmail = extract_long(cret, 9); + // position 9 is no longer used rret[0]->RRfloor = extract_int(cret, 10); rret[0]->RRcurrentview = extract_int(cret, 11); rret[0]->RRdefaultview = extract_int(cret, 12); - /* position 13 is a trash folder flag ... irrelevant in this client */ + // position 13 is a trash folder flag ... irrelevant in this client rret[0]->RRflags2 = extract_int(cret, 14); - } else { + } + else { free(*rret); *rret = NULL; } @@ -548,10 +499,11 @@ int CtdlIPCGotoRoom(CtdlIPC * ipc, const char *room, const char *passwd, struct /* MSGS */ + /* which is 0 = all, 1 = old, 2 = new, 3 = last, 4 = first, 5 = gt, 6 = lt */ + /* whicharg is number of messages, applies to last, first, gt, lt */ -int CtdlIPCGetMessages(CtdlIPC * ipc, enum MessageList which, int whicharg, const char *mtemplate, unsigned long **mret, char *cret) -{ +int CtdlIPCGetMessages(CtdlIPC * ipc, enum MessageList which, int whicharg, const char *mtemplate, unsigned long **mret, char *cret) { int ret; unsigned long count = 0; static char *proto[] = { "ALL", "OLD", "NEW", "LAST", "FIRST", "GT", "LT" }; @@ -588,7 +540,8 @@ int CtdlIPCGetMessages(CtdlIPC * ipc, enum MessageList which, int whicharg, cons if (*mret) { (*mret)[count++] = atol(aaa); (*mret)[count] = 0L; - } else { + } + else { break; } } @@ -599,8 +552,7 @@ int CtdlIPCGetMessages(CtdlIPC * ipc, enum MessageList which, int whicharg, cons /* MSG0, MSG2 */ -int CtdlIPCGetSingleMessage(CtdlIPC * ipc, long msgnum, int headers, int as_mime, struct ctdlipcmessage **mret, char *cret) -{ +int CtdlIPCGetSingleMessage(CtdlIPC * ipc, long msgnum, int headers, int as_mime, struct ctdlipcmessage **mret, char *cret) { int ret; char aaa[SIZ]; char *bbb = NULL; @@ -622,6 +574,7 @@ int CtdlIPCGetSingleMessage(CtdlIPC * ipc, long msgnum, int headers, int as_mime strcpy(encoding, ""); strcpy(mret[0]->content_type, ""); + mret[0]->is_local = 0; sprintf(aaa, "MSG%d %ld|%d", as_mime, msgnum, headers); ret = CtdlIPCGenericCommand(ipc, aaa, NULL, 0, &bbb, &bbb_len, cret); if (ret / 100 == 1) { @@ -634,23 +587,25 @@ int CtdlIPCGetSingleMessage(CtdlIPC * ipc, long msgnum, int headers, int as_mime if (!strncasecmp(aaa, "nhdr=yes", 8)) mret[0]->nhdr = 1; else if (!strncasecmp(aaa, "from=", 5)) - safestrncpy(mret[0]->author, &aaa[5], SIZ); + strncpy(mret[0]->author, &aaa[5], SIZ); else if (!strncasecmp(aaa, "type=", 5)) mret[0]->type = atoi(&aaa[5]); else if (!strncasecmp(aaa, "msgn=", 5)) - safestrncpy(mret[0]->msgid, &aaa[5], SIZ); + strncpy(mret[0]->msgid, &aaa[5], SIZ); else if (!strncasecmp(aaa, "subj=", 5)) - safestrncpy(mret[0]->subject, &aaa[5], SIZ); + strncpy(mret[0]->subject, &aaa[5], SIZ); else if (!strncasecmp(aaa, "rfca=", 5)) - safestrncpy(mret[0]->email, &aaa[5], SIZ); + strncpy(mret[0]->email, &aaa[5], SIZ); else if (!strncasecmp(aaa, "room=", 5)) - safestrncpy(mret[0]->room, &aaa[5], SIZ); + strncpy(mret[0]->room, &aaa[5], SIZ); else if (!strncasecmp(aaa, "rcpt=", 5)) - safestrncpy(mret[0]->recipient, &aaa[5], SIZ); + strncpy(mret[0]->recipient, &aaa[5], SIZ); else if (!strncasecmp(aaa, "wefw=", 5)) - safestrncpy(mret[0]->references, &aaa[5], SIZ); + strncpy(mret[0]->references, &aaa[5], SIZ); else if (!strncasecmp(aaa, "time=", 5)) mret[0]->time = atol(&aaa[5]); + else if (!strncasecmp(aaa, "locl", 4)) + mret[0]->is_local = 1; /* Multipart/alternative prefix & suffix strings help * us to determine which part we want to download. @@ -660,7 +615,8 @@ int CtdlIPCGetSingleMessage(CtdlIPC * ipc, long msgnum, int headers, int as_mime if (!strcasecmp(multipart_prefix, "multipart/alternative")) { ++multipart_hunting; } - } else if (!strncasecmp(aaa, "suff=", 5)) { + } + else if (!strncasecmp(aaa, "suff=", 5)) { extract_token(multipart_prefix, &aaa[5], 1, '|', sizeof multipart_prefix); if (!strcasecmp(multipart_prefix, "multipart/alternative")) { ++multipart_hunting; @@ -709,7 +665,7 @@ int CtdlIPCGetSingleMessage(CtdlIPC * ipc, long msgnum, int headers, int as_mime if (!strncasecmp(bbb, "Content-type:", 13)) { extract_token(mret[0]->content_type, bbb, 0, '\n', sizeof mret[0]->content_type); strcpy(mret[0]->content_type, &mret[0]->content_type[13]); - striplt(mret[0]->content_type); + string_trim(mret[0]->content_type); /* strip out ";charset=" portion. FIXME do something with * the charset (like... convert it) instead of just throwing @@ -723,12 +679,12 @@ int CtdlIPCGetSingleMessage(CtdlIPC * ipc, long msgnum, int headers, int as_mime if (!strncasecmp(bbb, "X-Citadel-MSG4-Partnum:", 23)) { extract_token(mret[0]->mime_chosen, bbb, 0, '\n', sizeof mret[0]->mime_chosen); strcpy(mret[0]->mime_chosen, &mret[0]->mime_chosen[23]); - striplt(mret[0]->mime_chosen); + string_trim(mret[0]->mime_chosen); } if (!strncasecmp(bbb, "Content-transfer-encoding:", 26)) { extract_token(encoding, bbb, 0, '\n', sizeof encoding); strcpy(encoding, &encoding[26]); - striplt(encoding); + string_trim(encoding); } remove_token(bbb, 0, '\n'); } while ((bbb[0] != 0) && (bbb[0] != '\n')); @@ -745,7 +701,8 @@ int CtdlIPCGetSingleMessage(CtdlIPC * ipc, long msgnum, int headers, int as_mime ccc = malloc(strlen(bbb) + 32768); if (!strcasecmp(encoding, "base64")) { bytes_decoded = CtdlDecodeBase64(ccc, bbb, strlen(bbb)); - } else if (!strcasecmp(encoding, "quoted-printable")) { + } + else if (!strcasecmp(encoding, "quoted-printable")) { bytes_decoded = CtdlDecodeQuotedPrintable(ccc, bbb, strlen(bbb)); } ccc[bytes_decoded] = 0; @@ -756,7 +713,8 @@ int CtdlIPCGetSingleMessage(CtdlIPC * ipc, long msgnum, int headers, int as_mime /* FIXME: Strip trailing whitespace */ bbb = (char *) realloc(bbb, (size_t) (strlen(bbb) + 1)); - } else { + } + else { bbb = (char *) realloc(bbb, 1); *bbb = '\0'; } @@ -767,8 +725,7 @@ int CtdlIPCGetSingleMessage(CtdlIPC * ipc, long msgnum, int headers, int as_mime /* WHOK */ -int CtdlIPCWhoKnowsRoom(CtdlIPC * ipc, char **listing, char *cret) -{ +int CtdlIPCWhoKnowsRoom(CtdlIPC * ipc, char **listing, char *cret) { int ret; size_t bytes; @@ -785,8 +742,7 @@ int CtdlIPCWhoKnowsRoom(CtdlIPC * ipc, char **listing, char *cret) /* INFO */ -int CtdlIPCServerInfo(CtdlIPC * ipc, char *cret) -{ +int CtdlIPCServerInfo(CtdlIPC * ipc, char *cret) { int ret; size_t bytes; char *listing = NULL; @@ -833,12 +789,6 @@ int CtdlIPCServerInfo(CtdlIPC * ipc, char *cret) case 10: ipc->ServInfo.ok_floors = atoi(buf); break; - case 11: - ipc->ServInfo.paging_level = atoi(buf); - break; - case 13: - ipc->ServInfo.supports_qnop = atoi(buf); - break; case 14: ipc->ServInfo.supports_ldap = atoi(buf); break; @@ -880,8 +830,7 @@ int CtdlIPCServerInfo(CtdlIPC * ipc, char *cret) /* RDIR */ -int CtdlIPCReadDirectory(CtdlIPC * ipc, char **listing, char *cret) -{ +int CtdlIPCReadDirectory(CtdlIPC * ipc, char **listing, char *cret) { int ret; size_t bytes; @@ -900,8 +849,7 @@ int CtdlIPCReadDirectory(CtdlIPC * ipc, char **listing, char *cret) /* * Set last-read pointer in this room to msgnum, or 0 for HIGHEST. */ -int CtdlIPCSetLastRead(CtdlIPC * ipc, long msgnum, char *cret) -{ +int CtdlIPCSetLastRead(CtdlIPC * ipc, long msgnum, char *cret) { int ret; char aaa[64]; @@ -910,7 +858,8 @@ int CtdlIPCSetLastRead(CtdlIPC * ipc, long msgnum, char *cret) if (msgnum) { sprintf(aaa, "SLRP %ld", msgnum); - } else { + } + else { sprintf(aaa, "SLRP HIGHEST"); } ret = CtdlIPCGenericCommand(ipc, aaa, NULL, 0, NULL, NULL, cret); @@ -919,8 +868,7 @@ int CtdlIPCSetLastRead(CtdlIPC * ipc, long msgnum, char *cret) /* INVT */ -int CtdlIPCInviteUserToRoom(CtdlIPC * ipc, const char *username, char *cret) -{ +int CtdlIPCInviteUserToRoom(CtdlIPC * ipc, const char *username, char *cret) { int ret; char *aaa; @@ -941,8 +889,7 @@ int CtdlIPCInviteUserToRoom(CtdlIPC * ipc, const char *username, char *cret) /* KICK */ -int CtdlIPCKickoutUserFromRoom(CtdlIPC * ipc, const char *username, char *cret) -{ +int CtdlIPCKickoutUserFromRoom(CtdlIPC * ipc, const char *username, char *cret) { int ret; char *aaa; @@ -961,8 +908,7 @@ int CtdlIPCKickoutUserFromRoom(CtdlIPC * ipc, const char *username, char *cret) /* GETR */ -int CtdlIPCGetRoomAttributes(CtdlIPC * ipc, struct ctdlroom **qret, char *cret) -{ +int CtdlIPCGetRoomAttributes(CtdlIPC * ipc, struct ctdlroom **qret, char *cret) { int ret; if (!cret) @@ -990,33 +936,31 @@ int CtdlIPCGetRoomAttributes(CtdlIPC * ipc, struct ctdlroom **qret, char *cret) /* SETR */ -/* set forget to kick all users out of room */ -int CtdlIPCSetRoomAttributes(CtdlIPC * ipc, int forget, struct ctdlroom *qret, char *cret) -{ +int CtdlIPCSetRoomAttributes(CtdlIPC * ipc, int forget, // if nonzero, kick all users out of the room + struct ctdlroom *qret, char *cret) { int ret; - char *aaa; + char *cmd; if (!cret) return -2; if (!qret) return -2; - aaa = (char *) malloc(strlen(qret->QRname) + strlen(qret->QRpasswd) + strlen(qret->QRdirname) + 64); - if (!aaa) + cmd = (char *) malloc(strlen(qret->QRname) + strlen(qret->QRpasswd) + strlen(qret->QRdirname) + 64); + if (!cmd) return -1; - sprintf(aaa, "SETR %s|%s|%s|%d|%d|%d|%d|%d|%d", + sprintf(cmd, "SETR %s|%s|%s|%d|%d|%d|%d|%d|%d", qret->QRname, qret->QRpasswd, qret->QRdirname, qret->QRflags, forget, qret->QRfloor, qret->QRorder, qret->QRdefaultview, qret->QRflags2); - ret = CtdlIPCGenericCommand(ipc, aaa, NULL, 0, NULL, NULL, cret); - free(aaa); + ret = CtdlIPCGenericCommand(ipc, cmd, NULL, 0, NULL, NULL, cret); + free(cmd); return ret; } /* GETA */ -int CtdlIPCGetRoomAide(CtdlIPC * ipc, char *cret) -{ +int CtdlIPCGetRoomAide(CtdlIPC * ipc, char *cret) { if (!cret) return -1; @@ -1025,8 +969,7 @@ int CtdlIPCGetRoomAide(CtdlIPC * ipc, char *cret) /* SETA */ -int CtdlIPCSetRoomAide(CtdlIPC * ipc, const char *username, char *cret) -{ +int CtdlIPCSetRoomAide(CtdlIPC * ipc, const char *username, char *cret) { int ret; char *aaa; @@ -1047,8 +990,7 @@ int CtdlIPCSetRoomAide(CtdlIPC * ipc, const char *username, char *cret) /* ENT0 */ -int CtdlIPCPostMessage(CtdlIPC * ipc, int flag, int *subject_required, struct ctdlipcmessage *mr, char *cret) -{ +int CtdlIPCPostMessage(CtdlIPC * ipc, int flag, int *subject_required, struct ctdlipcmessage *mr, char *cret) { int ret; char cmd[SIZ]; char *ptr; @@ -1082,8 +1024,7 @@ int CtdlIPCPostMessage(CtdlIPC * ipc, int flag, int *subject_required, struct ct /* RINF */ -int CtdlIPCRoomInfo(CtdlIPC * ipc, char **iret, char *cret) -{ +int CtdlIPCRoomInfo(CtdlIPC * ipc, char **iret, char *cret) { size_t bytes; if (!cret) @@ -1098,8 +1039,7 @@ int CtdlIPCRoomInfo(CtdlIPC * ipc, char **iret, char *cret) /* DELE */ -int CtdlIPCDeleteMessage(CtdlIPC * ipc, long msgnum, char *cret) -{ +int CtdlIPCDeleteMessage(CtdlIPC * ipc, long msgnum, char *cret) { char aaa[64]; if (!cret) @@ -1113,8 +1053,7 @@ int CtdlIPCDeleteMessage(CtdlIPC * ipc, long msgnum, char *cret) /* MOVE */ -int CtdlIPCMoveMessage(CtdlIPC * ipc, int copy, long msgnum, const char *destroom, char *cret) -{ +int CtdlIPCMoveMessage(CtdlIPC * ipc, int copy, long msgnum, const char *destroom, char *cret) { int ret; char *aaa; @@ -1137,8 +1076,7 @@ int CtdlIPCMoveMessage(CtdlIPC * ipc, int copy, long msgnum, const char *destroo /* KILL */ -int CtdlIPCDeleteRoom(CtdlIPC * ipc, int for_real, char *cret) -{ +int CtdlIPCDeleteRoom(CtdlIPC * ipc, int for_real, char *cret) { char aaa[64]; if (!cret) @@ -1150,8 +1088,7 @@ int CtdlIPCDeleteRoom(CtdlIPC * ipc, int for_real, char *cret) /* CRE8 */ -int CtdlIPCCreateRoom(CtdlIPC * ipc, int for_real, const char *roomname, int type, const char *password, int floor, char *cret) -{ +int CtdlIPCCreateRoom(CtdlIPC * ipc, int for_real, const char *roomname, int type, const char *password, int floor, char *cret) { int ret; char *aaa; @@ -1165,7 +1102,8 @@ int CtdlIPCCreateRoom(CtdlIPC * ipc, int for_real, const char *roomname, int typ if (!aaa) return -1; sprintf(aaa, "CRE8 %d|%s|%d|%s|%d", for_real, roomname, type, password, floor); - } else { + } + else { aaa = (char *) malloc(strlen(roomname) + 40); if (!aaa) return -1; @@ -1178,8 +1116,7 @@ int CtdlIPCCreateRoom(CtdlIPC * ipc, int for_real, const char *roomname, int typ /* FORG */ -int CtdlIPCForgetRoom(CtdlIPC * ipc, char *cret) -{ +int CtdlIPCForgetRoom(CtdlIPC * ipc, char *cret) { if (!cret) return -2; @@ -1188,8 +1125,7 @@ int CtdlIPCForgetRoom(CtdlIPC * ipc, char *cret) /* MESG */ -int CtdlIPCSystemMessage(CtdlIPC * ipc, const char *message, char **mret, char *cret) -{ +int CtdlIPCSystemMessage(CtdlIPC * ipc, const char *message, char **mret, char *cret) { int ret; char *aaa; size_t bytes; @@ -1215,8 +1151,7 @@ int CtdlIPCSystemMessage(CtdlIPC * ipc, const char *message, char **mret, char * /* GNUR */ -int CtdlIPCNextUnvalidatedUser(CtdlIPC * ipc, char *cret) -{ +int CtdlIPCNextUnvalidatedUser(CtdlIPC * ipc, char *cret) { if (!cret) return -2; @@ -1225,8 +1160,7 @@ int CtdlIPCNextUnvalidatedUser(CtdlIPC * ipc, char *cret) /* GREG */ -int CtdlIPCGetUserRegistration(CtdlIPC * ipc, const char *username, char **rret, char *cret) -{ +int CtdlIPCGetUserRegistration(CtdlIPC * ipc, const char *username, char **rret, char *cret) { int ret; char *aaa; size_t bytes; @@ -1256,8 +1190,7 @@ int CtdlIPCGetUserRegistration(CtdlIPC * ipc, const char *username, char **rret, /* VALI */ -int CtdlIPCValidateUser(CtdlIPC * ipc, const char *username, int axlevel, char *cret) -{ +int CtdlIPCValidateUser(CtdlIPC * ipc, const char *username, int axlevel, char *cret) { int ret; char *aaa; @@ -1280,8 +1213,7 @@ int CtdlIPCValidateUser(CtdlIPC * ipc, const char *username, int axlevel, char * /* EINF */ -int CtdlIPCSetRoomInfo(CtdlIPC * ipc, int for_real, const char *info, char *cret) -{ +int CtdlIPCSetRoomInfo(CtdlIPC * ipc, int for_real, const char *info, char *cret) { char aaa[64]; if (!cret) @@ -1295,8 +1227,7 @@ int CtdlIPCSetRoomInfo(CtdlIPC * ipc, int for_real, const char *info, char *cret /* LIST */ -int CtdlIPCUserListing(CtdlIPC * ipc, char *searchstring, char **listing, char *cret) -{ +int CtdlIPCUserListing(CtdlIPC * ipc, char *searchstring, char **listing, char *cret) { size_t bytes; char *cmd; int ret; @@ -1320,8 +1251,7 @@ int CtdlIPCUserListing(CtdlIPC * ipc, char *searchstring, char **listing, char * /* REGI */ -int CtdlIPCSetRegistration(CtdlIPC * ipc, const char *info, char *cret) -{ +int CtdlIPCSetRegistration(CtdlIPC * ipc, const char *info, char *cret) { if (!cret) return -1; if (!info) @@ -1332,8 +1262,7 @@ int CtdlIPCSetRegistration(CtdlIPC * ipc, const char *info, char *cret) /* CHEK */ -int CtdlIPCMiscCheck(CtdlIPC * ipc, struct ctdlipcmisc *chek, char *cret) -{ +int CtdlIPCMiscCheck(CtdlIPC * ipc, struct ctdlipcmisc *chek, char *cret) { int ret; if (!cret) @@ -1352,8 +1281,7 @@ int CtdlIPCMiscCheck(CtdlIPC * ipc, struct ctdlipcmisc *chek, char *cret) /* DELF */ -int CtdlIPCDeleteFile(CtdlIPC * ipc, const char *filename, char *cret) -{ +int CtdlIPCDeleteFile(CtdlIPC * ipc, const char *filename, char *cret) { int ret; char *aaa; @@ -1374,8 +1302,7 @@ int CtdlIPCDeleteFile(CtdlIPC * ipc, const char *filename, char *cret) /* MOVF */ -int CtdlIPCMoveFile(CtdlIPC * ipc, const char *filename, const char *destroom, char *cret) -{ +int CtdlIPCMoveFile(CtdlIPC * ipc, const char *filename, const char *destroom, char *cret) { int ret; char *aaa; @@ -1398,8 +1325,7 @@ int CtdlIPCMoveFile(CtdlIPC * ipc, const char *filename, const char *destroom, c /* RWHO */ -int CtdlIPCOnlineUsers(CtdlIPC * ipc, char **listing, time_t * stamp, char *cret) -{ +int CtdlIPCOnlineUsers(CtdlIPC * ipc, char **listing, time_t * stamp, char *cret) { int ret; size_t bytes; @@ -1420,8 +1346,7 @@ int CtdlIPCOnlineUsers(CtdlIPC * ipc, char **listing, time_t * stamp, char *cret /* OPEN */ int CtdlIPCFileDownload(CtdlIPC * ipc, const char *filename, void **buf, size_t resume, void (*progress_gauge_callback) - (CtdlIPC *, unsigned long, unsigned long), char *cret) -{ + (CtdlIPC *, unsigned long, unsigned long), char *cret) { int ret; size_t bytes; time_t last_mod; @@ -1451,13 +1376,7 @@ int CtdlIPCFileDownload(CtdlIPC * ipc, const char *filename, void **buf, size_t bytes = extract_long(cret, 0); last_mod = extract_int(cret, 1); extract_token(mimetype, cret, 2, '|', sizeof mimetype); - ret = CtdlIPCReadDownload(ipc, buf, bytes, resume, progress_gauge_callback, cret); - /* - ret = CtdlIPCHighSpeedReadDownload(ipc, buf, bytes, resume, - progress_gauge_callback, cret); - */ - ret = CtdlIPCEndDownload(ipc, cret); if (ret / 100 == 2) sprintf(cret, "%d|%ld|%s|%s", (int) bytes, last_mod, filename, mimetype); @@ -1468,8 +1387,7 @@ int CtdlIPCFileDownload(CtdlIPC * ipc, const char *filename, void **buf, size_t /* OPNA */ int CtdlIPCAttachmentDownload(CtdlIPC * ipc, long msgnum, const char *part, void **buf, void (*progress_gauge_callback) - (CtdlIPC *, unsigned long, unsigned long), char *cret) -{ + (CtdlIPC *, unsigned long, unsigned long), char *cret) { int ret; size_t bytes; time_t last_mod; @@ -1510,8 +1428,7 @@ int CtdlIPCAttachmentDownload(CtdlIPC * ipc, long msgnum, const char *part, void /* OIMG */ int CtdlIPCImageDownload(CtdlIPC * ipc, const char *filename, void **buf, void (*progress_gauge_callback) - (CtdlIPC *, unsigned long, unsigned long), char *cret) -{ + (CtdlIPC *, unsigned long, unsigned long), char *cret) { int ret; size_t bytes; time_t last_mod; @@ -1541,6 +1458,7 @@ int CtdlIPCImageDownload(CtdlIPC * ipc, const char *filename, void **buf, void ( bytes = extract_long(cret, 0); last_mod = extract_int(cret, 1); extract_token(mimetype, cret, 2, '|', sizeof mimetype); + /* ret = CtdlIPCReadDownload(ipc, buf, bytes, 0, progress_gauge_callback, cret); */ ret = CtdlIPCHighSpeedReadDownload(ipc, buf, bytes, 0, progress_gauge_callback, cret); ret = CtdlIPCEndDownload(ipc, cret); @@ -1553,8 +1471,7 @@ int CtdlIPCImageDownload(CtdlIPC * ipc, const char *filename, void **buf, void ( /* UOPN */ int CtdlIPCFileUpload(CtdlIPC * ipc, const char *save_as, const char *comment, const char *path, void (*progress_gauge_callback) - (CtdlIPC *, unsigned long, unsigned long), char *cret) -{ + (CtdlIPC *, unsigned long, unsigned long), char *cret) { int ret; char *aaa; FILE *uploadFP; @@ -1604,8 +1521,7 @@ int CtdlIPCFileUpload(CtdlIPC * ipc, const char *save_as, const char *comment, c /* UIMG */ int CtdlIPCImageUpload(CtdlIPC * ipc, int for_real, const char *path, const char *save_as, void (*progress_gauge_callback) - (CtdlIPC *, unsigned long, unsigned long), char *cret) -{ + (CtdlIPC *, unsigned long, unsigned long), char *cret) { int ret; FILE *uploadFP; char *aaa; @@ -1652,8 +1568,7 @@ int CtdlIPCImageUpload(CtdlIPC * ipc, int for_real, const char *path, const char /* QUSR */ -int CtdlIPCQueryUsername(CtdlIPC * ipc, const char *username, char *cret) -{ +int CtdlIPCQueryUsername(CtdlIPC * ipc, const char *username, char *cret) { int ret; char *aaa; @@ -1674,8 +1589,7 @@ int CtdlIPCQueryUsername(CtdlIPC * ipc, const char *username, char *cret) /* LFLR */ -int CtdlIPCFloorListing(CtdlIPC * ipc, char **listing, char *cret) -{ +int CtdlIPCFloorListing(CtdlIPC * ipc, char **listing, char *cret) { size_t bytes; if (!cret) @@ -1690,8 +1604,7 @@ int CtdlIPCFloorListing(CtdlIPC * ipc, char **listing, char *cret) /* CFLR */ -int CtdlIPCCreateFloor(CtdlIPC * ipc, int for_real, const char *name, char *cret) -{ +int CtdlIPCCreateFloor(CtdlIPC * ipc, int for_real, const char *name, char *cret) { int ret; char aaa[SIZ]; @@ -1707,8 +1620,7 @@ int CtdlIPCCreateFloor(CtdlIPC * ipc, int for_real, const char *name, char *cret /* KFLR */ -int CtdlIPCDeleteFloor(CtdlIPC * ipc, int for_real, int floornum, char *cret) -{ +int CtdlIPCDeleteFloor(CtdlIPC * ipc, int for_real, int floornum, char *cret) { char aaa[SIZ]; if (!cret) @@ -1722,8 +1634,7 @@ int CtdlIPCDeleteFloor(CtdlIPC * ipc, int for_real, int floornum, char *cret) /* EFLR */ -int CtdlIPCEditFloor(CtdlIPC * ipc, int floornum, const char *floorname, char *cret) -{ +int CtdlIPCEditFloor(CtdlIPC * ipc, int floornum, const char *floorname, char *cret) { int ret; char aaa[SIZ]; @@ -1747,8 +1658,7 @@ int CtdlIPCEditFloor(CtdlIPC * ipc, int floornum, const char *floorname, char *c * other fields are not set properly. */ int CtdlIPCIdentifySoftware(CtdlIPC * ipc, int developerid, int clientid, - int revision, const char *software_name, const char *hostname, char *cret) -{ + int revision, const char *software_name, const char *hostname, char *cret) { int ret; char *aaa; @@ -1756,7 +1666,7 @@ int CtdlIPCIdentifySoftware(CtdlIPC * ipc, int developerid, int clientid, developerid = 8; clientid = 0; revision = CLIENT_VERSION - 600; - software_name = "Citadel (libcitadel)"; + software_name = "Citadel text client"; } if (!hostname) return -2; @@ -1773,8 +1683,7 @@ int CtdlIPCIdentifySoftware(CtdlIPC * ipc, int developerid, int clientid, /* SEXP */ -int CtdlIPCSendInstantMessage(CtdlIPC * ipc, const char *username, const char *text, char *cret) -{ +int CtdlIPCSendInstantMessage(CtdlIPC * ipc, const char *username, const char *text, char *cret) { int ret; char *aaa; @@ -1790,7 +1699,8 @@ int CtdlIPCSendInstantMessage(CtdlIPC * ipc, const char *username, const char *t if (text) { sprintf(aaa, "SEXP %s|-", username); ret = CtdlIPCGenericCommand(ipc, aaa, text, strlen(text), NULL, NULL, cret); - } else { + } + else { sprintf(aaa, "SEXP %s||", username); ret = CtdlIPCGenericCommand(ipc, aaa, NULL, 0, NULL, NULL, cret); } @@ -1800,8 +1710,7 @@ int CtdlIPCSendInstantMessage(CtdlIPC * ipc, const char *username, const char *t /* GEXP */ -int CtdlIPCGetInstantMessage(CtdlIPC * ipc, char **listing, char *cret) -{ +int CtdlIPCGetInstantMessage(CtdlIPC * ipc, char **listing, char *cret) { size_t bytes; if (!cret) @@ -1816,9 +1725,9 @@ int CtdlIPCGetInstantMessage(CtdlIPC * ipc, char **listing, char *cret) /* DEXP */ + /* mode is 0 = enable, 1 = disable, 2 = status */ -int CtdlIPCEnableInstantMessageReceipt(CtdlIPC * ipc, int mode, char *cret) -{ +int CtdlIPCEnableInstantMessageReceipt(CtdlIPC * ipc, int mode, char *cret) { char aaa[64]; if (!cret) @@ -1830,8 +1739,7 @@ int CtdlIPCEnableInstantMessageReceipt(CtdlIPC * ipc, int mode, char *cret) /* EBIO */ -int CtdlIPCSetBio(CtdlIPC * ipc, char *bio, char *cret) -{ +int CtdlIPCSetBio(CtdlIPC * ipc, char *bio, char *cret) { if (!cret) return -2; if (!bio) @@ -1842,8 +1750,7 @@ int CtdlIPCSetBio(CtdlIPC * ipc, char *bio, char *cret) /* RBIO */ -int CtdlIPCGetBio(CtdlIPC * ipc, const char *username, char **listing, char *cret) -{ +int CtdlIPCGetBio(CtdlIPC * ipc, const char *username, char **listing, char *cret) { int ret; size_t bytes; char *aaa; @@ -1869,8 +1776,7 @@ int CtdlIPCGetBio(CtdlIPC * ipc, const char *username, char **listing, char *cre /* LBIO */ -int CtdlIPCListUsersWithBios(CtdlIPC * ipc, char **listing, char *cret) -{ +int CtdlIPCListUsersWithBios(CtdlIPC * ipc, char **listing, char *cret) { size_t bytes; if (!cret) @@ -1885,8 +1791,7 @@ int CtdlIPCListUsersWithBios(CtdlIPC * ipc, char **listing, char *cret) /* STEL */ -int CtdlIPCStealthMode(CtdlIPC * ipc, int mode, char *cret) -{ +int CtdlIPCStealthMode(CtdlIPC * ipc, int mode, char *cret) { char aaa[64]; if (!cret) @@ -1898,8 +1803,7 @@ int CtdlIPCStealthMode(CtdlIPC * ipc, int mode, char *cret) /* TERM */ -int CtdlIPCTerminateSession(CtdlIPC * ipc, int sid, char *cret) -{ +int CtdlIPCTerminateSession(CtdlIPC * ipc, int sid, char *cret) { char aaa[64]; if (!cret) @@ -1911,8 +1815,7 @@ int CtdlIPCTerminateSession(CtdlIPC * ipc, int sid, char *cret) /* DOWN */ -int CtdlIPCTerminateServerNow(CtdlIPC * ipc, char *cret) -{ +int CtdlIPCTerminateServerNow(CtdlIPC * ipc, char *cret) { if (!cret) return -1; @@ -1921,8 +1824,7 @@ int CtdlIPCTerminateServerNow(CtdlIPC * ipc, char *cret) /* SCDN */ -int CtdlIPCTerminateServerScheduled(CtdlIPC * ipc, int mode, char *cret) -{ +int CtdlIPCTerminateServerScheduled(CtdlIPC * ipc, int mode, char *cret) { char aaa[16]; if (!cret) @@ -1934,8 +1836,7 @@ int CtdlIPCTerminateServerScheduled(CtdlIPC * ipc, int mode, char *cret) /* EMSG */ -int CtdlIPCEnterSystemMessage(CtdlIPC * ipc, const char *filename, const char *text, char *cret) -{ +int CtdlIPCEnterSystemMessage(CtdlIPC * ipc, const char *filename, const char *text, char *cret) { int ret; char *aaa; @@ -1958,16 +1859,17 @@ int CtdlIPCEnterSystemMessage(CtdlIPC * ipc, const char *filename, const char *t /* TIME */ + /* This function returns the actual server time reported, or 0 if error */ -time_t CtdlIPCServerTime(CtdlIPC * ipc, char *cret) -{ +time_t CtdlIPCServerTime(CtdlIPC * ipc, char *cret) { time_t tret; int ret; ret = CtdlIPCGenericCommand(ipc, "TIME", NULL, 0, NULL, NULL, cret); if (ret / 100 == 2) { tret = extract_long(cret, 0); - } else { + } + else { tret = 0L; } return tret; @@ -1975,8 +1877,7 @@ time_t CtdlIPCServerTime(CtdlIPC * ipc, char *cret) /* AGUP */ -int CtdlIPCAideGetUserParameters(CtdlIPC * ipc, const char *who, struct ctdluser **uret, char *cret) -{ +int CtdlIPCAideGetUserParameters(CtdlIPC * ipc, const char *who, struct ctdluser **uret, char *cret) { int ret; char aaa[SIZ]; @@ -1996,8 +1897,6 @@ int CtdlIPCAideGetUserParameters(CtdlIPC * ipc, const char *who, struct ctdluser extract_token(uret[0]->fullname, cret, 0, '|', sizeof uret[0]->fullname); extract_token(uret[0]->password, cret, 1, '|', sizeof uret[0]->password); uret[0]->flags = extract_int(cret, 2); - uret[0]->timescalled = extract_long(cret, 3); - uret[0]->posted = extract_long(cret, 4); uret[0]->axlevel = extract_int(cret, 5); uret[0]->usernum = extract_long(cret, 6); uret[0]->lastcall = extract_long(cret, 7); @@ -2008,8 +1907,7 @@ int CtdlIPCAideGetUserParameters(CtdlIPC * ipc, const char *who, struct ctdluser /* ASUP */ -int CtdlIPCAideSetUserParameters(CtdlIPC * ipc, const struct ctdluser *uret, char *cret) -{ +int CtdlIPCAideSetUserParameters(CtdlIPC * ipc, const struct ctdluser *uret, char *cret) { int ret; char *aaa; @@ -2022,9 +1920,8 @@ int CtdlIPCAideSetUserParameters(CtdlIPC * ipc, const struct ctdluser *uret, cha if (!aaa) return -1; - sprintf(aaa, "ASUP %s|%s|%d|%ld|%ld|%d|%ld|%ld|%d", - uret->fullname, uret->password, uret->flags, uret->timescalled, - uret->posted, uret->axlevel, uret->usernum, uret->lastcall, uret->USuserpurge); + sprintf(aaa, "ASUP %s|%s|%d|0|0|%d|%ld|%ld|%d", + uret->fullname, uret->password, uret->flags, uret->axlevel, uret->usernum, uret->lastcall, uret->USuserpurge); ret = CtdlIPCGenericCommand(ipc, aaa, NULL, 0, NULL, NULL, cret); free(aaa); return ret; @@ -2032,8 +1929,7 @@ int CtdlIPCAideSetUserParameters(CtdlIPC * ipc, const struct ctdluser *uret, cha /* AGEA */ -int CtdlIPCAideGetEmailAddresses(CtdlIPC * ipc, const char *who, char *target_buf, char *cret) -{ +int CtdlIPCAideGetEmailAddresses(CtdlIPC * ipc, const char *who, char *target_buf, char *cret) { int ret; char aaa[SIZ]; char *emailaddrs = NULL; @@ -2055,8 +1951,7 @@ int CtdlIPCAideGetEmailAddresses(CtdlIPC * ipc, const char *who, char *target_bu /* ASEA */ -int CtdlIPCAideSetEmailAddresses(CtdlIPC * ipc, const char *who, char *emailaddrs, char *cret) -{ +int CtdlIPCAideSetEmailAddresses(CtdlIPC * ipc, const char *who, char *emailaddrs, char *cret) { char aaa[SIZ]; int ret; @@ -2074,10 +1969,11 @@ int CtdlIPCAideSetEmailAddresses(CtdlIPC * ipc, const char *who, char *emailaddr /* GPEX */ + /* which is 0 = room, 1 = floor, 2 = site, 3 = default for mailboxes */ + /* caller must free the struct ExpirePolicy */ -int CtdlIPCGetMessageExpirationPolicy(CtdlIPC * ipc, GPEXWhichPolicy which, struct ExpirePolicy **policy, char *cret) -{ +int CtdlIPCGetMessageExpirationPolicy(CtdlIPC * ipc, GPEXWhichPolicy which, struct ExpirePolicy **policy, char *cret) { static char *proto[] = { strof(roompolicy), strof(floorpolicy), @@ -2109,10 +2005,11 @@ int CtdlIPCGetMessageExpirationPolicy(CtdlIPC * ipc, GPEXWhichPolicy which, stru /* SPEX */ + /* which is 0 = room, 1 = floor, 2 = site, 3 = default for mailboxes */ + /* policy is 0 = inherit, 1 = no purge, 2 = by count, 3 = by age (days) */ -int CtdlIPCSetMessageExpirationPolicy(CtdlIPC * ipc, int which, struct ExpirePolicy *policy, char *cret) -{ +int CtdlIPCSetMessageExpirationPolicy(CtdlIPC * ipc, int which, struct ExpirePolicy *policy, char *cret) { char aaa[38]; char *whichvals[] = { "room", "floor", "site", "mailboxes" }; @@ -2133,8 +2030,7 @@ int CtdlIPCSetMessageExpirationPolicy(CtdlIPC * ipc, int which, struct ExpirePol /* CONF GET */ -int CtdlIPCGetSystemConfig(CtdlIPC * ipc, char **listing, char *cret) -{ +int CtdlIPCGetSystemConfig(CtdlIPC * ipc, char **listing, char *cret) { size_t bytes; if (!cret) @@ -2149,8 +2045,7 @@ int CtdlIPCGetSystemConfig(CtdlIPC * ipc, char **listing, char *cret) /* CONF SET */ -int CtdlIPCSetSystemConfig(CtdlIPC * ipc, const char *listing, char *cret) -{ +int CtdlIPCSetSystemConfig(CtdlIPC * ipc, const char *listing, char *cret) { if (!cret) return -2; if (!listing) @@ -2161,8 +2056,7 @@ int CtdlIPCSetSystemConfig(CtdlIPC * ipc, const char *listing, char *cret) /* CONF GETSYS */ -int CtdlIPCGetSystemConfigByType(CtdlIPC * ipc, const char *mimetype, char **listing, char *cret) -{ +int CtdlIPCGetSystemConfigByType(CtdlIPC * ipc, const char *mimetype, char **listing, char *cret) { int ret; char *aaa; size_t bytes; @@ -2187,8 +2081,7 @@ int CtdlIPCGetSystemConfigByType(CtdlIPC * ipc, const char *mimetype, char **lis /* CONF PUTSYS */ -int CtdlIPCSetSystemConfigByType(CtdlIPC * ipc, const char *mimetype, const char *listing, char *cret) -{ +int CtdlIPCSetSystemConfigByType(CtdlIPC * ipc, const char *mimetype, const char *listing, char *cret) { int ret; char *aaa; @@ -2210,8 +2103,7 @@ int CtdlIPCSetSystemConfigByType(CtdlIPC * ipc, const char *mimetype, const char /* GNET */ -int CtdlIPCGetRoomNetworkConfig(CtdlIPC * ipc, char **listing, char *cret) -{ +int CtdlIPCGetRoomNetworkConfig(CtdlIPC * ipc, char **listing, char *cret) { size_t bytes; if (!cret) @@ -2226,8 +2118,7 @@ int CtdlIPCGetRoomNetworkConfig(CtdlIPC * ipc, char **listing, char *cret) /* SNET */ -int CtdlIPCSetRoomNetworkConfig(CtdlIPC * ipc, const char *listing, char *cret) -{ +int CtdlIPCSetRoomNetworkConfig(CtdlIPC * ipc, const char *listing, char *cret) { if (!cret) return -2; if (!listing) @@ -2238,8 +2129,7 @@ int CtdlIPCSetRoomNetworkConfig(CtdlIPC * ipc, const char *listing, char *cret) /* REQT */ -int CtdlIPCRequestClientLogout(CtdlIPC * ipc, int session, char *cret) -{ +int CtdlIPCRequestClientLogout(CtdlIPC * ipc, int session, char *cret) { char aaa[64]; if (!cret) @@ -2253,8 +2143,7 @@ int CtdlIPCRequestClientLogout(CtdlIPC * ipc, int session, char *cret) /* SEEN */ -int CtdlIPCSetMessageSeen(CtdlIPC * ipc, long msgnum, int seen, char *cret) -{ +int CtdlIPCSetMessageSeen(CtdlIPC * ipc, long msgnum, int seen, char *cret) { char aaa[27]; if (!cret) @@ -2268,8 +2157,7 @@ int CtdlIPCSetMessageSeen(CtdlIPC * ipc, long msgnum, int seen, char *cret) /* STLS */ -int CtdlIPCStartEncryption(CtdlIPC * ipc, char *cret) -{ +int CtdlIPCStartEncryption(CtdlIPC * ipc, char *cret) { int a; int r; char buf[SIZ]; @@ -2325,8 +2213,7 @@ int CtdlIPCStartEncryption(CtdlIPC * ipc, char *cret) #ifdef HAVE_OPENSSL -static void endtls(SSL * ssl) -{ +static void endtls(SSL * ssl) { if (ssl) { SSL_shutdown(ssl); SSL_free(ssl); @@ -2336,8 +2223,7 @@ static void endtls(SSL * ssl) /* QDIR */ -int CtdlIPCDirectoryLookup(CtdlIPC * ipc, const char *address, char *cret) -{ +int CtdlIPCDirectoryLookup(CtdlIPC * ipc, const char *address, char *cret) { int ret; char *aaa; @@ -2358,8 +2244,7 @@ int CtdlIPCDirectoryLookup(CtdlIPC * ipc, const char *address, char *cret) /* IPGM */ -int CtdlIPCInternalProgram(CtdlIPC * ipc, int secret, char *cret) -{ +int CtdlIPCInternalProgram(CtdlIPC * ipc, int secret, char *cret) { char aaa[30]; if (!cret) @@ -2372,13 +2257,14 @@ int CtdlIPCInternalProgram(CtdlIPC * ipc, int secret, char *cret) /* ************************************************************************** */ + /* Stuff below this line is not for public consumption */ + /* ************************************************************************** */ /* Read a listing from the server up to 000. Append to dest if it exists */ -char *CtdlIPCReadListing(CtdlIPC * ipc, char *dest) -{ +char *CtdlIPCReadListing(CtdlIPC * ipc, char *dest) { size_t length = 0; size_t linelength; char *ret = NULL; @@ -2387,7 +2273,8 @@ char *CtdlIPCReadListing(CtdlIPC * ipc, char *dest) ret = dest; if (ret != NULL) { length = strlen(ret); - } else { + } + else { length = 0; } @@ -2406,8 +2293,7 @@ char *CtdlIPCReadListing(CtdlIPC * ipc, char *dest) /* Send a listing to the server; generate the ending 000. */ -int CtdlIPCSendListing(CtdlIPC * ipc, const char *listing) -{ +int CtdlIPCSendListing(CtdlIPC * ipc, const char *listing) { char *text; text = (char *) malloc(strlen(listing) + 6); @@ -2419,7 +2305,8 @@ int CtdlIPCSendListing(CtdlIPC * ipc, const char *listing) CtdlIPC_putline(ipc, text); free(text); text = NULL; - } else { + } + else { /* Malloc failed but we are committed to send */ /* This may result in extra blanks at the bottom */ CtdlIPC_putline(ipc, text); @@ -2430,8 +2317,7 @@ int CtdlIPCSendListing(CtdlIPC * ipc, const char *listing) /* Partial read of file from server */ -size_t CtdlIPCPartialRead(CtdlIPC * ipc, void **buf, size_t offset, size_t bytes, char *cret) -{ +size_t CtdlIPCPartialRead(CtdlIPC * ipc, void **buf, size_t offset, size_t bytes, char *cret) { size_t len = 0; char aaa[SIZ]; @@ -2454,7 +2340,8 @@ size_t CtdlIPCPartialRead(CtdlIPC * ipc, void **buf, size_t offset, size_t bytes if (*buf) { /* I know what I'm doing */ serv_read(ipc, ((char *) (*buf) + offset), len); - } else { + } + else { /* We have to read regardless */ serv_read(ipc, aaa, len); len = 0; @@ -2466,8 +2353,7 @@ size_t CtdlIPCPartialRead(CtdlIPC * ipc, void **buf, size_t offset, size_t bytes /* CLOS */ -int CtdlIPCEndDownload(CtdlIPC * ipc, char *cret) -{ +int CtdlIPCEndDownload(CtdlIPC * ipc, char *cret) { int ret; if (!cret) @@ -2483,8 +2369,7 @@ int CtdlIPCEndDownload(CtdlIPC * ipc, char *cret) /* MSGP */ -int CtdlIPCSpecifyPreferredFormats(CtdlIPC * ipc, char *cret, char *formats) -{ +int CtdlIPCSpecifyPreferredFormats(CtdlIPC * ipc, char *cret, char *formats) { int ret; char cmd[SIZ]; @@ -2497,8 +2382,7 @@ int CtdlIPCSpecifyPreferredFormats(CtdlIPC * ipc, char *cret, char *formats) /* READ */ int CtdlIPCReadDownload(CtdlIPC * ipc, void **buf, size_t bytes, size_t resume, void (*progress_gauge_callback) - (CtdlIPC *, unsigned long, unsigned long), char *cret) -{ + (CtdlIPC *, unsigned long, unsigned long), char *cret) { size_t len; if (!cret) @@ -2530,8 +2414,7 @@ int CtdlIPCReadDownload(CtdlIPC * ipc, void **buf, size_t bytes, size_t resume, /* READ - pipelined */ int CtdlIPCHighSpeedReadDownload(CtdlIPC * ipc, void **buf, size_t bytes, size_t resume, void (*progress_gauge_callback) - (CtdlIPC *, unsigned long, unsigned long), char *cret) -{ + (CtdlIPC *, unsigned long, unsigned long), char *cret) { size_t len; int calls; /* How many calls in the pipeline */ int i; /* iterator */ @@ -2585,8 +2468,7 @@ int CtdlIPCHighSpeedReadDownload(CtdlIPC * ipc, void **buf, size_t bytes, size_t /* UCLS */ -int CtdlIPCEndUpload(CtdlIPC * ipc, int discard, char *cret) -{ +int CtdlIPCEndUpload(CtdlIPC * ipc, int discard, char *cret) { int ret; char cmd[8]; @@ -2604,8 +2486,7 @@ int CtdlIPCEndUpload(CtdlIPC * ipc, int discard, char *cret) /* WRIT */ int CtdlIPCWriteUpload(CtdlIPC * ipc, FILE * uploadFP, void (*progress_gauge_callback) - (CtdlIPC *, unsigned long, unsigned long), char *cret) -{ + (CtdlIPC *, unsigned long, unsigned long), char *cret) { int ret = -1; size_t offset = 0; size_t bytes; @@ -2648,7 +2529,8 @@ int CtdlIPCWriteUpload(CtdlIPC * ipc, FILE * uploadFP, void (*progress_gauge_cal /* Detect short reads and back up if needed */ /* offset will never be negative anyway */ fseek(fd, (signed) offset, SEEK_SET); - } else { + } + else { break; } } @@ -2683,21 +2565,24 @@ int CtdlIPCWriteUpload(CtdlIPC * ipc, FILE * uploadFP, void (*progress_gauge_cal * -1 if an internal error occurred, -2 if caller provided bad values, * or 0 - the protocol response number if bad values were found during * the protocol exchange. + * * It stores the protocol response string (minus the number) in * protocol_response as described above. Some commands send additional * data in this string. */ int CtdlIPCGenericCommand(CtdlIPC * ipc, - const char *command, const char *to_send, - size_t bytes_to_send, char **to_receive, size_t * bytes_to_receive, char *proto_response) -{ + const char *command, + const char *to_send, + size_t bytes_to_send, char **to_receive, size_t *bytes_to_receive, char *proto_response) { char buf[SIZ]; int ret; - if (!command) + if (!command) { return -2; - if (!proto_response) + } + if (!proto_response) { return -2; + } CtdlIPC_lock(ipc); CtdlIPC_putline(ipc, command); @@ -2717,7 +2602,8 @@ int CtdlIPCGenericCommand(CtdlIPC * ipc, case 1: /* LISTING_FOLLOWS */ if (to_receive && !*to_receive && bytes_to_receive) { *to_receive = CtdlIPCReadListing(ipc, NULL); - } else { /* Drain */ + } + else { /* Drain */ while (CtdlIPC_getline(ipc, buf), strcmp(buf, "000")); ret = -ret; } @@ -2725,7 +2611,8 @@ int CtdlIPCGenericCommand(CtdlIPC * ipc, case 4: /* SEND_LISTING */ if (to_send) { CtdlIPCSendListing(ipc, to_send); - } else { + } + else { /* No listing given, fake it */ CtdlIPC_putline(ipc, "000"); ret = -ret; @@ -2735,13 +2622,15 @@ int CtdlIPCGenericCommand(CtdlIPC * ipc, if (to_receive && !*to_receive && bytes_to_receive) { *bytes_to_receive = extract_long(proto_response, 0); *to_receive = (char *) - malloc((size_t) * bytes_to_receive); + malloc((size_t) *bytes_to_receive); if (!*to_receive) { ret = -1; - } else { + } + else { serv_read(ipc, *to_receive, *bytes_to_receive); } - } else { + } + else { /* Drain */ size_t drain; @@ -2757,7 +2646,8 @@ int CtdlIPCGenericCommand(CtdlIPC * ipc, case 7: /* SEND_BINARY */ if (to_send && bytes_to_send) { serv_write(ipc, to_send, bytes_to_send); - } else if (bytes_to_send) { + } + else if (bytes_to_send) { /* Fake it, send nulls */ size_t fake; @@ -2771,23 +2661,26 @@ int CtdlIPCGenericCommand(CtdlIPC * ipc, ret = -ret; } /* else who knows? DANGER WILL ROBINSON */ break; - case 8: /* START_CHAT_MODE */ + case 8: /* SEND_THEN_RECV */ if (!strncasecmp(command, "CHAT", 4)) { /* Don't call chatmode with generic! */ CtdlIPC_putline(ipc, "/quit"); ret = -ret; - } else { + } + else { /* In this mode we send then receive listing */ if (to_send) { CtdlIPCSendListing(ipc, to_send); - } else { + } + else { /* No listing given, fake it */ CtdlIPC_putline(ipc, "000"); ret = -ret; } if (to_receive && !*to_receive && bytes_to_receive) { *to_receive = CtdlIPCReadListing(ipc, NULL); - } else { /* Drain */ + } + else { /* Drain */ while (CtdlIPC_getline(ipc, buf), strcmp(buf, "000")); ret = -ret; } @@ -2809,8 +2702,7 @@ int CtdlIPCGenericCommand(CtdlIPC * ipc, /* * Connect to a Citadel on a remote host using a TCP/IP socket */ -static int tcp_connectsock(char *host, char *service) -{ +static int tcp_connectsock(char *host, char *service) { struct in6_addr serveraddr; struct addrinfo hints; struct addrinfo *res = NULL; @@ -2837,7 +2729,8 @@ static int tcp_connectsock(char *host, char *service) if (rc == 1) { /* dotted quad */ hints.ai_family = AF_INET; hints.ai_flags |= AI_NUMERICHOST; - } else { + } + else { rc = inet_pton(AF_INET6, host, &serveraddr); if (rc == 1) { /* IPv6 address */ hints.ai_family = AF_INET6; @@ -2863,29 +2756,25 @@ static int tcp_connectsock(char *host, char *service) rc = connect(sock, ai->ai_addr, ai->ai_addrlen); if (rc >= 0) { return (sock); /* Connected! */ - } else { + } + else { close(sock); /* Failed. Close the socket to avoid fd leak! */ } } - return (-1); } - - - /* * Connect to a Citadel on the local host using a unix domain socket */ -static int uds_connectsock(int *isLocal, char *sockpath) -{ +static int uds_connectsock(int *isLocal, char *sockpath) { struct sockaddr_un addr; int s; memset(&addr, 0, sizeof(addr)); addr.sun_family = AF_UNIX; - safestrncpy(addr.sun_path, sockpath, sizeof addr.sun_path); + strncpy(addr.sun_path, sockpath, sizeof addr.sun_path); s = socket(AF_UNIX, SOCK_STREAM, 0); if (s < 0) { @@ -2905,8 +2794,7 @@ static int uds_connectsock(int *isLocal, char *sockpath) /* * input binary data from socket */ -static void serv_read(CtdlIPC * ipc, char *buf, unsigned int bytes) -{ +static void serv_read(CtdlIPC * ipc, char *buf, unsigned int bytes) { unsigned int len, rlen; #if defined(HAVE_OPENSSL) @@ -2930,8 +2818,7 @@ static void serv_read(CtdlIPC * ipc, char *buf, unsigned int bytes) /* * send binary to server */ -void serv_write(CtdlIPC * ipc, const char *buf, unsigned int nbytes) -{ +void serv_write(CtdlIPC * ipc, const char *buf, unsigned int nbytes) { unsigned int bytes_written = 0; int retval; @@ -2953,11 +2840,11 @@ void serv_write(CtdlIPC * ipc, const char *buf, unsigned int nbytes) #ifdef HAVE_OPENSSL + /* * input binary data from encrypted connection */ -static void serv_read_ssl(CtdlIPC * ipc, char *buf, unsigned int bytes) -{ +static void serv_read_ssl(CtdlIPC * ipc, char *buf, unsigned int bytes) { int len, rlen; char junk[1]; @@ -2978,17 +2865,6 @@ static void serv_read_ssl(CtdlIPC * ipc, char *buf, unsigned int bytes) sleep(1); continue; } -/*** - Not sure why we'd want to handle these error codes any differently, - but this definitely isn't the way to handle them. Someone must have - naively assumed that we could fall back to unencrypted communications, - but all it does is just recursively blow the stack. - if (errval == SSL_ERROR_ZERO_RETURN || - errval == SSL_ERROR_SSL) { - serv_read(ipc, &buf[len], bytes - len); - return; - } - ***/ error_printf("SSL_read in serv_read: %s\n", ERR_reason_error_string(ERR_peek_error())); connection_died(ipc, 1); return; @@ -3001,8 +2877,7 @@ static void serv_read_ssl(CtdlIPC * ipc, char *buf, unsigned int bytes) /* * send binary to server encrypted */ -static void serv_write_ssl(CtdlIPC * ipc, const char *buf, unsigned int nbytes) -{ +static void serv_write_ssl(CtdlIPC * ipc, const char *buf, unsigned int nbytes) { unsigned int bytes_written = 0; int retval; char junk[1]; @@ -3036,10 +2911,7 @@ static void serv_write_ssl(CtdlIPC * ipc, const char *buf, unsigned int nbytes) } - - -static void CtdlIPC_init_OpenSSL(void) -{ +static void CtdlIPC_init_OpenSSL(void) { int a; const SSL_METHOD *ssl_method; DH *dh; @@ -3090,8 +2962,7 @@ static void CtdlIPC_init_OpenSSL(void) #endif /* HAVE_OPENSSL */ -int ReadNetworkChunk(CtdlIPC * ipc) -{ +int ReadNetworkChunk(CtdlIPC * ipc) { fd_set read_fd; int ret = 0; int err = 0; @@ -3116,41 +2987,29 @@ int ReadNetworkChunk(CtdlIPC * ipc) ipc->BufPtr[n] = '\0'; ipc->BufUsed += n; return n; - } else + } + else { return n; - } else if (ret < 0) { + } + } + else if (ret < 0) { if (!(errno == EINTR || errno == EAGAIN)) error_printf("\nselect failed: %d %s\n", err, strerror(err)); return -1; - } /* - else { - tries ++; - if (tries >= 10) - n = read(ipc->sock, ipc->BufPtr, ipc->BufSize - (ipc->BufPtr - ipc->Buf) - 1); - if (n > 0) { - ipc->BufPtr[n]='\0'; - ipc->BufUsed += n; - return n; - } - else { - connection_died(ipc, 0); - return -1; - } - } */ + } } } + /* * input string from socket - implemented in terms of serv_read() */ #ifdef CHUNKED_READ -static void CtdlIPC_getline(CtdlIPC * ipc, char *buf) -{ +static void CtdlIPC_getline(CtdlIPC * ipc, char *buf) { int i, ntries; char *aptr, *bptr, *aeptr, *beptr; -// error_printf("---\n"); beptr = buf + SIZ; #if defined(HAVE_OPENSSL) @@ -3173,7 +3032,8 @@ static void CtdlIPC_getline(CtdlIPC * ipc, char *buf) buf[i--] = 0; if (i >= 0 && buf[i] == 13) buf[i--] = 0; - } else + } + else #endif { if (ipc->Buf == NULL) { @@ -3184,13 +3044,10 @@ static void CtdlIPC_getline(CtdlIPC * ipc, char *buf) } ntries = 0; -// while ((ipc->BufUsed == 0)||(ntries++ > 10)) if (ipc->BufUsed == 0) ReadNetworkChunk(ipc); -//// if (ipc->BufUsed != 0) while (1) bptr = buf; - while (1) { aptr = ipc->BufPtr; aeptr = ipc->Buf + ipc->BufSize; @@ -3203,21 +3060,21 @@ static void CtdlIPC_getline(CtdlIPC * ipc, char *buf) while ((aptr < aeptr) && (*(aptr + 1) == '\0')) aptr++; *(bptr++) = '\0'; -// fprintf(stderr, "parsing %d %d %d - %d %d %d %s\n", ipc->BufPtr - ipc->Buf, aptr - ipc->BufPtr, ipc->BufUsed , *aptr, *(aptr-1), *(aptr+1), buf); if ((bptr > buf + 1) && (*(bptr - 1) == '\r')) *(--bptr) = '\0'; /* is there more in the buffer we need to read later? */ if (ipc->Buf + ipc->BufUsed > aptr) { ipc->BufPtr = aptr; - } else { + } + else { ipc->BufUsed = 0; ipc->BufPtr = ipc->Buf; } -// error_printf("----bla6\n"); return; - } /* should we move our read stuf to the bufferstart so we have more space at the end? */ + } + // should we move our read stuf to the bufferstart so we have more space at the end? else if ((ipc->BufPtr != ipc->Buf) && (ipc->BufUsed > (ipc->BufSize - (ipc->BufSize / 4)))) { size_t NewBufSize = ipc->BufSize * 2; int delta = (ipc->BufPtr - ipc->Buf); @@ -3232,19 +3089,15 @@ static void CtdlIPC_getline(CtdlIPC * ipc, char *buf) ipc->BufSize = NewBufSize; } if (ReadNetworkChunk(ipc) < 0) { -// error_printf("----bla\n"); return; } } -/// error_printf("----bl45761%s\nipc->BufUsed"); } -// error_printf("----bla1\n"); } #else /* CHUNKED_READ */ -static void CtdlIPC_getline(CtdlIPC * ipc, char *buf) -{ +static void CtdlIPC_getline(CtdlIPC * ipc, char *buf) { int i; /* Read one character at a time. */ @@ -3270,16 +3123,14 @@ static void CtdlIPC_getline(CtdlIPC * ipc, char *buf) #endif /* CHUNKED_READ */ -void CtdlIPC_chat_recv(CtdlIPC * ipc, char *buf) -{ +void CtdlIPC_chat_recv(CtdlIPC * ipc, char *buf) { CtdlIPC_getline(ipc, buf); } /* * send line to server - implemented in terms of serv_write() */ -static void CtdlIPC_putline(CtdlIPC * ipc, const char *buf) -{ +static void CtdlIPC_putline(CtdlIPC * ipc, const char *buf) { char *cmd = NULL; int len; @@ -3289,7 +3140,8 @@ static void CtdlIPC_putline(CtdlIPC * ipc, const char *buf) /* This requires no extra memory */ serv_write(ipc, buf, len); serv_write(ipc, "\n", 1); - } else { + } + else { /* This is network-optimized */ strncpy(cmd, buf, len); strcpy(cmd + len, "\n"); @@ -3300,8 +3152,8 @@ static void CtdlIPC_putline(CtdlIPC * ipc, const char *buf) ipc->last_command_sent = time(NULL); } -void CtdlIPC_chat_send(CtdlIPC * ipc, const char *buf) -{ + +void CtdlIPC_chat_send(CtdlIPC * ipc, const char *buf) { CtdlIPC_putline(ipc, buf); } @@ -3309,8 +3161,7 @@ void CtdlIPC_chat_send(CtdlIPC * ipc, const char *buf) /* * attach to server */ -CtdlIPC *CtdlIPC_new(int argc, char **argv, char *hostbuf, char *portbuf) -{ +CtdlIPC *CtdlIPC_new(int argc, char **argv, char *hostbuf, char *portbuf) { int a; char cithost[SIZ]; char citport[SIZ]; @@ -3350,11 +3201,14 @@ CtdlIPC *CtdlIPC_new(int argc, char **argv, char *hostbuf, char *portbuf) for (a = 0; a < argc; ++a) { if (a == 0) { /* do nothing */ - } else if (a == 1) { + } + else if (a == 1) { strcpy(cithost, argv[a]); - } else if (a == 2) { + } + else if (a == 2) { strcpy(citport, argv[a]); - } else { + } + else { error_printf("%s: usage: ", argv[0]); error_printf("%s [host] [port] ", argv[0]); free(ipc); @@ -3371,7 +3225,8 @@ CtdlIPC *CtdlIPC_new(int argc, char **argv, char *hostbuf, char *portbuf) if (!strcmp(cithost, UDS)) { if (!strcasecmp(citport, DEFAULT_PORT)) { snprintf(sockpath, sizeof sockpath, "%s", file_citadel_socket); - } else { + } + else { snprintf(sockpath, sizeof sockpath, "%s/%s", citport, "citadel.socket"); } printf("[%s]\n", sockpath); @@ -3422,8 +3277,7 @@ CtdlIPC *CtdlIPC_new(int argc, char **argv, char *hostbuf, char *portbuf) /* * Disconnect and delete the IPC class (destructor) */ -void CtdlIPC_delete(CtdlIPC * ipc) -{ +void CtdlIPC_delete(CtdlIPC * ipc) { #ifdef HAVE_OPENSSL if (ipc->ssl) { SSL_shutdown(ipc->ssl); @@ -3447,38 +3301,7 @@ void CtdlIPC_delete(CtdlIPC * ipc) * Disconnect and delete the IPC class (destructor) * Also NULLs out the pointer */ -void CtdlIPC_delete_ptr(CtdlIPC ** pipc) -{ +void CtdlIPC_delete_ptr(CtdlIPC ** pipc) { CtdlIPC_delete(*pipc); *pipc = NULL; } - - -/* - * return the file descriptor of the server socket so we can select() on it. - * - * FIXME: This is only used in chat mode; eliminate it when chat mode gets - * rewritten... - */ -int CtdlIPC_getsockfd(CtdlIPC * ipc) -{ - return ipc->sock; -} - - -/* - * return one character - * - * FIXME: This is only used in chat mode; eliminate it when chat mode gets - * rewritten... - */ -char CtdlIPC_get(CtdlIPC * ipc) -{ - char buf[2]; - char ch; - - serv_read(ipc, buf, 1); - ch = (int) buf[0]; - - return (ch); -}