From 3f46a4cb43b195b827e585b8806a9fcd3f23d466 Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 20 Apr 2008 20:47:49 +0200 Subject: [PATCH] Init winsock. Incorporate ICU. Pazpar2 runs on Windows. --- src/charsets.c | 5 +++-- src/connection.c | 2 +- src/icu_I18N.c | 11 +++++++---- src/pazpar2.c | 20 ++++++++++++++++++++ win/makefile | 33 ++++++++++++++++++--------------- 5 files changed, 49 insertions(+), 22 deletions(-) diff --git a/src/charsets.c b/src/charsets.c index 80388e8..b2470bd 100644 --- a/src/charsets.c +++ b/src/charsets.c @@ -70,9 +70,10 @@ pp2_charset_t pp2_charset_create_xml(xmlNode *xml_node) { #ifdef HAVE_ICU UErrorCode status = U_ZERO_ERROR; + struct icu_chain *chain = 0; while (xml_node && xml_node->type != XML_ELEMENT_NODE) xml_node = xml_node->next; - struct icu_chain *chain = icu_chain_xml_config(xml_node, &status); + chain = icu_chain_xml_config(xml_node, &status); if (!chain || U_FAILURE(status)){ //xmlDocPtr icu_doc = 0; //xmlChar *xmlstr = 0; @@ -139,8 +140,8 @@ pp2_relevance_token_t pp2_relevance_tokenize(pp2_charset_t pct, #ifdef HAVE_ICU if (pct->icu_chn) { - pct->icu_sts = U_ZERO_ERROR; int ok = 0; + pct->icu_sts = U_ZERO_ERROR; ok = icu_chain_assign_cstr(pct->icu_chn, buf, &pct->icu_sts); //printf("\nfield ok: %d '%s'\n", ok, buf); prt->pct = pct; diff --git a/src/connection.c b/src/connection.c index 9a152b0..c330155 100644 --- a/src/connection.c +++ b/src/connection.c @@ -183,7 +183,7 @@ static void connection_handler(IOCHAN i, int event) int errcode; socklen_t errlen = sizeof(errcode); - if (getsockopt(cs_fileno(co->link), SOL_SOCKET, SO_ERROR, &errcode, + if (getsockopt(cs_fileno(co->link), SOL_SOCKET, SO_ERROR, (char*) &errcode, &errlen) < 0 || errcode != 0) { client_fatal(cl); diff --git a/src/icu_I18N.c b/src/icu_I18N.c index cfd3b18..f40b529 100644 --- a/src/icu_I18N.c +++ b/src/icu_I18N.c @@ -885,6 +885,8 @@ struct icu_chain * icu_chain_xml_config(xmlNode *xml_node, xmlNode *node = 0; struct icu_chain * chain = 0; + xmlChar *xml_id = 0; + xmlChar *xml_locale = 0; if (!xml_node ||xml_node->type != XML_ELEMENT_NODE @@ -892,8 +894,8 @@ struct icu_chain * icu_chain_xml_config(xmlNode *xml_node, return 0; - xmlChar *xml_id = xmlGetProp(xml_node, (xmlChar *) "id"); - xmlChar *xml_locale = xmlGetProp(xml_node, (xmlChar *) "locale"); + xml_id = xmlGetProp(xml_node, (xmlChar *) "id"); + xml_locale = xmlGetProp(xml_node, (xmlChar *) "locale"); if (!xml_id || !strlen((const char *) xml_id) || !xml_locale || !strlen((const char *) xml_locale)) @@ -909,11 +911,12 @@ struct icu_chain * icu_chain_xml_config(xmlNode *xml_node, for (node = xml_node->children; node; node = node->next) { + xmlChar *xml_rule = 0; + struct icu_chain_step * step = 0; if (node->type != XML_ELEMENT_NODE) continue; - xmlChar *xml_rule = xmlGetProp(node, (xmlChar *) "rule"); - struct icu_chain_step * step = 0; + xml_rule = xmlGetProp(node, (xmlChar *) "rule"); if (!strcmp((const char *) node->name, (const char *) "casemap")){ diff --git a/src/pazpar2.c b/src/pazpar2.c index dbcf4b8..7eecacb 100644 --- a/src/pazpar2.c +++ b/src/pazpar2.c @@ -20,6 +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 @@ -64,6 +67,20 @@ static void show_version(void) exit(0); } +#ifdef WIN32 +static int tcpip_init (void) +{ + WORD requested; + WSADATA wd; + + requested = MAKEWORD(1, 1); + if (WSAStartup(requested, &wd)) + return 0; + return 1; +} +#endif + + int main(int argc, char **argv) { int daemon = 0; @@ -76,6 +93,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"); @@ -83,6 +102,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) diff --git a/win/makefile b/win/makefile index abc3cd7..685ca97 100644 --- a/win/makefile +++ b/win/makefile @@ -1,7 +1,7 @@ # This file is part of Pazpar2. # Copyright (C) 2006-2008 Index Data -DEBUG=0 # 0 for release, 1 for debug +DEBUG=1 # 0 for release, 1 for debug USE_MANIFEST = 0 # Can be enabled Visual Studio 2005 PACKAGE_NAME=pazpar2 PACKAGE_VERSION=1.0.7 @@ -15,6 +15,10 @@ ICONV_DIR=\iconv-1.9.2.win32 LIBXML2_DIR=\libxml2-2.6.28.win32 LIBXSLT_DIR=\libxslt-1.1.19.win32 +# ICU +HAVE_ICU=1 +ICU_DIR=c:\icu + default: all all: dirs yaz libxslt pazpar2 @@ -45,8 +49,6 @@ YAZD=yaz3 TMPDIR=$(ROOTDIR)\win\tmp TMP=$(TMPDIR) -# Targets - what to make - PAZPAR2_EXE=$(BINDIR)\pazpar2.exe pazpar2: $(PAZPAR2_EXE) @@ -57,6 +59,7 @@ YAZ_DEF=/DYAZ_HAVE_XML2=2 /DYAZ_HAVE_XSLT=1 /I"$(YAZ_DIR)\include" yaz: $(BINDIR)\$(YAZD).dll $(BINDIR)\$(YAZD).dll: "$(YAZ_DIR)\bin\$(YAZD).dll" + copy "$(YAZ_DIR)\bin\icu*.dll" $(BINDIR) copy "$(YAZ_DIR)\bin\$(YAZD).dll" $(BINDIR) # Copy libxslt and associates to our bin directory @@ -79,6 +82,16 @@ LIBXSLT_LIB = \ "$(LIBXML2_DIR)\lib\libxml2.lib" \ "$(LIBXSLT_DIR)\lib\libxslt.lib" +!if $(HAVE_ICU) +ICU_DEF=/DHAVE_ICU=1 /D HAVE_ICU_H=1 /I"$(ICU_DIR)\include" +ICU_LIB= $(ICU_DIR)\lib\icudt.lib \ + $(ICU_DIR)\lib\icuin.lib \ + $(ICU_DIR)\lib\icuuc.lib +!else +ICU_DEF=/DHAVE_ICU=0 +ICU_LIB= +!endif + COMMON_C_OPTIONS= \ /nologo /W3 /EHsc /FD /c \ /D "_CRT_SECURE_NO_DEPRECATE" \ @@ -86,6 +99,7 @@ COMMON_C_OPTIONS= \ /D "PACKAGE_NAME=\"$(PACKAGE_NAME)\"" \ /D "VERSION=\"$(PACKAGE_VERSION)\"" \ $(YAZ_DEF) \ + $(ICU_DEF) \ $(LIBXSLT_DEF) \ /D "_WINDOWS" \ /D "WIN32" \ @@ -126,7 +140,7 @@ LINK=link.exe LINK_LIBS= kernel32.lib user32.lib gdi32.lib advapi32.lib uuid.lib \ wsock32.lib advapi32.lib \ - $(YAZ_LIB) $(LIBXSLT_LIB) + $(YAZ_LIB) $(ICU_LIB) $(LIBXSLT_LIB) COMMON_LNK_OPTIONS= /nologo /subsystem:windows /machine:i386 /incremental:no @@ -177,17 +191,6 @@ PAZPAR2_OBJS = \ {$(SRCDIR)}.c{$(OBJDIR)}.obj: $(CPP) $(COPT) $< -### The RC compiler (resource files) -RSC=rc.exe -COMMON_RC_OPTIONS= /l 0x406 /i"$(ROOTDIR)" -DEBUG_RC_OPTIONS=/d "_DEBUG" -RELEASE_RC_OPTIONS=/d "NDEBUG" - -!if $(DEBUG) -RSOPT=/d_DEBUG -!else -RSOPT=/d_NDEBUG -!endif !if $(USE_MANIFEST) MT=mt.exe /nologo -- 1.7.10.4