Bring in new dkim code
[citadel.git] / webcit / dav_get.c
index b2225543e254a815d30a0de3436d3dc851870d57..bbf013ffbb061166df6cc1bc4371541fdebe8e4d 100644 (file)
@@ -1,25 +1,19 @@
 /*
  * Handles GroupDAV GET requests.
  *
- * Copyright (c) 2005-2010 by the citadel.org team
+ * Copyright (c) 2005-2012 by the citadel.org team
  *
  * This program is open source software.  You can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 3 of the
- * License, or (at your option) any later version.
+ * modify it under the terms of the GNU General Public License, version 3.
  *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
 
 #include "webcit.h"
-#include "webserver.h"
+
 #include "dav.h"
 
 
  * Fetch the entire contents of the room as one big ics file.
  * This is for "webcal://" type access.
  */    
-void groupdav_get_big_ics(void) {
+void dav_get_big_ics(void) {
        char buf[1024];
 
        serv_puts("ICAL getics");
        serv_getln(buf, sizeof buf);
        if (buf[0] != '1') {
                hprintf("HTTP/1.1 404 not found\r\n");
-               groupdav_common_headers();
+               dav_common_headers();
                hprintf("Content-Type: text/plain\r\n");
                begin_burst();
                wc_printf("%s\r\n",
@@ -45,7 +39,7 @@ void groupdav_get_big_ics(void) {
        }
 
        hprintf("HTTP/1.1 200 OK\r\n");
-       groupdav_common_headers();
+       dav_common_headers();
        hprintf("Content-type: text/calendar; charset=UTF-8\r\n");
        begin_burst();
        while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
@@ -56,7 +50,7 @@ void groupdav_get_big_ics(void) {
 
 
 /* 
- * MIME parser callback function for groupdav_get()
+ * MIME parser callback function for dav_get()
  * Helps identify the relevant section of a multipart message
  */
 void extract_preferred(char *name, char *filename, char *partnum, char *disp,
@@ -101,7 +95,7 @@ void extract_preferred(char *name, char *filename, char *partnum, char *disp,
  * /groupdav/room_name/euid    (GroupDAV)
  * /groupdav/room_name         (webcal)
  */
-void groupdav_get(void)
+void dav_get(void)
 {
        wcsession *WCC = WC;
        StrBuf *dav_roomname;
@@ -122,7 +116,7 @@ void groupdav_get(void)
 
        if (StrBufNum_tokens(WCC->Hdr->HR.ReqLine, '/') < 2) {
                hprintf("HTTP/1.1 404 not found\r\n");
-               groupdav_common_headers();
+               dav_common_headers();
                hprintf("Content-Type: text/plain\r\n");
                wc_printf("The object you requested was not found.\r\n");
                end_burst();
@@ -144,7 +138,7 @@ void groupdav_get(void)
        }
        if (strcasecmp(ChrPtr(WCC->CurRoom.name), ChrPtr(dav_roomname))) {
                hprintf("HTTP/1.1 404 not found\r\n");
-               groupdav_common_headers();
+               dav_common_headers();
                hprintf("Content-Type: text/plain\r\n");
                wc_printf("There is no folder called \"%s\" on this server.\r\n",
                        ChrPtr(dav_roomname));
@@ -157,7 +151,7 @@ void groupdav_get(void)
        /** GET on the collection itself returns an ICS of the entire collection.
         */
        if (StrLength(dav_uid) == 0) {
-               groupdav_get_big_ics();
+               dav_get_big_ics();
                FreeStrBuf(&dav_roomname);
                FreeStrBuf(&dav_uid);
                return;
@@ -168,7 +162,7 @@ void groupdav_get(void)
        serv_getln(buf, sizeof buf);
        if (buf[0] != '1') {
                hprintf("HTTP/1.1 404 not found\r\n");
-               groupdav_common_headers();
+               dav_common_headers();
                hprintf("Content-Type: text/plain\r\n");
                wc_printf("Object \"%s\" was not found in the \"%s\" folder.\r\n",
                        ChrPtr(dav_uid),
@@ -207,15 +201,15 @@ void groupdav_get(void)
                if (!in_body) {
                        if (!strncasecmp(buf, "Date:", 5)) {
                                safestrncpy(date, &buf[5], sizeof date);
-                               striplt(date);
+                               string_trim(date);
                        }
                        if (!strncasecmp(buf, "Content-type:", 13)) {
                                safestrncpy(content_type, &buf[13], sizeof content_type);
-                               striplt(content_type);
+                               string_trim(content_type);
                                ptr = bmstrcasestr(&buf[13], "charset=");
                                if (ptr) {
                                        safestrncpy(charset, ptr+8, sizeof charset);
-                                       striplt(charset);
+                                       string_trim(charset);
                                        endptr = strchr(charset, ';');
                                        if (endptr != NULL) strcpy(endptr, "");
                                }
@@ -229,7 +223,7 @@ void groupdav_get(void)
        /* Output headers common to single or multi part messages */
 
        hprintf("HTTP/1.1 200 OK\r\n");
-       groupdav_common_headers();
+       dav_common_headers();
        hprintf("etag: \"%ld\"\r\n", dav_msgnum);
        hprintf("Date: %s\r\n", date);