# ParaZ. Copyright (C) 2000-2004, Index Data ApS
# All rights reserved.
-# $Id: Makefile,v 1.5 2006-12-08 22:21:36 quinn Exp $
+# $Id: Makefile,v 1.6 2006-12-19 04:49:34 quinn Exp $
SHELL=/bin/sh
clean:
rm -f *.[oa] test core mon.out gmon.out errlist $(PROG)
+
+## Dependencies go below
+
+command.o: command.c command.h util.h eventl.h pazpar2.h termlists.h \
+ relevance.h reclists.h
+eventl.o: eventl.c eventl.h
+http.o: http.c command.h util.h eventl.h pazpar2.h termlists.h \
+ relevance.h reclists.h http.h http_command.h
+http_command.o: http_command.c command.h util.h eventl.h pazpar2.h \
+ termlists.h relevance.h reclists.h http.h http_command.h
+pazpar2.o: pazpar2.c pazpar2.h termlists.h relevance.h reclists.h \
+ eventl.h command.h http.h
+reclists.o: reclists.c pazpar2.h termlists.h relevance.h reclists.h \
+ eventl.h
+relevance.o: relevance.c relevance.h pazpar2.h termlists.h eventl.h \
+ reclists.h
+termlists.o: termlists.c termlists.h
+util.o: util.c
/*
- * $Id: http.c,v 1.5 2006-12-08 21:40:58 quinn Exp $
+ * $Id: http.c,v 1.6 2006-12-19 04:49:34 quinn Exp $
*/
#include <stdio.h>
channel_list = c;
}
-/* Create a http-channel listener */
-void http_init(int port)
+/* Create a http-channel listener, syntax [host:]port */
+void http_init(const char *addr)
{
IOCHAN c;
int l;
struct protoent *p;
struct sockaddr_in myaddr;
int one = 1;
+ const char *pp;
+ int port;
+
+ yaz_log(YLOG_LOG, "HTTP listener is %s", addr);
+
+ bzero(&myaddr, sizeof myaddr);
+ myaddr.sin_family = AF_INET;
+ pp = strchr(addr, ':');
+ if (pp)
+ {
+ int len = pp - addr;
+ char hostname[128];
+ struct hostent *he;
+
+ strncpy(hostname, addr, len);
+ hostname[len] = '\0';
+ if (!(he = gethostbyname(hostname)))
+ {
+ yaz_log(YLOG_FATAL, "Unable to resolve '%s'", hostname);
+ exit(1);
+ }
+ memcpy(&myaddr.sin_addr.s_addr, he->h_addr_list[0], he->h_length);
+ port = atoi(pp + 1);
+ }
+ else
+ {
+ port = atoi(addr);
+ myaddr.sin_addr.s_addr = INADDR_ANY;
+ }
+ myaddr.sin_port = htons(port);
- yaz_log(YLOG_LOG, "HTTP port is %d", port);
if (!(p = getprotobyname("tcp"))) {
abort();
}
&one, sizeof(one)) < 0)
abort();
- bzero(&myaddr, sizeof myaddr);
- myaddr.sin_family = AF_INET;
- myaddr.sin_addr.s_addr = INADDR_ANY;
- myaddr.sin_port = htons(port);
if (bind(l, (struct sockaddr *) &myaddr, sizeof myaddr) < 0)
yaz_log(YLOG_FATAL|YLOG_ERRNO, "bind");
if (listen(l, SOMAXCONN) < 0)
};
void http_set_proxyaddr(char *url);
-void http_init(int port);
+void http_init(const char *addr);
void http_addheader(struct http_response *r, const char *name, const char *value);
char *http_argbyname(struct http_request *r, char *name);
char *http_headerbyname(struct http_request *r, char *name);
-/* $Id: pazpar2.c,v 1.16 2006-12-18 16:29:57 quinn Exp $ */;
+/* $Id: pazpar2.c,v 1.17 2006-12-19 04:49:34 quinn Exp $ */;
#include <stdlib.h>
#include <stdio.h>
if (signal(SIGPIPE, SIG_IGN) < 0)
yaz_log(YLOG_WARN|YLOG_ERRNO, "signal");
- yaz_log_init(YLOG_DEFAULT_LEVEL|YLOG_DEBUG, "pazpar2", 0);
+ yaz_log_init(YLOG_DEFAULT_LEVEL, "pazpar2", 0);
while ((ret = options("c:h:p:C:s:", argv, argc, &arg)) != -2)
{
setport++;
break;
case 'h':
- http_init(atoi(arg));
+ http_init(arg);
setport++;
break;
case 'C':
break;
default:
fprintf(stderr, "Usage: pazpar2\n"
- " -h httpport (REST)\n"
+ " -h [host:]port (REST protocol listener)\n"
" -c cmdport (telnet-style)\n"
" -C cclconfig\n"
" -s simpletargetfile\n"