Back to index

webcit  8.12-dfsg
autocompletion.c
Go to the documentation of this file.
00001 /*
00002  * ajax-powered autocompletion...
00003  *
00004  * Copyright (c) 1996-2012 by the citadel.org team
00005  *
00006  * This program is open source software: you can redistribute it and/or modify
00007  * it under the terms of the GNU General Public License, version 3.
00008  *
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  */
00014 
00015 #include "webcit.h"
00016 
00017 /*
00018  * Recipient autocompletion results
00019  */
00020 void recp_autocomplete(char *partial) {
00021        char buf[1024];
00022        char name[128];
00023 
00024        output_headers(0, 0, 0, 0, 0, 0);
00025 
00026        hprintf("Content-type: text/html\r\n"
00027               "Server: %s\r\n"
00028               "Connection: close\r\n"
00029               "Pragma: no-cache\r\n"
00030               "Cache-Control: no-store\r\n"
00031               "Expires: -1\r\n"
00032               ,
00033               PACKAGE_STRING);
00034        begin_burst();
00035 
00036        wc_printf("<ul>");
00037 
00038        serv_printf("AUTO %s", partial);
00039        serv_getln(buf, sizeof buf);
00040        if (buf[0] == '1') {
00041               while(serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
00042                      extract_token(name, buf, 0, '|', sizeof name);
00043                      wc_printf("<li>");
00044                      escputs(name);
00045                      wc_printf("</li>");
00046               }
00047        }
00048 
00049        wc_printf("</ul>");
00050 
00051        wc_printf("\r\n\r\n");
00052        wDumpContent(0);
00053 }
00054 
00055 
00056 void _recp_autocomplete(void) {recp_autocomplete(bstr("recp"));}
00057 void _cc_autocomplete(void)   {recp_autocomplete(bstr("cc"));} 
00058 void _bcc_autocomplete(void)  {recp_autocomplete(bstr("bcc"));}
00059 
00060 
00061 void 
00062 InitModule_AUTO_COMPLETE
00063 (void)
00064 {
00065        WebcitAddUrlHandler(HKEY("recp_autocomplete"), "", 0, _recp_autocomplete, 0);
00066        WebcitAddUrlHandler(HKEY("cc_autocomplete"),   "", 0, _cc_autocomplete, 0);
00067        WebcitAddUrlHandler(HKEY("bcc_autocomplete"),  "", 0, _bcc_autocomplete, 0);
00068 }