* migrated to new hash create signature
authorWilfried Göesgens <willi@citadel.org>
Sat, 26 Apr 2008 09:01:37 +0000 (09:01 +0000)
committerWilfried Göesgens <willi@citadel.org>
Sat, 26 Apr 2008 09:01:37 +0000 (09:01 +0000)
* bumped min libcitadel version to 1.10
* first starts for hashing url-handlers

webcit/addressbook_popup.c
webcit/context_loop.c
webcit/siteconfig.c
webcit/webcit.c
webcit/webcit.h
webcit/who.c

index 47b40a4bd4211a93a2dd864b45e77295527971d1..03a1f6277db381684a673d97d974c7ad1009ac77 100644 (file)
@@ -49,7 +49,7 @@ void display_address_book_middle_div(void) {
        wprintf("</option>\n");
 
        
-       List = NewHash();
+       List = NewHash(1, NULL);
        serv_puts("LKRA");
        serv_getln(buf, sizeof buf);
        if (buf[0] == '1') while(len = serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
@@ -108,7 +108,7 @@ void display_address_book_inner_div() {
 
        begin_ajax_response();
 
-       List = NewHash();
+       List = NewHash(1, NULL);
        wprintf("<div align=center><form onSubmit=\"return false;\">"
                "<select multiple name=\"whichaddr\" id=\"whichaddr\" size=\"15\">\n");
 
index 79687511cf3aa47a43a65e5d4f923aca0d46bd2a..3a742a7ee63beef5b14d55f853f75a00c979e00d 100644 (file)
@@ -473,7 +473,7 @@ void context_loop(int sock)
 
                strcpy(TheSession->httpauth_user, httpauth_user);
                strcpy(TheSession->httpauth_pass, httpauth_pass);
-               TheSession->hash_prefs = NewHash();     /* Get a hash table for the user preferences */
+               TheSession->hash_prefs = NewHash(1,NULL);       /* Get a hash table for the user preferences */
                pthread_mutex_init(&TheSession->SessionMutex, NULL);
                pthread_mutex_lock(&SessionListMutex);
                TheSession->nonce = rand();
index d15d8506ced306f7bc7214ae325a658f3ccaead2..f03fe5669928d39d82e2510247aaa4509ef02610 100644 (file)
@@ -505,7 +505,7 @@ void display_siteconfig(void)
                        HashList *List;
                        HashPos  *it;
 
-                       List = NewHash();
+                       List = NewHash(1, NULL);
                        len = sizeof("UTC") + 1;
                        ZName = malloc(len + 1);
                        memcpy(ZName, "UTC", len + 1);
index ceca387e26fe69a689986966ff15cb04a0ab07b0..ed3bf025e0c0979e8f422c521a77563fceffab0a 100644 (file)
  */
 static char *unset = "; expires=28-May-1971 18:10:00 GMT";
 
+static HashList *HandlerHash = NULL;
+
+
+void WebcitAddUrlHandler(const char * UrlString, long UrlSLen, WebcitHandlerFunc F, int IsAjax)
+{
+       WebcitHandler *NewHandler;
+
+       if (HandlerHash == NULL)
+               HandlerHash = NewHash(1, NULL);
+       
+       NewHandler = (WebcitHandler*) malloc(sizeof(WebcitHandler));
+       NewHandler->F = F;
+       NewHandler->IsAjax = IsAjax;
+
+       Put(HandlerHash, UrlString, UrlSLen, NewHandler, NULL);
+}
+
 /**   
  * \brief remove escaped strings from i.e. the url string (like %20 for blanks)
  * \param buf the buffer to examine
@@ -88,7 +105,7 @@ void addurls(char *url)
        struct wcsession *WCC = WC;
 
        if (WCC->urlstrings == NULL)
-               WCC->urlstrings = NewHash();
+               WCC->urlstrings = NewHash(1, NULL);
        eptr = buf + sizeof (buf);
        up = url;
        /** locate the = sign */
@@ -1140,7 +1157,7 @@ void upload_handler(char *name, char *filename, char *partnum, char *disp,
        lprintf(9, "upload_handler() name=%s, type=%s, len=%d\n", name, cbtype, length);
 */
        if (WC->urlstrings == NULL)
-               WC->urlstrings = NewHash();
+               WC->urlstrings = NewHash(1, NULL);
 
        /* Form fields */
        if ( (length > 0) && (IsEmptyStr(cbtype)) ) {
@@ -1688,6 +1705,7 @@ void session_loop(struct httprequest *req)
         * Various commands...
         */
 
+
        else if (!strcasecmp(action, "do_welcome")) {
                do_welcome();
        } else if (!strcasecmp(action, "blank")) {
@@ -2027,7 +2045,7 @@ void session_loop(struct httprequest *req)
        else {
                display_main_menu();
        }
-
+}
 SKIP_ALL_THIS_CRAP:
        fflush(stdout);
        if (content != NULL) {
index b4a2c9ddffba305a8894a6f31f3b5ed39d7cf10d..73dba3f86001b56c3a91854fafe81d9f6220e537 100644 (file)
@@ -126,7 +126,7 @@ extern locale_t wc_locales[];
 #define CLIENT_ID              4
 #define CLIENT_VERSION         735             /* This version of WebCit */
 #define MINIMUM_CIT_VERSION    730             /* min required Citadel ver */
-#define        LIBCITADEL_MIN          109             /* min required libcitadel ver */
+#define        LIBCITADEL_MIN          110             /* min required libcitadel ver */
 #define DEFAULT_HOST           "localhost"     /* Default Citadel server */
 #define DEFAULT_PORT           "504"
 #define LB                     (1)             /* Internal escape chars */
@@ -823,6 +823,15 @@ extern char *hourname[];   /**< Names of hours (12am, 1am, etc.) */
 void http_datestring(char *buf, size_t n, time_t xtime);
 
 
+typedef void (*WebcitHandlerFunc)(void);
+typedef struct  _WebcitHandler{
+       WebcitHandlerFunc F;
+       int IsAjax;
+} WebcitHandler;
+void WebcitAddUrlHandler(const char * UrlString, long UrlSLen, WebcitHandlerFunc F, int IsAjax);
+
+
+
 /* These should be empty, but we have them for testing */
 #define DEFAULT_HTTPAUTH_USER  ""
 #define DEFAULT_HTTPAUTH_PASS  ""
index 8af2c8fa9c151948ef9795bde9925c8686a1f3db..50677c93715dd03d2517d033edcd567e6bd314a3 100644 (file)
@@ -140,7 +140,7 @@ void who_inner_div(void) {
                now = time(NULL);
        }
 
-       List = NewHash();
+       List = NewHash(1, NULL);
 
        if (GetWholistSection(List, now)) {
                it = GetNewHashPos();
@@ -408,7 +408,7 @@ void wholist_section(void) {
                now = time(NULL);
        }
 
-       List = NewHash();
+       List = NewHash(1, NULL);
 
        if (GetWholistSection(List, now)) {
                SortByPayload(List, CompareUserStruct);