]> code.citadel.org Git - citadel.git/blob - webcit/groupdav_main.c
926bf23e7e2e4b94c655cdef2e52a7390b37cd90
[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
29 /*
30  * Main entry point for GroupDAV requests
31  */
32 void groupdav_main(struct httprequest *req) {
33
34         struct httprequest *rptr;
35         char dav_method[SIZ];
36         char dav_pathname[SIZ];
37
38         if (!WC->logged_in) {
39                 wprintf(
40                         "HTTP/1.1 401 Unauthorized\n"
41                         "WWW-Authenticate: Basic realm=\"%s\"\n"
42                         "Connection: close\n",
43                         serv_info.serv_humannode
44                 );
45                 wprintf("Content-Type: text/plain\n");
46                 wprintf("\n");
47                 wprintf("GroupDAV sessions require HTTP authentication.\n");
48                 return;
49         }
50
51         extract_token(dav_method, req->line, 0, ' ');
52         extract_token(dav_pathname, req->line, 1, ' ');
53         unescape_input(dav_pathname);
54
55         /*
56          * We like the GET method ... it's nice and simple.
57          */
58         if (!strcasecmp(dav_method, "GET")) {
59                 groupdav_get(dav_pathname);
60                 return;
61         }
62
63         /*
64          * Couldn't find what we were looking for.  Die in a car fire.
65          */
66         wprintf(
67                 "HTTP/1.1 501 Method not implemented\n"
68                 "Connection: close\n"
69                 "Content-Type: text/plain\n"
70                 "\n"
71         );
72         wprintf("GroupDAV method \"%s\" is not implemented.\n", dav_method);
73
74         /*
75          * FIXME ... after development is finished, get rid of all this
76          */
77         wprintf("\n\n\n ** DEBUGGING INFO FOLLOWS ** \n\n");
78         wprintf("WC->httpauth_user = %s\n", WC->httpauth_user);
79         wprintf("WC->httpauth_pass = (%d characters)\n", strlen(WC->httpauth_pass));
80         wprintf("WC->wc_session    = %d\n", WC->wc_session);
81         
82         for (rptr=req; rptr!=NULL; rptr=rptr->next) {
83                 wprintf("> %s\n", rptr->line);
84         }
85 }