Changed 'free software' to 'open source' to piss off Richard Stallman
[citadel.git] / webcit / calendar_tools.c
index 95bae39f38a74dc763975a0496dc302b86d23c75..a9b77d6114f4b8542d675f88f45f358957327ef3 100644 (file)
@@ -1,7 +1,21 @@
 /*
- * $Id$
- *
  * Miscellaneous functions which handle calendar components.
+ *
+ * Copyright (c) 1996-2010 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.
+ *
+ * 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"
@@ -34,6 +48,7 @@ char *hourname[] = {
  */
 
 void display_icaltimetype_as_webform(struct icaltimetype *t, char *prefix, int date_only) {
+       wcsession *WCC = WC;
        int i;
        time_t now;
        struct tm tm_now;
@@ -60,14 +75,14 @@ void display_icaltimetype_as_webform(struct icaltimetype *t, char *prefix, int d
                localtime_r(&tt, &tm);
        }
 
-       wprintf("<input type=\"text\" name=\"");
-       wprintf(prefix);
-       wprintf("\" id=\"");
-       wprintf(prefix);
-       wprintf("\" size=\"10\" maxlength=\"10\" value=\"");
+       wc_printf("<input type=\"text\" name=\"");
+       StrBufAppendBufPlain(WCC->WBuf, prefix, -1, 0);
+       wc_printf("\" id=\"");
+       StrBufAppendBufPlain(WCC->WBuf, prefix, -1, 0);
+       wc_printf("\" size=\"10\" maxlength=\"10\" value=\"");
        wc_strftime(timebuf, 32, "%Y-%m-%d", &tm);
-       wprintf(timebuf);
-       wprintf("\">");
+       StrBufAppendBufPlain(WCC->WBuf, timebuf, -1, 0);
+       wc_printf("\">");
 
        StrBufAppendPrintf(WC->trailing_javascript, "attachDatePicker('");
        StrBufAppendPrintf(WC->trailing_javascript, prefix);
@@ -77,46 +92,46 @@ void display_icaltimetype_as_webform(struct icaltimetype *t, char *prefix, int d
         * This keeps the data model consistent.
         */
        if (date_only) {
-               wprintf("<div style=\"display:none\">");
+               wc_printf("<div style=\"display:none\">");
        }
 
-       wprintf("<span ID=\"");
-       wprintf(prefix);
-       wprintf("_time\">");
-       wprintf(_("Hour: "));
-       wprintf("<SELECT NAME=\"%s_hour\" SIZE=\"1\">\n", prefix);
+       wc_printf("<span ID=\"");
+       StrBufAppendBufPlain(WCC->WBuf, prefix, -1, 0);
+       wc_printf("_time\">");
+       wc_printf(_("Hour: "));
+       wc_printf("<SELECT NAME=\"%s_hour\" SIZE=\"1\">\n", prefix);
        for (i=0; i<=23; ++i) {
 
                if (time_format == WC_TIMEFORMAT_24) {
-                       wprintf("<OPTION %s VALUE=\"%d\">%d</OPTION>\n",
+                       wc_printf("<OPTION %s VALUE=\"%d\">%d</OPTION>\n",
                                ((tm.tm_hour == i) ? "SELECTED" : ""),
                                i, i
                                );
                }
                else {
-                       wprintf("<OPTION %s VALUE=\"%d\">%s</OPTION>\n",
+                       wc_printf("<OPTION %s VALUE=\"%d\">%s</OPTION>\n",
                                ((tm.tm_hour == i) ? "SELECTED" : ""),
                                i, hourname[i]
                                );
                }
 
        }
-       wprintf("</SELECT>\n");
+       wc_printf("</SELECT>\n");
 
-       wprintf(_("Minute: "));
-       wprintf("<SELECT NAME=\"%s_minute\" SIZE=\"1\">\n", prefix);
+       wc_printf(_("Minute: "));
+       wc_printf("<SELECT NAME=\"%s_minute\" SIZE=\"1\">\n", prefix);
        for (i=0; i<=59; ++i) {
                if ( (i % 5 == 0) || (tm.tm_min == i) ) {
-                       wprintf("<OPTION %s VALUE=\"%d\">:%02d</OPTION>\n",
+                       wc_printf("<OPTION %s VALUE=\"%d\">:%02d</OPTION>\n",
                                ((tm.tm_min == i) ? "SELECTED" : ""),
                                i, i
                                );
                }
        }
-       wprintf("</SELECT></span>\n");
+       wc_printf("</SELECT></span>\n");
 
        if (date_only) {
-               wprintf("</div>");
+               wc_printf("</div>");
        }
 }