* Completed HTTP "Basic" authentication, and a stub function for the
[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
27 void groupdav_main(struct httprequest *req) {
28
29         struct httprequest *rptr;
30
31         if (!WC->logged_in) {
32                 wprintf(
33                         "HTTP/1.1 401 Authorization Required\n"
34                         "WWW-Authenticate: Basic realm=\"%s\"\n"
35                         "Connection: close\n",
36                         serv_info.serv_humannode
37                 );
38                 wprintf("Content-Type: text/plain\n");
39                 wprintf("\n");
40                 wprintf("GroupDAV sessions require HTTP authentication.\n");
41                 return;
42         }
43
44         wprintf(
45                 "HTTP/1.1 404 Not found - FIXME\n"
46                 "Connection: close\n"
47                 "Content-Type: text/plain\n"
48                 "\n"
49         );
50         wprintf("You are authenticated, but sent a bogus request.\n");
51         wprintf("WC->httpauth_user=%s\n", WC->httpauth_user);
52         wprintf("WC->httpauth_pass=%s\n", WC->httpauth_pass);   /* FIXME don't display this */
53         wprintf("WC->wc_session   =%d\n", WC->wc_session);
54         
55         for (rptr=req; rptr!=NULL; rptr=rptr->next) {
56                 wprintf("> %s\n", rptr->line);
57         }
58 }