*
*/
-#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/euid
*/
-void groupdav_delete(char *dav_pathname, char *dav_ifmatch) {
- char dav_roomname[SIZ];
+void groupdav_delete(void)
+{
+ wcsession *WCC = WC;
char dav_uid[SIZ];
long dav_msgnum = (-1);
char buf[SIZ];
int n = 0;
-
- /* First, break off the "/groupdav/" prefix */
- remove_token(dav_pathname, 0, '/');
- remove_token(dav_pathname, 0, '/');
-
+ StrBuf *dav_roomname = NewStrBuf();
+
/* Now extract the message euid */
- n = num_tokens(dav_pathname, '/');
- extract_token(dav_uid, dav_pathname, n-1, '/', sizeof dav_uid);
- remove_token(dav_pathname, n-1, '/');
+ n = StrBufNum_tokens(WCC->Hdr->HR.ReqLine, '/');
+ extract_token(dav_uid, ChrPtr(WCC->Hdr->HR.ReqLine), n-1, '/', sizeof dav_uid);
+ StrBufExtract_token(dav_roomname, WCC->Hdr->HR.ReqLine, 0, '/');
- /* What's left is the room name. Remove trailing slashes. */
- if (dav_pathname[strlen(dav_pathname)-1] == '/') {
- dav_pathname[strlen(dav_pathname)-1] = 0;
- }
- strcpy(dav_roomname, dav_pathname);
+ ///* What's left is the room name. Remove trailing slashes. */
+ //len = StrLength(WCC->Hdr->HR.ReqLine);
+ //if ((len > 0) && (ChrPtr(WCC->Hdr->HR.ReqLinee)[len-1] == '/')) {
+ // StrBufCutRight(WCC->Hdr->HR.ReqLine, 1);
+ //}
+ //StrBufCutLeft(WCC->Hdr->HR.ReqLine, 1);
/* Go to the correct room. */
- if (strcasecmp(WC->wc_roomname, dav_roomname)) {
+ if (strcasecmp(ChrPtr(WC->CurRoom.name), ChrPtr(dav_roomname))) {
gotoroom(dav_roomname);
}
- if (strcasecmp(WC->wc_roomname, dav_roomname)) {
- wprintf("HTTP/1.1 404 not found\r\n");
+ if (strcasecmp(ChrPtr(WC->CurRoom.name), ChrPtr(dav_roomname))) {
+ hprintf("HTTP/1.1 404 not found\r\n");
groupdav_common_headers();
- wprintf("Content-Length: 0\r\n\r\n");
+ hprintf("Content-Length: 0\r\n\r\n");
+ begin_burst();
+ end_burst();
+ FreeStrBuf(&dav_roomname);
return;
}
* If no item exists with the requested uid ... simple error.
*/
if (dav_msgnum < 0L) {
- wprintf("HTTP/1.1 404 Not Found\r\n");
+ hprintf("HTTP/1.1 404 Not Found\r\n");
groupdav_common_headers();
- wprintf("Content-Length: 0\r\n\r\n");
+ hprintf("Content-Length: 0\r\n\r\n");
+ begin_burst();
+ end_burst();
+ FreeStrBuf(&dav_roomname);
return;
}
* It's there ... check the ETag and make sure it matches
* the message number.
*/
- if (strlen(dav_ifmatch) > 0) {
- if (atol(dav_ifmatch) != dav_msgnum) {
- wprintf("HTTP/1.1 412 Precondition Failed\r\n");
+ if (StrLength(WCC->Hdr->HR.dav_ifmatch) > 0) {
+ if (StrTol(WCC->Hdr->HR.dav_ifmatch) != dav_msgnum) {
+ hprintf("HTTP/1.1 412 Precondition Failed\r\n");
groupdav_common_headers();
- wprintf("Content-Length: 0\r\n\r\n");
+ hprintf("Content-Length: 0\r\n\r\n");
+ begin_burst();
+ end_burst();
+ FreeStrBuf(&dav_roomname);
return;
}
}
* Ok, attempt to delete the item.
*/
serv_printf("DELE %ld", dav_msgnum);
- serv_gets(buf);
+ serv_getln(buf, sizeof buf);
if (buf[0] == '2') {
- wprintf("HTTP/1.1 204 No Content\r\n"); /* success */
+ hprintf("HTTP/1.1 204 No Content\r\n"); /* success */
groupdav_common_headers();
- wprintf("Content-Length: 0\r\n\r\n");
+ hprintf("Content-Length: 0\r\n\r\n");
+ begin_burst();
+ end_burst();
}
else {
- wprintf("HTTP/1.1 403 Forbidden\r\n"); /* access denied */
+ hprintf("HTTP/1.1 403 Forbidden\r\n"); /* access denied */
groupdav_common_headers();
- wprintf("Content-Length: 0\r\n\r\n");
+ hprintf("Content-Length: 0\r\n\r\n");
+ begin_burst();
+ end_burst();
}
+ FreeStrBuf(&dav_roomname);
return;
}