]> code.citadel.org Git - citadel.git/blobdiff - citadel/citadel_ipc.c
* Applied a patch sent in by Wilfried Goesgens which allows the various
[citadel.git] / citadel / citadel_ipc.c
index bfcc416d5332de65c8c7aadd05acb62e38581a8b..e519e870798ad77911d4efa9daf2394f0eda8944 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,7 +294,7 @@ 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;
 
@@ -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;
@@ -471,7 +471,7 @@ 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[128];
 
@@ -483,7 +483,7 @@ 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" */
@@ -579,6 +579,15 @@ int CtdlIPCGetSingleMessage(CtdlIPC *ipc, long msgnum, int headers, int as_mime,
                                                strcpy(mret[0]->content_type,
                                                        &mret[0]->content_type[14]);
                                                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, ";"), "");
+                                               }
+
                                        }
                                        remove_token(bbb, 0, '\n');
                                } while ((bbb[0] != 0) && (bbb[0] != '\n'));
@@ -645,7 +654,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;
@@ -1021,15 +1030,23 @@ int CtdlIPCSetRoomInfo(CtdlIPC *ipc, int for_real, const char *info, char *cret)
 
 
 /* LIST */
-int CtdlIPCUserListing(CtdlIPC *ipc, char **listing, char *cret)
+int CtdlIPCUserListing(CtdlIPC *ipc, char *searchstring, char **listing, char *cret)
 {
        size_t bytes;
+       char *cmd;
+       int ret;
 
        if (!cret) return -1;
        if (!listing) return -1;
        if (*listing) return -1;
+       if (!searchstring) return -1;
 
-       return CtdlIPCGenericCommand(ipc, "LIST", NULL, 0, listing, &bytes, cret);
+       cmd = malloc(strlen(searchstring) + 10);
+       sprintf(cmd, "LIST %s", searchstring);
+
+       ret = CtdlIPCGenericCommand(ipc, cmd, NULL, 0, listing, &bytes, cret);
+       free(cmd);
+       return(ret);
 }
 
 
@@ -1914,8 +1931,8 @@ int CtdlIPCStartEncryption(CtdlIPC *ipc, char *cret)
        SSL_set_session_id_context(temp_ssl, "Citadel SID", 14);
 #endif
 
-       if (!access("/var/run/egd-pool", F_OK))
-               RAND_egd("/var/run/egd-pool");
+       if (!access(EGD_POOL, F_OK))
+               RAND_egd(EGD_POOL);
 
        if (!RAND_status()) {
                error_printf("PRNG not properly seeded\n");
@@ -2924,11 +2941,22 @@ 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");
+#ifndef HAVE_RUN_DIR
+                                        CTDLDIR
+#else
+                                        RUN_DIR
+#endif
+                                        , "/citadel.socket");
                }
                else {
                        snprintf(sockpath, sizeof sockpath, "%s%s",
-                               citport, "/citadel.socket");
+                               citport, 
+#ifndef HAVE_RUN_DIR
+                                        CTDLDIR
+#else
+                                        RUN_DIR
+#endif
+                                        "/citadel.socket");
                }
                ipc->sock = uds_connectsock(&(ipc->isLocal), sockpath);
                if (ipc->sock == -1) {