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 41 41 return JS_TRUE; 42 42 } 43 43 44 JSBool 45 JSLoadScripts(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 44 74 int zoo_js_support(maps** main_conf,map* request,service* s, 45 75 maps **inputs,maps **outputs) 46 76 { … … 94 124 return 1; 95 125 if (!JS_DefineFunction(cx, global, "alert", JSAlert, 2, 0)) 96 126 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); 97 135 98 136 map* tmpm1=getMap(request,"metapath"); 99 137 char ntmp[1024];