From 77ad06c3f4bf4d2a4e3a7ff82ec94fcdff343273 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Wilfried=20G=C3=B6esgens?= Date: Fri, 26 Dec 2008 15:42:49 +0000 Subject: [PATCH] * --pedantic cleanup. * move several files headers out of webcit.h into their own ones. its getting to crowded over there. --- webcit/auth.c | 3 +- webcit/availability.c | 4 +- webcit/calendar.c | 14 +- webcit/calendar_tools.c | 2 +- webcit/calendar_view.c | 10 +- webcit/context_loop.c | 57 ++----- webcit/decode.c | 2 +- webcit/downloads.c | 15 +- webcit/event.c | 14 +- webcit/fmt_date.c | 2 +- webcit/gettext.c | 40 +---- webcit/graphics.c | 2 +- webcit/groupdav_get.c | 2 +- webcit/groupdav_put.c | 4 +- webcit/html2html.c | 4 +- webcit/iconbar.c | 10 +- webcit/mainmenu.c | 2 +- webcit/messages.c | 33 ++-- webcit/messages.h | 91 +++++++++++ webcit/msg_renderers.c | 17 +- webcit/netconf.c | 260 +------------------------------ webcit/paramhandling.h | 41 +++++ webcit/preferences.c | 277 --------------------------------- webcit/preferences.h | 24 +++ webcit/roomops.c | 10 +- webcit/rss.c | 12 +- webcit/serv_func.c | 7 +- webcit/smtpqueue.c | 2 +- webcit/subst.c | 32 ++-- webcit/subst.h | 165 ++++++++++++++++++++ webcit/useredit.c | 2 +- webcit/utils.c | 4 +- webcit/wc_gettext.h | 11 ++ webcit/webcit.c | 6 +- webcit/webcit.h | 334 +--------------------------------------- webcit/webserver.c | 70 ++------- webcit/who.c | 1 - 37 files changed, 478 insertions(+), 1108 deletions(-) create mode 100644 webcit/messages.h create mode 100644 webcit/paramhandling.h create mode 100644 webcit/preferences.h create mode 100644 webcit/subst.h create mode 100644 webcit/wc_gettext.h diff --git a/webcit/auth.c b/webcit/auth.c index 3ae236e4c..77c2d457f 100644 --- a/webcit/auth.c +++ b/webcit/auth.c @@ -261,12 +261,13 @@ void do_login(void) */ void openid_manual_create(void) { + char buf[1024]; + if (havebstr("exit_action")) { do_logout(); return; } - char buf[1024]; if (havebstr("newuser_action")) { serv_printf("OIDC %s", bstr("name")); serv_getln(buf, sizeof buf); diff --git a/webcit/availability.c b/webcit/availability.c index 156137b1b..f8772780b 100644 --- a/webcit/availability.c +++ b/webcit/availability.c @@ -90,11 +90,11 @@ int ical_ctdl_is_overlap( /* If event 1 ends before event 2 starts, we're in the clear. */ if (icaltime_compare(t1end, t2start) <= 0) return(0); - // lprintf(9, "first passed\n"); + /* lprintf(9, "first passed\n"); */ /* If event 2 ends before event 1 starts, we're also ok. */ if (icaltime_compare(t2end, t1start) <= 0) return(0); - // lprintf(9, "second passed\n"); + /* lprintf(9, "second passed\n"); */ /* Otherwise, they overlap. */ return(1); diff --git a/webcit/calendar.c b/webcit/calendar.c index b583d133a..a80e62c16 100644 --- a/webcit/calendar.c +++ b/webcit/calendar.c @@ -56,8 +56,8 @@ void cal_process_object(StrBuf *Target, /* See what we need to do with this */ if (method != NULL) { - the_method = icalproperty_get_method(method); char *title; + the_method = icalproperty_get_method(method); StrBufAppendPrintf(Target, "
", divname); StrBufAppendPrintf(Target, ""); @@ -415,6 +415,7 @@ void display_individual_cal(icalcomponent *cal, long msgnum, char *from, int unr icalrecur_iterator *ritr = NULL; struct icaltimetype next; int num_recur = 0; + int stop_rr = 0; dtstart = icaltime_null_time(); dtend = icaltime_null_time(); @@ -499,10 +500,10 @@ void display_individual_cal(icalcomponent *cal, long msgnum, char *from, int unr ritr = icalrecur_iterator_new(recur, dtstart); if (!ritr) return; - int stop_rr = 0; while (next = icalrecur_iterator_next(ritr), ((!icaltime_is_null_time(next))&&(!stop_rr)) ) { ++num_recur; if (num_recur > 1) { /* Skip the first one. We already did it at the root. */ + icalcomponent *cptr; /* lprintf(9, "REPEATS: %s\n", icaltime_as_ical_string(next)); */ /* Note: anything we do here, we also have to do above for the root event. */ @@ -515,7 +516,6 @@ void display_individual_cal(icalcomponent *cal, long msgnum, char *from, int unr memcpy(Cal->from, from, len + 1); Cal->cal_msgnum = msgnum; - icalcomponent *cptr; if (icalcomponent_isa(Cal->cal) == ICAL_VEVENT_COMPONENT) { cptr = Cal->cal; } @@ -622,11 +622,11 @@ void display_edit_individual_task(icalcomponent *supplied_vtodo, long msgnum, ch created_new_vtodo = 1; } - // TODO: Can we take all this and move it into a template? + /*/ TODO: Can we take all this and move it into a template? */ output_headers(1, 1, 1, 0, 0, 0); wprintf(""); p = icalcomponent_get_first_property(vtodo, ICAL_SUMMARY_PROPERTY); - // Get summary early for title + /* Get summary early for title */ wprintf("
\n"); wprintf("
"); wprintf(_("Edit task")); @@ -710,7 +710,7 @@ void display_edit_individual_task(icalcomponent *supplied_vtodo, long msgnum, ch } wprintf(" >"); wprintf(""); - // start category field + /* start category field */ p = icalcomponent_get_first_property(vtodo, ICAL_CATEGORIES_PROPERTY); wprintf(""); wprintf(_("Category:")); @@ -721,7 +721,7 @@ void display_edit_individual_task(icalcomponent *supplied_vtodo, long msgnum, ch } wprintf("\">"); wprintf("\n "); - // end category field + /* end category field */ wprintf(""); wprintf(_("Description:")); wprintf(""); diff --git a/webcit/calendar_tools.c b/webcit/calendar_tools.c index 15f89ee35..b2d9fb090 100644 --- a/webcit/calendar_tools.c +++ b/webcit/calendar_tools.c @@ -264,7 +264,7 @@ icalcomponent *ical_encapsulate_subcomponent(icalcomponent *subcomp) { || (icalproperty_isa(p) == ICAL_MINDATE_PROPERTY) || (icalproperty_isa(p) == ICAL_RECURRENCEID_PROPERTY) ) { - t = icalproperty_get_dtstart(p); // it's safe to use dtstart for all of them + t = icalproperty_get_dtstart(p); /*/ it's safe to use dtstart for all of them */ if ((icaltime_is_valid_time(t)) && (z=icaltime_get_timezone(t), z)) { zone_already_attached = 0; diff --git a/webcit/calendar_view.c b/webcit/calendar_view.c index db5c45346..7b6518aec 100644 --- a/webcit/calendar_view.c +++ b/webcit/calendar_view.c @@ -1318,6 +1318,7 @@ void parse_calendar_view_request(struct calview *c) { time_t now; struct tm tm; char calview[32]; + int span = 3888000; /* In case no date was specified, go with today */ now = time(NULL); @@ -1364,7 +1365,6 @@ void parse_calendar_view_request(struct calview *c) { tm.tm_mday = c->day; now = mktime(&tm); - int span = 3888000; if (c->view == calview_month) span = 3888000; if (c->view == calview_brief) span = 3888000; if (c->view == calview_week) span = 604800; @@ -1456,10 +1456,10 @@ int task_due_cmp(const void *vtask1, const void *vtask2) { */ int task_completed_cmp(const void *vtask1, const void *vtask2) { disp_cal * Task1 = (disp_cal *)GetSearchPayload(vtask1); -// disp_cal * Task2 = (disp_cal *)GetSearchPayload(vtask2); +/* disp_cal * Task2 = (disp_cal *)GetSearchPayload(vtask2); */ icalproperty_status t1 = icalcomponent_get_status((Task1)->cal); - // icalproperty_status t2 = icalcomponent_get_status(((struct disp_cal *)task2)->cal); + /* icalproperty_status t2 = icalcomponent_get_status(((struct disp_cal *)task2)->cal); */ if (t1 == ICAL_STATUS_COMPLETED) return 1; @@ -1513,9 +1513,11 @@ void do_tasks_view(void) { Pos = GetNewHashPos(WCC->disp_cal_items, 0); while (GetNextHashPos(WCC->disp_cal_items, Pos, &hklen, &HashKey, &vCal)) { + icalproperty_status todoStatus; + Cal = (disp_cal*)vCal; wprintf(""); - icalproperty_status todoStatus = icalcomponent_get_status(Cal->cal); + todoStatus = icalcomponent_get_status(Cal->cal); wprintf("serv_sock); close((*sessions_to_kill)->chat_sock); +/* // if ((*sessions_to_kill)->preferences != NULL) { // free((*sessions_to_kill)->preferences); // } +*/ if ((*sessions_to_kill)->cache_fold != NULL) { free((*sessions_to_kill)->cache_fold); } @@ -154,45 +156,6 @@ int GenerateSessionID(void) return ++seq; } - -/* - * Collapse multiple cookies on one line - */ -////int req_gets(int *sock, char *buf, char *hold, size_t hlen) -////{ -//// int a, b; -//// -//// if (IsEmptyStr(hold)) { -//// strcpy(buf, ""); -//// a = client_getln(sock, buf, SIZ); -//// if (a<1) return(-1); -//// } else { -//// safestrncpy(buf, hold, SIZ); -//// } -//// strcpy(hold, ""); -//// -//// if (!strncasecmp(buf, "Cookie: ", 8)) { -//// int len; -//// len = strlen(buf); -//// for (a = 0; a < len; ++a) -//// if (buf[a] == ';') { -//// // we don't refresh len, because of we -//// // only exit from here. -//// snprintf(hold, hlen, "Cookie: %s", &buf[a + 1]); -//// buf[a] = 0; -//// b = 8; -//// while (isspace(hold[b])) -//// b++; -//// -//// memmove(&hold[8], &hold[b], len - b + 1); -//// return(0); -//// } -//// } -//// -//// return(0); -////} - - /* * Collapse multiple cookies on one line */ @@ -251,12 +214,7 @@ int lingering_close(int fd) int is_bogus(StrBuf *http_cmd) { const char *url; int i, max; - - url = ChrPtr(http_cmd); - if (IsEmptyStr(url)) return(1); - ++url; - - char *bogus_prefixes[] = { + const char *bogus_prefixes[] = { "/scripts/root.exe", /**< Worms and trojans and viruses, oh my! */ "/c/winnt", "/MSADC/", @@ -264,6 +222,11 @@ int is_bogus(StrBuf *http_cmd) { "/MSOffice" /**< Stoopid MSOffice thinks everyone is IIS */ }; + url = ChrPtr(http_cmd); + if (IsEmptyStr(url)) return(1); + ++url; + + max = sizeof(bogus_prefixes) / sizeof(char *); for (i=0; i 0); FreeStrBuf(&HeaderName); -//// dbg_PrintHash(HTTPHeaders, nix, NULL); +/*/// dbg_PrintHash(HTTPHeaders, nix, NULL); */ /** diff --git a/webcit/decode.c b/webcit/decode.c index cf64886ee..267e85982 100644 --- a/webcit/decode.c +++ b/webcit/decode.c @@ -75,7 +75,7 @@ void utf8ify_rfc822_string(char *buf) { for (i=0; i 126)) { illegal_non_rfc2047_encoding = 1; - i = len; ///< take a shortcut, it won't be more than one. + i = len; /*< take a shortcut, it won't be more than one. */ } } if (illegal_non_rfc2047_encoding) { diff --git a/webcit/downloads.c b/webcit/downloads.c index 8ec113738..4706d0042 100644 --- a/webcit/downloads.c +++ b/webcit/downloads.c @@ -204,11 +204,12 @@ void display_room_directory(void) "static/up_pointer.gif", "static/down_pointer.gif", "static/sort_none.gif"}; - char *RowNames[5] = {"", - _("Filename"), - _("Size"), - _("Content"), - _("Description")}; + char *RowNames[5]; + RowNames[0] = ""; + RowNames[1] = _("Filename"); + RowNames[2] = _("Size"); + RowNames[3] = _("Content"); + RowNames[4] = _("Description"); Files = LoadFileList (&havepics); output_headers(1, 1, 2, 0, 0, 0); @@ -447,7 +448,7 @@ void upload_file(void) { blocksize = (WCC->upload_length - bytes_transmitted); } - serv_printf("WRIT %d", blocksize); + serv_printf("WRIT %ld", blocksize); serv_getln(buf, sizeof buf); if (buf[0] == '7') { @@ -471,6 +472,7 @@ void upload_file(void) */ void output_image() { + char blank_gif[SIZ]; wcsession *WCC = WC; char buf[SIZ]; off_t bytes; @@ -503,7 +505,6 @@ void output_image() * Instead of an ugly 404, send a 1x1 transparent GIF * when there's no such image on the server. */ - char blank_gif[SIZ]; snprintf (blank_gif, SIZ, "%s%s", static_dirs[0], "/blank.gif"); output_static(blank_gif); } diff --git a/webcit/event.c b/webcit/event.c index 0258c2ffc..9b05425bb 100644 --- a/webcit/event.c +++ b/webcit/event.c @@ -33,6 +33,13 @@ void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum, char weekday_labels[7][32]; char month_labels[12][32]; long weekstart = 0; + icalproperty *rrule = NULL; + struct icalrecurrencetype recur; + + char *tabnames[3]; + tabnames[0] = _("Event"); + tabnames[1] = _("Attendees"); + tabnames[2] = _("Recurrence"); get_pref_long("weekstart", &weekstart, 17); if (weekstart > 6) weekstart = 0; @@ -140,11 +147,6 @@ void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum, wprintf("\n", bstr("day")); - char *tabnames[] = { - _("Event"), - _("Attendees"), - _("Recurrence") - }; tabbed_dialog(3, tabnames); begin_tab(0, 3); @@ -414,8 +416,6 @@ void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum, /* Recurrence tab */ begin_tab(2, 3); - icalproperty *rrule = NULL; - struct icalrecurrencetype recur; rrule = icalcomponent_get_first_property(vevent, ICAL_RRULE_PROPERTY); if (rrule) { diff --git a/webcit/fmt_date.c b/webcit/fmt_date.c index 779d458f4..5c625d667 100644 --- a/webcit/fmt_date.c +++ b/webcit/fmt_date.c @@ -31,7 +31,7 @@ size_t wc_strftime(char *s, size_t max, const char *format, const struct tm *tm) if (wc_locales[WC->selected_language] == NULL) { return strftime(s, max, format, tm); } - else { // TODO: this gives empty strings on debian. + else { /* TODO: this gives empty strings on debian. */ return strftime_l(s, max, format, tm, wc_locales[WC->selected_language]); } #else diff --git a/webcit/gettext.c b/webcit/gettext.c index fc2cc6000..241fb9eed 100644 --- a/webcit/gettext.c +++ b/webcit/gettext.c @@ -162,44 +162,6 @@ void httplang_to_locale(StrBuf *LocaleString) FreeStrBuf(&SBuf); } -/* TODO: we skip the language weighting so far. */ -/* Accept-Language: 'de-de,en-us;q=0.7,en;q=0.3' */ -/* Accept-Language: de,en-ph;q=0.8,en-us;q=0.5,de-at;q=0.3 */ -//void httplang_to_locale(char *LocaleString) -//{ -// char selected_locale[16]; -// int i, j; -// char lang[64]; -// int num_accept = 0; -// -// lprintf(9, "languageAccept: %s\n", LocaleString); -// -// strcpy(selected_locale, "C"); -// num_accept = num_tokens(LocaleString, ','); -// -// for (i=num_accept-1; i>=0; --i) { -// extract_token(lang, LocaleString, i, ',', sizeof lang); -// -// /* Strip out the weights; we don't use them. Also convert -// * hyphens to underscores. -// */ -// for (j=0; jcurrent_iconbar = current_iconbar_menu; if (WCC->IconBarSetttings == NULL) WCC->IconBarSetttings = NewHash(1, NULL); @@ -380,6 +382,7 @@ void do_iconbar(void) { * we generate its innerHTML... */ void do_iconbar_roomlist(void) { + int ib_displayas; WC->current_iconbar = current_iconbar_roomlist; @@ -389,7 +392,6 @@ void do_iconbar_roomlist(void) { * their iconbars. These should probably be set in a master * configuration somewhere. */ - int ib_displayas; LoadIconSettings(); diff --git a/webcit/mainmenu.c b/webcit/mainmenu.c index aa2e07396..60de06cb5 100644 --- a/webcit/mainmenu.c +++ b/webcit/mainmenu.c @@ -390,7 +390,7 @@ void display_shutdown(void) else { serv_printf("SEXP broadcast|%s", message); - serv_getln(buf, sizeof buf); // should we care? + serv_getln(buf, sizeof buf); /* TODO: should we care? */ begin_burst(); output_headers(1, 0, 0, 0, 1, 0); DoTemplate(HKEY("display_serverrestartpagedo"), NULL, NULL, 0); diff --git a/webcit/messages.c b/webcit/messages.c index fadb68d70..141a63a74 100644 --- a/webcit/messages.c +++ b/webcit/messages.c @@ -34,6 +34,9 @@ int summcmp_rdate(const void *s1, const void *s2); typedef void (*MsgPartEvaluatorFunc)(message_summary *Sum, StrBuf *Buf); +typedef struct _MsgPartEvaluatorStruct { + MsgPartEvaluatorFunc f; +}MsgPartEvaluatorStruct; /*----------------------------------------------------------------------------*/ @@ -154,7 +157,7 @@ int read_message(StrBuf *Target, const char *tmpl, long tmpllen, long msgnum, in if (Msg->MsgBody->size_known > 0) { StrBuf_ServGetBLOB(Msg->MsgBody->Data, Msg->MsgBody->length); state ++; - /// todo: check next line, if not 000, append following lines + /*/ todo: check next line, if not 000, append following lines */ } else if (1){ if (StrLength(Msg->MsgBody->Data) > 0) @@ -179,9 +182,9 @@ int read_message(StrBuf *Target, const char *tmpl, long tmpllen, long msgnum, in /* look up the renderer, that will convert this mimeitem into the htmlized form */ if (GetHash(MimeRenderHandler, SKEY(Buf), &vHdr) && (vHdr != NULL)) { - RenderMimeFunc Render; - Render = (RenderMimeFunc)vHdr; - Render(Msg->MsgBody, NULL, FoundCharset); + RenderMimeFuncStruct *Render; + Render = (RenderMimeFuncStruct*)vHdr; + Render->f(Msg->MsgBody, NULL, FoundCharset); } if (StrLength(Msg->reply_references)> 0) { @@ -336,7 +339,7 @@ void display_headers(void) { message_summary *ReadOneMessageSummary(StrBuf *RawMessage, const char *DefaultSubject, long MsgNum) { void *vEval; - MsgPartEvaluatorFunc Eval; + MsgPartEvaluatorStruct *Eval; message_summary *Msg; StrBuf *Buf; const char *buf; @@ -363,9 +366,9 @@ message_summary *ReadOneMessageSummary(StrBuf *RawMessage, const char *DefaultSu ebuf = strchr(ChrPtr(Buf), '='); nBuf = ebuf - buf; if (GetHash(MsgEvaluators, buf, nBuf, &vEval) && vEval != NULL) { - Eval = (MsgPartEvaluatorFunc) vEval; + Eval = (MsgPartEvaluatorStruct*) vEval; StrBufCutLeft(Buf, nBuf + 1); - Eval(Msg, Buf); + Eval->f(Msg, Buf); } else lprintf(1, "Don't know how to handle Message Headerline [%s]", ChrPtr(Buf)); } @@ -408,7 +411,6 @@ int load_msg_ptrs(char *servcmd, int with_headers) FreeStrBuf(&Buf); return (nummsgs); } -// TODO if (with_headers) { //// TODO: Have Attachments? Buf2 = NewStrBuf(); while (len = StrBuf_ServGetln(Buf), ((len != 3) || @@ -581,11 +583,12 @@ void load_seen_flags(void) message_summary *Msg; const char *HashKey; long HKLen; - StrBuf *OldMsg = NewStrBuf();; - wcsession *WCC = WC; HashPos *at; void *vMsg; + StrBuf *OldMsg; + wcsession *WCC = WC; + OldMsg = NewStrBuf(); serv_puts("GTSN"); StrBuf_ServGetln(OldMsg); if (ChrPtr(OldMsg)[0] == '2') { @@ -1100,7 +1103,7 @@ void post_message(void) const StrBuf *Bcc = NULL; const StrBuf *Wikipage = NULL; const StrBuf *my_email_addr = NULL; - StrBuf *CmdBuf = NULL;; + StrBuf *CmdBuf = NULL; StrBuf *references = NULL; if (havebstr("references")) @@ -1283,7 +1286,7 @@ void display_enter(void) const StrBuf *Cc = NULL; const StrBuf *Bcc = NULL; const StrBuf *Wikipage = NULL; - StrBuf *CmdBuf = NULL;; + StrBuf *CmdBuf = NULL; const char CMD[] = "ENT0 0|%s|%d|0||%s||%s|%s|%s"; Recp = sbstr("recp"); @@ -1319,7 +1322,7 @@ void display_enter(void) } } else if (buf[0] != '2') { /** Any other error means that we cannot continue */ - wprintf("%s
\n", &buf[4]);/// -> important message + wprintf("%s
\n", &buf[4]);/*TODO -> important message */ return; } } @@ -1550,7 +1553,7 @@ void MimeLoadData(wc_mime_attachment *Mime) { char buf[SIZ]; off_t bytes; -//// TODO: is there a chance the contenttype is different to the one we know? +/* TODO: is there a chance the contenttype is different to the one we know? */ serv_printf("DLAT %ld|%s", Mime->msgnum, ChrPtr(Mime->PartNum)); serv_getln(buf, sizeof buf); if (buf[0] == '6') { @@ -1563,7 +1566,7 @@ void MimeLoadData(wc_mime_attachment *Mime) } else { FlushStrBuf(Mime->Data); - /// TODO XImportant message + /* TODO XImportant message */ } } diff --git a/webcit/messages.h b/webcit/messages.h new file mode 100644 index 000000000..904e6b9d1 --- /dev/null +++ b/webcit/messages.h @@ -0,0 +1,91 @@ + +extern HashList *MsgHeaderHandler; +extern HashList *MimeRenderHandler; + +typedef struct wc_mime_attachment wc_mime_attachment; +typedef void (*RenderMimeFunc)(wc_mime_attachment *Mime, StrBuf *RawData, StrBuf *FoundCharset); +typedef struct _RenderMimeFuncStruct { + RenderMimeFunc f; +} RenderMimeFuncStruct; + +struct wc_mime_attachment { + int level; + StrBuf *Name; + StrBuf *FileName; + StrBuf *PartNum; + StrBuf *Disposition; + StrBuf *ContentType; + StrBuf *Charset; + StrBuf *Data; + size_t length; /* length of the mimeatachment */ + long size_known; + long lvalue; /* if we put a long... */ + long msgnum; /**< the message number on the citadel server derived from message_summary */ + const RenderMimeFuncStruct *Renderer; +}; +void DestroyMime(void *vMime); + + +/* + * \brief message summary structure. ??? + */ +typedef struct _message_summary { + time_t date; /**< its creation date */ + long msgnum; /**< the message number on the citadel server */ + int nhdr; + int format_type; + StrBuf *from; /**< the author */ + StrBuf *to; /**< the recipient */ + StrBuf *subj; /**< the title / subject */ + StrBuf *reply_inreplyto; + StrBuf *reply_references; + StrBuf *reply_to; + StrBuf *cccc; + StrBuf *hnod; + StrBuf *AllRcpt; + StrBuf *Room; + StrBuf *Rfca; + StrBuf *OtherNode; + const StrBuf *PartNum; + + HashList *Attachments; /**< list of Accachments */ + HashList *Submessages; + HashList *AttachLinks; + + HashList *AllAttach; + + int is_new; /**< is it yet read? */ + int hasattachments; /* does it have atachments? */ + + + /** The mime part of the message */ + wc_mime_attachment *MsgBody; +} message_summary; +void DestroyMessageSummary(void *vMsg); +inline message_summary* GetMessagePtrAt(int n, HashList *Summ); + +typedef void (*ExamineMsgHeaderFunc)(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset); + +void evaluate_mime_part(message_summary *Msg, wc_mime_attachment *Mime); + +enum { + do_search, + headers, + readfwd, + readnew, + readold +}; + +typedef void (*readloop_servcmd)(char *buf, long bufsize); + +typedef struct _readloopstruct { + ConstStr name; + readloop_servcmd cmd; +} readloop_struct; + + +void readloop(long oper); +int read_message(StrBuf *Target, const char *tmpl, long tmpllen, long msgnum, int printable_view, const StrBuf *section); + + +int load_msg_ptrs(char *servcmd, int with_headers); diff --git a/webcit/msg_renderers.c b/webcit/msg_renderers.c index 90202273e..abf6b55e4 100644 --- a/webcit/msg_renderers.c +++ b/webcit/msg_renderers.c @@ -63,7 +63,11 @@ void RegisterMsgHdr(const char *HeaderName, long HdrNLen, ExamineMsgHeaderFunc e void RegisterMimeRenderer(const char *HeaderName, long HdrNLen, RenderMimeFunc MimeRenderer) { - Put(MimeRenderHandler, HeaderName, HdrNLen, MimeRenderer, reference_free_handler); + RenderMimeFuncStruct *f; + + f = (RenderMimeFuncStruct*) malloc(sizeof(RenderMimeFuncStruct)); + f->f = MimeRenderer; + Put(MimeRenderHandler, HeaderName, HdrNLen, f, NULL); } @@ -182,7 +186,7 @@ void examine_suff(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset) { void examine_path(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset) {return;} void examine_content_encoding(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset) { -////TODO: do we care? +/* TODO: do we care? */ } void examine_nhdr(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset) @@ -225,7 +229,8 @@ void examine_subj(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset) StrBuf_RFC822_to_Utf8(Msg->subj, HdrLine, WC->DefaultCharset, FoundCharset); } void tmplput_MAIL_SUMM_SUBJECT(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType) -{/////TODO: Fwd: and RE: filter!! +{/*////TODO: Fwd: and RE: filter!!*/ + message_summary *Msg = (message_summary*) Context; StrBufAppendTemplate(Target, nArgs, Tokens, Context, ContextType, Msg->subj, 0); } @@ -498,7 +503,7 @@ void evaluate_mime_part(message_summary *Msg, wc_mime_attachment *Mime) GetHash(MimeRenderHandler, SKEY(Mime->ContentType), &vMimeRenderer) && vMimeRenderer != NULL) { - Mime->Renderer = (RenderMimeFunc) vMimeRenderer; + Mime->Renderer = (RenderMimeFuncStruct*) vMimeRenderer; if (Msg->Submessages == NULL) Msg->Submessages = NewHash(1,NULL); Put(Msg->Submessages, SKEY(Mime->PartNum), Mime, reference_free_handler); @@ -902,9 +907,9 @@ void tmplput_MIME_Data(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void { wc_mime_attachment *mime = (wc_mime_attachment*) Context; if (mime->Renderer != NULL) - mime->Renderer(mime, NULL, NULL); + mime->Renderer->f(mime, NULL, NULL); StrBufAppendTemplate(Target, nArgs, Tokens, Context, ContextType, mime->Data, 0); - /// TODO: check whether we need to load it now? + /* TODO: check whether we need to load it now? */ } void tmplput_MIME_LoadData(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType) diff --git a/webcit/netconf.c b/webcit/netconf.c index bd48e7631..d95c6ea5e 100644 --- a/webcit/netconf.c +++ b/webcit/netconf.c @@ -168,12 +168,7 @@ void edit_node(void) { HashList *NodeConfig; const StrBuf *Index; NodeConf *NewNode; -/* - char buf[SIZ]; - char node[SIZ]; - char cnode[SIZ]; - FILE *fp; -*/ + if (havebstr("ok_button")) { Index = sbstr("index"); NewNode = HttpGetNewNode(); @@ -187,85 +182,11 @@ void edit_node(void) { Put(NodeConfig, ChrPtr(Index), StrLength(Index), NewNode, DeleteNodeConf); save_net_conf(NodeConfig); DeleteHash(&NodeConfig); -/* - strcpy(node, bstr("node") ); - fp = tmpfile(); - if (fp != NULL) { - serv_puts("CONF getsys|application/x-citadel-ignet-config"); - serv_getln(buf, sizeof buf); - if (buf[0] == '1') { - while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) { - extract_token(cnode, buf, 0, '|', sizeof cnode); - if (strcasecmp(node, cnode)) { - fprintf(fp, "%s\n", buf); - } - } - rewind(fp); - } - - serv_puts("CONF putsys|application/x-citadel-ignet-config"); - serv_getln(buf, sizeof buf); - if (buf[0] == '4') { - if (fp != NULL) { - while (fgets(buf, sizeof buf, fp) != NULL) { - buf[strlen(buf)-1] = 0; - if (buf[0] != 0) { - serv_puts(buf); - } - } - fclose(fp); - } - serv_printf("%s|%s|%s|%s", - bstr("node"), - bstr("secret"), - bstr("host"), - bstr("port") ); - } - serv_puts("000"); - } -*/ } - - //display_netconf(); url_do_template(); } -/** - * \brief add a node - */ -void display_add_node(void) -{/* - output_headers(1, 1, 2, 0, 0, 0); - wprintf("
\n"); - wprintf("

"); - wprintf(_("Add a new node")); - wprintf("

"); - wprintf("
\n"); - - wprintf("
\n"); - - wprintf("
\n"); - wprintf("\n", WC->nonce); - wprintf("
\n"); - wprintf("", _("Node name")); - wprintf("\n"); - wprintf("", _("Shared secret")); - wprintf("\n"); - wprintf("", _("Host or IP address")); - wprintf("\n"); - wprintf("", _("Port number")); - wprintf("\n"); - wprintf("
%s
%s
%s
%s

"); - wprintf("", _("Add node")); - wprintf(" "); - wprintf("", _("Cancel")); - wprintf("
\n"); - - wDumpContent(1); - */ -} - /** * \brief modify an existing node */ @@ -297,131 +218,14 @@ void display_edit_node(void) DeleteHash(&NodeConfig); -/* - char buf[512]; - char node[256]; - char cnode[256]; - char csecret[256]; - char chost[256]; - char cport[256]; - - strcpy(node, bstr("node")); - - output_headers(1, 1, 2, 0, 0, 0); - wprintf("
\n"); - wprintf("

"); - wprintf(_("Edit node configuration for ")); - escputs(node); - wprintf("

"); - wprintf("
\n"); - - wprintf("
\n"); - - serv_puts("CONF getsys|application/x-citadel-ignet-config"); - serv_getln(buf, sizeof buf); - if (buf[0] == '1') { - while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) { - extract_token(cnode, buf, 0, '|', sizeof cnode); - extract_token(csecret, buf, 1, '|', sizeof csecret); - extract_token(chost, buf, 2, '|', sizeof chost); - extract_token(cport, buf, 3, '|', sizeof cport); - - if (!strcasecmp(node, cnode)) { - wprintf("
\n"); - wprintf("\n", WC->nonce); - wprintf("
\n"); - wprintf(""); - wprintf("\n", cnode); - wprintf(""); - wprintf("\n", csecret); - wprintf(""); - wprintf("\n", chost); - wprintf(""); - wprintf("\n", cport); - wprintf("
"); - wprintf(_("Node name")); - wprintf("
"); - wprintf(_("Shared secret")); - wprintf("
"); - wprintf(_("Host or IP address")); - wprintf("
"); - wprintf(_("Port number")); - wprintf("

"); - wprintf("", - _("Save changes")); - wprintf(" "); - wprintf("", - _("Cancel")); - wprintf("
\n"); - } - - } - } - - else { / ** command error getting configuration * / - wprintf("%s
\n", &buf[4]); - } - - wDumpContent(1); -*/ } - - -//CFG:IGNET:NODE /** * \brief display all configured nodes */ void display_netconf(void) { -/* - char buf[SIZ]; - char node[SIZ]; - output_headers(1, 1, 2, 0, 0, 0); - wprintf("
\n"); - wprintf("

"); - wprintf(_("Network configuration")); - wprintf("

"); - wprintf("
\n"); - - wprintf("
\n"); - - wprintf("
"); - wprintf(""); - wprintf(_("Add a new node")); - wprintf("
\n"); - wprintf("
"); - - wprintf("
"); - wprintf(""); - wprintf(_("Currently configured nodes")); - wprintf("\n"); - wprintf("
\n"); - serv_puts("CONF getsys|application/x-citadel-ignet-config"); - serv_getln(buf, sizeof buf); - if (buf[0] == '1') { - wprintf("
\n"); - while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) { - extract_token(node, buf, 0, '|', sizeof node); - wprintf(""); - wprintf(""); - wprintf(""); - wprintf("\n"); - } - wprintf("
"); - escputs(node); - wprintf(""); - wprintf(_("(Edit)")); - wprintf(""); - wprintf(_("(Delete)")); - wprintf("
\n"); - } -*/ wDumpContent(1); } @@ -430,32 +234,6 @@ void display_netconf(void) */ void display_confirm_delete_node(void) { -/* - char node[SIZ]; - output_headers(1, 1, 2, 0, 0, 0); - wprintf("
\n"); - wprintf("

"); - wprintf(_("Confirm delete")); - wprintf("

"); - wprintf("
\n"); - - wprintf("
\n"); - - strcpy(node, bstr("node")); - wprintf("
"); - wprintf(_("Are you sure you want to delete ")); - wprintf(""); - escputs(node); - wprintf("?
\n"); - wprintf(""); - wprintf(_("Yes")); - wprintf("   "); - wprintf(""); - wprintf(_("No")); - wprintf("
\n"); -*/ wDumpContent(1); } @@ -492,41 +270,6 @@ void delete_node(void) url_do_template(); -/* - char buf[SIZ]; - char node[SIZ]; - char cnode[SIZ]; - FILE *fp; - - strcpy(node, bstr("node") ); - fp = tmpfile(); - if (fp != NULL) { - serv_puts("CONF getsys|application/x-citadel-ignet-config"); - serv_getln(buf, sizeof buf); - if (buf[0] == '1') { - while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) { - extract_token(cnode, buf, 0, '|', sizeof cnode); - if (strcasecmp(node, cnode)) { - fprintf(fp, "%s\n", buf); - } - } - } - rewind(fp); - - serv_puts("CONF putsys|application/x-citadel-ignet-config"); - serv_getln(buf, sizeof buf); - if (buf[0] == '4') { - while (fgets(buf, sizeof buf, fp) != NULL) { - buf[strlen(buf)-1] = 0; - serv_puts(buf); - } - serv_puts("000"); - } - fclose(fp); - } - - display_netconf(); -*/ } void @@ -539,7 +282,6 @@ InitModule_NETCONF WebcitAddUrlHandler(HKEY("display_netconf"), display_netconf, 0); WebcitAddUrlHandler(HKEY("display_confirm_delete_node"), display_confirm_delete_node, 0); WebcitAddUrlHandler(HKEY("delete_node"), delete_node, 0); - WebcitAddUrlHandler(HKEY("display_add_node"), display_add_node, 0); RegisterIterator("NODECONFIG", 0, NULL, load_netconf, NodeCfgSubst, DeleteHash, CTX_NODECONF, CTX_NONE); } /*@}*/ diff --git a/webcit/paramhandling.h b/webcit/paramhandling.h new file mode 100644 index 000000000..35999ad98 --- /dev/null +++ b/webcit/paramhandling.h @@ -0,0 +1,41 @@ +/* URL / Mime Post parsing -> paramhandling.c */ +void upload_handler(char *name, char *filename, char *partnum, char *disp, + void *content, char *cbtype, char *cbcharset, + size_t length, char *encoding, char *cbid, void *userdata); + +void ParseURLParams(StrBuf *url); + + +/* These may return NULL if not foud */ +#define sbstr(a) SBstr(a, sizeof(a) - 1) +const StrBuf *SBSTR(const char *key); +const StrBuf *SBstr(const char *key, size_t keylen); + +#define xbstr(a, b) (char*) XBstr(a, sizeof(a) - 1, b) +const char *XBstr(const char *key, size_t keylen, size_t *len); +const char *XBSTR(const char *key, size_t *len); + +#define lbstr(a) LBstr(a, sizeof(a) - 1) +long LBstr(const char *key, size_t keylen); +long LBSTR(const char *key); + +#define ibstr(a) IBstr(a, sizeof(a) - 1) +int IBstr(const char *key, size_t keylen); +int IBSTR(const char *key); + +#define havebstr(a) HaveBstr(a, sizeof(a) - 1) +int HaveBstr(const char *key, size_t keylen); +int HAVEBSTR(const char *key); + +#define yesbstr(a) YesBstr(a, sizeof(a) - 1) +int YesBstr(const char *key, size_t keylen); +int YESBSTR(const char *key); + +/* TODO: get rid of the non-const-typecast */ +#define bstr(a) (char*) Bstr(a, sizeof(a) - 1) +const char *BSTR(const char *key); +const char *Bstr(const char *key, size_t keylen); +/* if you want to ease some parts by just parametring yourself... */ +#define putbstr(a, b) PutBstr(a, sizeof(a) - 1, b) +void PutBstr(const char *key, long keylen, StrBuf *Value); + diff --git a/webcit/preferences.c b/webcit/preferences.c index 0ed7b68d7..b66a3bd38 100644 --- a/webcit/preferences.c +++ b/webcit/preferences.c @@ -357,282 +357,6 @@ void set_ROOM_PREFS(const char *key, size_t keylen, StrBuf *value, int save_to_s FreeStrBuf(&pref_name); } -/** - * \brief display form for changing your preferences and settings - */ -void display_preferences(void) -{ - output_headers(1, 1, 1, 0, 0, 0); - StrBuf *ebuf = NULL; - int i; - long DayEnd, DayStart, WeekStart; - int UseSig, ShowEmptyFloors; - int time_format; - time_t tt; - struct tm tm; - char daylabel[32]; - StrBuf *Buf; - StrBuf *Signature; - - time_format = get_time_format_cached (); - - wprintf("
\n"); - wprintf("
"); - wprintf(_("Preferences and settings")); - wprintf("
"); - - wprintf("
"); - - /** begin form */ - wprintf("
\n"); - wprintf("\n", WC->nonce); - - /** begin table */ - wprintf("\n"); - - /** - * Room list view - */ - get_preference("roomlistview", &Buf); - wprintf("\n"); - - /** - * Time hour format - */ - - wprintf("\n"); - - /** - * Calendar day view -- day start time - */ - get_pref_long("daystart", &DayStart, 8); - - wprintf("\n"); - - /** - * Calendar day view -- day end time - */ - get_pref_long("dayend", &DayEnd, 17); - - wprintf("\n"); - - /** - * Day of week to begin calendar month view - */ - get_pref_long("weekstart", &WeekStart, 17); - wprintf("\n"); - - /** - * Signature - */ - get_pref_yesno("use_sig", &UseSig, 0); - wprintf("\n"); - - wprintf(" " - ); - - /** Character set to assume is in use for improperly encoded headers */ - if (!get_preference("default_header_charset", &Buf)) { - Buf = NewStrBuf(); - StrBufPrintf(Buf, "%s", "UTF-8"); - set_preference("default_header_charset", Buf, 0); - } - wprintf(""); - - /** - * Show empty floors? - */ - - get_pref_yesno("emptyfloors", &ShowEmptyFloors, 0); - wprintf("\n"); - - /** end table */ - wprintf("
"); - wprintf(PrefGetLocalStr(HKEY("roomlistview"))); - wprintf(""); - - wprintf(""); - wprintf(_("Tree (folders) view")); - wprintf("   "); - - wprintf(""); - wprintf(_("Table (rooms) view")); - wprintf("\n"); - - wprintf("
"); - wprintf(PrefGetLocalStr(HKEY("calhourformat"))); - wprintf(""); - - wprintf(""); - wprintf(_("12 hour (am/pm)")); - wprintf("   "); - - wprintf(""); - wprintf(_("24 hour")); - wprintf("\n"); - - wprintf("
"); - wprintf(PrefGetLocalStr(HKEY("daystart"))); - wprintf(""); - - wprintf("\n"); - wprintf("
"); - wprintf(PrefGetLocalStr(HKEY("dayend"))); - wprintf(""); - - wprintf("\n"); - wprintf("
"); - wprintf(PrefGetLocalStr(HKEY("weekstart"))); - wprintf(""); - - wprintf("\n"); - wprintf("
"); - wprintf(_("Attach signature to email messages?")); - wprintf(""); - - wprintf(" " - ); - - wprintf(PrefGetLocalStr(HKEY("use_sig"))); - - wprintf(""); - wprintf(_("No signature")); - wprintf(" ,  \n"); - - wprintf(""); - wprintf(PrefGetLocalStr(HKEY("signature"))); - wprintf("
" - "
" - "
" - ); - - wprintf("\n"); - - wprintf("
"); - wprintf(PrefGetLocalStr(HKEY("default_header_charset"))); - wprintf(""); - wprintf(""); - wprintf("
"); - wprintf(PrefGetLocalStr(HKEY("emptyfloors"))); - wprintf(""); - - wprintf(""); - wprintf(_("Yes")); - wprintf("   "); - - wprintf(""); - wprintf(_("No")); - wprintf("\n"); - - wprintf("
\n"); - - /** submit buttons */ - wprintf("
"); - wprintf("" - " " - "\n", - _("Change"), - _("Cancel") - ); - wprintf("
\n"); - - /** end form */ - wprintf("
\n"); - wprintf("
\n"); - wDumpContent(1); -} - - - - /* * Offer to make any page the user's "start page." */ @@ -862,7 +586,6 @@ void InitModule_PREFERENCES (void) { - WebcitAddUrlHandler(HKEY("display_preferences"), display_preferences, 0); WebcitAddUrlHandler(HKEY("set_preferences"), set_preferences, 0); WebcitAddUrlHandler(HKEY("change_start_page"), change_start_page, 0); diff --git a/webcit/preferences.h b/webcit/preferences.h new file mode 100644 index 000000000..d02ae73bc --- /dev/null +++ b/webcit/preferences.h @@ -0,0 +1,24 @@ +void load_preferences(void); +void save_preferences(void); +#define get_preference(a, b) get_PREFERENCE(a, sizeof(a) - 1, b) +#define get_pref(a, b) get_PREFERENCE(ChrPtr(a), StrLength(a), b) +int get_PREFERENCE(const char *key, size_t keylen, StrBuf **value); +#define set_preference(a, b, c) set_PREFERENCE(a, sizeof(a) - 1, b, c) +#define set_pref(a, b, c) set_PREFERENCE(ChrPtr(a), StrLength(a), b, c) +void set_PREFERENCE(const char *key, size_t keylen, StrBuf *value, int save_to_server); + +#define get_pref_long(a, b, c) get_PREF_LONG(a, sizeof(a) - 1, b, c) +int get_PREF_LONG(const char *key, size_t keylen, long *value, long Default); +#define set_pref_long(a, b, c) set_PREF_LONG(a, sizeof(a) - 1, b, c) +void set_PREF_LONG(const char *key, size_t keylen, long value, int save_to_server); + +#define get_pref_yesno(a, b, c) get_PREF_YESNO(a, sizeof(a) - 1, b, c) +int get_PREF_YESNO(const char *key, size_t keylen, int *value, int Default); +#define set_pref_yesno(a, b, c) set_PREF_YESNO(a, sizeof(a) - 1, b, c) +void set_PREF_YESNO(const char *key, size_t keylen, int value, int save_to_server); + +#define get_room_pref(a) get_ROOM_PREFS(a, sizeof(a) - 1) +StrBuf *get_ROOM_PREFS(const char *key, size_t keylen); + +#define set_room_pref(a, b, c) set_ROOM_PREFS(a, sizeof(a) - 1, b, c) +void set_ROOM_PREFS(const char *key, size_t keylen, StrBuf *value, int save_to_server); diff --git a/webcit/roomops.c b/webcit/roomops.c index 958c25d6e..4c47999e4 100644 --- a/webcit/roomops.c +++ b/webcit/roomops.c @@ -509,7 +509,7 @@ void embed_room_banner(char *got, int navbar_style) { svcallback("START", offer_start_page); do_template("roombanner", NULL); - // roombanner contains this for mobile + /* roombanner contains this for mobile */ if (navbar_style != navbar_none && !WC->is_mobile) { wprintf("