Index: /trunk/docs/install/installation.rst
===================================================================
--- /trunk/docs/install/installation.rst (revision 783)
+++ /trunk/docs/install/installation.rst (revision 784)
@@ -87,4 +87,21 @@
ZOO-Kernel will be deployed in the specified directory (so,
`/Lbrary/WebServer/CGI-Executables`` in this example).
+
+Specific main.cfg location (Optional)
+**************************************
+
+Per default, the ZOO-Kernel search for the ``main.cfg`` file from its
+installation directory but, in case you want to store this file in
+another place, then you can use the ``--with-etc-dir`` option so it
+will search for the ``main.cfg``file in the ``sysconfdir`` directory.
+
+For instance, you can define that the directory to store the
+``main.cfg`` file is the ``/etc/zoo-project`` directory, by using the
+following command:
+
+.. code::
+
+ ./configure --with-etc-dir=yes --sysconfdir=/etc/zoo-project
+
.. _zoo_install_db_backend:
Index: /trunk/docs/kernel/configuration.rst
===================================================================
--- /trunk/docs/kernel/configuration.rst (revision 783)
+++ /trunk/docs/kernel/configuration.rst (revision 784)
@@ -87,4 +87,8 @@
Resource Sharing `__. If this
paramater is not defined, then the ZOO-Kernel won't support CORS.
+ * ``servicePath``: Define a specific location to search for services
+ rather than using the ZOO-Kernel directory. If this parameter is
+ not defined, then the ZOO-Kernel will search for services using its
+ directory.
In case you have activated the MapServer support, please refer to
Index: /trunk/zoo-project/HISTORY.txt
===================================================================
--- /trunk/zoo-project/HISTORY.txt (revision 783)
+++ /trunk/zoo-project/HISTORY.txt (revision 784)
@@ -1,3 +1,5 @@
Version 1.6.0-dev
+ * Add servicePath special key to specify the service location
+ * Add --with-etc-dir option to specify the location of the main.cfg file
* Support GDAL version 2.1.0.
* Add the MapServer 7.0.1 internal support.
Index: /trunk/zoo-project/zoo-kernel/Makefile.in
===================================================================
--- /trunk/zoo-project/zoo-kernel/Makefile.in (revision 783)
+++ /trunk/zoo-project/zoo-kernel/Makefile.in (revision 784)
@@ -3,6 +3,8 @@
all: version.h zoo_loader.cgi ${YAML_FILE1}
-version.h:
+version.h: Makefile
echo "#define ZOO_VERSION \"`svnversion`\"" > version.h
+ echo "@ETC_DEF@" >> version.h
+ echo "#define LOCALEDIR \"@localedir@\"" >> version.h
service.o: service.c service.h
@@ -90,5 +92,5 @@
g++ -c ${XML2CFLAGS} ${PYTHONCFLAGS} ${CFLAGS} service_loader.c
-zoo_service_loader.o: zoo_service_loader.c service.h
+zoo_service_loader.o: zoo_service_loader.c service.h version.h ${MS_FILE} ${PYTHON_FILE} ${PHP_FILE} ${JAVA_FILE} ${JS_FILE} ${PERL_FILE} ${RUBY_FILE} ${YAML_FILE} ${OTB_FILE} ${SAGA_FILE}
g++ -g -O2 ${XML2CFLAGS} ${CFLAGS} ${SAGA_CFLAGS} ${OTBCFLAGS} ${PYTHONCFLAGS} ${JAVACFLAGS} ${JSCFLAGS} ${PERLCFLAGS} ${PHPCFLAGS} ${SAGA_ENABLED} ${OTB_ENABLED} ${PYTHON_ENABLED} ${JS_ENABLED} ${PHP_ENABLED} ${PERL_ENABLED} ${JAVA_ENABLED} -c zoo_service_loader.c -fno-common -DPIC -o zoo_service_loader.o
Index: /trunk/zoo-project/zoo-kernel/ZOOMakefile.opts.in
===================================================================
--- /trunk/zoo-project/zoo-kernel/ZOOMakefile.opts.in (revision 783)
+++ /trunk/zoo-project/zoo-kernel/ZOOMakefile.opts.in (revision 784)
@@ -99,2 +99,3 @@
LDFLAGS=-lzoo_service @DEFAULT_LIBS@ -L../../thirds/cgic206 -lcgic ${GDAL_LIBS} ${XML2LDFLAGS} ${PYTHONLDFLAGS} ${PERLLDFLAGS} ${PHPLDFLAGS} ${JAVALDFLAGS} ${JSLDFLAGS} ${FCGI_LDFLAGS} @OPENSSL_LDFLAGS@ -luuid ${MS_LDFLAGS} ${MACOS_LD_FLAGS} ${MACOS_LD_NET_FLAGS} ${YAML_LDFLAGS} ${OTBLDFLAGS} ${SAGA_LDFLAGS}
+DATAROOTDIR=@datarootdir@/zoo-project
Index: /trunk/zoo-project/zoo-kernel/configure.ac
===================================================================
--- /trunk/zoo-project/zoo-kernel/configure.ac (revision 783)
+++ /trunk/zoo-project/zoo-kernel/configure.ac (revision 784)
@@ -67,4 +67,9 @@
fi
AC_SUBST([DEB_DEF])
+
+AC_ARG_WITH([etc-dir],
+ [AS_HELP_STRING([--with-etc-dir=PATH], [Specifies an alternative path to store the main.cfg file ( default: ZOO-Kernel location) ])],
+ [ETC_DEF="#define ETC_DIR \\\"${sysconfdir}\\\""], [ETC_DEF=""])
+AC_SUBST([ETC_DEF])
AC_ARG_WITH([cgi-dir],
Index: /trunk/zoo-project/zoo-kernel/locale/po/messages.po
===================================================================
--- /trunk/zoo-project/zoo-kernel/locale/po/messages.po (revision 783)
+++ /trunk/zoo-project/zoo-kernel/locale/po/messages.po (revision 784)
@@ -305,4 +305,8 @@
msgstr "Unable to load the main.cfg file."
+#: zoo_service_loader.c:895
+msgid "%s The following file: %s cannot be found."
+msgstr "%s The following file: %s cannot be found."
+
#: zoo_service_loader.c:940
#, c-format
Index: /trunk/zoo-project/zoo-kernel/main_conf_read.l
===================================================================
--- /trunk/zoo-project/zoo-kernel/main_conf_read.l (revision 783)
+++ /trunk/zoo-project/zoo-kernel/main_conf_read.l (revision 784)
@@ -36,5 +36,5 @@
attname [a-zA-Z0-9_\-:.]+
-attvalue1 [%\*,;@a-zA-Z0-9_\-.:" "\"\'/\\\(\)\+\x41-\xff?&=]+
+attvalue1 [%\*,;@a-zA-Z0-9_\-.:" "\"\'/\\\(\)\+\x41-\xff?&=\!$]+
whitesp [ ]
Index: /trunk/zoo-project/zoo-kernel/response_print.c
===================================================================
--- /trunk/zoo-project/zoo-kernel/response_print.c (revision 783)
+++ /trunk/zoo-project/zoo-kernel/response_print.c (revision 784)
@@ -1546,14 +1546,20 @@
* Else fallback to the initial method using the xml file to write in ...
*/
- char ntmp[1024];
-#ifndef WIN32
- getcwd(ntmp,1024);
-#else
- _getcwd(ntmp,1024);
-#endif
+ map* cwdMap=getMapFromMaps(m,"main","servicePath");
struct stat myFileInfo;
int statRes;
char file_path[1024];
- sprintf(file_path,"%s/GetStatus.zcfg",ntmp);
+ if(cwdMap!=NULL){
+ sprintf(file_path,"%s/GetStatus.zcfg",cwdMap->value);
+ }else{
+ char ntmp[1024];
+#ifndef WIN32
+ getcwd(ntmp,1024);
+#else
+ _getcwd(ntmp,1024);
+#endif
+ sprintf(file_path,"%s/GetStatus.zcfg",ntmp);
+ }
+ fprintf(stderr,"%s \n",file_path);
statRes=stat(file_path,&myFileInfo);
if(statRes==0){
Index: /trunk/zoo-project/zoo-kernel/service_internal_js.c
===================================================================
--- /trunk/zoo-project/zoo-kernel/service_internal_js.c (revision 783)
+++ /trunk/zoo-project/zoo-kernel/service_internal_js.c (revision 784)
@@ -70,7 +70,4 @@
JS_MaybeGC(cx);
- char ntmp[1024];
- getcwd(ntmp,1024);
-
jsval *argv = JS_ARGV(cx,argv1);
int i=0;
@@ -78,12 +75,9 @@
for(i=0;ivalue);
+ else
+ getcwd(ntmp,1024);
/**
Index: /trunk/zoo-project/zoo-kernel/service_internal_php.c
===================================================================
--- /trunk/zoo-project/zoo-kernel/service_internal_php.c (revision 783)
+++ /trunk/zoo-project/zoo-kernel/service_internal_php.c (revision 784)
@@ -185,6 +185,4 @@
maps* inputs=*real_inputs;
maps* outputs=*real_outputs;
- char ntmp[1024];
- getcwd(ntmp,1024);
map* libp = getMapFromMaps(m, "main", "libPath");
Index: /trunk/zoo-project/zoo-kernel/service_internal_python.c
===================================================================
--- /trunk/zoo-project/zoo-kernel/service_internal_python.c (revision 783)
+++ /trunk/zoo-project/zoo-kernel/service_internal_python.c (revision 784)
@@ -168,5 +168,9 @@
}
else{
- python_path=(char*)".";
+ map* cwdMap=getMapFromMaps(*main_conf,"main","servicePath");
+ if(cwdMap!=NULL)
+ python_path=cwdMap->value;
+ else
+ python_path=(char*)".";
}
tmp=NULL;
Index: /trunk/zoo-project/zoo-kernel/sqlapi.c
===================================================================
--- /trunk/zoo-project/zoo-kernel/sqlapi.c (revision 783)
+++ /trunk/zoo-project/zoo-kernel/sqlapi.c (revision 784)
@@ -27,4 +27,7 @@
#include "ogrsf_frmts.h"
#include "ogr_p.h"
+#if GDAL_VERSION_MAJOR >= 2
+#include
+#endif
#include "sqlapi.h"
@@ -35,5 +38,10 @@
* Global GDALDataset pointer
*/
-OGRDataSource *zoo_DS = NULL;
+#if GDAL_VERSION_MAJOR >=2
+GDALDataset
+#else
+OGRDataSource
+#endif
+ *zoo_DS = NULL;
/**
@@ -98,5 +106,12 @@
OGRSFDriver *poDriver = NULL;
OGRRegisterAll();
+
+#if GDAL_VERSION_MAJOR >= 2
+ zoo_DS = (GDALDataset*) GDALOpenEx( sqlInitString,
+ GDAL_OF_UPDATE | GDAL_OF_VECTOR,
+ NULL, NULL, NULL );
+#else
zoo_DS = OGRSFDriverRegistrar::Open(sqlInitString,false,&poDriver);
+#endif
if( zoo_DS == NULL ){
#ifdef DEBUG
@@ -124,5 +139,9 @@
zoo_DS->ReleaseResultSet( zoo_ResultSet );
if(zoo_DS!=NULL){
+#if GDAL_VERSION_MAJOR >= 2
+ GDALClose(zoo_DS);
+#else
OGRDataSource::DestroyDataSource( zoo_DS );
+#endif
zoo_DS=NULL;
}
Index: /trunk/zoo-project/zoo-kernel/sqlapi.h
===================================================================
--- /trunk/zoo-project/zoo-kernel/sqlapi.h (revision 783)
+++ /trunk/zoo-project/zoo-kernel/sqlapi.h (revision 784)
@@ -25,12 +25,11 @@
#ifndef ZOO_SQLAPI_H
#define ZOO_SQLAPI_H 1
+#ifdef RELY_ON_DB
+#include "service.h"
+#include "service_internal.h"
#ifdef __cplusplus
extern "C" {
#endif
-
-#ifdef RELY_ON_DB
-#include "service.h"
-#include "service_internal.h"
ZOO_DLL_EXPORT void init_sql(maps*);
ZOO_DLL_EXPORT void close_sql(maps*);
@@ -43,5 +42,4 @@
ZOO_DLL_EXPORT char* getStatusId(maps*,char*);
ZOO_DLL_EXPORT void removeService(maps*,char*);
-#endif
#ifdef __cplusplus
@@ -50,2 +48,3 @@
#endif
+#endif
Index: /trunk/zoo-project/zoo-kernel/zoo_service_loader.c
===================================================================
--- /trunk/zoo-project/zoo-kernel/zoo_service_loader.c (revision 783)
+++ /trunk/zoo-project/zoo-kernel/zoo_service_loader.c (revision 784)
@@ -415,9 +415,14 @@
*/
map *r_inputs = NULL;
+ map* cwdMap=getMapFromMaps(m,"main","servicePath");
+ if(cwdMap!=NULL){
+ sprintf(ntmp,"%s",cwdMap->value);
+ }else{
#ifndef WIN32
- getcwd (ntmp, 1024);
+ getcwd (ntmp, 1024);
#else
- _getcwd (ntmp, 1024);
-#endif
+ _getcwd (ntmp, 1024);
+#endif
+ }
r_inputs = getMap (s1->content, "serviceType");
#ifdef DEBUG
@@ -915,4 +920,5 @@
}
char ntmp[1024];
+#ifndef ETC_DIR
#ifndef WIN32
getcwd (ntmp, 1024);
@@ -920,8 +926,18 @@
_getcwd (ntmp, 1024);
#endif
+#else
+ sprintf(ntmp,"%s",ETC_DIR);
+#endif
r_inputs = getMapOrFill (&request_inputs, "metapath", "");
char conf_file[10240];
snprintf (conf_file, 10240, "%s/%s/main.cfg", ntmp, r_inputs->value);
+#ifdef ETC_DIR
+#ifndef WIN32
+ getcwd (ntmp, 1024);
+#else
+ _getcwd (ntmp, 1024);
+#endif
+#endif
if (conf_read (conf_file, m) == 2)
{
@@ -945,6 +961,6 @@
else
{
- bindtextdomain ("zoo-kernel", "/usr/share/locale/");
- bindtextdomain ("zoo-services", "/usr/share/locale/");
+ bindtextdomain ("zoo-kernel", LOCALEDIR);
+ bindtextdomain ("zoo-services", LOCALEDIR);
}
@@ -1186,10 +1202,15 @@
r_inputs = NULL;
r_inputs = getMap (request_inputs, "metapath");
-
+ map* cwdMap0=getMapFromMaps(m,"main","servicePath");
if (r_inputs != NULL)
- snprintf (conf_dir, 1024, "%s/%s", ntmp, r_inputs->value);
+ if(cwdMap0!=NULL)
+ snprintf (conf_dir, 1024, "%s/%s", cwdMap0->value, r_inputs->value);
+ else
+ snprintf (conf_dir, 1024, "%s/%s", ntmp, r_inputs->value);
else
- snprintf (conf_dir, 1024, "%s", ntmp);
-
+ if(cwdMap0!=NULL)
+ snprintf (conf_dir, 1024, "%s", cwdMap0->value);
+ else
+ snprintf (conf_dir, 1024, "%s", ntmp);
map* reg = getMapFromMaps (m, "main", "registry");
registry* zooRegistry=NULL;
@@ -1292,5 +1313,5 @@
{
errorException (m, _("The specified path does not exist."),
- "InvalidParameterValue", conf_dir);
+ "InternalError", NULL);
freeMaps (&m);
free (m);
@@ -1617,13 +1638,6 @@
}
- r_inputs = getMap (request_inputs, "MetaPath");
- if (r_inputs != NULL)
- snprintf (tmps1, 1024, "%s/%s", ntmp, r_inputs->value);
- else
- snprintf (tmps1, 1024, "%s/", ntmp);
r_inputs = getMap (request_inputs, "Identifier");
- char *ttmp = zStrdup (tmps1);
- snprintf (tmps1, 1024, "%s/%s.zcfg", ttmp, r_inputs->value);
- free (ttmp);
+ snprintf (tmps1, 1024, "%s/%s.zcfg", conf_dir, r_inputs->value);
#ifdef DEBUG
fprintf (stderr, "Trying to load %s\n", tmps1);
@@ -1862,5 +1876,5 @@
* - message : is a string where you can store error messages, in case
* service is failing, or o provide details on the ongoing operation.
- * - cwd : is the current working directory
+ * - cwd : the current working directory or servicePath if defined
* - soap : is a boolean value, true if the request was contained in a SOAP
* Envelop
@@ -1888,5 +1902,10 @@
free(tmpUuid);
addToMap (_tmpMaps->content, "status", "0");
- addToMap (_tmpMaps->content, "cwd", ntmp);
+ if(cwdMap0!=NULL){
+ addToMap (_tmpMaps->content, "cwd", cwdMap0->value);
+ addToMap (_tmpMaps->content, "rcwd", ntmp);
+ }
+ else
+ addToMap (_tmpMaps->content, "cwd", ntmp);
addToMap (_tmpMaps->content, "message", _("No message provided"));
map *ltmp = getMap (request_inputs, "soap");