\n");
@@ -51,8 +51,7 @@ void display_page(void)
wc_printf(_("Enter message text:"));
wc_printf("
");
- wc_printf("
\n");
+ wc_printf("
\n");
wc_printf("
\n");
@@ -67,8 +66,7 @@ void display_page(void)
/*
* page another user
*/
-void page_user(void)
-{
+void page_user(void) {
char recp[256];
StrBuf *Line;
@@ -76,7 +74,8 @@ void page_user(void)
if (!havebstr("send_button")) {
AppendImportantMessage(_("Message was not sent."), -1);
- } else {
+ }
+ else {
Line = NewStrBuf();
serv_printf("SEXP %s|-", recp);
StrBuf_ServGetln(Line);
@@ -100,12 +99,12 @@ void page_user(void)
* If there are instant messages waiting, and we notice that we haven't checked them in
* a while, it probably means that we need to open the instant messenger window.
*/
-int Conditional_PAGE_WAITING(StrBuf *Target, WCTemplputParams *TP)
-{
+int Conditional_PAGE_WAITING(StrBuf * Target, WCTemplputParams * TP) {
int len;
char buf[SIZ];
/** JavaScript function to alert the user that popups are probably blocked */
+
/** First, do the check as part of our page load. */
serv_puts("NOOP");
len = serv_getln(buf, sizeof buf);
@@ -133,14 +132,11 @@ void ajax_send_instant_message(void) {
serv_puts("000");
}
- escputs(buf); /* doesn't really matter what we return - the client ignores it */
+ escputs(buf); /* doesn't really matter what we return - the client ignores it */
}
-void
-InitModule_PAGING
-(void)
-{
+void InitModule_PAGING(void) {
WebcitAddUrlHandler(HKEY("display_page"), "", 0, display_page, 0);
WebcitAddUrlHandler(HKEY("page_user"), "", 0, page_user, 0);
WebcitAddUrlHandler(HKEY("ajax_send_instant_message"), "", 0, ajax_send_instant_message, AJAX);
@@ -148,9 +144,6 @@ InitModule_PAGING
}
-void
-SessionDestroyModule_PAGING
-(wcsession *sess)
-{
+void SessionDestroyModule_PAGING(wcsession * sess) {
/* nothing here anymore */
}
diff --git a/webcit/paramhandling.c b/webcit/paramhandling.c
index 1e07fcfb3..027a960c4 100644
--- a/webcit/paramhandling.c
+++ b/webcit/paramhandling.c
@@ -1,3 +1,4 @@
+
/*
* parse urlparts and post data
*
@@ -16,12 +17,12 @@
#include "webserver.h"
/* uncomment to see all parameters sent to the server by the browser. */
+
/* #define DEBUG_URLSTRINGS */
-void free_url(void *U)
-{
- urlcontent *u = (urlcontent*) U;
+void free_url(void *U) {
+ urlcontent *u = (urlcontent *) U;
FreeStrBuf(&u->url_data);
if (u->sub != NULL) {
DeleteHash(&u->sub);
@@ -29,27 +30,25 @@ void free_url(void *U)
free(u);
}
-void PutSubstructUrlKey(HashList *list, urlcontent *u, char **keys, long *lengths, int max, int which){
+void PutSubstructUrlKey(HashList * list, urlcontent * u, char **keys, long *lengths, int max, int which) {
void *vUrl;
urlcontent *subu;
HashList *thisList = list;
- if (GetHash(list, keys[which], lengths[which], &vUrl) &&
- (vUrl != NULL))
- {
- subu = (urlcontent*) vUrl;
+ if (GetHash(list, keys[which], lengths[which], &vUrl) && (vUrl != NULL)) {
+ subu = (urlcontent *) vUrl;
if (subu->sub == NULL) {
subu->sub = NewHash(1, NULL);
}
thisList = subu->sub;
- }
+ }
else if (which < max) {
subu = (urlcontent *) malloc(sizeof(urlcontent));
-
+
memcpy(subu->url_key, keys[which], lengths[which]);
subu->klen = lengths[which];
subu->url_data = NULL;
subu->sub = NewHash(1, NULL);
-
+
Put(list, subu->url_key, subu->klen, subu, free_url);
thisList = subu->sub;
}
@@ -61,7 +60,7 @@ void PutSubstructUrlKey(HashList *list, urlcontent *u, char **keys, long *length
}
}
-void PutUrlKey(HashList *urlstrings, urlcontent *u, int have_colons) {
+void PutUrlKey(HashList * urlstrings, urlcontent * u, int have_colons) {
if (have_colons == 0) {
Put(urlstrings, u->url_key, u->klen, u, free_url);
}
@@ -79,12 +78,8 @@ void PutUrlKey(HashList *urlstrings, urlcontent *u, int have_colons) {
pche = u->url_key + u->klen;
while ((i < 10) && (pch <= pche)) {
if ((have_colons == 2) &&
- (*pch == '%') &&
- (*(pch + 1) == '3') &&
- ((*(pch + 2) == 'A') ||
- (*(pch + 1) == 'a')
- ))
- {
+ (*pch == '%') && (*(pch + 1) == '3') && ((*(pch + 2) == 'A') || (*(pch + 1) == 'a')
+ )) {
*pch = '\0';
if (i == 0) {
@@ -101,8 +96,7 @@ void PutUrlKey(HashList *urlstrings, urlcontent *u, int have_colons) {
pchs = pch;
i++;
}
- else if ((have_colons == 1) &&
- (*pch == ':')) {
+ else if ((have_colons == 1) && (*pch == ':')) {
*pch = '\0';
if (i == 0) {
/* Separate the toplevel key : */
@@ -111,12 +105,12 @@ void PutUrlKey(HashList *urlstrings, urlcontent *u, int have_colons) {
/* sub-section: */
keys[i] = pchs;
lengths[i] = pch - pchs;
-
+
pch++;
pchs = pch;
i++;
}
- else if (pch == pche){
+ else if (pch == pche) {
/* sub-section: */
keys[i] = pchs;
lengths[i] = pch - pchs;
@@ -124,10 +118,10 @@ void PutUrlKey(HashList *urlstrings, urlcontent *u, int have_colons) {
break;
}
else {
- pch ++;
+ pch++;
}
}
-
+
PutSubstructUrlKey(urlstrings, u, keys, lengths, i - 1, 0);
}
}
@@ -135,8 +129,7 @@ void PutUrlKey(HashList *urlstrings, urlcontent *u, int have_colons) {
/*
* Extract variables from the URL.
*/
-void ParseURLParams(StrBuf *url)
-{
+void ParseURLParams(StrBuf * url) {
const char *aptr, *bptr, *eptr, *up = NULL;
int len, keylen = 0;
urlcontent *u = NULL;
@@ -154,12 +147,8 @@ void ParseURLParams(StrBuf *url)
if (*aptr == ':') {
have_colon = 1;
}
- else if ((*aptr == '%') &&
- (*(aptr + 1) == '3') &&
- ((*(aptr + 2) == 'A') ||
- (*(aptr + 1) == 'a')
- ))
- {
+ else if ((*aptr == '%') && (*(aptr + 1) == '3') && ((*(aptr + 2) == 'A') || (*(aptr + 1) == 'a')
+ )) {
have_colon = 2;
}
aptr++;
@@ -170,14 +159,14 @@ void ParseURLParams(StrBuf *url)
aptr++;
bptr = aptr;
while ((bptr < eptr) && (*bptr != '\0')
- && (*bptr != '&') && (*bptr != '?') && (*bptr != ' ')) {
+ && (*bptr != '&') && (*bptr != '?') && (*bptr != ' ')) {
bptr++;
}
- keylen = aptr - up - 1; /* -1 -> '=' */
+ keylen = aptr - up - 1; /* -1 -> '=' */
if (keylen > sizeof(u->url_key)) {
syslog(LOG_WARNING, "%s:%d: invalid url_key of size %d in string size %ld",
- __FILE__, __LINE__, keylen, (long)sizeof(u->url_key)
- );
+ __FILE__, __LINE__, keylen, (long) sizeof(u->url_key)
+ );
free(u);
return;
}
@@ -187,23 +176,19 @@ void ParseURLParams(StrBuf *url)
free(u);
return;
}
-
+
u = (urlcontent *) malloc(sizeof(urlcontent));
memcpy(u->url_key, up, keylen);
u->url_key[keylen] = '\0';
u->klen = keylen;
u->sub = NULL;
- if (strncmp(u->url_key, "__", 2) != 0)
- {
+ if (strncmp(u->url_key, "__", 2) != 0) {
len = bptr - aptr;
u->url_data = NewStrBufPlain(aptr, len);
StrBufUnescape(u->url_data, 1);
#ifdef DEBUG_URLSTRINGS
- syslog(LOG_DEBUG, "%s = [%d] %s\n",
- u->url_key,
- StrLength(u->url_data),
- ChrPtr(u->url_data));
+ syslog(LOG_DEBUG, "%s = [%d] %s\n", u->url_key, StrLength(u->url_data), ChrPtr(u->url_data));
#endif
PutUrlKey(WCC->Hdr->urlstrings, u, have_colon);
}
@@ -211,11 +196,9 @@ void ParseURLParams(StrBuf *url)
len = bptr - aptr;
u->url_data = NewStrBufPlain(aptr, len);
StrBufUnescape(u->url_data, 1);
- syslog(LOG_WARNING, "REJECTED because of __ is internal only: %s = [%d] %s\n",
- u->url_key,
- StrLength(u->url_data),
- ChrPtr(u->url_data));
-
+ syslog(LOG_WARNING, "REJECTED because of __ is internal only: %s = [%d] %s\n",
+ u->url_key, StrLength(u->url_data), ChrPtr(u->url_data));
+
free_url(u);
}
up = bptr;
@@ -226,8 +209,7 @@ void ParseURLParams(StrBuf *url)
/*
* free urlstring memory
*/
-void free_urls(void)
-{
+void free_urls(void) {
DeleteHash(&WC->Hdr->urlstrings);
}
@@ -235,18 +217,17 @@ void free_urls(void)
* Diagnostic function to display the contents of all variables
*/
-void dump_vars(void)
-{
+void dump_vars(void) {
wcsession *WCC = WC;
urlcontent *u;
void *U;
long HKLen;
const char *HKey;
HashPos *Cursor;
-
- Cursor = GetNewHashPos (WCC->Hdr->urlstrings, 0);
+
+ Cursor = GetNewHashPos(WCC->Hdr->urlstrings, 0);
while (GetNextHashPos(WCC->Hdr->urlstrings, Cursor, &HKLen, &HKey, &U)) {
- u = (urlcontent*) U;
+ u = (urlcontent *) U;
wc_printf("%38s = %s\n", u->url_key, ChrPtr(u->url_data));
}
}
@@ -255,14 +236,12 @@ void dump_vars(void)
* Return the value of a variable supplied to the current web page (from the url or a form)
*/
-const char *XBstr(const char *key, size_t keylen, size_t *len)
-{
+const char *XBstr(const char *key, size_t keylen, size_t *len) {
void *U;
- if ((WC->Hdr->urlstrings != NULL) &&
- GetHash(WC->Hdr->urlstrings, key, keylen, &U)) {
- *len = StrLength(((urlcontent *)U)->url_data);
- return ChrPtr(((urlcontent *)U)->url_data);
+ if ((WC->Hdr->urlstrings != NULL) && GetHash(WC->Hdr->urlstrings, key, keylen, &U)) {
+ *len = StrLength(((urlcontent *) U)->url_data);
+ return ChrPtr(((urlcontent *) U)->url_data);
}
else {
*len = 0;
@@ -270,14 +249,12 @@ const char *XBstr(const char *key, size_t keylen, size_t *len)
}
}
-const char *XBSTR(const char *key, size_t *len)
-{
+const char *XBSTR(const char *key, size_t *len) {
void *U;
- if ((WC->Hdr->urlstrings != NULL) &&
- GetHash(WC->Hdr->urlstrings, key, strlen (key), &U)){
- *len = StrLength(((urlcontent *)U)->url_data);
- return ChrPtr(((urlcontent *)U)->url_data);
+ if ((WC->Hdr->urlstrings != NULL) && GetHash(WC->Hdr->urlstrings, key, strlen(key), &U)) {
+ *len = StrLength(((urlcontent *) U)->url_data);
+ return ChrPtr(((urlcontent *) U)->url_data);
}
else {
*len = 0;
@@ -286,113 +263,93 @@ const char *XBSTR(const char *key, size_t *len)
}
-const char *BSTR(const char *key)
-{
+const char *BSTR(const char *key) {
void *U;
- if ((WC->Hdr->urlstrings != NULL) &&
- GetHash(WC->Hdr->urlstrings, key, strlen (key), &U))
- return ChrPtr(((urlcontent *)U)->url_data);
- else
+ if ((WC->Hdr->urlstrings != NULL) && GetHash(WC->Hdr->urlstrings, key, strlen(key), &U))
+ return ChrPtr(((urlcontent *) U)->url_data);
+ else
return ("");
}
-const char *Bstr(const char *key, size_t keylen)
-{
+const char *Bstr(const char *key, size_t keylen) {
void *U;
- if ((WC->Hdr->urlstrings != NULL) &&
- GetHash(WC->Hdr->urlstrings, key, keylen, &U))
- return ChrPtr(((urlcontent *)U)->url_data);
- else
+ if ((WC->Hdr->urlstrings != NULL) && GetHash(WC->Hdr->urlstrings, key, keylen, &U))
+ return ChrPtr(((urlcontent *) U)->url_data);
+ else
return ("");
}
-const StrBuf *SBSTR(const char *key)
-{
+const StrBuf *SBSTR(const char *key) {
void *U;
- if ((WC->Hdr->urlstrings != NULL) &&
- GetHash(WC->Hdr->urlstrings, key, strlen (key), &U))
- return ((urlcontent *)U)->url_data;
- else
+ if ((WC->Hdr->urlstrings != NULL) && GetHash(WC->Hdr->urlstrings, key, strlen(key), &U))
+ return ((urlcontent *) U)->url_data;
+ else
return NULL;
}
-const StrBuf *SBstr(const char *key, size_t keylen)
-{
+const StrBuf *SBstr(const char *key, size_t keylen) {
void *U;
- if ((WC->Hdr->urlstrings != NULL) &&
- GetHash(WC->Hdr->urlstrings, key, keylen, &U))
- return ((urlcontent *)U)->url_data;
- else
+ if ((WC->Hdr->urlstrings != NULL) && GetHash(WC->Hdr->urlstrings, key, keylen, &U))
+ return ((urlcontent *) U)->url_data;
+ else
return NULL;
}
-long LBstr(const char *key, size_t keylen)
-{
+long LBstr(const char *key, size_t keylen) {
void *U;
- if ((WC->Hdr->urlstrings != NULL) &&
- GetHash(WC->Hdr->urlstrings, key, keylen, &U))
- return StrTol(((urlcontent *)U)->url_data);
- else
+ if ((WC->Hdr->urlstrings != NULL) && GetHash(WC->Hdr->urlstrings, key, keylen, &U))
+ return StrTol(((urlcontent *) U)->url_data);
+ else
return (0);
}
-int IBstr(const char *key, size_t keylen)
-{
+int IBstr(const char *key, size_t keylen) {
void *U;
- if ((WC->Hdr->urlstrings != NULL) &&
- GetHash(WC->Hdr->urlstrings, key, keylen, &U))
- return StrTol(((urlcontent *)U)->url_data);
- else
+ if ((WC->Hdr->urlstrings != NULL) && GetHash(WC->Hdr->urlstrings, key, keylen, &U))
+ return StrTol(((urlcontent *) U)->url_data);
+ else
return (0);
}
-int IBSTR(const char *key)
-{
+int IBSTR(const char *key) {
void *U;
- if ((WC->Hdr->urlstrings != NULL) &&
- GetHash(WC->Hdr->urlstrings, key, strlen(key), &U))
- return StrToi(((urlcontent *)U)->url_data);
- else
+ if ((WC->Hdr->urlstrings != NULL) && GetHash(WC->Hdr->urlstrings, key, strlen(key), &U))
+ return StrToi(((urlcontent *) U)->url_data);
+ else
return (0);
}
-int HaveBstr(const char *key, size_t keylen)
-{
+int HaveBstr(const char *key, size_t keylen) {
void *U;
- if ((WC->Hdr->urlstrings != NULL) &&
- GetHash(WC->Hdr->urlstrings, key, keylen, &U))
- return (StrLength(((urlcontent *)U)->url_data) != 0);
- else
+ if ((WC->Hdr->urlstrings != NULL) && GetHash(WC->Hdr->urlstrings, key, keylen, &U))
+ return (StrLength(((urlcontent *) U)->url_data) != 0);
+ else
return (0);
}
-int YesBstr(const char *key, size_t keylen)
-{
+int YesBstr(const char *key, size_t keylen) {
void *U;
- if ((WC->Hdr->urlstrings != NULL) &&
- GetHash(WC->Hdr->urlstrings, key, keylen, &U))
- return strcmp( ChrPtr(((urlcontent *)U)->url_data), "yes") == 0;
- else
+ if ((WC->Hdr->urlstrings != NULL) && GetHash(WC->Hdr->urlstrings, key, keylen, &U))
+ return strcmp(ChrPtr(((urlcontent *) U)->url_data), "yes") == 0;
+ else
return (0);
}
-int YESBSTR(const char *key)
-{
+int YESBSTR(const char *key) {
void *U;
- if ((WC->Hdr->urlstrings != NULL) &&
- GetHash(WC->Hdr->urlstrings, key, strlen(key), &U))
- return strcmp( ChrPtr(((urlcontent *)U)->url_data), "yes") == 0;
- else
+ if ((WC->Hdr->urlstrings != NULL) && GetHash(WC->Hdr->urlstrings, key, strlen(key), &U))
+ return strcmp(ChrPtr(((urlcontent *) U)->url_data), "yes") == 0;
+ else
return (0);
}
@@ -400,14 +357,12 @@ int YESBSTR(const char *key)
/*
* Return a sub array that was separated by a colon:
*/
-HashList* getSubStruct(const char *key, size_t keylen)
-{
+HashList *getSubStruct(const char *key, size_t keylen) {
void *U;
- if ((WC->Hdr->urlstrings != NULL) &&
- GetHash(WC->Hdr->urlstrings, key, strlen(key), &U))
- return ((urlcontent *)U)->sub;
- else
+ if ((WC->Hdr->urlstrings != NULL) && GetHash(WC->Hdr->urlstrings, key, strlen(key), &U))
+ return ((urlcontent *) U)->sub;
+ else
return NULL;
}
@@ -415,14 +370,12 @@ HashList* getSubStruct(const char *key, size_t keylen)
/*
* Return the value of a variable of a substruct provided by getSubStruct
*/
-const char *XSubBstr(HashList *sub, const char *key, size_t keylen, size_t *len)
-{
+const char *XSubBstr(HashList * sub, const char *key, size_t keylen, size_t *len) {
void *U;
- if ((sub != NULL) &&
- GetHash(sub, key, keylen, &U)) {
- *len = StrLength(((urlcontent *)U)->url_data);
- return ChrPtr(((urlcontent *)U)->url_data);
+ if ((sub != NULL) && GetHash(sub, key, keylen, &U)) {
+ *len = StrLength(((urlcontent *) U)->url_data);
+ return ChrPtr(((urlcontent *) U)->url_data);
}
else {
*len = 0;
@@ -430,75 +383,63 @@ const char *XSubBstr(HashList *sub, const char *key, size_t keylen, size_t *len)
}
}
-const char *SubBstr(HashList *sub, const char *key, size_t keylen)
-{
+const char *SubBstr(HashList * sub, const char *key, size_t keylen) {
void *U;
- if ((sub != NULL) &&
- GetHash(sub, key, keylen, &U)) {
- return ChrPtr(((urlcontent *)U)->url_data);
+ if ((sub != NULL) && GetHash(sub, key, keylen, &U)) {
+ return ChrPtr(((urlcontent *) U)->url_data);
}
- else
+ else
return ("");
}
-const StrBuf *SSubBstr(HashList *sub, const char *key, size_t keylen)
-{
+const StrBuf *SSubBstr(HashList * sub, const char *key, size_t keylen) {
void *U;
- if ((sub != NULL) &&
- GetHash(sub, key, keylen, &U)) {
- return ((urlcontent *)U)->url_data;
+ if ((sub != NULL) && GetHash(sub, key, keylen, &U)) {
+ return ((urlcontent *) U)->url_data;
}
- else
+ else
return NULL;
}
-long LSubBstr(HashList *sub, const char *key, size_t keylen)
-{
+long LSubBstr(HashList * sub, const char *key, size_t keylen) {
void *U;
- if ((sub != NULL) &&
- GetHash(sub, key, keylen, &U)) {
- return StrTol(((urlcontent *)U)->url_data);
+ if ((sub != NULL) && GetHash(sub, key, keylen, &U)) {
+ return StrTol(((urlcontent *) U)->url_data);
}
- else
+ else
return (0);
}
-int ISubBstr(HashList *sub, const char *key, size_t keylen)
-{
+int ISubBstr(HashList * sub, const char *key, size_t keylen) {
void *U;
- if ((sub != NULL) &&
- GetHash(sub, key, keylen, &U)) {
- return StrTol(((urlcontent *)U)->url_data);
+ if ((sub != NULL) && GetHash(sub, key, keylen, &U)) {
+ return StrTol(((urlcontent *) U)->url_data);
}
- else
+ else
return (0);
}
-int HaveSubBstr(HashList *sub, const char *key, size_t keylen)
-{
+int HaveSubBstr(HashList * sub, const char *key, size_t keylen) {
void *U;
- if ((sub != NULL) &&
- GetHash(sub, key, keylen, &U)) {
- return (StrLength(((urlcontent *)U)->url_data) != 0);
+ if ((sub != NULL) && GetHash(sub, key, keylen, &U)) {
+ return (StrLength(((urlcontent *) U)->url_data) != 0);
}
- else
+ else
return (0);
}
-int YesSubBstr(HashList *sub, const char *key, size_t keylen)
-{
+int YesSubBstr(HashList * sub, const char *key, size_t keylen) {
void *U;
- if ((sub != NULL) &&
- GetHash(sub, key, keylen, &U)) {
- return strcmp( ChrPtr(((urlcontent *)U)->url_data), "yes") == 0;
+ if ((sub != NULL) && GetHash(sub, key, keylen, &U)) {
+ return strcmp(ChrPtr(((urlcontent *) U)->url_data), "yes") == 0;
}
- else
+ else
return (0);
}
@@ -521,80 +462,70 @@ int YesSubBstr(HashList *sub, const char *key, size_t keylen)
* userdata Not used here
*/
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 *content, char *cbtype, char *cbcharset, size_t length, char *encoding, char *cbid, void *userdata) {
wcsession *WCC = WC;
urlcontent *u;
long keylen;
#ifdef DEBUG_URLSTRINGS
- syslog(LOG_DEBUG, "upload_handler() name=%s, type=%s, len="SIZE_T_FMT, name, cbtype, length);
+ syslog(LOG_DEBUG, "upload_handler() name=%s, type=%s, len=" SIZE_T_FMT, name, cbtype, length);
#endif
if (WCC->Hdr->urlstrings == NULL)
WCC->Hdr->urlstrings = NewHash(1, NULL);
/* Form fields */
- if ( (length > 0) && (IsEmptyStr(cbtype)) ) {
+ if ((length > 0) && (IsEmptyStr(cbtype))) {
u = (urlcontent *) malloc(sizeof(urlcontent));
-
+
keylen = safestrncpy(u->url_key, name, sizeof(u->url_key));
u->url_data = NewStrBufPlain(content, length);
u->klen = keylen;
u->sub = NULL;
-
- if (strncmp(u->url_key, "__", 2) != 0)
- {
+
+ if (strncmp(u->url_key, "__", 2) != 0) {
PutUrlKey(WCC->Hdr->urlstrings, u, (strchr(u->url_key, ':') != NULL));
}
else {
- syslog(LOG_INFO, "REJECTED because of __ is internal only: %s = [%d] %s\n",
- u->url_key,
- StrLength(u->url_data),
- ChrPtr(u->url_data));
-
+ syslog(LOG_INFO, "REJECTED because of __ is internal only: %s = [%d] %s\n",
+ u->url_key, StrLength(u->url_data), ChrPtr(u->url_data));
+
free_url(u);
}
#ifdef DEBUG_URLSTRINGS
- syslog(LOG_DEBUG, "Key: <%s> len: [%d] Data: <%s>",
- u->url_key,
- StrLength(u->url_data),
- ChrPtr(u->url_data));
+ syslog(LOG_DEBUG, "Key: <%s> len: [%d] Data: <%s>", u->url_key, StrLength(u->url_data), ChrPtr(u->url_data));
#endif
}
/* Uploaded files */
- if ( (length > 0) && (!IsEmptyStr(cbtype)) ) {
+ if ((length > 0) && (!IsEmptyStr(cbtype))) {
WCC->upload = NewStrBufPlain(content, length);
WCC->upload_length = length;
WCC->upload_filename = NewStrBufPlain(filename, -1);
safestrncpy(WCC->upload_content_type, cbtype, sizeof(WC->upload_content_type));
#ifdef DEBUG_URLSTRINGS
- syslog(LOG_DEBUG, "File: <%s> len: [%ld]", filename, (long int)length);
+ syslog(LOG_DEBUG, "File: <%s> len: [%ld]", filename, (long int) length);
#endif
-
+
}
}
-void PutBstr(const char *key, long keylen, StrBuf *Value)
-{
+void PutBstr(const char *key, long keylen, StrBuf * Value) {
urlcontent *u;
- if(keylen >= sizeof(u->url_key)) {
+ if (keylen >= sizeof(u->url_key)) {
syslog(LOG_WARNING, "%s:%d: invalid url_key of size %ld", __FILE__, __LINE__, keylen);
FreeStrBuf(&Value);
return;
}
- u = (urlcontent*)malloc(sizeof(urlcontent));
+ u = (urlcontent *) malloc(sizeof(urlcontent));
memcpy(u->url_key, key, keylen + 1);
u->klen = keylen;
u->url_data = Value;
u->sub = NULL;
Put(WC->Hdr->urlstrings, u->url_key, keylen, u, free_url);
}
-void PutlBstr(const char *key, long keylen, long Value)
-{
+void PutlBstr(const char *key, long keylen, long Value) {
StrBuf *Buf;
Buf = NewStrBufPlain(NULL, sizeof(long) * 16);
@@ -604,53 +535,45 @@ void PutlBstr(const char *key, long keylen, long Value)
-int ConditionalBstr(StrBuf *Target, WCTemplputParams *TP)
-{
- if(TP->Tokens->nParameters == 3)
+int ConditionalBstr(StrBuf * Target, WCTemplputParams * TP) {
+ if (TP->Tokens->nParameters == 3)
return HaveBstr(TKEY(2));
else {
- if (IS_NUMBER(TP->Tokens->Params[3]->Type))
- {
- return LBstr(TKEY(2)) ==
- GetTemplateTokenNumber(Target,
- TP,
- 3,
- 0);
+ if (IS_NUMBER(TP->Tokens->Params[3]->Type)) {
+ return LBstr(TKEY(2)) == GetTemplateTokenNumber(Target, TP, 3, 0);
}
else {
const char *pch;
long len;
- GetTemplateTokenString (Target, TP, 3, &pch, &len);
+ GetTemplateTokenString(Target, TP, 3, &pch, &len);
return strcmp(Bstr(TKEY(2)), pch) == 0;
}
}
}
-void tmplput_bstr(StrBuf *Target, WCTemplputParams *TP)
-{
+void tmplput_bstr(StrBuf * Target, WCTemplputParams * TP) {
const StrBuf *Buf = SBstr(TKEY(0));
if (Buf != NULL)
StrBufAppendTemplate(Target, TP, Buf, 1);
}
-void tmplput_bstrforward(StrBuf *Target, WCTemplputParams *TP)
-{
+void tmplput_bstrforward(StrBuf * Target, WCTemplputParams * TP) {
const StrBuf *Buf = SBstr(TKEY(0));
if (Buf != NULL) {
- StrBufAppendBufPlain(Target, HKEY("?"), 0);
+ StrBufAppendBufPlain(Target, HKEY("?"), 0);
StrBufAppendBufPlain(Target, TKEY(0), 0);
- StrBufAppendBufPlain(Target, HKEY("="), 0);
+ StrBufAppendBufPlain(Target, HKEY("="), 0);
StrBufAppendTemplate(Target, TP, Buf, 1);
}
}
-void diagnostics(void)
-{
+void diagnostics(void) {
output_headers(1, 1, 1, 0, 0, 0);
wc_printf("Session: %d
\n", WC->wc_session);
wc_printf("Command:
\n");
+
/*
StrEscAppend(WC->WBuf, NULL, WC->UrlFragment1, 0, 0);
wc_printf(" \n");
@@ -666,12 +589,11 @@ StrEscAppend(WC->WBuf, NULL, WC->UrlFragment3, 0, 0);
}
-void tmplput_url_part(StrBuf *Target, WCTemplputParams *TP)
-{
+void tmplput_url_part(StrBuf * Target, WCTemplputParams * TP) {
StrBuf *Name = NULL;
StrBuf *UrlBuf = NULL;
wcsession *WCC = WC;
-
+
if (WCC != NULL) {
long n;
@@ -689,44 +611,41 @@ void tmplput_url_part(StrBuf *Target, WCTemplputParams *TP)
StrBufExtract_token(UrlBuf, WCC->Hdr->HR.ReqLine, 1, '/');
}
- if (UrlBuf == NULL) {
+ if (UrlBuf == NULL) {
LogTemplateError(Target, "urlbuf", ERR_PARM1, TP, "not set.");
}
StrBufAppendTemplate(Target, TP, UrlBuf, 2);
- if (Name == NULL) FreeStrBuf(&UrlBuf);
+ if (Name == NULL)
+ FreeStrBuf(&UrlBuf);
}
}
typedef struct __BstrPair {
StrBuf *x;
StrBuf *y;
-}BstrPair;
+} BstrPair;
CtxType CTX_BSTRPAIRS = CTX_NONE;
-void HFreeBstrPair(void *pv)
-{
- BstrPair *p = (BstrPair*) pv;
+void HFreeBstrPair(void *pv) {
+ BstrPair *p = (BstrPair *) pv;
FreeStrBuf(&p->x);
FreeStrBuf(&p->y);
free(pv);
}
-HashList *iterate_GetBstrPairs(StrBuf *Target, WCTemplputParams *TP)
-{
+HashList *iterate_GetBstrPairs(StrBuf * Target, WCTemplputParams * TP) {
StrBuf *X, *Y;
- const char *ch = NULL;
- long len;
+ const char *ch = NULL;
+ long len;
const StrBuf *TheBStr;
BstrPair *OnePair;
- HashList *List;
+ HashList *List;
const char *Pos = NULL;
int i = 0;
- if (HaveTemplateTokenString(NULL, TP, 2, &ch, &len))
- {
- GetTemplateTokenString(Target, TP, 2, &ch, &len);
- }
- else
- {
+ if (HaveTemplateTokenString(NULL, TP, 2, &ch, &len)) {
+ GetTemplateTokenString(Target, TP, 2, &ch, &len);
+ }
+ else {
return NULL;
}
@@ -734,8 +653,7 @@ HashList *iterate_GetBstrPairs(StrBuf *Target, WCTemplputParams *TP)
if ((TheBStr == NULL) || (StrLength(TheBStr) == 0))
return NULL;
List = NewHash(1, NULL);
- while (Pos != StrBufNOTNULL)
- {
+ while (Pos != StrBufNOTNULL) {
X = NewStrBufPlain(NULL, StrLength(TheBStr));
StrBufExtract_NextToken(X, TheBStr, &Pos, '|');
if (Pos == StrBufNOTNULL) {
@@ -745,7 +663,7 @@ HashList *iterate_GetBstrPairs(StrBuf *Target, WCTemplputParams *TP)
}
Y = NewStrBufPlain(NULL, StrLength(TheBStr));
StrBufExtract_NextToken(Y, TheBStr, &Pos, '|');
- OnePair = (BstrPair*)malloc(sizeof(BstrPair));
+ OnePair = (BstrPair *) malloc(sizeof(BstrPair));
OnePair->x = X;
OnePair->y = Y;
Put(List, IKEY(i), OnePair, HFreeBstrPair);
@@ -755,22 +673,20 @@ HashList *iterate_GetBstrPairs(StrBuf *Target, WCTemplputParams *TP)
}
-void tmplput_bstr_pair(StrBuf *Target, WCTemplputParams *TP, int XY)
-{
- BstrPair *Pair = (BstrPair*) CTX(CTX_BSTRPAIRS);
+void tmplput_bstr_pair(StrBuf * Target, WCTemplputParams * TP, int XY) {
+ BstrPair *Pair = (BstrPair *) CTX(CTX_BSTRPAIRS);
- StrBufAppendTemplate(Target, TP, (XY)?Pair->y:Pair->x, 0);
+ StrBufAppendTemplate(Target, TP, (XY) ? Pair->y : Pair->x, 0);
}
-void tmplput_bstr_pair_x(StrBuf *Target, WCTemplputParams *TP)
-{ tmplput_bstr_pair(Target, TP, 0); }
-void tmplput_bstr_pair_y(StrBuf *Target, WCTemplputParams *TP)
-{ tmplput_bstr_pair(Target, TP, 1); }
+void tmplput_bstr_pair_x(StrBuf * Target, WCTemplputParams * TP) {
+ tmplput_bstr_pair(Target, TP, 0);
+}
+void tmplput_bstr_pair_y(StrBuf * Target, WCTemplputParams * TP) {
+ tmplput_bstr_pair(Target, TP, 1);
+}
-void
-InitModule_PARAMHANDLING
-(void)
-{
+void InitModule_PARAMHANDLING(void) {
RegisterCTX(CTX_BSTRPAIRS);
WebcitAddUrlHandler(HKEY("diagnostics"), "", 0, diagnostics, NEED_URL);
@@ -785,17 +701,11 @@ InitModule_PARAMHANDLING
}
-void
-SessionAttachModule_PARAMHANDLING
-(wcsession *sess)
-{
- sess->Hdr->urlstrings = NewHash(1,NULL);
+void SessionAttachModule_PARAMHANDLING(wcsession * sess) {
+ sess->Hdr->urlstrings = NewHash(1, NULL);
}
-void
-SessionDetachModule_PARAMHANDLING
-(wcsession *sess)
-{
+void SessionDetachModule_PARAMHANDLING(wcsession * sess) {
DeleteHash(&sess->Hdr->urlstrings);
FreeStrBuf(&sess->upload_filename);
}
diff --git a/webcit/paramhandling.h b/webcit/paramhandling.h
index 1b2f62d02..bcfc909e8 100644
--- a/webcit/paramhandling.h
+++ b/webcit/paramhandling.h
@@ -1,3 +1,4 @@
+
/*
* Copyright (c) 1996-2013 by the citadel.org team
*
@@ -12,10 +13,9 @@
/* 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 *content, char *cbtype, char *cbcharset, size_t length, char *encoding, char *cbid, void *userdata);
-void ParseURLParams(StrBuf *url);
+void ParseURLParams(StrBuf * url);
/* These may return NULL if not foud */
@@ -41,27 +41,27 @@ int HaveBstr(const char *key, size_t keylen);
int YesBstr(const char *key, size_t keylen);
int YESBSTR(const char *key);
-HashList* getSubStruct(const char *key, size_t keylen);
+HashList *getSubStruct(const char *key, size_t keylen);
/* These may return NULL if not foud */
#define ssubbstr(s, a) SSubBstr(s, a, sizeof(a) - 1)
-const StrBuf *SSubBstr(HashList *sub, const char *key, size_t keylen);
+const StrBuf *SSubBstr(HashList * sub, const char *key, size_t keylen);
#define xsubbstr(s, a, b) (char*) XSubBstr(s, a, sizeof(a) - 1, b)
-const char *XSubBstr(HashList *sub, const char *key, size_t keylen, size_t *len);
+const char *XSubBstr(HashList * sub, const char *key, size_t keylen, size_t *len);
#define lsubbstr(s, a) LSubBstr(s, a, sizeof(a) - 1)
-long LSubBstr(HashList *sub, const char *key, size_t keylen);
+long LSubBstr(HashList * sub, const char *key, size_t keylen);
#define isubbstr(s, a) ISubBstr(s, a, sizeof(a) - 1)
#define isubbcstr(s, a) ISubBstr(s, a.Key, a.len)
-int ISubBstr(HashList *sub, const char *key, size_t keylen);
+int ISubBstr(HashList * sub, const char *key, size_t keylen);
#define havesubbstr(s, a) HaveSubBstr(s, a, sizeof(a) - 1)
-int HaveSubBstr(HashList *sub, const char *key, size_t keylen);
+int HaveSubBstr(HashList * sub, const char *key, size_t keylen);
#define yessubbstr(s, a) YesSubBstr(s, a, sizeof(a) - 1)
-int YesSubBstr(HashList *sub, const char *key, size_t keylen);
+int YesSubBstr(HashList * sub, const char *key, size_t keylen);
@@ -70,10 +70,10 @@ int YesSubBstr(HashList *sub, const char *key, size_t keylen);
#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 PutBstr(const char *key, long keylen, StrBuf * Value);
#define putlbstr(a, b) PutlBstr(a, sizeof(a) - 1, b)
void PutlBstr(const char *key, long keylen, long Value);
-
diff --git a/webcit/preferences.c b/webcit/preferences.c
index ae381cc1e..244be7ffc 100644
--- a/webcit/preferences.c
+++ b/webcit/preferences.c
@@ -1,3 +1,4 @@
+
/*
* Manage user preferences with a little help from the Citadel server.
*
@@ -39,17 +40,15 @@ typedef struct _Preference {
StrBuf *DeQPed;
} Preference;
-void DestroyPrefDef(void *vPrefDef)
-{
- PrefDef *Prefdef = (PrefDef*) vPrefDef;
+void DestroyPrefDef(void *vPrefDef) {
+ PrefDef *Prefdef = (PrefDef *) vPrefDef;
FreeStrBuf(&Prefdef->Setting);
FreeStrBuf(&Prefdef->OnLoadName);
free(Prefdef);
}
-void DestroyPreference(void *vPref)
-{
- Preference *Pref = (Preference*) vPref;
+void DestroyPreference(void *vPref) {
+ Preference *Pref = (Preference *) vPref;
FreeStrBuf(&Pref->Key);
FreeStrBuf(&Pref->Val);
FreeStrBuf(&Pref->DeQPed);
@@ -57,13 +56,9 @@ void DestroyPreference(void *vPref)
}
-void _RegisterPreference(const char *Setting, long SettingLen,
- const char *PrefStr,
- ePrefType Type,
- PrefEvalFunc OnLoad,
- const char *OnLoadName)
-{
- PrefDef *Newpref = (PrefDef*) malloc(sizeof(PrefDef));
+void _RegisterPreference(const char *Setting, long SettingLen,
+ const char *PrefStr, ePrefType Type, PrefEvalFunc OnLoad, const char *OnLoadName) {
+ PrefDef *Newpref = (PrefDef *) malloc(sizeof(PrefDef));
Newpref->Setting = NewStrBufPlain(Setting, SettingLen);
Newpref->PrefStr = PrefStr;
Newpref->eType = Type;
@@ -76,11 +71,10 @@ void _RegisterPreference(const char *Setting, long SettingLen,
Put(PreferenceHooks, Setting, SettingLen, Newpref, DestroyPrefDef);
}
-const char *PrefGetLocalStr(const char *Setting, long len)
-{
+const char *PrefGetLocalStr(const char *Setting, long len) {
void *hash_value;
if (GetHash(PreferenceHooks, Setting, len, &hash_value) != 0) {
- PrefDef *Newpref = (PrefDef*) hash_value;
+ PrefDef *Newpref = (PrefDef *) hash_value;
return _(Newpref->PrefStr);
}
@@ -88,18 +82,16 @@ const char *PrefGetLocalStr(const char *Setting, long len)
}
#ifdef DBG_PREFS_HASH
-inline const char *PrintPref(void *vPref)
-{
- Preference *Pref = (Preference*) vPref;
+inline const char *PrintPref(void *vPref) {
+ Preference *Pref = (Preference *) vPref;
if (Pref->DeQPed != NULL)
return ChrPtr(Pref->DeQPed);
- else
+ else
return ChrPtr(Pref->Val);
}
#endif
-void GetPrefTypes(HashList *List)
-{
+void GetPrefTypes(HashList * List) {
HashPos *It;
long len;
const char *Key;
@@ -109,24 +101,18 @@ void GetPrefTypes(HashList *List)
PrefDef *PrefType;
It = GetNewHashPos(List, 0);
- while (GetNextHashPos(List, It, &len, &Key, &vSetting))
- {
- Pref = (Preference*) vSetting;
- if (GetHash(PreferenceHooks, SKEY(Pref->Key), &vPrefDef) &&
- (vPrefDef != NULL))
- {
- PrefType = (PrefDef*) vPrefDef;
+ while (GetNextHashPos(List, It, &len, &Key, &vSetting)) {
+ Pref = (Preference *) vSetting;
+ if (GetHash(PreferenceHooks, SKEY(Pref->Key), &vPrefDef) && (vPrefDef != NULL)) {
+ PrefType = (PrefDef *) vPrefDef;
Pref->Type = PrefType;
Pref->eFlatPrefType = Pref->Type->eType;
syslog(LOG_DEBUG, "Loading [%s]with type [%d] [\"%s\"]\n",
- ChrPtr(Pref->Key),
- Pref->Type->eType,
- ChrPtr(Pref->Val));
+ ChrPtr(Pref->Key), Pref->Type->eType, ChrPtr(Pref->Val));
- switch (Pref->Type->eType)
- {
- case PRF_UNSET: /* WHUT? */
+ switch (Pref->Type->eType) {
+ case PRF_UNSET: /* WHUT? */
break;
case PRF_STRING:
break;
@@ -145,12 +131,10 @@ void GetPrefTypes(HashList *List)
break;
}
- if (PrefType->OnLoad != NULL){
+ if (PrefType->OnLoad != NULL) {
syslog(LOG_DEBUG, "Loading with: -> %s(\"%s\", %ld)\n",
- ChrPtr(PrefType->OnLoadName),
- ChrPtr(Pref->Val),
- Pref->lval);
+ ChrPtr(PrefType->OnLoadName), ChrPtr(Pref->Val), Pref->lval);
PrefType->OnLoad(Pref->Val, Pref->lval);
}
}
@@ -158,23 +142,20 @@ void GetPrefTypes(HashList *List)
DeleteHashPos(&It);
}
-void ParsePref(HashList **List, StrBuf *ReadBuf)
-{
+void ParsePref(HashList ** List, StrBuf * ReadBuf) {
int Done = 0;
Preference *Data = NULL;
Preference *LastData = NULL;
-
+
while (!Done) {
if (StrBuf_ServGetln(ReadBuf) < 0)
break;
- if ( (StrLength(ReadBuf)==3) &&
- !strcmp(ChrPtr(ReadBuf), "000")) {
+ if ((StrLength(ReadBuf) == 3) && !strcmp(ChrPtr(ReadBuf), "000")) {
Done = 1;
break;
}
- if ((ChrPtr(ReadBuf)[0] == ' ') &&
- (LastData != NULL)) {
+ if ((ChrPtr(ReadBuf)[0] == ' ') && (LastData != NULL)) {
StrBufAppendBuf(LastData->Val, ReadBuf, 1);
}
else {
@@ -189,27 +170,21 @@ void ParsePref(HashList **List, StrBuf *ReadBuf)
/* some users might still have this start page configured, which now breaks */
- if ( (!strcasecmp(ChrPtr(Data->Key), "startpage"))
- && (!strcasecmp(ChrPtr(Data->Val), "/do_template?template=summary_page"))
- ) {
+ if ((!strcasecmp(ChrPtr(Data->Key), "startpage"))
+ && (!strcasecmp(ChrPtr(Data->Val), "/do_template?template=summary_page"))
+ ) {
FreeStrBuf(&Data->Val);
Data->Val = NewStrBufPlain(HKEY("/summary"));
}
/******************* END VILE SLEAZY HACK ************************/
- if (!IsEmptyStr(ChrPtr(Data->Key)))
- {
- Put(*List,
- SKEY(Data->Key),
- Data,
- DestroyPreference);
+ if (!IsEmptyStr(ChrPtr(Data->Key))) {
+ Put(*List, SKEY(Data->Key), Data, DestroyPreference);
}
- else
- {
+ else {
StrBufTrim(ReadBuf);
- syslog(LOG_INFO, "ignoring spurious preference line: [%s]\n",
- ChrPtr(ReadBuf));
+ syslog(LOG_INFO, "ignoring spurious preference line: [%s]\n", ChrPtr(ReadBuf));
DestroyPreference(Data);
LastData = NULL;
}
@@ -223,21 +198,20 @@ void ParsePref(HashList **List, StrBuf *ReadBuf)
/*
* display preferences dialog
*/
-void load_preferences(void)
-{
+void load_preferences(void) {
folder Room;
wcsession *WCC = WC;
int Done = 0;
StrBuf *ReadBuf;
long msgnum = 0L;
-
+
memset(&Room, 0, sizeof(folder));
ReadBuf = NewStrBufPlain(NULL, SIZ * 4);
if (goto_config_room(ReadBuf, &Room) != 0) {
FreeStrBuf(&ReadBuf);
FlushFolder(&Room);
- return; /* oh well. */
+ return; /* oh well. */
}
serv_puts("MSGS ALL|0|1");
@@ -247,7 +221,7 @@ void load_preferences(void)
serv_puts("000");
}
while (!Done && (StrBuf_ServGetln(ReadBuf) >= 0)) {
- if ( (StrLength(ReadBuf)==3) && !strcmp(ChrPtr(ReadBuf), "000")) {
+ if ((StrLength(ReadBuf) == 3) && !strcmp(ChrPtr(ReadBuf), "000")) {
Done = 1;
break;
}
@@ -258,10 +232,10 @@ void load_preferences(void)
serv_printf("MSG0 %ld", msgnum);
StrBuf_ServGetln(ReadBuf);
if (GetServerStatus(ReadBuf, NULL) == 1) {
- while ( (StrBuf_ServGetln(ReadBuf) >= 0)
- && (strcmp(ChrPtr(ReadBuf), "text")
- && strcmp(ChrPtr(ReadBuf), "000"))
- ) {
+ while ((StrBuf_ServGetln(ReadBuf) >= 0)
+ && (strcmp(ChrPtr(ReadBuf), "text")
+ && strcmp(ChrPtr(ReadBuf), "000"))
+ ) {
/* flush */
}
if (!strcmp(ChrPtr(ReadBuf), "text")) {
@@ -285,8 +259,7 @@ void load_preferences(void)
* Go to the user's configuration room, creating it if necessary.
* returns 0 on success or nonzero upon failure.
*/
-int goto_config_room(StrBuf *Buf, folder *Room)
-{
+int goto_config_room(StrBuf * Buf, folder * Room) {
serv_printf("GOTO %s", USERCONFIGROOM);
StrBuf_ServGetln(Buf);
if (GetServerStatus(Buf, NULL) != 2) { /* try to create the config room if not there */
@@ -297,15 +270,14 @@ int goto_config_room(StrBuf *Buf, folder *Room)
serv_printf("GOTO %s", USERCONFIGROOM);
StrBuf_ServGetln(Buf);
if (GetServerStatus(Buf, NULL) != 2) {
- return(1);
+ return (1);
}
}
ParseGoto(Room, Buf);
- return(0);
+ return (0);
}
-void WritePrefsToServer(HashList *Hash)
-{
+void WritePrefsToServer(HashList * Hash) {
wcsession *WCC = WC;
long len;
HashPos *HashPos;
@@ -313,20 +285,19 @@ void WritePrefsToServer(HashList *Hash)
const char *Key;
Preference *Pref;
StrBuf *SubBuf = NULL;
-
+
Hash = WCC->hash_prefs;
#ifdef DBG_PREFS_HASH
dbg_PrintHash(Hash, PrintPref, NULL);
#endif
HashPos = GetNewHashPos(Hash, 0);
- while (GetNextHashPos(Hash, HashPos, &len, &Key, &vPref)!=0)
- {
+ while (GetNextHashPos(Hash, HashPos, &len, &Key, &vPref) != 0) {
size_t nchars;
if (vPref == NULL)
continue;
- Pref = (Preference*) vPref;
+ Pref = (Preference *) vPref;
nchars = StrLength(Pref->Val);
- if (nchars > 80){
+ if (nchars > 80) {
int n = 0;
size_t offset, nchars;
if (SubBuf == NULL)
@@ -336,28 +307,28 @@ void WritePrefsToServer(HashList *Hash)
while (nchars > 0) {
if (n == 0)
nchars = 70;
- else
+ else
nchars = 80;
-
+
nchars = StrBufSub(SubBuf, Pref->Val, offset, nchars);
-
+
if (n == 0) {
serv_printf("%s|%s", ChrPtr(Pref->Key), ChrPtr(SubBuf));
}
else {
serv_printf(" %s", ChrPtr(SubBuf));
}
-
+
offset += nchars;
nchars = StrLength(Pref->Val) - offset;
n++;
}
-
+
}
else {
serv_printf("%s|%s", ChrPtr(Pref->Key), ChrPtr(Pref->Val));
}
-
+
}
FreeStrBuf(&SubBuf);
DeleteHashPos(&HashPos);
@@ -366,21 +337,20 @@ void WritePrefsToServer(HashList *Hash)
/*
* save the modifications
*/
-void save_preferences(void)
-{
+void save_preferences(void) {
folder Room;
wcsession *WCC = WC;
int Done = 0;
StrBuf *ReadBuf;
long msgnum = 0L;
-
+
ReadBuf = NewStrBuf();
memset(&Room, 0, sizeof(folder));
if (goto_config_room(ReadBuf, &Room) != 0) {
FreeStrBuf(&ReadBuf);
FlushFolder(&Room);
- return; /* oh well. */
+ return; /* oh well. */
}
/* make shure the config room has the right type, else it might reject our config */
@@ -393,7 +363,7 @@ void save_preferences(void)
else if (goto_config_room(ReadBuf, &Room) != 0) {
FreeStrBuf(&ReadBuf);
FlushFolder(&Room);
-
+
return; /* oh well. */
}
}
@@ -405,7 +375,7 @@ void save_preferences(void)
serv_puts("000");
}
while (!Done && (StrBuf_ServGetln(ReadBuf) >= 0)) {
- if ( (StrLength(ReadBuf)==3) && !strcmp(ChrPtr(ReadBuf), "000")) {
+ if ((StrLength(ReadBuf) == 3) && !strcmp(ChrPtr(ReadBuf), "000")) {
Done = 1;
break;
}
@@ -445,8 +415,7 @@ void save_preferences(void)
* value StrBuf-value to the key to get
* returns: found?
*/
-int get_pref_backend(const char *key, size_t keylen, Preference **Pref)
-{
+int get_pref_backend(const char *key, size_t keylen, Preference ** Pref) {
void *hash_value = NULL;
#ifdef DBG_PREFS_HASH
dbg_PrintHash(WC->hash_prefs, PrintPref, NULL);
@@ -456,13 +425,12 @@ int get_pref_backend(const char *key, size_t keylen, Preference **Pref)
return 0;
}
else {
- *Pref = (Preference*) hash_value;
+ *Pref = (Preference *) hash_value;
return 1;
}
}
-int get_PREFERENCE(const char *key, size_t keylen, StrBuf **value)
-{
+int get_PREFERENCE(const char *key, size_t keylen, StrBuf ** value) {
Preference *Pref;
int Ret;
@@ -482,8 +450,7 @@ int get_PREFERENCE(const char *key, size_t keylen, StrBuf **value)
* value value to set
* save_to_server 1 = flush all data to the server, 0 = cache it for now
*/
-long compare_preference(const Preference *PrefA, const Preference *PrefB)
-{
+long compare_preference(const Preference * PrefA, const Preference * PrefB) {
ePrefType TypeA, TypeB;
if (PrefA->Type != NULL) {
@@ -500,14 +467,14 @@ long compare_preference(const Preference *PrefA, const Preference *PrefB)
TypeB = PrefB->eFlatPrefType;
}
- if ( (TypeA != PRF_UNSET)
- && (TypeB != PRF_UNSET)
- && (TypeA != TypeB)
- ) {
+ if ((TypeA != PRF_UNSET)
+ && (TypeB != PRF_UNSET)
+ && (TypeA != TypeB)
+ ) {
if (TypeA > TypeB) {
return 1;
}
- else { /* (PrefA->Type < PrefB->Type) */
+ else { /* (PrefA->Type < PrefB->Type) */
return -1;
}
}
@@ -515,9 +482,8 @@ long compare_preference(const Preference *PrefA, const Preference *PrefB)
if (TypeB == PRF_UNSET) {
TypeA = PRF_UNSET;
}
-
- switch (TypeA)
- {
+
+ switch (TypeA) {
default:
case PRF_UNSET:
case PRF_STRING:
@@ -531,8 +497,7 @@ long compare_preference(const Preference *PrefA, const Preference *PrefB)
else
return -1;
case PRF_QP_STRING:
- return strcmp(ChrPtr(PrefA->DeQPed),
- ChrPtr(PrefB->DeQPed));
+ return strcmp(ChrPtr(PrefA->DeQPed), ChrPtr(PrefB->DeQPed));
}
}
@@ -545,37 +510,28 @@ long compare_preference(const Preference *PrefA, const Preference *PrefB)
* value value to set
* save_to_server 1 = flush all data to the server, 0 = cache it for now
*/
-void set_preference_backend(const char *key, size_t keylen,
- long lvalue,
- StrBuf *value,
- long lPrefType,
- int save_to_server,
- PrefDef *PrefType)
-{
+void set_preference_backend(const char *key, size_t keylen,
+ long lvalue, StrBuf * value, long lPrefType, int save_to_server, PrefDef * PrefType) {
wcsession *WCC = WC;
void *vPrefDef;
void *vPrefB;
Preference *Pref;
- Pref = (Preference*) malloc(sizeof(Preference));
+ Pref = (Preference *) malloc(sizeof(Preference));
memset(Pref, 0, sizeof(Preference));
Pref->Key = NewStrBufPlain(key, keylen);
- if ((PrefType == NULL) &&
- GetHash(PreferenceHooks, SKEY(Pref->Key), &vPrefDef) &&
- (vPrefDef != NULL))
- PrefType = (PrefDef*) vPrefDef;
+ if ((PrefType == NULL) && GetHash(PreferenceHooks, SKEY(Pref->Key), &vPrefDef) && (vPrefDef != NULL))
+ PrefType = (PrefDef *) vPrefDef;
- if (PrefType != NULL)
- {
+ if (PrefType != NULL) {
Pref->Type = PrefType;
Pref->eFlatPrefType = PrefType->eType;
if (Pref->Type->eType != lPrefType)
syslog(LOG_WARNING, "warning: saving preference with wrong type [%s] %d != %ld \n",
- key, Pref->Type->eType, lPrefType);
- switch (Pref->Type->eType)
- {
- case PRF_UNSET: /* default to string... */
+ key, Pref->Type->eType, lPrefType);
+ switch (Pref->Type->eType) {
+ case PRF_UNSET: /* default to string... */
case PRF_STRING:
Pref->Val = value;
Pref->decoded = 1;
@@ -596,7 +552,7 @@ void set_preference_backend(const char *key, size_t keylen,
break;
case PRF_YESNO:
Pref->lval = lvalue;
- if (lvalue)
+ if (lvalue)
Pref->Val = NewStrBufPlain(HKEY("yes"));
else
Pref->Val = NewStrBufPlain(HKEY("no"));
@@ -608,8 +564,7 @@ void set_preference_backend(const char *key, size_t keylen,
}
else {
Pref->eFlatPrefType = lPrefType;
- switch (lPrefType)
- {
+ switch (lPrefType) {
case PRF_STRING:
Pref->Val = value;
Pref->decoded = 1;
@@ -630,7 +585,7 @@ void set_preference_backend(const char *key, size_t keylen,
break;
case PRF_YESNO:
Pref->lval = lvalue;
- if (lvalue)
+ if (lvalue)
Pref->Val = NewStrBufPlain(HKEY("yes"));
else
Pref->Val = NewStrBufPlain(HKEY("no"));
@@ -639,24 +594,21 @@ void set_preference_backend(const char *key, size_t keylen,
}
}
- if ((save_to_server != 0) &&
- GetHash(WCC->hash_prefs, key, keylen, &vPrefB) &&
- (vPrefB != NULL) &&
- (compare_preference (Pref, vPrefB) == 0))
+ if ((save_to_server != 0) &&
+ GetHash(WCC->hash_prefs, key, keylen, &vPrefB) && (vPrefB != NULL) && (compare_preference(Pref, vPrefB) == 0))
save_to_server = 0;
Put(WCC->hash_prefs, key, keylen, Pref, DestroyPreference);
-
- if (save_to_server) WCC->SavePrefsToServer = 1;
+
+ if (save_to_server)
+ WCC->SavePrefsToServer = 1;
}
-void set_PREFERENCE(const char *key, size_t keylen, StrBuf *value, int save_to_server)
-{
+void set_PREFERENCE(const char *key, size_t keylen, StrBuf * value, int save_to_server) {
set_preference_backend(key, keylen, 0, value, PRF_STRING, save_to_server, NULL);
}
-int get_PREF_LONG(const char *key, size_t keylen, long *value, long Default)
-{
+int get_PREF_LONG(const char *key, size_t keylen, long *value, long Default) {
Preference *Pref;
int Ret;
@@ -676,13 +628,11 @@ int get_PREF_LONG(const char *key, size_t keylen, long *value, long Default)
}
-void set_PREF_LONG(const char *key, size_t keylen, long value, int save_to_server)
-{
+void set_PREF_LONG(const char *key, size_t keylen, long value, int save_to_server) {
set_preference_backend(key, keylen, value, NULL, PRF_INT, save_to_server, NULL);
}
-int get_PREF_YESNO(const char *key, size_t keylen, int *value, int Default)
-{
+int get_PREF_YESNO(const char *key, size_t keylen, int *value, int Default) {
Preference *Pref;
int Ret;
@@ -701,18 +651,15 @@ int get_PREF_YESNO(const char *key, size_t keylen, int *value, int Default)
return Ret;
}
-void set_PREF_YESNO(const char *key, size_t keylen, long value, int save_to_server)
-{
+void set_PREF_YESNO(const char *key, size_t keylen, long value, int save_to_server) {
set_preference_backend(key, keylen, value, NULL, PRF_YESNO, save_to_server, NULL);
}
-int get_room_prefs_backend(const char *key, size_t keylen,
- Preference **Pref)
-{
+int get_room_prefs_backend(const char *key, size_t keylen, Preference ** Pref) {
StrBuf *pref_name;
int Ret;
- pref_name = NewStrBufPlain (HKEY("ROOM:"));
+ pref_name = NewStrBufPlain(HKEY("ROOM:"));
StrBufAppendBuf(pref_name, WC->CurRoom.name, 0);
StrBufAppendBufPlain(pref_name, HKEY(":"), 0);
StrBufAppendBufPlain(pref_name, key, keylen, 0);
@@ -722,14 +669,12 @@ int get_room_prefs_backend(const char *key, size_t keylen,
return Ret;
}
-const StrBuf *get_X_PREFS(const char *key, size_t keylen,
- const char *xkey, size_t xkeylen)
-{
+const StrBuf *get_X_PREFS(const char *key, size_t keylen, const char *xkey, size_t xkeylen) {
int ret;
StrBuf *pref_name;
Preference *Prf;
-
- pref_name = NewStrBufPlain (HKEY("XPREF:"));
+
+ pref_name = NewStrBufPlain(HKEY("XPREF:"));
StrBufAppendBufPlain(pref_name, xkey, xkeylen, 0);
StrBufAppendBufPlain(pref_name, HKEY(":"), 0);
StrBufAppendBufPlain(pref_name, key, keylen, 0);
@@ -739,14 +684,14 @@ const StrBuf *get_X_PREFS(const char *key, size_t keylen,
if (ret)
return Prf->Val;
- else return NULL;
+ else
+ return NULL;
}
-void set_X_PREFS(const char *key, size_t keylen, const char *xkey, size_t xkeylen, StrBuf *value, int save_to_server)
-{
+void set_X_PREFS(const char *key, size_t keylen, const char *xkey, size_t xkeylen, StrBuf * value, int save_to_server) {
StrBuf *pref_name;
-
- pref_name = NewStrBufPlain (HKEY("XPREF:"));
+
+ pref_name = NewStrBufPlain(HKEY("XPREF:"));
StrBufAppendBufPlain(pref_name, xkey, xkeylen, 0);
StrBufAppendBufPlain(pref_name, HKEY(":"), 0);
StrBufAppendBufPlain(pref_name, key, keylen, 0);
@@ -756,8 +701,7 @@ void set_X_PREFS(const char *key, size_t keylen, const char *xkey, size_t xkeyle
}
-long get_ROOM_PREFS_LONG(const char *key, size_t keylen, long *value, long Default)
-{
+long get_ROOM_PREFS_LONG(const char *key, size_t keylen, long *value, long Default) {
Preference *Pref;
int Ret;
@@ -778,8 +722,7 @@ long get_ROOM_PREFS_LONG(const char *key, size_t keylen, long *value, long Defau
}
-StrBuf *get_ROOM_PREFS(const char *key, size_t keylen)
-{
+StrBuf *get_ROOM_PREFS(const char *key, size_t keylen) {
Preference *Pref;
int Ret;
@@ -788,15 +731,14 @@ StrBuf *get_ROOM_PREFS(const char *key, size_t keylen)
if (Ret == 0) {
return NULL;
}
- else
+ else
return Pref->Val;
}
-void set_ROOM_PREFS(const char *key, size_t keylen, StrBuf *value, int save_to_server)
-{
+void set_ROOM_PREFS(const char *key, size_t keylen, StrBuf * value, int save_to_server) {
StrBuf *pref_name;
-
- pref_name = NewStrBufPlain (HKEY("ROOM:"));
+
+ pref_name = NewStrBufPlain(HKEY("ROOM:"));
StrBufAppendBuf(pref_name, WC->CurRoom.name, 0);
StrBufAppendBufPlain(pref_name, HKEY(":"), 0);
StrBufAppendBufPlain(pref_name, key, keylen, 0);
@@ -805,9 +747,8 @@ void set_ROOM_PREFS(const char *key, size_t keylen, StrBuf *value, int save_to_s
}
-void GetPreferences(HashList *Setting)
-{
- wcsession *WCC = WC;
+void GetPreferences(HashList * Setting) {
+ wcsession *WCC = WC;
HashPos *It;
long len;
const char *Key;
@@ -822,7 +763,7 @@ void GetPreferences(HashList *Setting)
It = GetNewHashPos(PreferenceHooks, 0);
while (GetNextHashPos(PreferenceHooks, It, &len, &Key, &vSetting)) {
- PrefType = (PrefDef*) vSetting;
+ PrefType = (PrefDef *) vSetting;
if (!HaveBstr(SKEY(PrefType->Setting)))
continue;
@@ -830,39 +771,19 @@ void GetPreferences(HashList *Setting)
case PRF_UNSET:
case PRF_STRING:
Buf = NewStrBufDup(SBstr(SKEY(PrefType->Setting)));
- set_preference_backend(SKEY(PrefType->Setting),
- 0,
- Buf,
- PRF_STRING,
- 1,
- PrefType);
+ set_preference_backend(SKEY(PrefType->Setting), 0, Buf, PRF_STRING, 1, PrefType);
break;
case PRF_INT:
lval = LBstr(SKEY(PrefType->Setting));
- set_preference_backend(SKEY(PrefType->Setting),
- lval,
- NULL,
- PRF_INT,
- 1,
- PrefType);
+ set_preference_backend(SKEY(PrefType->Setting), lval, NULL, PRF_INT, 1, PrefType);
break;
case PRF_QP_STRING:
Buf = NewStrBufDup(SBstr(SKEY(PrefType->Setting)));
- set_preference_backend(SKEY(PrefType->Setting),
- 0,
- Buf,
- PRF_QP_STRING,
- 1,
- PrefType);
+ set_preference_backend(SKEY(PrefType->Setting), 0, Buf, PRF_QP_STRING, 1, PrefType);
break;
case PRF_YESNO:
lval = YesBstr(SKEY(PrefType->Setting));
- set_preference_backend(SKEY(PrefType->Setting),
- lval,
- NULL,
- PRF_YESNO,
- 1,
- PrefType);
+ set_preference_backend(SKEY(PrefType->Setting), lval, NULL, PRF_YESNO, 1, PrefType);
break;
}
}
@@ -874,8 +795,7 @@ void GetPreferences(HashList *Setting)
/*
* Commit new preferences and settings
*/
-void set_preferences(void)
-{
+void set_preferences(void) {
if (!havebstr("change_button")) {
AppendImportantMessage(_("Cancelled. No settings were changed."), -1);
display_main_menu();
@@ -886,17 +806,14 @@ void set_preferences(void)
}
-void tmplput_CFG_Value(StrBuf *Target, WCTemplputParams *TP)
-{
+void tmplput_CFG_Value(StrBuf * Target, WCTemplputParams * TP) {
Preference *Pref;
- if (get_pref_backend(TKEY(0), &Pref))
- {
+ if (get_pref_backend(TKEY(0), &Pref)) {
if (Pref->Type == NULL) {
StrBufAppendTemplate(Target, TP, Pref->Val, 1);
}
- switch (Pref->Type->eType)
- {
- case PRF_UNSET: /* default to string... */
+ switch (Pref->Type->eType) {
+ case PRF_UNSET: /* default to string... */
case PRF_STRING:
StrBufAppendTemplate(Target, TP, Pref->Val, 1);
break;
@@ -913,7 +830,7 @@ void tmplput_CFG_Value(StrBuf *Target, WCTemplputParams *TP)
if (Pref->decoded != 1) {
if (Pref->DeQPed == NULL)
Pref->DeQPed = NewStrBufPlain(NULL, StrLength(Pref->Val));
-
+
StrBufEUid_unescapize(Pref->DeQPed, Pref->Val);
Pref->decoded = 1;
}
@@ -930,15 +847,13 @@ void tmplput_CFG_Value(StrBuf *Target, WCTemplputParams *TP)
}
}
-void tmplput_CFG_Descr(StrBuf *Target, WCTemplputParams *TP)
-{
+void tmplput_CFG_Descr(StrBuf * Target, WCTemplputParams * TP) {
const char *SettingStr;
SettingStr = PrefGetLocalStr(TKEY(0));
- if (SettingStr != NULL)
+ if (SettingStr != NULL)
StrBufAppendBufPlain(Target, SettingStr, -1, 0);
}
-void tmplput_CFG_RoomValueLong(StrBuf *Target, WCTemplputParams *TP)
-{
+void tmplput_CFG_RoomValueLong(StrBuf * Target, WCTemplputParams * TP) {
long lvalue;
long defval = 0;
@@ -947,55 +862,46 @@ void tmplput_CFG_RoomValueLong(StrBuf *Target, WCTemplputParams *TP)
get_ROOM_PREFS_LONG(TKEY(0), &lvalue, defval);
StrBufAppendPrintf(Target, "%ld", lvalue);
}
-void tmplput_CFG_RoomValue(StrBuf *Target, WCTemplputParams *TP)
-{
+void tmplput_CFG_RoomValue(StrBuf * Target, WCTemplputParams * TP) {
StrBuf *pref = get_ROOM_PREFS(TKEY(0));
- if (pref != NULL)
+ if (pref != NULL)
StrBufAppendBuf(Target, pref, 0);
}
-int ConditionalHasRoomPreference(StrBuf *Target, WCTemplputParams *TP)
-{
- if (get_ROOM_PREFS(TP->Tokens->Params[0]->Start,
- TP->Tokens->Params[0]->len) != NULL)
+int ConditionalHasRoomPreference(StrBuf * Target, WCTemplputParams * TP) {
+ if (get_ROOM_PREFS(TP->Tokens->Params[0]->Start, TP->Tokens->Params[0]->len) != NULL)
return 1;
-
+
return 0;
}
-int ConditionalPreference(StrBuf *Target, WCTemplputParams *TP)
-{
+int ConditionalPreference(StrBuf * Target, WCTemplputParams * TP) {
StrBuf *Pref;
- if (!get_PREFERENCE(TKEY(2), &Pref))
+ if (!get_PREFERENCE(TKEY(2), &Pref))
return 0;
-
+
if (!HAVE_PARAM(3)) {
return 1;
}
- else if (IS_NUMBER(TP->Tokens->Params[3]->Type))
- {
- return StrTol(Pref) == GetTemplateTokenNumber (Target, TP, 3, 0);
+ else if (IS_NUMBER(TP->Tokens->Params[3]->Type)) {
+ return StrTol(Pref) == GetTemplateTokenNumber(Target, TP, 3, 0);
}
- else
- {
+ else {
const char *pch;
long len;
-
+
GetTemplateTokenString(Target, TP, 3, &pch, &len);
-
- return ((len == StrLength(Pref)) &&
- (strcmp(pch, ChrPtr(Pref)) == 0));
+
+ return ((len == StrLength(Pref)) && (strcmp(pch, ChrPtr(Pref)) == 0));
}
}
-int ConditionalHasPreference(StrBuf *Target, WCTemplputParams *TP)
-{
+int ConditionalHasPreference(StrBuf * Target, WCTemplputParams * TP) {
StrBuf *Pref;
- if (!get_PREFERENCE(TKEY(2), &Pref) ||
- (Pref == NULL))
+ if (!get_PREFERENCE(TKEY(2), &Pref) || (Pref == NULL))
return 0;
- else
+ else
return 1;
}
@@ -1007,26 +913,22 @@ CtxType CTX_VEA = CTX_NONE;
typedef struct __ValidEmailAddress {
StrBuf *Address;
int IsDefault;
-}ValidEmailAddress;
+} ValidEmailAddress;
-void DeleteValidEmailAddress(void *v)
-{
- ValidEmailAddress *VEA = (ValidEmailAddress*)v;
+void DeleteValidEmailAddress(void *v) {
+ ValidEmailAddress *VEA = (ValidEmailAddress *) v;
FreeStrBuf(&VEA->Address);
free(VEA);
}
-void tmplput_VEA(StrBuf *Target, WCTemplputParams *TP)
-{
- ValidEmailAddress* VEA = (ValidEmailAddress*) CTX((CTX_VEA));
+void tmplput_VEA(StrBuf * Target, WCTemplputParams * TP) {
+ ValidEmailAddress *VEA = (ValidEmailAddress *) CTX((CTX_VEA));
StrBufAppendTemplate(Target, TP, VEA->Address, 0);
}
-int ConditionalPreferenceIsDefaulVEA(StrBuf *Target, WCTemplputParams *TP)
-{
- ValidEmailAddress* VEA = (ValidEmailAddress*) CTX((CTX_VEA));
+int ConditionalPreferenceIsDefaulVEA(StrBuf * Target, WCTemplputParams * TP) {
+ ValidEmailAddress *VEA = (ValidEmailAddress *) CTX((CTX_VEA));
return VEA->IsDefault;
}
-HashList *GetGVEAHash(StrBuf *Target, WCTemplputParams *TP)
-{
+HashList *GetGVEAHash(StrBuf * Target, WCTemplputParams * TP) {
StrBuf *Rcp;
HashList *List = NULL;
int Done = 0;
@@ -1044,14 +946,12 @@ HashList *GetGVEAHash(StrBuf *Target, WCTemplputParams *TP)
if (GetServerStatus(Rcp, NULL) == 1) {
FlushStrBuf(Rcp);
List = NewHash(1, NULL);
- while (!Done && (StrBuf_ServGetln(Rcp)>=0)) {
- if ( (StrLength(Rcp)==3) &&
- !strcmp(ChrPtr(Rcp), "000"))
- {
+ while (!Done && (StrBuf_ServGetln(Rcp) >= 0)) {
+ if ((StrLength(Rcp) == 3) && !strcmp(ChrPtr(Rcp), "000")) {
Done = 1;
}
else {
- VEA = (ValidEmailAddress*) malloc(sizeof(ValidEmailAddress));
+ VEA = (ValidEmailAddress *) malloc(sizeof(ValidEmailAddress));
i = snprintf(N, sizeof(N), "%d", n);
StrBufTrim(Rcp);
VEA->Address = Rcp;
@@ -1071,13 +971,11 @@ HashList *GetGVEAHash(StrBuf *Target, WCTemplputParams *TP)
FreeStrBuf(&Rcp);
return List;
}
-void DeleteGVEAHash(HashList **KillMe)
-{
+void DeleteGVEAHash(HashList ** KillMe) {
DeleteHash(KillMe);
}
-HashList *GetGVSNHash(StrBuf *Target, WCTemplputParams *TP)
-{
+HashList *GetGVSNHash(StrBuf * Target, WCTemplputParams * TP) {
StrBuf *Rcp;
HashList *List = NULL;
int Done = 0;
@@ -1090,10 +988,8 @@ HashList *GetGVSNHash(StrBuf *Target, WCTemplputParams *TP)
if (GetServerStatus(Rcp, NULL) == 1) {
FlushStrBuf(Rcp);
List = NewHash(1, NULL);
- while (!Done && (StrBuf_ServGetln(Rcp)>=0)) {
- if ( (StrLength(Rcp)==3) &&
- !strcmp(ChrPtr(Rcp), "000"))
- {
+ while (!Done && (StrBuf_ServGetln(Rcp) >= 0)) {
+ if ((StrLength(Rcp) == 3) && !strcmp(ChrPtr(Rcp), "000")) {
Done = 1;
}
else {
@@ -1108,8 +1004,7 @@ HashList *GetGVSNHash(StrBuf *Target, WCTemplputParams *TP)
FreeStrBuf(&Rcp);
return List;
}
-void DeleteGVSNHash(HashList **KillMe)
-{
+void DeleteGVSNHash(HashList ** KillMe) {
DeleteHash(KillMe);
}
@@ -1119,8 +1014,7 @@ void DeleteGVSNHash(HashList **KillMe)
/*
* Offer to make any page the user's "start page" (only if logged in)
*/
-void offer_start_page(StrBuf *Target, WCTemplputParams *TP)
-{
+void offer_start_page(StrBuf * Target, WCTemplputParams * TP) {
if (WC->logged_in) {
wc_printf("Hdr->this_page));
@@ -1134,8 +1028,7 @@ void offer_start_page(StrBuf *Target, WCTemplputParams *TP)
/*
* Change the user's start page
*/
-void change_start_page(void)
-{
+void change_start_page(void) {
const char *pch;
void *vHandler;
int ProhibitSave = 0;
@@ -1144,24 +1037,13 @@ void change_start_page(void)
if (pStartPage != NULL) {
pch = strchr(ChrPtr(pStartPage), '?');
- if ((pch != NULL) && (
- GetHash(HandlerHash, ChrPtr(pStartPage), pch - ChrPtr(pStartPage), &vHandler),
- (vHandler != NULL) &&
- ((((WebcitHandler*)vHandler)->Flags & PROHIBIT_STARTPAGE) != 0)))
- { /* OK, This handler doesn't want to be set as start page, prune it. */
+ if ((pch != NULL) && (GetHash(HandlerHash, ChrPtr(pStartPage), pch - ChrPtr(pStartPage), &vHandler), (vHandler != NULL) && ((((WebcitHandler *) vHandler)->Flags & PROHIBIT_STARTPAGE) != 0))) { /* OK, This handler doesn't want to be set as start page, prune it. */
ProhibitSave = 1;
}
}
- if ((pStartPage == NULL) ||
- (ProhibitSave == 1))
- {
- set_preference_backend(HKEY("startpage"),
- 0,
- NewStrBufPlain(HKEY("")),
- PRF_STRING,
- 1,
- NULL);
+ if ((pStartPage == NULL) || (ProhibitSave == 1)) {
+ set_preference_backend(HKEY("startpage"), 0, NewStrBufPlain(HKEY("")), PRF_STRING, 1, NULL);
if (ProhibitSave == 1)
AppendImportantMessage(_("This isn't allowed to become the start page."), -1);
else
@@ -1172,12 +1054,7 @@ void change_start_page(void)
- set_preference_backend(HKEY("startpage"),
- 0,
- NewStrBufDup(pStartPage),
- PRF_STRING,
- 1,
- NULL);
+ set_preference_backend(HKEY("startpage"), 0, NewStrBufDup(pStartPage), PRF_STRING, 1, NULL);
output_headers(1, 1, 0, 0, 0, 0);
do_template("newstartpage");
@@ -1185,8 +1062,7 @@ void change_start_page(void)
}
-void LoadStartpage(StrBuf *URL, long lvalue)
-{
+void LoadStartpage(StrBuf * URL, long lvalue) {
const char *pch;
void *vHandler;
pch = strchr(ChrPtr(URL), '?');
@@ -1198,20 +1074,14 @@ void LoadStartpage(StrBuf *URL, long lvalue)
WC->SavePrefsToServer = 1;
}
}
- else if (GetHash(HandlerHash, ChrPtr(URL), pch - ChrPtr(URL), &vHandler),
- (vHandler != NULL) &&
- ((((WebcitHandler*)vHandler)->Flags & PROHIBIT_STARTPAGE) != 0))
- { /* OK, This handler doesn't want to be set as start page, prune it. */
+ else if (GetHash(HandlerHash, ChrPtr(URL), pch - ChrPtr(URL), &vHandler), (vHandler != NULL) && ((((WebcitHandler *) vHandler)->Flags & PROHIBIT_STARTPAGE) != 0)) { /* OK, This handler doesn't want to be set as start page, prune it. */
FlushStrBuf(URL);
WC->SavePrefsToServer = 1;
}
}
-void
-InitModule_PREFERENCES
-(void)
-{
+void InitModule_PREFERENCES(void) {
RegisterCTX(CTX_VEA);
WebcitAddUrlHandler(HKEY("set_preferences"), "", 0, set_preferences, 0);
@@ -1220,63 +1090,46 @@ InitModule_PREFERENCES
RegisterPreference("startpage", _("Prefered startpage"), PRF_STRING, LoadStartpage);
RegisterNamespace("OFFERSTARTPAGE", 0, 0, offer_start_page, NULL, CTX_NONE);
- RegisterNamespace("PREF:ROOM:VALUE", 1, 2, tmplput_CFG_RoomValue, NULL, CTX_NONE);
- RegisterNamespace("PREF:ROOM:VALUE:INT", 1, 2, tmplput_CFG_RoomValueLong, NULL, CTX_NONE);
+ RegisterNamespace("PREF:ROOM:VALUE", 1, 2, tmplput_CFG_RoomValue, NULL, CTX_NONE);
+ RegisterNamespace("PREF:ROOM:VALUE:INT", 1, 2, tmplput_CFG_RoomValueLong, NULL, CTX_NONE);
RegisterNamespace("PREF:VALUE", 1, 2, tmplput_CFG_Value, NULL, CTX_NONE);
-
+
RegisterNamespace("PREF:DESCR", 1, 1, tmplput_CFG_Descr, NULL, CTX_NONE);
RegisterConditional("COND:PREF", 4, ConditionalPreference, CTX_NONE);
RegisterConditional("COND:PREF:SET", 4, ConditionalHasPreference, CTX_NONE);
RegisterConditional("COND:ROOM:SET", 4, ConditionalHasRoomPreference, CTX_NONE);
-
- RegisterIterator("PREF:VALID:EMAIL:ADDR", 0, NULL,
- GetGVEAHash, NULL, DeleteGVEAHash, CTX_VEA, CTX_NONE, IT_NOFLAG);
+
+ RegisterIterator("PREF:VALID:EMAIL:ADDR", 0, NULL, GetGVEAHash, NULL, DeleteGVEAHash, CTX_VEA, CTX_NONE, IT_NOFLAG);
RegisterNamespace("PREF:VALID:EMAIL:ADDR:STR", 1, 1, tmplput_VEA, NULL, CTX_VEA);
RegisterConditional("COND:PREF:VALID:EMAIL:ADDR:STR", 4, ConditionalPreferenceIsDefaulVEA, CTX_VEA);
- RegisterIterator("PREF:VALID:EMAIL:NAME", 0, NULL,
- GetGVSNHash, NULL, DeleteGVSNHash, CTX_STRBUF, CTX_NONE, IT_NOFLAG);
+ RegisterIterator("PREF:VALID:EMAIL:NAME", 0, NULL, GetGVSNHash, NULL, DeleteGVSNHash, CTX_STRBUF, CTX_NONE, IT_NOFLAG);
}
-void
-ServerStartModule_PREFERENCES
-(void)
-{
+void ServerStartModule_PREFERENCES(void) {
PreferenceHooks = NewHash(1, NULL);
}
-void
-ServerShutdownModule_PREFERENCES
-(void)
-{
+void ServerShutdownModule_PREFERENCES(void) {
DeleteHash(&PreferenceHooks);
}
-void
-SessionDetachModule__PREFERENCES
-(wcsession *sess)
-{
+void SessionDetachModule__PREFERENCES(wcsession * sess) {
if (sess->SavePrefsToServer) {
save_preferences();
sess->SavePrefsToServer = 0;
}
}
-void
-SessionNewModule_PREFERENCES
-(wcsession *sess)
-{
- sess->hash_prefs = NewHash(1,NULL);
+void SessionNewModule_PREFERENCES(wcsession * sess) {
+ sess->hash_prefs = NewHash(1, NULL);
}
-void
-SessionDestroyModule_PREFERENCES
-(wcsession *sess)
-{
+void SessionDestroyModule_PREFERENCES(wcsession * sess) {
DeleteHash(&sess->hash_prefs);
}
diff --git a/webcit/preferences.h b/webcit/preferences.h
index 7a30a7bbd..e1f9a0841 100644
--- a/webcit/preferences.h
+++ b/webcit/preferences.h
@@ -1,3 +1,4 @@
+
/*
* Copyright (c) 1996-2013 by the citadel.org team
*
@@ -11,7 +12,7 @@
*/
-typedef enum _ePrefType{
+typedef enum _ePrefType {
PRF_UNSET = 0,
PRF_STRING = 1,
PRF_INT = 2,
@@ -20,13 +21,10 @@ typedef enum _ePrefType{
} ePrefType;
-typedef void (*PrefEvalFunc)(StrBuf *Preference, long lvalue);
+typedef void (*PrefEvalFunc)(StrBuf * Preference, long lvalue);
-void _RegisterPreference(const char *Setting, long SettingLen,
- const char *PrefStr,
- ePrefType Type,
- PrefEvalFunc OnLoad,
- const char *OnLoadName);
+void _RegisterPreference(const char *Setting, long SettingLen,
+ const char *PrefStr, ePrefType Type, PrefEvalFunc OnLoad, const char *OnLoadName);
#define RegisterPreference(a, b, c, d) _RegisterPreference(a, sizeof(a) -1, b, c, d, #d)
@@ -34,10 +32,10 @@ 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(SKEY(a), b)
-int get_PREFERENCE(const char *key, size_t keylen, StrBuf **value);
+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(SKEY(a), b, c)
-void set_PREFERENCE(const char *key, size_t keylen, StrBuf *value, int save_to_server);
+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);
@@ -53,16 +51,15 @@ void set_PREF_YESNO(const char *key, size_t keylen, long value, int save_to_serv
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 set_ROOM_PREFS(const char *key, size_t keylen, StrBuf * value, int save_to_server);
#define get_room_pref_long(a, b, c) get_ROOM_PREFS_LONG(a, sizeof(a) - 1, b, c)
long get_ROOM_PREFS_LONG(const char *key, size_t keylen, long *value, long Default);
#define get_x_pref(a, b) get_ROOM_PREFS(a, sizeof(a) - 1, b, sizeof(b) - 1)
-const StrBuf *get_X_PREFS(const char *key, size_t keylen,
- const char *xkey, size_t xkeylen);
+const StrBuf *get_X_PREFS(const char *key, size_t keylen, const char *xkey, size_t xkeylen);
#define set_x_pref(a, b, c) set_ROOM_PREFS(a, sizeof(a) - 1, b, sizeof(b) - 1, c, d)
-void set_X_PREFS(const char *key, size_t keylen, const char *xkey, size_t xkeylen, StrBuf *value, int save_to_server);
+void set_X_PREFS(const char *key, size_t keylen, const char *xkey, size_t xkeylen, StrBuf * value, int save_to_server);
-int goto_config_room(StrBuf *Buf, folder *room);
+int goto_config_room(StrBuf * Buf, folder * room);
diff --git a/webcit/pushemail.c b/webcit/pushemail.c
index 92fd026b1..e3abeb698 100644
--- a/webcit/pushemail.c
+++ b/webcit/pushemail.c
@@ -1,22 +1,22 @@
+
/*
* Edits a users push email settings
* Author: Mathew McBride
*/
#include "webcit.h"
-void display_pushemail(void)
-{
+void display_pushemail(void) {
folder Room;
int Done = 0;
StrBuf *Buf;
- long vector[8] = {8, 0, 0, 1, 2, 3, 4, 5};
+ long vector[8] = { 8, 0, 0, 1, 2, 3, 4, 5 };
WCTemplputParams SubTP;
char mobnum[20];
StackContext(NULL, &SubTP, &vector, CTX_LONGVECTOR, 0, NULL);
vector[0] = 16;
- /* Find any existing settings*/
+ /* Find any existing settings */
Buf = NewStrBuf();
memset(&Room, 0, sizeof(folder));
if (goto_config_room(Buf, &Room) == 0) {
@@ -26,10 +26,8 @@ void display_pushemail(void)
if (GetServerStatus(Buf, NULL) == 8) {
serv_puts("subj|__ Push email settings __");
serv_puts("000");
- while (!Done &&
- StrBuf_ServGetln(Buf) >= 0) {
- if ( (StrLength(Buf)==3) &&
- !strcmp(ChrPtr(Buf), "000")) {
+ while (!Done && StrBuf_ServGetln(Buf) >= 0) {
+ if ((StrLength(Buf) == 3) && !strcmp(ChrPtr(Buf), "000")) {
Done = 1;
break;
}
@@ -37,48 +35,47 @@ void display_pushemail(void)
}
}
if (msgnum > 0L) {
- serv_printf("MSG0 %d", msgnum);
- StrBuf_ServGetln(Buf);
- if (GetServerStatus(Buf, NULL) == 1) {
- int i =0;
- Done = 0;
- while (!Done &&
- StrBuf_ServGetln(Buf) >= 0) {
- if (( (StrLength(Buf)==3) &&
- !strcmp(ChrPtr(Buf), "000"))||
- ((StrLength(Buf)==4) &&
- !strcmp(ChrPtr(Buf), "text")))
- {
- Done = 1;
- break;
- }
- }
- if (!strcmp(ChrPtr(Buf), "text")) {
+ serv_printf("MSG0 %d", msgnum);
+ StrBuf_ServGetln(Buf);
+ if (GetServerStatus(Buf, NULL) == 1) {
+ int i = 0;
Done = 0;
- while (!Done &&
- StrBuf_ServGetln(Buf) >= 0) {
- if ( (StrLength(Buf)==3) &&
- !strcmp(ChrPtr(Buf), "000")) {
+ while (!Done && StrBuf_ServGetln(Buf) >= 0) {
+ if (((StrLength(Buf) == 3) &&
+ !strcmp(ChrPtr(Buf), "000")) ||
+ ((StrLength(Buf) == 4) && !strcmp(ChrPtr(Buf), "text"))) {
Done = 1;
break;
}
- if (strncasecmp(ChrPtr(Buf), "none", 4) == 0) {
- vector[1] = 0;
- } else if (strncasecmp(ChrPtr(Buf), "textmessage", 11) == 0) {
- vector[1] = 1;
- i++;
- } else if (strncasecmp(ChrPtr(Buf), "funambol", 8) == 0) {
- vector[1] = 2;
- } else if (strncasecmp(ChrPtr(Buf), "httpmessage", 12) == 0) {
- vector[1] = 3;
- } else if (i == 1) {
- strncpy(mobnum, ChrPtr(Buf), 20);
- i++;
+ }
+ if (!strcmp(ChrPtr(Buf), "text")) {
+ Done = 0;
+ while (!Done && StrBuf_ServGetln(Buf) >= 0) {
+ if ((StrLength(Buf) == 3) && !strcmp(ChrPtr(Buf), "000")) {
+ Done = 1;
+ break;
+ }
+ if (strncasecmp(ChrPtr(Buf), "none", 4) == 0) {
+ vector[1] = 0;
+ }
+ else if (strncasecmp(ChrPtr(Buf), "textmessage", 11) == 0) {
+ vector[1] = 1;
+ i++;
+ }
+ else if (strncasecmp(ChrPtr(Buf), "funambol", 8) == 0) {
+ vector[1] = 2;
+ }
+ else if (strncasecmp(ChrPtr(Buf), "httpmessage", 12) == 0) {
+ vector[1] = 3;
+ }
+ else if (i == 1) {
+ strncpy(mobnum, ChrPtr(Buf), 20);
+ i++;
+ }
}
- }
+ }
}
}
- }
serv_printf("GOTO %s", ChrPtr(WC->CurRoom.name));
StrBuf_ServGetln(Buf);
GetServerStatus(Buf, NULL);
@@ -91,8 +88,7 @@ void display_pushemail(void)
FreeStrBuf(&Buf);
}
-void save_pushemail(void)
-{
+void save_pushemail(void) {
folder Room;
int Done = 0;
StrBuf *Buf;
@@ -109,7 +105,7 @@ void save_pushemail(void)
if (goto_config_room(Buf, &Room) != 0) {
FreeStrBuf(&Buf);
FlushFolder(&Room);
- return; /* oh well. */
+ return; /* oh well. */
}
FlushFolder(&Room);
@@ -118,16 +114,15 @@ void save_pushemail(void)
if (GetServerStatus(Buf, NULL) == 8) {
serv_puts("subj|__ Push email settings __");
serv_puts("000");
- } else {
+ }
+ else {
printf("Junk in save_pushemail buffer!: %s\n", buf);
FreeStrBuf(&Buf);
return;
}
- while (!Done &&
- StrBuf_ServGetln(Buf) >= 0) {
- if ( (StrLength(Buf)==3) &&
- !strcmp(ChrPtr(Buf), "000")) {
+ while (!Done && StrBuf_ServGetln(Buf) >= 0) {
+ if ((StrLength(Buf) == 3) && !strcmp(ChrPtr(Buf), "000")) {
Done = 1;
break;
}
@@ -145,8 +140,8 @@ void save_pushemail(void)
if (GetServerStatus(Buf, NULL) == 4) {
serv_puts(pushsetting);
if (sms != NULL) {
- serv_puts(sms);
- }
+ serv_puts(sms);
+ }
serv_puts("");
serv_puts("000");
}
@@ -159,10 +154,7 @@ void save_pushemail(void)
FreeStrBuf(&Buf);
}
-void
-InitModule_PUSHMAIL
-(void)
-{
+void InitModule_PUSHMAIL(void) {
WebcitAddUrlHandler(HKEY("display_pushemail"), "", 0, display_pushemail, 0);
WebcitAddUrlHandler(HKEY("save_pushemail"), "", 0, save_pushemail, 0);
}
diff --git a/webcit/roomchat.c b/webcit/roomchat.c
index 3b0091e44..21c27f7f8 100644
--- a/webcit/roomchat.c
+++ b/webcit/roomchat.c
@@ -1,3 +1,4 @@
+
/*
* This module handles multiuser chat.
*
@@ -18,8 +19,7 @@
/*
* Display the screen containing multiuser chat for a room.
*/
-void do_chat(void)
-{
+void do_chat(void) {
char buf[256];
WC->last_chat_seq = 0;
@@ -141,15 +141,12 @@ void chat_exit(void) {
char buf[1024];
serv_puts("RCHT exit");
- serv_getln(buf, sizeof buf); /* Throw away the server reply */
+ serv_getln(buf, sizeof buf); /* Throw away the server reply */
}
-void
-InitModule_ROOMCHAT
-(void)
-{
+void InitModule_ROOMCHAT(void) {
WebcitAddUrlHandler(HKEY("chat"), "", 0, do_chat, 0);
WebcitAddUrlHandler(HKEY("chat_recv"), "", 0, chat_recv, AJAX);
WebcitAddUrlHandler(HKEY("chat_rwho"), "", 0, chat_rwho, AJAX);
@@ -158,9 +155,6 @@ InitModule_ROOMCHAT
}
-void
-SessionDestroyModule_ROOMCHAT
-(wcsession *sess)
-{
+void SessionDestroyModule_ROOMCHAT(wcsession * sess) {
/* nothing here anymore */
}
diff --git a/webcit/roomlist.c b/webcit/roomlist.c
index b9f967ce6..695a7a01a 100644
--- a/webcit/roomlist.c
+++ b/webcit/roomlist.c
@@ -1,3 +1,4 @@
+
/*
* room listings and filters.
*/
@@ -9,10 +10,9 @@ typedef enum __eRoomParamType {
eNotSet,
eDomain,
eAlias
-}eRoomParamType;
+} eRoomParamType;
-HashList *GetWhoKnowsHash(StrBuf *Target, WCTemplputParams *TP)
-{
+HashList *GetWhoKnowsHash(StrBuf * Target, WCTemplputParams * TP) {
StrBuf *Line;
StrBuf *Token;
long State;
@@ -23,26 +23,19 @@ HashList *GetWhoKnowsHash(StrBuf *Target, WCTemplputParams *TP)
serv_puts("WHOK");
Line = NewStrBuf();
StrBuf_ServGetln(Line);
- if (GetServerStatus(Line, &State) == 1)
- {
+ if (GetServerStatus(Line, &State) == 1) {
Whok = NewHash(1, Flathash);
- while(!Done && (StrBuf_ServGetln(Line) >= 0) )
- if ( (StrLength(Line)==3) &&
- !strcmp(ChrPtr(Line), "000"))
- {
+ while (!Done && (StrBuf_ServGetln(Line) >= 0))
+ if ((StrLength(Line) == 3) && !strcmp(ChrPtr(Line), "000")) {
Done = 1;
}
- else
- {
-
+ else {
+
const char *Pos = NULL;
- Token = NewStrBufPlain (NULL, StrLength(Line));
+ Token = NewStrBufPlain(NULL, StrLength(Line));
StrBufExtract_NextToken(Token, Line, &Pos, '|');
- Put(Whok,
- IKEY(n),
- Token,
- HFreeStrBuf);
+ Put(Whok, IKEY(n), Token, HFreeStrBuf);
n++;
}
}
@@ -55,19 +48,17 @@ HashList *GetWhoKnowsHash(StrBuf *Target, WCTemplputParams *TP)
}
-void DeleteFloor(void *vFloor)
-{
+void DeleteFloor(void *vFloor) {
Floor *pFloor;
- pFloor = (Floor*) vFloor;
+ pFloor = (Floor *) vFloor;
FreeStrBuf(&pFloor->Name);
free(pFloor);
}
-int SortFloorsByNameOrder(const void *vfloor1, const void *vfloor2)
-{
- Floor *f1 = (Floor*) GetSearchPayload(vfloor1);
- Floor *f2 = (Floor*) GetSearchPayload(vfloor2);
-
+int SortFloorsByNameOrder(const void *vfloor1, const void *vfloor2) {
+ Floor *f1 = (Floor *) GetSearchPayload(vfloor1);
+ Floor *f2 = (Floor *) GetSearchPayload(vfloor2);
+
/* prefer My floor over alpabetical sort */
if (f1->ID == VIRTUAL_MY_FLOOR)
return 1;
@@ -77,8 +68,7 @@ int SortFloorsByNameOrder(const void *vfloor1, const void *vfloor2)
return strcmp(ChrPtr(f1->Name), ChrPtr(f2->Name));
}
-HashList *GetFloorListHash(StrBuf *Target, WCTemplputParams *TP)
-{
+HashList *GetFloorListHash(StrBuf * Target, WCTemplputParams * TP) {
int Done = 0;
const char *Err;
StrBuf *Buf;
@@ -100,30 +90,26 @@ HashList *GetFloorListHash(StrBuf *Target, WCTemplputParams *TP)
WCC->FloorsByName = floorsbyname = NewHash(1, NULL);
Buf = NewStrBuf();
- pFloor = (Floor*) malloc(sizeof(Floor));
+ pFloor = (Floor *) malloc(sizeof(Floor));
pFloor->ID = VIRTUAL_MY_FLOOR;
pFloor->Name = NewStrBufPlain(_("My Folders"), -1);
pFloor->NRooms = 0;
-
+
Put(floors, IKEY(pFloor->ID), pFloor, DeleteFloor);
Put(floorsbyname, SKEY(pFloor->Name), pFloor, reference_free_handler);
- serv_puts("LFLR"); /* get floors */
- StrBufTCP_read_line(Buf, &WC->serv_sock, 0, &Err); /* '100', we hope */
- if (GetServerStatus(Buf, NULL) == 1)
- {
- while(!Done && StrBuf_ServGetln(Buf) >= 0)
- if ( (StrLength(Buf)==3) &&
- !strcmp(ChrPtr(Buf), "000"))
- {
+ serv_puts("LFLR"); /* get floors */
+ StrBufTCP_read_line(Buf, &WC->serv_sock, 0, &Err); /* '100', we hope */
+ if (GetServerStatus(Buf, NULL) == 1) {
+ while (!Done && StrBuf_ServGetln(Buf) >= 0)
+ if ((StrLength(Buf) == 3) && !strcmp(ChrPtr(Buf), "000")) {
Done = 1;
}
- else
- {
-
+ else {
+
Pos = NULL;
- pFloor = (Floor*) malloc(sizeof(Floor));
+ pFloor = (Floor *) malloc(sizeof(Floor));
pFloor->ID = StrBufExtractNext_int(Buf, &Pos, '|');
pFloor->Name = NewStrBufPlain(NULL, StrLength(Buf));
StrBufExtract_NextToken(pFloor->Name, Buf, &Pos, '|');
@@ -134,21 +120,20 @@ HashList *GetFloorListHash(StrBuf *Target, WCTemplputParams *TP)
}
}
FreeStrBuf(&Buf);
-
+
/* now lets pre-sort them alphabeticaly. */
i = 1;
SortByPayload(floors, SortFloorsByNameOrder);
it = GetNewHashPos(floors, 0);
- while ( GetNextHashPos(floors, it, &HKLen, &HashKey, &vFloor))
- ((Floor*) vFloor)->AlphaN = i++;
+ while (GetNextHashPos(floors, it, &HKLen, &HashKey, &vFloor))
+ ((Floor *) vFloor)->AlphaN = i++;
DeleteHashPos(&it);
SortByHashKeyStr(floors);
return floors;
}
-HashList *GetZappedRoomListHash(StrBuf *Target, WCTemplputParams *TP)
-{
+HashList *GetZappedRoomListHash(StrBuf * Target, WCTemplputParams * TP) {
wcsession *WCC = WC;
if (WCC->Floors == NULL)
@@ -156,32 +141,27 @@ HashList *GetZappedRoomListHash(StrBuf *Target, WCTemplputParams *TP)
serv_puts("LZRM -1");
return GetRoomListHash(Target, TP);
}
-HashList *GetRoomListHashLKRA(StrBuf *Target, WCTemplputParams *TP)
-{
+HashList *GetRoomListHashLKRA(StrBuf * Target, WCTemplputParams * TP) {
wcsession *WCC = WC;
if (WCC->Floors == NULL)
GetFloorListHash(Target, TP);
- if (WCC->Rooms == NULL)
- {
+ if (WCC->Rooms == NULL) {
serv_puts("LKRA");
- WCC->Rooms = GetRoomListHash(Target, TP);
+ WCC->Rooms = GetRoomListHash(Target, TP);
}
return WCC->Rooms;
}
-HashList *GetRoomListHashLPRM(StrBuf *Target, WCTemplputParams *TP)
-{
+HashList *GetRoomListHashLPRM(StrBuf * Target, WCTemplputParams * TP) {
serv_puts("LPRM");
return GetRoomListHash(Target, TP);
}
-void FlushIgnetCfgs(folder *room)
-{
+void FlushIgnetCfgs(folder * room) {
int i;
- if (room->IgnetCfgs[maxRoomNetCfg] == (HashList*) StrBufNOTNULL)
- {
+ if (room->IgnetCfgs[maxRoomNetCfg] == (HashList *) StrBufNOTNULL) {
for (i = ignet_push_share; i < maxRoomNetCfg; i++)
DeleteHash(&room->IgnetCfgs[i]);
}
@@ -190,8 +170,7 @@ void FlushIgnetCfgs(folder *room)
}
-void FlushFolder(folder *room)
-{
+void FlushFolder(folder * room) {
int i;
FreeStrBuf(&room->XAPass);
@@ -204,28 +183,25 @@ void FlushFolder(folder *room)
FlushIgnetCfgs(room);
- if (room->RoomNameParts != NULL)
- {
- for (i=0; i < room->nRoomNameParts; i++)
+ if (room->RoomNameParts != NULL) {
+ for (i = 0; i < room->nRoomNameParts; i++)
FreeStrBuf(&room->RoomNameParts[i]);
free(room->RoomNameParts);
}
memset(room, 0, sizeof(folder));
}
-void vDeleteFolder(void *vFolder)
-{
+void vDeleteFolder(void *vFolder) {
folder *room;
- room = (folder*) vFolder;
+ room = (folder *) vFolder;
FlushFolder(room);
free(room);
}
-HashList *GetRoomListHash(StrBuf *Target, WCTemplputParams *TP)
-{
+HashList *GetRoomListHash(StrBuf * Target, WCTemplputParams * TP) {
int Done = 0;
HashList *rooms;
folder *room;
@@ -239,18 +215,14 @@ HashList *GetRoomListHash(StrBuf *Target, WCTemplputParams *TP)
Buf = NewStrBuf();
rooms = NewHash(1, NULL);
StrBuf_ServGetln(Buf);
- if (GetServerStatus(Buf, NULL) == 1)
- {
- while(!Done && (StrBuf_ServGetln(Buf) >= 0))
- if ( (StrLength(Buf)==3) &&
- !strcmp(ChrPtr(Buf), "000"))
- {
+ if (GetServerStatus(Buf, NULL) == 1) {
+ while (!Done && (StrBuf_ServGetln(Buf) >= 0))
+ if ((StrLength(Buf) == 3) && !strcmp(ChrPtr(Buf), "000")) {
Done = 1;
}
- else
- {
+ else {
Pos = NULL;
- room = (folder*) malloc (sizeof(folder));
+ room = (folder *) malloc(sizeof(folder));
memset(room, 0, sizeof(folder));
/* Load the base data from the server reply */
@@ -277,37 +249,30 @@ HashList *GetRoomListHash(StrBuf *Target, WCTemplputParams *TP)
/* Evaluate the Server sent data for later use */
/* find out, whether we are in a sub-room */
room->nRoomNameParts = StrBufNum_tokens(room->name, '\\');
- if (room->nRoomNameParts > 1)
- {
+ if (room->nRoomNameParts > 1) {
int i;
Pos = NULL;
- room->RoomNameParts = malloc(sizeof(StrBuf*) * (room->nRoomNameParts + 1));
- memset(room->RoomNameParts, 0, sizeof(StrBuf*) * (room->nRoomNameParts + 1));
- for (i=0; i < room->nRoomNameParts; i++)
- {
+ room->RoomNameParts = malloc(sizeof(StrBuf *) * (room->nRoomNameParts + 1));
+ memset(room->RoomNameParts, 0, sizeof(StrBuf *) * (room->nRoomNameParts + 1));
+ for (i = 0; i < room->nRoomNameParts; i++) {
room->RoomNameParts[i] = NewStrBuf();
- StrBufExtract_NextToken(room->RoomNameParts[i],
- room->name, &Pos, '\\');
+ StrBufExtract_NextToken(room->RoomNameParts[i], room->name, &Pos, '\\');
}
}
/* Private mailboxes on the main floor get remapped to the personal folder */
- if ((room->QRFlags & QR_MAILBOX) &&
- (room->floorid == 0))
- {
+ if ((room->QRFlags & QR_MAILBOX) && (room->floorid == 0)) {
room->floorid = VIRTUAL_MY_FLOOR;
- if ((room->nRoomNameParts == 1) &&
- (StrLength(room->name) == 4) &&
- (strcmp(ChrPtr(room->name), "Mail") == 0))
- {
+ if ((room->nRoomNameParts == 1) &&
+ (StrLength(room->name) == 4) && (strcmp(ChrPtr(room->name), "Mail") == 0)) {
room->is_inbox = 1;
}
}
/* get a pointer to the floor we're on: */
GetHash(WCC->Floors, IKEY(room->floorid), &vFloor);
- room->Floor = (const Floor*) vFloor;
+ room->Floor = (const Floor *) vFloor;
@@ -320,14 +285,13 @@ HashList *GetRoomListHash(StrBuf *Target, WCTemplputParams *TP)
SortIt = RetrieveSort(&SubTP, NULL, 0, HKEY("fileunsorted"), 0);
if (SortIt != NULL)
SortByPayload(rooms, SortIt);
- else
+ else
SortByPayload(rooms, SortRoomsByListOrder);
FreeStrBuf(&Buf);
return rooms;
}
-HashList *GetThisRoomMAlias(StrBuf *Target, WCTemplputParams *TP)
-{
+HashList *GetThisRoomMAlias(StrBuf * Target, WCTemplputParams * TP) {
wcsession *WCC = WC;
StrBuf *Line;
StrBuf *Token;
@@ -336,24 +300,20 @@ HashList *GetThisRoomMAlias(StrBuf *Target, WCTemplputParams *TP)
long aliaslen;
long locallen;
long State;
-
- serv_puts("GNET "FILE_MAILALIAS);
+
+ serv_puts("GNET " FILE_MAILALIAS);
Line = NewStrBuf();
StrBuf_ServGetln(Line);
- if (GetServerStatus(Line, &State) == 1)
- {
+ if (GetServerStatus(Line, &State) == 1) {
int Done = 0;
int n = 0;
Aliases = NewHash(1, NULL);
- while(!Done && (StrBuf_ServGetln(Line) >= 0))
- if ( (StrLength(Line)==3) &&
- !strcmp(ChrPtr(Line), "000"))
- {
+ while (!Done && (StrBuf_ServGetln(Line) >= 0))
+ if ((StrLength(Line) == 3) && !strcmp(ChrPtr(Line), "000")) {
Done = 1;
}
- else
- {
+ else {
pComma = strchr(ChrPtr(Line), ',');
if (pComma == NULL)
continue;
@@ -367,10 +327,7 @@ HashList *GetThisRoomMAlias(StrBuf *Target, WCTemplputParams *TP)
if (strcasecmp(pComma + 6, ChrPtr(WCC->CurRoom.name)) != 0)
continue;
Token = NewStrBufPlain(ChrPtr(Line), aliaslen);
- Put(Aliases,
- IKEY(n),
- Token,
- HFreeStrBuf);
+ Put(Aliases, IKEY(n), Token, HFreeStrBuf);
n++;
}
}
@@ -383,15 +340,9 @@ HashList *GetThisRoomMAlias(StrBuf *Target, WCTemplputParams *TP)
}
-void AppendPossibleAliasWithDomain(
- HashList *PossibleAliases,
- long *nPossibleAliases,
- const HashList *Domains,
- const char *prefix,
- long len,
- const char* Alias,
- long AliasLen)
-{
+void AppendPossibleAliasWithDomain(HashList * PossibleAliases,
+ long *nPossibleAliases,
+ const HashList * Domains, const char *prefix, long len, const char *Alias, long AliasLen) {
const StrBuf *OneDomain;
StrBuf *Line;
HashPos *It = NULL;
@@ -402,34 +353,29 @@ void AppendPossibleAliasWithDomain(
It = GetNewHashPos(Domains, 1);
n = *nPossibleAliases;
- while (GetNextHashPos(Domains, It, &KLen, &Key, &pV))
- {
- OneDomain = (const StrBuf*) pV;
+ while (GetNextHashPos(Domains, It, &KLen, &Key, &pV)) {
+ OneDomain = (const StrBuf *) pV;
Line = NewStrBuf();
StrBufAppendBufPlain(Line, prefix, len, 0);
StrBufAppendBufPlain(Line, Alias, AliasLen, 0);
StrBufAppendBufPlain(Line, HKEY("@"), 0);
StrBufAppendBuf(Line, OneDomain, 0);
- Put(PossibleAliases,
- IKEY(n),
- Line,
- HFreeStrBuf);
+ Put(PossibleAliases, IKEY(n), Line, HFreeStrBuf);
n++;
}
DeleteHashPos(&It);
*nPossibleAliases = n;
}
-HashList *GetThisRoomPossibleMAlias(StrBuf *Target, WCTemplputParams *TP)
-{
+HashList *GetThisRoomPossibleMAlias(StrBuf * Target, WCTemplputParams * TP) {
wcsession *WCC = WC;
HashList *Domains;
StrBuf *Line;
StrBuf *Token;
StrBuf *RoomName;
HashList *PossibleAliases = NULL;
-
+
const char *pComma;
const char *pAt;
long aliaslen;
@@ -450,27 +396,19 @@ HashList *GetThisRoomPossibleMAlias(StrBuf *Target, WCTemplputParams *TP)
StrBufAsciify(RoomName, '_');
StrBufReplaceChars(RoomName, ' ', '_');
- AppendPossibleAliasWithDomain(PossibleAliases,
- &n,
- Domains,
- HKEY("room_"),
- SKEY(RoomName));
+ AppendPossibleAliasWithDomain(PossibleAliases, &n, Domains, HKEY("room_"), SKEY(RoomName));
- serv_puts("GNET "FILE_MAILALIAS);
+ serv_puts("GNET " FILE_MAILALIAS);
StrBuf_ServGetln(Line);
- if (GetServerStatus(Line, &State) == 1)
- {
+ if (GetServerStatus(Line, &State) == 1) {
int Done = 0;
- while(!Done && (StrBuf_ServGetln(Line) >= 0))
- if ( (StrLength(Line)==3) &&
- !strcmp(ChrPtr(Line), "000"))
- {
+ while (!Done && (StrBuf_ServGetln(Line) >= 0))
+ if ((StrLength(Line) == 3) && !strcmp(ChrPtr(Line), "000")) {
Done = 1;
}
- else
- {
+ else {
pComma = strchr(ChrPtr(Line), ',');
if (pComma == NULL)
continue;
@@ -484,24 +422,15 @@ HashList *GetThisRoomPossibleMAlias(StrBuf *Target, WCTemplputParams *TP)
if (strcasecmp(pComma + 6, ChrPtr(WCC->CurRoom.name)) != 0)
continue;
pAt = strchr(ChrPtr(Line), '@');
- if ((pAt == NULL) || (pAt > pComma))
- {
+ if ((pAt == NULL) || (pAt > pComma)) {
AppendPossibleAliasWithDomain(PossibleAliases,
- &n,
- Domains,
- HKEY(""),
- ChrPtr(Line),
- aliaslen);
+ &n, Domains, HKEY(""), ChrPtr(Line), aliaslen);
n++;
}
- else
- {
-
+ else {
+
Token = NewStrBufPlain(ChrPtr(Line), aliaslen);
- Put(PossibleAliases,
- IKEY(n),
- Token,
- HFreeStrBuf);
+ Put(PossibleAliases, IKEY(n), Token, HFreeStrBuf);
n++;
}
}
@@ -515,8 +444,7 @@ HashList *GetThisRoomPossibleMAlias(StrBuf *Target, WCTemplputParams *TP)
}
-HashList *GetNetConfigHash(StrBuf *Target, WCTemplputParams *TP)
-{
+HashList *GetNetConfigHash(StrBuf * Target, WCTemplputParams * TP) {
wcsession *WCC = WC;
StrBuf *Line;
StrBuf *Token;
@@ -524,65 +452,51 @@ HashList *GetNetConfigHash(StrBuf *Target, WCTemplputParams *TP)
long WantThisOne;
long PutTo;
long State;
-
+
WantThisOne = GetTemplateTokenNumber(Target, TP, 5, -1);
if ((WantThisOne < 0) || (WantThisOne > maxRoomNetCfg))
return NULL;
- if (WCC->CurRoom.IgnetCfgs[maxRoomNetCfg] == (HashList*) StrBufNOTNULL)
+ if (WCC->CurRoom.IgnetCfgs[maxRoomNetCfg] == (HashList *) StrBufNOTNULL)
return WCC->CurRoom.IgnetCfgs[WantThisOne];
- WCC->CurRoom.IgnetCfgs[maxRoomNetCfg] = (HashList*) StrBufNOTNULL;
+ WCC->CurRoom.IgnetCfgs[maxRoomNetCfg] = (HashList *) StrBufNOTNULL;
serv_puts("GNET");
Line = NewStrBuf();
Token = NewStrBuf();
StrBuf_ServGetln(Line);
- if (GetServerStatus(Line, &State) == 1)
- {
+ if (GetServerStatus(Line, &State) == 1) {
const char *Pos = NULL;
int Done = 0;
int HaveRoomMailAlias = 0;
- while(!Done && (StrBuf_ServGetln(Line) >= 0))
- {
+ while (!Done && (StrBuf_ServGetln(Line) >= 0)) {
if (StrLength(Line) == 0)
continue;
- if ( (StrLength(Line)==3) &&
- !strcmp(ChrPtr(Line), "000"))
- {
+ if ((StrLength(Line) == 3) && !strcmp(ChrPtr(Line), "000")) {
Done = 1;
}
- else
- {
+ else {
StrBufExtract_NextToken(Token, Line, &Pos, '|');
PutTo = GetTokenDefine(SKEY(Token), -1);
- if (PutTo == roommailalias)
- {
+ if (PutTo == roommailalias) {
if (HaveRoomMailAlias > 0)
- continue; /* Only ONE alias possible! */
+ continue; /* Only ONE alias possible! */
HaveRoomMailAlias++;
}
- if ((PutTo >= 0) &&
- (PutTo < maxRoomNetCfg) &&
- (Pos != StrBufNOTNULL))
- {
+ if ((PutTo >= 0) && (PutTo < maxRoomNetCfg) && (Pos != StrBufNOTNULL)) {
int n;
HashList *SubH;
-
- if (WCC->CurRoom.IgnetCfgs[PutTo] == NULL)
- {
+
+ if (WCC->CurRoom.IgnetCfgs[PutTo] == NULL) {
n = 0;
WCC->CurRoom.IgnetCfgs[PutTo] = NewHash(1, NULL);
}
- else
- {
+ else {
n = GetCount(WCC->CurRoom.IgnetCfgs[PutTo]);
}
SubH = NewHash(1, NULL);
- Put(WCC->CurRoom.IgnetCfgs[PutTo],
- IKEY(n),
- SubH,
- HDeleteHash);
- n = 1; /* #0 is the type... */
+ Put(WCC->CurRoom.IgnetCfgs[PutTo], IKEY(n), SubH, HDeleteHash);
+ n = 1; /* #0 is the type... */
while (Pos != StrBufNOTNULL) {
Content = NewStrBuf();
StrBufExtract_NextToken(Content, Line, &Pos, '|');
@@ -590,10 +504,7 @@ HashList *GetNetConfigHash(StrBuf *Target, WCTemplputParams *TP)
if ((PutTo == roommailalias) && n == 1)
WCC->CurRoom.RoomAlias = Content;
- Put(SubH,
- IKEY(n),
- Content,
- HFreeStrBuf);
+ Put(SubH, IKEY(n), Content, HFreeStrBuf);
n++;
}
}
@@ -611,30 +522,29 @@ HashList *GetNetConfigHash(StrBuf *Target, WCTemplputParams *TP)
}
/** Unused function that orders rooms by the listorder flag */
-int SortRoomsByListOrder(const void *room1, const void *room2)
-{
- folder *r1 = (folder*) GetSearchPayload(room1);
- folder *r2 = (folder*) GetSearchPayload(room2);
-
- if (r1->Order == r2->Order) return 0;
- if (r1->Order > r2->Order) return 1;
+int SortRoomsByListOrder(const void *room1, const void *room2) {
+ folder *r1 = (folder *) GetSearchPayload(room1);
+ folder *r2 = (folder *) GetSearchPayload(room2);
+
+ if (r1->Order == r2->Order)
+ return 0;
+ if (r1->Order > r2->Order)
+ return 1;
return -1;
}
-int CompareRoomListByFloorRoomPrivFirst(const void *room1, const void *room2)
-{
- folder *r1 = (folder*) GetSearchPayload(room1);
- folder *r2 = (folder*) GetSearchPayload(room2);
-
- if ((r1->Floor == NULL) ||
- (r2->Floor == NULL))
+int CompareRoomListByFloorRoomPrivFirst(const void *room1, const void *room2) {
+ folder *r1 = (folder *) GetSearchPayload(room1);
+ folder *r2 = (folder *) GetSearchPayload(room2);
+
+ if ((r1->Floor == NULL) || (r2->Floor == NULL))
return 0;
-
+
/**
* are we on the same floor? else sort by floor.
*/
- if (r1->Floor != r2->Floor)
- {
+ if (r1->Floor != r2->Floor) {
+
/**
* the private rooms are first in any case.
*/
@@ -642,10 +552,11 @@ int CompareRoomListByFloorRoomPrivFirst(const void *room1, const void *room2)
return -1;
if (r2->Floor->ID == VIRTUAL_MY_FLOOR)
return 1;
+
/**
* else decide alpaheticaly by floorname
*/
- return (r1->Floor->AlphaN > r2->Floor->AlphaN)? 1 : -1;
+ return (r1->Floor->AlphaN > r2->Floor->AlphaN) ? 1 : -1;
}
/**
@@ -653,22 +564,17 @@ int CompareRoomListByFloorRoomPrivFirst(const void *room1, const void *room2)
* we want the toplevel to be first, regardless of sort
* sequence.
*/
- if (((r1->nRoomNameParts > 1) ||
- (r2->nRoomNameParts > 1) )&&
- (r1->nRoomNameParts != r2->nRoomNameParts))
- {
+ if (((r1->nRoomNameParts > 1) || (r2->nRoomNameParts > 1)) && (r1->nRoomNameParts != r2->nRoomNameParts)) {
int i, ret;
- int nparts = (r1->nRoomNameParts > r2->nRoomNameParts)?
- r2->nRoomNameParts : r1->nRoomNameParts;
+ int nparts = (r1->nRoomNameParts > r2->nRoomNameParts) ? r2->nRoomNameParts : r1->nRoomNameParts;
+
+ for (i = 0; i < nparts; i++) {
+ ret = strcmp(ChrPtr(r1->name), ChrPtr(r2->name));
- for (i=0; i < nparts; i++)
- {
- ret = strcmp (ChrPtr(r1->name),
- ChrPtr(r2->name));
/**
* Deltas in common parts? exit here.
*/
- if (ret != 0)
+ if (ret != 0)
return ret;
}
@@ -685,24 +591,21 @@ int CompareRoomListByFloorRoomPrivFirst(const void *room1, const void *room2)
/**
* else just sort alphabeticaly.
*/
- return strcmp (ChrPtr(r1->name),
- ChrPtr(r2->name));
+ return strcmp(ChrPtr(r1->name), ChrPtr(r2->name));
}
-int CompareRoomListByFloorRoomPrivFirstRev(const void *room1, const void *room2)
-{
- folder *r1 = (folder*) GetSearchPayload(room1);
- folder *r2 = (folder*) GetSearchPayload(room2);
+int CompareRoomListByFloorRoomPrivFirstRev(const void *room1, const void *room2) {
+ folder *r1 = (folder *) GetSearchPayload(room1);
+ folder *r2 = (folder *) GetSearchPayload(room2);
- if ((r1->Floor == NULL) ||
- (r2->Floor == NULL))
+ if ((r1->Floor == NULL) || (r2->Floor == NULL))
return 0;
/**
* are we on the same floor? else sort by floor.
*/
- if (r2->Floor != r1->Floor)
- {
+ if (r2->Floor != r1->Floor) {
+
/**
* the private rooms are first in any case.
*/
@@ -710,11 +613,12 @@ int CompareRoomListByFloorRoomPrivFirstRev(const void *room1, const void *room2)
return -1;
if (r2->Floor->ID == VIRTUAL_MY_FLOOR)
return 1;
+
/**
* else decide alpaheticaly by floorname
*/
- return (r1->Floor->AlphaN < r2->Floor->AlphaN)? 1 : -1;
+ return (r1->Floor->AlphaN < r2->Floor->AlphaN) ? 1 : -1;
}
/**
@@ -722,32 +626,26 @@ int CompareRoomListByFloorRoomPrivFirstRev(const void *room1, const void *room2)
* we want the toplevel to be first, regardless of sort
* sequence.
*/
- if (((r1->nRoomNameParts > 1) ||
- (r2->nRoomNameParts > 1) )&&
- (r1->nRoomNameParts != r2->nRoomNameParts))
- {
+ if (((r1->nRoomNameParts > 1) || (r2->nRoomNameParts > 1)) && (r1->nRoomNameParts != r2->nRoomNameParts)) {
int i, ret;
- int nparts = (r1->nRoomNameParts > r2->nRoomNameParts)?
- r2->nRoomNameParts : r1->nRoomNameParts;
+ int nparts = (r1->nRoomNameParts > r2->nRoomNameParts) ? r2->nRoomNameParts : r1->nRoomNameParts;
+
+ for (i = 0; i < nparts; i++) {
- for (i=0; i < nparts; i++)
- {
/**
* special cases if one room is top-level...
*/
if (r2->nRoomNameParts == 1)
- ret = strcmp (ChrPtr(r2->name),
- ChrPtr(r1->RoomNameParts[i]));
+ ret = strcmp(ChrPtr(r2->name), ChrPtr(r1->RoomNameParts[i]));
else if (r1->nRoomNameParts == 1)
- ret = strcmp (ChrPtr(r2->RoomNameParts[i]),
- ChrPtr(r1->name));
- else
- ret = strcmp (ChrPtr(r2->RoomNameParts[i]),
- ChrPtr(r1->RoomNameParts[i]));
+ ret = strcmp(ChrPtr(r2->RoomNameParts[i]), ChrPtr(r1->name));
+ else
+ ret = strcmp(ChrPtr(r2->RoomNameParts[i]), ChrPtr(r1->RoomNameParts[i]));
+
/**
* Deltas in common parts? exit here.
*/
- if (ret != 0)
+ if (ret != 0)
return ret;
}
@@ -760,71 +658,64 @@ int CompareRoomListByFloorRoomPrivFirstRev(const void *room1, const void *room2)
return -1;
}
- return strcmp (ChrPtr(r2->name),
- ChrPtr(r1->name));
+ return strcmp(ChrPtr(r2->name), ChrPtr(r1->name));
}
-int GroupchangeRoomListByFloorRoomPrivFirst(const void *room1, const void *room2)
-{
- folder *r1 = (folder*) room1;
- folder *r2 = (folder*) room2;
-
+int GroupchangeRoomListByFloorRoomPrivFirst(const void *room1, const void *room2) {
+ folder *r1 = (folder *) room1;
+ folder *r2 = (folder *) room2;
- if ((r1->Floor == NULL) ||
- (r2->Floor == NULL))
+
+ if ((r1->Floor == NULL) || (r2->Floor == NULL))
return 0;
-
+
if (r1->Floor == r2->Floor)
return 0;
- else
- {
+ else {
wcsession *WCC = WC;
static int columns = 3;
int boxes_per_column = 0;
int nf;
nf = GetCount(WCC->Floors);
- while (nf % columns != 0) ++nf;
+ while (nf % columns != 0)
+ ++nf;
boxes_per_column = (nf / columns);
if (boxes_per_column < 1)
boxes_per_column = 1;
if (r1->Floor->AlphaN % boxes_per_column == 0)
return 2;
- else
+ else
return 1;
}
}
-int CompareRooms(const folder *room1, const folder *room2)
-{
+int CompareRooms(const folder * room1, const folder * room2) {
if ((room1 == NULL) || (room2 == NULL))
return -1;
return CompareRoomListByFloorRoomPrivFirst(room1, room2);
}
-int ConditionalThisRoomIsStrBufContextAlias(StrBuf *Target, WCTemplputParams *TP)
-{
- wcsession *WCC = WC;
- const char *pVal;
- long len;
- eRoomParamType ParamType;
+int ConditionalThisRoomIsStrBufContextAlias(StrBuf * Target, WCTemplputParams * TP) {
+ wcsession *WCC = WC;
+ const char *pVal;
+ long len;
+ eRoomParamType ParamType;
ParamType = GetTemplateTokenNumber(Target, TP, 2, eNotSet);
GetTemplateTokenString(Target, TP, 3, &pVal, &len);
- if (ParamType == eNotSet)
- {
+ if (ParamType == eNotSet) {
return StrLength(WCC->CurRoom.RoomAlias) == 0;
}
- else if (ParamType == eDomain)
- {
- const StrBuf *CtxStr = (const StrBuf*) CTX(CTX_STRBUF);
+ else if (ParamType == eDomain) {
+ const StrBuf *CtxStr = (const StrBuf *) CTX(CTX_STRBUF);
const char *pAt;
- if (CtxStr == NULL)
+ if (CtxStr == NULL)
return 0;
-
+
if (StrLength(WCC->CurRoom.RoomAlias) == 0)
return 0;
@@ -836,36 +727,32 @@ int ConditionalThisRoomIsStrBufContextAlias(StrBuf *Target, WCTemplputParams *TP
return 0;
return strcmp(pAt + 1, ChrPtr(CtxStr)) == 0;
}
- else if (ParamType == eAlias)
- {
- const StrBuf *CtxStr = (const StrBuf*) CTX(CTX_STRBUF);
+ else if (ParamType == eAlias) {
+ const StrBuf *CtxStr = (const StrBuf *) CTX(CTX_STRBUF);
- if (CtxStr == NULL)
+ if (CtxStr == NULL)
return 0;
-
+
if (StrLength(WCC->CurRoom.RoomAlias) == 0)
return 0;
return strcmp(ChrPtr(WCC->CurRoom.RoomAlias), ChrPtr(CtxStr)) == 0;
}
- else
- {
- LogTemplateError(Target, "TokenParameter", 2, TP,
- "Invalid paramtype; need one of [eNotSet|eDomain|eAlias]");
+ else {
+ LogTemplateError(Target, "TokenParameter", 2, TP, "Invalid paramtype; need one of [eNotSet|eDomain|eAlias]");
return 0;
}
}
-int ConditionalRoomIsRESTSubRoom(StrBuf *Target, WCTemplputParams *TP)
-{
- wcsession *WCC = WC;
- folder *Folder = (folder *)CTX(CTX_ROOMS);
- HashPos *it;
- StrBuf * Dir;
- void *vDir;
- long len;
- const char *Key;
+int ConditionalRoomIsRESTSubRoom(StrBuf * Target, WCTemplputParams * TP) {
+ wcsession *WCC = WC;
+ folder *Folder = (folder *) CTX(CTX_ROOMS);
+ HashPos *it;
+ StrBuf *Dir;
+ void *vDir;
+ long len;
+ const char *Key;
int i, j, urlp;
int delta;
@@ -877,10 +764,7 @@ int ConditionalRoomIsRESTSubRoom(StrBuf *Target, WCTemplputParams *TP)
urlp = GetCount(WCC->Directory);
delta = Folder->nRoomNameParts - urlp + 1;
- syslog(LOG_DEBUG, "\n->%s: %d - %ld ",
- ChrPtr(Folder->name),
- urlp,
- Folder->nRoomNameParts);
+ syslog(LOG_DEBUG, "\n->%s: %d - %ld ", ChrPtr(Folder->name), urlp, Folder->nRoomNameParts);
/* list only the floors which are in relation to the dav_depth header */
if (WCC->Hdr->HR.dav_depth != delta) {
syslog(LOG_DEBUG, "1\n");
@@ -892,24 +776,16 @@ int ConditionalRoomIsRESTSubRoom(StrBuf *Target, WCTemplputParams *TP)
/* Fast forward the floorname we checked above... */
GetNextHashPos(WCC->Directory, it, &len, &Key, &vDir);
- if (Folder->nRoomNameParts > 1) {
- for (i = 0, j = 1;
- (i > Folder->nRoomNameParts) && (j > urlp);
- i++, j++)
- {
- if (!GetNextHashPos(WCC->Directory,
- it, &len, &Key, &vDir) ||
- (vDir == NULL))
- {
+ if (Folder->nRoomNameParts > 1) {
+ for (i = 0, j = 1; (i > Folder->nRoomNameParts) && (j > urlp); i++, j++) {
+ if (!GetNextHashPos(WCC->Directory, it, &len, &Key, &vDir) || (vDir == NULL)) {
DeleteHashPos(&it);
syslog(LOG_DEBUG, "3\n");
return 0;
}
- Dir = (StrBuf*) vDir;
- if (strcmp(ChrPtr(Folder->RoomNameParts[i]),
- ChrPtr(Dir)) != 0)
- {
+ Dir = (StrBuf *) vDir;
+ if (strcmp(ChrPtr(Folder->RoomNameParts[i]), ChrPtr(Dir)) != 0) {
DeleteHashPos(&it);
syslog(LOG_DEBUG, "4\n");
return 0;
@@ -919,20 +795,16 @@ int ConditionalRoomIsRESTSubRoom(StrBuf *Target, WCTemplputParams *TP)
return 1;
}
else {
- if (!GetNextHashPos(WCC->Directory,
- it, &len, &Key, &vDir) ||
- (vDir == NULL))
- {
+ if (!GetNextHashPos(WCC->Directory, it, &len, &Key, &vDir) || (vDir == NULL)) {
DeleteHashPos(&it);
-
+
syslog(LOG_DEBUG, "5\n");
return WCC->Hdr->HR.dav_depth == 1;
}
DeleteHashPos(&it);
- Dir = (StrBuf*) vDir;
+ Dir = (StrBuf *) vDir;
if (WCC->Hdr->HR.dav_depth == 0) {
- return (strcmp(ChrPtr(Folder->name),
- ChrPtr(Dir))
+ return (strcmp(ChrPtr(Folder->name), ChrPtr(Dir))
== 0);
}
@@ -941,10 +813,7 @@ int ConditionalRoomIsRESTSubRoom(StrBuf *Target, WCTemplputParams *TP)
}
-void
-InitModule_ROOMLIST
-(void)
-{
+void InitModule_ROOMLIST(void) {
/* we duplicate this, just to be shure its already done. */
RegisterCTX(CTX_ROOMS);
RegisterCTX(CTX_FLOORS);
@@ -952,7 +821,8 @@ InitModule_ROOMLIST
RegisterIterator("ITERATE:THISROOM:WHO_KNOWS", 0, NULL, GetWhoKnowsHash, NULL, DeleteHash, CTX_STRBUF, CTX_NONE, IT_NOFLAG);
RegisterIterator("ITERATE:THISROOM:GNET", 1, NULL, GetNetConfigHash, NULL, NULL, CTX_STRBUFARR, CTX_NONE, IT_NOFLAG);
RegisterIterator("ITERATE:THISROOM:MALIAS", 1, NULL, GetThisRoomMAlias, NULL, DeleteHash, CTX_STRBUF, CTX_NONE, IT_NOFLAG);
- RegisterIterator("ITERATE:THISROOM:POSSIBLE:MALIAS", 1, NULL, GetThisRoomPossibleMAlias, NULL, DeleteHash, CTX_STRBUF, CTX_NONE, IT_NOFLAG);
+ RegisterIterator("ITERATE:THISROOM:POSSIBLE:MALIAS", 1, NULL, GetThisRoomPossibleMAlias, NULL, DeleteHash, CTX_STRBUF,
+ CTX_NONE, IT_NOFLAG);
RegisterIterator("LFLR", 0, NULL, GetFloorListHash, NULL, NULL, CTX_FLOORS, CTX_NONE, IT_FLAG_DETECT_GROUPCHANGE);
RegisterIterator("LKRA", 0, NULL, GetRoomListHashLKRA, NULL, NULL, CTX_ROOMS, CTX_NONE, IT_FLAG_DETECT_GROUPCHANGE);
@@ -972,8 +842,6 @@ InitModule_ROOMLIST
RegisterSortFunc(HKEY("byfloorroom"),
NULL, 0,
CompareRoomListByFloorRoomPrivFirst,
- CompareRoomListByFloorRoomPrivFirstRev,
- GroupchangeRoomListByFloorRoomPrivFirst,
- CTX_ROOMS);
+ CompareRoomListByFloorRoomPrivFirstRev, GroupchangeRoomListByFloorRoomPrivFirst, CTX_ROOMS);
}
diff --git a/webcit/roomops.c b/webcit/roomops.c
index be4c628da..d9a8f18db 100644
--- a/webcit/roomops.c
+++ b/webcit/roomops.c
@@ -1,3 +1,4 @@
+
/*
* Lots of different room-related operations.
*
@@ -16,49 +17,48 @@
#include "webserver.h"
ConstStr QRFlagList[] = {
- {HKEY(strof(QR_PERMANENT))},
- {HKEY(strof(QR_INUSE))},
- {HKEY(strof(QR_PRIVATE))},
- {HKEY(strof(QR_PASSWORDED))},
- {HKEY(strof(QR_GUESSNAME))},
- {HKEY(strof(QR_DIRECTORY))},
- {HKEY(strof(QR_UPLOAD))},
- {HKEY(strof(QR_DOWNLOAD))},
- {HKEY(strof(QR_VISDIR))},
- {HKEY(strof(QR_ANONONLY))},
- {HKEY(strof(QR_ANONOPT))},
- {HKEY(strof(QR_NETWORK))},
- {HKEY(strof(QR_PREFONLY))},
- {HKEY(strof(QR_READONLY))},
- {HKEY(strof(QR_MAILBOX))}
+ { HKEY(strof(QR_PERMANENT)) },
+ { HKEY(strof(QR_INUSE)) },
+ { HKEY(strof(QR_PRIVATE)) },
+ { HKEY(strof(QR_PASSWORDED)) },
+ { HKEY(strof(QR_GUESSNAME)) },
+ { HKEY(strof(QR_DIRECTORY)) },
+ { HKEY(strof(QR_UPLOAD)) },
+ { HKEY(strof(QR_DOWNLOAD)) },
+ { HKEY(strof(QR_VISDIR)) },
+ { HKEY(strof(QR_ANONONLY)) },
+ { HKEY(strof(QR_ANONOPT)) },
+ { HKEY(strof(QR_NETWORK)) },
+ { HKEY(strof(QR_PREFONLY)) },
+ { HKEY(strof(QR_READONLY)) },
+ { HKEY(strof(QR_MAILBOX)) }
};
+
ConstStr QR2FlagList[] = {
- {HKEY(strof(QR2_SYSTEM))},
- {HKEY(strof(QR2_SELFLIST))},
- {HKEY(strof(QR2_COLLABDEL))},
- {HKEY(strof(QR2_SUBJECTREQ))},
- {HKEY(strof(QR2_SMTP_PUBLIC))},
- {HKEY(strof(QR2_MODERATED))},
- {HKEY(strof(QR2_NOUPLMSG))},
- {HKEY("")},
- {HKEY("")},
- {HKEY("")},
- {HKEY("")},
- {HKEY("")},
- {HKEY("")},
- {HKEY("")},
- {HKEY("")}
+ { HKEY(strof(QR2_SYSTEM)) },
+ { HKEY(strof(QR2_SELFLIST)) },
+ { HKEY(strof(QR2_COLLABDEL)) },
+ { HKEY(strof(QR2_SUBJECTREQ)) },
+ { HKEY(strof(QR2_SMTP_PUBLIC)) },
+ { HKEY(strof(QR2_MODERATED)) },
+ { HKEY(strof(QR2_NOUPLMSG)) },
+ { HKEY("") },
+ { HKEY("") },
+ { HKEY("") },
+ { HKEY("") },
+ { HKEY("") },
+ { HKEY("") },
+ { HKEY("") },
+ { HKEY("") }
};
-void _DBG_QR(long QR)
-{
+void _DBG_QR(long QR) {
int i = 1;
- int j=0;
+ int j = 0;
StrBuf *QRVec;
QRVec = NewStrBufPlain(NULL, 256);
- while (i != 0)
- {
+ while (i != 0) {
if ((QR & i) != 0) {
if (StrLength(QRVec) > 0)
StrBufAppendBufPlain(QRVec, HKEY(" | "), 0);
@@ -73,15 +73,13 @@ void _DBG_QR(long QR)
-void _DBG_QR2(long QR2)
-{
+void _DBG_QR2(long QR2) {
int i = 1;
- int j=0;
+ int j = 0;
StrBuf *QR2Vec;
QR2Vec = NewStrBufPlain(NULL, 256);
- while (i != 0)
- {
+ while (i != 0) {
if ((QR2 & i) != 0) {
if (StrLength(QR2Vec) > 0)
StrBufAppendBufPlain(QR2Vec, HKEY(" | "), 0);
@@ -127,7 +125,7 @@ void dotgoto(void) {
/*
* goto next room
*/
-void smart_goto(const StrBuf *next_room) {
+void smart_goto(const StrBuf * next_room) {
if (gotoroom(next_room) / 100 == 2)
readloop(readnew, eUseDefault);
else
@@ -137,8 +135,7 @@ void smart_goto(const StrBuf *next_room) {
/*
* goto a private room
*/
-void goto_private(void)
-{
+void goto_private(void) {
char hold_rm[SIZ];
StrBuf *Buf;
const StrBuf *gr_name;
@@ -151,11 +148,9 @@ void goto_private(void)
gr_name = sbstr("gr_name");
Buf = NewStrBuf();
strcpy(hold_rm, ChrPtr(WC->CurRoom.name));
- serv_printf("GOTO %s|%s",
- ChrPtr(gr_name),
- bstr("gr_pass"));
+ serv_printf("GOTO %s|%s", ChrPtr(gr_name), bstr("gr_pass"));
StrBuf_ServGetln(Buf);
- if (GetServerStatus(Buf, &err) == 2) {
+ if (GetServerStatus(Buf, &err) == 2) {
FlushRoomlist();
smart_goto(gr_name);
FreeStrBuf(&Buf);
@@ -167,7 +162,7 @@ void goto_private(void)
return;
}
StrBufCutLeft(Buf, 4);
- AppendImportantMessage (SKEY(Buf));
+ AppendImportantMessage(SKEY(Buf));
Buf = NewStrBufPlain(HKEY("_BASEROOM_"));
smart_goto(Buf);
FreeStrBuf(&Buf);
@@ -177,8 +172,7 @@ void goto_private(void)
/*
* back end routine to take the session to a new room
*/
-long gotoroom(const StrBuf *gname)
-{
+long gotoroom(const StrBuf * gname) {
wcsession *WCC = WC;
StrBuf *Buf;
static long ls = (-1L);
@@ -212,7 +206,7 @@ long gotoroom(const StrBuf *gname)
serv_printf("GOTO 00000000000000000000");
}
StrBuf_ServGetln(Buf);
- if (GetServerStatus(Buf, &err) != 2) {
+ if (GetServerStatus(Buf, &err) != 2) {
if (failvisibly) {
FreeStrBuf(&Buf);
return err;
@@ -245,8 +239,7 @@ long gotoroom(const StrBuf *gname)
-void ParseGoto(folder *room, StrBuf *Line)
-{
+void ParseGoto(folder * room, StrBuf * Line) {
wcsession *WCC = WC;
const char *Pos;
int flag;
@@ -256,20 +249,19 @@ void ParseGoto(folder *room, StrBuf *Line)
if (StrLength(Line) < 4) {
return;
}
-
+
/* ignore the commandstate... */
Pos = ChrPtr(Line) + 4;
- if (room->RoomNameParts != NULL)
- {
+ if (room->RoomNameParts != NULL) {
int i;
- for (i=0; i < room->nRoomNameParts; i++)
+ for (i = 0; i < room->nRoomNameParts; i++)
FreeStrBuf(&room->RoomNameParts[i]);
free(room->RoomNameParts);
room->RoomNameParts = NULL;
}
- pBuf = room->name;
+ pBuf = room->name;
if (pBuf == NULL)
pBuf = NewStrBufPlain(NULL, StrLength(Line));
else
@@ -279,14 +271,14 @@ void ParseGoto(folder *room, StrBuf *Line)
StrBufExtract_NextToken(room->name, Line, &Pos, '|');
- room->nNewMessages = StrBufExtractNext_long(Line, &Pos, '|');
+ room->nNewMessages = StrBufExtractNext_long(Line, &Pos, '|');
if (room->nNewMessages > 0)
room->RAFlags |= UA_HASNEWMSGS;
room->nTotalMessages = StrBufExtractNext_long(Line, &Pos, '|');
- room->ShowInfo = StrBufExtractNext_long(Line, &Pos, '|');
-
+ room->ShowInfo = StrBufExtractNext_long(Line, &Pos, '|');
+
room->QRFlags = StrBufExtractNext_long(Line, &Pos, '|');
DBG_QR(room->QRFlags);
@@ -318,62 +310,51 @@ void ParseGoto(folder *room, StrBuf *Line)
/* find out, whether we are in a sub-room */
room->nRoomNameParts = StrBufNum_tokens(room->name, '\\');
- if (room->nRoomNameParts > 1)
- {
+ if (room->nRoomNameParts > 1) {
int i;
-
+
Pos = NULL;
- room->RoomNameParts = malloc(sizeof(StrBuf*) * (room->nRoomNameParts + 1));
- memset(room->RoomNameParts, 0, sizeof(StrBuf*) * (room->nRoomNameParts + 1));
- for (i=0; i < room->nRoomNameParts; i++)
- {
+ room->RoomNameParts = malloc(sizeof(StrBuf *) * (room->nRoomNameParts + 1));
+ memset(room->RoomNameParts, 0, sizeof(StrBuf *) * (room->nRoomNameParts + 1));
+ for (i = 0; i < room->nRoomNameParts; i++) {
room->RoomNameParts[i] = NewStrBuf();
- StrBufExtract_NextToken(room->RoomNameParts[i],
- room->name, &Pos, '\\');
+ StrBufExtract_NextToken(room->RoomNameParts[i], room->name, &Pos, '\\');
}
}
/* Private mailboxes on the main floor get remapped to the personal folder */
- if ((room->QRFlags & QR_MAILBOX) &&
- (room->floorid == 0))
- {
+ if ((room->QRFlags & QR_MAILBOX) && (room->floorid == 0)) {
room->floorid = VIRTUAL_MY_FLOOR;
- if ((room->nRoomNameParts == 1) &&
- (StrLength(room->name) == 4) &&
- (strcmp(ChrPtr(room->name), "Mail") == 0))
- {
+ if ((room->nRoomNameParts == 1) && (StrLength(room->name) == 4) && (strcmp(ChrPtr(room->name), "Mail") == 0)) {
room->is_inbox = 1;
}
-
+
}
/* get a pointer to the floor we're on: */
if (WCC->Floors == NULL)
GetFloorListHash(NULL, NULL);
GetHash(WCC->Floors, IKEY(room->floorid), &vFloor);
- room->Floor = (const Floor*) vFloor;
+ room->Floor = (const Floor *) vFloor;
}
/*
* Delete the current room
*/
-void delete_room(void)
-{
+void delete_room(void) {
StrBuf *Line = NewStrBuf();
const StrBuf *GoBstr;
-
+
GoBstr = sbstr("go");
- if (GoBstr != NULL)
- {
- if (gotoroom(GoBstr) == 200)
- {
+ if (GoBstr != NULL) {
+ if (gotoroom(GoBstr) == 200) {
serv_puts("KILL 1");
StrBuf_ServGetln(Line);
if (GetServerStatusMsg(Line, NULL, 1, 2) == 2) {
StrBuf *Buf;
-
- FlushRoomlist ();
+
+ FlushRoomlist();
Buf = NewStrBufPlain(HKEY("_BASEROOM_"));
smart_goto(Buf);
FreeStrBuf(&Buf);
@@ -389,8 +370,7 @@ void delete_room(void)
/*
* zap a room
*/
-void zap(void)
-{
+void zap(void) {
char buf[SIZ];
StrBuf *final_destination;
@@ -411,7 +391,7 @@ void zap(void)
StrBufAppendBufPlain(final_destination, HKEY("_BASEROOM_"), 0);
}
}
- FlushRoomlist ();
+ FlushRoomlist();
}
smart_goto(final_destination);
FreeStrBuf(&final_destination);
@@ -421,8 +401,7 @@ void zap(void)
/*
* mark all messages in current room as having been read
*/
-void slrp_highest(void)
-{
+void slrp_highest(void) {
char buf[256];
serv_puts("SLRP HIGHEST");
@@ -450,11 +429,10 @@ void slrp_highest(void)
-void LoadRoomAide(void)
-{
+void LoadRoomAide(void) {
wcsession *WCC = WC;
StrBuf *Buf;
-
+
if (WCC->CurRoom.RoomAideLoaded)
return;
@@ -464,30 +442,29 @@ void LoadRoomAide(void)
StrBuf_ServGetln(Buf);
if (GetServerStatus(Buf, NULL) != 2) {
FlushStrBuf(WCC->CurRoom.RoomAide);
- AppendImportantMessage (ChrPtr(Buf) + 4,
- StrLength(Buf) - 4);
- } else {
+ AppendImportantMessage(ChrPtr(Buf) + 4, StrLength(Buf) - 4);
+ }
+ else {
const char *Pos;
Pos = ChrPtr(Buf) + 4;
FreeStrBuf(&WCC->CurRoom.RoomAide);
- WCC->CurRoom.RoomAide = NewStrBufPlain (NULL, StrLength (Buf));
+ WCC->CurRoom.RoomAide = NewStrBufPlain(NULL, StrLength(Buf));
- StrBufExtract_NextToken(WCC->CurRoom.RoomAide, Buf, &Pos, '|');
+ StrBufExtract_NextToken(WCC->CurRoom.RoomAide, Buf, &Pos, '|');
}
- FreeStrBuf (&Buf);
+ FreeStrBuf(&Buf);
}
-int SaveRoomAide(folder *Room)
-{
+int SaveRoomAide(folder * Room) {
StrBuf *Buf;
- Buf = NewStrBuf ();
+ Buf = NewStrBuf();
serv_printf("SETA %s", ChrPtr(Room->RoomAide));
StrBuf_ServGetln(Buf);
if (GetServerStatus(Buf, NULL) != 2) {
StrBufCutLeft(Buf, 4);
- AppendImportantMessage (SKEY(Buf));
+ AppendImportantMessage(SKEY(Buf));
FreeStrBuf(&Buf);
return 0;
}
@@ -496,8 +473,7 @@ int SaveRoomAide(folder *Room)
}
-int GetCurrentRoomFlags(folder *Room, int CareForStatusMessage)
-{
+int GetCurrentRoomFlags(folder * Room, int CareForStatusMessage) {
StrBuf *Buf;
Buf = NewStrBuf();
@@ -508,11 +484,12 @@ int GetCurrentRoomFlags(folder *Room, int CareForStatusMessage)
FlushStrBuf(Room->Directory);
StrBufCutLeft(Buf, 4);
if (CareForStatusMessage)
- AppendImportantMessage (SKEY(Buf));
+ AppendImportantMessage(SKEY(Buf));
FreeStrBuf(&Buf);
Room->XALoaded = 2;
return 0;
- } else {
+ }
+ else {
const char *Pos;
Pos = ChrPtr(Buf) + 4;
@@ -520,30 +497,29 @@ int GetCurrentRoomFlags(folder *Room, int CareForStatusMessage)
FreeStrBuf(&Room->XAPass);
FreeStrBuf(&Room->Directory);
- Room->XAPass = NewStrBufPlain (NULL, StrLength (Buf));
- Room->Directory = NewStrBufPlain (NULL, StrLength (Buf));
+ Room->XAPass = NewStrBufPlain(NULL, StrLength(Buf));
+ Room->Directory = NewStrBufPlain(NULL, StrLength(Buf));
FreeStrBuf(&Room->name);
Room->name = NewStrBufPlain(NULL, StrLength(Buf));
- StrBufExtract_NextToken(Room->name, Buf, &Pos, '|');
-
- StrBufExtract_NextToken(Room->XAPass, Buf, &Pos, '|');
- StrBufExtract_NextToken(Room->Directory, Buf, &Pos, '|');
-
+ StrBufExtract_NextToken(Room->name, Buf, &Pos, '|');
+
+ StrBufExtract_NextToken(Room->XAPass, Buf, &Pos, '|');
+ StrBufExtract_NextToken(Room->Directory, Buf, &Pos, '|');
+
Room->QRFlags = StrBufExtractNext_long(Buf, &Pos, '|');
Room->floorid = StrBufExtractNext_long(Buf, &Pos, '|');
Room->Order = StrBufExtractNext_long(Buf, &Pos, '|');
Room->defview = StrBufExtractNext_long(Buf, &Pos, '|');
Room->QRFlags2 = StrBufExtractNext_long(Buf, &Pos, '|');
- FreeStrBuf (&Buf);
+ FreeStrBuf(&Buf);
Room->XALoaded = 1;
return 1;
}
}
-int SetCurrentRoomFlags(folder *Room)
-{
+int SetCurrentRoomFlags(folder * Room) {
StrBuf *Buf;
Buf = NewStrBuf();
@@ -554,29 +530,24 @@ int SetCurrentRoomFlags(folder *Room)
ChrPtr(Room->name),
ChrPtr(Room->XAPass),
ChrPtr(Room->Directory),
- Room->QRFlags,
- Room->BumpUsers,
- Room->floorid,
- Room->Order,
- Room->defview,
- Room->QRFlags2);
+ Room->QRFlags, Room->BumpUsers, Room->floorid, Room->Order, Room->defview, Room->QRFlags2);
StrBuf_ServGetln(Buf);
if (GetServerStatus(Buf, NULL) != 2) {
StrBufCutLeft(Buf, 4);
- AppendImportantMessage (SKEY(Buf));
+ AppendImportantMessage(SKEY(Buf));
FreeStrBuf(&Buf);
return 0;
- } else {
+ }
+ else {
FreeStrBuf(&Buf);
return 1;
}
}
-void LoadRoomXA (void)
-{
+void LoadRoomXA(void) {
wcsession *WCC = WC;
-
+
if (WCC->CurRoom.XALoaded > 0)
return;
@@ -584,12 +555,11 @@ void LoadRoomXA (void)
}
-void LoadXRoomPic(void)
-{
+void LoadXRoomPic(void) {
wcsession *WCC = WC;
StrBuf *Buf;
off_t bytes;
-
+
if (WCC->CurRoom.XHaveRoomPicLoaded) {
return;
}
@@ -602,20 +572,20 @@ void LoadXRoomPic(void)
StrBufCutLeft(Buf, 4);
bytes = StrBufExtract_long(Buf, 0, '|');
WCC->CurRoom.XHaveRoomPic = 1;
- StrBuf_ServGetBLOBBuffered(Buf, bytes); // discard the data
- } else {
+ StrBuf_ServGetBLOBBuffered(Buf, bytes); // discard the data
+ }
+ else {
WCC->CurRoom.XHaveRoomPic = 0;
}
- FreeStrBuf (&Buf);
+ FreeStrBuf(&Buf);
}
-void LoadXRoomInfoText(void)
-{
+void LoadXRoomInfoText(void) {
wcsession *WCC = WC;
StrBuf *Buf;
int Done = 0;
-
+
if (WCC->CurRoom.XHaveInfoTextLoaded) {
return;
}
@@ -627,13 +597,12 @@ void LoadXRoomInfoText(void)
StrBuf_ServGetln(Buf);
if (GetServerStatus(Buf, NULL) == 1) {
- WCC->CurRoom.XInfoText = NewStrBuf ();
-
- while (!Done && StrBuf_ServGetln(Buf)>=0) {
- if ( (StrLength(Buf)==3) &&
- !strcmp(ChrPtr(Buf), "000"))
+ WCC->CurRoom.XInfoText = NewStrBuf();
+
+ while (!Done && StrBuf_ServGetln(Buf) >= 0) {
+ if ((StrLength(Buf) == 3) && !strcmp(ChrPtr(Buf), "000"))
Done = 1;
- else
+ else
StrBufAppendBuf(WCC->CurRoom.XInfoText, Buf, 0);
}
}
@@ -642,12 +611,11 @@ void LoadXRoomInfoText(void)
}
-void LoadXRoomXCountFiles(void)
-{
+void LoadXRoomXCountFiles(void) {
wcsession *WCC = WC;
StrBuf *Buf;
int Done = 0;
-
+
if (WCC->CurRoom.XHaveDownloadCount)
return;
@@ -657,17 +625,16 @@ void LoadXRoomXCountFiles(void)
serv_puts("RDIR");
StrBuf_ServGetln(Buf);
if (GetServerStatus(Buf, NULL) == 1) {
-
- while (!Done && StrBuf_ServGetln(Buf)>=0) {
- if ( (StrLength(Buf)==3) &&
- !strcmp(ChrPtr(Buf), "000"))
+
+ while (!Done && StrBuf_ServGetln(Buf) >= 0) {
+ if ((StrLength(Buf) == 3) && !strcmp(ChrPtr(Buf), "000"))
Done = 1;
- else
+ else
WCC->CurRoom.XDownloadCount++;
}
}
- FreeStrBuf (&Buf);
+ FreeStrBuf(&Buf);
}
@@ -677,31 +644,31 @@ void LoadXRoomXCountFiles(void)
void toggle_self_service(void) {
wcsession *WCC = WC;
- if (GetCurrentRoomFlags (&WCC->CurRoom, 1) == 0)
+ if (GetCurrentRoomFlags(&WCC->CurRoom, 1) == 0)
return;
- if (yesbstr("QR2_SelfList"))
+ if (yesbstr("QR2_SelfList"))
WCC->CurRoom.QRFlags2 = WCC->CurRoom.QRFlags2 | QR2_SELFLIST;
- else
+ else
WCC->CurRoom.QRFlags2 = WCC->CurRoom.QRFlags2 & ~QR2_SELFLIST;
- if (yesbstr("QR2_SMTP_PUBLIC"))
+ if (yesbstr("QR2_SMTP_PUBLIC"))
WCC->CurRoom.QRFlags2 = WCC->CurRoom.QRFlags2 | QR2_SMTP_PUBLIC;
else
WCC->CurRoom.QRFlags2 = WCC->CurRoom.QRFlags2 & ~QR2_SMTP_PUBLIC;
- if (yesbstr("QR2_Moderated"))
+ if (yesbstr("QR2_Moderated"))
WCC->CurRoom.QRFlags2 = WCC->CurRoom.QRFlags2 | QR2_MODERATED;
else
WCC->CurRoom.QRFlags2 = WCC->CurRoom.QRFlags2 & ~QR2_MODERATED;
- if (yesbstr("QR2_SubsOnly"))
+ if (yesbstr("QR2_SubsOnly"))
WCC->CurRoom.QRFlags2 = WCC->CurRoom.QRFlags2 | QR2_SMTP_PUBLIC;
else
WCC->CurRoom.QRFlags2 = WCC->CurRoom.QRFlags2 & ~QR2_SMTP_PUBLIC;
- SetCurrentRoomFlags (&WCC->CurRoom);
+ SetCurrentRoomFlags(&WCC->CurRoom);
- output_headers(1, 1, 1, 0, 0, 0);
+ output_headers(1, 1, 1, 0, 0, 0);
do_template("room_edit");
wDumpContent(1);
}
@@ -711,8 +678,7 @@ void toggle_self_service(void) {
/*
* save new parameters for a room
*/
-void editroom(void)
-{
+void editroom(void) {
wcsession *WCC = WC;
const StrBuf *Ptr;
const StrBuf *er_name;
@@ -727,27 +693,27 @@ void editroom(void)
putlbstr("success", 0);
AppendImportantMessage(_("Cancelled. Changes were not saved."), -1);
if (templ != NULL) {
- output_headers(1, 0, 0, 0, 0, 0);
+ output_headers(1, 0, 0, 0, 0, 0);
DoTemplate(SKEY(templ), NULL, &NoCtx);
end_burst();
}
else {
- output_headers(1, 1, 1, 0, 0, 0);
+ output_headers(1, 1, 1, 0, 0, 0);
do_template("room_edit");
wDumpContent(1);
}
return;
}
- if (GetCurrentRoomFlags (&WCC->CurRoom, 1) == 0) {
+ if (GetCurrentRoomFlags(&WCC->CurRoom, 1) == 0) {
putlbstr("success", 0);
if (templ != NULL) {
- output_headers(1, 0, 0, 0, 0, 0);
+ output_headers(1, 0, 0, 0, 0, 0);
DoTemplate(SKEY(templ), NULL, &NoCtx);
end_burst();
}
else {
- output_headers(1, 1, 1, 0, 0, 0);
+ output_headers(1, 1, 1, 0, 0, 0);
do_template("room_edit");
wDumpContent(1);
}
@@ -769,73 +735,85 @@ void editroom(void)
}
if (!strcmp(ChrPtr(Ptr), "personal")) {
WCC->CurRoom.QRFlags |= QR_MAILBOX;
- } else {
+ }
+ else {
WCC->CurRoom.QRFlags &= ~QR_MAILBOX;
}
if (yesbstr("prefonly")) {
WCC->CurRoom.QRFlags |= QR_PREFONLY;
- } else {
+ }
+ else {
WCC->CurRoom.QRFlags &= ~QR_PREFONLY;
}
if (yesbstr("readonly")) {
WCC->CurRoom.QRFlags |= QR_READONLY;
- } else {
+ }
+ else {
WCC->CurRoom.QRFlags &= ~QR_READONLY;
}
if (yesbstr("collabdel")) {
WCC->CurRoom.QRFlags2 |= QR2_COLLABDEL;
- } else {
+ }
+ else {
WCC->CurRoom.QRFlags2 &= ~QR2_COLLABDEL;
}
if (yesbstr("permanent")) {
WCC->CurRoom.QRFlags |= QR_PERMANENT;
- } else {
+ }
+ else {
WCC->CurRoom.QRFlags &= ~QR_PERMANENT;
}
if (yesbstr("subjectreq")) {
WCC->CurRoom.QRFlags2 |= QR2_SUBJECTREQ;
- } else {
+ }
+ else {
WCC->CurRoom.QRFlags2 &= ~QR2_SUBJECTREQ;
}
if (yesbstr("network")) {
WCC->CurRoom.QRFlags |= QR_NETWORK;
- } else {
+ }
+ else {
WCC->CurRoom.QRFlags &= ~QR_NETWORK;
}
if (yesbstr("directory")) {
WCC->CurRoom.QRFlags |= QR_DIRECTORY;
- } else {
+ }
+ else {
WCC->CurRoom.QRFlags &= ~QR_DIRECTORY;
}
if (yesbstr("ulallowed")) {
WCC->CurRoom.QRFlags |= QR_UPLOAD;
- } else {
+ }
+ else {
WCC->CurRoom.QRFlags &= ~QR_UPLOAD;
}
if (yesbstr("dlallowed")) {
WCC->CurRoom.QRFlags |= QR_DOWNLOAD;
- } else {
+ }
+ else {
WCC->CurRoom.QRFlags &= ~QR_DOWNLOAD;
}
if (yesbstr("ulmsg")) {
WCC->CurRoom.QRFlags2 |= QR2_NOUPLMSG;
- } else {
+ }
+ else {
WCC->CurRoom.QRFlags2 &= ~QR2_NOUPLMSG;
}
if (yesbstr("visdir")) {
WCC->CurRoom.QRFlags |= QR_VISDIR;
- } else {
+ }
+ else {
WCC->CurRoom.QRFlags &= ~QR_VISDIR;
}
@@ -847,8 +825,8 @@ void editroom(void)
if (!strcmp(ChrPtr(Ptr), "anon2"))
WCC->CurRoom.QRFlags |= QR_ANONOPT;
- er_name = sbstr("er_name");
- er_dirname = sbstr("er_dirname");
+ er_name = sbstr("er_name");
+ er_dirname = sbstr("er_dirname");
er_roomaide = sbstr("er_roomaide");
er_password = sbstr("er_password");
@@ -870,22 +848,22 @@ void editroom(void)
succ1 = SetCurrentRoomFlags(&WCC->CurRoom);
- succ2 = SaveRoomAide (&WCC->CurRoom);
-
+ succ2 = SaveRoomAide(&WCC->CurRoom);
+
if (succ1 + succ2 == 0) {
putlbstr("success", 1);
- AppendImportantMessage (_("Your changes have been saved."), -1);
+ AppendImportantMessage(_("Your changes have been saved."), -1);
}
else {
putlbstr("success", 0);
}
if (templ != NULL) {
- output_headers(1, 0, 0, 0, 0, 0);
+ output_headers(1, 0, 0, 0, 0, 0);
DoTemplate(SKEY(templ), NULL, &NoCtx);
end_burst();
}
else {
- output_headers(1, 1, 1, 0, 0, 0);
+ output_headers(1, 1, 1, 0, 0, 0);
do_template("room_edit");
wDumpContent(1);
}
@@ -897,16 +875,14 @@ void editroom(void)
/*
* Display form for Invite, Kick, and show Who Knows a room
*/
-void do_invt_kick(void)
-{
+void do_invt_kick(void) {
StrBuf *Buf, *User;
const StrBuf *UserNames;
int Kick, Invite;
wcsession *WCC = WC;
- if (GetCurrentRoomFlags(&WCC->CurRoom, 1) == 1)
- {
+ if (GetCurrentRoomFlags(&WCC->CurRoom, 1) == 1) {
const char *Pos;
UserNames = sbstr("username");
Kick = havebstr("kick_button");
@@ -914,50 +890,46 @@ void do_invt_kick(void)
User = NewStrBufPlain(NULL, StrLength(UserNames));
Buf = NewStrBuf();
-
+
Pos = ChrPtr(UserNames);
- while (Pos != StrBufNOTNULL)
- {
+ while (Pos != StrBufNOTNULL) {
StrBufExtract_NextToken(User, UserNames, &Pos, ',');
StrBufTrim(User);
- if ((StrLength(User) > 0) && (Kick))
- {
+ if ((StrLength(User) > 0) && (Kick)) {
serv_printf("KICK %s", ChrPtr(User));
if (StrBuf_ServGetln(Buf) < 0)
break;
if (GetServerStatus(Buf, NULL) != 2) {
StrBufCutLeft(Buf, 4);
AppendImportantMessage(SKEY(Buf));
- } else {
- StrBufPrintf(Buf,
- _("User '%s' kicked out of room '%s'."),
- ChrPtr(User),
- ChrPtr(WCC->CurRoom.name)
- );
+ }
+ else {
+ StrBufPrintf(Buf,
+ _("User '%s' kicked out of room '%s'."),
+ ChrPtr(User), ChrPtr(WCC->CurRoom.name)
+ );
AppendImportantMessage(SKEY(Buf));
}
}
- else if ((StrLength(User) > 0) && (Invite))
- {
+ else if ((StrLength(User) > 0) && (Invite)) {
serv_printf("INVT %s", ChrPtr(User));
if (StrBuf_ServGetln(Buf) < 0)
break;
if (GetServerStatus(Buf, NULL) != 2) {
StrBufCutLeft(Buf, 4);
AppendImportantMessage(SKEY(Buf));
- } else {
- StrBufPrintf(Buf,
- _("User '%s' invited to room '%s'."),
- ChrPtr(User),
- ChrPtr(WCC->CurRoom.name)
- );
+ }
+ else {
+ StrBufPrintf(Buf,
+ _("User '%s' invited to room '%s'."), ChrPtr(User), ChrPtr(WCC->CurRoom.name)
+ );
AppendImportantMessage(SKEY(Buf));
}
}
- }
- }
+ }
+ }
- output_headers(1, 1, 1, 0, 0, 0);
+ output_headers(1, 1, 1, 0, 0, 0);
do_template("room_edit");
wDumpContent(1);
}
@@ -966,8 +938,7 @@ void do_invt_kick(void)
/*
* Create a new room
*/
-void entroom(void)
-{
+void entroom(void) {
StrBuf *Line;
const StrBuf *er_name;
const StrBuf *er_type;
@@ -983,7 +954,7 @@ void entroom(void)
putlbstr("success", 0);
AppendImportantMessage(_("Cancelled. No new room was created."), -1);
if (template != NULL) {
- output_headers(1, 0, 0, 0, 0, 0);
+ output_headers(1, 0, 0, 0, 0, 0);
DoTemplate(SKEY(template), NULL, &NoCtx);
end_burst();
}
@@ -1008,13 +979,7 @@ void entroom(void)
else if (!strcmp(ChrPtr(er_type), "personal"))
er_num_type = 4;
- serv_printf("CRE8 1|%s|%d|%s|%d|%d|%d",
- ChrPtr(er_name),
- er_num_type,
- ChrPtr(er_password),
- er_floor,
- 0,
- er_view);
+ serv_printf("CRE8 1|%s|%d|%s|%d|%d|%d", ChrPtr(er_name), er_num_type, ChrPtr(er_password), er_floor, 0, er_view);
Line = NewStrBuf();
StrBuf_ServGetln(Line);
@@ -1022,7 +987,7 @@ void entroom(void)
putlbstr("success", 0);
FreeStrBuf(&Line);
if (template != NULL) {
- output_headers(1, 0, 0, 0, 0, 0);
+ output_headers(1, 0, 0, 0, 0, 0);
DoTemplate(SKEY(template), NULL, &NoCtx);
end_burst();
}
@@ -1031,25 +996,27 @@ void entroom(void)
}
return;
}
+
/** TODO: Room created, now update the left hand icon bar for this user */
gotoroom(er_name);
serv_printf("VIEW %d", er_view);
StrBuf_ServGetln(Line);
- FreeStrBuf(&Line); /* TODO: should we care about errors? */
+ FreeStrBuf(&Line); /* TODO: should we care about errors? */
WCC->CurRoom.view = er_view;
putlbstr("success", 1);
if (template != NULL) {
- output_headers(1, 0, 0, 0, 0, 0);
+ output_headers(1, 0, 0, 0, 0, 0);
DoTemplate(SKEY(template), NULL, &NoCtx);
end_burst();
}
- else if ( (WCC->CurRoom.RAFlags & UA_ADMINALLOWED) != 0) {
- output_headers(1, 1, 1, 0, 0, 0);
+ else if ((WCC->CurRoom.RAFlags & UA_ADMINALLOWED) != 0) {
+ output_headers(1, 1, 1, 0, 0, 0);
do_template("room_edit");
wDumpContent(1);
- } else {
+ }
+ else {
smart_goto(WCC->CurRoom.name);
}
FreeStrBuf(&Line);
@@ -1083,7 +1050,7 @@ void set_room_policy(void) {
if (!havebstr("ok_button")) {
AppendImportantMessage(_("Cancelled. Changes were not saved."), -1);
- output_headers(1, 1, 1, 0, 0, 0);
+ output_headers(1, 1, 1, 0, 0, 0);
do_template("room_edit");
wDumpContent(1);
return;
@@ -1102,7 +1069,7 @@ void set_room_policy(void) {
FreeStrBuf(&Line);
ReloadCurrentRoom();
- output_headers(1, 1, 1, 0, 0, 0);
+ output_headers(1, 1, 1, 0, 0, 0);
do_template("room_edit");
wDumpContent(1);
}
@@ -1128,8 +1095,8 @@ void netedit(void) {
int Done;
line[0] = '\0';
- if (havebstr("force_room")) {
- gotoroom(sbstr("force_room"));
+ if (havebstr("force_room")) {
+ gotoroom(sbstr("force_room"));
}
/*/ TODO: do line dynamic! */
if (havebstr("line_pop3host")) {
@@ -1140,9 +1107,9 @@ void netedit(void) {
strcat(line, "|");
strcat(line, bstr("line_pop3pass"));
strcat(line, "|");
- strcat(line, ibstr("line_pop3keep") ? "1" : "0" );
+ strcat(line, ibstr("line_pop3keep") ? "1" : "0");
strcat(line, "|");
- sprintf(&line[strlen(line)],"%ld", lbstr("line_pop3int"));
+ sprintf(&line[strlen(line)], "%ld", lbstr("line_pop3int"));
strcat(line, bstr("suffix"));
}
else if (havebstr("line")) {
@@ -1153,19 +1120,16 @@ void netedit(void) {
else if (havebstr("alias")) {
const char *domain;
domain = bstr("aliasdomain");
- if ((domain == NULL) || IsEmptyStr(domain))
- {
+ if ((domain == NULL) || IsEmptyStr(domain)) {
malias_set_default = 1;
strcpy(line, bstr("prefix"));
strcat(line, bstr("default_aliasdomain"));
}
- else
- {
+ else {
malias = 1;
sepchar = ',';
strcat(line, bstr("prefix"));
- if (!IsEmptyStr(domain))
- {
+ if (!IsEmptyStr(domain)) {
strcat(line, "@");
strcat(line, domain);
}
@@ -1175,7 +1139,7 @@ void netedit(void) {
}
}
else {
- output_headers(1, 1, 1, 0, 0, 0);
+ output_headers(1, 1, 1, 0, 0, 0);
do_template("room_edit");
wDumpContent(1);
return;
@@ -1184,14 +1148,14 @@ void netedit(void) {
Line = NewStrBuf();
TmpBuf = NewStrBuf();
if (malias)
- serv_puts("GNET "FILE_MAILALIAS);
+ serv_puts("GNET " FILE_MAILALIAS);
else
serv_puts("GNET");
StrBuf_ServGetln(Line);
- if (GetServerStatus(Line, NULL) != 1) {
- AppendImportantMessage(SRV_STATUS_MSG(Line));
+ if (GetServerStatus(Line, NULL) != 1) {
+ AppendImportantMessage(SRV_STATUS_MSG(Line));
FreeStrBuf(&Line);
- output_headers(1, 1, 1, 0, 0, 0);
+ output_headers(1, 1, 1, 0, 0, 0);
do_template("room_edit");
wDumpContent(1);
return;
@@ -1201,31 +1165,24 @@ void netedit(void) {
Done = 0;
extract_token(cmpb0, line, 0, sepchar, sizeof cmpb0);
extract_token(cmpb1, line, 1, sepchar, sizeof cmpb1);
- while (!Done && StrBuf_ServGetln(Line)>=0) {
- if ( (StrLength(Line)==3) &&
- !strcmp(ChrPtr(Line), "000"))
- {
+ while (!Done && StrBuf_ServGetln(Line) >= 0) {
+ if ((StrLength(Line) == 3) && !strcmp(ChrPtr(Line), "000")) {
Done = 1;
}
- else
- {
+ else {
if (StrLength(Line) == 0)
continue;
- if (malias_set_default)
- {
- if (strncasecmp(ChrPtr(Line), HKEY("roommailalias|")) != 0)
- {
+ if (malias_set_default) {
+ if (strncasecmp(ChrPtr(Line), HKEY("roommailalias|")) != 0) {
StrBufAppendBufPlain(Line, HKEY("\n"), 0);
StrBufAppendBuf(TmpBuf, Line, 0);
}
}
- else
- {
+ else {
extract_token(cmpa0, ChrPtr(Line), 0, sepchar, sizeof cmpa0);
extract_token(cmpa1, ChrPtr(Line), 1, sepchar, sizeof cmpa1);
- if ( (strcasecmp(cmpa0, cmpb0)) || (strcasecmp(cmpa1, cmpb1)) )
- {
+ if ((strcasecmp(cmpa0, cmpb0)) || (strcasecmp(cmpa1, cmpb1))) {
StrBufAppendBufPlain(Line, HKEY("\n"), 0);
StrBufAppendBuf(TmpBuf, Line, 0);
}
@@ -1234,14 +1191,14 @@ void netedit(void) {
}
if (malias)
- serv_puts("SNET "FILE_MAILALIAS);
+ serv_puts("SNET " FILE_MAILALIAS);
else
serv_puts("SNET");
StrBuf_ServGetln(Line);
- if (GetServerStatus(Line, NULL) != 4) {
+ if (GetServerStatus(Line, NULL) != 4) {
- AppendImportantMessage(SRV_STATUS_MSG(Line));
- output_headers(1, 1, 1, 0, 0, 0);
+ AppendImportantMessage(SRV_STATUS_MSG(Line));
+ output_headers(1, 1, 1, 0, 0, 0);
do_template("room_edit");
wDumpContent(1);
FreeStrBuf(&Line);
@@ -1260,7 +1217,7 @@ void netedit(void) {
}
else {
/* adding multiple addresses separated by commas */
- for (i=0; iCurRoom);
FreeStrBuf(&Line);
- output_headers(1, 1, 1, 0, 0, 0);
+ output_headers(1, 1, 1, 0, 0, 0);
do_template("room_edit");
wDumpContent(1);
}
@@ -1291,10 +1248,9 @@ void netedit(void) {
/*
* Known rooms list (box style)
*/
-void knrooms(void)
-{
+void knrooms(void) {
DeleteHash(&WC->Rooms);
- output_headers(1, 1, 1, 0, 0, 0);
+ output_headers(1, 1, 1, 0, 0, 0);
do_template("knrooms");
wDumpContent(1);
}
@@ -1329,20 +1285,20 @@ void delete_floor(void) {
int floornum;
StrBuf *Buf;
const char *Err;
-
+
floornum = ibstr("floornum");
Buf = NewStrBuf();
serv_printf("KFLR %d|1", floornum);
-
+
StrBufTCP_read_line(Buf, &WC->serv_sock, 0, &Err);
if (GetServerStatus(Buf, NULL) == 2) {
- StrBufPlain(Buf, _("Floor has been deleted."),-1);
+ StrBufPlain(Buf, _("Floor has been deleted."), -1);
}
else {
StrBufCutLeft(Buf, 4);
}
- AppendImportantMessage (SKEY(Buf));
+ AppendImportantMessage(SKEY(Buf));
FlushRoomlist();
http_transmit_thing(ChrPtr(do_template("floors")), 0);
@@ -1361,12 +1317,12 @@ void create_floor(void) {
StrBufTCP_read_line(Buf, &WC->serv_sock, 0, &Err);
if (GetServerStatus(Buf, NULL) == 2) {
- StrBufPlain(Buf, _("New floor has been created."),-1);
+ StrBufPlain(Buf, _("New floor has been created."), -1);
}
else {
StrBufCutLeft(Buf, 4);
}
- AppendImportantMessage (SKEY(Buf));
+ AppendImportantMessage(SKEY(Buf));
FlushRoomlist();
http_transmit_thing(ChrPtr(do_template("floors")), 0);
FreeStrBuf(&Buf);
@@ -1386,7 +1342,7 @@ void rename_floor(void) {
StrBuf_ServGetln(Buf);
StrBufCutLeft(Buf, 4);
- AppendImportantMessage (SKEY(Buf));
+ AppendImportantMessage(SKEY(Buf));
http_transmit_thing(ChrPtr(do_template("floors")), 0);
FreeStrBuf(&Buf);
@@ -1394,8 +1350,7 @@ void rename_floor(void) {
-void jsonRoomFlr(void)
-{
+void jsonRoomFlr(void) {
/* Send as our own (application/json) content type */
hprintf("HTTP/1.1 200 OK\r\n");
hprintf("Content-type: application/json; charset=utf-8\r\n");
@@ -1403,12 +1358,11 @@ void jsonRoomFlr(void)
hprintf("Connection: close\r\n");
hprintf("Pragma: no-cache\r\nCache-Control: no-store\r\nExpires:-1\r\n");
begin_burst();
- DoTemplate(HKEY("json_roomflr"),NULL,&NoCtx);
- end_burst();
+ DoTemplate(HKEY("json_roomflr"), NULL, &NoCtx);
+ end_burst();
}
-void _FlushRoomList(wcsession *WCC)
-{
+void _FlushRoomList(wcsession * WCC) {
free_march_list(WCC);
DeleteHash(&WCC->Floors);
DeleteHash(&WCC->Rooms);
@@ -1416,8 +1370,7 @@ void _FlushRoomList(wcsession *WCC)
FlushFolder(&WCC->CurRoom);
}
-void ReloadCurrentRoom(void)
-{
+void ReloadCurrentRoom(void) {
wcsession *WCC = WC;
StrBuf *CurRoom;
@@ -1428,22 +1381,15 @@ void ReloadCurrentRoom(void)
FreeStrBuf(&CurRoom);
}
-void FlushRoomlist(void)
-{
+void FlushRoomlist(void) {
wcsession *WCC = WC;
_FlushRoomList(WCC);
}
-void
-InitModule_ROOMOPS
-(void)
-{
- RegisterPreference("roomlistview",
- _("Room list view"),
- PRF_STRING,
- NULL);
- RegisterPreference("emptyfloors", _("Show empty floors"), PRF_YESNO, NULL);
+void InitModule_ROOMOPS(void) {
+ RegisterPreference("roomlistview", _("Room list view"), PRF_STRING, NULL);
+ RegisterPreference("emptyfloors", _("Show empty floors"), PRF_YESNO, NULL);
WebcitAddUrlHandler(HKEY("json_roomflr"), "", 0, jsonRoomFlr, 0);
@@ -1459,7 +1405,7 @@ InitModule_ROOMOPS
WebcitAddUrlHandler(HKEY("zap"), "", 0, zap, 0);
WebcitAddUrlHandler(HKEY("entroom"), "", 0, entroom, 0);
WebcitAddUrlHandler(HKEY("do_invt_kick"), "", 0, do_invt_kick, 0);
-
+
WebcitAddUrlHandler(HKEY("netedit"), "", 0, netedit, 0);
WebcitAddUrlHandler(HKEY("editroom"), "", 0, editroom, 0);
WebcitAddUrlHandler(HKEY("delete_room"), "", 0, delete_room, 0);
@@ -1517,12 +1463,12 @@ InitModule_ROOMOPS
REGISTERTokenParamDefine(US_USER_SET);
REGISTERTokenParamDefine(VIEW_BBS);
- REGISTERTokenParamDefine(VIEW_MAILBOX);
+ REGISTERTokenParamDefine(VIEW_MAILBOX);
REGISTERTokenParamDefine(VIEW_ADDRESSBOOK);
- REGISTERTokenParamDefine(VIEW_CALENDAR);
- REGISTERTokenParamDefine(VIEW_TASKS);
- REGISTERTokenParamDefine(VIEW_NOTES);
- REGISTERTokenParamDefine(VIEW_WIKI);
+ REGISTERTokenParamDefine(VIEW_CALENDAR);
+ REGISTERTokenParamDefine(VIEW_TASKS);
+ REGISTERTokenParamDefine(VIEW_NOTES);
+ REGISTERTokenParamDefine(VIEW_WIKI);
REGISTERTokenParamDefine(VIEW_CALBRIEF);
REGISTERTokenParamDefine(VIEW_JOURNAL);
REGISTERTokenParamDefine(VIEW_BLOG);
@@ -1535,14 +1481,14 @@ InitModule_ROOMOPS
REGISTERTokenParamDefine(lastsent);
REGISTERTokenParamDefine(ignet_push_share);
- { /* these are the parts of an IGNET push config */
+ { /* these are the parts of an IGNET push config */
REGISTERTokenParamDefine(GNET_IGNET_NODE);
REGISTERTokenParamDefine(GNET_IGNET_ROOM);
}
REGISTERTokenParamDefine(listrecp);
REGISTERTokenParamDefine(digestrecp);
REGISTERTokenParamDefine(pop3client);
- { /* These are the parts of a pop3 client line... */
+ { /* These are the parts of a pop3 client line... */
REGISTERTokenParamDefine(GNET_POP3_HOST);
REGISTERTokenParamDefine(GNET_POP3_USER);
REGISTERTokenParamDefine(GNET_POP3_DONT_DELETE_REMOTE);
@@ -1557,10 +1503,6 @@ InitModule_ROOMOPS
}
-void
-SessionDestroyModule_ROOMOPS
-(wcsession *sess)
-{
- _FlushRoomList (sess);
+void SessionDestroyModule_ROOMOPS(wcsession * sess) {
+ _FlushRoomList(sess);
}
-
diff --git a/webcit/roomops.h b/webcit/roomops.h
index fd1f60e4a..e4403e07e 100644
--- a/webcit/roomops.h
+++ b/webcit/roomops.h
@@ -1,3 +1,4 @@
+
/*
* Copyright (c) 1996-2013 by the citadel.org team
*
@@ -17,10 +18,10 @@
* This struct holds a list of rooms for "Goto" operations.
*/
struct march {
- struct march *next; /* pointer to next in linked list */
- char march_name[128]; /* name of room */
- int march_floor; /* floor number of room */
- int march_order; /* sequence in which we are to visit this room */
+ struct march *next; /* pointer to next in linked list */
+ char march_name[128]; /* name of room */
+ int march_floor; /* floor number of room */
+ int march_order; /* sequence in which we are to visit this room */
};
/*
@@ -29,10 +30,10 @@ struct march {
struct roomlisting {
struct roomlisting *lnext; /* pointer to 'left' tree node */
struct roomlisting *rnext; /* pointer to 'right' tree node */
- char rlname[128]; /* name of room */
- unsigned rlflags; /* room flags */
- int rlfloor; /* the floor it resides on */
- int rlorder; /* room listing order */
+ char rlname[128]; /* name of room */
+ unsigned rlflags; /* room flags */
+ int rlfloor; /* the floor it resides on */
+ int rlorder; /* room listing order */
};
@@ -50,14 +51,14 @@ typedef struct _floor {
* Data structure for roomlist-to-folderlist conversion
*/
struct __ofolder {
- int floor; /* which floor is it on */
- char room[SIZ]; /* which roomname ??? */
- char name[SIZ]; /* which is its own name??? */
- int hasnewmsgs; /* are there unread messages inside */
- int is_mailbox; /* is it a mailbox? */
- int selectable; /* can we select it ??? */
- int view; /* whats its default view? inbox/calendar.... */
- int num_rooms; /* If this is a floor, how many rooms does it have */
+ int floor; /* which floor is it on */
+ char room[SIZ]; /* which roomname ??? */
+ char name[SIZ]; /* which is its own name??? */
+ int hasnewmsgs; /* are there unread messages inside */
+ int is_mailbox; /* is it a mailbox? */
+ int selectable; /* can we select it ??? */
+ int view; /* whats its default view? inbox/calendar.... */
+ int num_rooms; /* If this is a floor, how many rooms does it have */
};
@@ -67,30 +68,30 @@ struct __ofolder {
*/
typedef struct _folder {
/* Data citserver tells us about the room */
- long QRFlags; /* roomflags */
- long QRFlags2; /* Bitbucket NO2 */
+ long QRFlags; /* roomflags */
+ long QRFlags2; /* Bitbucket NO2 */
long RAFlags;
- int view; /* whats its default view? inbox/calendar.... */
+ int view; /* whats its default view? inbox/calendar.... */
long defview;
- long lastchange; /* todo... */
+ long lastchange; /* todo... */
/* later evaluated data from the serverdata */
- StrBuf *name; /* the full name of the room we're talking about */
+ StrBuf *name; /* the full name of the room we're talking about */
long nRoomNameParts;
StrBuf **RoomNameParts;
- int floorid; /* which floor is it on */
- const Floor *Floor; /* point to the floor we're on.. */
+ int floorid; /* which floor is it on */
+ const Floor *Floor; /* point to the floor we're on.. */
- int hasnewmsgs; /* are there unread messages inside */
- int is_inbox; /* is it a mailbox? */
+ int hasnewmsgs; /* are there unread messages inside */
+ int is_inbox; /* is it a mailbox? */
int RoomAideLoaded;
StrBuf *RoomAide;
/* only available if GNET contains this */
- const StrBuf* RoomAlias; /* by what mail will this room send mail? */
+ const StrBuf *RoomAlias; /* by what mail will this room send mail? */
/* only available if GETR was run */
int XALoaded;
@@ -104,8 +105,9 @@ typedef struct _folder {
long LastMessageRead;
long HighestRead;
int ShowInfo;
- int UsersNewMAilboxMessages; /* should we notify the user about new messages? */
+ int UsersNewMAilboxMessages; /* should we notify the user about new messages? */
int IsTrash;
+
/* Only available if certain other commands ran */
int XHaveRoomPic;
int XHaveRoomPicLoaded;
@@ -115,44 +117,44 @@ typedef struct _folder {
int XHaveDownloadCount;
int XDownloadCount;
-
- int BumpUsers; /* if SETR set to 1 to make all users who knew this room to forget about it. */
+
+ int BumpUsers; /* if SETR set to 1 to make all users who knew this room to forget about it. */
HashList *IgnetCfgs[maxRoomNetCfg + 1];
} folder;
-HashList *GetFloorListHash(StrBuf *Target, WCTemplputParams *TP);
+HashList *GetFloorListHash(StrBuf * Target, WCTemplputParams * TP);
void vDeleteFolder(void *vFolder);
-void FlushFolder(folder *room);
-void FlushIgnetCfgs(folder *room);
-void ParseGoto(folder *proom, StrBuf *Line);
-void FlushRoomlist(void); /* release our caches, so a deleted / zapped room disapears */
-void ReloadCurrentRoom(void); /* Flush cache; reload current state */
-
-HashList *GetFloorListHash(StrBuf *Target, WCTemplputParams *TP);
-HashList *GetRoomListHash(StrBuf *Target, WCTemplputParams *TP);
+void FlushFolder(folder * room);
+void FlushIgnetCfgs(folder * room);
+void ParseGoto(folder * proom, StrBuf * Line);
+void FlushRoomlist(void); /* release our caches, so a deleted / zapped room disapears */
+void ReloadCurrentRoom(void); /* Flush cache; reload current state */
+
+HashList *GetFloorListHash(StrBuf * Target, WCTemplputParams * TP);
+HashList *GetRoomListHash(StrBuf * Target, WCTemplputParams * TP);
int SortRoomsByListOrder(const void *room1, const void *room2);
-void tmplput_roombanner(StrBuf *Target, WCTemplputParams *TP);
+void tmplput_roombanner(StrBuf * Target, WCTemplputParams * TP);
void LoadRoomAide(void);
-void LoadRoomXA (void);
+void LoadRoomXA(void);
void LoadXRoomPic(void);
void LoadXRoomInfoText(void);
void LoadXRoomXCountFiles(void);
-long gotoroom(const StrBuf *gname);
+long gotoroom(const StrBuf * gname);
void slrp_highest(void);
-void remove_march(const StrBuf *aaa);
+void remove_march(const StrBuf * aaa);
void dotskip(void);
-void smart_goto(const StrBuf *next_room);
-void free_march_list(wcsession *wcf);
+void smart_goto(const StrBuf * next_room);
+void free_march_list(wcsession * wcf);
/*
* wrapper around usual sort-comparator; private rooms will allways be prefered, -1 if one of them NULL
*/
-int CompareRooms(const folder *room1, const folder *room2);
+int CompareRooms(const folder * room1, const folder * room2);
#define REST_TOPLEVEL 0
diff --git a/webcit/roomtokens.c b/webcit/roomtokens.c
index 199cc3c1e..31b9eb94b 100644
--- a/webcit/roomtokens.c
+++ b/webcit/roomtokens.c
@@ -1,3 +1,4 @@
+
/*
* Lots of different room-related operations.
*
@@ -24,20 +25,17 @@ CtxType CTX_FLOORS = CTX_NONE;
* got The information returned from a GOTO server command
* navbar_style Determines which navigation buttons to display
*/
-void tmplput_roombanner(StrBuf *Target, WCTemplputParams *TP)
-{
+void tmplput_roombanner(StrBuf * Target, WCTemplputParams * TP) {
wcsession *WCC = WC;
-
+
/* Refresh current room states. Doesn't work? gotoroom(NULL); */
wc_printf("\n");
/* The browser needs some information for its own use */
wc_printf("\n",
- ((WC->CurRoom.RAFlags & UA_ISTRASH) != 0)
- );
+ " room_is_trash = %d; \n" "\n", ((WC->CurRoom.RAFlags & UA_ISTRASH) != 0)
+ );
/*
* If the user happens to select the "make this my start page" link,
@@ -61,24 +59,21 @@ void tmplput_roombanner(StrBuf *Target, WCTemplputParams *TP)
*******************************************************************************/
-void tmplput_FLOOR_ID(StrBuf *Target, WCTemplputParams *TP)
-{
- Floor *myFloor = (Floor *)CTX(CTX_FLOORS);
+void tmplput_FLOOR_ID(StrBuf * Target, WCTemplputParams * TP) {
+ Floor *myFloor = (Floor *) CTX(CTX_FLOORS);
StrBufAppendPrintf(Target, "%d", myFloor->ID);
}
-void tmplput_ROOM_FLOORID(StrBuf *Target, WCTemplputParams *TP)
-{
- folder *Folder = (folder *)CTX(CTX_ROOMS);
+void tmplput_ROOM_FLOORID(StrBuf * Target, WCTemplputParams * TP) {
+ folder *Folder = (folder *) CTX(CTX_ROOMS);
StrBufAppendPrintf(Target, "%d", Folder->floorid);
}
-void tmplput_ROOM_FLOOR_ID(StrBuf *Target, WCTemplputParams *TP)
-{
- folder *Folder = (folder *)CTX(CTX_ROOMS);
+void tmplput_ROOM_FLOOR_ID(StrBuf * Target, WCTemplputParams * TP) {
+ folder *Folder = (folder *) CTX(CTX_ROOMS);
const Floor *pFloor = Folder->Floor;
if (pFloor == NULL)
@@ -88,9 +83,8 @@ void tmplput_ROOM_FLOOR_ID(StrBuf *Target, WCTemplputParams *TP)
}
-void tmplput_ROOM_FLOOR_NAME(StrBuf *Target, WCTemplputParams *TP)
-{
- folder *Folder = (folder *)CTX(CTX_ROOMS);
+void tmplput_ROOM_FLOOR_NAME(StrBuf * Target, WCTemplputParams * TP) {
+ folder *Folder = (folder *) CTX(CTX_ROOMS);
const Floor *pFloor = Folder->Floor;
if (pFloor == NULL)
@@ -100,8 +94,7 @@ void tmplput_ROOM_FLOOR_NAME(StrBuf *Target, WCTemplputParams *TP)
}
-void tmplput_ThisRoomFloorName(StrBuf *Target, WCTemplputParams *TP)
-{
+void tmplput_ThisRoomFloorName(StrBuf * Target, WCTemplputParams * TP) {
wcsession *WCC = WC;
folder *Folder = &WCC->CurRoom;
const Floor *pFloor;
@@ -117,25 +110,22 @@ void tmplput_ThisRoomFloorName(StrBuf *Target, WCTemplputParams *TP)
}
-void tmplput_FLOOR_NAME(StrBuf *Target, WCTemplputParams *TP)
-{
- Floor *myFloor = (Floor *)CTX(CTX_FLOORS);
+void tmplput_FLOOR_NAME(StrBuf * Target, WCTemplputParams * TP) {
+ Floor *myFloor = (Floor *) CTX(CTX_FLOORS);
StrBufAppendTemplate(Target, TP, myFloor->Name, 0);
}
-void tmplput_FLOOR_NROOMS(StrBuf *Target, WCTemplputParams *TP)
-{
- Floor *myFloor = (Floor *)CTX(CTX_FLOORS);
+void tmplput_FLOOR_NROOMS(StrBuf * Target, WCTemplputParams * TP) {
+ Floor *myFloor = (Floor *) CTX(CTX_FLOORS);
StrBufAppendPrintf(Target, "%d", myFloor->NRooms);
}
-void tmplput_ROOM_FLOOR_NROOMS(StrBuf *Target, WCTemplputParams *TP)
-{
- folder *Folder = (folder *)CTX(CTX_ROOMS);
+void tmplput_ROOM_FLOOR_NROOMS(StrBuf * Target, WCTemplputParams * TP) {
+ folder *Folder = (folder *) CTX(CTX_ROOMS);
const Floor *pFloor = Folder->Floor;
if (pFloor == NULL)
@@ -144,9 +134,8 @@ void tmplput_ROOM_FLOOR_NROOMS(StrBuf *Target, WCTemplputParams *TP)
}
-int ConditionalFloorHaveNRooms(StrBuf *Target, WCTemplputParams *TP)
-{
- Floor *MyFloor = (Floor *)CTX(CTX_FLOORS);
+int ConditionalFloorHaveNRooms(StrBuf * Target, WCTemplputParams * TP) {
+ Floor *MyFloor = (Floor *) CTX(CTX_FLOORS);
int HaveN;
HaveN = GetTemplateTokenNumber(Target, TP, 0, 0);
@@ -155,30 +144,27 @@ int ConditionalFloorHaveNRooms(StrBuf *Target, WCTemplputParams *TP)
}
-int ConditionalFloorIsRESTSubFloor(StrBuf *Target, WCTemplputParams *TP)
-{
- wcsession *WCC = WC;
- Floor *MyFloor = (Floor *)CTX(CTX_FLOORS);
+int ConditionalFloorIsRESTSubFloor(StrBuf * Target, WCTemplputParams * TP) {
+ wcsession *WCC = WC;
+ Floor *MyFloor = (Floor *) CTX(CTX_FLOORS);
+
/** if we have dav_depth the client just wants the subfloors */
- if ((WCC->Hdr->HR.dav_depth == 1) &&
- (GetCount(WCC->Directory) == 0))
+ if ((WCC->Hdr->HR.dav_depth == 1) && (GetCount(WCC->Directory) == 0))
return 1;
return WCC->CurrentFloor == MyFloor;
}
-int ConditionalFloorIsSUBROOM(StrBuf *Target, WCTemplputParams *TP)
-{
- wcsession *WCC = WC;
- Floor *MyFloor = (Floor *)CTX(CTX_FLOORS);
+int ConditionalFloorIsSUBROOM(StrBuf * Target, WCTemplputParams * TP) {
+ wcsession *WCC = WC;
+ Floor *MyFloor = (Floor *) CTX(CTX_FLOORS);
return WCC->CurRoom.floorid == MyFloor->ID;
}
-int ConditionalFloorIsVirtual(StrBuf *Target, WCTemplputParams *TP)
-{
- Floor *MyFloor = (Floor *)CTX(CTX_FLOORS);
+int ConditionalFloorIsVirtual(StrBuf * Target, WCTemplputParams * TP) {
+ Floor *MyFloor = (Floor *) CTX(CTX_FLOORS);
return MyFloor->ID == VIRTUAL_MY_FLOOR;
}
@@ -187,51 +173,43 @@ int ConditionalFloorIsVirtual(StrBuf *Target, WCTemplputParams *TP)
/*******************************************************************************
********************** ROOM Tokens ********************************************
*******************************************************************************/
+
/**** Name ******/
-void tmplput_ThisRoom(StrBuf *Target, WCTemplputParams *TP)
-{
+void tmplput_ThisRoom(StrBuf * Target, WCTemplputParams * TP) {
wcsession *WCC = WC;
if (WCC != NULL) {
- StrBufAppendTemplate(Target, TP,
- WCC->CurRoom.name,
- 0
- );
+ StrBufAppendTemplate(Target, TP, WCC->CurRoom.name, 0);
}
}
-void tmplput_ROOM_NAME(StrBuf *Target, WCTemplputParams *TP)
-{
- folder *Folder = (folder *)CTX(CTX_ROOMS);
+void tmplput_ROOM_NAME(StrBuf * Target, WCTemplputParams * TP) {
+ folder *Folder = (folder *) CTX(CTX_ROOMS);
StrBufAppendTemplate(Target, TP, Folder->name, 0);
}
-void tmplput_ROOM_BASENAME(StrBuf *Target, WCTemplputParams *TP)
-{
- folder *room = (folder *)CTX(CTX_ROOMS);
+void tmplput_ROOM_BASENAME(StrBuf * Target, WCTemplputParams * TP) {
+ folder *room = (folder *) CTX(CTX_ROOMS);
if (room->nRoomNameParts > 1)
- StrBufAppendTemplate(Target, TP,
- room->RoomNameParts[room->nRoomNameParts - 1], 0);
- else
+ StrBufAppendTemplate(Target, TP, room->RoomNameParts[room->nRoomNameParts - 1], 0);
+ else
StrBufAppendTemplate(Target, TP, room->name, 0);
}
-void tmplput_ROOM_LEVEL_N_TIMES(StrBuf *Target, WCTemplputParams *TP)
-{
- folder *room = (folder *)CTX(CTX_ROOMS);
+void tmplput_ROOM_LEVEL_N_TIMES(StrBuf * Target, WCTemplputParams * TP) {
+ folder *room = (folder *) CTX(CTX_ROOMS);
int i;
- const char *AppendMe;
- long AppendMeLen;
+ const char *AppendMe;
+ long AppendMeLen;
- if (room->nRoomNameParts > 1)
- {
+ if (room->nRoomNameParts > 1) {
GetTemplateTokenString(Target, TP, 0, &AppendMe, &AppendMeLen);
for (i = 0; i < room->nRoomNameParts; i++)
StrBufAppendBufPlain(Target, AppendMe, AppendMeLen, 0);
@@ -239,23 +217,19 @@ void tmplput_ROOM_LEVEL_N_TIMES(StrBuf *Target, WCTemplputParams *TP)
}
-int ConditionalRoomIsInbox(StrBuf *Target, WCTemplputParams *TP)
-{
- folder *Folder = (folder *)CTX(CTX_ROOMS);
+int ConditionalRoomIsInbox(StrBuf * Target, WCTemplputParams * TP) {
+ folder *Folder = (folder *) CTX(CTX_ROOMS);
return Folder->is_inbox;
}
-int ConditionalRoomIsType(StrBuf *Target, WCTemplputParams *TP)
-{
- folder *Folder = (folder *)CTX(CTX_ROOMS);
+int ConditionalRoomIsType(StrBuf * Target, WCTemplputParams * TP) {
+ folder *Folder = (folder *) CTX(CTX_ROOMS);
if (Folder == NULL)
return 0;
- if ((TP->Tokens->nParameters < 3))
- {
- return ((Folder->view < VIEW_BBS) ||
- (Folder->view > VIEW_MAX));
+ if ((TP->Tokens->nParameters < 3)) {
+ return ((Folder->view < VIEW_BBS) || (Folder->view > VIEW_MAX));
}
return Folder->view == GetTemplateTokenNumber(Target, TP, 2, VIEW_BBS);
@@ -264,87 +238,78 @@ int ConditionalRoomIsType(StrBuf *Target, WCTemplputParams *TP)
/****** Properties ******/
-int ConditionalRoom_MayEdit(StrBuf *Target, WCTemplputParams *TP)
-{
+int ConditionalRoom_MayEdit(StrBuf * Target, WCTemplputParams * TP) {
wcsession *WCC = WC;
- LoadRoomXA ();
+ LoadRoomXA();
return WCC->CurRoom.XALoaded == 1;
}
-int ConditionalThisRoomHas_QRFlag(StrBuf *Target, WCTemplputParams *TP)
-{
+int ConditionalThisRoomHas_QRFlag(StrBuf * Target, WCTemplputParams * TP) {
long QR_CheckFlag;
wcsession *WCC = WC;
-
+
QR_CheckFlag = GetTemplateTokenNumber(Target, TP, 2, 0);
if (QR_CheckFlag == 0)
LogTemplateError(Target, "Conditional", ERR_PARM1, TP,
"requires one of the #\"QR*\"- defines or an integer flag 0 is invalid!");
-
+
if (WCC == NULL)
return 0;
- if ((TP->Tokens->Params[2]->MaskBy == eOR) ||
- (TP->Tokens->Params[2]->MaskBy == eNO))
+ if ((TP->Tokens->Params[2]->MaskBy == eOR) || (TP->Tokens->Params[2]->MaskBy == eNO))
return (WCC->CurRoom.QRFlags & QR_CheckFlag) != 0;
else
return (WCC->CurRoom.QRFlags & QR_CheckFlag) == QR_CheckFlag;
}
-int ConditionalRoomHas_QRFlag(StrBuf *Target, WCTemplputParams *TP)
-{
+int ConditionalRoomHas_QRFlag(StrBuf * Target, WCTemplputParams * TP) {
long QR_CheckFlag;
- folder *Folder = (folder *)(TP->Context);
+ folder *Folder = (folder *) (TP->Context);
QR_CheckFlag = GetTemplateTokenNumber(Target, TP, 2, 0);
if (QR_CheckFlag == 0)
LogTemplateError(Target, "Conditional", ERR_PARM1, TP,
"requires one of the #\"QR*\"- defines or an integer flag 0 is invalid!");
- if ((TP->Tokens->Params[2]->MaskBy == eOR) ||
- (TP->Tokens->Params[2]->MaskBy == eNO))
+ if ((TP->Tokens->Params[2]->MaskBy == eOR) || (TP->Tokens->Params[2]->MaskBy == eNO))
return (Folder->QRFlags & QR_CheckFlag) != 0;
else
return (Folder->QRFlags & QR_CheckFlag) == QR_CheckFlag;
}
-void tmplput_ROOM_QRFLAGS(StrBuf *Target, WCTemplputParams *TP)
-{
- folder *Folder = (folder *)CTX(CTX_ROOMS);
+void tmplput_ROOM_QRFLAGS(StrBuf * Target, WCTemplputParams * TP) {
+ folder *Folder = (folder *) CTX(CTX_ROOMS);
StrBufAppendPrintf(Target, "%d", Folder->QRFlags);
}
-int ConditionalThisRoomHas_QRFlag2(StrBuf *Target, WCTemplputParams *TP)
-{
+int ConditionalThisRoomHas_QRFlag2(StrBuf * Target, WCTemplputParams * TP) {
long QR2_CheckFlag;
wcsession *WCC = WC;
-
+
QR2_CheckFlag = GetTemplateTokenNumber(Target, TP, 2, 0);
if (QR2_CheckFlag == 0)
LogTemplateError(Target, "Conditional", ERR_PARM1, TP,
"requires one of the #\"QR2*\"- defines or an integer flag 0 is invalid!");
-
+
if (WCC == NULL)
return 0;
- if ((TP->Tokens->Params[2]->MaskBy == eOR) ||
- (TP->Tokens->Params[2]->MaskBy == eNO))
+ if ((TP->Tokens->Params[2]->MaskBy == eOR) || (TP->Tokens->Params[2]->MaskBy == eNO))
return (WCC->CurRoom.QRFlags2 & QR2_CheckFlag) != 0;
else
return (WCC->CurRoom.QRFlags2 & QR2_CheckFlag) == QR2_CheckFlag;
}
-int ConditionalRoomHas_QRFlag2(StrBuf *Target, WCTemplputParams *TP)
-{
+int ConditionalRoomHas_QRFlag2(StrBuf * Target, WCTemplputParams * TP) {
long QR2_CheckFlag;
- folder *Folder = (folder *)(TP->Context);
+ folder *Folder = (folder *) (TP->Context);
QR2_CheckFlag = GetTemplateTokenNumber(Target, TP, 2, 0);
if (QR2_CheckFlag == 0)
@@ -354,11 +319,10 @@ int ConditionalRoomHas_QRFlag2(StrBuf *Target, WCTemplputParams *TP)
}
-int ConditionalRoomHas_UAFlag(StrBuf *Target, WCTemplputParams *TP)
-{
- folder *Folder = (folder *)(TP->Context);
+int ConditionalRoomHas_UAFlag(StrBuf * Target, WCTemplputParams * TP) {
+ folder *Folder = (folder *) (TP->Context);
long UA_CheckFlag;
-
+
UA_CheckFlag = GetTemplateTokenNumber(Target, TP, 2, 0);
if (UA_CheckFlag == 0)
LogTemplateError(Target, "Conditional", ERR_PARM1, TP,
@@ -368,23 +332,20 @@ int ConditionalRoomHas_UAFlag(StrBuf *Target, WCTemplputParams *TP)
}
-void tmplput_ROOM_ACL(StrBuf *Target, WCTemplputParams *TP)
-{
- folder *Folder = (folder *)CTX(CTX_ROOMS);
+void tmplput_ROOM_ACL(StrBuf * Target, WCTemplputParams * TP) {
+ folder *Folder = (folder *) CTX(CTX_ROOMS);
StrBufAppendPrintf(Target, "%ld", Folder->RAFlags, 0);
}
-void tmplput_ROOM_RAFLAGS(StrBuf *Target, WCTemplputParams *TP)
-{
- folder *Folder = (folder *)(TP->Context);
+void tmplput_ROOM_RAFLAGS(StrBuf * Target, WCTemplputParams * TP) {
+ folder *Folder = (folder *) (TP->Context);
StrBufAppendPrintf(Target, "%d", Folder->RAFlags);
}
-void tmplput_ThisRoomAide(StrBuf *Target, WCTemplputParams *TP)
-{
+void tmplput_ThisRoomAide(StrBuf * Target, WCTemplputParams * TP) {
wcsession *WCC = WC;
LoadRoomAide();
@@ -393,41 +354,33 @@ void tmplput_ThisRoomAide(StrBuf *Target, WCTemplputParams *TP)
}
-int ConditionalRoomAide(StrBuf *Target, WCTemplputParams *TP)
-{
+int ConditionalRoomAide(StrBuf * Target, WCTemplputParams * TP) {
wcsession *WCC = WC;
- return (WCC != NULL)?
- ((WCC->CurRoom.RAFlags & UA_ADMINALLOWED) != 0) : 0;
+ return (WCC != NULL) ? ((WCC->CurRoom.RAFlags & UA_ADMINALLOWED) != 0) : 0;
}
-int ConditionalRoomAcessDelete(StrBuf *Target, WCTemplputParams *TP)
-{
+int ConditionalRoomAcessDelete(StrBuf * Target, WCTemplputParams * TP) {
wcsession *WCC = WC;
- return (WCC == NULL)? 0 :
- ( ((WCC->CurRoom.RAFlags & UA_ADMINALLOWED) != 0) ||
- (WCC->CurRoom.is_inbox) ||
- (WCC->CurRoom.QRFlags2 & QR2_COLLABDEL) );
+ return (WCC == NULL) ? 0 :
+ (((WCC->CurRoom.RAFlags & UA_ADMINALLOWED) != 0) || (WCC->CurRoom.is_inbox) || (WCC->CurRoom.QRFlags2 & QR2_COLLABDEL));
}
-int ConditionalHaveRoomeditRights(StrBuf *Target, WCTemplputParams *TP)
-{
+int ConditionalHaveRoomeditRights(StrBuf * Target, WCTemplputParams * TP) {
wcsession *WCC = WC;
- return ( (WCC != NULL)
- && (WCC->logged_in)
- && (
- (WCC->axlevel >= 6)
- || ((WCC->CurRoom.RAFlags & UA_ADMINALLOWED) != 0)
- || (WCC->CurRoom.is_inbox)
- )
- );
+ return ((WCC != NULL)
+ && (WCC->logged_in)
+ && ((WCC->axlevel >= 6)
+ || ((WCC->CurRoom.RAFlags & UA_ADMINALLOWED) != 0)
+ || (WCC->CurRoom.is_inbox)
+ )
+ );
}
-void tmplput_ThisRoomPass(StrBuf *Target, WCTemplputParams *TP)
-{
+void tmplput_ThisRoomPass(StrBuf * Target, WCTemplputParams * TP) {
wcsession *WCC = WC;
LoadRoomXA();
@@ -435,24 +388,21 @@ void tmplput_ThisRoomPass(StrBuf *Target, WCTemplputParams *TP)
}
-void tmplput_ThisRoom_nNewMessages(StrBuf *Target, WCTemplputParams *TP)
-{
+void tmplput_ThisRoom_nNewMessages(StrBuf * Target, WCTemplputParams * TP) {
wcsession *WCC = WC;
StrBufAppendPrintf(Target, "%d", WCC->CurRoom.nNewMessages);
}
-void tmplput_ThisRoom_nTotalMessages(StrBuf *Target, WCTemplputParams *TP)
-{
+void tmplput_ThisRoom_nTotalMessages(StrBuf * Target, WCTemplputParams * TP) {
wcsession *WCC = WC;
StrBufAppendPrintf(Target, "%d", WCC->CurRoom.nTotalMessages);
}
-void tmplput_ThisRoomOrder(StrBuf *Target, WCTemplputParams *TP)
-{
+void tmplput_ThisRoomOrder(StrBuf * Target, WCTemplputParams * TP) {
wcsession *WCC = WC;
LoadRoomXA();
@@ -461,8 +411,7 @@ void tmplput_ThisRoomOrder(StrBuf *Target, WCTemplputParams *TP)
}
-int ConditionalThisRoomOrder(StrBuf *Target, WCTemplputParams *TP)
-{
+int ConditionalThisRoomOrder(StrBuf * Target, WCTemplputParams * TP) {
wcsession *WCC = WC;
long CheckThis;
@@ -476,17 +425,15 @@ int ConditionalThisRoomOrder(StrBuf *Target, WCTemplputParams *TP)
}
-void tmplput_ROOM_LISTORDER(StrBuf *Target, WCTemplputParams *TP)
-{
- folder *Folder = (folder *)CTX(CTX_ROOMS);
+void tmplput_ROOM_LISTORDER(StrBuf * Target, WCTemplputParams * TP) {
+ folder *Folder = (folder *) CTX(CTX_ROOMS);
StrBufAppendPrintf(Target, "%d", Folder->Order);
}
-int ConditionalThisRoomXHavePic(StrBuf *Target, WCTemplputParams *TP)
-{
+int ConditionalThisRoomXHavePic(StrBuf * Target, WCTemplputParams * TP) {
wcsession *WCC = WC;
-
+
if (WCC == NULL)
return 0;
@@ -494,30 +441,27 @@ int ConditionalThisRoomXHavePic(StrBuf *Target, WCTemplputParams *TP)
return WCC->CurRoom.XHaveRoomPic == 1;
}
-int ConditionalThisRoomIsEdit(StrBuf *Target, WCTemplputParams *TP)
-{
+int ConditionalThisRoomIsEdit(StrBuf * Target, WCTemplputParams * TP) {
wcsession *WCC = WC;
if (WCC == NULL)
return 0;
- return ((WCC->CurRoom.nRoomNameParts > 1) &&
+ return ((WCC->CurRoom.nRoomNameParts > 1) &&
(strcmp(ChrPtr(WCC->CurRoom.RoomNameParts[WCC->CurRoom.nRoomNameParts]), "edit") == 0));
}
-int ConditionalThisRoomXHaveInfoText(StrBuf *Target, WCTemplputParams *TP)
-{
+int ConditionalThisRoomXHaveInfoText(StrBuf * Target, WCTemplputParams * TP) {
wcsession *WCC = WC;
-
+
if (WCC == NULL)
return 0;
LoadXRoomInfoText();
- return (StrLength(WCC->CurRoom.XInfoText)>0);
+ return (StrLength(WCC->CurRoom.XInfoText) > 0);
}
-void tmplput_ThisRoomInfoText(StrBuf *Target, WCTemplputParams *TP)
-{
+void tmplput_ThisRoomInfoText(StrBuf * Target, WCTemplputParams * TP) {
wcsession *WCC = WC;
long nchars = 0;
@@ -542,15 +486,13 @@ void tmplput_ThisRoomInfoText(StrBuf *Target, WCTemplputParams *TP)
}
-void tmplput_ROOM_LASTCHANGE(StrBuf *Target, WCTemplputParams *TP)
-{
- folder *Folder = (folder *)CTX(CTX_ROOMS);
+void tmplput_ROOM_LASTCHANGE(StrBuf * Target, WCTemplputParams * TP) {
+ folder *Folder = (folder *) CTX(CTX_ROOMS);
StrBufAppendPrintf(Target, "%d", Folder->lastchange);
}
-void tmplput_ThisRoomDirectory(StrBuf *Target, WCTemplputParams *TP)
-{
+void tmplput_ThisRoomDirectory(StrBuf * Target, WCTemplputParams * TP) {
wcsession *WCC = WC;
LoadRoomXA();
@@ -559,8 +501,7 @@ void tmplput_ThisRoomDirectory(StrBuf *Target, WCTemplputParams *TP)
}
-void tmplput_ThisRoomXNFiles(StrBuf *Target, WCTemplputParams *TP)
-{
+void tmplput_ThisRoomXNFiles(StrBuf * Target, WCTemplputParams * TP) {
wcsession *WCC = WC;
LoadXRoomXCountFiles();
@@ -569,8 +510,7 @@ void tmplput_ThisRoomXNFiles(StrBuf *Target, WCTemplputParams *TP)
}
-void tmplput_ThisRoomX_FileString(StrBuf *Target, WCTemplputParams *TP)
-{
+void tmplput_ThisRoomX_FileString(StrBuf * Target, WCTemplputParams * TP) {
wcsession *WCC = WC;
LoadXRoomXCountFiles();
@@ -582,9 +522,8 @@ void tmplput_ThisRoomX_FileString(StrBuf *Target, WCTemplputParams *TP)
}
-int ConditionalIsThisThatRoom(StrBuf *Target, WCTemplputParams *TP)
-{
- folder *Folder = (folder *)CTX(CTX_ROOMS);
+int ConditionalIsThisThatRoom(StrBuf * Target, WCTemplputParams * TP) {
+ folder *Folder = (folder *) CTX(CTX_ROOMS);
wcsession *WCC = WC;
if (WCC == NULL)
@@ -593,11 +532,10 @@ int ConditionalIsThisThatRoom(StrBuf *Target, WCTemplputParams *TP)
return Folder == WCC->ThisRoom;
}
-int ConditionalRoomIsName(StrBuf *Target, WCTemplputParams *TP)
-{
- folder *Folder = (folder *)CTX(CTX_ROOMS);
- const char *CheckRoomName = NULL;
- long CheckRoomNameLen;
+int ConditionalRoomIsName(StrBuf * Target, WCTemplputParams * TP) {
+ folder *Folder = (folder *) CTX(CTX_ROOMS);
+ const char *CheckRoomName = NULL;
+ long CheckRoomNameLen;
GetTemplateTokenString(Target, TP, 3, &CheckRoomName, &CheckRoomNameLen);
if (CheckRoomName == NULL)
@@ -606,10 +544,7 @@ int ConditionalRoomIsName(StrBuf *Target, WCTemplputParams *TP)
}
-void
-InitModule_ROOMTOKENS
-(void)
-{
+void InitModule_ROOMTOKENS(void) {
/* we duplicate this, just to be shure its already done. */
RegisterCTX(CTX_ROOMS);
RegisterCTX(CTX_FLOORS);
@@ -633,7 +568,8 @@ InitModule_ROOMTOKENS
RegisterConditional("COND:FLOOR:ISVIRTUAL", 0, ConditionalFloorIsVirtual, CTX_FLOORS);
/**** Room... ******/
- /**** Name ******/
+
+ /**** Name ******/
RegisterNamespace("THISROOM:NAME", 0, 1, tmplput_ThisRoom, NULL, CTX_NONE);
RegisterNamespace("ROOM:INFO:NAME", 0, 1, tmplput_ROOM_NAME, NULL, CTX_ROOMS);
diff --git a/webcit/roomviews.c b/webcit/roomviews.c
index 18563000d..6364049c8 100644
--- a/webcit/roomviews.c
+++ b/webcit/roomviews.c
@@ -1,3 +1,4 @@
+
/*
* Lots of different room-related operations.
*/
@@ -12,18 +13,18 @@ char *viewdefs[VIEW_MAX];
* default view for a room at the time of its creation.
*/
int allowed_default_views[VIEW_MAX] = {
- 1, /* VIEW_BBS Bulletin board */
- 1, /* VIEW_MAILBOX Mailbox summary */
- 1, /* VIEW_ADDRESSBOOK Address book */
- 1, /* VIEW_CALENDAR Calendar */
- 1, /* VIEW_TASKS Tasks */
- 1, /* VIEW_NOTES Notes */
- 1, /* VIEW_WIKI Wiki */
- 0, /* VIEW_CALBRIEF Brief Calendar */
- 0, /* VIEW_JOURNAL Journal */
- 0, /* VIEW_DRAFTS Drafts */
- 1, /* VIEW_BLOG Blog */
- 0 /* VIEW_QUEUE Mail Queue */
+ 1, /* VIEW_BBS Bulletin board */
+ 1, /* VIEW_MAILBOX Mailbox summary */
+ 1, /* VIEW_ADDRESSBOOK Address book */
+ 1, /* VIEW_CALENDAR Calendar */
+ 1, /* VIEW_TASKS Tasks */
+ 1, /* VIEW_NOTES Notes */
+ 1, /* VIEW_WIKI Wiki */
+ 0, /* VIEW_CALBRIEF Brief Calendar */
+ 0, /* VIEW_JOURNAL Journal */
+ 0, /* VIEW_DRAFTS Drafts */
+ 1, /* VIEW_BLOG Blog */
+ 0 /* VIEW_QUEUE Mail Queue */
};
/*
@@ -48,25 +49,24 @@ ROOM_VIEWS exchangeable_views[VIEW_MAX][VIEW_MAX] = {
* Initialize the viewdefs with localized strings
*/
void initialize_viewdefs(void) {
- viewdefs[VIEW_BBS] = _("Bulletin Board");
- viewdefs[VIEW_MAILBOX] = _("Mail Folder");
- viewdefs[VIEW_ADDRESSBOOK] = _("Address Book");
- viewdefs[VIEW_CALENDAR] = _("Calendar");
- viewdefs[VIEW_TASKS] = _("Task List");
- viewdefs[VIEW_NOTES] = _("Notes List");
- viewdefs[VIEW_WIKI] = _("Wiki");
- viewdefs[VIEW_CALBRIEF] = _("Calendar List");
- viewdefs[VIEW_JOURNAL] = _("Journal");
- viewdefs[VIEW_DRAFTS] = _("Drafts");
- viewdefs[VIEW_BLOG] = _("Blog");
+ viewdefs[VIEW_BBS] = _("Bulletin Board");
+ viewdefs[VIEW_MAILBOX] = _("Mail Folder");
+ viewdefs[VIEW_ADDRESSBOOK] = _("Address Book");
+ viewdefs[VIEW_CALENDAR] = _("Calendar");
+ viewdefs[VIEW_TASKS] = _("Task List");
+ viewdefs[VIEW_NOTES] = _("Notes List");
+ viewdefs[VIEW_WIKI] = _("Wiki");
+ viewdefs[VIEW_CALBRIEF] = _("Calendar List");
+ viewdefs[VIEW_JOURNAL] = _("Journal");
+ viewdefs[VIEW_DRAFTS] = _("Drafts");
+ viewdefs[VIEW_BLOG] = _("Blog");
}
-void tmplput_ROOM_COLLECTIONTYPE(StrBuf *Target, WCTemplputParams *TP)
-{
- folder *Folder = (folder *)CTX(CTX_ROOMS);
-
- switch(Folder->view) {
+void tmplput_ROOM_COLLECTIONTYPE(StrBuf * Target, WCTemplputParams * TP) {
+ folder *Folder = (folder *) CTX(CTX_ROOMS);
+
+ switch (Folder->view) {
case VIEW_CALENDAR:
StrBufAppendBufPlain(Target, HKEY("vevent"), 0);
break;
@@ -90,50 +90,37 @@ void tmplput_ROOM_COLLECTIONTYPE(StrBuf *Target, WCTemplputParams *TP)
-int ConditionalRoomHasGroupdavContent(StrBuf *Target, WCTemplputParams *TP)
-{
- folder *Folder = (folder *)CTX(CTX_ROOMS);
+int ConditionalRoomHasGroupdavContent(StrBuf * Target, WCTemplputParams * TP) {
+ folder *Folder = (folder *) CTX(CTX_ROOMS);
syslog(LOG_DEBUG, "-> %s: %d\n", ChrPtr(Folder->name), Folder->view);
- return ((Folder->view == VIEW_CALENDAR) ||
- (Folder->view == VIEW_TASKS) ||
- (Folder->view == VIEW_ADDRESSBOOK) ||
- (Folder->view == VIEW_NOTES) ||
- (Folder->view == VIEW_JOURNAL) );
+ return ((Folder->view == VIEW_CALENDAR) ||
+ (Folder->view == VIEW_TASKS) ||
+ (Folder->view == VIEW_ADDRESSBOOK) || (Folder->view == VIEW_NOTES) || (Folder->view == VIEW_JOURNAL));
}
-int ConditionalIsRoomtype(StrBuf *Target, WCTemplputParams *TP)
-{
+int ConditionalIsRoomtype(StrBuf * Target, WCTemplputParams * TP) {
wcsession *WCC = WC;
- if ((WCC == NULL) ||
- (TP->Tokens->nParameters < 3))
- {
- return ((WCC->CurRoom.view < VIEW_BBS) ||
- (WCC->CurRoom.view > VIEW_MAX));
+ if ((WCC == NULL) || (TP->Tokens->nParameters < 3)) {
+ return ((WCC->CurRoom.view < VIEW_BBS) || (WCC->CurRoom.view > VIEW_MAX));
}
return WCC->CurRoom.view == GetTemplateTokenNumber(Target, TP, 2, VIEW_BBS);
}
-void tmplput_CurrentRoomViewString(StrBuf *Target, WCTemplputParams *TP)
-{
+void tmplput_CurrentRoomViewString(StrBuf * Target, WCTemplputParams * TP) {
wcsession *WCC = WC;
StrBuf *Buf;
- if ((WCC == NULL) ||
- (WCC->CurRoom.defview >= VIEW_MAX) ||
- (WCC->CurRoom.defview < VIEW_BBS))
- {
+ if ((WCC == NULL) || (WCC->CurRoom.defview >= VIEW_MAX) || (WCC->CurRoom.defview < VIEW_BBS)) {
LogTemplateError(Target, "Token", ERR_PARM2, TP,
- "Roomview [%ld] not valid\n",
- (WCC != NULL)?
- WCC->CurRoom.defview : -1);
+ "Roomview [%ld] not valid\n", (WCC != NULL) ? WCC->CurRoom.defview : -1);
return;
}
@@ -142,17 +129,13 @@ void tmplput_CurrentRoomViewString(StrBuf *Target, WCTemplputParams *TP)
FreeStrBuf(&Buf);
}
-void tmplput_RoomViewString(StrBuf *Target, WCTemplputParams *TP)
-{
+void tmplput_RoomViewString(StrBuf * Target, WCTemplputParams * TP) {
long CheckThis;
StrBuf *Buf;
CheckThis = GetTemplateTokenNumber(Target, TP, 0, 0);
- if ((CheckThis >= VIEW_MAX) || (CheckThis < VIEW_BBS))
- {
- LogTemplateError(Target, "Token", ERR_PARM2, TP,
- "Roomview [%ld] not valid\n",
- CheckThis);
+ if ((CheckThis >= VIEW_MAX) || (CheckThis < VIEW_BBS)) {
+ LogTemplateError(Target, "Token", ERR_PARM2, TP, "Roomview [%ld] not valid\n", CheckThis);
return;
}
@@ -163,28 +146,23 @@ void tmplput_RoomViewString(StrBuf *Target, WCTemplputParams *TP)
-int ConditionalIsAllowedDefaultView(StrBuf *Target, WCTemplputParams *TP)
-{
+int ConditionalIsAllowedDefaultView(StrBuf * Target, WCTemplputParams * TP) {
wcsession *WCC = WC;
long CheckThis;
-
+
if (WCC == NULL)
return 0;
CheckThis = GetTemplateTokenNumber(Target, TP, 2, 0);
- if ((CheckThis >= VIEW_MAX) || (CheckThis < VIEW_BBS))
- {
- LogTemplateError(Target, "Conditional", ERR_PARM2, TP,
- "Roomview [%ld] not valid\n",
- CheckThis);
+ if ((CheckThis >= VIEW_MAX) || (CheckThis < VIEW_BBS)) {
+ LogTemplateError(Target, "Conditional", ERR_PARM2, TP, "Roomview [%ld] not valid\n", CheckThis);
return 0;
}
return allowed_default_views[CheckThis] != 0;
}
-int ConditionalThisRoomDefView(StrBuf *Target, WCTemplputParams *TP)
-{
+int ConditionalThisRoomDefView(StrBuf * Target, WCTemplputParams * TP) {
wcsession *WCC = WC;
long CheckThis;
@@ -195,8 +173,7 @@ int ConditionalThisRoomDefView(StrBuf *Target, WCTemplputParams *TP)
return CheckThis == WCC->CurRoom.defview;
}
-int ConditionalThisRoomCurrView(StrBuf *Target, WCTemplputParams *TP)
-{
+int ConditionalThisRoomCurrView(StrBuf * Target, WCTemplputParams * TP) {
wcsession *WCC = WC;
long CheckThis;
@@ -207,49 +184,39 @@ int ConditionalThisRoomCurrView(StrBuf *Target, WCTemplputParams *TP)
return CheckThis == WCC->CurRoom.view;
}
-int ConditionalThisRoomHaveView(StrBuf *Target, WCTemplputParams *TP)
-{
+int ConditionalThisRoomHaveView(StrBuf * Target, WCTemplputParams * TP) {
wcsession *WCC = WC;
long CheckThis;
-
+
if (WCC == NULL)
return 0;
CheckThis = GetTemplateTokenNumber(Target, TP, 2, 0);
- if ((CheckThis >= VIEW_MAX) || (CheckThis < VIEW_BBS))
- {
- LogTemplateError(Target, "Conditional", ERR_PARM2, TP,
- "Roomview [%ld] not valid\n",
- CheckThis);
+ if ((CheckThis >= VIEW_MAX) || (CheckThis < VIEW_BBS)) {
+ LogTemplateError(Target, "Conditional", ERR_PARM2, TP, "Roomview [%ld] not valid\n", CheckThis);
return 0;
}
- return exchangeable_views [WCC->CurRoom.defview][CheckThis] ;
+ return exchangeable_views[WCC->CurRoom.defview][CheckThis];
}
-void tmplput_ROOM_VIEW(StrBuf *Target, WCTemplputParams *TP)
-{
- folder *Folder = (folder *)CTX(CTX_ROOMS);
+void tmplput_ROOM_VIEW(StrBuf * Target, WCTemplputParams * TP) {
+ folder *Folder = (folder *) CTX(CTX_ROOMS);
StrBufAppendPrintf(Target, "%d", Folder->view);
}
-void tmplput_ROOM_DEFVIEW(StrBuf *Target, WCTemplputParams *TP)
-{
- folder *Folder = (folder *)CTX(CTX_ROOMS);
+void tmplput_ROOM_DEFVIEW(StrBuf * Target, WCTemplputParams * TP) {
+ folder *Folder = (folder *) CTX(CTX_ROOMS);
StrBufAppendPrintf(Target, "%d", Folder->defview);
}
-void tmplput_CurrentRoomDefView(StrBuf *Target, WCTemplputParams *TP)
-{
+void tmplput_CurrentRoomDefView(StrBuf * Target, WCTemplputParams * TP) {
wcsession *WCC = WC;
StrBufAppendPrintf(Target, "%d", WCC->CurRoom.defview);
}
-void
-InitModule_ROOMVIEWS
-(void)
-{
+void InitModule_ROOMVIEWS(void) {
/* we duplicate this, just to be shure its already done. */
RegisterCTX(CTX_ROOMS);
RegisterCTX(CTX_FLOORS);
diff --git a/webcit/serv_func.c b/webcit/serv_func.c
index 88af2024f..709266de7 100644
--- a/webcit/serv_func.c
+++ b/webcit/serv_func.c
@@ -24,7 +24,7 @@ void SetInlinMimeRenderers(void) {
}
-void DeleteServInfo(ServInfo **FreeMe) {
+void DeleteServInfo(ServInfo ** FreeMe) {
if (*FreeMe == NULL)
return;
FreeStrBuf(&(*FreeMe)->serv_nodename);
@@ -45,7 +45,7 @@ void DeleteServInfo(ServInfo **FreeMe) {
* browser_host the citadel we want to connect to
* user_agent which browser uses our client?
*/
-ServInfo *get_serv_info(StrBuf *browser_host, StrBuf *user_agent) {
+ServInfo *get_serv_info(StrBuf * browser_host, StrBuf * user_agent) {
ServInfo *info;
StrBuf *Buf;
int a;
@@ -54,17 +54,11 @@ ServInfo *get_serv_info(StrBuf *browser_host, StrBuf *user_agent) {
Buf = NewStrBuf();
/* Tell the server what kind of client is connecting */
- serv_printf("IDEN %d|%d|%d|%s|%s",
- DEVELOPER_ID,
- CLIENT_ID,
- CLIENT_VERSION,
- ChrPtr(user_agent),
- ChrPtr(browser_host)
- );
+ serv_printf("IDEN %d|%d|%d|%s|%s", DEVELOPER_ID, CLIENT_ID, CLIENT_VERSION, ChrPtr(user_agent), ChrPtr(browser_host)
+ );
StrBuf_ServGetln(Buf);
if (GetServerStatus(Buf, NULL) != 2) {
- syslog(LOG_WARNING, "get_serv_info(IDEN): unexpected answer [%s]\n",
- ChrPtr(Buf));
+ syslog(LOG_WARNING, "get_serv_info(IDEN): unexpected answer [%s]\n", ChrPtr(Buf));
FreeStrBuf(&Buf);
return NULL;
}
@@ -77,8 +71,7 @@ ServInfo *get_serv_info(StrBuf *browser_host, StrBuf *user_agent) {
serv_puts("ICAL sgi|1");
StrBuf_ServGetln(Buf);
if (GetServerStatus(Buf, NULL) != 2) {
- syslog(LOG_WARNING, "get_serv_info(ICAL sgi|1): unexpected answer [%s]\n",
- ChrPtr(Buf));
+ syslog(LOG_WARNING, "get_serv_info(ICAL sgi|1): unexpected answer [%s]\n", ChrPtr(Buf));
FreeStrBuf(&Buf);
return NULL;
}
@@ -87,20 +80,15 @@ ServInfo *get_serv_info(StrBuf *browser_host, StrBuf *user_agent) {
serv_puts("INFO");
StrBuf_ServGetln(Buf);
if (GetServerStatus(Buf, NULL) != 1) {
- syslog(LOG_WARNING, "get_serv_info(INFO sgi|1): unexpected answer [%s]\n",
- ChrPtr(Buf));
+ syslog(LOG_WARNING, "get_serv_info(INFO sgi|1): unexpected answer [%s]\n", ChrPtr(Buf));
FreeStrBuf(&Buf);
return NULL;
}
- info = (ServInfo*)malloc(sizeof(ServInfo));
+ info = (ServInfo *) malloc(sizeof(ServInfo));
memset(info, 0, sizeof(ServInfo));
a = 0;
- while (rc = StrBuf_ServGetln(Buf),
- (rc >= 0) &&
- ((rc != 3) ||
- strcmp(ChrPtr(Buf), "000")))
- {
+ while (rc = StrBuf_ServGetln(Buf), (rc >= 0) && ((rc != 3) || strcmp(ChrPtr(Buf), "000"))) {
switch (a) {
case 0:
info->serv_pid = StrToi(Buf);
@@ -158,7 +146,7 @@ ServInfo *get_serv_info(StrBuf *browser_host, StrBuf *user_agent) {
return info;
}
-int GetConnected (void) {
+int GetConnected(void) {
StrBuf *Buf;
if (WC->ReadBuf == NULL) {
@@ -170,7 +158,7 @@ int GetConnected (void) {
snprintf(serv_sock_name, sizeof serv_sock_name, "%s/citadel.socket", ctdl_dir);
}
WC->serv_sock = connect_to_citadel(serv_sock_name);
-
+
if (WC->serv_sock < 0) {
WC->connected = 0;
FreeStrBuf(&WC->ReadBuf);
@@ -190,13 +178,12 @@ int GetConnected (void) {
if (Status == 551) {
hprintf("HTTP/1.1 503 Service Unavailable\r\n");
hprintf("Content-type: text/plain; charset=utf-8\r\n");
- wc_printf(_("This server is already serving its maximum number of users and cannot accept any additional logins at this time. Please try again later or contact your system administrator."));
+ wc_printf(_
+ ("This server is already serving its maximum number of users and cannot accept any additional logins at this time. Please try again later or contact your system administrator."));
}
else {
- wc_printf("%ld %s\n",
- Status,
- _("Received unexpected answer from Citadel server; bailing out.")
- );
+ wc_printf("%ld %s\n", Status, _("Received unexpected answer from Citadel server; bailing out.")
+ );
hprintf("HTTP/1.1 502 Bad Gateway\r\n");
hprintf("Content-type: text/plain; charset=utf-8\r\n");
}
@@ -211,18 +198,17 @@ int GetConnected (void) {
* unless we are following X-Forwarded-For: headers
* and such a header has already turned up something.
*/
- if ( (!follow_xff) || (StrLength(WC->Hdr->HR.browser_host) == 0) ) {
+ if ((!follow_xff) || (StrLength(WC->Hdr->HR.browser_host) == 0)) {
if (WC->Hdr->HR.browser_host == NULL) {
WC->Hdr->HR.browser_host = NewStrBuf();
- Put(WC->Hdr->HTTPHeaders, HKEY("FreeMeWithTheOtherHeaders"),
- WC->Hdr->HR.browser_host, HFreeStrBuf);
+ Put(WC->Hdr->HTTPHeaders, HKEY("FreeMeWithTheOtherHeaders"), WC->Hdr->HR.browser_host, HFreeStrBuf);
}
locate_host(WC->Hdr->HR.browser_host, WC->Hdr->http_sock);
}
if (WC->serv_info == NULL) {
WC->serv_info = get_serv_info(WC->Hdr->HR.browser_host, WC->Hdr->HR.user_agent);
}
- if (WC->serv_info == NULL){
+ if (WC->serv_info == NULL) {
begin_burst();
wc_printf(_("Received unexpected answer from Citadel server; bailing out."));
hprintf("HTTP/1.1 502 Bad Gateway\r\n");
@@ -234,15 +220,10 @@ int GetConnected (void) {
if (WC->serv_info->serv_rev_level < MINIMUM_CIT_VERSION) {
begin_burst();
wc_printf(_("You are connected to a Citadel "
- "server running Citadel %d.%02d. \n"
- "In order to run this version of WebCit "
- "you must also have Citadel %d.%02d or"
- " newer.\n\n\n"),
- WC->serv_info->serv_rev_level,
- 0,
- MINIMUM_CIT_VERSION,
- 0
- );
+ "server running Citadel %d.%02d. \n"
+ "In order to run this version of WebCit "
+ "you must also have Citadel %d.%02d or"
+ " newer.\n\n\n"), WC->serv_info->serv_rev_level, 0, MINIMUM_CIT_VERSION, 0);
hprintf("HTTP/1.1 200 OK\r\n");
hprintf("Content-type: text/plain; charset=utf-8\r\n");
end_burst();
@@ -255,7 +236,7 @@ int GetConnected (void) {
}
-void FmOut(StrBuf *Target, const char *align, const StrBuf *Source) {
+void FmOut(StrBuf * Target, const char *align, const StrBuf * Source) {
const char *ptr, *pte;
const char *BufPtr = NULL;
StrBuf *Line = NewStrBufPlain(NULL, SIZ);
@@ -269,9 +250,8 @@ void FmOut(StrBuf *Target, const char *align, const StrBuf *Source) {
StrBufAppendPrintf(Target, "
\n", align);
- if (StrLength(Source) > 0)
- do
- {
+ if (StrLength(Source) > 0)
+ do {
StrBufSipLine(Line, Source, &BufPtr);
bq = 0;
i = 0;
@@ -283,27 +263,26 @@ void FmOut(StrBuf *Target, const char *align, const StrBuf *Source) {
StrBufAppendBufPlain(Target, HKEY("
"), 0);
}
intext = 1;
- if (isspace(*ptr)) while ((ptr < pte) &&
- ((*ptr == '>') ||
- isspace(*ptr)))
- {
- if (*ptr == '>')
- bq++;
- ptr ++;
- i++;
- }
+ if (isspace(*ptr))
+ while ((ptr < pte) && ((*ptr == '>') || isspace(*ptr))) {
+ if (*ptr == '>')
+ bq++;
+ ptr++;
+ i++;
+ }
/*
* Quoted text should be displayed in italics and in a
* different colour. This code understands Citadel-style
* " >" quotes and will convert to
tags.
*/
- if (i > 0) StrBufCutLeft(Line, i);
-
+ if (i > 0)
+ StrBufCutLeft(Line, i);
+
- for (i = bn; i < bq; i++)
+ for (i = bn; i < bq; i++)
StrBufAppendBufPlain(Target, HKEY(""), 0);
- for (i = bq; i < bn; i++)
+ for (i = bq; i < bn; i++)
StrBufAppendBufPlain(Target, HKEY(" "), 0);
bn = bq;
@@ -317,8 +296,7 @@ void FmOut(StrBuf *Target, const char *align, const StrBuf *Source) {
StrBufAppendBufPlain(Target, HKEY("\n"), 0);
}
- while ((BufPtr != StrBufNOTNULL) &&
- (BufPtr != NULL));
+ while ((BufPtr != StrBufNOTNULL) && (BufPtr != NULL));
for (i = 0; i < bn; i++) {
StrBufAppendBufPlain(Target, HKEY(" "), 0);
@@ -348,14 +326,16 @@ void text_to_server(char *ptr) {
}
else if (ch == 10) {
len = strlen(buf);
- while ( (isspace(buf[len - 1]))
- && (buf[0] != '\0')
- && (buf[1] != '\0') )
+ while ((isspace(buf[len - 1]))
+ && (buf[0] != '\0')
+ && (buf[1] != '\0'))
buf[--len] = 0;
serv_puts(buf);
buf[0] = 0;
- if (ptr[pos] != 0) strcat(buf, " ");
- } else {
+ if (ptr[pos] != 0)
+ strcat(buf, " ");
+ }
+ else {
a = strlen(buf);
buf[a + 1] = 0;
buf[a] = ch;
@@ -377,7 +357,7 @@ void text_to_server(char *ptr) {
/*
* Transmit message text (in memory) to the server, converting to Quoted-Printable encoding as we go.
*/
-void text_to_server_qp(const StrBuf *SendMeEncoded) {
+void text_to_server_qp(const StrBuf * SendMeEncoded) {
StrBuf *ServBuf;
ServBuf = StrBufRFC2047encodeMessage(SendMeEncoded);
@@ -413,22 +393,20 @@ void server_to_text() {
* usual 000 terminator is found. Caller is responsible for freeing
* the returned pointer.
*/
-int read_server_text(StrBuf *Buf, long *nLines) {
+int read_server_text(StrBuf * Buf, long *nLines) {
StrBuf *ReadBuf;
long nRead;
long nTotal = 0;
long nlines;
-
+
nlines = 0;
ReadBuf = NewStrBuf();
- while ((WC->serv_sock!=-1) &&
- (nRead = StrBuf_ServGetln(ReadBuf), (nRead >= 0) &&
- ((nRead != 3)||(strcmp(ChrPtr(ReadBuf), "000") != 0))))
- {
+ while ((WC->serv_sock != -1) &&
+ (nRead = StrBuf_ServGetln(ReadBuf), (nRead >= 0) && ((nRead != 3) || (strcmp(ChrPtr(ReadBuf), "000") != 0)))) {
StrBufAppendBuf(Buf, ReadBuf, 0);
StrBufAppendBufPlain(Buf, HKEY("\n"), 0);
nTotal += nRead;
- nlines ++;
+ nlines++;
}
FreeStrBuf(&ReadBuf);
*nLines = nlines;
@@ -436,14 +414,12 @@ int read_server_text(StrBuf *Buf, long *nLines) {
}
-int GetServerStatusMsg(StrBuf *Line, long* FullState, int PutImportantMessage, int MajorOK) {
+int GetServerStatusMsg(StrBuf * Line, long *FullState, int PutImportantMessage, int MajorOK) {
int rc;
if (FullState != NULL)
*FullState = StrTol(Line);
rc = ChrPtr(Line)[0] - 48;
- if ((!PutImportantMessage) ||
- (MajorOK == rc)||
- (StrLength(Line) <= 4))
+ if ((!PutImportantMessage) || (MajorOK == rc) || (StrLength(Line) <= 4))
return rc;
AppendImportantMessage(ChrPtr(Line) + 4, StrLength(Line) - 4);
@@ -451,81 +427,82 @@ int GetServerStatusMsg(StrBuf *Line, long* FullState, int PutImportantMessage, i
}
-void tmplput_serv_ip(StrBuf *Target, WCTemplputParams *TP) {
+void tmplput_serv_ip(StrBuf * Target, WCTemplputParams * TP) {
StrBufAppendPrintf(Target, "%d", WC->ctdl_pid);
}
-void tmplput_serv_admin(StrBuf *Target, WCTemplputParams *TP) {
+void tmplput_serv_admin(StrBuf * Target, WCTemplputParams * TP) {
if (WC->serv_info == NULL)
return;
StrBufAppendTemplate(Target, TP, WC->serv_info->serv_sysadm, 0);
}
-void tmplput_serv_nodename(StrBuf *Target, WCTemplputParams *TP) {
+void tmplput_serv_nodename(StrBuf * Target, WCTemplputParams * TP) {
if (WC->serv_info == NULL)
return;
StrBufAppendTemplate(Target, TP, WC->serv_info->serv_nodename, 0);
}
-void tmplput_serv_humannode(StrBuf *Target, WCTemplputParams *TP) {
+void tmplput_serv_humannode(StrBuf * Target, WCTemplputParams * TP) {
if (WC->serv_info == NULL)
return;
StrBufAppendTemplate(Target, TP, WC->serv_info->serv_humannode, 0);
}
-void tmplput_serv_fqdn(StrBuf *Target, WCTemplputParams *TP) {
+void tmplput_serv_fqdn(StrBuf * Target, WCTemplputParams * TP) {
if (WC->serv_info == NULL)
return;
StrBufAppendTemplate(Target, TP, WC->serv_info->serv_fqdn, 0);
}
-void tmplput_serv_software(StrBuf *Target, WCTemplputParams *TP) {
+void tmplput_serv_software(StrBuf * Target, WCTemplputParams * TP) {
if (WC->serv_info == NULL)
return;
StrBufAppendTemplate(Target, TP, WC->serv_info->serv_software, 0);
}
-void tmplput_serv_rev_level(StrBuf *Target, WCTemplputParams *TP) {
- if (WC->serv_info == NULL) return;
+void tmplput_serv_rev_level(StrBuf * Target, WCTemplputParams * TP) {
+ if (WC->serv_info == NULL)
+ return;
StrBufAppendPrintf(Target, "%d", WC->serv_info->serv_rev_level);
}
-int conditional_serv_newuser_disabled(StrBuf *Target, WCTemplputParams *TP) {
+int conditional_serv_newuser_disabled(StrBuf * Target, WCTemplputParams * TP) {
if (WC->serv_info == NULL)
return 0;
return WC->serv_info->serv_newuser_disabled != 0;
}
-int conditional_serv_supports_guest(StrBuf *Target, WCTemplputParams *TP) {
- if (WC->serv_info == NULL)
+int conditional_serv_supports_guest(StrBuf * Target, WCTemplputParams * TP) {
+ if (WC->serv_info == NULL)
return 0;
- return WC->serv_info->serv_supports_guest != 0;
+ return WC->serv_info->serv_supports_guest != 0;
}
-int conditional_serv_supports_openid(StrBuf *Target, WCTemplputParams *TP) {
+int conditional_serv_supports_openid(StrBuf * Target, WCTemplputParams * TP) {
if (WC->serv_info == NULL)
return 0;
return WC->serv_info->serv_supports_openid != 0;
}
-int conditional_serv_fulltext_enabled(StrBuf *Target, WCTemplputParams *TP) {
+int conditional_serv_fulltext_enabled(StrBuf * Target, WCTemplputParams * TP) {
if (WC->serv_info == NULL)
return 0;
return WC->serv_info->serv_fulltext_enabled != 0;
}
-int conditional_serv_ldap_enabled(StrBuf *Target, WCTemplputParams *TP) {
+int conditional_serv_ldap_enabled(StrBuf * Target, WCTemplputParams * TP) {
if (WC->serv_info == NULL)
return 0;
return WC->serv_info->serv_supports_ldap != 0;
}
-void tmplput_serv_bbs_city(StrBuf *Target, WCTemplputParams *TP) {
+void tmplput_serv_bbs_city(StrBuf * Target, WCTemplputParams * TP) {
if (WC->serv_info == NULL)
return;
StrBufAppendTemplate(Target, TP, WC->serv_info->serv_bbs_city, 0);
}
-void tmplput_mesg(StrBuf *Target, WCTemplputParams *TP) {
+void tmplput_mesg(StrBuf * Target, WCTemplputParams * TP) {
int n = 0;
int Done = 0;
StrBuf *Line;
@@ -537,19 +514,17 @@ void tmplput_mesg(StrBuf *Target, WCTemplputParams *TP) {
StrBuf_ServGetln(Line);
if (GetServerStatus(Line, NULL) == 1) {
- while (!Done && (StrBuf_ServGetln(Line)>=0)) {
- if ( (StrLength(Line)==3) &&
- !strcmp(ChrPtr(Line), "000"))
+ while (!Done && (StrBuf_ServGetln(Line) >= 0)) {
+ if ((StrLength(Line) == 3) && !strcmp(ChrPtr(Line), "000"))
Done = 1;
- else
- {
+ else {
if (n > 0)
StrBufAppendBufPlain(Buf, "\n", 1, 0);
StrBufAppendBuf(Buf, Line, 0);
}
n++;
}
-
+
FlushStrBuf(Line);
FmOut(Line, "center", Buf);
StrBufAppendTemplate(Target, TP, Line, 1);
@@ -558,7 +533,7 @@ void tmplput_mesg(StrBuf *Target, WCTemplputParams *TP) {
FreeStrBuf(&Line);
}
-void tmplput_site_prefix(StrBuf *Target, WCTemplputParams *TP) {
+void tmplput_site_prefix(StrBuf * Target, WCTemplputParams * TP) {
if ((WC != NULL) && (WC->Hdr->HostHeader != NULL)) {
StrBufAppendTemplate(Target, TP, WC->Hdr->HostHeader, 0);
}
@@ -571,54 +546,44 @@ void RegisterEmbeddableMimeType(const char *MimeType, long MTLen, int Priority)
}
void CreateMimeStr(void) {
- HashPos *it;
+ HashPos *it;
void *vMime;
long len = 0;
const char *Key;
it = GetNewHashPos(EmbeddableMimes, 0);
- while (GetNextHashPos(EmbeddableMimes, it, &len, &Key, &vMime) &&
- (vMime != NULL)) {
+ while (GetNextHashPos(EmbeddableMimes, it, &len, &Key, &vMime) && (vMime != NULL)) {
if (StrLength(EmbeddableMimeStrs) > 0)
StrBufAppendBufPlain(EmbeddableMimeStrs, HKEY("|"), 0);
- else
+ else
StrBufAppendBufPlain(EmbeddableMimeStrs, HKEY("MSGP "), 0);
- StrBufAppendBuf(EmbeddableMimeStrs, (StrBuf*) vMime, 0);
+ StrBufAppendBuf(EmbeddableMimeStrs, (StrBuf *) vMime, 0);
}
DeleteHashPos(&it);
}
-void
-ServerStartModule_SERV_FUNC
-(void)
-{
+void ServerStartModule_SERV_FUNC(void) {
EmbeddableMimes = NewHash(1, Flathash);
EmbeddableMimeStrs = NewStrBuf();
}
-void
-ServerShutdownModule_SERV_FUNC
-(void)
-{
+void ServerShutdownModule_SERV_FUNC(void) {
FreeStrBuf(&EmbeddableMimeStrs);
DeleteHash(&EmbeddableMimes);
}
-void
-InitModule_SERVFUNC
-(void)
-{
+void InitModule_SERVFUNC(void) {
RegisterConditional("COND:SERV:OPENID", 2, conditional_serv_supports_openid, CTX_NONE);
RegisterConditional("COND:SERV:NEWU", 2, conditional_serv_newuser_disabled, CTX_NONE);
RegisterConditional("COND:SERV:FULLTEXT_ENABLED", 2, conditional_serv_fulltext_enabled, CTX_NONE);
RegisterConditional("COND:SERV:LDAP_ENABLED", 2, conditional_serv_ldap_enabled, CTX_NONE);
- RegisterConditional("COND:SERV:SUPPORTS_GUEST", 2, conditional_serv_supports_guest, CTX_NONE);
+ RegisterConditional("COND:SERV:SUPPORTS_GUEST", 2, conditional_serv_supports_guest, CTX_NONE);
RegisterNamespace("SERV:PID", 0, 0, tmplput_serv_ip, NULL, CTX_NONE);
RegisterNamespace("SERV:NODENAME", 0, 1, tmplput_serv_nodename, NULL, CTX_NONE);
RegisterNamespace("SERV:HUMANNODE", 0, 1, tmplput_serv_humannode, NULL, CTX_NONE);
RegisterNamespace("SERV:FQDN", 0, 1, tmplput_serv_fqdn, NULL, CTX_NONE);
-
+
RegisterNamespace("SERV:SOFTWARE", 0, 1, tmplput_serv_software, NULL, CTX_NONE);
RegisterNamespace("SERV:REV_LEVEL", 0, 0, tmplput_serv_rev_level, NULL, CTX_NONE);
RegisterNamespace("SERV:BBS_CITY", 0, 1, tmplput_serv_bbs_city, NULL, CTX_NONE);
@@ -632,9 +597,6 @@ InitModule_SERVFUNC
-void
-SessionDestroyModule_SERVFUNC
-(wcsession *sess)
-{
+void SessionDestroyModule_SERVFUNC(wcsession * sess) {
DeleteServInfo(&sess->serv_info);
}
diff --git a/webcit/sieve.c b/webcit/sieve.c
index 2e3d61585..528009ef3 100644
--- a/webcit/sieve.c
+++ b/webcit/sieve.c
@@ -1,3 +1,4 @@
+
/*
* Copyright (c) 1996-2020 by the citadel.org team
*
@@ -48,19 +49,20 @@ void parse_fields_from_rule_editor(void) {
char rule[2048];
char encoded_rule[4096];
char my_addresses[4096];
-
+
/* Enumerate my email addresses in case they are needed for a vacation rule */
my_addresses[0] = 0;
serv_puts("GVEA");
serv_getln(buf, sizeof buf);
- if (buf[0] == '1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
- if (!IsEmptyStr(my_addresses)) {
- strcat(my_addresses, ",\n");
+ if (buf[0] == '1')
+ while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
+ if (!IsEmptyStr(my_addresses)) {
+ strcat(my_addresses, ",\n");
+ }
+ strcat(my_addresses, "\"");
+ strcat(my_addresses, buf);
+ strcat(my_addresses, "\"");
}
- strcat(my_addresses, "\"");
- strcat(my_addresses, buf);
- strcat(my_addresses, "\"");
- }
/* Now generate the script and write it to the Citadel server */
serv_printf("PIBR");
@@ -69,51 +71,49 @@ void parse_fields_from_rule_editor(void) {
return;
}
- for (i=0; i
IsActive;
}
-int ConditionalSieveScriptIsRulesScript(StrBuf *Target, WCTemplputParams *TP)
-{
- SieveListing *SieveList = (SieveListing *)CTX(CTX_SIEVELIST);
+int ConditionalSieveScriptIsRulesScript(StrBuf * Target, WCTemplputParams * TP) {
+ SieveListing *SieveList = (SieveListing *) CTX(CTX_SIEVELIST);
return SieveList->IsActive;
}
-void tmplput_SieveScriptName(StrBuf *Target, WCTemplputParams *TP)
-{
- SieveListing *SieveList = (SieveListing *)CTX(CTX_SIEVELIST);
+void tmplput_SieveScriptName(StrBuf * Target, WCTemplputParams * TP) {
+ SieveListing *SieveList = (SieveListing *) CTX(CTX_SIEVELIST);
StrBufAppendTemplate(Target, TP, SieveList->Name, 0);
}
-void tmplput_SieveScriptContent(StrBuf *Target, WCTemplputParams *TP)
-{
- SieveListing *SieveList = (SieveListing *)CTX(CTX_SIEVELIST);
+void tmplput_SieveScriptContent(StrBuf * Target, WCTemplputParams * TP) {
+ SieveListing *SieveList = (SieveListing *) CTX(CTX_SIEVELIST);
StrBufAppendTemplate(Target, TP, SieveList->Content, 0);
}
-void FreeSieveListing(void *vSieveListing)
-{
- SieveListing *List = (SieveListing*) vSieveListing;
+void FreeSieveListing(void *vSieveListing) {
+ SieveListing *List = (SieveListing *) vSieveListing;
FreeStrBuf(&List->Name);
free(List);
}
-HashList *GetSieveScriptListing(StrBuf *Target, WCTemplputParams *TP)
-{
- wcsession *WCC = WC;
+HashList *GetSieveScriptListing(StrBuf * Target, WCTemplputParams * TP) {
+ wcsession *WCC = WC;
StrBuf *Line;
int num_scripts = 0;
int rules_script_active = 0;
int have_rules_script = 0;
const char *pch;
- HashPos *it;
+ HashPos *it;
int Done = 0;
SieveListing *Ruleset;
@@ -218,31 +212,25 @@ HashList *GetSieveScriptListing(StrBuf *Target, WCTemplputParams *TP)
serv_puts("MSIV listscripts");
Line = NewStrBuf();
StrBuf_ServGetln(Line);
- if (GetServerStatus(Line, NULL) == 1)
- {
+ if (GetServerStatus(Line, NULL) == 1) {
WCC->KnownSieveScripts = NewHash(1, Flathash);
- while(!Done && (StrBuf_ServGetln(Line) >= 0) )
- if ( (StrLength(Line)==3) &&
- !strcmp(ChrPtr(Line), "000"))
- {
+ while (!Done && (StrBuf_ServGetln(Line) >= 0))
+ if ((StrLength(Line) == 3) && !strcmp(ChrPtr(Line), "000")) {
Done = 1;
}
- else
- {
+ else {
pch = NULL;
Ruleset = (SieveListing *) malloc(sizeof(SieveListing));
Ruleset->Name = NewStrBufPlain(NULL, StrLength(Line));
StrBufExtract_NextToken(Ruleset->Name, Line, &pch, '|');
- Ruleset->IsActive = StrBufExtractNext_int(Line, &pch, '|');
+ Ruleset->IsActive = StrBufExtractNext_int(Line, &pch, '|');
Ruleset->Content = NULL;
- if (!strcasecmp(ChrPtr(Ruleset->Name), RULES_SCRIPT))
- {
+ if (!strcasecmp(ChrPtr(Ruleset->Name), RULES_SCRIPT)) {
Ruleset->IsRulesScript = 1;
have_rules_script = 1;
- if (Ruleset->IsActive)
- {
+ if (Ruleset->IsActive) {
rules_script_active = 1;
PutBstr(HKEY("__SIEVE:RULESSCRIPT"), NewStrBufPlain(HKEY("1")));
}
@@ -257,8 +245,7 @@ HashList *GetSieveScriptListing(StrBuf *Target, WCTemplputParams *TP)
PutBstr(HKEY("__SIEVE:EXTERNAL_SCRIPT"), NewStrBufPlain(HKEY("1")));
}
- if (num_scripts > have_rules_script)
- {
+ if (num_scripts > have_rules_script) {
long rc = 0;
long len;
const char *Key;
@@ -270,29 +257,24 @@ HashList *GetSieveScriptListing(StrBuf *Target, WCTemplputParams *TP)
PutBstr(HKEY("__SIEVE:HAVE_EXTERNAL_SCRIPT"), NewStrBufPlain(HKEY("1")));
it = GetNewHashPos(WCC->KnownSieveScripts, 0);
- while (GetNextHashPos(WCC->KnownSieveScripts, it, &len, &Key, &vRuleset) &&
- (vRuleset != NULL))
- {
+ while (GetNextHashPos(WCC->KnownSieveScripts, it, &len, &Key, &vRuleset) && (vRuleset != NULL)) {
Ruleset = (SieveListing *) vRuleset;
serv_printf("MSIV getscript|%s", ChrPtr(Ruleset->Name));
StrBuf_ServGetln(Line);
- if (GetServerStatus(Line, NULL) == 1)
- {
+ if (GetServerStatus(Line, NULL) == 1) {
Ruleset->Content = NewStrBuf();
Done = 0;
- while(!Done && (rc = StrBuf_ServGetln(Line), rc >= 0) )
- if ( (StrLength(Line)==3) &&
- !strcmp(ChrPtr(Line), "000"))
- {
+ while (!Done && (rc = StrBuf_ServGetln(Line), rc >= 0))
+ if ((StrLength(Line) == 3) && !strcmp(ChrPtr(Line), "000")) {
Done = 1;
}
- else
- {
- if (StrLength(Ruleset->Content)>0)
+ else {
+ if (StrLength(Ruleset->Content) > 0)
StrBufAppendBufPlain(Ruleset->Content, HKEY("\n"), 0);
StrBufAppendBuf(Ruleset->Content, Line, 0);
}
- if (rc < 0) break;
+ if (rc < 0)
+ break;
}
}
}
@@ -301,22 +283,21 @@ HashList *GetSieveScriptListing(StrBuf *Target, WCTemplputParams *TP)
}
-typedef enum __eSieveHfield
-{
- from,
- tocc,
- subject,
- replyto,
- sender,
- resentfrom,
- resentto,
- envfrom,
- envto,
- xmailer,
- xspamflag,
- xspamstatus,
- listid,
- size,
+typedef enum __eSieveHfield {
+ from,
+ tocc,
+ subject,
+ replyto,
+ sender,
+ resentfrom,
+ resentto,
+ envfrom,
+ envto,
+ xmailer,
+ xspamflag,
+ xspamstatus,
+ listid,
+ size,
all
} eSieveHfield;
@@ -362,128 +343,89 @@ typedef struct __SieveRule {
StrBuf *redirect;
StrBuf *automsg;
eSieveFinal final;
-}SieveRule;
+} SieveRule;
-int ConditionalSieveRule_hfield(StrBuf *Target, WCTemplputParams *TP)
-{
- SieveRule *Rule = (SieveRule *)CTX(CTX_SIEVESCRIPT);
-
- return GetTemplateTokenNumber(Target,
- TP,
- 3,
- from)
- ==
- Rule->hfield;
+int ConditionalSieveRule_hfield(StrBuf * Target, WCTemplputParams * TP) {
+ SieveRule *Rule = (SieveRule *) CTX(CTX_SIEVESCRIPT);
+
+ return GetTemplateTokenNumber(Target, TP, 3, from)
+ == Rule->hfield;
}
-int ConditionalSieveRule_compare(StrBuf *Target, WCTemplputParams *TP)
-{
- SieveRule *Rule = (SieveRule *)CTX(CTX_SIEVESCRIPT);
- return GetTemplateTokenNumber(Target,
- TP,
- 3,
- contains)
- ==
- Rule->compare;
+int ConditionalSieveRule_compare(StrBuf * Target, WCTemplputParams * TP) {
+ SieveRule *Rule = (SieveRule *) CTX(CTX_SIEVESCRIPT);
+ return GetTemplateTokenNumber(Target, TP, 3, contains)
+ == Rule->compare;
}
-int ConditionalSieveRule_action(StrBuf *Target, WCTemplputParams *TP)
-{
- SieveRule *Rule = (SieveRule *)CTX(CTX_SIEVESCRIPT);
- return GetTemplateTokenNumber(Target,
- TP,
- 3,
- keep)
- ==
- Rule->Action;
+int ConditionalSieveRule_action(StrBuf * Target, WCTemplputParams * TP) {
+ SieveRule *Rule = (SieveRule *) CTX(CTX_SIEVESCRIPT);
+ return GetTemplateTokenNumber(Target, TP, 3, keep)
+ == Rule->Action;
}
-int ConditionalSieveRule_sizecomp(StrBuf *Target, WCTemplputParams *TP)
-{
- SieveRule *Rule = (SieveRule *)CTX(CTX_SIEVESCRIPT);
- return GetTemplateTokenNumber(Target,
- TP,
- 3,
- larger)
- ==
- Rule->sizecomp;
+int ConditionalSieveRule_sizecomp(StrBuf * Target, WCTemplputParams * TP) {
+ SieveRule *Rule = (SieveRule *) CTX(CTX_SIEVESCRIPT);
+ return GetTemplateTokenNumber(Target, TP, 3, larger)
+ == Rule->sizecomp;
}
-int ConditionalSieveRule_final(StrBuf *Target, WCTemplputParams *TP)
-{
- SieveRule *Rule = (SieveRule *)CTX(CTX_SIEVESCRIPT);
- return GetTemplateTokenNumber(Target,
- TP,
- 3,
- econtinue)
- ==
- Rule->final;
+int ConditionalSieveRule_final(StrBuf * Target, WCTemplputParams * TP) {
+ SieveRule *Rule = (SieveRule *) CTX(CTX_SIEVESCRIPT);
+ return GetTemplateTokenNumber(Target, TP, 3, econtinue)
+ == Rule->final;
}
-int ConditionalSieveRule_ThisRoom(StrBuf *Target, WCTemplputParams *TP)
-{
- SieveRule *Rule = (SieveRule *)CTX(CTX_SIEVESCRIPT);
- return GetTemplateTokenNumber(Target,
- TP,
- 3,
- econtinue)
- ==
- Rule->final;
+int ConditionalSieveRule_ThisRoom(StrBuf * Target, WCTemplputParams * TP) {
+ SieveRule *Rule = (SieveRule *) CTX(CTX_SIEVESCRIPT);
+ return GetTemplateTokenNumber(Target, TP, 3, econtinue)
+ == Rule->final;
}
-int ConditionalSieveRule_Active(StrBuf *Target, WCTemplputParams *TP)
-{
- SieveRule *Rule = (SieveRule *)CTX(CTX_SIEVESCRIPT);
- return Rule->active;
+int ConditionalSieveRule_Active(StrBuf * Target, WCTemplputParams * TP) {
+ SieveRule *Rule = (SieveRule *) CTX(CTX_SIEVESCRIPT);
+ return Rule->active;
}
-void tmplput_SieveRule_htext(StrBuf *Target, WCTemplputParams *TP)
-{
- SieveRule *Rule = (SieveRule *)CTX(CTX_SIEVESCRIPT);
+void tmplput_SieveRule_htext(StrBuf * Target, WCTemplputParams * TP) {
+ SieveRule *Rule = (SieveRule *) CTX(CTX_SIEVESCRIPT);
StrBufAppendTemplate(Target, TP, Rule->htext, 0);
}
-void tmplput_SieveRule_fileinto(StrBuf *Target, WCTemplputParams *TP)
-{
- SieveRule *Rule = (SieveRule *)CTX(CTX_SIEVESCRIPT);
+void tmplput_SieveRule_fileinto(StrBuf * Target, WCTemplputParams * TP) {
+ SieveRule *Rule = (SieveRule *) CTX(CTX_SIEVESCRIPT);
StrBufAppendTemplate(Target, TP, Rule->fileinto, 0);
}
-void tmplput_SieveRule_redirect(StrBuf *Target, WCTemplputParams *TP)
-{
- SieveRule *Rule = (SieveRule *)CTX(CTX_SIEVESCRIPT);
+void tmplput_SieveRule_redirect(StrBuf * Target, WCTemplputParams * TP) {
+ SieveRule *Rule = (SieveRule *) CTX(CTX_SIEVESCRIPT);
StrBufAppendTemplate(Target, TP, Rule->redirect, 0);
}
-void tmplput_SieveRule_automsg(StrBuf *Target, WCTemplputParams *TP)
-{
- SieveRule *Rule = (SieveRule *)CTX(CTX_SIEVESCRIPT);
+void tmplput_SieveRule_automsg(StrBuf * Target, WCTemplputParams * TP) {
+ SieveRule *Rule = (SieveRule *) CTX(CTX_SIEVESCRIPT);
StrBufAppendTemplate(Target, TP, Rule->automsg, 0);
}
-void tmplput_SieveRule_sizeval(StrBuf *Target, WCTemplputParams *TP)
-{
- SieveRule *Rule = (SieveRule *)CTX(CTX_SIEVESCRIPT);
+void tmplput_SieveRule_sizeval(StrBuf * Target, WCTemplputParams * TP) {
+ SieveRule *Rule = (SieveRule *) CTX(CTX_SIEVESCRIPT);
StrBufAppendPrintf(Target, "%d", Rule->sizeval);
}
-void tmplput_SieveRule_lookup_FileIntoRoom(StrBuf *Target, WCTemplputParams *TP)
-{
+void tmplput_SieveRule_lookup_FileIntoRoom(StrBuf * Target, WCTemplputParams * TP) {
void *vRoom;
- SieveRule *Rule = (SieveRule *)CTX(CTX_SIEVESCRIPT);
- wcsession *WCC = WC;
+ SieveRule *Rule = (SieveRule *) CTX(CTX_SIEVESCRIPT);
+ wcsession *WCC = WC;
HashList *Rooms = GetRoomListHashLKRA(Target, TP);
GetHash(Rooms, SKEY(Rule->fileinto), &vRoom);
- WCC->ThisRoom = (folder*) vRoom;
+ WCC->ThisRoom = (folder *) vRoom;
}
-void FreeSieveRule(void *vRule)
-{
- SieveRule *Rule = (SieveRule*) vRule;
+void FreeSieveRule(void *vRule) {
+ SieveRule *Rule = (SieveRule *) vRule;
FreeStrBuf(&Rule->htext);
FreeStrBuf(&Rule->fileinto);
FreeStrBuf(&Rule->redirect);
FreeStrBuf(&Rule->automsg);
-
+
free(Rule);
}
#define WC_RULE_HEADER "rule|"
-HashList *GetSieveRules(StrBuf *Target, WCTemplputParams *TP)
-{
+HashList *GetSieveRules(StrBuf * Target, WCTemplputParams * TP) {
StrBuf *Line = NULL;
StrBuf *EncodedRule = NULL;
int n = 0;
@@ -497,38 +439,34 @@ HashList *GetSieveRules(StrBuf *Target, WCTemplputParams *TP)
Line = NewStrBuf();
EncodedRule = NewStrBuf();
StrBuf_ServGetln(Line);
- if (GetServerStatus(Line, NULL) == 1)
- {
- while(!Done && (StrBuf_ServGetln(Line) >= 0) )
- if ( (StrLength(Line)==3) &&
- !strcmp(ChrPtr(Line), "000"))
- {
+ if (GetServerStatus(Line, NULL) == 1) {
+ while (!Done && (StrBuf_ServGetln(Line) >= 0))
+ if ((StrLength(Line) == 3) && !strcmp(ChrPtr(Line), "000")) {
Done = 1;
}
- else
- {
+ else {
pch = NULL;
/* We just care for our encoded header and skip everything else */
- if ((StrLength(Line) > sizeof(WC_RULE_HEADER) - 1) && (!strncasecmp(ChrPtr(Line), HKEY(WC_RULE_HEADER))))
- {
+ if ((StrLength(Line) > sizeof(WC_RULE_HEADER) - 1)
+ && (!strncasecmp(ChrPtr(Line), HKEY(WC_RULE_HEADER)))) {
StrBufSkip_NTokenS(Line, &pch, '|', 1);
- n = StrBufExtractNext_int(Line, &pch, '|');
+ n = StrBufExtractNext_int(Line, &pch, '|');
StrBufExtract_NextToken(EncodedRule, Line, &pch, '|');
StrBufDecodeBase64(EncodedRule);
- Rule = (SieveRule*) malloc(sizeof(SieveRule));
+ Rule = (SieveRule *) malloc(sizeof(SieveRule));
- Rule->htext = NewStrBufPlain (NULL, StrLength(EncodedRule));
+ Rule->htext = NewStrBufPlain(NULL, StrLength(EncodedRule));
- Rule->fileinto = NewStrBufPlain (NULL, StrLength(EncodedRule));
- Rule->redirect = NewStrBufPlain (NULL, StrLength(EncodedRule));
- Rule->automsg = NewStrBufPlain (NULL, StrLength(EncodedRule));
+ Rule->fileinto = NewStrBufPlain(NULL, StrLength(EncodedRule));
+ Rule->redirect = NewStrBufPlain(NULL, StrLength(EncodedRule));
+ Rule->automsg = NewStrBufPlain(NULL, StrLength(EncodedRule));
/* Grab our existing values to populate */
pch = NULL;
Rule->active = StrBufExtractNext_int(EncodedRule, &pch, '|');
StrBufExtract_NextToken(Line, EncodedRule, &pch, '|');
-
+
Rule->hfield = (eSieveHfield) GetTokenDefine(SKEY(Line), tocc);
StrBufExtract_NextToken(Line, EncodedRule, &pch, '|');
Rule->compare = (eSieveCompare) GetTokenDefine(SKEY(Line), contains);
@@ -550,10 +488,10 @@ HashList *GetSieveRules(StrBuf *Target, WCTemplputParams *TP)
}
while (n < MAX_RULES) {
- Rule = (SieveRule*) malloc(sizeof(SieveRule));
+ Rule = (SieveRule *) malloc(sizeof(SieveRule));
memset(Rule, 0, sizeof(SieveRule));
Put(SieveRules, IKEY(n), Rule, FreeSieveRule);
-
+
n++;
}
@@ -563,33 +501,27 @@ HashList *GetSieveRules(StrBuf *Target, WCTemplputParams *TP)
return SieveRules;
}
-void
-SessionDetachModule_SIEVE
-(wcsession *sess)
-{
+void SessionDetachModule_SIEVE(wcsession * sess) {
DeleteHash(&sess->KnownSieveScripts);
}
-void
-InitModule_SIEVE
-(void)
-{
+void InitModule_SIEVE(void) {
RegisterCTX(CTX_SIEVELIST);
RegisterCTX(CTX_SIEVESCRIPT);
- REGISTERTokenParamDefine(from);
- REGISTERTokenParamDefine(tocc);
- REGISTERTokenParamDefine(subject);
- REGISTERTokenParamDefine(replyto);
- REGISTERTokenParamDefine(sender);
- REGISTERTokenParamDefine(resentfrom);
- REGISTERTokenParamDefine(resentto);
- REGISTERTokenParamDefine(envfrom);
- REGISTERTokenParamDefine(envto);
- REGISTERTokenParamDefine(xmailer);
- REGISTERTokenParamDefine(xspamflag);
- REGISTERTokenParamDefine(xspamstatus);
- REGISTERTokenParamDefine(listid);
- REGISTERTokenParamDefine(size);
+ REGISTERTokenParamDefine(from);
+ REGISTERTokenParamDefine(tocc);
+ REGISTERTokenParamDefine(subject);
+ REGISTERTokenParamDefine(replyto);
+ REGISTERTokenParamDefine(sender);
+ REGISTERTokenParamDefine(resentfrom);
+ REGISTERTokenParamDefine(resentto);
+ REGISTERTokenParamDefine(envfrom);
+ REGISTERTokenParamDefine(envto);
+ REGISTERTokenParamDefine(xmailer);
+ REGISTERTokenParamDefine(xspamflag);
+ REGISTERTokenParamDefine(xspamstatus);
+ REGISTERTokenParamDefine(listid);
+ REGISTERTokenParamDefine(size);
REGISTERTokenParamDefine(all);
REGISTERTokenParamDefine(contains);
@@ -620,7 +552,7 @@ InitModule_SIEVE
RegisterNamespace("SIEVE:SCRIPT:NAME", 0, 1, tmplput_SieveScriptName, NULL, CTX_SIEVELIST);
RegisterNamespace("SIEVE:SCRIPT:CONTENT", 0, 1, tmplput_SieveScriptContent, NULL, CTX_SIEVELIST);
-
+
RegisterIterator("SIEVE:RULES", 0, NULL, GetSieveRules, NULL, DeleteHash, CTX_SIEVESCRIPT, CTX_NONE, IT_NOFLAG);
RegisterConditional("COND:SIEVE:ACTIVE", 1, ConditionalSieveRule_Active, CTX_SIEVESCRIPT);
diff --git a/webcit/siteconfig.c b/webcit/siteconfig.c
index b82b0d2ab..11dcb102d 100644
--- a/webcit/siteconfig.c
+++ b/webcit/siteconfig.c
@@ -1,3 +1,4 @@
+
/*
* Administrative screen for site-wide configuration
*
@@ -18,22 +19,26 @@
/*
* Expiry policy for the autopurger
*/
-#define EXPIRE_NEXTLEVEL 0 /* Inherit expiration policy */
-#define EXPIRE_MANUAL 1 /* Don't expire messages at all */
-#define EXPIRE_NUMMSGS 2 /* Keep only latest n messages */
-#define EXPIRE_AGE 3 /* Expire messages after n days */
+#define EXPIRE_NEXTLEVEL 0 /* Inherit expiration policy */
+#define EXPIRE_MANUAL 1 /* Don't expire messages at all */
+#define EXPIRE_NUMMSGS 2 /* Keep only latest n messages */
+#define EXPIRE_AGE 3 /* Expire messages after n days */
CtxType CTX_SRVLOG = CTX_NONE;
HashList *ZoneHash = NULL;
-ConstStr ExpirePolicyString = {CStrOf(roompolicy) };
+ConstStr ExpirePolicyString = { CStrOf(roompolicy) };
ConstStr ExpirePolicyStrings[][2] = {
- { { CStrOf(roompolicy) } , { strof(roompolicy) "_value", sizeof(strof(roompolicy) "_value") - 1 } },
- { { CStrOf(floorpolicy) } , { strof(floorpolicy) "_value", sizeof(strof(floorpolicy) "_value") - 1 } },
- { { CStrOf(sitepolicy) } , { strof(sitepolicy) "_value", sizeof(strof(sitepolicy) "_value") - 1 } },
- { { CStrOf(mailboxespolicy)} , { strof(mailboxespolicy)"_value", sizeof(strof(mailboxespolicy)"_value") - 1 } }
+ { { CStrOf(roompolicy)}, { strof(roompolicy) "_value", sizeof(strof(roompolicy) "_value") - 1}
+ },
+ { { CStrOf(floorpolicy)}, { strof(floorpolicy) "_value", sizeof(strof(floorpolicy) "_value") - 1}
+ },
+ { { CStrOf(sitepolicy)}, { strof(sitepolicy) "_value", sizeof(strof(sitepolicy) "_value") - 1}
+ },
+ { { CStrOf(mailboxespolicy)}, { strof(mailboxespolicy) "_value", sizeof(strof(mailboxespolicy) "_value") - 1}
+ }
};
@@ -60,10 +65,9 @@ void SaveExpirePolicyFromHTTP(GPEXWhichPolicy which) {
StrBuf *Buf;
long State;
- serv_printf("SPEX %s|%d|%d",
- ExpirePolicyStrings[which][0].Key,
- ibcstr( ExpirePolicyStrings[which][1] ),
- ibcstr( ExpirePolicyStrings[which][1] ) );
+ serv_printf("SPEX %s|%d|%d",
+ ExpirePolicyStrings[which][0].Key,
+ ibcstr(ExpirePolicyStrings[which][1]), ibcstr(ExpirePolicyStrings[which][1]));
Buf = NewStrBuf();
StrBuf_ServGetln(Buf);
@@ -74,7 +78,7 @@ void SaveExpirePolicyFromHTTP(GPEXWhichPolicy which) {
}
-int ConditionalExpire(StrBuf *Target, WCTemplputParams *TP) {
+int ConditionalExpire(StrBuf * Target, WCTemplputParams * TP) {
GPEXWhichPolicy which;
int CompareWith;
@@ -82,23 +86,23 @@ int ConditionalExpire(StrBuf *Target, WCTemplputParams *TP) {
CompareWith = GetTemplateTokenNumber(Target, TP, 3, 0);
LoadExpirePolicy(which);
-
+
return WC->Policy[which].expire_mode == CompareWith;
}
-void tmplput_ExpireValue(StrBuf *Target, WCTemplputParams *TP) {
+void tmplput_ExpireValue(StrBuf * Target, WCTemplputParams * TP) {
GPEXWhichPolicy which;
-
+
which = GetTemplateTokenNumber(Target, TP, 0, 0);
LoadExpirePolicy(which);
StrBufAppendPrintf(Target, "%d", WC->Policy[which].expire_value);
}
-void tmplput_ExpireMode(StrBuf *Target, WCTemplputParams *TP) {
+void tmplput_ExpireMode(StrBuf * Target, WCTemplputParams * TP) {
GPEXWhichPolicy which;
-
+
which = GetTemplateTokenNumber(Target, TP, 2, 0);
LoadExpirePolicy(which);
StrBufAppendPrintf(Target, "%d", WC->Policy[which].expire_mode);
@@ -111,16 +115,16 @@ void LoadZoneFiles(void) {
long len;
const char *this_zone;
StrBuf *ZName;
-
+
ZoneHash = NewHash(1, NULL);
ZName = NewStrBufPlain(HKEY("UTC"));
Put(ZoneHash, HKEY("UTC"), ZName, HFreeStrBuf);
zones = icaltimezone_get_builtin_timezones();
for (z = 0; z < zones->num_elements; ++z) {
/* syslog(LOG_DEBUG, "Location: %-40s tzid: %s\n",
- icaltimezone_get_location(icalarray_element_at(zones, z)),
- icaltimezone_get_tzid(icalarray_element_at(zones, z))
- ); */
+ icaltimezone_get_location(icalarray_element_at(zones, z)),
+ icaltimezone_get_tzid(icalarray_element_at(zones, z))
+ ); */
this_zone = icaltimezone_get_location(icalarray_element_at(zones, z));
len = strlen(this_zone);
ZName = NewStrBufPlain(this_zone, len);
@@ -145,78 +149,78 @@ typedef struct _CfgMapping {
#define CFG_INT 4
CfgMapping ServerConfig[] = {
- {CFG_STR, 0, 0, "", HKEY("c_nodename")},
- {CFG_STR, 0, 0, "", HKEY("c_fqdn")},
- {CFG_STR, 0, 0, "", HKEY("c_humannode")},
- {CFG_STR, 0, 0, "", HKEY("c_phonenum")},
- {CFG_YES, 0, 0, "", HKEY("c_creataide")},
- {CFG_STR, 0, 0, "", HKEY("c_sleeping")},
- {CFG_STR, 0, 0, "", HKEY("c_initax")},
- {CFG_YES, 0, 0, "", HKEY("c_regiscall")},
- {CFG_YES, 0, 0, "", HKEY("c_twitdetect")},
- {CFG_STR, 0, 0, "", HKEY("c_twitroom")},
- {CFG_STR, 0, 0, "", HKEY("c_moreprompt")},
- {CFG_YES, 0, 0, "", HKEY("c_restrict")},
- {CFG_STR, 0, 0, "", HKEY("c_bbs_city")},
- {CFG_STR, 0, 0, "", HKEY("c_sysadm")},
- {CFG_STR, 0, 0, "", HKEY("c_maxsessions")},
- {CFG_STR, 0, 0, "", HKEY("reserved1")},
- {CFG_STR, 0, 0, "", HKEY("c_userpurge")},
- {CFG_STR, 0, 0, "", HKEY("c_roompurge")},
- {CFG_STR, 0, 0, "", HKEY("c_logpages")},
- {CFG_STR, 0, 0, "", HKEY("c_createax")},
- {CFG_STR, 0, 0, "", HKEY("c_maxmsglen")},
- {CFG_STR, 0, 0, "", HKEY("c_min_workers")},
- {CFG_STR, 0, 0, "", HKEY("c_max_workers")},
- {CFG_STR, 0, 0, "", HKEY("c_pop3_port")},
- {CFG_STR, 0, 0, "", HKEY("c_smtp_port")},
- {CFG_INT, CFG_SMTP_FROM_FILTERALL, CFG_SMTP_FROM_REJECT, "0", HKEY("c_rfc822_strict_from")},
- {CFG_YES, 0, 0, "", HKEY("c_aide_zap")},
- {CFG_STR, 0, 0, "", HKEY("c_imap_port")},
- {CFG_STR, 0, 0, "", HKEY("c_net_freq")},
- {CFG_YES, 0, 0, "", HKEY("c_disable_newu")},
- {CFG_STR, 0, 0, "", HKEY("reserved2")},
- {CFG_STR, 0, 0, "", HKEY("c_purge_hour")},
- {CFG_STR, 0, 0, "", HKEY("c_ldap_host")},
- {CFG_STR, 0, 0, "", HKEY("c_ldap_port")},
- {CFG_STR, 0, 0, "", HKEY("c_ldap_base_dn")},
- {CFG_STR, 0, 0, "", HKEY("c_ldap_bind_dn")},
- {CFG_STR, 0, 0, "", HKEY("c_ldap_bind_pw")},
- {CFG_STR, 0, 0, "", HKEY("c_ip_addr")},
- {CFG_STR, 0, 0, "", HKEY("c_msa_port")},
- {CFG_STR, 0, 0, "", HKEY("c_imaps_port")},
- {CFG_STR, 0, 0, "", HKEY("c_pop3s_port")},
- {CFG_STR, 0, 0, "", HKEY("c_smtps_port")},
- {CFG_YES, 0, 0, "", HKEY("c_enable_fulltext")},
- {CFG_YES, 0, 0, "", HKEY("c_auto_cull")},
- {CFG_YES, 0, 0, "", HKEY("reserved3")},
- {CFG_YES, 0, 0, "", HKEY("c_allow_spoofing")},
- {CFG_YES, 0, 0, "", HKEY("c_journal_email")},
- {CFG_YES, 0, 0, "", HKEY("c_journal_pubmsgs")},
- {CFG_STR, 0, 0, "", HKEY("c_journal_dest")},
- {CFG_STR, 0, 0, "", HKEY("c_default_cal_zone")},
- {CFG_STR, 0, 0, "", HKEY("c_pftcpdict_port")},
- {CFG_STR, 0, 0, "", HKEY("c_mgesve_port")},
- {CFG_STR, 0, 0, "", HKEY("c_auth_mode")},
- {CFG_STR, 0, 0, "", HKEY("c_funambol_host")},
- {CFG_STR, 0, 0, "", HKEY("c_funambol_port")},
- {CFG_STR, 0, 0, "", HKEY("c_funambol_source")},
- {CFG_STR, 0, 0, "", HKEY("c_funambol_auth")},
- {CFG_YES, 0, 0, "", HKEY("c_rbl_at_greeting")},
- {CFG_STR, 0, 0, "", HKEY("c_master_user")},
- {CFG_STR, 0, 0, "", HKEY("c_master_pass")},
- {CFG_STR, 0, 0, "", HKEY("c_pager_program")},
- {CFG_YES, 0, 0, "", HKEY("c_imap_keep_from")},
- {CFG_STR, 0, 0, "", HKEY("c_xmpp_c2s_port")},
- {CFG_STR, 0, 0, "", HKEY("c_xmpp_s2s_port")},
- {CFG_STR, 0, 0, "", HKEY("c_pop3_fetch")},
- {CFG_STR, 0, 0, "", HKEY("c_pop3_fastest")},
- {CFG_YES, 0, 0, "", HKEY("c_spam_flag_only")},
- {CFG_YES, 0, 0, "", HKEY("c_guest_logins")},
- {CFG_STR, 0, 0, "", HKEY("c_port_number")},
- {CFG_STR, 0, 0, "", HKEY("c_ctdluid")},
- {CFG_STR, 0, 0, "", HKEY("c_nntp_port")},
- {CFG_STR, 0, 0, "", HKEY("c_nntps_port")}
+ { CFG_STR, 0, 0, "", HKEY("c_nodename") },
+ { CFG_STR, 0, 0, "", HKEY("c_fqdn") },
+ { CFG_STR, 0, 0, "", HKEY("c_humannode") },
+ { CFG_STR, 0, 0, "", HKEY("c_phonenum") },
+ { CFG_YES, 0, 0, "", HKEY("c_creataide") },
+ { CFG_STR, 0, 0, "", HKEY("c_sleeping") },
+ { CFG_STR, 0, 0, "", HKEY("c_initax") },
+ { CFG_YES, 0, 0, "", HKEY("c_regiscall") },
+ { CFG_YES, 0, 0, "", HKEY("c_twitdetect") },
+ { CFG_STR, 0, 0, "", HKEY("c_twitroom") },
+ { CFG_STR, 0, 0, "", HKEY("c_moreprompt") },
+ { CFG_YES, 0, 0, "", HKEY("c_restrict") },
+ { CFG_STR, 0, 0, "", HKEY("c_bbs_city") },
+ { CFG_STR, 0, 0, "", HKEY("c_sysadm") },
+ { CFG_STR, 0, 0, "", HKEY("c_maxsessions") },
+ { CFG_STR, 0, 0, "", HKEY("reserved1") },
+ { CFG_STR, 0, 0, "", HKEY("c_userpurge") },
+ { CFG_STR, 0, 0, "", HKEY("c_roompurge") },
+ { CFG_STR, 0, 0, "", HKEY("c_logpages") },
+ { CFG_STR, 0, 0, "", HKEY("c_createax") },
+ { CFG_STR, 0, 0, "", HKEY("c_maxmsglen") },
+ { CFG_STR, 0, 0, "", HKEY("c_min_workers") },
+ { CFG_STR, 0, 0, "", HKEY("c_max_workers") },
+ { CFG_STR, 0, 0, "", HKEY("c_pop3_port") },
+ { CFG_STR, 0, 0, "", HKEY("c_smtp_port") },
+ { CFG_INT, CFG_SMTP_FROM_FILTERALL, CFG_SMTP_FROM_REJECT, "0", HKEY("c_rfc822_strict_from") },
+ { CFG_YES, 0, 0, "", HKEY("c_aide_zap") },
+ { CFG_STR, 0, 0, "", HKEY("c_imap_port") },
+ { CFG_STR, 0, 0, "", HKEY("c_net_freq") },
+ { CFG_YES, 0, 0, "", HKEY("c_disable_newu") },
+ { CFG_STR, 0, 0, "", HKEY("reserved2") },
+ { CFG_STR, 0, 0, "", HKEY("c_purge_hour") },
+ { CFG_STR, 0, 0, "", HKEY("c_ldap_host") },
+ { CFG_STR, 0, 0, "", HKEY("c_ldap_port") },
+ { CFG_STR, 0, 0, "", HKEY("c_ldap_base_dn") },
+ { CFG_STR, 0, 0, "", HKEY("c_ldap_bind_dn") },
+ { CFG_STR, 0, 0, "", HKEY("c_ldap_bind_pw") },
+ { CFG_STR, 0, 0, "", HKEY("c_ip_addr") },
+ { CFG_STR, 0, 0, "", HKEY("c_msa_port") },
+ { CFG_STR, 0, 0, "", HKEY("c_imaps_port") },
+ { CFG_STR, 0, 0, "", HKEY("c_pop3s_port") },
+ { CFG_STR, 0, 0, "", HKEY("c_smtps_port") },
+ { CFG_YES, 0, 0, "", HKEY("c_enable_fulltext") },
+ { CFG_YES, 0, 0, "", HKEY("c_auto_cull") },
+ { CFG_YES, 0, 0, "", HKEY("reserved3") },
+ { CFG_YES, 0, 0, "", HKEY("c_allow_spoofing") },
+ { CFG_YES, 0, 0, "", HKEY("c_journal_email") },
+ { CFG_YES, 0, 0, "", HKEY("c_journal_pubmsgs") },
+ { CFG_STR, 0, 0, "", HKEY("c_journal_dest") },
+ { CFG_STR, 0, 0, "", HKEY("c_default_cal_zone") },
+ { CFG_STR, 0, 0, "", HKEY("c_pftcpdict_port") },
+ { CFG_STR, 0, 0, "", HKEY("c_mgesve_port") },
+ { CFG_STR, 0, 0, "", HKEY("c_auth_mode") },
+ { CFG_STR, 0, 0, "", HKEY("c_funambol_host") },
+ { CFG_STR, 0, 0, "", HKEY("c_funambol_port") },
+ { CFG_STR, 0, 0, "", HKEY("c_funambol_source") },
+ { CFG_STR, 0, 0, "", HKEY("c_funambol_auth") },
+ { CFG_YES, 0, 0, "", HKEY("c_rbl_at_greeting") },
+ { CFG_STR, 0, 0, "", HKEY("c_master_user") },
+ { CFG_STR, 0, 0, "", HKEY("c_master_pass") },
+ { CFG_STR, 0, 0, "", HKEY("c_pager_program") },
+ { CFG_YES, 0, 0, "", HKEY("c_imap_keep_from") },
+ { CFG_STR, 0, 0, "", HKEY("c_xmpp_c2s_port") },
+ { CFG_STR, 0, 0, "", HKEY("c_xmpp_s2s_port") },
+ { CFG_STR, 0, 0, "", HKEY("c_pop3_fetch") },
+ { CFG_STR, 0, 0, "", HKEY("c_pop3_fastest") },
+ { CFG_YES, 0, 0, "", HKEY("c_spam_flag_only") },
+ { CFG_YES, 0, 0, "", HKEY("c_guest_logins") },
+ { CFG_STR, 0, 0, "", HKEY("c_port_number") },
+ { CFG_STR, 0, 0, "", HKEY("c_ctdluid") },
+ { CFG_STR, 0, 0, "", HKEY("c_nntp_port") },
+ { CFG_STR, 0, 0, "", HKEY("c_nntps_port") }
};
@@ -228,7 +232,7 @@ void load_siteconfig(void) {
HashList *Cfg;
long len;
int i, j;
-
+
if (WC->ServCfg == NULL)
WC->ServCfg = NewHash(1, NULL);
Cfg = WC->ServCfg;
@@ -242,26 +246,19 @@ void load_siteconfig(void) {
AppendImportantMessage(SKEY(Buf));
FreeStrBuf(&Buf);
return;
-
+
}
j = i = 0;
- while (len = StrBuf_ServGetln(Buf),
- (len >= 0) &&
- ((len != 3) || strcmp(ChrPtr(Buf), "000")))
- {
- if (i < (sizeof(ServerConfig) / sizeof(CfgMapping)))
- {
- Put(Cfg,
- ServerConfig[i].Key,
- ServerConfig[i].len,
- Buf,
- HFreeStrBuf);
+ while (len = StrBuf_ServGetln(Buf), (len >= 0) && ((len != 3) || strcmp(ChrPtr(Buf), "000"))) {
+ if (i < (sizeof(ServerConfig) / sizeof(CfgMapping))) {
+ Put(Cfg, ServerConfig[i].Key, ServerConfig[i].len, Buf, HFreeStrBuf);
i++;
Buf = NewStrBuf();
}
else {
if (j == 0) {
- syslog(LOG_WARNING, "The server sent more configuration data than this version of webcit is capable of changing. Unknown configuration values will remain unchanged.");
+ syslog(LOG_WARNING,
+ "The server sent more configuration data than this version of webcit is capable of changing. Unknown configuration values will remain unchanged.");
}
j++;
}
@@ -297,34 +294,27 @@ void siteconfig(void) {
FreeStrBuf(&Line);
- for (i=0; i < (sizeof(ServerConfig) / sizeof(CfgMapping)); i ++)
- {
+ for (i = 0; i < (sizeof(ServerConfig) / sizeof(CfgMapping)); i++) {
switch (ServerConfig[i].type) {
default:
case CFG_STR:
serv_putbuf(SBstr(ServerConfig[i].Key, ServerConfig[i].len));
break;
case CFG_YES:
- serv_puts(YesBstr(ServerConfig[i].Key,
- ServerConfig[i].len) ?
- "1" : "0");
+ serv_puts(YesBstr(ServerConfig[i].Key, ServerConfig[i].len) ? "1" : "0");
break;
case CFG_NO:
- serv_puts(YesBstr(ServerConfig[i].Key,
- ServerConfig[i].len) ?
- "0" : "1");
+ serv_puts(YesBstr(ServerConfig[i].Key, ServerConfig[i].len) ? "0" : "1");
break;
case CFG_INT:
- value = IBstr(ServerConfig[i].Key,
- ServerConfig[i].len);
- if ((value < ServerConfig[i].min) ||
- (value > ServerConfig[i].max))
+ value = IBstr(ServerConfig[i].Key, ServerConfig[i].len);
+ if ((value < ServerConfig[i].min) || (value > ServerConfig[i].max))
value = atol(ServerConfig[i].defval);
serv_printf("%d", value);
break;
}
}
- serv_puts("000");
+ serv_puts("000");
SaveExpirePolicyFromHTTP(sitepolicy);
SaveExpirePolicyFromHTTP(mailboxespolicy);
@@ -339,7 +329,7 @@ void siteconfig(void) {
// if WebCit Classic wasn't obsolete we would replace this with a "CONF GETVAL" type of thing
-void tmplput_servcfg(StrBuf *Target, WCTemplputParams *TP) {
+void tmplput_servcfg(StrBuf * Target, WCTemplputParams * TP) {
void *vBuf;
StrBuf *Buf;
@@ -347,13 +337,13 @@ void tmplput_servcfg(StrBuf *Target, WCTemplputParams *TP) {
if (WC->ServCfg == NULL)
load_siteconfig();
GetHash(WC->ServCfg, TKEY(0), &vBuf);
- Buf = (StrBuf*) vBuf;
+ Buf = (StrBuf *) vBuf;
StrBufAppendTemplate(Target, TP, Buf, 1);
}
}
-int ConditionalServCfg(StrBuf *Target, WCTemplputParams *TP) {
+int ConditionalServCfg(StrBuf * Target, WCTemplputParams * TP) {
void *vBuf;
StrBuf *Buf;
@@ -361,43 +351,45 @@ int ConditionalServCfg(StrBuf *Target, WCTemplputParams *TP) {
if (WC->ServCfg == NULL)
load_siteconfig();
GetHash(WC->ServCfg, TKEY(2), &vBuf);
- if (vBuf == NULL) return 0;
- Buf = (StrBuf*) vBuf;
+ if (vBuf == NULL)
+ return 0;
+ Buf = (StrBuf *) vBuf;
if (TP->Tokens->nParameters == 3) {
return 1;
}
else if (IS_NUMBER(TP->Tokens->Params[3]->Type))
- return (StrTol(Buf) == GetTemplateTokenNumber (Target, TP, 3, 0));
- else
- {
+ return (StrTol(Buf) == GetTemplateTokenNumber(Target, TP, 3, 0));
+ else {
const char *pch;
long len;
-
+
GetTemplateTokenString(Target, TP, 3, &pch, &len);
-
- return ((len == StrLength(Buf)) &&
- (strcmp(pch, ChrPtr(Buf)) == 0));
+
+ return ((len == StrLength(Buf)) && (strcmp(pch, ChrPtr(Buf)) == 0));
}
}
- else return 0;
+ else
+ return 0;
}
-int ConditionalServCfgCTXStrBuf(StrBuf *Target, WCTemplputParams *TP) {
+int ConditionalServCfgCTXStrBuf(StrBuf * Target, WCTemplputParams * TP) {
void *vBuf;
StrBuf *Buf;
- StrBuf *ZoneToCheck = (StrBuf*) CTX(CTX_STRBUF);
+ StrBuf *ZoneToCheck = (StrBuf *) CTX(CTX_STRBUF);
if ((WC->is_aide) || (ZoneToCheck == NULL)) {
if (WC->ServCfg == NULL)
load_siteconfig();
GetHash(WC->ServCfg, TKEY(2), &vBuf);
- if (vBuf == NULL) return 0;
- Buf = (StrBuf*) vBuf;
+ if (vBuf == NULL)
+ return 0;
+ Buf = (StrBuf *) vBuf;
return strcmp(ChrPtr(Buf), ChrPtr(ZoneToCheck)) == 0;
}
- else return 0;
+ else
+ return 0;
}
/*----------------------------------------------------------------------------*
@@ -406,33 +398,29 @@ int ConditionalServCfgCTXStrBuf(StrBuf *Target, WCTemplputParams *TP) {
typedef struct __LogStatusStruct {
int Enable;
StrBuf *Name;
-}LogStatusStruct;
+} LogStatusStruct;
-void DeleteLogStatusStruct(void *v)
-{
- LogStatusStruct *Stat = (LogStatusStruct*)v;
+void DeleteLogStatusStruct(void *v) {
+ LogStatusStruct *Stat = (LogStatusStruct *) v;
FreeStrBuf(&Stat->Name);
free(Stat);
}
-void tmplput_servcfg_LogName(StrBuf *Target, WCTemplputParams *TP)
-{
- LogStatusStruct *Stat = (LogStatusStruct*) CTX(CTX_SRVLOG);
+void tmplput_servcfg_LogName(StrBuf * Target, WCTemplputParams * TP) {
+ LogStatusStruct *Stat = (LogStatusStruct *) CTX(CTX_SRVLOG);
StrBufAppendTemplate(Target, TP, Stat->Name, 1);
}
-int ConditionalServCfgThisLogEnabled(StrBuf *Target, WCTemplputParams *TP)
-{
- LogStatusStruct *Stat = (LogStatusStruct*) CTX(CTX_SRVLOG);
+int ConditionalServCfgThisLogEnabled(StrBuf * Target, WCTemplputParams * TP) {
+ LogStatusStruct *Stat = (LogStatusStruct *) CTX(CTX_SRVLOG);
return Stat->Enable;
}
-HashList *iterate_GetSrvLogEnable(StrBuf *Target, WCTemplputParams *TP)
-{
- HashList *Hash = NULL;
+HashList *iterate_GetSrvLogEnable(StrBuf * Target, WCTemplputParams * TP) {
+ HashList *Hash = NULL;
StrBuf *Buf;
LogStatusStruct *Stat;
const char *Pos;
@@ -440,39 +428,33 @@ HashList *iterate_GetSrvLogEnable(StrBuf *Target, WCTemplputParams *TP)
long len;
int num_logs = 0;
- serv_puts("LOGP");
- Buf = NewStrBuf();
- StrBuf_ServGetln(Buf);
- if (GetServerStatus(Buf, NULL) == 1) {
- Hash = NewHash(1, Flathash);
- while (!Done) {
- len = StrBuf_ServGetln(Buf);
- if ((len <0) ||
- ((len == 3) &&
- !strcmp(ChrPtr(Buf), "000")))
- {
- Done = 1;
- break;
- }
- Stat = (LogStatusStruct*) malloc (sizeof(LogStatusStruct));
+ serv_puts("LOGP");
+ Buf = NewStrBuf();
+ StrBuf_ServGetln(Buf);
+ if (GetServerStatus(Buf, NULL) == 1) {
+ Hash = NewHash(1, Flathash);
+ while (!Done) {
+ len = StrBuf_ServGetln(Buf);
+ if ((len < 0) || ((len == 3) && !strcmp(ChrPtr(Buf), "000"))) {
+ Done = 1;
+ break;
+ }
+ Stat = (LogStatusStruct *) malloc(sizeof(LogStatusStruct));
Pos = NULL;
Stat->Name = NewStrBufPlain(NULL, len);
- StrBufExtract_NextToken(Stat->Name, Buf, &Pos, '|');
- Stat->Enable = StrBufExtractNext_int(Buf, &Pos, '|');
+ StrBufExtract_NextToken(Stat->Name, Buf, &Pos, '|');
+ Stat->Enable = StrBufExtractNext_int(Buf, &Pos, '|');
- Put(Hash, IKEY(num_logs), Stat, DeleteLogStatusStruct);
+ Put(Hash, IKEY(num_logs), Stat, DeleteLogStatusStruct);
num_logs++;
- }
+ }
}
FreeStrBuf(&Buf);
return Hash;
}
-void
-InitModule_SITECONFIG
-(void)
-{
+void InitModule_SITECONFIG(void) {
RegisterCTX(CTX_SRVLOG);
WebcitAddUrlHandler(HKEY("siteconfig"), "", 0, siteconfig, CTX_NONE);
@@ -504,24 +486,15 @@ InitModule_SITECONFIG
RegisterNamespace("SERVCFG:LOGNAME", 0, 1, tmplput_servcfg_LogName, NULL, CTX_SRVLOG);
}
-void
-ServerStartModule_SITECONFIG
-(void)
-{
+void ServerStartModule_SITECONFIG(void) {
LoadZoneFiles();
}
-void
-ServerShutdownModule_SITECONFIG
-(void)
-{
+void ServerShutdownModule_SITECONFIG(void) {
DeleteHash(&ZoneHash);
}
-void
-SessionDestroyModule_SITECONFIG
-(wcsession *sess)
-{
+void SessionDestroyModule_SITECONFIG(wcsession * sess) {
DeleteHash(&sess->ServCfg);
}
diff --git a/webcit/sitemap.c b/webcit/sitemap.c
index 50618e636..34b92f46e 100644
--- a/webcit/sitemap.c
+++ b/webcit/sitemap.c
@@ -1,3 +1,4 @@
+
/*
* XML sitemap generator
*
@@ -30,9 +31,10 @@ void sitemap_do_bbs(void) {
Stat.lowest_found = (-1);
Stat.highest_found = (-1);
num_msgs = load_msg_ptrs("MSGS ALL", NULL, NULL, &Stat, NULL, NULL, NULL, NULL, 0);
- if (num_msgs < 1) return;
+ if (num_msgs < 1)
+ return;
- for (i=0; isumm);
if (Msg != NULL) {
wc_printf("%s/readfwd", ChrPtr(site_prefix));
@@ -60,25 +62,27 @@ void sitemap_do_wiki(void) {
Stat.lowest_found = (-1);
Stat.highest_found = (-1);
num_msgs = load_msg_ptrs("MSGS ALL", NULL, NULL, &Stat, NULL, NULL, NULL, NULL, 0);
- if (num_msgs < 1) return;
+ if (num_msgs < 1)
+ return;
- for (i=0; isumm);
if (Msg != NULL) {
serv_printf("MSG0 %ld|3", Msg->msgnum);
serv_getln(buf, sizeof buf);
- if (buf[0] == '1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
- if ( (!strncasecmp(buf, "exti=", 5))
- && (!bmstrcasestr(buf, "_HISTORY_"))
- ) {
- wc_printf("%s/wiki", ChrPtr(site_prefix));
- wc_printf("?go=");
- urlescputs(ChrPtr(WC->CurRoom.name));
- wc_printf("?page=%s", &buf[5]);
- wc_printf(" \r\n");
+ if (buf[0] == '1')
+ while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
+ if ((!strncasecmp(buf, "exti=", 5))
+ && (!bmstrcasestr(buf, "_HISTORY_"))
+ ) {
+ wc_printf("%s/wiki", ChrPtr(site_prefix));
+ wc_printf("?go=");
+ urlescputs(ChrPtr(WC->CurRoom.name));
+ wc_printf("?page=%s", &buf[5]);
+ wc_printf(" \r\n");
+ }
}
- }
}
}
}
@@ -101,16 +105,17 @@ struct sitemap_room_list *sitemap_load_roomlist(void) {
serv_puts("LKRA");
serv_getln(buf, sizeof buf);
- if (buf[0] == '1') while(serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
- struct sitemap_room_list *ptr = malloc(sizeof(struct sitemap_room_list));
- extract_token(roomname_plain, buf, 0, '|', sizeof roomname_plain);
- ptr->roomname = NewStrBufPlain(roomname_plain, -1);
- ptr->defview = extract_int(buf, 6);
- ptr->next = roomlist;
- roomlist = ptr;
- }
+ if (buf[0] == '1')
+ while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
+ struct sitemap_room_list *ptr = malloc(sizeof(struct sitemap_room_list));
+ extract_token(roomname_plain, buf, 0, '|', sizeof roomname_plain);
+ ptr->roomname = NewStrBufPlain(roomname_plain, -1);
+ ptr->defview = extract_int(buf, 6);
+ ptr->next = roomlist;
+ roomlist = ptr;
+ }
- return(roomlist);
+ return (roomlist);
}
extern void sitemap_do_blog(void);
@@ -122,12 +127,8 @@ void sitemap(void) {
struct sitemap_room_list *roomlist = NULL;
output_headers(0, 0, 0, 0, 1, 0);
hprintf("Content-type: text/xml\r\n");
- hprintf(
- "Server: %s / %s\r\n"
- "Connection: close\r\n"
- ,
- PACKAGE_STRING, ChrPtr(WC->serv_info->serv_software)
- );
+ hprintf("Server: %s / %s\r\n" "Connection: close\r\n", PACKAGE_STRING, ChrPtr(WC->serv_info->serv_software)
+ );
begin_burst();
wc_printf("\r\n");
@@ -135,14 +136,13 @@ void sitemap(void) {
roomlist = sitemap_load_roomlist();
- while (roomlist != NULL)
- {
+ while (roomlist != NULL) {
struct sitemap_room_list *ptr;
gotoroom(roomlist->roomname);
/* Output the messages in this room only if it's a room type we can make sense of */
- switch(roomlist->defview) {
+ switch (roomlist->defview) {
case VIEW_BBS:
sitemap_do_bbs();
break;
@@ -167,10 +167,7 @@ void sitemap(void) {
}
-void
-InitModule_SITEMAP
-(void)
-{
- WebcitAddUrlHandler(HKEY("sitemap"), "", 0, sitemap, ANONYMOUS|COOKIEUNNEEDED);
- WebcitAddUrlHandler(HKEY("sitemap.xml"), "", 0, sitemap, ANONYMOUS|COOKIEUNNEEDED);
+void InitModule_SITEMAP(void) {
+ WebcitAddUrlHandler(HKEY("sitemap"), "", 0, sitemap, ANONYMOUS | COOKIEUNNEEDED);
+ WebcitAddUrlHandler(HKEY("sitemap.xml"), "", 0, sitemap, ANONYMOUS | COOKIEUNNEEDED);
}
diff --git a/webcit/smtpqueue.c b/webcit/smtpqueue.c
index b5c750a31..7168d6fa4 100644
--- a/webcit/smtpqueue.c
+++ b/webcit/smtpqueue.c
@@ -1,3 +1,4 @@
+
/*
* Display the outbound SMTP queue
*/
@@ -13,6 +14,7 @@ typedef struct _mailq_entry {
StrBuf *Recipient;
StrBuf *StatusMessage;
int Status;
+
/**<
* 0 = No delivery has yet been attempted
* 2 = Delivery was successful
@@ -25,7 +27,7 @@ typedef struct _mailq_entry {
int n;
int Active;
-}MailQEntry;
+} MailQEntry;
typedef struct queueitem {
long MessageID;
@@ -33,6 +35,7 @@ typedef struct queueitem {
long Submitted;
int FailNow;
HashList *MailQEntries;
+
/* copy of the currently parsed item in the MailQEntries list;
* if null add a new one.
*/
@@ -49,28 +52,25 @@ typedef struct queueitem {
} OneQueItem;
-typedef void (*QItemHandler)(OneQueItem *Item, StrBuf *Line, const char **Pos);
+typedef void (*QItemHandler)(OneQueItem * Item, StrBuf * Line, const char **Pos);
typedef struct __QItemHandlerStruct {
QItemHandler H;
} QItemHandlerStruct;
-void RegisterQItemHandler(const char *Key, long Len, QItemHandler H)
-{
- QItemHandlerStruct *HS = (QItemHandlerStruct*)malloc(sizeof(QItemHandlerStruct));
+void RegisterQItemHandler(const char *Key, long Len, QItemHandler H) {
+ QItemHandlerStruct *HS = (QItemHandlerStruct *) malloc(sizeof(QItemHandlerStruct));
HS->H = H;
Put(QItemHandlers, Key, Len, HS, NULL);
}
-void FreeMailQEntry(void *qv)
-{
+void FreeMailQEntry(void *qv) {
MailQEntry *Q = qv;
FreeStrBuf(&Q->Recipient);
FreeStrBuf(&Q->StatusMessage);
free(Q);
}
-void FreeQueItem(OneQueItem **Item)
-{
+void FreeQueItem(OneQueItem ** Item) {
DeleteHash(&(*Item)->MailQEntries);
FreeStrBuf(&(*Item)->EnvelopeFrom);
FreeStrBuf(&(*Item)->BounceTo);
@@ -79,20 +79,18 @@ void FreeQueItem(OneQueItem **Item)
free(*Item);
Item = NULL;
}
-void HFreeQueItem(void *Item)
-{
- FreeQueItem((OneQueItem**)&Item);
+void HFreeQueItem(void *Item) {
+ FreeQueItem((OneQueItem **) & Item);
}
-OneQueItem *DeserializeQueueItem(StrBuf *RawQItem, long QueMsgID)
-{
+OneQueItem *DeserializeQueueItem(StrBuf * RawQItem, long QueMsgID) {
OneQueItem *Item;
const char *pLine = NULL;
StrBuf *Line;
StrBuf *Token;
-
- Item = (OneQueItem*)malloc(sizeof(OneQueItem));
+
+ Item = (OneQueItem *) malloc(sizeof(OneQueItem));
memset(Item, 0, sizeof(OneQueItem));
Item->Retry = 0;
Item->MessageID = -1;
@@ -105,77 +103,69 @@ OneQueItem *DeserializeQueueItem(StrBuf *RawQItem, long QueMsgID)
void *vHandler;
StrBufExtract_NextToken(Line, RawQItem, &pLine, '\n');
- if (StrLength(Line) == 0) continue;
+ if (StrLength(Line) == 0)
+ continue;
StrBufExtract_NextToken(Token, Line, &pItemPart, '|');
- if (GetHash(QItemHandlers, SKEY(Token), &vHandler))
- {
+ if (GetHash(QItemHandlers, SKEY(Token), &vHandler)) {
QItemHandlerStruct *HS;
- HS = (QItemHandlerStruct*) vHandler;
+ HS = (QItemHandlerStruct *) vHandler;
HS->H(Item, Line, &pItemPart);
}
}
FreeStrBuf(&Line);
FreeStrBuf(&Token);
+
/*
Put(ActiveQItems,
LKEY(Item->MessageID),
Item,
HFreeQueItem);
-*/
+*/
return Item;
}
-void tmplput_MailQID(StrBuf *Target, WCTemplputParams *TP)
-{
- OneQueItem *Item = (OneQueItem*) CTX(CTX_MAILQITEM);
+void tmplput_MailQID(StrBuf * Target, WCTemplputParams * TP) {
+ OneQueItem *Item = (OneQueItem *) CTX(CTX_MAILQITEM);
StrBufAppendPrintf(Target, "%ld", Item->QueMsgID);;
}
-void tmplput_MailQPayloadID(StrBuf *Target, WCTemplputParams *TP)
-{
- OneQueItem *Item = (OneQueItem*) CTX(CTX_MAILQITEM);
+void tmplput_MailQPayloadID(StrBuf * Target, WCTemplputParams * TP) {
+ OneQueItem *Item = (OneQueItem *) CTX(CTX_MAILQITEM);
StrBufAppendPrintf(Target, "%ld", Item->MessageID);
}
-void tmplput_MailQBounceTo(StrBuf *Target, WCTemplputParams *TP)
-{
- OneQueItem *Item = (OneQueItem*) CTX(CTX_MAILQITEM);
+void tmplput_MailQBounceTo(StrBuf * Target, WCTemplputParams * TP) {
+ OneQueItem *Item = (OneQueItem *) CTX(CTX_MAILQITEM);
StrBufAppendTemplate(Target, TP, Item->BounceTo, 0);
}
-void tmplput_MailQAttempted(StrBuf *Target, WCTemplputParams *TP)
-{
- char datebuf[64];
- OneQueItem *Item = (OneQueItem*) CTX(CTX_MAILQITEM);
- webcit_fmt_date(datebuf, 64, Item->ReattemptWhen, DATEFMT_BRIEF);
- StrBufAppendBufPlain(Target, datebuf, -1, 0);
-}
-void tmplput_MailQSubmitted(StrBuf *Target, WCTemplputParams *TP)
-{
- char datebuf[64];
- OneQueItem *Item = (OneQueItem*) CTX(CTX_MAILQITEM);
- webcit_fmt_date(datebuf, 64, Item->Submitted, DATEFMT_BRIEF);
- StrBufAppendBufPlain(Target, datebuf, -1, 0);
-}
-void tmplput_MailQEnvelopeFrom(StrBuf *Target, WCTemplputParams *TP)
-{
- OneQueItem *Item = (OneQueItem*) CTX(CTX_MAILQITEM);
+void tmplput_MailQAttempted(StrBuf * Target, WCTemplputParams * TP) {
+ char datebuf[64];
+ OneQueItem *Item = (OneQueItem *) CTX(CTX_MAILQITEM);
+ webcit_fmt_date(datebuf, 64, Item->ReattemptWhen, DATEFMT_BRIEF);
+ StrBufAppendBufPlain(Target, datebuf, -1, 0);
+}
+void tmplput_MailQSubmitted(StrBuf * Target, WCTemplputParams * TP) {
+ char datebuf[64];
+ OneQueItem *Item = (OneQueItem *) CTX(CTX_MAILQITEM);
+ webcit_fmt_date(datebuf, 64, Item->Submitted, DATEFMT_BRIEF);
+ StrBufAppendBufPlain(Target, datebuf, -1, 0);
+}
+void tmplput_MailQEnvelopeFrom(StrBuf * Target, WCTemplputParams * TP) {
+ OneQueItem *Item = (OneQueItem *) CTX(CTX_MAILQITEM);
StrBufAppendTemplate(Target, TP, Item->EnvelopeFrom, 0);
}
-void tmplput_MailQSourceRoom(StrBuf *Target, WCTemplputParams *TP)
-{
- OneQueItem *Item = (OneQueItem*) CTX(CTX_MAILQITEM);
+void tmplput_MailQSourceRoom(StrBuf * Target, WCTemplputParams * TP) {
+ OneQueItem *Item = (OneQueItem *) CTX(CTX_MAILQITEM);
StrBufAppendTemplate(Target, TP, Item->SenderRoom, 0);
}
-int Conditional_MailQ_HaveSourceRoom(StrBuf *Target, WCTemplputParams *TP)
-{
- OneQueItem *Item = (OneQueItem*) CTX(CTX_MAILQITEM);
+int Conditional_MailQ_HaveSourceRoom(StrBuf * Target, WCTemplputParams * TP) {
+ OneQueItem *Item = (OneQueItem *) CTX(CTX_MAILQITEM);
return StrLength(Item->SenderRoom) > 0;
}
-void tmplput_MailQRetry(StrBuf *Target, WCTemplputParams *TP)
-{
- char datebuf[64];
- OneQueItem *Item = (OneQueItem*) CTX(CTX_MAILQITEM);
+void tmplput_MailQRetry(StrBuf * Target, WCTemplputParams * TP) {
+ char datebuf[64];
+ OneQueItem *Item = (OneQueItem *) CTX(CTX_MAILQITEM);
if (Item->Retry == 0) {
StrBufAppendBufPlain(Target, _("First Attempt pending"), -1, 0);
@@ -186,77 +176,64 @@ void tmplput_MailQRetry(StrBuf *Target, WCTemplputParams *TP)
}
}
-void tmplput_MailQRCPT(StrBuf *Target, WCTemplputParams *TP)
-{
- MailQEntry *Entry = (MailQEntry*) CTX(CTX_MAILQ_RCPT);
+void tmplput_MailQRCPT(StrBuf * Target, WCTemplputParams * TP) {
+ MailQEntry *Entry = (MailQEntry *) CTX(CTX_MAILQ_RCPT);
StrBufAppendTemplate(Target, TP, Entry->Recipient, 0);
}
-void tmplput_MailQRCPTStatus(StrBuf *Target, WCTemplputParams *TP)
-{
- MailQEntry *Entry = (MailQEntry*) CTX(CTX_MAILQ_RCPT);
+void tmplput_MailQRCPTStatus(StrBuf * Target, WCTemplputParams * TP) {
+ MailQEntry *Entry = (MailQEntry *) CTX(CTX_MAILQ_RCPT);
StrBufAppendPrintf(Target, "%ld", Entry->Status);
}
-void tmplput_MailQStatusMsg(StrBuf *Target, WCTemplputParams *TP)
-{
- MailQEntry *Entry = (MailQEntry*) CTX(CTX_MAILQ_RCPT);
+void tmplput_MailQStatusMsg(StrBuf * Target, WCTemplputParams * TP) {
+ MailQEntry *Entry = (MailQEntry *) CTX(CTX_MAILQ_RCPT);
StrBufAppendTemplate(Target, TP, Entry->StatusMessage, 0);
}
-HashList *iterate_get_Recipients(StrBuf *Target, WCTemplputParams *TP)
-{
- OneQueItem *Item = (OneQueItem*) CTX(CTX_MAILQITEM);
+HashList *iterate_get_Recipients(StrBuf * Target, WCTemplputParams * TP) {
+ OneQueItem *Item = (OneQueItem *) CTX(CTX_MAILQITEM);
return Item->MailQEntries;
}
-void NewMailQEntry(OneQueItem *Item)
-{
- Item->Current = (MailQEntry*) malloc(sizeof(MailQEntry));
+void NewMailQEntry(OneQueItem * Item) {
+ Item->Current = (MailQEntry *) malloc(sizeof(MailQEntry));
memset(Item->Current, 0, sizeof(MailQEntry));
if (Item->MailQEntries == NULL)
Item->MailQEntries = NewHash(1, Flathash);
Item->Current->StatusMessage = NewStrBuf();
Item->Current->n = GetCount(Item->MailQEntries);
- Put(Item->MailQEntries,
- IKEY(Item->Current->n),
- Item->Current,
- FreeMailQEntry);
+ Put(Item->MailQEntries, IKEY(Item->Current->n), Item->Current, FreeMailQEntry);
}
-void QItem_Handle_MsgID(OneQueItem *Item, StrBuf *Line, const char **Pos)
-{
+void QItem_Handle_MsgID(OneQueItem * Item, StrBuf * Line, const char **Pos) {
Item->MessageID = StrBufExtractNext_long(Line, Pos, '|');
}
-void QItem_Handle_EnvelopeFrom(OneQueItem *Item, StrBuf *Line, const char **Pos)
-{
+void QItem_Handle_EnvelopeFrom(OneQueItem * Item, StrBuf * Line, const char **Pos) {
if (Item->EnvelopeFrom == NULL)
Item->EnvelopeFrom = NewStrBufPlain(NULL, StrLength(Line));
StrBufExtract_NextToken(Item->EnvelopeFrom, Line, Pos, '|');
}
-void QItem_Handle_BounceTo(OneQueItem *Item, StrBuf *Line, const char **Pos)
-{
+void QItem_Handle_BounceTo(OneQueItem * Item, StrBuf * Line, const char **Pos) {
if (Item->BounceTo == NULL)
Item->BounceTo = NewStrBufPlain(NULL, StrLength(Line));
StrBufExtract_NextToken(Item->BounceTo, Line, Pos, '|');
}
-void QItem_Handle_SenderRoom(OneQueItem *Item, StrBuf *Line, const char **Pos)
-{
+void QItem_Handle_SenderRoom(OneQueItem * Item, StrBuf * Line, const char **Pos) {
if (Item->SenderRoom == NULL)
Item->SenderRoom = NewStrBufPlain(NULL, StrLength(Line));
StrBufExtract_NextToken(Item->SenderRoom, Line, Pos, '|');
}
-void QItem_Handle_Recipient(OneQueItem *Item, StrBuf *Line, const char **Pos)
-{
+void QItem_Handle_Recipient(OneQueItem * Item, StrBuf * Line, const char **Pos) {
const char *pch;
if (Item->Current == NULL)
NewMailQEntry(Item);
if (Item->Current->Recipient == NULL)
- Item->Current->Recipient=NewStrBufPlain(NULL, StrLength(Line));
+ Item->Current->Recipient = NewStrBufPlain(NULL, StrLength(Line));
StrBufExtract_NextToken(Item->Current->Recipient, Line, Pos, '|');
Item->Current->Status = StrBufExtractNext_int(Line, Pos, '|');
StrBufExtract_NextToken(Item->Current->StatusMessage, Line, Pos, '|');
@@ -265,42 +242,37 @@ void QItem_Handle_Recipient(OneQueItem *Item, StrBuf *Line, const char **Pos)
while ((pch != NULL) && (*pch != '\0')) {
pch = strchr(pch, ';');
if (pch != NULL) {
- pch ++;
+ pch++;
if (*pch == ' ') {
- StrBufPeek(Item->Current->StatusMessage,
- pch, -1, '\n');
+ StrBufPeek(Item->Current->StatusMessage, pch, -1, '\n');
}
}
}
- Item->Current = NULL; // TODO: is this always right?
+ Item->Current = NULL; // TODO: is this always right?
}
-void QItem_Handle_retry(OneQueItem *Item, StrBuf *Line, const char **Pos)
-{
+void QItem_Handle_retry(OneQueItem * Item, StrBuf * Line, const char **Pos) {
Item->Retry = StrBufExtractNext_int(Line, Pos, '|');
}
-void QItem_Handle_Submitted(OneQueItem *Item, StrBuf *Line, const char **Pos)
-{
+void QItem_Handle_Submitted(OneQueItem * Item, StrBuf * Line, const char **Pos) {
Item->Submitted = atol(*Pos);
}
-void QItem_Handle_Attempted(OneQueItem *Item, StrBuf *Line, const char **Pos)
-{
+void QItem_Handle_Attempted(OneQueItem * Item, StrBuf * Line, const char **Pos) {
Item->ReattemptWhen = StrBufExtractNext_int(Line, Pos, '|');
}
-void render_QUEUE(StrBuf *Target, WCTemplputParams *TP, StrBuf *FoundCharset)
-{
+void render_QUEUE(StrBuf * Target, WCTemplputParams * TP, StrBuf * FoundCharset) {
wc_mime_attachment *Mime = CTX(CTX_MIME_ATACH);
WCTemplputParams SubTP;
- OneQueItem* Context;
+ OneQueItem *Context;
Context = DeserializeQueueItem(Mime->Data, Mime->msgnum);
StackContext(TP, &SubTP, Context, CTX_MAILQITEM, 0, TP->Tokens);
@@ -309,24 +281,18 @@ void render_QUEUE(StrBuf *Target, WCTemplputParams *TP, StrBuf *FoundCharset)
}
UnStackContext(&SubTP);
- FreeQueItem (&Context);
+ FreeQueItem(&Context);
}
-void
-ServerShutdownModule_SMTP_QUEUE
-(void)
-{
+void ServerShutdownModule_SMTP_QUEUE(void) {
DeleteHash(&QItemHandlers);
}
-void
-ServerStartModule_SMTP_QUEUE
-(void)
-{
+
+void ServerStartModule_SMTP_QUEUE(void) {
QItemHandlers = NewHash(0, NULL);
}
-int qview_PrintPageHeader(SharedMessageStatus *Stat, void **ViewSpecific)
-{
+int qview_PrintPageHeader(SharedMessageStatus * Stat, void **ViewSpecific) {
if (yesbstr("ListOnly"))
output_headers(1, 0, 0, 0, 0, 0);
else
@@ -334,16 +300,9 @@ int qview_PrintPageHeader(SharedMessageStatus *Stat, void **ViewSpecific)
return 0;
}
-int qview_GetParamsGetServerCall(SharedMessageStatus *Stat,
- void **ViewSpecific,
- long oper,
- char *cmd,
- long len,
- char *filter,
- long flen)
-{
- if (!WC->is_aide)
- {
+int qview_GetParamsGetServerCall(SharedMessageStatus * Stat,
+ void **ViewSpecific, long oper, char *cmd, long len, char *filter, long flen) {
+ if (!WC->is_aide) {
DoTemplate(HKEY("aide_required"), NULL, NULL);
end_burst();
@@ -363,64 +322,51 @@ int qview_GetParamsGetServerCall(SharedMessageStatus *Stat,
/*
* Display task view
*/
-int qview_LoadMsgFromServer(SharedMessageStatus *Stat,
- void **ViewSpecific,
- message_summary* Msg,
- int is_new,
- int i)
-{
+int qview_LoadMsgFromServer(SharedMessageStatus * Stat, void **ViewSpecific, message_summary * Msg, int is_new, int i) {
wcsession *WCC = WC;
const StrBuf *Mime;
- /* Not (yet?) needed here? calview *c = (calview *) *ViewSpecific; */
+ /* Not (yet?) needed here? calview *c = (calview *) *ViewSpecific; */
read_message(WCC->WBuf, HKEY("view_mailq_message_bearer"), Msg->msgnum, NULL, &Mime, NULL);
- return 0;
+ return 0;
}
-int qview_RenderView_or_Tail(SharedMessageStatus *Stat,
- void **ViewSpecific,
- long oper)
-{
+int qview_RenderView_or_Tail(SharedMessageStatus * Stat, void **ViewSpecific, long oper) {
wcsession *WCC = WC;
WCTemplputParams SubTP;
memset(&SubTP, 0, sizeof(WCTemplputParams));
if (yesbstr("ListOnly"))
- DoTemplate(HKEY("view_mailq_footer_listonly"),NULL, &SubTP);
- else
- {
+ DoTemplate(HKEY("view_mailq_footer_listonly"), NULL, &SubTP);
+ else {
if (GetCount(WCC->summ) == 0)
- DoTemplate(HKEY("view_mailq_footer_empty"),NULL, &SubTP);
+ DoTemplate(HKEY("view_mailq_footer_empty"), NULL, &SubTP);
else
- DoTemplate(HKEY("view_mailq_footer"),NULL, &SubTP);
+ DoTemplate(HKEY("view_mailq_footer"), NULL, &SubTP);
}
return 0;
}
-int qview_Cleanup(void **ViewSpecific)
-{
-
- wDumpContent(yesbstr("ListOnly")?0:1);
+int qview_Cleanup(void **ViewSpecific) {
+
+ wDumpContent(yesbstr("ListOnly") ? 0 : 1);
return 0;
}
-void
-InitModule_SMTP_QUEUE
-(void)
-{
+void InitModule_SMTP_QUEUE(void) {
RegisterCTX(CTX_MAILQITEM);
RegisterCTX(CTX_MAILQ_RCPT);
- RegisterQItemHandler(HKEY("msgid"), QItem_Handle_MsgID);
- RegisterQItemHandler(HKEY("envelope_from"), QItem_Handle_EnvelopeFrom);
- RegisterQItemHandler(HKEY("retry"), QItem_Handle_retry);
- RegisterQItemHandler(HKEY("attempted"), QItem_Handle_Attempted);
- RegisterQItemHandler(HKEY("remote"), QItem_Handle_Recipient);
- RegisterQItemHandler(HKEY("bounceto"), QItem_Handle_BounceTo);
- RegisterQItemHandler(HKEY("source_room"), QItem_Handle_SenderRoom);
- RegisterQItemHandler(HKEY("submitted"), QItem_Handle_Submitted);
+ RegisterQItemHandler(HKEY("msgid"), QItem_Handle_MsgID);
+ RegisterQItemHandler(HKEY("envelope_from"), QItem_Handle_EnvelopeFrom);
+ RegisterQItemHandler(HKEY("retry"), QItem_Handle_retry);
+ RegisterQItemHandler(HKEY("attempted"), QItem_Handle_Attempted);
+ RegisterQItemHandler(HKEY("remote"), QItem_Handle_Recipient);
+ RegisterQItemHandler(HKEY("bounceto"), QItem_Handle_BounceTo);
+ RegisterQItemHandler(HKEY("source_room"), QItem_Handle_SenderRoom);
+ RegisterQItemHandler(HKEY("submitted"), QItem_Handle_Submitted);
RegisterMimeRenderer(HKEY("application/x-citadel-delivery-list"), render_QUEUE, 1, 9000);
RegisterNamespace("MAILQ:ID", 0, 0, tmplput_MailQID, NULL, CTX_MAILQITEM);
RegisterNamespace("MAILQ:PAYLOAD:ID", 0, 0, tmplput_MailQPayloadID, NULL, CTX_MAILQITEM);
@@ -429,26 +375,17 @@ InitModule_SMTP_QUEUE
RegisterNamespace("MAILQ:SUBMITTED", 0, 0, tmplput_MailQSubmitted, NULL, CTX_MAILQITEM);
RegisterNamespace("MAILQ:ENVELOPEFROM", 0, 1, tmplput_MailQEnvelopeFrom, NULL, CTX_MAILQITEM);
RegisterNamespace("MAILQ:SRCROOM", 0, 1, tmplput_MailQSourceRoom, NULL, CTX_MAILQITEM);
- RegisterConditional("COND:MAILQ:HAVESRCROOM", 0, Conditional_MailQ_HaveSourceRoom, CTX_MAILQITEM);
+ RegisterConditional("COND:MAILQ:HAVESRCROOM", 0, Conditional_MailQ_HaveSourceRoom, CTX_MAILQITEM);
RegisterNamespace("MAILQ:RETRY", 0, 0, tmplput_MailQRetry, NULL, CTX_MAILQITEM);
RegisterNamespace("MAILQ:RCPT:ADDR", 0, 1, tmplput_MailQRCPT, NULL, CTX_MAILQ_RCPT);
RegisterNamespace("MAILQ:RCPT:STATUS", 0, 0, tmplput_MailQRCPTStatus, NULL, CTX_MAILQ_RCPT);
RegisterNamespace("MAILQ:RCPT:STATUSMSG", 0, 1, tmplput_MailQStatusMsg, NULL, CTX_MAILQ_RCPT);
- RegisterIterator("MAILQ:RCPT", 0, NULL, iterate_get_Recipients,
- NULL, NULL, CTX_MAILQ_RCPT, CTX_MAILQITEM, IT_NOFLAG);
+ RegisterIterator("MAILQ:RCPT", 0, NULL, iterate_get_Recipients, NULL, NULL, CTX_MAILQ_RCPT, CTX_MAILQITEM, IT_NOFLAG);
- RegisterReadLoopHandlerset(
- VIEW_QUEUE,
- qview_GetParamsGetServerCall,
- qview_PrintPageHeader,
- NULL, /* TODO: is this right? */
- NULL,
- qview_LoadMsgFromServer,
- qview_RenderView_or_Tail,
- qview_Cleanup,
- NULL);
+ RegisterReadLoopHandlerset(VIEW_QUEUE, qview_GetParamsGetServerCall, qview_PrintPageHeader, NULL, /* TODO: is this right? */
+ NULL, qview_LoadMsgFromServer, qview_RenderView_or_Tail, qview_Cleanup, NULL);
}
diff --git a/webcit/sockets.c b/webcit/sockets.c
index 57ca65466..0971a7486 100644
--- a/webcit/sockets.c
+++ b/webcit/sockets.c
@@ -1,3 +1,4 @@
+
/*
* Copyright (c) 1987-2021 by the citadel.org team
*
@@ -18,7 +19,7 @@
#include "webcit.h"
#include "webserver.h"
-long MaxRead = -1; /* should we do READ scattered or all at once? */
+long MaxRead = -1; /* should we do READ scattered or all at once? */
/*
* register the timeout
@@ -43,13 +44,13 @@ int connect_to_citadel(char *sockpath) {
s = socket(AF_UNIX, SOCK_STREAM, 0);
if (s < 0) {
syslog(LOG_WARNING, "Can't create socket [%s]: %s\n", sockpath, strerror(errno));
- return(-1);
+ return (-1);
}
if (connect(s, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
syslog(LOG_WARNING, "Can't connect [%s]: %s\n", sockpath, strerror(errno));
close(s);
- return(-1);
+ return (-1);
}
return s;
}
@@ -76,33 +77,26 @@ int serv_getln(char *strbuf, int bufsize) {
}
-int StrBuf_ServGetln(StrBuf *buf) {
+int StrBuf_ServGetln(StrBuf * buf) {
const char *ErrStr = NULL;
int rc;
-
+
if (!WC->connected)
return -1;
FlushStrBuf(buf);
- rc = StrBufTCP_read_buffered_line_fast(buf,
- WC->ReadBuf,
- &WC->ReadPos,
- &WC->serv_sock,
- 5, 1,
- &ErrStr);
- if (rc < 0)
- {
- syslog(LOG_INFO, "StrBuf_ServGetln(): Server connection broken: %s\n",
- (ErrStr)?ErrStr:"");
+ rc = StrBufTCP_read_buffered_line_fast(buf, WC->ReadBuf, &WC->ReadPos, &WC->serv_sock, 5, 1, &ErrStr);
+ if (rc < 0) {
+ syslog(LOG_INFO, "StrBuf_ServGetln(): Server connection broken: %s\n", (ErrStr) ? ErrStr : "");
wc_backtrace(LOG_INFO);
- if (WC->serv_sock > 0) close(WC->serv_sock);
+ if (WC->serv_sock > 0)
+ close(WC->serv_sock);
WC->serv_sock = (-1);
WC->connected = 0;
WC->logged_in = 0;
}
#ifdef SERV_TRACE
- else
- {
+ else {
long pos = 0;
if (WC->ReadPos != NULL)
pos = WC->ReadPos - ChrPtr(WC->ReadBuf);
@@ -112,60 +106,53 @@ int StrBuf_ServGetln(StrBuf *buf) {
return rc;
}
-int StrBuf_ServGetBLOBBuffered(StrBuf *buf, long BlobSize) {
+int StrBuf_ServGetBLOBBuffered(StrBuf * buf, long BlobSize) {
const char *ErrStr;
int rc;
-
- rc = StrBufReadBLOBBuffered(buf,
- WC->ReadBuf,
- &WC->ReadPos,
- &WC->serv_sock,
- 1,
- BlobSize,
- NNN_TERM,
- &ErrStr);
+
+ rc = StrBufReadBLOBBuffered(buf, WC->ReadBuf, &WC->ReadPos, &WC->serv_sock, 1, BlobSize, NNN_TERM, &ErrStr);
if (rc < 0) {
- syslog(LOG_INFO, "StrBuf_ServGetBLOBBuffered(): Server connection broken: %s\n",
- (ErrStr)?ErrStr:"");
+ syslog(LOG_INFO, "StrBuf_ServGetBLOBBuffered(): Server connection broken: %s\n", (ErrStr) ? ErrStr : "");
wc_backtrace(LOG_INFO);
- if (WC->serv_sock > 0) close(WC->serv_sock);
+ if (WC->serv_sock > 0)
+ close(WC->serv_sock);
WC->serv_sock = (-1);
WC->connected = 0;
WC->logged_in = 0;
}
#ifdef SERV_TRACE
- else
- syslog(LOG_DEBUG, "%3d<<serv_sock, StrLength(buf));
+ else
+ syslog(LOG_DEBUG, "%3d<<serv_sock, StrLength(buf));
#endif
return rc;
}
-int StrBuf_ServGetBLOB(StrBuf *buf, long BlobSize) {
+int StrBuf_ServGetBLOB(StrBuf * buf, long BlobSize) {
const char *ErrStr;
int rc;
-
+
WC->ReadPos = NULL;
rc = StrBufReadBLOB(buf, &WC->serv_sock, 1, BlobSize, &ErrStr);
if (rc < 0) {
- syslog(LOG_INFO, "StrBuf_ServGetBLOB(): Server connection broken: %s\n",
- (ErrStr)?ErrStr:"");
+ syslog(LOG_INFO, "StrBuf_ServGetBLOB(): Server connection broken: %s\n", (ErrStr) ? ErrStr : "");
wc_backtrace(LOG_INFO);
- if (WC->serv_sock > 0) close(WC->serv_sock);
+ if (WC->serv_sock > 0)
+ close(WC->serv_sock);
WC->serv_sock = (-1);
WC->connected = 0;
WC->logged_in = 0;
}
#ifdef SERV_TRACE
- else
- syslog(LOG_DEBUG, "%3d<<serv_sock, StrLength(buf));
+ else
+ syslog(LOG_DEBUG, "%3d<<serv_sock, StrLength(buf));
#endif
return rc;
}
-void FlushReadBuf (void) {
+void FlushReadBuf(void) {
long len;
const char *pch;
const char *pche;
@@ -176,16 +163,13 @@ void FlushReadBuf (void) {
pche = pch + len;
if (WC->ReadPos != pche) {
syslog(LOG_ERR,
- "ERROR: somebody didn't eat his soup! Remaing Chars: %ld [%s]\n",
- (long)(pche - WC->ReadPos),
- pche
- );
- syslog(LOG_ERR,
- "--------------------------------------------------------------------------------\n"
- "Whole buf: [%s]\n"
- "--------------------------------------------------------------------------------\n",
- pch);
- AppendImportantMessage(HKEY("Suppenkasper alert! watch your webcit logfile and get connected to your favourite opensource Crew."));
+ "ERROR: somebody didn't eat his soup! Remaing Chars: %ld [%s]\n", (long) (pche - WC->ReadPos), pche);
+ syslog(LOG_ERR,
+ "--------------------------------------------------------------------------------\n"
+ "Whole buf: [%s]\n"
+ "--------------------------------------------------------------------------------\n", pch);
+ AppendImportantMessage(HKEY
+ ("Suppenkasper alert! watch your webcit logfile and get connected to your favourite opensource Crew."));
}
}
@@ -210,8 +194,9 @@ int serv_write(const char *buf, int nbytes) {
retval = write(WC->serv_sock, &buf[bytes_written], nbytes - bytes_written);
if (retval < 1) {
const char *ErrStr = strerror(errno);
- syslog(LOG_INFO, "serv_write(): Server connection broken: %s\n", (ErrStr)?ErrStr:"");
- if (WC->serv_sock > 0) close(WC->serv_sock);
+ syslog(LOG_INFO, "serv_write(): Server connection broken: %s\n", (ErrStr) ? ErrStr : "");
+ if (WC->serv_sock > 0)
+ close(WC->serv_sock);
WC->serv_sock = (-1);
WC->connected = 0;
WC->logged_in = 0;
@@ -242,7 +227,7 @@ int serv_puts(const char *string) {
* send line to server
* string the line to send to the citadel server
*/
-int serv_putbuf(const StrBuf *string) {
+int serv_putbuf(const StrBuf * string) {
#ifdef SERV_TRACE
syslog(LOG_DEBUG, "%3d>>>%s\n", WC->serv_sock, ChrPtr(string));
#endif
@@ -259,7 +244,7 @@ int serv_putbuf(const StrBuf *string) {
* format the formatstring
* ... the entities to insert into format
*/
-int serv_printf(const char *format,...) {
+int serv_printf(const char *format, ...) {
va_list arg_ptr;
char buf[SIZ];
size_t len;
@@ -286,7 +271,7 @@ int serv_printf(const char *format,...) {
* Read binary data from server into memory using a series of server READ commands.
* returns the read content as StrBuf
*/
-int serv_read_binary(StrBuf *Ret, size_t total_len, StrBuf *Buf) {
+int serv_read_binary(StrBuf * Ret, size_t total_len, StrBuf * Buf) {
size_t bytes_read = 0;
size_t this_block = 0;
int rc = 6;
@@ -298,13 +283,13 @@ int serv_read_binary(StrBuf *Ret, size_t total_len, StrBuf *Buf) {
while ((bytes_read < total_len) && (ServerRc == 6)) {
- if (WC->serv_sock==-1) {
- FlushStrBuf(Ret);
- return -1;
+ if (WC->serv_sock == -1) {
+ FlushStrBuf(Ret);
+ return -1;
}
- serv_printf("READ "SIZE_T_FMT"|"SIZE_T_FMT, bytes_read, total_len-bytes_read);
- if ( (rc = StrBuf_ServGetln(Buf) > 0) && (ServerRc = GetServerStatus(Buf, NULL), ServerRc == 6) ) {
+ serv_printf("READ " SIZE_T_FMT "|" SIZE_T_FMT, bytes_read, total_len - bytes_read);
+ if ((rc = StrBuf_ServGetln(Buf) > 0) && (ServerRc = GetServerStatus(Buf, NULL), ServerRc == 6)) {
if (rc < 0)
return rc;
StrBufCutLeft(Buf, 4);
@@ -313,7 +298,8 @@ int serv_read_binary(StrBuf *Ret, size_t total_len, StrBuf *Buf) {
if (rc < 0) {
syslog(LOG_INFO, "Server connection broken during download\n");
wc_backtrace(LOG_INFO);
- if (WC->serv_sock > 0) close(WC->serv_sock);
+ if (WC->serv_sock > 0)
+ close(WC->serv_sock);
WC->serv_sock = (-1);
WC->connected = 0;
WC->logged_in = 0;
@@ -327,12 +313,12 @@ int serv_read_binary(StrBuf *Ret, size_t total_len, StrBuf *Buf) {
}
-int client_write(StrBuf *ThisBuf) {
- const char *ptr, *eptr;
- long count;
+int client_write(StrBuf * ThisBuf) {
+ const char *ptr, *eptr;
+ long count;
ssize_t res = 0;
- fd_set wset;
- int fdflags;
+ fd_set wset;
+ int fdflags;
ptr = ChrPtr(ThisBuf);
count = StrLength(ThisBuf);
@@ -340,34 +326,34 @@ int client_write(StrBuf *ThisBuf) {
fdflags = fcntl(WC->Hdr->http_sock, F_GETFL);
- while ((ptr < eptr) && (WC->Hdr->http_sock != -1)) {
- if ((fdflags & O_NONBLOCK) == O_NONBLOCK) {
- FD_ZERO(&wset);
- FD_SET(WC->Hdr->http_sock, &wset);
- if (select(WC->Hdr->http_sock + 1, NULL, &wset, NULL, NULL) == -1) {
- syslog(LOG_INFO, "client_write: Socket select failed (%s)\n", strerror(errno));
- return -1;
- }
- }
-
- if ((WC->Hdr->http_sock == -1) || ((res = write(WC->Hdr->http_sock, ptr, count)), (res == -1))) {
- syslog(LOG_INFO, "client_write: Socket write failed (%s)\n", strerror(errno));
+ while ((ptr < eptr) && (WC->Hdr->http_sock != -1)) {
+ if ((fdflags & O_NONBLOCK) == O_NONBLOCK) {
+ FD_ZERO(&wset);
+ FD_SET(WC->Hdr->http_sock, &wset);
+ if (select(WC->Hdr->http_sock + 1, NULL, &wset, NULL, NULL) == -1) {
+ syslog(LOG_INFO, "client_write: Socket select failed (%s)\n", strerror(errno));
+ return -1;
+ }
+ }
+
+ if ((WC->Hdr->http_sock == -1) || ((res = write(WC->Hdr->http_sock, ptr, count)), (res == -1))) {
+ syslog(LOG_INFO, "client_write: Socket write failed (%s)\n", strerror(errno));
wc_backtrace(LOG_INFO);
- return -1;
- }
- count -= res;
+ return -1;
+ }
+ count -= res;
ptr += res;
- }
+ }
return 0;
}
-int read_serv_chunk( StrBuf *Buf, size_t total_len, size_t *bytes_read) {
+int read_serv_chunk(StrBuf * Buf, size_t total_len, size_t *bytes_read) {
int rc;
int ServerRc;
- serv_printf("READ "SIZE_T_FMT"|"SIZE_T_FMT, *bytes_read, total_len-(*bytes_read));
- if ( (rc = StrBuf_ServGetln(Buf) > 0) && (ServerRc = GetServerStatus(Buf, NULL), ServerRc == 6) ) {
+ serv_printf("READ " SIZE_T_FMT "|" SIZE_T_FMT, *bytes_read, total_len - (*bytes_read));
+ if ((rc = StrBuf_ServGetln(Buf) > 0) && (ServerRc = GetServerStatus(Buf, NULL), ServerRc == 6)) {
size_t this_block = 0;
if (rc < 0)
@@ -379,7 +365,8 @@ int read_serv_chunk( StrBuf *Buf, size_t total_len, size_t *bytes_read) {
if (rc < 0) {
syslog(LOG_INFO, "Server connection broken during download\n");
wc_backtrace(LOG_INFO);
- if (WC->serv_sock > 0) close(WC->serv_sock);
+ if (WC->serv_sock > 0)
+ close(WC->serv_sock);
WC->serv_sock = (-1);
WC->connected = 0;
WC->logged_in = 0;
@@ -390,7 +377,7 @@ int read_serv_chunk( StrBuf *Buf, size_t total_len, size_t *bytes_read) {
return 6;
}
-static inline int send_http(StrBuf *Buf) {
+static inline int send_http(StrBuf * Buf) {
#ifdef HAVE_OPENSSL
if (is_https)
return client_write_ssl(Buf);
@@ -398,11 +385,12 @@ static inline int send_http(StrBuf *Buf) {
#endif
return client_write(Buf);
}
+
/*
* Read binary data from server into memory using a series of server READ commands.
* returns the read content as StrBuf
*/
-void serv_read_binary_to_http(StrBuf *MimeType, size_t total_len, int is_static, int detect_mime) {
+void serv_read_binary_to_http(StrBuf * MimeType, size_t total_len, int is_static, int detect_mime) {
int ServerRc = 6;
size_t bytes_read = 0;
int first = 1;
@@ -416,7 +404,7 @@ void serv_read_binary_to_http(StrBuf *MimeType, size_t total_len, int is_static,
vStreamT *SC = NULL;
IOBuffer ReadBuffer;
IOBuffer WriteBuffer;
-
+
Buf = NewStrBuf();
@@ -424,13 +412,13 @@ void serv_read_binary_to_http(StrBuf *MimeType, size_t total_len, int is_static,
WC->Hdr->HaveRange++;
WC->Hdr->TotalBytes = total_len;
/* open range? or beyound file border? correct the numbers. */
- if ((WC->Hdr->RangeTil == -1) || (WC->Hdr->RangeTil>= total_len))
+ if ((WC->Hdr->RangeTil == -1) || (WC->Hdr->RangeTil >= total_len))
WC->Hdr->RangeTil = total_len - 1;
bytes_read = WC->Hdr->RangeStart;
total_len = WC->Hdr->RangeTil;
}
else
- chunked = total_len > SIZ * 10; /* TODO: disallow for HTTP / 1.0 */
+ chunked = total_len > SIZ * 10; /* TODO: disallow for HTTP / 1.0 */
if (chunked) {
BufHeader = NewStrBuf();
@@ -441,13 +429,9 @@ void serv_read_binary_to_http(StrBuf *MimeType, size_t total_len, int is_static,
size_t bytes_read = 0;
const char *CT;
- ServerRc = read_serv_chunk(
- Buf,
- total_len,
- &bytes_read);
+ ServerRc = read_serv_chunk(Buf, total_len, &bytes_read);
- if (ServerRc != 6)
- {
+ if (ServerRc != 6) {
FreeStrBuf(&BufHeader);
FreeStrBuf(&Buf);
return;
@@ -463,7 +447,7 @@ void serv_read_binary_to_http(StrBuf *MimeType, size_t total_len, int is_static,
memset(&WriteBuffer, 0, sizeof(IOBuffer));
if (chunked && !DisableGzip && WC->Hdr->HR.gzip_ok) {
is_gzip = 1;
- SC = StrBufNewStreamContext (eZLibEncode, &Err);
+ SC = StrBufNewStreamContext(eZLibEncode, &Err);
if (SC == NULL) {
syslog(LOG_ERR, "Error while initializing stream context: %s", Err);
FreeStrBuf(&Buf);
@@ -473,7 +457,7 @@ void serv_read_binary_to_http(StrBuf *MimeType, size_t total_len, int is_static,
memset(&ReadBuffer, 0, sizeof(IOBuffer));
ReadBuffer.Buf = WC->WBuf;
- WriteBuffer.Buf = NewStrBufPlain(NULL, SIZ*2);;
+ WriteBuffer.Buf = NewStrBufPlain(NULL, SIZ * 2);;
pBuf = WriteBuffer.Buf;
}
else {
@@ -482,7 +466,7 @@ void serv_read_binary_to_http(StrBuf *MimeType, size_t total_len, int is_static,
if (!detect_mime) {
http_transmit_headers(ChrPtr(MimeType), is_static, chunked, is_gzip);
-
+
if (send_http(WC->HBuf) < 0) {
FreeStrBuf(&Buf);
FreeStrBuf(&WriteBuffer.Buf);
@@ -496,8 +480,8 @@ void serv_read_binary_to_http(StrBuf *MimeType, size_t total_len, int is_static,
while ((bytes_read < total_len) && (ServerRc == 6) && (client_con_state == 0)) {
- if (WC->serv_sock==-1) {
- FlushStrBuf(WC->WBuf);
+ if (WC->serv_sock == -1) {
+ FlushStrBuf(WC->WBuf);
FreeStrBuf(&Buf);
FreeStrBuf(&WriteBuffer.Buf);
FreeStrBuf(&BufHeader);
@@ -508,17 +492,14 @@ void serv_read_binary_to_http(StrBuf *MimeType, size_t total_len, int is_static,
return;
}
- ServerRc = read_serv_chunk(
- Buf,
- total_len,
- &bytes_read);
+ ServerRc = read_serv_chunk(Buf, total_len, &bytes_read);
if (ServerRc != 6)
break;
if (detect_mime) {
const char *CT;
detect_mime = 0;
-
+
CT = GuessMimeType(SKEY(WC->WBuf));
StrBufPlain(MimeType, CT, -1);
if (is_gzip) {
@@ -526,7 +507,7 @@ void serv_read_binary_to_http(StrBuf *MimeType, size_t total_len, int is_static,
is_gzip = WC->Hdr->HR.gzip_ok;
}
http_transmit_headers(ChrPtr(MimeType), is_static, chunked, is_gzip);
-
+
client_con_state = send_http(WC->HBuf);
}
@@ -536,12 +517,11 @@ void serv_read_binary_to_http(StrBuf *MimeType, size_t total_len, int is_static,
int rc;
do {
- rc = StrBufStreamTranscode(eZLibEncode, &WriteBuffer, &ReadBuffer, NULL, -1, SC, done, &Err);
+ rc = StrBufStreamTranscode(eZLibEncode, &WriteBuffer, &ReadBuffer, NULL, -1, SC, done,
+ &Err);
- if (StrLength (pBuf) > 0) {
- StrBufPrintf(BufHeader, "%s%x\r\n",
- (first)?"":"\r\n",
- StrLength (pBuf));
+ if (StrLength(pBuf) > 0) {
+ StrBufPrintf(BufHeader, "%s%x\r\n", (first) ? "" : "\r\n", StrLength(pBuf));
first = 0;
client_con_state = send_http(BufHeader);
if (client_con_state == 0) {
@@ -555,9 +535,7 @@ void serv_read_binary_to_http(StrBuf *MimeType, size_t total_len, int is_static,
}
else {
if ((chunked) && (client_con_state == 0)) {
- StrBufPrintf(BufHeader, "%s%x\r\n",
- (first)?"":"\r\n",
- StrLength (pBuf));
+ StrBufPrintf(BufHeader, "%s%x\r\n", (first) ? "" : "\r\n", StrLength(pBuf));
first = 0;
client_con_state = send_http(BufHeader);
}
@@ -577,7 +555,7 @@ void serv_read_binary_to_http(StrBuf *MimeType, size_t total_len, int is_static,
StrBufPlain(BufHeader, HKEY("\r\n0\r\n\r\n"));
if (send_http(BufHeader) < 0) {
FreeStrBuf(&Buf);
- FreeStrBuf(&BufHeader);
+ FreeStrBuf(&BufHeader);
return;
}
}
@@ -585,7 +563,7 @@ void serv_read_binary_to_http(StrBuf *MimeType, size_t total_len, int is_static,
FreeStrBuf(&Buf);
}
-int ClientGetLine(ParsedHttpHdrs *Hdr, StrBuf *Target) {
+int ClientGetLine(ParsedHttpHdrs * Hdr, StrBuf * Target) {
const char *Error;
#ifdef HAVE_OPENSSL
const char *pch, *pchs;
@@ -599,15 +577,15 @@ int ClientGetLine(ParsedHttpHdrs *Hdr, StrBuf *Target) {
if (pch != NULL) {
rlen = 0;
len = pch - pchs;
- if (len > 0 && (*(pch - 1) == '\r') )
- rlen ++;
+ if (len > 0 && (*(pch - 1) == '\r'))
+ rlen++;
StrBufSub(Target, Hdr->ReadBuf, 0, len - rlen);
StrBufCutLeft(Hdr->ReadBuf, len + 1);
return len - rlen;
}
}
- while (retval == 0) {
+ while (retval == 0) {
pch = NULL;
pchs = ChrPtr(Hdr->ReadBuf);
if (*pchs != '\0')
@@ -621,7 +599,7 @@ int ClientGetLine(ParsedHttpHdrs *Hdr, StrBuf *Target) {
}
if (retval == 0) {
sleeeeeeeeeep(1);
- ntries ++;
+ ntries++;
}
if (ntries > 10)
return 0;
@@ -629,25 +607,19 @@ int ClientGetLine(ParsedHttpHdrs *Hdr, StrBuf *Target) {
if ((retval > 0) && (pch != NULL)) {
rlen = 0;
len = pch - pchs;
- if (len > 0 && (*(pch - 1) == '\r') )
- rlen ++;
+ if (len > 0 && (*(pch - 1) == '\r'))
+ rlen++;
StrBufSub(Target, Hdr->ReadBuf, 0, len - rlen);
StrBufCutLeft(Hdr->ReadBuf, len + 1);
return len - rlen;
}
- else
+ else
return -1;
}
- else
+ else
#endif
- return StrBufTCP_read_buffered_line_fast(Target,
- Hdr->ReadBuf,
- &Hdr->Pos,
- &Hdr->http_sock,
- 5,
- 1,
- &Error);
+ return StrBufTCP_read_buffered_line_fast(Target, Hdr->ReadBuf, &Hdr->Pos, &Hdr->http_sock, 5, 1, &Error);
}
@@ -668,35 +640,32 @@ int webcit_tcp_server(const char *ip_addr, int port_number, int queue_len) {
int s, i, b;
int ip_version = 6;
-retry:
+ retry:
memset(&sin6, 0, sizeof(sin6));
memset(&sin4, 0, sizeof(sin4));
sin6.sin6_family = AF_INET6;
sin4.sin_family = AF_INET;
- if ( (ip_addr == NULL) /* any IPv6 */
- || (IsEmptyStr(ip_addr))
- || (!strcmp(ip_addr, "*"))
- ) {
+ if ((ip_addr == NULL) /* any IPv6 */
+ ||(IsEmptyStr(ip_addr))
+ || (!strcmp(ip_addr, "*"))
+ ) {
IsDefault = 1;
ip_version = 6;
sin6.sin6_addr = in6addr_any;
}
- else if (!strcmp(ip_addr, "0.0.0.0")) /* any IPv4 */
- {
+ else if (!strcmp(ip_addr, "0.0.0.0")) { /* any IPv4 */
ip_version = 4;
sin4.sin_addr.s_addr = INADDR_ANY;
}
- else if ((strchr(ip_addr, '.')) && (!strchr(ip_addr, ':'))) /* specific IPv4 */
- {
+ else if ((strchr(ip_addr, '.')) && (!strchr(ip_addr, ':'))) { /* specific IPv4 */
ip_version = 4;
if (inet_pton(AF_INET, ip_addr, &sin4.sin_addr) <= 0) {
syslog(LOG_WARNING, "Error binding to [%s] : %s\n", ip_addr, strerror(errno));
return (-WC_EXIT_BIND);
}
}
- else /* specific IPv6 */
- {
+ else { /* specific IPv6 */
ip_version = 6;
if (inet_pton(AF_INET6, ip_addr, &sin6.sin6_addr) <= 0) {
syslog(LOG_WARNING, "Error binding to [%s] : %s\n", ip_addr, strerror(errno));
@@ -713,10 +682,9 @@ retry:
p = getprotobyname("tcp");
- s = socket( ((ip_version == 6) ? PF_INET6 : PF_INET), SOCK_STREAM, (p->p_proto));
+ s = socket(((ip_version == 6) ? PF_INET6 : PF_INET), SOCK_STREAM, (p->p_proto));
if (s < 0) {
- if (IsDefault && (errno == EAFNOSUPPORT))
- {
+ if (IsDefault && (errno == EAFNOSUPPORT)) {
s = 0;
ip_addr = ipv4broadcast;
goto retry;
@@ -762,12 +730,12 @@ int webcit_uds_server(char *sockpath, int queue_len) {
int actual_queue_len;
actual_queue_len = queue_len;
- if (actual_queue_len < 5) actual_queue_len = 5;
+ if (actual_queue_len < 5)
+ actual_queue_len = 5;
i = unlink(sockpath);
if ((i != 0) && (errno != ENOENT)) {
- syslog(LOG_WARNING, "webcit: can't unlink %s: %s\n",
- sockpath, strerror(errno));
+ syslog(LOG_WARNING, "webcit: can't unlink %s: %s\n", sockpath, strerror(errno));
return (-WC_EXIT_BIND);
}
@@ -781,7 +749,7 @@ int webcit_uds_server(char *sockpath, int queue_len) {
return (-WC_EXIT_BIND);
}
- if (bind(s, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
+ if (bind(s, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
syslog(LOG_WARNING, "webcit: Can't bind: %s\n", strerror(errno));
close(s);
return (-WC_EXIT_BIND);
@@ -794,7 +762,7 @@ int webcit_uds_server(char *sockpath, int queue_len) {
}
chmod(sockpath, 0777);
- return(s);
+ return (s);
}
@@ -811,7 +779,7 @@ int webcit_uds_server(char *sockpath, int queue_len) {
* 0 Request timed out.
* -1 Connection is broken, or other error.
*/
-int client_read_to(ParsedHttpHdrs *Hdr, StrBuf *Target, int bytes, int timeout) {
+int client_read_to(ParsedHttpHdrs * Hdr, StrBuf * Target, int bytes, int timeout) {
const char *Error;
int retval = 0;
@@ -828,7 +796,7 @@ int client_read_to(ParsedHttpHdrs *Hdr, StrBuf *Target, int bytes, int timeout)
if (StrLength(Hdr->ReadBuf) > 0) {
bufremain = StrLength(Hdr->ReadBuf) - (Hdr->Pos - ChrPtr(Hdr->ReadBuf));
-
+
if (bytes < bufremain)
bufremain = bytes;
StrBufAppendBufPlain(Target, Hdr->Pos, bufremain, 0);
@@ -836,11 +804,10 @@ int client_read_to(ParsedHttpHdrs *Hdr, StrBuf *Target, int bytes, int timeout)
}
if (bytes > bufremain) {
- while ((StrLength(Hdr->ReadBuf) + StrLength(Target) < bytes + baselen) &&
- (retval >= 0))
+ while ((StrLength(Hdr->ReadBuf) + StrLength(Target) < bytes + baselen) && (retval >= 0))
retval = client_read_sslbuffer(Hdr->ReadBuf, timeout);
if (retval >= 0) {
- StrBufAppendBuf(Target, Hdr->ReadBuf, 0); /* todo: Buf > bytes? */
+ StrBufAppendBuf(Target, Hdr->ReadBuf, 0); /* todo: Buf > bytes? */
return 1;
}
else {
@@ -848,18 +815,11 @@ int client_read_to(ParsedHttpHdrs *Hdr, StrBuf *Target, int bytes, int timeout)
return -1;
}
}
- else
+ else
return 1;
}
#endif
- retval = StrBufReadBLOBBuffered(Target,
- Hdr->ReadBuf,
- &Hdr->Pos,
- &Hdr->http_sock,
- 1,
- bytes,
- O_TERM,
- &Error);
+ retval = StrBufReadBLOBBuffered(Target, Hdr->ReadBuf, &Hdr->Pos, &Hdr->http_sock, 1, bytes, O_TERM, &Error);
if (retval < 0) {
syslog(LOG_INFO, "client_read() failed: %s\n", Error);
wc_backtrace(LOG_DEBUG);
@@ -873,8 +833,7 @@ int client_read_to(ParsedHttpHdrs *Hdr, StrBuf *Target, int bytes, int timeout)
/*
* Begin buffering HTTP output so we can transmit it all in one write operation later.
*/
-void begin_burst(void)
-{
+void begin_burst(void) {
if (WC->WBuf == NULL) {
WC->WBuf = NewStrBufPlain(NULL, 32768);
}
@@ -884,16 +843,14 @@ void begin_burst(void)
/*
* Finish buffering HTTP output. [Compress using zlib and] output with a Content-Length: header.
*/
-long end_burst(void)
-{
- const char *ptr, *eptr;
- long count;
+long end_burst(void) {
+ const char *ptr, *eptr;
+ long count;
ssize_t res = 0;
- fd_set wset;
- int fdflags;
+ fd_set wset;
+ int fdflags;
- if (!DisableGzip && (WC->Hdr->HR.gzip_ok))
- {
+ if (!DisableGzip && (WC->Hdr->HR.gzip_ok)) {
if (CompressBuffer(WC->WBuf) > 0)
hprintf("Content-encoding: gzip\r\n");
else {
@@ -929,52 +886,46 @@ long end_burst(void)
fdflags = fcntl(WC->Hdr->http_sock, F_GETFL);
while ((ptr < eptr) && (WC->Hdr->http_sock != -1)) {
- if ((fdflags & O_NONBLOCK) == O_NONBLOCK) {
- FD_ZERO(&wset);
- FD_SET(WC->Hdr->http_sock, &wset);
- if (select(WC->Hdr->http_sock + 1, NULL, &wset, NULL, NULL) == -1) {
- syslog(LOG_DEBUG, "client_write: Socket select failed (%s)\n", strerror(errno));
- return -1;
- }
- }
-
- if ((WC->Hdr->http_sock == -1) ||
- (res = write(WC->Hdr->http_sock,
- ptr,
- count)) == -1) {
- syslog(LOG_DEBUG, "client_write: Socket write failed (%s)\n", strerror(errno));
- wc_backtrace(LOG_INFO);
- return res;
- }
- count -= res;
+ if ((fdflags & O_NONBLOCK) == O_NONBLOCK) {
+ FD_ZERO(&wset);
+ FD_SET(WC->Hdr->http_sock, &wset);
+ if (select(WC->Hdr->http_sock + 1, NULL, &wset, NULL, NULL) == -1) {
+ syslog(LOG_DEBUG, "client_write: Socket select failed (%s)\n", strerror(errno));
+ return -1;
+ }
+ }
+
+ if ((WC->Hdr->http_sock == -1) || (res = write(WC->Hdr->http_sock, ptr, count)) == -1) {
+ syslog(LOG_DEBUG, "client_write: Socket write failed (%s)\n", strerror(errno));
+ wc_backtrace(LOG_INFO);
+ return res;
+ }
+ count -= res;
ptr += res;
- }
+ }
ptr = ChrPtr(WC->WBuf);
count = StrLength(WC->WBuf);
eptr = ptr + count;
- while ((ptr < eptr) && (WC->Hdr->http_sock != -1)) {
- if ((fdflags & O_NONBLOCK) == O_NONBLOCK) {
- FD_ZERO(&wset);
- FD_SET(WC->Hdr->http_sock, &wset);
- if (select(WC->Hdr->http_sock + 1, NULL, &wset, NULL, NULL) == -1) {
- syslog(LOG_INFO, "client_write: Socket select failed (%s)\n", strerror(errno));
- return -1;
- }
- }
-
- if ((WC->Hdr->http_sock == -1) ||
- (res = write(WC->Hdr->http_sock,
- ptr,
- count)) == -1) {
- syslog(LOG_INFO, "client_write: Socket write failed (%s)\n", strerror(errno));
+ while ((ptr < eptr) && (WC->Hdr->http_sock != -1)) {
+ if ((fdflags & O_NONBLOCK) == O_NONBLOCK) {
+ FD_ZERO(&wset);
+ FD_SET(WC->Hdr->http_sock, &wset);
+ if (select(WC->Hdr->http_sock + 1, NULL, &wset, NULL, NULL) == -1) {
+ syslog(LOG_INFO, "client_write: Socket select failed (%s)\n", strerror(errno));
+ return -1;
+ }
+ }
+
+ if ((WC->Hdr->http_sock == -1) || (res = write(WC->Hdr->http_sock, ptr, count)) == -1) {
+ syslog(LOG_INFO, "client_write: Socket write failed (%s)\n", strerror(errno));
wc_backtrace(LOG_INFO);
- return res;
- }
- count -= res;
+ return res;
+ }
+ count -= res;
ptr += res;
- }
+ }
return StrLength(WC->WBuf);
}
@@ -984,8 +935,7 @@ long end_burst(void)
* lingering_close() a`la Apache. see
* http://httpd.apache.org/docs/2.0/misc/fin_wait_2.html for rationale
*/
-int lingering_close(int fd)
-{
+int lingering_close(int fd) {
char buf[SIZ];
int i;
fd_set set;
@@ -1018,44 +968,29 @@ int lingering_close(int fd)
return close(fd);
}
-void
-HttpNewModule_TCPSOCKETS
-(ParsedHttpHdrs *httpreq)
-{
+void HttpNewModule_TCPSOCKETS(ParsedHttpHdrs * httpreq) {
httpreq->ReadBuf = NewStrBufPlain(NULL, SIZ * 4);
}
-void
-HttpDetachModule_TCPSOCKETS
-(ParsedHttpHdrs *httpreq)
-{
+void HttpDetachModule_TCPSOCKETS(ParsedHttpHdrs * httpreq) {
FlushStrBuf(httpreq->ReadBuf);
ReAdjustEmptyBuf(httpreq->ReadBuf, 4 * SIZ, SIZ);
}
-void
-HttpDestroyModule_TCPSOCKETS
-(ParsedHttpHdrs *httpreq)
-{
+void HttpDestroyModule_TCPSOCKETS(ParsedHttpHdrs * httpreq) {
FreeStrBuf(&httpreq->ReadBuf);
}
-void
-SessionNewModule_TCPSOCKETS
-(wcsession *sess)
-{
+void SessionNewModule_TCPSOCKETS(wcsession * sess) {
sess->CLineBuf = NewStrBuf();
sess->MigrateReadLineBuf = NewStrBuf();
}
-void
-SessionDestroyModule_TCPSOCKETS
-(wcsession *sess)
-{
+void SessionDestroyModule_TCPSOCKETS(wcsession * sess) {
FreeStrBuf(&sess->CLineBuf);
FreeStrBuf(&sess->ReadBuf);
sess->connected = 0;
diff --git a/webcit/sockets.h b/webcit/sockets.h
index 340e71eb5..de2220bb2 100644
--- a/webcit/sockets.h
+++ b/webcit/sockets.h
@@ -1,3 +1,4 @@
+
/*
* Copyright (c) 1996-2013 by the citadel.org team
*
@@ -13,7 +14,7 @@
int connect_to_citadel(char *);
int connectsock(char *, char *);
int serv_getln(char *strbuf, int bufsize);
-int StrBuf_ServGetln(StrBuf *buf);
+int StrBuf_ServGetln(StrBuf * buf);
/*
* parse & check the server reply
@@ -27,7 +28,7 @@ int StrBuf_ServGetln(StrBuf *buf);
* returns the most significant digit of the server status
*/
-int GetServerStatusMsg(StrBuf *Line, long* FullState, int PutImportantMessage, int MajorOK);
+int GetServerStatusMsg(StrBuf * Line, long *FullState, int PutImportantMessage, int MajorOK);
/*
* to migrate old calls....
@@ -37,15 +38,15 @@ int GetServerStatusMsg(StrBuf *Line, long* FullState, int PutImportantMessage, i
int serv_puts(const char *string);
int serv_write(const char *buf, int nbytes);
-int serv_putbuf(const StrBuf *string);
-int serv_printf(const char *format,...)__attribute__((__format__(__printf__,1,2)));
-int serv_read_binary(StrBuf *Ret, size_t total_len, StrBuf *Buf);
-void serv_read_binary_to_http(StrBuf *MimeType, size_t total_len, int is_static, int detect_mime);
-int StrBuf_ServGetBLOB(StrBuf *buf, long BlobSize);
-int StrBuf_ServGetBLOBBuffered(StrBuf *buf, long BlobSize);
-int read_server_text(StrBuf *Buf, long *nLines);
+int serv_putbuf(const StrBuf * string);
+int serv_printf(const char *format, ...) __attribute__((__format__(__printf__, 1, 2)));
+int serv_read_binary(StrBuf * Ret, size_t total_len, StrBuf * Buf);
+void serv_read_binary_to_http(StrBuf * MimeType, size_t total_len, int is_static, int detect_mime);
+int StrBuf_ServGetBLOB(StrBuf * buf, long BlobSize);
+int StrBuf_ServGetBLOBBuffered(StrBuf * buf, long BlobSize);
+int read_server_text(StrBuf * Buf, long *nLines);
void text_to_server(char *ptr);
-void text_to_server_qp(const StrBuf *SendMeEncoded);
+void text_to_server_qp(const StrBuf * SendMeEncoded);
void server_to_text(void);
int lingering_close(int fd);
diff --git a/webcit/static.c b/webcit/static.c
index ccae7d297..cb8e496c0 100644
--- a/webcit/static.c
+++ b/webcit/static.c
@@ -17,11 +17,11 @@
#include "webserver.h"
unsigned char OnePixelGif[37] = {
- 0x47, 0x49, 0x46, 0x38, 0x37, 0x61, 0x01, 0x00,
- 0x01, 0x00, 0x80, 0x00, 0x00, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0x2c, 0x00, 0x00, 0x00, 0x00,
- 0x01, 0x00, 0x01, 0x00, 0x00, 0x02, 0x02, 0x44,
- 0x01, 0x00, 0x3b
+ 0x47, 0x49, 0x46, 0x38, 0x37, 0x61, 0x01, 0x00,
+ 0x01, 0x00, 0x80, 0x00, 0x00, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0x2c, 0x00, 0x00, 0x00, 0x00,
+ 0x01, 0x00, 0x01, 0x00, 0x00, 0x02, 0x02, 0x44,
+ 0x01, 0x00, 0x3b
};
@@ -30,7 +30,7 @@ void output_error_pic(const char *ErrMsg1, const char *ErrMsg2) {
hprintf("Content-Type: image/gif\r\n");
hprintf("x-webcit-errormessage: %s\r\n", ErrMsg2);
begin_burst();
- StrBufPlain(WC->WBuf, (const char *)OnePixelGif, sizeof(OnePixelGif));
+ StrBufPlain(WC->WBuf, (const char *) OnePixelGif, sizeof(OnePixelGif));
end_burst();
}
@@ -45,10 +45,10 @@ void output_static(char *prefix) {
int len;
const char *Err;
char what[SIZ];
- snprintf(what, sizeof what, "./%s/%s", prefix, (char *)ChrPtr(WC->Hdr->HR.ReqLine));
+ snprintf(what, sizeof what, "./%s/%s", prefix, (char *) ChrPtr(WC->Hdr->HR.ReqLine));
syslog(LOG_DEBUG, "output_static(%s)", what);
- len = strlen (what);
+ len = strlen(what);
content_type = GuessMimeByFilename(what, len);
fd = open(what, O_RDONLY);
if (fd <= 0) {
@@ -77,19 +77,21 @@ void output_static(char *prefix) {
wc_printf("Cannot fstat %s: %s\n", what, strerror(errno));
end_burst();
}
- if (fd > 0) close(fd);
+ if (fd > 0)
+ close(fd);
return;
}
bytes = statbuf.st_size;
if (StrBufReadBLOB(WC->WBuf, &fd, 1, bytes, &Err) < 0) {
- if (fd > 0) close(fd);
+ if (fd > 0)
+ close(fd);
syslog(LOG_INFO, "output_static('%s') -- FREAD FAILED (%s) --\n", what, strerror(errno));
- hprintf("HTTP/1.1 500 internal server error \r\n");
- hprintf("Content-Type: text/plain\r\n");
- end_burst();
- return;
+ hprintf("HTTP/1.1 500 internal server error \r\n");
+ hprintf("Content-Type: text/plain\r\n");
+ end_burst();
+ return;
}
close(fd);
@@ -107,61 +109,52 @@ void output_static(char *prefix) {
void robots_txt(void) {
output_headers(0, 0, 0, 0, 0, 0);
- hprintf("Content-type: text/plain\r\n"
- "Server: %s\r\n"
- "Connection: close\r\n",
- PACKAGE_STRING);
+ hprintf("Content-type: text/plain\r\n" "Server: %s\r\n" "Connection: close\r\n", PACKAGE_STRING);
begin_burst();
wc_printf("User-agent: *\r\n"
- "Disallow: /printmsg\r\n"
- "Disallow: /msgheaders\r\n"
- "Disallow: /groupdav\r\n"
- "Disallow: /do_template\r\n"
- "Disallow: /static\r\n"
- "Disallow: /display_page\r\n"
- "Disallow: /readnew\r\n"
- "Disallow: /display_enter\r\n"
- "Disallow: /skip\r\n"
- "Disallow: /ungoto\r\n"
- "Sitemap: %s/sitemap.xml\r\n"
- "\r\n"
- ,
- ChrPtr(site_prefix)
- );
+ "Disallow: /printmsg\r\n"
+ "Disallow: /msgheaders\r\n"
+ "Disallow: /groupdav\r\n"
+ "Disallow: /do_template\r\n"
+ "Disallow: /static\r\n"
+ "Disallow: /display_page\r\n"
+ "Disallow: /readnew\r\n"
+ "Disallow: /display_enter\r\n"
+ "Disallow: /skip\r\n" "Disallow: /ungoto\r\n" "Sitemap: %s/sitemap.xml\r\n" "\r\n", ChrPtr(site_prefix)
+ );
wDumpContent(0);
}
// These are the various prefixes we can use to fetch static pages.
-void output_static_root(void) { output_static("."); }
-void output_static_static(void) { output_static("static"); }
-void output_static_tinymce(void) { output_static("tiny_mce"); }
-void output_static_acme(void) { output_static(".well-known"); }
+void output_static_root(void) {
+ output_static(".");
+}
+void output_static_static(void) {
+ output_static("static");
+}
+void output_static_tinymce(void) {
+ output_static("tiny_mce");
+}
+void output_static_acme(void) {
+ output_static(".well-known");
+}
-void
-ServerStartModule_STATIC
-(void)
-{
+void ServerStartModule_STATIC(void) {
}
-void
-ServerShutdownModule_STATIC
-(void)
-{
+void ServerShutdownModule_STATIC(void) {
}
-void
-InitModule_STATIC
-(void)
-{
- WebcitAddUrlHandler(HKEY("robots.txt"), "", 0, robots_txt, ANONYMOUS|COOKIEUNNEEDED|ISSTATIC|LOGCHATTY);
- WebcitAddUrlHandler(HKEY("favicon.ico"), "", 0, output_static_root, ANONYMOUS|COOKIEUNNEEDED|ISSTATIC|LOGCHATTY);
- WebcitAddUrlHandler(HKEY("static"), "", 0, output_static_static, ANONYMOUS|COOKIEUNNEEDED|ISSTATIC|LOGCHATTY);
- WebcitAddUrlHandler(HKEY("tinymce"), "", 0, output_static_tinymce, ANONYMOUS|COOKIEUNNEEDED|ISSTATIC|LOGCHATTY);
- WebcitAddUrlHandler(HKEY("tiny_mce"), "", 0, output_static_tinymce, ANONYMOUS|COOKIEUNNEEDED|ISSTATIC|LOGCHATTY);
- WebcitAddUrlHandler(HKEY(".well-known"), "", 0, output_static_acme, ANONYMOUS|COOKIEUNNEEDED|ISSTATIC|LOGCHATTY);
+void InitModule_STATIC(void) {
+ WebcitAddUrlHandler(HKEY("robots.txt"), "", 0, robots_txt, ANONYMOUS | COOKIEUNNEEDED | ISSTATIC | LOGCHATTY);
+ WebcitAddUrlHandler(HKEY("favicon.ico"), "", 0, output_static_root, ANONYMOUS | COOKIEUNNEEDED | ISSTATIC | LOGCHATTY);
+ WebcitAddUrlHandler(HKEY("static"), "", 0, output_static_static, ANONYMOUS | COOKIEUNNEEDED | ISSTATIC | LOGCHATTY);
+ WebcitAddUrlHandler(HKEY("tinymce"), "", 0, output_static_tinymce, ANONYMOUS | COOKIEUNNEEDED | ISSTATIC | LOGCHATTY);
+ WebcitAddUrlHandler(HKEY("tiny_mce"), "", 0, output_static_tinymce, ANONYMOUS | COOKIEUNNEEDED | ISSTATIC | LOGCHATTY);
+ WebcitAddUrlHandler(HKEY(".well-known"), "", 0, output_static_acme, ANONYMOUS | COOKIEUNNEEDED | ISSTATIC | LOGCHATTY);
}
diff --git a/webcit/subst.c b/webcit/subst.c
index 0cd7615f2..0798d3b71 100644
--- a/webcit/subst.c
+++ b/webcit/subst.c
@@ -17,7 +17,7 @@
#include "webcit.h"
#include "webserver.h"
-extern char *static_dirs[PATH_MAX]; /* Disk representation */
+extern char *static_dirs[PATH_MAX]; /* Disk representation */
HashList *TemplateCache;
HashList *LocalTemplateCache;
@@ -34,7 +34,7 @@ int dbg_backtrace_template_errors = 0;
WCTemplputParams NoCtx;
StrBuf *I18nDump = NULL;
-const char EmptyStr[]="";
+const char EmptyStr[] = "";
#define SV_GETTEXT 1
#define SV_CONDITIONAL 2
@@ -50,11 +50,11 @@ const char EmptyStr[]="";
*/
typedef struct _wcsubst {
ContextFilter Filter;
- 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 */
- WCHandlerFunc wcs_function; /* funcion hook ???*/
+ 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 */
+ WCHandlerFunc wcs_function; /* funcion hook ??? */
} wcsubst;
@@ -71,15 +71,15 @@ typedef struct _HashHandler {
ContextFilter Filter;
WCPreevalFunc PreEvalFunc;
WCHandlerFunc HandlerFunc;
-}HashHandler;
+} HashHandler;
typedef enum _estate {
eNext,
eSkipTilEnd
} TemplState;
-void *load_template(StrBuf *Target, WCTemplate *NewTemplate);
-int EvaluateConditional(StrBuf *Target, int Neg, int state, WCTemplputParams **TPP);
+void *load_template(StrBuf * Target, WCTemplate * NewTemplate);
+int EvaluateConditional(StrBuf * Target, int Neg, int state, WCTemplputParams ** TPP);
@@ -91,7 +91,7 @@ typedef struct _SortStruct {
CompareFunc GroupChange;
CtxType ContextType;
-}SortStruct;
+} SortStruct;
HashList *CtxList = NULL;
@@ -104,24 +104,21 @@ CtxType CTX_LONGVECTOR = CTX_NONE;
CtxType CTX_ITERATE = CTX_NONE;
CtxType CTX_TAB = CTX_NONE;
-void HFreeContextType(void *pCtx)
-{
+void HFreeContextType(void *pCtx) {
CtxTypeStruct *FreeStruct = (CtxTypeStruct *) pCtx;
FreeStrBuf(&FreeStruct->Name);
free(FreeStruct);
}
-void PutContextType(const char *name, long len, CtxType TheCtx)
-{
+void PutContextType(const char *name, long len, CtxType TheCtx) {
CtxTypeStruct *NewStruct;
- NewStruct = (CtxTypeStruct*) malloc(sizeof(CtxTypeStruct));
+ NewStruct = (CtxTypeStruct *) malloc(sizeof(CtxTypeStruct));
NewStruct->Name = NewStrBufPlain(name, len);
NewStruct->Type = TheCtx;
Put(CtxList, IKEY(NewStruct->Type), NewStruct, HFreeContextType);
}
-void RegisterContextType(const char *name, long len, CtxType *TheCtx)
-{
+void RegisterContextType(const char *name, long len, CtxType * TheCtx) {
if (*TheCtx != CTX_NONE)
return;
@@ -129,8 +126,7 @@ void RegisterContextType(const char *name, long len, CtxType *TheCtx)
PutContextType(name, len, *TheCtx);
}
-CtxTypeStruct *GetContextType(CtxType Type)
-{
+CtxTypeStruct *GetContextType(CtxType Type) {
void *pv = NULL;
GetHash(CtxList, IKEY(Type), &pv);
return pv;
@@ -138,27 +134,21 @@ CtxTypeStruct *GetContextType(CtxType Type)
const char *UnknownContext = "CTX_UNKNOWN";
-const char *ContextName(CtxType ContextType)
-{
+const char *ContextName(CtxType ContextType) {
CtxTypeStruct *pCtx;
pCtx = GetContextType(ContextType);
- if (pCtx != NULL)
+ if (pCtx != NULL)
return ChrPtr(pCtx->Name);
else
return UnknownContext;
}
-void StackDynamicContext(WCTemplputParams *Super,
- WCTemplputParams *Sub,
+void StackDynamicContext(WCTemplputParams * Super,
+ WCTemplputParams * Sub,
void *Context,
- CtxType ContextType,
- int nArgs,
- WCTemplateToken *Tokens,
- WCConditionalFunc ExitCtx,
- long ExitCTXID)
-{
+ CtxType ContextType, int nArgs, WCTemplateToken * Tokens, WCConditionalFunc ExitCtx, long ExitCTXID) {
memset(Sub, 0, sizeof(WCTemplputParams));
if (Super != NULL) {
@@ -168,7 +158,7 @@ void StackDynamicContext(WCTemplputParams *Super,
if (Sub->Sub != NULL)
Sub->Sub->Super = Sub;
Sub->Super = Super;
-
+
Sub->Context = Context;
Sub->Filter.ContextType = ContextType;
Sub->nArgs = nArgs;
@@ -177,27 +167,22 @@ void StackDynamicContext(WCTemplputParams *Super,
Sub->ExitCTXID = ExitCTXID;
}
-void UnStackContext(WCTemplputParams *Sub)
-{
- if (Sub->Super != NULL)
- {
+void UnStackContext(WCTemplputParams * Sub) {
+ if (Sub->Super != NULL) {
Sub->Super->Sub = Sub->Sub;
}
- if (Sub->Sub != NULL)
- {
+ if (Sub->Sub != NULL) {
Sub->Sub->Super = Sub->Super;
}
}
-void UnStackDynamicContext(StrBuf *Target, WCTemplputParams **TPP)
-{
+void UnStackDynamicContext(StrBuf * Target, WCTemplputParams ** TPP) {
WCTemplputParams *TP = *TPP;
WCTemplputParams *Super = TP->Super;
TP->ExitCtx(Target, TP);
*TPP = Super;
}
-void *GetContextPayload(WCTemplputParams *TP, CtxType ContextType)
-{
+void *GetContextPayload(WCTemplputParams * TP, CtxType ContextType) {
WCTemplputParams *whichTP = TP;
if (ContextType == CTX_NONE)
@@ -206,96 +191,73 @@ void *GetContextPayload(WCTemplputParams *TP, CtxType ContextType)
while ((whichTP != NULL) && (whichTP->Filter.ContextType != ContextType))
whichTP = whichTP->Super;
- return whichTP->Context;
+ return whichTP->Context;
}
-void DestroySortStruct(void *vSort)
-{
- SortStruct *Sort = (SortStruct*) vSort;
+void DestroySortStruct(void *vSort) {
+ SortStruct *Sort = (SortStruct *) vSort;
FreeStrBuf(&Sort->Name);
FreeStrBuf(&Sort->PrefPrepend);
- free (Sort);
+ free(Sort);
}
-void LogTemplateError (StrBuf *Target, const char *Type, int ErrorPos, WCTemplputParams *TP, const char *Format, ...)
-{
+void LogTemplateError(StrBuf * Target, const char *Type, int ErrorPos, WCTemplputParams * TP, const char *Format, ...) {
StrBuf *Error;
StrBuf *Info;
- va_list arg_ptr;
+ va_list arg_ptr;
const char *Err = NULL;
Info = NewStrBuf();
Error = NewStrBuf();
- va_start(arg_ptr, Format);
+ va_start(arg_ptr, Format);
StrBufVAppendPrintf(Error, Format, arg_ptr);
va_end(arg_ptr);
switch (ErrorPos) {
- case ERR_NAME: /* the main token name... */
- Err = (TP->Tokens!= NULL)? TP->Tokens->pName:"";
+ case ERR_NAME: /* the main token name... */
+ Err = (TP->Tokens != NULL) ? TP->Tokens->pName : "";
break;
default:
- Err = ((TP->Tokens!= NULL) &&
- (TP->Tokens->nParameters > ErrorPos - 1))?
- TP->Tokens->Params[ErrorPos - 1]->Start : "";
+ Err = ((TP->Tokens != NULL) &&
+ (TP->Tokens->nParameters > ErrorPos - 1)) ? TP->Tokens->Params[ErrorPos - 1]->Start : "";
break;
}
- if (TP->Tokens != NULL)
- {
- syslog(LOG_WARNING, "%s [%s] (in '%s' line %ld); %s; [%s]\n",
- Type,
- Err,
- ChrPtr(TP->Tokens->FileName),
- TP->Tokens->Line,
- ChrPtr(Error),
- ChrPtr(TP->Tokens->FlatToken));
- }
- else
- {
- syslog(LOG_WARNING, "%s: %s;\n",
- Type,
- ChrPtr(Error));
+ if (TP->Tokens != NULL) {
+ syslog(LOG_WARNING, "%s [%s] (in '%s' line %ld); %s; [%s]\n",
+ Type, Err, ChrPtr(TP->Tokens->FileName), TP->Tokens->Line, ChrPtr(Error), ChrPtr(TP->Tokens->FlatToken));
+ }
+ else {
+ syslog(LOG_WARNING, "%s: %s;\n", Type, ChrPtr(Error));
}
if (WC == NULL) {
FreeStrBuf(&Info);
FreeStrBuf(&Error);
- return;
+ return;
}
- if (WC->WFBuf == NULL) WC->WFBuf = NewStrBuf();
- if (TP->Tokens != NULL)
- {
+ if (WC->WFBuf == NULL)
+ WC->WFBuf = NewStrBuf();
+ if (TP->Tokens != NULL) {
/* deprecated:
- StrBufAppendPrintf(
- Target,
- "\n%s [%s] (in '%s' line %ld); %s\n[%s]\n \n",
- Type,
- Err,
- ChrPtr(TP->Tokens->FileName),
- TP->Tokens->Line,
- ChrPtr(Error),
- ChrPtr(TP->Tokens->FlatToken));
- */
- StrBufPrintf(Info, "%s [%s] %s; [%s]",
- Type,
- Err,
- ChrPtr(Error),
- ChrPtr(TP->Tokens->FlatToken));
-
-
- SerializeJson(WC->WFBuf, WildFireException(SKEY(TP->Tokens->FileName),
- TP->Tokens->Line,
- Info,
- 1), 1);
+ StrBufAppendPrintf(
+ Target,
+ "\n%s [%s] (in '%s' line %ld); %s\n[%s]\n \n",
+ Type,
+ Err,
+ ChrPtr(TP->Tokens->FileName),
+ TP->Tokens->Line,
+ ChrPtr(Error),
+ ChrPtr(TP->Tokens->FlatToken));
+ */
+ StrBufPrintf(Info, "%s [%s] %s; [%s]", Type, Err, ChrPtr(Error), ChrPtr(TP->Tokens->FlatToken));
+
+
+ SerializeJson(WC->WFBuf, WildFireException(SKEY(TP->Tokens->FileName), TP->Tokens->Line, Info, 1), 1);
}
else {
- StrBufPrintf(Info, "%s [%s] %s; [%s]",
- Type,
- Err,
- ChrPtr(Error),
- ChrPtr(TP->Tokens->FlatToken));
+ StrBufPrintf(Info, "%s [%s] %s; [%s]", Type, Err, ChrPtr(Error), ChrPtr(TP->Tokens->FlatToken));
SerializeJson(WC->WFBuf, WildFireException(HKEY(__FILE__), __LINE__, Info, 1), 1);
}
FreeStrBuf(&Info);
@@ -303,86 +265,72 @@ void LogTemplateError (StrBuf *Target, const char *Type, int ErrorPos, WCTemplpu
}
-void LogError (StrBuf *Target, const char *Type, const char *Format, ...) {
+void LogError(StrBuf * Target, const char *Type, const char *Format, ...) {
StrBuf *Error;
StrBuf *Info;
- va_list arg_ptr;
+ va_list arg_ptr;
Info = NewStrBuf();
Error = NewStrBuf();
- va_start(arg_ptr, Format);
+ va_start(arg_ptr, Format);
StrBufVAppendPrintf(Error, Format, arg_ptr);
va_end(arg_ptr);
syslog(LOG_WARNING, "%s", ChrPtr(Error));
- if (WC->WFBuf == NULL) WC->WFBuf = NewStrBuf();
+ if (WC->WFBuf == NULL)
+ WC->WFBuf = NewStrBuf();
- SerializeJson(WC->WFBuf, WildFireException(Type, strlen(Type),
- 0,
- Info,
- 1), 1);
+ SerializeJson(WC->WFBuf, WildFireException(Type, strlen(Type), 0, Info, 1), 1);
FreeStrBuf(&Info);
FreeStrBuf(&Error);
}
-void RegisterNS(const char *NSName,
- long len,
- int nMinArgs,
- int nMaxArgs,
- WCHandlerFunc HandlerFunc,
- WCPreevalFunc PreevalFunc,
- CtxType ContextRequired)
-{
+void RegisterNS(const char *NSName,
+ long len,
+ int nMinArgs, int nMaxArgs, WCHandlerFunc HandlerFunc, WCPreevalFunc PreevalFunc, CtxType ContextRequired) {
HashHandler *NewHandler;
-
- NewHandler = (HashHandler*) malloc(sizeof(HashHandler));
+
+ NewHandler = (HashHandler *) malloc(sizeof(HashHandler));
memset(NewHandler, 0, sizeof(HashHandler));
NewHandler->Filter.nMinArgs = nMinArgs;
NewHandler->Filter.nMaxArgs = nMaxArgs;
NewHandler->Filter.ContextType = ContextRequired;
NewHandler->PreEvalFunc = PreevalFunc;
- NewHandler->HandlerFunc = HandlerFunc;
+ NewHandler->HandlerFunc = HandlerFunc;
Put(GlobalNS, NSName, len, NewHandler, NULL);
}
-int CheckContext(StrBuf *Target, ContextFilter *Need, WCTemplputParams *TP, const char *ErrType)
-{
+int CheckContext(StrBuf * Target, ContextFilter * Need, WCTemplputParams * TP, const char *ErrType) {
WCTemplputParams *TPP = TP;
-
- if ((Need != NULL) &&
- (Need->ContextType != CTX_NONE) &&
- (Need->ContextType != TPP->Filter.ContextType)) {
-
- while ((TPP != NULL) &&
- (Need->ContextType != TPP->Filter.ContextType))
- {
+
+ if ((Need != NULL) && (Need->ContextType != CTX_NONE) && (Need->ContextType != TPP->Filter.ContextType)) {
+
+ while ((TPP != NULL) && (Need->ContextType != TPP->Filter.ContextType)) {
TPP = TPP->Super;
}
if (TPP != NULL)
return 1;
- LogTemplateError(
- Target, ErrType, ERR_NAME, TP,
- " WARNING: requires Context: [%s], have [%s]!",
- ContextName(Need->ContextType),
- ContextName(TP->Filter.ContextType));
+ LogTemplateError(Target, ErrType, ERR_NAME, TP,
+ " WARNING: requires Context: [%s], have [%s]!",
+ ContextName(Need->ContextType), ContextName(TP->Filter.ContextType));
return 0;
}
return 1;
}
-void FreeToken(WCTemplateToken **Token) {
- int i;
+void FreeToken(WCTemplateToken ** Token) {
+ int i;
FreeStrBuf(&(*Token)->FlatToken);
- if ((*Token)->HaveParameters)
+ if ((*Token)->HaveParameters)
for (i = 0; i < (*Token)->nParameters; i++)
free((*Token)->Params[i]);
free(*Token);
@@ -392,10 +340,10 @@ void FreeToken(WCTemplateToken **Token) {
void FreeWCTemplate(void *vFreeMe) {
int i;
- WCTemplate *FreeMe = (WCTemplate*)vFreeMe;
+ WCTemplate *FreeMe = (WCTemplate *) vFreeMe;
if (FreeMe->TokenSpace > 0) {
- for (i = 0; i < FreeMe->nTokensUsed; i ++) {
+ for (i = 0; i < FreeMe->nTokensUsed; i++) {
FreeToken(&FreeMe->Tokens[i]);
}
free(FreeMe->Tokens);
@@ -406,12 +354,7 @@ void FreeWCTemplate(void *vFreeMe) {
free(FreeMe);
}
-int HaveTemplateTokenString(StrBuf *Target,
- WCTemplputParams *TP,
- int N,
- const char **Value,
- long *len)
-{
+int HaveTemplateTokenString(StrBuf * Target, WCTemplputParams * TP, int N, const char **Value, long *len) {
if (N >= TP->Tokens->nParameters) {
return 0;
}
@@ -432,13 +375,11 @@ int HaveTemplateTokenString(StrBuf *Target,
}
}
-void GetTemplateTokenString(StrBuf *Target, WCTemplputParams *TP, int N, const char **Value, long *len) {
+void GetTemplateTokenString(StrBuf * Target, WCTemplputParams * TP, int N, const char **Value, long *len) {
StrBuf *Buf;
if (N >= TP->Tokens->nParameters) {
- LogTemplateError(Target,
- "TokenParameter", N, TP,
- "invalid token %d. this shouldn't have come till here.\n", N);
+ LogTemplateError(Target, "TokenParameter", N, TP, "invalid token %d. this shouldn't have come till here.\n", N);
*Value = "";
*len = 0;
return;
@@ -453,21 +394,21 @@ void GetTemplateTokenString(StrBuf *Target, WCTemplputParams *TP, int N, const c
break;
case TYPE_BSTR:
if (TP->Tokens->Params[N]->len == 0) {
- LogTemplateError(Target,
- "TokenParameter", N, TP,
+ LogTemplateError(Target,
+ "TokenParameter", N, TP,
"Requesting parameter %d; of type BSTR, empty lookup string not admitted.", N);
*len = 0;
*Value = EmptyStr;
break;
}
- Buf = (StrBuf*) SBstr(TKEY(N));
+ Buf = (StrBuf *) SBstr(TKEY(N));
*Value = ChrPtr(Buf);
*len = StrLength(Buf);
break;
case TYPE_PREFSTR:
if (TP->Tokens->Params[N]->len == 0) {
- LogTemplateError(Target,
- "TokenParameter", N, TP,
+ LogTemplateError(Target,
+ "TokenParameter", N, TP,
"Requesting parameter %d; of type PREFSTR, empty lookup string not admitted.", N);
*len = 0;
*Value = EmptyStr;
@@ -479,8 +420,8 @@ void GetTemplateTokenString(StrBuf *Target, WCTemplputParams *TP, int N, const c
break;
case TYPE_ROOMPREFSTR:
if (TP->Tokens->Params[N]->len == 0) {
- LogTemplateError(Target,
- "TokenParameter", N, TP,
+ LogTemplateError(Target,
+ "TokenParameter", N, TP,
"Requesting parameter %d; of type PREFSTR, empty lookup string not admitted.", N);
*len = 0;
*Value = EmptyStr;
@@ -491,14 +432,10 @@ void GetTemplateTokenString(StrBuf *Target, WCTemplputParams *TP, int N, const c
*len = StrLength(Buf);
break;
case TYPE_LONG:
- LogTemplateError(Target,
- "TokenParameter", N, TP,
- "Requesting parameter %d; of type LONG, want string.", N);
+ LogTemplateError(Target, "TokenParameter", N, TP, "Requesting parameter %d; of type LONG, want string.", N);
break;
case TYPE_PREFINT:
- LogTemplateError(Target,
- "TokenParameter", N, TP,
- "Requesting parameter %d; of type PREFINT, want string.", N);
+ LogTemplateError(Target, "TokenParameter", N, TP, "Requesting parameter %d; of type PREFINT, want string.", N);
break;
case TYPE_GETTEXT:
*Value = _(TP->Tokens->Params[N]->Start);
@@ -506,8 +443,8 @@ void GetTemplateTokenString(StrBuf *Target, WCTemplputParams *TP, int N, const c
break;
case TYPE_SUBTEMPLATE:
if (TP->Tokens->Params[N]->len == 0) {
- LogTemplateError(Target,
- "TokenParameter", N, TP,
+ LogTemplateError(Target,
+ "TokenParameter", N, TP,
"Requesting parameter %d; of type SUBTEMPLATE, empty lookup string not admitted.", N);
*len = 0;
*Value = EmptyStr;
@@ -524,20 +461,16 @@ void GetTemplateTokenString(StrBuf *Target, WCTemplputParams *TP, int N, const c
break;
default:
- LogTemplateError(Target,
- "TokenParameter", N, TP,
- "unknown param type %d; [%d]", N, TP->Tokens->Params[N]->Type);
+ LogTemplateError(Target, "TokenParameter", N, TP, "unknown param type %d; [%d]", N, TP->Tokens->Params[N]->Type);
break;
}
}
-long GetTemplateTokenNumber(StrBuf *Target, WCTemplputParams *TP, int N, long dflt) {
+long GetTemplateTokenNumber(StrBuf * Target, WCTemplputParams * TP, int N, long dflt) {
long Ret;
if (N >= TP->Tokens->nParameters) {
- LogTemplateError(Target,
- "TokenParameter", N, TP,
- "invalid token %d. this shouldn't have come till here.\n", N);
- wc_backtrace(LOG_DEBUG);
+ LogTemplateError(Target, "TokenParameter", N, TP, "invalid token %d. this shouldn't have come till here.\n", N);
+ wc_backtrace(LOG_DEBUG);
return 0;
}
@@ -548,20 +481,18 @@ long GetTemplateTokenNumber(StrBuf *Target, WCTemplputParams *TP, int N, long df
break;
case TYPE_BSTR:
if (TP->Tokens->Params[N]->len == 0) {
- LogTemplateError(Target,
- "TokenParameter", N, TP,
+ LogTemplateError(Target,
+ "TokenParameter", N, TP,
"Requesting parameter %d; of type BSTR, empty lookup string not admitted.", N);
return 0;
}
- return LBstr(TKEY(N));
+ return LBstr(TKEY(N));
break;
case TYPE_PREFSTR:
- LogTemplateError(Target,
- "TokenParameter", N, TP,
- "requesting a prefstring in param %d want a number", N);
+ LogTemplateError(Target, "TokenParameter", N, TP, "requesting a prefstring in param %d want a number", N);
if (TP->Tokens->Params[N]->len == 0) {
- LogTemplateError(Target,
- "TokenParameter", N, TP,
+ LogTemplateError(Target,
+ "TokenParameter", N, TP,
"Requesting parameter %d; of type PREFSTR, empty lookup string not admitted.", N);
return 0;
}
@@ -569,12 +500,10 @@ long GetTemplateTokenNumber(StrBuf *Target, WCTemplputParams *TP, int N, long df
return Ret;
return 0;
case TYPE_ROOMPREFSTR:
- LogTemplateError(Target,
- "TokenParameter", N, TP,
- "requesting a prefstring in param %d want a number", N);
+ LogTemplateError(Target, "TokenParameter", N, TP, "requesting a prefstring in param %d want a number", N);
if (TP->Tokens->Params[N]->len == 0) {
- LogTemplateError(Target,
- "TokenParameter", N, TP,
+ LogTemplateError(Target,
+ "TokenParameter", N, TP,
"Requesting parameter %d; of type PREFSTR, empty lookup string not admitted.", N);
return 0;
}
@@ -586,28 +515,23 @@ long GetTemplateTokenNumber(StrBuf *Target, WCTemplputParams *TP, int N, long df
return TP->Tokens->Params[N]->lvalue;
case TYPE_PREFINT:
if (TP->Tokens->Params[N]->len == 0) {
- LogTemplateError(Target,
- "TokenParameter", N, TP,
+ LogTemplateError(Target,
+ "TokenParameter", N, TP,
"Requesting parameter %d; of type PREFINT, empty lookup string not admitted.", N);
return 0;
}
if (get_PREF_LONG(TKEY(N), &Ret, dflt))
return Ret;
- return 0;
+ return 0;
case TYPE_GETTEXT:
- LogTemplateError(Target,
- "TokenParameter", N, TP,
- "requesting a I18N string in param %d; want a number", N);
+ LogTemplateError(Target, "TokenParameter", N, TP, "requesting a I18N string in param %d; want a number", N);
return 0;
case TYPE_SUBTEMPLATE:
- LogTemplateError(Target,
- "TokenParameter", N, TP,
- "requesting a subtemplate in param %d; not supported for numbers", N);
+ LogTemplateError(Target,
+ "TokenParameter", N, TP, "requesting a subtemplate in param %d; not supported for numbers", N);
return 0;
default:
- LogTemplateError(Target,
- "TokenParameter", N, TP,
- "unknown param type %d; [%d]", N, TP->Tokens->Params[N]->Type);
+ LogTemplateError(Target, "TokenParameter", N, TP, "unknown param type %d; [%d]", N, TP->Tokens->Params[N]->Type);
return 0;
}
}
@@ -618,23 +542,18 @@ long GetTemplateTokenNumber(StrBuf *Target, WCTemplputParams *TP, int N, long df
* Source = the string we should put into the template
* FormatTypeIndex = where should we look for escape types if?
*/
-void StrBufAppendTemplate(StrBuf *Target,
- WCTemplputParams *TP,
- const StrBuf *Source, int FormatTypeIndex)
-{
+void StrBufAppendTemplate(StrBuf * Target, WCTemplputParams * TP, const StrBuf * Source, int FormatTypeIndex) {
const char *pFmt = NULL;
char EscapeAs = ' ';
if ((FormatTypeIndex < TP->Tokens->nParameters) &&
(TP->Tokens->Params[FormatTypeIndex] != NULL) &&
- (TP->Tokens->Params[FormatTypeIndex]->Type == TYPE_STR) &&
- (TP->Tokens->Params[FormatTypeIndex]->len >= 1)) {
+ (TP->Tokens->Params[FormatTypeIndex]->Type == TYPE_STR) && (TP->Tokens->Params[FormatTypeIndex]->len >= 1)) {
pFmt = TP->Tokens->Params[FormatTypeIndex]->Start;
EscapeAs = *pFmt;
}
- switch(EscapeAs)
- {
+ switch (EscapeAs) {
case 'H':
StrEscAppend(Target, Source, NULL, 0, 2);
break;
@@ -651,9 +570,12 @@ void StrBufAppendTemplate(StrBuf *Target,
StrBufUrlescAppend(Target, Source, NULL);
break;
case 'F':
- if (pFmt != NULL) pFmt++;
- else pFmt = "JUSTIFY";
- if (*pFmt == '\0') pFmt = "JUSTIFY";
+ if (pFmt != NULL)
+ pFmt++;
+ else
+ pFmt = "JUSTIFY";
+ if (*pFmt == '\0')
+ pFmt = "JUSTIFY";
FmOut(Target, pFmt, Source);
break;
default:
@@ -666,22 +588,17 @@ void StrBufAppendTemplate(StrBuf *Target,
* Source = the string we should put into the template
* FormatTypeIndex = where should we look for escape types if?
*/
-void StrBufAppendTemplateStr(StrBuf *Target,
- WCTemplputParams *TP,
- const char *Source, int FormatTypeIndex)
-{
+void StrBufAppendTemplateStr(StrBuf * Target, WCTemplputParams * TP, const char *Source, int FormatTypeIndex) {
const char *pFmt = NULL;
char EscapeAs = ' ';
if ((FormatTypeIndex < TP->Tokens->nParameters) &&
- (TP->Tokens->Params[FormatTypeIndex]->Type == TYPE_STR) &&
- (TP->Tokens->Params[FormatTypeIndex]->len >= 1)) {
+ (TP->Tokens->Params[FormatTypeIndex]->Type == TYPE_STR) && (TP->Tokens->Params[FormatTypeIndex]->len >= 1)) {
pFmt = TP->Tokens->Params[FormatTypeIndex]->Start;
EscapeAs = *pFmt;
}
- switch(EscapeAs)
- {
+ switch (EscapeAs) {
case 'H':
StrEscAppend(Target, NULL, Source, 0, 2);
break;
@@ -690,13 +607,14 @@ void StrBufAppendTemplateStr(StrBuf *Target,
break;
case 'J':
StrECMAEscAppend(Target, NULL, Source);
- break;
+ break;
case 'K':
StrHtmlEcmaEscAppend(Target, NULL, Source, 0, 0);
- break;
+ break;
case 'U':
StrBufUrlescAppend(Target, NULL, Source);
break;
+
/*
case 'F':
if (pFmt != NULL) pFmt++;
@@ -711,27 +629,21 @@ void StrBufAppendTemplateStr(StrBuf *Target,
}
-void PutNewToken(WCTemplate *Template, WCTemplateToken *NewToken)
-{
+void PutNewToken(WCTemplate * Template, WCTemplateToken * NewToken) {
if (Template->nTokensUsed + 1 >= Template->TokenSpace) {
if (Template->TokenSpace <= 0) {
- Template->Tokens = (WCTemplateToken**)malloc(
- sizeof(WCTemplateToken*) * 10);
- memset(Template->Tokens, 0, sizeof(WCTemplateToken*) * 10);
+ Template->Tokens = (WCTemplateToken **) malloc(sizeof(WCTemplateToken *) * 10);
+ memset(Template->Tokens, 0, sizeof(WCTemplateToken *) * 10);
Template->TokenSpace = 10;
}
else {
WCTemplateToken **NewTokens;
- NewTokens= (WCTemplateToken**) malloc(
- sizeof(WCTemplateToken*) * Template->TokenSpace * 2);
+ NewTokens = (WCTemplateToken **) malloc(sizeof(WCTemplateToken *) * Template->TokenSpace * 2);
- memset(NewTokens,
- 0, sizeof(WCTemplateToken*) * Template->TokenSpace * 2);
+ memset(NewTokens, 0, sizeof(WCTemplateToken *) * Template->TokenSpace * 2);
- memcpy(NewTokens,
- Template->Tokens,
- sizeof(WCTemplateToken*) * Template->nTokensUsed);
+ memcpy(NewTokens, Template->Tokens, sizeof(WCTemplateToken *) * Template->nTokensUsed);
free(Template->Tokens);
Template->TokenSpace *= 2;
@@ -741,14 +653,9 @@ void PutNewToken(WCTemplate *Template, WCTemplateToken *NewToken)
Template->Tokens[(Template->nTokensUsed)++] = NewToken;
}
-int GetNextParameter(StrBuf *Buf,
- const char **pCh,
- const char *pe,
- WCTemplateToken *Tokens,
- WCTemplate *pTmpl,
- WCTemplputParams *TP,
- TemplateParam **pParm)
-{
+int GetNextParameter(StrBuf * Buf,
+ const char **pCh,
+ const char *pe, WCTemplateToken * Tokens, WCTemplate * pTmpl, WCTemplputParams * TP, TemplateParam ** pParm) {
const char *pch = *pCh;
const char *pchs, *pche;
TemplateParam *Parm;
@@ -760,60 +667,58 @@ int GetNextParameter(StrBuf *Buf,
Parm->Type = TYPE_STR;
/* Skip leading whitespaces */
- while ((*pch == ' ' )||
- (*pch == '\t')||
- (*pch == '\r')||
- (*pch == '\n')) pch ++;
+ while ((*pch == ' ') || (*pch == '\t') || (*pch == '\r') || (*pch == '\n'))
+ pch++;
if (*pch == ':') {
Parm->Type = TYPE_PREFSTR;
- pch ++;
+ pch++;
if (*pch == '(') {
- pch ++;
+ pch++;
ParamBrace = 1;
}
}
else if (*pch == '.') {
Parm->Type = TYPE_ROOMPREFSTR;
- pch ++;
+ pch++;
if (*pch == '(') {
- pch ++;
+ pch++;
ParamBrace = 1;
}
}
else if (*pch == ';') {
Parm->Type = TYPE_PREFINT;
- pch ++;
+ pch++;
if (*pch == '(') {
- pch ++;
+ pch++;
ParamBrace = 1;
}
}
else if (*pch == '#') {
Parm->Type = TYPE_INTDEFINE;
- pch ++;
+ pch++;
}
else if (*pch == '_') {
Parm->Type = TYPE_GETTEXT;
- pch ++;
+ pch++;
if (*pch == '(') {
- pch ++;
+ pch++;
ParamBrace = 1;
}
}
else if (*pch == 'B') {
Parm->Type = TYPE_BSTR;
- pch ++;
+ pch++;
if (*pch == '(') {
- pch ++;
+ pch++;
ParamBrace = 1;
}
}
else if (*pch == '=') {
Parm->Type = TYPE_SUBTEMPLATE;
- pch ++;
+ pch++;
if (*pch == '(') {
- pch ++;
+ pch++;
ParamBrace = 1;
}
}
@@ -824,40 +729,34 @@ int GetNextParameter(StrBuf *Buf,
else if (*pch == '\'')
quote = '\'';
if (quote != '\0') {
- pch ++;
+ pch++;
pchs = pch;
- while (pch <= pe &&
- ((*pch != quote) ||
- ( (pch > pchs) && (*(pch - 1) == '\\'))
- )) {
- pch ++;
+ while (pch <= pe && ((*pch != quote) || ((pch > pchs) && (*(pch - 1) == '\\'))
+ )) {
+ pch++;
}
pche = pch;
if (*pch != quote) {
syslog(LOG_WARNING, "Error (in '%s' line %ld); "
- "evaluating template param [%s] in Token [%s]\n",
- ChrPtr(pTmpl->FileName),
- Tokens->Line,
- ChrPtr(Tokens->FlatToken),
- *pCh);
- pch ++;
+ "evaluating template param [%s] in Token [%s]\n",
+ ChrPtr(pTmpl->FileName), Tokens->Line, ChrPtr(Tokens->FlatToken), *pCh);
+ pch++;
free(Parm);
*pParm = NULL;
return 0;
}
else {
- StrBufPeek(Buf, pch, -1, '\0');
- if (LoadTemplates > 1) {
+ StrBufPeek(Buf, pch, -1, '\0');
+ if (LoadTemplates > 1) {
syslog(LOG_DEBUG,
- "DBG: got param [%s] "SIZE_T_FMT" "SIZE_T_FMT"\n",
- pchs, pche - pchs, strlen(pchs)
- );
+ "DBG: got param [%s] " SIZE_T_FMT " " SIZE_T_FMT "\n", pchs, pche - pchs, strlen(pchs)
+ );
}
Parm->Start = pchs;
Parm->len = pche - pchs;
- pch ++; /* move after trailing quote */
+ pch++; /* move after trailing quote */
if (ParamBrace && (*pch == ')')) {
- pch ++;
+ pch++;
}
}
@@ -865,13 +764,10 @@ int GetNextParameter(StrBuf *Buf,
else {
Parm->Type = TYPE_LONG;
pchs = pch;
- while ((pch <= pe) &&
- (isdigit(*pch) ||
- (*pch == '+') ||
- (*pch == '-')))
- pch ++;
- pch ++;
- if (pch - pchs > 1){
+ while ((pch <= pe) && (isdigit(*pch) || (*pch == '+') || (*pch == '-')))
+ pch++;
+ pch++;
+ if (pch - pchs > 1) {
StrBufPeek(Buf, pch, -1, '\0');
Parm->lvalue = atol(pchs);
Parm->Start = pchs;
@@ -879,6 +775,7 @@ int GetNextParameter(StrBuf *Buf,
}
else {
Parm->lvalue = 0;
+
/* TODO whUT?
syslog(LOG_DEBUG, "Error (in '%s' line %ld); "
"evaluating long template param [%s] in Token [%s]\n",
@@ -892,161 +789,131 @@ int GetNextParameter(StrBuf *Buf,
return 0;
}
}
- while ((*pch == ' ' )||
- (*pch == '\t')||
- (*pch == '\r')||
- (*pch == ',' )||
- (*pch == '\n')) pch ++;
+ while ((*pch == ' ') || (*pch == '\t') || (*pch == '\r') || (*pch == ',') || (*pch == '\n'))
+ pch++;
- switch (Parm->Type)
- {
+ switch (Parm->Type) {
case TYPE_GETTEXT:
if (DumpTemplateI18NStrings) {
StrBufAppendPrintf(I18nDump, "_(\"%s\");\n", Parm->Start);
}
break;
- case TYPE_INTDEFINE: {
- void *vPVal;
-
- if (GetHash(Defines, Parm->Start, Parm->len, &vPVal) &&
- (vPVal != NULL))
- {
- long *PVal;
- PVal = (long*) vPVal;
-
- Parm->lvalue = *PVal;
- }
- else if (strchr(Parm->Start, '|') != NULL)
- {
- const char *Pos;
- StrBuf *pToken;
- StrBuf *Match;
-
- Parm->MaskBy = eOR;
- pToken = NewStrBufPlain (Parm->Start, Parm->len);
- Match = NewStrBufPlain (NULL, Parm->len);
- Pos = ChrPtr(pToken);
-
- while ((Pos != NULL) && (Pos != StrBufNOTNULL))
- {
- StrBufExtract_NextToken(Match, pToken, &Pos, '|');
- StrBufTrim(Match);
- if (StrLength (Match) > 0)
- {
- if (GetHash(Defines, SKEY(Match), &vPVal) &&
- (vPVal != NULL))
- {
- long *PVal;
- PVal = (long*) vPVal;
-
- Parm->lvalue |= *PVal;
- }
- else {
- LogTemplateError(NULL, "Define",
- Tokens->nParameters,
- TP,
- "%s isn't known!!",
- ChrPtr(Match));
+ case TYPE_INTDEFINE:{
+ void *vPVal;
+ if (GetHash(Defines, Parm->Start, Parm->len, &vPVal) && (vPVal != NULL)) {
+ long *PVal;
+ PVal = (long *) vPVal;
+
+ Parm->lvalue = *PVal;
+ }
+ else if (strchr(Parm->Start, '|') != NULL) {
+ const char *Pos;
+ StrBuf *pToken;
+ StrBuf *Match;
+
+ Parm->MaskBy = eOR;
+ pToken = NewStrBufPlain(Parm->Start, Parm->len);
+ Match = NewStrBufPlain(NULL, Parm->len);
+ Pos = ChrPtr(pToken);
+
+ while ((Pos != NULL) && (Pos != StrBufNOTNULL)) {
+ StrBufExtract_NextToken(Match, pToken, &Pos, '|');
+ StrBufTrim(Match);
+ if (StrLength(Match) > 0) {
+ if (GetHash(Defines, SKEY(Match), &vPVal) && (vPVal != NULL)) {
+ long *PVal;
+ PVal = (long *) vPVal;
+
+ Parm->lvalue |= *PVal;
+ }
+ else {
+ LogTemplateError(NULL, "Define",
+ Tokens->nParameters,
+ TP, "%s isn't known!!", ChrPtr(Match));
+
+ }
}
}
+ FreeStrBuf(&pToken);
+ FreeStrBuf(&Match);
}
- FreeStrBuf(&pToken);
- FreeStrBuf(&Match);
- }
- else if (strchr(Parm->Start, '&') != NULL)
- {
- const char *Pos;
- StrBuf *pToken;
- StrBuf *Match;
-
- Parm->MaskBy = eAND;
- pToken = NewStrBufPlain (Parm->Start, Parm->len);
- Match = NewStrBufPlain (NULL, Parm->len);
- Pos = ChrPtr(pToken);
-
- while ((Pos != NULL) && (Pos != StrBufNOTNULL))
- {
- StrBufExtract_NextToken(Match, pToken, &Pos, '&');
- StrBufTrim(Match);
- if (StrLength (Match) > 0)
- {
- if (GetHash(Defines, SKEY(Match), &vPVal) &&
- (vPVal != NULL))
- {
- long *PVal;
- PVal = (long*) vPVal;
-
- Parm->lvalue |= *PVal;
- }
- else {
- LogTemplateError(NULL, "Define",
- Tokens->nParameters,
- TP,
- "%s isn't known!!",
- ChrPtr(Match));
+ else if (strchr(Parm->Start, '&') != NULL) {
+ const char *Pos;
+ StrBuf *pToken;
+ StrBuf *Match;
+
+ Parm->MaskBy = eAND;
+ pToken = NewStrBufPlain(Parm->Start, Parm->len);
+ Match = NewStrBufPlain(NULL, Parm->len);
+ Pos = ChrPtr(pToken);
+
+ while ((Pos != NULL) && (Pos != StrBufNOTNULL)) {
+ StrBufExtract_NextToken(Match, pToken, &Pos, '&');
+ StrBufTrim(Match);
+ if (StrLength(Match) > 0) {
+ if (GetHash(Defines, SKEY(Match), &vPVal) && (vPVal != NULL)) {
+ long *PVal;
+ PVal = (long *) vPVal;
+
+ Parm->lvalue |= *PVal;
+ }
+ else {
+ LogTemplateError(NULL, "Define",
+ Tokens->nParameters,
+ TP, "%s isn't known!!", ChrPtr(Match));
+ }
}
}
+ FreeStrBuf(&Match);
+ FreeStrBuf(&pToken);
}
- FreeStrBuf(&Match);
- FreeStrBuf(&pToken);
- }
- else {
+ else {
- LogTemplateError(NULL, "Define",
- Tokens->nParameters,
- TP,
- "%s isn't known!!",
- Parm->Start);
- }}
+ LogTemplateError(NULL, "Define", Tokens->nParameters, TP, "%s isn't known!!", Parm->Start);
+ }
+ }
break;
case TYPE_SUBTEMPLATE:{
- void *vTmpl;
- /* well, we don't check the mobile stuff here... */
- if (!GetHash(LocalTemplateCache, Parm->Start, Parm->len, &vTmpl) &&
- !GetHash(TemplateCache, Parm->Start, Parm->len, &vTmpl)) {
- LogTemplateError(NULL,
- "SubTemplate",
- Tokens->nParameters,
- TP,
- "referenced here doesn't exist");
- }}
+ void *vTmpl;
+ /* well, we don't check the mobile stuff here... */
+ if (!GetHash(LocalTemplateCache, Parm->Start, Parm->len, &vTmpl) &&
+ !GetHash(TemplateCache, Parm->Start, Parm->len, &vTmpl)) {
+ LogTemplateError(NULL, "SubTemplate", Tokens->nParameters, TP, "referenced here doesn't exist");
+ }
+ }
break;
}
*pCh = pch;
return 1;
}
-WCTemplateToken *NewTemplateSubstitute(StrBuf *Buf,
- const char *pStart,
- const char *pTokenStart,
- const char *pTokenEnd,
- long Line,
- WCTemplate *pTmpl)
-{
+WCTemplateToken *NewTemplateSubstitute(StrBuf * Buf,
+ const char *pStart,
+ const char *pTokenStart, const char *pTokenEnd, long Line, WCTemplate * pTmpl) {
void *vVar;
const char *pch;
WCTemplateToken *NewToken;
WCTemplputParams TP;
- NewToken = (WCTemplateToken*)malloc(sizeof(WCTemplateToken));
+ NewToken = (WCTemplateToken *) malloc(sizeof(WCTemplateToken));
memset(NewToken, 0, sizeof(WCTemplateToken));
TP.Tokens = NewToken;
- NewToken->FileName = pTmpl->FileName; /* to print meaningfull log messages... */
+ NewToken->FileName = pTmpl->FileName; /* to print meaningfull log messages... */
NewToken->Flags = 0;
NewToken->Line = Line + 1;
NewToken->pTokenStart = pTokenStart;
NewToken->TokenStart = pTokenStart - pStart;
- NewToken->TokenEnd = (pTokenEnd - pStart) - NewToken->TokenStart;
+ NewToken->TokenEnd = (pTokenEnd - pStart) - NewToken->TokenStart;
NewToken->pTokenEnd = pTokenEnd;
NewToken->NameEnd = NewToken->TokenEnd - 2;
NewToken->PreEval = NULL;
NewToken->FlatToken = NewStrBufPlain(pTokenStart + 2, pTokenEnd - pTokenStart - 2);
StrBufShrinkToFit(NewToken->FlatToken, 1);
- StrBufPeek(Buf, pTokenStart, + 1, '\0');
+ StrBufPeek(Buf, pTokenStart, +1, '\0');
StrBufPeek(Buf, pTokenEnd, -1, '\0');
pch = NewToken->pName = pTokenStart + 2;
@@ -1057,39 +924,30 @@ WCTemplateToken *NewTemplateSubstitute(StrBuf *Buf,
if (*pch == '(') {
StrBufPeek(Buf, pch, -1, '\0');
NewToken->NameEnd = pch - NewToken->pName;
- pch ++;
+ pch++;
if (*(pTokenEnd - 1) != ')') {
- LogTemplateError(
- NULL, "Parseerror", ERR_NAME, &TP,
- "Warning, Non welformed Token; missing right parenthesis");
+ LogTemplateError(NULL, "Parseerror", ERR_NAME, &TP,
+ "Warning, Non welformed Token; missing right parenthesis");
}
while (pch < pTokenEnd - 1) {
NewToken->nParameters++;
- if (GetNextParameter(Buf,
- &pch,
- pTokenEnd - 1,
- NewToken,
- pTmpl,
- &TP,
- &NewToken->Params[NewToken->nParameters - 1]))
- {
+ if (GetNextParameter(Buf,
+ &pch,
+ pTokenEnd - 1,
+ NewToken, pTmpl, &TP, &NewToken->Params[NewToken->nParameters - 1])) {
NewToken->HaveParameters = 1;
if (NewToken->nParameters >= MAXPARAM) {
- LogTemplateError(
- NULL, "Parseerror", ERR_NAME, &TP,
- "only [%d] Params allowed in Tokens",
- MAXPARAM);
+ LogTemplateError(NULL, "Parseerror", ERR_NAME, &TP,
+ "only [%d] Params allowed in Tokens", MAXPARAM);
FreeToken(&NewToken);
return NULL;
}
}
- else break;
+ else
+ break;
}
- if((NewToken->NameEnd == 1) &&
- (NewToken->HaveParameters == 1))
-
- {
+ if ((NewToken->NameEnd == 1) && (NewToken->HaveParameters == 1)) {
if (*(NewToken->pName) == '_')
NewToken->Flags = SV_GETTEXT;
else if (*(NewToken->pName) == '=')
@@ -1102,60 +960,48 @@ WCTemplateToken *NewTemplateSubstitute(StrBuf *Buf,
NewToken->Flags = SV_NEG_CONDITIONAL;
}
}
- else pch ++;
+ else
+ pch++;
}
-
+
switch (NewToken->Flags) {
case 0:
/* If we're able to find out more about the token, do it now while its fresh. */
pch = NewToken->pName;
- while (pch < NewToken->pName + NewToken->NameEnd)
- {
- if (((*pch >= 'A') && (*pch <= 'Z')) ||
- ((*pch >= '0') && (*pch <= '9')) ||
- (*pch == ':') ||
- (*pch == '-') ||
- (*pch == '_'))
- pch ++;
- else
- {
- LogTemplateError(
- NULL, "Token Name", ERR_NAME, &TP,
- "contains illegal char: '%c'",
- *pch);
+ while (pch < NewToken->pName + NewToken->NameEnd) {
+ if (((*pch >= 'A') && (*pch <= 'Z')) ||
+ ((*pch >= '0') && (*pch <= '9')) || (*pch == ':') || (*pch == '-') || (*pch == '_'))
+ pch++;
+ else {
+ LogTemplateError(NULL, "Token Name", ERR_NAME, &TP, "contains illegal char: '%c'", *pch);
pch++;
}
}
if (GetHash(GlobalNS, NewToken->pName, NewToken->NameEnd, &vVar)) {
HashHandler *Handler;
- Handler = (HashHandler*) vVar;
- if ((NewToken->nParameters < Handler->Filter.nMinArgs) ||
+ Handler = (HashHandler *) vVar;
+ if ((NewToken->nParameters < Handler->Filter.nMinArgs) ||
(NewToken->nParameters > Handler->Filter.nMaxArgs)) {
- LogTemplateError(
- NULL, "Token", ERR_NAME, &TP,
- "doesn't work with %d params",
- NewToken->nParameters);
+ LogTemplateError(NULL, "Token", ERR_NAME, &TP,
+ "doesn't work with %d params", NewToken->nParameters);
}
else {
NewToken->PreEval = Handler;
- NewToken->Flags = SV_PREEVALUATED;
+ NewToken->Flags = SV_PREEVALUATED;
if (Handler->PreEvalFunc != NULL)
Handler->PreEvalFunc(NewToken);
}
- } else {
- LogTemplateError(
- NULL, "Token ", ERR_NAME, &TP,
- " isn't known to us.");
+ }
+ else {
+ LogTemplateError(NULL, "Token ", ERR_NAME, &TP, " isn't known to us.");
}
break;
case SV_GETTEXT:
if ((NewToken->nParameters < 1) || (NewToken->nParameters > 2)) {
- LogTemplateError(
- NULL, "Gettext", ERR_NAME, &TP,
- "requires 1 or 2 parameter, you gave %d params",
- NewToken->nParameters);
+ LogTemplateError(NULL, "Gettext", ERR_NAME, &TP,
+ "requires 1 or 2 parameter, you gave %d params", NewToken->nParameters);
NewToken->Flags = 0;
break;
}
@@ -1165,58 +1011,41 @@ WCTemplateToken *NewTemplateSubstitute(StrBuf *Buf,
break;
case SV_SUBTEMPL:
if (NewToken->nParameters != 1) {
- LogTemplateError(
- NULL, "Subtemplates", ERR_NAME, &TP,
- "require exactly 1 parameter, you gave %d params",
- NewToken->nParameters);
+ LogTemplateError(NULL, "Subtemplates", ERR_NAME, &TP,
+ "require exactly 1 parameter, you gave %d params", NewToken->nParameters);
break;
}
else {
void *vTmpl;
/* well, we don't check the mobile stuff here... */
- if (!GetHash(LocalTemplateCache,
- NewToken->Params[0]->Start,
- NewToken->Params[0]->len,
+ if (!GetHash(LocalTemplateCache,
+ NewToken->Params[0]->Start,
+ NewToken->Params[0]->len,
&vTmpl) &&
- !GetHash(TemplateCache,
- NewToken->Params[0]->Start,
- NewToken->Params[0]->len,
- &vTmpl)) {
- LogTemplateError(
- NULL, "SubTemplate", ERR_PARM1, &TP,
- "doesn't exist");
+ !GetHash(TemplateCache, NewToken->Params[0]->Start, NewToken->Params[0]->len, &vTmpl)) {
+ LogTemplateError(NULL, "SubTemplate", ERR_PARM1, &TP, "doesn't exist");
}
}
break;
case SV_CUST_STR_CONDITIONAL:
case SV_CONDITIONAL:
case SV_NEG_CONDITIONAL:
- if (NewToken->nParameters <2) {
- LogTemplateError(
- NULL, "Conditional", ERR_PARM1, &TP,
- "require at least 2 parameters, you gave %d params",
- NewToken->nParameters);
+ if (NewToken->nParameters < 2) {
+ LogTemplateError(NULL, "Conditional", ERR_PARM1, &TP,
+ "require at least 2 parameters, you gave %d params", NewToken->nParameters);
NewToken->Flags = 0;
break;
}
if (NewToken->Params[1]->lvalue == 0) {
- LogTemplateError(
- NULL, "Conditional", ERR_PARM1, &TP,
- "Conditional ID (Parameter 1) mustn't be 0!");
+ LogTemplateError(NULL, "Conditional", ERR_PARM1, &TP, "Conditional ID (Parameter 1) mustn't be 0!");
NewToken->Flags = 0;
break;
}
- if (!GetHash(Conditionals,
- NewToken->Params[0]->Start,
- NewToken->Params[0]->len,
- &vVar) ||
- (vVar == NULL)) {
- if ((NewToken->Params[0]->len == 1) &&
- (NewToken->Params[0]->Start[0] == 'X'))
+ if (!GetHash(Conditionals, NewToken->Params[0]->Start, NewToken->Params[0]->len, &vVar) || (vVar == NULL)) {
+ if ((NewToken->Params[0]->len == 1) && (NewToken->Params[0]->Start[0] == 'X'))
break;
- LogTemplateError(
- NULL, "Conditional", ERR_PARM1, &TP,
- "Not found!");
+ LogTemplateError(NULL, "Conditional", ERR_PARM1, &TP, "Not found!");
+
/*
NewToken->Error = NewStrBuf();
StrBufAppendPrintf(
@@ -1244,7 +1073,7 @@ WCTemplateToken *NewTemplateSubstitute(StrBuf *Buf,
* Display a variable-substituted template
* templatename template file to load
*/
-void *prepare_template(StrBuf *filename, StrBuf *Key, HashList *PutThere) {
+void *prepare_template(StrBuf * filename, StrBuf * Key, HashList * PutThere) {
WCTemplate *NewTemplate;
NewTemplate = (WCTemplate *) malloc(sizeof(WCTemplate));
@@ -1255,7 +1084,7 @@ void *prepare_template(StrBuf *filename, StrBuf *Key, HashList *PutThere) {
NewTemplate->nTokensUsed = 0;
NewTemplate->TokenSpace = 0;
NewTemplate->Tokens = NULL;
- NewTemplate->MimeType = NewStrBufPlain(GuessMimeByFilename (SKEY(NewTemplate->FileName)), -1);
+ NewTemplate->MimeType = NewStrBufPlain(GuessMimeByFilename(SKEY(NewTemplate->FileName)), -1);
if (strstr(ChrPtr(NewTemplate->MimeType), "text") != NULL) {
StrBufAppendBufPlain(NewTemplate->MimeType, HKEY("; charset=utf-8"), 0);
}
@@ -1272,7 +1101,7 @@ void *prepare_template(StrBuf *filename, StrBuf *Key, HashList *PutThere) {
* Display a variable-substituted template
* templatename template file to load
*/
-void *duplicate_template(WCTemplate *OldTemplate) {
+void *duplicate_template(WCTemplate * OldTemplate) {
WCTemplate *NewTemplate;
NewTemplate = (WCTemplate *) malloc(sizeof(WCTemplate));
@@ -1288,40 +1117,32 @@ void *duplicate_template(WCTemplate *OldTemplate) {
}
-void SanityCheckTemplate(StrBuf *Target, WCTemplate *CheckMe) {
+void SanityCheckTemplate(StrBuf * Target, WCTemplate * CheckMe) {
int i = 0;
int j;
int FoundConditionalEnd;
for (i = 0; i < CheckMe->nTokensUsed; i++) {
- switch(CheckMe->Tokens[i]->Flags) {
+ switch (CheckMe->Tokens[i]->Flags) {
case SV_CONDITIONAL:
case SV_NEG_CONDITIONAL:
FoundConditionalEnd = 0;
- if ((CheckMe->Tokens[i]->Params[0]->len == 1) &&
- (CheckMe->Tokens[i]->Params[0]->Start[0] == 'X'))
+ if ((CheckMe->Tokens[i]->Params[0]->len == 1) && (CheckMe->Tokens[i]->Params[0]->Start[0] == 'X'))
break;
- for (j = i + 1; j < CheckMe->nTokensUsed; j++)
- {
+ for (j = i + 1; j < CheckMe->nTokensUsed; j++) {
if (((CheckMe->Tokens[j]->Flags == SV_CONDITIONAL) ||
- (CheckMe->Tokens[j]->Flags == SV_NEG_CONDITIONAL)) &&
- (CheckMe->Tokens[i]->Params[1]->lvalue ==
- CheckMe->Tokens[j]->Params[1]->lvalue))
- {
+ (CheckMe->Tokens[j]->Flags == SV_NEG_CONDITIONAL)) &&
+ (CheckMe->Tokens[i]->Params[1]->lvalue == CheckMe->Tokens[j]->Params[1]->lvalue)) {
FoundConditionalEnd = 1;
break;
}
}
- if (!FoundConditionalEnd)
- {
+ if (!FoundConditionalEnd) {
WCTemplputParams TP;
memset(&TP, 0, sizeof(WCTemplputParams));
TP.Tokens = CheckMe->Tokens[i];
- LogTemplateError(
- Target, "Token", ERR_PARM1, &TP,
- "Conditional without Endconditional"
- );
+ LogTemplateError(Target, "Token", ERR_PARM1, &TP, "Conditional without Endconditional");
}
break;
default:
@@ -1334,8 +1155,7 @@ void SanityCheckTemplate(StrBuf *Target, WCTemplate *CheckMe) {
* Display a variable-substituted template
* templatename template file to load
*/
-void *load_template(StrBuf *Target, WCTemplate *NewTemplate)
-{
+void *load_template(StrBuf * Target, WCTemplate * NewTemplate) {
int fd;
struct stat statbuf;
const char *pS, *pE, *pch, *Err;
@@ -1343,22 +1163,19 @@ void *load_template(StrBuf *Target, WCTemplate *NewTemplate)
fd = open(ChrPtr(NewTemplate->FileName), O_RDONLY);
if (fd <= 0) {
- syslog(LOG_WARNING, "ERROR: could not open template '%s' - %s\n",
- ChrPtr(NewTemplate->FileName), strerror(errno));
+ syslog(LOG_WARNING, "ERROR: could not open template '%s' - %s\n", ChrPtr(NewTemplate->FileName), strerror(errno));
return NULL;
}
if (fstat(fd, &statbuf) == -1) {
- syslog(LOG_WARNING, "ERROR: could not stat template '%s' - %s\n",
- ChrPtr(NewTemplate->FileName), strerror(errno));
+ syslog(LOG_WARNING, "ERROR: could not stat template '%s' - %s\n", ChrPtr(NewTemplate->FileName), strerror(errno));
return NULL;
}
NewTemplate->Data = NewStrBufPlain(NULL, statbuf.st_size + 1);
if (StrBufReadBLOB(NewTemplate->Data, &fd, 1, statbuf.st_size, &Err) < 0) {
close(fd);
- syslog(LOG_WARNING, "ERROR: reading template '%s' - %s \n",
- ChrPtr(NewTemplate->FileName), strerror(errno));
+ syslog(LOG_WARNING, "ERROR: reading template '%s' - %s \n", ChrPtr(NewTemplate->FileName), strerror(errno));
return NULL;
}
close(fd);
@@ -1374,39 +1191,30 @@ void *load_template(StrBuf *Target, WCTemplate *NewTemplate)
void *pv;
/** Find one > */
- for (; pch < pE; pch ++) {
- if ((*pch=='<')&&(*(pch + 1)=='?') &&
- !((pch == pS) && /* we must ommit a = pE)
continue;
pts = pch;
/** Found one? parse it. */
- for (; pch <= pE - 1; pch ++) {
- if ((!InQuotes) &&
- ((*pch == '\'') || (*pch == '"')))
- {
+ for (; pch <= pE - 1; pch++) {
+ if ((!InQuotes) && ((*pch == '\'') || (*pch == '"'))) {
InQuotes = *pch;
}
- else if (InQuotes && (InQuotes == *pch))
- {
+ else if (InQuotes && (InQuotes == *pch)) {
InQuotes = '\0';
}
- else if ((InQuotes) &&
- (*pch == '\\') &&
- (*(pch + 1) == InQuotes))
- {
+ else if ((InQuotes) && (*pch == '\\') && (*(pch + 1) == InQuotes)) {
pch++;
}
- else if ((!InQuotes) &&
- (*pch == '>'))
- {
+ else if ((!InQuotes) && (*pch == '>')) {
break;
}
}
@@ -1416,7 +1224,7 @@ void *load_template(StrBuf *Target, WCTemplate *NewTemplate)
pv = NewTemplateSubstitute(NewTemplate->Data, pS, pts, pte, Line, NewTemplate);
if (pv != NULL) {
PutNewToken(NewTemplate, pv);
- pch ++;
+ pch++;
}
}
@@ -1425,16 +1233,14 @@ void *load_template(StrBuf *Target, WCTemplate *NewTemplate)
}
-const char* PrintTemplate(void *vSubst)
-{
+const char *PrintTemplate(void *vSubst) {
WCTemplate *Tmpl = vSubst;
return ChrPtr(Tmpl->FileName);
}
-int LoadTemplateDir(const StrBuf *DirName, HashList *big, const StrBuf *BaseKey)
-{
+int LoadTemplateDir(const StrBuf * DirName, HashList * big, const StrBuf * BaseKey) {
int Toplevel;
StrBuf *FileName;
StrBuf *Key;
@@ -1446,13 +1252,13 @@ int LoadTemplateDir(const StrBuf *DirName, HashList *big, const StrBuf *BaseKey)
int d_type = 0;
int d_namelen;
int d_without_ext;
-
- d = (struct dirent *)malloc(offsetof(struct dirent, d_name) + PATH_MAX + 1);
+
+ d = (struct dirent *) malloc(offsetof(struct dirent, d_name) + PATH_MAX + 1);
if (d == NULL) {
return 0;
}
- filedir = opendir (ChrPtr(DirName));
+ filedir = opendir(ChrPtr(DirName));
if (filedir == NULL) {
free(d);
return 0;
@@ -1463,9 +1269,7 @@ int LoadTemplateDir(const StrBuf *DirName, HashList *big, const StrBuf *BaseKey)
SubKey = NewStrBuf();
FileName = NewStrBufPlain(NULL, PATH_MAX);
Key = NewStrBuf();
- while ((readdir_r(filedir, d, &filedir_entry) == 0) &&
- (filedir_entry != NULL))
- {
+ while ((readdir_r(filedir, d, &filedir_entry) == 0) && (filedir_entry != NULL)) {
char *MinorPtr;
#ifdef _DIRENT_HAVE_D_NAMLEN
@@ -1492,28 +1296,23 @@ int LoadTemplateDir(const StrBuf *DirName, HashList *big, const StrBuf *BaseKey)
d_without_ext = d_namelen;
if ((d_namelen > 1) && filedir_entry->d_name[d_namelen - 1] == '~')
- continue; /* Ignore backup files... */
+ continue; /* Ignore backup files... */
- if ((d_namelen == 1) &&
- (filedir_entry->d_name[0] == '.'))
+ if ((d_namelen == 1) && (filedir_entry->d_name[0] == '.'))
continue;
- if ((d_namelen == 2) &&
- (filedir_entry->d_name[0] == '.') &&
- (filedir_entry->d_name[1] == '.'))
+ if ((d_namelen == 2) && (filedir_entry->d_name[0] == '.') && (filedir_entry->d_name[1] == '.'))
continue;
if (d_type == DT_UNKNOWN) {
struct stat s;
char path[PATH_MAX];
- snprintf(path, PATH_MAX, "%s/%s",
- ChrPtr(DirName), filedir_entry->d_name);
+ snprintf(path, PATH_MAX, "%s/%s", ChrPtr(DirName), filedir_entry->d_name);
if (lstat(path, &s) == 0) {
d_type = IFTODT(s.st_mode);
}
}
- switch (d_type)
- {
+ switch (d_type) {
case DT_DIR:
/* Skip directories we are not interested in... */
if (strcmp(filedir_entry->d_name, ".svn") == 0)
@@ -1521,7 +1320,7 @@ int LoadTemplateDir(const StrBuf *DirName, HashList *big, const StrBuf *BaseKey)
FlushStrBuf(SubKey);
if (!Toplevel) {
- /* If we're not toplevel, the upper dirs count as foo_bar_*/
+ /* If we're not toplevel, the upper dirs count as foo_bar_ */
StrBufAppendBuf(SubKey, BaseKey, 0);
StrBufAppendBufPlain(SubKey, HKEY("_"), 0);
}
@@ -1536,25 +1335,25 @@ int LoadTemplateDir(const StrBuf *DirName, HashList *big, const StrBuf *BaseKey)
LoadTemplateDir(SubDirectory, big, SubKey);
break;
- case DT_LNK:
+ case DT_LNK:
case DT_REG:
while ((d_without_ext > 0) && (filedir_entry->d_name[d_without_ext] != '.'))
- d_without_ext --;
+ d_without_ext--;
if ((d_without_ext == 0) || (d_namelen < 3))
continue;
if (((d_namelen > 1) && filedir_entry->d_name[d_namelen - 1] == '~') ||
(strcmp(&filedir_entry->d_name[d_without_ext], ".orig") == 0) ||
(strcmp(&filedir_entry->d_name[d_without_ext], ".swp") == 0))
- continue; /* Ignore backup files... */
- StrBufPrintf(FileName, "%s/%s", ChrPtr(DirName), filedir_entry->d_name);
+ continue; /* Ignore backup files... */
+ StrBufPrintf(FileName, "%s/%s", ChrPtr(DirName), filedir_entry->d_name);
MinorPtr = strchr(filedir_entry->d_name, '.');
if (MinorPtr != NULL)
*MinorPtr = '\0';
FlushStrBuf(Key);
if (!Toplevel) {
- /* If we're not toplevel, the upper dirs count as foo_bar_*/
+ /* If we're not toplevel, the upper dirs count as foo_bar_ */
StrBufAppendBuf(Key, BaseKey, 0);
StrBufAppendBufPlain(Key, HKEY("_"), 0);
}
@@ -1576,8 +1375,7 @@ int LoadTemplateDir(const StrBuf *DirName, HashList *big, const StrBuf *BaseKey)
return 1;
}
-void InitTemplateCache(void)
-{
+void InitTemplateCache(void) {
int i;
StrBuf *Key;
StrBuf *Dir;
@@ -1593,17 +1391,17 @@ void InitTemplateCache(void)
/* User local Template set */
StrBufPrintf(Dir, "%s/t", static_dirs[1]);
LoadTemplateDir(Dir, LocalTemplateCache, Key);
-
+
/* Debug Templates, just to be loaded while debugging. */
-
+
StrBufPrintf(Dir, "%s/dbg", static_dirs[0]);
LoadTemplateDir(Dir, TemplateCache, Key);
Templates[0] = TemplateCache;
Templates[1] = LocalTemplateCache;
- if (LoadTemplates == 0)
- for (i=0; i < 2; i++) {
+ if (LoadTemplates == 0)
+ for (i = 0; i < 2; i++) {
const char *Key;
long KLen;
HashPos *At;
@@ -1611,7 +1409,7 @@ void InitTemplateCache(void)
At = GetNewHashPos(Templates[i], 0);
while (GetNextHashPos(Templates[i], At, &KLen, &Key, &vTemplate) && (vTemplate != NULL)) {
- load_template(NULL, (WCTemplate *)vTemplate);
+ load_template(NULL, (WCTemplate *) vTemplate);
}
DeleteHashPos(&At);
}
@@ -1626,6 +1424,7 @@ void InitTemplateCache(void)
/*-----------------------------------------------------------------------------
* Filling & processing Templates
*/
+
/**
* \brief executes one token
* \param Target buffer to append to
@@ -1635,14 +1434,13 @@ void InitTemplateCache(void)
* \param state are we in conditional state?
* \param ContextType what type of information does context giv us?
*/
-int EvaluateToken(StrBuf *Target, int state, WCTemplputParams **TPP)
-{
+int EvaluateToken(StrBuf * Target, int state, WCTemplputParams ** TPP) {
const char *AppendMe;
long AppendMeLen;
HashHandler *Handler;
void *vVar;
WCTemplputParams *TP = *TPP;
-
+
/* much output, since pName is not terminated...
syslog(LOG_DEBUG,"Doing token: %s\n",Token->pName);
*/
@@ -1651,22 +1449,25 @@ int EvaluateToken(StrBuf *Target, int state, WCTemplputParams **TPP)
case SV_GETTEXT:
TmplGettext(Target, TP);
break;
- case SV_CONDITIONAL: /** Forward conditional evaluation */
- Handler = (HashHandler*) TP->Tokens->PreEval;
+
+ case SV_CONDITIONAL:/** Forward conditional evaluation */
+ Handler = (HashHandler *) TP->Tokens->PreEval;
if (!CheckContext(Target, &Handler->Filter, TP, "Conditional")) {
return 0;
}
return EvaluateConditional(Target, 1, state, TPP);
break;
- case SV_NEG_CONDITIONAL: /** Reverse conditional evaluation */
- Handler = (HashHandler*) TP->Tokens->PreEval;
+
+ case SV_NEG_CONDITIONAL:/** Reverse conditional evaluation */
+ Handler = (HashHandler *) TP->Tokens->PreEval;
if (!CheckContext(Target, &Handler->Filter, TP, "Conditional")) {
return 0;
}
return EvaluateConditional(Target, 0, state, TPP);
break;
- case SV_CUST_STR_CONDITIONAL: /** Conditional put custom strings from params */
- Handler = (HashHandler*) TP->Tokens->PreEval;
+
+ case SV_CUST_STR_CONDITIONAL:/** Conditional put custom strings from params */
+ Handler = (HashHandler *) TP->Tokens->PreEval;
if (!CheckContext(Target, &Handler->Filter, TP, "Conditional")) {
return 0;
}
@@ -1675,17 +1476,16 @@ int EvaluateToken(StrBuf *Target, int state, WCTemplputParams **TPP)
GetTemplateTokenString(Target, TP, 5, &AppendMe, &AppendMeLen);
StrBufAppendBufPlain(Target, AppendMe, AppendMeLen, 0);
}
- else{
+ else {
GetTemplateTokenString(Target, TP, 4, &AppendMe, &AppendMeLen);
StrBufAppendBufPlain(Target, AppendMe, AppendMeLen, 0);
}
- if (*TPP != TP)
- {
+ if (*TPP != TP) {
UnStackDynamicContext(Target, TPP);
}
}
- else {
- LogTemplateError( Target, "Conditional", ERR_NAME, TP, "needs at least 6 Params!");
+ else {
+ LogTemplateError(Target, "Conditional", ERR_NAME, TP, "needs at least 6 Params!");
}
break;
case SV_SUBTEMPL:
@@ -1693,15 +1493,15 @@ int EvaluateToken(StrBuf *Target, int state, WCTemplputParams **TPP)
DoTemplate(TKEY(0), Target, TP);
break;
case SV_PREEVALUATED:
- Handler = (HashHandler*) TP->Tokens->PreEval;
+ Handler = (HashHandler *) TP->Tokens->PreEval;
if (!CheckContext(Target, &Handler->Filter, TP, "Token")) {
return 0;
}
Handler->HandlerFunc(Target, TP);
- break;
+ break;
default:
if (GetHash(GlobalNS, TP->Tokens->pName, TP->Tokens->NameEnd, &vVar)) {
- Handler = (HashHandler*) vVar;
+ Handler = (HashHandler *) vVar;
if (!CheckContext(Target, &Handler->Filter, TP, "Token")) {
return 0;
}
@@ -1710,9 +1510,8 @@ int EvaluateToken(StrBuf *Target, int state, WCTemplputParams **TPP)
}
}
else {
- LogTemplateError(
- Target, "Token UNKNOWN", ERR_NAME, TP,
- "You've specified a token that isn't known to webcit.!");
+ LogTemplateError(Target, "Token UNKNOWN", ERR_NAME, TP,
+ "You've specified a token that isn't known to webcit.!");
}
}
return 0;
@@ -1720,8 +1519,7 @@ int EvaluateToken(StrBuf *Target, int state, WCTemplputParams **TPP)
-const StrBuf *ProcessTemplate(WCTemplate *Tmpl, StrBuf *Target, WCTemplputParams *CallingTP)
-{
+const StrBuf *ProcessTemplate(WCTemplate * Tmpl, StrBuf * Target, WCTemplputParams * CallingTP) {
WCTemplate *pTmpl = Tmpl;
int done = 0;
int i;
@@ -1739,15 +1537,14 @@ const StrBuf *ProcessTemplate(WCTemplate *Tmpl, StrBuf *Target, WCTemplputParams
TP.Sub = CallingTP->Sub;
TP.Super = CallingTP->Super;
- if (LoadTemplates != 0) {
+ if (LoadTemplates != 0) {
if (LoadTemplates > 1)
- syslog(LOG_DEBUG, "DBG: ----- loading: [%s] ------ \n",
- ChrPtr(Tmpl->FileName));
+ syslog(LOG_DEBUG, "DBG: ----- loading: [%s] ------ \n", ChrPtr(Tmpl->FileName));
pTmpl = duplicate_template(Tmpl);
- if(load_template(Target, pTmpl) == NULL) {
- StrBufAppendPrintf( Target,
- "\nError loading Template [%s]\n See Logfile for details\n \n",
- ChrPtr(Tmpl->FileName));
+ if (load_template(Target, pTmpl) == NULL) {
+ StrBufAppendPrintf(Target,
+ "\nError loading Template [%s]\n See Logfile for details\n \n",
+ ChrPtr(Tmpl->FileName));
FreeWCTemplate(pTmpl);
return NULL;
}
@@ -1766,11 +1563,11 @@ const StrBuf *ProcessTemplate(WCTemplate *Tmpl, StrBuf *Target, WCTemplputParams
else {
int TokenRc = 0;
- StrBufAppendBufPlain( Target, pData, pTmpl->Tokens[i]->pTokenStart - pData, 0);
+ StrBufAppendBufPlain(Target, pData, pTmpl->Tokens[i]->pTokenStart - pData, 0);
TPtr->Tokens = pTmpl->Tokens[i];
TPtr->nArgs = pTmpl->Tokens[i]->nParameters;
- TokenRc = EvaluateToken(Target, TokenRc, &TPtr);
+ TokenRc = EvaluateToken(Target, TokenRc, &TPtr);
if (TokenRc > 0) {
state = eSkipTilEnd;
}
@@ -1781,24 +1578,18 @@ const StrBuf *ProcessTemplate(WCTemplate *Tmpl, StrBuf *Target, WCTemplputParams
TokenRc = 0;
}
- while ((state != eNext) && (i+1 < pTmpl->nTokensUsed)) {
- /* condition told us to skip till its end condition */
+ while ((state != eNext) && (i + 1 < pTmpl->nTokensUsed)) {
+ /* condition told us to skip till its end condition */
i++;
TPtr->Tokens = pTmpl->Tokens[i];
TPtr->nArgs = pTmpl->Tokens[i]->nParameters;
- if ((pTmpl->Tokens[i]->Flags == SV_CONDITIONAL) ||
- (pTmpl->Tokens[i]->Flags == SV_NEG_CONDITIONAL))
- {
+ if ((pTmpl->Tokens[i]->Flags == SV_CONDITIONAL) || (pTmpl->Tokens[i]->Flags == SV_NEG_CONDITIONAL)) {
int rc;
- rc = EvaluateConditional(
- Target,
- pTmpl->Tokens[i]->Flags,
- TokenRc,
- &TPtr);
+ rc = EvaluateConditional(Target, pTmpl->Tokens[i]->Flags, TokenRc, &TPtr);
if (-rc == TokenRc) {
TokenRc = 0;
state = eNext;
- if ((TPtr != &TP) && (TPtr->ExitCTXID == - rc)) {
+ if ((TPtr != &TP) && (TPtr->ExitCTXID == -rc)) {
UnStackDynamicContext(Target, &TPtr);
}
}
@@ -1819,18 +1610,18 @@ const StrBuf *ProcessTemplate(WCTemplate *Tmpl, StrBuf *Target, WCTemplputParams
StrBuf *textPlainType;
+
/**
* \brief Display a variable-substituted template
* \param templatename template file to load
* \returns the mimetype of the template its doing
*/
-const StrBuf *DoTemplate(const char *templatename, long len, StrBuf *Target, WCTemplputParams *TP)
-{
+const StrBuf *DoTemplate(const char *templatename, long len, StrBuf * Target, WCTemplputParams * TP) {
WCTemplputParams LocalTP;
HashList *Static;
HashList *StaticLocal;
void *vTmpl;
-
+
if (Target == NULL)
Target = WC->WBuf;
if (TP == NULL) {
@@ -1847,15 +1638,13 @@ const StrBuf *DoTemplate(const char *templatename, long len, StrBuf *Target, WCT
return textPlainType;
}
- if (!GetHash(StaticLocal, templatename, len, &vTmpl) &&
- !GetHash(Static, templatename, len, &vTmpl)) {
+ if (!GetHash(StaticLocal, templatename, len, &vTmpl) && !GetHash(Static, templatename, len, &vTmpl)) {
StrBuf *escapedString = NewStrBufPlain(NULL, len);
-
+
StrHtmlEcmaEscAppend(escapedString, NULL, templatename, 1, 1);
- syslog(LOG_WARNING, "didn't find Template [%s] %ld %ld\n", ChrPtr(escapedString), len , (long)strlen(templatename));
- StrBufAppendPrintf(Target, "\ndidn't find Template [%s] %ld %ld\n ",
- ChrPtr(escapedString), len,
- (long)strlen(templatename));
+ syslog(LOG_WARNING, "didn't find Template [%s] %ld %ld\n", ChrPtr(escapedString), len, (long) strlen(templatename));
+ StrBufAppendPrintf(Target, "\ndidn't find Template [%s] %ld %ld\n ",
+ ChrPtr(escapedString), len, (long) strlen(templatename));
WC->isFailure = 1;
#if 0
dbg_PrintHash(Static, PrintTemplate, NULL);
@@ -1864,17 +1653,15 @@ const StrBuf *DoTemplate(const char *templatename, long len, StrBuf *Target, WCT
FreeStrBuf(&escapedString);
return textPlainType;
}
- if (vTmpl == NULL)
+ if (vTmpl == NULL)
return textPlainType;
return ProcessTemplate(vTmpl, Target, TP);
}
-void tmplput_Comment(StrBuf *Target, WCTemplputParams *TP)
-{
- if (LoadTemplates != 0)
- {
+void tmplput_Comment(StrBuf * Target, WCTemplputParams * TP) {
+ if (LoadTemplates != 0) {
StrBuf *Comment;
const char *pch;
long len;
@@ -1903,20 +1690,16 @@ typedef struct _HashIterator {
FilterByParamFunc Filter;
} HashIterator;
-void RegisterITERATOR(const char *Name, long len,
- int AdditionalParams,
- HashList *StaticList,
- RetrieveHashlistFunc GetHash,
+void RegisterITERATOR(const char *Name, long len,
+ int AdditionalParams,
+ HashList * StaticList,
+ RetrieveHashlistFunc GetHash,
SubTemplFunc DoSubTempl,
HashDestructorFunc Destructor,
- FilterByParamFunc Filter,
- CtxType ContextType,
- CtxType XPectContextType,
- int Flags)
-{
+ FilterByParamFunc Filter, CtxType ContextType, CtxType XPectContextType, int Flags) {
HashIterator *It;
- It = (HashIterator*)malloc(sizeof(HashIterator));
+ It = (HashIterator *) malloc(sizeof(HashIterator));
memset(It, 0, sizeof(HashIterator));
It->StaticList = StaticList;
It->AdditionalParams = AdditionalParams;
@@ -1937,10 +1720,9 @@ typedef struct _iteratestruct {
long KeyLen;
int n;
int LastN;
- }IterateStruct;
+} IterateStruct;
-int preeval_iterate(WCTemplateToken *Token)
-{
+int preeval_iterate(WCTemplateToken * Token) {
WCTemplputParams TPP;
WCTemplputParams *TP;
void *vTmpl;
@@ -1951,42 +1733,33 @@ int preeval_iterate(WCTemplateToken *Token)
TP = &TPP;
TP->Tokens = Token;
if (!GetHash(Iterators, TKEY(0), &vIt)) {
- LogTemplateError(
- NULL, "Iterator", ERR_PARM1, TP,
- "not found");
+ LogTemplateError(NULL, "Iterator", ERR_PARM1, TP, "not found");
return 0;
}
if (TP->Tokens->Params[1]->Type != TYPE_SUBTEMPLATE) {
LogTemplateError(NULL, "Iterator", ERR_PARM1, TP,
- "Need token with type Subtemplate as param 1, have %s",
- TP->Tokens->Params[1]->Start);
+ "Need token with type Subtemplate as param 1, have %s", TP->Tokens->Params[1]->Start);
}
-
+
/* well, we don't check the mobile stuff here... */
- if (!GetHash(LocalTemplateCache, TKEY(1), &vTmpl) &&
- !GetHash(TemplateCache, TKEY(1), &vTmpl)) {
- LogTemplateError(NULL, "SubTemplate", ERR_PARM1, TP,
- "referenced here doesn't exist");
+ if (!GetHash(LocalTemplateCache, TKEY(1), &vTmpl) && !GetHash(TemplateCache, TKEY(1), &vTmpl)) {
+ LogTemplateError(NULL, "SubTemplate", ERR_PARM1, TP, "referenced here doesn't exist");
}
Token->Preeval2 = vIt;
It = (HashIterator *) vIt;
if (TP->Tokens->nParameters < It->AdditionalParams + 2) {
- LogTemplateError(
- NULL, "Iterator", ERR_PARM1, TP,
- "doesn't work with %d params",
- TP->Tokens->nParameters);
+ LogTemplateError(NULL, "Iterator", ERR_PARM1, TP, "doesn't work with %d params", TP->Tokens->nParameters);
}
return 1;
}
-void tmpl_iterate_subtmpl(StrBuf *Target, WCTemplputParams *TP)
-{
+void tmpl_iterate_subtmpl(StrBuf * Target, WCTemplputParams * TP) {
HashIterator *It;
HashList *List;
- HashPos *it;
+ HashPos *it;
SortStruct *SortBy = NULL;
void *vSortBy;
int DetectGroupChange = 0;
@@ -2003,31 +1776,24 @@ void tmpl_iterate_subtmpl(StrBuf *Target, WCTemplputParams *TP)
long StopAt = -1;
memset(&Status, 0, sizeof(IterateStruct));
-
- It = (HashIterator*) TP->Tokens->Preeval2;
+
+ It = (HashIterator *) TP->Tokens->Preeval2;
if (It == NULL) {
- LogTemplateError(
- Target, "Iterator", ERR_PARM1, TP, "Unknown!");
+ LogTemplateError(Target, "Iterator", ERR_PARM1, TP, "Unknown!");
return;
}
if (TP->Tokens->nParameters < It->AdditionalParams + 2) {
- LogTemplateError(
- Target, "Iterator", ERR_PARM1, TP,
- "doesn't work with %d params",
- TP->Tokens->nParameters - 1);
+ LogTemplateError(Target, "Iterator", ERR_PARM1, TP, "doesn't work with %d params", TP->Tokens->nParameters - 1);
return;
}
- if ((It->XPectContextType != CTX_NONE) &&
- (It->XPectContextType != TP->Filter.ContextType)) {
- LogTemplateError(
- Target, "Iterator", ERR_PARM1, TP,
- "requires context of type %s, have %s",
- ContextName(It->XPectContextType),
- ContextName(TP->Filter.ContextType));
- return ;
-
+ if ((It->XPectContextType != CTX_NONE) && (It->XPectContextType != TP->Filter.ContextType)) {
+ LogTemplateError(Target, "Iterator", ERR_PARM1, TP,
+ "requires context of type %s, have %s",
+ ContextName(It->XPectContextType), ContextName(TP->Filter.ContextType));
+ return;
+
}
if (It->StaticList == NULL)
@@ -2041,11 +1807,11 @@ void tmpl_iterate_subtmpl(StrBuf *Target, WCTemplputParams *TP)
DetectGroupChange = 0;
if (havebstr("SortBy")) {
BSort = sbstr("SortBy");
- if (GetHash(SortHash, SKEY(BSort), &vSortBy) &&
- (vSortBy != NULL)) {
- SortBy = (SortStruct*)vSortBy;
+ if (GetHash(SortHash, SKEY(BSort), &vSortBy) && (vSortBy != NULL)) {
+ SortBy = (SortStruct *) vSortBy;
/* first check whether its intended for us... */
- if ((SortBy->ContextType == It->ContextType)&&
+ if ((SortBy->ContextType == It->ContextType) &&
+
/** Ok, its us, lets see in which direction we should sort... */
(havebstr("SortOrder"))) {
int SortOrder;
@@ -2058,10 +1824,10 @@ void tmpl_iterate_subtmpl(StrBuf *Target, WCTemplputParams *TP)
}
nMembersUsed = GetCount(List);
- StackContext (TP, &IterateTP, &Status, CTX_ITERATE, 0, TP->Tokens);
+ StackContext(TP, &IterateTP, &Status, CTX_ITERATE, 0, TP->Tokens);
{
SubBuf = NewStrBuf();
-
+
if (HAVE_PARAM(2)) {
StartAt = GetTemplateTokenNumber(Target, TP, 2, 0);
}
@@ -2078,9 +1844,7 @@ void tmpl_iterate_subtmpl(StrBuf *Target, WCTemplputParams *TP)
while (GetNextHashPos(List, it, &Status.KeyLen, &Status.Key, &vContext)) {
if ((Status.n >= StartAt) && (Status.n <= StopAt)) {
- if ((It->Filter != NULL) &&
- !It->Filter(Status.Key, Status.KeyLen, vContext, Target, TP))
- {
+ if ((It->Filter != NULL) && !It->Filter(Status.Key, Status.KeyLen, vContext, Target, TP)) {
continue;
}
@@ -2098,7 +1862,7 @@ void tmpl_iterate_subtmpl(StrBuf *Target, WCTemplputParams *TP)
FlushStrBuf(SubBuf);
}
UnStackContext(&SubTP);
- Status.oddeven = ! Status.oddeven;
+ Status.oddeven = !Status.oddeven;
vLastContext = vContext;
}
Status.n++;
@@ -2112,17 +1876,15 @@ void tmpl_iterate_subtmpl(StrBuf *Target, WCTemplputParams *TP)
}
-int conditional_ITERATE_ISGROUPCHANGE(StrBuf *Target, WCTemplputParams *TP)
-{
+int conditional_ITERATE_ISGROUPCHANGE(StrBuf * Target, WCTemplputParams * TP) {
IterateStruct *Ctx = CTX(CTX_ITERATE);
if (TP->Tokens->nParameters < 3)
- return Ctx->GroupChange;
+ return Ctx->GroupChange;
return TP->Tokens->Params[2]->lvalue == Ctx->GroupChange;
}
-void tmplput_ITERATE_ODDEVEN(StrBuf *Target, WCTemplputParams *TP)
-{
+void tmplput_ITERATE_ODDEVEN(StrBuf * Target, WCTemplputParams * TP) {
IterateStruct *Ctx = CTX(CTX_ITERATE);
if (Ctx->oddeven)
StrBufAppendBufPlain(Target, HKEY("odd"), 0);
@@ -2131,15 +1893,13 @@ void tmplput_ITERATE_ODDEVEN(StrBuf *Target, WCTemplputParams *TP)
}
-void tmplput_ITERATE_KEY(StrBuf *Target, WCTemplputParams *TP)
-{
+void tmplput_ITERATE_KEY(StrBuf * Target, WCTemplputParams * TP) {
IterateStruct *Ctx = CTX(CTX_ITERATE);
StrBufAppendBufPlain(Target, Ctx->Key, Ctx->KeyLen, 0);
}
-void tmplput_ITERATE_N_DIV(StrBuf *Target, WCTemplputParams *TP)
-{
+void tmplput_ITERATE_N_DIV(StrBuf * Target, WCTemplputParams * TP) {
IterateStruct *Ctx = CTX(CTX_ITERATE);
long div;
long divisor = GetTemplateTokenNumber(Target, TP, 0, 1);
@@ -2148,31 +1908,27 @@ void tmplput_ITERATE_N_DIV(StrBuf *Target, WCTemplputParams *TP)
StrBufAppendPrintf(Target, "%ld", div);
}
-void tmplput_ITERATE_N(StrBuf *Target, WCTemplputParams *TP)
-{
+void tmplput_ITERATE_N(StrBuf * Target, WCTemplputParams * TP) {
IterateStruct *Ctx = CTX(CTX_ITERATE);
StrBufAppendPrintf(Target, "%d", Ctx->n);
}
-int conditional_ITERATE_FIRSTN(StrBuf *Target, WCTemplputParams *TP)
-{
+int conditional_ITERATE_FIRSTN(StrBuf * Target, WCTemplputParams * TP) {
IterateStruct *Ctx = CTX(CTX_ITERATE);
return Ctx->n == 0;
}
-int conditional_ITERATE_LASTN(StrBuf *Target, WCTemplputParams *TP)
-{
+int conditional_ITERATE_LASTN(StrBuf * Target, WCTemplputParams * TP) {
IterateStruct *Ctx = CTX(CTX_ITERATE);
return Ctx->LastN;
}
-int conditional_ITERATE_ISMOD(StrBuf *Target, WCTemplputParams *TP)
-{
+int conditional_ITERATE_ISMOD(StrBuf * Target, WCTemplputParams * TP) {
IterateStruct *Ctx = CTX(CTX_ITERATE);
long divisor = GetTemplateTokenNumber(Target, TP, 2, 1);
long expectRemainder = GetTemplateTokenNumber(Target, TP, 3, 0);
-
+
return Ctx->n % divisor == expectRemainder;
}
@@ -2181,24 +1937,19 @@ int conditional_ITERATE_ISMOD(StrBuf *Target, WCTemplputParams *TP)
/*-----------------------------------------------------------------------------
* Conditionals
*/
-int EvaluateConditional(StrBuf *Target, int Neg, int state, WCTemplputParams **TPP)
-{
+int EvaluateConditional(StrBuf * Target, int Neg, int state, WCTemplputParams ** TPP) {
ConditionalStruct *Cond;
int rc = 0;
int res;
WCTemplputParams *TP = *TPP;
- if ((TP->Tokens->Params[0]->len == 1) &&
- (TP->Tokens->Params[0]->Start[0] == 'X'))
- {
- return - (TP->Tokens->Params[1]->lvalue);
+ if ((TP->Tokens->Params[0]->len == 1) && (TP->Tokens->Params[0]->Start[0] == 'X')) {
+ return -(TP->Tokens->Params[1]->lvalue);
}
-
+
Cond = (ConditionalStruct *) TP->Tokens->PreEval;
if (Cond == NULL) {
- LogTemplateError(
- Target, "Conditional", ERR_PARM1, TP,
- "unknown!");
+ LogTemplateError(Target, "Conditional", ERR_PARM1, TP, "unknown!");
return 0;
}
@@ -2210,27 +1961,20 @@ int EvaluateConditional(StrBuf *Target, int Neg, int state, WCTemplputParams **T
if (res == Neg)
rc = TP->Tokens->Params[1]->lvalue;
- if (LoadTemplates > 5)
- syslog(LOG_DEBUG, "<%s> : %d %d==%d\n",
- ChrPtr(TP->Tokens->FlatToken),
- rc, res, Neg);
+ if (LoadTemplates > 5)
+ syslog(LOG_DEBUG, "<%s> : %d %d==%d\n", ChrPtr(TP->Tokens->FlatToken), rc, res, Neg);
- if (TP->Sub != NULL)
- {
+ if (TP->Sub != NULL) {
*TPP = TP->Sub;
}
return rc;
}
-void RegisterContextConditional(const char *Name, long len,
- int nParams,
- WCConditionalFunc CondF,
- WCConditionalFunc ExitCtxCond,
- int ContextRequired)
-{
+void RegisterContextConditional(const char *Name, long len,
+ int nParams, WCConditionalFunc CondF, WCConditionalFunc ExitCtxCond, int ContextRequired) {
ConditionalStruct *Cond;
- Cond = (ConditionalStruct*)malloc(sizeof(ConditionalStruct));
+ Cond = (ConditionalStruct *) malloc(sizeof(ConditionalStruct));
memset(Cond, 0, sizeof(ConditionalStruct));
Cond->PlainName = Name;
Cond->Filter.nMaxArgs = nParams;
@@ -2241,43 +1985,34 @@ void RegisterContextConditional(const char *Name, long len,
Put(Conditionals, Name, len, Cond, NULL);
}
-void RegisterTokenParamDefine(const char *Name, long len,
- long Value)
-{
+void RegisterTokenParamDefine(const char *Name, long len, long Value) {
long *PVal;
- PVal = (long*)malloc(sizeof(long));
+ PVal = (long *) malloc(sizeof(long));
*PVal = Value;
Put(Defines, Name, len, PVal, NULL);
}
-long GetTokenDefine(const char *Name, long len,
- long DefValue)
-{
+long GetTokenDefine(const char *Name, long len, long DefValue) {
void *vPVal;
- if (GetHash(Defines, Name, len, &vPVal) &&
- (vPVal != NULL))
- {
- return *(long*) vPVal;
- }
- else
- {
- return DefValue;
- }
+ if (GetHash(Defines, Name, len, &vPVal) && (vPVal != NULL)) {
+ return *(long *) vPVal;
+ }
+ else {
+ return DefValue;
+ }
}
-void tmplput_DefStr(StrBuf *Target, WCTemplputParams *TP)
-{
+void tmplput_DefStr(StrBuf * Target, WCTemplputParams * TP) {
const char *Str;
long len;
GetTemplateTokenString(Target, TP, 2, &Str, &len);
-
+
StrBufAppendBufPlain(Target, Str, len, 0);
}
-void tmplput_DefVal(StrBuf *Target, WCTemplputParams *TP)
-{
+void tmplput_DefVal(StrBuf * Target, WCTemplputParams * TP) {
int val;
val = GetTemplateTokenNumber(Target, TP, 0, 0);
@@ -2289,13 +2024,11 @@ HashList *Defines;
/*-----------------------------------------------------------------------------
* Context Strings
*/
-void tmplput_ContextString(StrBuf *Target, WCTemplputParams *TP)
-{
- StrBufAppendTemplate(Target, TP, (StrBuf*)CTX(CTX_STRBUF), 0);
+void tmplput_ContextString(StrBuf * Target, WCTemplputParams * TP) {
+ StrBufAppendTemplate(Target, TP, (StrBuf *) CTX(CTX_STRBUF), 0);
}
-int ConditionalContextStr(StrBuf *Target, WCTemplputParams *TP)
-{
- StrBuf *TokenText = (StrBuf*) CTX((CTX_STRBUF));
+int ConditionalContextStr(StrBuf * Target, WCTemplputParams * TP) {
+ StrBuf *TokenText = (StrBuf *) CTX((CTX_STRBUF));
const char *CompareToken;
long len;
@@ -2303,21 +2036,18 @@ int ConditionalContextStr(StrBuf *Target, WCTemplputParams *TP)
return strcmp(ChrPtr(TokenText), CompareToken) == 0;
}
-void tmplput_ContextStringArray(StrBuf *Target, WCTemplputParams *TP)
-{
- HashList *Arr = (HashList*) CTX(CTX_STRBUFARR);
+void tmplput_ContextStringArray(StrBuf * Target, WCTemplputParams * TP) {
+ HashList *Arr = (HashList *) CTX(CTX_STRBUFARR);
void *pV;
int val;
val = GetTemplateTokenNumber(Target, TP, 0, 0);
- if (GetHash(Arr, IKEY(val), &pV) &&
- (pV != NULL)) {
- StrBufAppendTemplate(Target, TP, (StrBuf*)pV, 1);
+ if (GetHash(Arr, IKEY(val), &pV) && (pV != NULL)) {
+ StrBufAppendTemplate(Target, TP, (StrBuf *) pV, 1);
}
}
-int ConditionalContextStrinArray(StrBuf *Target, WCTemplputParams *TP)
-{
- HashList *Arr = (HashList*) CTX(CTX_STRBUFARR);
+int ConditionalContextStrinArray(StrBuf * Target, WCTemplputParams * TP) {
+ HashList *Arr = (HashList *) CTX(CTX_STRBUFARR);
void *pV;
int val;
const char *CompareToken;
@@ -2325,9 +2055,8 @@ int ConditionalContextStrinArray(StrBuf *Target, WCTemplputParams *TP)
GetTemplateTokenString(Target, TP, 2, &CompareToken, &len);
val = GetTemplateTokenNumber(Target, TP, 0, 0);
- if (GetHash(Arr, IKEY(val), &pV) &&
- (pV != NULL)) {
- return strcmp(ChrPtr((StrBuf*)pV), CompareToken) == 0;
+ if (GetHash(Arr, IKEY(val), &pV) && (pV != NULL)) {
+ return strcmp(ChrPtr((StrBuf *) pV), CompareToken) == 0;
}
else
return 0;
@@ -2337,8 +2066,7 @@ int ConditionalContextStrinArray(StrBuf *Target, WCTemplputParams *TP)
* Boxed-API
*/
-void tmpl_do_boxed(StrBuf *Target, WCTemplputParams *TP)
-{
+void tmpl_do_boxed(StrBuf * Target, WCTemplputParams * TP) {
WCTemplputParams SubTP;
StrBuf *Headline = NULL;
@@ -2350,17 +2078,13 @@ void tmpl_do_boxed(StrBuf *Target, WCTemplputParams *TP)
else {
const char *Ch;
long len;
- GetTemplateTokenString(Target,
- TP,
- 1,
- &Ch,
- &len);
+ GetTemplateTokenString(Target, TP, 1, &Ch, &len);
Headline = NewStrBufPlain(Ch, len);
}
}
/* else TODO error? logging? */
- StackContext (TP, &SubTP, Headline, CTX_STRBUF, 0, NULL);
+ StackContext(TP, &SubTP, Headline, CTX_STRBUF, 0, NULL);
{
DoTemplate(HKEY("box_begin"), Target, &SubTP);
}
@@ -2379,8 +2103,7 @@ typedef struct _tab_struct {
StrBuf *TabTitle;
} tab_struct;
-int preeval_do_tabbed(WCTemplateToken *Token)
-{
+int preeval_do_tabbed(WCTemplateToken * Token) {
WCTemplputParams TPP;
WCTemplputParams *TP;
const char *Ch;
@@ -2391,49 +2114,30 @@ int preeval_do_tabbed(WCTemplateToken *Token)
TP = &TPP;
TP->Tokens = Token;
nTabs = TP->Tokens->nParameters / 2 - 1;
- if (TP->Tokens->nParameters % 2 != 0)
- {
- LogTemplateError(NULL, "TabbedApi", ERR_PARM1, TP,
- "need even number of arguments");
+ if (TP->Tokens->nParameters % 2 != 0) {
+ LogTemplateError(NULL, "TabbedApi", ERR_PARM1, TP, "need even number of arguments");
return 0;
}
- else for (i = 0; i < nTabs; i++) {
- if (!HaveTemplateTokenString(NULL,
- TP,
- i * 2,
- &Ch,
- &len) ||
- (TP->Tokens->Params[i * 2]->len == 0))
- {
- LogTemplateError(NULL, "TabbedApi", ERR_PARM1, TP,
- "Tab-Subject %d needs to be able to produce a string, have %s",
- i, TP->Tokens->Params[i * 2]->Start);
- return 0;
- }
- if (!HaveTemplateTokenString(NULL,
- TP,
- i * 2 + 1,
- &Ch,
- &len) ||
- (TP->Tokens->Params[i * 2 + 1]->len == 0))
- {
- LogTemplateError(NULL, "TabbedApi", ERR_PARM1, TP,
- "Tab-Content %d needs to be able to produce a string, have %s",
- i, TP->Tokens->Params[i * 2 + 1]->Start);
- return 0;
+ else
+ for (i = 0; i < nTabs; i++) {
+ if (!HaveTemplateTokenString(NULL, TP, i * 2, &Ch, &len) || (TP->Tokens->Params[i * 2]->len == 0)) {
+ LogTemplateError(NULL, "TabbedApi", ERR_PARM1, TP,
+ "Tab-Subject %d needs to be able to produce a string, have %s",
+ i, TP->Tokens->Params[i * 2]->Start);
+ return 0;
+ }
+ if (!HaveTemplateTokenString(NULL, TP, i * 2 + 1, &Ch, &len) || (TP->Tokens->Params[i * 2 + 1]->len == 0)) {
+ LogTemplateError(NULL, "TabbedApi", ERR_PARM1, TP,
+ "Tab-Content %d needs to be able to produce a string, have %s",
+ i, TP->Tokens->Params[i * 2 + 1]->Start);
+ return 0;
+ }
}
- }
- if (!HaveTemplateTokenString(NULL,
- TP,
- i * 2 + 1,
- &Ch,
- &len) ||
- (TP->Tokens->Params[i * 2 + 1]->len == 0))
- {
+ if (!HaveTemplateTokenString(NULL, TP, i * 2 + 1, &Ch, &len) || (TP->Tokens->Params[i * 2 + 1]->len == 0)) {
LogTemplateError(NULL, "TabbedApi", ERR_PARM1, TP,
- "Tab-Content %d needs to be able to produce a string, have %s",
+ "Tab-Content %d needs to be able to produce a string, have %s",
i, TP->Tokens->Params[i * 2 + 1]->Start);
return 0;
}
@@ -2441,8 +2145,7 @@ int preeval_do_tabbed(WCTemplateToken *Token)
}
-void tmpl_do_tabbed(StrBuf *Target, WCTemplputParams *TP)
-{
+void tmpl_do_tabbed(StrBuf * Target, WCTemplputParams * TP) {
StrBuf **TabNames;
int i, ntabs, nTabs;
tab_struct TS;
@@ -2451,31 +2154,27 @@ void tmpl_do_tabbed(StrBuf *Target, WCTemplputParams *TP)
memset(&TS, 0, sizeof(tab_struct));
nTabs = ntabs = TP->Tokens->nParameters / 2;
- TabNames = (StrBuf **) malloc(ntabs * sizeof(StrBuf*));
- memset(TabNames, 0, ntabs * sizeof(StrBuf*));
+ TabNames = (StrBuf **) malloc(ntabs * sizeof(StrBuf *));
+ memset(TabNames, 0, ntabs * sizeof(StrBuf *));
for (i = 0; i < ntabs; i++) {
- if ((TP->Tokens->Params[i * 2]->Type == TYPE_STR) &&
- (TP->Tokens->Params[i * 2]->len > 0)) {
+ if ((TP->Tokens->Params[i * 2]->Type == TYPE_STR) && (TP->Tokens->Params[i * 2]->len > 0)) {
TabNames[i] = NewStrBuf();
DoTemplate(TKEY(i * 2), TabNames[i], TP);
}
else if (TP->Tokens->Params[i * 2]->Type == TYPE_GETTEXT) {
const char *Ch;
long len;
- GetTemplateTokenString(Target,
- TP,
- i * 2,
- &Ch,
- &len);
+ GetTemplateTokenString(Target, TP, i * 2, &Ch, &len);
TabNames[i] = NewStrBufPlain(Ch, -1);
}
- else {
+ else {
+
/** A Tab without subject? we can't count that, add it as silent */
- nTabs --;
+ nTabs--;
}
}
- StackContext (TP, &SubTP, &TS, CTX_TAB, 0, NULL);
+ StackContext(TP, &SubTP, &TS, CTX_TAB, 0, NULL);
{
StrTabbedDialog(Target, nTabs, TabNames);
for (i = 0; i < ntabs; i++) {
@@ -2486,22 +2185,20 @@ void tmpl_do_tabbed(StrBuf *Target, WCTemplputParams *TP)
DoTemplate(TKEY(i * 2 + 1), Target, &SubTP);
StrEndTab(Target, i, nTabs);
}
- for (i = 0; i < ntabs; i++)
+ for (i = 0; i < ntabs; i++)
FreeStrBuf(&TabNames[i]);
free(TabNames);
}
UnStackContext(&SubTP);
}
-void tmplput_TAB_N(StrBuf *Target, WCTemplputParams *TP)
-{
+void tmplput_TAB_N(StrBuf * Target, WCTemplputParams * TP) {
tab_struct *Ctx = CTX(CTX_TAB);
StrBufAppendPrintf(Target, "%d", Ctx->CurrentTab);
}
-void tmplput_TAB_TITLE(StrBuf *Target, WCTemplputParams *TP)
-{
+void tmplput_TAB_TITLE(StrBuf * Target, WCTemplputParams * TP) {
tab_struct *Ctx = CTX(CTX_TAB);
StrBufAppendTemplate(Target, TP, Ctx->TabTitle, 0);
}
@@ -2511,16 +2208,12 @@ void tmplput_TAB_TITLE(StrBuf *Target, WCTemplputParams *TP)
*/
-void RegisterSortFunc(const char *name, long len,
+void RegisterSortFunc(const char *name, long len,
const char *prepend, long preplen,
- CompareFunc Forward,
- CompareFunc Reverse,
- CompareFunc GroupChange,
- CtxType ContextType)
-{
+ CompareFunc Forward, CompareFunc Reverse, CompareFunc GroupChange, CtxType ContextType) {
SortStruct *NewSort;
- NewSort = (SortStruct*) malloc(sizeof(SortStruct));
+ NewSort = (SortStruct *) malloc(sizeof(SortStruct));
memset(NewSort, 0, sizeof(SortStruct));
NewSort->Name = NewStrBufPlain(name, len);
if (prepend != NULL)
@@ -2535,19 +2228,17 @@ void RegisterSortFunc(const char *name, long len,
syslog(LOG_WARNING, "sorting requires a context. CTX_NONE won't make it.\n");
exit(1);
}
-
+
Put(SortHash, name, len, NewSort, DestroySortStruct);
}
-CompareFunc RetrieveSort(WCTemplputParams *TP,
- const char *OtherPrefix, long OtherPrefixLen,
- const char *Default, long ldefault, long DefaultDirection)
-{
+CompareFunc RetrieveSort(WCTemplputParams * TP,
+ const char *OtherPrefix, long OtherPrefixLen, const char *Default, long ldefault, long DefaultDirection) {
const StrBuf *BSort = NULL;
SortStruct *SortBy;
void *vSortBy;
long SortOrder = -1;
-
+
if (havebstr("SortBy")) {
BSort = sbstr("SortBy");
if (OtherPrefix == NULL) {
@@ -2557,6 +2248,7 @@ CompareFunc RetrieveSort(WCTemplputParams *TP,
set_X_PREFS(HKEY("sort"), OtherPrefix, OtherPrefixLen, NewStrBufDup(BSort), 0);
}
}
+
else { /** Try to fallback to our remembered values... */
if (OtherPrefix == NULL) {
BSort = get_room_pref("sort");
@@ -2574,17 +2266,13 @@ CompareFunc RetrieveSort(WCTemplputParams *TP,
}
}
- if (!GetHash(SortHash, SKEY(BSort), &vSortBy) ||
- (vSortBy == NULL)) {
- if (!GetHash(SortHash, Default, ldefault, &vSortBy) ||
- (vSortBy == NULL)) {
- LogTemplateError(
- NULL, "Sorting", ERR_PARM1, TP,
- "Illegal default sort: [%s]", Default);
+ if (!GetHash(SortHash, SKEY(BSort), &vSortBy) || (vSortBy == NULL)) {
+ if (!GetHash(SortHash, Default, ldefault, &vSortBy) || (vSortBy == NULL)) {
+ LogTemplateError(NULL, "Sorting", ERR_PARM1, TP, "Illegal default sort: [%s]", Default);
wc_backtrace(LOG_WARNING);
}
}
- SortBy = (SortStruct*)vSortBy;
+ SortBy = (SortStruct *) vSortBy;
if (SortBy->ContextType != TP->Filter.ContextType)
return NULL;
@@ -2593,6 +2281,7 @@ CompareFunc RetrieveSort(WCTemplputParams *TP,
if (havebstr("SortOrder")) {
SortOrder = lbstr("SortOrder");
}
+
else { /** Try to fallback to our remembered values... */
StrBuf *Buf = NULL;
if (SortBy->PrefPrepend == NULL) {
@@ -2623,38 +2312,36 @@ CompareFunc RetrieveSort(WCTemplputParams *TP,
enum {
- eNO_SUCH_SORT,
+ eNO_SUCH_SORT,
eNOT_SPECIFIED,
eINVALID_PARAM,
eFOUND
};
ConstStr SortIcons[] = {
- {HKEY("static/webcit_icons/sort_none.gif")},
- {HKEY("static/webcit_icons/up_pointer.gif")},
- {HKEY("static/webcit_icons/down_pointer.gif")},
+ { HKEY("static/webcit_icons/sort_none.gif") },
+ { HKEY("static/webcit_icons/up_pointer.gif") },
+ { HKEY("static/webcit_icons/down_pointer.gif") },
};
ConstStr SortNextOrder[] = {
- {HKEY("1")},
- {HKEY("2")},
- {HKEY("0")},
+ { HKEY("1") },
+ { HKEY("2") },
+ { HKEY("0") },
};
-int GetSortMetric(WCTemplputParams *TP, SortStruct **Next, SortStruct **Param, long *SortOrder, int N)
-{
+int GetSortMetric(WCTemplputParams * TP, SortStruct ** Next, SortStruct ** Param, long *SortOrder, int N) {
int bSortError = eNOT_SPECIFIED;
const StrBuf *BSort;
void *vSort;
-
+
*SortOrder = 0;
*Next = NULL;
- if (!GetHash(SortHash, TKEY(0), &vSort) ||
- (vSort == NULL))
+ if (!GetHash(SortHash, TKEY(0), &vSort) || (vSort == NULL))
return eNO_SUCH_SORT;
- *Param = (SortStruct*) vSort;
-
+ *Param = (SortStruct *) vSort;
+
if (havebstr("SortBy")) {
BSort = sbstr("SortBy");
@@ -2666,6 +2353,7 @@ int GetSortMetric(WCTemplputParams *TP, SortStruct **Next, SortStruct **Param, l
set_X_PREFS(HKEY("sort"), TKEY(N), NewStrBufDup(BSort), 0);
}
}
+
else { /** Try to fallback to our remembered values... */
if ((*Param)->PrefPrepend == NULL) {
BSort = get_room_pref("sort");
@@ -2675,16 +2363,16 @@ int GetSortMetric(WCTemplputParams *TP, SortStruct **Next, SortStruct **Param, l
}
}
- if (!GetHash(SortHash, SKEY(BSort), &vSort) ||
- (vSort == NULL))
+ if (!GetHash(SortHash, SKEY(BSort), &vSort) || (vSort == NULL))
return bSortError;
- *Next = (SortStruct*) vSort;
+ *Next = (SortStruct *) vSort;
/** Ok, its us, lets see in which direction we should sort... */
if (havebstr("SortOrder")) {
*SortOrder = lbstr("SortOrder");
}
+
else { /** Try to fallback to our remembered values... */
if ((*Param)->PrefPrepend == NULL) {
*SortOrder = StrTol(get_room_pref("SortOrder"));
@@ -2700,29 +2388,24 @@ int GetSortMetric(WCTemplputParams *TP, SortStruct **Next, SortStruct **Param, l
}
-void tmplput_SORT_ICON(StrBuf *Target, WCTemplputParams *TP)
-{
+void tmplput_SORT_ICON(StrBuf * Target, WCTemplputParams * TP) {
long SortOrder;
SortStruct *Next;
SortStruct *Param;
const ConstStr *SortIcon;
- switch (GetSortMetric(TP, &Next, &Param, &SortOrder, 2)){
+ switch (GetSortMetric(TP, &Next, &Param, &SortOrder, 2)) {
case eNO_SUCH_SORT:
- LogTemplateError(
- Target, "Sorter", ERR_PARM1, TP,
- " Sorter [%s] unknown!",
- TP->Tokens->Params[0]->Start);
- break;
+ LogTemplateError(Target, "Sorter", ERR_PARM1, TP, " Sorter [%s] unknown!", TP->Tokens->Params[0]->Start);
+ break;
case eINVALID_PARAM:
- LogTemplateError(NULL, "Sorter", ERR_PARM1, TP,
- " Sorter specified by BSTR 'SortBy' [%s] unknown!",
- bstr("SortBy"));
+ LogTemplateError(NULL, "Sorter", ERR_PARM1, TP, " Sorter specified by BSTR 'SortBy' [%s] unknown!", bstr("SortBy"));
case eNOT_SPECIFIED:
case eFOUND:
if (Next == Param) {
SortIcon = &SortIcons[SortOrder];
}
+
else { /** Not Us... */
SortIcon = &SortIcons[0];
}
@@ -2730,55 +2413,42 @@ void tmplput_SORT_ICON(StrBuf *Target, WCTemplputParams *TP)
}
}
-void tmplput_SORT_NEXT(StrBuf *Target, WCTemplputParams *TP)
-{
+void tmplput_SORT_NEXT(StrBuf * Target, WCTemplputParams * TP) {
long SortOrder;
SortStruct *Next;
SortStruct *Param;
- switch (GetSortMetric(TP, &Next, &Param, &SortOrder, 2)){
+ switch (GetSortMetric(TP, &Next, &Param, &SortOrder, 2)) {
case eNO_SUCH_SORT:
- LogTemplateError(
- Target, "Sorter", ERR_PARM1, TP,
- " Sorter [%s] unknown!",
- TP->Tokens->Params[0]->Start);
- break;
+ LogTemplateError(Target, "Sorter", ERR_PARM1, TP, " Sorter [%s] unknown!", TP->Tokens->Params[0]->Start);
+ break;
case eINVALID_PARAM:
- LogTemplateError(
- NULL, "Sorter", ERR_PARM1, TP,
- " Sorter specified by BSTR 'SortBy' [%s] unknown!",
- bstr("SortBy"));
+ LogTemplateError(NULL, "Sorter", ERR_PARM1, TP, " Sorter specified by BSTR 'SortBy' [%s] unknown!", bstr("SortBy"));
case eNOT_SPECIFIED:
case eFOUND:
StrBufAppendBuf(Target, Param->Name, 0);
-
+
}
}
-void tmplput_SORT_ORDER(StrBuf *Target, WCTemplputParams *TP)
-{
+void tmplput_SORT_ORDER(StrBuf * Target, WCTemplputParams * TP) {
long SortOrder;
const ConstStr *SortOrderStr;
SortStruct *Next;
SortStruct *Param;
- switch (GetSortMetric(TP, &Next, &Param, &SortOrder, 2)){
+ switch (GetSortMetric(TP, &Next, &Param, &SortOrder, 2)) {
case eNO_SUCH_SORT:
- LogTemplateError(
- Target, "Sorter", ERR_PARM1, TP,
- " Sorter [%s] unknown!",
- TP->Tokens->Params[0]->Start);
- break;
+ LogTemplateError(Target, "Sorter", ERR_PARM1, TP, " Sorter [%s] unknown!", TP->Tokens->Params[0]->Start);
+ break;
case eINVALID_PARAM:
- LogTemplateError(
- NULL, "Sorter", ERR_PARM1, TP,
- " Sorter specified by BSTR 'SortBy' [%s] unknown!",
- bstr("SortBy"));
+ LogTemplateError(NULL, "Sorter", ERR_PARM1, TP, " Sorter specified by BSTR 'SortBy' [%s] unknown!", bstr("SortBy"));
case eNOT_SPECIFIED:
case eFOUND:
if (Next == Param) {
SortOrderStr = &SortNextOrder[SortOrder];
}
+
else { /** Not Us... */
SortOrderStr = &SortNextOrder[0];
}
@@ -2787,34 +2457,25 @@ void tmplput_SORT_ORDER(StrBuf *Target, WCTemplputParams *TP)
}
-void tmplput_long_vector(StrBuf *Target, WCTemplputParams *TP)
-{
- long *LongVector = (long*) CTX(CTX_LONGVECTOR);
+void tmplput_long_vector(StrBuf * Target, WCTemplputParams * TP) {
+ long *LongVector = (long *) CTX(CTX_LONGVECTOR);
- if ((TP->Tokens->Params[0]->Type == TYPE_LONG) &&
- (TP->Tokens->Params[0]->lvalue <= LongVector[0]))
- {
+ if ((TP->Tokens->Params[0]->Type == TYPE_LONG) && (TP->Tokens->Params[0]->lvalue <= LongVector[0])) {
StrBufAppendPrintf(Target, "%ld", LongVector[TP->Tokens->Params[0]->lvalue]);
}
- else
- {
+ else {
if (TP->Tokens->Params[0]->Type != TYPE_LONG) {
- LogTemplateError(
- Target, "Longvector", ERR_NAME, TP,
- "needs a numerical Parameter!");
+ LogTemplateError(Target, "Longvector", ERR_NAME, TP, "needs a numerical Parameter!");
}
else {
- LogTemplateError(
- Target, "LongVector", ERR_PARM1, TP,
- "doesn't have %ld Parameters, its just the size of %ld!",
- TP->Tokens->Params[0]->lvalue,
- LongVector[0]);
+ LogTemplateError(Target, "LongVector", ERR_PARM1, TP,
+ "doesn't have %ld Parameters, its just the size of %ld!",
+ TP->Tokens->Params[0]->lvalue, LongVector[0]);
}
}
}
-void dbg_print_longvector(long *LongVector)
-{
+void dbg_print_longvector(long *LongVector) {
StrBuf *Buf = NewStrBufPlain(HKEY("Longvector: ["));
int nItems = LongVector[0];
int i;
@@ -2830,48 +2491,33 @@ void dbg_print_longvector(long *LongVector)
FreeStrBuf(&Buf);
}
-int ConditionalLongVector(StrBuf *Target, WCTemplputParams *TP)
-{
- long *LongVector = (long*) CTX(CTX_LONGVECTOR);
+int ConditionalLongVector(StrBuf * Target, WCTemplputParams * TP) {
+ long *LongVector = (long *) CTX(CTX_LONGVECTOR);
- if ((TP->Tokens->Params[2]->Type == TYPE_LONG) &&
- (TP->Tokens->Params[2]->lvalue <= LongVector[0])&&
- (TP->Tokens->Params[3]->Type == TYPE_LONG) &&
- (TP->Tokens->Params[3]->lvalue <= LongVector[0]))
- {
- return LongVector[TP->Tokens->Params[2]->lvalue] ==
- LongVector[TP->Tokens->Params[3]->lvalue];
+ if ((TP->Tokens->Params[2]->Type == TYPE_LONG) &&
+ (TP->Tokens->Params[2]->lvalue <= LongVector[0]) &&
+ (TP->Tokens->Params[3]->Type == TYPE_LONG) && (TP->Tokens->Params[3]->lvalue <= LongVector[0])) {
+ return LongVector[TP->Tokens->Params[2]->lvalue] == LongVector[TP->Tokens->Params[3]->lvalue];
}
- else
- {
- if ((TP->Tokens->Params[2]->Type == TYPE_LONG) ||
- (TP->Tokens->Params[2]->Type == TYPE_LONG)) {
- LogTemplateError(
- Target, "ConditionalLongvector", ERR_PARM1, TP,
- "needs two long Parameter!");
+ else {
+ if ((TP->Tokens->Params[2]->Type == TYPE_LONG) || (TP->Tokens->Params[2]->Type == TYPE_LONG)) {
+ LogTemplateError(Target, "ConditionalLongvector", ERR_PARM1, TP, "needs two long Parameter!");
}
else {
- LogTemplateError(
- Target, "Longvector", ERR_PARM1, TP,
- "doesn't have %ld / %ld Parameters, its just the size of %ld!",
- TP->Tokens->Params[2]->lvalue,
- TP->Tokens->Params[3]->lvalue,
- LongVector[0]);
+ LogTemplateError(Target, "Longvector", ERR_PARM1, TP,
+ "doesn't have %ld / %ld Parameters, its just the size of %ld!",
+ TP->Tokens->Params[2]->lvalue, TP->Tokens->Params[3]->lvalue, LongVector[0]);
}
}
return 0;
}
-void tmplput_CURRENT_FILE(StrBuf *Target, WCTemplputParams *TP)
-{
+void tmplput_CURRENT_FILE(StrBuf * Target, WCTemplputParams * TP) {
StrBufAppendTemplate(Target, TP, TP->Tokens->FileName, 0);
}
-void
-InitModule_SUBST
-(void)
-{
+void InitModule_SUBST(void) {
RegisterCTX(CTX_TAB);
RegisterCTX(CTX_ITERATE);
@@ -2897,18 +2543,10 @@ InitModule_SUBST
RegisterConditional("COND:LONGVECTOR", 4, ConditionalLongVector, CTX_LONGVECTOR);
- RegisterConditional("COND:ITERATE:ISGROUPCHANGE", 2,
- conditional_ITERATE_ISGROUPCHANGE,
- CTX_ITERATE);
- RegisterConditional("COND:ITERATE:LASTN", 2,
- conditional_ITERATE_LASTN,
- CTX_ITERATE);
- RegisterConditional("COND:ITERATE:FIRSTN", 2,
- conditional_ITERATE_FIRSTN,
- CTX_ITERATE);
- RegisterConditional("COND:ITERATE:ISMOD", 3,
- conditional_ITERATE_ISMOD,
- CTX_ITERATE);
+ RegisterConditional("COND:ITERATE:ISGROUPCHANGE", 2, conditional_ITERATE_ISGROUPCHANGE, CTX_ITERATE);
+ RegisterConditional("COND:ITERATE:LASTN", 2, conditional_ITERATE_LASTN, CTX_ITERATE);
+ RegisterConditional("COND:ITERATE:FIRSTN", 2, conditional_ITERATE_FIRSTN, CTX_ITERATE);
+ RegisterConditional("COND:ITERATE:ISMOD", 3, conditional_ITERATE_ISMOD, CTX_ITERATE);
RegisterNamespace("ITERATE:ODDEVEN", 0, 0, tmplput_ITERATE_ODDEVEN, NULL, CTX_ITERATE);
RegisterNamespace("ITERATE:KEY", 0, 0, tmplput_ITERATE_KEY, NULL, CTX_ITERATE);
@@ -2923,10 +2561,7 @@ InitModule_SUBST
}
-void
-ServerStartModule_SUBST
-(void)
-{
+void ServerStartModule_SUBST(void) {
textPlainType = NewStrBufPlain(HKEY("text/plain"));
LocalTemplateCache = NewHash(1, NULL);
TemplateCache = NewHash(1, NULL);
@@ -2936,7 +2571,7 @@ ServerStartModule_SUBST
SortHash = NewHash(1, NULL);
Defines = NewHash(1, NULL);
CtxList = NewHash(1, NULL);
-
+
PutContextType(HKEY("CTX_NONE"), 0);
RegisterCTX(CTX_STRBUF);
@@ -2944,22 +2579,16 @@ ServerStartModule_SUBST
RegisterCTX(CTX_LONGVECTOR);
}
-void
-FinalizeModule_SUBST
-(void)
-{
+void FinalizeModule_SUBST(void) {
}
-void
-ServerShutdownModule_SUBST
-(void)
-{
+void ServerShutdownModule_SUBST(void) {
FreeStrBuf(&textPlainType);
DeleteHash(&TemplateCache);
DeleteHash(&LocalTemplateCache);
-
+
DeleteHash(&GlobalNS);
DeleteHash(&Iterators);
DeleteHash(&Conditionals);
@@ -2969,29 +2598,17 @@ ServerShutdownModule_SUBST
}
-void
-SessionNewModule_SUBST
-(wcsession *sess)
-{
+void SessionNewModule_SUBST(wcsession * sess) {
}
-void
-SessionAttachModule_SUBST
-(wcsession *sess)
-{
+void SessionAttachModule_SUBST(wcsession * sess) {
}
-void
-SessionDetachModule_SUBST
-(wcsession *sess)
-{
+void SessionDetachModule_SUBST(wcsession * sess) {
FreeStrBuf(&sess->WFBuf);
}
-void
-SessionDestroyModule_SUBST
-(wcsession *sess)
-{
+void SessionDestroyModule_SUBST(wcsession * sess) {
}
diff --git a/webcit/subst.h b/webcit/subst.h
index 063f46d21..4acf59f92 100644
--- a/webcit/subst.h
+++ b/webcit/subst.h
@@ -1,3 +1,4 @@
+
/*
* Copyright (c) 1996-2013 by the citadel.org team
*
@@ -38,12 +39,12 @@ extern HashList *LocalTemplateCache;
* \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 */
+ 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 */
};
#define CTX_NONE 0
@@ -55,7 +56,7 @@ typedef struct __CtxTypeStruct {
} CtxTypeStruct;
CtxTypeStruct *GetContextType(CtxType Type);
-void RegisterContextType(const char *name, long len, CtxType *TheCtx);
+void RegisterContextType(const char *name, long len, CtxType * TheCtx);
#define RegisterCTX(a) RegisterContextType(#a, sizeof(#a) - 1, &a)
extern CtxType CTX_STRBUF;
@@ -70,9 +71,9 @@ extern CtxType CTX_LONGVECTOR;
* if not, we will log/print an error and refuse to call it.
*/
typedef struct _contexts {
- CtxType ContextType; /* do we require a User Context ? */
- int nMinArgs; /* How many arguments do we need at least? */
- int nMaxArgs; /* up to how many arguments can we handle? */
+ CtxType ContextType; /* do we require a User Context ? */
+ int nMinArgs; /* How many arguments do we need at least? */
+ int nMaxArgs; /* up to how many arguments can we handle? */
} ContextFilter;
@@ -81,15 +82,15 @@ typedef struct WCTemplateToken WCTemplateToken;
typedef struct WCTemplputParams WCTemplputParams;
/* this is the signature of a tmplput function */
-typedef void (*WCHandlerFunc)(StrBuf *Target, WCTemplputParams *TP);
+typedef void (*WCHandlerFunc)(StrBuf * Target, WCTemplputParams * TP);
-/* if you want to pre-evaluate parts of your token, or do additional syntax, use this. */
-typedef int (*WCPreevalFunc)(WCTemplateToken *Token);
+/* if you want to pre-evaluate parts of your token, or do additional syntax, use this. */
+typedef int (*WCPreevalFunc)(WCTemplateToken * Token);
/* make a template token a lookup key: */
#define TKEY(a) TP->Tokens->Params[a]->Start, TP->Tokens->Params[a]->len
-void *GetContextPayload(WCTemplputParams *TP, CtxType ContextType);
+void *GetContextPayload(WCTemplputParams * TP, CtxType ContextType);
#define CTX(a) GetContextPayload(TP, a)
/**
@@ -97,16 +98,16 @@ void *GetContextPayload(WCTemplputParams *TP, CtxType ContextType);
* this is the signature of a conditional function
* Note: Target is just passed in for error messages; don't write onto it in regular cases.
*/
-typedef int (*WCConditionalFunc)(StrBuf *Target, WCTemplputParams *TP);
+typedef int (*WCConditionalFunc)(StrBuf * Target, WCTemplputParams * TP);
typedef enum _eBitMask {
eNO = 0,
eOR,
eAND
-}eBitMask;
+} eBitMask;
typedef struct _TemplateParam {
- /* are we a string or a number? */
+ /* are we a string or a number? */
int Type;
/* string data: */
const char *Start;
@@ -120,10 +121,10 @@ typedef struct _TemplateParam {
/**
* @ingroup subst
* Representation of a token; everything thats inbetween and >
- */
+ */
struct WCTemplateToken {
- /* Reference to the filename we're in to print error messages; not to be freed */
- const StrBuf *FileName;
+ /* Reference to the filename we're in to print error messages; not to be freed */
+ const StrBuf *FileName;
/* Raw copy of our original token; for error printing */
StrBuf *FlatToken;
/* Which line did the template parser pick us up in? For error printing */
@@ -164,7 +165,7 @@ struct WCTemplputParams {
WCTemplateToken *Tokens;
WCTemplputParams *Sub, *Super;
WCConditionalFunc ExitCtx;
- long ExitCTXID;
+ long ExitCTXID;
};
@@ -177,10 +178,10 @@ typedef struct _ConditionalStruct {
} ConditionalStruct;
-typedef void (*SubTemplFunc)(StrBuf *TemplBuffer, WCTemplputParams *TP);
-typedef HashList *(*RetrieveHashlistFunc)(StrBuf *Target, WCTemplputParams *TP);
-typedef void (*HashDestructorFunc) (HashList **KillMe);
-typedef int (*FilterByParamFunc)(const char* key, long len, void *Context, StrBuf *Target, WCTemplputParams *TP);
+typedef void (*SubTemplFunc)(StrBuf * TemplBuffer, WCTemplputParams * TP);
+typedef HashList *(*RetrieveHashlistFunc)(StrBuf * Target, WCTemplputParams * TP);
+typedef void (*HashDestructorFunc)(HashList ** KillMe);
+typedef int (*FilterByParamFunc)(const char *key, long len, void *Context, StrBuf * Target, WCTemplputParams * TP);
extern WCTemplputParams NoCtx;
@@ -190,6 +191,7 @@ extern WCTemplputParams NoCtx;
#define ERR_NAME 0
#define ERR_PARM1 1
#define ERR_PARM2 2
+
/**
* @ingroup subst
* @brief log an error while evaluating a token; print it to the actual template
@@ -197,12 +199,10 @@ extern WCTemplputParams NoCtx;
* @param Type What sort of thing are we talking about? Tokens? Conditionals?
* @param TP grab our set of default information here
* @param Format for the custom error message
- */
-void LogTemplateError (StrBuf *Target,
- const char *Type,
- int ErrorPos,
- WCTemplputParams *TP,
- const char *Format, ...)__attribute__((__format__(__printf__,5,6)));
+ */
+void LogTemplateError(StrBuf * Target,
+ const char *Type,
+ int ErrorPos, WCTemplputParams * TP, const char *Format, ...) __attribute__((__format__(__printf__, 5, 6)));
/**
@@ -211,8 +211,8 @@ void LogTemplateError (StrBuf *Target,
* @param Target your Target Buffer to print the error message next to the log
* @param Type What sort of thing are we talking about? Tokens? Conditionals?
* @param Format for the custom error message
- */
-void LogError (StrBuf *Target, const char *Type, const char *Format, ...);
+ */
+void LogError(StrBuf * Target, const char *Type, const char *Format, ...);
/**
* @ingroup subst
@@ -228,20 +228,13 @@ void LogError (StrBuf *Target, const char *Type, const char *Format, ...);
* @param Value reference to the string of the token; don't free me.
* @param len the length of Value
*/
-void GetTemplateTokenString(StrBuf *Target,
- WCTemplputParams *TP,
- int N,
- const char **Value,
- long *len);
+void GetTemplateTokenString(StrBuf * Target, WCTemplputParams * TP, int N, const char **Value, long *len);
+
/**
* @ingroup subst
* @return whether @ref GetTemplateTokenString would be able to give you a string
*/
-int HaveTemplateTokenString(StrBuf *Target,
- WCTemplputParams *TP,
- int N,
- const char **Value,
- long *len);
+int HaveTemplateTokenString(StrBuf * Target, WCTemplputParams * TP, int N, const char **Value, long *len);
@@ -259,9 +252,7 @@ int HaveTemplateTokenString(StrBuf *Target,
* @param dflt default value to be retrieved if not found in preferences
* \returns the long value
*/
-long GetTemplateTokenNumber(StrBuf *Target,
- WCTemplputParams *TP,
- int N, long dflt);
+long GetTemplateTokenNumber(StrBuf * Target, WCTemplputParams * TP, int N, long dflt);
/**
* @brief put a token value into the template
@@ -276,18 +267,13 @@ long GetTemplateTokenNumber(StrBuf *Target,
* @param FormatTypeIndex which parameter contains the escaping functionality?
* if this token doesn't have as much parameters, plain append is done.
*/
-void StrBufAppendTemplate(StrBuf *Target,
- WCTemplputParams *TP,
- const StrBuf *Source,
- int FormatTypeIndex);
+void StrBufAppendTemplate(StrBuf * Target, WCTemplputParams * TP, const StrBuf * Source, int FormatTypeIndex);
-void StrBufAppendTemplateStr(StrBuf *Target,
- WCTemplputParams *TP,
- const char *Source,
- int FormatTypeIndex);
+void StrBufAppendTemplateStr(StrBuf * Target, WCTemplputParams * TP, const char *Source, int FormatTypeIndex);
#define RegisterNamespace(a, b, c, d, e, f) RegisterNS(a, sizeof(a)-1, b, c, d, e, f)
+
/**
* @ingroup subst
* @brief register a template token handler
@@ -299,12 +285,8 @@ void StrBufAppendTemplateStr(StrBuf *Target,
* syntax checks here or pre-evaluate stuff for better performance
* @param ContextRequired if your token requires a specific context, else say CTX_NONE here.
*/
-void RegisterNS(const char *NSName, long len,
- int nMinArgs,
- int nMaxArgs,
- WCHandlerFunc HandlerFunc,
- WCPreevalFunc PreEvalFunc,
- int ContextRequired);
+void RegisterNS(const char *NSName, long len,
+ int nMinArgs, int nMaxArgs, WCHandlerFunc HandlerFunc, WCPreevalFunc PreEvalFunc, int ContextRequired);
/**
* @ingroup subst
@@ -318,11 +300,8 @@ void RegisterNS(const char *NSName, long len,
* @param ExitCtxCond if non-NULL, will be called after the area of the conditional is left behind.
* @param ContextRequired if your token requires a specific context, else say CTX_NONE here.
*/
-void RegisterContextConditional(const char *Name, long len,
- int nParams,
- WCConditionalFunc CondF,
- WCConditionalFunc ExitCtxCond,
- int ContextRequired);
+void RegisterContextConditional(const char *Name, long len,
+ int nParams, WCConditionalFunc CondF, WCConditionalFunc ExitCtxCond, int ContextRequired);
#define RegisterCtxConditional(Name, nParams, CondF, ExitCtxCond, ContextRequired) \
RegisterContextConditional(Name, sizeof(Name) -1, nParams, CondF, ExitCtxCond, ContextRequired)
@@ -341,8 +320,8 @@ void RegisterContextConditional(const char *Name, long len,
* @param len length of Name
* @param Value the value to associate with Name
*/
-void RegisterTokenParamDefine(const char *Name, long len,
- long Value);
+void RegisterTokenParamDefine(const char *Name, long len, long Value);
+
/**
* teh r0x0r! forward your favourite define from C to the templates with one easy call!
*/
@@ -355,63 +334,52 @@ void RegisterTokenParamDefine(const char *Name, long len,
* @param len length of Name
* @param Value the value to return if not found
*/
-long GetTokenDefine(const char *Name,
- long len,
- long DefValue);
+long GetTokenDefine(const char *Name, long len, long DefValue);
#define IT_NOFLAG 0
#define IT_FLAG_DETECT_GROUPCHANGE (1<<0)
-#define IT_ADDT_PARAM(n) 5 + n /* If you have AdditionalParams, use this macro to fetch them. */
+#define IT_ADDT_PARAM(n) 5 + n /* If you have AdditionalParams, use this macro to fetch them. */
#define RegisterIterator(a, b, c, d, e, f, g, h, i) RegisterITERATOR(a, sizeof(a)-1, b, c, d, e, f, NULL, g, h, i)
#define RegisterFilteredIterator(a, b, c, d, e, f, g, h, i, j) RegisterITERATOR(a, sizeof(a)-1, b, c, d, e, f, g, h, i, j)
-void RegisterITERATOR(const char *Name, long len, /* Our identifier */
- int AdditionalParams, /* do 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 */
- FilterByParamFunc Filter, /* use this function if you want to skip items */
- CtxType ContextType, /* which context do we provide to the subtemplate? */
- CtxType XPectContextType, /* which context do we expct to be called in? */
+void RegisterITERATOR(const char *Name, long len, /* Our identifier */
+ int AdditionalParams, /* do 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 */
+ FilterByParamFunc Filter, /* use this function if you want to skip items */
+ CtxType ContextType, /* which context do we provide to the subtemplate? */
+ CtxType XPectContextType, /* which context do we expct to be called in? */
int Flags);
-void StackDynamicContext(WCTemplputParams *Super,
- WCTemplputParams *Sub,
+void StackDynamicContext(WCTemplputParams * Super,
+ WCTemplputParams * Sub,
void *Context,
- CtxType ContextType,
- int nArgs,
- WCTemplateToken *Tokens,
- WCConditionalFunc ExitCtx,
- long ExitCTXID);
+ CtxType ContextType, int nArgs, WCTemplateToken * Tokens, WCConditionalFunc ExitCtx, long ExitCTXID);
#define StackContext(Super, Sub, Context, ContextType, nArgs, Tokens) \
StackDynamicContext(Super, Sub, Context, ContextType, nArgs, Tokens, NULL, 0)
-void UnStackContext(WCTemplputParams *Sub);
+void UnStackContext(WCTemplputParams * Sub);
-CompareFunc RetrieveSort(WCTemplputParams *TP,
- const char *OtherPrefix, long OtherPrefixLen,
- const char *Default, long ldefault,
- long DefaultDirection);
-void RegisterSortFunc(const char *name, long len,
+CompareFunc RetrieveSort(WCTemplputParams * TP,
+ const char *OtherPrefix, long OtherPrefixLen, const char *Default, long ldefault, long DefaultDirection);
+void RegisterSortFunc(const char *name, long len,
const char *prepend, long preplen,
- CompareFunc Forward,
- CompareFunc Reverse,
- CompareFunc GroupChange,
- CtxType ContextType);
+ CompareFunc Forward, CompareFunc Reverse, CompareFunc GroupChange, CtxType ContextType);
void dbg_print_longvector(long *LongVector);
#define do_template(a) DoTemplate(a, sizeof(a) -1, NULL, &NoCtx)
-const StrBuf *DoTemplate(const char *templatename, long len, StrBuf *Target, WCTemplputParams *TP);
+const StrBuf *DoTemplate(const char *templatename, long len, StrBuf * Target, WCTemplputParams * TP);
void url_do_template(void);
-int CompareSubstToToken(TemplateParam *ParamToCompare, TemplateParam *ParamToLookup);
-int CompareSubstToStrBuf(StrBuf *Compare, TemplateParam *ParamToLookup);
+int CompareSubstToToken(TemplateParam * ParamToCompare, TemplateParam * ParamToLookup);
+int CompareSubstToStrBuf(StrBuf * Compare, TemplateParam * ParamToLookup);
diff --git a/webcit/summary.c b/webcit/summary.c
index 5dbe60435..97dd184f9 100644
--- a/webcit/summary.c
+++ b/webcit/summary.c
@@ -1,3 +1,4 @@
+
/*
* Displays the "Summary Page"
*
@@ -32,8 +33,7 @@ void output_date(void) {
wc_printf("%s", buf);
}
-void tmplput_output_date(StrBuf *Target, WCTemplputParams *TP)
-{
+void tmplput_output_date(StrBuf * Target, WCTemplputParams * TP) {
struct tm tm;
time_t now;
char buf[128];
@@ -59,10 +59,11 @@ void new_messages_section(void) {
number_of_rooms_to_check = num_tokens(rooms_to_check, '|');
- if (number_of_rooms_to_check == 0) return;
+ if (number_of_rooms_to_check == 0)
+ return;
wc_printf("\n");
- for (i=0; i");
escputs(room);
- wc_printf("%d/%d \n",
- extract_int(&buf[4], 1),
- extract_int(&buf[4], 2)
- );
+ wc_printf("%d/%d \n", extract_int(&buf[4], 1), extract_int(&buf[4], 2)
+ );
}
}
wc_printf("
\n");
@@ -116,7 +115,7 @@ void tasks_section(void) {
if (num_msgs > 0) {
at = GetNewHashPos(WC->summ, 0);
while (GetNextHashPos(WC->summ, at, &HKLen, &HashKey, &vMsg)) {
- Msg = (message_summary*) vMsg;
+ Msg = (message_summary *) vMsg;
tasks_LoadMsgFromServer(NULL, NULL, Msg, 0, 0);
}
DeleteHashPos(&at);
@@ -150,29 +149,23 @@ void calendar_section(void) {
Stat.maxload = 10000;
Stat.lowest_found = (-1);
Stat.highest_found = (-1);
-
+
Buf = NewStrBufPlain(HKEY("_CALENDAR_"));
gotoroom(Buf);
FreeStrBuf(&Buf);
- if ( (WC->CurRoom.view != VIEW_CALENDAR) && (WC->CurRoom.view != VIEW_CALBRIEF) ) {
+ if ((WC->CurRoom.view != VIEW_CALENDAR) && (WC->CurRoom.view != VIEW_CALBRIEF)) {
num_msgs = 0;
}
else {
num_msgs = load_msg_ptrs("MSGS ALL", NULL, NULL, &Stat, NULL, NULL, NULL, NULL, 0);
}
- calendar_GetParamsGetServerCall(&Stat,
- &v,
- readnew,
- cmd,
- sizeof(cmd),
- filter,
- sizeof(filter));
+ calendar_GetParamsGetServerCall(&Stat, &v, readnew, cmd, sizeof(cmd), filter, sizeof(filter));
if (num_msgs > 0) {
at = GetNewHashPos(WC->summ, 0);
while (GetNextHashPos(WC->summ, at, &HKLen, &HashKey, &vMsg)) {
- Msg = (message_summary*) vMsg;
+ Msg = (message_summary *) vMsg;
calendar_LoadMsgFromServer(NULL, &v, Msg, 0, 0);
}
DeleteHashPos(&at);
@@ -185,13 +178,13 @@ void calendar_section(void) {
__calendar_Cleanup(&v);
}
-void tmplput_new_messages_section(StrBuf *Target, WCTemplputParams *TP) {
+void tmplput_new_messages_section(StrBuf * Target, WCTemplputParams * TP) {
new_messages_section();
}
-void tmplput_tasks_section(StrBuf *Target, WCTemplputParams *TP) {
+void tmplput_tasks_section(StrBuf * Target, WCTemplputParams * TP) {
tasks_section();
}
-void tmplput_calendar_section(StrBuf *Target, WCTemplputParams *TP) {
+void tmplput_calendar_section(StrBuf * Target, WCTemplputParams * TP) {
calendar_section();
}
@@ -199,22 +192,17 @@ void tmplput_calendar_section(StrBuf *Target, WCTemplputParams *TP) {
/*
* summary page
*/
-void display_summary_page(void)
-{
- output_headers(1, 1, 1, 0, 0, 0);
+void display_summary_page(void) {
+ output_headers(1, 1, 1, 0, 0, 0);
do_template("summary_page");
wDumpContent(1);
}
-void
-InitModule_SUMMARY
-(void)
-{
+void InitModule_SUMMARY(void) {
RegisterNamespace("TIME:NOW", 0, 0, tmplput_output_date, NULL, CTX_NONE);
WebcitAddUrlHandler(HKEY("summary"), "", 0, display_summary_page, ANONYMOUS);
WebcitAddUrlHandler(HKEY("new_messages_html"), "", 0, new_messages_section, AJAX);
WebcitAddUrlHandler(HKEY("tasks_inner_html"), "", 0, tasks_section, AJAX);
WebcitAddUrlHandler(HKEY("calendar_inner_html"), "", 0, calendar_section, AJAX);
}
-
diff --git a/webcit/sysdep.c b/webcit/sysdep.c
index 7c699699a..5e79bd90e 100644
--- a/webcit/sysdep.c
+++ b/webcit/sysdep.c
@@ -1,3 +1,4 @@
+
/*
* WebCit "system dependent" code.
*
@@ -55,22 +56,22 @@
#endif
pthread_mutex_t Critters[MAX_SEMAPHORES]; /* Things needing locking */
-pthread_key_t MyConKey; /* TSD key for MyContext() */
-pthread_key_t MyReq; /* TSD key for MyReq() */
+pthread_key_t MyConKey; /* TSD key for MyContext() */
+pthread_key_t MyReq; /* TSD key for MyReq() */
int msock; /* master listening socket */
-int time_to_die = 0; /* Nonzero if server is shutting down */
+int time_to_die = 0; /* Nonzero if server is shutting down */
-extern void *context_loop(ParsedHttpHdrs *Hdr);
+extern void *context_loop(ParsedHttpHdrs * Hdr);
extern void *housekeeping_loop(void);
extern void do_housekeeping(void);
-char file_etc_mimelist[PATH_MAX]="";
+char file_etc_mimelist[PATH_MAX] = "";
char etc_dir[PATH_MAX];
-char static_dir[PATH_MAX]; /* calculated on startup */
-char static_local_dir[PATH_MAX]; /* calculated on startup */
-char static_icon_dir[PATH_MAX]; /* where should we find our mime icons? */
-char *static_dirs[]={ /* needs same sort order as the web mapping */
+char static_dir[PATH_MAX]; /* calculated on startup */
+char static_local_dir[PATH_MAX]; /* calculated on startup */
+char static_icon_dir[PATH_MAX]; /* where should we find our mime icons? */
+char *static_dirs[] = { /* needs same sort order as the web mapping */
"./static",
"./static.local",
"./tiny_mce",
@@ -78,14 +79,13 @@ char *static_dirs[]={ /* needs same sort order as the web mapping */
};
int ExitPipe[2];
-HashList *GZMimeBlackList = NULL; /* mimetypes which shouldn't be gzip compressed */
+HashList *GZMimeBlackList = NULL; /* mimetypes which shouldn't be gzip compressed */
-void LoadMimeBlacklist(void)
-{
+void LoadMimeBlacklist(void) {
StrBuf *MimeBlackLine;
IOBuffer IOB;
eReadState state;
-
+
memset(&IOB, 0, sizeof(IOBuffer));
IOB.fd = open(file_etc_mimelist, O_RDONLY);
@@ -93,22 +93,17 @@ void LoadMimeBlacklist(void)
MimeBlackLine = NewStrBuf();
GZMimeBlackList = NewHash(1, NULL);
- do
- {
+ do {
state = StrBufChunkSipLine(MimeBlackLine, &IOB);
- switch (state)
- {
+ switch (state) {
case eMustReadMore:
if (StrBuf_read_one_chunk_callback(IOB.fd, 0, &IOB) <= 0)
state = eReadFail;
break;
case eReadSuccess:
- if ((StrLength(MimeBlackLine) > 1) &&
- (*ChrPtr(MimeBlackLine) != '#'))
- {
- Put(GZMimeBlackList, SKEY(MimeBlackLine),
- (void*) 1, reference_free_handler);
+ if ((StrLength(MimeBlackLine) > 1) && (*ChrPtr(MimeBlackLine) != '#')) {
+ Put(GZMimeBlackList, SKEY(MimeBlackLine), (void *) 1, reference_free_handler);
}
FlushStrBuf(MimeBlackLine);
break;
@@ -121,34 +116,29 @@ void LoadMimeBlacklist(void)
while (state != eReadFail);
close(IOB.fd);
-
+
FreeStrBuf(&IOB.Buf);
FreeStrBuf(&MimeBlackLine);
}
-void CheckGZipCompressionAllowed(const char *MimeType, long MLen)
-{
+void CheckGZipCompressionAllowed(const char *MimeType, long MLen) {
void *v;
if (WC->Hdr->HR.gzip_ok)
- WC->Hdr->HR.gzip_ok = GetHash(GZMimeBlackList, MimeType, MLen, &v) == 0;
+ WC->Hdr->HR.gzip_ok = GetHash(GZMimeBlackList, MimeType, MLen, &v) == 0;
}
-void InitialiseSemaphores(void)
-{
+void InitialiseSemaphores(void) {
int i;
/* Set up a bunch of semaphores to be used for critical sections */
- for (i=0; i 0) && (ssock < 0) && (time_to_die == 0));
+ if (ssock < 0)
+ fail_this_transaction = 1;
+ } while ((msock > 0) && (ssock < 0) && (time_to_die == 0));
- if ((msock == -1)||(time_to_die))
- {/* ok, we're going down. */
+ if ((msock == -1) || (time_to_die)) { /* ok, we're going down. */
int shutdown = 0;
/* The first thread to get here will have to do the cleanup.
* Make sure it's really just one.
*/
begin_critical_section(S_SHUTDOWN);
- if (msock == -1)
- {
+ if (msock == -1) {
msock = -2;
shutdown = 1;
}
end_critical_section(S_SHUTDOWN);
- if (shutdown == 1)
- {/* we're the one to cleanup the mess. */
+ if (shutdown == 1) { /* we're the one to cleanup the mess. */
http_destroy_modules(&Hdr);
syslog(LOG_DEBUG, "I'm master shutdown: tagging sessions to be killed.\n");
shutdown_sessions();
syslog(LOG_DEBUG, "master shutdown: waiting for others\n");
- sleeeeeeeeeep(1); /* wait so some others might finish... */
+ sleeeeeeeeeep(1); /* wait so some others might finish... */
syslog(LOG_DEBUG, "master shutdown: cleaning up sessions\n");
do_housekeeping();
syslog(LOG_DEBUG, "master shutdown: cleaning up libical\n");
ShutDownWebcit();
- syslog(LOG_DEBUG, "master shutdown exiting.\n");
+ syslog(LOG_DEBUG, "master shutdown exiting.\n");
exit(0);
}
break;
}
- if (ssock < 0 ) continue;
+ if (ssock < 0)
+ continue;
check_thread_pool_size();
/* Now do something. */
if (msock < 0) {
- if (ssock > 0) close (ssock);
+ if (ssock > 0)
+ close(ssock);
syslog(LOG_DEBUG, "in between.");
pthread_exit(NULL);
- } else {
+ }
+ else {
/* Got it? do some real work! */
/* Set the SO_REUSEADDR socket option */
i = 1;
@@ -271,18 +258,17 @@ void worker_entry(void)
close(ssock);
}
}
- else
+ else
#endif
{
- int fdflags;
+ int fdflags;
fdflags = fcntl(ssock, F_GETFL);
if (fdflags < 0)
- syslog(LOG_WARNING, "unable to get server socket flags! %s \n",
- strerror(errno));
+ syslog(LOG_WARNING, "unable to get server socket flags! %s \n", strerror(errno));
fdflags = fdflags | O_NONBLOCK;
if (fcntl(ssock, F_SETFL, fdflags) < 0)
syslog(LOG_WARNING, "unable to set server socket nonblocking flags! %s \n",
- strerror(errno));
+ strerror(errno));
}
if (fail_this_transaction == 0) {
@@ -343,9 +329,9 @@ void graceful_shutdown(int signum) {
fd = msock;
msock = -1;
time_to_die = 1;
- FD=fdopen(fd, "a+");
- fflush (FD);
- fclose (FD);
+ FD = fdopen(fd, "a+");
+ fflush(FD);
+ fclose(FD);
close(fd);
write(ExitPipe[0], HKEY(" "));
}
@@ -354,8 +340,7 @@ void graceful_shutdown(int signum) {
/*
* Start running as a daemon.
*/
-void start_daemon(char *pid_file)
-{
+void start_daemon(char *pid_file) {
int status = 0;
pid_t child = 0;
FILE *fp;
@@ -389,19 +374,19 @@ void start_daemon(char *pid_file)
do {
current_child = fork();
-
+
if (current_child < 0) {
perror("fork");
- ShutDownLibCitadel ();
+ ShutDownLibCitadel();
exit(errno);
}
-
+
else if (current_child == 0) { /* child process */
signal(SIGHUP, graceful_shutdown);
- return; /* continue starting webcit. */
+ return; /* continue starting webcit. */
}
- else { /* watcher process */
+ else { /* watcher process */
if (pid_file) {
fp = fopen(pid_file, "w");
if (fp != NULL) {
@@ -423,7 +408,7 @@ void start_daemon(char *pid_file)
}
/* Exit code 101-109 means the watcher should exit */
- else if ( (WEXITSTATUS(status) >= 101) && (WEXITSTATUS(status) <= 109) ) {
+ else if ((WEXITSTATUS(status) >= 101) && (WEXITSTATUS(status) <= 109)) {
do_restart = 0;
}
@@ -443,7 +428,7 @@ void start_daemon(char *pid_file)
if (pid_file) {
unlink(pid_file);
}
- ShutDownLibCitadel ();
+ ShutDownLibCitadel();
exit(WEXITSTATUS(status));
}
@@ -451,8 +436,7 @@ void start_daemon(char *pid_file)
/*
* Spawn an additional worker thread into the pool.
*/
-void spawn_another_worker_thread()
-{
+void spawn_another_worker_thread() {
pthread_t SessThread; /* Thread descriptor */
pthread_attr_t attr; /* Thread attributes */
int ret;
@@ -483,13 +467,11 @@ void spawn_another_worker_thread()
}
-void
-webcit_calc_dirs_n_files(int relh, const char *basedir, int home, char *webcitdir, char *relhome)
-{
- char dirbuffer[PATH_MAX]="";
+void webcit_calc_dirs_n_files(int relh, const char *basedir, int home, char *webcitdir, char *relhome) {
+ char dirbuffer[PATH_MAX] = "";
/* calculate all our path on a central place */
- /* where to keep our config */
-
+ /* where to keep our config */
+
#define COMPUTE_DIRECTORY(SUBDIR) memcpy(dirbuffer,SUBDIR, sizeof dirbuffer);\
snprintf(SUBDIR,sizeof SUBDIR, "%s%s%s%s%s%s%s", \
(home&!relh)?webcitdir:basedir, \
@@ -499,25 +481,22 @@ webcit_calc_dirs_n_files(int relh, const char *basedir, int home, char *webcitdi
(relhome[0]!='\0')?"/":"",\
dirbuffer,\
(dirbuffer[0]!='\0')?"/":"");
- basedir=RUNDIR;
+ basedir = RUNDIR;
COMPUTE_DIRECTORY(socket_dir);
- basedir=WWWDIR "/static";
+ basedir = WWWDIR "/static";
COMPUTE_DIRECTORY(static_dir);
- basedir=WWWDIR "/static/icons";
+ basedir = WWWDIR "/static/icons";
COMPUTE_DIRECTORY(static_icon_dir);
- basedir=WWWDIR "/static.local";
+ basedir = WWWDIR "/static.local";
COMPUTE_DIRECTORY(static_local_dir);
StripSlashes(static_dir, 1);
StripSlashes(static_icon_dir, 1);
StripSlashes(static_local_dir, 1);
- basedir=ETCDIR;
+ basedir = ETCDIR;
COMPUTE_DIRECTORY(etc_dir);
StripSlashes(etc_dir, 1);
- snprintf(file_etc_mimelist,
- sizeof file_etc_mimelist,
- "%s/nogz-mimetypes.txt",
- etc_dir);
+ snprintf(file_etc_mimelist, sizeof file_etc_mimelist, "%s/nogz-mimetypes.txt", etc_dir);
/* we should go somewhere we can leave our coredump, if enabled... */
syslog(LOG_INFO, "Changing directory to %s\n", socket_dir);
@@ -526,8 +505,7 @@ webcit_calc_dirs_n_files(int relh, const char *basedir, int home, char *webcitdi
}
}
-void drop_root(uid_t UID)
-{
+void drop_root(uid_t UID) {
struct passwd pw, *pwp = NULL;
#ifdef HAVE_GETPWUID_R
char pwbuf[SIZ];
@@ -538,28 +516,25 @@ void drop_root(uid_t UID)
* corresponding group ids
*/
if (UID != -1) {
-
+
#ifdef HAVE_GETPWUID_R
#ifdef SOLARIS_GETPWUID
pwp = getpwuid_r(UID, &pw, pwbuf, sizeof(pwbuf));
-#else /* SOLARIS_GETPWUID */
+#else /* SOLARIS_GETPWUID */
getpwuid_r(UID, &pw, pwbuf, sizeof(pwbuf), &pwp);
-#endif /* SOLARIS_GETPWUID */
-#else /* HAVE_GETPWUID_R */
+#endif /* SOLARIS_GETPWUID */
+#else /* HAVE_GETPWUID_R */
pwp = NULL;
-#endif /* HAVE_GETPWUID_R */
+#endif /* HAVE_GETPWUID_R */
if (pwp == NULL)
- syslog(LOG_CRIT, "WARNING: getpwuid(%d): %s\n"
- "Group IDs will be incorrect.\n", UID,
- strerror(errno));
+ syslog(LOG_CRIT, "WARNING: getpwuid(%d): %s\n" "Group IDs will be incorrect.\n", UID, strerror(errno));
else {
initgroups(pw.pw_name, pw.pw_gid);
if (setgid(pw.pw_gid))
- syslog(LOG_CRIT, "setgid(%ld): %s\n", (long)pw.pw_gid,
- strerror(errno));
+ syslog(LOG_CRIT, "setgid(%ld): %s\n", (long) pw.pw_gid, strerror(errno));
}
- syslog(LOG_INFO, "Changing uid to %ld\n", (long)UID);
+ syslog(LOG_INFO, "Changing uid to %ld\n", (long) UID);
if (setuid(UID) != 0) {
syslog(LOG_CRIT, "setuid() failed: %s\n", strerror(errno));
}
@@ -573,15 +548,14 @@ void drop_root(uid_t UID)
/*
* print the actual stack frame.
*/
-void wc_backtrace(long LogLevel)
-{
+void wc_backtrace(long LogLevel) {
#ifdef HAVE_BACKTRACE
void *stack_frames[50];
size_t size, i;
char **strings;
- size = backtrace(stack_frames, sizeof(stack_frames) / sizeof(void*));
+ size = backtrace(stack_frames, sizeof(stack_frames) / sizeof(void *));
strings = backtrace_symbols(stack_frames, size);
for (i = 0; i < size; i++) {
if (strings != NULL)
diff --git a/webcit/sysmsgs.c b/webcit/sysmsgs.c
index 99f84533e..f73fbf971 100644
--- a/webcit/sysmsgs.c
+++ b/webcit/sysmsgs.c
@@ -1,3 +1,4 @@
+
/*
* Copyright (c) 1996-2012 by the citadel.org team
*
@@ -18,8 +19,7 @@
* enter_cmd which command to enter at the citadel server???
* regoto should we go to that room again after executing that command?
*/
-void save_edit(char *description, char *enter_cmd, int regoto)
-{
+void save_edit(char *description, char *enter_cmd, int regoto) {
StrBuf *Line;
const StrBuf *templ;
@@ -36,7 +36,7 @@ void save_edit(char *description, char *enter_cmd, int regoto)
putlbstr("success", 0);
FreeStrBuf(&Line);
if (templ != NULL) {
- output_headers(1, 0, 0, 0, 0, 0);
+ output_headers(1, 0, 0, 0, 0, 0);
DoTemplate(SKEY(templ), NULL, &NoCtx);
end_burst();
}
@@ -53,26 +53,28 @@ void save_edit(char *description, char *enter_cmd, int regoto)
AppendImportantMessage(_(" has been saved."), -1);
putlbstr("success", 1);
if (templ != NULL) {
- output_headers(1, 0, 0, 0, 0, 0);
+ output_headers(1, 0, 0, 0, 0, 0);
DoTemplate(SKEY(templ), NULL, &NoCtx);
end_burst();
}
else if (regoto) {
smart_goto(WC->CurRoom.name);
- } else {
+ }
+ else {
display_main_menu();
return;
}
}
-void editinfo(void) {save_edit(_("Room info"), "EINF 1", 1);}
-void editbio(void) { save_edit(_("Your bio"), "EBIO", 0); }
+void editinfo(void) {
+ save_edit(_("Room info"), "EINF 1", 1);
+}
+void editbio(void) {
+ save_edit(_("Your bio"), "EBIO", 0);
+}
-void
-InitModule_SYSMSG
-(void)
-{
+void InitModule_SYSMSG(void) {
WebcitAddUrlHandler(HKEY("editinfo"), "", 0, editinfo, 0);
WebcitAddUrlHandler(HKEY("editbio"), "", 0, editbio, 0);
}
diff --git a/webcit/tabs.c b/webcit/tabs.c
index 4b58ba590..20f3e3583 100644
--- a/webcit/tabs.c
+++ b/webcit/tabs.c
@@ -9,31 +9,24 @@ void tabbed_dialog(int num_tabs, const char *tabnames[]) {
int i;
StrBufAppendPrintf(WC->trailing_javascript,
- "var previously_selected_tab = '0'; \n"
- "function tabsel(which_tab) { \n"
- " if (which_tab == previously_selected_tab) { \n"
- " return; \n"
- " } \n"
- " $('tabdiv'+previously_selected_tab).style.display = 'none'; \n"
- " $('tabdiv'+which_tab).style.display = 'block'; \n"
- " $('tabtd'+previously_selected_tab).className = 'tab_cell_edit'; \n"
- " $('tabtd'+which_tab).className = 'tab_cell_label'; \n"
- " previously_selected_tab = which_tab; \n"
- "} \n"
- );
+ "var previously_selected_tab = '0'; \n"
+ "function tabsel(which_tab) { \n"
+ " if (which_tab == previously_selected_tab) { \n"
+ " return; \n"
+ " } \n"
+ " $('tabdiv'+previously_selected_tab).style.display = 'none'; \n"
+ " $('tabdiv'+which_tab).style.display = 'block'; \n"
+ " $('tabtd'+previously_selected_tab).className = 'tab_cell_edit'; \n"
+ " $('tabtd'+which_tab).className = 'tab_cell_label'; \n"
+ " previously_selected_tab = which_tab; \n"
+ "} \n");
wc_printf(""
- " "
- );
+ " ");
- for (i=0; i",
- i,
- ( (i==0) ? "tab_cell_label" : "tab_cell_edit" ),
- i
- );
+ "onClick='tabsel(\"%d\");'" ">", i, ((i == 0) ? "tab_cell_label" : "tab_cell_edit"), i);
wc_printf("%s", tabnames[i]);
wc_printf("");
@@ -60,9 +53,8 @@ void begin_tab(int tabnum, int num_tabs) {
else {
wc_printf("\n", tabnum, num_tabs);
wc_printf("",
- tabnum,
- ( (tabnum == 0) ? "block" : "none" )
- );
+ tabnum, ((tabnum == 0) ? "block" : "none")
+ );
}
}
@@ -89,55 +81,37 @@ void end_tab(int tabnum, int num_tabs) {
/*
* print tabbed dialog
*/
-void StrTabbedDialog(StrBuf *Target, int num_tabs, StrBuf *tabnames[]) {
+void StrTabbedDialog(StrBuf * Target, int num_tabs, StrBuf * tabnames[]) {
int i;
- StrBufAppendBufPlain(
- Target,
- HKEY(
- " \n"
- ), 0);
-
- StrBufAppendBufPlain(
- Target,
- HKEY(
- "
"
- " "
- ), 0);
-
- for (i=0; i",
- i,
- ( (i==0) ? "tab_cell_label" : "tab_cell_edit" ),
- i
- );
+ StrBufAppendBufPlain(Target,
+ HKEY(" \n"), 0);
+
+ StrBufAppendBufPlain(Target,
+ HKEY(""
+ " "), 0);
+
+ for (i = 0; i < num_tabs; ++i) {
+ StrBufAppendPrintf(Target,
+ "", i, ((i == 0) ? "tab_cell_label" : "tab_cell_edit"), i);
StrEscAppend(Target, tabnames[i], NULL, 0, 0);
- StrBufAppendBufPlain(
- Target,
- HKEY(
- " "
- " \n"), 0);
+ StrBufAppendBufPlain(Target, HKEY("" " \n"), 0);
}
- StrBufAppendBufPlain(
- Target,
- HKEY("
\n"), 0);
+ StrBufAppendBufPlain(Target, HKEY("
\n"), 0);
}
/*
@@ -147,34 +121,24 @@ void StrTabbedDialog(StrBuf *Target, int num_tabs, StrBuf *tabnames[]) {
* num_tabs: total number oftabs to be printed
*
*/
-void StrBeginTab(StrBuf *Target, int tabnum, int num_tabs, StrBuf **Names) {
+void StrBeginTab(StrBuf * Target, int tabnum, int num_tabs, StrBuf ** Names) {
if (tabnum == num_tabs) {
- StrBufAppendBufPlain(
- Target,
- HKEY("\n
"), 0);
+ StrBufAppendBufPlain(Target, HKEY("] -->\n
"), 0);
}
else {
- StrBufAppendBufPlain(
- Target,
- HKEY("\n
",
- tabnum,
- ( (tabnum == 0) ? "block" : "none" )
- );
+ StrBufAppendPrintf(Target,
+ "] -->\n
",
+ tabnum, ((tabnum == 0) ? "block" : "none")
+ );
}
}
@@ -184,27 +148,16 @@ void StrBeginTab(StrBuf *Target, int tabnum, int num_tabs, StrBuf **Names) {
* num_tabs: total number of tabs to be printed
*
*/
-void StrEndTab(StrBuf *Target, int tabnum, int num_tabs) {
+void StrEndTab(StrBuf * Target, int tabnum, int num_tabs) {
if (tabnum == num_tabs) {
- StrBufAppendBufPlain(
- Target,
- HKEY(
- "
\n"
- "\n"), 0);
+ StrBufAppendBufPlain(Target, HKEY("
\n" "\n"), 0);
}
else {
- StrBufAppendPrintf(
- Target,
- "
\n",
- "\n", tabnum, num_tabs
- );
+ StrBufAppendPrintf(Target, "
\n", "\n", tabnum, num_tabs);
}
- if (havebstr("last_tabsel"))
- {
+ if (havebstr("last_tabsel")) {
StrBufAppendPrintf(Target, "", BSTR("last_tabsel"));
}
}
-
-
diff --git a/webcit/tasks.c b/webcit/tasks.c
index b3543826f..4ab709997 100644
--- a/webcit/tasks.c
+++ b/webcit/tasks.c
@@ -6,13 +6,14 @@
* qsort filter to move completed tasks to bottom of task list
*/
int task_completed_cmp(const void *vtask1, const void *vtask2) {
- disp_cal * Task1 = (disp_cal *)GetSearchPayload(vtask1);
+ disp_cal *Task1 = (disp_cal *) GetSearchPayload(vtask1);
+
/* 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); */
-
- if (t1 == ICAL_STATUS_COMPLETED)
+
+ if (t1 == ICAL_STATUS_COMPLETED)
return 1;
return 0;
}
@@ -21,11 +22,11 @@ int task_completed_cmp(const void *vtask1, const void *vtask2) {
/*
* Helper function for do_tasks_view(). Returns the due date/time of a vtodo.
*/
-time_t get_task_due_date(icalcomponent *vtodo, int *is_date) {
+time_t get_task_due_date(icalcomponent * vtodo, int *is_date) {
icalproperty *p;
if (vtodo == NULL) {
- return(0L);
+ return (0L);
}
/*
@@ -34,11 +35,7 @@ time_t get_task_due_date(icalcomponent *vtodo, int *is_date) {
* structure until we get a VTODO.
*/
if (icalcomponent_isa(vtodo) == ICAL_VCALENDAR_COMPONENT) {
- return get_task_due_date(
- icalcomponent_get_first_component(
- vtodo, ICAL_VTODO_COMPONENT
- ), is_date
- );
+ return get_task_due_date(icalcomponent_get_first_component(vtodo, ICAL_VTODO_COMPONENT), is_date);
}
p = icalcomponent_get_first_property(vtodo, ICAL_DUE_PROPERTY);
@@ -47,10 +44,10 @@ time_t get_task_due_date(icalcomponent *vtodo, int *is_date) {
if (is_date)
*is_date = t.is_date;
- return(icaltime_as_timet(t));
+ return (icaltime_as_timet(t));
}
else {
- return(0L);
+ return (0L);
}
}
@@ -58,26 +55,25 @@ time_t get_task_due_date(icalcomponent *vtodo, int *is_date) {
* Compare the due dates of two tasks (this is for sorting)
*/
int task_due_cmp(const void *vtask1, const void *vtask2) {
- disp_cal * Task1 = (disp_cal *)GetSearchPayload(vtask1);
- disp_cal * Task2 = (disp_cal *)GetSearchPayload(vtask2);
+ disp_cal *Task1 = (disp_cal *) GetSearchPayload(vtask1);
+ disp_cal *Task2 = (disp_cal *) GetSearchPayload(vtask2);
time_t t1;
time_t t2;
- t1 = get_task_due_date(Task1->cal, NULL);
- t2 = get_task_due_date(Task2->cal, NULL);
- if (t1 < t2) return(-1);
- if (t1 > t2) return(1);
- return(0);
+ t1 = get_task_due_date(Task1->cal, NULL);
+ t2 = get_task_due_date(Task2->cal, NULL);
+ if (t1 < t2)
+ return (-1);
+ if (t1 > t2)
+ return (1);
+ return (0);
}
/*
* do the whole task view stuff
*/
-int tasks_RenderView_or_Tail(SharedMessageStatus *Stat,
- void **ViewSpecific,
- long oper)
-{
+int tasks_RenderView_or_Tail(SharedMessageStatus * Stat, void **ViewSpecific, long oper) {
long hklen;
const char *HashKey;
void *vCal;
@@ -96,22 +92,20 @@ int tasks_RenderView_or_Tail(SharedMessageStatus *Stat,
wc_printf(_("Date due"));
wc_printf("
");
wc_printf(_("Category"));
- wc_printf(" (%s ) \n",
- _("Show All"));
+ wc_printf(" (%s )\n", _("Show All"));
nItems = GetCount(WC->disp_cal_items);
/* Sort them if necessary
- if (nItems > 1) {
- SortByPayload(WC->disp_cal_items, task_due_cmp);
- }
- * this shouldn't be neccessary, since we sort by the start time.
- */
+ if (nItems > 1) {
+ SortByPayload(WC->disp_cal_items, task_due_cmp);
+ }
+ * this shouldn't be neccessary, since we sort by the start time.
+ */
/* And then again, by completed */
if (nItems > 1) {
- SortByPayload(WC->disp_cal_items,
- task_completed_cmp);
+ SortByPayload(WC->disp_cal_items, task_completed_cmp);
}
Pos = GetNewHashPos(WC->disp_cal_items, 0);
@@ -119,7 +113,7 @@ int tasks_RenderView_or_Tail(SharedMessageStatus *Stat,
icalproperty_status todoStatus;
int is_date;
- Cal = (disp_cal*)vCal;
+ Cal = (disp_cal *) vCal;
wc_printf("");
todoStatus = icalcomponent_get_status(Cal->cal);
wc_printf(" \n ");
- p = icalcomponent_get_first_property(Cal->cal,
- ICAL_SUMMARY_PROPERTY);
+ p = icalcomponent_get_first_property(Cal->cal, ICAL_SUMMARY_PROPERTY);
wc_printf("cal_msgnum);
urlescputs(ChrPtr(WC->CurRoom.name));
wc_printf("\">");
/* wc_printf(" "); */
+ "src=\"static/taskmanag_16x.gif\" border=0> "); */
if (p != NULL) {
- escputs((char *)icalproperty_get_comment(p));
+ escputs((char *) icalproperty_get_comment(p));
}
wc_printf(" \n");
wc_printf(" \n");
@@ -144,17 +137,16 @@ int tasks_RenderView_or_Tail(SharedMessageStatus *Stat,
wc_printf(" 0) {
webcit_fmt_date(buf, SIZ, due, is_date ? DATEFMT_RAWDATE : DATEFMT_FULL);
- wc_printf(">%s",buf);
+ wc_printf(">%s", buf);
}
else {
wc_printf(">");
}
wc_printf(" ");
wc_printf("");
- p = icalcomponent_get_first_property(Cal->cal,
- ICAL_CATEGORIES_PROPERTY);
+ p = icalcomponent_get_first_property(Cal->cal, ICAL_CATEGORIES_PROPERTY);
if (p != NULL) {
- escputs((char *)icalproperty_get_categories(p));
+ escputs((char *) icalproperty_get_categories(p));
}
wc_printf(" ");
wc_printf(" ");
@@ -172,9 +164,7 @@ int tasks_RenderView_or_Tail(SharedMessageStatus *Stat,
/*
* Display a task by itself (for editing)
*/
-void display_edit_individual_task(icalcomponent *supplied_vtodo, long msgnum, char *from,
- int unread, calview *calv)
-{
+void display_edit_individual_task(icalcomponent * supplied_vtodo, long msgnum, char *from, int unread, calview * calv) {
icalcomponent *vtodo;
icalproperty *p;
struct icaltimetype IcalTime;
@@ -198,12 +188,8 @@ void display_edit_individual_task(icalcomponent *supplied_vtodo, long msgnum, ch
* new one.
*/
if (icalcomponent_isa(vtodo) == ICAL_VCALENDAR_COMPONENT) {
- display_edit_individual_task(
- icalcomponent_get_first_component(
- vtodo, ICAL_VTODO_COMPONENT
- ),
- msgnum, from, unread, calv
- );
+ display_edit_individual_task(icalcomponent_get_first_component(vtodo, ICAL_VTODO_COMPONENT),
+ msgnum, from, unread, calv);
return;
}
}
@@ -211,8 +197,8 @@ void display_edit_individual_task(icalcomponent *supplied_vtodo, long msgnum, ch
vtodo = icalcomponent_new(ICAL_VTODO_COMPONENT);
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);
wc_printf("");
p = icalcomponent_get_first_property(vtodo, ICAL_SUMMARY_PROPERTY);
@@ -222,10 +208,10 @@ void display_edit_individual_task(icalcomponent *supplied_vtodo, long msgnum, ch
wc_printf(_("Edit task"));
wc_printf("- ");
if (p != NULL) {
- escputs((char *)icalproperty_get_comment(p));
+ escputs((char *) icalproperty_get_comment(p));
}
wc_printf("");
-
+
wc_printf("\n");
wc_printf("
\n");
wc_printf("
\n");
@@ -373,9 +350,7 @@ void display_edit_individual_task(icalcomponent *supplied_vtodo, long msgnum, ch
* supplied_vtodo the task to save
* msgnum number of the mesage in our db
*/
-void save_individual_task(icalcomponent *supplied_vtodo, long msgnum, char* from, int unread,
- calview *calv)
-{
+void save_individual_task(icalcomponent * supplied_vtodo, long msgnum, char *from, int unread, calview * calv) {
char buf[SIZ];
int delete_existing = 0;
icalproperty *prop;
@@ -387,6 +362,7 @@ void save_individual_task(icalcomponent *supplied_vtodo, long msgnum, char* from
if (supplied_vtodo != NULL) {
vtodo = supplied_vtodo;
+
/**
* If we're looking at a fully encapsulated VCALENDAR
* rather than a VTODO component, attempt to use the first
@@ -396,11 +372,8 @@ void save_individual_task(icalcomponent *supplied_vtodo, long msgnum, char* from
* new one.
*/
if (icalcomponent_isa(vtodo) == ICAL_VCALENDAR_COMPONENT) {
- save_individual_task(
- icalcomponent_get_first_component(
- vtodo, ICAL_VTODO_COMPONENT),
- msgnum, from, unread, calv
- );
+ save_individual_task(icalcomponent_get_first_component(vtodo, ICAL_VTODO_COMPONENT),
+ msgnum, from, unread, calv);
return;
}
}
@@ -413,32 +386,27 @@ void save_individual_task(icalcomponent *supplied_vtodo, long msgnum, char* from
/** Replace values in the component with ones from the form */
- while (prop = icalcomponent_get_first_property(vtodo,
- ICAL_SUMMARY_PROPERTY), prop != NULL) {
+ while (prop = icalcomponent_get_first_property(vtodo, ICAL_SUMMARY_PROPERTY), prop != NULL) {
icalcomponent_remove_property(vtodo, prop);
icalproperty_free(prop);
}
if (havebstr("summary")) {
- icalcomponent_add_property(vtodo,
- icalproperty_new_summary(bstr("summary")));
- } else {
- icalcomponent_add_property(vtodo,
- icalproperty_new_summary(_("Untitled Task")));
+ icalcomponent_add_property(vtodo, icalproperty_new_summary(bstr("summary")));
+ }
+ else {
+ icalcomponent_add_property(vtodo, icalproperty_new_summary(_("Untitled Task")));
}
-
- while (prop = icalcomponent_get_first_property(vtodo,
- ICAL_DESCRIPTION_PROPERTY), prop != NULL) {
+
+ while (prop = icalcomponent_get_first_property(vtodo, ICAL_DESCRIPTION_PROPERTY), prop != NULL) {
icalcomponent_remove_property(vtodo, prop);
icalproperty_free(prop);
}
if (havebstr("description")) {
- icalcomponent_add_property(vtodo,
- icalproperty_new_description(bstr("description")));
+ icalcomponent_add_property(vtodo, icalproperty_new_description(bstr("description")));
}
-
- while (prop = icalcomponent_get_first_property(vtodo,
- ICAL_DTSTART_PROPERTY), prop != NULL) {
+
+ while (prop = icalcomponent_get_first_property(vtodo, ICAL_DTSTART_PROPERTY), prop != NULL) {
icalcomponent_remove_property(vtodo, prop);
icalproperty_free(prop);
}
@@ -449,18 +417,15 @@ void save_individual_task(icalcomponent *supplied_vtodo, long msgnum, char* from
else {
icaltime_from_webform_dateonly(&t, "dtstart");
}
- icalcomponent_add_property(vtodo,
- icalproperty_new_dtstart(t)
- );
+ icalcomponent_add_property(vtodo, icalproperty_new_dtstart(t)
+ );
}
- while(prop = icalcomponent_get_first_property(vtodo,
- ICAL_STATUS_PROPERTY), prop != NULL) {
- icalcomponent_remove_property(vtodo,prop);
+ while (prop = icalcomponent_get_first_property(vtodo, ICAL_STATUS_PROPERTY), prop != NULL) {
+ icalcomponent_remove_property(vtodo, prop);
icalproperty_free(prop);
}
- while(prop = icalcomponent_get_first_property(vtodo,
- ICAL_PERCENTCOMPLETE_PROPERTY), prop != NULL) {
- icalcomponent_remove_property(vtodo,prop);
+ while (prop = icalcomponent_get_first_property(vtodo, ICAL_PERCENTCOMPLETE_PROPERTY), prop != NULL) {
+ icalcomponent_remove_property(vtodo, prop);
icalproperty_free(prop);
}
@@ -468,25 +433,23 @@ void save_individual_task(icalcomponent *supplied_vtodo, long msgnum, char* from
icalproperty_status taskStatus = icalproperty_string_to_status(bstr("status"));
icalcomponent_set_status(vtodo, taskStatus);
icalcomponent_add_property(vtodo,
- icalproperty_new_percentcomplete(
- (strcasecmp(bstr("status"), "completed") ? 0 : 100)
- )
- );
+ icalproperty_new_percentcomplete((strcasecmp(bstr("status"), "completed") ? 0 :
+ 100)
+ )
+ );
}
else {
icalcomponent_add_property(vtodo, icalproperty_new_percentcomplete(0));
}
- while (prop = icalcomponent_get_first_property(vtodo,
- ICAL_CATEGORIES_PROPERTY), prop != NULL) {
- icalcomponent_remove_property(vtodo,prop);
+ while (prop = icalcomponent_get_first_property(vtodo, ICAL_CATEGORIES_PROPERTY), prop != NULL) {
+ icalcomponent_remove_property(vtodo, prop);
icalproperty_free(prop);
}
if (!IsEmptyStr(bstr("category"))) {
prop = icalproperty_new_categories(bstr("category"));
- icalcomponent_add_property(vtodo,prop);
+ icalcomponent_add_property(vtodo, prop);
}
- while (prop = icalcomponent_get_first_property(vtodo,
- ICAL_DUE_PROPERTY), prop != NULL) {
+ while (prop = icalcomponent_get_first_property(vtodo, ICAL_DUE_PROPERTY), prop != NULL) {
icalcomponent_remove_property(vtodo, prop);
icalproperty_free(prop);
}
@@ -497,35 +460,32 @@ void save_individual_task(icalcomponent *supplied_vtodo, long msgnum, char* from
else {
icaltime_from_webform_dateonly(&t, "due");
}
- icalcomponent_add_property(vtodo,
- icalproperty_new_due(t)
- );
+ icalcomponent_add_property(vtodo, icalproperty_new_due(t)
+ );
}
+
/** Give this task a UID if it doesn't have one. */
syslog(LOG_DEBUG, "Give this task a UID if it doesn't have one.\n");
- if (icalcomponent_get_first_property(vtodo,
- ICAL_UID_PROPERTY) == NULL) {
+ if (icalcomponent_get_first_property(vtodo, ICAL_UID_PROPERTY) == NULL) {
generate_uuid(buf);
- icalcomponent_add_property(vtodo,
- icalproperty_new_uid(buf)
- );
+ icalcomponent_add_property(vtodo, icalproperty_new_uid(buf)
+ );
}
/* Increment the sequence ID */
syslog(LOG_DEBUG, "Increment the sequence ID\n");
- while (prop = icalcomponent_get_first_property(vtodo,
- ICAL_SEQUENCE_PROPERTY), (prop != NULL) ) {
+ while (prop = icalcomponent_get_first_property(vtodo, ICAL_SEQUENCE_PROPERTY), (prop != NULL)) {
i = icalproperty_get_sequence(prop);
syslog(LOG_DEBUG, "Sequence was %d\n", i);
- if (i > sequence) sequence = i;
+ if (i > sequence)
+ sequence = i;
icalcomponent_remove_property(vtodo, prop);
icalproperty_free(prop);
}
++sequence;
syslog(LOG_DEBUG, "New sequence is %d. Adding...\n", sequence);
- icalcomponent_add_property(vtodo,
- icalproperty_new_sequence(sequence)
- );
+ icalcomponent_add_property(vtodo, icalproperty_new_sequence(sequence)
+ );
/*
* Encapsulate event into full VCALENDAR component. Clone it first,
@@ -563,7 +523,7 @@ void save_individual_task(icalcomponent *supplied_vtodo, long msgnum, char* from
delete_existing = 1;
}
- if ( (delete_existing) && (msgnum > 0L) ) {
+ if ((delete_existing) && (msgnum > 0L)) {
serv_printf("DELE %ld", lbstr("msgnum"));
serv_getln(buf, sizeof buf);
}
@@ -585,20 +545,18 @@ void save_individual_task(icalcomponent *supplied_vtodo, long msgnum, char* from
/*
* free memory allocated using libical
*/
-void delete_task(void *vCal)
-{
- disp_cal *Cal = (disp_cal*) vCal;
- icalcomponent_free(Cal->cal);
- free(Cal->from);
- free(Cal);
+void delete_task(void *vCal) {
+ disp_cal *Cal = (disp_cal *) vCal;
+ icalcomponent_free(Cal->cal);
+ free(Cal->from);
+ free(Cal);
}
/*
* Load a Task into a hash table for later display.
*/
-void load_task(icalcomponent *event, long msgnum, char *from, int unread, calview *calv)
-{
+void load_task(icalcomponent * event, long msgnum, char *from, int unread, calview * calv) {
icalproperty *ps = NULL;
struct icaltimetype dtstart, dtend;
disp_cal *Cal;
@@ -607,12 +565,12 @@ void load_task(icalcomponent *event, long msgnum, char *from, int unread, calvie
dtstart = icaltime_null_time();
dtend = icaltime_null_time();
-
+
if (WC->disp_cal_items == NULL) {
WC->disp_cal_items = NewHash(0, Flathash);
}
- Cal = (disp_cal*) malloc(sizeof(disp_cal));
+ Cal = (disp_cal *) malloc(sizeof(disp_cal));
memset(Cal, 0, sizeof(disp_cal));
Cal->cal = icalcomponent_new_clone(event);
@@ -629,7 +587,7 @@ void load_task(icalcomponent *event, long msgnum, char *from, int unread, calvie
Cal->unread = unread;
len = strlen(from);
- Cal->from = (char*)malloc(len+ 1);
+ Cal->from = (char *) malloc(len + 1);
memcpy(Cal->from, from, len + 1);
Cal->cal_msgnum = msgnum;
@@ -652,12 +610,7 @@ void load_task(icalcomponent *event, long msgnum, char *from, int unread, calvie
/* Store it in the hash list. */
/* syslog(LOG_DEBUG, "INITIAL: %s", ctime(&Cal->event_start)); */
- Put(WC->disp_cal_items,
- (char*) &Cal->event_start,
- sizeof(Cal->event_start),
- Cal,
- delete_task
- );
+ Put(WC->disp_cal_items, (char *) &Cal->event_start, sizeof(Cal->event_start), Cal, delete_task);
}
@@ -665,12 +618,7 @@ void load_task(icalcomponent *event, long msgnum, char *from, int unread, calvie
/*
* Display task view
*/
-int tasks_LoadMsgFromServer(SharedMessageStatus *Stat,
- void **ViewSpecific,
- message_summary* Msg,
- int is_new,
- int i)
-{
+int tasks_LoadMsgFromServer(SharedMessageStatus * Stat, void **ViewSpecific, message_summary * Msg, int is_new, int i) {
/* Not (yet?) needed here? calview *c = (calview *) *ViewSpecific; */
load_ical_object(Msg->msgnum, is_new, ICAL_VTODO_COMPONENT, load_task, NULL, 0);
@@ -682,7 +630,7 @@ int tasks_LoadMsgFromServer(SharedMessageStatus *Stat,
*/
void display_edit_task(void) {
long msgnum = 0L;
-
+
/* Force change the room if we have to */
if (havebstr("taskrm")) {
gotoroom(sbstr("taskrm"));
@@ -691,11 +639,7 @@ void display_edit_task(void) {
msgnum = lbstr("msgnum");
if (msgnum > 0L) {
/* existing task */
- load_ical_object(msgnum, 0,
- ICAL_VTODO_COMPONENT,
- display_edit_individual_task,
- NULL, 0
- );
+ load_ical_object(msgnum, 0, ICAL_VTODO_COMPONENT, display_edit_individual_task, NULL, 0);
}
else {
/* new task */
@@ -719,23 +663,17 @@ void save_task(void) {
-int tasks_GetParamsGetServerCall(SharedMessageStatus *Stat,
- void **ViewSpecific,
- long oper,
- char *cmd,
- long len,
- char *filter,
- long flen)
-{
+int tasks_GetParamsGetServerCall(SharedMessageStatus * Stat,
+ void **ViewSpecific, long oper, char *cmd, long len, char *filter, long flen) {
strcpy(cmd, "MSGS ALL");
Stat->maxmsgs = 32767;
return 200;
}
-int tasks_Cleanup(void **ViewSpecific)
-{
+int tasks_Cleanup(void **ViewSpecific) {
wDumpContent(1);
+
/* Tasks doesn't need the calview struct...
free (*ViewSpecific);
*ViewSpecific = NULL;
@@ -743,19 +681,9 @@ int tasks_Cleanup(void **ViewSpecific)
return 0;
}
-void
-InitModule_TASKS
-(void)
-{
- RegisterReadLoopHandlerset(
- VIEW_TASKS,
- tasks_GetParamsGetServerCall,
- NULL,
- NULL,
- NULL,
- tasks_LoadMsgFromServer,
- tasks_RenderView_or_Tail,
- tasks_Cleanup,
- NULL);
+void InitModule_TASKS(void) {
+ RegisterReadLoopHandlerset(VIEW_TASKS,
+ tasks_GetParamsGetServerCall,
+ NULL, NULL, NULL, tasks_LoadMsgFromServer, tasks_RenderView_or_Tail, tasks_Cleanup, NULL);
WebcitAddUrlHandler(HKEY("save_task"), "", 0, save_task, 0);
}
diff --git a/webcit/useredit.c b/webcit/useredit.c
index 80371dc9f..0d334bdcd 100644
--- a/webcit/useredit.c
+++ b/webcit/useredit.c
@@ -1,3 +1,4 @@
+
/*
* Copyright (c) 1996-2021 by the citadel.org team
*
@@ -14,16 +15,16 @@
#include "webserver.h"
CtxType CTX_USERLIST = CTX_NONE;
+
/*
* show a list of available users to edit them
* message the header message???
* preselect = which user should be selected in the browser
*/
-void select_user_to_edit(const char *preselect)
-{
+void select_user_to_edit(const char *preselect) {
output_headers(1, 0, 0, 0, 1, 0);
do_template("aide_edituser_select");
- end_burst();
+ end_burst();
}
@@ -47,35 +48,34 @@ typedef struct _UserListEntry {
} UserListEntry;
-UserListEntry* NewUserListOneEntry(StrBuf *SerializedUser, const char *Pos)
-{
+UserListEntry *NewUserListOneEntry(StrBuf * SerializedUser, const char *Pos) {
UserListEntry *ul;
- if (StrLength(SerializedUser) < 8)
+ if (StrLength(SerializedUser) < 8)
return NULL;
- ul = (UserListEntry*) malloc(sizeof(UserListEntry));
+ ul = (UserListEntry *) malloc(sizeof(UserListEntry));
ul->UserName = NewStrBuf();
ul->Passvoid = NewStrBuf();
ul->PrimaryEmail = NewStrBuf();
ul->OtherEmails = NewStrBuf();
- StrBufExtract_NextToken(ul->UserName, SerializedUser, &Pos, '|');
- StrBufExtract_NextToken(ul->Passvoid, SerializedUser, &Pos, '|');
- ul->Flags = StrBufExtractNext_unsigned_long(SerializedUser, &Pos, '|');
- ul->nLogons = StrBufExtractNext_int( SerializedUser, &Pos, '|');
- ul->nPosts = StrBufExtractNext_int( SerializedUser, &Pos, '|');
- ul->AccessLevel = StrBufExtractNext_int( SerializedUser, &Pos, '|');
- ul->UID = StrBufExtractNext_int( SerializedUser, &Pos, '|');
- ul->LastLogonT = StrBufExtractNext_long( SerializedUser, &Pos, '|');
- ul->DaysTillPurge = StrBufExtractNext_int( SerializedUser, &Pos, '|');
+ StrBufExtract_NextToken(ul->UserName, SerializedUser, &Pos, '|');
+ StrBufExtract_NextToken(ul->Passvoid, SerializedUser, &Pos, '|');
+ ul->Flags = StrBufExtractNext_unsigned_long(SerializedUser, &Pos, '|');
+ ul->nLogons = StrBufExtractNext_int(SerializedUser, &Pos, '|');
+ ul->nPosts = StrBufExtractNext_int(SerializedUser, &Pos, '|');
+ ul->AccessLevel = StrBufExtractNext_int(SerializedUser, &Pos, '|');
+ ul->UID = StrBufExtractNext_int(SerializedUser, &Pos, '|');
+ ul->LastLogonT = StrBufExtractNext_long(SerializedUser, &Pos, '|');
+ ul->DaysTillPurge = StrBufExtractNext_int(SerializedUser, &Pos, '|');
return ul;
}
-void DeleteUserListEntry(void *vUserList)
-{
- UserListEntry *ul = (UserListEntry*) vUserList;
- if (!ul) return;
+void DeleteUserListEntry(void *vUserList) {
+ UserListEntry *ul = (UserListEntry *) vUserList;
+ if (!ul)
+ return;
FreeStrBuf(&ul->UserName);
FreeStrBuf(&ul->Passvoid);
FreeStrBuf(&ul->PrimaryEmail);
@@ -83,27 +83,26 @@ void DeleteUserListEntry(void *vUserList)
free(ul);
}
-UserListEntry* NewUserListEntry(StrBuf *SerializedUserList)
-{
+UserListEntry *NewUserListEntry(StrBuf * SerializedUserList) {
const char *Pos = NULL;
UserListEntry *ul;
- if (StrLength(SerializedUserList) < 8)
+ if (StrLength(SerializedUserList) < 8)
return NULL;
- ul = (UserListEntry*) malloc(sizeof(UserListEntry));
+ ul = (UserListEntry *) malloc(sizeof(UserListEntry));
ul->UserName = NewStrBuf();
ul->Passvoid = NewStrBuf();
ul->PrimaryEmail = NewStrBuf();
ul->OtherEmails = NewStrBuf();
- StrBufExtract_NextToken(ul->UserName, SerializedUserList, &Pos, '|');
- ul->AccessLevel = StrBufExtractNext_int( SerializedUserList, &Pos, '|');
- ul->UID = StrBufExtractNext_int( SerializedUserList, &Pos, '|');
- ul->LastLogonT = StrBufExtractNext_long(SerializedUserList, &Pos, '|');
- ul->nLogons = StrBufExtractNext_int( SerializedUserList, &Pos, '|');
- ul->nPosts = StrBufExtractNext_int( SerializedUserList, &Pos, '|');
- StrBufExtract_NextToken(ul->Passvoid, SerializedUserList, &Pos, '|');
+ StrBufExtract_NextToken(ul->UserName, SerializedUserList, &Pos, '|');
+ ul->AccessLevel = StrBufExtractNext_int(SerializedUserList, &Pos, '|');
+ ul->UID = StrBufExtractNext_int(SerializedUserList, &Pos, '|');
+ ul->LastLogonT = StrBufExtractNext_long(SerializedUserList, &Pos, '|');
+ ul->nLogons = StrBufExtractNext_int(SerializedUserList, &Pos, '|');
+ ul->nPosts = StrBufExtractNext_int(SerializedUserList, &Pos, '|');
+ StrBufExtract_NextToken(ul->Passvoid, SerializedUserList, &Pos, '|');
ul->Flags = 0;
ul->HasBio = 0;
ul->DaysTillPurge = -1;
@@ -113,51 +112,45 @@ UserListEntry* NewUserListEntry(StrBuf *SerializedUserList)
/*
* Sort by Username
*/
-int CompareUserListName(const void *vUser1, const void *vUser2)
-{
- UserListEntry *u1 = (UserListEntry*) GetSearchPayload(vUser1);
- UserListEntry *u2 = (UserListEntry*) GetSearchPayload(vUser2);
+int CompareUserListName(const void *vUser1, const void *vUser2) {
+ UserListEntry *u1 = (UserListEntry *) GetSearchPayload(vUser1);
+ UserListEntry *u2 = (UserListEntry *) GetSearchPayload(vUser2);
return strcmp(ChrPtr(u1->UserName), ChrPtr(u2->UserName));
}
-int CompareUserListNameRev(const void *vUser1, const void *vUser2)
-{
- UserListEntry *u1 = (UserListEntry*) GetSearchPayload(vUser1);
- UserListEntry *u2 = (UserListEntry*) GetSearchPayload(vUser2);
+int CompareUserListNameRev(const void *vUser1, const void *vUser2) {
+ UserListEntry *u1 = (UserListEntry *) GetSearchPayload(vUser1);
+ UserListEntry *u2 = (UserListEntry *) GetSearchPayload(vUser2);
return strcmp(ChrPtr(u2->UserName), ChrPtr(u1->UserName));
}
-int GroupchangeUserListName(const void *vUser1, const void *vUser2)
-{
- UserListEntry *u1 = (UserListEntry*) vUser1;
- UserListEntry *u2 = (UserListEntry*) vUser2;
+int GroupchangeUserListName(const void *vUser1, const void *vUser2) {
+ UserListEntry *u1 = (UserListEntry *) vUser1;
+ UserListEntry *u2 = (UserListEntry *) vUser2;
return ChrPtr(u2->UserName)[0] != ChrPtr(u1->UserName)[0];
}
/*
* Sort by access level
*/
-int CompareAccessLevel(const void *vUser1, const void *vUser2)
-{
- UserListEntry *u1 = (UserListEntry*) GetSearchPayload(vUser1);
- UserListEntry *u2 = (UserListEntry*) GetSearchPayload(vUser2);
+int CompareAccessLevel(const void *vUser1, const void *vUser2) {
+ UserListEntry *u1 = (UserListEntry *) GetSearchPayload(vUser1);
+ UserListEntry *u2 = (UserListEntry *) GetSearchPayload(vUser2);
return (u1->AccessLevel > u2->AccessLevel);
}
-int CompareAccessLevelRev(const void *vUser1, const void *vUser2)
-{
- UserListEntry *u1 = (UserListEntry*) GetSearchPayload(vUser1);
- UserListEntry *u2 = (UserListEntry*) GetSearchPayload(vUser2);
+int CompareAccessLevelRev(const void *vUser1, const void *vUser2) {
+ UserListEntry *u1 = (UserListEntry *) GetSearchPayload(vUser1);
+ UserListEntry *u2 = (UserListEntry *) GetSearchPayload(vUser2);
return (u2->AccessLevel > u1->AccessLevel);
}
-int GroupchangeAccessLevel(const void *vUser1, const void *vUser2)
-{
- UserListEntry *u1 = (UserListEntry*) vUser1;
- UserListEntry *u2 = (UserListEntry*) vUser2;
+int GroupchangeAccessLevel(const void *vUser1, const void *vUser2) {
+ UserListEntry *u1 = (UserListEntry *) vUser1;
+ UserListEntry *u2 = (UserListEntry *) vUser2;
return u2->AccessLevel != u1->AccessLevel;
}
@@ -165,26 +158,23 @@ int GroupchangeAccessLevel(const void *vUser1, const void *vUser2)
/*
* Sort by UID
*/
-int CompareUID(const void *vUser1, const void *vUser2)
-{
- UserListEntry *u1 = (UserListEntry*) GetSearchPayload(vUser1);
- UserListEntry *u2 = (UserListEntry*) GetSearchPayload(vUser2);
+int CompareUID(const void *vUser1, const void *vUser2) {
+ UserListEntry *u1 = (UserListEntry *) GetSearchPayload(vUser1);
+ UserListEntry *u2 = (UserListEntry *) GetSearchPayload(vUser2);
return (u1->UID > u2->UID);
}
-int CompareUIDRev(const void *vUser1, const void *vUser2)
-{
- UserListEntry *u1 = (UserListEntry*) GetSearchPayload(vUser1);
- UserListEntry *u2 = (UserListEntry*) GetSearchPayload(vUser2);
+int CompareUIDRev(const void *vUser1, const void *vUser2) {
+ UserListEntry *u1 = (UserListEntry *) GetSearchPayload(vUser1);
+ UserListEntry *u2 = (UserListEntry *) GetSearchPayload(vUser2);
return (u2->UID > u1->UID);
}
-int GroupchangeUID(const void *vUser1, const void *vUser2)
-{
- UserListEntry *u1 = (UserListEntry*) vUser1;
- UserListEntry *u2 = (UserListEntry*) vUser2;
+int GroupchangeUID(const void *vUser1, const void *vUser2) {
+ UserListEntry *u1 = (UserListEntry *) vUser1;
+ UserListEntry *u2 = (UserListEntry *) vUser2;
return (u2->UID / 10) != (u1->UID / 10);
}
@@ -192,26 +182,23 @@ int GroupchangeUID(const void *vUser1, const void *vUser2)
/*
* Sort By Date /// TODO!
*/
-int CompareLastLogon(const void *vUser1, const void *vUser2)
-{
- UserListEntry *u1 = (UserListEntry*) GetSearchPayload(vUser1);
- UserListEntry *u2 = (UserListEntry*) GetSearchPayload(vUser2);
+int CompareLastLogon(const void *vUser1, const void *vUser2) {
+ UserListEntry *u1 = (UserListEntry *) GetSearchPayload(vUser1);
+ UserListEntry *u2 = (UserListEntry *) GetSearchPayload(vUser2);
return (u1->LastLogonT > u2->LastLogonT);
}
-int CompareLastLogonRev(const void *vUser1, const void *vUser2)
-{
- UserListEntry *u1 = (UserListEntry*) GetSearchPayload(vUser1);
- UserListEntry *u2 = (UserListEntry*) GetSearchPayload(vUser2);
+int CompareLastLogonRev(const void *vUser1, const void *vUser2) {
+ UserListEntry *u1 = (UserListEntry *) GetSearchPayload(vUser1);
+ UserListEntry *u2 = (UserListEntry *) GetSearchPayload(vUser2);
return (u2->LastLogonT > u1->LastLogonT);
}
-int GroupchangeLastLogon(const void *vUser1, const void *vUser2)
-{
- UserListEntry *u1 = (UserListEntry*) vUser1;
- UserListEntry *u2 = (UserListEntry*) vUser2;
+int GroupchangeLastLogon(const void *vUser1, const void *vUser2) {
+ UserListEntry *u1 = (UserListEntry *) vUser1;
+ UserListEntry *u2 = (UserListEntry *) vUser2;
return (u2->LastLogonT != u1->LastLogonT);
}
@@ -219,26 +206,23 @@ int GroupchangeLastLogon(const void *vUser1, const void *vUser2)
/*
* Sort By Number of Logons
*/
-int ComparenLogons(const void *vUser1, const void *vUser2)
-{
- UserListEntry *u1 = (UserListEntry*) GetSearchPayload(vUser1);
- UserListEntry *u2 = (UserListEntry*) GetSearchPayload(vUser2);
+int ComparenLogons(const void *vUser1, const void *vUser2) {
+ UserListEntry *u1 = (UserListEntry *) GetSearchPayload(vUser1);
+ UserListEntry *u2 = (UserListEntry *) GetSearchPayload(vUser2);
return (u1->nLogons > u2->nLogons);
}
-int ComparenLogonsRev(const void *vUser1, const void *vUser2)
-{
- UserListEntry *u1 = (UserListEntry*) GetSearchPayload(vUser1);
- UserListEntry *u2 = (UserListEntry*) GetSearchPayload(vUser2);
+int ComparenLogonsRev(const void *vUser1, const void *vUser2) {
+ UserListEntry *u1 = (UserListEntry *) GetSearchPayload(vUser1);
+ UserListEntry *u2 = (UserListEntry *) GetSearchPayload(vUser2);
return (u2->nLogons > u1->nLogons);
}
-int GroupchangenLogons(const void *vUser1, const void *vUser2)
-{
- UserListEntry *u1 = (UserListEntry*) vUser1;
- UserListEntry *u2 = (UserListEntry*) vUser2;
+int GroupchangenLogons(const void *vUser1, const void *vUser2) {
+ UserListEntry *u1 = (UserListEntry *) vUser1;
+ UserListEntry *u2 = (UserListEntry *) vUser2;
return (u2->nLogons / 100) != (u1->nLogons / 100);
}
@@ -246,45 +230,41 @@ int GroupchangenLogons(const void *vUser1, const void *vUser2)
/*
* Sort By Number of Posts
*/
-int ComparenPosts(const void *vUser1, const void *vUser2)
-{
- UserListEntry *u1 = (UserListEntry*) GetSearchPayload(vUser1);
- UserListEntry *u2 = (UserListEntry*) GetSearchPayload(vUser2);
+int ComparenPosts(const void *vUser1, const void *vUser2) {
+ UserListEntry *u1 = (UserListEntry *) GetSearchPayload(vUser1);
+ UserListEntry *u2 = (UserListEntry *) GetSearchPayload(vUser2);
return (u1->nPosts > u2->nPosts);
}
-int ComparenPostsRev(const void *vUser1, const void *vUser2)
-{
- UserListEntry *u1 = (UserListEntry*) GetSearchPayload(vUser1);
- UserListEntry *u2 = (UserListEntry*) GetSearchPayload(vUser2);
+int ComparenPostsRev(const void *vUser1, const void *vUser2) {
+ UserListEntry *u1 = (UserListEntry *) GetSearchPayload(vUser1);
+ UserListEntry *u2 = (UserListEntry *) GetSearchPayload(vUser2);
return (u2->nPosts > u1->nPosts);
}
-int GroupchangenPosts(const void *vUser1, const void *vUser2)
-{
- UserListEntry *u1 = (UserListEntry*) vUser1;
- UserListEntry *u2 = (UserListEntry*) vUser2;
+int GroupchangenPosts(const void *vUser1, const void *vUser2) {
+ UserListEntry *u1 = (UserListEntry *) vUser1;
+ UserListEntry *u2 = (UserListEntry *) vUser2;
return (u2->nPosts / 100) != (u1->nPosts / 100);
}
-HashList *iterate_load_userlist(StrBuf *Target, WCTemplputParams *TP)
-{
+HashList *iterate_load_userlist(StrBuf * Target, WCTemplputParams * TP) {
int Done = 0;
CompareFunc SortIt;
HashList *Hash = NULL;
StrBuf *Buf;
- UserListEntry* ul;
+ UserListEntry *ul;
int len;
int UID;
void *vData;
WCTemplputParams SubTP;
- memset(&SubTP, 0, sizeof(WCTemplputParams));
- serv_puts("LIST");
+ memset(&SubTP, 0, sizeof(WCTemplputParams));
+ serv_puts("LIST");
Buf = NewStrBuf();
StrBuf_ServGetln(Buf);
if (GetServerStatus(Buf, NULL) == 1) {
@@ -292,10 +272,7 @@ HashList *iterate_load_userlist(StrBuf *Target, WCTemplputParams *TP)
Done = 0;
while (!Done) {
len = StrBuf_ServGetln(Buf);
- if ((len <0) ||
- ((len == 3) &&
- !strcmp(ChrPtr(Buf), "000")))
- {
+ if ((len < 0) || ((len == 3) && !strcmp(ChrPtr(Buf), "000"))) {
Done = 1;
break;
}
@@ -303,7 +280,7 @@ HashList *iterate_load_userlist(StrBuf *Target, WCTemplputParams *TP)
if (ul == NULL)
continue;
- Put(Hash, IKEY(ul->UID), ul, DeleteUserListEntry);
+ Put(Hash, IKEY(ul->UID), ul, DeleteUserListEntry);
}
serv_puts("LBIO 1");
@@ -312,16 +289,14 @@ HashList *iterate_load_userlist(StrBuf *Target, WCTemplputParams *TP)
Done = 0;
while (!Done) {
len = StrBuf_ServGetln(Buf);
- if ((len <0) || ((len == 3) && !strcmp(ChrPtr(Buf), "000")))
- {
+ if ((len < 0) || ((len == 3) && !strcmp(ChrPtr(Buf), "000"))) {
Done = 1;
break;
}
}
UID = atoi(ChrPtr(Buf));
- if (GetHash(Hash, IKEY(UID), &vData) && vData != 0)
- {
- ul = (UserListEntry*)vData;
+ if (GetHash(Hash, IKEY(UID), &vData) && vData != 0) {
+ ul = (UserListEntry *) vData;
ul->HasBio = 1;
}
}
@@ -329,162 +304,139 @@ HashList *iterate_load_userlist(StrBuf *Target, WCTemplputParams *TP)
SortIt = RetrieveSort(&SubTP, HKEY("USER"), HKEY("user:uid"), 0);
if (SortIt != NULL)
SortByPayload(Hash, SortIt);
- else
+ else
SortByPayload(Hash, CompareUID);
- }
+ }
FreeStrBuf(&Buf);
return Hash;
}
-void tmplput_USERLIST_UserName(StrBuf *Target, WCTemplputParams *TP)
-{
- UserListEntry *ul = (UserListEntry*) CTX(CTX_USERLIST);
+void tmplput_USERLIST_UserName(StrBuf * Target, WCTemplputParams * TP) {
+ UserListEntry *ul = (UserListEntry *) CTX(CTX_USERLIST);
StrBufAppendTemplate(Target, TP, ul->UserName, 0);
}
-void tmplput_USERLIST_Password(StrBuf *Target, WCTemplputParams *TP)
-{
- UserListEntry *ul = (UserListEntry*) CTX(CTX_USERLIST);
+void tmplput_USERLIST_Password(StrBuf * Target, WCTemplputParams * TP) {
+ UserListEntry *ul = (UserListEntry *) CTX(CTX_USERLIST);
StrBufAppendTemplate(Target, TP, ul->Passvoid, 0);
}
-void tmplput_USERLIST_PrimaryEmail(StrBuf *Target, WCTemplputParams *TP)
-{
- UserListEntry *ul = (UserListEntry*) CTX(CTX_USERLIST);
+void tmplput_USERLIST_PrimaryEmail(StrBuf * Target, WCTemplputParams * TP) {
+ UserListEntry *ul = (UserListEntry *) CTX(CTX_USERLIST);
StrBufAppendTemplate(Target, TP, ul->PrimaryEmail, 0);
}
-void tmplput_USERLIST_OtherEmails(StrBuf *Target, WCTemplputParams *TP)
-{
- UserListEntry *ul = (UserListEntry*) CTX(CTX_USERLIST);
+void tmplput_USERLIST_OtherEmails(StrBuf * Target, WCTemplputParams * TP) {
+ UserListEntry *ul = (UserListEntry *) CTX(CTX_USERLIST);
StrBufAppendTemplate(Target, TP, ul->OtherEmails, 0);
}
-void tmplput_USERLIST_AccessLevelNo(StrBuf *Target, WCTemplputParams *TP)
-{
- UserListEntry *ul = (UserListEntry*) CTX(CTX_USERLIST);
+void tmplput_USERLIST_AccessLevelNo(StrBuf * Target, WCTemplputParams * TP) {
+ UserListEntry *ul = (UserListEntry *) CTX(CTX_USERLIST);
StrBufAppendPrintf(Target, "%d", ul->AccessLevel, 0);
}
-void tmplput_USERLIST_AccessLevelStr(StrBuf *Target, WCTemplputParams *TP)
-{
- UserListEntry *ul = (UserListEntry*) CTX(CTX_USERLIST);
-
+void tmplput_USERLIST_AccessLevelStr(StrBuf * Target, WCTemplputParams * TP) {
+ UserListEntry *ul = (UserListEntry *) CTX(CTX_USERLIST);
+
StrBufAppendBufPlain(Target, _(axdefs[ul->AccessLevel]), -1, 0);
}
-void tmplput_USERLIST_UID(StrBuf *Target, WCTemplputParams *TP)
-{
- UserListEntry *ul = (UserListEntry*) CTX(CTX_USERLIST);
+void tmplput_USERLIST_UID(StrBuf * Target, WCTemplputParams * TP) {
+ UserListEntry *ul = (UserListEntry *) CTX(CTX_USERLIST);
StrBufAppendPrintf(Target, "%d", ul->UID, 0);
}
-void tmplput_USERLIST_LastLogonNo(StrBuf *Target, WCTemplputParams *TP)
-{
- UserListEntry *ul = (UserListEntry*) CTX(CTX_USERLIST);
+void tmplput_USERLIST_LastLogonNo(StrBuf * Target, WCTemplputParams * TP) {
+ UserListEntry *ul = (UserListEntry *) CTX(CTX_USERLIST);
- StrBufAppendPrintf(Target,"%ld", ul->LastLogonT, 0);
+ StrBufAppendPrintf(Target, "%ld", ul->LastLogonT, 0);
}
-void tmplput_USERLIST_LastLogonStr(StrBuf *Target, WCTemplputParams *TP)
-{
- UserListEntry *ul = (UserListEntry*) CTX(CTX_USERLIST);
+void tmplput_USERLIST_LastLogonStr(StrBuf * Target, WCTemplputParams * TP) {
+ UserListEntry *ul = (UserListEntry *) CTX(CTX_USERLIST);
StrEscAppend(Target, NULL, asctime(localtime(&ul->LastLogonT)), 0, 0);
}
-void tmplput_USERLIST_nLogons(StrBuf *Target, WCTemplputParams *TP)
-{
- UserListEntry *ul = (UserListEntry*) CTX(CTX_USERLIST);
+void tmplput_USERLIST_nLogons(StrBuf * Target, WCTemplputParams * TP) {
+ UserListEntry *ul = (UserListEntry *) CTX(CTX_USERLIST);
StrBufAppendPrintf(Target, "%d", ul->nLogons, 0);
}
-void tmplput_USERLIST_nPosts(StrBuf *Target, WCTemplputParams *TP)
-{
- UserListEntry *ul = (UserListEntry*) CTX(CTX_USERLIST);
+void tmplput_USERLIST_nPosts(StrBuf * Target, WCTemplputParams * TP) {
+ UserListEntry *ul = (UserListEntry *) CTX(CTX_USERLIST);
StrBufAppendPrintf(Target, "%d", ul->nPosts, 0);
}
-void tmplput_USERLIST_Flags(StrBuf *Target, WCTemplputParams *TP)
-{
- UserListEntry *ul = (UserListEntry*) CTX(CTX_USERLIST);
+void tmplput_USERLIST_Flags(StrBuf * Target, WCTemplputParams * TP) {
+ UserListEntry *ul = (UserListEntry *) CTX(CTX_USERLIST);
StrBufAppendPrintf(Target, "%d", ul->Flags, 0);
}
-void tmplput_USERLIST_DaysTillPurge(StrBuf *Target, WCTemplputParams *TP)
-{
- UserListEntry *ul = (UserListEntry*) CTX(CTX_USERLIST);
+void tmplput_USERLIST_DaysTillPurge(StrBuf * Target, WCTemplputParams * TP) {
+ UserListEntry *ul = (UserListEntry *) CTX(CTX_USERLIST);
StrBufAppendPrintf(Target, "%d", ul->DaysTillPurge, 0);
}
-int ConditionalUser(StrBuf *Target, WCTemplputParams *TP)
-{
- UserListEntry *ul = (UserListEntry*) CTX(CTX_USERLIST);
+int ConditionalUser(StrBuf * Target, WCTemplputParams * TP) {
+ UserListEntry *ul = (UserListEntry *) CTX(CTX_USERLIST);
if (havebstr("usernum")) {
return ibstr("usernum") == ul->UID;
}
else if (havebstr("username")) {
return strcmp(bstr("username"), ChrPtr(ul->UserName)) == 0;
}
- else
+ else
return 0;
}
-int ConditionalFlagINetEmail(StrBuf *Target, WCTemplputParams *TP)
-{
- UserListEntry *ul = (UserListEntry*) CTX(CTX_USERLIST);
+int ConditionalFlagINetEmail(StrBuf * Target, WCTemplputParams * TP) {
+ UserListEntry *ul = (UserListEntry *) CTX(CTX_USERLIST);
return (ul->Flags & US_INTERNET) != 0;
}
-int ConditionalUserAccess(StrBuf *Target, WCTemplputParams *TP)
-{
- UserListEntry *ul = (UserListEntry*) CTX(CTX_USERLIST);
-
+int ConditionalUserAccess(StrBuf * Target, WCTemplputParams * TP) {
+ UserListEntry *ul = (UserListEntry *) CTX(CTX_USERLIST);
+
if (ul == NULL)
return 0;
- return GetTemplateTokenNumber(Target,
- TP,
- 3,
- AxNewU)
- ==
- ul->AccessLevel;
+ return GetTemplateTokenNumber(Target, TP, 3, AxNewU)
+ == ul->AccessLevel;
}
-int ConditionalHaveBIO(StrBuf *Target, WCTemplputParams *TP)
-{
- UserListEntry *ul = (UserListEntry*) CTX(CTX_USERLIST);
-
+int ConditionalHaveBIO(StrBuf * Target, WCTemplputParams * TP) {
+ UserListEntry *ul = (UserListEntry *) CTX(CTX_USERLIST);
+
if (ul == NULL)
return 0;
return ul->HasBio;
}
-int ConditionalSuppressEmailFields(StrBuf *Target, WCTemplputParams *TP)
-{
+int ConditionalSuppressEmailFields(StrBuf * Target, WCTemplputParams * TP) {
return 0; // FIXME this makes all email fields display
}
-void tmplput_USER_BIO(StrBuf *Target, WCTemplputParams *TP)
-{
+void tmplput_USER_BIO(StrBuf * Target, WCTemplputParams * TP) {
int Done = 0;
StrBuf *Buf;
const char *who;
@@ -500,9 +452,8 @@ void tmplput_USER_BIO(StrBuf *Target, WCTemplputParams *TP)
StrBuf_ServGetln(Buf);
if (GetServerStatus(Buf, NULL) == 1) {
StrBuf *BioBuf = NewStrBufPlain(NULL, SIZ);
- while (!Done && StrBuf_ServGetln(Buf)>=0) {
- if ( (StrLength(Buf)==3) &&
- !strcmp(ChrPtr(Buf), "000"))
+ while (!Done && StrBuf_ServGetln(Buf) >= 0) {
+ if ((StrLength(Buf) == 3) && !strcmp(ChrPtr(Buf), "000"))
Done = 1;
else {
StrBufAppendBuf(BioBuf, Buf, 0);
@@ -516,10 +467,9 @@ void tmplput_USER_BIO(StrBuf *Target, WCTemplputParams *TP)
}
-int Conditional_USER_HAS_PIC(StrBuf *Target, WCTemplputParams *TP)
-{
+int Conditional_USER_HAS_PIC(StrBuf * Target, WCTemplputParams * TP) {
// ajc 2016apr10 this needs to be re-evaluated with the new protocol
- return(0);
+ return (0);
}
@@ -527,8 +477,7 @@ int Conditional_USER_HAS_PIC(StrBuf *Target, WCTemplputParams *TP)
* Locate the message number of a user's vCard in the current room
* Returns the message id of his vcard
*/
-long locate_user_vcard_in_this_room(message_summary **VCMsg, wc_mime_attachment **VCAtt)
-{
+long locate_user_vcard_in_this_room(message_summary ** VCMsg, wc_mime_attachment ** VCAtt) {
HashPos *at;
HashPos *att;
const char *HashKey;
@@ -545,7 +494,7 @@ long locate_user_vcard_in_this_room(message_summary **VCMsg, wc_mime_attachment
Buf = NewStrBuf();
-TRYAGAIN:
+ TRYAGAIN:
memset(&Stat, 0, sizeof(SharedMessageStatus));
Stat.maxload = 10000;
Stat.lowest_found = (-1);
@@ -554,22 +503,20 @@ TRYAGAIN:
if (load_msg_ptrs("MSGS ALL||||1", NULL, NULL, &Stat, NULL, NULL, NULL, NULL, 0) > 0) {
at = GetNewHashPos(WC->summ, 0);
while (GetNextHashPos(WC->summ, at, &HKLen, &HashKey, &vMsg)) {
- Msg = (message_summary*) vMsg;
- Msg->MsgBody = (wc_mime_attachment*) malloc(sizeof(wc_mime_attachment));
+ Msg = (message_summary *) vMsg;
+ Msg->MsgBody = (wc_mime_attachment *) malloc(sizeof(wc_mime_attachment));
memset(Msg->MsgBody, 0, sizeof(wc_mime_attachment));
Msg->MsgBody->msgnum = Msg->msgnum;
load_message(Msg, FoundCharset, &Error);
-
+
if (Msg->AllAttach != NULL) {
att = GetNewHashPos(Msg->AllAttach, 0);
- while (GetNextHashPos(Msg->AllAttach, att, &HKLen, &HashKey, &vMsg) &&
- (vcard_msgnum == -1)) {
- Att = (wc_mime_attachment*) vMsg;
- if (
- (strcasecmp(ChrPtr(Att->ContentType), "text/x-vcard") == 0)
- || (strcasecmp(ChrPtr(Att->ContentType), "text/vcard") == 0)
- ) {
+ while (GetNextHashPos(Msg->AllAttach, att, &HKLen, &HashKey, &vMsg) && (vcard_msgnum == -1)) {
+ Att = (wc_mime_attachment *) vMsg;
+ if ((strcasecmp(ChrPtr(Att->ContentType), "text/x-vcard") == 0)
+ || (strcasecmp(ChrPtr(Att->ContentType), "text/vcard") == 0)
+ ) {
*VCAtt = Att;
*VCMsg = Msg;
vcard_msgnum = Msg->msgnum;
@@ -581,9 +528,9 @@ TRYAGAIN:
DeleteHashPos(&att);
}
FreeStrBuf(&Error); /* don't care... */
-
+
}
- DeleteHashPos(&at);
+ DeleteHashPos(&at);
}
/* If there's no vcard, create one */
@@ -599,14 +546,14 @@ TRYAGAIN:
serv_puts("end:vcard");
serv_puts("000");
}
- else
+ else
syslog(LOG_WARNING, "Error while creating user vcard: %s\n", ChrPtr(Buf));
goto TRYAGAIN;
}
FreeStrBuf(&Buf);
FreeStrBuf(&FoundCharset);
- return(vcard_msgnum);
+ return (vcard_msgnum);
}
@@ -652,11 +599,7 @@ void display_edit_address_book_entry(const char *username, long usernum) {
return;
}
- do_edit_vcard(vcard_msgnum, "1",
- VCMsg,
- VCAtt,
- "select_user_to_edit",
- ChrPtr(roomname));
+ do_edit_vcard(vcard_msgnum, "1", VCMsg, VCAtt, "select_user_to_edit", ChrPtr(roomname));
FreeStrBuf(&roomname);
}
@@ -666,20 +609,20 @@ void display_edit_address_book_entry(const char *username, long usernum) {
*/
void delete_user(char *username) {
StrBuf *Buf;
-
+
Buf = NewStrBuf();
serv_printf("ASUP %s|0|0|0|0|0|", username);
StrBuf_ServGetln(Buf);
GetServerStatusMsg(Buf, NULL, 1, 2);
- select_user_to_edit( bstr("username"));
+ select_user_to_edit(bstr("username"));
FreeStrBuf(&Buf);
}
-
+
void display_edituser(const char *supplied_username, int is_new) {
const char *Pos;
- UserListEntry* UL;
+ UserListEntry *UL;
StrBuf *Buf;
char username[256];
int i = 0;
@@ -713,7 +656,7 @@ void display_edituser(const char *supplied_username, int is_new) {
serv_printf("AGEA %s", username);
StrBuf_ServGetln(Buf);
if (GetServerStatusMsg(Buf, NULL, 1, 2) == 1) {
- while(StrBuf_ServGetln(Buf) , strcmp(ChrPtr(Buf), "000")) {
+ while (StrBuf_ServGetln(Buf), strcmp(ChrPtr(Buf), "000")) {
if (i == 0) {
StrBufAppendPrintf(UL->PrimaryEmail, "%s", ChrPtr(Buf));
}
@@ -736,7 +679,7 @@ void display_edituser(const char *supplied_username, int is_new) {
end_burst();
}
DeleteUserListEntry(UL);
-
+
}
FreeStrBuf(&Buf);
}
@@ -754,7 +697,7 @@ void edituser(void) {
if (!havebstr("ok_button")) {
AppendImportantMessage(_("Changes were not saved."), -1);
- }
+ }
else {
StrBuf *Buf = NewStrBuf();
@@ -763,7 +706,7 @@ void edituser(void) {
flags |= US_INTERNET;
}
else {
- flags &= ~US_INTERNET ;
+ flags &= ~US_INTERNET;
}
if ((havebstr("newname")) && (strcasecmp(bstr("username"), bstr("newname")))) {
@@ -776,16 +719,12 @@ void edituser(void) {
/* Send the new account parameters */
serv_printf("ASUP %s|%s|%d|%s|%s|%s|%s|%s|%s|",
- username,
- bstr("password"),
- flags,
- bstr("timescalled"),
- bstr("msgsposted"),
- bstr("axlevel"),
- bstr("usernum"),
- bstr("lastcall"),
- bstr("purgedays")
- );
+ username,
+ bstr("password"),
+ flags,
+ bstr("timescalled"),
+ bstr("msgsposted"), bstr("axlevel"), bstr("usernum"), bstr("lastcall"), bstr("purgedays")
+ );
StrBuf_ServGetln(Buf);
GetServerStatusMsg(Buf, NULL, 1, 2);
@@ -795,20 +734,21 @@ void edituser(void) {
/* Replace any commas, semicolons, or spaces with newlines */
char *pos;
- for (pos=all_the_emails; *pos!=0; ++pos) {
- if ((*pos == ',') || (*pos == ';') || (*pos == ' ')) *pos = '\n' ;
+ for (pos = all_the_emails; *pos != 0; ++pos) {
+ if ((*pos == ',') || (*pos == ';') || (*pos == ' '))
+ *pos = '\n';
}
/* Remove any naughty inappropriate whitespace */
striplt(all_the_emails);
while (pos = strstr(all_the_emails, "\n,"), (pos != NULL)) {
- strcpy(pos, pos+1);
+ strcpy(pos, pos + 1);
}
while (pos = strstr(all_the_emails, ",\n"), (pos != NULL)) {
- strcpy(pos+1, pos+2);
+ strcpy(pos + 1, pos + 2);
}
while (pos = strstr(all_the_emails, "\n\n"), (pos != NULL)) {
- strcpy(pos+1, pos+2);
+ strcpy(pos + 1, pos + 2);
}
/* Now send it to the server. */
@@ -826,7 +766,7 @@ void edituser(void) {
* the vCard edit screen.
*/
if (is_new) {
- display_edit_address_book_entry(username, lbstr("usernum") );
+ display_edit_address_book_entry(username, lbstr("usernum"));
}
else {
select_user_to_edit(username);
@@ -854,8 +794,7 @@ void create_user(void) {
else if (FullState == 570) {
AppendImportantMessage(_("You are attempting to create a new user from within Citadel "
"while running in host based authentication mode. In this mode, "
- "you must create new users on the host system, not within Citadel."),
- -1);
+ "you must create new users on the host system, not within Citadel."), -1);
select_user_to_edit(NULL);
}
else {
@@ -899,10 +838,7 @@ void _display_edituser(void) {
}
-void
-InitModule_USEREDIT
-(void)
-{
+void InitModule_USEREDIT(void) {
RegisterCTX(CTX_USERLIST);
WebcitAddUrlHandler(HKEY("select_user_to_edit"), "", 0, _select_user_to_edit, 0);
WebcitAddUrlHandler(HKEY("display_edituser"), "", 0, _display_edituser, 0);
@@ -910,70 +846,46 @@ InitModule_USEREDIT
WebcitAddUrlHandler(HKEY("create_user"), "", 0, create_user, 0);
WebcitAddUrlHandler(HKEY("userpic"), "", 0, display_userpic, 0);
- RegisterNamespace("USERLIST:USERNAME", 0, 1, tmplput_USERLIST_UserName, NULL, CTX_USERLIST);
- RegisterNamespace("USERLIST:PASSWD", 0, 1, tmplput_USERLIST_Password, NULL, CTX_USERLIST);
- RegisterNamespace("USERLIST:ACCLVLNO", 0, 0, tmplput_USERLIST_AccessLevelNo, NULL, CTX_USERLIST);
- RegisterNamespace("USERLIST:ACCLVLSTR", 0, 0, tmplput_USERLIST_AccessLevelStr, NULL, CTX_USERLIST);
- RegisterNamespace("USERLIST:UID", 0, 0, tmplput_USERLIST_UID, NULL, CTX_USERLIST);
+ RegisterNamespace("USERLIST:USERNAME", 0, 1, tmplput_USERLIST_UserName, NULL, CTX_USERLIST);
+ RegisterNamespace("USERLIST:PASSWD", 0, 1, tmplput_USERLIST_Password, NULL, CTX_USERLIST);
+ RegisterNamespace("USERLIST:ACCLVLNO", 0, 0, tmplput_USERLIST_AccessLevelNo, NULL, CTX_USERLIST);
+ RegisterNamespace("USERLIST:ACCLVLSTR", 0, 0, tmplput_USERLIST_AccessLevelStr, NULL, CTX_USERLIST);
+ RegisterNamespace("USERLIST:UID", 0, 0, tmplput_USERLIST_UID, NULL, CTX_USERLIST);
RegisterNamespace("USERLIST:LASTLOGON:STR", 0, 0, tmplput_USERLIST_LastLogonStr, NULL, CTX_USERLIST);
- RegisterNamespace("USERLIST:LASTLOGON:NO", 0, 0, tmplput_USERLIST_LastLogonNo, NULL, CTX_USERLIST);
- RegisterNamespace("USERLIST:NLOGONS", 0, 0, tmplput_USERLIST_nLogons, NULL, CTX_USERLIST);
- RegisterNamespace("USERLIST:NPOSTS", 0, 0, tmplput_USERLIST_nPosts, NULL, CTX_USERLIST);
- RegisterNamespace("USERLIST:PRIMARYEMAIL", 0, 1, tmplput_USERLIST_PrimaryEmail, NULL, CTX_USERLIST);
- RegisterNamespace("USERLIST:OTHEREMAILS", 0, 1, tmplput_USERLIST_OtherEmails, NULL, CTX_USERLIST);
- RegisterNamespace("USERLIST:FLAGS", 0, 0, tmplput_USERLIST_Flags, NULL, CTX_USERLIST);
+ RegisterNamespace("USERLIST:LASTLOGON:NO", 0, 0, tmplput_USERLIST_LastLogonNo, NULL, CTX_USERLIST);
+ RegisterNamespace("USERLIST:NLOGONS", 0, 0, tmplput_USERLIST_nLogons, NULL, CTX_USERLIST);
+ RegisterNamespace("USERLIST:NPOSTS", 0, 0, tmplput_USERLIST_nPosts, NULL, CTX_USERLIST);
+ RegisterNamespace("USERLIST:PRIMARYEMAIL", 0, 1, tmplput_USERLIST_PrimaryEmail, NULL, CTX_USERLIST);
+ RegisterNamespace("USERLIST:OTHEREMAILS", 0, 1, tmplput_USERLIST_OtherEmails, NULL, CTX_USERLIST);
+ RegisterNamespace("USERLIST:FLAGS", 0, 0, tmplput_USERLIST_Flags, NULL, CTX_USERLIST);
RegisterNamespace("USERLIST:DAYSTILLPURGE", 0, 0, tmplput_USERLIST_DaysTillPurge, NULL, CTX_USERLIST);
- RegisterNamespace("USER:BIO", 1, 2, tmplput_USER_BIO, NULL, CTX_NONE);
+ RegisterNamespace("USER:BIO", 1, 2, tmplput_USER_BIO, NULL, CTX_NONE);
- RegisterConditional("COND:USERNAME", 0, ConditionalUser, CTX_USERLIST);
- RegisterConditional("COND:USERACCESS", 0, ConditionalUserAccess, CTX_USERLIST);
- RegisterConditional("COND:USERLIST:FLAG:USE_INTERNET", 0, ConditionalFlagINetEmail, CTX_USERLIST);
- RegisterConditional("COND:USERLIST:HAVEBIO", 0, ConditionalHaveBIO, CTX_USERLIST);
- RegisterConditional("COND:USER:PIC", 1, Conditional_USER_HAS_PIC, CTX_NONE);
+ RegisterConditional("COND:USERNAME", 0, ConditionalUser, CTX_USERLIST);
+ RegisterConditional("COND:USERACCESS", 0, ConditionalUserAccess, CTX_USERLIST);
+ RegisterConditional("COND:USERLIST:FLAG:USE_INTERNET", 0, ConditionalFlagINetEmail, CTX_USERLIST);
+ RegisterConditional("COND:USERLIST:HAVEBIO", 0, ConditionalHaveBIO, CTX_USERLIST);
+ RegisterConditional("COND:USER:PIC", 1, Conditional_USER_HAS_PIC, CTX_NONE);
- RegisterIterator("USERLIST", 0, NULL, iterate_load_userlist, NULL, DeleteHash, CTX_USERLIST, CTX_NONE, IT_FLAG_DETECT_GROUPCHANGE);
+ RegisterIterator("USERLIST", 0, NULL, iterate_load_userlist, NULL, DeleteHash, CTX_USERLIST, CTX_NONE,
+ IT_FLAG_DETECT_GROUPCHANGE);
RegisterSortFunc(HKEY("user:name"),
- HKEY("userlist"),
- CompareUserListName,
- CompareUserListNameRev,
- GroupchangeUserListName,
- CTX_USERLIST);
+ HKEY("userlist"), CompareUserListName, CompareUserListNameRev, GroupchangeUserListName, CTX_USERLIST);
RegisterSortFunc(HKEY("user:accslvl"),
- HKEY("userlist"),
- CompareAccessLevel,
- CompareAccessLevelRev,
- GroupchangeAccessLevel,
- CTX_USERLIST);
+ HKEY("userlist"), CompareAccessLevel, CompareAccessLevelRev, GroupchangeAccessLevel, CTX_USERLIST);
RegisterSortFunc(HKEY("user:nlogons"),
- HKEY("userlist"),
- ComparenLogons,
- ComparenLogonsRev,
- GroupchangenLogons,
- CTX_USERLIST);
-
- RegisterSortFunc(HKEY("user:uid"),
- HKEY("userlist"),
- CompareUID,
- CompareUIDRev,
- GroupchangeUID,
- CTX_USERLIST);
+ HKEY("userlist"), ComparenLogons, ComparenLogonsRev, GroupchangenLogons, CTX_USERLIST);
+
+ RegisterSortFunc(HKEY("user:uid"), HKEY("userlist"), CompareUID, CompareUIDRev, GroupchangeUID, CTX_USERLIST);
RegisterSortFunc(HKEY("user:lastlogon"),
- HKEY("userlist"),
- CompareLastLogon,
- CompareLastLogonRev,
- GroupchangeLastLogon,
- CTX_USERLIST);
+ HKEY("userlist"), CompareLastLogon, CompareLastLogonRev, GroupchangeLastLogon, CTX_USERLIST);
RegisterSortFunc(HKEY("user:nmsgposts"),
- HKEY("userlist"),
- ComparenPosts,
- ComparenPostsRev,
- GroupchangenPosts,
- CTX_USERLIST);
+ HKEY("userlist"), ComparenPosts, ComparenPostsRev, GroupchangenPosts, CTX_USERLIST);
REGISTERTokenParamDefine(AxDeleted);
REGISTERTokenParamDefine(AxNewU);
@@ -983,4 +895,3 @@ InitModule_USEREDIT
REGISTERTokenParamDefine(AxPrefU);
REGISTERTokenParamDefine(AxAideU);
}
-
diff --git a/webcit/utils.c b/webcit/utils.c
index 4a8228146..b5812b595 100644
--- a/webcit/utils.c
+++ b/webcit/utils.c
@@ -1,3 +1,4 @@
+
/*
* de/encoding stuff. hopefully mostly to be depricated in favour of subst.c + strbuf
*/
@@ -11,8 +12,7 @@
/*
* remove escaped strings from i.e. the url string (like %20 for blanks)
*/
-long unescape_input(char *buf)
-{
+long unescape_input(char *buf) {
unsigned int a, b;
char hex[3];
long buflen;
@@ -20,12 +20,12 @@ long unescape_input(char *buf)
buflen = strlen(buf);
- while ((buflen > 0) && (isspace(buf[buflen - 1]))){
+ while ((buflen > 0) && (isspace(buf[buflen - 1]))) {
buf[buflen - 1] = 0;
- buflen --;
+ buflen--;
}
- a = 0;
+ a = 0;
while (a < buflen) {
if (buf[a] == '+')
buf[a] = ' ';
@@ -35,7 +35,7 @@ long unescape_input(char *buf)
buf[a] = '\0';
buflen = a;
}
- else {
+ else {
hex[0] = buf[a + 1];
hex[1] = buf[a + 2];
hex[2] = 0;
@@ -45,8 +45,8 @@ long unescape_input(char *buf)
len = buflen - a - 2;
if (len > 0)
memmove(&buf[a + 1], &buf[a + 3], len);
-
- buflen -=2;
+
+ buflen -= 2;
}
}
a++;
@@ -62,84 +62,81 @@ long unescape_input(char *buf)
* nbsp If nonzero, spaces are converted to non-breaking spaces.
* nolinebreaks if set, linebreaks are removed from the string.
*/
-long stresc(char *target, long tSize, char *strbuf, int nbsp, int nolinebreaks)
-{
- char *aptr, *bptr, *eptr;
-
- *target = '\0';
- aptr = strbuf;
- bptr = target;
- eptr = target + tSize - 6; /* our biggest unit to put in... */
-
-
- while ((bptr < eptr) && !IsEmptyStr(aptr) ){
- if (*aptr == '<') {
- memcpy(bptr, "<", 4);
- bptr += 4;
- }
- else if (*aptr == '>') {
- memcpy(bptr, ">", 4);
- bptr += 4;
- }
- else if (*aptr == '&') {
- memcpy(bptr, "&", 5);
- bptr += 5;
- }
- else if (*aptr == '\"') {
- memcpy(bptr, """, 6);
- bptr += 6;
- }
- else if (*aptr == '\'') {
- memcpy(bptr, "'", 5);
- bptr += 5;
- }
- else if (*aptr == LB) {
- *bptr = '<';
- bptr ++;
- }
- else if (*aptr == RB) {
- *bptr = '>';
- bptr ++;
- }
- else if (*aptr == QU) {
- *bptr ='"';
- bptr ++;
- }
- else if ((*aptr == 32) && (nbsp == 1)) {
- memcpy(bptr, " ", 6);
- bptr += 6;
- }
- else if ((*aptr == '\n') && (nolinebreaks)) {
- *bptr='\0'; /* nothing */
- }
- else if ((*aptr == '\r') && (nolinebreaks)) {
- *bptr='\0'; /* nothing */
- }
- else{
- *bptr = *aptr;
- bptr++;
- }
- aptr ++;
- }
- *bptr = '\0';
- if ((bptr = eptr - 1 ) && !IsEmptyStr(aptr) )
- return -1;
- return (bptr - target);
+long stresc(char *target, long tSize, char *strbuf, int nbsp, int nolinebreaks) {
+ char *aptr, *bptr, *eptr;
+
+ *target = '\0';
+ aptr = strbuf;
+ bptr = target;
+ eptr = target + tSize - 6; /* our biggest unit to put in... */
+
+
+ while ((bptr < eptr) && !IsEmptyStr(aptr)) {
+ if (*aptr == '<') {
+ memcpy(bptr, "<", 4);
+ bptr += 4;
+ }
+ else if (*aptr == '>') {
+ memcpy(bptr, ">", 4);
+ bptr += 4;
+ }
+ else if (*aptr == '&') {
+ memcpy(bptr, "&", 5);
+ bptr += 5;
+ }
+ else if (*aptr == '\"') {
+ memcpy(bptr, """, 6);
+ bptr += 6;
+ }
+ else if (*aptr == '\'') {
+ memcpy(bptr, "'", 5);
+ bptr += 5;
+ }
+ else if (*aptr == LB) {
+ *bptr = '<';
+ bptr++;
+ }
+ else if (*aptr == RB) {
+ *bptr = '>';
+ bptr++;
+ }
+ else if (*aptr == QU) {
+ *bptr = '"';
+ bptr++;
+ }
+ else if ((*aptr == 32) && (nbsp == 1)) {
+ memcpy(bptr, " ", 6);
+ bptr += 6;
+ }
+ else if ((*aptr == '\n') && (nolinebreaks)) {
+ *bptr = '\0'; /* nothing */
+ }
+ else if ((*aptr == '\r') && (nolinebreaks)) {
+ *bptr = '\0'; /* nothing */
+ }
+ else {
+ *bptr = *aptr;
+ bptr++;
+ }
+ aptr++;
+ }
+ *bptr = '\0';
+ if ((bptr = eptr - 1) && !IsEmptyStr(aptr))
+ return -1;
+ return (bptr - target);
}
/*
* static wrapper for ecsputs1
*/
-void escputs(const char *strbuf)
-{
+void escputs(const char *strbuf) {
StrEscAppend(WC->WBuf, NULL, strbuf, 0, 0);
}
/*
* urlescape buffer and print it to the client
*/
-void urlescputs(const char *strbuf)
-{
+void urlescputs(const char *strbuf) {
StrBufUrlescAppend(WC->WBuf, NULL, strbuf);
}
@@ -147,8 +144,7 @@ void urlescputs(const char *strbuf)
/**
* urlescape buffer and print it as header
*/
-void hurlescputs(const char *strbuf)
-{
+void hurlescputs(const char *strbuf) {
StrBufUrlescAppend(WC->HBuf, NULL, strbuf);
}
@@ -156,16 +152,16 @@ void hurlescputs(const char *strbuf)
/*
* Output a string to the client as a CDATA block
*/
-void cdataout(char *rawdata)
-{
+void cdataout(char *rawdata) {
char *ptr = rawdata;
wc_printf("", 3)) {
wc_printf("]]]]>");
- ++ptr; ++ptr; ++ptr;
+ ++ptr;
+ ++ptr;
+ ++ptr;
}
else {
wc_printf("%c", ptr[0]);
@@ -175,4 +171,3 @@ void cdataout(char *rawdata)
wc_printf("]]>");
}
-
diff --git a/webcit/utils.h b/webcit/utils.h
index 7c322492b..206df63c1 100644
--- a/webcit/utils.h
+++ b/webcit/utils.h
@@ -1,3 +1,4 @@
+
/*
* Copyright (c) 1996-2013 by the citadel.org team
*
@@ -10,8 +11,8 @@
* GNU General Public License for more details.
*/
-void StrEscPuts(const StrBuf *strbuf);
-void StrEscputs1(const StrBuf *strbuf, int nbsp, int nolinebreaks);
+void StrEscPuts(const StrBuf * strbuf);
+void StrEscputs1(const StrBuf * strbuf, int nbsp, int nolinebreaks);
void urlescputs(const char *);
void hurlescputs(const char *);
diff --git a/webcit/vcard_edit.c b/webcit/vcard_edit.c
index d1a16d383..e9fd37a37 100644
--- a/webcit/vcard_edit.c
+++ b/webcit/vcard_edit.c
@@ -1,3 +1,4 @@
+
/*
* Copyright (c) 1996-2021 by the citadel.org team
*
@@ -31,7 +32,7 @@ typedef enum _VCStrEnum {
Base64BinaryAttachment,
UnKnown,
TerminateList
-}VCStrEnum;
+} VCStrEnum;
typedef struct vcField vcField;
struct vcField {
ConstStr STR;
@@ -42,65 +43,65 @@ struct vcField {
ConstStr Name;
};
-vcField VCStr_Ns [] = {
- {{HKEY("last")}, FlatString, NULL, 0, 0, {HKEY("Last Name")}},
- {{HKEY("first")}, FlatString, NULL, 0, 0, {HKEY("First Name")}},
- {{HKEY("middle")}, FlatString, NULL, 0, 0, {HKEY("Middle Name")}},
- {{HKEY("prefix")}, FlatString, NULL, 0, 0, {HKEY("Prefix")}},
- {{HKEY("suffix")}, FlatString, NULL, 0, 0, {HKEY("Suffix")}},
- {{HKEY("")}, TerminateList, NULL, 0, 0, {HKEY("")}}
+vcField VCStr_Ns[] = {
+ { { HKEY("last")}, FlatString, NULL, 0, 0, { HKEY("Last Name")} },
+ { { HKEY("first")}, FlatString, NULL, 0, 0, { HKEY("First Name")} },
+ { { HKEY("middle")}, FlatString, NULL, 0, 0, { HKEY("Middle Name")} },
+ { { HKEY("prefix")}, FlatString, NULL, 0, 0, { HKEY("Prefix")} },
+ { { HKEY("suffix")}, FlatString, NULL, 0, 0, { HKEY("Suffix")} },
+ { { HKEY("")}, TerminateList, NULL, 0, 0, { HKEY("")} }
};
-vcField VCStr_Addrs [] = {
- {{HKEY("POBox")}, Address, NULL, 0, 0, {HKEY("PO box")}},
- {{HKEY("extadr")}, Address, NULL, 0, 0, {HKEY("Address")}},
- {{HKEY("street")}, Address, NULL, 0, 0, {HKEY("")}},
- {{HKEY("city")}, Address, NULL, 0, 0, {HKEY("City")}},
- {{HKEY("state")}, Address, NULL, 0, 0, {HKEY("State")}},
- {{HKEY("zip")}, Address, NULL, 0, 0, {HKEY("ZIP code")}},
- {{HKEY("country")}, Address, NULL, 0, 0, {HKEY("Country")}},
- {{HKEY("")}, TerminateList, NULL, 0, 0, {HKEY("")}}
+vcField VCStr_Addrs[] = {
+ { { HKEY("POBox")}, Address, NULL, 0, 0, { HKEY("PO box")} },
+ { { HKEY("extadr")}, Address, NULL, 0, 0, { HKEY("Address")} },
+ { { HKEY("street")}, Address, NULL, 0, 0, { HKEY("")} },
+ { { HKEY("city")}, Address, NULL, 0, 0, { HKEY("City")} },
+ { { HKEY("state")}, Address, NULL, 0, 0, { HKEY("State")} },
+ { { HKEY("zip")}, Address, NULL, 0, 0, { HKEY("ZIP code")} },
+ { { HKEY("country")}, Address, NULL, 0, 0, { HKEY("Country")} },
+ { { HKEY("")}, TerminateList, NULL, 0, 0, { HKEY("")} }
};
-vcField VCStrE [] = {
- {{HKEY("version")}, Number, NULL, 0, 0, {HKEY("")}},
- {{HKEY("rev")}, Number, NULL, 0, 0, {HKEY("")}},
- {{HKEY("label")}, FlatString, NULL, 0, 0, {HKEY("")}},
- {{HKEY("uid")}, FlatString, NULL, 0, 0, {HKEY("")}},
- {{HKEY("n")}, StringCluster, VCStr_Ns, 0, 0, {HKEY("")}}, /* N is name, but only if there's no FN already there */
- {{HKEY("fn")}, FlatString, NULL, 0, 0, {HKEY("")}}, /* FN (full name) is a true 'display name' field */
- {{HKEY("title")}, FlatString, NULL, 0, 0, {HKEY("Title:")}},
- {{HKEY("org")}, FlatString, NULL, 0, 0, {HKEY("Organization:")}},/* organization */
- {{HKEY("email")}, EmailAddr, NULL, 0, 0, {HKEY("E-mail:")}},
- {{HKEY("tel")}, PhoneNumber, NULL, 0, 0, {HKEY("Telephone:")}},
- {{HKEY("adr")}, StringCluster, VCStr_Addrs, 0, 0, {HKEY("Address:")}},
- {{HKEY("photo")}, Base64BinaryAttachment, NULL, 0, 0, {HKEY("Photo:")}},
- {{HKEY("tel;home")}, PhoneNumber, NULL, 0, 0, {HKEY(" (home)")}},
- {{HKEY("tel;work")}, PhoneNumber, NULL, 0, 0, {HKEY(" (work)")}},
- {{HKEY("tel;fax")}, PhoneNumber, NULL, 0, 0, {HKEY(" (fax)")}},
- {{HKEY("tel;cell")}, PhoneNumber, NULL, 0, 0, {HKEY(" (cell)")}},
- {{HKEY("email;internet")}, EmailAddr, NULL, 0, 0, {HKEY("E-mail:")}},
- {{HKEY("UNKNOWN")}, UnKnown, NULL, 0, 0, {HKEY("")}},
- {{HKEY("")}, TerminateList, NULL, 0, 0, {HKEY("")}}
+vcField VCStrE[] = {
+ { { HKEY("version")}, Number, NULL, 0, 0, { HKEY("")} },
+ { { HKEY("rev")}, Number, NULL, 0, 0, { HKEY("")} },
+ { { HKEY("label")}, FlatString, NULL, 0, 0, { HKEY("")} },
+ { { HKEY("uid")}, FlatString, NULL, 0, 0, { HKEY("")} },
+ { { HKEY("n")}, StringCluster, VCStr_Ns, 0, 0, { HKEY("")} }, /* N is name, but only if there's no FN already there */
+ { { HKEY("fn")}, FlatString, NULL, 0, 0, { HKEY("")} }, /* FN (full name) is a true 'display name' field */
+ { { HKEY("title")}, FlatString, NULL, 0, 0, { HKEY("Title:")} },
+ { { HKEY("org")}, FlatString, NULL, 0, 0, { HKEY("Organization:")} }, /* organization */
+ { { HKEY("email")}, EmailAddr, NULL, 0, 0, { HKEY("E-mail:")} },
+ { { HKEY("tel")}, PhoneNumber, NULL, 0, 0, { HKEY("Telephone:")} },
+ { { HKEY("adr")}, StringCluster, VCStr_Addrs, 0, 0, { HKEY("Address:")} },
+ { { HKEY("photo")}, Base64BinaryAttachment, NULL, 0, 0, { HKEY("Photo:")} },
+ { { HKEY("tel;home")}, PhoneNumber, NULL, 0, 0, { HKEY(" (home)")} },
+ { { HKEY("tel;work")}, PhoneNumber, NULL, 0, 0, { HKEY(" (work)")} },
+ { { HKEY("tel;fax")}, PhoneNumber, NULL, 0, 0, { HKEY(" (fax)")} },
+ { { HKEY("tel;cell")}, PhoneNumber, NULL, 0, 0, { HKEY(" (cell)")} },
+ { { HKEY("email;internet")}, EmailAddr, NULL, 0, 0, { HKEY("E-mail:")} },
+ { { HKEY("UNKNOWN")}, UnKnown, NULL, 0, 0, { HKEY("")} },
+ { { HKEY("")}, TerminateList, NULL, 0, 0, { HKEY("")} }
};
-ConstStr VCStr [] = {
- {HKEY("")},
- {HKEY("n")}, /* N is name, but only if there's no FN already there */
- {HKEY("fn")}, /* FN (full name) is a true 'display name' field */
- {HKEY("title")}, /* title */
- {HKEY("org")}, /* organization */
- {HKEY("email")},
- {HKEY("tel")},
- {HKEY("work")},
- {HKEY("home")},
- {HKEY("cell")},
- {HKEY("adr")},
- {HKEY("photo")},
- {HKEY("version")},
- {HKEY("rev")},
- {HKEY("label")},
- {HKEY("uid")}
+ConstStr VCStr[] = {
+ { HKEY("") },
+ { HKEY("n") }, /* N is name, but only if there's no FN already there */
+ { HKEY("fn") }, /* FN (full name) is a true 'display name' field */
+ { HKEY("title") }, /* title */
+ { HKEY("org") }, /* organization */
+ { HKEY("email") },
+ { HKEY("tel") },
+ { HKEY("work") },
+ { HKEY("home") },
+ { HKEY("cell") },
+ { HKEY("adr") },
+ { HKEY("photo") },
+ { HKEY("version") },
+ { HKEY("rev") },
+ { HKEY("label") },
+ { HKEY("uid") }
};
/*
@@ -115,7 +116,7 @@ typedef struct _addrbookent {
} addrbookent;
void deleteAbEnt(void *v) {
- addrbookent *vc = (addrbookent*)v;
+ addrbookent *vc = (addrbookent *) v;
DeleteHash(&vc->VC);
FreeStrBuf(&vc->name);
FreeStrBuf(&vc->msgNoStr);
@@ -124,15 +125,14 @@ void deleteAbEnt(void *v) {
HashList *DefineToToken = NULL;
HashList *VCTokenToDefine = NULL;
-HashList *vcNames = NULL; /* todo: fill with the name strings */
-vcField* vcfUnknown = NULL;
+HashList *vcNames = NULL; /* todo: fill with the name strings */
+vcField *vcfUnknown = NULL;
/******************************************************************************
* initialize vcard structure *
******************************************************************************/
-void RegisterVCardToken(vcField* vf, StrBuf *name, int inTokenCount)
-{
+void RegisterVCardToken(vcField * vf, StrBuf * name, int inTokenCount) {
if (vf->Type == UnKnown) {
vcfUnknown = vf;
}
@@ -140,20 +140,16 @@ void RegisterVCardToken(vcField* vf, StrBuf *name, int inTokenCount)
Put(DefineToToken, LKEY(vf->cval), vf, reference_free_handler);
Put(vcNames, LKEY(vf->cval), NewStrBufPlain(CKEY(vf->Name)), HFreeStrBuf);
- syslog(LOG_DEBUG, "Token: %s -> %ld, %d",
- ChrPtr(name),
- vf->cval,
- inTokenCount);
+ syslog(LOG_DEBUG, "Token: %s -> %ld, %d", ChrPtr(name), vf->cval, inTokenCount);
}
-void autoRegisterTokens(long *enumCounter, vcField* vf, StrBuf *BaseStr, int layer, long parentCVal)
-{
+void autoRegisterTokens(long *enumCounter, vcField * vf, StrBuf * BaseStr, int layer, long parentCVal) {
int i = 0;
StrBuf *subStr = NewStrBuf();
while (vf[i].STR.len > 0) {
FlushStrBuf(subStr);
- vf[i].cval = (*enumCounter) ++;
+ vf[i].cval = (*enumCounter)++;
vf[i].parentCVal = parentCVal;
StrBufAppendBuf(subStr, BaseStr, 0);
if (StrLength(subStr) > 0) {
@@ -167,10 +163,10 @@ void autoRegisterTokens(long *enumCounter, vcField* vf, StrBuf *BaseStr, int lay
case FlatString:
break;
case StringCluster:
- {
- autoRegisterTokens(enumCounter, vf[i].Sub, subStr, 1, vf[i].cval);
- }
- break;
+ {
+ autoRegisterTokens(enumCounter, vf[i].Sub, subStr, 1, vf[i].cval);
+ }
+ break;
case PhoneNumber:
break;
case EmailAddr:
@@ -200,8 +196,7 @@ void autoRegisterTokens(long *enumCounter, vcField* vf, StrBuf *BaseStr, int lay
* VCard template functions *
******************************************************************************/
-int preeval_vcard_item(WCTemplateToken *Token)
-{
+int preeval_vcard_item(WCTemplateToken * Token) {
WCTemplputParams TPP;
WCTemplputParams *TP;
int searchFieldNo;
@@ -218,21 +213,19 @@ int preeval_vcard_item(WCTemplateToken *Token)
return 1;
}
-void tmpl_vcard_item(StrBuf *Target, WCTemplputParams *TP)
-{
+void tmpl_vcard_item(StrBuf * Target, WCTemplputParams * TP) {
void *vItem;
long searchFieldNo = GetTemplateTokenNumber(Target, TP, 0, 0);
- addrbookent *ab = (addrbookent*) CTX(CTX_VCARD);
+ addrbookent *ab = (addrbookent *) CTX(CTX_VCARD);
if (GetHash(ab->VC, LKEY(searchFieldNo), &vItem) && (vItem != NULL)) {
- StrBufAppendTemplate(Target, TP, (StrBuf*) vItem, 1);
+ StrBufAppendTemplate(Target, TP, (StrBuf *) vItem, 1);
}
}
-void tmpl_vcard_context_item(StrBuf *Target, WCTemplputParams *TP)
-{
+void tmpl_vcard_context_item(StrBuf * Target, WCTemplputParams * TP) {
void *vItem;
- vcField *t = (vcField*) CTX(CTX_VCARD_TYPE);
- addrbookent *ab = (addrbookent*) CTX(CTX_VCARD);
+ vcField *t = (vcField *) CTX(CTX_VCARD_TYPE);
+ addrbookent *ab = (addrbookent *) CTX(CTX_VCARD);
if (t == NULL) {
LogTemplateError(NULL, "VCard item", ERR_NAME, TP, "Missing context");
@@ -240,15 +233,13 @@ void tmpl_vcard_context_item(StrBuf *Target, WCTemplputParams *TP)
}
if (GetHash(ab->VC, LKEY(t->cval), &vItem) && (vItem != NULL)) {
- StrBufAppendTemplate(Target, TP, (StrBuf*) vItem, 0);
+ StrBufAppendTemplate(Target, TP, (StrBuf *) vItem, 0);
}
else {
- LogTemplateError(NULL, "VCard item", ERR_NAME, TP,
- "Doesn't have that key - did you miss to filter in advance?");
+ LogTemplateError(NULL, "VCard item", ERR_NAME, TP, "Doesn't have that key - did you miss to filter in advance?");
}
}
-int preeval_vcard_name_str(WCTemplateToken *Token)
-{
+int preeval_vcard_name_str(WCTemplateToken * Token) {
WCTemplputParams TPP;
WCTemplputParams *TP;
int searchFieldNo;
@@ -259,71 +250,63 @@ int preeval_vcard_name_str(WCTemplateToken *Token)
TP->Tokens = Token;
searchFieldNo = GetTemplateTokenNumber(Target, TP, 0, 0);
if (searchFieldNo >= VCEnumCounter) {
- LogTemplateError(NULL, "VCardName", ERR_PARM1, TP,
- "Invalid define");
+ LogTemplateError(NULL, "VCardName", ERR_PARM1, TP, "Invalid define");
return 0;
}
return 1;
}
-void tmpl_vcard_name_str(StrBuf *Target, WCTemplputParams *TP)
-{
+void tmpl_vcard_name_str(StrBuf * Target, WCTemplputParams * TP) {
void *vItem;
long searchFieldNo = GetTemplateTokenNumber(Target, TP, 0, 0);
/* todo: get descriptive string for this vcard type */
if (GetHash(vcNames, LKEY(searchFieldNo), &vItem) && (vItem != NULL)) {
- StrBufAppendTemplate(Target, TP, (StrBuf*) vItem, 1);
+ StrBufAppendTemplate(Target, TP, (StrBuf *) vItem, 1);
}
else {
- LogTemplateError(NULL, "VCard item type", ERR_NAME, TP,
- "No i18n string for this.");
+ LogTemplateError(NULL, "VCard item type", ERR_NAME, TP, "No i18n string for this.");
return;
}
}
-void tmpl_vcard_msgno(StrBuf *Target, WCTemplputParams *TP)
-{
- addrbookent *ab = (addrbookent*) CTX(CTX_VCARD);
+void tmpl_vcard_msgno(StrBuf * Target, WCTemplputParams * TP) {
+ addrbookent *ab = (addrbookent *) CTX(CTX_VCARD);
if (ab->msgNoStr == NULL) {
ab->msgNoStr = NewStrBufPlain(NULL, 64);
}
StrBufPrintf(ab->msgNoStr, "%ld", ab->ab_msgnum);
StrBufAppendTemplate(Target, TP, ab->msgNoStr, 0);
}
-void tmpl_vcard_context_name_str(StrBuf *Target, WCTemplputParams *TP)
-{
+void tmpl_vcard_context_name_str(StrBuf * Target, WCTemplputParams * TP) {
void *vItem;
- vcField *t = (vcField*) CTX(CTX_VCARD_TYPE);
+ vcField *t = (vcField *) CTX(CTX_VCARD_TYPE);
if (t == NULL) {
- LogTemplateError(NULL, "VCard item type", ERR_NAME, TP,
- "Missing context");
+ LogTemplateError(NULL, "VCard item type", ERR_NAME, TP, "Missing context");
return;
}
-
+
if (GetHash(vcNames, LKEY(t->cval), &vItem) && (vItem != NULL)) {
- StrBufAppendTemplate(Target, TP, (StrBuf*) vItem, 1);
+ StrBufAppendTemplate(Target, TP, (StrBuf *) vItem, 1);
}
else {
- LogTemplateError(NULL, "VCard item type", ERR_NAME, TP,
- "No i18n string for this.");
+ LogTemplateError(NULL, "VCard item type", ERR_NAME, TP, "No i18n string for this.");
return;
}
}
-int filter_VC_ByType(const char* key, long len, void *Context, StrBuf *Target, WCTemplputParams *TP)
-{
+int filter_VC_ByType(const char *key, long len, void *Context, StrBuf * Target, WCTemplputParams * TP) {
long searchType;
long type = 0;
void *v;
- vcField *vf = (vcField*) Context;
+ vcField *vf = (vcField *) Context;
int rc = 0;
memcpy(&type, key, sizeof(long));
searchType = GetTemplateTokenNumber(Target, TP, IT_ADDT_PARAM(0), 0);
-
+
if (vf->Type == searchType) {
- addrbookent *ab = (addrbookent*) CTX(CTX_VCARD);
+ addrbookent *ab = (addrbookent *) CTX(CTX_VCARD);
if (GetHash(ab->VC, LKEY(vf->cval), &v) && v != NULL) {
return 1;
}
@@ -331,27 +314,24 @@ int filter_VC_ByType(const char* key, long len, void *Context, StrBuf *Target, W
return rc;
}
-HashList *getContextVcard(StrBuf *Target, WCTemplputParams *TP)
-{
- vcField *vf = (vcField*) CTX(CTX_VCARD_TYPE);
- addrbookent *ab = (addrbookent*) CTX(CTX_VCARD);
+HashList *getContextVcard(StrBuf * Target, WCTemplputParams * TP) {
+ vcField *vf = (vcField *) CTX(CTX_VCARD_TYPE);
+ addrbookent *ab = (addrbookent *) CTX(CTX_VCARD);
if ((vf == NULL) || (ab == NULL)) {
- LogTemplateError(NULL, "VCard item type", ERR_NAME, TP,
- "Need VCard and Vcard type in context");
-
+ LogTemplateError(NULL, "VCard item type", ERR_NAME, TP, "Need VCard and Vcard type in context");
+
return NULL;
}
return ab->VC;
}
-int filter_VC_ByContextType(const char* key, long len, void *Context, StrBuf *Target, WCTemplputParams *TP)
-{
+int filter_VC_ByContextType(const char *key, long len, void *Context, StrBuf * Target, WCTemplputParams * TP) {
long searchType;
- vcField *vf = (vcField*) CTX(CTX_VCARD_TYPE);
+ vcField *vf = (vcField *) CTX(CTX_VCARD_TYPE);
memcpy(&searchType, key, sizeof(long));
-
+
if (vf->cval == searchType) {
return 1;
}
@@ -360,25 +340,20 @@ int filter_VC_ByContextType(const char* key, long len, void *Context, StrBuf *Ta
}
}
-int conditional_VC_Havetype(StrBuf *Target, WCTemplputParams *TP)
-{
- addrbookent *ab = (addrbookent*) CTX(CTX_VCARD);
+int conditional_VC_Havetype(StrBuf * Target, WCTemplputParams * TP) {
+ addrbookent *ab = (addrbookent *) CTX(CTX_VCARD);
long HaveFieldType = GetTemplateTokenNumber(Target, TP, 2, 0);
- int rc = 0;
+ int rc = 0;
void *vVCitem;
const char *Key;
long len;
HashPos *it = GetNewHashPos(ab->VC, 0);
- while (GetNextHashPos(ab->VC, it, &len, &Key, &vVCitem) &&
- (vVCitem != NULL))
- {
+ while (GetNextHashPos(ab->VC, it, &len, &Key, &vVCitem) && (vVCitem != NULL)) {
void *vvcField;
long type = 0;
memcpy(&type, Key, sizeof(long));
- if (GetHash(DefineToToken, LKEY(type), &vvcField) &&
- (vvcField != NULL))
- {
- vcField *t = (vcField*) vvcField;
+ if (GetHash(DefineToToken, LKEY(type), &vvcField) && (vvcField != NULL)) {
+ vcField *t = (vcField *) vvcField;
if (t && t->Type == HaveFieldType) {
rc = 1;
break;
@@ -393,9 +368,8 @@ int conditional_VC_Havetype(StrBuf *Target, WCTemplputParams *TP)
/* Returns 1 to suppress the "email" fields in the vCard editor, if we're editing a user's contact info.
* Returns 0 to present those fields, if we're editing a vCard in an address book.
*/
-int conditional_VC_SuppressEmailFields(StrBuf *Target, WCTemplputParams *TP)
-{
- return(atoi(bstr("suppress_email")));
+int conditional_VC_SuppressEmailFields(StrBuf * Target, WCTemplputParams * TP) {
+ return (atoi(bstr("suppress_email")));
}
@@ -403,20 +377,18 @@ int conditional_VC_SuppressEmailFields(StrBuf *Target, WCTemplputParams *TP)
* parse one VCard *
******************************************************************************/
-void PutVcardItem(HashList *thisVC, vcField *thisField, StrBuf *ThisFieldStr, int is_qp, StrBuf *Swap)
-{
+void PutVcardItem(HashList * thisVC, vcField * thisField, StrBuf * ThisFieldStr, int is_qp, StrBuf * Swap) {
/* if we have some untagged QP, detect it here. */
- if (is_qp || (strstr(ChrPtr(ThisFieldStr), "=?")!=NULL)){
+ if (is_qp || (strstr(ChrPtr(ThisFieldStr), "=?") != NULL)) {
FlushStrBuf(Swap);
- StrBuf_RFC822_to_Utf8(Swap, ThisFieldStr, NULL, NULL); /* default charset, current charset */
+ StrBuf_RFC822_to_Utf8(Swap, ThisFieldStr, NULL, NULL); /* default charset, current charset */
SwapBuffers(Swap, ThisFieldStr);
FlushStrBuf(Swap);
}
Put(thisVC, LKEY(thisField->cval), ThisFieldStr, HFreeStrBuf);
}
-void parse_vcard(StrBuf *Target, struct vCard *v, HashList *VC, wc_mime_attachment *Mime)
-{
+void parse_vcard(StrBuf * Target, struct vCard *v, HashList * VC, wc_mime_attachment * Mime) {
StrBuf *Swap = NULL;
int i, j, k;
char buf[SIZ];
@@ -428,20 +400,20 @@ void parse_vcard(StrBuf *Target, struct vCard *v, HashList *VC, wc_mime_attachme
StrBuf *thisVCToken;
void *vField = NULL;
- Swap = NewStrBuf ();
+ Swap = NewStrBuf();
thisname = NewStrBuf();
thisVCToken = NewStrBufPlain(NULL, 63);
- for (i=0; i<(v->numprops); ++i) {
+ for (i = 0; i < (v->numprops); ++i) {
FlushStrBuf(thisVCToken);
is_qp = 0;
is_b64 = 0;
// syslog(LOG_DEBUG, "i: %d oneprop: %s - value: %s", i, v->prop[i].name, v->prop[i].value);
StrBufPlain(thisname, v->prop[i].name, -1);
StrBufLowerCase(thisname);
-
+
extract_token(firsttoken, ChrPtr(thisname), 0, ';', sizeof firsttoken);
ntokens = num_tokens(ChrPtr(thisname), ';');
- for (j=0, k=0; j < ntokens && k < 10; ++j) {
+ for (j = 0, k = 0; j < ntokens && k < 10; ++j) {
len = extract_token(buf, ChrPtr(thisname), j, ';', sizeof buf);
if (!strcasecmp(buf, "encoding=quoted-printable")) {
is_qp = 1;
@@ -457,28 +429,26 @@ void parse_vcard(StrBuf *Target, struct vCard *v, HashList *VC, wc_mime_attachme
}
}
- vField = NULL;
- if ((StrLength(thisVCToken) > 0) &&
- GetHash(VCTokenToDefine, SKEY(thisVCToken), &vField) &&
- (vField != NULL)) {
- vcField *thisField = (vcField *)vField;
+ vField = NULL;
+ if ((StrLength(thisVCToken) > 0) && GetHash(VCTokenToDefine, SKEY(thisVCToken), &vField) && (vField != NULL)) {
+ vcField *thisField = (vcField *) vField;
StrBuf *ThisFieldStr = NULL;
// syslog(LOG_DEBUG, "got this token: %s, found: %s", ChrPtr(thisVCToken), thisField->STR.Key);
switch (thisField->Type) {
- case StringCluster: {
- int j = 0;
- const char *Pos = NULL;
- StrBuf *thisArray = NewStrBufPlain(v->prop[i].value, -1);
- StrBuf *Buf = NewStrBufPlain(NULL, StrLength(thisArray));
- while (thisField->Sub[j].STR.len > 0) {
- StrBufExtract_NextToken(Buf, thisArray, &Pos, ';');
- ThisFieldStr = NewStrBufDup(Buf);
- PutVcardItem(VC, &thisField->Sub[j], ThisFieldStr, is_qp, Swap);
- j++;
+ case StringCluster:{
+ int j = 0;
+ const char *Pos = NULL;
+ StrBuf *thisArray = NewStrBufPlain(v->prop[i].value, -1);
+ StrBuf *Buf = NewStrBufPlain(NULL, StrLength(thisArray));
+ while (thisField->Sub[j].STR.len > 0) {
+ StrBufExtract_NextToken(Buf, thisArray, &Pos, ';');
+ ThisFieldStr = NewStrBufDup(Buf);
+ PutVcardItem(VC, &thisField->Sub[j], ThisFieldStr, is_qp, Swap);
+ j++;
+ }
+ FreeStrBuf(&thisArray);
+ FreeStrBuf(&Buf);
}
- FreeStrBuf(&thisArray);
- FreeStrBuf(&Buf);
- }
break;
case Address:
case FlatString:
@@ -508,7 +478,7 @@ void parse_vcard(StrBuf *Target, struct vCard *v, HashList *VC, wc_mime_attachme
void *pv = NULL;
StrBuf *oldVal;
GetHash(VC, IKEY(vcfUnknown->cval), &pv);
- oldVal = (StrBuf*) pv;
+ oldVal = (StrBuf *) pv;
if (oldVal == NULL) {
oldVal = NewStrBuf();
Put(VC, IKEY(vcfUnknown->cval), oldVal, HFreeStrBuf);
@@ -528,8 +498,7 @@ void parse_vcard(StrBuf *Target, struct vCard *v, HashList *VC, wc_mime_attachme
FreeStrBuf(&thisVCToken);
}
-HashList *CtxGetVcardList(StrBuf *Target, WCTemplputParams *TP)
-{
+HashList *CtxGetVcardList(StrBuf * Target, WCTemplputParams * TP) {
HashList *pb = CTX(CTX_VCARD_LIST);
return pb;
}
@@ -538,8 +507,7 @@ HashList *CtxGetVcardList(StrBuf *Target, WCTemplputParams *TP)
* Extract an embedded photo from a vCard for display on the client *
******************************************************************************/
-void display_vcard_photo_img(void)
-{
+void display_vcard_photo_img(void) {
long msgnum = 0L;
StrBuf *vcard;
struct vCard *v;
@@ -547,17 +515,17 @@ void display_vcard_photo_img(void)
const char *contentType;
msgnum = StrBufExtract_long(WC->Hdr->HR.ReqLine, 0, '/');
-
- vcard = load_mimepart(msgnum,"1");
+
+ vcard = load_mimepart(msgnum, "1");
v = VCardLoad(vcard);
-
- photosrc = vcard_get_prop(v, "PHOTO", 1,0,0);
+
+ photosrc = vcard_get_prop(v, "PHOTO", 1, 0, 0);
FlushStrBuf(WC->WBuf);
StrBufAppendBufPlain(WC->WBuf, photosrc, -1, 0);
if (StrBufDecodeBase64(WC->WBuf) <= 0) {
FlushStrBuf(WC->WBuf);
-
- hprintf("HTTP/1.1 500 %s\n","Unable to get photo");
+
+ hprintf("HTTP/1.1 500 %s\n", "Unable to get photo");
output_headers(0, 0, 0, 0, 0, 0);
hprintf("Content-Type: text/plain\r\n");
begin_burst();
@@ -571,9 +539,8 @@ void display_vcard_photo_img(void)
free(photosrc);
}
-wc_mime_attachment *load_vcard(message_summary *Msg)
-{
- HashPos *it;
+wc_mime_attachment *load_vcard(message_summary * Msg) {
+ HashPos *it;
StrBuf *FoundCharset = NewStrBuf();
StrBuf *Error;
void *vMime;
@@ -582,7 +549,7 @@ wc_mime_attachment *load_vcard(message_summary *Msg)
wc_mime_attachment *Mime;
wc_mime_attachment *VCMime = NULL;
- Msg->MsgBody = (wc_mime_attachment*) malloc(sizeof(wc_mime_attachment));
+ Msg->MsgBody = (wc_mime_attachment *) malloc(sizeof(wc_mime_attachment));
memset(Msg->MsgBody, 0, sizeof(wc_mime_attachment));
Msg->MsgBody->msgnum = Msg->msgnum;
@@ -591,15 +558,10 @@ wc_mime_attachment *load_vcard(message_summary *Msg)
FreeStrBuf(&FoundCharset);
/* look up the vcard... */
it = GetNewHashPos(Msg->AllAttach, 0);
- while (GetNextHashPos(Msg->AllAttach, it, &len, &Key, &vMime) &&
- (vMime != NULL))
- {
- Mime = (wc_mime_attachment*) vMime;
+ while (GetNextHashPos(Msg->AllAttach, it, &len, &Key, &vMime) && (vMime != NULL)) {
+ Mime = (wc_mime_attachment *) vMime;
if ((strcmp(ChrPtr(Mime->ContentType),
- "text/x-vcard") == 0) ||
- (strcmp(ChrPtr(Mime->ContentType),
- "text/vcard") == 0))
- {
+ "text/x-vcard") == 0) || (strcmp(ChrPtr(Mime->ContentType), "text/vcard") == 0)) {
VCMime = Mime;
break;
}
@@ -619,11 +581,8 @@ wc_mime_attachment *load_vcard(message_summary *Msg)
* and MIME part number to fetch. Or, specify -1 for the message number
* to start with a blank card.
*/
-void do_edit_vcard(long msgnum, char *partnum,
- message_summary *VCMsg,
- wc_mime_attachment *VCAtt,
- const char *return_to,
- const char *force_room) {
+void do_edit_vcard(long msgnum, char *partnum,
+ message_summary * VCMsg, wc_mime_attachment * VCAtt, const char *return_to, const char *force_room) {
WCTemplputParams SubTP;
message_summary *Msg = NULL;
wc_mime_attachment *VCMime = NULL;
@@ -638,9 +597,7 @@ void do_edit_vcard(long msgnum, char *partnum,
safestrncpy(whatuser, "", sizeof whatuser);
- if ((msgnum >= 0) ||
- ((VCMsg != NULL) && (VCAtt != NULL)))
- {
+ if ((msgnum >= 0) || ((VCMsg != NULL) && (VCAtt != NULL))) {
if ((VCMsg == NULL) && (VCAtt == NULL)) {
Msg = (message_summary *) malloc(sizeof(message_summary));
@@ -648,12 +605,12 @@ void do_edit_vcard(long msgnum, char *partnum,
Msg->msgnum = msgnum;
VCMime = load_vcard(Msg);
if (VCMime == NULL) {
- convenience_page("770000", _("Error"), "");/*TODO: important message*/
+ convenience_page("770000", _("Error"), ""); /*TODO: important message */
DestroyMessageSummary(Msg);
return;
DeleteHash(&ab.VC);
}
-
+
v = VCardLoad(VCMime->Data);
}
else {
@@ -661,12 +618,12 @@ void do_edit_vcard(long msgnum, char *partnum,
}
parse_vcard(WC->WBuf, v, ab.VC, NULL);
-
-
+
+
vcard_free(v);
}
- memset(&SubTP, 0, sizeof(WCTemplputParams));
+ memset(&SubTP, 0, sizeof(WCTemplputParams));
{
WCTemplputParams *TP = NULL;
WCTemplputParams SubTP;
@@ -706,7 +663,7 @@ void submit_vcard(void) {
char *serialized_vcard;
StrBuf *Buf;
const StrBuf *ForceRoom;
- HashList* postVcard;
+ HashList *postVcard;
HashPos *it, *itSub;
const char *Key;
long len;
@@ -715,7 +672,7 @@ void submit_vcard(void) {
const StrBuf *s;
const char *Pos = NULL;
- if (!havebstr("ok_button")) {
+ if (!havebstr("ok_button")) {
readloop(readnew, eUseDefault);
return;
}
@@ -749,21 +706,19 @@ void submit_vcard(void) {
if (postVcard == NULL) {
AppendImportantMessage(_("An error has occurred."), -1);
edit_vcard();
- return;/*/// more details*/
+ return; /*/// more details */
}
-
+
Buf = NewStrBuf();
serv_write(HKEY("ENT0 1|||4\n"));
- if (!StrBuf_ServGetln(Buf) && (GetServerStatus(Buf, NULL) != 4))
- {
+ if (!StrBuf_ServGetln(Buf) && (GetServerStatus(Buf, NULL) != 4)) {
edit_vcard();
return;
}
-
+
/* Make a vCard structure out of the data supplied in the form */
- StrBufPrintf(Buf, "begin:vcard\r\n%s\r\nend:vcard\r\n",
- bstr("extrafields")
- );
+ StrBufPrintf(Buf, "begin:vcard\r\n%s\r\nend:vcard\r\n", bstr("extrafields")
+ );
v = VCardLoad(Buf); /* Start with the extra fields */
if (v == NULL) {
AppendImportantMessage(_("An error has occurred."), -1);
@@ -774,21 +729,17 @@ void submit_vcard(void) {
SubStr = NewStrBuf();
it = GetNewHashPos(DefineToToken, 0);
- while (GetNextHashPos(DefineToToken, it, &len, &Key, &pv) &&
- (pv != NULL))
- {
+ while (GetNextHashPos(DefineToToken, it, &len, &Key, &pv) && (pv != NULL)) {
char buf[32];
long blen;
- vcField *t = (vcField*) pv;
+ vcField *t = (vcField *) pv;
- if (t->Sub != NULL){
+ if (t->Sub != NULL) {
vcField *Sub;
FlushStrBuf(SubStr);
itSub = GetNewHashPos(DefineToToken, 0);
- while (GetNextHashPos(DefineToToken, itSub, &len, &Key, &pv) &&
- (pv != NULL))
- {
- Sub = (vcField*) pv;
+ while (GetNextHashPos(DefineToToken, itSub, &len, &Key, &pv) && (pv != NULL)) {
+ Sub = (vcField *) pv;
if (Sub->parentCVal == t->cval) {
if (StrLength(SubStr) > 0)
StrBufAppendBufPlain(SubStr, HKEY(";"), 0);
@@ -797,7 +748,7 @@ void submit_vcard(void) {
blen = snprintf(buf, sizeof(buf), "%ld", Sub->cval);
s = SSubBstr(postVcard, buf, blen);
-
+
if ((s != NULL) && (StrLength(s) > 0)) {
/// todo: utf8 qp
StrBufAppendBuf(SubStr, s, 0);
@@ -812,7 +763,7 @@ void submit_vcard(void) {
else if (t->parentCVal == 0) {
blen = snprintf(buf, sizeof(buf), "%ld", t->cval);
s = SSubBstr(postVcard, buf, blen);
-
+
if ((s != NULL) && (StrLength(s) > 0)) {
vcard_add_prop(v, t->STR.Key, ChrPtr(s));
}
@@ -823,7 +774,7 @@ void submit_vcard(void) {
s = sbstr("other_inetemail");
if (StrLength(s) > 0) {
FlushStrBuf(SubStr);
- while (StrBufSipLine(SubStr, s, &Pos), ((Pos!=StrBufNOTNULL) && (Pos!=NULL)) ) {
+ while (StrBufSipLine(SubStr, s, &Pos), ((Pos != StrBufNOTNULL) && (Pos != NULL))) {
if (StrLength(SubStr) > 0) {
vcard_add_prop(v, "email;internet", ChrPtr(SubStr));
}
@@ -874,19 +825,13 @@ typedef struct _vcardview_struct {
} vcardview_struct;
-int vcard_GetParamsGetServerCall(SharedMessageStatus *Stat,
- void **ViewSpecific,
- long oper,
- char *cmd,
- long len,
- char *filter,
- long flen)
-{
+int vcard_GetParamsGetServerCall(SharedMessageStatus * Stat,
+ void **ViewSpecific, long oper, char *cmd, long len, char *filter, long flen) {
vcardview_struct *VS;
- VS = (vcardview_struct*) malloc (sizeof(vcardview_struct));
+ VS = (vcardview_struct *) malloc(sizeof(vcardview_struct));
memset(VS, 0, sizeof(vcardview_struct));
- *ViewSpecific = (void*)VS;
+ *ViewSpecific = (void *) VS;
VS->is_singlecard = ibstr("is_singlecard");
if (VS->is_singlecard != 1) {
@@ -902,20 +847,15 @@ int vcard_GetParamsGetServerCall(SharedMessageStatus *Stat,
return 200;
}
-int vcard_LoadMsgFromServer(SharedMessageStatus *Stat,
- void **ViewSpecific,
- message_summary* Msg,
- int is_new,
- int i)
-{
+int vcard_LoadMsgFromServer(SharedMessageStatus * Stat, void **ViewSpecific, message_summary * Msg, int is_new, int i) {
WCTemplputParams *TP = NULL;
WCTemplputParams SubTP;
vcardview_struct *VS;
wc_mime_attachment *VCMime = NULL;
struct vCard *v;
- addrbookent* abEntry;
+ addrbookent *abEntry;
- VS = (vcardview_struct*) *ViewSpecific;
+ VS = (vcardview_struct *) * ViewSpecific;
VCMime = load_vcard(Msg);
if (VCMime == NULL)
@@ -923,9 +863,10 @@ int vcard_LoadMsgFromServer(SharedMessageStatus *Stat,
v = VCardLoad(VCMime->Data);
- if (v == NULL) return 0;
+ if (v == NULL)
+ return 0;
- abEntry = (addrbookent*) malloc(sizeof(addrbookent));
+ abEntry = (addrbookent *) malloc(sizeof(addrbookent));
memset(abEntry, 0, sizeof(addrbookent));
abEntry->name = NewStrBuf();
abEntry->VC = NewHash(0, lFlathash);
@@ -933,7 +874,7 @@ int vcard_LoadMsgFromServer(SharedMessageStatus *Stat,
parse_vcard(WC->WBuf, v, abEntry->VC, VCMime);
- memset(&SubTP, 0, sizeof(WCTemplputParams));
+ memset(&SubTP, 0, sizeof(WCTemplputParams));
StackContext(TP, &SubTP, abEntry, CTX_VCARD, 0, NULL);
// No, don't display the name, it just shits all over the screen
@@ -948,7 +889,7 @@ int vcard_LoadMsgFromServer(SharedMessageStatus *Stat,
syslog(LOG_DEBUG, "abEntry->name : %s", ChrPtr(abEntry->name));
vcard_free(v);
-
+
Put(VS->addrbook, SKEY(abEntry->name), abEntry, deleteAbEnt);
return 0;
}
@@ -961,7 +902,7 @@ int vcard_LoadMsgFromServer(SharedMessageStatus *Stat,
* num_ab the number of the addressbook
*/
static int NAMESPERPAGE = 60;
-void do_addrbook_view(vcardview_struct* VS) {
+void do_addrbook_view(vcardview_struct * VS) {
long i = 0;
int num_pages = 0;
int tabfirst = 0;
@@ -973,8 +914,8 @@ void do_addrbook_view(vcardview_struct* VS) {
WCTemplputParams *TP = NULL;
WCTemplputParams SubTP;
- memset(&SubTP, 0, sizeof(WCTemplputParams));
-
+ memset(&SubTP, 0, sizeof(WCTemplputParams));
+
if (num_ab == 0) {
do_template("vcard_list_empty");
return;
@@ -986,13 +927,13 @@ void do_addrbook_view(vcardview_struct* VS) {
num_pages = (GetCount(VS->addrbook) / NAMESPERPAGE) + 1;
- tablabels = malloc(num_pages * sizeof (StrBuf *));
+ tablabels = malloc(num_pages * sizeof(StrBuf *));
if (tablabels == NULL) {
return;
}
headlines = NewHash(0, lFlathash);
- for (i=0; i (num_ab - 1)) tablast = (num_ab - 1);
+ if (tablast > (num_ab - 1))
+ tablast = (num_ab - 1);
headline = NewStrBufPlain(NULL, StrLength(v1) + StrLength(v2) + 10);
if (GetHashAt(VS->addrbook, tabfirst, &hklen1, &c1, &v1)) {
- a1 = (addrbookent*) v1;
+ a1 = (addrbookent *) v1;
StrBufAppendBuf(headline, a1->name, 0);
StrBuf_Utf8StrCut(headline, 3);
if (GetHashAt(VS->addrbook, tablast, &hklen2, &c2, &v2)) {
- a2 = (addrbookent*) v2;
+ a2 = (addrbookent *) v2;
StrBufAppendBufPlain(headline, HKEY(" - "), 0);
StrBufAppendBuf(headline, a2->name, 0);
StrBuf_Utf8StrCut(headline, 9);
@@ -1027,17 +969,16 @@ void do_addrbook_view(vcardview_struct* VS) {
UnStackContext(&SubTP);
DeleteHash(&headlines);
free(tablabels);
- StrBufAppendBufPlain(WC->WBuf, HKEY(""), 0);/* closes: id=global */
+ StrBufAppendBufPlain(WC->WBuf, HKEY(""), 0); /* closes: id=global */
}
-int vcard_RenderView_or_Tail(SharedMessageStatus *Stat, void **ViewSpecific, long oper)
-{
+int vcard_RenderView_or_Tail(SharedMessageStatus * Stat, void **ViewSpecific, long oper) {
const StrBuf *Mime;
vcardview_struct *VS;
- VS = (vcardview_struct*) *ViewSpecific;
+ VS = (vcardview_struct *) * ViewSpecific;
if (VS->is_singlecard) {
read_message(WC->WBuf, HKEY("view_message"), lbstr("startmsg"), NULL, &Mime, NULL);
}
@@ -1047,24 +988,22 @@ int vcard_RenderView_or_Tail(SharedMessageStatus *Stat, void **ViewSpecific, lon
return 0;
}
-int vcard_Cleanup(void **ViewSpecific)
-{
+int vcard_Cleanup(void **ViewSpecific) {
vcardview_struct *VS;
- VS = (vcardview_struct*) *ViewSpecific;
+ VS = (vcardview_struct *) * ViewSpecific;
wDumpContent(1);
if ((VS != NULL) && (VS->addrbook != NULL)) {
DeleteHash(&VS->addrbook);
}
- if (VS != NULL) {
+ if (VS != NULL) {
free(VS);
}
return 0;
}
-void render_MIME_VCard(StrBuf *Target, WCTemplputParams *TP, StrBuf *FoundCharset)
-{
+void render_MIME_VCard(StrBuf * Target, WCTemplputParams * TP, StrBuf * FoundCharset) {
wc_mime_attachment *Mime = (wc_mime_attachment *) CTX(CTX_MIME_ATACH);
if (StrLength(Mime->Data) == 0) {
MimeLoadData(Mime);
@@ -1074,14 +1013,14 @@ void render_MIME_VCard(StrBuf *Target, WCTemplputParams *TP, StrBuf *FoundCharse
StrBuf *Buf;
Buf = NewStrBuf();
+
/** If it's my vCard I can edit it */
- if ( (!strcasecmp(ChrPtr(WC->CurRoom.name), USERCONFIGROOM))
- || ((StrLength(WC->CurRoom.name) > 11) &&
- (!strcasecmp(&(ChrPtr(WC->CurRoom.name)[11]), USERCONFIGROOM)))
- || (WC->CurRoom.view == VIEW_ADDRESSBOOK)
- ) {
+ if ((!strcasecmp(ChrPtr(WC->CurRoom.name), USERCONFIGROOM))
+ || ((StrLength(WC->CurRoom.name) > 11) && (!strcasecmp(&(ChrPtr(WC->CurRoom.name)[11]), USERCONFIGROOM)))
+ || (WC->CurRoom.view == VIEW_ADDRESSBOOK)
+ ) {
StrBufAppendPrintf(Buf, "",
- Mime->msgnum, ChrPtr(Mime->PartNum));
+ Mime->msgnum, ChrPtr(Mime->PartNum));
StrBufAppendPrintf(Buf, "[%s] ", _("edit"));
}
@@ -1100,7 +1039,7 @@ void render_MIME_VCard(StrBuf *Target, WCTemplputParams *TP, StrBuf *FoundCharse
parse_vcard(Target, v, ab.VC, Mime);
- memset(&SubTP, 0, sizeof(WCTemplputParams));
+ memset(&SubTP, 0, sizeof(WCTemplputParams));
StackContext(TP, &SubTP, &ab, CTX_VCARD, 0, NULL);
DoTemplate(HKEY("vcard_msg_display"), Target, &SubTP);
@@ -1118,28 +1057,19 @@ void render_MIME_VCard(StrBuf *Target, WCTemplputParams *TP, StrBuf *FoundCharse
}
-void
-ServerStartModule_VCARD
-(void)
-{
+void ServerStartModule_VCARD(void) {
}
-void
-ServerShutdownModule_VCARD
-(void)
-{
+void ServerShutdownModule_VCARD(void) {
DeleteHash(&DefineToToken);
DeleteHash(&vcNames);
DeleteHash(&VCTokenToDefine);
}
-void
-InitModule_VCARD
-(void)
-{
- StrBuf *Prefix = NewStrBufPlain(HKEY("VC:"));
- DefineToToken = NewHash(1, lFlathash);
- vcNames = NewHash(1, lFlathash);
+void InitModule_VCARD(void) {
+ StrBuf *Prefix = NewStrBufPlain(HKEY("VC:"));
+ DefineToToken = NewHash(1, lFlathash);
+ vcNames = NewHash(1, lFlathash);
VCTokenToDefine = NewHash(1, NULL);
autoRegisterTokens(&VCEnumCounter, VCStrE, Prefix, 0, 0);
FreeStrBuf(&Prefix);
@@ -1151,16 +1081,9 @@ InitModule_VCARD
RegisterCTX(CTX_VCARD_LIST);
RegisterCTX(CTX_VCARD_TYPE);
- RegisterReadLoopHandlerset(
- VIEW_ADDRESSBOOK,
- vcard_GetParamsGetServerCall,
- NULL,
- NULL,
- NULL,
- vcard_LoadMsgFromServer,
- vcard_RenderView_or_Tail,
- vcard_Cleanup,
- NULL);
+ RegisterReadLoopHandlerset(VIEW_ADDRESSBOOK,
+ vcard_GetParamsGetServerCall,
+ NULL, NULL, NULL, vcard_LoadMsgFromServer, vcard_RenderView_or_Tail, vcard_Cleanup, NULL);
RegisterIterator("MAIL:VCARDS", 0, NULL, CtxGetVcardList, NULL, NULL, CTX_VCARD, CTX_VCARD_LIST, IT_NOFLAG);
@@ -1185,11 +1108,13 @@ InitModule_VCARD
REGISTERTokenParamDefine(TerminateList);
REGISTERTokenParamDefine(Address);
- RegisterConditional("VC:HAVE:TYPE", 1, conditional_VC_Havetype, CTX_VCARD);
- RegisterConditional("COND:VC:SUPPRESS_EMAIL_FIELDS", 1, conditional_VC_SuppressEmailFields, CTX_VCARD);
+ RegisterConditional("VC:HAVE:TYPE", 1, conditional_VC_Havetype, CTX_VCARD);
+ RegisterConditional("COND:VC:SUPPRESS_EMAIL_FIELDS", 1, conditional_VC_SuppressEmailFields, CTX_VCARD);
- RegisterFilteredIterator("VC:TYPE", 1, DefineToToken, NULL, NULL, NULL, filter_VC_ByType, CTX_VCARD_TYPE, CTX_VCARD, IT_NOFLAG);
- RegisterFilteredIterator("VC:TYPE:ITEMS", 0, NULL, getContextVcard, NULL, NULL, filter_VC_ByContextType, CTX_STRBUF, CTX_VCARD_TYPE, IT_NOFLAG);
+ RegisterFilteredIterator("VC:TYPE", 1, DefineToToken, NULL, NULL, NULL, filter_VC_ByType, CTX_VCARD_TYPE, CTX_VCARD,
+ IT_NOFLAG);
+ RegisterFilteredIterator("VC:TYPE:ITEMS", 0, NULL, getContextVcard, NULL, NULL, filter_VC_ByContextType, CTX_STRBUF,
+ CTX_VCARD_TYPE, IT_NOFLAG);
RegisterMimeRenderer(HKEY("text/x-vcard"), render_MIME_VCard, 1, 201);
RegisterMimeRenderer(HKEY("text/vcard"), render_MIME_VCard, 1, 200);
diff --git a/webcit/webcit.c b/webcit/webcit.c
index 7cc9768b9..59d5bc822 100644
--- a/webcit/webcit.c
+++ b/webcit/webcit.c
@@ -22,29 +22,23 @@ void stuff_to_cookie(int unset_cookie);
extern int GetConnected(void);
extern int verbose;
-void PutRequestLocalMem(void *Data, DeleteHashDataFunc DeleteIt)
-{
+void PutRequestLocalMem(void *Data, DeleteHashDataFunc DeleteIt) {
int n;
-
+
n = GetCount(WC->Hdr->HTTPHeaders);
Put(WC->Hdr->HTTPHeaders, IKEY(n), Data, DeleteIt);
}
-void DeleteWebcitHandler(void *vHandler)
-{
- WebcitHandler *Handler = (WebcitHandler*) vHandler;
+void DeleteWebcitHandler(void *vHandler) {
+ WebcitHandler *Handler = (WebcitHandler *) vHandler;
FreeStrBuf(&Handler->Name);
FreeStrBuf(&Handler->DisplayName);
- free (Handler);
+ free(Handler);
}
-void WebcitAddUrlHandler(const char * UrlString, long UrlSLen,
- const char *DisplayName, long dslen,
- WebcitHandlerFunc F,
- long Flags)
-{
- WebcitHandler *NewHandler;
- NewHandler = (WebcitHandler*) malloc(sizeof(WebcitHandler));
+void WebcitAddUrlHandler(const char *UrlString, long UrlSLen, const char *DisplayName, long dslen, WebcitHandlerFunc F, long Flags) {
+ WebcitHandler *NewHandler;
+ NewHandler = (WebcitHandler *) malloc(sizeof(WebcitHandler));
NewHandler->F = F;
NewHandler->Flags = Flags;
NewHandler->Name = NewStrBufPlain(UrlString, UrlSLen);
@@ -54,8 +48,7 @@ void WebcitAddUrlHandler(const char * UrlString, long UrlSLen,
Put(HandlerHash, UrlString, UrlSLen, NewHandler, DeleteWebcitHandler);
}
-void tmplput_HANDLER_DISPLAYNAME(StrBuf *Target, WCTemplputParams *TP)
-{
+void tmplput_HANDLER_DISPLAYNAME(StrBuf * Target, WCTemplputParams * TP) {
if (WC->Hdr->HR.Handler != NULL)
StrBufAppendTemplate(Target, TP, WC->Hdr->HR.Handler->DisplayName, 0);
}
@@ -65,9 +58,9 @@ void tmplput_HANDLER_DISPLAYNAME(StrBuf *Target, WCTemplputParams *TP)
* web-printing funcion. uses our vsnprintf wrapper
*/
#ifdef UBER_VERBOSE_DEBUGGING
-void wcc_printf(const char *FILE, const char *FUNCTION, long LINE, const char *format,...)
+void wcc_printf(const char *FILE, const char *FUNCTION, long LINE, const char *format, ...)
#else
-void wc_printf(const char *format,...)
+void wc_printf(const char *format, ...)
#endif
{
va_list arg_ptr;
@@ -89,8 +82,7 @@ void wc_printf(const char *format,...)
/*
* http-header-printing funcion. uses our vsnprintf wrapper
*/
-void hprintf(const char *format,...)
-{
+void hprintf(const char *format, ...) {
va_list arg_ptr;
va_start(arg_ptr, format);
@@ -107,8 +99,7 @@ void hprintf(const char *format,...)
* 0 - to transmit only,
* nonzero - to append the closing tags
*/
-void wDumpContent(int print_standard_html_footer)
-{
+void wDumpContent(int print_standard_html_footer) {
if (print_standard_html_footer) {
wc_printf(" \n");
do_template("trailing");
@@ -121,21 +112,21 @@ void wDumpContent(int print_standard_html_footer)
}
-
+
/*
* Output HTTP headers and leading HTML for a page
*/
-void output_headers( int do_httpheaders, /* 1 = output HTTP headers */
- int do_htmlhead, /* 1 = output HTML section and opener */
- int do_room_banner, /* 1 = include the room banner and
*/
- int unset_cookies, /* 1 = session is terminating, so unset the cookies */
- int suppress_check, /* 1 = suppress check for instant messages */
- int cache /* 1 = allow browser to cache this page */
-) {
+void output_headers(int do_httpheaders, /* 1 = output HTTP headers */
+ int do_htmlhead, /* 1 = output HTML section and opener */
+ int do_room_banner, /* 1 = include the room banner and
*/
+ int unset_cookies, /* 1 = session is terminating, so unset the cookies */
+ int suppress_check, /* 1 = suppress check for instant messages */
+ int cache /* 1 = allow browser to cache this page */
+ ) {
char httpnow[128];
- if (WC->isFailure)
+ if (WC->isFailure)
hprintf("HTTP/2.2 500 Internal Server Error");
else if (WC->Hdr->HaveRange > 1)
hprintf("HTTP/1.1 206 Partial Content\r\n");
@@ -147,44 +138,32 @@ void output_headers( int do_httpheaders, /* 1 = output HTTP headers */
if (do_httpheaders) {
if (WC->serv_info != NULL)
hprintf("Content-type: text/html; charset=utf-8\r\n"
- "Server: %s / %s\n"
- "Connection: close\r\n",
- PACKAGE_STRING,
- ChrPtr(WC->serv_info->serv_software));
+ "Server: %s / %s\n" "Connection: close\r\n", PACKAGE_STRING, ChrPtr(WC->serv_info->serv_software));
else
hprintf("Content-type: text/html; charset=utf-8\r\n"
- "Server: %s / [n/a]\n"
- "Connection: close\r\n",
- PACKAGE_STRING);
+ "Server: %s / [n/a]\n" "Connection: close\r\n", PACKAGE_STRING);
}
if (cache > 0) {
char httpTomorow[128];
- http_datestring(httpTomorow, sizeof httpTomorow,
- time(NULL) + 60 * 60 * 24 * 2);
+ http_datestring(httpTomorow, sizeof httpTomorow, time(NULL) + 60 * 60 * 24 * 2);
hprintf("Pragma: public\r\n"
"Cache-Control: max-age=3600, must-revalidate\r\n"
- "Last-modified: %s\r\n"
- "Expires: %s\r\n",
- httpnow,
- httpTomorow
- );
+ "Last-modified: %s\r\n" "Expires: %s\r\n", httpnow, httpTomorow);
}
else {
- hprintf("Pragma: no-cache\r\n"
- "Cache-Control: no-store\r\n"
- "Expires: -1\r\n"
- );
+ hprintf("Pragma: no-cache\r\n" "Cache-Control: no-store\r\n" "Expires: -1\r\n");
}
- if (cache < 2) stuff_to_cookie(unset_cookies);
+ if (cache < 2)
+ stuff_to_cookie(unset_cookies);
if (do_htmlhead) {
begin_burst();
do_template("head");
- if ( (WC->logged_in) && (!unset_cookies) ) {
+ if ((WC->logged_in) && (!unset_cookies)) {
DoTemplate(HKEY("paging"), NULL, &NoCtx);
}
if (do_room_banner) {
@@ -199,7 +178,7 @@ void output_headers( int do_httpheaders, /* 1 = output HTTP headers */
void output_custom_content_header(const char *ctype) {
hprintf("HTTP/1.1 200 OK\r\n");
- hprintf("Content-type: %s; charset=utf-8\r\n",ctype);
+ hprintf("Content-type: %s; charset=utf-8\r\n", ctype);
hprintf("Server: %s / %s\r\n", PACKAGE_STRING, ChrPtr(WC->serv_info->serv_software));
hprintf("Connection: close\r\n");
}
@@ -231,23 +210,17 @@ void http_redirect(const char *whichpage) {
* bunch of headers to the client. end_burst() will add some headers of its own, and then
* transmit the buffered content to the client.
*/
-void http_transmit_thing(const char *content_type, int is_static)
-{
+void http_transmit_thing(const char *content_type, int is_static) {
if (verbose)
syslog(LOG_DEBUG, "http_transmit_thing(%s)%s", content_type, ((is_static > 0) ? " (static)" : ""));
output_headers(0, 0, 0, 0, 0, is_static);
- hprintf("Content-type: %s\r\n"
- "Server: %s\r\n"
- "Connection: close\r\n",
- content_type,
- PACKAGE_STRING);
+ hprintf("Content-type: %s\r\n" "Server: %s\r\n" "Connection: close\r\n", content_type, PACKAGE_STRING);
end_burst();
}
-void http_transmit_headers(const char *content_type, int is_static, long is_chunked, int is_gzip)
-{
+void http_transmit_headers(const char *content_type, int is_static, long is_chunked, int is_gzip) {
if (verbose)
syslog(LOG_DEBUG, "http_transmit_thing(%s)%s", content_type, ((is_static > 0) ? " (static)" : ""));
output_headers(0, 0, 0, 0, 0, is_static);
@@ -257,17 +230,11 @@ void http_transmit_headers(const char *content_type, int is_static, long is_chun
if (WC->Hdr->HaveRange)
hprintf("Accept-Ranges: bytes\r\n"
- "Content-Range: bytes %ld-%ld/%ld\r\n",
- WC->Hdr->RangeStart,
- WC->Hdr->RangeTil,
- WC->Hdr->TotalBytes);
+ "Content-Range: bytes %ld-%ld/%ld\r\n", WC->Hdr->RangeStart, WC->Hdr->RangeTil, WC->Hdr->TotalBytes);
hprintf("Content-type: %s\r\n"
- "Server: "PACKAGE_STRING"\r\n"
- "%s"
- "Connection: close\r\n\r\n",
- content_type,
- (is_chunked)?"Transfer-Encoding: chunked\r\n":"");
+ "Server: " PACKAGE_STRING "\r\n"
+ "%s" "Connection: close\r\n\r\n", content_type, (is_chunked) ? "Transfer-Encoding: chunked\r\n" : "");
}
@@ -278,8 +245,7 @@ void http_transmit_headers(const char *content_type, int is_static, long is_chun
* titlebarmsg text to display in the title bar
* messagetext body of the box
*/
-void convenience_page(const char *titlebarcolor, const char *titlebarmsg, const char *messagetext)
-{
+void convenience_page(const char *titlebarcolor, const char *titlebarmsg, const char *messagetext) {
hprintf("HTTP/1.1 200 OK\n");
output_headers(1, 1, 1, 0, 0, 0);
wc_printf("\n");
@@ -318,8 +284,7 @@ void url_do_template(void) {
/*
* convenience function to indicate success
*/
-void display_success(const char *successmessage)
-{
+void display_success(const char *successmessage) {
convenience_page("007700", "OK", successmessage);
}
@@ -327,16 +292,12 @@ void display_success(const char *successmessage)
/*
* Authorization required page (sends a 401, causing the browser to request login credentials)
*/
-void authorization_required(void)
-{
+void authorization_required(void) {
const char *message = "";
hprintf("HTTP/1.1 401 Authorization Required\r\n");
- hprintf(
- "Server: %s / %s\r\n"
- "Connection: close\r\n",
- PACKAGE_STRING, ChrPtr(WC->serv_info->serv_software)
- );
+ hprintf("Server: %s / %s\r\n" "Connection: close\r\n", PACKAGE_STRING, ChrPtr(WC->serv_info->serv_software)
+ );
hprintf("WWW-Authenticate: Basic realm=\"%s\"\r\n", ChrPtr(WC->serv_info->serv_humannode));
/* if this is a false cookie authentication, remove it to avoid endless loops. */
@@ -353,11 +314,8 @@ void authorization_required(void)
message = ChrPtr(WC->ImportantMsg);
}
- wc_printf(
- _("The resource you requested requires a valid username and password. "
- "You could not be logged in: %s\n"),
- message
- );
+ wc_printf(_("The resource you requested requires a valid username and password. "
+ "You could not be logged in: %s\n"), message);
wDumpContent(0);
}
@@ -370,11 +328,7 @@ void begin_ajax_response(void) {
FlushStrBuf(WC->HBuf);
output_headers(0, 0, 0, 0, 0, 0);
- hprintf("Content-type: text/html; charset=UTF-8\r\n"
- "Server: %s\r\n"
- "Connection: close\r\n"
- ,
- PACKAGE_STRING);
+ hprintf("Content-type: text/html; charset=UTF-8\r\n" "Server: %s\r\n" "Connection: close\r\n", PACKAGE_STRING);
begin_burst();
}
@@ -397,7 +351,7 @@ void ajax_servcmd(void) {
size_t len;
if (verbose) {
- syslog(LOG_DEBUG, "ajax_servcmd() g_cmd=\"%s\"", bstr("g_cmd") );
+ syslog(LOG_DEBUG, "ajax_servcmd() g_cmd=\"%s\"", bstr("g_cmd"));
}
begin_ajax_response();
Buf = NewStrBuf();
@@ -405,12 +359,11 @@ void ajax_servcmd(void) {
StrBuf_ServGetln(Buf);
StrBufAppendBuf(WC->WBuf, Buf, 0);
StrBufAppendBufPlain(WC->WBuf, HKEY("\n"), 0);
-
+
switch (GetServerStatus(Buf, NULL)) {
case 8:
serv_puts("\n\n000");
- if ( (StrLength(Buf)==3) &&
- !strcmp(ChrPtr(Buf), "000")) {
+ if ((StrLength(Buf) == 3) && !strcmp(ChrPtr(Buf), "000")) {
StrBufAppendBufPlain(WC->WBuf, HKEY("\000"), 0);
break;
}
@@ -418,8 +371,7 @@ void ajax_servcmd(void) {
while (!Done) {
if (StrBuf_ServGetln(Buf) < 0)
break;
- if ( (StrLength(Buf)==3) &&
- !strcmp(ChrPtr(Buf), "000")) {
+ if ((StrLength(Buf) == 3) && !strcmp(ChrPtr(Buf), "000")) {
Done = 1;
}
StrBufAppendBuf(WC->WBuf, Buf, 0);
@@ -441,9 +393,9 @@ void ajax_servcmd(void) {
serv_write(junk, len);
free(junk);
}
-
+
end_ajax_response();
-
+
/*
* This is kind of an ugly hack, but this is the only place it can go.
* If the command was GEXP, then the instant messenger window must be
@@ -461,11 +413,10 @@ void ajax_servcmd(void) {
* Helper function for the asynchronous check to see if we need
* to open the instant messenger window.
*/
-void seconds_since_last_gexp(void)
-{
+void seconds_since_last_gexp(void) {
char buf[256];
- if ( (time(NULL) - WC->last_pager_check) < 30) {
+ if ((time(NULL) - WC->last_pager_check) < 30) {
wc_printf("NO\n");
}
else {
@@ -523,7 +474,7 @@ void pop_destination(void) {
* Do something reasonable if we somehow ended up requesting a pop without
* having first done a push.
*/
- if ( (!WC) || (WC->PushedDestination == NULL) || (StrLength(WC->PushedDestination) == 0) ) {
+ if ((!WC) || (WC->PushedDestination == NULL) || (StrLength(WC->PushedDestination) == 0)) {
do_welcome();
return;
}
@@ -542,18 +493,15 @@ int ReadPostData(void) {
int rc;
int urlencoded_post = 0;
StrBuf *content = NULL;
-
- urlencoded_post = (strncasecmp(ChrPtr(WC->Hdr->HR.ContentType), "application/x-www-form-urlencoded", 33) == 0) ;
+
+ urlencoded_post = (strncasecmp(ChrPtr(WC->Hdr->HR.ContentType), "application/x-www-form-urlencoded", 33) == 0);
content = NewStrBufPlain(NULL, WC->Hdr->HR.ContentLength + 256);
if (!urlencoded_post) {
- StrBufPrintf(content,
- "Content-type: %s\n"
- "Content-length: %ld\n\n",
- ChrPtr(WC->Hdr->HR.ContentType),
- WC->Hdr->HR.ContentLength
- );
+ StrBufPrintf(content,
+ "Content-type: %s\n"
+ "Content-length: %ld\n\n", ChrPtr(WC->Hdr->HR.ContentType), WC->Hdr->HR.ContentLength);
}
/* Read the entire input data at once. */
@@ -561,7 +509,7 @@ int ReadPostData(void) {
if (rc < 0) {
return rc;
}
-
+
if (urlencoded_post) {
ParseURLParams(content);
}
@@ -586,22 +534,21 @@ int ReadPostData(void) {
}
-int Conditional_REST_DEPTH(StrBuf *Target, WCTemplputParams *TP)
-{
+int Conditional_REST_DEPTH(StrBuf * Target, WCTemplputParams * TP) {
long Depth, IsDepth;
long offset = 0;
if (WC->Hdr->HR.Handler != NULL)
- offset ++;
+ offset++;
Depth = GetTemplateTokenNumber(Target, TP, 2, 0);
IsDepth = GetCount(WC->Directory) + offset;
-// LogTemplateError(Target, "bla", 1, TP, "REST_DEPTH: %ld : %ld\n", Depth, IsDepth);
+// LogTemplateError(Target, "bla", 1, TP, "REST_DEPTH: %ld : %ld\n", Depth, IsDepth);
if (Depth < 0) {
Depth = -Depth;
return IsDepth > Depth;
}
- else
+ else
return Depth == IsDepth;
}
@@ -610,11 +557,10 @@ int Conditional_REST_DEPTH(StrBuf *Target, WCTemplputParams *TP)
/*
* Entry point for WebCit transaction
*/
-void session_loop(void)
-{
+void session_loop(void) {
int xhttp;
StrBuf *Buf;
-
+
/*
* We stuff these with the values coming from the client cookies,
* so we can use them to reconnect a timed out session if we have to.
@@ -671,14 +617,12 @@ void session_loop(void)
begin_burst();
wc_printf("
503 Service Unavailable \n");
wc_printf(_("This program was unable to connect or stay "
- "connected to the Citadel server. Please report "
- "this problem to your system administrator.")
- );
+ "connected to the Citadel server. Please report " "this problem to your system administrator.")
+ );
wc_printf("
");
wc_printf("
%s ",
- _("Read More...")
- );
+ "faq:generalquestions:webcit_unable_to_connect\">%s", _("Read More...")
+ );
wc_printf("\n");
end_burst();
goto SKIP_ALL_THIS_CRAP;
@@ -689,10 +633,10 @@ void session_loop(void)
* If we're not logged in, but we have authentication data (either from
* a cookie or from http-auth), try logging in to Citadel using that.
*/
- if ( (!WC->logged_in)
- && (StrLength(WC->Hdr->c_username) > 0)
- && (StrLength(WC->Hdr->c_password) > 0)
- ) {
+ if ((!WC->logged_in)
+ && (StrLength(WC->Hdr->c_username) > 0)
+ && (StrLength(WC->Hdr->c_password) > 0)
+ ) {
long Status;
FlushStrBuf(Buf);
@@ -717,9 +661,7 @@ void session_loop(void)
}
}
- xhttp = (WC->Hdr->HR.eReqType != eGET) &&
- (WC->Hdr->HR.eReqType != ePOST) &&
- (WC->Hdr->HR.eReqType != eHEAD);
+ xhttp = (WC->Hdr->HR.eReqType != eGET) && (WC->Hdr->HR.eReqType != ePOST) && (WC->Hdr->HR.eReqType != eHEAD);
/*
* If a 'go' (or 'gotofirst') parameter has been specified, attempt to goto that room
@@ -730,7 +672,7 @@ void session_loop(void)
if (verbose)
syslog(LOG_DEBUG, "Explicit room selection: %s", bstr("go"));
ret = gotoroom(sbstr("go")); /* do quietly to avoid session output! */
- if ((ret/100) != 2) {
+ if ((ret / 100) != 2) {
if (verbose)
syslog(LOG_DEBUG, "Unable to change to [%s]; Reason: %d", bstr("go"), ret);
}
@@ -740,7 +682,7 @@ void session_loop(void)
if (verbose)
syslog(LOG_DEBUG, "Explicit room selection: %s", bstr("gotofirst"));
ret = gotoroom(sbstr("gotofirst")); /* do quietly to avoid session output! */
- if ((ret/100) != 2) {
+ if ((ret / 100) != 2) {
syslog(LOG_INFO, "Unable to change to [%s]; Reason: %d", bstr("gotofirst"), ret);
}
}
@@ -749,16 +691,15 @@ void session_loop(void)
* If we aren't in any room yet, but we have cookie data telling us where we're
* supposed to be, and 'go' was not specified, then go there.
*/
- else if ( (StrLength(WC->CurRoom.name) == 0) && ( (StrLength(WC->Hdr->c_roomname) > 0) )) {
+ else if ((StrLength(WC->CurRoom.name) == 0) && ((StrLength(WC->Hdr->c_roomname) > 0))) {
int ret;
if (verbose)
syslog(LOG_DEBUG, "We are in '%s' but cookie indicates '%s', going there...",
- ChrPtr(WC->CurRoom.name),
- ChrPtr(WC->Hdr->c_roomname)
- );
+ ChrPtr(WC->CurRoom.name), ChrPtr(WC->Hdr->c_roomname)
+ );
ret = gotoroom(WC->Hdr->c_roomname); /* do quietly to avoid session output! */
- if ((ret/100) != 2) {
+ if ((ret / 100) != 2) {
if (verbose)
syslog(LOG_DEBUG, "COOKIEGOTO: Unable to change to [%s]; Reason: %d",
ChrPtr(WC->Hdr->c_roomname), ret);
@@ -766,11 +707,11 @@ void session_loop(void)
}
if (WC->Hdr->HR.Handler != NULL) {
- if ( (!WC->logged_in)
- && ((WC->Hdr->HR.Handler->Flags & ANONYMOUS) == 0)
- && (WC->serv_info != NULL)
- && (WC->serv_info->serv_supports_guest == 0)
- ) {
+ if ((!WC->logged_in)
+ && ((WC->Hdr->HR.Handler->Flags & ANONYMOUS) == 0)
+ && (WC->serv_info != NULL)
+ && (WC->serv_info->serv_supports_guest == 0)
+ ) {
display_login();
}
else {
@@ -789,7 +730,7 @@ void session_loop(void)
* ordinary browser users get a nice login screen, DAV etc. requsets
* are given a 401 so they can handle it appropriate.
*/
- if (!WC->logged_in) {
+ if (!WC->logged_in) {
if (xhttp) {
authorization_required();
}
@@ -810,7 +751,7 @@ void session_loop(void)
}
}
-SKIP_ALL_THIS_CRAP:
+ SKIP_ALL_THIS_CRAP:
FreeStrBuf(&Buf);
fflush(stdout);
}
@@ -847,8 +788,7 @@ void display_default_landing_page(void) {
/*
* Replacement for sleep() that uses select() in order to avoid SIGALRM
*/
-void sleeeeeeeeeep(int seconds)
-{
+void sleeeeeeeeeep(int seconds) {
struct timeval tv;
tv.tv_sec = seconds;
@@ -856,23 +796,20 @@ void sleeeeeeeeeep(int seconds)
select(0, NULL, NULL, NULL, &tv);
}
-int Conditional_IS_HTTPS(StrBuf *Target, WCTemplputParams *TP)
-{
+int Conditional_IS_HTTPS(StrBuf * Target, WCTemplputParams * TP) {
return is_https != 0;
}
-void AppendImportantMessage(const char *pch, long len)
-{
+void AppendImportantMessage(const char *pch, long len) {
if (StrLength(WC->ImportantMsg) > 0) {
StrBufAppendBufPlain(WC->ImportantMsg, HKEY("\n"), 0);
}
-
+
StrBufAppendBufPlain(WC->ImportantMsg, pch, len, 0);
}
-int ConditionalImportantMesage(StrBuf *Target, WCTemplputParams *TP)
-{
+int ConditionalImportantMesage(StrBuf * Target, WCTemplputParams * TP) {
if (WC != NULL) {
return (StrLength(WC->ImportantMsg) > 0);
}
@@ -881,9 +818,8 @@ int ConditionalImportantMesage(StrBuf *Target, WCTemplputParams *TP)
}
}
-void tmplput_importantmessage(StrBuf *Target, WCTemplputParams *TP)
-{
-
+void tmplput_importantmessage(StrBuf * Target, WCTemplputParams * TP) {
+
if (WC != NULL) {
if (StrLength(WC->ImportantMsg) > 0) {
StrBufAppendTemplate(Target, TP, WC->ImportantMsg, 0);
@@ -891,42 +827,36 @@ void tmplput_importantmessage(StrBuf *Target, WCTemplputParams *TP)
}
}
-void tmplput_trailing_javascript(StrBuf *Target, WCTemplputParams *TP)
-{
+void tmplput_trailing_javascript(StrBuf * Target, WCTemplputParams * TP) {
if (WC != NULL) {
StrBufAppendTemplate(Target, TP, WC->trailing_javascript, 0);
}
}
-void tmplput_csslocal(StrBuf *Target, WCTemplputParams *TP)
-{
- StrBufAppendBuf(Target,
- csslocal, 0);
+void tmplput_csslocal(StrBuf * Target, WCTemplputParams * TP) {
+ StrBufAppendBuf(Target, csslocal, 0);
}
-void tmplput_packagestring(StrBuf *Target, WCTemplputParams *TP) {
+void tmplput_packagestring(StrBuf * Target, WCTemplputParams * TP) {
StrBufAppendBufPlain(Target, HKEY(PACKAGE_STRING), 0);
}
extern char static_local_dir[PATH_MAX];
-void
-InitModule_WEBCIT
-(void)
-{
+void InitModule_WEBCIT(void) {
char dir[SIZ];
- WebcitAddUrlHandler(HKEY("blank"), "", 0, blank_page, ANONYMOUS|COOKIEUNNEEDED|ISSTATIC);
- WebcitAddUrlHandler(HKEY("landing"), "", 0, display_default_landing_page, ANONYMOUS|COOKIEUNNEEDED);
+ WebcitAddUrlHandler(HKEY("blank"), "", 0, blank_page, ANONYMOUS | COOKIEUNNEEDED | ISSTATIC);
+ WebcitAddUrlHandler(HKEY("landing"), "", 0, display_default_landing_page, ANONYMOUS | COOKIEUNNEEDED);
WebcitAddUrlHandler(HKEY("do_template"), "", 0, url_do_template, ANONYMOUS);
- WebcitAddUrlHandler(HKEY("sslg"), "", 0, seconds_since_last_gexp, AJAX|LOGCHATTY);
+ WebcitAddUrlHandler(HKEY("sslg"), "", 0, seconds_since_last_gexp, AJAX | LOGCHATTY);
WebcitAddUrlHandler(HKEY("ajax_servcmd"), "", 0, ajax_servcmd, 0);
WebcitAddUrlHandler(HKEY("webcit"), "", 0, blank_page, URLNAMESPACE);
WebcitAddUrlHandler(HKEY("push"), "", 0, push_destination, AJAX);
WebcitAddUrlHandler(HKEY("pop"), "", 0, pop_destination, 0);
- WebcitAddUrlHandler(HKEY("401"), "", 0, authorization_required, ANONYMOUS|COOKIEUNNEEDED);
+ WebcitAddUrlHandler(HKEY("401"), "", 0, authorization_required, ANONYMOUS | COOKIEUNNEEDED);
RegisterConditional("COND:IMPMSG", 0, ConditionalImportantMesage, CTX_NONE);
RegisterConditional("COND:REST:DEPTH", 0, Conditional_REST_DEPTH, CTX_NONE);
RegisterConditional("COND:IS_HTTPS", 0, Conditional_IS_HTTPS, CTX_NONE);
@@ -937,7 +867,7 @@ InitModule_WEBCIT
RegisterNamespace("URL:DISPLAYNAME", 0, 1, tmplput_HANDLER_DISPLAYNAME, NULL, CTX_NONE);
RegisterNamespace("PACKAGESTRING", 0, 1, tmplput_packagestring, NULL, CTX_NONE);
-
+
snprintf(dir, SIZ, "%s/webcit.css", static_local_dir);
if (!access(dir, R_OK)) {
syslog(LOG_INFO, "Using local Stylesheet [%s]", dir);
@@ -948,46 +878,33 @@ InitModule_WEBCIT
}
-void
-ServerStartModule_WEBCIT
-(void)
-{
+void ServerStartModule_WEBCIT(void) {
HandlerHash = NewHash(1, NULL);
}
-void
-ServerShutdownModule_WEBCIT
-(void)
-{
+void ServerShutdownModule_WEBCIT(void) {
FreeStrBuf(&csslocal);
DeleteHash(&HandlerHash);
}
-void
-SessionNewModule_WEBCIT
-(wcsession *sess)
-{
+void SessionNewModule_WEBCIT(wcsession * sess) {
sess->ImportantMsg = NewStrBuf();
sess->WBuf = NewStrBufPlain(NULL, SIZ * 4);
sess->HBuf = NewStrBufPlain(NULL, SIZ / 4);
}
-void
-SessionDetachModule_WEBCIT
-(wcsession *sess)
-{
+void SessionDetachModule_WEBCIT(wcsession * sess) {
DeleteHash(&sess->Directory);
FreeStrBuf(&sess->upload);
sess->upload_length = 0;
-
+
FreeStrBuf(&sess->trailing_javascript);
- if (StrLength(sess->WBuf) > SIZ * 30) /* Bigger than 120K? release. */
- {
+ if (StrLength(sess->WBuf) > SIZ * 30) { /* Bigger than 120K? release. */
FreeStrBuf(&sess->WBuf);
sess->WBuf = NewStrBuf();
}
@@ -1000,13 +917,10 @@ SessionDetachModule_WEBCIT
}
-void
-SessionDestroyModule_WEBCIT
-(wcsession *sess)
-{
+void
+ SessionDestroyModule_WEBCIT(wcsession * sess) {
FreeStrBuf(&sess->WBuf);
FreeStrBuf(&sess->HBuf);
FreeStrBuf(&sess->ImportantMsg);
FreeStrBuf(&sess->PushedDestination);
}
-
diff --git a/webcit/webcit.h b/webcit/webcit.h
index a5adb52fd..5e58b755a 100644
--- a/webcit/webcit.h
+++ b/webcit/webcit.h
@@ -1,3 +1,4 @@
+
/*
* Copyright (c) 1987-2021 by the citadel.org team
*
@@ -90,6 +91,7 @@ typedef struct wcsession wcsession;
#include "sockets.h"
#include "utils.h"
#ifdef HAVE_OPENSSL
+
/* Work around RedHat's b0rken OpenSSL includes */
#define OPENSSL_NO_KRB5
#include
@@ -99,7 +101,7 @@ extern char *ssl_cipher_list;
#define DEFAULT_SSL_CIPHER_LIST "DEFAULT" /* See http://openssl.org/docs/apps/ciphers.html */
#endif
-#if SIZEOF_SIZE_T == SIZEOF_INT
+#if SIZEOF_SIZE_T == SIZEOF_INT
#define SIZE_T_FMT "%d"
#else
#define SIZE_T_FMT "%ld"
@@ -114,7 +116,7 @@ extern char *ssl_cipher_list;
#define CALENDAR_ROOM_NAME "Calendar"
#define PRODID "-//Citadel//NONSGML Citadel Calendar//EN"
-#define SIZ 4096 /* generic buffer size */
+#define SIZ 4096 /* generic buffer size */
#define TRACE syslog(LOG_DEBUG, "\033[3%dmCHECKPOINT: %s:%d\033[0m", ((__LINE__%6)+1), __FILE__, __LINE__)
@@ -122,19 +124,19 @@ extern char *ssl_cipher_list;
#undef memcpy
#endif
-#define SLEEPING 180 /* TCP connection timeout */
-#define WEBCIT_TIMEOUT 900 /* WebCit session timeout */
-#define PORT_NUM 80 /* port number to listen on */
+#define SLEEPING 180 /* TCP connection timeout */
+#define WEBCIT_TIMEOUT 900 /* WebCit session timeout */
+#define PORT_NUM 80 /* port number to listen on */
#define DEVELOPER_ID 0
#define CLIENT_ID 4
-#define CLIENT_VERSION 957 /* This version of WebCit */
-#define MINIMUM_CIT_VERSION 931 /* Minimum required version of Citadel server */
-#define LIBCITADEL_MIN 931 /* Minimum required version of libcitadel */
+#define CLIENT_VERSION 957 /* This version of WebCit */
+#define MINIMUM_CIT_VERSION 931 /* Minimum required version of Citadel server */
+#define LIBCITADEL_MIN 931 /* Minimum required version of libcitadel */
#define DEFAULT_CTDLDIR "/usr/local/citadel" /* Default Citadel server directory */
-#define TARGET "webcit01" /* Window target for inline URL's */
-#define HOUSEKEEPING 15 /* Housekeeping frequency */
+#define TARGET "webcit01" /* Window target for inline URL's */
+#define HOUSEKEEPING 15 /* Housekeeping frequency */
#define MAX_WORKER_THREADS 250
-#define LISTEN_QUEUE_LENGTH 100 /* listen() backlog queue */
+#define LISTEN_QUEUE_LENGTH 100 /* listen() backlog queue */
#define USERCONFIGROOM "My Citadel Config"
#define DEFAULT_MAXMSGS 20
@@ -149,7 +151,7 @@ extern char *ssl_cipher_list;
#define MAJORCODE(a) (((int)(a / 100) ) * 100)
#define LISTING_FOLLOWS 100
-#define CIT_OK 200
+#define CIT_OK 200
#define MORE_DATA 300
#define SEND_LISTING 400
#define ERROR 500
@@ -159,27 +161,27 @@ extern char *ssl_cipher_list;
#define ASYNC_MSG 900
#define MINORCODE(a) (a % 100)
-#define ASYNC_GEXP 02
-#define INTERNAL_ERROR 10
-#define TOO_BIG 11
-#define ILLEGAL_VALUE 12
-#define NOT_LOGGED_IN 20
-#define CMD_NOT_SUPPORTED 30
-#define SERVER_SHUTTING_DOWN 31
-#define PASSWORD_REQUIRED 40
-#define ALREADY_LOGGED_IN 41
-#define USERNAME_REQUIRED 42
-#define HIGHER_ACCESS_REQUIRED 50
-#define MAX_SESSIONS_EXCEEDED 51
-#define RESOURCE_BUSY 52
-#define RESOURCE_NOT_OPEN 53
-#define NOT_HERE 60
-#define INVALID_FLOOR_OPERATION 61
-#define NO_SUCH_USER 70
-#define FILE_NOT_FOUND 71
-#define ROOM_NOT_FOUND 72
-#define NO_SUCH_SYSTEM 73
-#define ALREADY_EXISTS 74
+#define ASYNC_GEXP 02
+#define INTERNAL_ERROR 10
+#define TOO_BIG 11
+#define ILLEGAL_VALUE 12
+#define NOT_LOGGED_IN 20
+#define CMD_NOT_SUPPORTED 30
+#define SERVER_SHUTTING_DOWN 31
+#define PASSWORD_REQUIRED 40
+#define ALREADY_LOGGED_IN 41
+#define USERNAME_REQUIRED 42
+#define HIGHER_ACCESS_REQUIRED 50
+#define MAX_SESSIONS_EXCEEDED 51
+#define RESOURCE_BUSY 52
+#define RESOURCE_NOT_OPEN 53
+#define NOT_HERE 60
+#define INVALID_FLOOR_OPERATION 61
+#define NO_SUCH_USER 70
+#define FILE_NOT_FOUND 71
+#define ROOM_NOT_FOUND 72
+#define NO_SUCH_SYSTEM 73
+#define ALREADY_EXISTS 74
#define MESSAGE_NOT_FOUND 75
/*
@@ -193,8 +195,8 @@ extern char *ssl_cipher_list;
*/
typedef struct __ExpirePolicy {
- int expire_mode;
- int expire_value;
+ int expire_mode;
+ int expire_value;
} ExpirePolicy;
/*
@@ -202,27 +204,27 @@ typedef struct __ExpirePolicy {
*/
typedef struct urlcontent urlcontent;
struct urlcontent {
- char url_key[32]; /* key */
+ char url_key[32]; /* key */
long klen;
- StrBuf *url_data; /* value */
+ StrBuf *url_data; /* value */
HashList *sub;
};
/*
* Information about the Citadel server to which we are connected
- */
+ */
typedef struct _serv_info {
- int serv_pid; /* Process ID of the Citadel server */
- StrBuf *serv_nodename; /* Node name of the Citadel server */
- StrBuf *serv_humannode; /* Juman readable node name of the Citadel server */
- StrBuf *serv_fqdn; /* Fully qualified Domain Name (such as uncensored.citadel.org) */
- StrBuf *serv_software; /* Free form text description of the server software in use */
- int serv_rev_level; /* Server version number (times 100) */
- StrBuf *serv_bbs_city; /* Geographic location of the Citadel server */
- StrBuf *serv_sysadm; /* Name of system administrator */
- int serv_supports_ldap; /* is the server linked against an ldap tree for adresses? */
+ int serv_pid; /* Process ID of the Citadel server */
+ StrBuf *serv_nodename; /* Node name of the Citadel server */
+ StrBuf *serv_humannode; /* Juman readable node name of the Citadel server */
+ StrBuf *serv_fqdn; /* Fully qualified Domain Name (such as uncensored.citadel.org) */
+ StrBuf *serv_software; /* Free form text description of the server software in use */
+ int serv_rev_level; /* Server version number (times 100) */
+ StrBuf *serv_bbs_city; /* Geographic location of the Citadel server */
+ StrBuf *serv_sysadm; /* Name of system administrator */
+ int serv_supports_ldap; /* is the server linked against an ldap tree for adresses? */
int serv_newuser_disabled; /* Has the server disabled self-service new user creation? */
- StrBuf *serv_default_cal_zone; /* Default timezone for unspecified calendar items */
+ StrBuf *serv_default_cal_zone; /* Default timezone for unspecified calendar items */
int serv_supports_sieve; /* Server supports Sieve mail filtering */
int serv_fulltext_enabled; /* Full text index is enabled */
StrBuf *serv_svn_revision; /* svn or git revision of the server */
@@ -231,20 +233,20 @@ typedef struct _serv_info {
} ServInfo;
-typedef struct _disp_cal {
- icalcomponent *cal; /* cal items for display */
- long cal_msgnum; /* cal msgids for display */
- char *from; /* owner of this component */
- int unread; /* already seen by the user? */
+typedef struct _disp_cal {
+ icalcomponent *cal; /* cal items for display */
+ long cal_msgnum; /* cal msgids for display */
+ char *from; /* owner of this component */
+ int unread; /* already seen by the user? */
time_t event_start;
time_t event_end;
int multi_day_event;
int is_repeat;
- icalcomponent *SortBy; /* cal items for display */
+ icalcomponent *SortBy; /* cal items for display */
icalproperty_status Status;
-} disp_cal;
+} disp_cal;
typedef struct _IcalKindEnumMap {
const char *Name;
@@ -254,7 +256,7 @@ typedef struct _IcalKindEnumMap {
typedef struct _IcalMethodEnumMap {
const char *Name;
long NameLen;
- icalproperty_method map;
+ icalproperty_method map;
} IcalMethodEnumMap;
@@ -287,7 +289,7 @@ typedef enum _RESTDispatchID {
typedef int (*WebcitRESTDispatchID)(RESTDispatchID WhichAction, int IgnoreFloor);
typedef void (*WebcitHandlerFunc)(void);
-typedef struct _WebcitHandler{
+typedef struct _WebcitHandler {
WebcitHandlerFunc F;
WebcitRESTDispatchID RID;
long Flags;
@@ -295,7 +297,7 @@ typedef struct _WebcitHandler{
StrBuf *DisplayName;
} WebcitHandler;
-void WebcitAddUrlHandler(const char * UrlString, long UrlSLen, const char *DisplayName, long dslen, WebcitHandlerFunc F, long Flags);
+void WebcitAddUrlHandler(const char *UrlString, long UrlSLen, const char *DisplayName, long dslen, WebcitHandlerFunc F, long Flags);
typedef struct _headereval {
ExamineMsgHeaderFunc evaluator;
@@ -333,7 +335,7 @@ extern const char *ReqStrs[eNONE];
#define AUTH_BASIC 2
typedef struct _HdrRefs {
- long eReqType; /* HTTP method */
+ long eReqType; /* HTTP method */
int desired_session;
int SessionKey;
@@ -341,7 +343,7 @@ typedef struct _HdrRefs {
int DontNeedAuth;
long ContentLength;
time_t if_modified_since;
- int gzip_ok; /* Nonzero if Accept-encoding: gzip */
+ int gzip_ok; /* Nonzero if Accept-encoding: gzip */
int prohibit_caching;
int dav_depth;
int Static;
@@ -360,7 +362,7 @@ typedef struct _HdrRefs {
} HdrRefs;
typedef struct _ParsedHttpHdrs {
- int http_sock; /* HTTP server socket */
+ int http_sock; /* HTTP server socket */
long HaveRange;
long RangeStart;
long RangeTil;
@@ -372,13 +374,13 @@ typedef struct _ParsedHttpHdrs {
StrBuf *c_password;
StrBuf *c_roomname;
StrBuf *c_language;
- StrBuf *this_page; /* URL of current page */
- StrBuf *PlainArgs;
+ StrBuf *this_page; /* URL of current page */
+ StrBuf *PlainArgs;
StrBuf *HostHeader;
- HashList *urlstrings; /* variables passed to webcit in a URL */
- HashList *HTTPHeaders; /* the headers the client sent us */
- int nWildfireHeaders; /* how many wildfire headers did we already send? */
+ HashList *urlstrings; /* variables passed to webcit in a URL */
+ HashList *HTTPHeaders; /* the headers the client sent us */
+ int nWildfireHeaders; /* how many wildfire headers did we already send? */
HdrRefs HR;
} ParsedHttpHdrs;
@@ -388,95 +390,98 @@ typedef struct _ParsedHttpHdrs {
* HTTP transactions are bound to one at a time.
*/
struct wcsession {
+
/* infrastructural members */
- wcsession *next; /* Linked list */
- pthread_mutex_t SessionMutex; /* mutex for exclusive access */
- int wc_session; /* WebCit session ID */
- int killthis; /* Nonzero == purge this session */
- int ctdl_pid; /* Session ID on the Citadel server */
- int nonce; /* session nonce (to prevent session riding) */
- int inuse; /* set to nonzero if bound to a running thread */
- int isFailure; /* Http 2xx or 5xx? */
+ wcsession *next; /* Linked list */
+ pthread_mutex_t SessionMutex; /* mutex for exclusive access */
+ int wc_session; /* WebCit session ID */
+ int killthis; /* Nonzero == purge this session */
+ int ctdl_pid; /* Session ID on the Citadel server */
+ int nonce; /* session nonce (to prevent session riding) */
+ int inuse; /* set to nonzero if bound to a running thread */
+ int isFailure; /* Http 2xx or 5xx? */
/* Session local Members */
- int serv_sock; /* Client socket to Citadel server */
- StrBuf *ReadBuf; /* linebuffered reads from the server */
- StrBuf *MigrateReadLineBuf; /* here we buffer legacy server read stuff */
- const char *ReadPos; /* whats our read position in ReadBuf? */
- int last_chat_seq; /* When in chat - last message seq# we saw */
- time_t lastreq; /* Timestamp of most recent HTTP */
- time_t last_pager_check; /* last time we polled for instant msgs */
- ServInfo *serv_info; /* Information about the citserver we're connected to */
- StrBuf *PushedDestination; /* Where to go after login, registration, etc. */
+ int serv_sock; /* Client socket to Citadel server */
+ StrBuf *ReadBuf; /* linebuffered reads from the server */
+ StrBuf *MigrateReadLineBuf; /* here we buffer legacy server read stuff */
+ const char *ReadPos; /* whats our read position in ReadBuf? */
+ int last_chat_seq; /* When in chat - last message seq# we saw */
+ time_t lastreq; /* Timestamp of most recent HTTP */
+ time_t last_pager_check; /* last time we polled for instant msgs */
+ ServInfo *serv_info; /* Information about the citserver we're connected to */
+ StrBuf *PushedDestination; /* Where to go after login, registration, etc. */
/* Request local Members */
- StrBuf *CLineBuf; /* linebuffering client stuff */
+ StrBuf *CLineBuf; /* linebuffering client stuff */
ParsedHttpHdrs *Hdr;
- StrBuf *WBuf; /* Our output buffer */
- StrBuf *HBuf; /* Our HeaderBuffer */
- StrBuf *WFBuf; /* Wildfire error logging buffer */
- StrBuf *trailing_javascript; /* extra javascript to be appended to page */
+ StrBuf *WBuf; /* Our output buffer */
+ StrBuf *HBuf; /* Our HeaderBuffer */
+ StrBuf *WFBuf; /* Wildfire error logging buffer */
+ StrBuf *trailing_javascript; /* extra javascript to be appended to page */
StrBuf *ImportantMsg;
- HashList *Directory; /* Parts of the directory URL in snippets */
- const Floor *CurrentFloor; /* when Parsing REST, which floor are we on? */
+ HashList *Directory; /* Parts of the directory URL in snippets */
+ const Floor *CurrentFloor; /* when Parsing REST, which floor are we on? */
/* accounting */
- StrBuf *wc_username; /* login name of current user */
- StrBuf *wc_fullname; /* Screen name of current user */
- StrBuf *wc_password; /* Password of current user */
- StrBuf *httpauth_pass; /* only for GroupDAV sessions */
- int axlevel; /* this user's access level */
- int is_aide; /* nonzero == this user is an Admin */
- int connected; /* nonzero == we are connected to Citadel */
- int logged_in; /* nonzero == we are logged in */
- int need_regi; /* This user needs to register. */
- int need_vali; /* New users require validation. */
+ StrBuf *wc_username; /* login name of current user */
+ StrBuf *wc_fullname; /* Screen name of current user */
+ StrBuf *wc_password; /* Password of current user */
+ StrBuf *httpauth_pass; /* only for GroupDAV sessions */
+ int axlevel; /* this user's access level */
+ int is_aide; /* nonzero == this user is an Admin */
+ int connected; /* nonzero == we are connected to Citadel */
+ int logged_in; /* nonzero == we are logged in */
+ int need_regi; /* This user needs to register. */
+ int need_vali; /* New users require validation. */
/* Preferences */
- StrBuf *cs_inet_email; /* User's preferred Internet addr. */
- HashList *hash_prefs; /* WebCit preferences for this user */
- StrBuf *DefaultCharset; /* Charset the user preferes */
- int downloaded_prefs; /* Has the client download its prefs yet? */
- int SavePrefsToServer; /* Should we save our preferences to the server at the end of the request? */
- int selected_language; /* Language selected by user */
- int time_format_cache; /* which timeformat does our user like? */
-
- folder CurRoom; /* information about our current room */
- const folder *ThisRoom; /* if REST found a room, remember it here. */
+ StrBuf *cs_inet_email; /* User's preferred Internet addr. */
+ HashList *hash_prefs; /* WebCit preferences for this user */
+ StrBuf *DefaultCharset; /* Charset the user preferes */
+ int downloaded_prefs; /* Has the client download its prefs yet? */
+ int SavePrefsToServer; /* Should we save our preferences to the server at the end of the request? */
+ int selected_language; /* Language selected by user */
+ int time_format_cache; /* which timeformat does our user like? */
+
+ folder CurRoom; /* information about our current room */
+ const folder *ThisRoom; /* if REST found a room, remember it here. */
+
/* next/previous room thingabob */
- struct march *march; /* march mode room list */
- char ugname[128]; /* where does 'ungoto' take us */
- long uglsn; /* last seen message number for ungoto */
+ struct march *march; /* march mode room list */
+ char ugname[128]; /* where does 'ungoto' take us */
+ long uglsn; /* last seen message number for ungoto */
/* Uploading; mime attachments for composing messages */
- HashList *attachments; /* list of attachments for 'enter message' */
- int upload_length; /* content length of http-uploaded data */
- StrBuf *upload; /* pointer to http-uploaded data */
- StrBuf *upload_filename; /* filename of http-uploaded data */
- char upload_content_type[256]; /* content type of http-uploaded data */
+ HashList *attachments; /* list of attachments for 'enter message' */
+ int upload_length; /* content length of http-uploaded data */
+ StrBuf *upload; /* pointer to http-uploaded data */
+ StrBuf *upload_filename; /* filename of http-uploaded data */
+ char upload_content_type[256]; /* content type of http-uploaded data */
- int remember_new_mail; /* last count of new mail messages */
+ int remember_new_mail; /* last count of new mail messages */
/* Roomiew control */
- HashList *Floors; /* floors our citserver has hashed numeric for quicker access*/
- HashList *FloorsByName; /* same but hashed by its name */
- HashList *Rooms; /* our directory structure as loaded by LKRA */
- HashList *summ; /* list of messages for mailbox summary view */
+ HashList *Floors; /* floors our citserver has hashed numeric for quicker access */
+ HashList *FloorsByName; /* same but hashed by its name */
+ HashList *Rooms; /* our directory structure as loaded by LKRA */
+ HashList *summ; /* list of messages for mailbox summary view */
+
/** Perhaps these should be within a struct instead */
- long startmsg; /* message number to start at */
- long maxmsgs; /* maximum messages to display */
- long num_displayed; /* number of messages actually displayed */
- HashList *disp_cal_items; /* sorted list of calendar items; startdate is the sort criteria. */
+ long startmsg; /* message number to start at */
+ long maxmsgs; /* maximum messages to display */
+ long num_displayed; /* number of messages actually displayed */
+ HashList *disp_cal_items; /* sorted list of calendar items; startdate is the sort criteria. */
char last_chat_user[256];
- StrBuf *IconTheme; /* Icontheme setting */
+ StrBuf *IconTheme; /* Icontheme setting */
/* Iconbar controls */
int cache_max_folders;
int cache_num_floors;
- long *IBSettingsVec; /* which icons should be shown / not shown? */
+ long *IBSettingsVec; /* which icons should be shown / not shown? */
const StrBuf *floordiv_expanded; /* which floordiv currently expanded */
int ib_wholist_expanded;
int ib_roomlist_expanded;
@@ -489,14 +494,14 @@ struct wcsession {
StrBuf *ConvertBuf2;
/* cache stuff for templates. TODO: find a smarter way */
- HashList *ServCfg; /* cache our server config for editing */
- HashList *InetCfg; /* Our inet server config for editing */
+ HashList *ServCfg; /* cache our server config for editing */
+ HashList *InetCfg; /* Our inet server config for editing */
ExpirePolicy Policy[maxpolicy];
};
-typedef void (*Header_Evaluator)(StrBuf *Line, ParsedHttpHdrs *hdr);
+typedef void (*Header_Evaluator)(StrBuf * Line, ParsedHttpHdrs * hdr);
typedef struct _HttpHeader {
Header_Evaluator H;
@@ -514,7 +519,7 @@ enum {
};
#ifndef num_parms
-#define num_parms(source) num_tokens(source, '|')
+#define num_parms(source) num_tokens(source, '|')
#endif
#define site_prefix (WC ? (WC->Hdr->HostHeader) : NULL)
@@ -531,9 +536,9 @@ extern pthread_key_t ThreadSSL;
void init_ssl(void);
void endtls(void);
int starttls(int sock);
-extern SSL_CTX *ssl_ctx;
-int client_read_sslbuffer(StrBuf *buf, int timeout);
-int client_write_ssl(const StrBuf *Buf);
+extern SSL_CTX *ssl_ctx;
+int client_read_sslbuffer(StrBuf * buf, int timeout);
+int client_write_ssl(const StrBuf * Buf);
#endif
extern int is_https;
@@ -556,21 +561,21 @@ void http_redirect(const char *);
#ifdef UBER_VERBOSE_DEBUGGING
#define wc_printf(...) wcc_printf(__FILE__, __FUNCTION__, __LINE__, __VA_ARGS__)
void wcc_printf(const char *FILE, const char *FUNCTION, long LINE, const char *format, ...);
-#else
-void wc_printf(const char *format,...)__attribute__((__format__(__printf__,1,2)));
+#else
+void wc_printf(const char *format, ...) __attribute__((__format__(__printf__, 1, 2)));
#endif
-void hprintf(const char *format,...)__attribute__((__format__(__printf__,1,2)));
-void CheckAuthBasic(ParsedHttpHdrs *hdr);
-void GetAuthBasic(ParsedHttpHdrs *hdr);
+void hprintf(const char *format, ...) __attribute__((__format__(__printf__, 1, 2)));
+void CheckAuthBasic(ParsedHttpHdrs * hdr);
+void GetAuthBasic(ParsedHttpHdrs * hdr);
void sleeeeeeeeeep(int);
size_t wc_strftime(char *s, size_t max, const char *format, const struct tm *tm);
void fmt_time(char *buf, size_t siz, time_t thetime);
void httpdate(char *buf, time_t thetime);
-time_t httpdate_to_timestamp(StrBuf *buf);
+time_t httpdate_to_timestamp(StrBuf * buf);
void end_webcit_session(void);
-void cookie_to_stuff(StrBuf *cookie, int *session, StrBuf *user, StrBuf *pass, StrBuf *room, StrBuf *language);
-void locate_host(StrBuf *TBuf, int);
-void become_logged_in(const StrBuf *user, const StrBuf *pass, StrBuf *serv_response);
+void cookie_to_stuff(StrBuf * cookie, int *session, StrBuf * user, StrBuf * pass, StrBuf * room, StrBuf * language);
+void locate_host(StrBuf * TBuf, int);
+void become_logged_in(const StrBuf * user, const StrBuf * pass, StrBuf * serv_response);
void display_login(void);
void display_openids(void);
void display_default_landing_page(void);
@@ -581,43 +586,44 @@ void display_aide_menu(void);
void RegisterEmbeddableMimeType(const char *MimeType, long MTLen, int Priority);
void CreateMimeStr(void);
void pop_destination(void);
-void FmOut(StrBuf *Target, const char *align, const StrBuf *Source);
+void FmOut(StrBuf * Target, const char *align, const StrBuf * Source);
void wDumpContent(int);
void PutRequestLocalMem(void *Data, DeleteHashDataFunc DeleteIt);
void output_headers(int do_httpheaders, int do_htmlhead, int do_room_banner, int unset_cookies, int suppress_check, int cache);
void cdataout(char *rawdata);
void url(char *buf, size_t bufsize);
-void UrlizeText(StrBuf* Target, StrBuf *Source, StrBuf *WrkBuf);
+void UrlizeText(StrBuf * Target, StrBuf * Source, StrBuf * WrkBuf);
void display_success(const char *successmessage);
void shutdown_sessions(void);
StrBuf *load_mimepart(long msgnum, char *partnum);
-void MimeLoadData(wc_mime_attachment *Mime);
-void do_edit_vcard(long msgnum, char *partnum, message_summary *VCMsg, wc_mime_attachment *VCAtt, const char *return_to, const char *force_room);
+void MimeLoadData(wc_mime_attachment * Mime);
+void do_edit_vcard(long msgnum, char *partnum, message_summary * VCMsg, wc_mime_attachment * VCAtt, const char *return_to,
+ const char *force_room);
void select_user_to_edit(const char *preselect);
void convenience_page(const char *titlebarcolor, const char *titlebarmsg, const char *messagetext);
void output_html(const char *, int, int, StrBuf *, StrBuf *);
ssize_t write(int fd, const void *buf, size_t count);
-void cal_process_attachment(wc_mime_attachment *Mime);
+void cal_process_attachment(wc_mime_attachment * Mime);
void begin_ajax_response(void);
void end_ajax_response(void);
extern char *months[];
extern char *days[];
-long locate_user_vcard_in_this_room(message_summary **VCMsg, wc_mime_attachment **VCAtt);
+long locate_user_vcard_in_this_room(message_summary ** VCMsg, wc_mime_attachment ** VCAtt);
void http_transmit_thing(const char *content_type, int is_static);
void http_transmit_headers(const char *content_type, int is_static, long is_chunked, int is_gzip);
long unescape_input(char *buf);
void check_thread_pool_size(void);
-void StrEndTab(StrBuf *Target, int tabnum, int num_tabs);
-void StrBeginTab(StrBuf *Target, int tabnum, int num_tabs, StrBuf **Names);
-void StrTabbedDialog(StrBuf *Target, int num_tabs, StrBuf *tabnames[]);
+void StrEndTab(StrBuf * Target, int tabnum, int num_tabs);
+void StrBeginTab(StrBuf * Target, int tabnum, int num_tabs, StrBuf ** Names);
+void StrTabbedDialog(StrBuf * Target, int num_tabs, StrBuf * tabnames[]);
void tabbed_dialog(int num_tabs, const char *tabnames[]);
void begin_tab(int tabnum, int num_tabs);
void end_tab(int tabnum, int num_tabs);
-int get_time_format_cached (void);
+int get_time_format_cached(void);
void display_wiki_pagelist(void);
void str_wiki_index(StrBuf *);
-HashList *GetRoomListHashLKRA(StrBuf *Target, WCTemplputParams *TP);
-void TmplGettext(StrBuf *Target, WCTemplputParams *TP); /* actual supported locales */
+HashList *GetRoomListHashLKRA(StrBuf * Target, WCTemplputParams * TP);
+void TmplGettext(StrBuf * Target, WCTemplputParams * TP); /* actual supported locales */
void set_selected_language(const char *);
void go_selected_language(void);
const char *get_selected_language(void);
@@ -642,11 +648,11 @@ void display_enter(void);
#define WC_TIMEFORMAT_AMPM 1
#define WC_TIMEFORMAT_24 2
-extern int time_to_die; /* Nonzero if server is shutting down */
+extern int time_to_die; /* Nonzero if server is shutting down */
extern int DisableGzip;
void display_summary_page(void);
-HashList *GetValidDomainNames(StrBuf *Target, WCTemplputParams *TP);
+HashList *GetValidDomainNames(StrBuf * Target, WCTemplputParams * TP);
void output_error_pic(const char *ErrMsg1, const char *ErrMsg2);
void jsonMessageListHdr(void);
-extern char *ctdl_dir; /* Directory where Citadel Server is running */
+extern char *ctdl_dir; /* Directory where Citadel Server is running */
diff --git a/webcit/webserver.c b/webcit/webserver.c
index 8f7a9c908..a72b48a8d 100644
--- a/webcit/webserver.c
+++ b/webcit/webserver.c
@@ -12,10 +12,10 @@
#include "webserver.h"
#include "modules_init.h"
-extern int msock; /* master listening socket */
-extern char static_icon_dir[PATH_MAX]; /* where should we find our mime icons */
-int is_https = 0; /* Nonzero if I am an HTTPS service */
-int follow_xff = 0; /* Follow X-Forwarded-For: header? */
+extern int msock; /* master listening socket */
+extern char static_icon_dir[PATH_MAX]; /* where should we find our mime icons */
+int is_https = 0; /* Nonzero if I am an HTTPS service */
+int follow_xff = 0; /* Follow X-Forwarded-For: header? */
int DisableGzip = 0;
char *default_landing_page = NULL;
extern pthread_mutex_t SessionListMutex;
@@ -30,18 +30,21 @@ extern void webcit_calc_dirs_n_files(int relh, const char *basedir, int home, ch
extern void worker_entry(void);
extern void drop_root(uid_t UID);
-char socket_dir[PATH_MAX]; /* where to talk to our citadel server */
-char *server_cookie = NULL; /* our Cookie connection to the client */
-int http_port = PORT_NUM; /* Port to listen on */
-int running_as_daemon = 0; /* should we deamonize on startup? */
+char socket_dir[PATH_MAX]; /* where to talk to our citadel server */
+char *server_cookie = NULL; /* our Cookie connection to the client */
+int http_port = PORT_NUM; /* Port to listen on */
+int running_as_daemon = 0; /* should we deamonize on startup? */
char *ctdl_dir = DEFAULT_CTDLDIR; /* Directory where Citadel Server is running */
/* #define DBG_PRINNT_HOOKS_AT_START */
#ifdef DBG_PRINNT_HOOKS_AT_START
extern HashList *HandlerHash;
const char foobuf[32];
-const char *nix(void *vptr) {snprintf(foobuf, 32, "%0x", (long) vptr); return foobuf;}
-#endif
+const char *nix(void *vptr) {
+ snprintf(foobuf, 32, "%0x", (long) vptr);
+ return foobuf;
+}
+#endif
extern int verbose;
extern int dbg_analyze_msg;
extern int dbg_backtrace_template_errors;
@@ -57,13 +60,13 @@ void LoadMimeBlacklist(void);
*/
int main(int argc, char **argv) {
uid_t UID = -1;
- pthread_t SessThread; /* Thread descriptor */
- pthread_attr_t attr; /* Thread attributes */
- int a; /* General-purpose variable */
- char ip_addr[256]="*";
- int relh=0;
- int home=0;
- char relhome[PATH_MAX]="";
+ pthread_t SessThread; /* Thread descriptor */
+ pthread_attr_t attr; /* Thread attributes */
+ int a; /* General-purpose variable */
+ char ip_addr[256] = "*";
+ int relh = 0;
+ int home = 0;
+ char relhome[PATH_MAX] = "";
char webcitdir[PATH_MAX] = DATADIR;
char *pidfile = NULL;
char *hdir;
@@ -77,14 +80,15 @@ int main(int argc, char **argv) {
start_modules();
#ifdef DBG_PRINNT_HOOKS_AT_START
+
/* dbg_PrintHash(HandlerHash, nix, NULL);*/
#endif
/* Ensure that we are linked to the correct version of libcitadel */
if (libcitadel_version_number() < LIBCITADEL_VERSION_NUMBER) {
- fprintf(stderr, " You are running libcitadel version %d\n", libcitadel_version_number() );
- fprintf(stderr, "WebCit was compiled against version %d\n", LIBCITADEL_VERSION_NUMBER );
- return(1);
+ fprintf(stderr, " You are running libcitadel version %d\n", libcitadel_version_number());
+ fprintf(stderr, "WebCit was compiled against version %d\n", LIBCITADEL_VERSION_NUMBER);
+ return (1);
}
strcpy(uds_listen_path, "");
@@ -101,14 +105,14 @@ int main(int argc, char **argv) {
break;
case 'h':
hdir = strdup(optarg);
- relh=hdir[0]!='/';
+ relh = hdir[0] != '/';
if (!relh) {
safestrncpy(webcitdir, hdir, sizeof webcitdir);
}
else {
safestrncpy(relhome, relhome, sizeof relhome);
}
- home=1;
+ home = 1;
break;
case 'd':
running_as_daemon = 1;
@@ -120,7 +124,7 @@ int main(int argc, char **argv) {
case 'g':
default_landing_page = strdup(optarg);
break;
- case 'B': /* deprecated */
+ case 'B': /* deprecated */
break;
case 'i':
safestrncpy(ip_addr, optarg, sizeof ip_addr);
@@ -136,8 +140,8 @@ int main(int argc, char **argv) {
break;
case 'T':
LoadTemplates = atoi(optarg);
- dbg_analyze_msg = (LoadTemplates & (1<<1)) != 0;
- dbg_backtrace_template_errors = (LoadTemplates & (1<<2)) != 0;
+ dbg_analyze_msg = (LoadTemplates & (1 << 1)) != 0;
+ dbg_backtrace_template_errors = (LoadTemplates & (1 << 2)) != 0;
break;
case 'Z':
DisableGzip = 1;
@@ -152,7 +156,7 @@ int main(int argc, char **argv) {
server_cookie = malloc(256);
if (server_cookie != NULL) {
safestrncpy(server_cookie, "Set-cookie: wcserver=", 256);
- if (gethostname (&server_cookie[strlen(server_cookie)], 200) != 0) {
+ if (gethostname(&server_cookie[strlen(server_cookie)], 200) != 0) {
syslog(LOG_INFO, "gethostname: %s", strerror(errno));
free(server_cookie);
}
@@ -173,7 +177,7 @@ int main(int argc, char **argv) {
I18nDumpFile = optarg;
break;
case 'v':
- verbose=1;
+ verbose = 1;
break;
default:
fprintf(stderr, "usage:\nwebcit "
@@ -181,9 +185,7 @@ int main(int argc, char **argv) {
"[-c] [-f] "
"[-T Templatedebuglevel] "
"[-d] [-Z] [-G i18ndumpfile] "
- "[-u uid] [-h homedirectory] "
- "[-D daemonizepid] [-v] "
- "[-g defaultlandingpage] "
+ "[-u uid] [-h homedirectory] " "[-D daemonizepid] [-v] " "[-g defaultlandingpage] "
#ifdef HAVE_OPENSSL
"[-s] [-S cipher_suites]"
#endif
@@ -193,10 +195,7 @@ int main(int argc, char **argv) {
/* Start the logger */
setlogmask(LOG_UPTO(max_log_level));
- openlog("webcit",
- ( running_as_daemon ? (LOG_PID) : (LOG_PID | LOG_PERROR) ),
- LOG_DAEMON
- );
+ openlog("webcit", (running_as_daemon ? (LOG_PID) : (LOG_PID | LOG_PERROR)), LOG_DAEMON);
while (optind < argc) {
ctdl_dir = strdup(argv[optind]);
@@ -242,14 +241,14 @@ int main(int argc, char **argv) {
if (DumpTemplateI18NStrings) {
FILE *fd;
StrBufAppendBufPlain(I18nDump, HKEY("}\n"), 0);
- if (StrLength(I18nDump) < 50) {
+ if (StrLength(I18nDump) < 50) {
syslog(LOG_INFO, "*******************************************************************\n");
syslog(LOG_INFO, "* No strings found in templates! Are you sure they're there? *\n");
syslog(LOG_INFO, "*******************************************************************\n");
return -1;
}
fd = fopen(I18nDumpFile, "w");
- if (fd == NULL) {
+ if (fd == NULL) {
syslog(LOG_INFO, "***********************************************\n");
syslog(LOG_INFO, "* unable to open I18N dumpfile [%s] *\n", I18nDumpFile);
syslog(LOG_INFO, "***********************************************\n");
@@ -263,9 +262,9 @@ int main(int argc, char **argv) {
/* Tell libical to return an error instead of aborting if it sees badly formed iCalendar data. */
#ifdef LIBICAL_ICAL_EXPORT // cheap and sleazy way to detect libical >=2.0
- icalerror_set_errors_are_fatal(0);
+ icalerror_set_errors_are_fatal(0);
#else
- icalerror_errors_are_fatal = 0;
+ icalerror_errors_are_fatal = 0;
#endif
/* Use our own prefix on tzid's generated from system tzdata */
@@ -307,8 +306,7 @@ int main(int argc, char **argv) {
syslog(LOG_DEBUG, "Attempting to bind to port %d...", http_port);
msock = webcit_tcp_server(ip_addr, http_port, LISTEN_QUEUE_LENGTH);
}
- if (msock < 0)
- {
+ if (msock < 0) {
ShutDownWebcit();
return -msock;
}
@@ -336,10 +334,3 @@ int main(int argc, char **argv) {
ShutDownLibCitadel();
return 0;
}
-
-
-
-
-
-
-
diff --git a/webcit/webserver.h b/webcit/webserver.h
index dc142d0d1..f8e966bd7 100644
--- a/webcit/webserver.h
+++ b/webcit/webserver.h
@@ -1,3 +1,4 @@
+
/*
* Copyright (c) 1996-2013 by the citadel.org team
*
@@ -11,16 +12,14 @@
*/
-extern char *static_dirs[PATH_MAX]; /**< Web representation */
+extern char *static_dirs[PATH_MAX]; /**< Web representation */
extern int ndirs;
extern char socket_dir[PATH_MAX];
extern char *default_landing_page;
-int ClientGetLine(ParsedHttpHdrs *Hdr, StrBuf *Target);
-int client_read_to(ParsedHttpHdrs *Hdr, StrBuf *Target, int bytes, int timeout);
+int ClientGetLine(ParsedHttpHdrs * Hdr, StrBuf * Target);
+int client_read_to(ParsedHttpHdrs * Hdr, StrBuf * Target, int bytes, int timeout);
void wc_backtrace(long LogLevel);
void ShutDownWebcit(void);
void shutdown_ssl(void);
-
-
diff --git a/webcit/who.c b/webcit/who.c
index dee492caf..3cc798d65 100644
--- a/webcit/who.c
+++ b/webcit/who.c
@@ -17,9 +17,8 @@ typedef struct UserStateStruct {
int SessionCount;
} UserStateStruct;
-void DestroyUserStruct(void *vUser)
-{
- UserStateStruct *User = (UserStateStruct*) vUser;
+void DestroyUserStruct(void *vUser) {
+ UserStateStruct *User = (UserStateStruct *) vUser;
FreeStrBuf(&User->UserName);
FreeStrBuf(&User->Room);
FreeStrBuf(&User->Host);
@@ -29,20 +28,17 @@ void DestroyUserStruct(void *vUser)
free(User);
}
-int CompareUserStruct(const void *VUser1, const void *VUser2)
-{
- const UserStateStruct *User1 = (UserStateStruct*) GetSearchPayload(VUser1);
- const UserStateStruct *User2 = (UserStateStruct*) GetSearchPayload(VUser2);
-
+int CompareUserStruct(const void *VUser1, const void *VUser2) {
+ const UserStateStruct *User1 = (UserStateStruct *) GetSearchPayload(VUser1);
+ const UserStateStruct *User2 = (UserStateStruct *) GetSearchPayload(VUser2);
+
if (User1->Idle != User2->Idle)
return User1->Idle > User2->Idle;
- return strcasecmp(ChrPtr(User1->UserName),
- ChrPtr(User2->UserName));
+ return strcasecmp(ChrPtr(User1->UserName), ChrPtr(User2->UserName));
}
-int GetWholistSection(HashList *List, time_t now, StrBuf *Buf, const char *FilterName, long FNLen)
-{
+int GetWholistSection(HashList * List, time_t now, StrBuf * Buf, const char *FilterName, long FNLen) {
UserStateStruct *User, *OldUser;
void *VOldUser;
size_t BufLen;
@@ -51,19 +47,16 @@ int GetWholistSection(HashList *List, time_t now, StrBuf *Buf, const char *Filte
serv_puts("RWHO");
StrBuf_ServGetln(Buf);
if (GetServerStatus(Buf, NULL) == 1) {
- while (BufLen = StrBuf_ServGetln(Buf),
- ((BufLen >= 0) &&
- ((BufLen != 3) || strcmp(ChrPtr(Buf), "000"))))
- {
+ while (BufLen = StrBuf_ServGetln(Buf), ((BufLen >= 0) && ((BufLen != 3) || strcmp(ChrPtr(Buf), "000")))) {
if (BufLen <= 0)
- continue;
+ continue;
Pos = NULL;
- User = (UserStateStruct*) malloc(sizeof(UserStateStruct));
+ User = (UserStateStruct *) malloc(sizeof(UserStateStruct));
User->Session = StrBufExtractNext_int(Buf, &Pos, '|');
User->UserName = NewStrBufPlain(NULL, BufLen);
StrBufExtract_NextToken(User->UserName, Buf, &Pos, '|');
-
+
User->Room = NewStrBufPlain(NULL, BufLen);
StrBufExtract_NextToken(User->Room, Buf, &Pos, '|');
@@ -81,40 +74,32 @@ int GetWholistSection(HashList *List, time_t now, StrBuf *Buf, const char *Filte
User->RealHost = NewStrBufPlain(NULL, BufLen);
StrBufExtract_NextToken(User->RealHost, Buf, &Pos, '|');
-
+
User->Idle = (now - User->LastActive) > 900L;
User->IdleSince = (now - User->LastActive) / 60;
User->SessionCount = 1;
if (FilterName == NULL) {
- if (GetHash(List,
- SKEY(User->UserName),
- &VOldUser)) {
+ if (GetHash(List, SKEY(User->UserName), &VOldUser)) {
OldUser = VOldUser;
OldUser->SessionCount++;
if (!User->Idle) {
- if (User->Session == WC->ctdl_pid)
+ if (User->Session == WC->ctdl_pid)
OldUser->Session = User->Session;
-
+
OldUser->Idle = User->Idle;
OldUser->LastActive = User->LastActive;
}
DestroyUserStruct(User);
}
else
- Put(List,
- SKEY(User->UserName),
- User, DestroyUserStruct);
+ Put(List, SKEY(User->UserName), User, DestroyUserStruct);
}
else {
- if (strcmp(FilterName, ChrPtr(User->UserName)) == 0)
- {
- Put(List,
- SKEY(User->UserName),
- User, DestroyUserStruct);
+ if (strcmp(FilterName, ChrPtr(User->UserName)) == 0) {
+ Put(List, SKEY(User->UserName), User, DestroyUserStruct);
}
- else
- {
+ else {
DestroyUserStruct(User);
}
}
@@ -131,8 +116,7 @@ int GetWholistSection(HashList *List, time_t now, StrBuf *Buf, const char *Filte
/*
* end session
*/
-void terminate_session(void)
-{
+void terminate_session(void) {
char buf[SIZ];
serv_printf("TERM %s", bstr("which_session"));
@@ -146,30 +130,27 @@ void _terminate_session(void) {
terminate_session();
}
-HashList *GetWholistHash(StrBuf *Target, WCTemplputParams *TP)
-
-{
+HashList *GetWholistHash(StrBuf * Target, WCTemplputParams * TP) {
const char *ch = NULL;
int HashUniq = 1;
long len;
StrBuf *FilterNameStr = NULL;
StrBuf *Buf;
HashList *List;
- time_t now;
+ time_t now;
Buf = NewStrBuf();
serv_puts("TIME");
StrBuf_ServGetln(Buf);
- if (GetServerStatus(Buf, NULL) == 2) {
+ if (GetServerStatus(Buf, NULL) == 2) {
const char *pos = ChrPtr(Buf) + 4;
now = StrBufExtractNext_long(Buf, &pos, '|');
}
else {
now = time(NULL);
}
- if (HaveTemplateTokenString(NULL, TP, 2, &ch, &len))
- {
+ if (HaveTemplateTokenString(NULL, TP, 2, &ch, &len)) {
FilterNameStr = NewStrBuf();
GetTemplateTokenString(FilterNameStr, TP, 2, &ch, &len);
HashUniq = 0;
@@ -183,124 +164,105 @@ HashList *GetWholistHash(StrBuf *Target, WCTemplputParams *TP)
}
-void DeleteWholistHash(HashList **KillMe)
-{
+void DeleteWholistHash(HashList ** KillMe) {
DeleteHash(KillMe);
}
-void tmplput_who_username(StrBuf *Target, WCTemplputParams *TP)
-{
- UserStateStruct *User = (UserStateStruct*) CTX(CTX_WHO);
+void tmplput_who_username(StrBuf * Target, WCTemplputParams * TP) {
+ UserStateStruct *User = (UserStateStruct *) CTX(CTX_WHO);
StrBufAppendTemplate(Target, TP, User->UserName, 0);
}
-void tmplput_who_UserAgent(StrBuf *Target, WCTemplputParams *TP)
-{
- UserStateStruct *User = (UserStateStruct*) CTX(CTX_WHO);
+void tmplput_who_UserAgent(StrBuf * Target, WCTemplputParams * TP) {
+ UserStateStruct *User = (UserStateStruct *) CTX(CTX_WHO);
StrBufAppendTemplate(Target, TP, User->UserAgent, 0);
}
-void tmplput_who_room(StrBuf *Target, WCTemplputParams *TP)
-{
- UserStateStruct *User = (UserStateStruct*) CTX(CTX_WHO);
+void tmplput_who_room(StrBuf * Target, WCTemplputParams * TP) {
+ UserStateStruct *User = (UserStateStruct *) CTX(CTX_WHO);
StrBufAppendTemplate(Target, TP, User->Room, 0);
}
-void tmplput_who_host(StrBuf *Target, WCTemplputParams *TP)
-{
- UserStateStruct *User = (UserStateStruct*) CTX(CTX_WHO);
+void tmplput_who_host(StrBuf * Target, WCTemplputParams * TP) {
+ UserStateStruct *User = (UserStateStruct *) CTX(CTX_WHO);
StrBufAppendTemplate(Target, TP, User->Host, 0);
}
-void tmplput_who_realroom(StrBuf *Target, WCTemplputParams *TP)
-{
- UserStateStruct *User = (UserStateStruct*) CTX(CTX_WHO);
+void tmplput_who_realroom(StrBuf * Target, WCTemplputParams * TP) {
+ UserStateStruct *User = (UserStateStruct *) CTX(CTX_WHO);
StrBufAppendTemplate(Target, TP, User->RealRoom, 0);
}
-int conditional_who_realroom(StrBuf *Target, WCTemplputParams *TP)
-{
- UserStateStruct *User = (UserStateStruct*) CTX(CTX_WHO);
+int conditional_who_realroom(StrBuf * Target, WCTemplputParams * TP) {
+ UserStateStruct *User = (UserStateStruct *) CTX(CTX_WHO);
return StrLength(User->RealRoom) > 0;
}
-void tmplput_who_realhost(StrBuf *Target, WCTemplputParams *TP)
-{
- UserStateStruct *User = (UserStateStruct*) CTX(CTX_WHO);
+void tmplput_who_realhost(StrBuf * Target, WCTemplputParams * TP) {
+ UserStateStruct *User = (UserStateStruct *) CTX(CTX_WHO);
StrBufAppendTemplate(Target, TP, User->RealHost, 0);
}
-int conditional_who_realhost(StrBuf *Target, WCTemplputParams *TP)
-{
- UserStateStruct *User = (UserStateStruct*) CTX(CTX_WHO);
+int conditional_who_realhost(StrBuf * Target, WCTemplputParams * TP) {
+ UserStateStruct *User = (UserStateStruct *) CTX(CTX_WHO);
return StrLength(User->RealHost) > 0;
}
-void tmplput_who_lastactive(StrBuf *Target, WCTemplputParams *TP)
-{
- UserStateStruct *User = (UserStateStruct*) CTX(CTX_WHO);
+void tmplput_who_lastactive(StrBuf * Target, WCTemplputParams * TP) {
+ UserStateStruct *User = (UserStateStruct *) CTX(CTX_WHO);
StrBufAppendPrintf(Target, "%d", User->LastActive);
}
-void tmplput_who_idlesince(StrBuf *Target, WCTemplputParams *TP)
-{
- UserStateStruct *User = (UserStateStruct*) CTX(CTX_WHO);
+void tmplput_who_idlesince(StrBuf * Target, WCTemplputParams * TP) {
+ UserStateStruct *User = (UserStateStruct *) CTX(CTX_WHO);
StrBufAppendPrintf(Target, "%d", User->IdleSince);
}
-void tmplput_who_session(StrBuf *Target, WCTemplputParams *TP)
-{
- UserStateStruct *User = (UserStateStruct*) CTX(CTX_WHO);
+void tmplput_who_session(StrBuf * Target, WCTemplputParams * TP) {
+ UserStateStruct *User = (UserStateStruct *) CTX(CTX_WHO);
StrBufAppendPrintf(Target, "%d", User->Session);
}
-int conditional_who_idle(StrBuf *Target, WCTemplputParams *TP)
-{
- UserStateStruct *User = (UserStateStruct*) CTX(CTX_WHO);
+int conditional_who_idle(StrBuf * Target, WCTemplputParams * TP) {
+ UserStateStruct *User = (UserStateStruct *) CTX(CTX_WHO);
return User->Idle;
}
-int conditional_who_nsessions(StrBuf *Target, WCTemplputParams *TP)
-{
- UserStateStruct *User = (UserStateStruct*) CTX(CTX_WHO);
+int conditional_who_nsessions(StrBuf * Target, WCTemplputParams * TP) {
+ UserStateStruct *User = (UserStateStruct *) CTX(CTX_WHO);
return User->SessionCount;
}
-void tmplput_who_nsessions(StrBuf *Target, WCTemplputParams *TP)
-{
- UserStateStruct *User = (UserStateStruct*) CTX(CTX_WHO);
+void tmplput_who_nsessions(StrBuf * Target, WCTemplputParams * TP) {
+ UserStateStruct *User = (UserStateStruct *) CTX(CTX_WHO);
StrBufAppendPrintf(Target, "%d", User->SessionCount);
}
-int conditional_who_isme(StrBuf *Target, WCTemplputParams *TP)
-{
- UserStateStruct *User = (UserStateStruct*) CTX(CTX_WHO);
+int conditional_who_isme(StrBuf * Target, WCTemplputParams * TP) {
+ UserStateStruct *User = (UserStateStruct *) CTX(CTX_WHO);
return (User->Session == WC->ctdl_pid);
}
-void
-InitModule_WHO
-(void)
-{
+void InitModule_WHO(void) {
RegisterCTX(CTX_WHO);
WebcitAddUrlHandler(HKEY("terminate_session"), "", 0, _terminate_session, 0);
RegisterIterator("WHOLIST", 1, NULL, GetWholistHash, NULL, DeleteWholistHash, CTX_WHO, CTX_NONE, IT_NOFLAG);
- RegisterNamespace("WHO:NAME", 0, 1, tmplput_who_username, NULL, CTX_WHO);
- RegisterNamespace("WHO:USERAGENT", 0, 1, tmplput_who_UserAgent, NULL, CTX_WHO);
- RegisterNamespace("WHO:ROOM", 0, 1, tmplput_who_room, NULL, CTX_WHO);
- RegisterNamespace("WHO:HOST", 0, 1, tmplput_who_host, NULL, CTX_WHO);
- RegisterNamespace("WHO:REALROOM", 0, 1, tmplput_who_realroom, NULL, CTX_WHO);
- RegisterNamespace("WHO:REALHOST", 0, 1, tmplput_who_realhost, NULL, CTX_WHO);
- RegisterNamespace("WHO:LASTACTIVE", 0, 1, tmplput_who_lastactive, NULL, CTX_WHO);
- RegisterNamespace("WHO:IDLESINCE", 0, 1, tmplput_who_idlesince, NULL, CTX_WHO);
- RegisterNamespace("WHO:SESSION", 0, 1, tmplput_who_session, NULL, CTX_WHO);
- RegisterNamespace("WHO:NSESSIONS", 0, 1, tmplput_who_nsessions, NULL, CTX_WHO);
- RegisterNamespace("WHO:NSESSIONS", 0, 1, tmplput_who_nsessions, NULL, CTX_WHO);
-
- RegisterConditional("WHO:IDLE", 1, conditional_who_idle, CTX_WHO);
+ RegisterNamespace("WHO:NAME", 0, 1, tmplput_who_username, NULL, CTX_WHO);
+ RegisterNamespace("WHO:USERAGENT", 0, 1, tmplput_who_UserAgent, NULL, CTX_WHO);
+ RegisterNamespace("WHO:ROOM", 0, 1, tmplput_who_room, NULL, CTX_WHO);
+ RegisterNamespace("WHO:HOST", 0, 1, tmplput_who_host, NULL, CTX_WHO);
+ RegisterNamespace("WHO:REALROOM", 0, 1, tmplput_who_realroom, NULL, CTX_WHO);
+ RegisterNamespace("WHO:REALHOST", 0, 1, tmplput_who_realhost, NULL, CTX_WHO);
+ RegisterNamespace("WHO:LASTACTIVE", 0, 1, tmplput_who_lastactive, NULL, CTX_WHO);
+ RegisterNamespace("WHO:IDLESINCE", 0, 1, tmplput_who_idlesince, NULL, CTX_WHO);
+ RegisterNamespace("WHO:SESSION", 0, 1, tmplput_who_session, NULL, CTX_WHO);
+ RegisterNamespace("WHO:NSESSIONS", 0, 1, tmplput_who_nsessions, NULL, CTX_WHO);
+ RegisterNamespace("WHO:NSESSIONS", 0, 1, tmplput_who_nsessions, NULL, CTX_WHO);
+
+ RegisterConditional("WHO:IDLE", 1, conditional_who_idle, CTX_WHO);
RegisterConditional("WHO:NSESSIONS", 1, conditional_who_nsessions, CTX_WHO);
- RegisterConditional("WHO:ISME", 1, conditional_who_isme, CTX_WHO);
- RegisterConditional("WHO:REALROOM", 1, conditional_who_realroom, CTX_WHO);
- RegisterConditional("WHO:REALHOST", 1, conditional_who_realhost, CTX_WHO);
+ RegisterConditional("WHO:ISME", 1, conditional_who_isme, CTX_WHO);
+ RegisterConditional("WHO:REALROOM", 1, conditional_who_realroom, CTX_WHO);
+ RegisterConditional("WHO:REALHOST", 1, conditional_who_realhost, CTX_WHO);
}
diff --git a/webcit/wiki.c b/webcit/wiki.c
index 390bf3cbe..c4b5736cc 100644
--- a/webcit/wiki.c
+++ b/webcit/wiki.c
@@ -1,3 +1,4 @@
+
/*
* Functions pertaining to rooms with a wiki view
*
@@ -18,8 +19,7 @@
/*
* Convert a string to something suitable as a wiki index
*/
-void str_wiki_index(StrBuf *s)
-{
+void str_wiki_index(StrBuf * s) {
StrBufSanitizeAscii(s, '_');
StrBufLowerCase(s);
}
@@ -30,14 +30,13 @@ void str_wiki_index(StrBuf *s)
* "rev" may be set to an empty string to display the current version.
* "do_revert" may be set to nonzero to perform a reversion to the specified version.
*/
-void display_wiki_page_backend(StrBuf *pagename, char *rev, int do_revert)
-{
+void display_wiki_page_backend(StrBuf * pagename, char *rev, int do_revert) {
const StrBuf *Mime;
long msgnum = (-1L);
char buf[256];
if (WC->CurRoom.view != VIEW_WIKI) {
- wc_printf(_("'%s' is not a Wiki room."), ChrPtr(WC->CurRoom.name) );
+ wc_printf(_("'%s' is not a Wiki room."), ChrPtr(WC->CurRoom.name));
return;
}
@@ -49,7 +48,7 @@ void display_wiki_page_backend(StrBuf *pagename, char *rev, int do_revert)
if ((rev != NULL) && (strlen(rev) > 0)) {
/* read an older revision */
- serv_printf("WIKI rev|%s|%s|%s", ChrPtr(pagename), rev, (do_revert ? "revert" : "fetch") );
+ serv_printf("WIKI rev|%s|%s|%s", ChrPtr(pagename), rev, (do_revert ? "revert" : "fetch"));
serv_getln(buf, sizeof buf);
if (buf[0] == '2') {
msgnum = extract_long(&buf[4], 0);
@@ -72,8 +71,7 @@ void display_wiki_page_backend(StrBuf *pagename, char *rev, int do_revert)
/*
* Display a specific page from a wiki room
*/
-void display_wiki_page(void)
-{
+void display_wiki_page(void) {
StrBuf *pagename;
char rev[128];
int do_revert = 0;
@@ -91,8 +89,7 @@ void display_wiki_page(void)
/*
* Display the revision history for a wiki page (template callback)
*/
-void tmplput_display_wiki_history(StrBuf *Target, WCTemplputParams *TP)
-{
+void tmplput_display_wiki_history(StrBuf * Target, WCTemplputParams * TP) {
StrBuf *pagename;
StrBuf *Buf;
int row = 0;
@@ -116,13 +113,13 @@ void tmplput_display_wiki_history(StrBuf *Target, WCTemplputParams *TP)
wc_printf("%s ", _("Date"));
wc_printf("%s ", _("Author"));
- while((StrBuf_ServGetln(Buf) >= 0) && strcmp(ChrPtr(Buf), "000")) {
+ while ((StrBuf_ServGetln(Buf) >= 0) && strcmp(ChrPtr(Buf), "000")) {
rev_date = extract_long(ChrPtr(Buf), 1);
webcit_fmt_date(rev_date_displayed, sizeof rev_date_displayed, rev_date, DATEFMT_FULL);
StrBufExtract_token(author, Buf, 2, '|');
- wc_printf("", ((row%2) ? "#FFFFFF" : "#DDDDDD"));
+ wc_printf(" ", ((row % 2) ? "#FFFFFF" : "#DDDDDD"));
wc_printf("%s ", rev_date_displayed);
wc_printf("CurRoom.name));
+ wc_printf("?go=");
+ urlescputs(ChrPtr(WC->CurRoom.name));
wc_printf("\">%s ", _("(show)"));
wc_printf("(%s) ", _("Current version"));
}
else {
- wc_printf("CurRoom.name));
+ wc_printf(" CurRoom.name));
wc_printf("\">%s ", _("(show)"));
- wc_printf("%s ",
- bstr("page"),
- ChrPtr(rev_uuid),
- _("(revert)")
- );
+ wc_printf
+ ("%s ",
+ bstr("page"), ChrPtr(rev_uuid), _("(revert)")
+ );
}
wc_printf(" \n");
@@ -180,8 +176,7 @@ void tmplput_display_wiki_history(StrBuf *Target, WCTemplputParams *TP)
/*
* Display the revision history for a wiki page
*/
-void display_wiki_history(void)
-{
+void display_wiki_history(void) {
output_headers(1, 1, 1, 0, 0, 0);
do_template("wiki_history");
wDumpContent(1);
@@ -191,8 +186,7 @@ void display_wiki_history(void)
/*
* Display a list of all pages in a Wiki room (template callback)
*/
-void tmplput_display_wiki_pagelist(StrBuf *Target, WCTemplputParams *TP)
-{
+void tmplput_display_wiki_pagelist(StrBuf * Target, WCTemplputParams * TP) {
StrBuf *Buf;
int row = 0;
@@ -200,7 +194,7 @@ void tmplput_display_wiki_pagelist(StrBuf *Target, WCTemplputParams *TP)
serv_printf("MSGS SEARCH|%s||4", bstr("query")); /* search-reduced list */
}
else {
- serv_printf("MSGS ALL|||4"); /* full list */
+ serv_printf("MSGS ALL|||4"); /* full list */
}
Buf = NewStrBuf();
@@ -211,11 +205,11 @@ void tmplput_display_wiki_pagelist(StrBuf *Target, WCTemplputParams *TP)
wc_printf("");
wc_printf("%s ", _("Page title"));
- while((StrBuf_ServGetln(Buf) >= 0) && strcmp(ChrPtr(Buf), "000")) {
+ while ((StrBuf_ServGetln(Buf) >= 0) && strcmp(ChrPtr(Buf), "000")) {
StrBufExtract_token(pagetitle, Buf, 1, '|');
- if (!bmstrcasestr((char *)ChrPtr(pagetitle), "_HISTORY_")) { /* no history pages */
- wc_printf("", ((row%2) ? "#FFFFFF" : "#DDDDDD"));
+ if (!bmstrcasestr((char *) ChrPtr(pagetitle), "_HISTORY_")) { /* no history pages */
+ wc_printf(" ", ((row % 2) ? "#FFFFFF" : "#DDDDDD"));
wc_printf("");
@@ -236,16 +230,14 @@ void tmplput_display_wiki_pagelist(StrBuf *Target, WCTemplputParams *TP)
/*
* Display a list of all pages in a Wiki room. Search requests in a Wiki room also go here.
*/
-void display_wiki_pagelist(void)
-{
+void display_wiki_pagelist(void) {
output_headers(1, 1, 1, 0, 0, 0);
do_template("wiki_pagelist");
wDumpContent(1);
}
-int wiki_Cleanup(void **ViewSpecific)
-{
+int wiki_Cleanup(void **ViewSpecific) {
StrBuf *pagename;
pagename = NewStrBufDup(sbstr("page"));
display_wiki_page_backend(pagename, "", 0);
@@ -254,8 +246,7 @@ int wiki_Cleanup(void **ViewSpecific)
}
-int ConditionalHaveWikiPage(StrBuf *Target, WCTemplputParams *TP)
-{
+int ConditionalHaveWikiPage(StrBuf * Target, WCTemplputParams * TP) {
const char *page;
const char *pch;
long len;
@@ -266,54 +257,34 @@ int ConditionalHaveWikiPage(StrBuf *Target, WCTemplputParams *TP)
}
-int ConditionalHavewikiType(StrBuf *Target, WCTemplputParams *TP)
-{
+int ConditionalHavewikiType(StrBuf * Target, WCTemplputParams * TP) {
const char *pch;
long len;
GetTemplateTokenString(Target, TP, 2, &pch, &len);
- return bmstrcasestr((char *)ChrPtr(WC->Hdr->HR.ReqLine), pch) != NULL;
+ return bmstrcasestr((char *) ChrPtr(WC->Hdr->HR.ReqLine), pch) != NULL;
}
-int wiki_PrintHeaderPage(SharedMessageStatus *Stat, void **ViewSpecific)
-{
+int wiki_PrintHeaderPage(SharedMessageStatus * Stat, void **ViewSpecific) {
/* this function was intentionaly left empty. */
return 0;
}
-int wiki_GetParamsGetServerCall(SharedMessageStatus *Stat,
- void **ViewSpecific,
- long oper,
- char *cmd,
- long len,
- char *filter,
- long flen)
-{
+int wiki_GetParamsGetServerCall(SharedMessageStatus * Stat,
+ void **ViewSpecific, long oper, char *cmd, long len, char *filter, long flen) {
if (oper == do_search)
display_wiki_pagelist();
- else
+ else
http_redirect("wiki?page=home");
return 300;
}
-void
-InitModule_WIKI
-(void)
-{
- RegisterReadLoopHandlerset(
- VIEW_WIKI,
- wiki_GetParamsGetServerCall,
- wiki_PrintHeaderPage,
- NULL,
- NULL,
- NULL,
- NULL,
- wiki_Cleanup,
- NULL
- );
+void InitModule_WIKI(void) {
+ RegisterReadLoopHandlerset(VIEW_WIKI,
+ wiki_GetParamsGetServerCall, wiki_PrintHeaderPage, NULL, NULL, NULL, NULL, wiki_Cleanup, NULL);
WebcitAddUrlHandler(HKEY("wiki"), "", 0, display_wiki_page, 0);
WebcitAddUrlHandler(HKEY("wiki_history"), "", 0, display_wiki_history, 0);
--
2.30.2