From a15ba5c1ede7c86a85d62ed5b539dcfc9f415bc1 Mon Sep 17 00:00:00 2001 From: Wilfried Goesgens Date: Sun, 24 Jul 2011 13:43:32 +0000 Subject: [PATCH] Fix lots of warnings all over the place, make inbound buffers of FMOUT const. --- webcit/auth.c | 13 ++-- webcit/bbsview_renderer.c | 2 +- webcit/blogview_renderer.c | 2 +- webcit/calendar.c | 3 +- webcit/calendar_tools.c | 2 - webcit/calendar_view.c | 10 +-- webcit/crypto.c | 10 +-- webcit/downloads.c | 4 +- webcit/event.c | 7 ++- webcit/gettext.c | 4 +- webcit/groupdav_get.c | 2 - webcit/groupdav_main.c | 4 +- webcit/marchlist.c | 4 +- webcit/messages.c | 25 ++++---- webcit/msg_renderers.c | 4 +- webcit/netconf.c | 4 +- webcit/notes.c | 6 +- webcit/roomlist.c | 6 +- webcit/roomops.c | 16 ++--- webcit/serv_func.c | 6 +- webcit/static.c | 124 ++++++++++++++++++++++++++++--------- webcit/subst.c | 39 +----------- webcit/tasks.c | 3 - webcit/vcard_edit.c | 17 ++--- webcit/webcit.c | 3 - webcit/webcit.h | 6 +- webcit/webserver.c | 3 - 27 files changed, 173 insertions(+), 156 deletions(-) diff --git a/webcit/auth.c b/webcit/auth.c index a5e357edf..656dfdc6f 100644 --- a/webcit/auth.c +++ b/webcit/auth.c @@ -658,7 +658,7 @@ void validate(void) int haveChar = 0; int haveNum = 0; int haveOther = 0; - int count = 0; + int haveLong = 0; pch = buf; while (!IsEmptyStr(pch)) { @@ -670,10 +670,13 @@ void validate(void) haveOther = 1; pch ++; } - count = pch - buf; - if (count > 7) - count = 0; - switch (count){ + if (pch - buf > 7) + haveLong = 1; + switch (haveLong + + haveChar + + haveNum + + haveOther) + { case 0: pch = _("very weak"); break; diff --git a/webcit/bbsview_renderer.c b/webcit/bbsview_renderer.c index 52edd1d34..fe0eb4fae 100644 --- a/webcit/bbsview_renderer.c +++ b/webcit/bbsview_renderer.c @@ -359,7 +359,7 @@ int bbsview_RenderView_or_Tail(SharedMessageStatus *Stat, wc_printf(_("Last")); } else { - wc_printf("%d", i + 1); // change to one-based for display + wc_printf("%d", i + 1); /* change to one-based for display */ } if (i == BBS->requested_page) { wc_printf("]"); diff --git a/webcit/blogview_renderer.c b/webcit/blogview_renderer.c index 2254b9c05..0a825327b 100644 --- a/webcit/blogview_renderer.c +++ b/webcit/blogview_renderer.c @@ -279,11 +279,11 @@ int blogview_render(SharedMessageStatus *Stat, void **ViewSpecific, long oper) * which they point are still owned by the hash list. */ if (num_blogposts > 0) { + int start_here = 0; /* Sort newest-to-oldest */ qsort(blogposts, num_blogposts, sizeof(void *), blogview_sortfunc); /* allow the user to select a starting point in the list */ - int start_here = 0; for (i=0; itop_level_id == firstp) { start_here = i; diff --git a/webcit/calendar.c b/webcit/calendar.c index 1a6f7fa9b..84493f90f 100644 --- a/webcit/calendar.c +++ b/webcit/calendar.c @@ -673,7 +673,6 @@ void load_ical_object(long msgnum, int unread, char mime_filename[256]; char mime_content_type[256]; char mime_disposition[256]; - int mime_length; char relevant_partnum[256]; char *relevant_source = NULL; int phase = 0; /* 0 = citadel headers, 1 = mime headers, 2 = body */ @@ -703,7 +702,7 @@ void load_ical_object(long msgnum, int unread, extract_token(mime_partnum, &bptr[5], 2, '|', sizeof mime_partnum); extract_token(mime_disposition, &bptr[5], 3, '|', sizeof mime_disposition); extract_token(mime_content_type, &bptr[5], 4, '|', sizeof mime_content_type); - mime_length = extract_int(&bptr[5], 5); + /* do we care? mime_length = */extract_int(&bptr[5], 5); if ( (!strcasecmp(mime_content_type, "text/calendar")) || (!strcasecmp(mime_content_type, "application/ics")) diff --git a/webcit/calendar_tools.c b/webcit/calendar_tools.c index b2c12afc7..b6dd7390c 100644 --- a/webcit/calendar_tools.c +++ b/webcit/calendar_tools.c @@ -53,7 +53,6 @@ void display_icaltimetype_as_webform(struct icaltimetype *t, char *prefix, int d int i; time_t now; struct tm tm_now; - int this_year; time_t tt; struct tm tm; int all_day_event = 0; @@ -64,7 +63,6 @@ void display_icaltimetype_as_webform(struct icaltimetype *t, char *prefix, int d now = time(NULL); localtime_r(&now, &tm_now); - this_year = tm_now.tm_year + 1900; if (t == NULL) return; if (t->is_date) all_day_event = 1; diff --git a/webcit/calendar_view.c b/webcit/calendar_view.c index 769cd2334..6cde0748e 100644 --- a/webcit/calendar_view.c +++ b/webcit/calendar_view.c @@ -424,7 +424,6 @@ void calendar_month_view_brief_events(time_t thetime, const char *daycolor) { icalproperty *e; struct icaltimetype t; disp_cal *Cal; - int month, day, year; int all_day_event = 0; char *timeformat; int time_format; @@ -435,9 +434,6 @@ void calendar_month_view_brief_events(time_t thetime, const char *daycolor) { else timeformat="%I:%M %p"; localtime_r(&thetime, &today_tm); - month = today_tm.tm_mon + 1; - day = today_tm.tm_mday; - year = today_tm.tm_year + 1900; Pos = GetNewHashPos(WCC->disp_cal_items, 0); while (GetNextHashPos(WCC->disp_cal_items, Pos, &hklen, &HashKey, &vCal)) { @@ -1186,9 +1182,11 @@ void calendar_day_view(int year, int month, int day) { wc_printf("
" "", +/* TODO: what have these been used for? (hour * extratimeline ), extratimeline, extrahourlabel, +*/ year, month, day, hour ); @@ -1211,9 +1209,11 @@ void calendar_day_view(int year, int month, int day) { wc_printf("
" "", +/*TODO: what have these been used for? gap + ((hour - daystart) * timeline ), timeline, hourlabel, +*/ year, month, day, hour ); @@ -1236,9 +1236,11 @@ void calendar_day_view(int year, int month, int day) { wc_printf("
" "", +/*TODO: what have these been used for? gap + ((hour - dayend - 1) * extratimeline ), extratimeline, extrahourlabel, +*/ year, month, day, hour ); diff --git a/webcit/crypto.c b/webcit/crypto.c index 2e8b3aac1..61c2366f9 100644 --- a/webcit/crypto.c +++ b/webcit/crypto.c @@ -58,7 +58,7 @@ void shutdown_ssl(void) */ void init_ssl(void) { - SSL_METHOD *ssl_method; + const SSL_METHOD *ssl_method; RSA *rsa=NULL; X509_REQ *req = NULL; X509 *cer = NULL; @@ -391,7 +391,7 @@ void init_ssl(void) * starts SSL/TLS encryption for the current session. */ int starttls(int sock) { - int retval, bits, alg_bits, r; + int retval, bits, alg_bits;/*r; */ SSL *newssl; pthread_setspecific(ThreadSSL, NULL); @@ -448,7 +448,7 @@ int starttls(int sock) { else { syslog(15, "SSL_accept success\n"); } - r = BIO_set_close(newssl->rbio, BIO_NOCLOSE); + /*r = */BIO_set_close(newssl->rbio, BIO_NOCLOSE); bits = SSL_CIPHER_get_bits(SSL_get_current_cipher(newssl), &alg_bits); syslog(15, "SSL/TLS using %s on %s (%d of %d bits)\n", SSL_CIPHER_get_name(SSL_get_current_cipher(newssl)), @@ -470,13 +470,13 @@ int starttls(int sock) { */ void endtls(void) { - SSL_CTX *ctx = NULL; + /*SSL_CTX *ctx;*/ if (THREADSSL == NULL) return; syslog(15, "Ending SSL/TLS\n"); SSL_shutdown(THREADSSL); - ctx = SSL_get_SSL_CTX(THREADSSL); + /*ctx = */SSL_get_SSL_CTX(THREADSSL); /* I don't think this is needed, and it crashes the server anyway * diff --git a/webcit/downloads.c b/webcit/downloads.c index fc06c379b..a130c6392 100644 --- a/webcit/downloads.c +++ b/webcit/downloads.c @@ -189,7 +189,7 @@ HashList* LoadFileList(StrBuf *Target, WCTemplputParams *TP) int sequence = 0; char buf[1024]; CompareFunc SortIt; - int HavePic; + int HavePic = 0; WCTemplputParams SubTP; memset(&SubTP, 0, sizeof(WCTemplputParams)); @@ -227,6 +227,8 @@ HashList* LoadFileList(StrBuf *Target, WCTemplputParams *TP) } Put(Files, SKEY(Entry->Filename), Entry, FreeFiles); } + if (HavePic) + putbstr("__HAVE_PIC", NewStrBufPlain(HKEY("1"))); SubTP.Filter.ContextType = CTX_FILELIST; SortIt = RetrieveSort(&SubTP, NULL, 0, HKEY("fileunsorted"), 0); if (SortIt != NULL) diff --git a/webcit/event.c b/webcit/event.c index 80c4f51eb..b0f41ca2d 100644 --- a/webcit/event.c +++ b/webcit/event.c @@ -44,7 +44,10 @@ void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum, char buf[SIZ]; int organizer_is_me = 0; int i, j = 0; + /************************************************************ + * Uncomment this to see the UID in calendar events for debugging int sequence = 0; + */ char weekday_labels[7][32]; char month_labels[12][32]; long weekstart = 0; @@ -157,10 +160,12 @@ void display_edit_individual_event(icalcomponent *supplied_vevent, long msgnum, /* Learn the sequence */ p = icalcomponent_get_first_property(vevent, ICAL_SEQUENCE_PROPERTY); + /************************************************************ + * Uncomment this to see the UID in calendar events for debugging if (p != NULL) { sequence = icalproperty_get_sequence(p); } - + */ /* Begin output */ output_headers(1, 1, 2, 0, 0, 0); wc_printf("
\n"); diff --git a/webcit/gettext.c b/webcit/gettext.c index 30a732588..62263c869 100644 --- a/webcit/gettext.c +++ b/webcit/gettext.c @@ -287,8 +287,6 @@ void initialize_locales(void) { int i; char buf[32]; char *language = NULL; - char *locale; - nLocales = 0; while (!IsEmptyStr(AvailLang[nLocales])) @@ -368,7 +366,7 @@ void initialize_locales(void) { } #ifdef ENABLE_NLS - locale = setlocale(LC_ALL, ""); + /*locale = */setlocale(LC_ALL, ""); syslog(9, "Message catalog directory: %s\n", bindtextdomain("webcit", LOCALEDIR"/locale")); syslog(9, "Text domain: %s\n", textdomain("webcit")); diff --git a/webcit/groupdav_get.c b/webcit/groupdav_get.c index 267f4bd6f..b99e7caaf 100644 --- a/webcit/groupdav_get.c +++ b/webcit/groupdav_get.c @@ -109,7 +109,6 @@ void groupdav_get(void) long dav_msgnum = (-1); char buf[1024]; int in_body = 0; - int found_content_type = 0; char *ptr; char *endptr; char *msgtext = NULL; @@ -185,7 +184,6 @@ void groupdav_get(void) /* We got it; a message is now arriving from the server. Read it in. */ in_body = 0; - found_content_type = 0; strcpy(charset, "UTF-8"); strcpy(content_type, "text/plain"); strcpy(date, ""); diff --git a/webcit/groupdav_main.c b/webcit/groupdav_main.c index 90de73b99..e673a38ff 100644 --- a/webcit/groupdav_main.c +++ b/webcit/groupdav_main.c @@ -328,7 +328,9 @@ void InitModule_GROUPDAV (void) { -// WebcitAddUrlHandler(HKEY("groupdav"), "", 0, groupdav_main, XHTTP_COMMANDS|COOKIEUNNEEDED|FORCE_SESSIONCLOSE); +/* + WebcitAddUrlHandler(HKEY("groupdav"), "", 0, groupdav_main, XHTTP_COMMANDS|COOKIEUNNEEDED|FORCE_SESSIONCLOSE); + */ RegisterDAVNamespace(HKEY("groupdav"), HKEY("GroupDAV"), groupdav_main, GroupdavDispatchREST, XHTTP_COMMANDS|COOKIEUNNEEDED|FORCE_SESSIONCLOSE); diff --git a/webcit/marchlist.c b/webcit/marchlist.c index 175f780e7..990c24fce 100644 --- a/webcit/marchlist.c +++ b/webcit/marchlist.c @@ -57,8 +57,6 @@ void remove_march(const StrBuf *aaa) char *pop_march(int desired_floor) { static char TheRoom[128]; - int TheFloor = 0; - int TheOrder = 32767; int TheWeight = 0; int weight; struct march *mptr = NULL; @@ -80,8 +78,10 @@ char *pop_march(int desired_floor) if (weight > TheWeight) { TheWeight = weight; strcpy(TheRoom, mptr->march_name); +/* TODOO: and now???? TheFloor = mptr->march_floor; TheOrder = mptr->march_order; +*/ } } return (TheRoom); diff --git a/webcit/messages.c b/webcit/messages.c index 63ab14c98..aede383fc 100644 --- a/webcit/messages.c +++ b/webcit/messages.c @@ -21,6 +21,7 @@ #include "webcit.h" #include "webserver.h" #include "groupdav.h" +#include "calendar.h" HashList *MsgHeaderHandler = NULL; HashList *MsgEvaluators = NULL; @@ -246,7 +247,7 @@ int read_message(StrBuf *Target, const char *tmpl, long tmpllen, long msgnum, co } -void +long HttpStatus(long CitadelStatus) { long httpstatus = 502; @@ -311,7 +312,7 @@ HttpStatus(long CitadelStatus) break; } - + return httpstatus; } /* @@ -733,7 +734,7 @@ void readloop(long oper, eCustomRoomRenderer ForceRenderer) GetHash(ReadLoopHandler, IKEY(WCC->CurRoom.view), &vViewMsg); } if (vViewMsg == NULL) { - return; // TODO: print message + return; /* TODO: print message */ } ViewMsg = (RoomRenderer*) vViewMsg; @@ -1282,7 +1283,6 @@ void remove_attachment(void) { void display_enter(void) { char buf[SIZ]; - long now; const StrBuf *display_name = NULL; int recipient_required = 0; int subject_required = 0; @@ -1290,8 +1290,7 @@ void display_enter(void) int is_anonymous = 0; wcsession *WCC = WC; int i = 0; - - now = time(NULL); + long replying_to; if (havebstr("force_room")) { gotoroom(sbstr("force_room")); @@ -1353,7 +1352,7 @@ void display_enter(void) * If the "replying_to" variable is set, it refers to a message * number from which we must extract some header fields... */ - long replying_to = lbstr("replying_to"); + replying_to = lbstr("replying_to"); if (replying_to > 0) { char wefw[1024] = ""; char msgn[256] = ""; @@ -1383,13 +1382,15 @@ void display_enter(void) } else if (!strncasecmp(buf, "wefw=", 5)) { + int rrtok; + int rrlen; safestrncpy(wefw, &buf[5], sizeof wefw); /* Trim down excessively long lists of thread references. We eliminate the * second one in the list so that the thread root remains intact. */ - int rrtok = num_tokens(wefw, '|'); - int rrlen = strlen(wefw); + rrtok = num_tokens(wefw, '|'); + rrlen = strlen(wefw); if ( ((rrtok >= 3) && (rrlen > 900)) || (rrtok > 10) ) { remove_token(wefw, 1, '|'); } @@ -1521,7 +1522,7 @@ void display_enter(void) if (havebstr("recp") && havebstr("cc" ) && havebstr("bcc" )) { - recipient_bad = 1; + recipient_bad = 1; /* TODO: and now????? */ } } else if (buf[0] != '2') { /* Any other error means that we cannot continue */ @@ -1593,13 +1594,9 @@ void move_msg(void) */ void confirm_move_msg(void) { - long msgid; char buf[SIZ]; char targ[SIZ]; - msgid = lbstr("msgid"); - - output_headers(1, 1, 2, 0, 0, 0); wc_printf("
\n"); wc_printf("

"); diff --git a/webcit/msg_renderers.c b/webcit/msg_renderers.c index ed58d93d5..a01e9e9b1 100644 --- a/webcit/msg_renderers.c +++ b/webcit/msg_renderers.c @@ -1418,9 +1418,9 @@ InitModule_MSGRENDERERS RegisterReadLoopHandlerset( VIEW_MAILBOX, mailview_GetParamsGetServerCall, - NULL, /// TODO: is this right? + NULL, /* TODO: is this right? */ ParseMessageListHeaders_Detail, - NULL, //// "" + NULL, mailview_RenderView_or_Tail, mailview_Cleanup); diff --git a/webcit/netconf.c b/webcit/netconf.c index 107328a7c..a62c96526 100644 --- a/webcit/netconf.c +++ b/webcit/netconf.c @@ -78,8 +78,8 @@ HashList *load_netconf(StrBuf *Target, WCTemplputParams *TP) HashList *Hash; char nnn[64]; char buf[SIZ]; - long len; int nUsed; + long len; NodeConf *Node; serv_puts("CONF getsys|application/x-citadel-ignet-config"); @@ -89,7 +89,7 @@ HashList *load_netconf(StrBuf *Target, WCTemplputParams *TP) Buf = NewStrBuf(); while ((len = StrBuf_ServGetln(Buf), - strcmp(ChrPtr(Buf), "000"))) { + (len != 3) || !strcmp(ChrPtr(Buf), "000"))) { Node = NewNode(Buf); if (Node == NULL) continue; diff --git a/webcit/notes.c b/webcit/notes.c index 63fce7f04..eb358369d 100644 --- a/webcit/notes.c +++ b/webcit/notes.c @@ -30,7 +30,6 @@ struct vnote *vnote_new_from_msg(long msgnum,int unread) char mime_filename[256]; char mime_content_type[256]; char mime_disposition[256]; - int mime_length; char relevant_partnum[256]; int phase = 0; /* 0 = citadel headers, 1 = mime headers, 2 = body */ char msg4_content_type[256] = ""; @@ -64,7 +63,6 @@ struct vnote *vnote_new_from_msg(long msgnum,int unread) extract_token(mime_partnum, &bptr[5], 2, '|', sizeof mime_partnum); extract_token(mime_disposition, &bptr[5], 3, '|', sizeof mime_disposition); extract_token(mime_content_type, &bptr[5], 4, '|', sizeof mime_content_type); - mime_length = extract_int(&bptr[5], 5); if (!strcasecmp(mime_content_type, "text/vnote")) { strcpy(relevant_partnum, mime_partnum); @@ -292,7 +290,7 @@ void ajax_update_note(void) { * * msgnum = Message number on the local server of the note to be displayed */ -////TODO: falscher hook +/*TODO: wrong hook */ int notes_LoadMsgFromServer(SharedMessageStatus *Stat, void **ViewSpecific, message_summary* Msg, @@ -402,7 +400,7 @@ void tmpl_vcard_put_bgcolor(StrBuf *Target, WCTemplputParams *TP) void tmpl_vcard_put_message(StrBuf *Target, WCTemplputParams *TP) { struct vnote *v = (struct vnote *) CTX; - StrEscAppend(Target, NULL, v->body, 0, 0); ///TODO? + StrEscAppend(Target, NULL, v->body, 0, 0); /*TODO?*/ } void tmpl_vcard_put_uid(StrBuf *Target, WCTemplputParams *TP) diff --git a/webcit/roomlist.c b/webcit/roomlist.c index c86a7f78d..d52351a23 100644 --- a/webcit/roomlist.c +++ b/webcit/roomlist.c @@ -607,8 +607,10 @@ int ConditionalRoomIsRESTSubRoom(StrBuf *Target, WCTemplputParams *TP) urlp = GetCount(WCC->Directory); delta = Folder->nRoomNameParts - urlp + 1; - syslog(0, "\n->%s: %ld - %ld ", ChrPtr(Folder->name), urlp, - Folder->nRoomNameParts); + syslog(0, "\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(0, "1\n"); diff --git a/webcit/roomops.c b/webcit/roomops.c index 5029030bb..ff18f8f69 100644 --- a/webcit/roomops.c +++ b/webcit/roomops.c @@ -260,7 +260,7 @@ void ParseGoto(folder *room, StrBuf *Line) memset(room, 0, sizeof(folder)); room->name = pBuf; - StrBufExtract_NextToken(room->name, Line, &Pos, '|'); // WC->CurRoom->name + StrBufExtract_NextToken(room->name, Line, &Pos, '|'); room->nNewMessages = StrBufExtractNext_long(Line, &Pos, '|'); if (room->nNewMessages > 0) @@ -270,14 +270,14 @@ void ParseGoto(folder *room, StrBuf *Line) room->ShowInfo = StrBufExtractNext_long(Line, &Pos, '|'); - room->QRFlags = StrBufExtractNext_long(Line, &Pos, '|'); //CurRoom->QRFlags + room->QRFlags = StrBufExtractNext_long(Line, &Pos, '|'); DBG_QR(room->QRFlags); room->HighestRead = StrBufExtractNext_long(Line, &Pos, '|'); room->LastMessageRead = StrBufExtractNext_long(Line, &Pos, '|'); - room->is_inbox = StrBufExtractNext_long(Line, &Pos, '|'); // is_mailbox + room->is_inbox = StrBufExtractNext_long(Line, &Pos, '|'); flag = StrBufExtractNext_long(Line, &Pos, '|'); if (WCC->is_aide || flag) { @@ -286,17 +286,17 @@ void ParseGoto(folder *room, StrBuf *Line) room->UsersNewMAilboxMessages = StrBufExtractNext_long(Line, &Pos, '|'); - room->floorid = StrBufExtractNext_int(Line, &Pos, '|'); // wc_floor + room->floorid = StrBufExtractNext_int(Line, &Pos, '|'); - room->view = StrBufExtractNext_long(Line, &Pos, '|'); // CurRoom->view + room->view = StrBufExtractNext_long(Line, &Pos, '|'); - room->defview = StrBufExtractNext_long(Line, &Pos, '|'); // CurRoom->defview + room->defview = StrBufExtractNext_long(Line, &Pos, '|'); flag = StrBufExtractNext_long(Line, &Pos, '|'); if (flag) - room->RAFlags |= UA_ISTRASH; // wc_is_trash + room->RAFlags |= UA_ISTRASH; - room->QRFlags2 = StrBufExtractNext_long(Line, &Pos, '|'); // CurRoom->QRFlags2 + room->QRFlags2 = StrBufExtractNext_long(Line, &Pos, '|'); DBG_QR2(room->QRFlags2); /* find out, whether we are in a sub-room */ diff --git a/webcit/serv_func.c b/webcit/serv_func.c index 14a4d6559..7ee74af2c 100644 --- a/webcit/serv_func.c +++ b/webcit/serv_func.c @@ -257,12 +257,12 @@ int GetConnected (void) * Read Citadel variformat text and spit it out as HTML. * align html align string */ -inline void fmout(char *align) +inline void fmout(const char *align) { _fmout(WC->WBuf, align); } -void _fmout(StrBuf *Target, char *align) +void _fmout(StrBuf *Target, const char *align) { int intext = 0; int bq = 0; @@ -303,7 +303,7 @@ void _fmout(StrBuf *Target, char *align) wc_printf("


\n"); } -void FmOut(StrBuf *Target, char *align, StrBuf *Source) +void FmOut(StrBuf *Target, const char *align, StrBuf *Source) { const char *ptr, *pte; const char *BufPtr = NULL; diff --git a/webcit/static.c b/webcit/static.c index 235322131..ece24acf5 100644 --- a/webcit/static.c +++ b/webcit/static.c @@ -17,17 +17,67 @@ #include "webcit.h" #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 +}; + HashList *StaticFilemappings[4] = {NULL, NULL, NULL, NULL}; /* - { - syslog(9, "Suspicious request. Ignoring."); - hprintf("HTTP/1.1 404 Security check failed\r\n"); - hprintf("Content-Type: text/plain\r\n\r\n"); - wc_printf("You have sent a malformed or invalid request.\r\n"); - end_burst(); - } + { + syslog(9, "Suspicious request. Ignoring."); + hprintf("HTTP/1.1 404 Security check failed\r\n"); + hprintf("Content-Type: text/plain\r\n\r\n"); + wc_printf("You have sent a malformed or invalid request.\r\n"); + end_burst(); + } */ + + +void output_error_pic(const char *ErrMsg1, const char *ErrMsg2) +{ + hprintf("HTTP/1.1 200 %s\r\n", ErrMsg1); + 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)); + end_burst(); +} + /* * dump out static pages from disk */ @@ -36,35 +86,46 @@ void output_static(const char *what) int fd; struct stat statbuf; off_t bytes; - off_t count = 0; const char *content_type; int len; const char *Err; + len = strlen (what); + content_type = GuessMimeByFilename(what, len); fd = open(what, O_RDONLY); if (fd <= 0) { syslog(9, "output_static('%s') [%s] -- NOT FOUND --\n", what, ChrPtr(WC->Hdr->this_page)); - hprintf("HTTP/1.1 404 %s\r\n", strerror(errno)); - hprintf("Content-Type: text/plain\r\n"); - begin_burst(); - wc_printf("Cannot open %s: %s\r\n", what, strerror(errno)); - end_burst(); - } else { - len = strlen (what); - content_type = GuessMimeByFilename(what, len); - - if (fstat(fd, &statbuf) == -1) { - syslog(9, "output_static('%s') -- FSTAT FAILED --\n", what); + if (strstr(content_type, "image/") != NULL) + { + output_error_pic("the file you requsted is gone.", strerror(errno)); + } + else + { hprintf("HTTP/1.1 404 %s\r\n", strerror(errno)); hprintf("Content-Type: text/plain\r\n"); begin_burst(); - wc_printf("Cannot fstat %s: %s\n", what, strerror(errno)); + wc_printf("Cannot open %s: %s\r\n", what, strerror(errno)); end_burst(); + } + } else { + if (fstat(fd, &statbuf) == -1) { + syslog(9, "output_static('%s') -- FSTAT FAILED --\n", what); + if (strstr(content_type, "image/") != NULL) + { + output_error_pic("Stat failed!", strerror(errno)); + } + else + { + hprintf("HTTP/1.1 404 %s\r\n", strerror(errno)); + hprintf("Content-Type: text/plain\r\n"); + begin_burst(); + wc_printf("Cannot fstat %s: %s\n", what, strerror(errno)); + end_burst(); + } if (fd > 0) close(fd); return; } - count = 0; bytes = statbuf.st_size; if (StrBufReadBLOB(WC->WBuf, &fd, 1, bytes, &Err) < 0) @@ -100,7 +161,6 @@ int LoadStaticDir(const char *DirName, HashList *DirList, const char *RelDir) struct dirent *filedir_entry; int d_type = 0; int d_namelen; - int d_without_ext; int istoplevel; filedir = opendir (DirName); @@ -121,7 +181,6 @@ int LoadStaticDir(const char *DirName, HashList *DirList, const char *RelDir) while ((readdir_r(filedir, d, &filedir_entry) == 0) && (filedir_entry != NULL)) { - char *PStart; #ifdef _DIRENT_HAVE_D_NAMELEN d_namelen = filedir_entry->d_namelen; d_type = filedir_entry->d_type; @@ -139,8 +198,6 @@ int LoadStaticDir(const char *DirName, HashList *DirList, const char *RelDir) d_namelen = strlen(filedir_entry->d_name); d_type = DT_UNKNOWN; #endif - d_without_ext = d_namelen; - if ((d_namelen > 1) && filedir_entry->d_name[d_namelen - 1] == '~') continue; /* Ignore backup files... */ @@ -184,7 +241,6 @@ int LoadStaticDir(const char *DirName, HashList *DirList, const char *RelDir) break; case DT_LNK: /* TODO: check whether its a file or a directory */ case DT_REG: - PStart = filedir_entry->d_name; FileName = NewStrBufDup(Dir); if (ChrPtr(FileName) [ StrLength(FileName) - 1] != '/') StrBufAppendBufPlain(FileName, "/", 1, 0); @@ -227,7 +283,7 @@ void output_flat_static(void) (vFile != NULL)) { File = (StrBuf*) vFile; - output_static(ChrPtr(vFile)); + output_static(ChrPtr(File)); } } @@ -236,18 +292,26 @@ void output_static_safe(HashList *DirList) wcsession *WCC = WC; void *vFile; StrBuf *File; + const char *MimeType; if (GetHash(DirList, SKEY(WCC->Hdr->HR.ReqLine), &vFile) && (vFile != NULL)) { File = (StrBuf*) vFile; - output_static(ChrPtr(vFile)); + output_static(ChrPtr(File)); } else { syslog(1, "output_static_safe() file %s not found. \n", ChrPtr(WCC->Hdr->HR.ReqLine)); -///TODO: detect image & output blank image - do_404(); + MimeType = GuessMimeByFilename(SKEY(WCC->Hdr->HR.ReqLine)); + if (strstr(MimeType, "image/") != NULL) + { + output_error_pic("the file you requested isn't known to our cache", "maybe reload webcit?"); + } + else + { + do_404(); + } } } void output_static_0(void) diff --git a/webcit/subst.c b/webcit/subst.c index 3b234f042..4048579ed 100644 --- a/webcit/subst.c +++ b/webcit/subst.c @@ -392,35 +392,6 @@ void FreeWCTemplate(void *vFreeMe) free(FreeMe); } - - -/** - * \brief back end for print_value_of() ... does a server command - * \param servcmd server command to execute on the citadel server - */ -void pvo_do_cmd(StrBuf *Target, StrBuf *servcmd) { - char buf[SIZ]; - int len; - - serv_puts(ChrPtr(servcmd)); - len = serv_getln(buf, sizeof buf); - - switch(buf[0]) { - case '2': - case '3': - case '5': - StrBufAppendPrintf(Target, "%s\n", &buf[4]); - break; - case '1': - _fmout(Target, "CENTER"); - break; - case '4': - StrBufAppendPrintf(Target, "%s\n", &buf[4]); - serv_puts("000"); - break; - } -} - int HaveTemplateTokenString(StrBuf *Target, WCTemplputParams *TP, int N, @@ -619,7 +590,6 @@ void StrBufAppendTemplate(StrBuf *Target, WCTemplputParams *TP, const StrBuf *Source, int FormatTypeIndex) { - wcsession *WCC; const char *pFmt = NULL; char EscapeAs = ' '; @@ -633,7 +603,6 @@ void StrBufAppendTemplate(StrBuf *Target, switch(EscapeAs) { case 'H': - WCC = WC; StrEscAppend(Target, Source, NULL, 0, 2); break; case 'X': @@ -1215,7 +1184,6 @@ void *load_template(WCTemplate *NewTemplate) struct stat statbuf; const char *pS, *pE, *pch, *Err; long Line; - int pos; fd = open(ChrPtr(NewTemplate->FileName), O_RDONLY); if (fd <= 0) { @@ -1235,7 +1203,6 @@ void *load_template(WCTemplate *NewTemplate) close(fd); syslog(1, "ERROR: reading template '%s' - %s
\n", ChrPtr(NewTemplate->FileName), strerror(errno)); - //FreeWCTemplate(NewTemplate);/////tODO return NULL; } close(fd); @@ -1252,7 +1219,6 @@ void *load_template(WCTemplate *NewTemplate) void *pv; /** Find one */ - pos = (-1); for (; pch < pE; pch ++) { if ((*pch=='<')&&(*(pch + 1)=='?') && !((pch == pS) && /* we must ommit a d_namelen; d_type = filedir_entry->d_type; @@ -1410,7 +1376,6 @@ int LoadTemplateDir(const StrBuf *DirName, HashList *big, const StrBuf *BaseKey) (strcmp(&filedir_entry->d_name[d_without_ext], ".orig") == 0) || (strcmp(&filedir_entry->d_name[d_without_ext], ".swp") == 0)) continue; /* Ignore backup files... */ - PStart = filedir_entry->d_name; StrBufPrintf(FileName, "%s/%s", ChrPtr(DirName), filedir_entry->d_name); MinorPtr = strchr(filedir_entry->d_name, '.'); if (MinorPtr != NULL) @@ -2354,7 +2319,6 @@ CompareFunc RetrieveSort(WCTemplputParams *TP, const char *OtherPrefix, long OtherPrefixLen, const char *Default, long ldefault, long DefaultDirection) { - int isdefault = 0; const StrBuf *BSort = NULL; SortStruct *SortBy; void *vSortBy; @@ -2388,7 +2352,6 @@ CompareFunc RetrieveSort(WCTemplputParams *TP, if (!GetHash(SortHash, SKEY(BSort), &vSortBy) || (vSortBy == NULL)) { - isdefault = 1; if (!GetHash(SortHash, Default, ldefault, &vSortBy) || (vSortBy == NULL)) { LogTemplateError( diff --git a/webcit/tasks.c b/webcit/tasks.c index a799794c6..e0d5a5571 100644 --- a/webcit/tasks.c +++ b/webcit/tasks.c @@ -179,12 +179,9 @@ void display_edit_individual_task(icalcomponent *supplied_vtodo, long msgnum, ch icalcomponent *vtodo; icalproperty *p; struct icaltimetype IcalTime; - time_t now; int created_new_vtodo = 0; icalproperty_status todoStatus; - now = time(NULL); - if (supplied_vtodo != NULL) { vtodo = supplied_vtodo; diff --git a/webcit/vcard_edit.c b/webcit/vcard_edit.c index c732144e3..ca76ec374 100644 --- a/webcit/vcard_edit.c +++ b/webcit/vcard_edit.c @@ -561,36 +561,31 @@ void parse_vcard(StrBuf *Target, struct vCard *v, HashList *VC, int full, wc_mim StrBuf *Swap = NULL; int i, j; char buf[SIZ]; - char *name; int is_qp = 0; int is_b64 = 0; StrBuf *thisname = NULL; - char *thisvalue = NULL; char firsttoken[SIZ]; - int pass; - long len; void *V; Swap = NewStrBuf (); thisname = NewStrBuf(); for (i=0; i<(v->numprops); ++i) { - int len; is_qp = 0; is_b64 = 0; StrBufPlain(thisname, v->prop[i].name, -1); StrBufLowerCase(thisname); - len = extract_token(firsttoken, thisname, 0, ';', sizeof firsttoken); + /*len = */extract_token(firsttoken, ChrPtr(thisname), 0, ';', sizeof firsttoken); - for (j=0; jupload_length = 0; WCC->upload = NULL; WCC->Hdr->nWildfireHeaders = 0; - if (WCC->Hdr->HR.Handler != NULL) - Flags = WCC->Hdr->HR.Handler->Flags; /* so we can temporarily add our own... */ if (WCC->Hdr->HR.ContentLength > 0) { if (ReadPostData() < 0) { diff --git a/webcit/webcit.h b/webcit/webcit.h index 567dc5d4e..ff7cb680e 100644 --- a/webcit/webcit.h +++ b/webcit/webcit.h @@ -710,9 +710,9 @@ void CreateMimeStr(void); void pop_destination(void); -void fmout(char *align); -void _fmout(StrBuf *Targt, char *align); -void FmOut(StrBuf *Target, char *align, StrBuf *Source); +void fmout(const char *align); +void _fmout(StrBuf *Targt, const char *align); +void FmOut(StrBuf *Target, const char *align, const StrBuf *Source); void wDumpContent(int); diff --git a/webcit/webserver.c b/webcit/webserver.c index cdb8367cd..603265eca 100644 --- a/webcit/webserver.c +++ b/webcit/webserver.c @@ -22,7 +22,6 @@ extern int verbosity; /* Logging level */ 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 home_specified = 0; /* did the user specify a homedir? */ int DisableGzip = 0; struct redirector *redir = NULL; char *default_landing_page = NULL; @@ -158,7 +157,6 @@ int main(int argc, char **argv) char ip_addr[256]="*"; int relh=0; int home=0; - int home_specified=0; char relhome[PATH_MAX]=""; char webcitdir[PATH_MAX] = DATADIR; char *pidfile = NULL; @@ -211,7 +209,6 @@ int main(int argc, char **argv) safestrncpy(relhome, relhome, sizeof relhome); } /* free(hdir); TODO: SHOULD WE DO THIS? */ - home_specified = 1; home=1; break; case 'd': -- 2.30.2