* Autocompletion now fetches candidate addresses using the AUTO server
[citadel.git] / webcit / autocompletion.c
1 /*
2  * $Id$
3  *
4  * ajax-powered autocompletion...
5  */
6
7 #include "webcit.h"
8
9
10 /*
11  * Recipient autocompletion results
12  */
13 void recp_autocomplete(void) {
14         char buf[1024];
15         char name[128];
16
17         output_headers(0, 0, 0, 0, 0, 0, 0);
18
19         wprintf("Content-type: text/html\r\n"
20                 "Server: %s\r\n"
21                 "Connection: close\r\n"
22                 "Pragma: no-cache\r\n"
23                 "Cache-Control: no-store\r\n",
24                 SERVER);
25         begin_burst();
26
27         wprintf("<ul>");
28
29
30         serv_printf("AUTO %s", bstr("recp"));
31         serv_getln(buf, sizeof buf);
32         if (buf[0] == '1') {
33                 while(serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
34                         extract_token(name, buf, 0, '|', sizeof name);
35                         wprintf("<li>");
36                         escputs(name);
37                         wprintf("</li>");
38                 }
39         }
40
41         wprintf("</ul>");
42
43         wprintf("\r\n\r\n");
44         wDumpContent(0);
45 }
46