From efccdcf4db04e63bfa3512c80215357ee9ffd98f Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Tue, 3 Jan 2012 18:13:57 -0500 Subject: [PATCH] Created stub for REPORT method --- webcit/Makefile.in | 4 +- webcit/context_loop.c | 7 ++- webcit/dav.h | 1 + webcit/dav_main.c | 9 +++- webcit/dav_options.c | 4 +- webcit/dav_report.c | 116 ++++++++++++++++++++++++++++++++++++++++++ webcit/netconf.c | 3 +- webcit/sysdep.c | 10 ++-- webcit/webcit.h | 11 ++-- webcit/webserver.c | 3 +- 10 files changed, 144 insertions(+), 24 deletions(-) create mode 100644 webcit/dav_report.c diff --git a/webcit/Makefile.in b/webcit/Makefile.in index ee7c89f38..dfcb06db7 100644 --- a/webcit/Makefile.in +++ b/webcit/Makefile.in @@ -54,7 +54,7 @@ webcit: webserver.o context_loop.o ical_dezonify.o \ graphics.o netconf.o siteconfig.o subst.o bbsview_renderer.o \ calendar.o calendar_tools.o calendar_view.o tasks.o event.o smtpqueue.o \ availability.o iconbar.o crypto.o inetconf.o notes.o wiki.o \ - dav_main.o dav_get.o dav_propfind.o fmt_date.o \ + dav_main.o dav_get.o dav_propfind.o dav_report.o fmt_date.o \ dav_options.o autocompletion.o gettext.o tabs.o sieve.o sitemap.o \ dav_delete.o dav_put.o http_datestring.o setup_wizard.o \ downloads.o addressbook_popup.o pushemail.o sysdep.o openid.o \ @@ -70,7 +70,7 @@ webcit: webserver.o context_loop.o ical_dezonify.o \ graphics.o netconf.o preferences.o html2html.o openid.o bbsview_renderer.o \ summary.o calendar.o calendar_tools.o calendar_view.o tasks.o event.o wiki.o \ availability.o ical_dezonify.o iconbar.o crypto.o inetconf.o notes.o \ - dav_main.o dav_get.o dav_propfind.o dav_delete.o \ + dav_main.o dav_get.o dav_propfind.o dav_report.o dav_delete.o \ dav_options.o autocompletion.o tabs.o smtpqueue.o sieve.o sitemap.o \ dav_put.o http_datestring.o setup_wizard.o fmt_date.o modules_init.o \ gettext.o downloads.o addressbook_popup.o pushemail.o sysdep.o decode.o \ diff --git a/webcit/context_loop.c b/webcit/context_loop.c index 04c5cf0a3..fb5914462 100644 --- a/webcit/context_loop.c +++ b/webcit/context_loop.c @@ -714,7 +714,8 @@ const char *ReqStrs[eNONE] = { "DELETE", "HEAD", "MOVE", - "COPY" + "COPY", + "REPORT" }; void @@ -760,6 +761,10 @@ ServerStartModule_CONTEXT v = malloc(sizeof(long)); *v = eCOPY; Put(HttpReqTypes, HKEY("COPY"), v, NULL); + + v = malloc(sizeof(long)); + *v = eREPORT; + Put(HttpReqTypes, HKEY("REPORT"), v, NULL); } void diff --git a/webcit/dav.h b/webcit/dav.h index 63d67dfef..a2963f0fb 100644 --- a/webcit/dav.h +++ b/webcit/dav.h @@ -17,6 +17,7 @@ void dav_put(void); void dav_delete(void); void dav_propfind(void); void dav_options(void); +void dav_report(void); long locate_message_by_uid(const char *); void dav_folder_list(void); diff --git a/webcit/dav_main.c b/webcit/dav_main.c index 833e75e75..f923a37b7 100644 --- a/webcit/dav_main.c +++ b/webcit/dav_main.c @@ -170,8 +170,15 @@ void dav_main(void) case eDELETE: dav_delete(); break; - default: + /* + * The REPORT method tells us that Mike Shaver is a self-righteous asshole. + */ + case eREPORT: + dav_report(); + break; + + default: /* * Couldn't find what we were looking for. Die in a car fire. */ diff --git a/webcit/dav_options.c b/webcit/dav_options.c index b91873001..250a3ce12 100644 --- a/webcit/dav_options.c +++ b/webcit/dav_options.c @@ -1,7 +1,7 @@ /* * Handles DAV OPTIONS requests (experimental -- not required by GroupDAV) * - * Copyright (c) 2005-2010 by the citadel.org team + * Copyright (c) 2005-2012 by the citadel.org team * * This program is open source software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -145,7 +145,7 @@ void dav_options(void) syslog(LOG_DEBUG, "\033[36mDAV: 1\033[0m"); } - hprintf("Allow: OPTIONS, PROPFIND, GET, PUT\r\n"); + hprintf("Allow: OPTIONS, PROPFIND, GET, PUT, REPORT\r\n"); begin_burst(); end_burst(); } diff --git a/webcit/dav_report.c b/webcit/dav_report.c new file mode 100644 index 000000000..33d168342 --- /dev/null +++ b/webcit/dav_report.c @@ -0,0 +1,116 @@ +/* + * Handles GroupDAV REPORT requests. + * + * Copyright (c) 2005-2012 by the citadel.org team + * + * This program is open source software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + + +/* SAMPLE QUERIES TO WORK WITH * + +REPORT /groupdav/calendar/ HTTP/1.1 +Content-type: application/xml +Content-length: 349 + + + + + + + + + + + + + + + +REPORT /groupdav/calendar/ HTTP/1.1 +Content-type: application/xml +Content-length: 255 + + + + + + + + + + + + +*/ + +#include "webcit.h" +#include "webserver.h" +#include "dav.h" + + +/* + * The pathname is always going to be /groupdav/room_name/msg_num + */ +void dav_report(void) +{ + char datestring[256]; + time_t now = time(NULL); + + http_datestring(datestring, sizeof datestring, now); + const char *req = ChrPtr(WC->upload); + + syslog(LOG_DEBUG, "REPORT: \033[31m%s\033[0m", req); + + hprintf("HTTP/1.1 500 Internal Server Error\r\n"); + dav_common_headers(); + hprintf("Date: %s\r\n", datestring); + hprintf("Content-Type: text/plain\r\n"); + wc_printf("An internal error has occurred at %s:%d.\r\n", __FILE__ , __LINE__ ); + end_burst(); + return; +} + + + +extern int ParseMessageListHeaders_EUID(StrBuf *Line, + const char **pos, + message_summary *Msg, + StrBuf *ConversionBuffer); + +extern int DavUIDL_GetParamsGetServerCall(SharedMessageStatus *Stat, + void **ViewSpecific, + long oper, + char *cmd, + long len); + +extern int DavUIDL_RenderView_or_Tail(SharedMessageStatus *Stat, + void **ViewSpecific, + long oper); + +extern int DavUIDL_Cleanup(void **ViewSpecific); + + + +void +InitModule_REPORT +(void) +{ + RegisterReadLoopHandlerset( + eReadEUIDS, + DavUIDL_GetParamsGetServerCall, + NULL, + ParseMessageListHeaders_EUID, + NULL, + DavUIDL_RenderView_or_Tail, + DavUIDL_Cleanup + ); + +} diff --git a/webcit/netconf.c b/webcit/netconf.c index a42621711..caecca46f 100644 --- a/webcit/netconf.c +++ b/webcit/netconf.c @@ -79,7 +79,6 @@ HashList *load_netconf(StrBuf *Target, WCTemplputParams *TP) char nnn[64]; char buf[SIZ]; int nUsed; - long len; NodeConf *Node; serv_puts("CONF getsys|application/x-citadel-ignet-config"); @@ -88,7 +87,7 @@ HashList *load_netconf(StrBuf *Target, WCTemplputParams *TP) Hash = NewHash(1, NULL); Buf = NewStrBuf(); - while (len = StrBuf_ServGetln(Buf), strcmp(ChrPtr(Buf), "000")) { + while (StrBuf_ServGetln(Buf), strcmp(ChrPtr(Buf), "000")) { Node = NewNode(Buf); if (Node != NULL) { nUsed = GetCount(Hash); diff --git a/webcit/sysdep.c b/webcit/sysdep.c index 197d2df6f..9ccbc1cd2 100644 --- a/webcit/sysdep.c +++ b/webcit/sysdep.c @@ -331,8 +331,6 @@ void start_daemon(char *pid_file) pid_t child = 0; FILE *fp; int do_restart = 0; - int rv; - FILE *rvfp = NULL; current_child = 0; @@ -340,7 +338,7 @@ void start_daemon(char *pid_file) * We don't just call close() because we don't want these fd's * to be reused for other files. */ - rv = chdir("/"); + chdir("/"); signal(SIGHUP, SIG_IGN); signal(SIGINT, SIG_IGN); @@ -353,9 +351,9 @@ void start_daemon(char *pid_file) setsid(); umask(0); - rvfp = freopen("/dev/null", "r", stdin); - rvfp = freopen("/dev/null", "w", stdout); - rvfp = freopen("/dev/null", "w", stderr); + freopen("/dev/null", "r", stdin); + freopen("/dev/null", "w", stdout); + freopen("/dev/null", "w", stderr); signal(SIGTERM, graceful_shutdown_watcher); signal(SIGHUP, graceful_shutdown_watcher); diff --git a/webcit/webcit.h b/webcit/webcit.h index c46e8b4b5..e80489f22 100644 --- a/webcit/webcit.h +++ b/webcit/webcit.h @@ -1,19 +1,13 @@ /* - * Copyright (c) 1987-2011 by the citadel.org team + * Copyright (c) 1987-2012 by the citadel.org team * * This program is open source software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as published - * by the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. + * modify it under the terms of the GNU General Public License version 3. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "sysdep.h" @@ -410,6 +404,7 @@ enum { eHEAD, eMOVE, eCOPY, + eREPORT, eNONE }; extern const char *ReqStrs[eNONE]; diff --git a/webcit/webserver.c b/webcit/webserver.c index ab523489b..e82148837 100644 --- a/webcit/webserver.c +++ b/webcit/webserver.c @@ -86,7 +86,6 @@ int main(int argc, char **argv) const char *basedir = NULL; char uds_listen_path[PATH_MAX]; /* listen on a unix domain socket? */ const char *I18nDumpFile = NULL; - int rv = 0; WildFireInitBacktrace(argv[0], 2); @@ -274,7 +273,7 @@ int main(int argc, char **argv) syslog(1, "***********************************************\n"); return -1; } - rv = fwrite(ChrPtr(I18nDump), 1, StrLength(I18nDump), fd); + fwrite(ChrPtr(I18nDump), 1, StrLength(I18nDump), fd); fclose(fd); return 0; } -- 2.30.2