X-Git-Url: http://lists.indexdata.dk/cgi-bin?a=blobdiff_plain;f=src%2Fpazpar2.c;h=371d6f5f5d6dab3ae228fe3be8c0fe650f726e49;hb=5fdac8e7a282d625568f5768bd3ae9367dd4acaf;hp=a4be363abf0b0fbb4dcc0ddf99c7ed6f5c970820;hpb=cc178327044177f177d0474b757f53bcd86b4d42;p=pazpar2-moved-to-github.git diff --git a/src/pazpar2.c b/src/pazpar2.c index a4be363..371d6f5 100644 --- a/src/pazpar2.c +++ b/src/pazpar2.c @@ -20,7 +20,9 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #if HAVE_CONFIG_H #include #endif - +#ifdef WIN32 +#include +#endif #include #include @@ -29,6 +31,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "database.h" #include "settings.h" #include +#include void child_handler(void *data) { @@ -65,7 +68,21 @@ static void show_version(void) exit(0); } -int main(int argc, char **argv) +#ifdef WIN32 +static int tcpip_init (void) +{ + WORD requested; + WSADATA wd; + + requested = MAKEWORD(1, 1); + if (WSAStartup(requested, &wd)) + return 0; + return 1; +} +#endif + + +static int sc_main(yaz_sc_t s, int argc, char **argv) { int daemon = 0; int ret; @@ -77,6 +94,8 @@ int main(int argc, char **argv) #ifndef WIN32 if (signal(SIGPIPE, SIG_IGN) == SIG_ERR) yaz_log(YLOG_WARN|YLOG_ERRNO, "signal"); +#else + tcpip_init(); #endif yaz_log_init_prefix("pazpar2"); @@ -84,6 +103,7 @@ int main(int argc, char **argv) yaz_log_xml_errors(0, YLOG_WARN); #endif + while ((ret = options("dDf:h:l:p:t:u:VX", argv, argc, &arg)) != -2) { switch (ret) @@ -150,7 +170,12 @@ int main(int argc, char **argv) } global_parameters.server = config->servers; - start_http_listener(); + ret = start_http_listener(); + if (ret) + return ret; /* error starting http listener */ + + yaz_sc_running(s); + yaz_daemon("pazpar2", (global_parameters.debug_mode ? YAZ_DAEMON_DEBUG : 0) + (daemon ? YAZ_DAEMON_FORK : 0) + YAZ_DAEMON_KEEPALIVE, @@ -160,6 +185,22 @@ int main(int argc, char **argv) } +static void sc_stop(yaz_sc_t s) +{ + +} + +int main(int argc, char **argv) +{ + int ret; + yaz_sc_t s = yaz_sc_create("pazpar2", "Pazpar Metasearcher"); + + ret = yaz_sc_program(s, argc, argv, sc_main, sc_stop); + + yaz_sc_destroy(&s); + exit(ret); +} + /* * Local variables: * c-basic-offset: 4