]> code.citadel.org Git - citadel.git/blobdiff - citadel/citadel_ipc.c
* Variable names, comments, documentation, etc... removed the acronym 'BBS'
[citadel.git] / citadel / citadel_ipc.c
index d0d68b6fbd5714ebd297ed64497d1be6f6f01ef2..3a72ac180db1e815b73577264c5cb3ba89fea934 100644 (file)
@@ -285,7 +285,7 @@ int CtdlIPCKnownRooms(CtdlIPC *ipc, enum RoomList which, int floor, struct march
                {"LKRA", "LKRN", "LKRO", "LZRM", "LRMS", "LPRM" };
        char aaa[SIZ];
        char *bbb = NULL;
-       size_t bbbsize;
+       size_t bbb_len;
 
        if (!listing) return -2;
        if (*listing) return -2;        /* Free the listing first */
@@ -294,20 +294,20 @@ int CtdlIPCKnownRooms(CtdlIPC *ipc, enum RoomList which, int floor, struct march
        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, &bbbsize, cret);
+       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');
+                       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(mptr->march_name, aaa, 0);
+                               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);
@@ -396,7 +396,7 @@ int CtdlIPCGotoRoom(CtdlIPC *ipc, const char *room, const char *passwd,
        }
        ret = CtdlIPCGenericCommand(ipc, aaa, NULL, 0, NULL, NULL, cret);
        if (ret / 100 == 2) {
-               extract(rret[0]->RRname, cret, 0);
+               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);
@@ -426,7 +426,7 @@ int CtdlIPCGetMessages(CtdlIPC *ipc, enum MessageList which, int whicharg,
                { "ALL", "OLD", "NEW", "LAST", "FIRST", "GT", "LT" };
        char aaa[33];
        char *bbb = NULL;
-       size_t bbbsize;
+       size_t bbb_len;
 
        if (!cret) return -2;
        if (!mret) return -2;
@@ -440,7 +440,7 @@ int CtdlIPCGetMessages(CtdlIPC *ipc, enum MessageList which, int whicharg,
                sprintf(aaa, "MSGS %s|%d|%d", proto[which], whicharg,
                                (mtemplate) ? 1 : 0);
        if (mtemplate) count = strlen(mtemplate);
-       ret = CtdlIPCGenericCommand(ipc, aaa, mtemplate, count, &bbb, &bbbsize, cret);
+       ret = CtdlIPCGenericCommand(ipc, aaa, mtemplate, count, &bbb, &bbb_len, cret);
        if (ret / 100 != 1)
                return ret;
        count = 0;
@@ -448,7 +448,7 @@ int CtdlIPCGetMessages(CtdlIPC *ipc, enum MessageList which, int whicharg,
        if (!*mret)
                return -1;
        while (bbb && strlen(bbb)) {
-               extract_token(aaa, bbb, 0, '\n');
+               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)));
@@ -471,9 +471,9 @@ int CtdlIPCGetSingleMessage(CtdlIPC *ipc, long msgnum, int headers, int as_mime,
        register int ret;
        char aaa[SIZ];
        char *bbb = NULL;
-       size_t bbbsize;
+       size_t bbb_len;
        int multipart_hunting = 0;
-       char multipart_prefix[SIZ];
+       char multipart_prefix[128];
 
        if (!cret) return -1;
        if (!mret) return -1;
@@ -483,12 +483,12 @@ int CtdlIPCGetSingleMessage(CtdlIPC *ipc, long msgnum, int headers, int as_mime,
 
        strcpy(mret[0]->content_type, "");
        sprintf(aaa, "MSG%d %ld|%d", as_mime, msgnum, headers);
-       ret = CtdlIPCGenericCommand(ipc, aaa, NULL, 0, &bbb, &bbbsize, cret);
+       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');
+                               extract_token(aaa, bbb, 0, '\n', sizeof aaa);
                                remove_token(bbb, 0, '\n');
 
                                if (!strncasecmp(aaa, "nhdr=yes", 8))
@@ -518,14 +518,14 @@ int CtdlIPCGetSingleMessage(CtdlIPC *ipc, long msgnum, int headers, int as_mime,
                                 * us to determine which part we want to download.
                                 */
                                else if (!strncasecmp(aaa, "pref=", 5)) {
-                                       extract(multipart_prefix, &aaa[5], 1);
+                                       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(multipart_prefix, &aaa[5], 1);
+                                       extract_token(multipart_prefix, &aaa[5], 1, '|', sizeof multipart_prefix);
                                        if (!strcasecmp(multipart_prefix,
                                           "multipart/alternative")) {
                                                ++multipart_hunting;
@@ -539,11 +539,11 @@ int CtdlIPCGetSingleMessage(CtdlIPC *ipc, long msgnum, int headers, int as_mime,
                                        if (ptr) {
 
                                                /* Fill the buffers for the caller */
-                                               extract(ptr->name, &aaa[5], 0);
-                                               extract(ptr->filename, &aaa[5], 1);
-                                               extract(ptr->number, &aaa[5], 2);
-                                               extract(ptr->disposition, &aaa[5], 3);
-                                               extract(ptr->mimetype, &aaa[5], 4);
+                                               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;
@@ -575,7 +575,7 @@ int CtdlIPCGetSingleMessage(CtdlIPC *ipc, long msgnum, int headers, int as_mime,
                        if (as_mime == 4) {
                                do {
                                        if (!strncasecmp(bbb, "Content-type: ", 14)) {
-                                               extract_token(mret[0]->content_type, bbb, 0, '\n');
+                                               extract_token(mret[0]->content_type, bbb, 0, '\n', sizeof mret[0]->content_type);
                                                strcpy(mret[0]->content_type,
                                                        &mret[0]->content_type[14]);
                                                striplt(mret[0]->content_type);
@@ -630,7 +630,7 @@ int CtdlIPCServerInfo(CtdlIPC *ipc, char *cret)
                int line = 0;
 
                while (*listing && strlen(listing)) {
-                       extract_token(buf, listing, 0, '\n');
+                       extract_token(buf, listing, 0, '\n', sizeof buf);
                        remove_token(listing, 0, '\n');
                        switch (line++) {
                        case 0:         ipc->ServInfo.pid = atoi(buf);
@@ -645,7 +645,7 @@ int CtdlIPCServerInfo(CtdlIPC *ipc, char *cret)
                                        break;
                        case 5:         ipc->ServInfo.rev_level = atoi(buf);
                                        break;
-                       case 6:         strcpy(ipc->ServInfo.bbs_city,buf);
+                       case 6:         strcpy(ipc->ServInfo.site_location,buf);
                                        break;
                        case 7:         strcpy(ipc->ServInfo.sysadm,buf);
                                        break;
@@ -752,9 +752,9 @@ int CtdlIPCGetRoomAttributes(CtdlIPC *ipc, struct ctdlroom **qret, char *cret)
 
        ret = CtdlIPCGenericCommand(ipc, "GETR", NULL, 0, NULL, NULL, cret);
        if (ret / 100 == 2) {
-               extract(qret[0]->QRname, cret, 0);
-               extract(qret[0]->QRpasswd, cret, 1);
-               extract(qret[0]->QRdirname, cret, 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);
@@ -1168,7 +1168,7 @@ int CtdlIPCFileDownload(CtdlIPC *ipc, const char *filename, void **buf,
                ipc->downloading = 1;
                bytes = extract_long(cret, 0);
                last_mod = extract_int(cret, 1);
-               extract(mimetype, cret, 2);
+               extract_token(mimetype, cret, 2, '|', sizeof mimetype);
 
                ret = CtdlIPCReadDownload(ipc, buf, bytes, resume,
                                        progress_gauge_callback, cret);
@@ -1213,8 +1213,8 @@ int CtdlIPCAttachmentDownload(CtdlIPC *ipc, long msgnum, const char *part,
                ipc->downloading = 1;
                bytes = extract_long(cret, 0);
                last_mod = extract_int(cret, 1);
-               extract(filename, cret, 2);
-               extract(mimetype, cret, 3);
+               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);
@@ -1254,7 +1254,7 @@ int CtdlIPCImageDownload(CtdlIPC *ipc, const char *filename, void **buf,
                ipc->downloading = 1;
                bytes = extract_long(cret, 0);
                last_mod = extract_int(cret, 1);
-               extract(mimetype, cret, 2);
+               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);
@@ -1694,8 +1694,8 @@ int CtdlIPCAideGetUserParameters(CtdlIPC *ipc, const char *who,
        ret = CtdlIPCGenericCommand(ipc, aaa, NULL, 0, NULL, NULL, cret);
 
        if (ret / 100 == 2) {
-               extract(uret[0]->fullname, cret, 0);
-               extract(uret[0]->password, cret, 1);
+               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);
@@ -2826,7 +2826,7 @@ static void CtdlIPC_getline(CtdlIPC* ipc, char *buf)
 
 void CtdlIPC_chat_recv(CtdlIPC* ipc, char* buf)
 {
-       return CtdlIPC_getline(ipc, buf);
+       CtdlIPC_getline(ipc, buf);
 }
 
 /*
@@ -2856,7 +2856,7 @@ static void CtdlIPC_putline(CtdlIPC *ipc, const char *buf)
 
 void CtdlIPC_chat_send(CtdlIPC* ipc, const char* buf)
 {
-       return CtdlIPC_putline(ipc, buf);
+       CtdlIPC_putline(ipc, buf);
 }
 
 
@@ -2924,7 +2924,7 @@ CtdlIPC* CtdlIPC_new(int argc, char **argv, char *hostbuf, char *portbuf)
        if (!strcmp(cithost, UDS)) {
                if (!strcasecmp(citport, DEFAULT_PORT)) {
                        snprintf(sockpath, sizeof sockpath, "%s%s",
-                               BBSDIR, "/citadel.socket");
+                               CTDLDIR, "/citadel.socket");
                }
                else {
                        snprintf(sockpath, sizeof sockpath, "%s%s",