From 2362c3d4de86f20822ab81015222a196137fd20e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Wilfried=20G=C3=B6esgens?= Date: Wed, 9 Jul 2008 00:52:34 +0000 Subject: [PATCH] * added gcc printf format checking to wprintf * corrected warnings of the above incidents * adopted strbuf in config handling * added multiline config handling --- webcit/auth.c | 31 ++--- webcit/calendar.c | 2 +- webcit/calendar_view.c | 31 ++--- webcit/context_loop.c | 3 +- webcit/crypto.c | 24 ++-- webcit/downloads.c | 2 +- webcit/event.c | 2 +- webcit/floors.c | 6 +- webcit/fmt_date.c | 6 +- webcit/graphics.c | 2 +- webcit/html2html.c | 2 +- webcit/iconbar.c | 302 ++++++++++++++++++++--------------------- webcit/inetconf.c | 2 +- webcit/mainmenu.c | 2 +- webcit/messages.c | 89 ++++++------ webcit/netconf.c | 4 +- webcit/notes.c | 2 +- webcit/openid.c | 2 +- webcit/paging.c | 4 +- webcit/preferences.c | 263 ++++++++++++++++++++++++++--------- webcit/roomops.c | 76 ++++++----- webcit/rss.c | 4 +- webcit/setup_wizard.c | 2 +- webcit/sieve.c | 6 +- webcit/siteconfig.c | 2 +- webcit/subst.c | 4 +- webcit/sysmsgs.c | 2 +- webcit/tabs.c | 3 +- webcit/tcp_sockets.c | 19 ++- webcit/useredit.c | 6 +- webcit/vcard_edit.c | 2 +- webcit/webcit.c | 6 +- webcit/webcit.h | 37 +++-- webcit/who.c | 8 +- 34 files changed, 560 insertions(+), 398 deletions(-) diff --git a/webcit/auth.c b/webcit/auth.c index 94bc438cb..d85ad0cb2 100644 --- a/webcit/auth.c +++ b/webcit/auth.c @@ -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("
\n"); for (a = 0; a <= 6; ++a) { - wprintf("nonce); + wprintf("nonce); urlescputs(user); wprintf("&axlevel=%d\">%s   \n", a, axdefs[a]); @@ -807,7 +804,7 @@ void display_changepw(void) } wprintf("
\n"); - wprintf("\n", WC->nonce); + wprintf("\n", WC->nonce); wprintf("
"); wprintf(_("Enter new password:")); diff --git a/webcit/calendar.c b/webcit/calendar.c index ddd6fa251..41395ef11 100644 --- a/webcit/calendar.c +++ b/webcit/calendar.c @@ -527,7 +527,7 @@ void display_edit_individual_task(icalcomponent *supplied_vtodo, long msgnum, ch wprintf("
\n"); wprintf("\n"); wprintf("
\n "); - wprintf("\n", WC->nonce); + wprintf("\n", WC->nonce); wprintf("\n", msgnum); wprintf("
"); diff --git a/webcit/calendar_view.c b/webcit/calendar_view.c index 6681389d9..479671317 100644 --- a/webcit/calendar_view.c +++ b/webcit/calendar_view.c @@ -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(""); wprintf("\n"); - wprintf("
\n"); + wprintf("
\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("" + wprintf("
%s %s
" " \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("
" " " "hash_prefs)); - + DeleteHash(&(sessions_to_kill->IconBarSetttings)); + pthread_mutex_unlock(&sessions_to_kill->SessionMutex); sptr = sessions_to_kill->next; free(sessions_to_kill); diff --git a/webcit/crypto.c b/webcit/crypto.c index 34aff8293..bfb84cb5d 100644 --- a/webcit/crypto.c +++ b/webcit/crypto.c @@ -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); diff --git a/webcit/downloads.c b/webcit/downloads.c index 50456bb1a..86c5108ab 100644 --- a/webcit/downloads.c +++ b/webcit/downloads.c @@ -279,7 +279,7 @@ void display_room_directory(void) "name=\"upload_file_form\"" ">\n" ); - wprintf("\n", WC->nonce); + wprintf("\n", WC->nonce); wprintf(_("Upload a file:")); wprintf("  \n"); diff --git a/webcit/event.c b/webcit/event.c index f2575508b..6a72c0b97 100644 --- a/webcit/event.c +++ b/webcit/event.c @@ -93,7 +93,7 @@ void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum, *************************************************************/ wprintf("\n"); - wprintf("\n", WC->nonce); + wprintf("\n", WC->nonce); wprintf("\n", msgnum); diff --git a/webcit/floors.c b/webcit/floors.c index f662ab408..e06dfaa8d 100644 --- a/webcit/floors.c +++ b/webcit/floors.c @@ -94,7 +94,7 @@ void display_floorconfig(char *prepend_html) "\n", floornum, floorname); - wprintf("\n", WC->nonce); + wprintf("\n", WC->nonce); wprintf("" "", _("Change name")); @@ -108,7 +108,7 @@ void display_floorconfig(char *prepend_html) "\n", floornum, floorname); - wprintf("\n", WC->nonce); + wprintf("\n", WC->nonce); wprintf("" "", _("Change CSS")); @@ -118,7 +118,7 @@ void display_floorconfig(char *prepend_html) wprintf("
" "\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("[%s] ", _("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("
\n", mime_content_type); + wprintf("
\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 = "" ; } - else if (!strcasecmp(sortby, "rsubject")) { + else if (!strcasecmp(ChrPtr(sortby), "rsubject")) { subjsort_button = "" ; } else { subjsort_button = "" ; } - if (!strcasecmp(sortby, "sender")) { + if (!strcasecmp(ChrPtr(sortby), "sender")) { sendsort_button = "" ; } - else if (!strcasecmp(sortby, "rsender")) { + else if (!strcasecmp(ChrPtr(sortby), "rsender")) { sendsort_button = "" ; } else { sendsort_button = "" ; } - if (!strcasecmp(sortby, "date")) { + if (!strcasecmp(ChrPtr(sortby), "date")) { datesort_button = "" ; } - else if (!strcasecmp(sortby, "rdate")) { + else if (!strcasecmp(ChrPtr(sortby), "rdate")) { datesort_button = "" ; } else { @@ -2653,7 +2657,7 @@ void readloop(char *oper) if (is_bbview) { /** begin bbview scroller */ wprintf(" \n

"); - wprintf(_("Reading #"), lowest_displayed, highest_displayed); + wprintf(_("Reading #"));//// TODO this isn't used, should it? : , lowest_displayed, highest_displayed); wprintf("\n", bstr("wikipage")); } wprintf("\n", bstr("return_to")); - wprintf("\n", WC->nonce); + wprintf("\n", WC->nonce); wprintf("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("
--
"); len = strlen(buf); for (i=0; i\n"); wprintf("\n"); - wprintf("\n", WC->nonce); + wprintf("\n", WC->nonce); wprintf("\n", bstr("msgid")); wprintf("\n", WC->nonce); + wprintf("\n", WC->nonce); wprintf("

%s %s
%s%s%s%s
 
"); - wprintf("\n", WC->nonce); + wprintf("\n", WC->nonce); wprintf("\n" "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; diff --git a/webcit/graphics.c b/webcit/graphics.c index a1d50b9e4..6949e09fd 100644 --- a/webcit/graphics.c +++ b/webcit/graphics.c @@ -30,7 +30,7 @@ void display_graphics_upload(char *description, char *filename, char *uplurl) wprintf("\n", uplurl); - wprintf("\n", WC->nonce); + wprintf("\n", WC->nonce); wprintf("\n"); diff --git a/webcit/html2html.c b/webcit/html2html.c index a695292fe..c65e674bc 100644 --- a/webcit/html2html.c +++ b/webcit/html2html.c @@ -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
%s:%s", errno, strerror(errno), __FILE__, __LINE__); + wprintf("Error %d: %s
%s:%d", errno, strerror(errno), __FILE__, __LINE__); goto BAIL; } diff --git a/webcit/iconbar.c b/webcit/iconbar.c index 0561d09ba..fe9699816 100644 --- a/webcit/iconbar.c +++ b/webcit/iconbar.c @@ -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; iIconBarSetttings, + 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("
\" \" " @@ -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( "
" " " @@ -106,7 +122,8 @@ void do_iconbar(void) { wprintf(_("switch to room list")); wprintf(""); - if (ib_summary) { +/** Summary page icon */ + if (IconbarIsEnabled("ib_summary", 1)) { wprintf("
  • ", _("Your summary page") @@ -121,7 +138,8 @@ void do_iconbar(void) { wprintf("
  • \n"); } - if (ib_inbox) { +/** Inbox icon */ + if (IconbarIsEnabled("ib_inbox", 1)) { wprintf("
  • " "
  • \n"); } - if (ib_calendar) { +/** Calendar icon */ + if (IconbarIsEnabled("ib_calendar", 1)) { wprintf("
  • " "
  • \n"); } - if (ib_contacts) { +/** Contacts icon */ + if (IconbarIsEnabled("ib_contacts", 1)) { wprintf("
  • " "
  • \n"); } - if (ib_notes) { +/** Notes icon */ + if (IconbarIsEnabled("ib_notes", 1)) { wprintf("
  • " "
  • \n"); } - if (ib_tasks) { +/** Tasks icon */ + if (IconbarIsEnabled("ib_tasks", 1)) { wprintf("
  • " "
  • \n"); } - if (ib_rooms) { +/** Rooms icon */ + if (IconbarIsEnabled("ib_rooms", 1)) { wprintf("
  • " "", _("List all of your accessible rooms") @@ -229,7 +252,8 @@ void do_iconbar(void) { wprintf("
  • \n"); } - if (ib_users) { +/** Users icon */ + if (IconbarIsEnabled("ib_users", 1)) { wprintf("
  • " "", @@ -245,13 +269,14 @@ void do_iconbar(void) { wprintf("\n"); - if (ib_users > 1) { + if (IconbarIsEnabled("ib_users", 0)) { wprintf("
      "); wprintf("
  • \n"); } } - if (ib_chat) { +/** Chat icon */ + if (IconbarIsEnabled("ib_chat", 1)) { wprintf("
  • " "
  • \n"); } - if (ib_advanced) { +/** Advanced Options icon */ + if (IconbarIsEnabled("ib_advanced", 1)) { wprintf("
  • " "\n"); - if (ib_users > 1) { + if (IconbarIsEnabled("ib_users", 0)) { wprintf( " \n" - ); + " \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 \" \" " @@ -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( "
    " " " @@ -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"); @@ -493,12 +464,13 @@ void display_customize_iconbar(void) { wprintf("
    "); wprintf("\n"); - wprintf("\n", WC->nonce); + wprintf("\n", WC->nonce); wprintf("\n"); wprintf("\n"); bar = 1 - bar; + val = IconbarIsEnabled("ib_logo", 0); wprintf("\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("\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("\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("\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("\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("\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("\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("\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("\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("\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("\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("\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("
    "); wprintf(_("Display icons as:")); wprintf(""); + ib_displayas = IconbarIsEnabled("ib_displayas",IB_PICTEXT); for (i=0; i<=2; ++i) { wprintf("
    " " %s    " " %s
    " @@ -526,13 +499,14 @@ void display_customize_iconbar(void) { "%s" "
    " " %s    " " %s
    " @@ -543,13 +517,14 @@ void display_customize_iconbar(void) { "%s" "
    " " %s    " " %s
    " @@ -560,13 +535,14 @@ void display_customize_iconbar(void) { "%s" "
    " " %s    " " %s
    " @@ -577,13 +553,14 @@ void display_customize_iconbar(void) { "%s" "
    " " %s    " " %s
    " @@ -594,13 +571,14 @@ void display_customize_iconbar(void) { "%s" "
    " " %s    " " %s
    " @@ -611,13 +589,14 @@ void display_customize_iconbar(void) { "%s" "
    " " %s    " " %s
    " @@ -628,13 +607,14 @@ void display_customize_iconbar(void) { "%s" "
    " " %s    " " %s
    " @@ -645,14 +625,15 @@ void display_customize_iconbar(void) { "%s" "
    " " %s    " " %s
    " @@ -664,15 +645,16 @@ void display_customize_iconbar(void) { "
    %s" "
    " " %s    " " %s
    " @@ -683,8 +665,8 @@ void display_customize_iconbar(void) { "%s" "
    " " %s    " " %s
    " @@ -702,14 +685,15 @@ void display_customize_iconbar(void) { "%s" "
    " " %s    " " %s
    " @@ -721,8 +705,8 @@ void display_customize_iconbar(void) { "%s" "
    \n"); wDumpContent(2); + printf("-----------icon-------------------\n"); + dbg_PrintHash(WC->IconBarSetttings, PrintInt, NULL); } diff --git a/webcit/inetconf.c b/webcit/inetconf.c index c61ee4166..b483dd1aa 100644 --- a/webcit/inetconf.c +++ b/webcit/inetconf.c @@ -134,7 +134,7 @@ void display_inetconf(void) } wprintf("\n"); - wprintf("\n", WC->nonce); + wprintf("\n", WC->nonce); wprintf("
  • " "" "", ic_keyword[which]); diff --git a/webcit/mainmenu.c b/webcit/mainmenu.c index dec9265d0..14b3cedc3 100644 --- a/webcit/mainmenu.c +++ b/webcit/mainmenu.c @@ -221,7 +221,7 @@ void display_generic(void) wprintf("
    \n"); wprintf("\n"); - wprintf("\n", WC->nonce); + wprintf("\n", WC->nonce); wprintf(_("Enter command:")); wprintf("

    \n"); diff --git a/webcit/messages.c b/webcit/messages.c index e0ab86082..6e3246a3e 100644 --- a/webcit/messages.c +++ b/webcit/messages.c @@ -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("
    "); wprintf(_("Photo:")); wprintf(""); - wprintf("\"Contact",msgnum); + wprintf("\"Contact",msgnum); wprintf("
    \n"); wprintf("", _("Node name")); wprintf("\n"); @@ -129,7 +129,7 @@ void display_edit_node(void) if (!strcasecmp(node, cnode)) { wprintf("\n"); - wprintf("\n", WC->nonce); + wprintf("\n", WC->nonce); wprintf("
    %s
    \n"); wprintf("
    "); wprintf(_("Node name")); diff --git a/webcit/notes.c b/webcit/notes.c index ccc530d2e..1945ae72a 100644 --- a/webcit/notes.c +++ b/webcit/notes.c @@ -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; } diff --git a/webcit/openid.c b/webcit/openid.c index ae037e851..cae9de053 100644 --- a/webcit/openid.c +++ b/webcit/openid.c @@ -43,7 +43,7 @@ void display_openids(void) wprintf("

    \n"); wprintf("\n"); - wprintf("\n", WC->nonce); + wprintf("\n", WC->nonce); wprintf(_("Add an OpenID: ")); wprintf("\n"); wprintf("" diff --git a/webcit/paging.c b/webcit/paging.c index dc3643603..93c402501 100644 --- a/webcit/paging.c +++ b/webcit/paging.c @@ -34,7 +34,7 @@ void display_page(void) wprintf("
    \n"); wprintf("\n"); - wprintf("\n", WC->nonce); + wprintf("\n", WC->nonce); wprintf("
    \n"); @@ -484,7 +484,7 @@ void chat_send(void) { WC->chat_sock = i; wprintf("\n"); - wprintf("\n", WC->nonce); + wprintf("\n", WC->nonce); wprintf("\n", SIZ-10); wprintf("
    "); diff --git a/webcit/preferences.c b/webcit/preferences.c index d1db3cbf8..2d803e9f7 100644 --- a/webcit/preferences.c +++ b/webcit/preferences.c @@ -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("
    \n"); @@ -188,7 +314,7 @@ void display_preferences(void) /** begin form */ wprintf("\n"); - wprintf("\n", WC->nonce); + wprintf("\n", WC->nonce); /** begin table */ wprintf("\n"); @@ -196,19 +322,19 @@ void display_preferences(void) /** * Room list view */ - get_preference("roomlistview", buf, sizeof buf); + get_preference("roomlistview", &Buf); wprintf(""); @@ -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("\n", node); wprintf("
    "); wprintf(_("Room list view")); wprintf(""); wprintf(""); wprintf(_("Tree (folders) view")); wprintf("   "); wprintf(""); wprintf(_("Table (rooms) view")); wprintf("\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("
    "); wprintf(_("Calendar day view begins at:")); wprintf(""); @@ -253,13 +379,13 @@ void display_preferences(void) if (time_format == WC_TIMEFORMAT_24) { wprintf("\n", - ((atoi(buf) == i) ? "selected" : ""), + ((DayStart == i) ? "selected" : ""), i, i ); } else { wprintf("\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("
    "); wprintf(_("Calendar day view ends at:")); wprintf(""); @@ -282,13 +408,13 @@ void display_preferences(void) if (time_format == WC_TIMEFORMAT_24) { wprintf("\n", - ((atoi(buf) == i) ? "selected" : ""), + ((DayEnd == i) ? "selected" : ""), i, i ); } else { wprintf("\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("
    "); wprintf(_("Week starts on:")); wprintf(""); @@ -315,7 +440,7 @@ void display_preferences(void) wc_strftime(daylabel, sizeof daylabel, "%A", &tm); wprintf("\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("
    "); wprintf(_("Attach signature to email messages?")); wprintf(""); @@ -345,21 +469,24 @@ void display_preferences(void) ); wprintf(""); wprintf(_("No signature")); wprintf(" ,  \n"); wprintf(""); wprintf(_("Use this signature:")); wprintf("
    " "
    " "
    " ); @@ -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("
    "); wprintf(_("Default character set for email headers:")); wprintf(""); wprintf(""); wprintf("
    "); wprintf(_("Show empty floors")); wprintf(""); wprintf(""); wprintf(_("Yes")); wprintf("   "); wprintf(""); wprintf(_("No")); wprintf("\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(); diff --git a/webcit/roomops.c b/webcit/roomops.c index 6fb8bafb4..4ade41486 100644 --- a/webcit/roomops.c +++ b/webcit/roomops.c @@ -380,7 +380,7 @@ void embed_view_o_matic(void) { int i; wprintf("\n"); - wprintf("\t
    \n\t\n", WC->nonce); + wprintf("\t
    \n\t\n", WC->nonce); wprintf(" " @@ -419,7 +419,7 @@ void embed_view_o_matic(void) { */ void embed_search_o_matic(void) { wprintf("\n"); - wprintf("
    \n", WC->nonce); + wprintf("
    \n", WC->nonce); wprintf("\n"); - wprintf("\n", WC->nonce); + wprintf("\n", WC->nonce); wprintf("
    • "); 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(""); - wprintf("\n", WC->nonce); + wprintf("\n", WC->nonce); wprintf("
    %s"); @@ -1618,7 +1618,7 @@ void display_editroom(void) extract_token(node, not_shared_with, i, '\n', sizeof node); if (!IsEmptyStr(node)) { wprintf(""); - wprintf("\n", WC->nonce); + wprintf("\n", WC->nonce); wprintf("
    "); escputs(node); wprintf("" @@ -1692,7 +1692,7 @@ void display_editroom(void) wprintf("
    \n" "\n" "\n"); - wprintf("\n", WC->nonce); + wprintf("\n", WC->nonce); wprintf("\n"); wprintf("", _("Add")); wprintf("\n"); @@ -1723,7 +1723,7 @@ void display_editroom(void) wprintf("
    \n" "\n" "\n"); - wprintf("\n", WC->nonce); + wprintf("\n", WC->nonce); wprintf("\n"); wprintf("", _("Add")); wprintf("
    \n"); @@ -1807,7 +1807,7 @@ void display_editroom(void) } wprintf("
    \n"); - wprintf("\n", WC->nonce); + wprintf("\n", WC->nonce); wprintf("\n"); wprintf("" "" "\n"); - wprintf("\n", WC->nonce); + wprintf("\n", WC->nonce); wprintf(""); @@ -2017,7 +2017,7 @@ void display_editroom(void) "" "" "\n"); - wprintf("\n", WC->nonce); + wprintf("\n", WC->nonce); wprintf("
    "); wprintf(_("Message expire policy for this room")); @@ -1950,7 +1950,7 @@ void display_editroom(void) "
    "); wprintf("\n"); wprintf("
    "); wprintf("\n"); @@ -2335,7 +2335,7 @@ void display_whok(void) wprintf("

    "); wprintf("
    \n"); - wprintf("\n", WC->nonce); + wprintf("\n", WC->nonce); wprintf("\n"); wprintf("\n"); - wprintf("\n", WC->nonce); + wprintf("\n", WC->nonce); wprintf(_("Invite:")); wprintf(" "); wprintf("
    \n" @@ -2408,7 +2408,7 @@ void display_entroom(void) do_template("beginbox"); wprintf("\n"); - wprintf("\n", WC->nonce); + wprintf("\n", WC->nonce); wprintf(" "); @@ -2643,7 +2643,7 @@ void display_private(char *rname, int req_pass) wprintf("

    "); wprintf("\n"); - wprintf("\n", WC->nonce); + wprintf("\n", WC->nonce); wprintf("
    " "", _("Change Login Logo")); sprintf(&general[strlen(general)], "\n", _("Change Logout Logo")); diff --git a/webcit/subst.c b/webcit/subst.c index aa255b9a3..85d5dcc65 100644 --- a/webcit/subst.c +++ b/webcit/subst.c @@ -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
    \n", - templatename, strerror(errno)); + (const char*)templatename, strerror(errno)); return; } diff --git a/webcit/sysmsgs.c b/webcit/sysmsgs.c index e336f0f77..00abb6cc5 100644 --- a/webcit/sysmsgs.c +++ b/webcit/sysmsgs.c @@ -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("\n", save_cmd); - wprintf("\n", WC->nonce); + wprintf("\n", WC->nonce); wprintf("
    "); @@ -2729,7 +2729,7 @@ void display_zap(void) "to do?
    \n"), WC->wc_roomname); wprintf("\n"); - wprintf("\n", WC->nonce); + wprintf("\n", WC->nonce); wprintf("", _("Zap this room")); wprintf(" "); wprintf("", _("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
    \n", floordiv_id, floordivtitle); wprintf("
    ", 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\n"); wprintf("
    "); wprintf("

    "); - 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("

    \n"); @@ -3585,13 +3587,13 @@ void knrooms(void) wprintf("\n", - ( !strcasecmp(listviewpref, "rooms") ? "SELECTED" : "" ) + ( !strcasecmp(ChrPtr(ListView), "rooms") ? "SELECTED" : "" ) ); wprintf("\n", - ( !strcasecmp(listviewpref, "folders") ? "SELECTED" : "" ) + ( !strcasecmp(ChrPtr(ListView), "folders") ? "SELECTED" : "" ) ); wprintf(""); @@ -3601,7 +3603,7 @@ void knrooms(void) wprintf("
    \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); } diff --git a/webcit/rss.c b/webcit/rss.c index 4a664f28d..73297a549 100644 --- a/webcit/rss.c +++ b/webcit/rss.c @@ -29,13 +29,13 @@ void display_rss_control(char *reply_to, char *subject) wprintf("[%s] \n", _("Reply")); wprintf("[%s]\n", _("Email")); wprintf("

    \n"); diff --git a/webcit/setup_wizard.c b/webcit/setup_wizard.c index a6beb9a0c..d2d177a2b 100644 --- a/webcit/setup_wizard.c +++ b/webcit/setup_wizard.c @@ -38,7 +38,7 @@ void do_setup_wizard(void) wprintf("
    " "\n" ); - wprintf("\n", WC->nonce); + wprintf("\n", WC->nonce); wprintf("
    " "This is where the setup wizard will be placed.
    \n" diff --git a/webcit/sieve.c b/webcit/sieve.c index a566c7941..cf68af89a 100644 --- a/webcit/sieve.c +++ b/webcit/sieve.c @@ -116,7 +116,7 @@ void display_sieve(void) wprintf("\n"); - wprintf("\n", WC->nonce); + wprintf("\n", WC->nonce); wprintf(_("When new mail arrives: ")); wprintf("\n", WC->nonce); + wprintf("\n", WC->nonce); wprintf(_("Script name: ")); wprintf("
    \n" "" @@ -682,7 +682,7 @@ void display_add_remove_scripts(char *message) wprintf("
    " "\n"); - wprintf("\n", WC->nonce); + wprintf("\n", WC->nonce); wprintf("\n", WC->nonce); + wprintf("\n", WC->nonce); sprintf(&general[strlen(general)], "
    %s %s