hprintf(
"Server: %s / %s\r\n"
"Connection: close\r\n",
- PACKAGE_STRING, serv_info.serv_software
+ PACKAGE_STRING, ChrPtr(WC->serv_info->serv_software)
);
}
/*
* string conversion function
*/
-void euid_escapize(char *target, char *source) {
+void euid_escapize(char *target, const char *source) {
int i, len;
int target_length = 0;
/*
* string conversion function
*/
-void euid_unescapize(char *target, char *source) {
+void euid_unescapize(char *target, const char *source) {
int a, b, len;
char hex[3];
int target_length = 0;
hex[1] = source[a + 2];
hex[2] = 0;
b = 0;
- sscanf(hex, "%02x", &b);
+ b = decode_hex(hex);
target[target_length] = b;
target[++target_length] = 0;
a += 2;
*/
void groupdav_main(HashList *HTTPHeaders,
StrBuf *DavPathname,
- StrBuf *DavMethod,
StrBuf *dav_content_type,
int dav_content_length,
StrBuf *dav_content,
int Offset
) {
+ wcsession *WCC = WC;
void *vLine;
char dav_ifmatch[256];
int dav_depth;
strcpy(dav_ifmatch, "");
dav_depth = 0;
- if (IsEmptyStr(WC->http_host) &&
+ if ((StrLength(WCC->Hdr->http_host) == 0) &&
GetHash(HTTPHeaders, HKEY("HOST"), &vLine) &&
(vLine != NULL)) {
- safestrncpy(WC->http_host, ChrPtr((StrBuf*)vLine),
- sizeof WC->http_host);
+ WCC->Hdr->http_host = (StrBuf*)vLine;
}
if (GetHash(HTTPHeaders, HKEY("IF-MATCH"), &vLine) &&
(vLine != NULL)) {
hprintf("HTTP/1.1 401 Unauthorized\r\n");
groupdav_common_headers();
hprintf("WWW-Authenticate: Basic realm=\"%s\"\r\n",
- serv_info.serv_humannode);
+ ChrPtr(WCC->serv_info->serv_humannode));
hprintf("Content-Length: 0\r\n");
end_burst();
return;
}
-// extract_token(dav_method, req->line, 0, ' ', sizeof dav_method);
-// extract_token(dav_pathname, req->line, 1, ' ', sizeof dav_pathname);
- //// TODO unescape_input(dav_pathname);
-
- /* If the request does not begin with "/groupdav", prepend it. If
- * we happen to introduce a double-slash, that's ok; we'll strip it
- * in the next step.
- *
- * (THIS IS DISABLED BECAUSE WE ARE NOW TRYING TO DO REAL DAV.)
- *
- if (strncasecmp(dav_pathname, "/groupdav", 9)) {
- char buf[512];
- snprintf(buf, sizeof buf, "/groupdav/%s", dav_pathname);
- safestrncpy(dav_pathname, buf, sizeof dav_pathname);
- }
- *
- */
-
+ StrBufUnescape(DavPathname, 0);
+
/* Remove any stray double-slashes in pathname */
while (ds=strstr(ChrPtr(DavPathname), "//"), ds != NULL) {
strcpy(ds, ds+1);
}
}
+ switch (WCC->Hdr->eReqType)
+ {
/*
* The OPTIONS method is not required by GroupDAV. This is an
* experiment to determine what might be involved in supporting
* other variants of DAV in the future.
*/
- if (!strcasecmp(ChrPtr(DavMethod), "OPTIONS")) {
- groupdav_options(ChrPtr(DavPathname));
- return;
- }
+ case eOPTIONS:
+ groupdav_options(DavPathname);
+ break;
+
/*
* The PROPFIND method is basically used to list all objects in a
* room, or to list all relevant rooms on the server.
*/
- if (!strcasecmp(ChrPtr(DavMethod), "PROPFIND")) {
- groupdav_propfind(ChrPtr(DavPathname), dav_depth,
+ case ePROPFIND:
+ groupdav_propfind(DavPathname, dav_depth,
dav_content_type, dav_content,
Offset);
- return;
- }
+ break;
/*
* The GET method is used for fetching individual items.
*/
- if (!strcasecmp(ChrPtr(DavMethod), "GET")) {
- groupdav_get(ChrPtr(DavPathname));
- return;
- }
-
+ case eGET:
+ groupdav_get(DavPathname);
+ break;
+
/*
* The PUT method is used to add or modify items.
*/
- if (!strcasecmp(ChrPtr(DavMethod), "PUT")) {
- groupdav_put(ChrPtr(DavPathname), dav_ifmatch,
+ case ePUT:
+ groupdav_put(DavPathname, dav_ifmatch,
ChrPtr(dav_content_type), dav_content,
Offset);
- return;
- }
-
+ break;
+
/*
* The DELETE method kills, maims, and destroys.
*/
- if (!strcasecmp(ChrPtr(DavMethod), "DELETE")) {
+ case eDELETE:
groupdav_delete(DavPathname, dav_ifmatch);
- return;
- }
+ break;
+ default:
/*
* Couldn't find what we were looking for. Die in a car fire.
*/
- hprintf("HTTP/1.1 501 Method not implemented\r\n");
- groupdav_common_headers();
- hprintf("Content-Type: text/plain\r\n");
- wprintf("GroupDAV method \"%s\" is not implemented.\r\n",
- ChrPtr(DavMethod));
- end_burst();
+ hprintf("HTTP/1.1 501 Method not implemented\r\n");
+ groupdav_common_headers();
+ hprintf("Content-Type: text/plain\r\n");
+ wprintf("GroupDAV method \"%s\" is not implemented.\r\n",
+ ReqStrs[WCC->Hdr->eReqType]);
+ end_burst();
+ }
}
* Output our host prefix for globally absolute URL's.
*/
void groupdav_identify_host(void) {
- if (!IsEmptyStr(WC->http_host)) {
+ wcsession *WCC = WC;
+
+ if (StrLength(WCC->Hdr->http_host)!=0) {
wprintf("%s://%s",
(is_https ? "https" : "http"),
- WC->http_host);
+ ChrPtr(WCC->Hdr->http_host));
}
}
+
+
+void
+InitModule_GROUPDAV
+(void)
+{
+
+ WebcitAddUrlHandler(HKEY("groupdav"), do_logout, XHTTP_COMMANDS|COOKIEUNNEEDED|FORCE_SESSIONCLOSE);
+
+}