- Timestamp:
- Feb 12, 2015, 11:18:07 PM (10 years ago)
- Location:
- trunk/zoo-project/zoo-kernel
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/zoo-project/zoo-kernel/service_internal.c
r579 r580 641 641 } 642 642 return (char*)"-1"; 643 }644 645 #endif646 647 #ifdef USE_JS648 649 JSBool650 JSUpdateStatus(JSContext *cx, uintN argc, jsval *argv1)651 {652 jsval *argv = JS_ARGV(cx,argv1);653 JS_MaybeGC(cx);654 int istatus=0;655 char *status=NULL;656 maps *conf;657 if(argc>2){658 #ifdef JS_DEBUG659 fprintf(stderr,"Number of arguments used to call the function : %i",argc);660 #endif661 return JS_FALSE;662 }663 conf=mapsFromJSObject(cx,argv[0]);664 if(JS_ValueToInt32(cx,argv[1],&istatus)==JS_TRUE){665 char tmpStatus[4];666 sprintf(tmpStatus,"%i",istatus);667 tmpStatus[3]=0;668 status=strdup(tmpStatus);669 }670 if(getMapFromMaps(conf,"lenv","status")!=NULL){671 if(status!=NULL){672 setMapInMaps(conf,"lenv","status",status);673 free(status);674 }675 else676 setMapInMaps(conf,"lenv","status","15");677 _updateStatus(conf);678 }679 freeMaps(&conf);680 free(conf);681 JS_MaybeGC(cx);682 return JS_TRUE;683 643 } 684 644 -
trunk/zoo-project/zoo-kernel/service_internal.h
r579 r580 168 168 169 169 #ifdef USE_JS 170 char* JSValToChar(JSContext*,jsval*);171 JSBool JSUpdateStatus(JSContext*,uintN,jsval *);172 170 #endif 173 171 -
trunk/zoo-project/zoo-kernel/service_internal_java.c
r539 r580 1 /* *1 /* 2 2 * Author : Gérald FENOY 3 3 * … … 25 25 #include "service_internal_java.h" 26 26 27 /** 28 * Load a JAVA class then run the static public method corresponding to the 29 * service by passing the conf, inputs and outputs parameters by reference. 30 * 31 * @param main_conf the conf maps containing the main.cfg settings 32 * @param request the map containing the HTTP request 33 * @param s the service structure 34 * @param real_inputs the maps containing the inputs 35 * @param real_outputs the maps containing the outputs 36 */ 27 37 int zoo_java_support(maps** main_conf,map* request,service* s,maps **real_inputs,maps **real_outputs){ 28 38 maps* m=*main_conf; … … 249 259 /** 250 260 * Error handling: display stack trace in an ExceptionReport Document 261 * 262 * @param env the JNI environment pointer 263 * @param main_conf the conf maps containing the main.cfg settings 251 264 */ 252 265 void displayStack(JNIEnv *env,maps* main_conf){ … … 287 300 } 288 301 302 /** 303 * Create a string containing the JVM -XX:* option for a given map 304 * Depending on the map' name: 305 * - in case the value is minus then the reult will be : -XX:-name 306 * - in case the value is plus then the reult will be : -XX:+name 307 * - in other cases the reult will be : -XX:name=value 308 * 309 * @param m the map containing the option 310 * @return a char* containing the valide JVM option (-XX:*) 311 */ 289 312 char *parseJVMXXOption(map* m){ 290 313 char *res=(char*)malloc((strlen(m->name)+strlen(m->value)+5)*sizeof(char)); … … 298 321 } 299 322 323 /** 324 * Create a string containing the JVM -X*:* option for a given map. 325 * The reult will be in the following format: -Xname:value 326 * 327 * @param m the map containing the option 328 * @return a char* containing the valide JVM option (-XX:*) 329 */ 300 330 char *parseJVMXOption(map* m){ 301 331 char *res=(char*)malloc((strlen(m->name)+strlen(m->value)+5)*sizeof(char)); … … 304 334 } 305 335 336 /** 337 * Convert a maps to a JAVA HashMap<String,HashMap<String,String>> 338 * 339 * @param env the JNI environment pointer 340 * @param t the maps to convert 341 * @param scHashMapClass the HashMap class 342 * @param scHashMap_class the HashMap class 343 * @param scHashMap_constructor the pointer to the hashMap constructor method 344 * @return a created JAVA HashMap containing the converted maps 345 * @warning make sure to free ressources returned by this function 346 */ 306 347 jobject HashMap_FromMaps(JNIEnv *env,maps* t,jclass scHashMapClass,jclass scHashMap_class,jmethodID scHashMap_constructor){ 307 348 jobject scObject,scObject1; … … 439 480 } 440 481 482 /** 483 * Convert a JAVA HashMap<String,HashMap<String,String>> to a maps 484 * 485 * @param env the JNI environment pointer 486 * @param t the HashMap 487 * @param scHashMapClass the hashMap class 488 * @return a created maps containing the converted HashMap 489 * @warning make sure to free ressources returned by this function 490 */ 441 491 maps* mapsFromHashMap(JNIEnv *env,jobject t,jclass scHashMapClass){ 442 492 #ifdef DEBUG -
trunk/zoo-project/zoo-kernel/service_internal_java.h
r539 r580 1 /* *1 /* 2 2 * Author : Gérald FENOY 3 3 * -
trunk/zoo-project/zoo-kernel/service_internal_js.c
r576 r580 1 /* *1 /* 2 2 * Author : Gérald FENOY 3 3 * … … 31 31 static char dbg[1024]; 32 32 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 */ 33 41 JSBool 34 42 JSAlert(JSContext *cx, uintN argc, jsval *argv1) … … 48 56 } 49 57 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 */ 50 66 JSBool 51 67 JSLoadScripts(JSContext *cx, uintN argc, jsval *argv1) … … 79 95 } 80 96 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 */ 110 int zoo_js_support(maps** main_conf,map* request,service* s,maps **inputs,maps **outputs) 84 111 { 85 112 maps* main=*main_conf; … … 355 382 } 356 383 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 */ 357 392 JSObject * loadZooApiFile(JSContext *cx,JSObject *global, char* filename){ 358 393 struct stat api_status; … … 381 416 } 382 417 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 */ 383 425 JSObject* JSObject_FromMaps(JSContext *cx,maps* t){ 384 385 426 JSObject* res=JS_NewObject(cx, NULL, NULL, NULL); 386 427 //JSObject *res = JS_NewArrayObject(cx, 0, NULL); … … 402 443 } 403 444 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 */ 404 452 JSObject* JSObject_FromMap(JSContext *cx,map* t){ 405 453 JSObject* res=JS_NewObject(cx, NULL, NULL, NULL); … … 454 502 } 455 503 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 */ 456 511 maps* mapsFromJSObject(JSContext *cx,jsval t){ 457 512 maps *res=NULL; … … 629 684 } 630 685 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 */ 631 693 map* mapFromJSObject(JSContext *cx,jsval t){ 632 694 map *res=NULL; … … 684 746 } 685 747 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 */ 687 755 void reportError(JSContext *cx, const char *message, JSErrorReport *report) 688 756 { … … 697 765 } 698 766 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 */ 699 775 char* JSValToChar(JSContext* context, jsval* arg) { 700 776 char *c; … … 724 800 } 725 801 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 */ 726 810 HINTERNET setHeader(HINTERNET* handle,JSContext *cx,JSObject *header){ 727 811 jsuint length=0; … … 758 842 } 759 843 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 */ 760 854 JSBool 761 855 JSTranslate(JSContext *cx, uintN argc, jsval *argv1) … … 769 863 } 770 864 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 */ 771 874 JSBool 772 875 JSRequest(JSContext *cx, uintN argc, jsval *argv1) … … 847 950 return JS_TRUE; 848 951 } 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 */ 963 JSBool 964 JSUpdateStatus(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 -
trunk/zoo-project/zoo-kernel/service_internal_js.h
r383 r580 1 /* *1 /* 2 2 * Author : Gérald FENOY 3 3 * … … 48 48 JSBool JSTranslate(JSContext*, uintN, jsval*); 49 49 JSBool JSRequest(JSContext*, uintN, jsval*); 50 JSBool JSUpdateStatus(JSContext*,uintN,jsval *); 50 51 51 52 void reportError(JSContext *cx, const char *message, JSErrorReport *report); -
trunk/zoo-project/zoo-kernel/service_internal_otb.c
r576 r580 1 /* *1 /* 2 2 * Author : Gérald FENOY 3 3 * … … 31 31 using namespace otb::Wrapper; 32 32 33 /** 34 * The ZooWatcher list 35 */ 33 36 WatcherListType m_WatcherList; 37 /** 38 * A pointer to the conf maps containing the main.cfg settings 39 */ 34 40 maps* m_Conf; 35 41 42 /** 43 * The command to create a ZooWatcher and add it to the global m_WatcherList 44 */ 36 45 class MyCommand : public itk::Command 37 46 { … … 40 49 public: 41 50 51 /** 52 * The method that defines the action to be taken by the command. 53 * 54 * @param caller an itk::Object pointer 55 * @param event an itk::EventObject pointer 56 */ 42 57 void Execute(itk::Object *caller, const itk::EventObject & event) 43 58 { … … 45 60 } 46 61 47 void Execute(const itk::Object * object, const itk::EventObject & event) 62 /** 63 * The method that defines the action to be taken by the command. 64 * Create a new ZooWatcher instance then add it to the m_WatcherList. 65 * 66 * @param caller a const itk::Object pointer 67 * @param event an itk::EventObject pointer 68 * @see ZooWatcher,ZooWatcher::SetConf 69 */ 70 void Execute(const itk::Object *caller, const itk::EventObject & event) 48 71 { 49 72 const AddProcessToWatchEvent* eventToWatch = dynamic_cast< const AddProcessToWatchEvent*> ( &event ); 50 73 std::string m_CurrentDescription = eventToWatch->GetProcessDescription(); 51 std::cerr << "err_service_zooo start ccalled." << m_CurrentDescription << std::endl;52 74 ZooWatcher * watch = new ZooWatcher(eventToWatch->GetProcess(), 53 75 eventToWatch->GetProcessDescription()); … … 56 78 } 57 79 58 59 60 80 }; 61 81 62 82 /** 83 * Replace all occurence of from by to in a str string 84 * 85 * @param str the string to transform 86 * @param from the string to replace 87 * @param to the string used as replacement 88 * @return the resulting string 89 */ 63 90 std::string ReplaceAll(std::string str, const std::string& from, const std::string& to) { 64 91 size_t start_pos = 0; … … 70 97 } 71 98 99 /** 100 * Load and run an OTB Application corresponding to the service by using inputs parameters. 101 * Define the m_Conf 102 * 103 * @param main_conf the conf maps containing the main.cfg settings 104 * @param request the map containing the HTTP request 105 * @param s the service structure 106 * @param real_inputs the maps containing the inputs 107 * @param real_outputs the maps containing the outputs 108 */ 72 109 int zoo_otb_support(maps** main_conf,map* request,service* s,maps **real_inputs,maps **real_outputs){ 73 110 maps* m=*main_conf; -
trunk/zoo-project/zoo-kernel/service_internal_otb.h
r561 r580 1 /* *1 /* 2 2 * Author : Gérald FENOY 3 3 * … … 43 43 #include <string> 44 44 45 /** 46 * A vector to store the ZooWatcher 47 */ 45 48 typedef std::vector<ZooWatcher *> WatcherListType; 49 46 50 int zoo_otb_support(maps**,map*,service*,maps**,maps**); 47 51 -
trunk/zoo-project/zoo-kernel/service_internal_php.c
r556 r580 1 /* *1 /* 2 2 * Author : Gérald FENOY 3 3 * … … 41 41 map* php_map_from_HasTable(HashTable* t); 42 42 43 /** 44 * Load a PHP script then run the function corresponding to the service by 45 * passing the conf, inputs and outputs parameters by reference. 46 * 47 * @param main_conf the conf maps containing the main.cfg settings 48 * @param request the map containing the HTTP request 49 * @param s the service structure 50 * @param real_inputs the maps containing the inputs 51 * @param real_outputs the maps containing the outputs 52 */ 43 53 int zoo_php_support(maps** main_conf,map* request,service* s,maps **real_inputs,maps **real_outputs){ 44 54 maps* m=*main_conf; … … 101 111 } 102 112 113 /** 114 * Convert a maps to a php Array 115 * 116 * @param t the maps to convert 117 * @return the php Array 118 */ 103 119 zval *php_Array_from_maps(maps* t){ 104 120 zval *mapArray; … … 115 131 } 116 132 133 /** 134 * Convert a map to a php Array 135 * 136 * @param t the map to convert 137 * @return the php Array 138 */ 117 139 zval *php_Array_from_map(map* t){ 118 140 zval *mapArray; … … 135 157 } 136 158 159 /** 160 * Convert a php Array to a maps 161 * 162 * @param t the php Array to convert 163 * @return the created maps 164 */ 137 165 maps* php_maps_from_Array(HashTable *t){ 138 166 maps* final_res=NULL; … … 201 229 } 202 230 231 /** 232 * Convert a php Array to a map 233 * 234 * @param t the php Array to convert 235 * @return the created map 236 */ 203 237 map* php_map_from_HasTable(HashTable* t){ 204 238 #ifdef DEBUG -
trunk/zoo-project/zoo-kernel/service_internal_php.h
r556 r580 1 /* *1 /* 2 2 * Author : Gérald FENOY 3 3 * -
trunk/zoo-project/zoo-kernel/service_internal_python.c
r579 r580 136 136 137 137 /** 138 * Load inga Python module then run the function corresponding to the service138 * Load a Python module then run the function corresponding to the service 139 139 * by passing the conf, inputs and outputs parameters by reference. 140 140 * … … 302 302 303 303 /** 304 * Rep port Python error which may occur on loading the Python module or at304 * Report Python error which may occur on loading the Python module or at 305 305 * runtime. 306 306 * … … 608 608 609 609 /** 610 * Use the ZOO-Services messages translation function 610 * Use the ZOO-Services messages translation function from the Python 611 611 * environment 612 612 * -
trunk/zoo-project/zoo-kernel/service_yaml.c
r490 r580 1 /* *1 /* 2 2 * Author : Gérald FENOY 3 3 * … … 31 31 static map* current_content=NULL; 32 32 static elements* current_element=NULL; 33 static char* curr_key; 34 35 /** 36 * getServiceFromFile : 37 * set service given as second parameter with informations extracted from the 38 * definition file. 39 */ 33 40 34 #ifdef __cplusplus 41 35 extern "C" { 42 36 #endif 43 37 38 /** 39 * Read and parse a ZCFG file in YAML format 40 * 41 * @param conf the conf maps containing the main.cfg settings 42 * @param file the file name to read 43 * @param service the service structure to fill 44 * @param name the service name 45 * @return 1 on success, -1 if error occured 46 */ 44 47 int getServiceFromYAML(maps* conf, char* file,service** service,char *name){ 45 48 FILE *fh = fopen("test.yml", "r");
Note: See TracChangeset
for help on using the changeset viewer.