Ignore:
Timestamp:
Feb 12, 2015, 11:18:07 PM (7 years ago)
Author:
djay
Message:

Continue adding initial doxygen documentation.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/zoo-project/zoo-kernel/service_internal_js.c

    r576 r580  
    1 /**
     1/*
    22 * Author : Gérald FENOY
    33 *
     
    3131static char dbg[1024];
    3232
     33/**
     34 * The function used as alert from the JavaScript environment (ZOO-API)
     35 *
     36 * @param cx the JavaScript context
     37 * @param argc the number of parameters
     38 * @param argv1 the parameter values
     39 * @return true
     40 */
    3341JSBool
    3442JSAlert(JSContext *cx, uintN argc, jsval *argv1)
     
    4856}
    4957
     58/**
     59 * The function used as importScript from the JavaScript environment (ZOO-API)
     60 *
     61 * @param cx the JavaScript context
     62 * @param argc the number of parameters
     63 * @param argv1 the parameter values
     64 * @return true
     65 */
    5066JSBool
    5167JSLoadScripts(JSContext *cx, uintN argc, jsval *argv1)
     
    7995}
    8096
    81 
    82 int zoo_js_support(maps** main_conf,map* request,service* s,
    83                    maps **inputs,maps **outputs)
     97/**
     98 * Load a JavaScript file then run the function corresponding to the service by
     99 * passing the conf, inputs and outputs parameters by value as JavaScript
     100 * Objects.
     101 *
     102 * @param main_conf the conf maps containing the main.cfg settings
     103 * @param request the map containing the HTTP request
     104 * @param s the service structure
     105 * @param inputs the maps containing the inputs
     106 * @param outputs the maps containing the outputs
     107 * @return ZOO_SERVICE_SUCCEEDED or ZOO_SERVICE_FAILED if the service run, -1
     108 *  if the service failed to load or throw error at runtime.
     109 */
     110int zoo_js_support(maps** main_conf,map* request,service* s,maps **inputs,maps **outputs)
    84111{
    85112  maps* main=*main_conf;
     
    355382}
    356383
     384/**
     385 * Load a JavaScript file
     386 *
     387 * @param cx the JavaScript context
     388 * @param globale the global JavaScript object (not used)
     389 * @param filename the file name to load
     390 * @return a JavaScript Object on success, NULL if an errro occured
     391 */
    357392JSObject * loadZooApiFile(JSContext *cx,JSObject  *global, char* filename){
    358393  struct stat api_status;
     
    381416}
    382417
     418/**
     419 * Convert a maps to a JavaScript Object
     420 *
     421 * @param cx the JavaScript context
     422 * @param t the maps to convert
     423 * @return a new JavaScript Object
     424 */
    383425JSObject* JSObject_FromMaps(JSContext *cx,maps* t){
    384 
    385426  JSObject* res=JS_NewObject(cx, NULL, NULL, NULL);
    386427  //JSObject *res = JS_NewArrayObject(cx, 0, NULL);
     
    402443}
    403444
     445/**
     446 * Convert a map to a JavaScript Object
     447 *
     448 * @param cx the JavaScript context
     449 * @param t the map to convert
     450 * @return a new JavaScript Object
     451 */
    404452JSObject* JSObject_FromMap(JSContext *cx,map* t){
    405453  JSObject* res=JS_NewObject(cx, NULL, NULL, NULL);
     
    454502}
    455503
     504/**
     505 * Convert a JavaScript Object to a maps
     506 *
     507 * @param cx the JavaScript context
     508 * @param t the JavaScript Object to convert
     509 * @return a new maps containing the JavaScript Object
     510 */
    456511maps* mapsFromJSObject(JSContext *cx,jsval t){
    457512  maps *res=NULL;
     
    629684}
    630685
     686/**
     687 * Convert a JavaScript Object to a map
     688 *
     689 * @param cx the JavaScript context
     690 * @param t the JavaScript Object to convert
     691 * @return a new map containing the JavaScript Object
     692 */
    631693map* mapFromJSObject(JSContext *cx,jsval t){
    632694  map *res=NULL;
     
    684746}
    685747
    686 /* The error reporter callback. */
     748/**
     749 * Print debug information messages on stderr
     750 *
     751 * @param cx the JavaScript context
     752 * @param message the error message
     753 * @param report the JavaScript Error Report
     754 */
    687755void reportError(JSContext *cx, const char *message, JSErrorReport *report)
    688756{
     
    697765}
    698766
     767/**
     768 * Convert a JavaScript value to a char*
     769 *
     770 * @param context the JavaScript context
     771 * @param arg the JavaScript value
     772 * @return a new char*
     773 * @warning be sure to free the ressources returned by this function
     774 */
    699775char* JSValToChar(JSContext* context, jsval* arg) {
    700776  char *c;
     
    724800}
    725801
     802/**
     803 * Set the HTTP header of a request
     804 *
     805 * @param handle the HINTERNET handle
     806 * @param cx the JavaScript context
     807 * @param header the JavaScript Array containing the headers to send
     808 * @return the HINTERNET handle
     809 */
    726810HINTERNET setHeader(HINTERNET* handle,JSContext *cx,JSObject *header){
    727811  jsuint length=0;
     
    758842}
    759843
     844/**
     845 * The function used as ZOOTranslate from the JavaScript environment.
     846 * Use the ZOO-Services messages translation function from the Python
     847 * environment (ZOO-API)
     848 *
     849 * @param cx the JavaScript context
     850 * @param argc the number of parameters
     851 * @param argv1 the parameter values
     852 * @return true
     853 */
    760854JSBool
    761855JSTranslate(JSContext *cx, uintN argc, jsval *argv1)
     
    769863}
    770864
     865/**
     866 * The function used as ZOORequest from the JavaScript environment (ZOO-API)
     867 *
     868 * @param cx the JavaScript context
     869 * @param argc the number of parameters
     870 * @param argv1 the parameter values
     871 * @return true
     872 * @see setHeader
     873 */
    771874JSBool
    772875JSRequest(JSContext *cx, uintN argc, jsval *argv1)
     
    847950  return JS_TRUE;
    848951}
     952
     953/**
     954 * The function used as ZOOUpdateStatus from the JavaScript environment
     955 * (ZOO-API).
     956 *
     957 * @param cx the JavaScript context
     958 * @param argc the number of parameters
     959 * @param argv1 the parameter values
     960 * @return true
     961 * @see setHeader
     962 */
     963JSBool
     964JSUpdateStatus(JSContext *cx, uintN argc, jsval *argv1)
     965{
     966  jsval *argv = JS_ARGV(cx,argv1);
     967  JS_MaybeGC(cx);
     968  int istatus=0;
     969  char *status=NULL;
     970  maps *conf;
     971  if(argc>2){
     972#ifdef JS_DEBUG
     973    fprintf(stderr,"Number of arguments used to call the function : %i",argc);
     974#endif
     975    return JS_FALSE;
     976  }
     977  conf=mapsFromJSObject(cx,argv[0]);
     978  if(JS_ValueToInt32(cx,argv[1],&istatus)==JS_TRUE){
     979    char tmpStatus[4];
     980    sprintf(tmpStatus,"%i",istatus);
     981    tmpStatus[3]=0;
     982    status=strdup(tmpStatus);
     983  }
     984  if(getMapFromMaps(conf,"lenv","status")!=NULL){
     985    if(status!=NULL){
     986      setMapInMaps(conf,"lenv","status",status);
     987      free(status);
     988    }
     989    else
     990      setMapInMaps(conf,"lenv","status","15");
     991    _updateStatus(conf);
     992  }
     993  freeMaps(&conf);
     994  free(conf);
     995  JS_MaybeGC(cx);
     996  return JS_TRUE;
     997}
     998
Note: See TracChangeset for help on using the changeset viewer.

Search

Context Navigation

ZOO Sponsors

http://www.zoo-project.org/trac/chrome/site/img/geolabs-logo.pnghttp://www.zoo-project.org/trac/chrome/site/img/neogeo-logo.png http://www.zoo-project.org/trac/chrome/site/img/apptech-logo.png http://www.zoo-project.org/trac/chrome/site/img/3liz-logo.png http://www.zoo-project.org/trac/chrome/site/img/gateway-logo.png

Become a sponsor !

Knowledge partners

http://www.zoo-project.org/trac/chrome/site/img/ocu-logo.png http://www.zoo-project.org/trac/chrome/site/img/gucas-logo.png http://www.zoo-project.org/trac/chrome/site/img/polimi-logo.png http://www.zoo-project.org/trac/chrome/site/img/fem-logo.png http://www.zoo-project.org/trac/chrome/site/img/supsi-logo.png http://www.zoo-project.org/trac/chrome/site/img/cumtb-logo.png

Become a knowledge partner

Related links

http://zoo-project.org/img/ogclogo.png http://zoo-project.org/img/osgeologo.png