HTMLPRINTER  2.13.5-1
jsproc.h File Reference
#include <string>
#include <vector>
#include <map>

Enumerations

enum  JSTraceType { JST_HTTPGET, JST_HTTPPOST, JST_HTTPRESULT }
 

Functions

DllSpec void jsGetConsole (void(*&cb)(void *, const char *), void *&data)
 
DllSpec const char * jsGetHttpProxy ()
 
DllSpec void jsGetLog (void(*&cb)(void *data, const std::string &app_id, JSLogLevel log_level, const std::vector< std::string > &msg), void *&data)
 
DllSpec void jsGetNotify (int(*&cb)(void *data, const char *to, const char *notification_id, const char *json_param, unsigned flags, const char *from), void *&data)
 
DllSpec void jsGetNotifyAndWait (int(*&cb)(void *data, const char *to, const char *notification_id, const char *json_param, unsigned flags, const char *from, const char *wait_id, std::string &result, int timeout_msec), void *&data)
 
DllSpec void jsGetTrace (void(*&cb)(void *data, JSTraceType type, const std::string &app_id, std::map< std::string, std::string > &trace), void *&data)
 
DllSpec bool jsProcessor (void *data, const std::string &sourcecode, std::map< std::string, std::string > &arg, std::string &out, std::string &err, std::string &exitcode)
 
DllSpec bool jsProcessorExt (void *data, const std::string &sourcecode, std::map< std::string, std::string > &arg, std::string &out, std::string &err, std::string &exitcode, vfihtml::ExtContext *context)
 
DllSpec const char * jsProcVersion ()
 
DllSpec void jsSetConsole (void(*cb)(void *data, const char *text), void *data)
 
DllSpec void jsSetHttpProxy (const char *proxy)
 
DllSpec void jsSetLog (void(*cb)(void *data, const std::string &app_id, JSLogLevel log_level, const std::vector< std::string > &msg), void *data)
 
DllSpec void jsSetNotify (int(*cb)(void *data, const char *to, const char *notification_id, const char *json_param, unsigned flags, const char *from), void *data)
 
DllSpec void jsSetNotifyAndWait (int(*cb)(void *data, const char *to, const char *notification_id, const char *json_param, unsigned flags, const char *from, const char *wait_id, std::string &result, int timeout_msec), void *data)
 
DllSpec void jsSetTrace (void(*cb)(void *data, JSTraceType type, const std::string &app_id, std::map< std::string, std::string > &trace), void *data)
 

Detailed Description

script processor

Enumeration Type Documentation

§ JSTraceType

trace type

Enumerator
JST_HTTPGET 

trace of an HTTP GET request, data provided: "url"

JST_HTTPPOST 

trace of an HTTP POST request, data provided: "url"

JST_HTTPRESULT 

trace of the HTTP result, data provided: "status"

Function Documentation

§ jsGetConsole()

DllSpec void jsGetConsole ( void(*&)(void *, const char *)  cb,
void *&  data 
)

get current setting of callback for console output

Parameters
[out]cbcallback function pointer or NULL
[out]datadata pointer provided to callback as first parameter

§ jsGetHttpProxy()

DllSpec const char* jsGetHttpProxy ( )

Read current proxy setting

Returns
proxy setting.

§ jsGetLog()

DllSpec void jsGetLog ( void(*&)(void *data, const std::string &app_id, JSLogLevel log_level, const std::vector< std::string > &msg)  cb,
void *&  data 
)

read logging callback

Parameters
[out]cbcallback function pointer or NULL
[out]datadata pointer provided to callback as first parameter

§ jsGetNotify()

DllSpec void jsGetNotify ( int(*&)(void *data, const char *to, const char *notification_id, const char *json_param, unsigned flags, const char *from)  cb,
void *&  data 
)

get current setting of notification callback

Parameters
[out]cbcallback function pointer or NULL
[out]datadata pointer provided to callback as first parameter

§ jsGetNotifyAndWait()

DllSpec void jsGetNotifyAndWait ( int(*&)(void *data, const char *to, const char *notification_id, const char *json_param, unsigned flags, const char *from, const char *wait_id, std::string &result, int timeout_msec)  cb,
void *&  data 
)

get current setting of notification callback

Parameters
[out]cbcallback function pointer or NULL
[out]datadata pointer provided to callback as first parameter

§ jsGetTrace()

DllSpec void jsGetTrace ( void(*&)(void *data, JSTraceType type, const std::string &app_id, std::map< std::string, std::string > &trace)  cb,
void *&  data 
)

read HTTP trace callback

Parameters
[out]cbcallback function pointer or NULL
[out]datadata pointer provided to callback as first parameter

§ jsProcessor()

DllSpec bool jsProcessor ( void *  data,
const std::string &  sourcecode,
std::map< std::string, std::string > &  arg,
std::string &  out,
std::string &  err,
std::string &  exitcode 
)

Process JavaScript script and return the data sent to stdout and stderr

Parameters
[in]datathis parameter is unused, it is just there for compatibility with the ADKGUI scripting interface
[in]sourcecodestring containing the Js source code
[in]argkey value map, can be accessed as table 'ARG' from within the JavaScript script
[out]outdata sent to stdout
[out]errdata sent to stderr
[out]exitcodeparameter that was passed to exit()
Returns
true if processing was successful, false if not

§ jsProcessorExt()

DllSpec bool jsProcessorExt ( void *  data,
const std::string &  sourcecode,
std::map< std::string, std::string > &  arg,
std::string &  out,
std::string &  err,
std::string &  exitcode,
vfihtml::ExtContext *  context 
)

Process JavaScript script and return the data sent to stdout and stderr. This is the variant with ADKGUI extensions support.

Parameters
[in]datathis parameter is unused, it is just there for compatibility with the ADKGUI scripting interface
[in]sourcecodestring containing the Js source code
[in]argkey value map, can be accessed as table 'ARG' from within the JavaScript script
[out]outdata sent to stdout
[out]errdata sent to stderr
[out]exitcodeparameter that was passed to exit()
[in,out]contextextended context, if NULL GUI extensions are disabled.
Returns
true if processing was successful, false if not

§ jsProcVersion()

DllSpec const char* jsProcVersion ( )
Returns
version information

§ jsSetConsole()

DllSpec void jsSetConsole ( void(*)(void *data, const char *text)  cb,
void *  data 
)

set callback for console output

Parameters
[in]cbcallback function pointer or NULL
[in]datadata pointer provided to callback as first parameter

The callback takes the following parameters:

Parameters
[in]datadata pointer
[in]textstring to be sent to console
Note
The console callback is global, only one callback may be set. Setting the callback function is not thread safe, i.e. appropriate actions have to be taken to protect against race conditions.

§ jsSetHttpProxy()

DllSpec void jsSetHttpProxy ( const char *  proxy)

Set Http-Proxy

Parameters
[in]proxyProxy setting, e.g. http://localhost:8888 or NULL

§ jsSetLog()

DllSpec void jsSetLog ( void(*)(void *data, const std::string &app_id, JSLogLevel log_level, const std::vector< std::string > &msg)  cb,
void *  data 
)

install logging callback

Parameters
[in]cbcallback function pointer or NULL
[in]datadata pointer provided to callback as first parameter

The callback takes the following parameters:

Parameters
[in]datadata pointer
[in]log_levellogging level 0-7 (emergency,alert,critical,
[in]app_idapplication ID (as found in ARGV["cp_appId"])
[in]msglog message parameters in the order they were provided to log.info()/log.debug(),log.error()
Note
The log callback is global, only one callback may be set. Setting the callback function is not thread safe, i.e. appropriate actions have to be taken to protect against race conditions.

§ jsSetNotify()

DllSpec void jsSetNotify ( int(*)(void *data, const char *to, const char *notification_id, const char *json_param, unsigned flags, const char *from)  cb,
void *  data 
)

set callback for sending notifications

Parameters
[in]cbcallback function pointer or NULL
[in]datadata pointer provided to callback as first parameter

The callback takes the following parameters:

Parameters
[in]datadata pointer
[in]todestination address
[in]notification_idnotification id
[in]json_paramstring containing the JSON encoded parameters
[in]flagsoptional flags
[in]fromoptional source address, if NULL use default source address
Returns
0 in case of success or negative error code
Note
The notification callback is global, only one callback may be set. Setting the callback function is not thread safe, i.e. appropriate actions have to be taken to protect against race conditions.

§ jsSetNotifyAndWait()

DllSpec void jsSetNotifyAndWait ( int(*)(void *data, const char *to, const char *notification_id, const char *json_param, unsigned flags, const char *from, const char *wait_id, std::string &result, int timeout_msec)  cb,
void *  data 
)

set callback for sending notifications

Parameters
[in]cbcallback function pointer or NULL
[in]datadata pointer provided to callback as first parameter

The callback takes the following parameters:

Parameters
[in]datadata pointer
[in]todestination address
[in]notification_idnotification id
[in]json_paramstring containing the JSON encoded parameters
[in]flagsoptional flags
[in]fromoptional source address, if NULL use default source address
[in]wait_idwait for notification with this id
[out]resultreceived notification
[in]timeout_msectimeout in milliseconds
Returns
0 in case of success or negative error code
Note
The notification callback is global, only one callback may be set. Setting the callback function is not thread safe, i.e. appropriate actions have to be taken to protect against race conditions.

§ jsSetTrace()

DllSpec void jsSetTrace ( void(*)(void *data, JSTraceType type, const std::string &app_id, std::map< std::string, std::string > &trace)  cb,
void *  data 
)

install HTTP trace callback

Parameters
[in]cbcallback function pointer or NULL
[in]datadata pointer provided to callback as first parameter

The callback takes the following parameters:

Parameters
[in]datadata pointer
[in]typetrace type
[in]app_idapplication ID (as found in ARGV["cp_appId"])
[in]tracekey value map containing trace parameters
Note
The trace callback is global, only one callback may be set. Setting the callback function is not thread safe, i.e. appropriate actions have to be taken to protect against race conditions.