* Implemented the Groupdav GET method, more or less in its final form
authorArt Cancro <ajc@citadel.org>
Tue, 25 Jan 2005 04:17:20 +0000 (04:17 +0000)
committerArt Cancro <ajc@citadel.org>
Tue, 25 Jan 2005 04:17:20 +0000 (04:17 +0000)
  (still need to fix the room/folder naming semantics)

webcit/ChangeLog
webcit/Makefile.in
webcit/groupdav.h [new file with mode: 0644]
webcit/groupdav_get.c [new file with mode: 0644]
webcit/groupdav_main.c
webcit/webcit.c
webcit/webcit.h

index b0ccf7c558018593aa5a35e5bf2de1dc4caec7fb..0f39cdb1b0fa6dea3d406d86b64b731f9e34994d 100644 (file)
@@ -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 <ajc@uncnsrd.mt-kisco.ny.us>
 
 1998-12-03 Nathan Bryant <bryant@cs.usm.maine.edu>
        * webserver.c: warning fix
+
index 1edcdf1082f262e93d97948f2a63e79478ea5a8c..1a0de31e5e70c2988fc2706655028298cfb06111 100644 (file)
@@ -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 (file)
index 0000000..bf90585
--- /dev/null
@@ -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 (file)
index 0000000..02287fb
--- /dev/null
@@ -0,0 +1,83 @@
+/*
+ * $Id$
+ *
+ * Handles GroupDAV GET requests.
+ *
+ */
+
+#include <ctype.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <fcntl.h>
+#include <signal.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <sys/socket.h>
+#include <limits.h>
+#include <string.h>
+#include <pwd.h>
+#include <errno.h>
+#include <stdarg.h>
+#include <time.h>
+#include <pthread.h>
+#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);
+       }
+}
index 81987514dcf97b1a025de38b407f046ed252a39b..adb402f37061c3f7e5b21ff87deb5affda24e3ae 100644 (file)
 #include <pthread.h>
 #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);
index 1857caead1961f9352f17bef2a79e119453f59ab..f4261e8b27b4b23b1e02a472734b8ff4fd870afd 100644 (file)
@@ -29,6 +29,7 @@
 #include <pthread.h>
 #include <signal.h>
 #include "webcit.h"
+#include "groupdav.h"
 #include "webserver.h"
 #include "mime_parser.h"
 
index 873354ad3aca3487c8e16aca6621b8f0ee050f1f..2dab1cb24d935d9c4eaf1fd16cc53aacd13c2e43 100644 (file)
@@ -497,4 +497,3 @@ extern char *ascmonths[];
 #define VIEW_TASKS             4       /* Tasks view */
 #define VIEW_NOTES             5       /* Notes view */
 
-void groupdav_main(struct httprequest *);