ZOO-Project
Macros | Functions | Variables
zoo_service_loader.c File Reference
#include "cgic.h"
#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.h"
#include "service_internal.h"
#include "server_internal.h"
#include "response_print.h"
#include "request_parser.h"
#include "sqlapi.h"
#include <dirent.h>
#include <signal.h>
#include <unistd.h>
#include <dlfcn.h>
#include <libgen.h>
#include <fcntl.h>
#include <time.h>
#include <stdarg.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...
 

Functions

int yylex ()
 
int crlex ()
 
void translateChar (char *str, char toReplace, char toReplaceBy)
 Replace a char by another one in a string. More...
 
int dumpBackFinalFile (maps *m, char *fbkp, char *fbkp1)
 Dump back the final file fbkp1 to fbkp. More...
 
int recursReaddirF (maps *m, registry *r, xmlNodePtr n, char *conf_dir, char *prefix, int saved_stdout, int level, void(func)(registry *, maps *, xmlNodePtr, service *))
 Recursivelly parse zcfg starting from the ZOO-Kernel cwd. 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 loadServiceAndRun (maps **myMap, service *s1, map *request_inputs, maps **inputs, maps **ioutputs, int *eres)
 Load a service provider and run the service function. More...
 
int runRequest (map **inputs)
 Process the request. More...
 

Variables

char ** environ
 

Macro Definition Documentation

#define _ (   String)    dgettext ("zoo-kernel",String)

Translation function for zoo-kernel.

#define __ (   String)    dgettext ("zoo-service",String)

Translation function for zoo-service.

Function Documentation

int crlex ( )
void donothing ( int  sig)

Signal handling function which simply call exit(0).

Parameters
sigthe signal number
int dumpBackFinalFile ( maps m,
char *  fbkp,
char *  fbkp1 
)

Dump back the final file fbkp1 to fbkp.

Parameters
mthe conf maps containing the main.cfg settings
fbkpthe string corresponding to the name of the file
fbkp1the string corresponding to the name of the file
void loadServiceAndRun ( maps **  myMap,
service s1,
map request_inputs,
maps **  inputs,
maps **  ioutputs,
int *  eres 
)

Load a service provider and run the service function.

Parameters
myMapthe conf maps containing the main.cfg settings
s1the service structure
request_inputsmap storing all the request parameters
inputsthe inputs maps
ioutputsthe outputs maps
eresthe 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 m,
registry r,
xmlNodePtr  n,
char *  conf_dir,
char *  prefix,
int  saved_stdout,
int  level,
void(func)(registry *, maps *, xmlNodePtr, service *)   
)

Recursivelly parse zcfg starting from the ZOO-Kernel cwd.

Call the func function given in arguments after parsing the ZCFG file.

Parameters
mthe conf maps containing the main.cfg settings
rthe registry containing profiles hierarchy
nthe root XML Node to add the sub-elements
conf_dirthe location of the main.cfg file (basically cwd)
prefixthe current prefix if any, or NULL
saved_stdoutthe saved stdout identifier
levelthe current level (number of sub-directories to reach the current path)
funca pointer to a function having 4 parameters (registry*, maps*, xmlNodePtr and service*).
See also
inheritance, readServiceFile
int runRequest ( map **  inputs)

Process the request.

Specific includes.

Parameters
inputsthe request parameters map
Returns
0 on sucess, other value on failure
See also
conf_read,recursReaddirF

Parsing service specfic configuration file

Manage our own error log file (usefull to separate standard apache debug messages from the ZOO-Kernel ones but also for IIS users to avoid wrong headers messages returned by the CGI due to wrong redirection of stderr)

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.'

Initialize the specific [lenv] section which contains runtime variables:

  • usid : it is an universally unique identifier
  • osid : it is an idenfitication number
  • sid : it is the process idenfitication number (OS)
  • uusid : it is an universally unique identifier
  • status : value between 0 and 100 to express the completude of the operations of the running service
  • message : is a string where you can store error messages, in case service is failing, or o provide details on the ongoing operation.
  • cwd : the current working directory or servicePath if defined
  • soap : is a boolean value, true if the request was contained in a SOAP Envelop
  • sessid : string storing the session identifier (only when cookie is used)
  • cgiSid : only defined on Window platforms (for being able to identify the created process)

dady : set status to SERVICE_ACCEPTED

son : have to close the stdout, stdin and stderr to let the parent process answer to http client.

set status to SERVICE_STARTED and flush stdout to ensure full content was outputed (the file used to store the ResponseDocument). The rewind stdout to restart writing from the bgining of the file, this way the data will be updated at the end of the process run.

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 sig_handler ( int  sig)

Signal handling function which create an ExceptionReport node containing the information message corresponding to the signal number.

Parameters
sigthe signal number
void translateChar ( char *  str,
char  toReplace,
char  toReplaceBy 
)

Replace a char by another one in a string.

Parameters
strthe string to update
toReplacethe char to replace
toReplaceBythe char that will be used
int yylex ( )

Variable Documentation

char** environ