* new longint-vector replacer if you just want to blast some numbers in tiny templates
* urlpart replacers so you can easily reference the actual api-name in templates (actualy needs to be enabled by the registerer of the api callback)
* cleanup and templatize the bbview-selector bar
}
SortByHashKey(List, 1);
- it = GetNewHashPos();
+ it = GetNewHashPos(List, 0);
while (GetNextHashPos(List, it, &len, &VCName, &Namee)) {
wprintf("<option value=\"");
urlescputs((char*)Namee);
}
SortByHashKey(List, 1);
- it = GetNewHashPos();
+ it = GetNewHashPos(List, 0);
while (GetNextHashPos(List, it, &len, &VCName, &Namee)) {
wprintf("<option value=\"");
escputs((char*)Namee);
}
SortByHashKey(List, 1);
- it = GetNewHashPos();
+ it = GetNewHashPos(List, 0);
while (GetNextHashPos(List, it, &len, &VCName, (void**)&Namee)) {
wprintf("<option value=\"");
escputs((char*)Namee);
const char *HKey;
HashPos *Cursor;
- Cursor = GetNewHashPos ();
+ Cursor = GetNewHashPos (WCC->urlstrings, 0);
while (GetNextHashPos(WCC->urlstrings, Cursor, &HKLen, &HKey, &U)) {
u = (urlcontent*) U;
if (!strncasecmp(u->url_key, "openid.", 7)) {
/*
* Now loop through our list of events to see which ones occur today.
*/
- Pos = GetNewHashPos();
+ Pos = GetNewHashPos(WCC->disp_cal_items, 0);
while (GetNextHashPos(WCC->disp_cal_items, Pos, &hklen, &HashKey, &vCal)) {
Cal = (disp_cal*)vCal;
all_day_event = 0;
day = today_tm.tm_mday;
year = today_tm.tm_year + 1900;
- Pos = GetNewHashPos();
+ Pos = GetNewHashPos(WCC->disp_cal_items, 0);
while (GetNextHashPos(WCC->disp_cal_items, Pos, &hklen, &HashKey, &vCal)) {
Cal = (disp_cal*)vCal;
p = icalcomponent_get_first_property(Cal->cal, ICAL_DTSTART_PROPERTY);
/* Now loop through our list of events to see which ones occur today.
*/
- Pos = GetNewHashPos();
+ Pos = GetNewHashPos(WCC->disp_cal_items, 0);
while (GetNextHashPos(WCC->disp_cal_items, Pos, &hklen, &HashKey, &vCal)) {
Cal = (disp_cal*)vCal;
now = time(NULL);
localtime_r(&now, &today_tm);
- Pos = GetNewHashPos();
+ Pos = GetNewHashPos(WCC->disp_cal_items, 0);
while (GetNextHashPos(WCC->disp_cal_items, Pos, &hklen, &HashKey, &vCal)) {
Cal = (disp_cal*)vCal;
p = icalcomponent_get_first_property(Cal->cal,
task_completed_cmp);
}
- Pos = GetNewHashPos();
+ Pos = GetNewHashPos(WCC->disp_cal_items, 0);
while (GetNextHashPos(WCC->disp_cal_items, Pos, &hklen, &HashKey, &vCal)) {
Cal = (disp_cal*)vCal;
wprintf("<tr><td>");
return;
}
if (GetCount(Hash) > 0) {
- where = GetNewHashPos();
+ where = GetNewHashPos(Hash, 0);
while (GetNextHashPos(Hash, where, &KeyLen, &Key, &vStr)) {
Str = (StrBuf*) vStr;
if ((Str!= NULL) && (StrLength(Str) > 0))
StrBufAppendBuf(Msg->reply_to, Msg->from, 0);
}
}
- it = GetNewHashPos();
+ it = GetNewHashPos(Msg->AllAttach, 0);
while (GetNextHashPos(Msg->AllAttach, it, &len, &Key, &vMime) &&
(vMime != NULL)) {
wc_mime_attachment *Mime = (wc_mime_attachment*) vMime;
}
+void DrawMessageSummarySelector(StrBuf *BBViewToolBar, long maxmsgs, long startmsg)
+{
+ struct wcsession *WCC = WC;
+ message_summary* Msg;
+ int lo, hi, n;
+ int i = 0;
+ long StartMsg;
+ void *vMsg;
+ long hklen;
+ const char *key;
+ int done = 0;
+ int nItems;
+ HashPos *At;
+ long vector[16];
+ StrBuf *Selector = NewStrBuf();
+
+ At = GetNewHashPos(WCC->summ, (lbstr("SortOrder") == 1)? -maxmsgs : maxmsgs);
+ nItems = GetCount(WCC->summ);
+
+ vector[0] = 7;
+ vector[1] = startmsg;
+ vector[2] = maxmsgs;
+ vector[3] = 0;
+ vector[4] = 1;
+
+ while (!done) {
+ lo = GetHashPosCounter(At);
+ if (lo + maxmsgs > nItems) {
+ hi = nItems;
+ }
+ else {
+ hi = lo + maxmsgs;
+ }
+ done = !GetNextHashPos(WCC->summ, At, &hklen, &key, &vMsg);
+ Msg = (message_summary*) vMsg;
+ n = (Msg==NULL)? 0 : Msg->msgnum;
+ if (i == 0)
+ StartMsg = n;
+ vector[4] = lo;
+ vector[5] = hi;
+ vector[6] = n;
+ FlushStrBuf(BBViewToolBar); /** abuse our target buffer to contstruct one item in it */
+ DoTemplate(HKEY("select_messageindex"), BBViewToolBar, &vector, CTX_LONGVECTOR);
+ StrBufAppendBuf(Selector, BBViewToolBar, 0);
+ i++;
+ }
+ vector[6] = StartMsg;
+ FlushStrBuf(BBViewToolBar);
+ DoTemplate(HKEY("select_messageindex_all"), BBViewToolBar, &vector, CTX_LONGVECTOR);
+ StrBufAppendBuf(Selector, BBViewToolBar, 0);
+
+ FlushStrBuf(BBViewToolBar);
+ DoTemplate(HKEY("msg_listselector"), BBViewToolBar, Selector, CTX_STRBUF);
+ FreeStrBuf(&Selector);
+}
+
+
/*
* command loop for reading messages
*
char buf[SIZ];
char old_msgs[SIZ];
int a = 0;
- int b = 0;
- int n;
+ ///int b = 0;
int nummsgs;
long startmsg = 0;
int maxmsgs;
int is_tasks = 0;
int is_notes = 0;
int is_bbview = 0;
- int lo, hi;
int lowest_displayed = (-1);
int highest_displayed = 0;
addrbookent *addrbook = NULL;
int num_ab = 0;
int bbs_reverse = 0;
- struct wcsession *WCC = WC; /* This is done to make it run faster; WC is a function */
+ struct wcsession *WCC = WC;
HashPos *at;
const char *HashKey;
long HKLen;
}
-
-
-
-
-
output_headers(1, 1, 1, 0, 0, 0);
/*
if (buf[0] == '2') {
strcpy(old_msgs, &buf[4]);
}
- at = GetNewHashPos();
+ at = GetNewHashPos(WCC->summ, 0);
while (GetNextHashPos(WCC->summ, at, &HKLen, &HashKey, &vMsg)) {
/** Are you a new message, or an old message? */
Msg = (message_summary*) vMsg;
* If we're not currently looking at ALL requested
* messages, then display the selector bar
*/
- if (is_bbview) {
- const char *selected;
- StrBuf *Selector = NewStrBuf();
+ if (is_bbview) {
BBViewToolBar = NewStrBuf();
-///// DoTemplate("bbview_scrollbar");
- /** begin bbview scroller */
- StrBufAppendPrintf(BBViewToolBar, "<form name=\"msgomatictop\" class=\"selector_top\" > \n <p>");
- StrBufAppendPrintf(BBViewToolBar, _("Reading #"));//// TODO this isn't used, should it? : , lowest_displayed, highest_displayed);
-
- StrBufAppendPrintf(BBViewToolBar, "<select name=\"whichones\" size=\"1\" "
- "OnChange=\"location.href=msgomatictop.whichones.options"
- "[selectedIndex].value\">\n");
+ maxmsgs = 20; //// todo?
- if (bbs_reverse) {
- for (b=nummsgs-1; b>=0; b = b - maxmsgs) {
- hi = b + 1;
- lo = b - maxmsgs + 2;
- if (lo < 1) lo = 1;
-
- Msg = GetMessagePtrAt(lo-1, WCC->summ);
- n = (Msg==NULL)? 0 : Msg->msgnum;
- selected = ((n == startmsg) ? "selected" : "");
-
- StrBufAppendPrintf(Selector,
- "<option %s value="
- "\"%s"
- "&startmsg=%ld"
- "&maxmsgs=%d"
- "&is_summary=%d\">"
- "%d-%d</option> \n",
- selected,
- oper,
-
-
- maxmsgs,
- is_summary,
- hi, lo);
- }
- }
- else {
- for (b=0; b<nummsgs; b = b + maxmsgs) {
- lo = b + 1;
- hi = b + maxmsgs + 1;
- if (hi > nummsgs) hi = nummsgs;
-
- Msg = GetMessagePtrAt(b, WCC->summ);
- n = (Msg==NULL)? 0 : Msg->msgnum;
- selected = ((n == startmsg) ? "selected" : "");
- Msg = GetMessagePtrAt(lo-1, WCC->summ);
- StrBufAppendPrintf(Selector,
- "<option %s value="
- "\"%s"
- "&startmsg=%ld"
- "&maxmsgs=%d"
- "&is_summary=%d\">"
- "%d-%d</option> \n",
- selected,
- oper,
- (Msg==NULL)? 0 : Msg->msgnum,
- maxmsgs,
- is_summary,
- lo, hi);
- }
- }
-
- StrBufAppendBuf(BBViewToolBar, Selector, 0);
-
- Msg = GetMessagePtrAt(0, WCC->summ);
-
- StrBufAppendPrintf(BBViewToolBar, "<option value=\"%s?startmsg=%ld"
- "&maxmsgs=9999999&is_summary=0\">",
- oper,
- (Msg==NULL)? 0 : Msg->msgnum);
- StrBufAppendPrintf(BBViewToolBar, _("All"));
-
- StrBufAppendPrintf(BBViewToolBar, "</option>");
- StrBufAppendPrintf(BBViewToolBar, "</select> ");
- StrBufAppendPrintf(BBViewToolBar, _("of %d messages."), nummsgs);
-
- /** forward/reverse */
- StrBufAppendPrintf(BBViewToolBar, "<input type=\"radio\" %s name=\"direction\" value=\"\""
- "OnChange=\"location.href='%s?sortby=forward'\"",
- (bbs_reverse ? "" : "checked"),
- oper
- );
- StrBufAppendPrintf(BBViewToolBar, ">");
- StrBufAppendPrintf(BBViewToolBar, _("oldest to newest"));
- StrBufAppendPrintf(BBViewToolBar, " ");
-
- StrBufAppendPrintf(BBViewToolBar, "<input type=\"radio\" %s name=\"direction\" value=\"\""
- "OnChange=\"location.href='%s?sortby=reverse'\"",
- (bbs_reverse ? "checked" : ""),
- oper
- );
- StrBufAppendPrintf(BBViewToolBar, ">");
- StrBufAppendPrintf(BBViewToolBar, _("newest to oldest"));
- StrBufAppendPrintf(BBViewToolBar, "\n");
-
- StrBufAppendPrintf(BBViewToolBar, "</p></form>\n");
+ DrawMessageSummarySelector(BBViewToolBar, maxmsgs, startmsg);
StrBufAppendBuf(WCC->WBuf, BBViewToolBar, 0);
- /** end bbview scroller */
- FreeStrBuf(&Selector);
}
- at = GetNewHashPos();
+ at = GetNewHashPos(WCC->summ, 0);
while (GetNextHashPos(WCC->summ, at, &HKLen, &HashKey, &vMsg)) {
Msg = (message_summary*) vMsg;
if ((Msg->msgnum >= startmsg) && (num_displayed < maxmsgs)) {
HashPos *it;
/* Add in the attachments */
- it = GetNewHashPos();
+ it = GetNewHashPos(WCC->attachments, 0);
while (GetNextHashPos(WCC->attachments, it, &len, &Key, &vAtt)) {
att = (wc_attachment*)vAtt;
encoded_length = ((att->length * 150) / 100);
InitModule_MSG
(void)
{
- WebcitAddUrlHandler(HKEY("readnew"), readnew, 0);
- WebcitAddUrlHandler(HKEY("readold"), readold, 0);
- WebcitAddUrlHandler(HKEY("readfwd"), readfwd, 0);
- WebcitAddUrlHandler(HKEY("headers"), headers, 0);
+ WebcitAddUrlHandler(HKEY("readnew"), readnew, NEED_URL);
+ WebcitAddUrlHandler(HKEY("readold"), readold, NEED_URL);
+ WebcitAddUrlHandler(HKEY("readfwd"), readfwd, NEED_URL);
+ WebcitAddUrlHandler(HKEY("headers"), headers, NEED_URL);
WebcitAddUrlHandler(HKEY("do_search"), do_search, 0);
WebcitAddUrlHandler(HKEY("display_enter"), display_enter, 0);
WebcitAddUrlHandler(HKEY("post"), post_message, 0);
serv_getln(buf, sizeof buf);
if (buf[0] == '4') {
if ((Nodelist != NULL) && (GetCount(Nodelist) > 0)) {
- where = GetNewHashPos();
+ where = GetNewHashPos(Nodelist, 0);
Buf = NewStrBuf();
while (GetNextHashPos(Nodelist, where, &KeyLen, &Key, &vNode)) {
Node = (NodeConf*) vNode;
#ifdef DBG_PREFS_HASH
dbg_PrintHash(Hash, PrintPref, NULL);
#endif
- HashPos = GetNewHashPos();
+ HashPos = GetNewHashPos(Hash, 0);
while (GetNextHashPos(Hash, HashPos, &len, &Key, &Value)!=0)
{
size_t nchars;
--- /dev/null
+<form name="msgomatictop" class="selector_top" >
+<p><?_("Reading #")>
+<select name="whichones" size="1"
+ OnChange="location.href=msgomatictop.whichones.options[selectedIndex].value">
+<?CONTEXTSTR>
+</select>
+
+<input type="radio" name="direction" value=""
+ OnChange="location.href='<?URLPART(1)>?SortBy=date&SortOrder=0'"
+ <?%("COND:BSTR", 1, "SortOrder", 1, "", "checked")>
+>
+<?_("oldest to newest")>
+
+
+
+<input type="radio" name="direction" value=""
+ OnChange="location.href='<?URLPART(1)>?SortBy=date&SortOrder=1'"
+ <?%("COND:BSTR", 1, "SortOrder", 1, "checked", "")>
+>
+<?_("newest to oldest")>
+</p>
+</form>
+
--- /dev/null
+<option <?%("COND:LONGVECTOR", 1, 1, 6, "selected", "")> value="<?URLPART(1)>&startmsg=<?LONGVECTOR(6)>&maxmsgs=<?LONGVECTOR(4)>&is_summary=0&SortBy=date&SortOrder=<?BSTR("SortOrder")>"><?LONGVECTOR(4)>-<?LONGVECTOR(5)></option>
--- /dev/null
+<option <?%("COND:LONGVECTOR", 1, 1, 6, "selected", "")> value="<?URLPART(1)>&startmsg=<?LONGVECTOR(6)>&maxmsgs=9999999&is_summary=0&SortBy=date&SortOrder=<?BSTR("SortOrder")>"><?_("All")></option>
List = It->StaticList;
SubBuf = NewStrBuf();
- it = GetNewHashPos();
+ it = GetNewHashPos(List, 0);
while (GetNextHashPos(List, it, &len, &Key, &vContext)) {
svprintf(HKEY("ITERATE:ODDEVEN"), WCS_STRING, "%s",
(oddeven) ? "odd" : "even");
}
+void tmplput_long_vector(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType)
+{
+ long *LongVector = (long*) Context;
+
+ if ((Tokens->Params[0]->Type == TYPE_LONG) &&
+ (Tokens->Params[0]->lvalue <= LongVector[0]))
+ {
+ StrBufAppendPrintf(Target, "%ld", LongVector[Tokens->Params[0]->lvalue]);
+ }
+ else
+ {
+ if (Tokens->Params[0]->Type == TYPE_LONG) {
+ lprintf(1, "longvector [%s] (in '%s' line %ld); needs a long Parameter![%s]\n",
+ Tokens->Params[0]->Start,
+ ChrPtr(Tokens->FileName),
+ Tokens->Line,
+ ChrPtr(Tokens->FlatToken));
+ StrBufAppendPrintf(
+ Target,
+ "<pre>\nlongvector [%s] (in '%s' line %ld); needs a numerical Parameter!\n[%s]\n</pre>\n",
+ Tokens->Params[0]->Start,
+ ChrPtr(Tokens->FileName),
+ Tokens->Line,
+ ChrPtr(Tokens->FlatToken));
+ }
+ else {
+ lprintf(1, "longvector [%s] (in '%s' line %ld); doesn't have %ld Parameters,"
+ " its just the size of %ld![%s]\n",
+ Tokens->Params[0]->Start,
+ ChrPtr(Tokens->FileName),
+ Tokens->Line,
+ Tokens->Params[0]->lvalue,
+ LongVector[0],
+ ChrPtr(Tokens->FlatToken));
+ StrBufAppendPrintf(
+ Target,
+ "<pre>\nlongvector [%s] (in '%s' line %ld); doesn't have %ld Parameters,"
+ " its just the size of %ld!\n[%s]\n</pre>\n",
+ Tokens->Params[0]->Start,
+ ChrPtr(Tokens->FileName),
+ Tokens->Line,
+ Tokens->Params[0]->lvalue,
+ LongVector[0],
+ ChrPtr(Tokens->FlatToken));
+ }
+ }
+}
+
+
+
+int ConditionalLongVector(WCTemplateToken *Tokens, void *Context, int ContextType)
+{
+ long *LongVector = (long*) Context;
+
+ if ((Tokens->Params[2]->Type == TYPE_LONG) &&
+ (Tokens->Params[2]->lvalue <= LongVector[0])&&
+ (Tokens->Params[3]->Type == TYPE_LONG) &&
+ (Tokens->Params[3]->lvalue <= LongVector[0]))
+ {
+ return LongVector[Tokens->Params[2]->lvalue] == LongVector[Tokens->Params[3]->lvalue];
+ }
+ else
+ {
+ if ((Tokens->Params[2]->Type == TYPE_LONG) ||
+ (Tokens->Params[2]->Type == TYPE_LONG)) {
+ lprintf(1, "ConditionalLongVector [%s] (in '%s' line %ld); needs two long Parameter![%s]\n",
+ Tokens->Params[0]->Start,
+ ChrPtr(Tokens->FileName),
+ Tokens->Line,
+ ChrPtr(Tokens->FlatToken));
+ }
+ else {
+ lprintf(1, "longvector [%s] (in '%s' line %ld); doesn't have %ld / %ld Parameters,"
+ " its just the size of %ld![%s]\n",
+ Tokens->Params[0]->Start,
+ ChrPtr(Tokens->FileName),
+ Tokens->Line,
+ Tokens->Params[2]->lvalue,
+ Tokens->Params[3]->lvalue,
+ LongVector[0],
+ ChrPtr(Tokens->FlatToken));
+ }
+ }
+ return 0;
+}
void
InitModule_SUBST
RegisterNamespace("ITERATE", 2, 100, tmpl_iterate_subtmpl, CTX_NONE);
RegisterNamespace("DOBOXED", 1, 2, tmpl_do_boxed, CTX_NONE);
RegisterNamespace("DOTABBED", 2, 100, tmpl_do_tabbed, CTX_NONE);
+ RegisterNamespace("LONGVECTOR", 1, 1, tmplput_long_vector, CTX_LONGVECTOR);
RegisterConditional(HKEY("COND:SUBST"), 3, ConditionalVar, CTX_NONE);
RegisterConditional(HKEY("COND:CONTEXTSTR"), 3, ConditionalContextStr, CTX_STRBUF);
+ RegisterConditional(HKEY("COND:LONGVECTOR"), 4, ConditionalLongVector, CTX_LONGVECTOR);
}
/*@}*/
wprintf("</i><br />\n");
}
else {
- at = GetNewHashPos();
+ at = GetNewHashPos(WCC->summ, 0);
while (GetNextHashPos(WCC->summ, at, &HKLen, &HashKey, &vMsg)) {
Msg = (message_summary*) vMsg;
display_task(Msg, 0);
wprintf("</i><br />\n");
}
else {
- at = GetNewHashPos();
+ at = GetNewHashPos(WCC->summ, 0);
while (GetNextHashPos(WCC->summ, at, &HKLen, &HashKey, &vMsg)) {
Msg = (message_summary*) vMsg;
load_calendar_item(Msg, 0, &c);
const char *HKey;
HashPos *Cursor;
- Cursor = GetNewHashPos ();
+ Cursor = GetNewHashPos (WCC->urlstrings, 0);
while (GetNextHashPos(WCC->urlstrings, Cursor, &HKLen, &HKey, &U)) {
u = (urlcontent*) U;
wprintf("%38s = %s\n", u->url_key, ChrPtr(u->url_data));
csslocal, 0);
}
+void tmplput_url_part(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType)
+{
+ StrBuf *UrlBuf;
+ struct wcsession *WCC = WC;
+
+ if (WCC != NULL) {
+ if (Tokens->Params[0]->lvalue == 0)
+ UrlBuf = WCC->UrlFragment1;
+ else
+ UrlBuf = WCC->UrlFragment2;
+ StrBufAppendTemplate(Target, nArgs, Tokens, Context, ContextType,
+ UrlBuf, 1);
+ }
+}
RegisterConditional(HKEY("COND:IMPMSG"), 0, ConditionalImportantMesage, CTX_NONE);
RegisterConditional(HKEY("COND:BSTR"), 1, ConditionalBstr, CTX_NONE);
RegisterNamespace("BSTR", 1, 2, tmplput_bstr, CTX_NONE);
+ RegisterNamespace("URLPART", 1, 2, tmplput_url_part, CTX_NONE);
RegisterNamespace("CSSLOCAL", 0, 0, tmplput_csslocal, CTX_NONE);
RegisterNamespace("IMPORTANTMESSAGE", 0, 0, tmplput_importantmessage, CTX_NONE);
RegisterNamespace("OFFERSTARTPAGE", 0, 0, offer_start_page, CTX_NONE);
#define CTX_MIME_ATACH 10
#define CTX_ATT 11
#define CTX_STRBUF 12
+#define CTX_LONGVECTOR 13
+
void RegisterNS(const char *NSName, long len,
int nMinArgs,