From a719bd431b76b3dd4909d16212964b8d7ed899f3 Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Tue, 25 Jan 2005 04:17:20 +0000 Subject: [PATCH] * Implemented the Groupdav GET method, more or less in its final form (still need to fix the room/folder naming semantics) --- webcit/ChangeLog | 5 +++ webcit/Makefile.in | 4 +- webcit/groupdav.h | 4 ++ webcit/groupdav_get.c | 83 ++++++++++++++++++++++++++++++++++++++++++ webcit/groupdav_main.c | 32 +++++++++++++--- webcit/webcit.c | 1 + webcit/webcit.h | 1 - 7 files changed, 122 insertions(+), 8 deletions(-) create mode 100644 webcit/groupdav.h create mode 100644 webcit/groupdav_get.c diff --git a/webcit/ChangeLog b/webcit/ChangeLog index b0ccf7c55..0f39cdb1b 100644 --- a/webcit/ChangeLog +++ b/webcit/ChangeLog @@ -1,4 +1,8 @@ $Log$ +Revision 528.19 2005/01/25 04:17:20 ajc +* Implemented the Groupdav GET method, more or less in its final form + (still need to fix the room/folder naming semantics) + Revision 528.18 2005/01/25 03:12:27 ajc * Completed HTTP "Basic" authentication, and a stub function for the main entry point for GroupDAV functions. @@ -2219,3 +2223,4 @@ Sun Dec 6 19:50:55 EST 1998 Art Cancro 1998-12-03 Nathan Bryant * webserver.c: warning fix + diff --git a/webcit/Makefile.in b/webcit/Makefile.in index 1edcdf108..1a0de31e5 100644 --- a/webcit/Makefile.in +++ b/webcit/Makefile.in @@ -37,7 +37,7 @@ webserver: webserver.o context_loop.o tools.o ical_dezonify.o \ mime_parser.o graphics.o netconf.o siteconfig.o subst.o \ calendar.o calendar_tools.o calendar_view.o event.o \ availability.o iconbar.o crypto.o inetconf.o notes.o \ - groupdav_main.o \ + groupdav_main.o groupdav_get.o \ $(LIBOBJS) $(CC) webserver.o context_loop.o tools.o cookie_conversion.o \ webcit.o auth.o tcp_sockets.o mainmenu.o serv_func.o who.o listsub.o \ @@ -46,7 +46,7 @@ webserver: webserver.o context_loop.o tools.o ical_dezonify.o \ mime_parser.o graphics.o netconf.o preferences.o html2html.o \ summary.o calendar.o calendar_tools.o calendar_view.o event.o \ availability.o ical_dezonify.o iconbar.o crypto.o inetconf.o notes.o \ - groupdav_main.o \ + groupdav_main.o groupdav_get.o \ $(LIBOBJS) $(LIBS) $(LDFLAGS) -o webserver .c.o: diff --git a/webcit/groupdav.h b/webcit/groupdav.h new file mode 100644 index 000000000..bf905850b --- /dev/null +++ b/webcit/groupdav.h @@ -0,0 +1,4 @@ +/* $Id$ */ + +void groupdav_main(struct httprequest *); + diff --git a/webcit/groupdav_get.c b/webcit/groupdav_get.c new file mode 100644 index 000000000..02287fb06 --- /dev/null +++ b/webcit/groupdav_get.c @@ -0,0 +1,83 @@ +/* + * $Id$ + * + * Handles GroupDAV GET requests. + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "webcit.h" +#include "webserver.h" +#include "groupdav.h" + + +/* + * The pathname is always going to be /groupdav/room_name/msg_num + */ +void groupdav_get(char *dav_pathname) { + char dav_roomname[SIZ]; + char dav_msgnum[SIZ]; + char buf[SIZ]; + int found_content_type = 0; + + extract_token(dav_roomname, dav_pathname, 2, '/'); + extract_token(dav_msgnum, dav_pathname, 3, '/'); + + /* Go to the correct room. */ + if (strcasecmp(WC->wc_roomname, dav_roomname)) { + gotoroom(dav_roomname); + } + if (strcasecmp(WC->wc_roomname, dav_roomname)) { + wprintf( + "HTTP/1.1 404 not found\n" + "Connection: close\n" + "Content-Type: text/plain\n" + "\n" + "There is no folder called \"%s\" on this server.\n", + dav_roomname + ); + return; + } + + serv_printf("MSG2 %s", dav_msgnum); + serv_gets(buf); + if (buf[0] != '1') { + wprintf( + "HTTP/1.1 404 not found\n" + "Connection: close\n" + "Content-Type: text/plain\n" + "\n" + "Object \"%s\" was not found in the \"%s\" folder.\n", + dav_msgnum, + dav_roomname + ); + return; + } + + wprintf("HTTP/1.1 200 OK\n"); + wprintf("ETag: %s\n", dav_msgnum); + while (serv_gets(buf), strcmp(buf, "000")) { + if (!strncasecmp(buf, "Content-type: ", 14)) { + found_content_type = 1; + } + if ((strlen(buf) == 0) && (found_content_type == 0)) { + wprintf("Content-type: text/plain\n"); + } + wprintf("%s\n", buf); + } +} diff --git a/webcit/groupdav_main.c b/webcit/groupdav_main.c index 81987514d..adb402f37 100644 --- a/webcit/groupdav_main.c +++ b/webcit/groupdav_main.c @@ -23,10 +23,13 @@ #include #include "webcit.h" #include "webserver.h" +#include "groupdav.h" void groupdav_main(struct httprequest *req) { struct httprequest *rptr; + char dav_method[SIZ]; + char dav_pathname[SIZ]; if (!WC->logged_in) { wprintf( @@ -41,16 +44,35 @@ void groupdav_main(struct httprequest *req) { return; } + extract_token(dav_method, req->line, 0, ' '); + extract_token(dav_pathname, req->line, 1, ' '); + + /* + * We like the GET method ... it's nice and simple. + */ + if (!strcasecmp(dav_method, "GET")) { + groupdav_get(dav_pathname); + return; + } + + /* + * Couldn't find what we were looking for. Die in a car fire. + */ wprintf( - "HTTP/1.1 404 Not found - FIXME\n" + "HTTP/1.1 404 not found\n" "Connection: close\n" "Content-Type: text/plain\n" "\n" ); - wprintf("You are authenticated, but sent a bogus request.\n"); - wprintf("WC->httpauth_user=%s\n", WC->httpauth_user); - wprintf("WC->httpauth_pass=%s\n", WC->httpauth_pass); /* FIXME don't display this */ - wprintf("WC->wc_session =%d\n", WC->wc_session); + wprintf("The object or resource \"%s\" was not found.\n", dav_pathname); + + /* + * FIXME ... after development is finished, get rid of all this + */ + wprintf("\n\n\n ** DEBUGGING INFO FOLLOWS ** \n\n"); + wprintf("WC->httpauth_user = %s\n", WC->httpauth_user); + wprintf("WC->httpauth_pass = (%d characters)\n", strlen(WC->httpauth_pass)); + wprintf("WC->wc_session = %d\n", WC->wc_session); for (rptr=req; rptr!=NULL; rptr=rptr->next) { wprintf("> %s\n", rptr->line); diff --git a/webcit/webcit.c b/webcit/webcit.c index 1857caead..f4261e8b2 100644 --- a/webcit/webcit.c +++ b/webcit/webcit.c @@ -29,6 +29,7 @@ #include #include #include "webcit.h" +#include "groupdav.h" #include "webserver.h" #include "mime_parser.h" diff --git a/webcit/webcit.h b/webcit/webcit.h index 873354ad3..2dab1cb24 100644 --- a/webcit/webcit.h +++ b/webcit/webcit.h @@ -497,4 +497,3 @@ extern char *ascmonths[]; #define VIEW_TASKS 4 /* Tasks view */ #define VIEW_NOTES 5 /* Notes view */ -void groupdav_main(struct httprequest *); -- 2.39.2