Merge branch 'stable-78x' of ssh://git.citadel.org/appl/gitroot/citadel into stable-78x
authorWilfried Goesgens <dothebart@citadel.org>
Wed, 29 Jun 2011 22:48:54 +0000 (22:48 +0000)
committerWilfried Goesgens <dothebart@citadel.org>
Wed, 29 Jun 2011 22:48:54 +0000 (22:48 +0000)
30 files changed:
citadel/clientsocket.c
citadel/internet_addressing.c
citadel/modules/xmpp/serv_xmpp.c
citadel/modules/xmpp/xmpp_presence.c
libcitadel/lib/stringbuf.c
webcit/auth.c
webcit/calendar.c
webcit/calendar_view.c
webcit/context_loop.c
webcit/crypto.c
webcit/event.c
webcit/gettext.c
webcit/html2html.c
webcit/marchlist.c
webcit/messages.c
webcit/netconf.c
webcit/notes.c
webcit/preferences.c
webcit/pushemail.c
webcit/roomops.c
webcit/serv_func.c
webcit/static.c
webcit/subst.c
webcit/subst.h
webcit/sysdep.c
webcit/tasks.c
webcit/tcp_sockets.c
webcit/useredit.c
webcit/webcit.c
webcit/webserver.c

index 572f28f17c1293d324b732e51b11261fbda33a28..3bc58a4f7cdf0c6afd2660d501122a01a304edcc 100644 (file)
@@ -30,6 +30,7 @@
 #include <sys/time.h>
 #include <sys/socket.h>
 #include <netinet/in.h>
+#include <sys/un.h>
 #include <arpa/inet.h>
 #include <netdb.h>
 #include <string.h>
 #define INADDR_NONE 0xffffffff
 #endif
 
+
+int uds_sock_connect(char *sockpath)
+{
+       struct sockaddr_un addr;
+       int s;
+
+       memset(&addr, 0, sizeof(addr));
+       addr.sun_family = AF_UNIX;
+       safestrncpy(addr.sun_path, sockpath, sizeof addr.sun_path);
+
+       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);
+       }
+
+       return s;
+}
+
+
 int sock_connect(char *host, char *service, char *protocol)
 {
        struct hostent *phe;
@@ -63,6 +88,11 @@ int sock_connect(char *host, char *service, char *protocol)
 
        if ((host == NULL) || IsEmptyStr(host)) 
                return(-1);
+
+       if (host[0] == '/') {
+               return uds_sock_connect(host);
+       }
+
        if ((service == NULL) || IsEmptyStr(service)) 
                return(-1);
        if ((protocol == NULL) || IsEmptyStr(protocol)) 
index 5f19a9a56cb6e7d3e19d5fb9f1f3db0dbd7dc499..b4815ccbc269c145f5a1ac5b9cf1edbc7acad6fd 100644 (file)
@@ -389,9 +389,10 @@ void unfold_rfc822_field(char **field, char **FieldEnd)
             pField++, sField++)
        {
                if ((*sField=='\r') || (*sField=='\n')) {
-                       while (isspace(*sField))
-                               sField++;
-                       *pField = *sField;
+                   sField++;
+                   if  (*sField == '\n')
+                       sField++;
+                   *pField = *sField;
                }
                else {
                        if (*sField=='\"') quote = 1 - quote;
index e958771d4815eb23acf71a13c2b48dff48ac7d52..b84634eb2e360c9bde01f74d750a3da3336aef34 100644 (file)
@@ -74,7 +74,7 @@ static void xmpp_entity_declaration(void *userData, const XML_Char *entityName,
                                const XML_Char *systemId, const XML_Char *publicId,
                                const XML_Char *notationName
 ) {
-       syslog(LOG_WARNING, "Illegal entity declaration encountered; stopping parser.");
+       syslog(CTDL_WARNING, "Illegal entity declaration encountered; stopping parser.");
        XML_StopParser(XMPP->xp, XML_FALSE);
 }
 #endif
index 2866daa97c1a432440dd0c31eb18e17abf26c614..31e798b53697503d4c66ddbdbab1db91bcd40519 100644 (file)
@@ -121,7 +121,7 @@ void xmpp_wholist_presence_dump(void)
  * Function to remove a buddy subscription and delete from the roster
  * (used in several places)
  */
-void xmpp_destroy_buddy(char *presence_jid) {
+void xmpp_destroy_buddy(char *presence_jid, int aggressively) {
        static int unsolicited_id = 1;
        char xmlbuf1[256];
        char xmlbuf2[256];
@@ -135,10 +135,20 @@ void xmpp_destroy_buddy(char *presence_jid) {
                xmlesc(xmlbuf1, presence_jid, sizeof xmlbuf1),
                xmlesc(xmlbuf2, XMPP->client_jid, sizeof xmlbuf2)
        );
-       cprintf("<presence type=\"unsubscribed\" from=\"%s\" to=\"%s\"></presence>",
-               xmlesc(xmlbuf1, presence_jid, sizeof xmlbuf1),
-               xmlesc(xmlbuf2, XMPP->client_jid, sizeof xmlbuf2)
-       );
+
+       /*
+        * Setting the "aggressively" flag also sends an "unsubscribed" presence update.
+        * We only ask for this when flushing the client side roster, because if we do it
+        * in the middle of a session when another user logs off, some clients (Jitsi) interpret
+        * it as a rejection of a subscription request.
+        */
+       if (aggressively) {
+               cprintf("<presence type=\"unsubscribed\" from=\"%s\" to=\"%s\"></presence>",
+                       xmlesc(xmlbuf1, presence_jid, sizeof xmlbuf1),
+                       xmlesc(xmlbuf2, XMPP->client_jid, sizeof xmlbuf2)
+               );
+       }
+
        // FIXME ... we should implement xmpp_indicate_nonpresence so we can use it elsewhere
 
        /* Do an unsolicited roster update that deletes the contact. */
@@ -208,7 +218,7 @@ void xmpp_presence_notify(char *presence_jid, int event_type) {
        if (visible_sessions == 0) {
                CtdlLogPrintf(CTDL_DEBUG, "Telling session %d that <%s> logged out\n",
                        CC->cs_pid, presence_jid);
-               xmpp_destroy_buddy(presence_jid);
+               xmpp_destroy_buddy(presence_jid, 0);    /* non aggressive presence update */
        }
 
        free(cptr);
@@ -393,7 +403,7 @@ void xmpp_delete_old_buddies_who_no_longer_exist_from_the_client_roster(void)
                }
 
                if (!online_now) {
-                       xmpp_destroy_buddy((char *)Value);
+                       xmpp_destroy_buddy((char *)Value, 1);   /* aggressive presence update */
                }
 
        }
index 1408669b0bf90810e78a1ac819f95fa60526e7ba..7a841df8f255fcdbfd5c20348639aa2387348a18 100644 (file)
@@ -2153,20 +2153,20 @@ long StrHtmlEcmaEscAppend(StrBuf *Target, const StrBuf *Source, const char *Plai
                        if (((unsigned char)*aptr) >= 0x20)
                        {
                                IsUtf8Sequence =  Ctdl_GetUtf8SequenceLength(aptr, eiptr);
-                               
+
                                *bptr = *aptr;
                                Target->BufUsed ++;
-                               while (IsUtf8Sequence > 1){
-                                       if(bptr + IsUtf8Sequence >= eptr) {
-                                               IncreaseBuf(Target, 1, -1);
-                                               eptr = Target->buf + Target->BufSize - 11; /* our biggest unit to put in...  */
-                                               bptr = Target->buf + Target->BufUsed - 1;
-                                       }
+                               if (IsUtf8Sequence > 1) while (IsUtf8Sequence > 0){
+                                               if(bptr + IsUtf8Sequence >= eptr) {
+                                                       IncreaseBuf(Target, 1, -1);
+                                                       eptr = Target->buf + Target->BufSize - 11; /* our biggest unit to put in...  */
+                                                       bptr = Target->buf + Target->BufUsed - 1;
+                                               }
                                        bptr++; aptr++;
-                                       IsUtf8Sequence --;
-                                       *bptr = *aptr;
-                                       Target->BufUsed ++;
-                               }
+                                               IsUtf8Sequence --;
+                                               *bptr = *aptr;
+                                               Target->BufUsed ++;
+                                       }
                                bptr++;
                        }
 
index d37382f224d8a22c144114e7a5a19a6dff3e35dd..fde5a501b1d6e8d06f4a79dfdbde5511b6133c6c 100644 (file)
@@ -681,7 +681,7 @@ void validate(void)
                                int haveChar = 0;
                                int haveNum = 0;
                                int haveOther = 0;
-                               int count = 0;
+                               int haveLong = 0;
                                pch = buf;
                                while (!IsEmptyStr(pch))
                                {
@@ -693,10 +693,13 @@ void validate(void)
                                                haveOther = 1;
                                        pch ++;
                                }
-                               count = pch - buf;
-                               if (count > 7)
-                                       count = 0;
-                               switch (count){
+                               if (pch - buf > 7)
+                                       haveLong = 1;
+                               switch (haveLong + 
+                                       haveChar + 
+                                       haveNum + 
+                                       haveOther)
+                               {
                                case 0:
                                        pch = _("very weak");
                                        break;
index 7ddd3539174f37cd525d27846a08a3ce2269ff41..6bfbead40a9cec7d4050a6e1b5a178efeaf58f7a 100644 (file)
@@ -654,7 +654,6 @@ void load_ical_object(long msgnum, int unread,
        StrBuf *Buf;
        StrBuf *Data = NULL;
        const char *bptr;
-       int Done = 0;
        char from[128] = "";
        char mime_partnum[256];
        char mime_filename[256];
@@ -676,10 +675,9 @@ void load_ical_object(long msgnum, int unread,
                FreeStrBuf (&Buf);
                return;
        }
-       while (!Done && (StrBuf_ServGetln(Buf)>=0)) {
+       while ((StrBuf_ServGetln(Buf)>=0)) {
                if ( (StrLength(Buf)==3) && 
                     !strcmp(ChrPtr(Buf), "000")) {
-                       Done = 1;
                        break;
                }
                bptr = ChrPtr(Buf);
index 5f7de0d9e8d5d61263c432db2cdf956923c2c26f..63ba3ceb54c5aa840557d8c7735180a45317f7cb 100644 (file)
@@ -854,6 +854,7 @@ void calendar_day_view_display_events(time_t thetime,
         * overlap with this one take place at least partially in this day.
         */
        memset(&starting_tm, 0, sizeof(struct tm));
+       memset(&event_te, 0, sizeof(struct tm));
        starting_tm.tm_year = year - 1900;
        starting_tm.tm_mon = month - 1;
        starting_tm.tm_mday = day;
index b506428b02387551563e337fdebb50da2dea5318..6d01f640928bf93d744c302fb7ca645765ca53d5 100644 (file)
@@ -436,7 +436,6 @@ int ReadHTTPRequest (ParsedHttpHdrs *Hdr)
                StrBufExtract_token(HeaderName, Line, 0, ':');
 
                pchs = ChrPtr(Line);
-               pche = pchs + StrLength(Line);
                pch = pchs + StrLength(HeaderName) + 1;
                pche = pchs + StrLength(Line);
                while ((pch < pche) && isspace(*pch))
@@ -522,6 +521,9 @@ void context_loop(ParsedHttpHdrs *Hdr)
 
                do_404();
 
+               /* How long did this transaction take? */
+               gettimeofday(&tx_finish, NULL);
+
                lprintf(9, "HTTP: 404 [%ld.%06ld] %s %s \n",
                        ((tx_finish.tv_sec*1000000 + tx_finish.tv_usec) - (tx_start.tv_sec*1000000 + tx_start.tv_usec)) / 1000000,
                        ((tx_finish.tv_sec*1000000 + tx_finish.tv_usec) - (tx_start.tv_sec*1000000 + tx_start.tv_usec)) % 1000000,
index 6618ac1bce0ce821669e0794358a845d9ee47a7e..aa5c78b9fec134888284255d59aa892a2d03c33d 100644 (file)
@@ -60,7 +60,7 @@ void shutdown_ssl(void)
  */
 void init_ssl(void)
 {
-       SSL_METHOD *ssl_method;
+       const SSL_METHOD *ssl_method;
        RSA *rsa=NULL;
        X509_REQ *req = NULL;
        X509 *cer = NULL;
index 4b34b3126baf8f22e32664df2e80acbf67ea5d88..3b6399913be85db17a0489fde41a7cd981760273 100644 (file)
@@ -46,7 +46,9 @@ void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum,
        char buf[SIZ];
        int organizer_is_me = 0;
        int i, j = 0;
+#ifdef DEBUG_UID_CALENDAR
        int sequence = 0;
+#endif
        char weekday_labels[7][32];
        char month_labels[12][32];
        long weekstart = 0;
@@ -159,9 +161,11 @@ void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum,
 
        /* Learn the sequence */
        p = icalcomponent_get_first_property(vevent, ICAL_SEQUENCE_PROPERTY);
+#ifdef DEBUG_UID_CALENDAR
        if (p != NULL) {
                sequence = icalproperty_get_sequence(p);
        }
+#endif
 
        /* Begin output */
        output_headers(1, 1, 2, 0, 0, 0);
@@ -175,8 +179,10 @@ void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum,
 
        wc_printf("<div class=\"fix_scrollbar_bug\">");
 
+#ifdef DEBUG_UID_CALENDAR
        /************************************************************
         * Uncomment this to see the UID in calendar events for debugging
+       *************************************************************/
        wc_printf("UID == ");
        p = icalcomponent_get_first_property(vevent, ICAL_UID_PROPERTY);
        if (p != NULL) {
@@ -184,7 +190,7 @@ void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum,
        }
        wc_printf("<br />\n");
        wc_printf("SEQUENCE == %d<br />\n", sequence);
-       *************************************************************/
+#endif
 
        wc_printf("<form name=\"EventForm\" method=\"POST\" action=\"save_event\">\n");
        wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
@@ -979,7 +985,7 @@ void save_individual_event(icalcomponent *supplied_vevent, long msgnum, char *fr
                                                if (YESBSTR(buf)) recur.by_day[j++] =
                                                        icalrecurrencetype_day_day_of_week(i+1);
                                        }
-                                       recur.by_day[j++] = ICAL_RECURRENCE_ARRAY_MAX;
+                                       recur.by_day[j] = ICAL_RECURRENCE_ARRAY_MAX;
                                        break;
 
                                case ICAL_MONTHLY_RECURRENCE:
index 382053a77804ed380c6c4239f537cf75e17fba82..b05bb9bff84e5be646d6dda257d56b38ce6353ca 100644 (file)
@@ -41,7 +41,7 @@ const char *AvailLang[] = {
        ""
 };
 
-const char **AvailLangLoaded;
+const char **AvailLangLoaded = NULL;
 long nLocalesLoaded = 0;
 
 #ifdef HAVE_USELOCALE
@@ -379,22 +379,6 @@ void initialize_locales(void) {
 #endif
 }
 
-
-void 
-ServerShutdownModule_GETTEXT
-(void)
-{
-#ifdef HAVE_USELOCALE
-       int i;
-       for (i = 0; i < nLocalesLoaded; ++i) {
-               if (Empty_Locale != wc_locales[i])
-                       freelocale(wc_locales[i]);
-       }
-       free(wc_locales);
-#endif
-       free(AvailLangLoaded);
-}
-
 #else  /* ENABLE_NLS */
 const char *AvailLang[] = {
        "C", ""};
@@ -494,3 +478,18 @@ SessionDestroyModule_GETTEXT
        stop_selected_language();                               /* unset locale */
 #endif
 }
+
+void 
+ServerShutdownModule_GETTEXT
+(void)
+{
+#ifdef ENABLE_NLS
+       int i;
+       for (i = 0; i < nLocalesLoaded; ++i) {
+               if (Empty_Locale != wc_locales[i])
+                       freelocale(wc_locales[i]);
+       }
+       free(wc_locales);
+       if (!AvailLangLoaded) free(AvailLangLoaded);
+#endif
+}
index 4185b1fedae980fc58db27c7feec74ddb6c1ec24..b91218b215d99cf8e06d2df7d3d4789da453accc 100644 (file)
@@ -529,17 +529,19 @@ void output_html(const char *supplied_charset, int treat_as_wiki, int msgnum, St
                         * so we don't turn things that look like URL's into
                         * links, when they're already links - or image sources.
                         */
-                       if ((ptr > msg) && (*(ptr-1) == '<')) {
+                       if ((ptr != NULL) && (ptr > msg) && (*(ptr-1) == '<')) {
                                ++brak;
                        }
-                       if ((ptr > msg) && (*(ptr-1) == '>')) {
+                       if ((ptr != NULL) && (ptr > msg) && (*(ptr-1) == '>')) {
                                --brak;
                                if ((scriptlevel == 0) && (script_start_pos >= 0)) {
                                        StrBufCutRight(converted_msg, StrLength(converted_msg) - script_start_pos);
                                        script_start_pos = (-1);
                                }
                        }
-                       if (!strncasecmp(ptr, "</A>", 3)) --alevel;
+                       if ((ptr != NULL) && 
+                           !strncasecmp(ptr, "</A>", 3))
+                               --alevel;
                }
        }
 
index 63cd84cc4fe098ef62ab191e6d2235371768aa90..fa0b8f55302f165bc06d4efdfd8e6b2511b74111 100644 (file)
@@ -58,8 +58,6 @@ void remove_march(const StrBuf *aaa)
 char *pop_march(int desired_floor)
 {
        static char TheRoom[128];
-       int TheFloor = 0;
-       int TheOrder = 32767;
        int TheWeight = 0;
        int weight;
        struct march *mptr = NULL;
@@ -81,8 +79,6 @@ char *pop_march(int desired_floor)
                if (weight > TheWeight) {
                        TheWeight = weight;
                        strcpy(TheRoom, mptr->march_name);
-                       TheFloor = mptr->march_floor;
-                       TheOrder = mptr->march_order;
                }
        }
        return (TheRoom);
index 0bd29376e10ec7fcfc1388da126c22bda5d19de6..fd6295d83e64912e30a3b78958c04933462814a7 100644 (file)
@@ -39,7 +39,6 @@ int load_message(message_summary *Msg,
        headereval *Hdr;
        void *vHdr;
        char buf[SIZ];
-       int Done = 0;
        int state=0;
        
        Buf = NewStrBuf();
@@ -63,11 +62,10 @@ int load_message(message_summary *Msg,
 
        /* begin everythingamundo table */
        HdrToken = NewStrBuf();
-       while (!Done && StrBuf_ServGetln(Buf)>=0) {
-               if ( (StrLength(Buf)==3) && 
+       while (StrBuf_ServGetln(Buf) >= 0) {
+               if ( (StrLength(Buf) ==3 ) && 
                    !strcmp(ChrPtr(Buf), "000")) 
                {
-                       Done = 1;
                        if (state < 2) {
                                if (Msg->MsgBody->Data == NULL)
                                        Msg->MsgBody->Data = NewStrBuf();
@@ -273,9 +271,10 @@ int read_message(StrBuf *Target, const char *tmpl, long tmpllen, long msgnum, co
 }
 
 
-void
+long
 HttpStatus(long CitadelStatus)
 {
+       /* TODO: this doesn't realy work currently, the HTTP status isn't printed to the browser! */
        long httpstatus = 502;
        
        switch (MAJORCODE(CitadelStatus))
@@ -338,7 +337,7 @@ HttpStatus(long CitadelStatus)
                break;
        }
 
-
+       return httpstatus;
 }
 
 /*
@@ -347,7 +346,7 @@ HttpStatus(long CitadelStatus)
  */
 void handle_one_message(void) 
 {
-       long CitStatus;
+       long CitStatus = ERROR;
        int CopyMessage = 0;
        const StrBuf *Destination;
        void *vLine;
@@ -718,7 +717,7 @@ void readloop(long oper, eCustomRoomRenderer ForceRenderer)
        void *vViewMsg;
        void *vMsg;
        message_summary *Msg;
-       char cmd[256] = "";
+       char cmd[256];
        int i, r;
        wcsession *WCC = WC;
        HashPos *at;
@@ -728,6 +727,8 @@ void readloop(long oper, eCustomRoomRenderer ForceRenderer)
        SharedMessageStatus Stat;
        void *ViewSpecific;
 
+       cmd[0] = '\0';
+
        if (havebstr("is_summary") && (1 == (ibstr("is_summary")))) {
                WCC->CurRoom.view = VIEW_MAILBOX;
        }
@@ -1454,13 +1455,9 @@ void move_msg(void)
  */
 void confirm_move_msg(void)
 {
-       long msgid;
        char buf[SIZ];
        char targ[SIZ];
 
-       msgid = lbstr("msgid");
-
-
        output_headers(1, 1, 2, 0, 0, 0);
        wc_printf("<div id=\"banner\">\n");
        wc_printf("<h1>");
index cdd265a412da3f5e96c2a9b7a722f4928fa4eccc..d08c42db3d60563fd56c50b6035c7a72be2e116f 100644 (file)
@@ -97,8 +97,8 @@ HashList *load_netconf(StrBuf *Target, WCTemplputParams *TP)
                Hash = NewHash(1, NULL);
 
                Buf = NewStrBuf();
-               while ((len = StrBuf_ServGetln(Buf),
-                       strcmp(ChrPtr(Buf), "000"))) {
+               while ((len = StrBuf_ServGetln(Buf), (len >= 0) && 
+                       ((len != 3) || !strcmp(ChrPtr(Buf), "000")))) {
                        Node = NewNode(Buf);
                        if (Node == NULL)
                                continue;
index 835c61f2d5658861b9c25338a0bcf0cee6dd478b..94176a31209e24d4fd7e3b6497a5074b9c562215 100644 (file)
@@ -28,7 +28,6 @@ struct vnote *vnote_new_from_msg(long msgnum,int unread)
        StrBuf *Buf;
        StrBuf *Data = NULL;
        const char *bptr;
-       int Done = 0;
        char uid_from_headers[256];
        char mime_partnum[256];
        char mime_filename[256];
@@ -43,6 +42,7 @@ struct vnote *vnote_new_from_msg(long msgnum,int unread)
        struct vnote *vnote_from_body = NULL;
        int vnote_inline = 0;                   /* 1 = MSG4 gave us a text/x-vnote top level */
 
+       uid_from_headers[0] = '\0';
        relevant_partnum[0] = '\0';
        serv_printf("MSG4 %ld", msgnum);        /* we need the mime headers */
        Buf = NewStrBuf();
@@ -51,10 +51,9 @@ struct vnote *vnote_new_from_msg(long msgnum,int unread)
                FreeStrBuf (&Buf);
                return NULL;
        }
-       while ((StrBuf_ServGetln(Buf)>=0) && !Done) {
+       while ((StrBuf_ServGetln(Buf)>=0)) {
                if ( (StrLength(Buf)==3) && 
                     !strcmp(ChrPtr(Buf), "000")) {
-                       Done = 1;
                        break;
                }
                bptr = ChrPtr(Buf);
index 1007811725f85efe9399b90edcd2cae801c3a1bd..e11dbaa582262f003d24c78e6d24152e222320ed 100644 (file)
@@ -152,16 +152,14 @@ void GetPrefTypes(HashList *List)
 
 void ParsePref(HashList **List, StrBuf *ReadBuf)
 {
-       int Done = 0;
        Preference *Data = NULL;
        Preference *LastData = NULL;
                                
-       while (!Done) {
+       while (1) {
                if (StrBuf_ServGetln(ReadBuf) < 0)
                        break;
                if ( (StrLength(ReadBuf)==3) && 
                     !strcmp(ChrPtr(ReadBuf), "000")) {
-                       Done = 1;
                        break;
                }
 
@@ -205,7 +203,6 @@ void load_preferences(void)
 {
        folder Room;
        wcsession *WCC = WC;
-       int Done = 0;
        StrBuf *ReadBuf;
        long msgnum = 0L;
        
@@ -224,11 +221,9 @@ void load_preferences(void)
                serv_puts("subj|__ WebCit Preferences __");
                serv_puts("000");
        }
-       while (!Done &&
-              (StrBuf_ServGetln(ReadBuf) >= 0)) {
+       while (StrBuf_ServGetln(ReadBuf) >= 0) {
                if ( (StrLength(ReadBuf)==3) && 
                     !strcmp(ChrPtr(ReadBuf), "000")) {
-                       Done = 1;
                        break;
                }
                msgnum = StrTol(ReadBuf);
@@ -344,7 +339,6 @@ void save_preferences(void)
 {
        folder Room;
        wcsession *WCC = WC;
-       int Done = 0;
        StrBuf *ReadBuf;
        long msgnum = 0L;
        
@@ -378,11 +372,9 @@ void save_preferences(void)
                serv_puts("subj|__ WebCit Preferences __");
                serv_puts("000");
        }
-       while (!Done &&
-              (StrBuf_ServGetln(ReadBuf) >= 0)) {
+       while (StrBuf_ServGetln(ReadBuf) >= 0) {
                if ( (StrLength(ReadBuf)==3) && 
                     !strcmp(ChrPtr(ReadBuf), "000")) {
-                       Done = 1;
                        break;
                }
                msgnum = StrTol(ReadBuf);
@@ -865,7 +857,7 @@ void tmplput_CFG_Value(StrBuf *Target, WCTemplputParams *TP)
                if (Pref->Type == NULL) {
                        StrBufAppendTemplate(Target, TP, Pref->Val, 1);
                }
-               switch (Pref->Type->eType)
+               else switch (Pref->Type->eType)
                {
                case PRF_UNSET: /* default to string... */
                case PRF_STRING:
index 2f59929eb72037a921ba346be619356feb46adfc..29a9ca98f33c6bd5b2e2faf8ea65347ab1df23fb 100644 (file)
@@ -7,7 +7,6 @@
 void display_pushemail(void) 
 {
        folder Room;
-       int Done = 0;
        StrBuf *Buf;
        long vector[8] = {8, 0, 0, 1, 2, 3, 4, 5};
        WCTemplputParams SubTP;
@@ -28,11 +27,9 @@ void display_pushemail(void)
                if (GetServerStatus(Buf, NULL) == 8) {
                        serv_puts("subj|__ Push email settings __");
                        serv_puts("000");
-                       while (!Done &&
-                              StrBuf_ServGetln(Buf) >= 0) {
+                       while (StrBuf_ServGetln(Buf) >= 0) {
                                if ( (StrLength(Buf)==3) && 
                                     !strcmp(ChrPtr(Buf), "000")) {
-                                       Done = 1;
                                        break;
                                }
                                msgnum = StrTol(Buf);
@@ -43,25 +40,19 @@ void display_pushemail(void)
                StrBuf_ServGetln(Buf);
                if (GetServerStatus(Buf, NULL) == 1) {
                        int i =0;
-                       Done = 0;
-                       while (!Done &&
-                              StrBuf_ServGetln(Buf) >= 0) {
+                       while (StrBuf_ServGetln(Buf) >= 0) {
                                if (( (StrLength(Buf)==3) && 
                                      !strcmp(ChrPtr(Buf), "000"))||
                                    ((StrLength(Buf)==4) && 
                                     !strcmp(ChrPtr(Buf), "text")))
                                {
-                                       Done = 1;
                                        break;
                                }
                        }
                        if (!strcmp(ChrPtr(Buf), "text")) {
-                               Done = 0;
-                               while (!Done &&
-                                      StrBuf_ServGetln(Buf) >= 0) {
+                               while (StrBuf_ServGetln(Buf) >= 0) {
                                        if ( (StrLength(Buf)==3) && 
                                             !strcmp(ChrPtr(Buf), "000")) {
-                                               Done = 1;
                                                break;
                                        }
                                        if (strncasecmp(ChrPtr(Buf), "none", 4) == 0) {
@@ -96,7 +87,6 @@ void display_pushemail(void)
 void save_pushemail(void) 
 {
        folder Room;
-       int Done = 0;
        StrBuf *Buf;
        char buf[SIZ];
        int msgnum = 0;
@@ -125,11 +115,9 @@ void save_pushemail(void)
                return;
        }
 
-       while (!Done &&
-              StrBuf_ServGetln(Buf) >= 0) {
+       while (StrBuf_ServGetln(Buf) >= 0) {
                if ( (StrLength(Buf)==3) && 
                     !strcmp(ChrPtr(Buf), "000")) {
-                       Done = 1;
                        break;
                }
                msgnum = StrTol(Buf);
index d2204f79260e86a27509f5f70f7392ef09051438..dc671632acecb2d0b46eca5429e76468701a6c68 100644 (file)
@@ -59,7 +59,6 @@ int is_view_allowed_as_default(int which_view)
 void load_floorlist(StrBuf *Buf)
 {
        int a;
-       int Done = 0;
 
        for (a = 0; a < MAX_FLOORS; ++a)
                floorlist[a][0] = 0;
@@ -70,10 +69,9 @@ void load_floorlist(StrBuf *Buf)
                strcpy(floorlist[0], "Main Floor");
                return;
        }
-       while (!Done && (StrBuf_ServGetln(Buf)>=0)) {
+       while (StrBuf_ServGetln(Buf) >= 0) {
                if ( (StrLength(Buf)==3) && 
                     !strcmp(ChrPtr(Buf), "000")) {
-                       Done = 1;
                        break;
                }
                extract_token(floorlist[StrBufExtract_int(Buf, 0, '|')], ChrPtr(Buf), 1, '|', sizeof floorlist[0]);
index f4162a5a0e84ed87dc8ec71bc5bca0d537e84092..d6751f24a7193a4fbd7f9fcc1deff3cccb28f705 100644 (file)
@@ -518,7 +518,7 @@ void text_to_server_qp(char *ptr)
                                output_len += 2;
                        }
                        buf[output_len++] = '=';
-                       buf[output_len++] = 0;
+                       buf[output_len] = '\0';
                        serv_puts((char *)buf);
                        output_len = 0;
                }
@@ -530,9 +530,8 @@ void text_to_server_qp(char *ptr)
                        sprintf((char *)&buf[output_len-1], "=%02X", buf[output_len-1]);
                        output_len += 2;
                }
-               buf[output_len++] = 0;
+               buf[output_len] = '\0';
                serv_puts((char *)buf);
-               output_len = 0;
        }
 }
 
index b5ea7965d928c00b42d519df49398d6373161cc0..fe9007a322772c4b3f26587e30130cb8eb364b9b 100644 (file)
@@ -38,7 +38,6 @@ void output_static(const char *what)
        int fd;
        struct stat statbuf;
        off_t bytes;
-       off_t count = 0;
        const char *content_type;
        int len;
        const char *Err;
@@ -65,7 +64,6 @@ void output_static(const char *what)
                        return;
                }
 
-               count = 0;
                bytes = statbuf.st_size;
 
                if (StrBufReadBLOB(WC->WBuf, &fd, 1, bytes, &Err) < 0)
@@ -104,7 +102,6 @@ int LoadStaticDir(const char *DirName, HashList *DirList, const char *RelDir)
        struct dirent *filedir_entry;
        int d_type = 0;
         int d_namelen;
-       int d_without_ext;
        int istoplevel;
                
        filedir = opendir (DirName);
@@ -125,7 +122,6 @@ int LoadStaticDir(const char *DirName, HashList *DirList, const char *RelDir)
        while ((readdir_r(filedir, d, &filedir_entry) == 0) &&
               (filedir_entry != NULL))
        {
-               char *PStart;
 #ifdef _DIRENT_HAVE_D_NAMELEN
                d_namelen = filedir_entry->d_namelen;
                d_type = filedir_entry->d_type;
@@ -143,8 +139,6 @@ int LoadStaticDir(const char *DirName, HashList *DirList, const char *RelDir)
                d_namelen = strlen(filedir_entry->d_name);
                d_type = DT_UNKNOWN;
 #endif
-               d_without_ext = d_namelen;
-
                if ((d_namelen > 1) && filedir_entry->d_name[d_namelen - 1] == '~')
                        continue; /* Ignore backup files... */
 
@@ -188,7 +182,6 @@ int LoadStaticDir(const char *DirName, HashList *DirList, const char *RelDir)
                        break;
                case DT_LNK: /* TODO: check whether its a file or a directory */
                case DT_REG:
-                       PStart = filedir_entry->d_name;
                        FileName = NewStrBufDup(Dir);
                        if (ChrPtr(FileName) [ StrLength(FileName) - 1] != '/')
                                StrBufAppendBufPlain(FileName, "/", 1, 0);
@@ -229,7 +222,7 @@ void output_flat_static(void)
            (vFile != NULL))
        {
                File = (StrBuf*) vFile;
-               output_static(ChrPtr(vFile));
+               output_static(ChrPtr(File));
        }
 }
 
@@ -245,7 +238,7 @@ void output_static_safe(HashList *DirList)
            (vFile != NULL))
        {
                File = (StrBuf*) vFile;
-               output_static(ChrPtr(vFile));
+               output_static(ChrPtr(File));
        }
        else {
                lprintf(1, "output_static_safe() file %s not found. \n", 
index bfffef3f4cbf88aa07b7b0922035f4f3f8f25035..4e795d2722806d277338388a78ddcff5453102c1 100644 (file)
@@ -233,11 +233,16 @@ void LogTemplateError (StrBuf *Target, const char *Type, int ErrorPos, WCTemplpu
                        Type, 
                        ChrPtr(Error));
                */
-               StrBufPrintf(Info, "%s [%s]  %s; [%s]", 
-                            Type, 
-                            Err, 
-                            ChrPtr(Error), 
-                            ChrPtr(TP->Tokens->FlatToken));
+               FlushStrBuf(Info);
+               StrBufAppendBufPlain(Info, Type, -1, 0);
+               StrBufAppendBufPlain(Info, HKEY(" ["), 0);
+               StrBufAppendBufPlain(Info, Err, -1, 0);
+               StrBufAppendBufPlain(Info, HKEY("] "), 0);
+               StrBufAppendBuf(Info, Error, 0);
+               StrBufAppendBufPlain(Info, HKEY("; ["), 0);
+               if (TP->Tokens != NULL)
+                       StrBufAppendBuf(Info, TP->Tokens->FlatToken, 0);
+               StrBufAppendBufPlain(Info, HKEY("]"), 0);
                SerializeJson(WCC->WFBuf, WildFireException(HKEY(__FILE__), __LINE__, Info, 1), 1);
        }
        FreeStrBuf(&Info);
@@ -418,9 +423,6 @@ void VarPrintEntry(const char *Key, void *vSubst, int odd)
        case WCS_STRING:
                lprintf(1, "  -> %s\n", ChrPtr(ptr->wcs_value));
                break;
-       case WCS_SERVCMD:
-               lprintf(1, "  -> Server [%s]\n", ChrPtr(ptr->wcs_value));
-               break;
        case WCS_FUNCTION:
                lprintf(1, "  -> function at [%0xd]\n", ptr->wcs_function);
                break;
@@ -452,7 +454,6 @@ int NeedNewBuf(int type)
 {
        switch(type) {
        case WCS_STRING:
-       case WCS_SERVCMD:
        case WCS_STRBUF:
                return 1;
        case WCS_FUNCTION:
@@ -468,7 +469,6 @@ void FlushPayload(wcsubst *ptr, int reusestrbuf, int type)
        int NeedNew = NeedNewBuf(type);
        switch(ptr->wcs_type) {
        case WCS_STRING:
-       case WCS_SERVCMD:
        case WCS_STRBUF:
                if (reusestrbuf && NeedNew) {
                        FlushStrBuf(ptr->wcs_value);
@@ -527,9 +527,6 @@ wcsubst *NewSubstVar(const char *keyname, int keylen, int type)
 
        switch(ptr->wcs_type) {
        case WCS_STRING:
-       case WCS_SERVCMD:
-               ptr->wcs_value = NewStrBuf();
-               break;
        case WCS_STRBUF:
        case WCS_FUNCTION:
        case WCS_STRBUF_REF:
@@ -733,33 +730,6 @@ void SVPUTBuf(const char *keyname, int keylen, const StrBuf *Buf, int ref)
        ptr->wcs_value = (StrBuf*)Buf;
 }
 
-/**
- * \brief back end for print_value_of() ... does a server command
- * \param servcmd server command to execute on the citadel server
- */
-void pvo_do_cmd(StrBuf *Target, StrBuf *servcmd) {
-       char buf[SIZ];
-       int len;
-
-       serv_puts(ChrPtr(servcmd));
-       len = serv_getln(buf, sizeof buf);
-
-       switch(buf[0]) {
-               case '2':
-               case '3':
-               case '5':
-                       StrBufAppendPrintf(Target, "%s\n", &buf[4]);
-                       break;
-               case '1':
-                       _fmout(Target, "CENTER");
-                       break;
-               case '4':
-                       StrBufAppendPrintf(Target, "%s\n", &buf[4]);
-                       serv_puts("000");
-                       break;
-       }
-}
-
 int HaveTemplateTokenString(StrBuf *Target, 
                            WCTemplputParams *TP,
                            int N,
@@ -975,9 +945,6 @@ void print_value_of(StrBuf *Target, WCTemplputParams *TP)
                case WCS_STRING:
                        StrBufAppendBuf(Target, ptr->wcs_value, 0);
                        break;
-               case WCS_SERVCMD:
-                       pvo_do_cmd(Target, ptr->wcs_value);
-                       break;
                case WCS_FUNCTION:
                        (*ptr->wcs_function) (Target, TP);
                        break;
@@ -1021,9 +988,6 @@ int CompareSubstToToken(TemplateParam *ParamToCompare, TemplateParam *ParamToLoo
                        else
                                return ParamToCompare->lvalue == StrTol(ptr->wcs_value);
                        break;
-               case WCS_SERVCMD:
-                       return 1; 
-                       break;
                case WCS_FUNCTION:
                        return 1;
                case WCS_LONG:
@@ -1055,9 +1019,6 @@ int CompareSubstToStrBuf(StrBuf *Compare, TemplateParam *ParamToLookup)
                case WCS_STRBUF_REF:
                        return ((StrLength(Compare) == StrLength(ptr->wcs_value)) &&
                                (strcmp(ChrPtr(Compare), ChrPtr(ptr->wcs_value)) == 0));
-               case WCS_SERVCMD:
-                       return 1; 
-                       break;
                case WCS_FUNCTION:
                        return 1;
                case WCS_LONG:
@@ -1081,7 +1042,6 @@ void StrBufAppendTemplate(StrBuf *Target,
                          WCTemplputParams *TP,
                          const StrBuf *Source, int FormatTypeIndex)
 {
-        wcsession *WCC;
        char EscapeAs = ' ';
 
        if ((FormatTypeIndex < TP->Tokens->nParameters) &&
@@ -1093,7 +1053,6 @@ void StrBufAppendTemplate(StrBuf *Target,
        switch(EscapeAs)
        {
        case 'H':
-               WCC = WC;
                StrEscAppend(Target, Source, NULL, 0, 2);
                break;
        case 'X':
@@ -1581,7 +1540,6 @@ void *load_template(WCTemplate *NewTemplate)
        struct stat statbuf;
        const char *pS, *pE, *pch, *Err;
        long Line;
-       int pos;
 
        fd = open(ChrPtr(NewTemplate->FileName), O_RDONLY);
        if (fd <= 0) {
@@ -1617,7 +1575,6 @@ void *load_template(WCTemplate *NewTemplate)
                int InDoubleQuotes = 0;
 
                /** Find one <? > */
-               pos = (-1);
                for (; pch < pE; pch ++) {
                        if ((*pch=='<')&&(*(pch + 1)=='?') &&
                            !((pch == pS) && /* we must ommit a <?xml */
@@ -1697,7 +1654,6 @@ int LoadTemplateDir(const StrBuf *DirName, HashList *wireless, HashList *big, co
               (filedir_entry != NULL))
        {
                char *MinorPtr;
-               char *PStart;
 #ifdef _DIRENT_HAVE_D_NAMELEN
                d_namelen = filedir_entry->d_namelen;
                d_type = filedir_entry->d_type;
@@ -1779,7 +1735,6 @@ int LoadTemplateDir(const StrBuf *DirName, HashList *wireless, HashList *big, co
                        if (d_without_ext > 2)
                                IsMobile = (filedir_entry->d_name[d_without_ext - 1] == 'm') &&
                                        (filedir_entry->d_name[d_without_ext - 2] == '.');
-                       PStart = filedir_entry->d_name;
                        StrBufPrintf(FileName, "%s/%s", ChrPtr(DirName),  filedir_entry->d_name);
                        MinorPtr = strchr(filedir_entry->d_name, '.');
                        if (MinorPtr != NULL)
@@ -2372,9 +2327,6 @@ int ConditionalVar(StrBuf *Target, WCTemplputParams *TP)
        switch(subst->wcs_type) {
        case WCS_FUNCTION:
                return (subst->wcs_function!=NULL);
-       case WCS_SERVCMD:
-               lprintf(1, "  -> Server [%s]\n", subst->wcs_value);/* TODO */
-               return 1;
        case WCS_STRING:
        case WCS_STRBUF:
        case WCS_STRBUF_REF:
@@ -2700,7 +2652,6 @@ CompareFunc RetrieveSort(WCTemplputParams *TP,
                         const char *OtherPrefix, long OtherPrefixLen,
                         const char *Default, long ldefault, long DefaultDirection)
 {
-       int isdefault = 0;
        const StrBuf *BSort = NULL;
        SortStruct *SortBy;
        void *vSortBy;
@@ -2734,7 +2685,6 @@ CompareFunc RetrieveSort(WCTemplputParams *TP,
 
        if (!GetHash(SortHash, SKEY(BSort), &vSortBy) || 
            (vSortBy == NULL)) {
-               isdefault = 1;
                if (!GetHash(SortHash, Default, ldefault, &vSortBy) || 
                    (vSortBy == NULL)) {
                        LogTemplateError(
@@ -2759,6 +2709,7 @@ CompareFunc RetrieveSort(WCTemplputParams *TP,
                        SortOrder = StrTol(Buf);
                }
                else {
+                       /* TODO: this is never used??? */
                        BSort = get_X_PREFS(HKEY("SortOrder"), OtherPrefix, OtherPrefixLen);
                }
 
index 970aa0368e837eb6649aab0f32cc1c1ec2a6885f..2899d05c9fdf73081665075ca7d9dfd1e885e04c 100644 (file)
@@ -26,7 +26,6 @@ extern HashList *LocalTemplateCache;
 enum {
        WCS_STRING,       /* its a string */
        WCS_FUNCTION,     /* its a function callback */
-       WCS_SERVCMD,      /* its a command to send to the citadel server */
        WCS_STRBUF,       /* its a strbuf we own */
        WCS_STRBUF_REF,   /* its a strbuf we mustn't free */
        WCS_LONG          /* its an integer */
index b3470a042c1362da057ef630d04f1a105ee5b70c..7c0acca7620df324373532c0b2e11006d402ea6a 100644 (file)
@@ -386,8 +386,6 @@ void start_daemon(char *pid_file)
                        waitpid(current_child, &status, 0);
                }
 
-               do_restart = 0;
-
                /* Did the main process exit with an actual exit code? */
                if (WIFEXITED(status)) {
 
index 42ae949ba5a4411f5b295885aaca9acf6134c471..25a638120b45374bcad4b6dc63a41daca1c1e66f 100644 (file)
@@ -181,12 +181,9 @@ void display_edit_individual_task(icalcomponent *supplied_vtodo, long msgnum, ch
        icalcomponent *vtodo;
        icalproperty *p;
        struct icaltimetype IcalTime;
-       time_t now;
        int created_new_vtodo = 0;
        icalproperty_status todoStatus;
 
-       now = time(NULL);
-
        if (supplied_vtodo != NULL) {
                vtodo = supplied_vtodo;
 
index 6bbef24fb5fb7459fb001af957229c48bb3a6757..9d670935d9f14aee2fe98572a4eec48a153be5fa 100644 (file)
@@ -332,7 +332,7 @@ int serv_read_binary(StrBuf *Ret, size_t total_len, StrBuf *Buf)
                        return -1; 
                }
 
-               serv_printf("READ %d|%d", bytes_read, total_len-bytes_read);
+               serv_printf("READ "SIZE_T_FMT"|"SIZE_T_FMT, bytes_read, total_len-bytes_read);
                if ( (rc = StrBuf_ServGetln(Buf) > 0) && (GetServerStatus(Buf, NULL) == 6) ) 
                {
                        if (rc < 0)
index 0bfc7ff37aee24f4cee429df3c2e82a050fdba4a..d4a5afbe214d1bb5e7817286e16accecf64149b3 100644 (file)
@@ -270,13 +270,12 @@ HashList *iterate_load_userlist(StrBuf *Target, WCTemplputParams *TP)
        if (GetServerStatus(Buf, NULL) == 1) {
                Hash = NewHash(1, NULL);
 
-               while (!Done) {
+               while (1) {
                        len = StrBuf_ServGetln(Buf);
-                       if ((len <0) || 
+                       if ((len < 0) || 
                            ((len == 3) &&
                             !strcmp(ChrPtr(Buf), "000")))
                        {
-                               Done = 1;
                                break;
                        }
                        ul = NewUserListEntry(Buf);
@@ -419,7 +418,6 @@ long locate_user_vcard_in_this_room(message_summary **VCMsg, wc_mime_attachment
        void *vMsg;
        message_summary *Msg;
        wc_mime_attachment *Att;
-       int Done;
        StrBuf *Buf;
        long vcard_msgnum = (-1L);
        int already_tried_creating_one = 0;
@@ -434,7 +432,6 @@ TRYAGAIN:
        Stat.maxload = 10000;
        Stat.lowest_found = (-1);
        Stat.highest_found = (-1);
-       Done = 0;
        /* Search for the user's vCard */
        if (load_msg_ptrs("MSGS ALL||||1", &Stat, NULL) > 0) {
                at = GetNewHashPos(WCC->summ, 0);
index 9de1ad242289209df0864d5fbb24f95e3ce8c0fb..75db9ec8b54b15f98dd543650309d037c29f0591 100644 (file)
@@ -595,7 +595,6 @@ int Conditional_REST_DEPTH(StrBuf *Target, WCTemplputParams *TP)
  */
 void session_loop(void)
 {
-       int Flags = 0;
        int xhttp;
        StrBuf *Buf;
        
@@ -610,8 +609,6 @@ void session_loop(void)
        WCC->upload = NULL;
        WCC->is_mobile = 0;
        WCC->Hdr->nWildfireHeaders = 0;
-       if (WCC->Hdr->HR.Handler != NULL)
-               Flags = WCC->Hdr->HR.Handler->Flags; /* so we can temporarily add our own... */
 
        if (WCC->Hdr->HR.ContentLength > 0) {
                if (ReadPostData() < 0) {
index 3546878dbcbeeb572aaad8d8b70a9afa3ef777fd..180e0e2b5af35557f86ff84acdbb1264db3510c0 100644 (file)
@@ -24,7 +24,6 @@ extern int verbosity;         /* Logging level */
 extern char static_icon_dir[PATH_MAX];          /* where should we find our mime icons */
 int is_https = 0;              /* Nonzero if I am an HTTPS service */
 int follow_xff = 0;            /* Follow X-Forwarded-For: header */
-int home_specified = 0;                /* did the user specify a homedir? */
 int DisableGzip = 0;
 extern pthread_mutex_t SessionListMutex;
 extern pthread_key_t MyConKey;
@@ -81,7 +80,6 @@ int main(int argc, char **argv)
        char ip_addr[256]="0.0.0.0";
        int relh=0;
        int home=0;
-       int home_specified=0;
        char relhome[PATH_MAX]="";
        char webcitdir[PATH_MAX] = DATADIR;
        char *pidfile = NULL;
@@ -131,7 +129,6 @@ int main(int argc, char **argv)
                                safestrncpy(relhome, relhome, sizeof relhome);
                        }
                        /* free(hdir); TODO: SHOULD WE DO THIS? */
-                       home_specified = 1;
                        home=1;
                        break;
                case 'd':