* move several files headers out of webcit.h into their own ones. its getting to crowded over there.
*/
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);
/* 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);
/* See what we need to do with this */
if (method != NULL) {
- the_method = icalproperty_get_method(method);
char *title;
+ the_method = icalproperty_get_method(method);
StrBufAppendPrintf(Target, "<div id=\"%s_title\">", divname);
StrBufAppendPrintf(Target, "<img src=\"static/calarea_48x.gif\">");
icalrecur_iterator *ritr = NULL;
struct icaltimetype next;
int num_recur = 0;
+ int stop_rr = 0;
dtstart = icaltime_null_time();
dtend = icaltime_null_time();
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. */
memcpy(Cal->from, from, len + 1);
Cal->cal_msgnum = msgnum;
- icalcomponent *cptr;
if (icalcomponent_isa(Cal->cal) == ICAL_VEVENT_COMPONENT) {
cptr = Cal->cal;
}
created_new_vtodo = 1;
}
- // TODO: Can we take all this and move it into a template?
+ /*/ TODO: Can we take all this and move it into a template? */
output_headers(1, 1, 1, 0, 0, 0);
wprintf("<!-- start task edit form -->");
p = icalcomponent_get_first_property(vtodo, ICAL_SUMMARY_PROPERTY);
- // Get summary early for title
+ /* Get summary early for title */
wprintf("<div class=\"box\">\n");
wprintf("<div class=\"boxlabel\">");
wprintf(_("Edit task"));
}
wprintf(" >");
wprintf("</TD></TR>");
- // start category field
+ /* start category field */
p = icalcomponent_get_first_property(vtodo, ICAL_CATEGORIES_PROPERTY);
wprintf("<TR><TD>");
wprintf(_("Category:"));
}
wprintf("\">");
wprintf("</TD></TR>\n ");
- // end category field
+ /* end category field */
wprintf("<TR><TD>");
wprintf(_("Description:"));
wprintf("</TD><TD>");
|| (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;
time_t now;
struct tm tm;
char calview[32];
+ int span = 3888000;
/* In case no date was specified, go with today */
now = time(NULL);
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;
*/
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;
Pos = GetNewHashPos(WCC->disp_cal_items, 0);
while (GetNextHashPos(WCC->disp_cal_items, Pos, &hklen, &HashKey, &vCal)) {
+ icalproperty_status todoStatus;
+
Cal = (disp_cal*)vCal;
wprintf("<tr><td>");
- icalproperty_status todoStatus = icalcomponent_get_status(Cal->cal);
+ todoStatus = icalcomponent_get_status(Cal->cal);
wprintf("<input type=\"checkbox\" name=\"completed\" value=\"completed\" ");
if (todoStatus == ICAL_STATUS_COMPLETED) {
wprintf("checked=\"checked\" ");
{
close((*sessions_to_kill)->serv_sock);
close((*sessions_to_kill)->chat_sock);
+/*
// if ((*sessions_to_kill)->preferences != NULL) {
// free((*sessions_to_kill)->preferences);
// }
+*/
if ((*sessions_to_kill)->cache_fold != NULL) {
free((*sessions_to_kill)->cache_fold);
}
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
*/
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/",
"/MSOffice" /**< Stoopid MSOffice thinks everyone is IIS */
};
+ url = ChrPtr(http_cmd);
+ if (IsEmptyStr(url)) return(1);
+ ++url;
+
+
max = sizeof(bogus_prefixes) / sizeof(char *);
for (i=0; i<max; ++i) {
}
StrBufExtract_token(HeaderName, Line, 0, ':');
- //// TODO: filter bad chars!
+ /*/// TODO: filter bad chars! */
pchs = ChrPtr(Line);
pch = pchs + StrLength(HeaderName) + 1;
} while (LineLen > 0);
FreeStrBuf(&HeaderName);
-//// dbg_PrintHash(HTTPHeaders, nix, NULL);
+/*/// dbg_PrintHash(HTTPHeaders, nix, NULL); */
/**
for (i=0; i<len; ++i) {
if ((buf[i] < 32) || (buf[i] > 126)) {
illegal_non_rfc2047_encoding = 1;
- i = len; ///< take a shortcut, it won't be more than one.
+ i = len; /*< take a shortcut, it won't be more than one. */
}
}
if (illegal_non_rfc2047_encoding) {
"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);
{
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')
{
*/
void output_image()
{
+ char blank_gif[SIZ];
wcsession *WCC = WC;
char buf[SIZ];
off_t bytes;
* 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);
}
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;
wprintf("<INPUT TYPE=\"hidden\" NAME=\"day\" VALUE=\"%s\">\n",
bstr("day"));
- char *tabnames[] = {
- _("Event"),
- _("Attendees"),
- _("Recurrence")
- };
tabbed_dialog(3, tabnames);
begin_tab(0, 3);
/* Recurrence tab */
begin_tab(2, 3);
- icalproperty *rrule = NULL;
- struct icalrecurrencetype recur;
rrule = icalcomponent_get_first_property(vevent, ICAL_RRULE_PROPERTY);
if (rrule) {
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
FreeStrBuf(&SBuf);
}
-/* TODO: we skip the language weighting so far. */
-/* Accept-Language: 'de-de,en-us;q=0.7,en;q=0.3' */
-/* Accept-Language: de,en-ph;q=0.8,en-us;q=0.5,de-at;q=0.3 */
-//void httplang_to_locale(char *LocaleString)
-//{
-// char selected_locale[16];
-// int i, j;
-// char lang[64];
-// int num_accept = 0;
-//
-// lprintf(9, "languageAccept: %s\n", LocaleString);
-//
-// strcpy(selected_locale, "C");
-// num_accept = num_tokens(LocaleString, ',');
-//
-// for (i=num_accept-1; i>=0; --i) {
-// extract_token(lang, LocaleString, i, ',', sizeof lang);
-//
-// /* Strip out the weights; we don't use them. Also convert
-// * hyphens to underscores.
-// */
-// for (j=0; j<strlen(lang); ++j) {
-// if (lang[j] == '-') lang[j] = '_';
-// if (lang[j] == ';') lang[j] = 0;
-// }
-//
-// for (j=0; j<NUM_LANGS; ++j) {
-// if (!strncasecmp(lang, AvailLang[j], strlen(lang))) {
-// strcpy(selected_locale, AvailLang[j]);
-// }
-// }
-// }
-//
-// lprintf(9, "language found: %s\n", selected_locale);
-// set_selected_language(selected_locale);
-//}
-
-
/**
* \brief show the language chooser on the login dialog
* depending on the browser locale change the sequence of the
for (i = 0; i < NUM_LANGS; ++i) {
if (i == 0) {
- sprintf(buf, "%s", AvailLang[i]); // locale 0 (C) is ascii, not utf-8
+ sprintf(buf, "%s", AvailLang[i]); /* locale 0 (C) is ascii, not utf-8 */
}
else {
sprintf(buf, "%s.UTF8", AvailLang[i]);
void display_graphics_upload(char *description, char *filename, char *uplurl)
{
+ StrBuf *Buf;
char buf[SIZ];
}
output_headers(1, 1, 0, 0, 0, 0);
- StrBuf *Buf;
output_headers(1, 1, 1, 0, 0, 0);
Buf = NewStrBufPlain(_("Image upload"), -1);
hprintf("Content-Type: text/plain\r\n");
wprintf("%s\r\n",
&buf[4]
- );/// TODO: do we need to end-burst here?
+ );/* TODO: do we need to end-burst here? */
return;
}
/* We created this item for the first time. */
if (old_msgnum < 0L) {
+ char escaped_uid[1024];
hprintf("HTTP/1.1 201 Created\r\n");
lprintf(9, "HTTP/1.1 201 Created\r\n");
groupdav_common_headers();
hprintf("etag: \"%ld\"\r\n", new_msgnum);
hprintf("Location: ");
groupdav_identify_host();
- hprintf("/groupdav/");/////TODO
+ hprintf("/groupdav/");/* TODO */
hurlescputs(dav_roomname);
- char escaped_uid[1024];
euid_escapize(escaped_uid, dav_uid);
hprintf("/%s\r\n", escaped_uid);
end_burst();
StrBufConvert(Source, Buf, &ic);
FreeStrBuf(&Buf);
iconv_close(ic);
- msg = (char*)ChrPtr(Source); //TODO: get rid of this.
+ msg = (char*)ChrPtr(Source); /* TODO: get rid of this. */
}
}
nbspreviewptr = strstr(ptr, " ");
if (nbspreviewptr != NULL) {
- ///*nbspreviewptr = '\0';
+ /* nbspreviewptr = '\0'; */
linklen = nbspreviewptr - ptr;
}
if (ltreviewptr != 0)
}
}
-void DontDeleteThis(void *Data){};
+void DontDeleteThis(void *Data){}
#define IconbarIsEnabled(a, b) IconbarIsENABLED(a, sizeof(a) - 1, b)
{
wcsession *WCC = WC;
StrBuf *iconbar = NULL;
- StrBuf *buf = NewStrBuf();;
- StrBuf *key = NewStrBuf();
+ StrBuf *buf;
+ StrBuf *key;
long val;
int i, nTokens;
+ buf = NewStrBuf();;
+ key = NewStrBuf();
WCC->current_iconbar = current_iconbar_menu;
if (WCC->IconBarSetttings == NULL)
WCC->IconBarSetttings = NewHash(1, NULL);
* we generate its innerHTML...
*/
void do_iconbar_roomlist(void) {
+ int ib_displayas;
WC->current_iconbar = current_iconbar_roomlist;
* their iconbars. These should probably be set in a master
* configuration somewhere.
*/
- int ib_displayas;
LoadIconSettings();
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);
typedef void (*MsgPartEvaluatorFunc)(message_summary *Sum, StrBuf *Buf);
+typedef struct _MsgPartEvaluatorStruct {
+ MsgPartEvaluatorFunc f;
+}MsgPartEvaluatorStruct;
/*----------------------------------------------------------------------------*/
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)
/* 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) {
message_summary *ReadOneMessageSummary(StrBuf *RawMessage, const char *DefaultSubject, long MsgNum)
{
void *vEval;
- MsgPartEvaluatorFunc Eval;
+ MsgPartEvaluatorStruct *Eval;
message_summary *Msg;
StrBuf *Buf;
const char *buf;
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));
}
FreeStrBuf(&Buf);
return (nummsgs);
}
-// TODO if (with_headers) { //// TODO: Have Attachments?
Buf2 = NewStrBuf();
while (len = StrBuf_ServGetln(Buf),
((len != 3) ||
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') {
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"))
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");
}
}
else if (buf[0] != '2') { /** Any other error means that we cannot continue */
- wprintf("<em>%s</em><br />\n", &buf[4]);/// -> important message
+ wprintf("<em>%s</em><br />\n", &buf[4]);/*TODO -> important message */
return;
}
}
{
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') {
}
else {
FlushStrBuf(Mime->Data);
- /// TODO XImportant message
+ /* TODO XImportant message */
}
}
--- /dev/null
+
+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);
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);
}
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)
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);
}
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);
{
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)
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();
Put(NodeConfig, ChrPtr(Index), StrLength(Index), NewNode, DeleteNodeConf);
save_net_conf(NodeConfig);
DeleteHash(&NodeConfig);
-/*
- strcpy(node, bstr("node") );
- fp = tmpfile();
- if (fp != NULL) {
- serv_puts("CONF getsys|application/x-citadel-ignet-config");
- serv_getln(buf, sizeof buf);
- if (buf[0] == '1') {
- while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
- extract_token(cnode, buf, 0, '|', sizeof cnode);
- if (strcasecmp(node, cnode)) {
- fprintf(fp, "%s\n", buf);
- }
- }
- rewind(fp);
- }
-
- serv_puts("CONF putsys|application/x-citadel-ignet-config");
- serv_getln(buf, sizeof buf);
- if (buf[0] == '4') {
- if (fp != NULL) {
- while (fgets(buf, sizeof buf, fp) != NULL) {
- buf[strlen(buf)-1] = 0;
- if (buf[0] != 0) {
- serv_puts(buf);
- }
- }
- fclose(fp);
- }
- serv_printf("%s|%s|%s|%s",
- bstr("node"),
- bstr("secret"),
- bstr("host"),
- bstr("port") );
- }
- serv_puts("000");
- }
-*/
}
-
- //display_netconf();
url_do_template();
}
-/**
- * \brief add a node
- */
-void display_add_node(void)
-{/*
- output_headers(1, 1, 2, 0, 0, 0);
- wprintf("<div id=\"banner\">\n");
- wprintf("<h1>");
- wprintf(_("Add a new node"));
- wprintf("</h1>");
- wprintf("</div>\n");
-
- wprintf("<div id=\"content\" class=\"service\">\n");
-
- wprintf("<FORM METHOD=\"POST\" action=\"edit_node\">\n");
- wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
- wprintf("<CENTER><TABLE border=0>\n");
- wprintf("<TR><TD>%s</TD>", _("Node name"));
- wprintf("<TD><INPUT TYPE=\"text\" NAME=\"node\" MAXLENGTH=\"16\"></TD></TR>\n");
- wprintf("<TR><TD>%s</TD>", _("Shared secret"));
- wprintf("<TD><INPUT TYPE=\"password\" NAME=\"secret\" MAXLENGTH=\"16\"></TD></TR>\n");
- wprintf("<TR><TD>%s</TD>", _("Host or IP address"));
- wprintf("<TD><INPUT TYPE=\"text\" NAME=\"host\" MAXLENGTH=\"64\"></TD></TR>\n");
- wprintf("<TR><TD>%s</TD>", _("Port number"));
- wprintf("<TD><INPUT TYPE=\"text\" NAME=\"port\" VALUE=\"504\" MAXLENGTH=\"8\"></TD></TR>\n");
- wprintf("</TABLE><br />");
- wprintf("<INPUT TYPE=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">", _("Add node"));
- wprintf(" ");
- wprintf("<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
- wprintf("</CENTER></FORM>\n");
-
- wDumpContent(1);
- */
-}
-
/**
* \brief modify an existing node
*/
DeleteHash(&NodeConfig);
-/*
- char buf[512];
- char node[256];
- char cnode[256];
- char csecret[256];
- char chost[256];
- char cport[256];
-
- strcpy(node, bstr("node"));
-
- output_headers(1, 1, 2, 0, 0, 0);
- wprintf("<div id=\"banner\">\n");
- wprintf("<h1>");
- wprintf(_("Edit node configuration for "));
- escputs(node);
- wprintf("</h1>");
- wprintf("</div>\n");
-
- wprintf("<div id=\"content\" class=\"service\">\n");
-
- serv_puts("CONF getsys|application/x-citadel-ignet-config");
- serv_getln(buf, sizeof buf);
- if (buf[0] == '1') {
- while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
- extract_token(cnode, buf, 0, '|', sizeof cnode);
- extract_token(csecret, buf, 1, '|', sizeof csecret);
- extract_token(chost, buf, 2, '|', sizeof chost);
- extract_token(cport, buf, 3, '|', sizeof cport);
-
- if (!strcasecmp(node, cnode)) {
- wprintf("<FORM METHOD=\"POST\" action=\"edit_node\">\n");
- wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
- wprintf("<CENTER><TABLE border=0>\n");
- wprintf("<TR><TD>");
- wprintf(_("Node name"));
- wprintf("</TD>");
- wprintf("<TD><INPUT TYPE=\"text\" NAME=\"node\" MAXLENGTH=\"16\" VALUE=\"%s\"></TD></TR>\n", cnode);
- wprintf("<TR><TD>");
- wprintf(_("Shared secret"));
- wprintf("</TD>");
- wprintf("<TD><INPUT TYPE=\"password\" NAME=\"secret\" MAXLENGTH=\"16\" VALUE=\"%s\"></TD></TR>\n", csecret);
- wprintf("<TR><TD>");
- wprintf(_("Host or IP address"));
- wprintf("</TD>");
- wprintf("<TD><INPUT TYPE=\"text\" NAME=\"host\" MAXLENGTH=\"64\" VALUE=\"%s\"></TD></TR>\n", chost);
- wprintf("<TR><TD>");
- wprintf(_("Port number"));
- wprintf("</TD>");
- wprintf("<TD><INPUT TYPE=\"text\" NAME=\"port\" MAXLENGTH=\"8\" VALUE=\"%s\"></TD></TR>\n", cport);
- wprintf("</TABLE><br />");
- wprintf("<INPUT TYPE=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">",
- _("Save changes"));
- wprintf(" ");
- wprintf("<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">",
- _("Cancel"));
- wprintf("</CENTER></FORM>\n");
- }
-
- }
- }
-
- else { / ** command error getting configuration * /
- wprintf("%s<br />\n", &buf[4]);
- }
-
- wDumpContent(1);
-*/
}
-
-
-//CFG:IGNET:NODE
/**
* \brief display all configured nodes
*/
void display_netconf(void)
{
-/*
- char buf[SIZ];
- char node[SIZ];
- output_headers(1, 1, 2, 0, 0, 0);
- wprintf("<div id=\"banner\">\n");
- wprintf("<h1>");
- wprintf(_("Network configuration"));
- wprintf("</h1>");
- wprintf("</div>\n");
-
- wprintf("<div id=\"content\" class=\"service\">\n");
-
- wprintf("<CENTER>");
- wprintf("<a href=\"display_add_node\">");
- wprintf(_("Add a new node"));
- wprintf("</A><br />\n");
- wprintf("</CENTER>");
-
- wprintf("<TABLE class=\"netconf_banner\"><TR><TD>");
- wprintf("<SPAN CLASS=\"titlebar\">");
- wprintf(_("Currently configured nodes"));
- wprintf("</SPAN>\n");
- wprintf("</TD></TR></TABLE>\n");
- serv_puts("CONF getsys|application/x-citadel-ignet-config");
- serv_getln(buf, sizeof buf);
- if (buf[0] == '1') {
- wprintf("<CENTER><TABLE border=0>\n");
- while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
- extract_token(node, buf, 0, '|', sizeof node);
- wprintf("<TR><TD><FONT SIZE=+1>");
- escputs(node);
- wprintf("</FONT></TD>");
- wprintf("<TD><a href=\"display_edit_node&node=");
- urlescputs(node);
- wprintf("\">");
- wprintf(_("(Edit)"));
- wprintf("</A></TD>");
- wprintf("<TD><a href=\"display_confirm_delete_node&node=");
- urlescputs(node);
- wprintf("\">");
- wprintf(_("(Delete)"));
- wprintf("</A></TD>");
- wprintf("</TR>\n");
- }
- wprintf("</TABLE></CENTER>\n");
- }
-*/
wDumpContent(1);
}
*/
void display_confirm_delete_node(void)
{
-/*
- char node[SIZ];
- output_headers(1, 1, 2, 0, 0, 0);
- wprintf("<div id=\"banner\">\n");
- wprintf("<h1>");
- wprintf(_("Confirm delete"));
- wprintf("</h1>");
- wprintf("</div>\n");
-
- wprintf("<div id=\"content\" class=\"service\" >\n");
-
- strcpy(node, bstr("node"));
- wprintf("<CENTER>");
- wprintf(_("Are you sure you want to delete "));
- wprintf("<FONT SIZE=+1>");
- escputs(node);
- wprintf("</FONT>?<br />\n");
- wprintf("<a href=\"delete_node&node=");
- urlescputs(node);
- wprintf("\">");
- wprintf(_("Yes"));
- wprintf("</A> ");
- wprintf("<a href=\"display_netconf\">");
- wprintf(_("No"));
- wprintf("</A><br />\n");
-*/
wDumpContent(1);
}
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
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);
}
/*@}*/
--- /dev/null
+/* 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);
+
FreeStrBuf(&pref_name);
}
-/**
- * \brief display form for changing your preferences and settings
- */
-void display_preferences(void)
-{
- output_headers(1, 1, 1, 0, 0, 0);
- StrBuf *ebuf = NULL;
- int i;
- long DayEnd, DayStart, WeekStart;
- int UseSig, ShowEmptyFloors;
- int time_format;
- time_t tt;
- struct tm tm;
- char daylabel[32];
- StrBuf *Buf;
- StrBuf *Signature;
-
- time_format = get_time_format_cached ();
-
- wprintf("<div class=\"box\">\n");
- wprintf("<div class=\"boxlabel\">");
- wprintf(_("Preferences and settings"));
- wprintf("</div>");
-
- wprintf("<div class=\"boxcontent\">");
-
- /** begin form */
- wprintf("<form name=\"prefform\" action=\"set_preferences\" "
- "method=\"post\">\n");
- wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
-
- /** begin table */
- wprintf("<table class=\"altern\">\n");
-
- /**
- * Room list view
- */
- get_preference("roomlistview", &Buf);
- wprintf("<tr class=\"even\"><td>");
- wprintf(PrefGetLocalStr(HKEY("roomlistview")));
- wprintf("</td><td>");
-
- wprintf("<input type=\"radio\" name=\"roomlistview\" VALUE=\"folders\"");
- if (!strcasecmp(ChrPtr(Buf), "folders")) wprintf(" checked");
- wprintf(">");
- wprintf(_("Tree (folders) view"));
- wprintf("</input> ");
-
- wprintf("<input type=\"radio\" name=\"roomlistview\" VALUE=\"rooms\"");
- if (IsEmptyStr(ChrPtr(Buf)) || !strcasecmp(ChrPtr(Buf), "rooms")) wprintf(" checked");
- wprintf(">");
- wprintf(_("Table (rooms) view"));
- wprintf("</input>\n");
-
- wprintf("</td></tr>\n");
-
- /**
- * Time hour format
- */
-
- wprintf("<tr class=\"odd\"><td>");
- wprintf(PrefGetLocalStr(HKEY("calhourformat")));
- wprintf("</td><td>");
-
- wprintf("<input type=\"radio\" name=\"calhourformat\" VALUE=\"12\"");
- if (time_format == WC_TIMEFORMAT_AMPM)
- wprintf(" checked");
- wprintf(">");
- wprintf(_("12 hour (am/pm)"));
- wprintf("</input> ");
-
- wprintf("<input type=\"radio\" name=\"calhourformat\" VALUE=\"24\"");
- if (time_format == WC_TIMEFORMAT_24)
- wprintf(" checked");
- wprintf(">");
- wprintf(_("24 hour"));
- wprintf("</input>\n");
-
- wprintf("</td></tr>\n");
-
- /**
- * Calendar day view -- day start time
- */
- get_pref_long("daystart", &DayStart, 8);
-
- wprintf("<tr class=\"even\"><td>");
- wprintf(PrefGetLocalStr(HKEY("daystart")));
- wprintf("</td><td>");
-
- wprintf("<select name=\"daystart\" size=\"1\">\n");
- for (i=0; i<=23; ++i) {
-
- if (time_format == WC_TIMEFORMAT_24) {
- wprintf("<option %s value=\"%d\">%d:00</option>\n",
- ((DayStart == i) ? "selected" : ""),
- i, i
- );
- }
- else {
- wprintf("<option %s value=\"%d\">%s</option>\n",
- ((DayStart == i) ? "selected" : ""),
- i, hourname[i]
- );
- }
-
- }
- wprintf("</select>\n");
- wprintf("</td></tr>\n");
-
- /**
- * Calendar day view -- day end time
- */
- get_pref_long("dayend", &DayEnd, 17);
-
- wprintf("<tr class=\"odd\"><td>");
- wprintf(PrefGetLocalStr(HKEY("dayend")));
- wprintf("</td><td>");
-
- wprintf("<select name=\"dayend\" size=\"1\">\n");
- for (i=0; i<=23; ++i) {
-
- if (time_format == WC_TIMEFORMAT_24) {
- wprintf("<option %s value=\"%d\">%d:00</option>\n",
- ((DayEnd == i) ? "selected" : ""),
- i, i
- );
- }
- else {
- wprintf("<option %s value=\"%d\">%s</option>\n",
- ((DayEnd == i) ? "selected" : ""),
- i, hourname[i]
- );
- }
-
- }
- wprintf("</select>\n");
- wprintf("</td></tr>\n");
-
- /**
- * Day of week to begin calendar month view
- */
- get_pref_long("weekstart", &WeekStart, 17);
- wprintf("<tr class=\"even\"><td>");
- wprintf(PrefGetLocalStr(HKEY("weekstart")));
- wprintf("</td><td>");
-
- wprintf("<select name=\"weekstart\" size=\"1\">\n");
-
- for (i=0; i<=1; ++i) {
- tt = time(NULL);
- localtime_r(&tt, &tm);
- tm.tm_wday = i;
- wc_strftime(daylabel, sizeof daylabel, "%A", &tm);
-
- wprintf("<option %s value=\"%d\">%s</option>\n",
- ((WeekStart == i) ? "selected" : ""),
- i, daylabel
- );
- }
-
- wprintf("</select>\n");
- wprintf("</td></tr>\n");
-
- /**
- * Signature
- */
- get_pref_yesno("use_sig", &UseSig, 0);
- wprintf("<tr class=\"odd\"><td>");
- wprintf(_("Attach signature to email messages?"));
- wprintf("</td><td>");
-
- wprintf(" <script type=\"text/javascript\"> "
- " function show_or_hide_sigbox() { "
- " if ( $F('yes_sig') ) { "
- " $('signature_box').style.display = 'inline'; "
- " } "
- " else { "
- " $('signature_box').style.display = 'none'; "
- " } "
- " } "
- " </script> "
- );
-
- wprintf(PrefGetLocalStr(HKEY("use_sig")));
-
- wprintf("<input type=\"radio\" id=\"no_sig\" name=\"use_sig\" VALUE=\"no\"");
- if (!UseSig) wprintf(" checked");
- wprintf(" onChange=\"show_or_hide_sigbox();\" >");
- wprintf(_("No signature"));
- wprintf("</input> , \n");
-
- wprintf("<input type=\"radio\" id=\"yes_sig\" name=\"use_sig\" VALUE=\"yes\"");
- if (UseSig) wprintf(" checked");
- wprintf(" onChange=\"show_or_hide_sigbox();\" >");
- wprintf(PrefGetLocalStr(HKEY("signature")));
- wprintf("<div id=\"signature_box\">"
- "<br><textarea name=\"signature\" cols=\"40\" rows=\"5\">"
- );
-
- get_preference("signature", &Signature);
- ebuf = NewStrBuf();
- StrBufEUid_unescapize(ebuf, Signature);
- StrEscPuts(ebuf);
- FreeStrBuf(&ebuf);
- wprintf("</textarea>"
- "</div>"
- );
-
- wprintf("</input>\n");
-
- wprintf("</td></tr>\n");
-
- wprintf(" <script type=\"text/javascript\"> "
- " show_or_hide_sigbox(); "
- " </script> "
- );
-
- /** Character set to assume is in use for improperly encoded headers */
- if (!get_preference("default_header_charset", &Buf)) {
- Buf = NewStrBuf();
- StrBufPrintf(Buf, "%s", "UTF-8");
- set_preference("default_header_charset", Buf, 0);
- }
- wprintf("<tr class=\"even\"><td>");
- wprintf(PrefGetLocalStr(HKEY("default_header_charset")));
- wprintf("</td><td>");
- wprintf("<input type=\"text\" NAME=\"default_header_charset\" MAXLENGTH=\"32\" VALUE=\"");
- StrEscPuts(Buf); // here shouldn't be bad chars, so...
- wprintf("\">");
- wprintf("</td></tr>");
-
- /**
- * Show empty floors?
- */
-
- get_pref_yesno("emptyfloors", &ShowEmptyFloors, 0);
- wprintf("<tr class=\"odd\"><td>");
- wprintf(PrefGetLocalStr(HKEY("emptyfloors")));
- wprintf("</td><td>");
-
- wprintf("<input type=\"radio\" name=\"emptyfloors\" VALUE=\"yes\"");
- if (ShowEmptyFloors) wprintf(" checked");
- wprintf(">");
- wprintf(_("Yes"));
- wprintf("</input> ");
-
- wprintf("<input type=\"radio\" name=\"emptyfloors\" VALUE=\"no\"");
- if (!ShowEmptyFloors) wprintf(" checked");
- wprintf(">");
- wprintf(_("No"));
- wprintf("</input>\n");
-
- wprintf("</td></tr>\n");
-
- /** end table */
- wprintf("</table>\n");
-
- /** submit buttons */
- wprintf("<div class=\"buttons\"> ");
- wprintf("<input type=\"submit\" name=\"change_button\" value=\"%s\">"
- " "
- "<INPUT type=\"submit\" name=\"cancel_button\" value=\"%s\">\n",
- _("Change"),
- _("Cancel")
- );
- wprintf("</div>\n");
-
- /** end form */
- wprintf("</form>\n");
- wprintf("</div>\n");
- wDumpContent(1);
-}
-
-
-
-
/*
* Offer to make any page the user's "start page."
*/
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);
--- /dev/null
+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);
svcallback("START", offer_start_page);
do_template("roombanner", NULL);
- // roombanner contains this for mobile
+ /* roombanner contains this for mobile */
if (navbar_style != navbar_none && !WC->is_mobile) {
wprintf("<div id=\"navbar\"><ul>");
wprintf("<td>%s</td>", extract_int(buf, 4) ? _("Yes") : _("No"));
- wprintf("<td>%ld</td>", extract_long(buf, 5)); // Fetching interval
+ wprintf("<td>%ld</td>", extract_long(buf, 5)); /* Fetching interval */
wprintf("<td class=\"button_link\">");
wprintf(" <a href=\"netedit&cmd=remove&tab=feeds&line=pop3client|");
char cmpb0[SIZ];
char cmpb1[SIZ];
int i, num_addrs;
- // TODO: do line dynamic!
+ /*/ TODO: do line dynamic! */
if (havebstr("line_pop3host")) {
strcpy(line, bstr("prefix"));
strcat(line, bstr("line_pop3host"));
floor_mapping[fold[i].floor]=i;
/** refresh the messages index for this room */
-// serv_puts("GOTO ");
-// while (serv_getln(buf, sizeof buf), strcmp(buf, "000"));
+/* TODO serv_puts("GOTO ");
+ while (serv_getln(buf, sizeof buf), strcmp(buf, "000")); */
/** Now add rooms */
serv_puts("LKRA");
serv_getln(buf, sizeof buf);
size_t obuflen; /**< Length of output buffer */
char *osav; /**< Saved pointer to output buffer */
#endif
+ char description[SIZ] = "";
char buf[SIZ];
char date[30];
char from[256];
}
}
}
- // Commented out. Play dumb for now, also doesn't work with anonrss hack
+ /*/ Commented out. Play dumb for now, also doesn't work with anonrss hack */
/* if (if_modified_since > 0 && if_modified_since > now) {
lprintf(3, "RSS: Feed not updated since the last time you looked\n");
hprintf("HTTP/1.1 304 Not Modified\r\n");
gmtime_r(&now, &now_tm);
strftime(date, sizeof date, "%a, %d %b %Y %H:%M:%S GMT", &now_tm);
hprintf("Date: %s\r\n", date);
- if (*msgn) hprintf("ETag: %s\r\n", msgn); */
+ if (*msgn) hprintf("ETag: %s\r\n", msgn); * /
// wDumpContent(0);
// return;
- //}
+ //} */
/* Do RSS header */
lprintf(3, "RSS: Yum yum! This feed is tasty!\n");
svput("XML_STYLE", WCS_STRING, "<?xml-stylesheet type=\"text/css\" href=\"/static/rss_browser.css\" ?>");
svput("ROOM", WCS_STRING, WCC->wc_roomname);
svput("NODE", WCS_STRING, serv_info.serv_humannode);
- // Fix me
+ /* TODO: Fix me */
svprintf(HKEY("ROOM_LINK"), WCS_STRING, "%s://%s/", (is_https ? "https" : "http"), WCC->http_host);
/** Get room info for description */
serv_puts("RINF");
serv_getln(buf, sizeof buf);
- char description[SIZ] = "";
if (buf[0] == '1') {
while (1) {
serv_getln(buf, sizeof buf);
}
ENDBODY:
- //wprintf(" </item>\n");
+ /* wprintf(" </item>\n"); */
do_template("rss_item_end", NULL);
ENDITEM:
now = 0L;
#include "webserver.h"
struct serv_info serv_info; /**< our connection data to the server */
-HashList *ServHash = NULL;//// TODO;
/*
* get info about the server we've connected to
*
/** Activate embedded URL's */
url(buf, sizeof(buf));
- escputs(buf);//// TODO: Target
+ escputs(buf);/*/ TODO: Target */
StrBufAppendBufPlain(Target, HKEY("\n"), 0);
}
if (bq == 1) {
{
if (ChrPtr(Buf)[0] == '6')
{
- StrBufCutLeft(Buf, 4); //thisblock = (size_t)atoi(&buf[4]);
+ StrBufCutLeft(Buf, 4); /*/ TODO : thisblock = (size_t)atoi(&buf[4]); */
thisblock = StrTol(Buf);
if (!WC->connected) {
FlushStrBuf(Ret);
RegisterNamespace("SERV:REV_LEVEL", 0, 0, tmplput_serv_rev_level, CTX_NONE);
RegisterNamespace("SERV:BBS_CITY", 0, 0, tmplput_serv_bbs_city, CTX_NONE);
RegisterNamespace("SERV:MESG", 1, 2, tmplput_mesg, CTX_NONE);
-/// RegisterNamespace("SERV:LDAP_SUPP", 0, 0, tmplput_serv_ldap_enabled, 0);
+/*TODO // RegisterNamespace("SERV:LDAP_SUPP", 0, 0, tmplput_serv_ldap_enabled, 0); */
}
/*@}*/
}
if (!strcasecmp(keyword, "bounceto")) {
+ char *atsign;
extract_token(sender, buf, 1, '|', sizeof sender);
/* Strip off local hostname if it's our own */
- char *atsign;
atsign = strchr(sender, '@');
if (atsign != NULL) {
++atsign;
break;
case TYPE_LONG:
case TYPE_PREFINT:
- break; ///todo: string to text?
+ break; /* todo: string to text? */
case TYPE_GETTEXT:
*Value = _(Tokens->Params[N]->Start);
*len = strlen(*Value);
break;
default:
break;
-//todo log error
+/*/todo log error */
}
}
void *vVar;
/*if (WCC->vars != NULL) PrintHash(WCC->vars, VarPrintTransition, VarPrintEntry);*/
- /// TODO: debricated!
+ /* TODO: depricated! */
if (Tokens->pName[0] == '=') {
DoTemplate(Tokens->pName+1, Tokens->NameEnd - 1, NULL, NULL, 0);
}
-//////TODO: if param[1] == "U" -> urlescape
-/// X -> escputs
+/*/////TODO: if param[1] == "U" -> urlescape
+/// X -> escputs */
/** Page-local variables */
if ((WCC->vars!= NULL) && GetHash(WCC->vars, Tokens->pName, Tokens->NameEnd, &vVar)) {
ptr = (wcsubst*) vVar;
}
-///void PrintTemplate(const char *Key, void *vSubst, int odd)
const char* PrintTemplate(void *vSubst)
{
WCTemplate *Tmpl = vSubst;
long AppendMeLen;
HashHandler *Handler;
void *vVar;
-// much output, since pName is not terminated...
-// lprintf(1,"Doing token: %s\n",Token->pName);
+/* much output, since pName is not terminated...
+ lprintf(1,"Doing token: %s\n",Token->pName);
+*/
switch (Tokens->Flags) {
case SV_GETTEXT:
StrBufAppendPrintf(Target, "<pre>\ndidn't find Template [%s] %ld %ld\n</pre>",
templatename, len,
(long)strlen(templatename));
-/// dbg_PrintHash(Static, PrintTemplate, NULL);
-// PrintHash(Static, VarPrintTransition, PrintTemplate);
+#if 0
+ dbg_PrintHash(Static, PrintTemplate, NULL);
+ PrintHash(Static, VarPrintTransition, PrintTemplate);
+#endif
return;
}
if (vTmpl == NULL)
case WCS_FUNCTION:
return (subst->wcs_function!=NULL);
case WCS_SERVCMD:
- lprintf(1, " -> Server [%s]\n", subst->wcs_value);////todo
+ lprintf(1, " -> Server [%s]\n", subst->wcs_value);/* TODO */
return 1;
case WCS_STRING:
case WCS_STRBUF:
BSort = get_room_pref("sort");
}
else {
- ////todo: nail prefprepend to sort, and lookup this!
+ /*TODO: nail prefprepend to sort, and lookup this! */
}
if (BSort != NULL)
putbstr("SortBy", NewStrBufDup(BSort));
SortOrder = StrTol(Buf);
}
else {
- ////todo: nail prefprepend to sort, and lookup this!
+ /* TODO: nail prefprepend to sort, and lookup this! */
}
if (Buf == NULL)
BSort = get_room_pref("sort");
}
else {
- ////todo: nail prefprepend to sort, and lookup this!
+ /* TODO: nail prefprepend to sort, and lookup this! */
}
}
*SortOrder = StrTol(get_room_pref("SortOrder"));
}
else {
- ////todo: nail prefprepend to sort, and lookup this!
+ /* TODO: nail prefprepend to sort, and lookup this! */
}
}
if (*SortOrder > 2)
--- /dev/null
+
+extern HashList *Conditionals;
+extern HashList *GlobalNS;
+extern HashList *Iterators;
+extern HashList *WirelessTemplateCache;
+extern HashList *WirelessLocalTemplateCache;
+extern HashList *TemplateCache;
+extern HashList *LocalTemplateCache;
+
+
+#define TYPE_STR 1
+#define TYPE_LONG 2
+#define TYPE_PREFSTR 3
+#define TYPE_PREFINT 4
+#define TYPE_GETTEXT 5
+#define TYPE_BSTR 6
+#define MAXPARAM 20
+
+
+/*
+ * \brief Values for wcs_type
+ */
+enum {
+ WCS_STRING, /* its a string */
+ WCS_FUNCTION, /* its a function callback */
+ WCS_SERVCMD, /* its a command to send to the citadel server */
+ WCS_STRBUF, /* its a strbuf we own */
+ WCS_STRBUF_REF, /* its a strbuf we mustn't free */
+ WCS_LONG /* its an integer */
+};
+
+
+
+typedef struct _TemplateParam {
+ const char *Start;
+ int Type;
+ long len;
+ long lvalue;
+} TemplateParam;
+
+/* make a template token a lookup key: */
+#define TKEY(a) Tokens->Params[a]->Start, Tokens->Params[a]->len
+typedef struct _TemplateToken {
+ const StrBuf *FileName; /* Reference to print error messages; not to be freed */
+ StrBuf *FlatToken;
+ long Line;
+ const char *pTokenStart;
+ size_t TokenStart;
+ size_t TokenEnd;
+ const char *pTokenEnd;
+ int Flags;
+ void *PreEval;
+
+ const char *pName;
+ size_t NameEnd;
+
+ int HaveParameters;
+ int nParameters;
+ TemplateParam *Params[MAXPARAM];
+} WCTemplateToken;
+
+typedef void (*WCHandlerFunc)();
+
+
+/*
+ * \brief Dynamic content for variable substitution in templates
+ */
+typedef struct _wcsubst {
+ int wcs_type; /* which type of Substitution are we */
+ char wcs_key[32]; /* copy of our hashkey for debugging */
+ StrBuf *wcs_value; /* if we're a string, keep it here */
+ long lvalue; /* type long? keep data here */
+ int ContextRequired; /* do we require a context type? */
+ WCHandlerFunc wcs_function; /* funcion hook ???*/
+} wcsubst;
+
+#define CTX_NONE 0
+#define CTX_SITECFG 1
+#define CTX_SESSION 2
+#define CTX_INETCFG 3
+#define CTX_VNOTE 4
+#define CTX_WHO 5
+#define CTX_PREF 6
+#define CTX_NODECONF 7
+#define CTX_USERLIST 8
+#define CTX_MAILSUM 9
+#define CTX_MIME_ATACH 10
+#define CTX_STRBUF 12
+#define CTX_LONGVECTOR 13
+
+
+void RegisterNS(const char *NSName, long len,
+ int nMinArgs,
+ int nMaxArgs,
+ WCHandlerFunc HandlerFunc,
+ int ContextRequired);
+#define RegisterNamespace(a, b, c, d, e) RegisterNS(a, sizeof(a)-1, b, c, d, e)
+
+typedef int (*WCConditionalFunc)(WCTemplateToken *Token, void *Context, int ContextType);
+typedef struct _ConditionalStruct {
+ const char *PlainName;
+ int nParams;
+ int ContextRequired;
+ WCConditionalFunc CondF;
+} ConditionalStruct;
+void RegisterConditional(const char *Name, long len,
+ int nParams,
+ WCConditionalFunc CondF,
+ int ContextRequired);
+
+
+
+typedef void (*SubTemplFunc)(StrBuf *TemplBuffer, void *Context, WCTemplateToken *Token);
+typedef HashList *(*RetrieveHashlistFunc)(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType);
+typedef void (*HashDestructorFunc) (HashList **KillMe);
+void RegisterITERATOR(const char *Name, long len, /* Our identifier */
+ int AdditionalParams, /* doe we use more parameters? */
+ HashList *StaticList, /* pointer to webcit lifetime hashlists */
+ RetrieveHashlistFunc GetHash, /* else retrieve the hashlist by calling this function */
+ SubTemplFunc DoSubTempl, /* call this function on each iteration for svput & friends */
+ HashDestructorFunc Destructor, /* use this function to shut down the hash; NULL if its a reference */
+ int ContextType, /* which context do we provide to the subtemplate? */
+ int XPectContextType); /* which context do we expct to be called in? */
+#define RegisterIterator(a, b, c, d, e, f, g, h) RegisterITERATOR(a, sizeof(a)-1, b, c, d, e, f, g, h)
+
+void GetTemplateTokenString(WCTemplateToken *Tokens,
+ int N,
+ const char **Value,
+ long *len);
+
+
+void SVPut(char *keyname, size_t keylen, int keytype, char *Data);
+#define svput(a, b, c) SVPut(a, sizeof(a) - 1, b, c)
+void SVPutLong(char *keyname, size_t keylen, long Data);
+#define svputlong(a, b) SVPutLong(a, sizeof(a) - 1, b)
+void svprintf(char *keyname, size_t keylen, int keytype, const char *format,...) __attribute__((__format__(__printf__,4,5)));
+void SVPRINTF(char *keyname, int keytype, const char *format,...) __attribute__((__format__(__printf__,3,4)));
+void SVCALLBACK(char *keyname, WCHandlerFunc fcn_ptr);
+void SVCallback(char *keyname, size_t keylen, WCHandlerFunc fcn_ptr);
+#define svcallback(a, b) SVCallback(a, sizeof(a) - 1, b)
+
+void SVPUTBuf(const char *keyname, int keylen, const StrBuf *Buf, int ref);
+#define SVPutBuf(a, b, c); SVPUTBuf(a, sizeof(a) - 1, b, c)
+
+void DoTemplate(const char *templatename, long len, StrBuf *Target, void *Context, int ContextType);
+#define do_template(a, b) DoTemplate(a, sizeof(a) -1, NULL, b, 0);
+void url_do_template(void);
+
+int CompareSubstToToken(TemplateParam *ParamToCompare, TemplateParam *ParamToLookup);
+int CompareSubstToStrBuf(StrBuf *Compare, TemplateParam *ParamToLookup);
+
+void StrBufAppendTemplate(StrBuf *Target,
+ int nArgs,
+ WCTemplateToken *Tokens,
+ void *Context, int ContextType,
+ const StrBuf *Source, int FormatTypeIndex);
+CompareFunc RetrieveSort(long ContextType, const char *OtherPrefix,
+ const char *Default, long ldefault, long DefaultDirection);
+void RegisterSortFunc(const char *name, long len,
+ const char *prepend, long preplen,
+ CompareFunc Forward,
+ CompareFunc Reverse,
+ long ContextType);
+
+void dbg_print_longvector(long *LongVector);
MajorStatus = ChrPtr(Buf)[0];
StrBufCutLeft(Buf, 4);
if (MajorStatus != '2') {
- ///TODO ImportantMessage
+ /*TODO ImportantMessage */
sprintf(error_message,
"<img src=\"static/error.gif\" align=center>"
"%s<br /><br />\n", ChrPtr(Buf));
*/
long unescape_input(char *buf)
{
- int a, b;
+ unsigned int a, b;
char hex[3];
long buflen;
long len;
*target = '\0';
aptr = strbuf;
bptr = target;
- eptr = target + tSize - 6; // our biggest unit to put in...
+ eptr = target + tSize - 6; /* our biggest unit to put in... */
while ((bptr < eptr) && !IsEmptyStr(aptr) ){
--- /dev/null
+#ifdef ENABLE_NLS
+void initialize_locales(void);
+void ShutdownLocale(void);
+#endif
+void TmplGettext(StrBuf *Target, int nTokens, WCTemplateToken *Token);
+void offer_languages(StrBuf *Target, int nArgs, WCTemplateToken *Token, void *Context, int ContextType);
+void set_selected_language(const char *);
+void go_selected_language(void);
+void stop_selected_language(void);
+void preset_locale(void);
+void httplang_to_locale(StrBuf *LocaleString);
} else if (strstr(user_agent, "Opera Mobi") != NULL) {
return 1;
} else if (strstr(user_agent, "Firefox/2.0.0 Opera 9.51 Beta") != NULL) {
- // For some reason a new install of Opera 9.51beta decided to spoof.
+ /* For some reason a new install of Opera 9.51beta decided to spoof. */
return 1;
}
return 0;
index[a] = arg[a-1];
sizes[a] = sizeof arg[a-1];
}
-//// index[9] = &foo; todo
+/*/// index[9] = &foo; todo */
nBackDots = 0;
nEmpty = 0;
for ( a = 0; a < 9; ++a)
}
}
}
-////////todo: restore language in this case
+/*///////todo: restore language in this case */
/*
* Functions which can be performed without logging in
*/
#undef PACKAGE_BUGREPORT
#include "sysdep.h"
-////////#include "hash.h"
+#include "subst.h"
+#include "wc_gettext.h"
+#include "messages.h"
+#include "paramhandling.h"
+#include "preferences.h"
+
#ifdef HAVE_OPENSSL
/* Work around RedHat's b0rken OpenSSL includes */
};
-#define TYPE_STR 1
-#define TYPE_LONG 2
-#define TYPE_PREFSTR 3
-#define TYPE_PREFINT 4
-#define TYPE_GETTEXT 5
-#define TYPE_BSTR 6
-#define MAXPARAM 20
-
-
-typedef struct _TemplateParam {
- const char *Start;
- int Type;
- long len;
- long lvalue;
-} TemplateParam;
-
-/* make a template token a lookup key: */
-#define TKEY(a) Tokens->Params[a]->Start, Tokens->Params[a]->len
-typedef struct _TemplateToken {
- const StrBuf *FileName; /* Reference to print error messages; not to be freed */
- StrBuf *FlatToken;
- long Line;
- const char *pTokenStart;
- size_t TokenStart;
- size_t TokenEnd;
- const char *pTokenEnd;
- int Flags;
- void *PreEval;
-
- const char *pName;
- size_t NameEnd;
-
- int HaveParameters;
- int nParameters;
- TemplateParam *Params[MAXPARAM];
-} WCTemplateToken;
-
-typedef void (*WCHandlerFunc)();
-
-
-/*
- * \brief Dynamic content for variable substitution in templates
- */
-typedef struct _wcsubst {
- int wcs_type; /* which type of Substitution are we */
- char wcs_key[32]; /* copy of our hashkey for debugging */
- StrBuf *wcs_value; /* if we're a string, keep it here */
- long lvalue; /* type long? keep data here */
- int ContextRequired; /* do we require a context type? */
- WCHandlerFunc wcs_function; /* funcion hook ???*/
-} wcsubst;
-
-#define CTX_NONE 0
-#define CTX_SITECFG 1
-#define CTX_SESSION 2
-#define CTX_INETCFG 3
-#define CTX_VNOTE 4
-#define CTX_WHO 5
-#define CTX_PREF 6
-#define CTX_NODECONF 7
-#define CTX_USERLIST 8
-#define CTX_MAILSUM 9
-#define CTX_MIME_ATACH 10
-#define CTX_STRBUF 12
-#define CTX_LONGVECTOR 13
-
-
-void RegisterNS(const char *NSName, long len,
- int nMinArgs,
- int nMaxArgs,
- WCHandlerFunc HandlerFunc,
- int ContextRequired);
-#define RegisterNamespace(a, b, c, d, e) RegisterNS(a, sizeof(a)-1, b, c, d, e)
-
-typedef int (*WCConditionalFunc)(WCTemplateToken *Token, void *Context, int ContextType);
-typedef struct _ConditionalStruct {
- const char *PlainName;
- int nParams;
- int ContextRequired;
- WCConditionalFunc CondF;
-} ConditionalStruct;
-void RegisterConditional(const char *Name, long len,
- int nParams,
- WCConditionalFunc CondF,
- int ContextRequired);
-
-
-
-typedef void (*SubTemplFunc)(StrBuf *TemplBuffer, void *Context, WCTemplateToken *Token);
-typedef HashList *(*RetrieveHashlistFunc)(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType);
-typedef void (*HashDestructorFunc) (HashList **KillMe);
-void RegisterITERATOR(const char *Name, long len, /* Our identifier */
- int AdditionalParams, /* doe we use more parameters? */
- HashList *StaticList, /* pointer to webcit lifetime hashlists */
- RetrieveHashlistFunc GetHash, /* else retrieve the hashlist by calling this function */
- SubTemplFunc DoSubTempl, /* call this function on each iteration for svput & friends */
- HashDestructorFunc Destructor, /* use this function to shut down the hash; NULL if its a reference */
- int ContextType, /* which context do we provide to the subtemplate? */
- int XPectContextType); /* which context do we expct to be called in? */
-#define RegisterIterator(a, b, c, d, e, f, g, h) RegisterITERATOR(a, sizeof(a)-1, b, c, d, e, f, g, h)
-
-void GetTemplateTokenString(WCTemplateToken *Tokens,
- int N,
- const char **Value,
- long *len);
-
-
-void SVPut(char *keyname, size_t keylen, int keytype, char *Data);
-#define svput(a, b, c) SVPut(a, sizeof(a) - 1, b, c)
-void SVPutLong(char *keyname, size_t keylen, long Data);
-#define svputlong(a, b) SVPutLong(a, sizeof(a) - 1, b)
-void svprintf(char *keyname, size_t keylen, int keytype, const char *format,...) __attribute__((__format__(__printf__,4,5)));
-void SVPRINTF(char *keyname, int keytype, const char *format,...) __attribute__((__format__(__printf__,3,4)));
-void SVCALLBACK(char *keyname, WCHandlerFunc fcn_ptr);
-void SVCallback(char *keyname, size_t keylen, WCHandlerFunc fcn_ptr);
-#define svcallback(a, b) SVCallback(a, sizeof(a) - 1, b)
-
-void SVPUTBuf(const char *keyname, int keylen, const StrBuf *Buf, int ref);
-#define SVPutBuf(a, b, c); SVPUTBuf(a, sizeof(a) - 1, b, c)
-
-void DoTemplate(const char *templatename, long len, StrBuf *Target, void *Context, int ContextType);
-#define do_template(a, b) DoTemplate(a, sizeof(a) -1, NULL, b, 0);
-void url_do_template(void);
-
-int CompareSubstToToken(TemplateParam *ParamToCompare, TemplateParam *ParamToLookup);
-int CompareSubstToStrBuf(StrBuf *Compare, TemplateParam *ParamToLookup);
-
-void StrBufAppendTemplate(StrBuf *Target,
- int nArgs,
- WCTemplateToken *Tokens,
- void *Context, int ContextType,
- const StrBuf *Source, int FormatTypeIndex);
-CompareFunc RetrieveSort(long ContextType, const char *OtherPrefix,
- const char *Default, long ldefault, long DefaultDirection);
-void RegisterSortFunc(const char *name, long len,
- const char *prepend, long preplen,
- CompareFunc Forward,
- CompareFunc Reverse,
- long ContextType);
-
-void dbg_print_longvector(long *LongVector);
-
-/*
- * \brief Values for wcs_type
- */
-enum {
- WCS_STRING, /* its a string */
- WCS_FUNCTION, /* its a function callback */
- WCS_SERVCMD, /* its a command to send to the citadel server */
- WCS_STRBUF, /* its a strbuf we own */
- WCS_STRBUF_REF, /* its a strbuf we mustn't free */
- WCS_LONG /* its an integer */
-};
-
-
-
-typedef struct wc_mime_attachment wc_mime_attachment;
-typedef void (*RenderMimeFunc)(wc_mime_attachment *Mime, StrBuf *RawData, StrBuf *FoundCharset);
-struct wc_mime_attachment {
- int level;
- StrBuf *Name;
- StrBuf *FileName;
- StrBuf *PartNum;
- StrBuf *Disposition;
- StrBuf *ContentType;
- StrBuf *Charset;
- StrBuf *Data;
- size_t length; /* length of the mimeatachment */
- long size_known;
- long lvalue; /* if we put a long... */
- long msgnum; /**< the message number on the citadel server derived from message_summary */
- RenderMimeFunc Renderer;
-};
-void DestroyMime(void *vMime);
-
-
-/*
- * \brief message summary structure. ???
- */
-typedef struct _message_summary {
- time_t date; /**< its creation date */
- long msgnum; /**< the message number on the citadel server */
- int nhdr;
- int format_type;
- StrBuf *from; /**< the author */
- StrBuf *to; /**< the recipient */
- StrBuf *subj; /**< the title / subject */
- StrBuf *reply_inreplyto;
- StrBuf *reply_references;
- StrBuf *reply_to;
- StrBuf *cccc;
- StrBuf *hnod;
- StrBuf *AllRcpt;
- StrBuf *Room;
- StrBuf *Rfca;
- StrBuf *OtherNode;
- const StrBuf *PartNum;
-
- HashList *Attachments; /**< list of Accachments */
- HashList *Submessages;
- HashList *AttachLinks;
-
- HashList *AllAttach;
-
- int is_new; /**< is it yet read? */
- int hasattachments; /* does it have atachments? */
-
-
- /** The mime part of the message */
- wc_mime_attachment *MsgBody;
-} message_summary;
-void DestroyMessageSummary(void *vMsg);
-inline message_summary* GetMessagePtrAt(int n, HashList *Summ);
-typedef void (*ExamineMsgHeaderFunc)(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset);
-void evaluate_mime_part(message_summary *Msg, wc_mime_attachment *Mime);
extern int follow_xff;
extern HashList *HandlerHash;
extern HashList *PreferenceHooks;
-extern HashList *WirelessTemplateCache;
-extern HashList *WirelessLocalTemplateCache;
-extern HashList *TemplateCache;
-extern HashList *LocalTemplateCache;
-extern HashList *GlobalNS;
-extern HashList *Iterators;
extern HashList *ZoneHash;
-extern HashList *Conditionals;
-extern HashList *MsgHeaderHandler;
-extern HashList *MimeRenderHandler;
extern HashList *SortHash;
void InitialiseSemaphores(void);
-/* URL / Mime Post parsing -> paramhandling.c */
-void upload_handler(char *name, char *filename, char *partnum, char *disp,
- void *content, char *cbtype, char *cbcharset,
- size_t length, char *encoding, char *cbid, void *userdata);
-
-void ParseURLParams(StrBuf *url);
-
-
-/* These may return NULL if not foud */
-#define sbstr(a) SBstr(a, sizeof(a) - 1)
-const StrBuf *SBSTR(const char *key);
-const StrBuf *SBstr(const char *key, size_t keylen);
-
-#define xbstr(a, b) (char*) XBstr(a, sizeof(a) - 1, b)
-const char *XBstr(const char *key, size_t keylen, size_t *len);
-const char *XBSTR(const char *key, size_t *len);
-
-#define lbstr(a) LBstr(a, sizeof(a) - 1)
-long LBstr(const char *key, size_t keylen);
-long LBSTR(const char *key);
-
-#define ibstr(a) IBstr(a, sizeof(a) - 1)
-int IBstr(const char *key, size_t keylen);
-int IBSTR(const char *key);
-
-#define havebstr(a) HaveBstr(a, sizeof(a) - 1)
-int HaveBstr(const char *key, size_t keylen);
-int HAVEBSTR(const char *key);
-
-#define yesbstr(a) YesBstr(a, sizeof(a) - 1)
-int YesBstr(const char *key, size_t keylen);
-int YESBSTR(const char *key);
-
-/* TODO: get rid of the non-const-typecast */
-#define bstr(a) (char*) Bstr(a, sizeof(a) - 1)
-const char *BSTR(const char *key);
-const char *Bstr(const char *key, size_t keylen);
-/* if you want to ease some parts by just parametring yourself... */
-#define putbstr(a, b) PutBstr(a, sizeof(a) - 1, b)
-void PutBstr(const char *key, long keylen, StrBuf *Value);
-
void UrlescPutStrBuf(const StrBuf *strbuf);
void embed_main_menu(void);
void serv_read(char *buf, int bytes);
-enum {
- do_search,
- headers,
- readfwd,
- readnew,
- readold
-};
-
-typedef void (*readloop_servcmd)(char *buf, long bufsize);
-
-typedef struct _readloopstruct {
- ConstStr name;
- readloop_servcmd cmd;
-} readloop_struct;
void SetAccessCommand(long Oper);
-void readloop(long oper);
-int read_message(StrBuf *Target, const char *tmpl, long tmpllen, long msgnum, int printable_view, const StrBuf *section);
void do_addrbook_view(addrbookent *addrbook, int num_ab);
void fetch_ab_name(message_summary *Msg, char *namebuf);
void display_vcard(StrBuf *Target, const char *vcard_source, char alpha, int full, char *storename, long msgnum);
void folders(void);
-void load_preferences(void);
-void save_preferences(void);
-#define get_preference(a, b) get_PREFERENCE(a, sizeof(a) - 1, b)
-#define get_pref(a, b) get_PREFERENCE(ChrPtr(a), StrLength(a), b)
-int get_PREFERENCE(const char *key, size_t keylen, StrBuf **value);
-#define set_preference(a, b, c) set_PREFERENCE(a, sizeof(a) - 1, b, c)
-#define set_pref(a, b, c) set_PREFERENCE(ChrPtr(a), StrLength(a), b, c)
-void set_PREFERENCE(const char *key, size_t keylen, StrBuf *value, int save_to_server);
-
-#define get_pref_long(a, b, c) get_PREF_LONG(a, sizeof(a) - 1, b, c)
-int get_PREF_LONG(const char *key, size_t keylen, long *value, long Default);
-#define set_pref_long(a, b, c) set_PREF_LONG(a, sizeof(a) - 1, b, c)
-void set_PREF_LONG(const char *key, size_t keylen, long value, int save_to_server);
-
-#define get_pref_yesno(a, b, c) get_PREF_YESNO(a, sizeof(a) - 1, b, c)
-int get_PREF_YESNO(const char *key, size_t keylen, int *value, int Default);
-#define set_pref_yesno(a, b, c) set_PREF_YESNO(a, sizeof(a) - 1, b, c)
-void set_PREF_YESNO(const char *key, size_t keylen, int value, int save_to_server);
-
-#define get_room_pref(a) get_ROOM_PREFS(a, sizeof(a) - 1)
-StrBuf *get_ROOM_PREFS(const char *key, size_t keylen);
-
-#define set_room_pref(a, b, c) set_ROOM_PREFS(a, sizeof(a) - 1, b, c)
-void set_ROOM_PREFS(const char *key, size_t keylen, StrBuf *value, int save_to_server);
void display_addressbook(long msgnum, char alpha);
void offer_start_page(StrBuf *Target, int nArgs, WCTemplateToken *Token, void *Context, int ContextType);
void render_calendar_view(struct calview *c);
void do_tasks_view(void);
void calendar_summary_view(void);
-int load_msg_ptrs(char *servcmd, int with_headers);
-void free_attachments(wcsession *sess);
void free_march_list(wcsession *wcf);
void display_rules_editor_inner_div(void);
void generate_uuid(char *);
struct icaltimetype t2end
);
-#ifdef ENABLE_NLS
-void initialize_locales(void);
-void ShutdownLocale(void);
-#endif
-void TmplGettext(StrBuf *Target, int nTokens, WCTemplateToken *Token);
extern char *months[];
extern char *days[];
int read_server_binary(StrBuf *Ret, size_t total_len);
int StrBuf_ServGetBLOB(StrBuf *buf, long BlobSize);
-int read_server_text(StrBuf *Buf, long *nLines);;
+int read_server_text(StrBuf *Buf, long *nLines);
int goto_config_room(void);
long locate_user_vcard(char *username, long usernum);
void sleeeeeeeeeep(int);
void do_selected_iconbar(void);
void spawn_another_worker_thread(void);
void display_rss(char *roomname, StrBuf *request_method);
-void offer_languages(StrBuf *Target, int nArgs, WCTemplateToken *Token, void *Context, int ContextType);
-void set_selected_language(const char *);
-void go_selected_language(void);
-void stop_selected_language(void);
-void preset_locale(void);
-void httplang_to_locale(StrBuf *LocaleString);
void StrEndTab(StrBuf *Target, int tabnum, int num_tabs);
void StrBeginTab(StrBuf *Target, int tabnum, int num_tabs);
void StrTabbedDialog(StrBuf *Target, int num_tabs, StrBuf *tabnames[]);
const char *get_selected_language(void);
void webcit_fmt_date(char *buf, time_t thetime, int brief);
int fetch_http(char *url, char *target_buf, int maxbytes);
+void free_attachments(wcsession *sess);
int is_mobile_ua(char *user_agent);
void client_write_ssl(const StrBuf *Buf);
#endif
-#ifdef HAVE_ZLIB
-#include <zlib.h>
-int ZEXPORT compress_gzip(Bytef * dest, size_t * destLen,
- const Bytef * source, uLong sourceLen, int level);
-#endif
-
void utf8ify_rfc822_string(char *buf);
void begin_burst(void);
(retval >= 0))
retval = client_read_sslbuffer(Buf, timeout);
if (retval >= 0) {
- StrBufAppendBuf(Target, Buf, 0); /// todo: Buf > bytes?
+ StrBufAppendBuf(Target, Buf, 0); /* todo: Buf > bytes? */
#ifdef HTTP_TRACING
write(2, "\033[32m", 5);
write(2, buf, bytes);
}
#endif
- if (StrLength(Buf) > 0) {//// todo: what if Buf > bytes?
+ if (StrLength(Buf) > 0) {/*/// todo: what if Buf > bytes?*/
StrBufAppendBuf(Target, Buf, 0);
}
retval = StrBufReadBLOB(Target,
}
-/*
- * Get a LF-terminated line of text from the client.
- * (This is implemented in terms of client_read() and could be
- * justifiably moved out of sysdep.c)
- *
- * sock socket fd to get client line from
- * buf buffer to write read data to
- * bufsiz how many bytes to read
- *
- * returns the number of bytes read
- */
-/////int client_getln(int *sock, char *buf, int bufsiz)
-/////{
-///// int i, retval;
-/////
-///// /* Read one character at a time.*/
-///// for (i = 0; *sock > 0; i++) {
-///// retval = client_read(sock, &buf[i], 1);
-///// if (retval < 0)
-///// return retval;
-///// if (retval != 1 || buf[i] == '\n' || i == (bufsiz-1))
-///// break;
-///// if ( (!isspace(buf[i])) && (!isprint(buf[i])) ) {
-///// /* Non printable character recieved from client */
-///// return(-1);
-///// }
-///// }
-/////
-///// /* If we got a long line, discard characters until the newline. */
-///// if (i == (bufsiz-1))
-///// while (buf[i] != '\n' && retval == 1)
-///// retval = client_read(sock, &buf[i], 1);
-/////
-///// /*
-///// * Strip any trailing non-printable characters.
-///// */
-///// buf[i] = 0;
-///// while ((i > 0) && (!isprint(buf[i - 1]))) {
-///// buf[--i] = 0;
-///// }
-///// return (retval);
-/////}
/*
* Shut us down the regular way.
*/
pid_t current_child;
void graceful_shutdown(int signum) {
-// kill(current_child, signum);
char wd[SIZ];
FILE *FD;
int fd;
exit(errno);
}
- else if (current_child == 0) { // child process
-// signal(SIGTERM, graceful_shutdown);
+ else if (current_child == 0) { /* child process */
signal(SIGHUP, graceful_shutdown);
return; /* continue starting webcit. */
}
-
- else { // watcher process
-// signal(SIGTERM, SIG_IGN);
-// signal(SIGHUP, SIG_IGN);
+ else { /* watcher process */
if (pid_file) {
fp = fopen(pid_file, "w");
if (fp != NULL) {
pthread_attr_destroy(&attr);
}
-//#define DBG_PRINNT_HOOKS_AT_START
+/* #define DBG_PRINNT_HOOKS_AT_START */
#ifdef DBG_PRINNT_HOOKS_AT_START
const char foobuf[32];
const char *nix(void *vptr) {snprintf(foobuf, 32, "%0x", (long) vptr); return foobuf;}
start_daemon(pidfile);
}
else {
-/// signal(SIGTERM, graceful_shutdown);
signal(SIGHUP, graceful_shutdown);
}
if (msock > 0) ret = select(msock+1, &tempset, NULL, NULL, &tv);
end_critical_section(S_SELECT);
if ((ret < 0) && (errno != EINTR) && (errno != EAGAIN))
- {// EINTR and EAGAIN are thrown but not of interest.
+ {/* EINTR and EAGAIN are thrown but not of interest. */
lprintf(2, "accept() failed:%d %s\n",
errno, strerror(errno));
}
else if ((ret > 0) && (msock > 0) && FD_ISSET(msock, &tempset))
- {// Successfully selected, and still not shutting down? Accept!
+ {/* Successfully selected, and still not shutting down? Accept! */
ssock = accept(msock, NULL, 0);
}
} while ((msock > 0) && (ssock < 0) && (time_to_die == 0));
if ((msock == -1)||(time_to_die))
- {// ok, we're going down.
+ {/* ok, we're going down. */
int shutdown = 0;
/* the first to come here will have to do the cleanup.
}
end_critical_section(S_SHUTDOWN);
if (shutdown == 1)
- {// we're the one to cleanup the mess.
+ {/* we're the one to cleanup the mess. */
lprintf(2, "I'm master shutdown: tagging sessions to be killed.\n");
shutdown_sessions();
lprintf(2, "master shutdown: waiting for others\n");
- sleeeeeeeeeep(1); // wait so some others might finish...
+ sleeeeeeeeeep(1); /* wait so some others might finish... */
lprintf(2, "master shutdown: cleaning up sessions\n");
do_housekeeping();
lprintf(2, "master shutdown: cleaning up libical\n");
if (ssock > 0) close (ssock);
lprintf(2, "inbetween.");
pthread_exit(NULL);
- } else { // Got it? do some real work!
+ } else { /* Got it? do some real work! */
/* Set the SO_REUSEADDR socket option */
i = 1;
setsockopt(ssock, SOL_SOCKET, SO_REUSEADDR,
serv_printf("TERM %s", bstr("which_session"));
serv_getln(buf, sizeof buf);
- ///who();
url_do_template();
}