* --pedantic cleanup.
authorWilfried Göesgens <willi@citadel.org>
Fri, 26 Dec 2008 15:42:49 +0000 (15:42 +0000)
committerWilfried Göesgens <willi@citadel.org>
Fri, 26 Dec 2008 15:42:49 +0000 (15:42 +0000)
* move several files headers out of webcit.h into their own ones. its getting to crowded over there.

37 files changed:
webcit/auth.c
webcit/availability.c
webcit/calendar.c
webcit/calendar_tools.c
webcit/calendar_view.c
webcit/context_loop.c
webcit/decode.c
webcit/downloads.c
webcit/event.c
webcit/fmt_date.c
webcit/gettext.c
webcit/graphics.c
webcit/groupdav_get.c
webcit/groupdav_put.c
webcit/html2html.c
webcit/iconbar.c
webcit/mainmenu.c
webcit/messages.c
webcit/messages.h [new file with mode: 0644]
webcit/msg_renderers.c
webcit/netconf.c
webcit/paramhandling.h [new file with mode: 0644]
webcit/preferences.c
webcit/preferences.h [new file with mode: 0644]
webcit/roomops.c
webcit/rss.c
webcit/serv_func.c
webcit/smtpqueue.c
webcit/subst.c
webcit/subst.h [new file with mode: 0644]
webcit/useredit.c
webcit/utils.c
webcit/wc_gettext.h [new file with mode: 0644]
webcit/webcit.c
webcit/webcit.h
webcit/webserver.c
webcit/who.c

index 3ae236e4c6cc82ce66ea4e582419a7e9a46aa5b2..77c2d457f503996e1c3a79aaa9c839c007a570e1 100644 (file)
@@ -261,12 +261,13 @@ void do_login(void)
  */
 void openid_manual_create(void)
 {
+       char buf[1024];
+
        if (havebstr("exit_action")) {
                do_logout();
                return;
        }
 
-       char buf[1024];
        if (havebstr("newuser_action")) {
                serv_printf("OIDC %s", bstr("name"));
                serv_getln(buf, sizeof buf);
index 156137b1b2e51a99f9a3a4fbaaac2b73a0d29526..f8772780bd8c296bb2f65d3c3e08ea5c83db3b98 100644 (file)
@@ -90,11 +90,11 @@ int ical_ctdl_is_overlap(
 
        /* If event 1 ends before event 2 starts, we're in the clear. */
        if (icaltime_compare(t1end, t2start) <= 0) return(0);
-       // lprintf(9, "first passed\n");
+       /* lprintf(9, "first passed\n"); */
 
        /* If event 2 ends before event 1 starts, we're also ok. */
        if (icaltime_compare(t2end, t1start) <= 0) return(0);
-       // lprintf(9, "second passed\n");
+       /* lprintf(9, "second passed\n"); */
 
        /* Otherwise, they overlap. */
        return(1);
index b583d133ac2b24f5a3118ce93defa88ad191be78..a80e62c167f863db8bbcab9a67c002afa4042106 100644 (file)
@@ -56,8 +56,8 @@ void cal_process_object(StrBuf *Target,
 
        /* See what we need to do with this */
        if (method != NULL) {
-               the_method = icalproperty_get_method(method);
                char *title;
+               the_method = icalproperty_get_method(method);
 
                StrBufAppendPrintf(Target, "<div id=\"%s_title\">", divname);
                StrBufAppendPrintf(Target, "<img src=\"static/calarea_48x.gif\">");
@@ -415,6 +415,7 @@ void display_individual_cal(icalcomponent *cal, long msgnum, char *from, int unr
        icalrecur_iterator *ritr = NULL;
        struct icaltimetype next;
        int num_recur = 0;
+       int stop_rr = 0;
 
        dtstart = icaltime_null_time();
        dtend = icaltime_null_time();
@@ -499,10 +500,10 @@ void display_individual_cal(icalcomponent *cal, long msgnum, char *from, int unr
        ritr = icalrecur_iterator_new(recur, dtstart);
        if (!ritr) return;
 
-       int stop_rr = 0;
        while (next = icalrecur_iterator_next(ritr), ((!icaltime_is_null_time(next))&&(!stop_rr)) ) {
                ++num_recur;
                if (num_recur > 1) {            /* Skip the first one.  We already did it at the root. */
+                       icalcomponent *cptr;
                        /* lprintf(9, "REPEATS: %s\n", icaltime_as_ical_string(next)); */
 
                        /* Note: anything we do here, we also have to do above for the root event. */
@@ -515,7 +516,6 @@ void display_individual_cal(icalcomponent *cal, long msgnum, char *from, int unr
                        memcpy(Cal->from, from, len + 1);
                        Cal->cal_msgnum = msgnum;
 
-                       icalcomponent *cptr;
                        if (icalcomponent_isa(Cal->cal) == ICAL_VEVENT_COMPONENT) {
                                cptr = Cal->cal;
                        }
@@ -622,11 +622,11 @@ void display_edit_individual_task(icalcomponent *supplied_vtodo, long msgnum, ch
                created_new_vtodo = 1;
        }
        
-       // TODO: Can we take all this and move it into a template?      
+       /*/ TODO: Can we take all this and move it into a template?      */
        output_headers(1, 1, 1, 0, 0, 0);
        wprintf("<!-- start task edit form -->");
        p = icalcomponent_get_first_property(vtodo, ICAL_SUMMARY_PROPERTY);
-       // Get summary early for title
+       /* Get summary early for title */
        wprintf("<div class=\"box\">\n");
        wprintf("<div class=\"boxlabel\">");
        wprintf(_("Edit task"));
@@ -710,7 +710,7 @@ void display_edit_individual_task(icalcomponent *supplied_vtodo, long msgnum, ch
        } 
        wprintf(" >");
        wprintf("</TD></TR>");
-       // start category field
+       /* start category field */
        p = icalcomponent_get_first_property(vtodo, ICAL_CATEGORIES_PROPERTY);
        wprintf("<TR><TD>");
        wprintf(_("Category:"));
@@ -721,7 +721,7 @@ void display_edit_individual_task(icalcomponent *supplied_vtodo, long msgnum, ch
        }
        wprintf("\">");
        wprintf("</TD></TR>\n   ");
-       // end category field
+       /* end category field */
        wprintf("<TR><TD>");
        wprintf(_("Description:"));
        wprintf("</TD><TD>");
index 15f89ee35f26dfc320d07492d68ecbdce4361634..b2d9fb090ca9bfe061583e01473c1f4813822d1e 100644 (file)
@@ -264,7 +264,7 @@ icalcomponent *ical_encapsulate_subcomponent(icalcomponent *subcomp) {
                  || (icalproperty_isa(p) == ICAL_MINDATE_PROPERTY)
                  || (icalproperty_isa(p) == ICAL_RECURRENCEID_PROPERTY)
                ) {
-                       t = icalproperty_get_dtstart(p);        // it's safe to use dtstart for all of them
+                       t = icalproperty_get_dtstart(p);        /*/ it's safe to use dtstart for all of them */
                        if ((icaltime_is_valid_time(t)) && (z=icaltime_get_timezone(t), z)) {
                        
                                zone_already_attached = 0;
index db5c45346f02feb506bcce742840cfe8010c99d5..7b6518aec5c53014ff72f142ed824e3e7ed06513 100644 (file)
@@ -1318,6 +1318,7 @@ void parse_calendar_view_request(struct calview *c) {
        time_t now;
        struct tm tm;
        char calview[32];
+       int span = 3888000;
 
        /* In case no date was specified, go with today */
        now = time(NULL);
@@ -1364,7 +1365,6 @@ void parse_calendar_view_request(struct calview *c) {
        tm.tm_mday = c->day;
        now = mktime(&tm);
 
-       int span = 3888000;
        if (c->view == calview_month)   span = 3888000;
        if (c->view == calview_brief)   span = 3888000;
        if (c->view == calview_week)    span = 604800;
@@ -1456,10 +1456,10 @@ int task_due_cmp(const void *vtask1, const void *vtask2) {
  */
 int task_completed_cmp(const void *vtask1, const void *vtask2) {
        disp_cal * Task1 = (disp_cal *)GetSearchPayload(vtask1);
-//     disp_cal * Task2 = (disp_cal *)GetSearchPayload(vtask2);
+/*     disp_cal * Task2 = (disp_cal *)GetSearchPayload(vtask2); */
 
        icalproperty_status t1 = icalcomponent_get_status((Task1)->cal);
-       // icalproperty_status t2 = icalcomponent_get_status(((struct disp_cal *)task2)->cal);
+       /* icalproperty_status t2 = icalcomponent_get_status(((struct disp_cal *)task2)->cal); */
        
        if (t1 == ICAL_STATUS_COMPLETED) 
                return 1;
@@ -1513,9 +1513,11 @@ void do_tasks_view(void) {
 
        Pos = GetNewHashPos(WCC->disp_cal_items, 0);
        while (GetNextHashPos(WCC->disp_cal_items, Pos, &hklen, &HashKey, &vCal)) {
+               icalproperty_status todoStatus;
+
                Cal = (disp_cal*)vCal;
                wprintf("<tr><td>");
-               icalproperty_status todoStatus = icalcomponent_get_status(Cal->cal);
+               todoStatus = icalcomponent_get_status(Cal->cal);
                wprintf("<input type=\"checkbox\" name=\"completed\" value=\"completed\" ");
                if (todoStatus == ICAL_STATUS_COMPLETED) {
                        wprintf("checked=\"checked\" ");
index fa789c138c247477b0b92442f816b617f7093e8c..dab22a9dec5ca80f923513db079be354799f8584 100644 (file)
@@ -24,9 +24,11 @@ void DestroySession(wcsession **sessions_to_kill)
 {
        close((*sessions_to_kill)->serv_sock);
        close((*sessions_to_kill)->chat_sock);
+/*
 //             if ((*sessions_to_kill)->preferences != NULL) {
 //                     free((*sessions_to_kill)->preferences);
 //             }
+*/
        if ((*sessions_to_kill)->cache_fold != NULL) {
                free((*sessions_to_kill)->cache_fold);
        }
@@ -154,45 +156,6 @@ int GenerateSessionID(void)
        return ++seq;
 }
 
-
-/*
- * Collapse multiple cookies on one line
- */
-////int req_gets(int *sock, char *buf, char *hold, size_t hlen)
-////{
-////   int a, b;
-////
-////   if (IsEmptyStr(hold)) {
-////           strcpy(buf, "");
-////           a = client_getln(sock, buf, SIZ);
-////           if (a<1) return(-1);
-////   } else {
-////           safestrncpy(buf, hold, SIZ);
-////   }
-////   strcpy(hold, "");
-////
-////   if (!strncasecmp(buf, "Cookie: ", 8)) {
-////           int len;
-////           len = strlen(buf);
-////           for (a = 0; a < len; ++a)
-////                   if (buf[a] == ';') {
-////                           // we don't refresh len, because of we 
-////                           // only exit from here.
-////                           snprintf(hold, hlen, "Cookie: %s", &buf[a + 1]);
-////                           buf[a] = 0;
-////                           b = 8;
-////                           while (isspace(hold[b]))
-////                                   b++;
-////                           
-////                           memmove(&hold[8], &hold[b], len - b + 1);
-////                           return(0);
-////                   }
-////   }
-////
-////   return(0);
-////}
-
-
 /*
  * Collapse multiple cookies on one line
  */
@@ -251,12 +214,7 @@ int lingering_close(int fd)
 int is_bogus(StrBuf *http_cmd) {
        const char *url;
        int i, max;
-
-       url = ChrPtr(http_cmd);
-       if (IsEmptyStr(url)) return(1);
-       ++url;
-
-       char *bogus_prefixes[] = {
+       const char *bogus_prefixes[] = {
                "/scripts/root.exe",    /**< Worms and trojans and viruses, oh my! */
                "/c/winnt",
                "/MSADC/",
@@ -264,6 +222,11 @@ int is_bogus(StrBuf *http_cmd) {
                "/MSOffice"             /**< Stoopid MSOffice thinks everyone is IIS */
        };
 
+       url = ChrPtr(http_cmd);
+       if (IsEmptyStr(url)) return(1);
+       ++url;
+
+
        max = sizeof(bogus_prefixes) / sizeof(char *);
 
        for (i=0; i<max; ++i) {
@@ -355,7 +318,7 @@ void context_loop(int *sock)
                }
 
                StrBufExtract_token(HeaderName, Line, 0, ':');
-       //// TODO: filter bad chars!
+               /*/// TODO: filter bad chars! */
 
                pchs = ChrPtr(Line);
                pch = pchs + StrLength(HeaderName) + 1;
@@ -370,7 +333,7 @@ void context_loop(int *sock)
        } while (LineLen > 0);
        FreeStrBuf(&HeaderName);
 
-////   dbg_PrintHash(HTTPHeaders, nix, NULL);
+/*///  dbg_PrintHash(HTTPHeaders, nix, NULL); */
 
 
        /**
index cf64886eeff85ff8ce0c11b7b55157e5493efdf8..267e85982117dde96c95a9f574417543f647f962 100644 (file)
@@ -75,7 +75,7 @@ void utf8ify_rfc822_string(char *buf) {
        for (i=0; i<len; ++i) {
                if ((buf[i] < 32) || (buf[i] > 126)) {
                        illegal_non_rfc2047_encoding = 1;
-                       i = len; ///< take a shortcut, it won't be more than one.
+                       i = len; /*< take a shortcut, it won't be more than one. */
                }
        }
        if (illegal_non_rfc2047_encoding) {
index 8ec1137380154abe0b9ac4074137b8d12b29de22..4706d0042f5693d5f7345315ade8f4fb398f6fce 100644 (file)
@@ -204,11 +204,12 @@ void display_room_directory(void)
                "static/up_pointer.gif",
                "static/down_pointer.gif",
                "static/sort_none.gif"};
-       char *RowNames[5] = {"",
-                           _("Filename"),
-                           _("Size"),
-                           _("Content"),
-                           _("Description")};
+       char *RowNames[5];
+       RowNames[0] = "";
+       RowNames[1] = _("Filename");
+       RowNames[2] = _("Size");
+       RowNames[3] = _("Content");
+       RowNames[4] = _("Description");
 
        Files = LoadFileList (&havepics);
        output_headers(1, 1, 2, 0, 0, 0);
@@ -447,7 +448,7 @@ void upload_file(void)
                {
                        blocksize = (WCC->upload_length - bytes_transmitted);
                }
-               serv_printf("WRIT %d", blocksize);
+               serv_printf("WRIT %ld", blocksize);
                serv_getln(buf, sizeof buf);
                if (buf[0] == '7')
                {
@@ -471,6 +472,7 @@ void upload_file(void)
  */
 void output_image()
 {
+       char blank_gif[SIZ];
        wcsession *WCC = WC;
        char buf[SIZ];
        off_t bytes;
@@ -503,7 +505,6 @@ void output_image()
         * Instead of an ugly 404, send a 1x1 transparent GIF
         * when there's no such image on the server.
         */
-       char blank_gif[SIZ];
        snprintf (blank_gif, SIZ, "%s%s", static_dirs[0], "/blank.gif");
        output_static(blank_gif);
 }
index 0258c2ffc828b1ff459fae8a85f88dd67ca0831c..9b05425bb8c4452e23e60128582b52206c85af70 100644 (file)
@@ -33,6 +33,13 @@ void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum,
        char weekday_labels[7][32];
        char month_labels[12][32];
        long weekstart = 0;
+       icalproperty *rrule = NULL;
+       struct icalrecurrencetype recur;
+
+       char *tabnames[3];
+       tabnames[0] = _("Event");
+       tabnames[1] = _("Attendees");
+       tabnames[2] = _("Recurrence");
 
        get_pref_long("weekstart", &weekstart, 17);
        if (weekstart > 6) weekstart = 0;
@@ -140,11 +147,6 @@ void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum,
        wprintf("<INPUT TYPE=\"hidden\" NAME=\"day\" VALUE=\"%s\">\n",
                bstr("day"));
 
-       char *tabnames[] = {
-               _("Event"),
-               _("Attendees"),
-               _("Recurrence")
-       };
 
        tabbed_dialog(3, tabnames);
        begin_tab(0, 3);
@@ -414,8 +416,6 @@ void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum,
 
        /* Recurrence tab */
        begin_tab(2, 3);
-       icalproperty *rrule = NULL;
-       struct icalrecurrencetype recur;
 
        rrule = icalcomponent_get_first_property(vevent, ICAL_RRULE_PROPERTY);
        if (rrule) {
index 779d458f4ee184034299bbddb21cace1bb578ccf..5c625d6676db36830edd099bcae79f8f2385afa6 100644 (file)
@@ -31,7 +31,7 @@ size_t wc_strftime(char *s, size_t max, const char *format, const struct tm *tm)
        if (wc_locales[WC->selected_language] == NULL) {
                return strftime(s, max, format, tm);
        }
-       else { // TODO: this gives empty strings on debian.
+       else { /* TODO: this gives empty strings on debian. */
                return strftime_l(s, max, format, tm, wc_locales[WC->selected_language]);
        }
 #else
index fc2cc6000f33a1ea0dffd2f2e342ef5581bc7c4c..241fb9eedd6924d4d94044a01ab3337347ff833c 100644 (file)
@@ -162,44 +162,6 @@ void httplang_to_locale(StrBuf *LocaleString)
        FreeStrBuf(&SBuf);
 }
 
-/* TODO: we skip the language weighting so far. */
-/* Accept-Language: 'de-de,en-us;q=0.7,en;q=0.3' */
-/* Accept-Language: de,en-ph;q=0.8,en-us;q=0.5,de-at;q=0.3 */
-//void httplang_to_locale(char *LocaleString)
-//{
-//     char selected_locale[16];
-//     int i, j;
-//     char lang[64];
-//     int num_accept = 0;
-//
-//     lprintf(9, "languageAccept: %s\n", LocaleString);
-//
-//     strcpy(selected_locale, "C");
-//     num_accept = num_tokens(LocaleString, ',');
-//
-//     for (i=num_accept-1; i>=0; --i) {
-//             extract_token(lang, LocaleString, i, ',', sizeof lang);
-//
-//             /* Strip out the weights; we don't use them.  Also convert
-//              * hyphens to underscores.
-//              */
-//             for (j=0; j<strlen(lang); ++j) {
-//                     if (lang[j] == '-') lang[j] = '_';
-//                     if (lang[j] == ';') lang[j] = 0;
-//             }
-//
-//             for (j=0; j<NUM_LANGS; ++j) {
-//                     if (!strncasecmp(lang, AvailLang[j], strlen(lang))) {
-//                             strcpy(selected_locale, AvailLang[j]);
-//                     }
-//             }
-//     }
-//
-//     lprintf(9, "language found: %s\n", selected_locale);
-//     set_selected_language(selected_locale);
-//}
-
-
 /**
  * \brief show the language chooser on the login dialog
  * depending on the browser locale change the sequence of the 
@@ -304,7 +266,7 @@ void initialize_locales(void) {
 
        for (i = 0; i < NUM_LANGS; ++i) {
                if (i == 0) {
-                       sprintf(buf, "%s", AvailLang[i]);       // locale 0 (C) is ascii, not utf-8
+                       sprintf(buf, "%s", AvailLang[i]);       /* locale 0 (C) is ascii, not utf-8 */
                }
                else {
                        sprintf(buf, "%s.UTF8", AvailLang[i]);
index add3b0021929ebe3072806906f481b5aefc9e2e7..378cdfbc5e922375921ce81a735a0d023fba4c2a 100644 (file)
@@ -9,6 +9,7 @@
 
 void display_graphics_upload(char *description, char *filename, char *uplurl)
 {
+       StrBuf *Buf;
        char buf[SIZ];
 
 
@@ -22,7 +23,6 @@ void display_graphics_upload(char *description, char *filename, char *uplurl)
        }
        output_headers(1, 1, 0, 0, 0, 0);
 
-       StrBuf *Buf;
        output_headers(1, 1, 1, 0, 0, 0);
 
        Buf = NewStrBufPlain(_("Image upload"), -1);
index 40b62d72c1506502d2831ad86d0d838d0c8aed19..85f643b83111cf7a44e6bc028f93552a431e7ece 100644 (file)
@@ -25,7 +25,7 @@ void groupdav_get_big_ics(void) {
                hprintf("Content-Type: text/plain\r\n");
                wprintf("%s\r\n",
                        &buf[4]
-                       );/// TODO: do we need to end-burst here?
+                       );/* TODO: do we need to end-burst here? */
                return;
        }
 
index cbb37f3853bba02ad57fbd738f7313a252842648..63d3a8dae9bf4bc6d66aa921ce42029abece2767 100644 (file)
@@ -176,15 +176,15 @@ void groupdav_put(const char *dav_pathname, char *dav_ifmatch,
 
        /* We created this item for the first time. */
        if (old_msgnum < 0L) {
+               char escaped_uid[1024];
                hprintf("HTTP/1.1 201 Created\r\n");
                lprintf(9, "HTTP/1.1 201 Created\r\n");
                groupdav_common_headers();
                hprintf("etag: \"%ld\"\r\n", new_msgnum);
                hprintf("Location: ");
                groupdav_identify_host();
-               hprintf("/groupdav/");/////TODO
+               hprintf("/groupdav/");/* TODO */
                hurlescputs(dav_roomname);
-               char escaped_uid[1024];
                euid_escapize(escaped_uid, dav_uid);
                hprintf("/%s\r\n", escaped_uid);
                end_burst();
index f24ca184dc554a2a54c059775eb1ff4fd85cfea3..e331cda67cc21f04347124d8399c9846b7601cf0 100644 (file)
@@ -273,7 +273,7 @@ void output_html(const char *supplied_charset, int treat_as_wiki, int msgnum, St
                        StrBufConvert(Source, Buf, &ic);
                        FreeStrBuf(&Buf);
                        iconv_close(ic);
-                       msg = (char*)ChrPtr(Source); //TODO: get rid of this.
+                       msg = (char*)ChrPtr(Source); /* TODO: get rid of this. */
                }
        }
                
@@ -425,7 +425,7 @@ void output_html(const char *supplied_charset, int treat_as_wiki, int msgnum, St
 
                                        nbspreviewptr = strstr(ptr, "&nbsp;");
                                        if (nbspreviewptr != NULL) {
-                                               ///*nbspreviewptr = '\0';
+                                               /* nbspreviewptr = '\0'; */
                                                linklen = nbspreviewptr - ptr;
                                        }
                                        if (ltreviewptr != 0)
index 271d0d6bac0fe139ff305cab229b79ef25952096..0cc9ceddc3f446e35f21a5fe4d680cc5b443a2c4 100644 (file)
@@ -28,7 +28,7 @@ void do_selected_iconbar(void) {
        }
 }
 
-void DontDeleteThis(void *Data){};
+void DontDeleteThis(void *Data){}
 
 #define IconbarIsEnabled(a, b) IconbarIsENABLED(a, sizeof(a) - 1, b)
 
@@ -55,11 +55,13 @@ void LoadIconSettings(void)
 {
        wcsession *WCC = WC;
        StrBuf *iconbar = NULL;
-       StrBuf *buf = NewStrBuf();;
-       StrBuf *key = NewStrBuf();
+       StrBuf *buf;
+       StrBuf *key;
        long val;
        int i, nTokens;
 
+       buf = NewStrBuf();;
+       key = NewStrBuf();
        WCC->current_iconbar = current_iconbar_menu;
        if (WCC->IconBarSetttings == NULL)
                WCC->IconBarSetttings = NewHash(1, NULL);
@@ -380,6 +382,7 @@ void do_iconbar(void) {
  * we generate its innerHTML...
  */
 void do_iconbar_roomlist(void) {
+       int ib_displayas;
                                
        WC->current_iconbar = current_iconbar_roomlist;
 
@@ -389,7 +392,6 @@ void do_iconbar_roomlist(void) {
         * their iconbars.  These should probably be set in a master
         * configuration somewhere.
         */
-       int ib_displayas;
 
        LoadIconSettings();
 
index aa2e07396b41128bd858cf9dc972bab5a9d413af..60de06cb5be02e70e2fdb9eb89ddeef23220dcac 100644 (file)
@@ -390,7 +390,7 @@ void display_shutdown(void)
                else
                {
                        serv_printf("SEXP broadcast|%s", message);
-                       serv_getln(buf, sizeof buf); // should we care?
+                       serv_getln(buf, sizeof buf); /* TODO: should we care? */
                        begin_burst();
                        output_headers(1, 0, 0, 0, 1, 0);
                        DoTemplate(HKEY("display_serverrestartpagedo"), NULL, NULL, 0);
index fadb68d707b6c5cdeb2ae15b9d31988297b75660..141a63a74f53dc0fca0d7199aeeaf870a85282f1 100644 (file)
@@ -34,6 +34,9 @@ int summcmp_rdate(const void *s1, const void *s2);
 
 typedef void (*MsgPartEvaluatorFunc)(message_summary *Sum, StrBuf *Buf);
 
+typedef struct _MsgPartEvaluatorStruct {
+       MsgPartEvaluatorFunc f;
+}MsgPartEvaluatorStruct;
 
 
 /*----------------------------------------------------------------------------*/
@@ -154,7 +157,7 @@ int read_message(StrBuf *Target, const char *tmpl, long tmpllen, long msgnum, in
                        if (Msg->MsgBody->size_known > 0) {
                                StrBuf_ServGetBLOB(Msg->MsgBody->Data, Msg->MsgBody->length);
                                state ++;
-                                       /// todo: check next line, if not 000, append following lines
+                               /*/ todo: check next line, if not 000, append following lines */
                        }
                        else if (1){
                                if (StrLength(Msg->MsgBody->Data) > 0)
@@ -179,9 +182,9 @@ int read_message(StrBuf *Target, const char *tmpl, long tmpllen, long msgnum, in
        /* look up the renderer, that will convert this mimeitem into the htmlized form */
        if (GetHash(MimeRenderHandler, SKEY(Buf), &vHdr) &&
            (vHdr != NULL)) {
-               RenderMimeFunc Render;
-               Render = (RenderMimeFunc)vHdr;
-               Render(Msg->MsgBody, NULL, FoundCharset);
+               RenderMimeFuncStruct *Render;
+               Render = (RenderMimeFuncStruct*)vHdr;
+               Render->f(Msg->MsgBody, NULL, FoundCharset);
        }
 
        if (StrLength(Msg->reply_references)> 0) {
@@ -336,7 +339,7 @@ void display_headers(void) {
 message_summary *ReadOneMessageSummary(StrBuf *RawMessage, const char *DefaultSubject, long MsgNum) 
 {
        void                 *vEval;
-       MsgPartEvaluatorFunc  Eval;
+       MsgPartEvaluatorStruct  *Eval;
        message_summary      *Msg;
        StrBuf *Buf;
        const char *buf;
@@ -363,9 +366,9 @@ message_summary *ReadOneMessageSummary(StrBuf *RawMessage, const char *DefaultSu
                ebuf = strchr(ChrPtr(Buf), '=');
                nBuf = ebuf - buf;
                if (GetHash(MsgEvaluators, buf, nBuf, &vEval) && vEval != NULL) {
-                       Eval = (MsgPartEvaluatorFunc) vEval;
+                       Eval = (MsgPartEvaluatorStruct*) vEval;
                        StrBufCutLeft(Buf, nBuf + 1);
-                       Eval(Msg, Buf);
+                       Eval->f(Msg, Buf);
                }
                else lprintf(1, "Don't know how to handle Message Headerline [%s]", ChrPtr(Buf));
        }
@@ -408,7 +411,6 @@ int load_msg_ptrs(char *servcmd, int with_headers)
                FreeStrBuf(&Buf);
                return (nummsgs);
        }
-// TODO                        if (with_headers) { //// TODO: Have Attachments?
        Buf2 = NewStrBuf();
        while (len = StrBuf_ServGetln(Buf),
               ((len != 3)  ||
@@ -581,11 +583,12 @@ void load_seen_flags(void)
        message_summary *Msg;
        const char *HashKey;
        long HKLen;
-       StrBuf *OldMsg = NewStrBuf();;
-       wcsession *WCC = WC;
        HashPos *at;
        void *vMsg;
+       StrBuf *OldMsg;
+       wcsession *WCC = WC;
 
+       OldMsg = NewStrBuf();
        serv_puts("GTSN");
        StrBuf_ServGetln(OldMsg);
        if (ChrPtr(OldMsg)[0] == '2') {
@@ -1100,7 +1103,7 @@ void post_message(void)
                const StrBuf *Bcc = NULL;
                const StrBuf *Wikipage = NULL;
                const StrBuf *my_email_addr = NULL;
-               StrBuf *CmdBuf = NULL;;
+               StrBuf *CmdBuf = NULL;
                StrBuf *references = NULL;
 
                if (havebstr("references"))
@@ -1283,7 +1286,7 @@ void display_enter(void)
                const StrBuf *Cc = NULL;
                const StrBuf *Bcc = NULL;
                const StrBuf *Wikipage = NULL;
-               StrBuf *CmdBuf = NULL;;
+               StrBuf *CmdBuf = NULL;
                const char CMD[] = "ENT0 0|%s|%d|0||%s||%s|%s|%s";
                
                Recp = sbstr("recp");
@@ -1319,7 +1322,7 @@ void display_enter(void)
                        }
                }
                else if (buf[0] != '2') {       /** Any other error means that we cannot continue */
-                       wprintf("<em>%s</em><br />\n", &buf[4]);/// -> important message
+                       wprintf("<em>%s</em><br />\n", &buf[4]);/*TODO -> important message */
                        return;
                }
        }
@@ -1550,7 +1553,7 @@ void MimeLoadData(wc_mime_attachment *Mime)
 {
        char buf[SIZ];
        off_t bytes;
-//// TODO: is there a chance the contenttype is different  to the one we know? 
+/* TODO: is there a chance the contenttype is different  to the one we know?    */
        serv_printf("DLAT %ld|%s", Mime->msgnum, ChrPtr(Mime->PartNum));
        serv_getln(buf, sizeof buf);
        if (buf[0] == '6') {
@@ -1563,7 +1566,7 @@ void MimeLoadData(wc_mime_attachment *Mime)
        }
        else {
                FlushStrBuf(Mime->Data);
-               /// TODO XImportant message
+               /* TODO XImportant message */
        }
 }
 
diff --git a/webcit/messages.h b/webcit/messages.h
new file mode 100644 (file)
index 0000000..904e6b9
--- /dev/null
@@ -0,0 +1,91 @@
+
+extern HashList *MsgHeaderHandler;
+extern HashList *MimeRenderHandler;
+
+typedef struct wc_mime_attachment wc_mime_attachment;
+typedef void (*RenderMimeFunc)(wc_mime_attachment *Mime, StrBuf *RawData, StrBuf *FoundCharset);
+typedef struct _RenderMimeFuncStruct {
+       RenderMimeFunc f;
+} RenderMimeFuncStruct;
+
+struct wc_mime_attachment {
+       int level;
+       StrBuf *Name;
+       StrBuf *FileName;
+       StrBuf *PartNum;
+       StrBuf *Disposition;
+       StrBuf *ContentType;
+       StrBuf *Charset;
+       StrBuf *Data;
+       size_t length;                     /* length of the mimeatachment */
+       long size_known;
+       long lvalue;               /* if we put a long... */
+       long msgnum;            /**< the message number on the citadel server derived from message_summary */
+       const RenderMimeFuncStruct *Renderer;
+};
+void DestroyMime(void *vMime);
+
+
+/*
+ * \brief message summary structure. ???
+ */
+typedef struct _message_summary {
+       time_t date;        /**< its creation date */
+       long msgnum;            /**< the message number on the citadel server */
+       int nhdr;
+       int format_type;
+       StrBuf *from;           /**< the author */
+       StrBuf *to;             /**< the recipient */
+       StrBuf *subj;           /**< the title / subject */
+       StrBuf *reply_inreplyto;
+       StrBuf *reply_references;
+       StrBuf *reply_to;
+       StrBuf *cccc;
+       StrBuf *hnod;
+       StrBuf *AllRcpt;
+       StrBuf *Room;
+       StrBuf *Rfca;
+       StrBuf *OtherNode;
+       const StrBuf *PartNum;
+
+       HashList *Attachments;  /**< list of Accachments */
+       HashList *Submessages;
+       HashList *AttachLinks;
+
+       HashList *AllAttach;
+
+       int is_new;         /**< is it yet read? */
+       int hasattachments;     /* does it have atachments? */
+
+
+       /** The mime part of the message */
+       wc_mime_attachment *MsgBody;
+} message_summary;
+void DestroyMessageSummary(void *vMsg);
+inline message_summary* GetMessagePtrAt(int n, HashList *Summ);
+
+typedef void (*ExamineMsgHeaderFunc)(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset);
+
+void evaluate_mime_part(message_summary *Msg, wc_mime_attachment *Mime);
+
+enum {
+       do_search,
+       headers,
+       readfwd,
+       readnew,
+       readold
+};
+
+typedef void (*readloop_servcmd)(char *buf, long bufsize);
+
+typedef struct _readloopstruct {
+       ConstStr name;
+       readloop_servcmd cmd;
+} readloop_struct;
+
+
+void readloop(long oper);
+int  read_message(StrBuf *Target, const char *tmpl, long tmpllen, long msgnum, int printable_view, const StrBuf *section);
+
+
+int load_msg_ptrs(char *servcmd, int with_headers);
index 90202273e07592b8d60dece96cb82675cee413af..abf6b55e4d834d863da3c94fbb8b84cd699d85ab 100644 (file)
@@ -63,7 +63,11 @@ void RegisterMsgHdr(const char *HeaderName, long HdrNLen, ExamineMsgHeaderFunc e
 
 void RegisterMimeRenderer(const char *HeaderName, long HdrNLen, RenderMimeFunc MimeRenderer)
 {
-       Put(MimeRenderHandler, HeaderName, HdrNLen, MimeRenderer, reference_free_handler);
+       RenderMimeFuncStruct *f;
+
+       f = (RenderMimeFuncStruct*) malloc(sizeof(RenderMimeFuncStruct));
+       f->f = MimeRenderer;
+       Put(MimeRenderHandler, HeaderName, HdrNLen, f, NULL);
        
 }
 
@@ -182,7 +186,7 @@ void examine_suff(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset) {
 void examine_path(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset) {return;}
 void examine_content_encoding(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
 {
-////TODO: do we care?
+/* TODO: do we care? */
 }
 
 void examine_nhdr(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
@@ -225,7 +229,8 @@ void examine_subj(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
        StrBuf_RFC822_to_Utf8(Msg->subj, HdrLine, WC->DefaultCharset, FoundCharset);
 }
 void tmplput_MAIL_SUMM_SUBJECT(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType)
-{/////TODO: Fwd: and RE: filter!!
+{/*////TODO: Fwd: and RE: filter!!*/
+
        message_summary *Msg = (message_summary*) Context;
        StrBufAppendTemplate(Target, nArgs, Tokens, Context, ContextType, Msg->subj, 0);
 }
@@ -498,7 +503,7 @@ void evaluate_mime_part(message_summary *Msg, wc_mime_attachment *Mime)
            GetHash(MimeRenderHandler, SKEY(Mime->ContentType), &vMimeRenderer) &&
            vMimeRenderer != NULL)
        {
-               Mime->Renderer = (RenderMimeFunc) vMimeRenderer;
+               Mime->Renderer = (RenderMimeFuncStruct*) vMimeRenderer;
                if (Msg->Submessages == NULL)
                        Msg->Submessages = NewHash(1,NULL);
                Put(Msg->Submessages, SKEY(Mime->PartNum), Mime, reference_free_handler);
@@ -902,9 +907,9 @@ void tmplput_MIME_Data(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void
 {
        wc_mime_attachment *mime = (wc_mime_attachment*) Context;
        if (mime->Renderer != NULL)
-               mime->Renderer(mime, NULL, NULL);
+               mime->Renderer->f(mime, NULL, NULL);
        StrBufAppendTemplate(Target, nArgs, Tokens, Context, ContextType, mime->Data, 0);
- /// TODO: check whether we need to load it now?
+       /* TODO: check whether we need to load it now? */
 }
 
 void tmplput_MIME_LoadData(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType)
index bd48e76315cc3263d919493a74d277381ad16fee..d95c6ea5e15fdbd252702553748d079c075571d6 100644 (file)
@@ -168,12 +168,7 @@ void edit_node(void) {
        HashList *NodeConfig;
        const StrBuf *Index;
        NodeConf *NewNode;
-/*
-       char buf[SIZ];
-       char node[SIZ];
-       char cnode[SIZ];
-       FILE *fp;
-*/
+
        if (havebstr("ok_button")) {
                Index = sbstr("index");
                NewNode = HttpGetNewNode();
@@ -187,85 +182,11 @@ void edit_node(void) {
                Put(NodeConfig, ChrPtr(Index), StrLength(Index), NewNode, DeleteNodeConf);
                save_net_conf(NodeConfig);
                DeleteHash(&NodeConfig);
-/*
-               strcpy(node, bstr("node") );
-               fp = tmpfile();
-               if (fp != NULL) {
-                       serv_puts("CONF getsys|application/x-citadel-ignet-config");
-                       serv_getln(buf, sizeof buf);
-                       if (buf[0] == '1') {
-                               while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
-                                       extract_token(cnode, buf, 0, '|', sizeof cnode);
-                                       if (strcasecmp(node, cnode)) {
-                                               fprintf(fp, "%s\n", buf);
-                                       }
-                               }
-                       rewind(fp);
-               }
-
-               serv_puts("CONF putsys|application/x-citadel-ignet-config");
-               serv_getln(buf, sizeof buf);
-               if (buf[0] == '4') {
-                       if (fp != NULL) {
-                               while (fgets(buf, sizeof buf, fp) != NULL) {
-                                       buf[strlen(buf)-1] = 0;
-                                       if (buf[0] != 0) {
-                                               serv_puts(buf);
-                                       }
-                               }
-                               fclose(fp);
-                       }
-                       serv_printf("%s|%s|%s|%s", 
-                               bstr("node"),
-                               bstr("secret"),
-                               bstr("host"),
-                               bstr("port") );
-                       }
-                       serv_puts("000");
-               }
-*/
        }
-
-       //display_netconf();
        url_do_template();
 }
 
 
-/**
- * \brief add a node
- */
-void display_add_node(void)
-{/*
-       output_headers(1, 1, 2, 0, 0, 0);
-       wprintf("<div id=\"banner\">\n");
-       wprintf("<h1>");
-       wprintf(_("Add a new node"));
-       wprintf("</h1>");
-       wprintf("</div>\n");
-
-       wprintf("<div id=\"content\" class=\"service\">\n");
-
-       wprintf("<FORM METHOD=\"POST\" action=\"edit_node\">\n");
-       wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
-       wprintf("<CENTER><TABLE border=0>\n");
-       wprintf("<TR><TD>%s</TD>", _("Node name"));
-       wprintf("<TD><INPUT TYPE=\"text\" NAME=\"node\" MAXLENGTH=\"16\"></TD></TR>\n");
-       wprintf("<TR><TD>%s</TD>", _("Shared secret"));
-       wprintf("<TD><INPUT TYPE=\"password\" NAME=\"secret\" MAXLENGTH=\"16\"></TD></TR>\n");
-       wprintf("<TR><TD>%s</TD>", _("Host or IP address"));
-       wprintf("<TD><INPUT TYPE=\"text\" NAME=\"host\" MAXLENGTH=\"64\"></TD></TR>\n");
-       wprintf("<TR><TD>%s</TD>", _("Port number"));
-       wprintf("<TD><INPUT TYPE=\"text\" NAME=\"port\" VALUE=\"504\" MAXLENGTH=\"8\"></TD></TR>\n");
-       wprintf("</TABLE><br />");
-               wprintf("<INPUT TYPE=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">", _("Add node"));
-       wprintf("&nbsp;");
-               wprintf("<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
-       wprintf("</CENTER></FORM>\n");
-
-       wDumpContent(1);
- */
-}
-
 /**
  * \brief modify an existing node
  */
@@ -297,131 +218,14 @@ void display_edit_node(void)
 
        DeleteHash(&NodeConfig);
        
-/*
-       char buf[512];
-       char node[256];
-       char cnode[256];
-       char csecret[256];
-       char chost[256];
-       char cport[256];
-
-       strcpy(node, bstr("node"));
-
-       output_headers(1, 1, 2, 0, 0, 0);
-       wprintf("<div id=\"banner\">\n");
-       wprintf("<h1>");
-       wprintf(_("Edit node configuration for "));
-       escputs(node);
-       wprintf("</h1>");
-       wprintf("</div>\n");
-
-       wprintf("<div id=\"content\" class=\"service\">\n");
-
-       serv_puts("CONF getsys|application/x-citadel-ignet-config");
-       serv_getln(buf, sizeof buf);
-       if (buf[0] == '1') {
-               while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
-                       extract_token(cnode, buf, 0, '|', sizeof cnode);
-                       extract_token(csecret, buf, 1, '|', sizeof csecret);
-                       extract_token(chost, buf, 2, '|', sizeof chost);
-                       extract_token(cport, buf, 3, '|', sizeof cport);
-
-                       if (!strcasecmp(node, cnode)) {
-                               wprintf("<FORM METHOD=\"POST\" action=\"edit_node\">\n");
-                               wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
-                               wprintf("<CENTER><TABLE border=0>\n");
-                               wprintf("<TR><TD>");
-                               wprintf(_("Node name"));
-                               wprintf("</TD>");
-                               wprintf("<TD><INPUT TYPE=\"text\" NAME=\"node\" MAXLENGTH=\"16\" VALUE=\"%s\"></TD></TR>\n", cnode);
-                               wprintf("<TR><TD>");
-                               wprintf(_("Shared secret"));
-                               wprintf("</TD>");
-                               wprintf("<TD><INPUT TYPE=\"password\" NAME=\"secret\" MAXLENGTH=\"16\" VALUE=\"%s\"></TD></TR>\n", csecret);
-                               wprintf("<TR><TD>");
-                               wprintf(_("Host or IP address"));
-                               wprintf("</TD>");
-                               wprintf("<TD><INPUT TYPE=\"text\" NAME=\"host\" MAXLENGTH=\"64\" VALUE=\"%s\"></TD></TR>\n", chost);
-                               wprintf("<TR><TD>");
-                               wprintf(_("Port number"));
-                               wprintf("</TD>");
-                               wprintf("<TD><INPUT TYPE=\"text\" NAME=\"port\" MAXLENGTH=\"8\" VALUE=\"%s\"></TD></TR>\n", cport);
-                               wprintf("</TABLE><br />");
-                               wprintf("<INPUT TYPE=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">",
-                                       _("Save changes"));
-                               wprintf("&nbsp;");
-                               wprintf("<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">",
-                                       _("Cancel"));
-                               wprintf("</CENTER></FORM>\n");
-                       }
-
-               }
-       }
-
-       else {          / ** command error getting configuration * /
-               wprintf("%s<br />\n", &buf[4]);
-       }
-
-       wDumpContent(1);
-*/
 }
 
 
-
-
-//CFG:IGNET:NODE
 /**
  * \brief display all configured nodes
  */
 void display_netconf(void)
 {
-/*
-       char buf[SIZ];
-       char node[SIZ];
-       output_headers(1, 1, 2, 0, 0, 0);
-       wprintf("<div id=\"banner\">\n");
-       wprintf("<h1>");
-       wprintf(_("Network configuration"));
-       wprintf("</h1>");
-       wprintf("</div>\n");
-
-       wprintf("<div id=\"content\" class=\"service\">\n");
-
-       wprintf("<CENTER>");
-       wprintf("<a href=\"display_add_node\">");
-       wprintf(_("Add a new node"));
-       wprintf("</A><br />\n");
-       wprintf("</CENTER>");
-
-       wprintf("<TABLE class=\"netconf_banner\"><TR><TD>");
-       wprintf("<SPAN CLASS=\"titlebar\">");
-       wprintf(_("Currently configured nodes"));
-       wprintf("</SPAN>\n");
-       wprintf("</TD></TR></TABLE>\n");
-       serv_puts("CONF getsys|application/x-citadel-ignet-config");
-       serv_getln(buf, sizeof buf);
-       if (buf[0] == '1') {
-               wprintf("<CENTER><TABLE border=0>\n");
-               while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
-                       extract_token(node, buf, 0, '|', sizeof node);
-                       wprintf("<TR><TD><FONT SIZE=+1>");
-                       escputs(node);
-                       wprintf("</FONT></TD>");
-                       wprintf("<TD><a href=\"display_edit_node&node=");
-                       urlescputs(node);
-                       wprintf("\">");
-                       wprintf(_("(Edit)"));
-                       wprintf("</A></TD>");
-                       wprintf("<TD><a href=\"display_confirm_delete_node&node=");
-                       urlescputs(node);
-                       wprintf("\">");
-                       wprintf(_("(Delete)"));
-                       wprintf("</A></TD>");
-                       wprintf("</TR>\n");
-               }
-               wprintf("</TABLE></CENTER>\n");
-       }
-*/
        wDumpContent(1);
 }
 
@@ -430,32 +234,6 @@ void display_netconf(void)
  */
 void display_confirm_delete_node(void)
 {
-/*
-       char node[SIZ];
-       output_headers(1, 1, 2, 0, 0, 0);
-       wprintf("<div id=\"banner\">\n");
-       wprintf("<h1>");
-       wprintf(_("Confirm delete"));
-       wprintf("</h1>");
-       wprintf("</div>\n");
-
-       wprintf("<div id=\"content\" class=\"service\" >\n");
-
-       strcpy(node, bstr("node"));
-       wprintf("<CENTER>");
-       wprintf(_("Are you sure you want to delete "));
-       wprintf("<FONT SIZE=+1>");
-       escputs(node);
-       wprintf("</FONT>?<br />\n");
-       wprintf("<a href=\"delete_node&node=");
-       urlescputs(node);
-       wprintf("\">");
-       wprintf(_("Yes"));
-       wprintf("</A>&nbsp;&nbsp;&nbsp;");
-       wprintf("<a href=\"display_netconf\">");
-       wprintf(_("No"));
-       wprintf("</A><br />\n");
-*/
        wDumpContent(1);
 }
 
@@ -492,41 +270,6 @@ void delete_node(void)
        
        url_do_template();
 
-/*
-       char buf[SIZ];
-       char node[SIZ];
-       char cnode[SIZ];
-       FILE *fp;
-
-       strcpy(node, bstr("node") );
-       fp = tmpfile();
-       if (fp != NULL) {
-               serv_puts("CONF getsys|application/x-citadel-ignet-config");
-               serv_getln(buf, sizeof buf);
-               if (buf[0] == '1') {
-                       while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
-                               extract_token(cnode, buf, 0, '|', sizeof cnode);
-                               if (strcasecmp(node, cnode)) {
-                                       fprintf(fp, "%s\n", buf);
-                               }
-                       }
-               }
-               rewind(fp);
-
-               serv_puts("CONF putsys|application/x-citadel-ignet-config");
-               serv_getln(buf, sizeof buf);
-               if (buf[0] == '4') {
-                       while (fgets(buf, sizeof buf, fp) != NULL) {
-                               buf[strlen(buf)-1] = 0;
-                               serv_puts(buf);
-                       }
-                       serv_puts("000");
-               }
-               fclose(fp);
-       }
-
-       display_netconf();
-*/
 }
 
 void 
@@ -539,7 +282,6 @@ InitModule_NETCONF
        WebcitAddUrlHandler(HKEY("display_netconf"), display_netconf, 0);
        WebcitAddUrlHandler(HKEY("display_confirm_delete_node"), display_confirm_delete_node, 0);
        WebcitAddUrlHandler(HKEY("delete_node"), delete_node, 0);
-       WebcitAddUrlHandler(HKEY("display_add_node"), display_add_node, 0);
        RegisterIterator("NODECONFIG", 0, NULL, load_netconf, NodeCfgSubst, DeleteHash, CTX_NODECONF, CTX_NONE);
 }
 /*@}*/
diff --git a/webcit/paramhandling.h b/webcit/paramhandling.h
new file mode 100644 (file)
index 0000000..35999ad
--- /dev/null
@@ -0,0 +1,41 @@
+/* URL / Mime Post parsing -> paramhandling.c */
+void upload_handler(char *name, char *filename, char *partnum, char *disp,
+                   void *content, char *cbtype, char *cbcharset,
+                   size_t length, char *encoding, char *cbid, void *userdata);
+
+void ParseURLParams(StrBuf *url);
+
+
+/* These may return NULL if not foud */
+#define sbstr(a) SBstr(a, sizeof(a) - 1)
+const StrBuf *SBSTR(const char *key);
+const StrBuf *SBstr(const char *key, size_t keylen);
+
+#define xbstr(a, b) (char*) XBstr(a, sizeof(a) - 1, b)
+const char *XBstr(const char *key, size_t keylen, size_t *len);
+const char *XBSTR(const char *key, size_t *len);
+
+#define lbstr(a) LBstr(a, sizeof(a) - 1)
+long LBstr(const char *key, size_t keylen);
+long LBSTR(const char *key);
+
+#define ibstr(a) IBstr(a, sizeof(a) - 1)
+int IBstr(const char *key, size_t keylen);
+int IBSTR(const char *key);
+
+#define havebstr(a) HaveBstr(a, sizeof(a) - 1)
+int HaveBstr(const char *key, size_t keylen);
+int HAVEBSTR(const char *key);
+
+#define yesbstr(a) YesBstr(a, sizeof(a) - 1)
+int YesBstr(const char *key, size_t keylen);
+int YESBSTR(const char *key);
+
+/* TODO: get rid of the non-const-typecast */
+#define bstr(a) (char*) Bstr(a, sizeof(a) - 1)
+const char *BSTR(const char *key);
+const char *Bstr(const char *key, size_t keylen);
+/* if you want to ease some parts by just parametring yourself... */
+#define putbstr(a, b) PutBstr(a, sizeof(a) - 1, b)
+void PutBstr(const char *key, long keylen, StrBuf *Value);
+
index 0ed7b68d729b9927d09fbecbe07e73cdc4ca85ac..b66a3bd383536baff970c2289aecc72a67ec49e0 100644 (file)
@@ -357,282 +357,6 @@ void set_ROOM_PREFS(const char *key, size_t keylen, StrBuf *value, int save_to_s
        FreeStrBuf(&pref_name);
 }
 
-/** 
- * \brief display form for changing your preferences and settings
- */
-void display_preferences(void)
-{
-       output_headers(1, 1, 1, 0, 0, 0);
-       StrBuf *ebuf = NULL;
-       int i;
-       long DayEnd, DayStart, WeekStart;
-       int UseSig, ShowEmptyFloors;
-       int time_format;
-       time_t tt;
-       struct tm tm;
-       char daylabel[32];
-       StrBuf *Buf;
-       StrBuf *Signature;
-
-       time_format = get_time_format_cached ();
-
-        wprintf("<div class=\"box\">\n");
-        wprintf("<div class=\"boxlabel\">");
-        wprintf(_("Preferences and settings"));
-        wprintf("</div>");
-
-        wprintf("<div class=\"boxcontent\">");
-
-       /** begin form */
-       wprintf("<form name=\"prefform\" action=\"set_preferences\" "
-               "method=\"post\">\n");
-       wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
-
-       /** begin table */
-        wprintf("<table class=\"altern\">\n");
-
-       /**
-        * Room list view
-        */
-       get_preference("roomlistview", &Buf);
-       wprintf("<tr class=\"even\"><td>");
-       wprintf(PrefGetLocalStr(HKEY("roomlistview")));
-       wprintf("</td><td>");
-
-       wprintf("<input type=\"radio\" name=\"roomlistview\" VALUE=\"folders\"");
-       if (!strcasecmp(ChrPtr(Buf), "folders")) wprintf(" checked");
-       wprintf(">");
-       wprintf(_("Tree (folders) view"));
-       wprintf("</input>&nbsp;&nbsp;&nbsp;");
-
-       wprintf("<input type=\"radio\" name=\"roomlistview\" VALUE=\"rooms\"");
-       if (IsEmptyStr(ChrPtr(Buf)) || !strcasecmp(ChrPtr(Buf), "rooms")) wprintf(" checked");
-       wprintf(">");
-       wprintf(_("Table (rooms) view"));
-       wprintf("</input>\n");
-
-       wprintf("</td></tr>\n");
-
-       /**
-        * Time hour format
-        */
-
-       wprintf("<tr class=\"odd\"><td>");
-       wprintf(PrefGetLocalStr(HKEY("calhourformat")));
-       wprintf("</td><td>");
-
-       wprintf("<input type=\"radio\" name=\"calhourformat\" VALUE=\"12\"");
-       if (time_format == WC_TIMEFORMAT_AMPM) 
-               wprintf(" checked");
-       wprintf(">");
-       wprintf(_("12 hour (am/pm)"));
-       wprintf("</input>&nbsp;&nbsp;&nbsp;");
-
-       wprintf("<input type=\"radio\" name=\"calhourformat\" VALUE=\"24\"");
-       if (time_format == WC_TIMEFORMAT_24)
-               wprintf(" checked");
-       wprintf(">");
-       wprintf(_("24 hour"));
-       wprintf("</input>\n");
-
-       wprintf("</td></tr>\n");
-
-       /**
-        * Calendar day view -- day start time
-        */
-       get_pref_long("daystart", &DayStart, 8);
-
-       wprintf("<tr class=\"even\"><td>");
-       wprintf(PrefGetLocalStr(HKEY("daystart")));
-       wprintf("</td><td>");
-
-       wprintf("<select name=\"daystart\" size=\"1\">\n");
-       for (i=0; i<=23; ++i) {
-
-               if (time_format == WC_TIMEFORMAT_24) {
-                       wprintf("<option %s value=\"%d\">%d:00</option>\n",
-                               ((DayStart == i) ? "selected" : ""),
-                               i, i
-                       );
-               }
-               else {
-                       wprintf("<option %s value=\"%d\">%s</option>\n",
-                               ((DayStart == i) ? "selected" : ""),
-                               i, hourname[i]
-                       );
-               }
-
-       }
-       wprintf("</select>\n");
-       wprintf("</td></tr>\n");
-
-       /**
-        * Calendar day view -- day end time
-        */
-       get_pref_long("dayend", &DayEnd, 17);
-
-       wprintf("<tr class=\"odd\"><td>");
-       wprintf(PrefGetLocalStr(HKEY("dayend")));
-       wprintf("</td><td>");
-
-       wprintf("<select name=\"dayend\" size=\"1\">\n");
-       for (i=0; i<=23; ++i) {
-
-               if (time_format == WC_TIMEFORMAT_24) {
-                       wprintf("<option %s value=\"%d\">%d:00</option>\n",
-                               ((DayEnd == i) ? "selected" : ""),
-                               i, i
-                       );
-               }
-               else {
-                       wprintf("<option %s value=\"%d\">%s</option>\n",
-                               ((DayEnd == i) ? "selected" : ""),
-                               i, hourname[i]
-                       );
-               }
-
-       }
-       wprintf("</select>\n");
-       wprintf("</td></tr>\n");
-
-       /**
-        * Day of week to begin calendar month view
-        */
-       get_pref_long("weekstart", &WeekStart, 17);
-       wprintf("<tr class=\"even\"><td>");
-       wprintf(PrefGetLocalStr(HKEY("weekstart")));
-       wprintf("</td><td>");
-
-       wprintf("<select name=\"weekstart\" size=\"1\">\n");
-
-       for (i=0; i<=1; ++i) {
-                tt = time(NULL);
-                localtime_r(&tt, &tm);
-               tm.tm_wday = i;
-                wc_strftime(daylabel, sizeof daylabel, "%A", &tm);
-
-               wprintf("<option %s value=\"%d\">%s</option>\n",
-                       ((WeekStart == i) ? "selected" : ""),
-                       i, daylabel
-               );
-       }
-
-       wprintf("</select>\n");
-       wprintf("</td></tr>\n");
-
-       /**
-        * Signature
-        */
-       get_pref_yesno("use_sig", &UseSig, 0);
-       wprintf("<tr class=\"odd\"><td>");
-       wprintf(_("Attach signature to email messages?"));
-       wprintf("</td><td>");
-
-       wprintf("       <script type=\"text/javascript\">                                       "
-               "       function show_or_hide_sigbox() {                                        "
-               "               if ( $F('yes_sig') ) {                                          "
-               "                       $('signature_box').style.display = 'inline';            "
-               "               }                                                               "
-               "               else {                                                          "
-               "                       $('signature_box').style.display = 'none';              "
-               "               }                                                               "
-               "       }                                                                       "
-               "       </script>                                                               "
-       );
-
-       wprintf(PrefGetLocalStr(HKEY("use_sig")));
-
-       wprintf("<input type=\"radio\" id=\"no_sig\" name=\"use_sig\" VALUE=\"no\"");
-       if (!UseSig) wprintf(" checked");
-       wprintf(" onChange=\"show_or_hide_sigbox();\" >");
-       wprintf(_("No signature"));
-       wprintf("</input>&nbsp,&nbsp;&nbsp;\n");
-
-       wprintf("<input type=\"radio\" id=\"yes_sig\" name=\"use_sig\" VALUE=\"yes\"");
-       if (UseSig) wprintf(" checked");
-       wprintf(" onChange=\"show_or_hide_sigbox();\" >");
-       wprintf(PrefGetLocalStr(HKEY("signature")));
-       wprintf("<div id=\"signature_box\">"
-               "<br><textarea name=\"signature\" cols=\"40\" rows=\"5\">"
-       );
-
-       get_preference("signature", &Signature);
-       ebuf = NewStrBuf();
-       StrBufEUid_unescapize(ebuf, Signature);
-       StrEscPuts(ebuf);
-       FreeStrBuf(&ebuf);
-       wprintf("</textarea>"
-               "</div>"
-       );
-
-       wprintf("</input>\n");
-
-       wprintf("</td></tr>\n");
-
-       wprintf("       <script type=\"text/javascript\">       "
-               "       show_or_hide_sigbox();                  "
-               "       </script>                               "
-       );
-
-       /** Character set to assume is in use for improperly encoded headers */
-       if (!get_preference("default_header_charset", &Buf)) {
-               Buf = NewStrBuf();
-               StrBufPrintf(Buf, "%s", "UTF-8");
-               set_preference("default_header_charset", Buf, 0);
-       }
-       wprintf("<tr class=\"even\"><td>");
-       wprintf(PrefGetLocalStr(HKEY("default_header_charset")));
-       wprintf("</td><td>");
-       wprintf("<input type=\"text\" NAME=\"default_header_charset\" MAXLENGTH=\"32\" VALUE=\"");
-       StrEscPuts(Buf); // here shouldn't be bad chars, so...
-       wprintf("\">");
-       wprintf("</td></tr>");
-
-       /**
-        * Show empty floors?
-        */
-
-       get_pref_yesno("emptyfloors", &ShowEmptyFloors, 0);
-       wprintf("<tr class=\"odd\"><td>");
-       wprintf(PrefGetLocalStr(HKEY("emptyfloors")));
-       wprintf("</td><td>");
-
-       wprintf("<input type=\"radio\" name=\"emptyfloors\" VALUE=\"yes\"");
-       if (ShowEmptyFloors) wprintf(" checked");
-       wprintf(">");
-       wprintf(_("Yes"));
-       wprintf("</input>&nbsp;&nbsp;&nbsp;");
-
-       wprintf("<input type=\"radio\" name=\"emptyfloors\" VALUE=\"no\"");
-       if (!ShowEmptyFloors) wprintf(" checked");
-       wprintf(">");
-       wprintf(_("No"));
-       wprintf("</input>\n");
-
-       wprintf("</td></tr>\n");
-
-       /** end table */
-       wprintf("</table>\n");
-
-       /** submit buttons */
-       wprintf("<div class=\"buttons\"> ");
-       wprintf("<input type=\"submit\" name=\"change_button\" value=\"%s\">"
-               "&nbsp;"
-               "<INPUT type=\"submit\" name=\"cancel_button\" value=\"%s\">\n",
-               _("Change"),
-               _("Cancel")
-       );
-       wprintf("</div>\n");
-
-       /** end form */
-       wprintf("</form>\n");
-       wprintf("</div>\n");
-       wDumpContent(1);
-}
-
-
-
-
 /*
  * Offer to make any page the user's "start page."
  */
@@ -862,7 +586,6 @@ void
 InitModule_PREFERENCES
 (void)
 {
-       WebcitAddUrlHandler(HKEY("display_preferences"), display_preferences, 0);
        WebcitAddUrlHandler(HKEY("set_preferences"), set_preferences, 0);
        WebcitAddUrlHandler(HKEY("change_start_page"), change_start_page, 0);
 
diff --git a/webcit/preferences.h b/webcit/preferences.h
new file mode 100644 (file)
index 0000000..d02ae73
--- /dev/null
@@ -0,0 +1,24 @@
+void load_preferences(void);
+void save_preferences(void);
+#define get_preference(a, b) get_PREFERENCE(a, sizeof(a) - 1, b)
+#define get_pref(a, b)       get_PREFERENCE(ChrPtr(a), StrLength(a), b)
+int get_PREFERENCE(const char *key, size_t keylen, StrBuf **value);
+#define set_preference(a, b, c) set_PREFERENCE(a, sizeof(a) - 1, b, c)
+#define set_pref(a, b, c)       set_PREFERENCE(ChrPtr(a), StrLength(a), b, c)
+void set_PREFERENCE(const char *key, size_t keylen, StrBuf *value, int save_to_server);
+
+#define get_pref_long(a, b, c) get_PREF_LONG(a, sizeof(a) - 1, b, c)
+int get_PREF_LONG(const char *key, size_t keylen, long *value, long Default);
+#define set_pref_long(a, b, c) set_PREF_LONG(a, sizeof(a) - 1, b, c)
+void set_PREF_LONG(const char *key, size_t keylen, long value, int save_to_server);
+
+#define get_pref_yesno(a, b, c) get_PREF_YESNO(a, sizeof(a) - 1, b, c)
+int get_PREF_YESNO(const char *key, size_t keylen, int *value, int Default);
+#define set_pref_yesno(a, b, c) set_PREF_YESNO(a, sizeof(a) - 1, b, c)
+void set_PREF_YESNO(const char *key, size_t keylen, int value, int save_to_server);
+
+#define get_room_pref(a) get_ROOM_PREFS(a, sizeof(a) - 1)
+StrBuf *get_ROOM_PREFS(const char *key, size_t keylen);
+
+#define set_room_pref(a, b, c) set_ROOM_PREFS(a, sizeof(a) - 1, b, c)
+void set_ROOM_PREFS(const char *key, size_t keylen, StrBuf *value, int save_to_server);
index 958c25d6e282bbd8a2e37463b00abb7e97981560..4c47999e4b85a2ac08a28491f2bfb2c218701617 100644 (file)
@@ -509,7 +509,7 @@ void embed_room_banner(char *got, int navbar_style) {
        svcallback("START", offer_start_page); 
  
        do_template("roombanner", NULL);
-       // roombanner contains this for mobile
+       /* roombanner contains this for mobile */
        if (navbar_style != navbar_none && !WC->is_mobile) { 
 
                wprintf("<div id=\"navbar\"><ul>");
@@ -1938,7 +1938,7 @@ void display_editroom(void)
 
                                wprintf("<td>%s</td>", extract_int(buf, 4) ? _("Yes") : _("No"));
 
-                               wprintf("<td>%ld</td>", extract_long(buf, 5));  // Fetching interval
+                               wprintf("<td>%ld</td>", extract_long(buf, 5));  /* Fetching interval */
                        
                                wprintf("<td class=\"button_link\">");
                                wprintf(" <a href=\"netedit&cmd=remove&tab=feeds&line=pop3client|");
@@ -2810,7 +2810,7 @@ void netedit(void) {
        char cmpb0[SIZ];
        char cmpb1[SIZ];
        int i, num_addrs;
-       // TODO: do line dynamic!
+       /*/ TODO: do line dynamic! */
        if (havebstr("line_pop3host")) {
                strcpy(line, bstr("prefix"));
                strcat(line, bstr("line_pop3host"));
@@ -3435,8 +3435,8 @@ void list_all_rooms_by_floor(const char *viewpref) {
                floor_mapping[fold[i].floor]=i;
        
        /** refresh the messages index for this room */
-//     serv_puts("GOTO ");
-//     while (serv_getln(buf, sizeof buf), strcmp(buf, "000"));
+/* TODO        serv_puts("GOTO ");
+   while (serv_getln(buf, sizeof buf), strcmp(buf, "000")); */
        /** Now add rooms */
        serv_puts("LKRA");
        serv_getln(buf, sizeof buf);
index 1369098903d67b07af80962942edee80593dc2f7..385091c4c0f1a15a8b0c3d62e99c6c66f1504f6a 100644 (file)
@@ -60,6 +60,7 @@ void display_rss(char *roomname, StrBuf *request_method)
        size_t obuflen;               /**< Length of output buffer              */
        char *osav;                   /**< Saved pointer to output buffer       */
 #endif
+       char description[SIZ] = "";
        char buf[SIZ];
        char date[30];
        char from[256];
@@ -124,7 +125,7 @@ void display_rss(char *roomname, StrBuf *request_method)
                        }
                }
        }
-       // Commented out. Play dumb for now, also doesn't work with anonrss hack
+       /*/ Commented out. Play dumb for now, also doesn't work with anonrss hack */
        /* if (if_modified_since > 0 && if_modified_since > now) {
                lprintf(3, "RSS: Feed not updated since the last time you looked\n");
                hprintf("HTTP/1.1 304 Not Modified\r\n");
@@ -133,10 +134,10 @@ void display_rss(char *roomname, StrBuf *request_method)
                gmtime_r(&now, &now_tm);
                strftime(date, sizeof date, "%a, %d %b %Y %H:%M:%S GMT", &now_tm);
                hprintf("Date: %s\r\n", date);
-               if (*msgn) hprintf("ETag: %s\r\n", msgn); */
+               if (*msgn) hprintf("ETag: %s\r\n", msgn); * /
                // wDumpContent(0);
                // return;
-       //} 
+               //} */
 
        /* Do RSS header */
        lprintf(3, "RSS: Yum yum! This feed is tasty!\n");
@@ -154,13 +155,12 @@ void display_rss(char *roomname, StrBuf *request_method)
        svput("XML_STYLE", WCS_STRING, "<?xml-stylesheet type=\"text/css\" href=\"/static/rss_browser.css\" ?>");
        svput("ROOM", WCS_STRING, WCC->wc_roomname);
        svput("NODE", WCS_STRING, serv_info.serv_humannode);
-       // Fix me
+       /* TODO:  Fix me */
        svprintf(HKEY("ROOM_LINK"), WCS_STRING, "%s://%s/", (is_https ? "https" : "http"), WCC->http_host);
        
        /** Get room info for description */
        serv_puts("RINF");
        serv_getln(buf, sizeof buf);
-       char description[SIZ] = "";
        if (buf[0] == '1') {
                while (1) {
                        serv_getln(buf, sizeof buf);
@@ -345,7 +345,7 @@ void display_rss(char *roomname, StrBuf *request_method)
                } 
 
 ENDBODY:
-               //wprintf("   </item>\n");
+               /* wprintf("   </item>\n"); */
                do_template("rss_item_end", NULL);
 ENDITEM:
                now = 0L;
index cd7b73a39b63971e674cd97a5d065a476485f08f..00b30479893f3de601944921a5d9fbe713f92138 100644 (file)
@@ -6,7 +6,6 @@
 #include "webserver.h"
 
 struct serv_info serv_info; /**< our connection data to the server */
-HashList *ServHash = NULL;//// TODO;
 /*
  * get info about the server we've connected to
  *
@@ -146,7 +145,7 @@ void _fmout(StrBuf *Target, char *align)
                /** Activate embedded URL's */
                url(buf, sizeof(buf));
 
-               escputs(buf);//// TODO: Target
+               escputs(buf);/*/ TODO: Target */
                StrBufAppendBufPlain(Target, HKEY("\n"), 0);
        }
        if (bq == 1) {
@@ -440,7 +439,7 @@ int read_server_binary(StrBuf *Ret, size_t total_len)
                {
                    if (ChrPtr(Buf)[0] == '6')
                    {
-                           StrBufCutLeft(Buf, 4); //thisblock = (size_t)atoi(&buf[4]);
+                           StrBufCutLeft(Buf, 4); /*/ TODO : thisblock = (size_t)atoi(&buf[4]); */
                            thisblock = StrTol(Buf);
                            if (!WC->connected) {
                                    FlushStrBuf(Ret); 
@@ -606,7 +605,7 @@ InitModule_SERVFUNC
        RegisterNamespace("SERV:REV_LEVEL", 0, 0, tmplput_serv_rev_level, CTX_NONE);
        RegisterNamespace("SERV:BBS_CITY", 0, 0, tmplput_serv_bbs_city, CTX_NONE);
        RegisterNamespace("SERV:MESG", 1, 2, tmplput_mesg, CTX_NONE);
-///    RegisterNamespace("SERV:LDAP_SUPP", 0, 0, tmplput_serv_ldap_enabled, 0);
+/*TODO //      RegisterNamespace("SERV:LDAP_SUPP", 0, 0, tmplput_serv_ldap_enabled, 0); */
 }
 
 /*@}*/
index ca17b24e1fcb6dfb2a265b531edd6de07ec7e0c5..dd2003c7e29b180a60c9bd77ea141403d68192fc 100644 (file)
@@ -83,10 +83,10 @@ void display_queue_msg(long msgnum)
                        }
 
                        if (!strcasecmp(keyword, "bounceto")) {
+                               char *atsign;
                                extract_token(sender, buf, 1, '|', sizeof sender);
 
                                /* Strip off local hostname if it's our own */
-                               char *atsign;
                                atsign = strchr(sender, '@');
                                if (atsign != NULL) {
                                        ++atsign;
index fc2bbec8e4c4002d920614d3381392f9978c3fee..ac0dd07874475cebb21101103975a623f39bb818 100644 (file)
@@ -496,14 +496,14 @@ void GetTemplateTokenString(WCTemplateToken *Tokens,
                break;
        case TYPE_LONG:
        case TYPE_PREFINT:
-               break; ///todo: string to text?
+               break; /* todo: string to text? */
        case TYPE_GETTEXT:
                *Value = _(Tokens->Params[N]->Start);
                *len = strlen(*Value);
                break;
        default:
                break;
-//todo log error
+/*/todo log error */
        }
 }
 
@@ -519,13 +519,13 @@ void print_value_of(StrBuf *Target, WCTemplateToken *Tokens, void *Context, int
        void *vVar;
 
        /*if (WCC->vars != NULL) PrintHash(WCC->vars, VarPrintTransition, VarPrintEntry);*/
-       /// TODO: debricated!
+       /* TODO: depricated! */
        if (Tokens->pName[0] == '=') {
                DoTemplate(Tokens->pName+1, Tokens->NameEnd - 1, NULL, NULL, 0);
        }
 
-//////TODO: if param[1] == "U" -> urlescape
-/// X -> escputs
+/*/////TODO: if param[1] == "U" -> urlescape
+/// X -> escputs */
        /** Page-local variables */
        if ((WCC->vars!= NULL) && GetHash(WCC->vars, Tokens->pName, Tokens->NameEnd, &vVar)) {
                ptr = (wcsubst*) vVar;
@@ -1090,7 +1090,6 @@ void *load_template(StrBuf *filename, StrBuf *Key, HashList *PutThere)
 }
 
 
-///void PrintTemplate(const char *Key, void *vSubst, int odd)
 const char* PrintTemplate(void *vSubst)
 {
        WCTemplate *Tmpl = vSubst;
@@ -1189,8 +1188,9 @@ int EvaluateToken(StrBuf *Target, WCTemplateToken *Tokens, WCTemplate *pTmpl, vo
        long AppendMeLen;
        HashHandler *Handler;
        void *vVar;
-// much output, since pName is not terminated...
-//     lprintf(1,"Doing token: %s\n",Token->pName);
+/* much output, since pName is not terminated...
+       lprintf(1,"Doing token: %s\n",Token->pName);
+*/
 
        switch (Tokens->Flags) {
        case SV_GETTEXT:
@@ -1431,8 +1431,10 @@ void DoTemplate(const char *templatename, long len, StrBuf *Target, void *Contex
                StrBufAppendPrintf(Target, "<pre>\ndidn't find Template [%s] %ld %ld\n</pre>", 
                                   templatename, len, 
                                   (long)strlen(templatename));
-///            dbg_PrintHash(Static, PrintTemplate, NULL);
-//             PrintHash(Static, VarPrintTransition, PrintTemplate);
+#if 0
+               dbg_PrintHash(Static, PrintTemplate, NULL);
+               PrintHash(Static, VarPrintTransition, PrintTemplate);
+#endif
                return;
        }
        if (vTmpl == NULL) 
@@ -1643,7 +1645,7 @@ int ConditionalVar(WCTemplateToken *Tokens, void *Context, int ContextType)
        case WCS_FUNCTION:
                return (subst->wcs_function!=NULL);
        case WCS_SERVCMD:
-               lprintf(1, "  -> Server [%s]\n", subst->wcs_value);////todo
+               lprintf(1, "  -> Server [%s]\n", subst->wcs_value);/* TODO */
                return 1;
        case WCS_STRING:
        case WCS_STRBUF:
@@ -1811,7 +1813,7 @@ CompareFunc RetrieveSort(long ContextType, const char *OtherPrefix,
                        BSort = get_room_pref("sort");
                }
                else {
-                       ////todo: nail prefprepend to sort, and lookup this!
+                       /*TODO: nail prefprepend to sort, and lookup this! */
                }
                if (BSort != NULL)
                        putbstr("SortBy", NewStrBufDup(BSort));
@@ -1845,7 +1847,7 @@ CompareFunc RetrieveSort(long ContextType, const char *OtherPrefix,
                        SortOrder = StrTol(Buf);
                }
                else {
-                       ////todo: nail prefprepend to sort, and lookup this!
+                       /* TODO: nail prefprepend to sort, and lookup this! */
                }
 
                if (Buf == NULL)
@@ -1910,7 +1912,7 @@ int GetSortMetric(WCTemplateToken *Tokens, SortStruct **Next, SortStruct **Param
                        BSort = get_room_pref("sort");
                }
                else {
-                       ////todo: nail prefprepend to sort, and lookup this!
+                       /* TODO: nail prefprepend to sort, and lookup this! */
                }
        }
 
@@ -1929,7 +1931,7 @@ int GetSortMetric(WCTemplateToken *Tokens, SortStruct **Next, SortStruct **Param
                        *SortOrder = StrTol(get_room_pref("SortOrder"));
                }
                else {
-                       ////todo: nail prefprepend to sort, and lookup this!
+                       /* TODO: nail prefprepend to sort, and lookup this! */
                }
        }
        if (*SortOrder > 2)
diff --git a/webcit/subst.h b/webcit/subst.h
new file mode 100644 (file)
index 0000000..58eaa79
--- /dev/null
@@ -0,0 +1,165 @@
+
+extern HashList *Conditionals;
+extern HashList *GlobalNS;
+extern HashList *Iterators;
+extern HashList *WirelessTemplateCache;
+extern HashList *WirelessLocalTemplateCache;
+extern HashList *TemplateCache;
+extern HashList *LocalTemplateCache;
+
+
+#define TYPE_STR   1
+#define TYPE_LONG  2
+#define TYPE_PREFSTR 3
+#define TYPE_PREFINT 4
+#define TYPE_GETTEXT 5
+#define TYPE_BSTR 6
+#define MAXPARAM  20
+
+
+/*
+ * \brief Values for wcs_type
+ */
+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 */
+};
+
+
+
+typedef struct _TemplateParam {
+       const char *Start;
+       int Type;
+       long len;
+       long lvalue;
+} TemplateParam;
+
+/* make a template token a lookup key: */
+#define TKEY(a) Tokens->Params[a]->Start, Tokens->Params[a]->len
+typedef struct _TemplateToken {
+       const StrBuf *FileName; /* Reference to print error messages; not to be freed */
+       StrBuf *FlatToken;
+       long Line;
+       const char *pTokenStart;
+       size_t TokenStart;
+       size_t TokenEnd;
+       const char *pTokenEnd;
+       int Flags;
+       void *PreEval;
+
+       const char *pName;
+       size_t NameEnd;
+
+       int HaveParameters;
+       int nParameters;
+       TemplateParam *Params[MAXPARAM];
+} WCTemplateToken;
+
+typedef void (*WCHandlerFunc)();
+
+
+/*
+ * \brief Dynamic content for variable substitution in templates
+ */
+typedef struct _wcsubst {
+       int wcs_type;                       /* which type of Substitution are we */
+       char wcs_key[32];                   /* copy of our hashkey for debugging */
+       StrBuf *wcs_value;                  /* if we're a string, keep it here */
+       long lvalue;                        /* type long? keep data here */
+       int ContextRequired;                /* do we require a context type? */
+       WCHandlerFunc wcs_function; /* funcion hook ???*/
+} wcsubst;
+
+#define CTX_NONE 0
+#define CTX_SITECFG 1
+#define CTX_SESSION 2
+#define CTX_INETCFG 3
+#define CTX_VNOTE 4
+#define CTX_WHO 5
+#define CTX_PREF 6
+#define CTX_NODECONF 7
+#define CTX_USERLIST 8
+#define CTX_MAILSUM 9
+#define CTX_MIME_ATACH 10
+#define CTX_STRBUF 12
+#define CTX_LONGVECTOR 13
+
+
+void RegisterNS(const char *NSName, long len, 
+               int nMinArgs, 
+               int nMaxArgs, 
+               WCHandlerFunc HandlerFunc,
+               int ContextRequired);
+#define RegisterNamespace(a, b, c, d, e) RegisterNS(a, sizeof(a)-1, b, c, d, e)
+
+typedef int (*WCConditionalFunc)(WCTemplateToken *Token, void *Context, int ContextType);
+typedef struct _ConditionalStruct {
+       const char *PlainName;
+       int nParams;
+       int ContextRequired;
+       WCConditionalFunc CondF;
+} ConditionalStruct;
+void RegisterConditional(const char *Name, long len, 
+                        int nParams,
+                        WCConditionalFunc CondF, 
+                        int ContextRequired);
+
+
+
+typedef void (*SubTemplFunc)(StrBuf *TemplBuffer, void *Context, WCTemplateToken *Token);
+typedef HashList *(*RetrieveHashlistFunc)(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType);
+typedef void (*HashDestructorFunc) (HashList **KillMe);
+void RegisterITERATOR(const char *Name, long len, /* Our identifier */
+                     int AdditionalParams,       /* doe we use more parameters? */
+                     HashList *StaticList,       /* pointer to webcit lifetime hashlists */
+                     RetrieveHashlistFunc GetHash, /* else retrieve the hashlist by calling this function */
+                     SubTemplFunc DoSubTempl,       /* call this function on each iteration for svput & friends */
+                     HashDestructorFunc Destructor, /* use this function to shut down the hash; NULL if its a reference */
+                     int ContextType,               /* which context do we provide to the subtemplate? */
+                     int XPectContextType);         /* which context do we expct to be called in? */
+#define RegisterIterator(a, b, c, d, e, f, g, h) RegisterITERATOR(a, sizeof(a)-1, b, c, d, e, f, g, h)
+
+void GetTemplateTokenString(WCTemplateToken *Tokens,
+                           int N, 
+                           const char **Value, 
+                           long *len);
+
+
+void SVPut(char *keyname, size_t keylen, int keytype, char *Data);
+#define svput(a, b, c) SVPut(a, sizeof(a) - 1, b, c)
+void SVPutLong(char *keyname, size_t keylen, long Data);
+#define svputlong(a, b) SVPutLong(a, sizeof(a) - 1, b)
+void svprintf(char *keyname, size_t keylen, int keytype, const char *format,...) __attribute__((__format__(__printf__,4,5)));
+void SVPRINTF(char *keyname, int keytype, const char *format,...) __attribute__((__format__(__printf__,3,4)));
+void SVCALLBACK(char *keyname, WCHandlerFunc fcn_ptr);
+void SVCallback(char *keyname, size_t keylen,  WCHandlerFunc fcn_ptr);
+#define svcallback(a, b) SVCallback(a, sizeof(a) - 1, b)
+
+void SVPUTBuf(const char *keyname, int keylen, const StrBuf *Buf, int ref);
+#define SVPutBuf(a, b, c); SVPUTBuf(a, sizeof(a) - 1, b, c)
+
+void DoTemplate(const char *templatename, long len, StrBuf *Target, void *Context, int ContextType);
+#define do_template(a, b) DoTemplate(a, sizeof(a) -1, NULL, b, 0);
+void url_do_template(void);
+
+int CompareSubstToToken(TemplateParam *ParamToCompare, TemplateParam *ParamToLookup);
+int CompareSubstToStrBuf(StrBuf *Compare, TemplateParam *ParamToLookup);
+
+void StrBufAppendTemplate(StrBuf *Target, 
+                         int nArgs, 
+                         WCTemplateToken *Tokens,
+                         void *Context, int ContextType,
+                         const StrBuf *Source, int FormatTypeIndex);
+CompareFunc RetrieveSort(long ContextType, const char *OtherPrefix, 
+                        const char *Default, long ldefault, long DefaultDirection);
+void RegisterSortFunc(const char *name, long len, 
+                     const char *prepend, long preplen,
+                     CompareFunc Forward, 
+                     CompareFunc Reverse, 
+                     long ContextType);
+
+void dbg_print_longvector(long *LongVector);
index ca9bf2045eb1102227755fbed07e82c6b582a6a5..312dc65ab98efba853d4954b0265a70e517e4a50 100644 (file)
@@ -501,7 +501,7 @@ void display_edituser(char *supplied_username, int is_new) {
        MajorStatus = ChrPtr(Buf)[0];
        StrBufCutLeft(Buf, 4);
        if (MajorStatus != '2') {
-               ///TODO ImportantMessage
+               /*TODO ImportantMessage */
                sprintf(error_message,
                        "<img src=\"static/error.gif\" align=center>"
                        "%s<br /><br />\n", ChrPtr(Buf));
index 78b6b8c25499fd6608537ac97981f0c6bef8883c..c2a4c02fa424f99d5fc5b36c9bc4c24d8891c922 100644 (file)
@@ -15,7 +15,7 @@
  */
 long unescape_input(char *buf)
 {
-       int a, b;
+       unsigned int a, b;
        char hex[3];
        long buflen;
        long len;
@@ -71,7 +71,7 @@ long stresc(char *target, long tSize, char *strbuf, int nbsp, int nolinebreaks)
         *target = '\0';
         aptr = strbuf;
         bptr = target;
-        eptr = target + tSize - 6; // our biggest unit to put in... 
+        eptr = target + tSize - 6; /* our biggest unit to put in...  */
  
  
         while ((bptr < eptr) && !IsEmptyStr(aptr) ){
diff --git a/webcit/wc_gettext.h b/webcit/wc_gettext.h
new file mode 100644 (file)
index 0000000..9a9d89b
--- /dev/null
@@ -0,0 +1,11 @@
+#ifdef ENABLE_NLS
+void initialize_locales(void);
+void ShutdownLocale(void);
+#endif
+void TmplGettext(StrBuf *Target, int nTokens, WCTemplateToken *Token);
+void offer_languages(StrBuf *Target, int nArgs, WCTemplateToken *Token, void *Context, int ContextType);
+void set_selected_language(const char *);
+void go_selected_language(void);
+void stop_selected_language(void);
+void preset_locale(void);
+void httplang_to_locale(StrBuf *LocaleString);
index 9303f65e641eb1524419ef1417ebf6a8abc9fd53..05a966fab7984420f791b98a03deb38a38ad01d7 100644 (file)
@@ -521,7 +521,7 @@ int is_mobile_ua(char *user_agent) {
       } else if (strstr(user_agent, "Opera Mobi") != NULL) {
        return 1;
       } else if (strstr(user_agent, "Firefox/2.0.0 Opera 9.51 Beta") != NULL) {
-                // For some reason a new install of Opera 9.51beta decided to spoof.
+             /*  For some reason a new install of Opera 9.51beta decided to spoof. */
          return 1;
          }
       return 0;
@@ -597,7 +597,7 @@ void session_loop(HashList *HTTPHeaders, StrBuf *ReqLine, StrBuf *request_method
                index[a] = arg[a-1];
                sizes[a] = sizeof arg[a-1];
        }
-////   index[9] = &foo; todo
+/*///  index[9] = &foo; todo */
        nBackDots = 0;
        nEmpty = 0;
        for ( a = 0; a < 9; ++a)
@@ -830,7 +830,7 @@ void session_loop(HashList *HTTPHeaders, StrBuf *ReqLine, StrBuf *request_method
                        }
                }
        }
-////////todo: restore language in this case
+/*///////todo: restore language in this case */
        /*
         * Functions which can be performed without logging in
         */
index bfed02edab22994b7421b7c87e507b738e57c138..8c6104a9934e2fd7281724dc75465f42b22324b0 100644 (file)
 #undef PACKAGE_BUGREPORT
 #include "sysdep.h"
 
-////////#include "hash.h"
+#include "subst.h"
+#include "wc_gettext.h"
+#include "messages.h"
+#include "paramhandling.h"
+#include "preferences.h"
+
 
 #ifdef HAVE_OPENSSL
 /* Work around RedHat's b0rken OpenSSL includes */
@@ -255,223 +260,8 @@ struct roomlisting {
 };
 
 
-#define TYPE_STR   1
-#define TYPE_LONG  2
-#define TYPE_PREFSTR 3
-#define TYPE_PREFINT 4
-#define TYPE_GETTEXT 5
-#define TYPE_BSTR 6
-#define MAXPARAM  20
-
-
-typedef struct _TemplateParam {
-       const char *Start;
-       int Type;
-       long len;
-       long lvalue;
-} TemplateParam;
-
-/* make a template token a lookup key: */
-#define TKEY(a) Tokens->Params[a]->Start, Tokens->Params[a]->len
-typedef struct _TemplateToken {
-       const StrBuf *FileName; /* Reference to print error messages; not to be freed */
-       StrBuf *FlatToken;
-       long Line;
-       const char *pTokenStart;
-       size_t TokenStart;
-       size_t TokenEnd;
-       const char *pTokenEnd;
-       int Flags;
-       void *PreEval;
-
-       const char *pName;
-       size_t NameEnd;
-
-       int HaveParameters;
-       int nParameters;
-       TemplateParam *Params[MAXPARAM];
-} WCTemplateToken;
-
-typedef void (*WCHandlerFunc)();
-
-
-/*
- * \brief Dynamic content for variable substitution in templates
- */
-typedef struct _wcsubst {
-       int wcs_type;                       /* which type of Substitution are we */
-       char wcs_key[32];                   /* copy of our hashkey for debugging */
-       StrBuf *wcs_value;                  /* if we're a string, keep it here */
-       long lvalue;                        /* type long? keep data here */
-       int ContextRequired;                /* do we require a context type? */
-       WCHandlerFunc wcs_function; /* funcion hook ???*/
-} wcsubst;
-
-#define CTX_NONE 0
-#define CTX_SITECFG 1
-#define CTX_SESSION 2
-#define CTX_INETCFG 3
-#define CTX_VNOTE 4
-#define CTX_WHO 5
-#define CTX_PREF 6
-#define CTX_NODECONF 7
-#define CTX_USERLIST 8
-#define CTX_MAILSUM 9
-#define CTX_MIME_ATACH 10
-#define CTX_STRBUF 12
-#define CTX_LONGVECTOR 13
-
-
-void RegisterNS(const char *NSName, long len, 
-               int nMinArgs, 
-               int nMaxArgs, 
-               WCHandlerFunc HandlerFunc,
-               int ContextRequired);
-#define RegisterNamespace(a, b, c, d, e) RegisterNS(a, sizeof(a)-1, b, c, d, e)
-
-typedef int (*WCConditionalFunc)(WCTemplateToken *Token, void *Context, int ContextType);
-typedef struct _ConditionalStruct {
-       const char *PlainName;
-       int nParams;
-       int ContextRequired;
-       WCConditionalFunc CondF;
-} ConditionalStruct;
-void RegisterConditional(const char *Name, long len, 
-                        int nParams,
-                        WCConditionalFunc CondF, 
-                        int ContextRequired);
-
-
-
-typedef void (*SubTemplFunc)(StrBuf *TemplBuffer, void *Context, WCTemplateToken *Token);
-typedef HashList *(*RetrieveHashlistFunc)(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType);
-typedef void (*HashDestructorFunc) (HashList **KillMe);
-void RegisterITERATOR(const char *Name, long len, /* Our identifier */
-                     int AdditionalParams,       /* doe we use more parameters? */
-                     HashList *StaticList,       /* pointer to webcit lifetime hashlists */
-                     RetrieveHashlistFunc GetHash, /* else retrieve the hashlist by calling this function */
-                     SubTemplFunc DoSubTempl,       /* call this function on each iteration for svput & friends */
-                     HashDestructorFunc Destructor, /* use this function to shut down the hash; NULL if its a reference */
-                     int ContextType,               /* which context do we provide to the subtemplate? */
-                     int XPectContextType);         /* which context do we expct to be called in? */
-#define RegisterIterator(a, b, c, d, e, f, g, h) RegisterITERATOR(a, sizeof(a)-1, b, c, d, e, f, g, h)
-
-void GetTemplateTokenString(WCTemplateToken *Tokens,
-                           int N, 
-                           const char **Value, 
-                           long *len);
-
-
-void SVPut(char *keyname, size_t keylen, int keytype, char *Data);
-#define svput(a, b, c) SVPut(a, sizeof(a) - 1, b, c)
-void SVPutLong(char *keyname, size_t keylen, long Data);
-#define svputlong(a, b) SVPutLong(a, sizeof(a) - 1, b)
-void svprintf(char *keyname, size_t keylen, int keytype, const char *format,...) __attribute__((__format__(__printf__,4,5)));
-void SVPRINTF(char *keyname, int keytype, const char *format,...) __attribute__((__format__(__printf__,3,4)));
-void SVCALLBACK(char *keyname, WCHandlerFunc fcn_ptr);
-void SVCallback(char *keyname, size_t keylen,  WCHandlerFunc fcn_ptr);
-#define svcallback(a, b) SVCallback(a, sizeof(a) - 1, b)
-
-void SVPUTBuf(const char *keyname, int keylen, const StrBuf *Buf, int ref);
-#define SVPutBuf(a, b, c); SVPUTBuf(a, sizeof(a) - 1, b, c)
-
-void DoTemplate(const char *templatename, long len, StrBuf *Target, void *Context, int ContextType);
-#define do_template(a, b) DoTemplate(a, sizeof(a) -1, NULL, b, 0);
-void url_do_template(void);
-
-int CompareSubstToToken(TemplateParam *ParamToCompare, TemplateParam *ParamToLookup);
-int CompareSubstToStrBuf(StrBuf *Compare, TemplateParam *ParamToLookup);
-
-void StrBufAppendTemplate(StrBuf *Target, 
-                         int nArgs, 
-                         WCTemplateToken *Tokens,
-                         void *Context, int ContextType,
-                         const StrBuf *Source, int FormatTypeIndex);
-CompareFunc RetrieveSort(long ContextType, const char *OtherPrefix, 
-                        const char *Default, long ldefault, long DefaultDirection);
-void RegisterSortFunc(const char *name, long len, 
-                     const char *prepend, long preplen,
-                     CompareFunc Forward, 
-                     CompareFunc Reverse, 
-                     long ContextType);
-
-void dbg_print_longvector(long *LongVector);
-
-/*
- * \brief Values for wcs_type
- */
-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 */
-};
-
-
-
-typedef struct wc_mime_attachment wc_mime_attachment;
-typedef void (*RenderMimeFunc)(wc_mime_attachment *Mime, StrBuf *RawData, StrBuf *FoundCharset);
-struct wc_mime_attachment {
-       int level;
-       StrBuf *Name;
-       StrBuf *FileName;
-       StrBuf *PartNum;
-       StrBuf *Disposition;
-       StrBuf *ContentType;
-       StrBuf *Charset;
-       StrBuf *Data;
-       size_t length;                     /* length of the mimeatachment */
-       long size_known;
-       long lvalue;               /* if we put a long... */
-       long msgnum;            /**< the message number on the citadel server derived from message_summary */
-       RenderMimeFunc Renderer;
-};
-void DestroyMime(void *vMime);
-
-
-/*
- * \brief message summary structure. ???
- */
-typedef struct _message_summary {
-       time_t date;        /**< its creation date */
-       long msgnum;            /**< the message number on the citadel server */
-       int nhdr;
-       int format_type;
-       StrBuf *from;           /**< the author */
-       StrBuf *to;             /**< the recipient */
-       StrBuf *subj;           /**< the title / subject */
-       StrBuf *reply_inreplyto;
-       StrBuf *reply_references;
-       StrBuf *reply_to;
-       StrBuf *cccc;
-       StrBuf *hnod;
-       StrBuf *AllRcpt;
-       StrBuf *Room;
-       StrBuf *Rfca;
-       StrBuf *OtherNode;
-       const StrBuf *PartNum;
-
-       HashList *Attachments;  /**< list of Accachments */
-       HashList *Submessages;
-       HashList *AttachLinks;
-
-       HashList *AllAttach;
-
-       int is_new;         /**< is it yet read? */
-       int hasattachments;     /* does it have atachments? */
-
-
-       /** The mime part of the message */
-       wc_mime_attachment *MsgBody;
-} message_summary;
-void DestroyMessageSummary(void *vMsg);
-inline message_summary* GetMessagePtrAt(int n, HashList *Summ);
 
-typedef void (*ExamineMsgHeaderFunc)(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset);
 
-void evaluate_mime_part(message_summary *Msg, wc_mime_attachment *Mime);
 
 
 
@@ -677,16 +467,7 @@ extern time_t if_modified_since;
 extern int follow_xff;
 extern HashList *HandlerHash;
 extern HashList *PreferenceHooks;
-extern HashList *WirelessTemplateCache;
-extern HashList *WirelessLocalTemplateCache;
-extern HashList *TemplateCache;
-extern HashList *LocalTemplateCache;
-extern HashList *GlobalNS;
-extern HashList *Iterators;
 extern HashList *ZoneHash;
-extern HashList *Conditionals;
-extern HashList *MsgHeaderHandler;
-extern HashList *MimeRenderHandler;
 extern HashList *SortHash;
 
 void InitialiseSemaphores(void);
@@ -731,47 +512,6 @@ int Flathash(const char *str, long len);
 
 
 
-/* URL / Mime Post parsing -> paramhandling.c */
-void upload_handler(char *name, char *filename, char *partnum, char *disp,
-                   void *content, char *cbtype, char *cbcharset,
-                   size_t length, char *encoding, char *cbid, void *userdata);
-
-void ParseURLParams(StrBuf *url);
-
-
-/* These may return NULL if not foud */
-#define sbstr(a) SBstr(a, sizeof(a) - 1)
-const StrBuf *SBSTR(const char *key);
-const StrBuf *SBstr(const char *key, size_t keylen);
-
-#define xbstr(a, b) (char*) XBstr(a, sizeof(a) - 1, b)
-const char *XBstr(const char *key, size_t keylen, size_t *len);
-const char *XBSTR(const char *key, size_t *len);
-
-#define lbstr(a) LBstr(a, sizeof(a) - 1)
-long LBstr(const char *key, size_t keylen);
-long LBSTR(const char *key);
-
-#define ibstr(a) IBstr(a, sizeof(a) - 1)
-int IBstr(const char *key, size_t keylen);
-int IBSTR(const char *key);
-
-#define havebstr(a) HaveBstr(a, sizeof(a) - 1)
-int HaveBstr(const char *key, size_t keylen);
-int HAVEBSTR(const char *key);
-
-#define yesbstr(a) YesBstr(a, sizeof(a) - 1)
-int YesBstr(const char *key, size_t keylen);
-int YESBSTR(const char *key);
-
-/* TODO: get rid of the non-const-typecast */
-#define bstr(a) (char*) Bstr(a, sizeof(a) - 1)
-const char *BSTR(const char *key);
-const char *Bstr(const char *key, size_t keylen);
-/* if you want to ease some parts by just parametring yourself... */
-#define putbstr(a, b) PutBstr(a, sizeof(a) - 1, b)
-void PutBstr(const char *key, long keylen, StrBuf *Value);
-
 
 
 void UrlescPutStrBuf(const StrBuf *strbuf);
@@ -806,23 +546,7 @@ void dump_vars(void);
 void embed_main_menu(void);
 void serv_read(char *buf, int bytes);
 
-enum {
-       do_search,
-       headers,
-       readfwd,
-       readnew,
-       readold
-};
-
-typedef void (*readloop_servcmd)(char *buf, long bufsize);
-
-typedef struct _readloopstruct {
-       ConstStr name;
-       readloop_servcmd cmd;
-} readloop_struct;
 void SetAccessCommand(long Oper);
-void readloop(long oper);
-int  read_message(StrBuf *Target, const char *tmpl, long tmpllen, long msgnum, int printable_view, const StrBuf *section);
 void do_addrbook_view(addrbookent *addrbook, int num_ab);
 void fetch_ab_name(message_summary *Msg, char *namebuf);
 void display_vcard(StrBuf *Target, const char *vcard_source, char alpha, int full, char *storename, long msgnum);
@@ -881,30 +605,6 @@ void do_change_view(int);
 void folders(void);
 
 
-void load_preferences(void);
-void save_preferences(void);
-#define get_preference(a, b) get_PREFERENCE(a, sizeof(a) - 1, b)
-#define get_pref(a, b)       get_PREFERENCE(ChrPtr(a), StrLength(a), b)
-int get_PREFERENCE(const char *key, size_t keylen, StrBuf **value);
-#define set_preference(a, b, c) set_PREFERENCE(a, sizeof(a) - 1, b, c)
-#define set_pref(a, b, c)       set_PREFERENCE(ChrPtr(a), StrLength(a), b, c)
-void set_PREFERENCE(const char *key, size_t keylen, StrBuf *value, int save_to_server);
-
-#define get_pref_long(a, b, c) get_PREF_LONG(a, sizeof(a) - 1, b, c)
-int get_PREF_LONG(const char *key, size_t keylen, long *value, long Default);
-#define set_pref_long(a, b, c) set_PREF_LONG(a, sizeof(a) - 1, b, c)
-void set_PREF_LONG(const char *key, size_t keylen, long value, int save_to_server);
-
-#define get_pref_yesno(a, b, c) get_PREF_YESNO(a, sizeof(a) - 1, b, c)
-int get_PREF_YESNO(const char *key, size_t keylen, int *value, int Default);
-#define set_pref_yesno(a, b, c) set_PREF_YESNO(a, sizeof(a) - 1, b, c)
-void set_PREF_YESNO(const char *key, size_t keylen, int value, int save_to_server);
-
-#define get_room_pref(a) get_ROOM_PREFS(a, sizeof(a) - 1)
-StrBuf *get_ROOM_PREFS(const char *key, size_t keylen);
-
-#define set_room_pref(a, b, c) set_ROOM_PREFS(a, sizeof(a) - 1, b, c)
-void set_ROOM_PREFS(const char *key, size_t keylen, StrBuf *value, int save_to_server);
 
 void display_addressbook(long msgnum, char alpha);
 void offer_start_page(StrBuf *Target, int nArgs, WCTemplateToken *Token, void *Context, int ContextType);
@@ -922,8 +622,6 @@ void parse_calendar_view_request(struct calview *c);
 void render_calendar_view(struct calview *c);
 void do_tasks_view(void);
 void calendar_summary_view(void);
-int load_msg_ptrs(char *servcmd, int with_headers);
-void free_attachments(wcsession *sess);
 void free_march_list(wcsession *wcf);
 void display_rules_editor_inner_div(void);
 void generate_uuid(char *);
@@ -959,17 +657,12 @@ int ical_ctdl_is_overlap(
                         struct icaltimetype t2end
 );
 
-#ifdef ENABLE_NLS
-void initialize_locales(void);
-void ShutdownLocale(void);
-#endif
-void TmplGettext(StrBuf *Target, int nTokens, WCTemplateToken *Token);
 
 extern char *months[];
 extern char *days[];
 int read_server_binary(StrBuf *Ret, size_t total_len);
 int StrBuf_ServGetBLOB(StrBuf *buf, long BlobSize);
-int read_server_text(StrBuf *Buf, long *nLines);;
+int read_server_text(StrBuf *Buf, long *nLines);
 int goto_config_room(void);
 long locate_user_vcard(char *username, long usernum);
 void sleeeeeeeeeep(int);
@@ -978,12 +671,6 @@ long unescape_input(char *buf);
 void do_selected_iconbar(void);
 void spawn_another_worker_thread(void);
 void display_rss(char *roomname, StrBuf *request_method);
-void offer_languages(StrBuf *Target, int nArgs, WCTemplateToken *Token, void *Context, int ContextType);
-void set_selected_language(const char *);
-void go_selected_language(void);
-void stop_selected_language(void);
-void preset_locale(void);
-void httplang_to_locale(StrBuf *LocaleString);
 void StrEndTab(StrBuf *Target, int tabnum, int num_tabs);
 void StrBeginTab(StrBuf *Target, int tabnum, int num_tabs);
 void StrTabbedDialog(StrBuf *Target, int num_tabs, StrBuf *tabnames[]);
@@ -996,6 +683,7 @@ int xtoi(const char *in, size_t len);
 const char *get_selected_language(void);
 void webcit_fmt_date(char *buf, time_t thetime, int brief);
 int fetch_http(char *url, char *target_buf, int maxbytes);
+void free_attachments(wcsession *sess);
 
 int is_mobile_ua(char *user_agent);
 
@@ -1018,12 +706,6 @@ int client_read_sslbuffer(StrBuf *buf, int timeout);
 void client_write_ssl(const StrBuf *Buf);
 #endif
 
-#ifdef HAVE_ZLIB
-#include <zlib.h>
-int ZEXPORT compress_gzip(Bytef * dest, size_t * destLen,
-                          const Bytef * source, uLong sourceLen, int level);
-#endif
-
 void utf8ify_rfc822_string(char *buf);
 
 void begin_burst(void);
index 1398f1616926ccc41ee9f6fee25c1c938bcc7cf5..d285f6dbb16c89fb9b37f65ad29615971ecb3d6e 100644 (file)
@@ -210,7 +210,7 @@ int client_read_to(int *sock, StrBuf *Target, StrBuf *Buf, int bytes, int timeou
                       (retval >= 0))
                        retval = client_read_sslbuffer(Buf, timeout);
                if (retval >= 0) {
-                       StrBufAppendBuf(Target, Buf, 0); /// todo: Buf > bytes?
+                       StrBufAppendBuf(Target, Buf, 0); /* todo: Buf > bytes? */
 #ifdef HTTP_TRACING
                        write(2, "\033[32m", 5);
                        write(2, buf, bytes);
@@ -225,7 +225,7 @@ int client_read_to(int *sock, StrBuf *Target, StrBuf *Buf, int bytes, int timeou
        }
 #endif
 
-       if (StrLength(Buf) > 0) {//// todo: what if Buf > bytes?
+       if (StrLength(Buf) > 0) {/*/// todo: what if Buf > bytes?*/
                StrBufAppendBuf(Target, Buf, 0);
        }
        retval = StrBufReadBLOB(Target, 
@@ -374,48 +374,6 @@ int client_read(int *sock, StrBuf *Target, StrBuf *buf, int bytes)
 }
 
 
-/*
- * Get a LF-terminated line of text from the client.
- * (This is implemented in terms of client_read() and could be
- * justifiably moved out of sysdep.c)
- *
- * sock                socket fd to get client line from
- * buf         buffer to write read data to
- * bufsiz      how many bytes to read
- *
- * returns the number of bytes read
- */
-/////int client_getln(int *sock, char *buf, int bufsiz)
-/////{
-/////  int i, retval;
-/////
-/////  /* Read one character at a time.*/
-/////  for (i = 0; *sock > 0; i++) {
-/////          retval = client_read(sock, &buf[i], 1);
-/////          if (retval < 0)
-/////                  return retval;
-/////          if (retval != 1 || buf[i] == '\n' || i == (bufsiz-1))
-/////                  break;
-/////          if ( (!isspace(buf[i])) && (!isprint(buf[i])) ) {
-/////                  /* Non printable character recieved from client */
-/////                  return(-1);
-/////          }
-/////  }
-/////
-/////  /* If we got a long line, discard characters until the newline. */
-/////  if (i == (bufsiz-1))
-/////          while (buf[i] != '\n' && retval == 1)
-/////                  retval = client_read(sock, &buf[i], 1);
-/////
-/////  /*
-/////   * Strip any trailing non-printable characters.
-/////   */
-/////  buf[i] = 0;
-/////  while ((i > 0) && (!isprint(buf[i - 1]))) {
-/////          buf[--i] = 0;
-/////  }
-/////  return (retval);
-/////}
 
 /*
  * Shut us down the regular way.
@@ -498,7 +456,6 @@ int ClientGetLine(int *sock, StrBuf *Target, StrBuf *CLineBuf)
  */
 pid_t current_child;
 void graceful_shutdown(int signum) {
-//     kill(current_child, signum);
        char wd[SIZ];
        FILE *FD;
        int fd;
@@ -559,16 +516,12 @@ void start_daemon(char *pid_file)
                        exit(errno);
                }
        
-               else if (current_child == 0) {  // child process
-//                     signal(SIGTERM, graceful_shutdown);
+               else if (current_child == 0) {  /* child process */
                        signal(SIGHUP, graceful_shutdown);
 
                        return; /* continue starting webcit. */
                }
-       
-               else { // watcher process
-//                     signal(SIGTERM, SIG_IGN);
-//                     signal(SIGHUP, SIG_IGN);
+               else { /* watcher process */
                        if (pid_file) {
                                fp = fopen(pid_file, "w");
                                if (fp != NULL) {
@@ -651,7 +604,7 @@ void spawn_another_worker_thread()
        pthread_attr_destroy(&attr);
 }
 
-//#define DBG_PRINNT_HOOKS_AT_START
+/* #define DBG_PRINNT_HOOKS_AT_START */
 #ifdef DBG_PRINNT_HOOKS_AT_START
 const char foobuf[32];
 const char *nix(void *vptr) {snprintf(foobuf, 32, "%0x", (long) vptr); return foobuf;}
@@ -812,7 +765,6 @@ int main(int argc, char **argv)
                start_daemon(pidfile);
        }
        else {
-///            signal(SIGTERM, graceful_shutdown);
                signal(SIGHUP, graceful_shutdown);
        }
 
@@ -1032,19 +984,19 @@ void worker_entry(void)
                        if (msock > 0)  ret = select(msock+1, &tempset, NULL, NULL,  &tv);
                        end_critical_section(S_SELECT);
                        if ((ret < 0) && (errno != EINTR) && (errno != EAGAIN))
-                       {// EINTR and EAGAIN are thrown but not of interest.
+                       {/* EINTR and EAGAIN are thrown but not of interest. */
                                lprintf(2, "accept() failed:%d %s\n",
                                        errno, strerror(errno));
                        }
                        else if ((ret > 0) && (msock > 0) && FD_ISSET(msock, &tempset))
-                       {// Successfully selected, and still not shutting down? Accept!
+                       {/* Successfully selected, and still not shutting down? Accept! */
                                ssock = accept(msock, NULL, 0);
                        }
                        
                } while ((msock > 0) && (ssock < 0)  && (time_to_die == 0));
 
                if ((msock == -1)||(time_to_die))
-               {// ok, we're going down.
+               {/* ok, we're going down. */
                        int shutdown = 0;
 
                        /* the first to come here will have to do the cleanup.
@@ -1058,11 +1010,11 @@ void worker_entry(void)
                        }
                        end_critical_section(S_SHUTDOWN);
                        if (shutdown == 1)
-                       {// we're the one to cleanup the mess.
+                       {/* we're the one to cleanup the mess. */
                                lprintf(2, "I'm master shutdown: tagging sessions to be killed.\n");
                                shutdown_sessions();
                                lprintf(2, "master shutdown: waiting for others\n");
-                               sleeeeeeeeeep(1); // wait so some others might finish...
+                               sleeeeeeeeeep(1); /* wait so some others might finish... */
                                lprintf(2, "master shutdown: cleaning up sessions\n");
                                do_housekeeping();
                                lprintf(2, "master shutdown: cleaning up libical\n");
@@ -1080,7 +1032,7 @@ void worker_entry(void)
                        if (ssock > 0) close (ssock);
                        lprintf(2, "inbetween.");
                        pthread_exit(NULL);
-               } else { // Got it? do some real work!
+               } else { /* Got it? do some real work! */
                        /* Set the SO_REUSEADDR socket option */
                        i = 1;
                        setsockopt(ssock, SOL_SOCKET, SO_REUSEADDR,
index 68b33d80676c73ee396ee7cfc2bd727ac4cd8b45..b4a9771977de1baf7f5d3ad67588e0fcf43255de 100644 (file)
@@ -120,7 +120,6 @@ void terminate_session(void)
 
        serv_printf("TERM %s", bstr("which_session"));
        serv_getln(buf, sizeof buf);
-       ///who();
        url_do_template();
 }