$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.
1998-12-03 Nathan Bryant <bryant@cs.usm.maine.edu>
* webserver.c: warning fix
+
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 \
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:
--- /dev/null
+/* $Id$ */
+
+void groupdav_main(struct httprequest *);
+
--- /dev/null
+/*
+ * $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);
+ }
+}
#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(
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);
#include <pthread.h>
#include <signal.h>
#include "webcit.h"
+#include "groupdav.h"
#include "webserver.h"
#include "mime_parser.h"
#define VIEW_TASKS 4 /* Tasks view */
#define VIEW_NOTES 5 /* Notes view */
-void groupdav_main(struct httprequest *);