Mailing list header changes (fuck you Google)
[citadel.git] / webcit / autocompletion.c
1 /*
2  * ajax-powered autocompletion...
3  *
4  * Copyright (c) 1996-2012 by the citadel.org team
5  *
6  * This program is open source software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License, version 3.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  */
14
15 #include "webcit.h"
16
17 /*
18  * Recipient autocompletion results
19  */
20 void recp_autocomplete(char *partial) {
21         char buf[1024];
22         char name[128];
23
24         output_headers(0, 0, 0, 0, 0, 0);
25
26         hprintf("Content-type: text/html\r\n"
27                 "Server: %s\r\n"
28                 "Connection: close\r\n"
29                 "Pragma: no-cache\r\n"
30                 "Cache-Control: no-store\r\n"
31                 "Expires: -1\r\n"
32                 ,
33                 PACKAGE_STRING);
34         begin_burst();
35
36         wc_printf("<ul>");
37
38         serv_printf("AUTO %s", partial);
39         serv_getln(buf, sizeof buf);
40         if (buf[0] == '1') {
41                 while(serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
42                         extract_token(name, buf, 0, '|', sizeof name);
43                         wc_printf("<li>");
44                         escputs(name);
45                         wc_printf("</li>");
46                 }
47         }
48
49         wc_printf("</ul>");
50
51         wc_printf("\r\n\r\n");
52         wDumpContent(0);
53 }
54
55
56 void _recp_autocomplete(void) {recp_autocomplete(bstr("recp"));}
57 void _cc_autocomplete(void)   {recp_autocomplete(bstr("cc"));} 
58 void _bcc_autocomplete(void)  {recp_autocomplete(bstr("bcc"));}
59
60
61 void 
62 InitModule_AUTO_COMPLETE
63 (void)
64 {
65         WebcitAddUrlHandler(HKEY("recp_autocomplete"), "", 0, _recp_autocomplete, 0);
66         WebcitAddUrlHandler(HKEY("cc_autocomplete"),   "", 0, _cc_autocomplete, 0);
67         WebcitAddUrlHandler(HKEY("bcc_autocomplete"),  "", 0, _bcc_autocomplete, 0);
68 }