Ticket #66: service_internal_js_importscripts.patch

File service_internal_js_importscripts.patch, 1.4 KB (added by rldhont, 13 years ago)

First patch to import scripts near the process file

  • .c

    old new  
    4141  return JS_TRUE;
    4242}
    4343
     44JSBool
     45JSLoadScripts(JSContext *cx, uintN argc, jsval *argv1)
     46{
     47  map* request = JS_GetContextPrivate(cx);
     48  map* tmpm1=getMap(request,"metapath");
     49  JS_MaybeGC(cx);
     50
     51  char ntmp[1024];
     52  getcwd(ntmp,1024);
     53
     54  jsval *argv = JS_ARGV(cx,argv1);
     55  int i=0;
     56  JS_MaybeGC(cx);
     57  for(i=0;i<argc;i++){
     58    JSString* jsmsg = JS_ValueToString(cx,argv[i]);
     59    char *filename = JSValToChar(cx,&argv[i]);
     60    char api0[strlen(tmpm1->value)+strlen(ntmp)+strlen(filename)+2];
     61    sprintf(api0,"%s/%s/%s",ntmp,tmpm1->value,filename);
     62#ifdef JS_DEBUG
     63    fprintf(stderr,"Trying to load %s\n",api0);
     64#endif
     65    JSObject *api_script1=loadZooApiFile(cx,JS_GetGlobalObject(cx),api0);
     66    fflush(stderr);
     67  }
     68  JS_MaybeGC(cx);
     69  JS_SET_RVAL(cx, argv1, JSVAL_VOID);
     70 
     71  return JS_TRUE;
     72}
     73
    4474int zoo_js_support(maps** main_conf,map* request,service* s,
    4575                   maps **inputs,maps **outputs)
    4676{
     
    94124    return 1;
    95125  if (!JS_DefineFunction(cx, global, "alert", JSAlert, 2, 0))
    96126    return 1;
     127  if (!JS_DefineFunction(cx, global, "importScripts", JSLoadScripts, 1, 0))
     128    return 1;
     129
     130  /**
     131   * Add private context object
     132   */
     133  void* cxPrivate = request;
     134  JS_SetContextPrivate(cx,cxPrivate);
    97135
    98136  map* tmpm1=getMap(request,"metapath");
    99137  char ntmp[1024];

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