Changeset 360 for trunk/zoo-project/zoo-kernel/service.h
- Timestamp:
- Jun 7, 2012, 10:54:31 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/zoo-project/zoo-kernel/service.h
r348 r360 2 2 * Author : Gérald FENOY 3 3 * 4 * Copyright (c) 2009-201 0GeoLabs SARL4 * Copyright (c) 2009-2012 GeoLabs SARL 5 5 * 6 6 * Permission is hereby granted, free of charge, to any person obtaining a copy … … 596 596 } 597 597 598 static map* getMapArray(map* m,char* key,int index){ 599 char tmp[1024]; 600 if(index>0) 601 sprintf(tmp,"%s_%d",key,index); 602 else 603 sprintf(tmp,key); 604 #ifdef DEBUG 605 fprintf(stderr,"** KEY %s\n",tmp); 606 #endif 607 map* tmpMap=getMap(m,tmp); 608 #ifdef DEBUG 609 if(tmpMap!=NULL) 610 dumpMap(tmpMap); 611 #endif 612 return tmpMap; 613 } 614 615 616 static void setMapArray(map* m,char* key,int index,char* value){ 617 char tmp[1024]; 618 if(index>0) 619 sprintf(tmp,"%s_%d",key,index); 620 else 621 sprintf(tmp,key); 622 map* tmpSize=getMapArray(m,"size",index); 623 if(tmpSize!=NULL && strncasecmp(key,"value",5)==0){ 624 fprintf(stderr,"%s\n",tmpSize->value); 625 map* ptr=getMapOrFill(m,tmp,""); 626 free(ptr->value); 627 ptr->value=(char*)malloc((atoi(tmpSize->value)+1)*sizeof(char)); 628 memcpy(ptr->value,value,atoi(tmpSize->value)); 629 } 630 else 631 addToMap(m,tmp,value); 632 } 633 634 static map* getMapType(map* mt){ 635 map* tmap=getMap(mt,"mimeType"); 636 if(tmap==NULL){ 637 tmap=getMap(mt,"dataType"); 638 if(tmap==NULL){ 639 tmap=getMap(mt,"CRS"); 640 } 641 } 642 dumpMap(tmap); 643 return tmap; 644 } 645 646 static int addMapsArrayToMaps(maps** mo,maps* mi,char* typ){ 647 maps* tmp=mi; 648 maps* _cursor=*mo; 649 maps* tmpMaps=getMaps(_cursor,tmp->name); 650 651 if(tmpMaps==NULL) 652 return -1; 653 654 map* tmpLength=getMap(tmpMaps->content,"length"); 655 char tmpLen[10]; 656 int len=1; 657 if(tmpLength!=NULL){ 658 len=atoi(tmpLength->value); 659 } 660 661 map* tmpValI=getMap(tmp->content,"value"); 662 char *tmpV[8]={ 663 "size", 664 "value", 665 "uom", 666 "Reference", 667 "xlink:href", 668 typ, 669 "schema", 670 "encoding" 671 }; 672 sprintf(tmpLen,"%d",len+1); 673 addToMap(_cursor->content,"length",tmpLen); 674 int i=0; 675 map* tmpSizeI=getMap(tmp->content,tmpV[i]); 676 for(0;i<8;i++){ 677 map* tmpVI=getMap(tmp->content,tmpV[i]); 678 if(tmpVI!=NULL){ 679 fprintf(stderr,"%s = %s\n",tmpV[i],tmpVI->value); 680 if(i<5) 681 setMapArray(_cursor->content,tmpV[i],len,tmpVI->value); 682 else 683 if(strncasecmp(tmpV[5],"mimeType",8)==0) 684 setMapArray(_cursor->content,tmpV[i],len,tmpVI->value); 685 } 686 } 687 688 addToMap(_cursor->content,"isArray","true"); 689 return 0; 690 } 598 691 599 692 static void setMapInMaps(maps* m,const char* key,const char* subkey,const char *value){
Note: See TracChangeset
for help on using the changeset viewer.