#define PORT_NUM 2000 /* port number to listen on */
#define DEVELOPER_ID 0
#define CLIENT_ID 4
-#define CLIENT_VERSION 737 /* This version of WebCit */
-#define MINIMUM_CIT_VERSION 737 /* min required Citadel ver */
-#define LIBCITADEL_MIN 738 /* min required libcitadel ver */
+#define CLIENT_VERSION 739 /* This version of WebCit */
+#define MINIMUM_CIT_VERSION 739 /* min required Citadel ver */
+#define LIBCITADEL_MIN 739 /* min required libcitadel ver */
#define DEFAULT_HOST "localhost" /* Default Citadel server */
#define DEFAULT_PORT "504"
#define TARGET "webcit01" /* Target for inline URL's */
#define NLI "(not logged in)"
-/** \brief Linked list of lines appearing in an HTTP client request */
-struct httprequest {
- struct httprequest *next; /**< the next request in the list */
- char line[SIZ]; /**< the request line */
-};
-
/**
* \brief Linked list of session variables encoded in an x-www-urlencoded content type
*/
};
-
-/**
- * \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 */
- void (*wcs_function)(void); /**< funcion hook ???*/
-} wcsubst;
-
#define TYPE_STR 1
#define TYPE_LONG 2
-#define MAXPARAM 10
+#define MAXPARAM 20
typedef struct _TemplateParam {
const char *Start;
int Type;
} TemplateParam;
typedef struct _TemplateToken {
+ 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;
TemplateParam *Params[MAXPARAM];
} WCTemplateToken;
+typedef void (*WCHandlerFunc)(StrBuf *Target, int nArgs, WCTemplateToken *Token, void *Context, int ContextType);
+
+
+/**
+ * \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
+
-typedef void (*WCHandlerFunc)(StrBuf *Target, int nArgs, WCTemplateToken *Token, void *Context);
void RegisterNS(const char *NSName, long len,
int nMinArgs,
int nMaxArgs,
- WCHandlerFunc HandlerFunc);
-#define RegisterNamespace(a, b, c, d) RegisterNS(a, sizeof(a)-1, b, c, d)
+ 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);
+typedef int (*WCConditionalFunc)(WCTemplateToken *Token, void *Context, int ContextType);
typedef struct _ConditionalStruct {
int nParams;
+ int ContextRequired;
WCConditionalFunc CondF;
} ConditionalStruct;
void RegisterConditional(const char *Name, long len,
int nParams,
- WCConditionalFunc CondF);
+ WCConditionalFunc CondF,
+ int ContextRequired);
-typedef void (*SubTemplFunc)(StrBuf *TemplBuffer, void *Context);
-typedef HashList *(*RetrieveHashlistFunc)(void);
-typedef void (*HashDestructorFunc) (HashList *KillMe);
-void RegisterITERATOR(const char *Name, long len,
+typedef void (*SubTemplFunc)(StrBuf *TemplBuffer, void *Context, WCTemplateToken *Token);
+typedef HashList *(*RetrieveHashlistFunc)(WCTemplateToken *Token);
+typedef void (*HashDestructorFunc) (HashList **KillMe);
+void RegisterITERATOR(const char *Name, long len,
+ int AdditionalParams,
HashList *StaticList,
RetrieveHashlistFunc GetHash,
SubTemplFunc DoSubTempl,
- HashDestructorFunc Destructor);
-#define RegisterIterator(a, b, c, d, e) RegisterITERATOR(a, sizeof(a)-1, b, c, d, e)
+ HashDestructorFunc Destructor,
+ int ContextType);
+#define RegisterIterator(a, b, c, d, e, f, g) RegisterITERATOR(a, sizeof(a)-1, b, c, d, e, f, g)
+
+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, void *Context, StrBuf *Target, int ContextType);
+#define do_template(a, b) DoTemplate(a, sizeof(a) -1, b, NULL, 0);
+void url_do_template(void);
+
+int CompareSubstToToken(TemplateParam *ParamToCompare, TemplateParam *ParamToLookup);
+int CompareSubstToStrBuf(StrBuf *Compare, TemplateParam *ParamToLookup);
+
+
/**
StrBuf *UrlFragment2; /**< second urlfragment, if NEED_URL is specified by the handler*/
StrBuf *WBuf; /**< Our output buffer */
StrBuf *HBuf; /**< Our HeaderBuffer */
+ StrBuf *CLineBuf; /**< linebuffering client stuff */
+
+ HashList *ServCfg; /**< cache our server config for editing */
+ HashList *InetCfg; /**< Our inet server config for editing */
};
/** values for WC->current_iconbar */
void stuff_to_cookie(char *cookie, size_t clen, int session,
char *user, char *pass, char *room);
-void cookie_to_stuff(char *cookie, int *session,
+void cookie_to_stuff(StrBuf *cookie, int *session,
char *user, size_t user_len,
char *pass, size_t pass_len,
char *room, size_t room_len);
void pullquote_fmout(void);
void wDumpContent(int);
-
/* 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(char *key, size_t keylen, size_t *len);
-const char *XBSTR(char *key, size_t *len);
+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(char *key, size_t keylen);
-long LBSTR(char *key);
+long LBstr(const char *key, size_t keylen);
+long LBSTR(const char *key);
#define ibstr(a) IBstr(a, sizeof(a) - 1)
-int IBstr(char *key, size_t keylen);
-int IBSTR(char *key);
+int IBstr(const char *key, size_t keylen);
+int IBSTR(const char *key);
#define havebstr(a) HaveBstr(a, sizeof(a) - 1)
-int HaveBstr(char *key, size_t keylen);
-int HAVEBSTR(char *key);
+int HaveBstr(const char *key, size_t keylen);
+int HAVEBSTR(const char *key);
#define yesbstr(a) YesBstr(a, sizeof(a) - 1)
-int YesBstr(char *key, size_t keylen);
-int YESBSTR(char *key);
+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(char *key);
-const char *Bstr(char *key, size_t keylen);
+const char *BSTR(const char *key);
+const char *Bstr(const char *key, size_t keylen);
void serv_gets(char *strbuf);
void serv_write(const char *buf, int nbytes);
void serv_puts(const char *string);
+void serv_putbuf(const StrBuf *string);
void serv_printf(const char *format,...)__attribute__((__format__(__printf__,1,2)));
void load_floorlist(void);
void shutdown_sessions(void);
void do_housekeeping(void);
void smart_goto(char *);
void worker_entry(void);
-void session_loop(struct httprequest *);
+void session_loop(HashList *HTTPHeaders, StrBuf *ReqLine, StrBuf *ReqType, StrBuf *ReadBuf);
size_t wc_strftime(char *s, size_t max, const char *format, const struct tm *tm);
void fmt_time(char *buf, time_t thetime);
void httpdate(char *buf, time_t thetime);
-time_t httpdate_to_timestamp(char *buf);
+time_t httpdate_to_timestamp(StrBuf *buf);
void end_webcit_session(void);
void page_popup(void);
void http_redirect(const char *);
void clear_local_substs(void);
-typedef void (*var_callback_fptr)();
-
-
-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, var_callback_fptr fcn_ptr);
-void SVCallback(char *keyname, size_t keylen, var_callback_fptr fcn_ptr);
-#define svcallback(a, b) SVCallback(a, sizeof(a) - 1, b)
-
-void SVPUTBuf(const char *keyname, int keylen, StrBuf *Buf, int ref);
-#define SVPutBuf(a, b, c); SVPUTBuf(a, sizeof(a) - 1, b, c)
-
-void DoTemplate(const char *templatename, long len, void *Context, StrBuf *Target);
-#define do_template(a, b) DoTemplate(a, sizeof(a) -1, b, NULL);
-
int lingering_close(int fd);
char *memreadline(char *start, char *buf, int maxlen);
int is_msg_in_mset(char *mset, long msgnum);
void display_addressbook(long msgnum, char alpha);
-void offer_start_page(void);
+void offer_start_page(StrBuf *Target, int nArgs, WCTemplateToken *Token, void *Context, int ContextType);
void convenience_page(char *titlebarcolor, char *titlebarmsg, char *messagetext);
void output_html(char *, int);
void do_listsub(void);
void partstat_as_string(char *buf, icalproperty *attendee);
icalcomponent *ical_encapsulate_subcomponent(icalcomponent *subcomp);
void check_attendee_availability(icalcomponent *supplied_vevent);
-void do_freebusy(char *req);
+void do_freebusy(const char *req);
int ical_ctdl_is_overlap(
struct icaltimetype t1start,
struct icaltimetype t1end,
void do_selected_iconbar(void);
int CtdlDecodeQuotedPrintable(char *decoded, char *encoded, int sourcelen);
void spawn_another_worker_thread(void);
-void display_rss(char *roomname, char *request_method);
-void offer_languages(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(char *LocaleString);
+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[]);
void tabbed_dialog(int num_tabs, char *tabnames[]);
void begin_tab(int tabnum, int num_tabs);
void end_tab(int tabnum, int num_tabs);
void str_wiki_index(char *s);
int get_time_format_cached (void);
-int xtoi(char *in, size_t len);
+int xtoi(const char *in, size_t len);
void webcit_fmt_date(char *buf, time_t thetime, int brief);
int fetch_http(char *url, char *target_buf, int maxbytes);
void ssl_lock(int mode, int n, const char *file, int line);
int starttls(int sock);
extern SSL_CTX *ssl_ctx;
-int client_read_ssl(char *buf, int bytes, int timeout);
+int client_read_sslbuffer(StrBuf *buf, int timeout);
void client_write_ssl(const StrBuf *Buf);
#endif