rename wprintf to wc_printf; wchar.h also has a wprintf
[citadel.git] / webcit / groupdav_propfind.c
index b28cb636a6fc6ac9331da7a3fb2be86abd1e809d..e12051265dd61db7b63b8179bd368724d4b035a6 100644 (file)
@@ -6,8 +6,7 @@
  * A few notes about our XML output:
  *
  * --> Yes, we are spewing tags directly instead of using an XML library.
- *     If you would like to rewrite this using libxml2, code it up and submit
- *     a patch.  Whining will be summarily ignored.
+ *     Whining about it will be summarily ignored.
  *
  * --> XML is deliberately output with no whitespace/newlines between tags.
  *     This makes it difficult to read, but we have discovered clients which
@@ -74,7 +73,7 @@ void groupdav_collection_list(void)
        now = time(NULL);
        http_datestring(datestring, sizeof datestring, now);
 
-       /**
+       /*
         * Be rude.  Completely ignore the XML request and simply send them
         * everything we know about.  Let the client sort it out.
         */
@@ -86,56 +85,56 @@ void groupdav_collection_list(void)
 
        begin_burst();
 
-       wprintf("<?xml version=\"1.0\" encoding=\"utf-8\"?>"
+       wc_printf("<?xml version=\"1.0\" encoding=\"utf-8\"?>"
                "<multistatus xmlns=\"DAV:\" xmlns:G=\"http://groupdav.org/\">"
        );
 
-       /**
-        *      If the client is requesting the root, show a root node.
+       /*
+        * If the client is requesting the root, show a root node.
         */
        if (starting_point == 0) {
-               wprintf("<response>");
-                       wprintf("<href>");
+               wc_printf("<response>");
+                       wc_printf("<href>");
                                groupdav_identify_host();
-                               wprintf("/");
-                       wprintf("</href>");
-                       wprintf("<propstat>");
-                               wprintf("<status>HTTP/1.1 200 OK</status>");
-                               wprintf("<prop>");
-                                       wprintf("<displayname>/</displayname>");
-                                       wprintf("<resourcetype><collection/></resourcetype>");
-                                       wprintf("<getlastmodified>");
+                               wc_printf("/");
+                       wc_printf("</href>");
+                       wc_printf("<propstat>");
+                               wc_printf("<status>HTTP/1.1 200 OK</status>");
+                               wc_printf("<prop>");
+                                       wc_printf("<displayname>/</displayname>");
+                                       wc_printf("<resourcetype><collection/></resourcetype>");
+                                       wc_printf("<getlastmodified>");
                                                escputs(datestring);
-                                       wprintf("</getlastmodified>");
-                               wprintf("</prop>");
-                       wprintf("</propstat>");
-               wprintf("</response>");
+                                       wc_printf("</getlastmodified>");
+                               wc_printf("</prop>");
+                       wc_printf("</propstat>");
+               wc_printf("</response>");
        }
 
-       /**
-        *      If the client is requesting "/groupdav", show a /groupdav subdirectory.
+       /*
+        * If the client is requesting "/groupdav", show a /groupdav subdirectory.
         */
        if ((starting_point + WCC->Hdr->HR.dav_depth) >= 1) {
-               wprintf("<response>");
-                       wprintf("<href>");
+               wc_printf("<response>");
+                       wc_printf("<href>");
                                groupdav_identify_host();
-                               wprintf("/groupdav");
-                       wprintf("</href>");
-                       wprintf("<propstat>");
-                               wprintf("<status>HTTP/1.1 200 OK</status>");
-                               wprintf("<prop>");
-                                       wprintf("<displayname>GroupDAV</displayname>");
-                                       wprintf("<resourcetype><collection/></resourcetype>");
-                                       wprintf("<getlastmodified>");
+                               wc_printf("/groupdav");
+                       wc_printf("</href>");
+                       wc_printf("<propstat>");
+                               wc_printf("<status>HTTP/1.1 200 OK</status>");
+                               wc_printf("<prop>");
+                                       wc_printf("<displayname>GroupDAV</displayname>");
+                                       wc_printf("<resourcetype><collection/></resourcetype>");
+                                       wc_printf("<getlastmodified>");
                                                escputs(datestring);
-                                       wprintf("</getlastmodified>");
-                               wprintf("</prop>");
-                       wprintf("</propstat>");
-               wprintf("</response>");
+                                       wc_printf("</getlastmodified>");
+                               wc_printf("</prop>");
+                       wc_printf("</propstat>");
+               wc_printf("</response>");
        }
 
-       /**
-        *      Now go through the list and make it look like a DAV collection
+       /*
+        * Now go through the list and make it look like a DAV collection
         */
        serv_puts("LKRA");
        serv_getln(buf, sizeof buf);
@@ -157,11 +156,13 @@ void groupdav_collection_list(void)
                 * GroupDAV calendar even if the user has switched it to a
                 * Calendar List view.
                 */
-               if ((view == VIEW_CALENDAR) || 
-                   (view == VIEW_TASKS) || 
-                   (view == VIEW_ADDRESSBOOK) ||
-                   (view == VIEW_NOTES) ||
-                   (view == VIEW_JOURNAL) ) {
+               if (    (view == VIEW_CALENDAR) || 
+                       (view == VIEW_TASKS) || 
+                       (view == VIEW_ADDRESSBOOK) ||
+                       (view == VIEW_NOTES) ||
+                       (view == VIEW_JOURNAL) ||
+                       (view == VIEW_WIKI)
+               ) {
                        is_groupware_collection = 1;
                }
                else {
@@ -169,50 +170,53 @@ void groupdav_collection_list(void)
                }
 
                if ( (is_groupware_collection) && ((starting_point + WCC->Hdr->HR.dav_depth) >= 2) ) {
-                       wprintf("<response>");
+                       wc_printf("<response>");
 
-                       wprintf("<href>");
+                       wc_printf("<href>");
                        groupdav_identify_host();
-                       wprintf("/groupdav/");
+                       wc_printf("/groupdav/");
                        urlescputs(roomname);
-                       wprintf("/</href>");
+                       wc_printf("/</href>");
 
-                       wprintf("<propstat>");
-                       wprintf("<status>HTTP/1.1 200 OK</status>");
-                       wprintf("<prop>");
-                       wprintf("<displayname>");
+                       wc_printf("<propstat>");
+                       wc_printf("<status>HTTP/1.1 200 OK</status>");
+                       wc_printf("<prop>");
+                       wc_printf("<displayname>");
                        escputs(roomname);
-                       wprintf("</displayname>");
-                       wprintf("<resourcetype><collection/>");
+                       wc_printf("</displayname>");
+                       wc_printf("<resourcetype><collection/>");
 
                        switch(view) {
                        case VIEW_CALENDAR:
-                               wprintf("<G:vevent-collection />");
+                               wc_printf("<G:vevent-collection />");
                                break;
                        case VIEW_TASKS:
-                               wprintf("<G:vtodo-collection />");
+                               wc_printf("<G:vtodo-collection />");
                                break;
                        case VIEW_ADDRESSBOOK:
-                               wprintf("<G:vcard-collection />");
+                               wc_printf("<G:vcard-collection />");
                                break;
                        case VIEW_NOTES:
-                               wprintf("<G:vnotes-collection />");
+                               wc_printf("<G:vnotes-collection />");
                                break;
                        case VIEW_JOURNAL:
-                               wprintf("<G:vjournal-collection />");
+                               wc_printf("<G:vjournal-collection />");
+                               break;
+                       case VIEW_WIKI:
+                               wc_printf("<G:wiki-collection />");
                                break;
                        }
 
-                       wprintf("</resourcetype>");
-                       wprintf("<getlastmodified>");
+                       wc_printf("</resourcetype>");
+                       wc_printf("<getlastmodified>");
                                escputs(datestring);
-                       wprintf("</getlastmodified>");
-                       wprintf("</prop>");
-                       wprintf("</propstat>");
-                       wprintf("</response>");
+                       wc_printf("</getlastmodified>");
+                       wc_printf("</prop>");
+                       wc_printf("</propstat>");
+                       wc_printf("</response>");
                }
        }
-       wprintf("</multistatus>\n");
+       wc_printf("</multistatus>\n");
 
        end_burst();
 }
@@ -258,15 +262,15 @@ void groupdav_propfind(void)
        }
 
        /* Go to the correct room. */
-       if (strcasecmp(ChrPtr(WC->wc_roomname), ChrPtr(dav_roomname))) {
+       if (strcasecmp(ChrPtr(WCC->wc_roomname), ChrPtr(dav_roomname))) {
                gotoroom(dav_roomname);
        }
-       if (strcasecmp(ChrPtr(WC->wc_roomname), ChrPtr(dav_roomname))) {
+       if (strcasecmp(ChrPtr(WCC->wc_roomname), ChrPtr(dav_roomname))) {
                hprintf("HTTP/1.1 404 not found\r\n");
                groupdav_common_headers();
                hprintf("Date: %s\r\n", datestring);
                hprintf("Content-Type: text/plain\r\n");
-               wprintf("There is no folder called \"%s\" on this server.\r\n",
+               wc_printf("There is no folder called \"%s\" on this server.\r\n",
                        ChrPtr(dav_roomname)
                );
                end_burst();
@@ -286,7 +290,7 @@ void groupdav_propfind(void)
                        hprintf("HTTP/1.1 404 not found\r\n");
                        groupdav_common_headers();
                        hprintf("Content-Type: text/plain\r\n");
-                       wprintf("Object \"%s\" was not found in the \"%s\" folder.\r\n",
+                       wc_printf("Object \"%s\" was not found in the \"%s\" folder.\r\n",
                                ChrPtr(dav_uid),
                                ChrPtr(dav_roomname)
                        );
@@ -308,31 +312,31 @@ void groupdav_propfind(void)
        
                begin_burst();
        
-               wprintf("<?xml version=\"1.0\" encoding=\"utf-8\"?>"
+               wc_printf("<?xml version=\"1.0\" encoding=\"utf-8\"?>"
                        "<multistatus xmlns=\"DAV:\">"
                );
 
-               wprintf("<response>");
+               wc_printf("<response>");
                
-               wprintf("<href>");
+               wc_printf("<href>");
                groupdav_identify_host();
-               wprintf("/groupdav/");
-               urlescputs(ChrPtr(WC->wc_roomname));
+               wc_printf("/groupdav/");
+               urlescputs(ChrPtr(WCC->wc_roomname));
                euid_escapize(encoded_uid, ChrPtr(dav_uid));
-               wprintf("/%s", encoded_uid);
-               wprintf("</href>");
-               wprintf("<propstat>");
-               wprintf("<status>HTTP/1.1 200 OK</status>");
-               wprintf("<prop>");
-               wprintf("<getetag>\"%ld\"</getetag>", dav_msgnum);
-               wprintf("<getlastmodified>");
+               wc_printf("/%s", encoded_uid);
+               wc_printf("</href>");
+               wc_printf("<propstat>");
+               wc_printf("<status>HTTP/1.1 200 OK</status>");
+               wc_printf("<prop>");
+               wc_printf("<getetag>\"%ld\"</getetag>", dav_msgnum);
+               wc_printf("<getlastmodified>");
                escputs(datestring);
-               wprintf("</getlastmodified>");
-               wprintf("</prop>");
-               wprintf("</propstat>");
+               wc_printf("</getlastmodified>");
+               wc_printf("</prop>");
+               wc_printf("</propstat>");
 
-               wprintf("</response>\n");
-               wprintf("</multistatus>\n");
+               wc_printf("</response>\n");
+               wc_printf("</multistatus>\n");
                end_burst();
                FreeStrBuf(&dav_roomname);
                FreeStrBuf(&dav_uid);
@@ -358,53 +362,53 @@ void groupdav_propfind(void)
 
        begin_burst();
 
-       wprintf("<?xml version=\"1.0\" encoding=\"utf-8\"?>"
+       wc_printf("<?xml version=\"1.0\" encoding=\"utf-8\"?>"
                "<multistatus xmlns=\"DAV:\" xmlns:G=\"http://groupdav.org/\">"
        );
 
 
-       /** Transmit the collection resource (FIXME check depth and starting point) */
-       wprintf("<response>");
+       /* Transmit the collection resource (FIXME check depth and starting point) */
+       wc_printf("<response>");
 
-       wprintf("<href>");
-               groupdav_identify_host();
-               wprintf("/groupdav/");
-               urlescputs(ChrPtr(WC->wc_roomname));
-       wprintf("</href>");
-
-       wprintf("<propstat>");
-       wprintf("<status>HTTP/1.1 200 OK</status>");
-       wprintf("<prop>");
-       wprintf("<displayname>");
-       escputs(ChrPtr(WC->wc_roomname));
-       wprintf("</displayname>");
-       wprintf("<resourcetype><collection/>");
-
-       switch(WC->wc_default_view) {
+       wc_printf("<href>");
+       groupdav_identify_host();
+       wc_printf("/groupdav/");
+       urlescputs(ChrPtr(WCC->wc_roomname));
+       wc_printf("</href>");
+
+       wc_printf("<propstat>");
+       wc_printf("<status>HTTP/1.1 200 OK</status>");
+       wc_printf("<prop>");
+       wc_printf("<displayname>");
+       escputs(ChrPtr(WCC->wc_roomname));
+       wc_printf("</displayname>");
+       wc_printf("<resourcetype><collection/>");
+
+       switch(WCC->wc_default_view) {
                case VIEW_CALENDAR:
-                       wprintf("<G:vevent-collection />");
+                       wc_printf("<G:vevent-collection />");
                        break;
                case VIEW_TASKS:
-                       wprintf("<G:vtodo-collection />");
+                       wc_printf("<G:vtodo-collection />");
                        break;
                case VIEW_ADDRESSBOOK:
-                       wprintf("<G:vcard-collection />");
+                       wc_printf("<G:vcard-collection />");
                        break;
        }
 
-       wprintf("</resourcetype>");
+       wc_printf("</resourcetype>");
        /* FIXME get the mtime
-       wprintf("<getlastmodified>");
+       wc_printf("<getlastmodified>");
                escputs(datestring);
-       wprintf("</getlastmodified>");
+       wc_printf("</getlastmodified>");
        */
-       wprintf("</prop>");
-       wprintf("</propstat>");
-       wprintf("</response>");
+       wc_printf("</prop>");
+       wc_printf("</propstat>");
+       wc_printf("</response>");
 
-       /** Transmit the collection listing (FIXME check depth and starting point) */
+       /* Transmit the collection listing (FIXME check depth and starting point) */
 
-       MsgNum = NewStrBuf ();
+       MsgNum = NewStrBuf();
        serv_puts("MSGS ALL");
 
        StrBuf_ServGetln(MsgNum);
@@ -432,43 +436,43 @@ void groupdav_propfind(void)
                }
 
                if (!IsEmptyStr(uid)) {
-                       wprintf("<response>");
-                               wprintf("<href>");
+                       wc_printf("<response>");
+                               wc_printf("<href>");
                                        groupdav_identify_host();
-                                       wprintf("/groupdav/");
-                                       urlescputs(ChrPtr(WC->wc_roomname));
+                                       wc_printf("/groupdav/");
+                                       urlescputs(ChrPtr(WCC->wc_roomname));
                                        euid_escapize(encoded_uid, uid);
-                                       wprintf("/%s", encoded_uid);
-                               wprintf("</href>");
-                               switch(WC->wc_default_view) {
+                                       wc_printf("/%s", encoded_uid);
+                               wc_printf("</href>");
+                               switch(WCC->wc_default_view) {
                                case VIEW_CALENDAR:
-                                       wprintf("<getcontenttype>text/x-ical</getcontenttype>");
+                                       wc_printf("<getcontenttype>text/x-ical</getcontenttype>");
                                        break;
                                case VIEW_TASKS:
-                                       wprintf("<getcontenttype>text/x-ical</getcontenttype>");
+                                       wc_printf("<getcontenttype>text/x-ical</getcontenttype>");
                                        break;
                                case VIEW_ADDRESSBOOK:
-                                       wprintf("<getcontenttype>text/x-vcard</getcontenttype>");
+                                       wc_printf("<getcontenttype>text/x-vcard</getcontenttype>");
                                        break;
                                }
-                               wprintf("<propstat>");
-                                       wprintf("<status>HTTP/1.1 200 OK</status>");
-                                       wprintf("<prop>");
-                                               wprintf("<getetag>\"%ld\"</getetag>", msgs[i]);
+                               wc_printf("<propstat>");
+                                       wc_printf("<status>HTTP/1.1 200 OK</status>");
+                                       wc_printf("<prop>");
+                                               wc_printf("<getetag>\"%ld\"</getetag>", msgs[i]);
                                        if (now > 0L) {
                                                http_datestring(datestring, sizeof datestring, now);
-                                               wprintf("<getlastmodified>");
+                                               wc_printf("<getlastmodified>");
                                                escputs(datestring);
-                                               wprintf("</getlastmodified>");
+                                               wc_printf("</getlastmodified>");
                                        }
-                                       wprintf("</prop>");
-                               wprintf("</propstat>");
-                       wprintf("</response>");
+                                       wc_printf("</prop>");
+                               wc_printf("</propstat>");
+                       wc_printf("</response>");
                }
        }
        FreeStrBuf(&MsgNum);
 
-       wprintf("</multistatus>\n");
+       wc_printf("</multistatus>\n");
        end_burst();
 
        if (msgs != NULL) {