ZOO-Project
|
#include <libxml/tree.h>
#include <libxml/xmlmemory.h>
#include <libxml/parser.h>
#include <libxml/xpath.h>
#include <libxml/xpathInternals.h>
#include "ulinet.h"
#include <libintl.h>
#include <locale.h>
#include <string.h>
#include "service_internal.h"
#include "server_internal.h"
#include "response_print.h"
#include "request_parser.h"
#include "service.h"
#include "sqlapi.h"
#include <dirent.h>
#include <signal.h>
#include <execinfo.h>
#include <unistd.h>
#include <dlfcn.h>
#include <libgen.h>
#include <fcntl.h>
#include <time.h>
#include <stdarg.h>
#include <libxslt/xslt.h>
#include <libxslt/xsltInternals.h>
#include <libxslt/transform.h>
#include <libxslt/xsltutils.h>
#include "cgic.h"
Macros | |
#define | _(String) dgettext ("zoo-kernel",String) |
Translation function for zoo-kernel. More... | |
#define | __(String) dgettext ("zoo-service",String) |
Translation function for zoo-service. More... | |
#define | localPrintExceptionJ localPrintException |
Functions | |
int | yylex () |
int | crlex () |
void | cleanUpSql (maps *pmsConf) |
Close any sql backend connexion and call end_sql. More... | |
void | translateChar (char *pcOrigin, char cToReplace, char cToReplaceBy) |
Replace a char by another one in a string. More... | |
int | createXidFile (maps *pmsConf, char *pcPath, char *pcUsid, const char *pcExtension, char *pcValue) |
Create PID (SID) file referencing the OS process identifier (service id) More... | |
int | createSPidFile (maps *pmsConf, char *pcPath) |
Create the PID and SID files referencing the OS process identifier and the service id, respectively. More... | |
int | createLenvFile (maps *pmsConf, char *pcPath, char *pcUsid) |
Create a _lenv.cfg file containing the lenv map. More... | |
int | dumpBackFinalFile (maps *pmsConf, char *pcFileName, char *pcFileName1) |
Dump back the final file fbkp1 to fbkp. More... | |
int | addServicesNamespaceToMap (maps **pmsConf) |
void | setRootUrlMap (maps *pmConf) |
int | _recursReaddirF (maps **ppmsConf, registry *prRegistry, void *pvDoc, void *pvNode, char *conf_dir, char *prefix, int saved_stdout, int level, void(func)(registry *, maps *, void *, void *, service *)) |
Recursivelly parse zcfg starting from the ZOO-Kernel cwd. More... | |
int | recursReaddirF (maps **ppmsConf, registry *prRegistry, void *pvDoc, void *pvNode, char *conf_dir_, char *prefix, int saved_stdout, int level, void(func)(registry *, maps *, void *, void *, service *)) |
Recursivelly parse zcfg from search path (services namespace and cwd). More... | |
void | exitAndCleanUp (registry *zooRegistry, maps **ppmsConf, const char *zcfg, const char *code, const char *locator, char *orig, char *corig, void(funcError)(maps **, map *)) |
When th zcfg file is not found, print error message and cleanup memory Note this function does free the *ppmsConf memory. More... | |
int | _fetchService (registry *zooRegistry, maps **pmsConf, service **spService, map *request_inputs, char *pcDir, char *cIdentifier, void(funcError)(maps **, map *)) |
Parse the ZOO-Service ZCFG to fill the service datastructure. More... | |
int | fetchService (registry *zooRegistry, maps **pmsConf, service **spService, map *request_inputs, char *pcDir, char *cIdentifier, void(funcError)(maps **, map *)) |
Parse the ZOO-Service ZCFG to fill the service datastructure. More... | |
int | _fetchServicesForDescription (registry *zooRegistry, maps **ppmsConf, char *r_inputs, void(func)(registry *, maps *, void *, void *, service *), void *doc, void *n, char *conf_dir, map *request_inputs, void(funcError)(maps **, map *)) |
Search services from various possible sources. More... | |
int | fetchServicesForDescription (registry *zooRegistry, maps **pmsConf, char *r_inputs, void(func)(registry *, maps *, void *, void *, service *), void *doc, void *n, char *pcDir, map *request_inputs, void(funcError)(maps **, map *)) |
Search services from various possible sources. More... | |
void | initAllEnvironment (maps *conf, map *request_inputs, const char *cPath, const char *request) |
Initialize environment sections, load env, and populate lenv and renv. More... | |
void | donothing (int sig) |
Signal handling function which simply call exit(0). More... | |
void | sig_handler (int sig) |
Signal handling function which create an ExceptionReport node containing the information message corresponding to the signal number. More... | |
void | register_signals (void(func)(int)) |
Register signals. More... | |
void | loadServiceAndRun (maps **myMap, service *s1, map *request_inputs, maps **inputs, maps **ioutputs, int *eres) |
Load a service provider and run the service function. More... | |
void | setSecurityFlags (maps *pmsConf, char *pcCgiQueryString) |
Set the security flag for the current request. More... | |
int | ensureFiltered (maps **ppmsConf, const char *pcType) |
Invoke the execution of the security module in case security is activated. More... | |
int | runRequest (map **inputs) |
Process the request. More... | |
Variables | |
char ** | environ |
#define _ | ( | String | ) | dgettext ("zoo-kernel",String) |
Translation function for zoo-kernel.
#define __ | ( | String | ) | dgettext ("zoo-service",String) |
Translation function for zoo-service.
#define localPrintExceptionJ localPrintException |
int _fetchService | ( | registry * | zooRegistry, |
maps ** | pmsConf, | ||
service ** | spService, | ||
map * | request_inputs, | ||
char * | pcDir, | ||
char * | cIdentifier, | ||
void(funcError)(maps **, map *) | |||
) |
Parse the ZOO-Service ZCFG to fill the service datastructure.
zooRegistry | the populated registry |
pmsConf | the maps pointer to the content of main.cfg file |
spService | the pointer to the service pointer to be filled |
request_inputs | the map pointer for http request inputs |
pcDir | the path where the ZCFG files are stored |
cIdentifier | the service identifier |
funcError | the error function to be used in case of error |
int _fetchServicesForDescription | ( | registry * | zooRegistry, |
maps ** | ppmsConf, | ||
char * | r_inputs, | ||
void(func)(registry *, maps *, void *, void *, service *) | , | ||
void * | doc, | ||
void * | n, | ||
char * | conf_dir, | ||
map * | request_inputs, | ||
void(funcError)(maps **, map *) | |||
) |
Search services from various possible sources.
zopRegistry | the populated registry |
ppmsConf | the maps pointer to the content of main.cfg file |
r_inputs | the service(s) name(s) |
func | the function used to print the result back |
doc | the xml document or NULL (for json) |
n | the xmlNode of JSON object pointer to the current element |
conf_dir | the directory where the main.cfg has been found |
request_inputs | the map pointer to the request KVP if any |
funcError | the function used to print the error back |
No support for dot in service name stored in metadb!? #ifdef META_DB service* s2=extractServiceFromDb(m,tmpMapI->value,0); if(s2==NULL){ #endif
int _recursReaddirF | ( | maps ** | ppmsConf, |
registry * | prRegistry, | ||
void * | pvDoc, | ||
void * | pvNode, | ||
char * | conf_dir, | ||
char * | prefix, | ||
int | saved_stdout, | ||
int | level, | ||
void(func)(registry *, maps *, void *, void *, service *) | |||
) |
Recursivelly parse zcfg starting from the ZOO-Kernel cwd.
Call the func function given in arguments after parsing the ZCFG file.
pmsConf | the conf maps containing the main.cfg settings |
prRegistry | the registry containing profiles hierarchy |
pvDoc | the root XML Node to add the sub-elements |
pvNode | the root XML Node to add the sub-elements |
conf_dir | the location of the main.cfg file (basically cwd) |
prefix | the current prefix if any, or NULL |
saved_stdout | the saved stdout identifier |
level | the current level (number of sub-directories to reach the current path) |
func | a pointer to a function having 5 parameters (registry*, maps*, xmlDocPtr, xmlNodePtr, and service*). |
int addServicesNamespaceToMap | ( | maps ** | pmsConf | ) |
void cleanUpSql | ( | maps * | pmsConf | ) |
int createLenvFile | ( | maps * | pmsConf, |
char * | pcPath, | ||
char * | pcUsid | ||
) |
Create a _lenv.cfg file containing the lenv map.
pmsConf | the conf maps containing the main.cfg settings |
pcPath | the path to store the sid file |
pcUsid | the usid value |
pcValue | the value to be stored |
int createSPidFile | ( | maps * | pmsConf, |
char * | pcPath | ||
) |
Create the PID and SID files referencing the OS process identifier and the service id, respectively.
pmsConf | the conf maps containing the main.cfg settings |
pcPath | the path to store the files |
int createXidFile | ( | maps * | pmsConf, |
char * | pcPath, | ||
char * | pcUsid, | ||
const char * | pcExtension, | ||
char * | pcValue | ||
) |
Create PID (SID) file referencing the OS process identifier (service id)
pmsConf | the conf maps containing the main.cfg settings |
pcPath | the path to store the sid file |
pcUsid | the usid value |
pcExtension | the file extension (sid or pid) |
pcValue | the value to be stored |
int crlex | ( | ) |
void donothing | ( | int | sig | ) |
Signal handling function which simply call exit(0).
sig | the signal number |
int dumpBackFinalFile | ( | maps * | pmsConf, |
char * | pcFileName, | ||
char * | pcFileName1 | ||
) |
Dump back the final file fbkp1 to fbkp.
pmsConf | the conf maps containing the main.cfg settings |
pcFileName | the string corresponding to the name of the file |
pcFileName1 | the string corresponding to the name of the file |
int ensureFiltered | ( | maps ** | ppmsConf, |
const char * | pcType | ||
) |
Invoke the execution of the security module in case security is activated.
ppmsConf | the maps pointing to the main.cfg file content |
pcType | the string defining the process to execute ('in' or 'out') |
void exitAndCleanUp | ( | registry * | zooRegistry, |
maps ** | ppmsConf, | ||
const char * | zcfg, | ||
const char * | code, | ||
const char * | locator, | ||
char * | orig, | ||
char * | corig, | ||
void(funcError)(maps **, map *) | |||
) |
When th zcfg file is not found, print error message and cleanup memory Note this function does free the *ppmsConf memory.
zooRegistry | the populated registry |
ppmsConf | the maps pointer address to the content of main.cfg file |
zcfg | the zcfg file name |
code | the string determining the nature of the error |
locator | the string determining which parameter the error refer to |
orig | the service name |
corig | the current service name (in case multiple services was parsed) |
funcError | the function used to print the error back |
int fetchService | ( | registry * | zooRegistry, |
maps ** | pmsConf, | ||
service ** | spService, | ||
map * | request_inputs, | ||
char * | pcDir, | ||
char * | cIdentifier, | ||
void(funcError)(maps **, map *) | |||
) |
Parse the ZOO-Service ZCFG to fill the service datastructure.
zooRegistry | the populated registry |
pmsConf | the maps pointer to the content of main.cfg file |
spService | the pointer to the service pointer to be filled |
request_inputs | the map pointer for http request inputs |
pcDir | the path where the ZCFG files are stored |
cIdentifier | the service identifier |
funcError | the error function to be used in case of error |
int fetchServicesForDescription | ( | registry * | zooRegistry, |
maps ** | pmsConf, | ||
char * | r_inputs, | ||
void(func)(registry *, maps *, void *, void *, service *) | , | ||
void * | doc, | ||
void * | n, | ||
char * | pcDir, | ||
map * | request_inputs, | ||
void(funcError)(maps **, map *) | |||
) |
Search services from various possible sources.
zopRegistry | the populated registry |
m | the maps pointer to the content of main.cfg file |
r_inputs | the service(s) name(s) |
func | the function used to print the result back |
doc | the xml document or NULL (for json) |
n | the xmlNode of JSON object pointer to the current element |
conf_dir | the directory where the main.cfg has been found |
request_inputs | the map pointer to the request KVP if any |
funcError | the function used to print the error back |
void initAllEnvironment | ( | maps * | conf, |
map * | request_inputs, | ||
const char * | cPath, | ||
const char * | request | ||
) |
Initialize environment sections, load env, and populate lenv and renv.
conf | the maps pointing to the main.cfg file content |
request_inputs | the map pointing to the request KVP |
cPath | a string pointing to the cwd |
request | a string pointing to the request key (xrequest or jrequest) |
Initialize the specific [lenv] section which contains runtime variables:
void loadServiceAndRun | ( | maps ** | myMap, |
service * | s1, | ||
map * | request_inputs, | ||
maps ** | inputs, | ||
maps ** | ioutputs, | ||
int * | eres | ||
) |
Load a service provider and run the service function.
myMap | the conf maps containing the main.cfg settings |
s1 | the service structure |
request_inputs | map storing all the request parameters |
inputs | the inputs maps |
ioutputs | the outputs maps |
eres | the result returned by the service execution |
Extract serviceType to know what kind of service should be loaded
Unable to load the specified shared library
int recursReaddirF | ( | maps ** | ppmsConf, |
registry * | prRegistry, | ||
void * | pvDoc, | ||
void * | pvNode, | ||
char * | conf_dir_, | ||
char * | prefix, | ||
int | saved_stdout, | ||
int | level, | ||
void(func)(registry *, maps *, void *, void *, service *) | |||
) |
Recursivelly parse zcfg from search path (services namespace and cwd).
If the main cofiguration maps (pmsConf) get, in the openapi section, a search_path key taking the value true, then the ZOO-Kernel default search_path used for searching zcfg files (cwd) is used in addition to the authenticated user namespace.
ppmsConf | the conf maps containing the main.cfg settings |
prRegistry | the registry containing profiles hierarchy |
n | the root XML Node to add the sub-elements |
conf_dir | the location of the main.cfg file (basically cwd) |
prefix | the current prefix if any, or NULL |
saved_stdout | the saved stdout identifier |
level | the current level (number of sub-directories to reach the current path) |
func | a pointer to a function having 4 parameters (registry*, maps*, xmlNodePtr and service*). |
void register_signals | ( | void(func)(int) | ) |
int runRequest | ( | map ** | inputs | ) |
Process the request.
Specific includes.
inputs | the request parameters map |
Here we need to close stdout to ensure that unsupported chars has been found in the zcfg and then printed on stdout
Loop over Identifier list
Create the input and output maps data structure
05-007r7 WPS 1.0.0 page 57 : 'If status="true" and storeExecuteResponse is "false" then the service shall raise an exception.'
error server don't accept the process need to output a valid error response here !!!
Ensure that if error occurs when freeing memory, no signal will return an ExceptionReport document as the result was already returned to the client.
void setRootUrlMap | ( | maps * | pmConf | ) |
void setSecurityFlags | ( | maps * | pmsConf, |
char * | pcCgiQueryString | ||
) |
Set the security flag for the current request.
Set [lenv] secured_url to true in case the access should be secured, false in other cases.
pmsConf | the maps pointing to the main.cfg file content |
pcCgiQueryString | the string containing the request |
void sig_handler | ( | int | sig | ) |
Signal handling function which create an ExceptionReport node containing the information message corresponding to the signal number.
sig | the signal number |
void translateChar | ( | char * | pcOrigin, |
char | cToReplace, | ||
char | cToReplaceBy | ||
) |
Replace a char by another one in a string.
pcOrigin | the string to update |
cToReplace | the char to replace |
cToReplaceBy | the char that will be used |
int yylex | ( | ) |
char** environ |