Back to index

citadel  8.12
Defines | Functions | Variables
citadel_ipc.c File Reference
#include "sysdep.h"
#include <time.h>
#include <unistd.h>
#include <stdio.h>
#include <sys/types.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include <netdb.h>
#include <sys/un.h>
#include <errno.h>
#include <libcitadel.h>
#include "citadel.h"
#include "citadel_ipc.h"
#include "citadel_decls.h"
#include "citadel_dirs.h"

Go to the source code of this file.

Defines

#define INADDR_NONE   0xffffffff

Functions

void setCryptoStatusHook (void(*hook)(char *s))
void CtdlIPC_SetNetworkStatusCallback (CtdlIPC *ipc, void(*hook)(int state))
static void serv_read (CtdlIPC *ipc, char *buf, unsigned int bytes)
static void serv_write (CtdlIPC *ipc, const char *buf, unsigned int nbytes)
static void CtdlIPC_getline (CtdlIPC *ipc, char *buf)
static void CtdlIPC_putline (CtdlIPC *ipc, const char *buf)
const char * svn_revision (void)
int CtdlIPCNoop (CtdlIPC *ipc)
int CtdlIPCEcho (CtdlIPC *ipc, const char *arg, char *cret)
int CtdlIPCQuit (CtdlIPC *ipc)
int CtdlIPCLogout (CtdlIPC *ipc)
int CtdlIPCTryLogin (CtdlIPC *ipc, const char *username, char *cret)
int CtdlIPCTryPassword (CtdlIPC *ipc, const char *passwd, char *cret)
int CtdlIPCTryApopPassword (CtdlIPC *ipc, const char *response, char *cret)
int CtdlIPCCreateUser (CtdlIPC *ipc, const char *username, int selfservice, char *cret)
int CtdlIPCChangePassword (CtdlIPC *ipc, const char *passwd, char *cret)
int CtdlIPCKnownRooms (CtdlIPC *ipc, enum RoomList which, int floor, struct march **listing, char *cret)
int CtdlIPCGetConfig (CtdlIPC *ipc, struct ctdluser **uret, char *cret)
int CtdlIPCSetConfig (CtdlIPC *ipc, struct ctdluser *uret, char *cret)
int CtdlIPCRenameUser (CtdlIPC *ipc, char *oldname, char *newname, char *cret)
int CtdlIPCGotoRoom (CtdlIPC *ipc, const char *room, const char *passwd, struct ctdlipcroom **rret, char *cret)
int CtdlIPCGetMessages (CtdlIPC *ipc, enum MessageList which, int whicharg, const char *mtemplate, unsigned long **mret, char *cret)
int CtdlIPCGetSingleMessage (CtdlIPC *ipc, long msgnum, int headers, int as_mime, struct ctdlipcmessage **mret, char *cret)
int CtdlIPCWhoKnowsRoom (CtdlIPC *ipc, char **listing, char *cret)
int CtdlIPCServerInfo (CtdlIPC *ipc, char *cret)
int CtdlIPCReadDirectory (CtdlIPC *ipc, char **listing, char *cret)
int CtdlIPCSetLastRead (CtdlIPC *ipc, long msgnum, char *cret)
int CtdlIPCInviteUserToRoom (CtdlIPC *ipc, const char *username, char *cret)
int CtdlIPCKickoutUserFromRoom (CtdlIPC *ipc, const char *username, char *cret)
int CtdlIPCGetRoomAttributes (CtdlIPC *ipc, struct ctdlroom **qret, char *cret)
int CtdlIPCSetRoomAttributes (CtdlIPC *ipc, int forget, struct ctdlroom *qret, char *cret)
int CtdlIPCGetRoomAide (CtdlIPC *ipc, char *cret)
int CtdlIPCSetRoomAide (CtdlIPC *ipc, const char *username, char *cret)
int CtdlIPCPostMessage (CtdlIPC *ipc, int flag, int *subject_required, struct ctdlipcmessage *mr, char *cret)
int CtdlIPCRoomInfo (CtdlIPC *ipc, char **iret, char *cret)
int CtdlIPCDeleteMessage (CtdlIPC *ipc, long msgnum, char *cret)
int CtdlIPCMoveMessage (CtdlIPC *ipc, int copy, long msgnum, const char *destroom, char *cret)
int CtdlIPCDeleteRoom (CtdlIPC *ipc, int for_real, char *cret)
int CtdlIPCCreateRoom (CtdlIPC *ipc, int for_real, const char *roomname, int type, const char *password, int floor, char *cret)
int CtdlIPCForgetRoom (CtdlIPC *ipc, char *cret)
int CtdlIPCSystemMessage (CtdlIPC *ipc, const char *message, char **mret, char *cret)
int CtdlIPCNextUnvalidatedUser (CtdlIPC *ipc, char *cret)
int CtdlIPCGetUserRegistration (CtdlIPC *ipc, const char *username, char **rret, char *cret)
int CtdlIPCValidateUser (CtdlIPC *ipc, const char *username, int axlevel, char *cret)
int CtdlIPCSetRoomInfo (CtdlIPC *ipc, int for_real, const char *info, char *cret)
int CtdlIPCUserListing (CtdlIPC *ipc, char *searchstring, char **listing, char *cret)
int CtdlIPCSetRegistration (CtdlIPC *ipc, const char *info, char *cret)
int CtdlIPCMiscCheck (CtdlIPC *ipc, struct ctdlipcmisc *chek, char *cret)
int CtdlIPCDeleteFile (CtdlIPC *ipc, const char *filename, char *cret)
int CtdlIPCMoveFile (CtdlIPC *ipc, const char *filename, const char *destroom, char *cret)
int CtdlIPCOnlineUsers (CtdlIPC *ipc, char **listing, time_t *stamp, char *cret)
int CtdlIPCFileDownload (CtdlIPC *ipc, const char *filename, void **buf, size_t resume, void(*progress_gauge_callback)(CtdlIPC *, unsigned long, unsigned long), char *cret)
int CtdlIPCAttachmentDownload (CtdlIPC *ipc, long msgnum, const char *part, void **buf, void(*progress_gauge_callback)(CtdlIPC *, unsigned long, unsigned long), char *cret)
int CtdlIPCImageDownload (CtdlIPC *ipc, const char *filename, void **buf, void(*progress_gauge_callback)(CtdlIPC *, unsigned long, unsigned long), char *cret)
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)
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)
int CtdlIPCQueryUsername (CtdlIPC *ipc, const char *username, char *cret)
int CtdlIPCFloorListing (CtdlIPC *ipc, char **listing, char *cret)
int CtdlIPCCreateFloor (CtdlIPC *ipc, int for_real, const char *name, char *cret)
int CtdlIPCDeleteFloor (CtdlIPC *ipc, int for_real, int floornum, char *cret)
int CtdlIPCEditFloor (CtdlIPC *ipc, int floornum, const char *floorname, char *cret)
int CtdlIPCIdentifySoftware (CtdlIPC *ipc, int developerid, int clientid, int revision, const char *software_name, const char *hostname, char *cret)
int CtdlIPCSendInstantMessage (CtdlIPC *ipc, const char *username, const char *text, char *cret)
int CtdlIPCGetInstantMessage (CtdlIPC *ipc, char **listing, char *cret)
int CtdlIPCEnableInstantMessageReceipt (CtdlIPC *ipc, int mode, char *cret)
int CtdlIPCSetBio (CtdlIPC *ipc, char *bio, char *cret)
int CtdlIPCGetBio (CtdlIPC *ipc, const char *username, char **listing, char *cret)
int CtdlIPCListUsersWithBios (CtdlIPC *ipc, char **listing, char *cret)
int CtdlIPCStealthMode (CtdlIPC *ipc, int mode, char *cret)
int CtdlIPCTerminateSession (CtdlIPC *ipc, int sid, char *cret)
int CtdlIPCTerminateServerNow (CtdlIPC *ipc, char *cret)
int CtdlIPCTerminateServerScheduled (CtdlIPC *ipc, int mode, char *cret)
int CtdlIPCEnterSystemMessage (CtdlIPC *ipc, const char *filename, const char *text, char *cret)
int CtdlIPCChangeHostname (CtdlIPC *ipc, const char *hostname, char *cret)
int CtdlIPCChangeRoomname (CtdlIPC *ipc, const char *roomname, char *cret)
int CtdlIPCChangeUsername (CtdlIPC *ipc, const char *username, char *cret)
time_t CtdlIPCServerTime (CtdlIPC *ipc, char *cret)
int CtdlIPCAideGetUserParameters (CtdlIPC *ipc, const char *who, struct ctdluser **uret, char *cret)
int CtdlIPCAideSetUserParameters (CtdlIPC *ipc, const struct ctdluser *uret, char *cret)
int CtdlIPCGetMessageExpirationPolicy (CtdlIPC *ipc, GPEXWhichPolicy which, struct ExpirePolicy **policy, char *cret)
int CtdlIPCSetMessageExpirationPolicy (CtdlIPC *ipc, int which, struct ExpirePolicy *policy, char *cret)
int CtdlIPCGetSystemConfig (CtdlIPC *ipc, char **listing, char *cret)
int CtdlIPCSetSystemConfig (CtdlIPC *ipc, const char *listing, char *cret)
int CtdlIPCGetSystemConfigByType (CtdlIPC *ipc, const char *mimetype, char **listing, char *cret)
int CtdlIPCSetSystemConfigByType (CtdlIPC *ipc, const char *mimetype, const char *listing, char *cret)
int CtdlIPCGetRoomNetworkConfig (CtdlIPC *ipc, char **listing, char *cret)
int CtdlIPCSetRoomNetworkConfig (CtdlIPC *ipc, const char *listing, char *cret)
int CtdlIPCRequestClientLogout (CtdlIPC *ipc, int session, char *cret)
int CtdlIPCSetMessageSeen (CtdlIPC *ipc, long msgnum, int seen, char *cret)
int CtdlIPCStartEncryption (CtdlIPC *ipc, char *cret)
int CtdlIPCDirectoryLookup (CtdlIPC *ipc, const char *address, char *cret)
int CtdlIPCInternalProgram (CtdlIPC *ipc, int secret, char *cret)
char * CtdlIPCReadListing (CtdlIPC *ipc, char *dest)
int CtdlIPCSendListing (CtdlIPC *ipc, const char *listing)
size_t CtdlIPCPartialRead (CtdlIPC *ipc, void **buf, size_t offset, size_t bytes, char *cret)
int CtdlIPCEndDownload (CtdlIPC *ipc, char *cret)
int CtdlIPCSpecifyPreferredFormats (CtdlIPC *ipc, char *cret, char *formats)
int CtdlIPCReadDownload (CtdlIPC *ipc, void **buf, size_t bytes, size_t resume, void(*progress_gauge_callback)(CtdlIPC *, unsigned long, unsigned long), char *cret)
int CtdlIPCHighSpeedReadDownload (CtdlIPC *ipc, void **buf, size_t bytes, size_t resume, void(*progress_gauge_callback)(CtdlIPC *, unsigned long, unsigned long), char *cret)
int CtdlIPCEndUpload (CtdlIPC *ipc, int discard, char *cret)
int CtdlIPCWriteUpload (CtdlIPC *ipc, FILE *uploadFP, void(*progress_gauge_callback)(CtdlIPC *, unsigned long, unsigned long), char *cret)
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)
static int tcp_connectsock (char *host, char *service)
static int uds_connectsock (int *isLocal, char *sockpath)
int ReadNetworkChunk (CtdlIPC *ipc)
void CtdlIPC_chat_recv (CtdlIPC *ipc, char *buf)
void CtdlIPC_chat_send (CtdlIPC *ipc, const char *buf)
CtdlIPCCtdlIPC_new (int argc, char **argv, char *hostbuf, char *portbuf)
void CtdlIPC_delete (CtdlIPC *ipc)
void CtdlIPC_delete_ptr (CtdlIPC **pipc)
int CtdlIPC_getsockfd (CtdlIPC *ipc)
char CtdlIPC_get (CtdlIPC *ipc)

Variables

static void(* status_hook )(char *s) = NULL
char instant_msgs = 0

Define Documentation

#define INADDR_NONE   0xffffffff

Definition at line 62 of file citadel_ipc.c.


Function Documentation

void CtdlIPC_chat_recv ( CtdlIPC ipc,
char *  buf 
)

Definition at line 3129 of file citadel_ipc.c.

{
       CtdlIPC_getline(ipc, buf);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void CtdlIPC_chat_send ( CtdlIPC ipc,
const char *  buf 
)

Definition at line 3159 of file citadel_ipc.c.

{
       CtdlIPC_putline(ipc, buf);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void CtdlIPC_delete ( CtdlIPC ipc)

Definition at line 3282 of file citadel_ipc.c.

{
#ifdef HAVE_OPENSSL
       if (ipc->ssl) {
              SSL_shutdown(ipc->ssl);
              SSL_free(ipc->ssl);
              ipc->ssl = NULL;
       }
#endif
       if (ipc->sock > -1) {
              shutdown(ipc->sock, 2);     /* Close it up */
              ipc->sock = -1;
       }
       if (ipc->Buf != NULL)
              free (ipc->Buf);
       ipc->Buf = NULL;
       ipc->BufPtr = NULL;
       ifree(ipc);
}

Here is the caller graph for this function:

void CtdlIPC_delete_ptr ( CtdlIPC **  pipc)

Definition at line 3307 of file citadel_ipc.c.

{
       CtdlIPC_delete(*pipc);
       *pipc = NULL;
}

Here is the call graph for this function:

Here is the caller graph for this function:

char CtdlIPC_get ( CtdlIPC ipc)

Definition at line 3332 of file citadel_ipc.c.

{
       char buf[2];
       char ch;

       serv_read(ipc, buf, 1);
       ch = (int) buf[0];

       return (ch);
}

Here is the call graph for this function:

static void CtdlIPC_getline ( CtdlIPC ipc,
char *  buf 
) [static]

Definition at line 3104 of file citadel_ipc.c.

{
       int i;

       /* Read one character at a time. */
       for (i = 0;; i++) {
              serv_read(ipc, &buf[i], 1);
              if (buf[i] == '\n' || i == (SIZ-1))
                     break;
       }

       /* If we got a long line, discard characters until the newline. */
       if (i == (SIZ-1))
              while (buf[i] != '\n')
                     serv_read(ipc, &buf[i], 1);

       /* Strip the trailing newline (and carriage return, if present) */
       if (i>=0 && buf[i] == 10) buf[i--] = 0;
       if (i>=0 && buf[i] == 13) buf[i--] = 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int CtdlIPC_getsockfd ( CtdlIPC ipc)

Definition at line 3320 of file citadel_ipc.c.

{
       return ipc->sock;
}
CtdlIPC* CtdlIPC_new ( int  argc,
char **  argv,
char *  hostbuf,
char *  portbuf 
)

Definition at line 3168 of file citadel_ipc.c.

{
       int a;
       char cithost[SIZ];
       char citport[SIZ];
       char sockpath[SIZ];
       CtdlIPC* ipc;

       ipc = ialloc(CtdlIPC);
       if (!ipc) {
              return 0;
       }
#if defined(HAVE_OPENSSL)
       ipc->ssl = NULL;
       CtdlIPC_init_OpenSSL();
#endif
#if defined(HAVE_PTHREAD_H)
       pthread_mutex_init(&(ipc->mutex), NULL); /* Default fast mutex */
#endif
       ipc->sock = -1;                    /* Not connected */
       ipc->isLocal = 0;           /* Not local, of course! */
       ipc->downloading = 0;
       ipc->uploading = 0;
       ipc->last_command_sent = 0L;
       ipc->network_status_cb = NULL;
       ipc->Buf = NULL;
       ipc->BufUsed = 0;
       ipc->BufPtr = NULL;

       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 */
              } else if (a == 1) {
                     strcpy(cithost, argv[a]);
              } else if (a == 2) {
                     strcpy(citport, argv[a]);
              } else {
                     error_printf("%s: usage: ",argv[0]);
                     error_printf("%s [host] [port] ",argv[0]);
                     ifree(ipc);
                     errno = EINVAL;
                     return 0;
              }
       }

       if ((!strcmp(cithost, "localhost"))
          || (!strcmp(cithost, "127.0.0.1"))) {
              ipc->isLocal = 1;
       }

       /* If we're using a unix domain socket we can do a bunch of stuff */
       if (!strcmp(cithost, UDS)) {
              if (!strcasecmp(citport, DEFAULT_PORT)) {
                     snprintf(sockpath, sizeof sockpath, "%s", file_citadel_socket);
              }
              else {
                     snprintf(sockpath, sizeof sockpath, "%s/%s", citport, "citadel.socket");
              }
              ipc->sock = uds_connectsock(&(ipc->isLocal), sockpath);
              if (ipc->sock == -1) {
                     ifree(ipc);
                     return 0;
              }
              if (hostbuf != NULL) strcpy(hostbuf, cithost);
              if (portbuf != NULL) strcpy(portbuf, sockpath);
              strcpy(ipc->ip_hostname, "");
              strcpy(ipc->ip_address, "");
              return ipc;
       }

       ipc->sock = tcp_connectsock(cithost, citport);
       if (ipc->sock == -1) {
              ifree(ipc);
              return 0;
       }


       /* Learn the actual network identity of the host to which we are connected */

       struct sockaddr_in6 clientaddr;
       unsigned int addrlen = sizeof(clientaddr);

       ipc->ip_hostname[0] = 0;
       ipc->ip_address[0] = 0;

       getpeername(ipc->sock, (struct sockaddr *)&clientaddr, &addrlen);
       getnameinfo((struct sockaddr *)&clientaddr, addrlen,
              ipc->ip_hostname, sizeof ipc->ip_hostname, NULL, 0, 0
       );
       getnameinfo((struct sockaddr *)&clientaddr, addrlen,
              ipc->ip_address, sizeof ipc->ip_address, NULL, 0, NI_NUMERICHOST
       );

       /* stuff other things elsewhere */

       if (hostbuf != NULL) strcpy(hostbuf, cithost);
       if (portbuf != NULL) strcpy(portbuf, citport);
       return ipc;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void CtdlIPC_putline ( CtdlIPC ipc,
const char *  buf 
) [static]

Definition at line 3137 of file citadel_ipc.c.

{
       char *cmd = NULL;
       int len;

       len = strlen(buf);
       cmd = malloc(len + 2);
       if (!cmd) {
              /* This requires no extra memory */
              serv_write(ipc, buf, len);
              serv_write(ipc, "\n", 1);
       } else {
              /* This is network-optimized */
              strncpy(cmd, buf, len);
              strcpy(cmd + len, "\n");
              serv_write(ipc, cmd, len + 1);
              free(cmd);
       }

       ipc->last_command_sent = time(NULL);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void CtdlIPC_SetNetworkStatusCallback ( CtdlIPC ipc,
void(*)(int state)  hook 
)

Definition at line 71 of file citadel_ipc.c.

                                                                             {
       ipc->network_status_cb = hook;
}

Here is the caller graph for this function:

int CtdlIPCAideGetUserParameters ( CtdlIPC ipc,
const char *  who,
struct ctdluser **  uret,
char *  cret 
)

Definition at line 1803 of file citadel_ipc.c.

{
       register int ret;
       char aaa[SIZ];

       if (!cret) return -2;
       if (!uret) return -2;
       if (!*uret) *uret = (struct ctdluser *)calloc(1, sizeof(struct ctdluser));
       if (!*uret) return -1;

       sprintf(aaa, "AGUP %s", who);
       ret = CtdlIPCGenericCommand(ipc, aaa, NULL, 0, NULL, NULL, cret);

       if (ret / 100 == 2) {
              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);
              uret[0]->USuserpurge = extract_int(cret, 8);
       }
       return ret;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int CtdlIPCAideSetUserParameters ( CtdlIPC ipc,
const struct ctdluser uret,
char *  cret 
)

Definition at line 1833 of file citadel_ipc.c.

{
       register int ret;
       char *aaa;

       if (!cret) return -2;
       if (!uret) return -2;

       aaa = (char *)malloc(strlen(uret->fullname) + strlen(uret->password) + 84);
       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);
       ret = CtdlIPCGenericCommand(ipc, aaa, NULL, 0, NULL, NULL, cret);
       free(aaa);
       return ret;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int CtdlIPCAttachmentDownload ( CtdlIPC ipc,
long  msgnum,
const char *  part,
void **  buf,
void(*)(CtdlIPC *, unsigned long, unsigned long)  progress_gauge_callback,
char *  cret 
)

Definition at line 1285 of file citadel_ipc.c.

{
       register int ret;
       size_t bytes;
       time_t last_mod;
       char filename[SIZ];
       char mimetype[SIZ];
       char aaa[SIZ];

       if (!cret) return -2;
       if (!buf) return -2;
       if (*buf) return -2;
       if (!part) return -2;
       if (!msgnum) return -2;
       if (ipc->downloading) return -2;

       sprintf(aaa, "OPNA %ld|%s", msgnum, part);
       ret = CtdlIPCGenericCommand(ipc, aaa, NULL, 0, NULL, NULL, cret);
       if (ret / 100 == 2) {
              ipc->downloading = 1;
              bytes = extract_long(cret, 0);
              last_mod = extract_int(cret, 1);
              extract_token(filename, cret, 2, '|', sizeof filename);
              extract_token(mimetype, cret, 3, '|', 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);
              if (ret / 100 == 2)
                     sprintf(cret, "%d|%ld|%s|%s", (int)bytes, last_mod,
                                   filename, mimetype);
       }
       return ret;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int CtdlIPCChangeHostname ( CtdlIPC ipc,
const char *  hostname,
char *  cret 
)

Definition at line 1729 of file citadel_ipc.c.

{
       register int ret;
       char *aaa;

       if (!cret) return -2;
       if (!hostname) return -2;

       aaa = (char *)malloc(strlen(hostname) + 6);
       if (!aaa) return -1;

       sprintf(aaa, "HCHG %s", hostname);
       ret = CtdlIPCGenericCommand(ipc, aaa, NULL, 0, NULL, NULL, cret);
       free(aaa);
       return ret;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int CtdlIPCChangePassword ( CtdlIPC ipc,
const char *  passwd,
char *  cret 
)

Definition at line 270 of file citadel_ipc.c.

{
       register int ret;
       char *aaa;

       if (!passwd) return -2;
       if (!cret) return -2;

       aaa = (char *)malloc((size_t)(strlen(passwd) + 6));
       if (!aaa) return -1;

       sprintf(aaa, "SETP %s", passwd);
       ret = CtdlIPCGenericCommand(ipc, aaa, NULL, 0, NULL, NULL, cret);
       free(aaa);
       return ret;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int CtdlIPCChangeRoomname ( CtdlIPC ipc,
const char *  roomname,
char *  cret 
)

Definition at line 1748 of file citadel_ipc.c.

{
       register int ret;
       char *aaa;

       if (!cret) return -2;
       if (!roomname) return -2;

       aaa = (char *)malloc(strlen(roomname) + 6);
       if (!aaa) return -1;

       sprintf(aaa, "RCHG %s", roomname);
       ret = CtdlIPCGenericCommand(ipc, aaa, NULL, 0, NULL, NULL, cret);
       free(aaa);
       return ret;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int CtdlIPCChangeUsername ( CtdlIPC ipc,
const char *  username,
char *  cret 
)

Definition at line 1767 of file citadel_ipc.c.

{
       register int ret;
       char *aaa;

       if (!cret) return -2;
       if (!username) return -2;

       aaa = (char *)malloc(strlen(username) + 6);
       if (!aaa) return -1;

       sprintf(aaa, "UCHG %s", username);
       ret = CtdlIPCGenericCommand(ipc, aaa, NULL, 0, NULL, NULL, cret);
       free(aaa);
       return ret;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int CtdlIPCCreateFloor ( CtdlIPC ipc,
int  for_real,
const char *  name,
char *  cret 
)

Definition at line 1488 of file citadel_ipc.c.

{
       register int ret;
       char aaa[SIZ];

       if (!cret) return -2;
       if (!name) return -2;

       sprintf(aaa, "CFLR %s|%d", name, for_real);
       ret = CtdlIPCGenericCommand(ipc, aaa, NULL, 0, NULL, NULL, cret);
       return ret;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int CtdlIPCCreateRoom ( CtdlIPC ipc,
int  for_real,
const char *  roomname,
int  type,
const char *  password,
int  floor,
char *  cret 
)

Definition at line 1004 of file citadel_ipc.c.

{
       register int ret;
       char *aaa;

       if (!cret) return -2;
       if (!roomname) return -2;

       if (password) {
              aaa = (char *)malloc(strlen(roomname) + strlen(password) + 40);
              if (!aaa) return -1;
              sprintf(aaa, "CRE8 %d|%s|%d|%s|%d", for_real, roomname, type,
                            password, floor);
       } else {
              aaa = (char *)malloc(strlen(roomname) + 40);
              if (!aaa) return -1;
              sprintf(aaa, "CRE8 %d|%s|%d||%d", for_real, roomname, type,
                            floor);
       }
       ret = CtdlIPCGenericCommand(ipc, aaa, NULL, 0, NULL, NULL, cret);
       free(aaa);
       return ret;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int CtdlIPCCreateUser ( CtdlIPC ipc,
const char *  username,
int  selfservice,
char *  cret 
)

Definition at line 249 of file citadel_ipc.c.

{
       register int ret;
       char *aaa;

       if (!username) return -2;
       if (!cret) return -2;

       aaa = (char *)malloc((size_t)(strlen(username) + 6));
       if (!aaa) return -1;

       sprintf(aaa, "%s %s", selfservice ? "NEWU" : "CREU",  username);
       ret = CtdlIPCGenericCommand(ipc, aaa, NULL, 0, NULL, NULL, cret);
       free(aaa);
       return ret;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int CtdlIPCDeleteFile ( CtdlIPC ipc,
const char *  filename,
char *  cret 
)

Definition at line 1181 of file citadel_ipc.c.

{
       register int ret;
       char *aaa;

       if (!cret) return -2;
       if (!filename) return -2;
       
       aaa = (char *)malloc(strlen(filename) + 6);
       if (!aaa) return -1;

       sprintf(aaa, "DELF %s", filename);
       ret = CtdlIPCGenericCommand(ipc, aaa, NULL, 0, NULL, NULL, cret);
       free(aaa);
       return ret;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int CtdlIPCDeleteFloor ( CtdlIPC ipc,
int  for_real,
int  floornum,
char *  cret 
)

Definition at line 1503 of file citadel_ipc.c.

{
       char aaa[SIZ];

       if (!cret) return -1;
       if (floornum < 0) return -1;

       sprintf(aaa, "KFLR %d|%d", floornum, for_real);
       return CtdlIPCGenericCommand(ipc, aaa, NULL, 0, NULL, NULL, cret);
}

Here is the call graph for this function:

Here is the caller graph for this function:

int CtdlIPCDeleteMessage ( CtdlIPC ipc,
long  msgnum,
char *  cret 
)

Definition at line 959 of file citadel_ipc.c.

{
       char aaa[64];

       if (!cret) return -2;
       if (!msgnum) return -2;

       sprintf(aaa, "DELE %ld", msgnum);
       return CtdlIPCGenericCommand(ipc, aaa, NULL, 0, NULL, NULL, cret);
}

Here is the call graph for this function:

Here is the caller graph for this function:

int CtdlIPCDeleteRoom ( CtdlIPC ipc,
int  for_real,
char *  cret 
)

Definition at line 992 of file citadel_ipc.c.

{
       char aaa[64];

       if (!cret) return -2;

       sprintf(aaa, "KILL %d", for_real);
       return CtdlIPCGenericCommand(ipc, aaa, NULL, 0, NULL, NULL, cret);
}

Here is the call graph for this function:

Here is the caller graph for this function:

int CtdlIPCDirectoryLookup ( CtdlIPC ipc,
const char *  address,
char *  cret 
)

Definition at line 2121 of file citadel_ipc.c.

{
    register int ret;
       char *aaa;

       if (!address) return -2;
       if (!cret) return -2;

       aaa = (char *)malloc(strlen(address) + 6);
       if (!aaa) return -1;

       sprintf(aaa, "QDIR %s", address);
       ret = CtdlIPCGenericCommand(ipc, aaa, NULL, 0, NULL, NULL, cret);
    free(aaa);
    return ret;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int CtdlIPCEcho ( CtdlIPC ipc,
const char *  arg,
char *  cret 
)

Definition at line 111 of file citadel_ipc.c.

{
       register int ret;
       char *aaa;
       
       if (!arg) return -2;
       if (!cret) return -2;

       aaa = (char *)malloc((size_t)(strlen(arg) + 6));
       if (!aaa) return -1;

       sprintf(aaa, "ECHO %s", arg);
       ret = CtdlIPCGenericCommand(ipc, aaa, NULL, 0, NULL, NULL, cret);
       free(aaa);
       return ret;
}

Here is the call graph for this function:

int CtdlIPCEditFloor ( CtdlIPC ipc,
int  floornum,
const char *  floorname,
char *  cret 
)

Definition at line 1516 of file citadel_ipc.c.

{
       register int ret;
       char aaa[SIZ];

       if (!cret) return -2;
       if (!floorname) return -2;
       if (floornum < 0) return -2;

       sprintf(aaa, "EFLR %d|%s", floornum, floorname);
       ret = CtdlIPCGenericCommand(ipc, aaa, NULL, 0, NULL, NULL, cret);
       return ret;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int CtdlIPCEnableInstantMessageReceipt ( CtdlIPC ipc,
int  mode,
char *  cret 
)

Definition at line 1605 of file citadel_ipc.c.

{
       char aaa[64];

       if (!cret) return -2;

       sprintf(aaa, "DEXP %d", mode);
       return CtdlIPCGenericCommand(ipc, aaa, NULL, 0, NULL, NULL, cret);
}

Here is the call graph for this function:

Here is the caller graph for this function:

int CtdlIPCEndDownload ( CtdlIPC ipc,
char *  cret 
)

Definition at line 2260 of file citadel_ipc.c.

{
       register int ret;

       if (!cret) return -2;
       if (!ipc->downloading) return -2;

       ret = CtdlIPCGenericCommand(ipc, "CLOS", NULL, 0, NULL, NULL, cret);
       if (ret / 100 == 2)
              ipc->downloading = 0;
       return ret;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int CtdlIPCEndUpload ( CtdlIPC ipc,
int  discard,
char *  cret 
)

Definition at line 2371 of file citadel_ipc.c.

{
       register int ret;
       char cmd[8];

       if (!cret) return -1;
       if (!ipc->uploading) return -1;

       sprintf(cmd, "UCLS %d", discard ? 0 : 1);
       ret = CtdlIPCGenericCommand(ipc, cmd, NULL, 0, NULL, NULL, cret);
       ipc->uploading = 0;
       return ret;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int CtdlIPCEnterSystemMessage ( CtdlIPC ipc,
const char *  filename,
const char *  text,
char *  cret 
)

Definition at line 1708 of file citadel_ipc.c.

{
       register int ret;
       char *aaa;

       if (!cret) return -2;
       if (!text) return -2;
       if (!filename) return -2;

       aaa = (char *)malloc(strlen(filename) + 6);
       if (!aaa) return -1;

       sprintf(aaa, "EMSG %s", filename);
       ret = CtdlIPCGenericCommand(ipc, aaa, text, strlen(text), NULL, NULL, cret);
       free(aaa);
       return ret;
}

Here is the call graph for this function:

int CtdlIPCFileDownload ( CtdlIPC ipc,
const char *  filename,
void **  buf,
size_t  resume,
void(*)(CtdlIPC *, unsigned long, unsigned long)  progress_gauge_callback,
char *  cret 
)

Definition at line 1238 of file citadel_ipc.c.

{
       register int ret;
       size_t bytes;
       time_t last_mod;
       char mimetype[SIZ];
       char *aaa;

       if (!cret) return -2;
       if (!filename) return -2;
       if (!buf) return -2;
       if (*buf) return -2;
       if (ipc->downloading) return -2;

       aaa = (char *)malloc(strlen(filename) + 6);
       if (!aaa) return -1;

       sprintf(aaa, "OPEN %s", filename);
       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_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);
       }
       return ret;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int CtdlIPCFileUpload ( CtdlIPC ipc,
const char *  save_as,
const char *  comment,
const char *  path,
void(*)(CtdlIPC *, unsigned long, unsigned long)  progress_gauge_callback,
char *  cret 
)

Definition at line 1365 of file citadel_ipc.c.

{
       register int ret;
       char *aaa;
       FILE *uploadFP;
       char MimeTestBuf[64];
       const char *MimeType;
       long len;

       if (!cret) return -1;
       if (!save_as) return -1;
       if (!comment) return -1;
       if (!path) return -1;
       if (!*path) return -1;
       if (ipc->uploading) return -1;

       uploadFP = fopen(path, "r");
       if (!uploadFP) return -2;

       len = fread(&MimeTestBuf[0], 1, 64, uploadFP);
       rewind (uploadFP);
       if (len < 0) 
              return -3;

       MimeType = GuessMimeType(&MimeTestBuf[0], len);
       aaa = (char *)malloc(strlen(save_as) + strlen(comment) + 7);
       if (!aaa) return -1;

       sprintf(aaa, "UOPN %s|%s|%s", save_as, MimeType,  comment);
       ret = CtdlIPCGenericCommand(ipc, aaa, NULL, 0, NULL, NULL, cret);
       free(aaa);
       if (ret / 100 == 2) {
              ipc->uploading = 1;
              ret = CtdlIPCWriteUpload(ipc, uploadFP, progress_gauge_callback, cret);
              ret = CtdlIPCEndUpload(ipc, (ret == -2 ? 1 : 0), cret);
              ipc->uploading = 0;
       }
       return ret;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int CtdlIPCFloorListing ( CtdlIPC ipc,
char **  listing,
char *  cret 
)

Definition at line 1475 of file citadel_ipc.c.

{
       size_t bytes;

       if (!cret) return -2;
       if (!listing) return -2;
       if (*listing) return -2;

       return CtdlIPCGenericCommand(ipc, "LFLR", NULL, 0, listing, &bytes, cret);
}

Here is the call graph for this function:

Here is the caller graph for this function:

int CtdlIPCForgetRoom ( CtdlIPC ipc,
char *  cret 
)

Definition at line 1031 of file citadel_ipc.c.

{
       if (!cret) return -2;

       return CtdlIPCGenericCommand(ipc, "FORG", NULL, 0, NULL, NULL, cret);
}

Here is the call graph for this function:

Here is the caller graph for this function:

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 
)

Definition at line 2471 of file citadel_ipc.c.

{
       char buf[SIZ];
       register int ret;

       if (!command) return -2;
       if (!proto_response) return -2;

       CtdlIPC_lock(ipc);
       CtdlIPC_putline(ipc, command);
       while (1) {
              CtdlIPC_getline(ipc, proto_response);
              if (proto_response[3] == '*')
                     instant_msgs = 1;
              ret = atoi(proto_response);
              strcpy(proto_response, &proto_response[4]);
              switch (ret / 100) {
              default:                    /* Unknown, punt */
              case 2:                            /* OK */
              case 3:                            /* MORE_DATA */
              case 5:                            /* ERROR */
                     /* Don't need to do anything */
                     break;
              case 1:                            /* LISTING_FOLLOWS */
                     if (to_receive && !*to_receive && bytes_to_receive) {
                            *to_receive = CtdlIPCReadListing(ipc, NULL);
                     } else { /* Drain */
                            while (CtdlIPC_getline(ipc, buf), strcmp(buf, "000")) ;
                            ret = -ret;
                     }
                     break;
              case 4:                            /* SEND_LISTING */
                     if (to_send) {
                            CtdlIPCSendListing(ipc, to_send);
                     } else {
                            /* No listing given, fake it */
                            CtdlIPC_putline(ipc, "000");
                            ret = -ret;
                     }
                     break;
              case 6:                            /* BINARY_FOLLOWS */
                     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);
                            if (!*to_receive) {
                                   ret = -1;
                            } else {
                                   serv_read(ipc, *to_receive,
                                                 *bytes_to_receive);
                            }
                     } else {
                            /* Drain */
                            size_t drain;

                            drain = extract_long(proto_response, 0);
                            while (drain > SIZ) {
                                   serv_read(ipc, buf, SIZ);
                                   drain -= SIZ;
                            }
                            serv_read(ipc, buf, drain);
                            ret = -ret;
                     }
                     break;
              case 7:                            /* SEND_BINARY */
                     if (to_send && bytes_to_send) {
                            serv_write(ipc, to_send, bytes_to_send);
                     } else if (bytes_to_send) {
                            /* Fake it, send nulls */
                            size_t fake;

                            fake = bytes_to_send;
                            memset(buf, '\0', SIZ);
                            while (fake > SIZ) {
                                   serv_write(ipc, buf, SIZ);
                                   fake -= SIZ;
                            }
                            serv_write(ipc, buf, fake);
                            ret = -ret;
                     } /* else who knows?  DANGER WILL ROBINSON */
                     break;
              case 8:                            /* START_CHAT_MODE */
                     if (!strncasecmp(command, "CHAT", 4)) {
                            /* Don't call chatmode with generic! */
                            CtdlIPC_putline(ipc, "/quit");
                            ret = -ret;
                     } else {
                            /* In this mode we send then receive listing */
                            if (to_send) {
                                   CtdlIPCSendListing(ipc, to_send);
                            } 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 */
                                   while (CtdlIPC_getline(ipc, buf),
                                                 strcmp(buf, "000")) ;
                                   ret = -ret;
                            }
                     }
                     break;
              case 9:                            /* ASYNC_MSG */
                     /* CtdlIPCDoAsync(ret, proto_response); */
                     free(CtdlIPCReadListing(ipc, NULL));      /* STUB FIXME */
                     break;
              }
              if (ret / 100 != 9)
                     break;
       }
       CtdlIPC_unlock(ipc);
       return ret;
}

Here is the call graph for this function:

int CtdlIPCGetBio ( CtdlIPC ipc,
const char *  username,
char **  listing,
char *  cret 
)

Definition at line 1628 of file citadel_ipc.c.

{
       register int ret;
       size_t bytes;
       char *aaa;

       if (!cret) return -2;
       if (!username) return -2;
       if (!listing) return -2;
       if (*listing) return -2;

       aaa = (char *)malloc(strlen(username) + 6);
       if (!aaa) return -1;

       sprintf(aaa, "RBIO %s", username);
       ret = CtdlIPCGenericCommand(ipc, aaa, NULL, 0, listing, &bytes, cret);
       free(aaa);
       return ret;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int CtdlIPCGetConfig ( CtdlIPC ipc,
struct ctdluser **  uret,
char *  cret 
)

Definition at line 349 of file citadel_ipc.c.

{
       register int ret;

       if (!cret) return -2;
       if (!uret) return -2;
       if (!*uret) *uret = (struct ctdluser *)calloc(1, sizeof (struct ctdluser));
       if (!*uret) return -1;

       ret = CtdlIPCGenericCommand(ipc, "GETU", NULL, 0, NULL, NULL, cret);
       if (ret / 100 == 2) {
              uret[0]->flags = extract_int(cret, 2);
       }
       return ret;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int CtdlIPCGetInstantMessage ( CtdlIPC ipc,
char **  listing,
char *  cret 
)

Definition at line 1591 of file citadel_ipc.c.

{
       size_t bytes;

       if (!cret) return -2;
       if (!listing) return -2;
       if (*listing) return -2;

       return CtdlIPCGenericCommand(ipc, "GEXP", NULL, 0, listing, &bytes, cret);
}

Here is the call graph for this function:

Here is the caller graph for this function:

int CtdlIPCGetMessageExpirationPolicy ( CtdlIPC ipc,
GPEXWhichPolicy  which,
struct ExpirePolicy **  policy,
char *  cret 
)

Definition at line 1857 of file citadel_ipc.c.

{
       static char *proto[] = {
              strof(roompolicy),
              strof(floorpolicy),
              strof(sitepolicy),
              strof(mailboxespolicy)
       };
       char cmd[256];
       register int ret;

       if (!cret) return -2;
       if (!policy) return -2;
       if (!*policy) *policy = (struct ExpirePolicy *)calloc(1, sizeof(struct ExpirePolicy));
       if (!*policy) return -1;
       if (which < 0 || which > 3) return -2;
       
       sprintf(cmd, "GPEX %s", proto[which]);
       ret = CtdlIPCGenericCommand(ipc, cmd, NULL, 0, NULL, NULL, cret);
       if (ret / 100 == 2) {
              policy[0]->expire_mode = extract_int(cret, 0);
              policy[0]->expire_value = extract_int(cret, 1);
       }
       return ret;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int CtdlIPCGetMessages ( CtdlIPC ipc,
enum MessageList  which,
int  whicharg,
const char *  mtemplate,
unsigned long **  mret,
char *  cret 
)

Definition at line 454 of file citadel_ipc.c.

{
       register int ret;
       register unsigned long count = 0;
       static char *proto[] =
              { "ALL", "OLD", "NEW", "LAST", "FIRST", "GT", "LT" };
       char aaa[33];
       char *bbb = NULL;
       size_t bbb_len;

       if (!cret) return -2;
       if (!mret) return -2;
       if (*mret) return -2;
       if (which < 0 || which > 6) return -2;

       if (which <= 2)
              sprintf(aaa, "MSGS %s||%d", proto[which],
                            (mtemplate) ? 1 : 0);
       else
              sprintf(aaa, "MSGS %s|%d|%d", proto[which], whicharg,
                            (mtemplate) ? 1 : 0);
       if (mtemplate) count = strlen(mtemplate);
       ret = CtdlIPCGenericCommand(ipc, aaa, mtemplate, count, &bbb, &bbb_len, cret);
       if (ret / 100 != 1)
              return ret;
       count = 0;
       *mret = (unsigned long *)calloc(1, sizeof(unsigned long));
       if (!*mret)
              return -1;
       while (bbb && strlen(bbb)) {
              extract_token(aaa, bbb, 0, '\n', sizeof aaa);
              remove_token(bbb, 0, '\n');
              *mret = (unsigned long *)realloc(*mret, (size_t)((count + 2) *
                                   sizeof (unsigned long)));
              if (*mret) {
                     (*mret)[count++] = atol(aaa);
                     (*mret)[count] = 0L;
              } else {
                     break;
              }
       }
       if (bbb) free(bbb);
       return ret;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int CtdlIPCGetRoomAide ( CtdlIPC ipc,
char *  cret 
)

Definition at line 885 of file citadel_ipc.c.

{
       if (!cret) return -1;

       return CtdlIPCGenericCommand(ipc, "GETA", NULL, 0, NULL, NULL, cret);
}

Here is the call graph for this function:

Here is the caller graph for this function:

int CtdlIPCGetRoomAttributes ( CtdlIPC ipc,
struct ctdlroom **  qret,
char *  cret 
)

Definition at line 836 of file citadel_ipc.c.

{
       register int ret;

       if (!cret) return -2;
       if (!qret) return -2;
       if (!*qret) *qret = (struct ctdlroom *)calloc(1, sizeof (struct ctdlroom));
       if (!*qret) return -1;

       ret = CtdlIPCGenericCommand(ipc, "GETR", NULL, 0, NULL, NULL, cret);
       if (ret / 100 == 2) {
              extract_token(qret[0]->QRname, cret, 0, '|', sizeof qret[0]->QRname);
              extract_token(qret[0]->QRpasswd, cret, 1, '|', sizeof qret[0]->QRpasswd);
              extract_token(qret[0]->QRdirname, cret, 2, '|', sizeof qret[0]->QRdirname);
              qret[0]->QRflags = extract_int(cret, 3);
              qret[0]->QRfloor = extract_int(cret, 4);
              qret[0]->QRorder = extract_int(cret, 5);
              qret[0]->QRdefaultview = extract_int(cret, 6);
              qret[0]->QRflags2 = extract_int(cret, 7);
       }
       return ret;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int CtdlIPCGetRoomNetworkConfig ( CtdlIPC ipc,
char **  listing,
char *  cret 
)

Definition at line 1976 of file citadel_ipc.c.

{
       size_t bytes;

       if (!cret) return -2;
       if (!listing) return -2;
       if (*listing) return -2;

       return CtdlIPCGenericCommand(ipc, "GNET", NULL, 0,
                     listing, &bytes, cret);
}

Here is the call graph for this function:

Here is the caller graph for this function:

int CtdlIPCGetSingleMessage ( CtdlIPC ipc,
long  msgnum,
int  headers,
int  as_mime,
struct ctdlipcmessage **  mret,
char *  cret 
)

Definition at line 502 of file citadel_ipc.c.

{
       register int ret;
       char aaa[SIZ];
       char *bbb = NULL;
       size_t bbb_len;
       int multipart_hunting = 0;
       char multipart_prefix[128];
       char encoding[256];

       if (!cret) return -1;
       if (!mret) return -1;
       if (!*mret) *mret = (struct ctdlipcmessage *)calloc(1, sizeof (struct ctdlipcmessage));
       if (!*mret) return -1;
       if (!msgnum) return -1;

       strcpy(encoding, "");
       strcpy(mret[0]->content_type, "");
       sprintf(aaa, "MSG%d %ld|%d", as_mime, msgnum, headers);
       ret = CtdlIPCGenericCommand(ipc, aaa, NULL, 0, &bbb, &bbb_len, cret);
       if (ret / 100 == 1) {
              if (as_mime != 2) {
                     strcpy(mret[0]->mime_chosen, "1"); /* Default chosen-part is "1" */
                     while (strlen(bbb) > 4 && bbb[4] == '=') {
                            extract_token(aaa, bbb, 0, '\n', sizeof aaa);
                            remove_token(bbb, 0, '\n');

                            if (!strncasecmp(aaa, "nhdr=yes", 8))
                                   mret[0]->nhdr = 1;
                            else if (!strncasecmp(aaa, "from=", 5))
                                   safestrncpy(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);
                            else if (!strncasecmp(aaa, "subj=", 5))
                                   safestrncpy(mret[0]->subject, &aaa[5], SIZ);
                            else if (!strncasecmp(aaa, "rfca=", 5))
                                   safestrncpy(mret[0]->email, &aaa[5], SIZ);
                            else if (!strncasecmp(aaa, "hnod=", 5))
                                   safestrncpy(mret[0]->hnod, &aaa[5], SIZ);
                            else if (!strncasecmp(aaa, "room=", 5))
                                   safestrncpy(mret[0]->room, &aaa[5], SIZ);
                            else if (!strncasecmp(aaa, "node=", 5))
                                   safestrncpy(mret[0]->node, &aaa[5], SIZ);
                            else if (!strncasecmp(aaa, "rcpt=", 5))
                                   safestrncpy(mret[0]->recipient, &aaa[5], SIZ);
                            else if (!strncasecmp(aaa, "wefw=", 5))
                                   safestrncpy(mret[0]->references, &aaa[5], SIZ);
                            else if (!strncasecmp(aaa, "time=", 5))
                                   mret[0]->time = atol(&aaa[5]);

                            /* Multipart/alternative prefix & suffix strings help
                             * us to determine which part we want to download.
                             */
                            else if (!strncasecmp(aaa, "pref=", 5)) {
                                   extract_token(multipart_prefix, &aaa[5], 1, '|', sizeof multipart_prefix);
                                   if (!strcasecmp(multipart_prefix,
                                      "multipart/alternative")) {
                                          ++multipart_hunting;
                                   }
                            }
                            else if (!strncasecmp(aaa, "suff=", 5)) {
                                   extract_token(multipart_prefix, &aaa[5], 1, '|', sizeof multipart_prefix);
                                   if (!strcasecmp(multipart_prefix,
                                      "multipart/alternative")) {
                                          ++multipart_hunting;
                                   }
                            }

                            else if (!strncasecmp(aaa, "part=", 5)) {
                                   struct parts *ptr, *chain;
       
                                   ptr = (struct parts *)calloc(1, sizeof (struct parts));
                                   if (ptr) {

                                          /* Fill the buffers for the caller */
                                          extract_token(ptr->name, &aaa[5], 0, '|', sizeof ptr->name);
                                          extract_token(ptr->filename, &aaa[5], 1, '|', sizeof ptr->filename);
                                          extract_token(ptr->number, &aaa[5], 2, '|', sizeof ptr->number);
                                          extract_token(ptr->disposition, &aaa[5], 3, '|', sizeof ptr->disposition);
                                          extract_token(ptr->mimetype, &aaa[5], 4, '|', sizeof ptr->mimetype);
                                          ptr->length = extract_long(&aaa[5], 5);
                                          if (!mret[0]->attachments)
                                                 mret[0]->attachments = ptr;
                                          else {
                                                 chain = mret[0]->attachments;
                                                 while (chain->next)
                                                        chain = chain->next;
                                                 chain->next = ptr;
                                          }

                                          /* Now handle multipart/alternative */
                                          if (multipart_hunting > 0) {
                                                 if ( (!strcasecmp(ptr->mimetype,
                                                      "text/plain"))
                                                    || (!strcasecmp(ptr->mimetype,
                                                       "text/html")) ) {
                                                        strcpy(mret[0]->mime_chosen,
                                                               ptr->number);
                                                 }
                                          }

                                   }
                            }
                     }
                     /* Eliminate "text\n" */
                     remove_token(bbb, 0, '\n');

                     /* If doing a MIME thing, pull out the extra headers */
                     if (as_mime == 4) {
                            do {
                                   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);

                                          /* strip out ";charset=" portion.  FIXME do something with
                                           * the charset (like... convert it) instead of just throwing
                                           * it away
                                           */
                                          if (strstr(mret[0]->content_type, ";") != NULL) {
                                                 strcpy(strstr(mret[0]->content_type, ";"), "");
                                          }

                                   }
                                   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);
                                   }
                                   if (!strncasecmp(bbb, "Content-transfer-encoding:", 26)) {
                                          extract_token(encoding, bbb, 0, '\n', sizeof encoding);
                                          strcpy(encoding, &encoding[26]);
                                          striplt(encoding);
                                   }
                                   remove_token(bbb, 0, '\n');
                            } while ((bbb[0] != 0) && (bbb[0] != '\n'));
                            remove_token(bbb, 0, '\n');
                     }


              }
              if (strlen(bbb)) {

                     if ( (!strcasecmp(encoding, "base64")) || (!strcasecmp(encoding, "quoted-printable")) ) {
                            char *ccc = NULL;
                            int bytes_decoded = 0;
                            ccc = malloc(strlen(bbb) + 32768);
                            if (!strcasecmp(encoding, "base64")) {
                                   bytes_decoded = CtdlDecodeBase64(ccc, bbb, strlen(bbb));
                            }
                            else if (!strcasecmp(encoding, "quoted-printable")) {
                                   bytes_decoded = CtdlDecodeQuotedPrintable(ccc, bbb, strlen(bbb));
                            }
                            ccc[bytes_decoded] = 0;
                            free(bbb);
                            bbb = ccc;
                     }

                     /* FIXME: Strip trailing whitespace */
                     bbb = (char *)realloc(bbb, (size_t)(strlen(bbb) + 1));

              } else {
                     bbb = (char *)realloc(bbb, 1);
                     *bbb = '\0';
              }
              mret[0]->text = bbb;
       }
       return ret;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int CtdlIPCGetSystemConfig ( CtdlIPC ipc,
char **  listing,
char *  cret 
)

Definition at line 1907 of file citadel_ipc.c.

{
       size_t bytes;

       if (!cret) return -2;
       if (!listing) return -2;
       if (*listing) return -2;

       return CtdlIPCGenericCommand(ipc, "CONF GET", NULL, 0,
                     listing, &bytes, cret);
}

Here is the call graph for this function:

Here is the caller graph for this function:

int CtdlIPCGetSystemConfigByType ( CtdlIPC ipc,
const char *  mimetype,
char **  listing,
char *  cret 
)

Definition at line 1932 of file citadel_ipc.c.

{
       register int ret;
       char *aaa;
       size_t bytes;

       if (!cret) return -2;
       if (!mimetype) return -2;
       if (!listing) return -2;
       if (*listing) return -2;

       aaa = malloc(strlen(mimetype) + 13);
       if (!aaa) return -1;
       sprintf(aaa, "CONF GETSYS|%s", mimetype);
       ret = CtdlIPCGenericCommand(ipc, aaa, NULL, 0,
                     listing, &bytes, cret);
    free(aaa);
    return ret;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int CtdlIPCGetUserRegistration ( CtdlIPC ipc,
const char *  username,
char **  rret,
char *  cret 
)

Definition at line 1071 of file citadel_ipc.c.

{
       register int ret;
       char *aaa;
       size_t bytes;

       if (!cret) return -2;
       if (!rret) return -2;
       if (*rret) return -2;

       if (username)
              aaa = (char *)malloc(strlen(username) + 6);
       else
              aaa = (char *)malloc(12);
       if (!aaa) return -1;

       if (username)
              sprintf(aaa, "GREG %s", username);
       else
              sprintf(aaa, "GREG _SELF_");
       ret = CtdlIPCGenericCommand(ipc, aaa, NULL, 0, rret, &bytes, cret);
       free(aaa);
       return ret;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int CtdlIPCGotoRoom ( CtdlIPC ipc,
const char *  room,
const char *  passwd,
struct ctdlipcroom **  rret,
char *  cret 
)

Definition at line 399 of file citadel_ipc.c.

{
       register int ret;
       char *aaa;

       if (!cret) return -2;
       if (!rret) return -2;
       if (!*rret) *rret = (struct ctdlipcroom *)calloc(1, sizeof (struct ctdlipcroom));
       if (!*rret) return -1;

       if (passwd) {
              aaa = (char *)malloc(strlen(room) + strlen(passwd) + 7);
              if (!aaa) {
                     free(*rret);
                     return -1;
              }
              sprintf(aaa, "GOTO %s|%s", room, passwd);
       } else {
              aaa = (char *)malloc(strlen(room) + 6);
              if (!aaa) {
                     free(*rret);
                     return -1;
              }
              sprintf(aaa, "GOTO %s", room);
       }
       ret = CtdlIPCGenericCommand(ipc, aaa, NULL, 0, NULL, NULL, cret);
       if (ret / 100 == 2) {
              extract_token(rret[0]->RRname, cret, 0, '|', sizeof rret[0]->RRname);
              rret[0]->RRunread = extract_long(cret, 1);
              rret[0]->RRtotal = extract_long(cret, 2);
              rret[0]->RRinfoupdated = extract_int(cret, 3);
              rret[0]->RRflags = extract_int(cret, 4);
              rret[0]->RRhighest = extract_long(cret, 5);
              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);
              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 */
              rret[0]->RRflags2 = extract_int(cret, 14);
       } else {
              free(*rret);
              *rret = NULL;
       }
       free(aaa);
       return ret;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int CtdlIPCHighSpeedReadDownload ( CtdlIPC ipc,
void **  buf,
size_t  bytes,
size_t  resume,
void(*)(CtdlIPC *, unsigned long, unsigned long)  progress_gauge_callback,
char *  cret 
)

Definition at line 2318 of file citadel_ipc.c.

{
       register size_t len;
       register int calls;  /* How many calls in the pipeline */
       register int i;             /* iterator */
       char aaa[4096];

       if (!cret) return -1;
       if (!buf) return -1;
       if (*buf) return -1;
       if (!ipc->downloading) return -1;

       *buf = (void *)realloc(*buf, bytes - resume);
       if (!*buf) return -1;

       len = 0;
       CtdlIPC_lock(ipc);
       if (progress_gauge_callback)
              progress_gauge_callback(ipc, len, bytes);

       /* How many calls will be in the pipeline? */
       calls = (bytes - resume) / 4096;
       if ((bytes - resume) % 4096) calls++;

       /* Send all requests at once */
       for (i = 0; i < calls; i++) {
              sprintf(aaa, "READ %d|4096", (int)(i * 4096 + resume) );
              CtdlIPC_putline(ipc, aaa);
       }

       /* Receive all responses at once */
       for (i = 0; i < calls; i++) {
              CtdlIPC_getline(ipc, aaa);
              if (aaa[0] != '6')
                     strcpy(cret, &aaa[4]);
              else {
                     len = extract_long(&aaa[4], 0);
                     /* I know what I'm doing */
                     serv_read(ipc, ((char *)(*buf) + (i * 4096)), len);
              }
              if (progress_gauge_callback)
                     progress_gauge_callback(ipc, i * 4096 + len, bytes);
       }
       CtdlIPC_unlock(ipc);
       return len;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int CtdlIPCIdentifySoftware ( CtdlIPC ipc,
int  developerid,
int  clientid,
int  revision,
const char *  software_name,
const char *  hostname,
char *  cret 
)

Definition at line 1537 of file citadel_ipc.c.

{
       register int ret;
       char *aaa;

       if (developerid < 0 || clientid < 0 || revision < 0 ||
           !software_name) {
              developerid = 8;
              clientid = 0;
              revision = REV_LEVEL - 600;
              software_name = "Citadel (libcitadel)";
       }
       if (!hostname) return -2;

       aaa = (char *)malloc(strlen(software_name) + strlen(hostname) + 29);
       if (!aaa) return -1;

       sprintf(aaa, "IDEN %d|%d|%d|%s|%s", developerid, clientid,
                     revision, software_name, hostname);
       ret = CtdlIPCGenericCommand(ipc, aaa, NULL, 0, NULL, NULL, cret);
       free(aaa);
       return ret;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int CtdlIPCImageDownload ( CtdlIPC ipc,
const char *  filename,
void **  buf,
void(*)(CtdlIPC *, unsigned long, unsigned long)  progress_gauge_callback,
char *  cret 
)

Definition at line 1325 of file citadel_ipc.c.

{
       register int ret;
       size_t bytes;
       time_t last_mod;
       char mimetype[SIZ];
       char *aaa;

       if (!cret) return -1;
       if (!buf) return -1;
       if (*buf) return -1;
       if (!filename) return -1;
       if (ipc->downloading) return -1;

       aaa = (char *)malloc(strlen(filename) + 6);
       if (!aaa) return -1;

       sprintf(aaa, "OIMG %s", filename);
       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_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);
              if (ret / 100 == 2)
                     sprintf(cret, "%d|%ld|%s|%s", (int)bytes, last_mod,
                                   filename, mimetype);
       }
       return ret;
}

Here is the call graph for this function:

int CtdlIPCImageUpload ( CtdlIPC ipc,
int  for_real,
const char *  path,
const char *  save_as,
void(*)(CtdlIPC *, unsigned long, unsigned long)  progress_gauge_callback,
char *  cret 
)

Definition at line 1411 of file citadel_ipc.c.

{
       register int ret;
       FILE *uploadFP;
       char *aaa;
       char MimeTestBuf[64];
       const char *MimeType;
       long len;

       if (!cret) return -1;
       if (!save_as) return -1;
       if (!path && for_real) return -1;
       if (!*path && for_real) return -1;
       if (ipc->uploading) return -1;

       aaa = (char *)malloc(strlen(save_as) + 17);
       if (!aaa) return -1;

       uploadFP = fopen(path, "r");
       if (!uploadFP) return -2;

       len = fread(&MimeTestBuf[0], 1, 64, uploadFP);
       rewind (uploadFP);
       if (len < 0) 
              return -3;
       MimeType = GuessMimeType(&MimeTestBuf[0], 64);

       sprintf(aaa, "UIMG %d|%s|%s", for_real, MimeType, save_as);
       ret = CtdlIPCGenericCommand(ipc, aaa, NULL, 0, NULL, NULL, cret);
       free(aaa);
       if (ret / 100 == 2 && for_real) {
              ipc->uploading = 1;
              ret = CtdlIPCWriteUpload(ipc, uploadFP, progress_gauge_callback, cret);
              ret = CtdlIPCEndUpload(ipc, (ret == -2 ? 1 : 0), cret);
              ipc->uploading = 0;
       }
       return ret;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int CtdlIPCInternalProgram ( CtdlIPC ipc,
int  secret,
char *  cret 
)

Definition at line 2140 of file citadel_ipc.c.

{
       char aaa[30];

       if (!cret) return -2;
       sprintf(aaa, "IPGM %d", secret);
       return CtdlIPCGenericCommand(ipc, aaa, NULL, 0, NULL, NULL, cret);
}

Here is the call graph for this function:

int CtdlIPCInviteUserToRoom ( CtdlIPC ipc,
const char *  username,
char *  cret 
)

Definition at line 799 of file citadel_ipc.c.

{
       register int ret;
       char *aaa;

       if (!cret) return -2;
       if (!username) return -2;

       aaa = (char *)malloc(strlen(username) + 6);
       if (!aaa) return -1;

       sprintf(aaa, "INVT %s", username);
       ret = CtdlIPCGenericCommand(ipc, aaa, NULL, 0, NULL, NULL, cret);
       free(aaa);
       return ret;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int CtdlIPCKickoutUserFromRoom ( CtdlIPC ipc,
const char *  username,
char *  cret 
)

Definition at line 818 of file citadel_ipc.c.

{
       register int ret;
       char *aaa;

       if (!cret) return -1;
       if (!username) return -1;

       aaa = (char *)malloc(strlen(username) + 6);

       sprintf(aaa, "KICK %s", username);
       ret = CtdlIPCGenericCommand(ipc, aaa, NULL, 0, NULL, NULL, cret);
       free(aaa);
       return ret;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int CtdlIPCKnownRooms ( CtdlIPC ipc,
enum RoomList  which,
int  floor,
struct march **  listing,
char *  cret 
)

Definition at line 292 of file citadel_ipc.c.

{
       register int ret;
       struct march *march = NULL;
       static char *proto[] =
              {"LKRA", "LKRN", "LKRO", "LZRM", "LRMS", "LPRM" };
       char aaa[SIZ];
       char *bbb = NULL;
       size_t bbb_len;

       if (!listing) return -2;
       if (*listing) return -2;    /* Free the listing first */
       if (!cret) return -2;
       /* if (which < 0 || which > 4) return -2; */
       if (floor < -1) return -2;  /* Can't validate upper bound, sorry */

       sprintf(aaa, "%s %d", proto[which], floor);
       ret = CtdlIPCGenericCommand(ipc, aaa, NULL, 0, &bbb, &bbb_len, cret);
       if (ret / 100 == 1) {
              struct march *mptr;

              while (bbb && strlen(bbb)) {
                     int a;

                     extract_token(aaa, bbb, 0, '\n', sizeof aaa);
                     a = strlen(aaa);
                     memmove(bbb, bbb + a + 1, strlen(bbb) - a);
                     mptr = (struct march *) malloc(sizeof (struct march));
                     if (mptr) {
                            mptr->next = NULL;
                            extract_token(mptr->march_name, aaa, 0, '|', sizeof mptr->march_name);
                            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 {
                                   struct march *mptr2;

                                   mptr2 = march;
                                   while (mptr2->next != NULL)
                                          mptr2 = mptr2->next;
                                   mptr2->next = mptr;
                            }
                     }
              }
       }
       *listing = march;
       if (bbb) free(bbb);
       return ret;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int CtdlIPCListUsersWithBios ( CtdlIPC ipc,
char **  listing,
char *  cret 
)

Definition at line 1650 of file citadel_ipc.c.

{
       size_t bytes;

       if (!cret) return -2;
       if (!listing) return -2;
       if (*listing) return -2;

       return CtdlIPCGenericCommand(ipc, "LBIO", NULL, 0, listing, &bytes, cret);
}

Here is the call graph for this function:

Here is the caller graph for this function:

int CtdlIPCLogout ( CtdlIPC ipc)

Definition at line 161 of file citadel_ipc.c.

{
       register int ret;
       char aaa[SIZ];

       CtdlIPC_lock(ipc);
       CtdlIPC_putline(ipc, "LOUT");
       CtdlIPC_getline(ipc, aaa);
       ret = atoi(aaa);
       CtdlIPC_unlock(ipc);
       return ret;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int CtdlIPCMiscCheck ( CtdlIPC ipc,
struct ctdlipcmisc chek,
char *  cret 
)

Definition at line 1163 of file citadel_ipc.c.

{
       register int ret;

       if (!cret) return -1;
       if (!chek) return -1;

       ret = CtdlIPCGenericCommand(ipc, "CHEK", NULL, 0, NULL, NULL, cret);
       if (ret / 100 == 2) {
              chek->newmail = extract_long(cret, 0);
              chek->needregis = extract_int(cret, 1);
              chek->needvalid = extract_int(cret, 2);
       }
       return ret;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int CtdlIPCMoveFile ( CtdlIPC ipc,
const char *  filename,
const char *  destroom,
char *  cret 
)

Definition at line 1200 of file citadel_ipc.c.

{
       register int ret;
       char *aaa;

       if (!cret) return -2;
       if (!filename) return -2;
       if (!destroom) return -2;

       aaa = (char *)malloc(strlen(filename) + strlen(destroom) + 7);
       if (!aaa) return -1;

       sprintf(aaa, "MOVF %s|%s", filename, destroom);
       ret = CtdlIPCGenericCommand(ipc, aaa, NULL, 0, NULL, NULL, cret);
       free(aaa);
       return ret;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int CtdlIPCMoveMessage ( CtdlIPC ipc,
int  copy,
long  msgnum,
const char *  destroom,
char *  cret 
)

Definition at line 972 of file citadel_ipc.c.

{
       register int ret;
       char *aaa;

       if (!cret) return -2;
       if (!destroom) return -2;
       if (!msgnum) return -2;

       aaa = (char *)malloc(strlen(destroom) + 28);
       if (!aaa) return -1;

       sprintf(aaa, "MOVE %ld|%s|%d", msgnum, destroom, copy);
       ret = CtdlIPCGenericCommand(ipc, aaa, NULL, 0, NULL, NULL, cret);
       free(aaa);
       return ret;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int CtdlIPCNextUnvalidatedUser ( CtdlIPC ipc,
char *  cret 
)

Definition at line 1062 of file citadel_ipc.c.

{
       if (!cret) return -2;

       return CtdlIPCGenericCommand(ipc, "GNUR", NULL, 0, NULL, NULL, cret);
}

Here is the call graph for this function:

Here is the caller graph for this function:

int CtdlIPCNoop ( CtdlIPC ipc)

Definition at line 99 of file citadel_ipc.c.

{
       char aaa[128];

       return CtdlIPCGenericCommand(ipc, "NOOP", NULL, 0, NULL, NULL, aaa);
}

Here is the call graph for this function:

Here is the caller graph for this function:

int CtdlIPCOnlineUsers ( CtdlIPC ipc,
char **  listing,
time_t *  stamp,
char *  cret 
)

Definition at line 1220 of file citadel_ipc.c.

{
       register int ret;
       size_t bytes;

       if (!cret) return -1;
       if (!listing) return -1;
       if (*listing) return -1;

       *stamp = CtdlIPCServerTime(ipc, cret);
       if (!*stamp)
              *stamp = time(NULL);
       ret = CtdlIPCGenericCommand(ipc, "RWHO", NULL, 0, listing, &bytes, cret);
       return ret;
}

Here is the call graph for this function:

Here is the caller graph for this function:

size_t CtdlIPCPartialRead ( CtdlIPC ipc,
void **  buf,
size_t  offset,
size_t  bytes,
char *  cret 
)

Definition at line 2227 of file citadel_ipc.c.

{
       register size_t len = 0;
       char aaa[SIZ];

       if (!buf) return 0;
       if (!cret) return 0;
       if (bytes < 1) return 0;

       CtdlIPC_lock(ipc);
       sprintf(aaa, "READ %d|%d", (int)offset, (int)bytes);
       CtdlIPC_putline(ipc, aaa);
       CtdlIPC_getline(ipc, aaa);
       if (aaa[0] != '6')
              strcpy(cret, &aaa[4]);
       else {
              len = extract_long(&aaa[4], 0);
              *buf = (void *)realloc(*buf, (size_t)(offset + len));
              if (*buf) {
                     /* I know what I'm doing */
                     serv_read(ipc, ((char *)(*buf) + offset), len);
              } else {
                     /* We have to read regardless */
                     serv_read(ipc, aaa, len);
                     len = 0;
              }
       }
       CtdlIPC_unlock(ipc);
       return len;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int CtdlIPCPostMessage ( CtdlIPC ipc,
int  flag,
int *  subject_required,
struct ctdlipcmessage mr,
char *  cret 
)

Definition at line 913 of file citadel_ipc.c.

{
       register int ret;
       char cmd[SIZ];
       char *ptr;

       if (!cret) return -2;
       if (!mr) return -2;

       if (mr->references) {
              for (ptr=mr->references; *ptr != 0; ++ptr) {
                     if (*ptr == '|') *ptr = '!';
              }
       }

       snprintf(cmd, sizeof cmd,
                     "ENT0 %d|%s|%d|%d|%s|%s||||||%s|", flag, mr->recipient,
                     mr->anonymous, mr->type, mr->subject, mr->author, mr->references);
       ret = CtdlIPCGenericCommand(ipc, cmd, mr->text, strlen(mr->text), NULL,
                     NULL, cret);
       if ((flag == 0) && (subject_required != NULL)) {
              /* Is the server strongly recommending that the user enter a message subject? */
              if ((cret[3] != '\0') && (cret[4] != '\0')) {
                     *subject_required = extract_int(&cret[4], 1);
              }

              
       }
       return ret;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int CtdlIPCQueryUsername ( CtdlIPC ipc,
const char *  username,
char *  cret 
)

Definition at line 1456 of file citadel_ipc.c.

{
       register int ret;
       char *aaa;

       if (!cret) return -2;
       if (!username) return -2;

       aaa = (char *)malloc(strlen(username) + 6);
       if (!aaa) return -1;

       sprintf(aaa, "QUSR %s", username);
       ret = CtdlIPCGenericCommand(ipc, aaa, NULL, 0, NULL, NULL, cret);
       free(aaa);
       return ret;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int CtdlIPCQuit ( CtdlIPC ipc)

Definition at line 133 of file citadel_ipc.c.

{
       register int ret = 221;            /* Default to successful quit */
       char aaa[SIZ]; 

       CtdlIPC_lock(ipc);
       if (ipc->sock > -1) {
              CtdlIPC_putline(ipc, "QUIT");
              CtdlIPC_getline(ipc, aaa);
              ret = atoi(aaa);
       }
#ifdef HAVE_OPENSSL
       if (ipc->ssl)
              SSL_shutdown(ipc->ssl);
       ipc->ssl = NULL;
#endif
       if (ipc->sock)
              shutdown(ipc->sock, 2);     /* Close connection; we're dead */
       ipc->sock = -1;
       CtdlIPC_unlock(ipc);
       return ret;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int CtdlIPCReadDirectory ( CtdlIPC ipc,
char **  listing,
char *  cret 
)

Definition at line 763 of file citadel_ipc.c.

{
       register int ret;
       size_t bytes;

       if (!cret) return -2;
       if (!listing) return -2;
       if (*listing) return -2;

       ret = CtdlIPCGenericCommand(ipc, "RDIR", NULL, 0, listing, &bytes, cret);
       return ret;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int CtdlIPCReadDownload ( CtdlIPC ipc,
void **  buf,
size_t  bytes,
size_t  resume,
void(*)(CtdlIPC *, unsigned long, unsigned long)  progress_gauge_callback,
char *  cret 
)

Definition at line 2287 of file citadel_ipc.c.

{
       register size_t len;

       if (!cret) return -1;
       if (!buf) return -1;
       if (*buf) return -1;
       if (!ipc->downloading) return -1;

       len = resume;
       if (progress_gauge_callback)
              progress_gauge_callback(ipc, len, bytes);
       while (len < bytes) {
              register size_t block;

              block = CtdlIPCPartialRead(ipc, buf, len, 4096, cret);
              if (block == 0) {
                     free(*buf);
                     return 0;
              }
              len += block;
              if (progress_gauge_callback)
                     progress_gauge_callback(ipc, len, bytes);
       }
       return len;
}

Here is the call graph for this function:

Here is the caller graph for this function:

char* CtdlIPCReadListing ( CtdlIPC ipc,
char *  dest 
)

Definition at line 2174 of file citadel_ipc.c.

{
       size_t length = 0;
       size_t linelength;
       char *ret = NULL;
       char aaa[SIZ];

       ret = dest;
       if (ret != NULL) {
              length = strlen(ret);
       } else {
              length = 0;
       }

       while (CtdlIPC_getline(ipc, aaa), strcmp(aaa, "000")) {
              linelength = strlen(aaa);
              ret = (char *)realloc(ret, (size_t)(length + linelength + 2));
              if (ret) {
                     strcpy(&ret[length], aaa);
                     length += linelength;
                     strcpy(&ret[length++], "\n");
              }
       }

       return(ret);
}

Here is the call graph for this function:

Here is the caller graph for this function:

int CtdlIPCRenameUser ( CtdlIPC ipc,
char *  oldname,
char *  newname,
char *  cret 
)

Definition at line 383 of file citadel_ipc.c.

{
       register int ret;
       char cmd[256];

       if (!oldname) return -2;
       if (!newname) return -2;
       if (!cret) return -2;

       snprintf(cmd, sizeof cmd, "RENU %s|%s", oldname, newname);
       ret = CtdlIPCGenericCommand(ipc, cmd, NULL, 0, NULL, NULL, cret);
       return ret;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int CtdlIPCRequestClientLogout ( CtdlIPC ipc,
int  session,
char *  cret 
)

Definition at line 2001 of file citadel_ipc.c.

{
       char aaa[64];

       if (!cret) return -2;
       if (session < 0) return -2;

       sprintf(aaa, "REQT %d", session);
       return CtdlIPCGenericCommand(ipc, aaa, NULL, 0, NULL, NULL, cret);
}

Here is the call graph for this function:

int CtdlIPCRoomInfo ( CtdlIPC ipc,
char **  iret,
char *  cret 
)

Definition at line 946 of file citadel_ipc.c.

{
       size_t bytes;

       if (!cret) return -2;
       if (!iret) return -2;
       if (*iret) return -2;

       return CtdlIPCGenericCommand(ipc, "RINF", NULL, 0, iret, &bytes, cret);
}

Here is the call graph for this function:

Here is the caller graph for this function:

int CtdlIPCSendInstantMessage ( CtdlIPC ipc,
const char *  username,
const char *  text,
char *  cret 
)

Definition at line 1565 of file citadel_ipc.c.

{
       register int ret;
       char *aaa;

       if (!cret) return -2;
       if (!username) return -2;

       aaa = (char *)malloc(strlen(username) + 8);
       if (!aaa) return -1;

       if (text) {
              sprintf(aaa, "SEXP %s|-", username);
              ret = CtdlIPCGenericCommand(ipc, aaa, text, strlen(text),
                            NULL, NULL, cret);
       } else {
              sprintf(aaa, "SEXP %s||", username);
              ret = CtdlIPCGenericCommand(ipc, aaa, NULL, 0, NULL, NULL, cret);
       }
       free(aaa);
       return ret;
}

Here is the call graph for this function:

int CtdlIPCSendListing ( CtdlIPC ipc,
const char *  listing 
)

Definition at line 2203 of file citadel_ipc.c.

{
       char *text;

       text = (char *)malloc(strlen(listing) + 6);
       if (text) {
              strcpy(text, listing);
              while (text[strlen(text) - 1] == '\n')
                     text[strlen(text) - 1] = '\0';
              strcat(text, "\n000");
              CtdlIPC_putline(ipc, text);
              free(text);
              text = NULL;
       } else {
              /* Malloc failed but we are committed to send */
              /* This may result in extra blanks at the bottom */
              CtdlIPC_putline(ipc, text);
              CtdlIPC_putline(ipc, "000");
       }
       return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int CtdlIPCServerInfo ( CtdlIPC ipc,
char *  cret 
)

Definition at line 692 of file citadel_ipc.c.

{
       register int ret;
       size_t bytes;
       char *listing = NULL;
       char buf[SIZ];

       if (!cret) return -2;

       ret = CtdlIPCGenericCommand(ipc, "INFO", NULL, 0, &listing, &bytes, cret);
       if (ret / 100 == 1) {
              int line = 0;

              while (*listing && strlen(listing)) {
                     extract_token(buf, listing, 0, '\n', sizeof buf);
                     remove_token(listing, 0, '\n');
                     switch (line++) {
                     case 0:              ipc->ServInfo.pid = atoi(buf);
                                   break;
                     case 1:              strcpy(ipc->ServInfo.nodename,buf);
                                   break;
                     case 2:              strcpy(ipc->ServInfo.humannode,buf);
                                   break;
                     case 3:              strcpy(ipc->ServInfo.fqdn,buf);
                                   break;
                     case 4:              strcpy(ipc->ServInfo.software,buf);
                                   break;
                     case 5:              ipc->ServInfo.rev_level = atoi(buf);
                                   break;
                     case 6:              strcpy(ipc->ServInfo.site_location,buf);
                                   break;
                     case 7:              strcpy(ipc->ServInfo.sysadm,buf);
                                   break;
                     case 9:              strcpy(ipc->ServInfo.moreprompt,buf);
                                   break;
                     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;
                     case 15:      ipc->ServInfo.newuser_disabled = atoi(buf);
                                   break;
                     case 16:      strcpy(ipc->ServInfo.default_cal_zone, buf);
                                   break;
                     case 17:      ipc->ServInfo.load_avg = atof(buf);
                                   break;
                     case 18:      ipc->ServInfo.worker_avg = atof(buf);
                                   break;
                     case 19:      ipc->ServInfo.thread_count = atoi(buf);
                                   break;
                     case 20:      ipc->ServInfo.has_sieve = atoi(buf);
                                   break;
                     case 21:      ipc->ServInfo.fulltext_enabled = atoi(buf);
                                   break;
                     case 22:      strcpy(ipc->ServInfo.svn_revision, buf);
                                   break;
                     case 24:      ipc->ServInfo.guest_logins = atoi(buf);
                                   break;
                     }
              }

       }
       if (listing) free(listing);
       return ret;
}

Here is the call graph for this function:

Here is the caller graph for this function:

time_t CtdlIPCServerTime ( CtdlIPC ipc,
char *  cret 
)

Definition at line 1787 of file citadel_ipc.c.

{
       register time_t tret;
       register int ret;

       ret = CtdlIPCGenericCommand(ipc, "TIME", NULL, 0, NULL, NULL, cret);
       if (ret / 100 == 2) {
              tret = extract_long(cret, 0);
       } else {
              tret = 0L;
       }
       return tret;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int CtdlIPCSetBio ( CtdlIPC ipc,
char *  bio,
char *  cret 
)

Definition at line 1617 of file citadel_ipc.c.

{
       if (!cret) return -2;
       if (!bio) return -2;

       return CtdlIPCGenericCommand(ipc, "EBIO", bio, strlen(bio),
                     NULL, NULL, cret);
}

Here is the call graph for this function:

int CtdlIPCSetConfig ( CtdlIPC ipc,
struct ctdluser uret,
char *  cret 
)

Definition at line 367 of file citadel_ipc.c.

{
       char aaa[48];

       if (!uret) return -2;
       if (!cret) return -2;

       sprintf(aaa,
              "SETU 80|24|%d",
              uret->flags
       );
       return CtdlIPCGenericCommand(ipc, aaa, NULL, 0, NULL, NULL, cret);
}

Here is the call graph for this function:

Here is the caller graph for this function:

int CtdlIPCSetLastRead ( CtdlIPC ipc,
long  msgnum,
char *  cret 
)

Definition at line 780 of file citadel_ipc.c.

{
       register int ret;
       char aaa[64];

       if (!cret) return -2;

       if (msgnum) {
              sprintf(aaa, "SLRP %ld", msgnum);
       }
       else {
              sprintf(aaa, "SLRP HIGHEST");
       }
       ret = CtdlIPCGenericCommand(ipc, aaa, NULL, 0, NULL, NULL, cret);
       return ret;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int CtdlIPCSetMessageExpirationPolicy ( CtdlIPC ipc,
int  which,
struct ExpirePolicy policy,
char *  cret 
)

Definition at line 1888 of file citadel_ipc.c.

{
       char aaa[38];
       char *whichvals[] = { "room", "floor", "site", "mailboxes" };

       if (!cret) return -2;
       if (which < 0 || which > 3) return -2;
       if (!policy) return -2;
       if (policy->expire_mode < 0 || policy->expire_mode > 3) return -2;
       if (policy->expire_mode >= 2 && policy->expire_value < 1) return -2;

       sprintf(aaa, "SPEX %s|%d|%d", whichvals[which],
                     policy->expire_mode, policy->expire_value);
       return CtdlIPCGenericCommand(ipc, aaa, NULL, 0, NULL, NULL, cret);
}

Here is the call graph for this function:

Here is the caller graph for this function:

int CtdlIPCSetMessageSeen ( CtdlIPC ipc,
long  msgnum,
int  seen,
char *  cret 
)

Definition at line 2014 of file citadel_ipc.c.

{
       char aaa[27];

       if (!cret) return -2;
       if (msgnum < 0) return -2;

       sprintf(aaa, "SEEN %ld|%d", msgnum, seen ? 1 : 0);
       return CtdlIPCGenericCommand(ipc, aaa, NULL, 0, NULL, NULL, cret);
}

Here is the call graph for this function:

int CtdlIPCSetRegistration ( CtdlIPC ipc,
const char *  info,
char *  cret 
)

Definition at line 1152 of file citadel_ipc.c.

{
       if (!cret) return -1;
       if (!info) return -1;

       return CtdlIPCGenericCommand(ipc, "REGI", info, strlen(info),
                     NULL, NULL, cret);
}

Here is the call graph for this function:

Here is the caller graph for this function:

int CtdlIPCSetRoomAide ( CtdlIPC ipc,
const char *  username,
char *  cret 
)

Definition at line 894 of file citadel_ipc.c.

{
       register int ret;
       char *aaa;

       if (!cret) return -2;
       if (!username) return -2;

       aaa = (char *)malloc(strlen(username) + 6);
       if (!aaa) return -1;

       sprintf(aaa, "SETA %s", username);
       ret = CtdlIPCGenericCommand(ipc, aaa, NULL, 0, NULL, NULL, cret);
       free(aaa);
       return ret;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int CtdlIPCSetRoomAttributes ( CtdlIPC ipc,
int  forget,
struct ctdlroom qret,
char *  cret 
)

Definition at line 862 of file citadel_ipc.c.

{
       register int ret;
       char *aaa;

       if (!cret) return -2;
       if (!qret) return -2;

       aaa = (char *)malloc(strlen(qret->QRname) + strlen(qret->QRpasswd) +
                     strlen(qret->QRdirname) + 64);
       if (!aaa) return -1;

       sprintf(aaa, "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);
       return ret;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int CtdlIPCSetRoomInfo ( CtdlIPC ipc,
int  for_real,
const char *  info,
char *  cret 
)

Definition at line 1118 of file citadel_ipc.c.

{
       char aaa[64];

       if (!cret) return -1;
       if (!info) return -1;

       sprintf(aaa, "EINF %d", for_real);
       return CtdlIPCGenericCommand(ipc, aaa, NULL, 0, NULL, NULL, cret);
}

Here is the call graph for this function:

int CtdlIPCSetRoomNetworkConfig ( CtdlIPC ipc,
const char *  listing,
char *  cret 
)

Definition at line 1990 of file citadel_ipc.c.

{
       if (!cret) return -2;
       if (!listing) return -2;

       return CtdlIPCGenericCommand(ipc, "SNET", listing, strlen(listing),
                     NULL, NULL, cret);
}

Here is the call graph for this function:

Here is the caller graph for this function:

int CtdlIPCSetSystemConfig ( CtdlIPC ipc,
const char *  listing,
char *  cret 
)

Definition at line 1921 of file citadel_ipc.c.

{
       if (!cret) return -2;
       if (!listing) return -2;

       return CtdlIPCGenericCommand(ipc, "CONF SET", listing, strlen(listing),
                     NULL, NULL, cret);
}

Here is the call graph for this function:

Here is the caller graph for this function:

int CtdlIPCSetSystemConfigByType ( CtdlIPC ipc,
const char *  mimetype,
const char *  listing,
char *  cret 
)

Definition at line 1955 of file citadel_ipc.c.

{
    register int ret;
       char *aaa;

       if (!cret) return -2;
       if (!mimetype) return -2;
       if (!listing) return -2;

       aaa = malloc(strlen(mimetype) + 13);
       if (!aaa) return -1;
       sprintf(aaa, "CONF PUTSYS|%s", mimetype);
       ret = CtdlIPCGenericCommand(ipc, aaa, listing, strlen(listing),
                     NULL, NULL, cret);
    free(aaa);
    return ret;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int CtdlIPCSpecifyPreferredFormats ( CtdlIPC ipc,
char *  cret,
char *  formats 
)

Definition at line 2275 of file citadel_ipc.c.

                                                                            {
       register int ret;
       char cmd[SIZ];
       
       snprintf(cmd, sizeof cmd, "MSGP %s", formats);
       ret = CtdlIPCGenericCommand(ipc, cmd, NULL, 0, NULL, NULL, cret);
       return ret;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int CtdlIPCStartEncryption ( CtdlIPC ipc,
char *  cret 
)

Definition at line 2027 of file citadel_ipc.c.

{
       int a;
       int r;
       char buf[SIZ];

#ifdef HAVE_OPENSSL
       SSL *temp_ssl;

       /* New SSL object */
       temp_ssl = SSL_new(ssl_ctx);
       if (!temp_ssl) {
              error_printf("SSL_new failed: %s\n",
                            ERR_reason_error_string(ERR_get_error()));
              return -2;
       }
       /* Pointless flag waving */
#if SSLEAY_VERSION_NUMBER >= 0x0922
       SSL_set_session_id_context(temp_ssl, (const unsigned char*) "Citadel SID", 14);
#endif

       if (!access(EGD_POOL, F_OK))
              RAND_egd(EGD_POOL);

       if (!RAND_status()) {
              error_printf("PRNG not properly seeded\n");
              return -2;
       }

       /* Associate network connection with SSL object */
       if (SSL_set_fd(temp_ssl, ipc->sock) < 1) {
              error_printf("SSL_set_fd failed: %s\n",
                            ERR_reason_error_string(ERR_get_error()));
              return -2;
       }

       if (status_hook != NULL)
              status_hook("Requesting encryption...\r");

       /* Ready to start SSL/TLS */
       /* Old code
       CtdlIPC_putline(ipc, "STLS");
       CtdlIPC_getline(ipc, buf);
       if (buf[0] != '2') {
              error_printf("Server can't start TLS: %s\n", buf);
              return 0;
       }
       */
       r = CtdlIPCGenericCommand(ipc,
                              "STLS", NULL, 0, NULL, NULL, cret);
       if (r / 100 != 2) {
              error_printf("Server can't start TLS: %s\n", buf);
              endtls(temp_ssl);
              return r;
       }

       /* Do SSL/TLS handshake */
       if ((a = SSL_connect(temp_ssl)) < 1) {
              error_printf("SSL_connect failed: %s\n",
                            ERR_reason_error_string(ERR_get_error()));
              endtls(temp_ssl);
              return -2;
       }
       ipc->ssl = temp_ssl;

       if (BIO_set_close(ipc->ssl->rbio, BIO_NOCLOSE))
       {
              int bits, alg_bits;

              bits = SSL_CIPHER_get_bits(SSL_get_current_cipher(ipc->ssl), &alg_bits);
              error_printf("Encrypting with %s cipher %s (%d of %d bits)\n",
                            SSL_CIPHER_get_version(SSL_get_current_cipher(ipc->ssl)),
                            SSL_CIPHER_get_name(SSL_get_current_cipher(ipc->ssl)),
                            bits, alg_bits);
       }
       return r;
#else
       return 0;
#endif /* HAVE_OPENSSL */
}

Here is the call graph for this function:

Here is the caller graph for this function:

int CtdlIPCStealthMode ( CtdlIPC ipc,
int  mode,
char *  cret 
)

Definition at line 1663 of file citadel_ipc.c.

{
       char aaa[64];

       if (!cret) return -1;

       sprintf(aaa, "STEL %d", mode ? 1 : 0);
       return CtdlIPCGenericCommand(ipc, aaa, NULL, 0, NULL, NULL, cret);
}

Here is the call graph for this function:

Here is the caller graph for this function:

int CtdlIPCSystemMessage ( CtdlIPC ipc,
const char *  message,
char **  mret,
char *  cret 
)

Definition at line 1040 of file citadel_ipc.c.

{
       register int ret;
       char *aaa;
       size_t bytes;

       if (!cret) return -2;
       if (!mret) return -2;
       if (*mret) return -2;
       if (!message) return -2;

       aaa = (char *)malloc(strlen(message) + 6);
       if (!aaa) return -1;

       sprintf(aaa, "MESG %s", message);
       ret = CtdlIPCGenericCommand(ipc, aaa, NULL, 0, mret, &bytes, cret);
       free(aaa);
       return ret;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int CtdlIPCTerminateServerNow ( CtdlIPC ipc,
char *  cret 
)

Definition at line 1687 of file citadel_ipc.c.

{
       if (!cret) return -1;

       return CtdlIPCGenericCommand(ipc, "DOWN", NULL, 0, NULL, NULL, cret);
}

Here is the call graph for this function:

Here is the caller graph for this function:

int CtdlIPCTerminateServerScheduled ( CtdlIPC ipc,
int  mode,
char *  cret 
)

Definition at line 1696 of file citadel_ipc.c.

{
       char aaa[16];

       if (!cret) return -1;

       sprintf(aaa, "SCDN %d", mode ? 1 : 0);
       return CtdlIPCGenericCommand(ipc, aaa, NULL, 0, NULL, NULL, cret);
}

Here is the call graph for this function:

Here is the caller graph for this function:

int CtdlIPCTerminateSession ( CtdlIPC ipc,
int  sid,
char *  cret 
)

Definition at line 1675 of file citadel_ipc.c.

{
       char aaa[64];

       if (!cret) return -1;

       sprintf(aaa, "TERM %d", sid);
       return CtdlIPCGenericCommand(ipc, aaa, NULL, 0, NULL, NULL, cret);
}

Here is the call graph for this function:

int CtdlIPCTryApopPassword ( CtdlIPC ipc,
const char *  response,
char *  cret 
)

Definition at line 224 of file citadel_ipc.c.

{
       register 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;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int CtdlIPCTryLogin ( CtdlIPC ipc,
const char *  username,
char *  cret 
)

Definition at line 180 of file citadel_ipc.c.

{
       register int ret;
       char *aaa;

       if (!username) return -2;
       if (!cret) return -2;

       aaa = (char *)malloc((size_t)(strlen(username) + 6));
       if (!aaa) return -1;

       sprintf(aaa, "USER %s", username);
       ret = CtdlIPCGenericCommand(ipc, aaa, NULL, 0, NULL, NULL, cret);
       free(aaa);
       return ret;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int CtdlIPCTryPassword ( CtdlIPC ipc,
const char *  passwd,
char *  cret 
)

Definition at line 202 of file citadel_ipc.c.

{
       register int ret;
       char *aaa;

       if (!passwd) return -2;
       if (!cret) return -2;

       aaa = (char *)malloc((size_t)(strlen(passwd) + 6));
       if (!aaa) return -1;

       sprintf(aaa, "PASS %s", passwd);
       ret = CtdlIPCGenericCommand(ipc, aaa, NULL, 0, NULL, NULL, cret);
       free(aaa);
       return ret;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int CtdlIPCUserListing ( CtdlIPC ipc,
char *  searchstring,
char **  listing,
char *  cret 
)

Definition at line 1131 of file citadel_ipc.c.

{
       size_t bytes;
       char *cmd;
       int ret;

       if (!cret) return -1;
       if (!listing) return -1;
       if (*listing) return -1;
       if (!searchstring) return -1;

       cmd = malloc(strlen(searchstring) + 10);
       sprintf(cmd, "LIST %s", searchstring);

       ret = CtdlIPCGenericCommand(ipc, cmd, NULL, 0, listing, &bytes, cret);
       free(cmd);
       return(ret);
}

Here is the call graph for this function:

Here is the caller graph for this function:

int CtdlIPCValidateUser ( CtdlIPC ipc,
const char *  username,
int  axlevel,
char *  cret 
)

Definition at line 1098 of file citadel_ipc.c.

{
       register int ret;
       char *aaa;

       if (!cret) return -2;
       if (!username) return -2;
       if (axlevel < AxDeleted || axlevel > AxAideU) return -2;

       aaa = (char *)malloc(strlen(username) + 17);
       if (!aaa) return -1;

       sprintf(aaa, "VALI %s|%d", username, axlevel);
       ret = CtdlIPCGenericCommand(ipc, aaa, NULL, 0, NULL, NULL, cret);
       free(aaa);
       return ret;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int CtdlIPCWhoKnowsRoom ( CtdlIPC ipc,
char **  listing,
char *  cret 
)

Definition at line 677 of file citadel_ipc.c.

{
       register int ret;
       size_t bytes;

       if (!cret) return -2;
       if (!listing) return -2;
       if (*listing) return -2;

       ret = CtdlIPCGenericCommand(ipc, "WHOK", NULL, 0, listing, &bytes, cret);
       return ret;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int CtdlIPCWriteUpload ( CtdlIPC ipc,
FILE *  uploadFP,
void(*)(CtdlIPC *, unsigned long, unsigned long)  progress_gauge_callback,
char *  cret 
)

Definition at line 2387 of file citadel_ipc.c.

{
       register int ret = -1;
       register size_t offset = 0;
       size_t bytes;
       char aaa[SIZ];
       char buf[4096];
       FILE *fd = uploadFP;
       int ferr;

       if (!cret) return -1;

       fseek(fd, 0L, SEEK_END);
       bytes = ftell(fd);
       rewind(fd);

       if (progress_gauge_callback)
              progress_gauge_callback(ipc, 0, bytes);

       while (offset < bytes) {
              register size_t to_write;

              /* Read some data in */
              to_write = fread(buf, 1, 4096, fd);
              if (!to_write) {
                     if (feof(fd) || ferror(fd)) break;
              }
              sprintf(aaa, "WRIT %d", (int)to_write);
              CtdlIPC_putline(ipc, aaa);
              CtdlIPC_getline(ipc, aaa);
              strcpy(cret, &aaa[4]);
              ret = atoi(aaa);
              if (aaa[0] == '7') {
                     to_write = extract_long(&aaa[4], 0);
                     
                     serv_write(ipc, buf, to_write);
                     offset += to_write;
                     if (progress_gauge_callback)
                            progress_gauge_callback(ipc, offset, bytes);
                     /* Detect short reads and back up if needed */
                     /* offset will never be negative anyway */
                     fseek(fd, (signed)offset, SEEK_SET);
              } else {
                     break;
              }
       }
       if (progress_gauge_callback)
              progress_gauge_callback(ipc, 1, 1);
       ferr = ferror(fd);
       fclose(fd);
       return (!ferr ? ret : -2);
}

Here is the call graph for this function:

Here is the caller graph for this function:

int ReadNetworkChunk ( CtdlIPC ipc)

Definition at line 2933 of file citadel_ipc.c.

{
       fd_set read_fd;
/*     int tries;*/
       int ret = 0;
       int err = 0;
       struct timeval tv;
       size_t n;

       tv.tv_sec = 1;
       tv.tv_usec = 1000;
       /*tries = 0; */
       n = 0;
       while (1)
       {
              errno=0;
              FD_ZERO(&read_fd);
              FD_SET(ipc->sock, &read_fd);
              ret = select(ipc->sock+1, &read_fd, NULL, NULL,  &tv);
              
//            fprintf(stderr, "\nselect failed: %d %d %s\n", ret,  err, strerror(err));
              
              if (ret > 0) {
                     
                     *(ipc->BufPtr) = '\0';
//                   n = read(ipc->sock, ipc->BufPtr, ipc->BufSize  - (ipc->BufPtr - ipc->Buf) - 1);
                     n = recv(ipc->sock, ipc->BufPtr, ipc->BufSize  - (ipc->BufPtr - ipc->Buf) - 1, 0);
                     if (n > 0) {
                            ipc->BufPtr[n]='\0';
                            ipc->BufUsed += n;
                            return n;
                     }
                     else 
                            return n;
              }
              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;
                     }
                     }*/
       }
}

Here is the call graph for this function:

static void serv_read ( CtdlIPC ipc,
char *  buf,
unsigned int  bytes 
) [static]

Definition at line 2693 of file citadel_ipc.c.

{
       unsigned int len, rlen;

#if defined(HAVE_OPENSSL)
       if (ipc->ssl) {
              serv_read_ssl(ipc, buf, bytes);
              return;
       }
#endif
       len = 0;
       while (len < bytes) {
              rlen = read(ipc->sock, &buf[len], bytes - len);
              if (rlen < 1) {
                     connection_died(ipc, 0);
                     return;
              }
              len += rlen;
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void serv_write ( CtdlIPC ipc,
const char *  buf,
unsigned int  nbytes 
) [static]

Definition at line 2718 of file citadel_ipc.c.

{
       unsigned int bytes_written = 0;
       int retval;

#if defined(HAVE_OPENSSL)
       if (ipc->ssl) {
              serv_write_ssl(ipc, buf, nbytes);
              return;
       }
#endif
       while (bytes_written < nbytes) {
              retval = write(ipc->sock, &buf[bytes_written],
                            nbytes - bytes_written);
              if (retval < 1) {
                     connection_died(ipc, 0);
                     return;
              }
              bytes_written += retval;
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void setCryptoStatusHook ( void(*)(char *s)  hook)

Definition at line 67 of file citadel_ipc.c.

                                                {
       status_hook = hook;
}

Here is the caller graph for this function:

const char* svn_revision ( void  )

Definition at line 10 of file svn_revision.c.

{
       const char *SVN_Version = "452067d";
       return SVN_Version;
}

Here is the caller graph for this function:

static int tcp_connectsock ( char *  host,
char *  service 
) [static]

Definition at line 2596 of file citadel_ipc.c.

{
       struct in6_addr serveraddr;
       struct addrinfo hints;
       struct addrinfo *res = NULL;
       struct addrinfo *ai = NULL;
       int rc = (-1);
       int sock = (-1);

       if ((host == NULL) || IsEmptyStr(host)) {
              service = DEFAULT_HOST ;
       }
       if ((service == NULL) || IsEmptyStr(service)) {
              service = DEFAULT_PORT ;
       }

       memset(&hints, 0x00, sizeof(hints));
       hints.ai_flags = AI_NUMERICSERV;
       hints.ai_family = AF_UNSPEC;
       hints.ai_socktype = SOCK_STREAM;

       /*
        * Handle numeric IPv4 and IPv6 addresses
        */
       rc = inet_pton(AF_INET, host, &serveraddr);
       if (rc == 1) {                                          /* dotted quad */
              hints.ai_family = AF_INET;
              hints.ai_flags |= AI_NUMERICHOST;
       }
       else {
              rc = inet_pton(AF_INET6, host, &serveraddr);
              if (rc == 1) {                                   /* IPv6 address */
                     hints.ai_family = AF_INET6;
                     hints.ai_flags |= AI_NUMERICHOST;
              }
       }

       /* Begin the connection process */

       rc = getaddrinfo(host, service, &hints, &res);
       if (rc != 0) {
              return(-1);
       }

       /*
        * Try all available addresses until we connect to one or until we run out.
        */
       for (ai = res; ai != NULL; ai = ai->ai_next) {
              sock = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol);
              if (sock < 0) return(-1);

              rc = connect(sock, ai->ai_addr, ai->ai_addrlen);
              if (rc >= 0) {
                     return(sock);        /* Connected! */
              }
              else {
                     close(sock);         /* Failed.  Close the socket to avoid fd leak! */
              }
       }

       return(-1);
}

Here is the caller graph for this function:

static int uds_connectsock ( int *  isLocal,
char *  sockpath 
) [static]

Definition at line 2666 of file citadel_ipc.c.

{
       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);

       s = socket(AF_UNIX, SOCK_STREAM, 0);
       if (s < 0) {
              return -1;
       }

       if (connect(s, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
              close(s);
              return -1;
       }

       *isLocal = 1;
       return s;
}

Here is the caller graph for this function:


Variable Documentation

char instant_msgs = 0

Definition at line 76 of file citadel_ipc.c.

void(* status_hook)(char *s) = NULL [static]

Definition at line 65 of file citadel_ipc.c.