* added gcc printf format checking to wprintf
authorWilfried Göesgens <willi@citadel.org>
Wed, 9 Jul 2008 00:52:34 +0000 (00:52 +0000)
committerWilfried Göesgens <willi@citadel.org>
Wed, 9 Jul 2008 00:52:34 +0000 (00:52 +0000)
* corrected warnings of the above incidents
* adopted strbuf in config handling
* added multiline config handling

34 files changed:
webcit/auth.c
webcit/calendar.c
webcit/calendar_view.c
webcit/context_loop.c
webcit/crypto.c
webcit/downloads.c
webcit/event.c
webcit/floors.c
webcit/fmt_date.c
webcit/graphics.c
webcit/html2html.c
webcit/iconbar.c
webcit/inetconf.c
webcit/mainmenu.c
webcit/messages.c
webcit/netconf.c
webcit/notes.c
webcit/openid.c
webcit/paging.c
webcit/preferences.c
webcit/roomops.c
webcit/rss.c
webcit/setup_wizard.c
webcit/sieve.c
webcit/siteconfig.c
webcit/subst.c
webcit/sysmsgs.c
webcit/tabs.c
webcit/tcp_sockets.c
webcit/useredit.c
webcit/vcard_edit.c
webcit/webcit.c
webcit/webcit.h
webcit/who.c

index 94bc438cbdc3130c17293999fee37fb904b4fa53..d85ad0cb2c09bf377caf807c2d356d8a21a47462 100644 (file)
@@ -227,10 +227,9 @@ void become_logged_in(char *user, char *pass, char *serv_response)
                extract_token(WC->cs_inet_email, &buf[4], 3, '|', sizeof WC->cs_inet_email);
        }
 
-       get_preference("current_iconbar", buf, sizeof buf);
-       WC->current_iconbar = atoi(buf);
+       get_pref_long("current_iconbar", &WC->current_iconbar, current_iconbar_menu);
 
-       get_preference("floordiv_expanded", WC->floordiv_expanded, sizeof WC->floordiv_expanded);
+       get_preference("floordiv_expanded", &WC->floordiv_expanded);
 }
 
 
@@ -487,7 +486,7 @@ void finalize_openid_login(void)
  */
 void do_welcome(void)
 {
-       char buf[SIZ];
+       StrBuf *Buf;
 #ifdef XXX_NOT_FINISHED_YET_XXX
        FILE *fp;
        int i;
@@ -529,15 +528,15 @@ void do_welcome(void)
        /*
         * Go to the user's preferred start page
         */
-       get_preference("startpage", buf, sizeof buf);
-       if (IsEmptyStr(buf)) {
-               safestrncpy(buf, "dotskip&room=_BASEROOM_", sizeof buf);
-               set_preference("startpage", buf, 1);
+       if (!get_preference("startpage", &Buf)) {
+               Buf = NewStrBuf ();
+               StrBufPrintf(Buf, "dotskip&room=_BASEROOM_");
+               set_preference("startpage", Buf, 1);
        }
-       if (buf[0] == '/') {
-               strcpy(buf, &buf[1]);
+       if (ChrPtr(Buf)[0] == '/') {
+               StrBufCutLeft(Buf, 1);
        }
-       http_redirect(buf);
+       http_redirect(ChrPtr(Buf));
 }
 
 
@@ -545,11 +544,9 @@ void do_welcome(void)
  * Disconnect from the Citadel server, and end this WebCit session
  */
 void end_webcit_session(void) {
-       char buf[256];
-
+       
        if (WC->logged_in) {
-               sprintf(buf, "%d", WC->current_iconbar);
-               set_preference("current_iconbar", buf, 0);
+               set_pref_long("current_iconbar", WC->current_iconbar, 0);
                set_preference("floordiv_expanded", WC->floordiv_expanded, 1);
        }
 
@@ -733,7 +730,7 @@ void validate(void)
        wprintf(_("Select access level for this user:"));
        wprintf("<br />\n");
        for (a = 0; a <= 6; ++a) {
-               wprintf("<a href=\"validate?nonce=%ld?user=", WC->nonce);
+               wprintf("<a href=\"validate?nonce=%d?user=", WC->nonce);
                urlescputs(user);
                wprintf("&axlevel=%d\">%s</A>&nbsp;&nbsp;&nbsp;\n",
                        a, axdefs[a]);
@@ -807,7 +804,7 @@ void display_changepw(void)
        }
 
        wprintf("<form name=\"changepwform\" action=\"changepw\" method=\"post\">\n");
-       wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
+       wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
        wprintf("<table class=\"altern\" ");
        wprintf("<tr class=\"even\"><td>");
        wprintf(_("Enter new password:"));
index ddd6fa251d177f19426b6c11df8328f9cc8a0b7e..41395ef1155afb416efb7724bb65f2785f51a0f5 100644 (file)
@@ -527,7 +527,7 @@ void display_edit_individual_task(icalcomponent *supplied_vtodo, long msgnum, ch
        wprintf("<div class=\"boxcontent\">\n");
        wprintf("<FORM METHOD=\"POST\" action=\"save_task\">\n");
        wprintf("<div style=\"display: none;\">\n       ");
-       wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
+       wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
        wprintf("<INPUT TYPE=\"hidden\" NAME=\"msgnum\" VALUE=\"%ld\">\n",
                msgnum);
        wprintf("</div>");
index 6681389d9ee2d45fbaea5641aca3cf5a68388b1a..4796713174648eb902be7ac40616ca46f5a92efb 100644 (file)
@@ -19,8 +19,7 @@ void embeddable_mini_calendar(int year, int month, char *urlformat)
        time_t colheader_time;
        struct tm colheader_tm;
        char colheader_label[32];
-       int weekstart = 0;
-       char weekstart_buf[16];
+       long weekstart = 0;
        char url[256];
        char div_id[256];
        char escaped_urlformat[256];
@@ -29,8 +28,7 @@ void embeddable_mini_calendar(int year, int month, char *urlformat)
 
        /* Determine what day to start.
        */
-       get_preference("weekstart", weekstart_buf, sizeof weekstart_buf);
-       weekstart = atoi(weekstart_buf);
+       get_pref_long("weekstart", &weekstart, 17);
 
        /*
        * Now back up to the 1st of the month...
@@ -480,14 +478,12 @@ void calendar_month_view(int year, int month, int day) {
        struct tm colheader_tm;
        char colheader_label[32];
        int chg_month = 0;
-       int weekstart = 0;
-       char weekstart_buf[16];
+       long weekstart = 0;
 
        /*
         * Determine what day to start
         */
-       get_preference("weekstart", weekstart_buf, sizeof weekstart_buf);
-       weekstart = atoi(weekstart_buf);
+       get_pref_long("weekstart", &weekstart, 17);
 
        /*
         * Now back up to the 1st of the month...
@@ -702,7 +698,7 @@ void calendar_brief_month_view(int year, int month, int day) {
        wprintf("<table width=100%% border=0 cellpadding=1 cellspacing=1 "
                "bgcolor=#EEEECC><TR>");
        wprintf("</tr>\n");
-       wprintf("<tr><td colspan=\"100%\">\n");
+       wprintf("<tr><td colspan=\"100%%\">\n");
 
        /* Now do 35 days */
        for (i = 0; i < 35; ++i) {
@@ -715,7 +711,7 @@ void calendar_brief_month_view(int year, int month, int day) {
                /* Before displaying Sunday, start a new CELL */
                if ((i % 7) == 0) {
                        wc_strftime(&weeknumber[0], sizeof(weeknumber), "%U", &tm);
-                       wprintf("<table border='0' bgcolor=\"#EEEECC\" width='100%'> <tr><th colspan='4'>%s %s</th></tr>"
+                       wprintf("<table border='0' bgcolor=\"#EEEECC\" width='100%%'> <tr><th colspan='4'>%s %s</th></tr>"
                                "   <tr><td>%s</td><td width=70%%>%s</td><td>%s</td><td>%s</td></tr>\n",
                                _("Week"), 
                                weeknumber,
@@ -1045,9 +1041,8 @@ void calendar_day_view_display_events(time_t thetime,
 void calendar_day_view(int year, int month, int day) {
        int hour;
        struct icaltimetype today, yesterday, tomorrow;
-       int daystart = 8;
-       int dayend = 17;
-       char daystart_str[16], dayend_str[16];
+       long daystart;
+       long dayend;
        struct tm d_tm;
        char d_str[128];
        int time_format;
@@ -1057,10 +1052,8 @@ void calendar_day_view(int year, int month, int day) {
        int gap = 0;
 
        time_format = get_time_format_cached ();
-       get_preference("daystart", daystart_str, sizeof daystart_str);
-       if (!IsEmptyStr(daystart_str)) daystart = atoi(daystart_str);
-       get_preference("dayend", dayend_str, sizeof dayend_str);
-       if (!IsEmptyStr(dayend_str)) dayend = atoi(dayend_str);
+       get_pref_long("daystart", &daystart, 8);
+       get_pref_long("dayend", &dayend, 17);
        
        /* Today's date */
        memset(&d_tm, 0, sizeof d_tm);
@@ -1130,7 +1123,7 @@ void calendar_day_view(int year, int month, int day) {
                 wprintf("<dt class=\"hour\"     "
                         "style=\"               "
                         "position: absolute;    "
-                        "top: %dpx; left: 0px;  "
+                        "top: %ldpx; left: 0px;  "
                         "height: %dpx;          "
                         "\" >                   "
                         "<a href=\"display_edit_event?msgnum=0&calview=day"
@@ -1158,7 +1151,7 @@ void calendar_day_view(int year, int month, int day) {
                 wprintf("<dt class=\"extrahour\"     "
                         "style=\"               "
                         "position: absolute;    "
-                        "top: %dpx; left: 0px;  "
+                        "top: %ldpx; left: 0px; "
                         "height: %dpx;          "
                         "\" >                   "
                         "<a href=\"display_edit_event?msgnum=0&calview=day"
index 8d7bb9e6666acef7b190aeaf9267bfe80e27e23e..27e643093d1c2cdda8b155ab1dc298e09e9c5808 100644 (file)
@@ -101,7 +101,8 @@ void do_housekeeping(void)
                free_attachments(sessions_to_kill);
                free_march_list(sessions_to_kill);
                DeleteHash(&(sessions_to_kill->hash_prefs));
-               
+               DeleteHash(&(sessions_to_kill->IconBarSetttings));
+
                pthread_mutex_unlock(&sessions_to_kill->SessionMutex);
                sptr = sessions_to_kill->next;
                free(sessions_to_kill);
index 34aff829349c3004cc033f71dd776ce921096032..bfb84cb5de52c9b92bc5372765f76e02cc9e59c4 100644 (file)
@@ -202,14 +202,22 @@ void init_ssl(void)
                                                MBSTRING_ASC, "Mount Kisco", -1, -1, 0);
                                        */
 
-                                       X509_NAME_add_entry_by_txt(name, "O",
-                                               MBSTRING_ASC, "Organization name", -1, -1, 0);
-
-                                       X509_NAME_add_entry_by_txt(name, "OU",
-                                               MBSTRING_ASC, "Citadel server", -1, -1, 0);
-
-                                       X509_NAME_add_entry_by_txt(name, "CN",
-                                               MBSTRING_ASC, "*", -1, -1, 0);
+                                       X509_NAME_add_entry_by_txt(
+                                               name, "O",
+                                               MBSTRING_ASC, 
+                                               (unsigned char*)"Organization name",
+                                               -1, -1, 0);
+
+                                       X509_NAME_add_entry_by_txt(
+                                               name, "OU",
+                                               MBSTRING_ASC, 
+                                               (unsigned char*)"Citadel server",
+                                               -1, -1, 0);
+
+                                       X509_NAME_add_entry_by_txt(
+                                               name, "CN",
+                                               MBSTRING_ASC, 
+                                               (unsigned char*)"*", -1, -1, 0);
                                
                                        X509_REQ_set_subject_name(req, name);
 
index 50456bb1a0997de112f7204be7acfd785be58563..86c5108ab86e816ab4a17834f8860d72c990a11b 100644 (file)
@@ -279,7 +279,7 @@ void display_room_directory(void)
                        "name=\"upload_file_form\""
                        ">\n"
                );
-               wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
+               wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
 
                wprintf(_("Upload a file:"));
                wprintf("&nbsp;<input NAME=\"filename\" SIZE=16 TYPE=\"file\">&nbsp;\n");
index f2575508b12dd72a280c40c8a940bdbf68071449..6a72c0b973499a8e4bc15356e9d30cbf34514c6e 100644 (file)
@@ -93,7 +93,7 @@ void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum,
        *************************************************************/
 
        wprintf("<FORM NAME=\"EventForm\" METHOD=\"POST\" action=\"save_event\">\n");
-       wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
+       wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
 
        wprintf("<INPUT TYPE=\"hidden\" NAME=\"msgnum\" VALUE=\"%ld\">\n",
                msgnum);
index f662ab408a3b16963ec96d5611d91333366c8477..e06dfaa8d864bff8741912d023ac3af8d967acff 100644 (file)
@@ -94,7 +94,7 @@ void display_floorconfig(char *prepend_html)
                        "<INPUT TYPE=\"text\" NAME=\"floorname\" "
                        "VALUE=\"%s\" MAXLENGTH=\"250\">\n",
                        floornum, floorname);
-               wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
+               wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
                wprintf("<INPUT TYPE=\"SUBMIT\" NAME=\"sc\" "
                        "VALUE=\"%s\">"
                        "</FORM></TD>", _("Change name"));
@@ -108,7 +108,7 @@ void display_floorconfig(char *prepend_html)
                        "<INPUT TYPE=\"text\" NAME=\"floorcss\" "
                        "VALUE=\"%s\" MAXLENGTH=\"250\">\n",
                        floornum, floorname);
-               wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
+               wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
                wprintf("<INPUT TYPE=\"SUBMIT\" NAME=\"sc\" "
                        "VALUE=\"%s\">"
                        "</FORM></TD>", _("Change CSS"));
@@ -118,7 +118,7 @@ void display_floorconfig(char *prepend_html)
 
        wprintf("<TR><TD>&nbsp;</TD>"
                "<TD><FORM METHOD=\"POST\" action=\"create_floor\">");
-       wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
+       wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
        wprintf("<INPUT TYPE=\"text\" NAME=\"floorname\" "
                "MAXLENGTH=\"250\">\n"
                "<INPUT TYPE=\"SUBMIT\" NAME=\"sc\" "
index 05b9900fdc051e2f94c6742ce4657a19d1a9495d..0492dbf550978604f20b6bcf498b4d48e67f98ad 100644 (file)
@@ -92,13 +92,13 @@ void webcit_fmt_date(char *buf, time_t thetime, int brief)
  */
 int get_time_format_cached (void)
 {
-       char calhourformat[16];
+       long calhourformat;
        int *time_format_cache;
        time_format_cache = &(WC->time_format_cache);
        if (*time_format_cache == WC_TIMEFORMAT_NONE)
        {
-               get_preference("calhourformat", calhourformat, sizeof calhourformat);
-               if (!strcasecmp(calhourformat, "24")
+               get_pref_long("calhourformat", &calhourformat, 24);
+               if (calhourformat == 24
                        *time_format_cache = WC_TIMEFORMAT_24;
                else
                        *time_format_cache = WC_TIMEFORMAT_AMPM;
index a1d50b9e44e790369b5cdaef5918cf80c7d078d0..6949e09fd81b8f0175f5b59c0554f0561acbf351 100644 (file)
@@ -30,7 +30,7 @@ void display_graphics_upload(char *description, char *filename, char *uplurl)
        wprintf("<form enctype=\"multipart/form-data\" action=\"%s\" "
                "method=\"post\" name=\"graphicsupload\">\n", uplurl);
 
-       wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
+       wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
        wprintf("<input type=\"hidden\" name=\"which_room\" value=\"");
        urlescputs(bstr("which_room"));
        wprintf("\">\n");
index a695292fe869c349f13f3f20ccd68d76b8544c2d..c65e674bcd69c649c65d3248fb9dcf66b829129f 100644 (file)
@@ -268,7 +268,7 @@ void output_html(char *supplied_charset, int treat_as_wiki) {
        converted_alloc = content_length + 8192;
        converted_msg = malloc(converted_alloc);
        if (converted_msg == NULL) {
-               wprintf("Error %d: %s<br />%s:%s", errno, strerror(errno), __FILE__, __LINE__);
+               wprintf("Error %d: %s<br />%s:%d", errno, strerror(errno), __FILE__, __LINE__);
                goto BAIL;
        }
 
index 0561d09ba235d71b48fa5dbf88e26b1c6078fedc..fe9699816cca66ff26f7470c15904615979dfe8b 100644 (file)
@@ -25,61 +25,76 @@ void do_selected_iconbar(void) {
        }
 }
 
-/**
- * \brief draw the icon bar???
- */
-void do_iconbar(void) {
-       char iconbar[SIZ];
-       char buf[SIZ];
-       char key[SIZ], value[SIZ];
-       int i;
+void DontDeleteThis(void *Data){};
+
+#define IconbarIsEnabled(a, b) IconbarIsENABLED(a, sizeof(a), b)
+
+long IconbarIsENABLED(const char *key, size_t keylen, long defval)
+{
+       void *Data;
+       if (GetHash(WC->IconBarSetttings, key, keylen,
+                   &Data))
+               return (long) Data;
+       else 
+               return defval;
+}
 
-       WC->current_iconbar = current_iconbar_menu;
+static char nbuf[32];
+inline const char *PrintInt(void *Prefstr)
+{
+       snprintf(nbuf, sizeof(nbuf), "%ld", Prefstr);
+       return nbuf;
+}
 
+void LoadIconSettings(void)
+{
+       struct wcsession *WCC = WC;
+       StrBuf *iconbar;
+       StrBuf *buf = NewStrBuf();;
+       StrBuf *key = NewStrBuf();
+       long val;
+       int i, nTokens;
+
+       WCC->current_iconbar = current_iconbar_menu;
+       if (WCC->IconBarSetttings == NULL)
+               WCC->IconBarSetttings = NewHash(1, NULL);
        /**
         * The initialized values of these variables also happen to
         * specify the default values for users who haven't customized
         * their iconbars.  These should probably be set in a master
         * configuration somewhere.
         */
-       int ib_displayas = 0;   /**< pictures and text, pictures, text */
-       int ib_logo = 0;        /**< Site logo */
-       int ib_summary = 1;     /**< Summary page icon */
-       int ib_inbox = 1;       /**< Inbox icon */
-       int ib_calendar = 1;    /**< Calendar icon */
-       int ib_contacts = 1;    /**< Contacts icon */
-       int ib_notes = 1;       /**< Notes icon */
-       int ib_tasks = 1;       /**< Tasks icon */
-       int ib_rooms = 1;       /**< Rooms icon */
-       int ib_users = 1;       /**< Users icon */
-       int ib_chat = 1;        /**< Chat icon */
-       int ib_advanced = 1;    /**< Advanced Options icon */
-       int ib_citadel = 1;     /**< 'Powered by Citadel' logo */
-       /*
-        */
 
-       get_preference("iconbar", iconbar, sizeof iconbar);
-       for (i=0; i<num_tokens(iconbar, ','); ++i) {
-               extract_token(buf, iconbar, i, ',', sizeof buf);
-               extract_token(key, buf, 0, '=', sizeof key);
-               extract_token(value, buf, 1, '=', sizeof value);
-
-               if (!strcasecmp(key, "ib_displayas")) ib_displayas = atoi(value);
-               if (!strcasecmp(key, "ib_logo")) ib_logo = atoi(value);
-               if (!strcasecmp(key, "ib_summary")) ib_summary = atoi(value);
-               if (!strcasecmp(key, "ib_inbox")) ib_inbox = atoi(value);
-               if (!strcasecmp(key, "ib_calendar")) ib_calendar = atoi(value);
-               if (!strcasecmp(key, "ib_contacts")) ib_contacts = atoi(value);
-               if (!strcasecmp(key, "ib_notes")) ib_notes = atoi(value);
-               if (!strcasecmp(key, "ib_tasks")) ib_tasks = atoi(value);
-               if (!strcasecmp(key, "ib_rooms")) ib_rooms = atoi(value);
-               if (!strcasecmp(key, "ib_users")) ib_users = atoi(value);
-               if (!strcasecmp(key, "ib_chat")) ib_chat = atoi(value);
-               if (!strcasecmp(key, "ib_advanced")) ib_advanced = atoi(value);
-               if (!strcasecmp(key, "ib_citadel")) ib_citadel = atoi(value);
+       if (get_preference("iconbar", &iconbar)) {
+               nTokens = StrBufNum_tokens(iconbar, ',');
+               for (i=0; i<nTokens; ++i) {
+                       StrBufExtract_token(buf, iconbar, i, ',');
+                       StrBufExtract_token(key, buf, 0, '=');
+                       val = StrBufExtract_long(buf, 1, '=');
+                       Put(WCC->IconBarSetttings, 
+                           ChrPtr(key), StrLength(key),
+                           (void*)val, DontDeleteThis);
+               }
        }
+       printf("-----------icon-------------------\n");
+       dbg_PrintHash(WCC->IconBarSetttings, PrintInt, NULL);
+
+       FreeStrBuf(&key);
+       FreeStrBuf(&buf);
+}
+
+
+/**
+ * \brief draw the icon bar???
+ */
+void do_iconbar(void) {
+       int ib_displayas = 0;   /**< pictures and text, pictures, text */
 
-        if (ib_logo) {
+       LoadIconSettings();
+       ib_displayas = IconbarIsEnabled("ib_displayas", 0);
+
+/** Site logo */
+       if (IconbarIsEnabled("ib_logo", 0)) {
                 if (ib_displayas != IB_TEXTONLY) {
                         wprintf("<div class=\"logo\"> <img "
                                 "src=\"image&name=hello\" alt=\"&nbsp;\"> "
@@ -89,7 +104,8 @@ void do_iconbar(void) {
                 wprintf("\n");
         }
 
-        if (ib_citadel) if (ib_displayas != IB_TEXTONLY) wprintf(
+/** 'Powered by Citadel' logo */
+        if (IconbarIsEnabled("ib_citadel", 1) && (ib_displayas != IB_TEXTONLY)) wprintf(
                 "<div class=\"logo_citadel\"> "
                 "<a href=\"http://www.citadel.org\" "
                 "title=\"%s\"> "
@@ -106,7 +122,8 @@ void do_iconbar(void) {
        wprintf(_("switch to room list"));
        wprintf("</a></li>");
 
-       if (ib_summary) {
+/** Summary page icon */
+       if (IconbarIsEnabled("ib_summary", 1)) {
                wprintf("<li><a href=\"summary\" "
                        "title=\"%s\" "
                        ">", _("Your summary page")
@@ -121,7 +138,8 @@ void do_iconbar(void) {
                wprintf("</a></li>\n");
        }
 
-       if (ib_inbox) {
+/** Inbox icon */
+       if (IconbarIsEnabled("ib_inbox", 1)) {
                wprintf("<li>"
                        "<a href=\"dotgoto?room=_MAIL_\" "
                        "title=\"%s\" "
@@ -146,7 +164,8 @@ void do_iconbar(void) {
                wprintf("</a></li>\n");
        }
 
-       if (ib_calendar) {
+/** Calendar icon */
+       if (IconbarIsEnabled("ib_calendar", 1)) {
                wprintf("<li>"
                        "<a href=\"dotgoto?room=_CALENDAR_\" "
                        "title=\"%s\" "
@@ -163,7 +182,8 @@ void do_iconbar(void) {
                wprintf("</a></li>\n");
        }
 
-       if (ib_contacts) {
+/** Contacts icon */
+       if (IconbarIsEnabled("ib_contacts", 1)) {
                wprintf("<li>"
                        "<a href=\"dotgoto?room=_CONTACTS_\" "
                        "title=\"%s\" "
@@ -180,7 +200,8 @@ void do_iconbar(void) {
                wprintf("</a></li>\n");
        }
 
-       if (ib_notes) {
+/** Notes icon */
+       if (IconbarIsEnabled("ib_notes", 1)) {
                wprintf("<li>"
                        "<a href=\"dotgoto?room=_NOTES_\" "
                        "title=\"%s\" "
@@ -197,7 +218,8 @@ void do_iconbar(void) {
                wprintf("</a></li>\n");
        }
 
-       if (ib_tasks)  {
+/** Tasks icon */
+       if (IconbarIsEnabled("ib_tasks", 1))  {
                wprintf("<li>"
                        "<a href=\"dotgoto?room=_TASKS_\" "
                        "title=\"%s\" "
@@ -214,7 +236,8 @@ void do_iconbar(void) {
                wprintf("</a></li>\n");
        }
 
-       if (ib_rooms) {
+/** Rooms icon */
+       if (IconbarIsEnabled("ib_rooms", 1)) {
                wprintf("<li>"
                        "<a href=\"knrooms\" title=\"%s\" >",
                        _("List all of your accessible rooms")
@@ -229,7 +252,8 @@ void do_iconbar(void) {
                wprintf("</a></li>\n");
        }
 
-       if (ib_users) {
+/** Users icon */
+       if (IconbarIsEnabled("ib_users", 1)) {
                wprintf("<li>"
                        "<a href=\"who\" title=\"%s\" "
                        ">",
@@ -245,13 +269,14 @@ void do_iconbar(void) {
                 
                wprintf("</a>\n");
 
-               if (ib_users > 1) {
+               if (IconbarIsEnabled("ib_users", 0)) {
                        wprintf("<ul id=\"wholist\">");
                        wprintf("</ul></li>\n");
                }
        }
 
-       if (ib_chat) {
+/** Chat icon */
+       if (IconbarIsEnabled("ib_chat", 1)) {
                wprintf("<li>"
                        "<a href=\"#\" onClick=\"window.open('chat', "
                        "'ctdl_chat_window', "
@@ -269,7 +294,8 @@ void do_iconbar(void) {
                wprintf("</a></li>\n");
        }
 
-       if (ib_advanced) {
+/** Advanced Options icon */
+       if (IconbarIsEnabled("ib_advanced", 1)) {
                wprintf("<li>"
                        "<a href=\"display_main_menu\" "
                        "title=\"%s\" "
@@ -331,14 +357,13 @@ void do_iconbar(void) {
 
        wprintf("</ul>\n");
 
-       if (ib_users > 1) {
+       if (IconbarIsEnabled("ib_users", 0)) {
                wprintf(
                        "<script type=\"text/javascript\"> "
                        " new Ajax.PeriodicalUpdater('wholist', 'wholist_section', { method: 'get', frequency: 30 } );"
-                "</script> \n"
-               );
+                       "</script> \n"
+                       );
        }
-
 }
 
 
@@ -348,11 +373,7 @@ void do_iconbar(void) {
  * we generate its innerHTML...
  */
 void do_iconbar_roomlist(void) {
-       char iconbar[SIZ];
-       char buf[SIZ];
-       char key[SIZ], value[SIZ];
-       int i;
-
+                               
        WC->current_iconbar = current_iconbar_roomlist;
 
        /**
@@ -361,24 +382,14 @@ void do_iconbar_roomlist(void) {
         * their iconbars.  These should probably be set in a master
         * configuration somewhere.
         */
-       int ib_displayas = 0;   /* pictures and text, pictures, text */
-       int ib_logo = 0;        /* Site logo */
-       int ib_citadel = 1;     /* 'Powered by Citadel' logo */
-       /*
-        */
+       int ib_displayas;
 
-       get_preference("iconbar", iconbar, sizeof iconbar);
-       for (i=0; i<num_tokens(iconbar, ','); ++i) {
-               extract_token(buf, iconbar, i, ',', sizeof buf);
-               extract_token(key, buf, 0, '=', sizeof key);
-               extract_token(value, buf, 1, '=', sizeof value);
+       LoadIconSettings();
 
-               if (!strcasecmp(key, "ib_displayas")) ib_displayas = atoi(value);
-               if (!strcasecmp(key, "ib_logo")) ib_logo = atoi(value);
-               if (!strcasecmp(key, "ib_citadel")) ib_citadel = atoi(value);
-       }
+       ib_displayas = IconbarIsEnabled("ib_displayas", 0);     /* pictures and text, pictures, text */
 
-       if (ib_logo) {
+/** Site logo */
+       if (IconbarIsEnabled("ib_logo", 0)) {
                if (ib_displayas != IB_TEXTONLY) {
                         wprintf("<div class=\"logo\"> <img "
                                 "src=\"image&name=hello\" alt=\"&nbsp;\"> "
@@ -387,7 +398,8 @@ void do_iconbar_roomlist(void) {
                }
        }
 
-        if (ib_citadel) if (ib_displayas != IB_TEXTONLY) wprintf(
+/** 'Powered by Citadel' logo */
+        if (IconbarIsEnabled("ib_citadel", 1) && (ib_displayas != IB_TEXTONLY)) wprintf(
                 "<div class=\"logo_citadel\"> "
                 "<a href=\"http://www.citadel.org\" "
                 "title=\"%s\"> "
@@ -433,54 +445,13 @@ void do_iconbar_roomlist(void) {
  * \brief display a customized version of the iconbar
  */
 void display_customize_iconbar(void) {
-       char iconbar[SIZ];
-       char buf[SIZ];
-       char key[SIZ], value[SIZ];
        int i;
        int bar = 0;
+       long val;
 
-       /**
-        * The initialized values of these variables also happen to
-        * specify the default values for users who haven't customized
-        * their iconbars.  These should probably be set in a master
-        * configuration somewhere.
-        */
-       int ib_displayas = IB_PICTEXT;  /**< pictures and text, pictures, text */
-       int ib_logo = 0;        /**< Site logo */
-       int ib_summary = 1;     /**< Summary page icon */
-       int ib_inbox = 1;       /**< Inbox icon */
-       int ib_calendar = 1;    /**< Calendar icon */
-       int ib_contacts = 1;    /**< Contacts icon */
-       int ib_notes = 1;       /**< Notes icon */
-       int ib_tasks = 1;       /**< Tasks icon */
-       int ib_rooms = 1;       /**< Rooms icon */
-       int ib_users = 1;       /**< Users icon */
-       int ib_chat = 1;        /**< Chat icon */
-       int ib_advanced = 1;    /**< Advanced Options icon */
-       int ib_citadel = 1;     /**< 'Powered by Citadel' logo */
-       /*
-        */
+       int ib_displayas;
 
-       get_preference("iconbar", iconbar, sizeof iconbar);
-       for (i=0; i<num_tokens(iconbar, ','); ++i) {
-               extract_token(buf, iconbar, i, ',', sizeof buf);
-               extract_token(key, buf, 0, '=', sizeof key);
-               extract_token(value, buf, 1, '=', sizeof value);
-
-               if (!strcasecmp(key, "ib_displayas")) ib_displayas = atoi(value);
-               if (!strcasecmp(key, "ib_logo")) ib_logo = atoi(value);
-               if (!strcasecmp(key, "ib_summary")) ib_summary = atoi(value);
-               if (!strcasecmp(key, "ib_inbox")) ib_inbox = atoi(value);
-               if (!strcasecmp(key, "ib_calendar")) ib_calendar = atoi(value);
-               if (!strcasecmp(key, "ib_contacts")) ib_contacts = atoi(value);
-               if (!strcasecmp(key, "ib_notes")) ib_notes = atoi(value);
-               if (!strcasecmp(key, "ib_tasks")) ib_tasks = atoi(value);
-               if (!strcasecmp(key, "ib_rooms")) ib_rooms = atoi(value);
-               if (!strcasecmp(key, "ib_users")) ib_users = atoi(value);
-               if (!strcasecmp(key, "ib_chat")) ib_chat = atoi(value);
-               if (!strcasecmp(key, "ib_advanced")) ib_advanced = atoi(value);
-               if (!strcasecmp(key, "ib_citadel")) ib_citadel = atoi(value);
-       }
+       LoadIconSettings();
 
        output_headers(1, 1, 2, 0, 0, 0);
        wprintf("<div id=\"banner\">");
@@ -493,12 +464,13 @@ void display_customize_iconbar(void) {
        wprintf("<div class=\"fix_scrollbar_bug\">");
 
        wprintf("<form method=\"post\" action=\"commit_iconbar\">\n");
-       wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
+       wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
 
        wprintf("<table class=\"altern\" >\n");
        wprintf("<tr><td></td><td colspan=\"2\"><b>");
        wprintf(_("Display icons as:"));
        wprintf("</b>");
+       ib_displayas = IconbarIsEnabled("ib_displayas",IB_PICTEXT);
        for (i=0; i<=2; ++i) {
                wprintf("<input type=\"radio\" name=\"ib_displayas\" value=\"%d\"", i);
                if (ib_displayas == i) wprintf(" CHECKED");
@@ -516,6 +488,7 @@ void display_customize_iconbar(void) {
        wprintf("</td></tr>\n");
 
        bar = 1 - bar;
+       val = IconbarIsEnabled("ib_logo", 0);
        wprintf("<tr class=\"%s\"><td>"
                "<input type=\"radio\" name=\"ib_logo\" value=\"yes\" %s> %s &nbsp;&nbsp;&nbsp;"
                "<input type=\"radio\" name=\"ib_logo\" value=\"no\" %s> %s <br />"
@@ -526,13 +499,14 @@ void display_customize_iconbar(void) {
                "%s"
                "</td></tr>\n",
                (bar ? "even" : "odd"),
-               (ib_logo ? "CHECKED" : ""),_("Yes"),
-               (!ib_logo ? "CHECKED" : ""),_("No"),
+               (val ? "CHECKED" : ""),_("Yes"),
+               (!val ? "CHECKED" : ""),_("No"),
                _("Site logo"),
                _("An icon describing this site")
        );
 
        bar = 1 - bar;
+       val = IconbarIsEnabled("ib_summary", 1);
        wprintf("<tr class=\"%s\"><td>"
                "<input type=\"radio\" name=\"ib_summary\" value=\"yes\" %s> %s &nbsp;&nbsp;&nbsp;"
                "<input type=\"radio\" name=\"ib_summary\" value=\"no\" %s> %s <br />"
@@ -543,13 +517,14 @@ void display_customize_iconbar(void) {
                "%s"
                "</td></tr>\n",
                (bar ? "even" : "odd"),
-               (ib_summary ? "CHECKED" : ""),_("Yes"),
-               (!ib_summary ? "CHECKED" : ""),_("No"),
+               (val ? "CHECKED" : ""),_("Yes"),
+               (!val ? "CHECKED" : ""),_("No"),
                _("Summary"),
                _("Your summary page")
        );
 
        bar = 1 - bar;
+       val = IconbarIsEnabled("ib_inbox", 1);
        wprintf("<tr class=\"%s\"><td>"
                "<input type=\"radio\" name=\"ib_inbox\" value=\"yes\" %s> %s &nbsp;&nbsp;&nbsp;"
                "<input type=\"radio\" name=\"ib_inbox\" value=\"no\" %s> %s <br />"
@@ -560,13 +535,14 @@ void display_customize_iconbar(void) {
                "%s"
                "</td></tr>\n",
                (bar ? "even" : "odd"),
-               (ib_inbox ? "CHECKED" : ""),_("Yes"),
-               (!ib_inbox ? "CHECKED" : ""),_("No"),
+               (val ? "CHECKED" : ""),_("Yes"),
+               (!val ? "CHECKED" : ""),_("No"),
                _("Mail (inbox)"),
                _("A shortcut to your email Inbox")
        );
 
        bar = 1 - bar;
+       val = IconbarIsEnabled("ib_contacts", 1);
        wprintf("<tr class=\"%s\"><td>"
                "<input type=\"radio\" name=\"ib_contacts\" value=\"yes\" %s> %s &nbsp;&nbsp;&nbsp;"
                "<input type=\"radio\" name=\"ib_contacts\" value=\"no\" %s> %s <br />"
@@ -577,13 +553,14 @@ void display_customize_iconbar(void) {
                "%s"
                "</td></tr>\n",
                (bar ? "even" : "odd"),
-               (ib_contacts ? "CHECKED" : ""),_("Yes"),
-               (!ib_contacts ? "CHECKED" : ""),_("No"),
+               (val ? "CHECKED" : ""),_("Yes"),
+               (!val ? "CHECKED" : ""),_("No"),
                _("Contacts"),
                _("Your personal address book")
        );
 
        bar = 1 - bar;
+       val = IconbarIsEnabled("ib_notes", 1);
        wprintf("<tr class=\"%s\"><td>"
                "<input type=\"radio\" name=\"ib_notes\" value=\"yes\" %s> %s &nbsp;&nbsp;&nbsp;"
                "<input type=\"radio\" name=\"ib_notes\" value=\"no\" %s> %s <br />"
@@ -594,13 +571,14 @@ void display_customize_iconbar(void) {
                "%s"
                "</td></tr>\n",
                (bar ? "even" : "odd"),
-               (ib_notes ? "CHECKED" : ""),_("Yes"),
-               (!ib_notes ? "CHECKED" : ""),_("No"),
+               (val ? "CHECKED" : ""),_("Yes"),
+               (!val ? "CHECKED" : ""),_("No"),
                _("Notes"),
                _("Your personal notes")
        );
 
        bar = 1 - bar;
+       val = IconbarIsEnabled("ib_calendar", 1);
        wprintf("<tr class=\"%s\"><td>"
                "<input type=\"radio\" name=\"ib_calendar\" value=\"yes\" %s> %s &nbsp;&nbsp;&nbsp;"
                "<input type=\"radio\" name=\"ib_calendar\" value=\"no\" %s> %s <br />"
@@ -611,13 +589,14 @@ void display_customize_iconbar(void) {
                "%s"
                "</td></tr>\n",
                (bar ? "even" : "odd"),
-               (ib_calendar ? "CHECKED" : ""),_("Yes"),
-               (!ib_calendar ? "CHECKED" : ""),_("No"),
+               (val ? "CHECKED" : ""),_("Yes"),
+               (!val ? "CHECKED" : ""),_("No"),
                _("Calendar"),
                _("A shortcut to your personal calendar")
        );
 
        bar = 1 - bar;
+       val = IconbarIsEnabled("ib_tasks", 1);
        wprintf("<tr class=\"%s\"><td>"
                "<input type=\"radio\" name=\"ib_tasks\" value=\"yes\" %s> %s &nbsp;&nbsp;&nbsp;"
                "<input type=\"radio\" name=\"ib_tasks\" value=\"no\" %s> %s <br />"
@@ -628,13 +607,14 @@ void display_customize_iconbar(void) {
                "%s"
                "</td></tr>\n",
                (bar ? "even" : "odd"),
-               (ib_tasks ? "CHECKED" : ""),_("Yes"),
-               (!ib_tasks ? "CHECKED" : ""),_("No"),
+               (val ? "CHECKED" : ""),_("Yes"),
+               (!val ? "CHECKED" : ""),_("No"),
                _("Tasks"),
                _("A shortcut to your personal task list")
        );
 
        bar = 1 - bar;
+       val = IconbarIsEnabled("ib_rooms", 1);
        wprintf("<tr class=\"%s\"><td>"
                "<input type=\"radio\" name=\"ib_rooms\" value=\"yes\" %s> %s &nbsp;&nbsp;&nbsp;"
                "<input type=\"radio\" name=\"ib_rooms\" value=\"no\" %s> %s <br />"
@@ -645,14 +625,15 @@ void display_customize_iconbar(void) {
                "%s"
                "</td></tr>\n",
                (bar ? "even" : "odd"),
-               (ib_rooms ? "CHECKED" : ""),_("Yes"),
-               (!ib_rooms ? "CHECKED" : ""),_("No"),
+               (val ? "CHECKED" : ""),_("Yes"),
+               (!val ? "CHECKED" : ""),_("No"),
                _("Rooms"),
                _("Clicking this icon displays a list of all accessible "
                "rooms (or folders) available.")
        );
 
        bar = 1 - bar;
+       val = IconbarIsEnabled("ib_users", 1);
        wprintf("<tr class=\"%s\"><td>"
                "<input type=\"radio\" name=\"ib_users\" value=\"yes\" %s> %s &nbsp;&nbsp;&nbsp;"
                "<input type=\"radio\" name=\"ib_users\" value=\"no\" %s> %s <br />"
@@ -664,15 +645,16 @@ void display_customize_iconbar(void) {
                "<br />%s"
                "</td></tr>\n",
                (bar ? "even" : "odd"),
-               (ib_users ? "CHECKED" : ""),_("Yes"),
-               (!ib_users ? "CHECKED" : ""),_("No"),
-               ((ib_users > 1) ? "CHECKED" : ""),_("Yes with users list"),
+               (val ? "CHECKED" : ""),_("Yes"),
+               (!val ? "CHECKED" : ""),_("No"),
+               ((val > 1) ? "CHECKED" : ""),_("Yes with users list"),
                _("Who is online?"),
                _("Clicking this icon displays a list of all users "
                "currently logged in.")
        );
 
        bar = 1 - bar;
+       val = IconbarIsEnabled("ib_chat", 1);
        wprintf("<tr class=\"%s\"><td>"
                "<input type=\"radio\" name=\"ib_chat\" value=\"yes\" %s> %s &nbsp;&nbsp;&nbsp;"
                "<input type=\"radio\" name=\"ib_chat\" value=\"no\" %s> %s <br />"
@@ -683,8 +665,8 @@ void display_customize_iconbar(void) {
                "%s"
                "</td></tr>\n",
                (bar ? "even" : "odd"),
-               (ib_chat ? "CHECKED" : ""),_("Yes"),
-               (!ib_chat ? "CHECKED" : ""),_("No"),
+               (val ? "CHECKED" : ""),_("Yes"),
+               (!val ? "CHECKED" : ""),_("No"),
                _("Chat"),
                _("Clicking this icon enters real-time chat mode "
                "with other users in the same room.")
@@ -692,6 +674,7 @@ void display_customize_iconbar(void) {
        );
 
        bar = 1 - bar;
+       val = IconbarIsEnabled("ib_advanced", 1);
        wprintf("<tr class=\"%s\"><td>"
                "<input type=\"radio\" name=\"ib_advanced\" value=\"yes\" %s> %s &nbsp;&nbsp;&nbsp;"
                "<input type=\"radio\" name=\"ib_advanced\" value=\"no\" %s> %s <br />"
@@ -702,14 +685,15 @@ void display_customize_iconbar(void) {
                "%s"
                "</td></tr>\n",
                (bar ? "even" : "odd"),
-               (ib_advanced ? "CHECKED" : ""),_("Yes"),
-               (!ib_advanced ? "CHECKED" : ""),_("No"),
+               (val ? "CHECKED" : ""),_("Yes"),
+               (!val ? "CHECKED" : ""),_("No"),
                _("Advanced options"),
                _("Access to the complete menu of Citadel functions.")
 
        );
 
        bar = 1 - bar;
+       val = IconbarIsEnabled("ib_citadel", 1);
        wprintf("<tr class=\"%s\"><td>"
                "<input type=\"radio\" name=\"ib_citadel\" value=\"yes\" %s> %s &nbsp;&nbsp;&nbsp;"
                "<input type=\"radio\" name=\"ib_citadel\" value=\"no\" %s> %s <br />"
@@ -721,8 +705,8 @@ void display_customize_iconbar(void) {
                "%s"
                "</td></tr>\n",
                (bar ? "even" : "odd"),
-               (ib_citadel ? "CHECKED" : ""),_("Yes"),
-               (!ib_citadel ? "CHECKED" : ""),_("No"),
+               (val ? "CHECKED" : ""),_("Yes"),
+               (!val ? "CHECKED" : ""),_("No"),
                _("Citadel logo"),
                _("Displays the 'Powered by Citadel' icon")
        );
@@ -745,7 +729,8 @@ void display_customize_iconbar(void) {
  * \brief commit the changes of an edited iconbar ????
  */
 void commit_iconbar(void) {
-       char iconbar[SIZ];
+       StrBuf *iconbar;
+       StrBuf *buf;
        int i;
 
        char *boxen[] = {
@@ -769,8 +754,9 @@ void commit_iconbar(void) {
                return;
        }
 
-       sprintf(iconbar, "ib_displayas=%d", ibstr("ib_displayas"));
-
+       iconbar = NewStrBuf();
+       buf = NewStrBuf();
+       StrBufPrintf(iconbar, "ib_displayas=%d", ibstr("ib_displayas"));
        for (i=0; i<(sizeof(boxen)/sizeof(char *)); ++i) {
                char *Val;
                if (!strcasecmp(BSTR(boxen[i]), "yes")) {
@@ -782,9 +768,11 @@ void commit_iconbar(void) {
                else {
                        Val = "0";
                }
-               sprintf(&iconbar[strlen(iconbar)], ",%s=%s", boxen[i], Val);
-       }
+               StrBufPrintf(buf, ",%s=%s", boxen[i], Val);
+               StrBufAppendBuf(iconbar, buf, 0);
 
+       }
+       FreeStrBuf(&buf);
        set_preference("iconbar", iconbar, 1);
 
        output_headers(1, 1, 2, 0, 0, 0);
@@ -802,6 +790,8 @@ void commit_iconbar(void) {
                "choices to continue."));
        wprintf("</td></tr></table>\n");
        wDumpContent(2);
+       printf("-----------icon-------------------\n");
+       dbg_PrintHash(WC->IconBarSetttings, PrintInt, NULL);
 }
 
 
index c61ee41665ce01f98c80e3159a90f8b4c7dc6dbd..b483dd1aa873c7151e7c313b843b73337ae44458 100644 (file)
@@ -134,7 +134,7 @@ void display_inetconf(void)
 
                }
                wprintf("<form method=\"post\" action=\"save_inetconf\">\n");
-               wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
+               wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
                wprintf("<tr><td>"
                        "<input type=\"text\" name=\"ename\" maxlength=\"64\">"
                        "<input type=\"hidden\" name=\"etype\" VALUE=\"%s\">", ic_keyword[which]);
index dec9265d083518490ef88ea49b918bc169c1316c..14b3cedc3fb1e7e25af947bcfd6a2c39e4dafdcb 100644 (file)
@@ -221,7 +221,7 @@ void display_generic(void)
        wprintf("<br />\n");
 
        wprintf("<form method=\"post\" action=\"do_generic\">\n");
-       wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
+       wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
 
        wprintf(_("Enter command:"));
        wprintf("<br /><input type=\"text\" name=\"g_cmd\" size=80 maxlength=\"250\"><br />\n");
index e0ab860823a1ab90e3760983ee176878fee43ac4..6e3246a3e254b563db8baa2ad53a38fc9ff7cb0c 100644 (file)
@@ -104,10 +104,11 @@ void utf8ify_rfc822_string(char *buf) {
                }
        }
        if (illegal_non_rfc2047_encoding) {
-               char default_header_charset[128];
-               get_preference("default_header_charset", default_header_charset, sizeof default_header_charset);
-               if ( (strcasecmp(default_header_charset, "UTF-8")) && (strcasecmp(default_header_charset, "us-ascii")) ) {
-                       ic = ctdl_iconv_open("UTF-8", default_header_charset);
+               StrBuf *default_header_charset;
+               get_preference("default_header_charset", &default_header_charset);
+               if ( (strcasecmp(ChrPtr(default_header_charset), "UTF-8")) && 
+                    (strcasecmp(ChrPtr(default_header_charset), "us-ascii")) ) {
+                       ic = ctdl_iconv_open("UTF-8", ChrPtr(default_header_charset));
                        if (ic != (iconv_t)(-1) ) {
                                ibuf = malloc(1024);
                                isav = ibuf;
@@ -665,7 +666,7 @@ void display_parsed_vcard(struct vCard *v, int full, long msgnum) {
                                wprintf("<tr><td>");
                                wprintf(_("Photo:"));
                                wprintf("</td><td>");
-                               wprintf("<img src=\"/vcardphoto/%d/\" alt=\"Contact photo\"/>",msgnum);
+                               wprintf("<img src=\"/vcardphoto/%ld/\" alt=\"Contact photo\"/>",msgnum);
                                wprintf("</td></tr>\n");
                        }
                        else if (!strcasecmp(firsttoken, "version")) {
@@ -1081,7 +1082,7 @@ void read_message(long msgnum, int printable_view, char *section) {
                        urlescputs(reply_to);
                        if (!IsEmptyStr(m_subject)) {
                                wprintf("?subject=");
-                               if (strncasecmp(m_subject, "Re:", 3)) wprintf("Re:%20");
+                               if (strncasecmp(m_subject, "Re:", 3)) wprintf("Re:%%20");
                                urlescputs(m_subject);
                        }
                        wprintf("?references=");
@@ -1102,7 +1103,7 @@ void read_message(long msgnum, int printable_view, char *section) {
                                urlescputs(reply_to);
                                if (!IsEmptyStr(m_subject)) {
                                        wprintf("?subject=");
-                                       if (strncasecmp(m_subject, "Re:", 3)) wprintf("Re:%20");
+                                       if (strncasecmp(m_subject, "Re:", 3)) wprintf("Re:%%20");
                                        urlescputs(m_subject);
                                }
                                wprintf("?references=");
@@ -1125,7 +1126,7 @@ void read_message(long msgnum, int printable_view, char *section) {
                        urlescputs(reply_all);
                        if (!IsEmptyStr(m_subject)) {
                                wprintf("?subject=");
-                               if (strncasecmp(m_subject, "Re:", 3)) wprintf("Re:%20");
+                               if (strncasecmp(m_subject, "Re:", 3)) wprintf("Re:%%20");
                                urlescputs(m_subject);
                        }
                        wprintf("?references=");
@@ -1140,7 +1141,7 @@ void read_message(long msgnum, int printable_view, char *section) {
                /* Forward */
                if (WC->wc_view == VIEW_MAILBOX) {
                        wprintf("<a href=\"display_enter?fwdquote=%ld?subject=", msgnum);
-                       if (strncasecmp(m_subject, "Fwd:", 4)) wprintf("Fwd:%20");
+                       if (strncasecmp(m_subject, "Fwd:", 4)) wprintf("Fwd:%%20");
                        urlescputs(m_subject);
                        wprintf("\"><span>[</span>%s<span>]</span></a> ", _("Forward"));
                }
@@ -1304,7 +1305,7 @@ void read_message(long msgnum, int printable_view, char *section) {
        /* Unknown weirdness */
        else {
                wprintf(_("I don't know how to display %s"), mime_content_type);
-               wprintf("<br />\n", mime_content_type);
+               wprintf("<br />\n");
                while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) { }
        }
 
@@ -2364,9 +2365,9 @@ void readloop(char *oper)
        int highest_displayed = 0;
        struct addrbookent *addrbook = NULL;
        int num_ab = 0;
-       char *sortby = NULL;
-       char sortpref_name[128];
-       char sortpref_value[128];
+       StrBuf *sortby = NULL;
+       StrBuf *sortpref_name;
+       StrBuf *sortpref_value;
        char *subjsort_button;
        char *sendsort_button;
        char *datesort_button;
@@ -2384,20 +2385,23 @@ void readloop(char *oper)
        is_summary = (ibstr("is_summary") && !WCC->is_mobile);
        if (maxmsgs == 0) maxmsgs = DEFAULT_MAXMSGS;
 
-       snprintf(sortpref_name, sizeof sortpref_name, "sort %s", WCC->wc_roomname);
-       get_preference(sortpref_name, sortpref_value, sizeof sortpref_value);
+       sortpref_name = NewStrBuf ();
+       StrBufPrintf(sortpref_name, "sort %s", WCC->wc_roomname);
+       get_pref(sortpref_name, &sortpref_value);
 
-       sortby = bstr("sortby");
-       if ( (!IsEmptyStr(sortby)) && (strcasecmp(sortby, sortpref_value)) ) {
-               set_preference(sortpref_name, sortby, 1);
+       sortby = NewStrBufPlain(bstr("sortby"), -1);
+       if ( (!IsEmptyStr(ChrPtr(sortby))) && 
+            (strcasecmp(ChrPtr(sortby), ChrPtr(sortpref_value))) ) {
+               set_pref(sortpref_name, sortby, 1);
        }
-       if (IsEmptyStr(sortby)) sortby = sortpref_value;
+       FreeStrBuf(&sortpref_name);
+       if (IsEmptyStr(ChrPtr(sortby))) StrBufAppendBuf(sortby,  sortpref_value, 0);
 
        /** mailbox sort */
-       if (IsEmptyStr(sortby)) sortby = "rdate";
+       if (IsEmptyStr(ChrPtr(sortby))) StrBufPrintf(sortby, "rdate");
 
        /** message board sort */
-       if (!strcasecmp(sortby, "reverse")) {
+       if (!strcasecmp(ChrPtr(sortby), "reverse")) {
                bbs_reverse = 1;
        }
        else {
@@ -2535,56 +2539,56 @@ void readloop(char *oper)
        }
 
        if (is_summary || WCC->is_mobile) {
-               if (!strcasecmp(sortby, "subject")) {
+               if (!strcasecmp(ChrPtr(sortby), "subject")) {
                        qsort(WCC->summ, WCC->num_summ,
                                sizeof(struct message_summary), summcmp_subj);
                }
-               else if (!strcasecmp(sortby, "rsubject")) {
+               else if (!strcasecmp(ChrPtr(sortby), "rsubject")) {
                        qsort(WCC->summ, WCC->num_summ,
                                sizeof(struct message_summary), summcmp_rsubj);
                }
-               else if (!strcasecmp(sortby, "sender")) {
+               else if (!strcasecmp(ChrPtr(sortby), "sender")) {
                        qsort(WCC->summ, WCC->num_summ,
                                sizeof(struct message_summary), summcmp_sender);
                }
-               else if (!strcasecmp(sortby, "rsender")) {
+               else if (!strcasecmp(ChrPtr(sortby), "rsender")) {
                        qsort(WCC->summ, WCC->num_summ,
                                sizeof(struct message_summary), summcmp_rsender);
                }
-               else if (!strcasecmp(sortby, "date")) {
+               else if (!strcasecmp(ChrPtr(sortby), "date")) {
                        qsort(WCC->summ, WCC->num_summ,
                                sizeof(struct message_summary), summcmp_date);
                }
-               else if (!strcasecmp(sortby, "rdate")) {
+               else if (!strcasecmp(ChrPtr(sortby), "rdate")) {
                        qsort(WCC->summ, WCC->num_summ,
                                sizeof(struct message_summary), summcmp_rdate);
                }
        }
 
-       if (!strcasecmp(sortby, "subject")) {
+       if (!strcasecmp(ChrPtr(sortby), "subject")) {
                subjsort_button = "<a href=\"readfwd?startmsg=1?maxmsgs=9999999?is_summary=1?sortby=rsubject\"><img border=\"0\" src=\"static/down_pointer.gif\" /></a>" ;
        }
-       else if (!strcasecmp(sortby, "rsubject")) {
+       else if (!strcasecmp(ChrPtr(sortby), "rsubject")) {
                subjsort_button = "<a href=\"readfwd?startmsg=1?maxmsgs=9999999?is_summary=1?sortby=subject\"><img border=\"0\" src=\"static/up_pointer.gif\" /></a>" ;
        }
        else {
                subjsort_button = "<a href=\"readfwd?startmsg=1?maxmsgs=9999999?is_summary=1?sortby=subject\"><img border=\"0\" src=\"static/sort_none.gif\" /></a>" ;
        }
 
-       if (!strcasecmp(sortby, "sender")) {
+       if (!strcasecmp(ChrPtr(sortby), "sender")) {
                sendsort_button = "<a href=\"readfwd?startmsg=1?maxmsgs=9999999?is_summary=1?sortby=rsender\"><img border=\"0\" src=\"static/down_pointer.gif\" /></a>" ;
        }
-       else if (!strcasecmp(sortby, "rsender")) {
+       else if (!strcasecmp(ChrPtr(sortby), "rsender")) {
                sendsort_button = "<a href=\"readfwd?startmsg=1?maxmsgs=9999999?is_summary=1?sortby=sender\"><img border=\"0\" src=\"static/up_pointer.gif\" /></a>" ;
        }
        else {
                sendsort_button = "<a href=\"readfwd?startmsg=1?maxmsgs=9999999?is_summary=1?sortby=sender\"><img border=\"0\" src=\"static/sort_none.gif\" /></a>" ;
        }
 
-       if (!strcasecmp(sortby, "date")) {
+       if (!strcasecmp(ChrPtr(sortby), "date")) {
                datesort_button = "<a href=\"readfwd?startmsg=1?maxmsgs=9999999?is_summary=1?sortby=rdate\"><img border=\"0\" src=\"static/down_pointer.gif\" /></a>" ;
        }
-       else if (!strcasecmp(sortby, "rdate")) {
+       else if (!strcasecmp(ChrPtr(sortby), "rdate")) {
                datesort_button = "<a href=\"readfwd?startmsg=1?maxmsgs=9999999?is_summary=1?sortby=date\"><img border=\"0\" src=\"static/up_pointer.gif\" /></a>" ;
        }
        else {
@@ -2653,7 +2657,7 @@ void readloop(char *oper)
        if (is_bbview) {
                /** begin bbview scroller */
                wprintf("<form name=\"msgomatictop\" class=\"selector_top\" > \n <p>");
-               wprintf(_("Reading #"), lowest_displayed, highest_displayed);
+               wprintf(_("Reading #"));//// TODO this isn't used, should it? : , lowest_displayed, highest_displayed);
 
                wprintf("<select name=\"whichones\" size=\"1\" "
                        "OnChange=\"location.href=msgomatictop.whichones.options"
@@ -2820,7 +2824,7 @@ void readloop(char *oper)
        if (is_bbview) {
                /** begin bbview scroller */
                wprintf("<form name=\"msgomatic\" class=\"selector_bottom\" > \n <p>");
-               wprintf(_("Reading #"), lowest_displayed, highest_displayed);
+               wprintf(_("Reading #")); /// TODO: this isn't used: , lowest_displayed, highest_displayed);
 
                wprintf("<select name=\"whichones\" size=\"1\" "
                        "OnChange=\"location.href=msgomatic.whichones.options"
@@ -3232,7 +3236,7 @@ void post_message(void)
 void display_enter(void)
 {
        char buf[SIZ];
-       char ebuf[SIZ];
+       StrBuf *ebuf;
        long now;
        char *display_name;
        struct wc_attachment *att;
@@ -3372,7 +3376,7 @@ void display_enter(void)
                wprintf("<input type=\"hidden\" name=\"wikipage\" value=\"%s\">\n", bstr("wikipage"));
        }
        wprintf("<input type=\"hidden\" name=\"return_to\" value=\"%s\">\n", bstr("return_to"));
-       wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
+       wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
        wprintf("<input type=\"hidden\" name=\"force_room\" value=\"");
        escputs(WC->wc_roomname);
        wprintf("\">\n");
@@ -3575,11 +3579,12 @@ void display_enter(void)
 
        /** Insert our signature if appropriate... */
        if ( (WC->is_mailbox) && yesbstr("sig_inserted") ) {
-               get_preference("use_sig", buf, sizeof buf);
-               if (!strcasecmp(buf, "yes")) {
+               int UseSig;
+               get_pref_yesno("use_sig", &UseSig, 0);
+               if (UseSig) {
                        int len;
-                       get_preference("signature", ebuf, sizeof ebuf);
-                       euid_unescapize(buf, ebuf);
+                       get_preference("signature", &ebuf);
+                       euid_unescapize(buf, ChrPtr(ebuf));/////TODO
                        wprintf("<br>--<br>");
                        len = strlen(buf);
                        for (i=0; i<len; ++i) {
@@ -3732,7 +3737,7 @@ void confirm_move_msg(void)
        wprintf("<br />\n");
 
        wprintf("<form METHOD=\"POST\" action=\"move_msg\">\n");
-       wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
+       wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
        wprintf("<INPUT TYPE=\"hidden\" NAME=\"msgid\" VALUE=\"%s\">\n", bstr("msgid"));
 
        wprintf("<SELECT NAME=\"target_room\" SIZE=5>\n");
index ee7c5a91fd7f4bf4e30dbe568453873f71c99fa8..79130b8db2fb5c78ea6723197f48c8d3664f0e5e 100644 (file)
@@ -75,7 +75,7 @@ void display_add_node(void)
        wprintf("<div id=\"content\" class=\"service\">\n");
 
        wprintf("<FORM METHOD=\"POST\" action=\"edit_node\">\n");
-       wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
+       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");
@@ -129,7 +129,7 @@ void display_edit_node(void)
 
                        if (!strcasecmp(node, cnode)) {
                                wprintf("<FORM METHOD=\"POST\" action=\"edit_node\">\n");
-                               wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
+                               wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
                                wprintf("<CENTER><TABLE border=0>\n");
                                wprintf("<TR><TD>");
                                wprintf(_("Node name"));
index ccc530d2ed511c12afb9937435e60a3918ae6ac5..1945ae72a915f2e075cd48bd73afe7d3399b0b67 100644 (file)
@@ -285,7 +285,7 @@ void ajax_update_note(void) {
        v = vnote_new_from_msg(msgnum);
        if (!v) {
                begin_ajax_response();
-               wprintf("Cannot locate a vNote within message %ld\n", msgnum);
+               wprintf("Cannot locate a vNote within message %d\n", msgnum);
                end_ajax_response();
                return;
        }
index ae037e851c6eb688766d9d0b59ce27e7fc12d096..cae9de053cbb7203842100b7fbcaacb7deae847b 100644 (file)
@@ -43,7 +43,7 @@ void display_openids(void)
                wprintf("</table><br />\n");
        
                wprintf("<form method=\"POST\" action=\"openid_attach\">\n");
-               wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
+               wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
                wprintf(_("Add an OpenID: "));
                wprintf("<input type=\"text\" name=\"openid_url\" class=\"openid_urlarea\" size=\"40\">\n");
                wprintf("<input type=\"submit\" name=\"attach_button\" value=\"%s\">"
index dc364360335910faf8e6480a264dc58b37a613df..93c402501e4913d0543ec497219f230ebef7f1fa 100644 (file)
@@ -34,7 +34,7 @@ void display_page(void)
        wprintf("<br>\n");
 
        wprintf("<FORM METHOD=\"POST\" action=\"page_user\">\n");
-       wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
+       wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
 
        wprintf("<TABLE border=0 width=100%%><TR><TD>\n");
 
@@ -484,7 +484,7 @@ void chat_send(void) {
        WC->chat_sock = i;
 
        wprintf("<FORM METHOD=\"POST\" action=\"chat_send\" NAME=\"chatsendform\">\n");
-       wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
+       wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
        wprintf("<INPUT TYPE=\"text\" SIZE=\"80\" MAXLENGTH=\"%d\" "
                "NAME=\"send_this\">\n", SIZ-10);
        wprintf("<br />");
index d1db3cbf8e1e1372b32f958756d401609543e5a5..2d803e9f7dbfa55c598d8e052852921891c64a15 100644 (file)
@@ -11,7 +11,7 @@
 
 inline const char *PrintPref(void *Prefstr)
 {
-       return Prefstr;
+       return ChrPtr(Prefstr);
 }
 
 /*
@@ -20,7 +20,7 @@ inline const char *PrintPref(void *Prefstr)
 void load_preferences(void) {
        char buf[SIZ];
        long msgnum = 0L;
-       char key[SIZ], value[SIZ];
+       StrBuf *ReadBuf;
        
        serv_printf("GOTO %s", USERCONFIGROOM);
        serv_getln(buf, sizeof buf);
@@ -40,16 +40,43 @@ void load_preferences(void) {
                serv_printf("MSG0 %ld", msgnum);
                serv_getln(buf, sizeof buf);
                if (buf[0] == '1') {
-                       while (serv_getln(buf, sizeof buf),
-                               (strcmp(buf, "text") && strcmp(buf, "000"))) {
+                       ReadBuf = NewStrBuf();
+                       while (StrBuf_ServGetln(ReadBuf),
+                              (strcmp(ChrPtr(ReadBuf), "text") && 
+                               strcmp(ChrPtr(ReadBuf), "000"))) {
                        }
-                       if (!strcmp(buf, "text")) {
-                               while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
-                                       extract_token(key, buf, 0, '|', sizeof key);
-                                       extract_token(value, buf, 1, '|', sizeof value);
-                                       if (!IsEmptyStr(key))
-                                               Put(WC->hash_prefs, key, strlen(key), strdup(value), free);
+                       if (!strcmp(ChrPtr(ReadBuf), "text")) {
+                               StrBuf *Key;
+                               StrBuf *Data = NULL;
+                               StrBuf *LastData = NULL;
+                               
+                               Key = NewStrBuf();
+                               while (StrBuf_ServGetln(ReadBuf), 
+                                      strcmp(ChrPtr(ReadBuf), "000")) 
+                               {
+                                       if ((ChrPtr(ReadBuf)[0] == ' ') &&
+                                           (Data != NULL)) {
+                                               StrBufAppendBuf(Data, ReadBuf, 1);
+                                       }
+                                       else {
+                                               LastData = Data = NewStrBuf();
+                                               StrBufExtract_token(Key, ReadBuf, 0, '|');
+                                               StrBufExtract_token(Data, ReadBuf, 1, '|');
+                                               if (!IsEmptyStr(ChrPtr(Key)))
+                                               {
+                                                       Put(WC->hash_prefs, 
+                                                           ChrPtr(Key), StrLength(Key), 
+                                                           Data, 
+                                                           HFreeStrBuf);
+                                               }
+                                               else 
+                                               {
+                                                       FreeStrBuf(&Data);
+                                                       LastData = NULL;
+                                               }
+                                       }
                                }
+                               FreeStrBuf(&Key);
                        }
                }
        }
@@ -109,14 +136,48 @@ void save_preferences(void) {
                HashList *Hash;
                void *Value;
                char *Key;
+               StrBuf *Buf;
+               StrBuf *SubBuf = NULL;
                
                Hash = WC->hash_prefs;
                dbg_PrintHash(Hash, PrintPref, NULL);
                HashPos = GetNewHashPos();
                while (GetNextHashPos(Hash, HashPos, &len, &Key, &Value)!=0)
                {
-                       serv_printf("%s|%s", Key, (char*)Value);
+                       size_t nchars;
+                       Buf = (StrBuf*) Value;
+                       nchars = StrLength(Buf);
+                       if (nchars > 80){
+                               int n = 0;
+                               size_t offset, nchars;
+                               if (SubBuf == NULL)
+                                       SubBuf = NewStrBuf();
+                               nchars = 1;
+                               offset = 0;
+                               while (nchars > 0) {
+                                       if (n == 0)
+                                               nchars = 70;
+                                       else 
+                                               nchars = 80;
+
+                                       nchars = StrBufSub(SubBuf, Buf, offset, nchars);
+                                       
+                                       if (n == 0)
+                                               serv_printf("%s|%s", Key, ChrPtr(SubBuf));
+                                       else
+                                               serv_printf(" %s", Key, ChrPtr(SubBuf));
+
+                                       offset += nchars;
+                                       n++;
+                               }
+                               
+                       }
+                       else
+                               serv_printf("%s|%s", Key, ChrPtr(Buf));
+                       
                }
+               if (SubBuf != NULL)
+                       FreeStrBuf(&SubBuf);
                serv_puts("");
                serv_puts("000");
                DeleteHashPos(&HashPos);
@@ -130,52 +191,117 @@ void save_preferences(void) {
 /**
  * \brief query the actual setting of key in the citadel database
  * \param key config key to query
- * \param value value to the key to get
- * \param value_len length of the value string
+ * \param keylen length of the key string
+ * \param value StrBuf-value to the key to get
+ * \returns found?
  */
-void get_preference(char *key, char *value, size_t value_len) {
+int get_PREFERENCE(const char *key, size_t keylen, StrBuf **value)
+{
        void *hash_value = NULL;
        
-       strcpy(value, "");
        dbg_PrintHash(WC->hash_prefs, PrintPref, NULL);
-       if (GetHash(WC->hash_prefs, key, strlen(key), &hash_value) == 0)
-               return;
-       
-       if(hash_value)
-               safestrncpy(value, hash_value, value_len);
+       if (GetHash(WC->hash_prefs, key, keylen, &hash_value) == 0) {
+               *value = NULL;
+               return 0;
+       }
+       else {
+               *value = NULL;
+               *value = (StrBuf*) hash_value;
+               return 1;
+       }
 }
 
 /**
  * \brief      Write a key into the webcit preferences database for this user
  *
  * \params     key             key whichs value is to be modified
+ * \param keylen length of the key string
  * \param      value           value to set
  * \param      save_to_server  1 = flush all data to the server, 0 = cache it for now
  */
-void set_preference(char *key, char *value, int save_to_server) {
+void set_PREFERENCE(const char *key, size_t keylen, StrBuf *value, int save_to_server) {
        
-       Put(WC->hash_prefs, key, strlen(key), strdup(value), free);
+       Put(WC->hash_prefs, key, keylen, value, HFreeStrBuf);
        
        if (save_to_server) save_preferences();
 }
 
+int get_PREF_LONG(const char *key, size_t keylen, long *value, long Default)
+{
+       int ret;
+       StrBuf *val;
+       ret = get_PREFERENCE(key, keylen, &val);
+       if (ret) {
+               *value = atol(ChrPtr(val));
+       }
+       else {
+               *value = Default;
+       }
+
+       return ret;
+}
+
+
+void set_PREF_LONG(const char *key, size_t keylen, long value, int save_to_server)
+{
+       StrBuf *val;
+       if (get_PREFERENCE(key, keylen, &val)) {
+               StrBufPrintf(val, "%ld", value);
+       }
+       else {
+               val = NewStrBuf();
+               StrBufPrintf(val, "%ld", value);
+               set_PREFERENCE(key, keylen, val, save_to_server);
+       }
+}
 
 
 
+int get_PREF_YESNO(const char *key, size_t keylen, int *value, int Default)
+{
+       int ret;
+       StrBuf *val;
+       ret = get_PREFERENCE(key, keylen, &val);
+       if (ret) {
+               *value = strcmp(ChrPtr(val), "yes") == 0;
+       }
+       else {
+               *value = Default;
+       }
+
+       return ret;
+}
+
+void set_PREF_YESNO(const char *key, size_t keylen, int value, int save_to_server)
+{
+       StrBuf *val;
+       if (get_PREFERENCE(key, keylen, &val)) {
+               StrBufPrintf(val, "%s", (value)?"yes":"no");
+       }
+       else {
+               val = NewStrBuf();
+               StrBufPrintf(val, "%s", (value)?"yes":"no");
+               set_PREFERENCE(key, keylen, val, save_to_server);
+       }
+}
+
 /** 
  * \brief display form for changing your preferences and settings
  */
 void display_preferences(void)
 {
        output_headers(1, 1, 1, 0, 0, 0);
-       char ebuf[300];
-       char buf[256];
+       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");
@@ -188,7 +314,7 @@ void display_preferences(void)
        /** begin form */
        wprintf("<form name=\"prefform\" action=\"set_preferences\" "
                "method=\"post\">\n");
-       wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
+       wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
 
        /** begin table */
         wprintf("<table class=\"altern\">\n");
@@ -196,19 +322,19 @@ void display_preferences(void)
        /**
         * Room list view
         */
-       get_preference("roomlistview", buf, sizeof buf);
+       get_preference("roomlistview", &Buf);
        wprintf("<tr class=\"even\"><td>");
        wprintf(_("Room list view"));
        wprintf("</td><td>");
 
        wprintf("<input type=\"radio\" name=\"roomlistview\" VALUE=\"folders\"");
-       if (!strcasecmp(buf, "folders")) wprintf(" checked");
+       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 (!strcasecmp(buf, "rooms")) wprintf(" checked");
+       if (IsEmptyStr(ChrPtr(Buf)) || !strcasecmp(ChrPtr(Buf), "rooms")) wprintf(" checked");
        wprintf(">");
        wprintf(_("Table (rooms) view"));
        wprintf("</input>\n");
@@ -242,8 +368,8 @@ void display_preferences(void)
        /**
         * Calendar day view -- day start time
         */
-       get_preference("daystart", buf, sizeof buf);
-       if (buf[0] == 0) strcpy(buf, "8");
+       get_pref_long("daystart", &DayStart, 8);
+
        wprintf("<tr class=\"even\"><td>");
        wprintf(_("Calendar day view begins at:"));
        wprintf("</td><td>");
@@ -253,13 +379,13 @@ void display_preferences(void)
 
                if (time_format == WC_TIMEFORMAT_24) {
                        wprintf("<option %s value=\"%d\">%d:00</option>\n",
-                               ((atoi(buf) == i) ? "selected" : ""),
+                               ((DayStart == i) ? "selected" : ""),
                                i, i
                        );
                }
                else {
                        wprintf("<option %s value=\"%d\">%s</option>\n",
-                               ((atoi(buf) == i) ? "selected" : ""),
+                               ((DayStart == i) ? "selected" : ""),
                                i, hourname[i]
                        );
                }
@@ -271,8 +397,8 @@ void display_preferences(void)
        /**
         * Calendar day view -- day end time
         */
-       get_preference("dayend", buf, sizeof buf);
-       if (buf[0] == 0) strcpy(buf, "17");
+       get_pref_long("dayend", &DayEnd, 17);
+
        wprintf("<tr class=\"odd\"><td>");
        wprintf(_("Calendar day view ends at:"));
        wprintf("</td><td>");
@@ -282,13 +408,13 @@ void display_preferences(void)
 
                if (time_format == WC_TIMEFORMAT_24) {
                        wprintf("<option %s value=\"%d\">%d:00</option>\n",
-                               ((atoi(buf) == i) ? "selected" : ""),
+                               ((DayEnd == i) ? "selected" : ""),
                                i, i
                        );
                }
                else {
                        wprintf("<option %s value=\"%d\">%s</option>\n",
-                               ((atoi(buf) == i) ? "selected" : ""),
+                               ((DayEnd == i) ? "selected" : ""),
                                i, hourname[i]
                        );
                }
@@ -300,8 +426,7 @@ void display_preferences(void)
        /**
         * Day of week to begin calendar month view
         */
-       get_preference("weekstart", buf, sizeof buf);
-       if (buf[0] == 0) strcpy(buf, "17");
+       get_pref_long("weekstart", &WeekStart, 17);
        wprintf("<tr class=\"even\"><td>");
        wprintf(_("Week starts on:"));
        wprintf("</td><td>");
@@ -315,7 +440,7 @@ void display_preferences(void)
                 wc_strftime(daylabel, sizeof daylabel, "%A", &tm);
 
                wprintf("<option %s value=\"%d\">%s</option>\n",
-                       ((atoi(buf) == i) ? "selected" : ""),
+                       ((WeekStart == i) ? "selected" : ""),
                        i, daylabel
                );
        }
@@ -326,8 +451,7 @@ void display_preferences(void)
        /**
         * Signature
         */
-       get_preference("use_sig", buf, sizeof buf);
-       if (buf[0] == 0) strcpy(buf, "no");
+       get_pref_yesno("use_sig", &UseSig, 0);
        wprintf("<tr class=\"odd\"><td>");
        wprintf(_("Attach signature to email messages?"));
        wprintf("</td><td>");
@@ -345,21 +469,24 @@ void display_preferences(void)
        );
 
        wprintf("<input type=\"radio\" id=\"no_sig\" name=\"use_sig\" VALUE=\"no\"");
-       if (!strcasecmp(buf, "no")) wprintf(" checked");
+       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 (!strcasecmp(buf, "yes")) wprintf(" checked");
+       if (UseSig) wprintf(" checked");
        wprintf(" onChange=\"show_or_hide_sigbox();\" >");
        wprintf(_("Use this signature:"));
        wprintf("<div id=\"signature_box\">"
                "<br><textarea name=\"signature\" cols=\"40\" rows=\"5\">"
        );
-       get_preference("signature", ebuf, sizeof ebuf);
-       euid_unescapize(buf, ebuf);
-       escputs(buf);
+
+       get_preference("signature", &Signature);
+       ebuf = NewStrBuf();
+       StrBufEUid_unescapize(ebuf, Signature);
+       escputs(ChrPtr(ebuf));
+       FreeStrBuf(&ebuf);
        wprintf("</textarea>"
                "</div>"
        );
@@ -374,13 +501,15 @@ void display_preferences(void)
        );
 
        /** Character set to assume is in use for improperly encoded headers */
-       get_preference("default_header_charset", buf, sizeof buf);
-       if (buf[0] == 0) strcpy(buf, "UTF-8");
+       if (!get_preference("default_header_charset", &Buf)) {
+               Buf = NewStrBuf();////TODO: freeme!
+               StrBufPrintf(Buf, "%s", "UTF-8");
+       }
        wprintf("<tr class=\"even\"><td>");
        wprintf(_("Default character set for email headers:"));
        wprintf("</td><td>");
        wprintf("<input type=\"text\" NAME=\"default_header_charset\" MAXLENGTH=\"32\" VALUE=\"");
-       escputs(buf);
+       escputs(ChrPtr(Buf));
        wprintf("\">");
        wprintf("</td></tr>");
 
@@ -388,20 +517,19 @@ void display_preferences(void)
         * Show empty floors?
         */
 
-       get_preference("emptyfloors", buf, sizeof buf);
-       if (buf[0] == 0) strcpy(buf, "no");
+       get_pref_yesno("emptyfloors", &ShowEmptyFloors, 0);
        wprintf("<tr class=\"odd\"><td>");
        wprintf(_("Show empty floors"));
        wprintf("</td><td>");
 
        wprintf("<input type=\"radio\" name=\"emptyfloors\" VALUE=\"yes\"");
-       if (!strcasecmp(buf, "yes")) wprintf(" checked");
+       if (ShowEmptyFloors) wprintf(" checked");
        wprintf(">");
        wprintf(_("Yes"));
        wprintf("</input>&nbsp;&nbsp;&nbsp;");
 
        wprintf("<input type=\"radio\" name=\"emptyfloors\" VALUE=\"no\"");
-       if (!strcasecmp(buf, "no")) wprintf(" checked");
+       if (!ShowEmptyFloors) wprintf(" checked");
        wprintf(">");
        wprintf(_("No"));
        wprintf("</input>\n");
@@ -432,8 +560,8 @@ void display_preferences(void)
  */
 void set_preferences(void)
 {
-       char *fmt;
-       char ebuf[300];
+       long fmt;
+       StrBuf *ebuf;
        int *time_format_cache;
        
        time_format_cache = &(WC->time_format_cache);
@@ -450,22 +578,23 @@ void set_preferences(void)
         * Set the last argument to 1 only for the final setting, so
         * we don't send the prefs file to the server repeatedly
         */
-       set_preference("roomlistview", bstr("roomlistview"), 0);
-       fmt = bstr("calhourformat");
-       set_preference("calhourformat", fmt, 0);
-       if (!strcasecmp(fmt, "24")
+       set_preference("roomlistview", NewStrBufPlain(bstr("roomlistview"), -1), 0);
+       fmt = lbstr("calhourformat");
+       set_pref_long("calhourformat", fmt, 0);
+       if (fmt == 24
                *time_format_cache = WC_TIMEFORMAT_24;
        else
                *time_format_cache = WC_TIMEFORMAT_AMPM;
 
-       set_preference("weekstart", bstr("weekstart"), 0);
-       set_preference("use_sig", bstr("use_sig"), 0);
-       set_preference("daystart", bstr("daystart"), 0);
-       set_preference("dayend", bstr("dayend"), 0);
-       set_preference("default_header_charset", bstr("default_header_charset"), 0);
-       set_preference("emptyfloors", bstr("emptyfloors"), 0);
+       set_pref_long("weekstart", lbstr("weekstart"), 0);
+       set_pref_yesno("use_sig", yesbstr("use_sig"), 0);
+       set_pref_long("daystart", lbstr("daystart"), 0);
+       set_pref_long("dayend", lbstr("dayend"), 0);
+       set_preference("default_header_charset", NewStrBufPlain(bstr("default_header_charset"), -1), 0);
+       set_preference("emptyfloors", NewStrBufPlain(bstr("emptyfloors"), -1), 0);
 
-       euid_escapize(ebuf, bstr("signature"));
+       ebuf = NewStrBufPlain(bstr("signature"), -1);
+       /////TODOeuid_escapize(ebuf);
        set_preference("signature", ebuf, 1);
 
        display_main_menu();
index 6fb8bafb43814103dba002f8bc4034e6c22040ab..4ade41486bfe07a7a3586abbc7b09577f2c0b6f6 100644 (file)
@@ -380,7 +380,7 @@ void embed_view_o_matic(void) {
        int i;
 
        wprintf("<form name=\"viewomatic\" action=\"changeview\">\n");
-       wprintf("\t<div style=\"display: inline;\">\n\t<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
+       wprintf("\t<div style=\"display: inline;\">\n\t<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
        wprintf("<label for=\"view_name\">");
        wprintf(_("View as:"));
        wprintf("</label> "
@@ -419,7 +419,7 @@ void embed_view_o_matic(void) {
  */
 void embed_search_o_matic(void) {
        wprintf("<form name=\"searchomatic\" action=\"do_search\">\n");
-       wprintf("<div style=\"display: inline;\"><input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
+       wprintf("<div style=\"display: inline;\"><input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
        wprintf("<label for=\"search_name\">");
        wprintf(_("Search: "));
        wprintf("</label><input ");
@@ -1291,7 +1291,7 @@ void display_editroom(void)
                        er_flags2 = extract_int(&buf[4], 7);
        
                        wprintf("<form method=\"POST\" action=\"editroom\">\n");
-                       wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
+                       wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
                
                        wprintf("<ul><li>");
                        wprintf(_("Name of room: "));
@@ -1577,7 +1577,7 @@ void display_editroom(void)
                        extract_token(remote_room, buf, 1, '|', sizeof remote_room);
                        if (!IsEmptyStr(node)) {
                                wprintf("<form method=\"POST\" action=\"netedit\">");
-                               wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
+                               wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
                                wprintf("<tr><td>%s</td>\n", node);
 
                                wprintf("<td>");
@@ -1618,7 +1618,7 @@ void display_editroom(void)
                        extract_token(node, not_shared_with, i, '\n', sizeof node);
                        if (!IsEmptyStr(node)) {
                                wprintf("<form method=\"POST\" action=\"netedit\">");
-                               wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
+                               wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
                                wprintf("<tr><td>");
                                escputs(node);
                                wprintf("</td><td>"
@@ -1692,7 +1692,7 @@ void display_editroom(void)
                wprintf("<br /><form method=\"POST\" action=\"netedit\">\n"
                        "<input type=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
                        "<input type=\"hidden\" NAME=\"prefix\" VALUE=\"listrecp|\">\n");
-               wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
+               wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
                wprintf("<input type=\"text\" id=\"add_as_listrecp\" NAME=\"line\">\n");
                wprintf("<input type=\"submit\" NAME=\"add_button\" VALUE=\"%s\">", _("Add"));
                wprintf("</form>\n");
@@ -1723,7 +1723,7 @@ void display_editroom(void)
                wprintf("<br /><form method=\"POST\" action=\"netedit\">\n"
                        "<input type=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
                        "<input type=\"hidden\" NAME=\"prefix\" VALUE=\"digestrecp|\">\n");
-               wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
+               wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
                wprintf("<input type=\"text\" id=\"add_as_digestrecp\" NAME=\"line\">\n");
                wprintf("<input type=\"submit\" NAME=\"add_button\" VALUE=\"%s\">", _("Add"));
                wprintf("</form>\n");
@@ -1807,7 +1807,7 @@ void display_editroom(void)
                        }
                        
                        wprintf("<br /><form method=\"POST\" action=\"set_room_policy\">\n");
-                       wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
+                       wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
                        wprintf("<table border=0 cellspacing=5>\n");
                        wprintf("<tr><td>");
                        wprintf(_("Message expire policy for this room"));
@@ -1950,7 +1950,7 @@ void display_editroom(void)
                        "<tr>"
                        "<input type=\"hidden\" name=\"tab\" value=\"feeds\">"
                        "<input type=\"hidden\" name=\"prefix\" value=\"pop3client|\">\n");
-               wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
+               wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
                wprintf("<td>");
                wprintf("<input type=\"text\" id=\"add_as_pop3host\" NAME=\"line_pop3host\">\n");
                wprintf("</td>");
@@ -2017,7 +2017,7 @@ void display_editroom(void)
                        "<tr>"
                        "<input type=\"hidden\" name=\"tab\" value=\"feeds\">"
                        "<input type=\"hidden\" name=\"prefix\" value=\"rssclient|\">\n");
-               wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
+               wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
                wprintf("<td>");
                wprintf("<input type=\"text\" id=\"add_as_pop3host\" size=\"72\" "
                        "maxlength=\"256\" name=\"line_pop3host\">\n");
@@ -2335,7 +2335,7 @@ void display_whok(void)
        wprintf("<br /><br />");
        
         wprintf("<CENTER><form method=\"POST\" action=\"do_invt_kick\">\n");
-       wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
+       wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
        wprintf("<input type=\"hidden\" NAME=\"tab\" VALUE=\"access\">\n");
         wprintf("<select NAME=\"username\" SIZE=\"10\" style=\"width:100%%\">\n");
         serv_puts("WHOK");
@@ -2360,7 +2360,7 @@ void display_whok(void)
 
         wprintf("<CENTER><form method=\"POST\" action=\"do_invt_kick\">\n");
        wprintf("<input type=\"hidden\" NAME=\"tab\" VALUE=\"access\">\n");
-       wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
+       wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
         wprintf(_("Invite:"));
        wprintf(" ");
         wprintf("<input type=\"text\" name=\"username\" id=\"username_id\" style=\"width:100%%\"><br />\n"
@@ -2408,7 +2408,7 @@ void display_entroom(void)
        do_template("beginbox");
 
        wprintf("<form name=\"create_room_form\" method=\"POST\" action=\"entroom\">\n");
-       wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
+       wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
 
        wprintf("<table class=\"altern\"> ");
 
@@ -2643,7 +2643,7 @@ void display_private(char *rname, int req_pass)
        wprintf("</p>");
 
        wprintf("<form method=\"post\" action=\"goto_private\">\n");
-       wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
+       wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
 
        wprintf("<table class=\"altern\"> "
                "<tr class=\"even\"><td>");
@@ -2729,7 +2729,7 @@ void display_zap(void)
                "to do?<br />\n"), WC->wc_roomname);
 
        wprintf("<form method=\"POST\" action=\"zap\">\n");
-       wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
+       wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
        wprintf("<input type=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">", _("Zap this room"));
        wprintf("&nbsp;");
        wprintf("<input type=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
@@ -3189,7 +3189,7 @@ void do_rooms_view(struct folder *fold, int max_folders, int num_floors) {
  */
 void set_floordiv_expanded(char *which_floordiv) {
        begin_ajax_response();
-       safestrncpy(WC->floordiv_expanded, which_floordiv, sizeof WC->floordiv_expanded);
+       StrBufPrintf(WC->floordiv_expanded, "%s", which_floordiv);
        end_ajax_response();
 }
 
@@ -3238,7 +3238,7 @@ void do_iconbar_view(struct folder *fold, int max_folders, int num_floors) {
                                "%s</span><br>\n", floordiv_id, floordivtitle);
                        wprintf("<div id=\"%s\" style=\"display:%s\">",
                                floordiv_id,
-                               (!strcasecmp(floordiv_id, WC->floordiv_expanded) ? "block" : "none")
+                               (!strcasecmp(floordiv_id, ChrPtr(WC->floordiv_expanded)) ? "block" : "none")
                        );
                }
 
@@ -3323,9 +3323,9 @@ void do_iconbar_view(struct folder *fold, int max_folders, int num_floors) {
        }
 
        wprintf("num_drop_targets = %d;\n", num_drop_targets);
-       if ((WC->floordiv_expanded[0] != '\0')&&
-           (WC->floordiv_expanded[1] != '\0')){
-               wprintf("which_div_expanded = '%s';\n", WC->floordiv_expanded);
+       if ((ChrPtr(WC->floordiv_expanded)[0] != '\0')&&
+           (ChrPtr(WC->floordiv_expanded)[1] != '\0')){
+               wprintf("which_div_expanded = '%s';\n", ChrPtr(WC->floordiv_expanded));
        }
 
        wprintf("\">\n");
@@ -3360,7 +3360,7 @@ void burn_folder_cache(time_t age)
  * \param viewpref the view preferences???
  */
 
-void list_all_rooms_by_floor(char *viewpref) {
+void list_all_rooms_by_floor(const char *viewpref) {
        char buf[SIZ];
        int swap = 0;
        struct folder *fold = NULL;
@@ -3370,10 +3370,10 @@ void list_all_rooms_by_floor(char *viewpref) {
        int *floor_mapping;
        int IDMax;
        int i, j;
+       int ShowEmptyFloors;
        int ra_flags = 0;
        int flags = 0;
        int num_floors = 1;     /** add an extra one for private folders */
-       char buf2[SIZ];
        char buf3[SIZ];
        
        /** If our cached folder list is very old, burn it. */
@@ -3463,8 +3463,8 @@ void list_all_rooms_by_floor(char *viewpref) {
        /*
         * Remove any floors that don't have rooms
         */
-       get_preference("emptyfloors", buf2, sizeof buf2);
-       if (buf2[0]==0 || (strcasecmp(buf2, "no") == 0))
+       get_pref_yesno("emptyfloors", &ShowEmptyFloors, 0);
+       if (ShowEmptyFloors)
        {
                for (i=0; i<num_floors; i++)
                {
@@ -3539,35 +3539,37 @@ void list_all_rooms_by_floor(char *viewpref) {
  */
 void knrooms(void)
 {
-       char listviewpref[SIZ];
+       StrBuf *ListView;
 
        output_headers(1, 1, 2, 0, 0, 0);
 
        /** Determine whether the user is trying to change views */
        if (bstr("view") != NULL) {
                if (havebstr("view")) {
-                       set_preference("roomlistview", bstr("view"), 1);
+                       set_preference("roomlistview", NewStrBufPlain(bstr("view"), -1), 1);
                }
        }
 
-       get_preference("roomlistview", listviewpref, sizeof listviewpref);
-
-       if ( (strcasecmp(listviewpref, "folders"))
-          && (strcasecmp(listviewpref, "table")) ) {
-               strcpy(listviewpref, "rooms");
+       if(!get_preference("roomlistview", &ListView) ||
+          ((strcasecmp(ChrPtr(ListView), "folders"))
+           && (strcasecmp(ChrPtr(ListView), "table")))) {
+               if (ListView == NULL)
+                       ListView = NewStrBuf();
+               StrBufPrintf(ListView, "%s", "rooms");
+               set_preference("roomlistview", ListView, 0);
        }
 
        /** title bar */
        wprintf("<div id=\"banner\">\n");
        wprintf("<div class=\"room_banner\">");
        wprintf("<h1>");
-       if (!strcasecmp(listviewpref, "rooms")) {
+       if (!strcasecmp(ChrPtr(ListView), "rooms")) {
                wprintf(_("Room list"));
        }
-       if (!strcasecmp(listviewpref, "folders")) {
+       else if (!strcasecmp(ChrPtr(ListView), "folders")) {
                wprintf(_("Folder list"));
        }
-       if (!strcasecmp(listviewpref, "table")) {
+       else if (!strcasecmp(ChrPtr(ListView), "table")) {
                wprintf(_("Room list"));
        }
        wprintf("</h1></div>\n");
@@ -3585,13 +3587,13 @@ void knrooms(void)
        wprintf("<option %s value=\"knrooms&view=rooms\">"
                "View as room list"
                "</option>\n",
-               ( !strcasecmp(listviewpref, "rooms") ? "SELECTED" : "" )
+               ( !strcasecmp(ChrPtr(ListView), "rooms") ? "SELECTED" : "" )
        );
 
        wprintf("<option %s value=\"knrooms&view=folders\">"
                "View as folder list"
                "</option>\n",
-               ( !strcasecmp(listviewpref, "folders") ? "SELECTED" : "" )
+               ( !strcasecmp(ChrPtr(ListView), "folders") ? "SELECTED" : "" )
        );
 
        wprintf("</select>");
@@ -3601,7 +3603,7 @@ void knrooms(void)
        wprintf("<div id=\"content\" class=\"service\">\n");
 
        /** Display the room list in the user's preferred format */
-       list_all_rooms_by_floor(listviewpref);
+       list_all_rooms_by_floor(ChrPtr(ListView));
        wDumpContent(1);
 }
 
index 4a664f28d87cc161d736847f5511c611df18835e..73297a54991fd844dcc5c90c7a041581d4d1714d 100644 (file)
@@ -29,13 +29,13 @@ void display_rss_control(char *reply_to, char *subject)
        wprintf("<a href=\"display_enter?recp=");
        urlescputs(reply_to);
        wprintf("&subject=");
-       if (strncasecmp(subject, "Re: ", 3)) wprintf("Re:%20");
+       if (strncasecmp(subject, "Re: ", 3)) wprintf("Re:%%20");
        urlescputs(subject);
        wprintf("\">[%s]</a> \n", _("Reply"));
        wprintf("<a href=\"display_enter?recp=");
        urlescputs(reply_to);
        wprintf("&force_room=_MAIL_&subject=");
-       if (strncasecmp(subject, "Re: ", 3)) wprintf("Re:%20");
+       if (strncasecmp(subject, "Re: ", 3)) wprintf("Re:%%20");
        urlescputs(subject);
        wprintf("\">[%s]</a>\n", _("Email"));
        wprintf("</p></div>\n");
index a6beb9a0cbca6fa1ec8a792e06a4a4c8ea4d2034..d2d177a2bee34651eb85aebb976f7b4531c07df2 100644 (file)
@@ -38,7 +38,7 @@ void do_setup_wizard(void)
        wprintf("<div class=\"fix_scrollbar_bug\">"
                "<form method=\"post\" action=\"setup_wizard\">\n"
        );
-       wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
+       wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
 
        wprintf("<div align=center>"
                "This is where the setup wizard will be placed.<br>\n"
index a566c79410214d30f6982d7ed4bde0e751effe94..cf68af89ae1eb3f19b364f15af1b8e3cf3749f74 100644 (file)
@@ -116,7 +116,7 @@ void display_sieve(void)
 
 
        wprintf("<form id=\"sieveform\" method=\"post\" action=\"save_sieve\">\n");
-       wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
+       wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
 
        wprintf(_("When new mail arrives: "));
         wprintf("<select name=\"bigaction\" size=1 onChange=\"ToggleSievePanels();\">\n");
@@ -656,7 +656,7 @@ void display_add_remove_scripts(char *message)
        wprintf("<br /><br />");
 
         wprintf("<center><form method=\"POST\" action=\"create_script\">\n");
-       wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
+       wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
         wprintf(_("Script name: "));
         wprintf("<input type=\"text\" name=\"script_name\"><br />\n"
                "<input type=\"submit\" name=\"create_button\" value=\"%s\">"
@@ -682,7 +682,7 @@ void display_add_remove_scripts(char *message)
        
         wprintf("<center>"
                "<form method=\"POST\" action=\"delete_script\">\n");
-       wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
+       wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
         wprintf("<select name=\"script_name\" size=10 style=\"width:100%%\">\n");
 
         serv_puts("MSIV listscripts");
index a18bbd18e56602a5064b329de0d90d85454e15a0..7a7288dee90c92b874d44dc8f8b3efbfff41a3b2 100644 (file)
@@ -113,7 +113,7 @@ void display_siteconfig(void)
                );
                
        wprintf("<form method=\"post\" action=\"siteconfig\">\n");
-       wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
+       wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
        
        sprintf(&general[strlen(general)], "<tr><td><a href=\"display_edithello\"> %s </a></td>",           _("Change Login Logo"));
        sprintf(&general[strlen(general)],     "<td><a href=\"display_editgoodbuye\"> %s </a></td></tr>\n", _("Change Logout Logo"));
index aa255b9a3984a0d4adb73e98857ec577c0b8116f..85d5dcc65af5f635e809656f1eaeedb33262fcc9 100644 (file)
@@ -287,7 +287,7 @@ void print_value_of(char *keyname, size_t keylen) {
                ptr = (wcsubst*) vVar;
                switch(ptr->wcs_type) {
                case WCS_STRING:
-                       wprintf("%s", ptr->wcs_value);
+                       wprintf("%s", (const char*)ptr->wcs_value);
                        break;
                case WCS_SERVCMD:
                        pvo_do_cmd(ptr->wcs_value);
@@ -374,7 +374,7 @@ void do_template(void *templatename) {
        if (fp == NULL) {
                wprintf(_("ERROR: could not open template "));
                wprintf("'%s' - %s<br />\n",
-                       templatename, strerror(errno));
+                       (const char*)templatename, strerror(errno));
                return;
        }
 
index e336f0f774327e111a0f164fb6491ed77e7f31bf..00abb6cc5eefec13b01e683e6466c579f1093220 100644 (file)
@@ -44,7 +44,7 @@ void display_edit(char *description, char *check_cmd,
                " A newline is forced by preceding the next line by a blank."), description);
 
        wprintf("<form method=\"post\" action=\"%s\">\n", save_cmd);
-       wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
+       wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
        wprintf("<textarea name=\"msgtext\" wrap=soft "
                "rows=10 cols=80 width=80>\n");
        serv_puts(read_cmd);
index c87cf4a4c269e43bdcd544e226faca256be8c17f..fd50c31b901c05ec9e33d4149147c3e31912d5aa 100644 (file)
@@ -36,9 +36,8 @@ void tabbed_dialog(int num_tabs, char *tabnames[]) {
                        ">",
                        i,
                        ( (i==0) ? "tab_cell_label" : "tab_cell_edit" ),
-                       i,
                        i
-               );
+                       );
                wprintf("%s", tabnames[i]);
                wprintf("</td>");
 
index 4b0e51c1f38a2303a60c82217c5ba41bb5380f58..e94c8a5fac36e78813049fc2d1df811de7f77017 100644 (file)
@@ -12,6 +12,7 @@
 #define SERV_TRACE 1
  */
 
+
 #include "webcit.h"
 #include "webserver.h"
 
@@ -176,7 +177,23 @@ int serv_getln(char *strbuf, int bufsize)
        return len;
 }
 
-
+int StrBuf_ServGetln(StrBuf *buf)
+{
+       const char *ErrStr;
+       int rc;
+
+       rc = StrBufTCP_read_line(buf, WC->serv_sock, 0, &ErrStr);
+       if (rc < 0)
+       {
+               lprintf(1, "Server connection broken: %s\n",
+                       ErrStr);
+               wc_backtrace();
+               WC->serv_sock = (-1);
+               WC->connected = 0;
+               WC->logged_in = 0;
+       }
+       return rc;
+}
 
 /**
  * \brief send binary to server
index 425139a7e67e331ec3e57a3e6229cbd28043b63d..e7ac53bd243d405b081dfb906cbbb507fbb3cd5f 100644 (file)
@@ -44,7 +44,7 @@ void select_user_to_edit(char *message, char *preselect)
        wprintf("<br /><br />");
 
         wprintf("<center><form method=\"POST\" action=\"create_user\">\n");
-       wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
+       wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
         wprintf(_("New user: "));
         wprintf("<input type=\"text\" name=\"username\"><br />\n"
                "<input type=\"submit\" name=\"create_button\" value=\"%s\">"
@@ -63,7 +63,7 @@ void select_user_to_edit(char *message, char *preselect)
        
         wprintf("<center>"
                "<form method=\"POST\" action=\"display_edituser\">\n");
-       wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
+       wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
         wprintf("<select name=\"username\" size=10 style=\"width:100%%\">\n");
         serv_puts("LIST");
         serv_getln(buf, sizeof buf);
@@ -296,7 +296,7 @@ void display_edituser(char *supplied_username, int is_new) {
        wprintf("<input type=\"hidden\" name=\"is_new\" value=\"%d\">\n"
                "<input type=\"hidden\" name=\"usernum\" value=\"%ld\">\n",
                is_new, usernum);
-       wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
+       wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
 
        wprintf("<input type=\"hidden\" name=\"flags\" value=\"%d\">\n", flags);
 
index 4b036e03fab68237dd857983f48ac650fff0eb16..17b781778c9804509c0c7d6138bf97b922ae4e13 100644 (file)
@@ -191,7 +191,7 @@ void do_edit_vcard(long msgnum, char *partnum, char *return_to, char *force_room
        do_template("beginbox");
 
        wprintf("<form method=\"POST\" action=\"submit_vcard\">\n");
-       wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
+       wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
 
        if (force_room != NULL) {
                wprintf("<input type=\"hidden\" name=\"force_room\" value=\"");
index f06c546a988790a2b1f76286b1ac0abea613da05..df08bd8e026ef9ecc20f3ef079b65e6a69dd4766 100644 (file)
@@ -725,7 +725,7 @@ void output_headers(        int do_httpheaders,     /* 1 = output HTTP headers
 /*
  * Generic function to do an HTTP redirect.  Easy and fun.
  */
-void http_redirect(char *whichpage) {
+void http_redirect(const char *whichpage) {
        wprintf("HTTP/1.1 302 Moved Temporarily\n");
        wprintf("Location: %s\r\n", whichpage);
        wprintf("URI: %s\r\n", whichpage);
@@ -1112,7 +1112,7 @@ void change_start_page(void) {
                return;
        }
 
-       set_preference("startpage", bstr("startpage"), 1);
+       set_preference("startpage", NewStrBufPlain(bstr("startpage"), -1), 1);
 
        output_headers(1, 1, 0, 0, 0, 0);
        do_template("newstartpage");
@@ -1137,7 +1137,7 @@ void display_success(char *successmessage)
 void authorization_required(const char *message)
 {
        wprintf("HTTP/1.1 401 Authorization Required\r\n");
-       wprintf("WWW-Authenticate: Basic realm=\"\"\r\n", serv_info.serv_humannode);
+       wprintf("WWW-Authenticate: Basic realm=\"%s\"\r\n", serv_info.serv_humannode);
        wprintf("Content-Type: text/html\r\n\r\n");
        wprintf("<h1>");
        wprintf(_("Authorization Required"));
index 21cf11f844c4bf2677f9b59450c9a52fd87bf481..d1f7e3f8080a2251a7013c4f561082105e12d32e 100644 (file)
@@ -126,7 +126,7 @@ extern locale_t wc_locales[];
 #define CLIENT_ID              4
 #define CLIENT_VERSION         737             /* This version of WebCit */
 #define MINIMUM_CIT_VERSION    737             /* min required Citadel ver */
-#define        LIBCITADEL_MIN          737             /* min required libcitadel ver */
+#define        LIBCITADEL_MIN          738             /* min required libcitadel ver */
 #define DEFAULT_HOST           "localhost"     /* Default Citadel server */
 #define DEFAULT_PORT           "504"
 #define LB                     (1)             /* Internal escape chars */
@@ -419,8 +419,9 @@ struct wcsession {
        int cache_max_folders;                  /**< ??? todo */
        int cache_num_floors;                   /**< ??? todo */
        time_t cache_timestamp;                 /**< ??? todo */
-       int current_iconbar;                    /**< What is currently in the iconbar? */
-       char floordiv_expanded[32];             /**< which floordiv currently expanded */
+       HashList *IconBarSetttings;             /**< which icons should be shown / not shown? */
+       long current_iconbar;                   /**< What is currently in the iconbar? */
+       StrBuf *floordiv_expanded;              /**< which floordiv currently expanded */
        int selected_language;                  /**< Language selected by user */
        time_t last_pager_check;                /**< last time we polled for instant msgs */
        int nonce;                              /**< session nonce (to prevent session riding) */
@@ -506,6 +507,7 @@ void get_serv_info(char *, char *);
 int uds_connectsock(char *);
 int tcp_connectsock(char *, char *);
 int serv_getln(char *strbuf, int bufsize);
+int StrBuf_ServGetln(StrBuf *buf);
 void serv_puts(char *string);
 void who(void);
 void who_inner_div(void);
@@ -554,7 +556,7 @@ void output_headers(    int do_httpheaders,
                        int unset_cookies,
                        int suppress_check,
                        int cache);
-void wprintf(const char *format,...);
+void wprintf(const char *format,...)__attribute__((__format__(__printf__,1,2)));
 void output_static(char *what);
 void display_mime_icon(void);
 void print_menu_box(char* Title, char *Class, int nLines, ...);
@@ -647,7 +649,7 @@ void end_webcit_session(void);
 void page_popup(void);
 void chat_recv(void);
 void chat_send(void);
-void http_redirect(char *);
+void http_redirect(const char *);
 void clear_substs(struct wcsession *wc);
 void clear_local_substs(void);
 
@@ -686,10 +688,29 @@ void edituser(void);
 void do_change_view(int);
 void change_view(void);
 void folders(void);
+
+
 void load_preferences(void);
 void save_preferences(void);
-void get_preference(char *key, char *value, size_t value_len);
-void set_preference(char *key, char *value, int save_to_server);
+#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_LONG(a, sizeof(a) - 1, b, c)
+void set_PREF_YESNO(const char *key, size_t keylen, int value, int save_to_server);
+
+
+
 void knrooms(void);
 int is_msg_in_mset(char *mset, long msgnum);
 void display_addressbook(long msgnum, char alpha);
@@ -745,7 +766,7 @@ void end_ajax_response(void);
 void initialize_viewdefs(void);
 void initialize_axdefs(void);
 void burn_folder_cache(time_t age);
-void list_all_rooms_by_floor(char *viewpref);
+void list_all_rooms_by_floor(const char *viewpref);
 void display_room_directory(void);
 void display_picture(void);
 void display_pictureview(void);
index 50677c93715dd03d2517d033edcd567e6bd314a3..834eb48177259bcf13cf88a245d99f1caa1a722b 100644 (file)
@@ -164,7 +164,7 @@ void who_inner_div(void) {
                        wprintf("</td>");
 
                        /* (link to page this user) */
-                       wprintf("<td width=\"5%\"><a href=\"display_page?recp=");
+                       wprintf("<td width=\"5%%\"><a href=\"display_page?recp=");
                        urlescputs(User->UserName);
                        wprintf("\">"
                                "<img align=\"middle\" "
@@ -174,12 +174,12 @@ void who_inner_div(void) {
                        wprintf("</td>");
 
                        /* (idle flag) */
-                       wprintf("<td width=\"5%\">");
+                       wprintf("<td width=\"5%%\">");
                        if (User->Idle) {
                                wprintf(" "
                                        "<img align=\"middle\" "
                                        "src=\"static/inactiveuser_24x.gif\" "
-                                       "alt=\"(%s %d %s)\" border=\"0\" />",
+                                       "alt=\"(%s %ld %s)\" border=\"0\" />",
                                        _("idle since"),
                                        (now - User->LastActive) / 60,
                                        _("Minutes")
@@ -345,7 +345,7 @@ void edit_me(void)
                wprintf("<br />\n");
 
                wprintf("<form method=\"POST\" action=\"edit_me\">\n");
-               wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
+               wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
 
                wprintf("<table border=0 width=100%%>\n");