- Timestamp:
- Nov 10, 2010, 6:56:18 AM (14 years ago)
- Location:
- trunk/zoo-kernel
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/zoo-kernel/service_internal_js.c
r34 r42 77 77 return 1; 78 78 79 map* tmpm1=getMap(request,"metapath"); 80 char ntmp[1024]; 81 getcwd(ntmp,1024); 82 83 /** 84 * Load the first part of the ZOO-API 85 */ 86 char api0[strlen(tmpm1->value)+strlen(ntmp)+15]; 87 sprintf(api0,"%s/%sZOO-proj4js.js",ntmp,tmpm1->value); 88 fprintf(stderr,"Trying to load %s\n",api0); 89 JSScript *api_script1=loadZooApiFile(cx,global,api0); 90 fflush(stderr); 91 92 char api1[strlen(tmpm1->value)+strlen(ntmp)+11]; 93 sprintf(api1,"%s/%sZOO-api.js",ntmp,tmpm1->value); 94 fprintf(stderr,"Trying to load %s\n",api1); 95 JSScript *api_script2=loadZooApiFile(cx,global,api1); 96 fflush(stderr); 97 79 98 /* Your application code here. This may include JSAPI calls 80 99 to create your own custom JS objects and run scripts. */ … … 82 101 int res=SERVICE_FAILED; 83 102 maps* mc=*main_conf; 84 map* tmpm1=getMap(request,"metapath");85 103 map* tmpm2=getMap(s->content,"serviceProvider"); 86 char ntmp[1024]; 87 getcwd(ntmp,1024); 104 88 105 char filename[strlen(tmpm1->value)+strlen(tmpm2->value)+strlen(ntmp)+2]; 89 106 sprintf(filename,"%s/%s%s",ntmp,tmpm1->value,tmpm2->value); … … 208 225 /* Cleanup. */ 209 226 JS_DestroyScript(cx, script); 227 JS_DestroyScript(cx, api_script1); 228 JS_DestroyScript(cx, api_script2); 210 229 //JS_MaybeGC(cx); 211 230 // If we use the DestroyContext as requested to release memory then we get … … 219 238 #endif 220 239 return res; 240 } 241 242 JSScript * loadZooApiFile(JSContext *cx,JSObject *global, char* filename){ 243 struct stat api_status; 244 int s=stat(filename, &api_status); 245 if(s==0){ 246 jsval rval; 247 FILE *jsfile=fopen(filename,"r"); 248 JSBool ok ; 249 JSScript *script = JS_CompileFileHandle(cx, global, filename,jsfile); 250 if(script!=NULL){ 251 (void)JS_ExecuteScript(cx, global, script, &rval); 252 fprintf(stderr,"**************\n%s correctly loaded\n**************\n",filename); 253 return script; 254 } 255 else 256 fprintf(stderr,"\n**************\nUnable to run %s\n**************\n",filename); 257 } 258 else 259 fprintf(stderr,"\n**************\nUnable to load %s\n**************\n",filename); 260 return NULL; 221 261 } 222 262 -
trunk/zoo-kernel/service_internal_js.h
r1 r42 52 52 int zoo_js_support(maps**,map*,service*,maps **,maps **); 53 53 54 JSScript *loadZooApiFile(JSContext*,JSObject*,char*); 55 54 56 #ifdef __cplusplus 55 57 }
Note: See TracChangeset
for help on using the changeset viewer.