function reclist_insert() does not change mergekey, so parameter signature changed...
[pazpar2-moved-to-github.git] / src / http.c
index 5248ede..189cbe3 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: http.c,v 1.23 2007-04-10 08:48:56 adam Exp $
+/* $Id: http.c,v 1.30 2007-04-23 08:56:52 marc Exp $
    Copyright (c) 2006-2007, Index Data.
 
 This file is part of Pazpar2.
@@ -56,10 +56,6 @@ static void proxy_io(IOCHAN i, int event);
 static struct http_channel *http_create(const char *addr);
 static void http_destroy(IOCHAN i);
 
-extern IOCHAN channel_list;
-extern struct parameters global_parameters;
-//extern NMEM nmem;
-
 // If this is set, we proxy normal HTTP requests
 static struct sockaddr_in *proxy_addr = 0; 
 static char proxy_url[256] = "";
@@ -612,8 +608,7 @@ static int http_proxy(struct http_request *rq)
         // We will add EVENT_OUTPUT below
         p->iochan = iochan_create(sock, proxy_io, EVENT_INPUT);
         iochan_setdata(p->iochan, p);
-        p->iochan->next = channel_list;
-        channel_list = p->iochan;
+        pazpar2_add_channel(p->iochan);
     }
 
     // Do _not_ modify Host: header, just checking it's existence
@@ -947,7 +942,7 @@ static struct http_channel *http_create(const char *addr)
         yaz_log(YLOG_WARN, "Invalid HTTP forward address");
         exit(1);
     }
-    r->addr = nmem_strdup(r->nmem, addr);
+    strcpy(r->addr, addr);
     return r;
 }
 
@@ -981,8 +976,7 @@ static void http_accept(IOCHAN i, int event)
     ch->iochan = c;
     iochan_setdata(c, ch);
 
-    c->next = channel_list;
-    channel_list = c;
+    pazpar2_add_channel(c);
 }
 
 /* Create a http-channel listener, syntax [host:]port */
@@ -1009,8 +1003,7 @@ void http_init(const char *addr)
 
         strncpy(hostname, addr, len);
         hostname[len] = '\0';
-        if (!(he = gethostbyname(hostname)))
-        {
+        if (!(he = gethostbyname(hostname))){
             yaz_log(YLOG_FATAL, "Unable to resolve '%s'", hostname);
             exit(1);
         }
@@ -1025,26 +1018,12 @@ void http_init(const char *addr)
     }
     else
     {
-        //size_t len = 128;
-        //char h[len];
         port = atoi(addr);
         myaddr.sin_addr.s_addr = INADDR_ANY;
-
-#if 0
-        // get hostname from system - after deciding to bind to any 
-        // IP address this box might have.
-        if (0 == gethostname(h, len)){
-            h[len - 1] = '\0';
-            global_parameters.server->host = nmem_strdup(nmem, h);
-        } else 
-            yaz_log(YLOG_WARN, "Could not get host name");
-#endif
     }
 
-
     myaddr.sin_port = htons(port);
 
-
     if (!(p = getprotobyname("tcp"))) {
         abort();
     }
@@ -1060,8 +1039,7 @@ void http_init(const char *addr)
         yaz_log(YLOG_FATAL|YLOG_ERRNO, "listen");
 
     c = iochan_create(l, http_accept, EVENT_INPUT | EVENT_EXCEPT);
-    c->next = channel_list;
-    channel_list = c;
+    pazpar2_add_channel(c);
 }
 
 void http_set_proxyaddr(char *host, char *base_url)