* use strbuffer as wprintf backend
[citadel.git] / webcit / autocompletion.c
index 9c99817350d1c4b55d4cf618ae1c3c607e61ffc3..4cf4ccd6f659ff139fe84df68da623d681c6282e 100644 (file)
@@ -6,28 +6,28 @@
 
 #include "webcit.h"
 
-
 /*
  * Recipient autocompletion results
  */
-void recp_autocomplete(void) {
+void recp_autocomplete(char *partial) {
        char buf[1024];
        char name[128];
 
-       output_headers(0, 0, 0, 0, 0, 0, 0);
+       output_headers(0, 0, 0, 0, 0, 0);
 
-       wprintf("Content-type: text/html\r\n"
+       hprintf("Content-type: text/html\r\n"
                "Server: %s\r\n"
                "Connection: close\r\n"
                "Pragma: no-cache\r\n"
-               "Cache-Control: no-store\r\n",
-               SERVER);
+               "Cache-Control: no-store\r\n"
+               "Expires: -1\r\n"
+               ,
+               PACKAGE_STRING);
        begin_burst();
 
        wprintf("<ul>");
 
-
-       serv_printf("AUTO %s", bstr("recp"));
+       serv_printf("AUTO %s", partial);
        serv_getln(buf, sizeof buf);
        if (buf[0] == '1') {
                while(serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
@@ -44,3 +44,17 @@ void recp_autocomplete(void) {
        wDumpContent(0);
 }
 
+
+void _recp_autocomplete(void) {recp_autocomplete(bstr("recp"));}
+void _cc_autocomplete(void)   {recp_autocomplete(bstr("cc"));} 
+void _bcc_autocomplete(void)  {recp_autocomplete(bstr("bcc"));}
+
+
+void 
+InitModule_AUTO_COMPLETE
+(void)
+{
+       WebcitAddUrlHandler(HKEY("recp_autocomplete"), _recp_autocomplete, 0);
+       WebcitAddUrlHandler(HKEY("cc_autocomplete"),   _cc_autocomplete, 0);
+       WebcitAddUrlHandler(HKEY("bcc_autocomplete"),  _bcc_autocomplete, 0);
+}