Changeset 877 for branches/prototype-v0/zoo-project/zoo-kernel/service.c
- Timestamp:
- Aug 16, 2018, 8:00:56 AM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/prototype-v0/zoo-project/zoo-kernel/service.c
r873 r877 539 539 */ 540 540 map* addToMapWithSize(map* m,const char* n,const char* v,int size){ 541 char sin[128]; 542 char sname[10]="size"; 543 map *tmp; 541 544 if(hasKey(m,n)==false){ 542 545 map* _cursor=m; … … 547 550 } 548 551 } 549 char sname[10]="size";550 552 if(strlen(n)>5) 551 553 sprintf(sname,"size_%s",n+6); 552 map *tmp=getMap(m,n);554 tmp=getMap(m,n); 553 555 if(tmp->value!=NULL) 554 556 free(tmp->value); … … 557 559 memmove(tmp->value,v,size*sizeof(char)); 558 560 tmp->value[size]=0; 559 char sin[128];560 561 sprintf(sin,"%d",size); 561 562 addToMap(m,sname,sin); … … 578 579 } 579 580 else{ 580 #ifdef DEBUG581 fprintf(stderr,"_CURSOR\n");582 dumpMap(_cursor);583 #endif584 while(_cursor->next!=NULL)585 _cursor=_cursor->next;586 581 map* tmp1=getMap(*mo,tmp->name); 587 582 if(tmp1==NULL){ 583 while(_cursor->next!=NULL) 584 _cursor=_cursor->next; 588 585 _cursor->next=createMap(tmp->name,tmp->value); 589 586 } … … 594 591 _cursor=*mo; 595 592 tmp=tmp->next; 596 #ifdef DEBUG597 fprintf(stderr,"MO\n");598 dumpMap(*mo);599 #endif600 593 } 601 594 } … … 711 704 map* size=getMap(in,"size"); 712 705 map *lout=*out; 706 map *tmpVin,*tmpVout; 713 707 if(size!=NULL && pos>0){ 714 708 char tmp[11]; … … 716 710 size=getMap(in,tmp); 717 711 sprintf(tmp,"value_%d",pos); 718 map*tmpVin=getMap(in,tmp);719 map*tmpVout=getMap(lout,tmp);712 tmpVin=getMap(in,tmp); 713 tmpVout=getMap(lout,tmp); 720 714 free(tmpVout->value); 721 715 tmpVout->value=(char*)malloc((atoi(size->value)+1)*sizeof(char)); … … 724 718 }else{ 725 719 if(size!=NULL){ 726 map*tmpVin=getMap(in,"value");727 map*tmpVout=getMap(lout,"value");720 tmpVin=getMap(in,"value"); 721 tmpVout=getMap(lout,"value"); 728 722 free(tmpVout->value); 729 723 tmpVout->value=(char*)malloc((atoi(size->value)+1)*sizeof(char)); … … 745 739 map* size=getMap(in,"size"); 746 740 map* length=getMap(in,"length"); 741 map* toload=getMap(in,"to_load"); 742 if(toload!=NULL && strcasecmp(toload->value,"false")==0){ 743 fprintf(stderr,"NO LOAD %s %d \n",__FILE__,__LINE__); 744 return ; 745 } 747 746 if(length!=NULL){ 748 747 int len=atoi(length->value); … … 767 766 maps* res=NULL; 768 767 if(_cursor!=NULL){ 768 map* mc=_cursor->content; 769 maps* mcs=_cursor->child; 769 770 res=createMaps(_cursor->name); 770 map* mc=_cursor->content;771 771 if(mc!=NULL){ 772 772 addMapToMap(&res->content,mc); 773 773 loadMapBinaries(&res->content,mc); 774 774 } 775 maps* mcs=_cursor->child;776 775 if(mcs!=NULL){ 777 776 res->child=dupMaps(&mcs); … … 797 796 } 798 797 else{ 798 maps* tmp1=getMaps(*mo,tmp->name); 799 799 while(_cursor->next!=NULL) 800 800 _cursor=_cursor->next; 801 maps* tmp1=getMaps(*mo,tmp->name);802 801 if(tmp1==NULL){ 803 802 _cursor->next=dupMaps(&tmp); … … 830 829 map* getMapArray(map* m,const char* key,int index){ 831 830 char tmp[1024]; 831 map* tmpMap; 832 832 if(index>0) 833 833 sprintf(tmp,"%s_%d",key,index); … … 837 837 fprintf(stderr,"** KEY %s\n",tmp); 838 838 #endif 839 map*tmpMap=getMap(m,tmp);839 tmpMap=getMap(m,tmp); 840 840 #ifdef DEBUG 841 841 if(tmpMap!=NULL) … … 856 856 void setMapArray(map* m,const char* key,int index,const char* value){ 857 857 char tmp[1024]; 858 map* tmpSize; 858 859 if(index>0){ 860 map* len=getMap(m,"length"); 859 861 sprintf(tmp,"%s_%d",key,index); 860 map* len=getMap(m,"length");861 862 if((len!=NULL && atoi(len->value)<index+1) || len==NULL){ 862 863 char tmp0[5]; … … 869 870 addToMap(m,"length","1"); 870 871 } 871 map*tmpSize=getMapArray(m,"size",index);872 tmpSize=getMapArray(m,"size",index); 872 873 if(tmpSize!=NULL && strncasecmp(key,"value",5)==0){ 874 map* ptr=getMapOrFill(&m,tmp,(char *)""); 873 875 #ifdef DEBUG 874 876 fprintf(stderr,"%s\n",tmpSize->value); 875 877 #endif 876 map* ptr=getMapOrFill(&m,tmp,(char *)"");877 878 free(ptr->value); 878 879 ptr->value=(char*)malloc((atoi(tmpSize->value)+1)*sizeof(char)); … … 930 931 maps* tmp=mi; 931 932 maps* _cursor=getMaps(*mo,tmp->name); 932 933 if(_cursor==NULL)934 return -1;935 936 map* tmpLength=getMap(_cursor->content,"length");937 933 char tmpLen[10]; 938 934 int len=1; 939 if(tmpLength!=NULL){940 len=atoi(tmpLength->value);941 }942 943 935 char *tmpV[14]={ 944 936 (char*)"size", … … 957 949 (char*)"UpperCorner" 958 950 }; 951 int i=0; 952 map* tmpLength; 953 954 if(_cursor==NULL) 955 return -1; 956 957 tmpLength=getMap(_cursor->content,"length"); 958 if(tmpLength!=NULL){ 959 len=atoi(tmpLength->value); 960 } 961 959 962 sprintf(tmpLen,"%d",len+1); 960 963 addToMap(_cursor->content,"length",tmpLen); 961 int i=0;962 964 for(i=0;i<14;i++){ 963 965 map* tmpVI=getMap(tmp->content,tmpV[i]); … … 1071 1073 elements* tmp=e; 1072 1074 while(tmp!=NULL){ 1075 iotype* tmpio=tmp->defaults; 1076 int ioc=0; 1073 1077 fprintf(stderr,"ELEMENT [%s]\n",tmp->name); 1074 1078 fprintf(stderr," > CONTENT [%s]\n",tmp->name); … … 1079 1083 dumpMap(tmp->additional_parameters); 1080 1084 fprintf(stderr," > FORMAT [%s]\n",tmp->format); 1081 iotype* tmpio=tmp->defaults;1082 int ioc=0;1083 1085 while(tmpio!=NULL){ 1084 1086 fprintf(stderr," > DEFAULTS [%s] (%i)\n",tmp->name,ioc); … … 1113 1115 int i; 1114 1116 while(tmp!=NULL){ 1117 map* mcurs=tmp->content; 1118 int ioc=0; 1119 iotype* tmpio; 1115 1120 for(i=0;i<2+(4*level);i++) 1116 1121 fprintf(stderr," "); 1117 1122 fprintf(stderr,"%s:\n",tmp->name); 1118 map* mcurs=tmp->content;1119 1123 while(mcurs!=NULL){ 1120 1124 for(i=0;i<4+(4*level);i++) … … 1144 1148 dumpElementsAsYAML(tmp->child,level+1); 1145 1149 } 1146 iotype* tmpio=tmp->defaults; 1147 int ioc=0; 1150 tmpio=tmp->defaults; 1148 1151 while(tmpio!=NULL){ 1149 1152 for(i=0;i<6+(4*level);i++) … … 1225 1228 tmp->defaults=NULL; 1226 1229 if(cursor->supported!=NULL && cursor->supported->content!=NULL){ 1230 iotype *tmp2=cursor->supported->next; 1227 1231 tmp->supported=(iotype*)malloc(IOTYPE_SIZE); 1228 1232 tmp->supported->content=NULL; 1229 1233 addMapToMap(&tmp->supported->content,cursor->supported->content); 1230 1234 tmp->supported->next=NULL; 1231 iotype *tmp2=cursor->supported->next; 1232 while(tmp2!=NULL){ 1235 while(tmp2!=NULL){ 1233 1236 addMapToIoType(&tmp->supported,tmp2->content); 1234 1237 #ifdef DEBUG … … 1373 1376 registry* p=r; 1374 1377 while(p!=NULL){ 1378 services* s=p->content; 1375 1379 fprintf(stderr,"%s \n",p->name); 1376 services* s=p->content;1377 1380 s=p->content; 1378 1381 while(s!=NULL){ … … 1573 1576 */ 1574 1577 void inheritance(registry *r,service** s){ 1578 service* ls=*s; 1579 map *profile,*level; 1575 1580 if(r==NULL) 1576 1581 return; 1577 service* ls=*s; 1578 if(ls->content==NULL) 1582 if(ls==NULL || ls->content==NULL) 1579 1583 return; 1580 map*profile=getMap(ls->content,"extend");1581 map*level=getMap(ls->content,"level");1584 profile=getMap(ls->content,"extend"); 1585 level=getMap(ls->content,"level"); 1582 1586 if(profile!=NULL&&level!=NULL){ 1583 1587 service* s1; … … 1614 1618 memset(tmp,0,1024*10*10); 1615 1619 while(tm!=NULL){ 1620 map* tc=tm->content; 1616 1621 if(i>=10) 1617 1622 break; … … 1620 1625 strcpy(tmp[i][j],tm->name); 1621 1626 j++; 1622 map* tc=tm->content;1623 1627 while(tc!=NULL){ 1624 1628 if(j>=30)
Note: See TracChangeset
for help on using the changeset viewer.