]> code.citadel.org Git - citadel.git/blobdiff - webcit/webcit.c
Mini month calendar is complete. The 'previous month'
[citadel.git] / webcit / webcit.c
index 25efc69e123bb6a578fbcf2f6f79b878eb3a7070..e3cef8ff782e95c43ab1e57efe2b791c73bbe2f8 100644 (file)
@@ -23,7 +23,7 @@
  */
 static char *unset = "; expires=28-May-1971 18:10:00 GMT";
 
-/**
+/**   
  * \brief remove escaped strings from i.e. the url string (like %20 for blanks)
  * \param buf the buffer to examine
  */
@@ -204,15 +204,16 @@ void wDumpContent(int print_standard_html_footer)
  * \param nbsp If nonzero, spaces are converted to non-breaking spaces.
  * \param nolinebreaks if set, linebreaks are removed from the string.
  */
-void stresc(char *target, char *strbuf, int nbsp, int nolinebreaks)
+long stresc(char *target, long tSize, char *strbuf, int nbsp, int nolinebreaks)
 {
-       char *aptr, *bptr;
+       char *aptr, *bptr, *eptr;
 
        *target = '\0';
        aptr = strbuf;
        bptr = target;
+       eptr = target + tSize - 6; // our biggest unit to put in... 
 
-       while (!IsEmptyStr(aptr) ){
+       while ((bptr < eptr) && !IsEmptyStr(aptr) ){
                if (*aptr == '<') {
                        memcpy(bptr, "&lt;", 4);
                        bptr += 4;
@@ -250,10 +251,10 @@ void stresc(char *target, char *strbuf, int nbsp, int nolinebreaks)
                        bptr += 6;
                }
                else if ((*aptr == '\n') && (nolinebreaks)) {
-                       strcat(bptr, "");       /* nothing */
+                       *bptr='\0';     /* nothing */
                }
                else if ((*aptr == '\r') && (nolinebreaks)) {
-                       strcat(bptr, "");       /* nothing */
+                       *bptr='\0';     /* nothing */
                }
                else{
                        *bptr = *aptr;
@@ -262,6 +263,9 @@ void stresc(char *target, char *strbuf, int nbsp, int nolinebreaks)
                aptr ++;
        }
        *bptr = '\0';
+       if ((bptr = eptr - 1 ) && !IsEmptyStr(aptr) )
+               return -1;
+       return (bptr - target);
 }
 
 /**
@@ -273,10 +277,12 @@ void stresc(char *target, char *strbuf, int nbsp, int nolinebreaks)
 void escputs1(char *strbuf, int nbsp, int nolinebreaks)
 {
        char *buf;
+       long Siz;
 
        if (strbuf == NULL) return;
-       buf = malloc( (3 * strlen(strbuf)) + SIZ );
-       stresc(buf, strbuf, nbsp, nolinebreaks);
+       Siz = (3 * strlen(strbuf)) + SIZ ;
+       buf = malloc(Siz);
+       stresc(buf, Siz, strbuf, nbsp, nolinebreaks);
        wprintf("%s", buf);
        free(buf);
 }
@@ -412,7 +418,7 @@ void msgescputs1( char *strbuf)
        outbuf = malloc( buflen);
        outbuf2 = malloc( buflen);
        msgesc(outbuf, strbuf);
-       stresc(outbuf2, outbuf, 0, 0);
+       stresc(outbuf2, buflen, outbuf, 0, 0);
        wprintf("%s", outbuf2);
        free(outbuf);
        free(outbuf2);
@@ -1499,6 +1505,8 @@ void session_loop(struct httprequest *req)
                url_do_template();
        } else if (!strcasecmp(action, "display_aide_menu")) {
                display_aide_menu();
+       } else if (!strcasecmp(action, "server_shutdown")) {
+               display_shutdown();
        } else if (!strcasecmp(action, "display_main_menu")) {
                display_main_menu();
        } else if (!strcasecmp(action, "who")) {
@@ -1525,6 +1533,10 @@ void session_loop(struct httprequest *req)
                begin_ajax_response();
                calendar_section();
                end_ajax_response();
+       } else if (!strcasecmp(action, "mini_calendar")) {
+               begin_ajax_response();
+               ajax_mini_calendar();
+               end_ajax_response();
        } else if (!strcasecmp(action, "iconbar_ajax_menu")) {
                begin_ajax_response();
                do_iconbar();
@@ -1755,6 +1767,10 @@ void session_loop(struct httprequest *req)
                display_sieve();
        } else if (!strcasecmp(action, "save_sieve")) {
                save_sieve();
+       } else if (!strcasecmp(action, "display_pushemail")) {
+               display_pushemail();
+       } else if (!strcasecmp(action, "save_pushemail")) {
+               save_pushemail();
        } else if (!strcasecmp(action, "display_add_remove_scripts")) {
                display_add_remove_scripts(NULL);
        } else if (!strcasecmp(action, "create_script")) {