ZOO-Project
Functions
service_internal_js.h File Reference
#include "service.h"
#include "service_internal.h"
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include "ulinet.h"

Go to the source code of this file.

Functions

char * JSValToChar (JSContext *, jsval *)
 Convert a JavaScript value to a char*. More...
 
JSObject * JSObject_FromMaps (JSContext *, maps *)
 Convert a maps to a JavaScript Object. More...
 
JSObject * JSObject_FromMap (JSContext *, map *)
 Convert a map to a JavaScript Object. More...
 
mapsmapsFromJSObject (JSContext *, jsval)
 Convert a JavaScript Object to a maps. More...
 
mapmapFromJSObject (JSContext *, jsval)
 Convert a JavaScript Object to a map. More...
 
JSBool JSTranslate (JSContext *, uintN, jsval *)
 The function used as ZOOTranslate from the JavaScript environment. More...
 
JSBool JSRequest (JSContext *, uintN, jsval *)
 The function used as ZOORequest from the JavaScript environment (ZOO-API) More...
 
JSBool JSUpdateStatus (JSContext *, uintN, jsval *)
 The function used as ZOOUpdateStatus from the JavaScript environment (ZOO-API). More...
 
JSBool JSSleep (JSContext *, uintN, jsval *)
 The function used as sleep from the JavaScript environment (ZOO-API). More...
 
void reportError (JSContext *cx, const char *message, JSErrorReport *report)
 Print debug information messages on stderr. More...
 
int zoo_js_support (maps **, map *, service *, maps **, maps **)
 Load a JavaScript file then run the function corresponding to the service by passing the conf, inputs and outputs parameters by value as JavaScript Objects. More...
 
JSObject * loadZooApiFile (JSContext *, JSObject *, char *)
 Load a JavaScript file. More...
 

Function Documentation

JSObject* JSObject_FromMap ( JSContext *  cx,
map t 
)

Convert a map to a JavaScript Object.

Parameters
cxthe JavaScript context
tthe map to convert
Returns
a new JavaScript Object
JSObject* JSObject_FromMaps ( JSContext *  cx,
maps t 
)

Convert a maps to a JavaScript Object.

Parameters
cxthe JavaScript context
tthe maps to convert
Returns
a new JavaScript Object
JSBool JSRequest ( JSContext *  cx,
uintN  argc,
jsval *  argv1 
)

The function used as ZOORequest from the JavaScript environment (ZOO-API)

Parameters
cxthe JavaScript context
argcthe number of parameters
argv1the parameter values
Returns
true
See also
setHeader
JSBool JSSleep ( JSContext *  cx,
uintN  argc,
jsval *  argv1 
)

The function used as sleep from the JavaScript environment (ZOO-API).

Parameters
cxthe JavaScript context
argcthe number of parameters
argv1the parameter values
Returns
true
JSBool JSTranslate ( JSContext *  cx,
uintN  argc,
jsval *  argv1 
)

The function used as ZOOTranslate from the JavaScript environment.

Use the ZOO-Services messages translation function from the Python environment (ZOO-API)

Parameters
cxthe JavaScript context
argcthe number of parameters
argv1the parameter values
Returns
true
JSBool JSUpdateStatus ( JSContext *  cx,
uintN  argc,
jsval *  argv1 
)

The function used as ZOOUpdateStatus from the JavaScript environment (ZOO-API).

Parameters
cxthe JavaScript context
argcthe number of parameters
argv1the parameter values
Returns
true
See also
setHeader,_updateStatus
char* JSValToChar ( JSContext *  context,
jsval *  arg 
)

Convert a JavaScript value to a char*.

Parameters
contextthe JavaScript context
argthe JavaScript value
Returns
a new char*
Warning
be sure to free the resources returned by this function
JSObject* loadZooApiFile ( JSContext *  cx,
JSObject *  global,
char *  filename 
)

Load a JavaScript file.

Parameters
cxthe JavaScript context
globalthe global JavaScript object (not used)
filenamethe file name to load
Returns
a JavaScript Object on success, NULL if an errro occurred
map* mapFromJSObject ( JSContext *  cx,
jsval  t 
)

Convert a JavaScript Object to a map.

Parameters
cxthe JavaScript context
tthe JavaScript Object to convert
Returns
a new map containing the JavaScript Object
maps* mapsFromJSObject ( JSContext *  cx,
jsval  t 
)

Convert a JavaScript Object to a maps.

Parameters
cxthe JavaScript context
tthe JavaScript Object to convert
Returns
a new maps containing the JavaScript Object
void reportError ( JSContext *  cx,
const char *  message,
JSErrorReport *  report 
)

Print debug information messages on stderr.

Parameters
cxthe JavaScript context
messagethe error message
reportthe JavaScript Error Report
int zoo_js_support ( maps **  main_conf,
map request,
service s,
maps **  inputs,
maps **  outputs 
)

Load a JavaScript file then run the function corresponding to the service by passing the conf, inputs and outputs parameters by value as JavaScript Objects.

Parameters
main_confthe conf maps containing the main.cfg settings
requestthe map containing the HTTP request
sthe service structure
inputsthe maps containing the inputs
outputsthe maps containing the outputs
Returns
SERVICE_SUCCEEDED or SERVICE_FAILED if the service run, -1 if the service failed to load or throw error at runtime.

Add private context object

Load the first part of the ZOO-API

Extract result

Extract outputs when available.

Extract conf when available.