]> code.citadel.org Git - citadel.git/blob - webcit/groupdav_main.c
* Implemented the Groupdav GET method, more or less in its final form
[citadel.git] / webcit / groupdav_main.c
1 /*
2  * $Id$
3  *
4  * Entry point for GroupDAV functions
5  *
6  */
7
8 #include <ctype.h>
9 #include <stdlib.h>
10 #include <unistd.h>
11 #include <stdio.h>
12 #include <fcntl.h>
13 #include <signal.h>
14 #include <sys/types.h>
15 #include <sys/wait.h>
16 #include <sys/socket.h>
17 #include <limits.h>
18 #include <string.h>
19 #include <pwd.h>
20 #include <errno.h>
21 #include <stdarg.h>
22 #include <time.h>
23 #include <pthread.h>
24 #include "webcit.h"
25 #include "webserver.h"
26 #include "groupdav.h"
27
28 void groupdav_main(struct httprequest *req) {
29
30         struct httprequest *rptr;
31         char dav_method[SIZ];
32         char dav_pathname[SIZ];
33
34         if (!WC->logged_in) {
35                 wprintf(
36                         "HTTP/1.1 401 Authorization Required\n"
37                         "WWW-Authenticate: Basic realm=\"%s\"\n"
38                         "Connection: close\n",
39                         serv_info.serv_humannode
40                 );
41                 wprintf("Content-Type: text/plain\n");
42                 wprintf("\n");
43                 wprintf("GroupDAV sessions require HTTP authentication.\n");
44                 return;
45         }
46
47         extract_token(dav_method, req->line, 0, ' ');
48         extract_token(dav_pathname, req->line, 1, ' ');
49
50         /*
51          * We like the GET method ... it's nice and simple.
52          */
53         if (!strcasecmp(dav_method, "GET")) {
54                 groupdav_get(dav_pathname);
55                 return;
56         }
57
58         /*
59          * Couldn't find what we were looking for.  Die in a car fire.
60          */
61         wprintf(
62                 "HTTP/1.1 404 not found\n"
63                 "Connection: close\n"
64                 "Content-Type: text/plain\n"
65                 "\n"
66         );
67         wprintf("The object or resource \"%s\" was not found.\n", dav_pathname);
68
69         /*
70          * FIXME ... after development is finished, get rid of all this
71          */
72         wprintf("\n\n\n ** DEBUGGING INFO FOLLOWS ** \n\n");
73         wprintf("WC->httpauth_user = %s\n", WC->httpauth_user);
74         wprintf("WC->httpauth_pass = (%d characters)\n", strlen(WC->httpauth_pass));
75         wprintf("WC->wc_session    = %d\n", WC->wc_session);
76         
77         for (rptr=req; rptr!=NULL; rptr=rptr->next) {
78                 wprintf("> %s\n", rptr->line);
79         }
80 }