Remove $Id$ tags from most of webcit
[citadel.git] / webcit / autocompletion.c
1 /*
2  * ajax-powered autocompletion...
3  *
4  * Copyright (c) 1996-2010 by the citadel.org team
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  */
20
21 #include "webcit.h"
22
23 /*
24  * Recipient autocompletion results
25  */
26 void recp_autocomplete(char *partial) {
27         char buf[1024];
28         char name[128];
29
30         output_headers(0, 0, 0, 0, 0, 0);
31
32         hprintf("Content-type: text/html\r\n"
33                 "Server: %s\r\n"
34                 "Connection: close\r\n"
35                 "Pragma: no-cache\r\n"
36                 "Cache-Control: no-store\r\n"
37                 "Expires: -1\r\n"
38                 ,
39                 PACKAGE_STRING);
40         begin_burst();
41
42         wc_printf("<ul>");
43
44         serv_printf("AUTO %s", partial);
45         serv_getln(buf, sizeof buf);
46         if (buf[0] == '1') {
47                 while(serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
48                         extract_token(name, buf, 0, '|', sizeof name);
49                         wc_printf("<li>");
50                         escputs(name);
51                         wc_printf("</li>");
52                 }
53         }
54
55         wc_printf("</ul>");
56
57         wc_printf("\r\n\r\n");
58         wDumpContent(0);
59 }
60
61
62 void _recp_autocomplete(void) {recp_autocomplete(bstr("recp"));}
63 void _cc_autocomplete(void)   {recp_autocomplete(bstr("cc"));} 
64 void _bcc_autocomplete(void)  {recp_autocomplete(bstr("bcc"));}
65
66
67 void 
68 InitModule_AUTO_COMPLETE
69 (void)
70 {
71         WebcitAddUrlHandler(HKEY("recp_autocomplete"), "", 0, _recp_autocomplete, 0);
72         WebcitAddUrlHandler(HKEY("cc_autocomplete"),   "", 0, _cc_autocomplete, 0);
73         WebcitAddUrlHandler(HKEY("bcc_autocomplete"),  "", 0, _bcc_autocomplete, 0);
74 }