Changeset 738 for trunk/zoo-project/zoo-kernel
- Timestamp:
- Jul 13, 2015, 3:42:39 PM (9 years ago)
- Location:
- trunk/zoo-project/zoo-kernel
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/zoo-project/zoo-kernel/caching.c
r725 r738 303 303 */ 304 304 int loadRemoteFile(maps** m,map** content,HINTERNET* hInternet,char *url){ 305 char* fcontent ;305 char* fcontent = NULL; 306 306 char* cached=isInCache(*m,url); 307 307 char *mimeType=NULL; … … 353 353 354 354 tmpMap->value=(char*)malloc((fsize+1)*sizeof(char)); 355 if(tmpMap->value==NULL )355 if(tmpMap->value==NULL || fcontent == NULL) 356 356 return errorException(*m, _("Unable to allocate memory"), "InternalError",NULL); 357 357 memcpy(tmpMap->value,fcontent,(fsize+1)*sizeof(char)); -
trunk/zoo-project/zoo-kernel/response_print.c
r725 r738 786 786 void printDescribeProcessForProcess(registry *reg, maps* m,xmlNodePtr nc,service* serv){ 787 787 xmlNsPtr ns,ns_ows,ns_xlink; 788 xmlNodePtr n,nc1,nc2; 788 xmlNodePtr n,nc1; 789 xmlNodePtr nc2 = NULL; 789 790 map* version=getMapFromMaps(m,"main","rversion"); 790 791 int vid=getVersionId(version->value); … … 872 873 if(vid==0) 873 874 xmlAddChild(n,nc); 874 else {875 else if (nc2 != NULL) { 875 876 xmlAddChild(nc2,nc); 876 877 xmlAddChild(n,nc2); -
trunk/zoo-project/zoo-kernel/service.c
r712 r738 455 455 * @param v the corresponding value to add 456 456 * @param size the size of the given value 457 */ 458 void addToMapWithSize(map* m,const char* n,const char* v,int size){ 457 * @return a pointer to the updated map m 458 */ 459 map* addToMapWithSize(map* m,const char* n,const char* v,int size){ 459 460 if(hasKey(m,n)==false){ 460 461 map* _cursor=m; … … 477 478 sprintf(sin,"%d",size); 478 479 addToMap(m,sname,sin); 480 return m; 479 481 } 480 482 -
trunk/zoo-project/zoo-kernel/service.h
r712 r738 292 292 ZOO_DLL_EXPORT void addToMap(map*,const char*,const char*); 293 293 ZOO_DLL_EXPORT void addIntToMap(map*,const char*,const int); 294 ZOO_DLL_EXPORT voidaddToMapWithSize(map*,const char*,const char*,int);294 ZOO_DLL_EXPORT map* addToMapWithSize(map*,const char*,const char*,int); 295 295 ZOO_DLL_EXPORT void addMapToMap(map**,map*); 296 296 ZOO_DLL_EXPORT void addMapToIoType(iotype**,map*); -
trunk/zoo-project/zoo-kernel/service_internal.c
r730 r738 189 189 sprintf (fbkpid, "%s/%s.status", r_inputs->value, lid); 190 190 FILE* f0 = fopen (fbkpid, "r"); 191 if(f0!=NULL){ 192 semid lockid ;191 if(f0!=NULL){ 192 semid lockid = NULL; 193 193 char* stat; 194 194 long flen; … … 270 270 if(status!=NULL && msg!=NULL && 271 271 status->value!=NULL && msg->value!=NULL && 272 strlen(status->value)>0 && strlen(msg->value)>1){ 273 semid lockid ;272 strlen(status->value)>0 && strlen(msg->value)>1){ 273 semid lockid = NULL; 274 274 char* stat=getStatusId(conf,sid->value); 275 275 if(stat!=NULL){ -
trunk/zoo-project/zoo-kernel/service_internal_php.c
r712 r738 432 432 convert_to_string(&tmpcopy); 433 433 if(strncmp(key,"value",5)==0){ 434 len=Z_STRLEN_P(&tmpcopy); 435 434 len=Z_STRLEN_P(&tmpcopy); 435 final_res = addToMapWithSize(final_res,key,Z_STRVAL_P(&tmpcopy),len); 436 436 } 437 437 else{ -
trunk/zoo-project/zoo-kernel/service_internal_python.c
r682 r738 563 563 564 564 /** 565 * Convert a Python dictionary to a maps 566 * 567 * @param t the PyDictObject to convert 568 * @return a new maps containing the converted PyDictObject 569 * @warning make sure to free resources returned by this function 570 */ 571 maps* _mapsFromPyDict(PyDictObject* t){ 572 573 PyObject* list = PyDict_Keys((PyObject*)t); // new ref 574 int nb = PyList_Size(list); 575 576 if (nb < 1) { 577 Py_DECREF(list); 578 return NULL; 579 } 580 581 maps* ptr = (maps*) malloc(MAPS_SIZE); 582 maps* res = ptr; 583 584 PyObject* key; 585 PyObject* value; 586 587 for(int i = 0; i < nb; i++) { 588 589 key = PyList_GetItem(list,i); // borrowed ref 590 value = PyDict_GetItem((PyObject*) t, key); // borrowed ref 591 592 ptr->name = zStrdup(PyString_AsString(key)); 593 ptr->content = mapFromPyDict((PyDictObject*) value); 594 595 ptr->next = i < nb - 1 ? (maps*) malloc(MAPS_SIZE) : NULL; 596 ptr = ptr->next; 597 } 598 Py_DECREF(list); 599 600 return res; 601 } // mapsFromPyDict 602 603 /** 565 604 * Convert a Python dictionary to a map 566 605 * … … 597 636 } 598 637 else{ 638 #ifdef DEBUG 599 639 fprintf(stderr,"Unsupported return value."); 640 #endif 600 641 return NULL; 601 642 } 602 643 #else 603 644 PyString_AsStringAndSize(value,&buffer,&size); 604 #endif 605 645 #endif 646 res = addToMapWithSize(res,PyString_AsString(key),buffer,size); 606 647 }else{ 607 648 char* lkey=PyString_AsString(key); … … 622 663 623 664 /** 665 * Convert a Python dictionary to a map 666 * 667 * @param t the PyDictObject to convert 668 * @return a new map containing the converted PyDictObject 669 * @warning make sure to free resources returned by this function 670 */ 671 map* _mapFromPyDict(PyDictObject* t) { 672 673 PyObject* list = PyDict_Keys((PyObject*) t); // new ref 674 int nb = PyList_Size(list); 675 676 if (nb < 1) { 677 Py_DECREF(list); 678 return NULL; 679 } 680 681 map* ptr = (map*) malloc(MAP_SIZE); 682 map* res = ptr; 683 684 PyObject* key; 685 PyObject* value; 686 char *buffer = NULL; 687 Py_ssize_t size; 688 for(int i = 0; i < nb; i++) { 689 690 key = PyList_GetItem(list, i); // borrowed ref 691 value = PyDict_GetItem((PyObject*) t, key); // borrowed ref 692 693 ptr->name = zStrdup(PyString_AsString(key)); 694 map* msize = NULL; 695 696 #if PY_MAJOR_VERSION >= 3 697 if (PyBytes_Check(value)) { 698 // value is byte array 699 size = PyBytes_Size(value); 700 buffer = PyBytes_AsString(value); // pointer to internal buffer 701 char sz[32]; 702 sprintf(sz, "%d", (int) size); 703 msize = createMap("size", sz); 704 } 705 else if (PyUnicode_Check(value) && PyUnicode_READY(value) == 0) { 706 // value is string object 707 buffer = PyUnicode_AsUTF8AndSize(value, &size); 708 size++; 709 } 710 else { 711 printf("Type not recognized\n"); 712 // error handling 713 // ... 714 } 715 #else 716 PyString_AsStringAndSize(value, &buffer, &size); 717 size++; 718 // to do: handle byte arrays 719 #endif 720 721 ptr->value = (char*) malloc(size); // check for NULL pointer 722 memmove(ptr->value, buffer, size); 723 724 if (msize != NULL) { 725 ptr->next = msize; 726 ptr = ptr->next; 727 } 728 729 ptr->next = i < nb - 1 ? (map*) malloc(MAP_SIZE) : NULL; 730 ptr = ptr->next; 731 } 732 Py_DECREF(list); 733 734 return res; 735 } // mapFromPyDict 736 737 /** 624 738 * Use the ZOO-Services messages translation function from the Python 625 739 * environment -
trunk/zoo-project/zoo-kernel/zoo_service_loader.c
r725 r738 961 961 setenv ("LC_ALL", tmp, 1); 962 962 #else 963 char tmp1[12];963 char tmp1[13]; 964 964 sprintf (tmp1, "LC_ALL=%s", tmp); 965 965 putenv (tmp1); … … 973 973 setenv ("LC_ALL", "en_US", 1); 974 974 #else 975 char tmp1[12];975 char tmp1[13]; 976 976 sprintf (tmp1, "LC_ALL=en_US"); 977 977 putenv (tmp1); … … 1473 1473 { 1474 1474 map* version=getMapFromMaps(m,"main","rversion"); 1475 int vid=getVersionId(version->value); 1476 int len,j=0; 1475 int vid=getVersionId(version->value); 1476 int len = 0; 1477 int j = 0; 1477 1478 for(j=0;j<nbSupportedRequests;j++){ 1478 1479 if(requests[vid][j]!=NULL)
Note: See TracChangeset
for help on using the changeset viewer.