Actually obey option -w dir
[pazpar2-moved-to-github.git] / src / pazpar2.c
index f51fa9e..f1a24bc 100644 (file)
@@ -1,5 +1,5 @@
 /* This file is part of Pazpar2.
-   Copyright (C) 2006-2011 Index Data
+   Copyright (C) 2006-2012 Index Data
 
 Pazpar2 is free software; you can redistribute it and/or modify it under
 the terms of the GNU General Public License as published by the Free
@@ -22,6 +22,10 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #endif
 #ifdef WIN32
 #include <winsock.h>
+#include <direct.h>
+#endif
+#if HAVE_UNISTD_H
+#include <unistd.h>
 #endif
 
 #include <signal.h>
@@ -114,12 +118,12 @@ static int sc_main(
     yaz_log_init_prefix("pazpar2");
     yaz_log_xml_errors(0, YLOG_WARN);
 
-    while ((ret = options("dDf:h:l:p:R:tu:v:VX", argv, argc, &arg)) != -2)
+    while ((ret = options("dDf:h:l:p:R:tu:v:Vw:X", argv, argc, &arg)) != -2)
     {
        switch (ret)
         {
         case 'd':
-            global_parameters.dump_records = 1;
+            global_parameters.dump_records++;
             break;
         case 'D':
             daemon = 1;
@@ -154,7 +158,13 @@ static int sc_main(
             show_version();
             break;
         case 'w':
-            if (chdir(arg))
+            if (
+#ifdef WIN32
+              _chdir
+#else
+              chdir
+#endif
+                (arg)) 
             {
                 yaz_log(YLOG_FATAL|YLOG_ERRNO, "chdir %s", arg);
                 return 1;