Changeset 640 for trunk/zoo-project/zoo-kernel/service.h
- Timestamp:
- May 28, 2015, 4:25:06 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/zoo-project/zoo-kernel/service.h
r631 r640 144 144 * The memory size to create an elements 145 145 */ 146 #define ELEMENTS_SIZE (sizeof(char*)+(((2*sizeof(char*))+sizeof(maps*))*2)+sizeof(char*)+(((2*sizeof(char*))+sizeof(iotype*))*2)+ sizeof(elements*))146 #define ELEMENTS_SIZE (sizeof(char*)+(((2*sizeof(char*))+sizeof(maps*))*2)+sizeof(char*)+(((2*sizeof(char*))+sizeof(iotype*))*2)+(2*sizeof(elements*))) 147 147 /** 148 148 * The memory size to create a map … … 206 206 struct maps* next; //!< the pointer to the next maps if any or NULL 207 207 } maps; 208 209 /**210 * Dump a map on stderr211 *212 * @param t the map to dump213 */214 static void _dumpMap(map* t){215 if(t!=NULL){216 fprintf(stderr,"%s: %s\n",t->name,t->value);217 fflush(stderr);218 }else{219 fprintf(stderr,"NULL\n");220 fflush(stderr);221 }222 }223 224 /**225 * Dump a map on stderr, see _dumpMap()226 *227 * @param t the map to dump228 */229 static void dumpMap(map* t){230 map* tmp=t;231 while(tmp!=NULL){232 _dumpMap(tmp);233 tmp=tmp->next;234 }235 }236 237 /**238 * Dump a map to a file239 *240 * @param t the map to dump to file241 * @param file the file to store the map242 */243 static void dumpMapToFile(map* t,FILE* file){244 map* tmp=t;245 while(tmp!=NULL){246 #ifdef DEBUG247 fprintf(stderr,"%s = %s\n",tmp->name,tmp->value);248 #endif249 fprintf(file,"%s = %s\n",tmp->name,tmp->value);250 tmp=tmp->next;251 }252 }253 208 254 /**255 * Dump a maps on stderr, see dumpMap().256 *257 * @param m the map to dump258 */259 static void dumpMaps(maps* m){260 maps* tmp=m;261 while(tmp!=NULL){262 fprintf(stderr,"MAP => [%s] \n",tmp->name);263 dumpMap(tmp->content);264 tmp=tmp->next;265 }266 }267 268 /**269 * Dump a maps to a file, see dumpMapToFile().270 *271 * @param m the map to dump272 * @param file_path the full path to the file name to store the map273 */274 static void dumpMapsToFile(maps* m,char* file_path){275 FILE* file=fopen(file_path,"w");276 maps* tmp=m;277 if(tmp!=NULL){278 fprintf(file,"[%s]\n",tmp->name);279 dumpMapToFile(tmp->content,file);280 fflush(file);281 }282 fclose(file);283 }284 285 /**286 * Create a new map287 *288 * @param name the key to add to the map289 * @param value the corresponding value to add to the map290 * @return the allocated map291 */292 static map* createMap(const char* name,const char* value){293 map* tmp=(map *)malloc(MAP_SIZE);294 tmp->name=zStrdup(name);295 tmp->value=zStrdup(value);296 tmp->next=NULL;297 return tmp;298 }299 300 /**301 * Count number of map in a map302 *303 * @param m the maps to count304 * @return number of map in a map305 */306 static int count(map* m){307 map* tmp=m;308 int c=0;309 while(tmp!=NULL){310 c++;311 tmp=tmp->next;312 }313 return c;314 }315 316 /**317 * Verify if a key exist in a map318 *319 * @param m the map to search for the key320 * @param key the key to search in the map321 * @return true if the key wwas found, false in other case322 */323 static bool hasKey(map* m,const char *key){324 map* tmp=m;325 while(tmp!=NULL){326 if(strcasecmp(tmp->name,key)==0)327 return true;328 tmp=tmp->next;329 }330 #ifdef DEBUG_MAP331 fprintf(stderr,"NOT FOUND \n");332 #endif333 return false;334 }335 336 /**337 * Access a specific maps338 *339 * @param m the maps to search for the key340 * @param key the key to search in the maps341 * @return a pointer on the maps found or NULL if not found342 */343 static maps* getMaps(maps* m,const char *key){344 maps* tmp=m;345 while(tmp!=NULL){346 if(strcasecmp(tmp->name,key)==0){347 return tmp;348 }349 tmp=tmp->next;350 }351 return NULL;352 }353 354 /**355 * Access a specific map356 *357 * @param m the map to search for the key358 * @param key the key to search in the map359 * @return a pointer on the map found or NULL if not found360 */361 static map* getMap(map* m,const char *key){362 map* tmp=m;363 while(tmp!=NULL){364 if(strcasecmp(tmp->name,key)==0){365 return tmp;366 }367 tmp=tmp->next;368 }369 return NULL;370 }371 372 373 /**374 * Access the last map375 *376 * @param m the map to search for the lastest map377 * @return a pointer on the lastest map found or NULL if not found378 */379 static map* getLastMap(map* m){380 map* tmp=m;381 while(tmp!=NULL){382 if(tmp->next==NULL){383 return tmp;384 }385 tmp=tmp->next;386 }387 return NULL;388 }389 390 /**391 * Access a specific map from a maps392 *393 * @param m the maps to search for the key394 * @param key the key to search in the maps395 * @param subkey the key to search in the map (found for the key, if any)396 * @return a pointer on the map found or NULL if not found397 */398 static map* getMapFromMaps(maps* m,const char* key,const char* subkey){399 maps* _tmpm=getMaps(m,key);400 if(_tmpm!=NULL){401 map* _ztmpm=getMap(_tmpm->content,subkey);402 return _ztmpm;403 }404 else return NULL;405 }406 407 /**408 * Free allocated memory of a map.409 * Require to call free on mo after calling this function.410 *411 * @param mo the map to free412 */413 static void freeMap(map** mo){414 map* _cursor=*mo;415 if(_cursor!=NULL){416 #ifdef DEBUG417 fprintf(stderr,"freeMap\n");418 #endif419 free(_cursor->name);420 free(_cursor->value);421 if(_cursor->next!=NULL){422 freeMap(&_cursor->next);423 free(_cursor->next);424 }425 }426 }427 428 /**429 * Free allocated memory of a maps.430 * Require to call free on mo after calling this function.431 *432 * @param mo the maps to free433 */434 static void freeMaps(maps** mo){435 maps* _cursor=*mo;436 if(_cursor && _cursor!=NULL){437 #ifdef DEBUG438 fprintf(stderr,"freeMaps\n");439 #endif440 free(_cursor->name);441 if(_cursor->content!=NULL){442 freeMap(&_cursor->content);443 free(_cursor->content);444 }445 if(_cursor->next!=NULL){446 freeMaps(&_cursor->next);447 free(_cursor->next);448 }449 }450 }451 452 209 /** 453 210 * Not named linked list … … 472 229 struct iotype* defaults; //!< the default iotype 473 230 struct iotype* supported; //!< the supported iotype 231 struct elements* child; //!< the pointer to the children element if any (or NULL) 474 232 struct elements* next; //!< the pointer to the next element if any (or NULL) 475 233 } elements; … … 503 261 } registry; 504 262 505 /** 506 * Verify if an elements contains a name equal to the given key. 507 * 508 * @param e the elements to search for the key 509 * @param key the elements name to search 510 * @return true if the elements contains the name, false in other cases. 511 */ 512 static bool hasElement(elements* e,const char* key){ 513 elements* tmp=e; 514 while(tmp!=NULL){ 515 if(strcasecmp(key,tmp->name)==0) 516 return true; 517 tmp=tmp->next; 518 } 519 return false; 520 } 521 522 /** 523 * Access a specific elements named key. 524 * 525 * @param m the elements to search 526 * @param key the elements name to search 527 * @return a pointer to the specific element if found, NULL in other case. 528 */ 529 static elements* getElements(elements* m,char *key){ 530 elements* tmp=m; 531 while(tmp!=NULL){ 532 if(strcasecmp(tmp->name,key)==0) 533 return tmp; 534 tmp=tmp->next; 535 } 536 return NULL; 537 } 538 539 /** 540 * Free allocated memory of an iotype. 541 * Require to call free on i after calling this function. 542 * 543 * @param i the iotype to free 544 */ 545 static void freeIOType(iotype** i){ 546 iotype* _cursor=*i; 547 if(_cursor!=NULL){ 548 if(_cursor->next!=NULL){ 549 freeIOType(&_cursor->next); 550 free(_cursor->next); 551 } 552 freeMap(&_cursor->content); 553 free(_cursor->content); 554 } 555 } 556 557 /** 558 * Free allocated memory of an elements. 559 * Require to call free on e after calling this function. 560 * 561 * @param e the iotype to free 562 */ 563 static void freeElements(elements** e){ 564 elements* tmp=*e; 565 if(tmp!=NULL){ 566 if(tmp->name!=NULL) 567 free(tmp->name); 568 freeMap(&tmp->content); 569 if(tmp->content!=NULL) 570 free(tmp->content); 571 freeMap(&tmp->metadata); 572 if(tmp->metadata!=NULL) 573 free(tmp->metadata); 574 if(tmp->format!=NULL) 575 free(tmp->format); 576 freeIOType(&tmp->defaults); 577 if(tmp->defaults!=NULL) 578 free(tmp->defaults); 579 freeIOType(&tmp->supported); 580 if(tmp->supported!=NULL){ 581 free(tmp->supported); 582 } 583 freeElements(&tmp->next); 584 if(tmp->next!=NULL) 585 free(tmp->next); 586 } 587 } 588 589 /** 590 * Free allocated memory of a service. 591 * Require to call free on e after calling this function. 592 * 593 * @param s the service to free 594 */ 595 static void freeService(service** s){ 596 service* tmp=*s; 597 if(tmp!=NULL){ 598 if(tmp->name!=NULL) 599 free(tmp->name); 600 freeMap(&tmp->content); 601 if(tmp->content!=NULL) 602 free(tmp->content); 603 freeMap(&tmp->metadata); 604 if(tmp->metadata!=NULL) 605 free(tmp->metadata); 606 freeElements(&tmp->inputs); 607 if(tmp->inputs!=NULL) 608 free(tmp->inputs); 609 freeElements(&tmp->outputs); 610 if(tmp->outputs!=NULL) 611 free(tmp->outputs); 612 } 613 } 614 615 /** 616 * Add key value pair to an existing map. 617 * 618 * @param m the map to add the KVP 619 * @param n the key to add 620 * @param v the corresponding value to add 621 */ 622 static void addToMap(map* m,const char* n,const char* v){ 623 if(hasKey(m,n)==false){ 624 map* _cursor=m; 625 while(_cursor->next!=NULL){ 626 _cursor=_cursor->next; 627 } 628 _cursor->next=createMap(n,v); 629 } 630 else{ 631 map *tmp=getMap(m,n); 632 if(tmp->value!=NULL) 633 free(tmp->value); 634 tmp->value=zStrdup(v); 635 } 636 } 637 638 /** 639 * Add a key and an integer value to an existing map. 640 * 641 * @param m the map to add the KVP 642 * @param n the key to add 643 * @param v the corresponding value to add 644 */ 645 static void addIntToMap(map* m,const char* n,const int v){ 646 char svalue[10]; 647 sprintf(svalue,"%d",v); 648 if(hasKey(m,n)==false){ 649 map* _cursor=m; 650 while(_cursor->next!=NULL){ 651 _cursor=_cursor->next; 652 } 653 _cursor->next=createMap(n,svalue); 654 } 655 else{ 656 map *tmp=getMap(m,n); 657 if(tmp->value!=NULL) 658 free(tmp->value); 659 tmp->value=zStrdup(svalue); 660 } 661 } 662 663 /** 664 * Add a key and a binary value to an existing map. 665 * 666 * @param m the map to add the KVP 667 * @param n the key to add 668 * @param v the corresponding value to add 669 * @param size the size of the given value 670 */ 671 static void addToMapWithSize(map* m,const char* n,const char* v,int size){ 672 if(hasKey(m,n)==false){ 673 map* _cursor=m; 674 if(_cursor!=NULL){ 675 addToMap(m,n,""); 676 }else{ 677 m=createMap(n,""); 678 } 679 } 680 char sname[10]="size"; 681 if(strlen(n)>5) 682 sprintf(sname,"size_%s",n+6); 683 map *tmp=getMap(m,n); 684 if(tmp->value!=NULL) 685 free(tmp->value); 686 tmp->value=(char*)malloc((size+1)*sizeof(char)); 687 memmove(tmp->value,v,size*sizeof(char)); 688 tmp->value[size]=0; 689 char sin[128]; 690 sprintf(sin,"%d",size); 691 addToMap(m,sname,sin); 692 } 693 694 /** 695 * Add a map at the end of another map. 696 * 697 * @param mo the map to add mi 698 * @param mi the map to add to mo 699 */ 700 static void addMapToMap(map** mo,map* mi){ 701 map* tmp=mi; 702 map* _cursor=*mo; 703 while(tmp!=NULL){ 704 if(_cursor==NULL){ 705 *mo=createMap(tmp->name,tmp->value); 706 (*mo)->next=NULL; 707 } 708 else{ 709 #ifdef DEBUG 710 fprintf(stderr,"_CURSOR\n"); 711 dumpMap(_cursor); 712 #endif 713 while(_cursor->next!=NULL) 714 _cursor=_cursor->next; 715 map* tmp1=getMap(*mo,tmp->name); 716 if(tmp1==NULL){ 717 _cursor->next=createMap(tmp->name,tmp->value); 718 } 719 else{ 720 addToMap(*mo,tmp->name,tmp->value); 721 } 722 } 723 _cursor=*mo; 724 tmp=tmp->next; 725 #ifdef DEBUG 726 fprintf(stderr,"MO\n"); 727 dumpMap(*mo); 728 #endif 729 } 730 } 731 732 /** 733 * Add a map to iotype. 734 * 735 * @param io the iotype to add the map 736 * @param mi the map to add to io 737 */ 738 static void addMapToIoType(iotype** io,map* mi){ 739 iotype* tmp=*io; 740 while(tmp->next!=NULL){ 741 tmp=tmp->next; 742 } 743 tmp->next=(iotype*)malloc(IOTYPE_SIZE); 744 tmp->next->content=NULL; 745 addMapToMap(&tmp->next->content,mi); 746 tmp->next->next=NULL; 747 } 748 749 /** 750 * Access a specific map or set its value. 751 * 752 * @param m the map to search for the key 753 * @param key the key to search/add in the map 754 * @param value the value to add if the key does not exist 755 * @return a pointer on the map found or NULL if not found 756 */ 757 static map* getMapOrFill(map** m,const char *key,const char* value){ 758 map* tmp=*m; 759 map* tmpMap=getMap(tmp,key); 760 if(tmpMap==NULL){ 761 if(tmp!=NULL){ 762 addToMap((*m),key,value); 763 } 764 else 765 (*m)=createMap(key,value); 766 tmpMap=getMap(*m,key); 767 } 768 return tmpMap; 769 } 770 771 /** 772 * Verify if a map is contained in another map. 773 * 774 * @param m the map to search for i 775 * @param i the map to search in m 776 * @return true if i was found in m, false in other case 777 */ 778 static bool contains(map* m,map* i){ 779 while(i!=NULL){ 780 if(strcasecmp(i->name,"value")!=0 && 781 strcasecmp(i->name,"xlink:href")!=0 && 782 strcasecmp(i->name,"useMapServer")!=0 && 783 strcasecmp(i->name,"asReference")!=0){ 784 map *tmp; 785 if(hasKey(m,i->name) && (tmp=getMap(m,i->name))!=NULL && 786 strcasecmp(i->value,tmp->value)!=0) 787 return false; 788 } 789 i=i->next; 790 } 791 return true; 792 } 793 794 /** 795 * Access a specific iotype from an elements. 796 * 797 * @param e the elements to search for the name 798 * @param name the name to search in the elements e 799 * @param values the map to verify it was contained in the defaults or 800 * supported content of the elements e 801 * @return a pointer on the iotype found or NULL if not found 802 */ 803 static iotype* getIoTypeFromElement(elements* e,char *name, map* values){ 804 elements* cursor=e; 805 while(cursor!=NULL){ 806 if(strcasecmp(cursor->name,name)==0){ 807 if(contains(cursor->defaults->content,values)==true) 808 return cursor->defaults; 809 else{ 810 iotype* tmp=cursor->supported; 811 while(tmp!=NULL){ 812 if(contains(tmp->content,values)==true) 813 return tmp; 814 tmp=tmp->next; 815 } 816 } 817 } 818 cursor=cursor->next; 819 } 820 return NULL; 821 } 822 823 /** 824 * Load binary values from a map (in) and add them to another map (out) 825 * 826 * @param out the map to add binaries values 827 * @param in the map containing the binary values to add ti out 828 * @param pos index of the binary in an array (in case of "MapArray") 829 */ 830 static void loadMapBinary(map** out,map* in,int pos){ 831 map* size=getMap(in,"size"); 832 map *lout=*out; 833 if(size!=NULL && pos>0){ 834 char tmp[11]; 835 sprintf(tmp,"size_%d",pos); 836 size=getMap(in,tmp); 837 sprintf(tmp,"value_%d",pos); 838 map* tmpVin=getMap(in,tmp); 839 map* tmpVout=getMap(lout,tmp); 840 free(tmpVout->value); 841 tmpVout->value=(char*)malloc((atoi(size->value)+1)*sizeof(char)); 842 memmove(tmpVout->value,tmpVin->value,atoi(size->value)*sizeof(char)); 843 tmpVout->value[atoi(size->value)]=0; 844 }else{ 845 if(size!=NULL){ 846 map* tmpVin=getMap(in,"value"); 847 map* tmpVout=getMap(lout,"value"); 848 free(tmpVout->value); 849 tmpVout->value=(char*)malloc((atoi(size->value)+1)*sizeof(char)); 850 memmove(tmpVout->value,tmpVin->value,atoi(size->value)*sizeof(char)); 851 tmpVout->value[atoi(size->value)]=0; 852 } 853 } 854 } 263 264 void _dumpMap(map*); 265 void dumpMap(map*); 266 void dumpMapToFile(map*,FILE*); 267 void dumpMaps(maps* m); 268 void dumpMapsToFile(maps*,char*); 269 map* createMap(const char*,const char*); 270 int count(map*); 271 bool hasKey(map*,const char*); 272 maps* getMaps(maps*,const char*); 273 map* getMap(map*,const char*); 274 map* getLastMap(map*); 275 map* getMapFromMaps(maps*,const char*,const char*); 276 void freeMap(map**); 277 void freeMaps(maps** mo); 855 278 856 /** 857 * Load binary values from a map (in) and add them to another map (out). 858 * This function will take care of MapArray. 859 * @see loadMapBinary 860 * 861 * @param out the map to add binaries values 862 * @param in the map containing the binary values to add ti out 863 */ 864 static void loadMapBinaries(map** out,map* in){ 865 map* size=getMap(in,"size"); 866 map* length=getMap(in,"length"); 867 if(length!=NULL){ 868 int len=atoi(length->value); 869 int i=0; 870 for(i=0;i<len;i++){ 871 loadMapBinary(out,in,i); 872 } 873 } 874 else 875 if(size!=NULL) 876 loadMapBinary(out,in,-1); 877 } 878 879 /** 880 * Duplicate a Maps 881 * 882 * @param mo the maps to clone 883 * @return the allocated maps containing a copy of the mo maps 884 */ 885 static maps* dupMaps(maps** mo){ 886 maps* _cursor=*mo; 887 maps* res=NULL; 888 if(_cursor!=NULL){ 889 res=(maps*)malloc(MAPS_SIZE); 890 res->name=zStrdup(_cursor->name); 891 res->content=NULL; 892 res->next=NULL; 893 map* mc=_cursor->content; 894 if(mc!=NULL){ 895 addMapToMap(&res->content,mc); 896 loadMapBinaries(&res->content,mc); 897 } 898 res->next=dupMaps(&_cursor->next); 899 } 900 return res; 901 } 902 903 /** 904 * Add a maps at the end of another maps. 905 * 906 * @see addMapToMap, dupMaps, getMaps 907 * @param mo the maps to add mi 908 * @param mi the maps to add to mo 909 */ 910 static void addMapsToMaps(maps** mo,maps* mi){ 911 maps* tmp=mi; 912 maps* _cursor=*mo; 913 while(tmp!=NULL){ 914 if(_cursor==NULL){ 915 *mo=dupMaps(&mi); 916 } 917 else{ 918 while(_cursor->next!=NULL) 919 _cursor=_cursor->next; 920 maps* tmp1=getMaps(*mo,tmp->name); 921 if(tmp1==NULL) 922 _cursor->next=dupMaps(&tmp); 923 else 924 addMapToMap(&tmp1->content,tmp->content); 925 _cursor=*mo; 926 } 927 tmp=tmp->next; 928 } 929 } 930 931 /** 932 * Access a specific map array element 933 * 934 * @param m the map to search for the key 935 * @param key the key to search in the map 936 * @param index of the MapArray 937 * @return a pointer on the map found or NULL if not found 938 */ 939 static map* getMapArray(map* m,const char* key,int index){ 940 char tmp[1024]; 941 if(index>0) 942 sprintf(tmp,"%s_%d",key,index); 943 else 944 sprintf(tmp,"%s",key); 945 #ifdef DEBUG 946 fprintf(stderr,"** KEY %s\n",tmp); 947 #endif 948 map* tmpMap=getMap(m,tmp); 949 #ifdef DEBUG 950 if(tmpMap!=NULL) 951 dumpMap(tmpMap); 952 #endif 953 return tmpMap; 954 } 955 956 957 /** 958 * Add a key value in a MapArray for a specific index 959 * 960 * @param m the map to search for the key 961 * @param key the key to search in the map 962 * @param index the index of the MapArray 963 * @param value the value to set in the MapArray 964 * @return a pointer on the map found or NULL if not found 965 */ 966 static void setMapArray(map* m,const char* key,int index,const char* value){ 967 char tmp[1024]; 968 if(index>0){ 969 sprintf(tmp,"%s_%d",key,index); 970 map* len=getMap(m,"length"); 971 if((len!=NULL && atoi(len->value)<index+1) || len==NULL){ 972 char tmp0[5]; 973 sprintf(tmp0,"%d",index+1); 974 addToMap(m,"length",tmp0); 975 } 976 } 977 else 978 sprintf(tmp,"%s",key); 979 map* tmpSize=getMapArray(m,"size",index); 980 if(tmpSize!=NULL && strncasecmp(key,"value",5)==0){ 981 #ifdef DEBUG 982 fprintf(stderr,"%s\n",tmpSize->value); 983 #endif 984 map* ptr=getMapOrFill(&m,tmp,(char *)""); 985 free(ptr->value); 986 ptr->value=(char*)malloc((atoi(tmpSize->value)+1)*sizeof(char)); 987 memcpy(ptr->value,value,atoi(tmpSize->value)); 988 } 989 else 990 addToMap(m,tmp,value); 991 } 992 993 /** 994 * Access the map "type" 995 * 996 * @param mt the map 997 * @return a pointer on the map for mimeType/dataType/CRS if found, NULL in 998 * other case 999 */ 1000 static map* getMapType(map* mt){ 1001 map* tmap=getMap(mt,(char *)"mimeType"); 1002 if(tmap==NULL){ 1003 tmap=getMap(mt,"dataType"); 1004 if(tmap==NULL){ 1005 tmap=getMap(mt,"CRS"); 1006 } 1007 } 1008 #ifdef DEBUG 1009 dumpMap(tmap); 1010 #endif 1011 return tmap; 1012 } 1013 1014 /** 1015 * Add a Maps containing a MapArray to a Maps 1016 * 1017 * @see getMapType 1018 * @param mo the maps 1019 * @param mi the maps 1020 * @param typ the map "type" 1021 * @return 1022 */ 1023 static int addMapsArrayToMaps(maps** mo,maps* mi,char* typ){ 1024 maps* tmp=mi; 1025 maps* _cursor=getMaps(*mo,tmp->name); 1026 1027 if(_cursor==NULL) 1028 return -1; 1029 1030 map* tmpLength=getMap(_cursor->content,"length"); 1031 char tmpLen[10]; 1032 int len=1; 1033 if(tmpLength!=NULL){ 1034 len=atoi(tmpLength->value); 1035 } 1036 1037 char *tmpV[12]={ 1038 (char*)"size", 1039 (char*)"value", 1040 (char*)"uom", 1041 (char*)"Reference", 1042 (char*)"Order", 1043 (char*)"cache_file", 1044 (char*)"fmimeType", 1045 (char*)"xlink:href", 1046 typ, 1047 (char*)"schema", 1048 (char*)"encoding", 1049 (char*)"isCached" 1050 }; 1051 sprintf(tmpLen,"%d",len+1); 1052 addToMap(_cursor->content,"length",tmpLen); 1053 int i=0; 1054 for(i=0;i<12;i++){ 1055 map* tmpVI=getMap(tmp->content,tmpV[i]); 1056 if(tmpVI!=NULL){ 1057 #ifdef DEBUG 1058 fprintf(stderr,"%s = %s\n",tmpV[i],tmpVI->value); 1059 #endif 1060 setMapArray(_cursor->content,tmpV[i],len,tmpVI->value); 1061 } 1062 } 1063 1064 addToMap(_cursor->content,"isArray","true"); 1065 return 0; 1066 } 1067 1068 /** 1069 * Set a key value pair to a map contained in a Maps 1070 * 1071 * @param m the maps 1072 * @param key the maps name 1073 * @param subkey the map name included in the maps corresponding to key 1074 * @param value the corresponding value to add in the map 1075 */ 1076 static void setMapInMaps(maps* m,const char* key,const char* subkey,const char *value){ 1077 maps* _tmpm=getMaps(m,key); 1078 if(_tmpm!=NULL){ 1079 map* _ztmpm=getMap(_tmpm->content,subkey); 1080 if(_ztmpm!=NULL){ 1081 if(_ztmpm->value!=NULL) 1082 free(_ztmpm->value); 1083 _ztmpm->value=zStrdup(value); 1084 }else{ 1085 maps *tmp=(maps*)malloc(MAPS_SIZE); 1086 tmp->name=zStrdup(key); 1087 tmp->content=createMap(subkey,value); 1088 tmp->next=NULL; 1089 addMapsToMaps(&_tmpm,tmp); 1090 freeMaps(&tmp); 1091 free(tmp); 1092 } 1093 }else{ 1094 maps *tmp=(maps*)malloc(MAPS_SIZE); 1095 tmp->name=zStrdup(key); 1096 tmp->content=createMap(subkey,value); 1097 tmp->next=NULL; 1098 addMapsToMaps(&m,tmp); 1099 freeMaps(&tmp); 1100 free(tmp); 1101 } 1102 } 1103 1104 /** 1105 * Dump an elements on stderr 1106 * 1107 * @param e the elements to dump 1108 */ 1109 static void dumpElements(elements* e){ 1110 elements* tmp=e; 1111 while(tmp!=NULL){ 1112 fprintf(stderr,"ELEMENT [%s]\n",tmp->name); 1113 fprintf(stderr," > CONTENT [%s]\n",tmp->name); 1114 dumpMap(tmp->content); 1115 fprintf(stderr," > METADATA [%s]\n",tmp->name); 1116 dumpMap(tmp->metadata); 1117 fprintf(stderr," > FORMAT [%s]\n",tmp->format); 1118 iotype* tmpio=tmp->defaults; 1119 int ioc=0; 1120 while(tmpio!=NULL){ 1121 fprintf(stderr," > DEFAULTS [%s] (%i)\n",tmp->name,ioc); 1122 dumpMap(tmpio->content); 1123 tmpio=tmpio->next; 1124 ioc++; 1125 } 1126 tmpio=tmp->supported; 1127 ioc=0; 1128 while(tmpio!=NULL){ 1129 fprintf(stderr," > SUPPORTED [%s] (%i)\n",tmp->name,ioc); 1130 dumpMap(tmpio->content); 1131 tmpio=tmpio->next; 1132 ioc++; 1133 } 1134 fprintf(stderr,"------------------\n"); 1135 tmp=tmp->next; 1136 } 1137 } 1138 1139 /** 1140 * Dump an elements on stderr using the YAML syntaxe 1141 * 1142 * @param e the elements to dump 1143 */ 1144 static void dumpElementsAsYAML(elements* e){ 1145 elements* tmp=e; 1146 int i; 1147 while(tmp!=NULL){ 1148 for(i=0;i<2;i++) 1149 fprintf(stderr," "); 1150 fprintf(stderr,"%s:\n",tmp->name); 1151 map* mcurs=tmp->content; 1152 while(mcurs!=NULL){ 1153 for(i=0;i<4;i++) 1154 fprintf(stderr," "); 1155 _dumpMap(mcurs); 1156 mcurs=mcurs->next; 1157 } 1158 mcurs=tmp->metadata; 1159 if(mcurs!=NULL){ 1160 for(i=0;i<4;i++) 1161 fprintf(stderr," "); 1162 fprintf(stderr,"MetaData:\n"); 1163 while(mcurs!=NULL){ 1164 for(i=0;i<6;i++) 1165 fprintf(stderr," "); 1166 _dumpMap(mcurs); 1167 mcurs=mcurs->next; 1168 } 1169 } 1170 for(i=0;i<4;i++) 1171 fprintf(stderr," "); 1172 fprintf(stderr,"%s:\n",tmp->format); 1173 iotype* tmpio=tmp->defaults; 1174 int ioc=0; 1175 while(tmpio!=NULL){ 1176 for(i=0;i<6;i++) 1177 fprintf(stderr," "); 1178 fprintf(stderr,"default:\n"); 1179 mcurs=tmpio->content; 1180 while(mcurs!=NULL){ 1181 for(i=0;i<8;i++) 1182 fprintf(stderr," "); 1183 if(strcasecmp(mcurs->name,"range")==0){ 1184 fprintf(stderr,"range: \"%s\"\n",mcurs->value); 1185 }else 1186 _dumpMap(mcurs); 1187 mcurs=mcurs->next; 1188 } 1189 tmpio=tmpio->next; 1190 ioc++; 1191 } 1192 tmpio=tmp->supported; 1193 ioc=0; 1194 while(tmpio!=NULL){ 1195 for(i=0;i<6;i++) 1196 fprintf(stderr," "); 1197 fprintf(stderr,"supported:\n"); 1198 mcurs=tmpio->content; 1199 while(mcurs!=NULL){ 1200 for(i=0;i<8;i++) 1201 fprintf(stderr," "); 1202 if(strcasecmp(mcurs->name,"range")==0){ 1203 fprintf(stderr,"range: \"%s\"\n",mcurs->value); 1204 }else 1205 _dumpMap(mcurs); 1206 mcurs=mcurs->next; 1207 } 1208 tmpio=tmpio->next; 1209 ioc++; 1210 } 1211 tmp=tmp->next; 1212 } 1213 } 1214 1215 /** 1216 * Duplicate an elements 1217 * 1218 * @param e the elements to clone 1219 * @return the allocated elements containing a copy of the elements e 1220 */ 1221 static elements* dupElements(elements* e){ 1222 elements* cursor=e; 1223 elements* tmp=NULL; 1224 if(cursor!=NULL){ 1225 #ifdef DEBUG 1226 fprintf(stderr,">> %s %i\n",__FILE__,__LINE__); 1227 dumpElements(e); 1228 fprintf(stderr,">> %s %i\n",__FILE__,__LINE__); 1229 #endif 1230 tmp=(elements*)malloc(ELEMENTS_SIZE); 1231 tmp->name=zStrdup(e->name); 1232 tmp->content=NULL; 1233 addMapToMap(&tmp->content,e->content); 1234 tmp->metadata=NULL; 1235 addMapToMap(&tmp->metadata,e->metadata); 1236 if(e->format!=NULL) 1237 tmp->format=zStrdup(e->format); 1238 else 1239 tmp->format=NULL; 1240 if(e->defaults!=NULL){ 1241 tmp->defaults=(iotype*)malloc(IOTYPE_SIZE); 1242 tmp->defaults->content=NULL; 1243 addMapToMap(&tmp->defaults->content,e->defaults->content); 1244 tmp->defaults->next=NULL; 1245 #ifdef DEBUG 1246 fprintf(stderr,">> %s %i\n",__FILE__,__LINE__); 1247 dumpMap(tmp->defaults->content); 1248 #endif 1249 }else 1250 tmp->defaults=NULL; 1251 if(e->supported!=NULL){ 1252 tmp->supported=(iotype*)malloc(IOTYPE_SIZE); 1253 tmp->supported->content=NULL; 1254 addMapToMap(&tmp->supported->content,e->supported->content); 1255 tmp->supported->next=NULL; 1256 iotype *tmp2=e->supported->next; 1257 while(tmp2!=NULL){ 1258 addMapToIoType(&tmp->supported,tmp2->content); 1259 #ifdef DEBUG 1260 fprintf(stderr,">> %s %i\n",__FILE__,__LINE__); 1261 dumpMap(tmp->defaults->content); 1262 #endif 1263 tmp2=tmp2->next; 1264 } 1265 } 1266 else 1267 tmp->supported=NULL; 1268 tmp->next=dupElements(cursor->next); 1269 } 1270 return tmp; 1271 } 1272 1273 /** 1274 * Add an elements to another elements. 1275 * 1276 * @see dupElements 1277 * @param m the elements to add the e 1278 * @param e the elements to be added to m 1279 */ 1280 static void addToElements(elements** m,elements* e){ 1281 elements* tmp=e; 1282 if(*m==NULL){ 1283 *m=dupElements(tmp); 1284 }else{ 1285 addToElements(&(*m)->next,tmp); 1286 } 1287 } 1288 1289 /** 1290 * Dump a service on stderr 1291 * 1292 * @param s the service to dump 1293 */ 1294 static void dumpService(service* s){ 1295 if(s==NULL) 1296 return; 1297 fprintf(stderr,"++++++++++++++++++\nSERVICE [%s]\n++++++++++++++++++\n",s->name); 1298 if(s->content!=NULL){ 1299 fprintf(stderr,"CONTENT MAP\n"); 1300 dumpMap(s->content); 1301 fprintf(stderr,"CONTENT METADATA\n"); 1302 dumpMap(s->metadata); 1303 } 1304 if(s->inputs!=NULL){ 1305 fprintf(stderr,"INPUT ELEMENTS [%s]\n------------------\n",s->name); 1306 dumpElements(s->inputs); 1307 } 1308 if(s->outputs!=NULL){ 1309 fprintf(stderr,"OUTPUT ELEMENTS [%s]\n------------------\n",s->name); 1310 dumpElements(s->outputs); 1311 } 1312 fprintf(stderr,"++++++++++++++++++\n"); 1313 } 1314 1315 /** 1316 * Dump a service on stderr using the YAML syntaxe 1317 * 1318 * @param s the service to dump 1319 */ 1320 static void dumpServiceAsYAML(service* s){ 1321 int i; 1322 fprintf(stderr,"# %s\n\n",s->name); 1323 if(s->content!=NULL){ 1324 map* mcurs=s->content; 1325 dumpMap(mcurs); 1326 mcurs=s->metadata; 1327 if(mcurs!=NULL){ 1328 fprintf(stderr,"MetaData:\n"); 1329 while(mcurs!=NULL){ 1330 for(i=0;i<2;i++) 1331 fprintf(stderr," "); 1332 _dumpMap(mcurs); 1333 mcurs=mcurs->next; 1334 } 1335 } 1336 } 1337 if(s->inputs!=NULL){ 1338 fprintf(stderr,"\ninputs:\n"); 1339 dumpElementsAsYAML(s->inputs); 1340 } 1341 if(s->outputs!=NULL){ 1342 fprintf(stderr,"\noutputs:\n"); 1343 dumpElementsAsYAML(s->outputs); 1344 } 1345 } 1346 1347 /** 1348 * Duplicate a service 1349 * 1350 * @param s the service to clone 1351 * @return the allocated service containing a copy of the serfvice s 1352 */ 1353 static service* dupService(service* s){ 1354 service *res=(service*)malloc(SERVICE_SIZE); 1355 res->name=zStrdup(s->name); 1356 res->content=NULL; 1357 addMapToMap(&res->content,s->content); 1358 res->metadata=NULL; 1359 addMapToMap(&res->metadata,s->metadata); 1360 res->inputs=dupElements(s->inputs); 1361 res->outputs=dupElements(s->outputs); 1362 return res; 1363 } 1364 1365 /** 1366 * Print the registry on stderr. 1367 * 1368 * @param r the registry 1369 */ 1370 static void dumpRegistry(registry* r){ 1371 registry* p=r; 1372 while(p!=NULL){ 1373 fprintf(stderr,"%s \n",p->name); 1374 services* s=p->content; 1375 s=p->content; 1376 while(s!=NULL){ 1377 dumpService(s->content); 1378 s=s->next; 1379 } 1380 p=p->next; 1381 } 1382 } 1383 1384 /** 1385 * Add a service to the registry 1386 * 1387 * @param reg the resgitry to add the service 1388 * @param name the registry name to update 1389 * @param content the service to add 1390 */ 1391 static bool addServiceToRegistry(registry** reg,char* name,service* content){ 1392 registry *l=*reg; 1393 int isInitial=-1; 1394 if(l==NULL){ 1395 l=(registry*)malloc(REGISTRY_SIZE); 1396 isInitial=1; 1397 } 1398 if(l!=NULL){ 1399 int hasLevel=-1; 1400 while(isInitial<0 && l!=NULL){ 1401 if(l->name!=NULL && strcasecmp(name,l->name)==0){ 1402 hasLevel=1; 1403 break; 1404 } 1405 l=l->next; 1406 } 1407 if(hasLevel<0){ 1408 if(isInitial<0) 1409 l=(registry*)malloc(REGISTRY_SIZE); 1410 l->name=zStrdup(name); 1411 l->content=NULL; 1412 l->next=NULL; 1413 } 1414 if(l->content==NULL){ 1415 l->content=(services*)malloc(SERVICES_SIZE); 1416 l->content->content=dupService(content); 1417 l->content->next=NULL; 1418 } 1419 else{ 1420 services* s=l->content; 1421 while(s->next!=NULL) 1422 s=s->next; 1423 s->next=(services*)malloc(SERVICES_SIZE); 1424 s->next->content=dupService(content); 1425 s->next->next=NULL; 1426 } 1427 l->next=NULL; 1428 if(isInitial>0) 1429 *reg=l; 1430 else{ 1431 registry *r=*reg; 1432 while(r->next!=NULL) 1433 r=r->next; 1434 r->next=l; 1435 r->next->next=NULL; 1436 } 1437 return true; 1438 } 1439 else 1440 return false; 1441 } 1442 1443 /** 1444 * Free memory allocated for the registry 1445 * 1446 * @param r the registry 1447 */ 1448 static void freeRegistry(registry** r){ 1449 registry* lr=*r; 1450 while(lr!=NULL){ 1451 services* s=lr->content; 1452 free(lr->name); 1453 while(s!=NULL){ 1454 service* s1=s->content; 1455 s=s->next; 1456 if(s1!=NULL){ 1457 freeService(&s1); 1458 free(s1); 1459 s1=NULL; 1460 } 1461 } 1462 lr=lr->next; 1463 } 1464 } 1465 1466 /** 1467 * Access a service in the registry 1468 * 1469 * @param r the registry 1470 * @param level the regitry to search ("concept", "generic" or "implementation") 1471 * @param sname the service name 1472 * @return the service pointer if a corresponding service was found or NULL 1473 */ 1474 static service* getServiceFromRegistry(registry* r,char *level,char* sname){ 1475 registry *lr=r; 1476 while(lr!=NULL){ 1477 if(strcasecmp(lr->name,level)==0){ 1478 services* s=lr->content; 1479 while(s!=NULL){ 1480 if(s->content!=NULL && strcasecmp(s->content->name,sname)==0) 1481 return s->content; 1482 s=s->next; 1483 } 1484 break; 1485 } 1486 lr=lr->next; 1487 } 1488 return NULL; 1489 } 1490 1491 /** 1492 * Apply inheritance to an out map from a reference in map 1493 * 1494 * @param out the map to update 1495 * @param in the reference map (containing inherited properties) 1496 */ 1497 static void inheritMap(map** out,map* in){ 1498 map* content=in; 1499 while(content!=NULL && *out!=NULL){ 1500 map* cmap=getMap(*out,content->name); 1501 if(cmap==NULL) 1502 addToMap(*out,content->name,content->value); 1503 content=content->next; 1504 } 1505 } 1506 1507 /** 1508 * Apply inheritance to an out iotype from a reference in iotype 1509 * 1510 * @param out the iotype to update 1511 * @param in the reference iotype (containing inherited properties) 1512 */ 1513 static void inheritIOType(iotype** out,iotype* in){ 1514 iotype* io=in; 1515 iotype* oio=*out; 1516 if(io!=NULL){ 1517 if(*out==NULL){ 1518 *out=(iotype*)malloc(IOTYPE_SIZE); 1519 (*out)->content=NULL; 1520 addMapToMap(&(*out)->content,io->content); 1521 (*out)->next=NULL; 1522 oio=*out; 1523 inheritIOType(&oio->next,io->next); 1524 }else{ 1525 inheritIOType(&oio->next,io->next); 1526 } 1527 } 1528 } 1529 1530 /** 1531 * Apply inheritance to an out elements from a reference in elements 1532 * 1533 * @param out the elements to update 1534 * @param in the reference elements (containing inherited properties) 1535 */ 1536 static void inheritElements(elements** out,elements* in){ 1537 elements* content=in; 1538 while(content!=NULL && *out!=NULL){ 1539 elements* cmap=getElements(*out,content->name); 1540 if(cmap==NULL) 1541 addToElements(out,content); 1542 else{ 1543 inheritMap(&cmap->content,content->content); 1544 inheritMap(&cmap->metadata,content->metadata); 1545 if(cmap->format==NULL && content->format!=NULL) 1546 cmap->format=zStrdup(content->format); 1547 inheritIOType(&cmap->defaults,content->defaults); 1548 if(cmap->supported==NULL) 1549 inheritIOType(&cmap->supported,content->supported); 1550 else{ 1551 iotype* p=content->supported; 1552 while(p!=NULL){ 1553 addMapToIoType(&cmap->supported,p->content); 1554 p=p->next; 1555 } 1556 } 1557 } 1558 content=content->next; 1559 } 1560 } 1561 1562 /** 1563 * Apply inheritance to a service based on a registry 1564 * 1565 * @param r the registry storing profiles hierarchy 1566 * @param s the service to update depending on its inheritance 1567 */ 1568 static void inheritance(registry *r,service** s){ 1569 if(r==NULL) 1570 return; 1571 service* ls=*s; 1572 if(ls->content==NULL) 1573 return; 1574 map* profile=getMap(ls->content,"extend"); 1575 map* level=getMap(ls->content,"level"); 1576 if(profile!=NULL&&level!=NULL){ 1577 service* s1; 1578 if(strncasecmp(level->value,"profile",7)==0) 1579 s1=getServiceFromRegistry(r,"generic",profile->value); 1580 else 1581 s1=getServiceFromRegistry(r,level->value,profile->value); 1582 1583 inheritMap(&ls->content,s1->content); 1584 inheritMap(&ls->metadata,s1->metadata); 1585 if(ls->inputs==NULL && s1->inputs!=NULL){ 1586 ls->inputs=dupElements(s1->inputs); 1587 }else{ 1588 inheritElements(&ls->inputs,s1->inputs); 1589 } 1590 if(ls->outputs==NULL && s1->outputs!=NULL){ 1591 ls->outputs=dupElements(s1->outputs); 1592 }else 1593 inheritElements(&ls->outputs,s1->outputs); 1594 } 1595 } 1596 1597 /** 1598 * Convert a maps to a char*** (only used for Fortran support) 1599 * 1600 * @param m the maps to convert 1601 * @param c the resulting array 1602 */ 1603 static void mapsToCharXXX(maps* m,char*** c){ 1604 maps* tm=m; 1605 int i=0; 1606 int j=0; 1607 char tmp[10][30][1024]; 1608 memset(tmp,0,1024*10*10); 1609 while(tm!=NULL){ 1610 if(i>=10) 1611 break; 1612 strcpy(tmp[i][j],"name"); 1613 j++; 1614 strcpy(tmp[i][j],tm->name); 1615 j++; 1616 map* tc=tm->content; 1617 while(tc!=NULL){ 1618 if(j>=30) 1619 break; 1620 strcpy(tmp[i][j],tc->name); 1621 j++; 1622 strcpy(tmp[i][j],tc->value); 1623 j++; 1624 tc=tc->next; 1625 } 1626 tm=tm->next; 1627 j=0; 1628 i++; 1629 } 1630 memcpy(c,tmp,10*10*1024); 1631 } 1632 1633 /** 1634 * Convert a char*** to a maps (only used for Fortran support) 1635 * 1636 * @param c the array to convert 1637 * @param m the resulting maps 1638 */ 1639 static void charxxxToMaps(char*** c,maps**m){ 1640 maps* trorf=*m; 1641 int i,j; 1642 char tmp[10][30][1024]; 1643 memcpy(tmp,c,10*30*1024); 1644 for(i=0;i<10;i++){ 1645 if(strlen(tmp[i][1])==0) 1646 break; 1647 trorf->name=tmp[i][1]; 1648 trorf->content=NULL; 1649 trorf->next=NULL; 1650 for(j=2;j<29;j+=2){ 1651 if(strlen(tmp[i][j+1])==0) 1652 break; 1653 if(trorf->content==NULL) 1654 trorf->content=createMap(tmp[i][j],tmp[i][j+1]); 1655 else 1656 addToMap(trorf->content,tmp[i][j],tmp[i][j+1]); 1657 } 1658 trorf=trorf->next; 1659 } 1660 m=&trorf; 1661 } 1662 279 280 bool hasElement(elements*,const char*); 281 elements* getElements(elements*,char*); 282 void freeIOType(iotype**); 283 void freeElements(elements**); 284 void freeService(service**); 285 void addToMap(map*,const char*,const char*); 286 void addIntToMap(map*,const char*,const int); 287 void addToMapWithSize(map*,const char*,const char*,int); 288 void addMapToMap(map**,map*); 289 void addMapToIoType(iotype**,map*); 290 map* getMapOrFill(map**,const char*,const char*); 291 bool contains(map*,map*); 292 iotype* getIoTypeFromElement(elements*,char*, map*); 293 void loadMapBinary(map**,map*,int); 294 void loadMapBinaries(map**,map*); 295 maps* dupMaps(maps**); 296 void addMapsToMaps(maps**,maps*); 297 map* getMapArray(map*,const char*,int); 298 void setMapArray(map*,const char*,int,const char*); 299 map* getMapType(map*); 300 int addMapsArrayToMaps(maps**,maps*,char*); 301 void setMapInMaps(maps*,const char*,const char*,const char*); 302 void dumpElements(elements*); 303 void dumpElementsAsYAML(elements*); 304 elements* dupElements(elements*); 305 void addToElements(elements**,elements*); 306 void dumpService(service*); 307 void dumpServiceAsYAML(service*); 308 service* dupService(service*); 309 void dumpRegistry(registry*); 310 bool addServiceToRegistry(registry**,char*,service*); 311 void freeRegistry(registry**); 312 service* getServiceFromRegistry(registry*,char*,char*); 313 void inheritMap(map**,map*); 314 void inheritIOType(iotype**,iotype*); 315 void inheritElements(elements**,elements*); 316 void inheritance(registry*,service**); 317 void mapsToCharXXX(maps*,char***); 318 void charxxxToMaps(char***,maps**); 1663 319 #ifdef WIN32 1664 320 extern char *url_encode(char *); 1665 1666 static char* getMapsAsKVP(maps* m,int length,int type){ 1667 char *dataInputsKVP=(char*) malloc(length*sizeof(char)); 1668 char *dataInputsKVPi=NULL; 1669 maps* curs=m; 1670 int i=0; 1671 while(curs!=NULL){ 1672 map *inRequest=getMap(curs->content,"inRequest"); 1673 map *hasLength=getMap(curs->content,"length"); 1674 if((inRequest!=NULL && strncasecmp(inRequest->value,"true",4)==0) || 1675 inRequest==NULL){ 1676 if(i==0) 1677 if(type==0){ 1678 sprintf(dataInputsKVP,"%s=",curs->name); 1679 if(hasLength!=NULL){ 1680 dataInputsKVPi=(char*)malloc((strlen(curs->name)+2)*sizeof(char)); 1681 sprintf(dataInputsKVPi,"%s=",curs->name); 1682 } 1683 } 1684 else 1685 sprintf(dataInputsKVP,"%s",curs->name); 1686 else{ 1687 char *temp=zStrdup(dataInputsKVP); 1688 if(type==0) 1689 sprintf(dataInputsKVP,"%s;%s=",temp,curs->name); 1690 else 1691 sprintf(dataInputsKVP,"%s;%s",temp,curs->name); 1692 } 1693 map* icurs=curs->content; 1694 if(type==0){ 1695 char *temp=zStrdup(dataInputsKVP); 1696 if(getMap(curs->content,"xlink:href")!=NULL) 1697 sprintf(dataInputsKVP,"%sReference",temp); 1698 else{ 1699 if(hasLength!=NULL){ 1700 int j; 1701 for(j=0;j<atoi(hasLength->value);j++){ 1702 map* tmp0=getMapArray(curs->content,"value",j); 1703 if(j==0) 1704 free(temp); 1705 temp=zStrdup(dataInputsKVP); 1706 if(j==0) 1707 sprintf(dataInputsKVP,"%s%s",temp,tmp0->value); 1708 else 1709 sprintf(dataInputsKVP,"%s;%s%s",temp,dataInputsKVPi,tmp0->value); 1710 } 1711 } 1712 else 1713 sprintf(dataInputsKVP,"%s%s",temp,icurs->value); 1714 } 1715 free(temp); 1716 } 1717 while(icurs!=NULL){ 1718 if(strncasecmp(icurs->name,"value",5)!=0 && 1719 strncasecmp(icurs->name,"mimeType_",9)!=0 && 1720 strncasecmp(icurs->name,"dataType_",9)!=0 && 1721 strncasecmp(icurs->name,"size",4)!=0 && 1722 strncasecmp(icurs->name,"length",4)!=0 && 1723 strncasecmp(icurs->name,"isArray",7)!=0 && 1724 strcasecmp(icurs->name,"Reference")!=0 && 1725 strcasecmp(icurs->name,"minOccurs")!=0 && 1726 strcasecmp(icurs->name,"maxOccurs")!=0 && 1727 strncasecmp(icurs->name,"fmimeType",9)!=0 && 1728 strcasecmp(icurs->name,"inRequest")!=0){ 1729 char *itemp=zStrdup(dataInputsKVP); 1730 if(strcasecmp(icurs->name,"xlink:href")!=0) 1731 sprintf(dataInputsKVP,"%s@%s=%s",itemp,icurs->name,icurs->value); 1732 else 1733 sprintf(dataInputsKVP,"%s@%s=%s",itemp,icurs->name,url_encode(icurs->value)); 1734 free(itemp); 1735 } 1736 icurs=icurs->next; 1737 } 1738 } 1739 curs=curs->next; 1740 i++; 1741 } 1742 return dataInputsKVP; 1743 } 321 char* getMapsAsKVP(maps*,int,int); 1744 322 #endif 1745 323
Note: See TracChangeset
for help on using the changeset viewer.