Changeset 790 for trunk/zoo-project/zoo-kernel/service_conf.y
- Timestamp:
- Dec 19, 2016, 6:01:06 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/zoo-project/zoo-kernel/service_conf.y
r788 r790 34 34 static bool wait_mainmetadata=false; 35 35 static bool wait_metadata=false; 36 static bool wait_nested=false; 36 37 static bool wait_inputs=false; 37 38 static bool wait_defaults=false; … … 47 48 static int previous_data=0; 48 49 static int current_data=0; 50 static int nested_level=0; 49 51 // namespace 50 52 using namespace std; … … 145 147 dumpMap(current_content); 146 148 #endif 147 if(my_service->content==NULL ){149 if(my_service->content==NULL && current_content!=NULL){ 148 150 #ifdef DEBUG_SERVICE_CONF 149 151 fprintf(stderr,"NO CONTENT\n"); … … 156 158 wait_maincontent=false; 157 159 } 160 if(strncasecmp($2,"EndNested",9)==0){ 161 #ifdef DEBUG_SERVICE_CONF 162 fprintf(stderr,"(ENDNESTED - %d) \n",__LINE__); 163 fflush(stderr); 164 #endif 165 nested_level-=1; 166 if(nested_level==0){ 167 wait_nested=false; 168 } 169 } 170 158 171 if(strncasecmp($2,"DataInputs",10)==0){ 159 172 if(current_element==NULL){ … … 167 180 #endif 168 181 current_element=NULL; 169 current_element=(elements*)malloc(ELEMENTS_SIZE); 170 current_element->name=NULL; 171 current_element->content=NULL; 172 current_element->metadata=NULL; 173 current_element->format=NULL; 174 current_element->defaults=NULL; 175 current_element->supported=NULL; 176 current_element->child=NULL; 177 current_element->next=NULL; 182 current_element=createEmptyElements(); 178 183 } 179 184 wait_inputs=true; … … 217 222 fflush(stderr); 218 223 #endif 219 current_element=(elements*)malloc(ELEMENTS_SIZE); 220 current_element->name=NULL; 221 current_element->content=NULL; 222 current_element->metadata=NULL; 223 current_element->format=NULL; 224 current_element->defaults=NULL; 225 current_element->supported=NULL; 226 current_element->child=NULL; 227 current_element->next=NULL; 224 current_element=createEmptyElements(); 228 225 } 229 226 wait_outputs=1; … … 269 266 current_element->defaults=NULL; 270 267 current_element->supported=NULL; 268 current_element->child=NULL; 271 269 current_content=NULL; 272 270 } … … 285 283 } 286 284 #ifdef DEBUG_SERVICE_CONF 287 printf("* Identifiant : %s\n",$2);288 fflush(std out);285 fprintf(stderr,"* Identifiant : %s\n",$2); 286 fflush(stderr); 289 287 #endif 290 288 } … … 340 338 current_content=NULL; 341 339 current_element->supported=NULL; 340 current_element->child=NULL; 342 341 current_element->next=NULL; 342 } 343 if(strncasecmp($2,"EndNested",9)==0){ 344 if(current_data==1){ 345 elements* cursor=my_service->inputs; 346 while(cursor->next!=NULL) 347 cursor=cursor->next; 348 if(nested_level>1){ 349 for(int j=0;j<nested_level-1;j++){ 350 cursor=cursor->child; 351 while(cursor->next!=NULL) 352 cursor=cursor->next; 353 } 354 } 355 if(cursor->child==NULL){ 356 cursor->child=dupElements(current_element); 357 }else{ 358 addToElements(&cursor->child,current_element); 359 } 360 }else{ 361 if(current_element->name!=NULL){ 362 elements* cursor=my_service->outputs; 363 while(cursor->next!=NULL) 364 cursor=cursor->next; 365 if(nested_level>1){ 366 for(int j=0;j<nested_level-1;j++){ 367 cursor=cursor->child; 368 while(cursor->next!=NULL) 369 cursor=cursor->next; 370 } 371 } 372 if(cursor->child==NULL){ 373 cursor->child=dupElements(current_element); 374 }else 375 addToElements(&cursor->child,current_element); 376 } 377 } 378 freeElements(¤t_element); 379 free(current_element); 380 current_element=NULL; 381 current_element=createEmptyElements(); 382 nested_level-=1; 383 if(nested_level==0){ 384 wait_nested=false; 385 } 343 386 } 344 387 } … … 395 438 current_element->defaults=NULL; 396 439 current_element->supported=NULL; 440 current_element->child=NULL; 397 441 }else{ 398 442 if(wait_mainmetadata){ … … 428 472 current_content=NULL; 429 473 current_element->supported=NULL; 474 current_element->child=NULL; 430 475 current_element->next=NULL; 431 476 } … … 443 488 }else{ 444 489 current_element->supported=NULL; 490 current_element->child=NULL; 445 491 current_element->next=NULL; 446 492 } … … 553 599 fprintf(stderr,"processid (%s %d) %s\n",__FILE__,__LINE__,$1); 554 600 #endif 555 // if(data==-1){556 // data=1;557 601 if(::data==-1){ // knut: add namespace to avoid ambiguous symbol 558 602 ::data=1; 559 603 if($1!=NULL){ 560 604 char *cen=zStrdup($1); 561 my_service->name=(char*)malloc((strlen(cen)-1)*sizeof(char*));562 605 cen[strlen(cen)-1]=0; 563 606 cen+=1; 564 s printf(my_service->name,"%s",cen);607 setServiceName(&my_service,cen); 565 608 cen-=1; 566 609 free(cen); 567 my_service->content=NULL;568 my_service->metadata=NULL;569 my_service->inputs=NULL;570 my_service->outputs=NULL;571 610 } 572 611 } else { … … 579 618 } 580 619 else{ 581 addToElements(&my_service->inputs,current_element); 620 if(wait_nested){ 621 elements* cursor=my_service->inputs; 622 while(cursor->next!=NULL) 623 cursor=cursor->next; 624 if(nested_level>1){ 625 for(int j=0;j<nested_level-1;j++){ 626 cursor=cursor->child; 627 while(cursor->next!=NULL) 628 cursor=cursor->next; 629 } 630 } 631 if(cursor->child==NULL){ 632 cursor->child=dupElements(current_element); 633 }else{ 634 addToElements(&cursor->child,current_element); 635 } 636 }else 637 addToElements(&my_service->inputs,current_element); 638 } 639 if(current_element->format==NULL){ 640 wait_nested=true; 641 nested_level+=1; 642 if(current_content!=NULL){ 643 elements* cursor=my_service->inputs; 644 while(cursor->next!=NULL) 645 cursor=cursor->next; 646 if(nested_level>1){ 647 for(int j=0;j<nested_level-1;j++){ 648 cursor=cursor->child; 649 while(cursor->next!=NULL) 650 cursor=cursor->next; 651 } 652 } 653 addMapToMap(&cursor->content,current_content); 654 freeMap(¤t_content); 655 free(current_content); 656 current_content=NULL; 657 } 582 658 } 583 659 #ifdef DEBUG_SERVICE_CONF … … 593 669 fprintf(stderr,"(DATAINPUTS - 489) ALLOCATE current_element\n"); 594 670 #endif 595 current_element=(elements*)malloc(ELEMENTS_SIZE); 596 current_element->name=NULL; 597 current_element->content=NULL; 598 current_element->metadata=NULL; 599 current_element->format=NULL; 600 current_element->defaults=NULL; 601 current_element->supported=NULL; 602 current_element->next=NULL; 671 current_element=createEmptyElements(); 603 672 } 604 673 if(current_element->name==NULL){ … … 613 682 if($1!=NULL){ 614 683 char *cen=zStrdup($1); 615 current_element->name=(char*)malloc((strlen(cen)-1)*sizeof(char*));616 684 cen[strlen(cen)-1]=0; 617 685 cen+=1; 618 s printf(current_element->name,"%s",cen);686 setElementsName(¤t_element,cen); 619 687 cen-=1; 620 688 free(cen); … … 622 690 fprintf(stderr,"NAME IN %s (current - %s)\n",$1,current_element->name); 623 691 #endif 624 current_element->content=NULL;625 current_element->metadata=NULL;626 current_element->format=NULL;627 current_element->defaults=NULL;628 current_element->supported=NULL;629 current_element->next=NULL;630 692 #ifdef DEBUG_SERVICE_CONF 631 693 fprintf(stderr,"NAME IN %s (current - %s)\n",$1,current_element->name); … … 659 721 fprintf(stderr,"(DATAOUTPUTS -%d) ALLOCATE current_element %s \n",__LINE__,__FILE__); 660 722 #endif 661 current_element=(elements*)malloc(ELEMENTS_SIZE); 662 current_element->name=NULL; 663 current_element->content=NULL; 664 current_element->metadata=NULL; 665 current_element->format=NULL; 666 current_element->defaults=NULL; 667 current_element->supported=NULL; 668 current_element->next=NULL; 723 current_element=createEmptyElements(); 669 724 } 670 725 if(current_element->name==NULL){ … … 675 730 if($1!=NULL){ 676 731 char *cen=zStrdup($1); 677 current_element->name=(char*)malloc((strlen(cen)-1)*sizeof(char));678 732 cen[strlen(cen)-1]=0; 679 733 cen+=1; 680 s printf(current_element->name,"%s",cen);734 setElementsName(¤t_element,cen); 681 735 cen-=1; 682 736 free(cen); 683 current_element->content=NULL;684 current_element->metadata=NULL;685 current_element->format=NULL;686 current_element->defaults=NULL;687 current_element->supported=NULL;688 current_element->next=NULL;689 737 } 690 738 } … … 696 744 if(my_service->outputs==NULL) 697 745 my_service->outputs=dupElements(current_element); 698 else 699 addToElements(&my_service->outputs,current_element); 746 else{ 747 if(wait_nested){ 748 elements* cursor=my_service->outputs; 749 while(cursor->next!=NULL) 750 cursor=cursor->next; 751 if(nested_level>1){ 752 for(int j=0;j<nested_level-1;j++){ 753 cursor=cursor->child; 754 while(cursor->next!=NULL) 755 cursor=cursor->next; 756 } 757 } 758 if(cursor->child==NULL){ 759 cursor->child=dupElements(current_element); 760 }else 761 addToElements(&cursor->child,current_element); 762 }else 763 addToElements(&my_service->outputs,current_element); 764 } 765 if(current_element->format==NULL){ 766 wait_nested=true; 767 nested_level+=1; 768 if(current_content!=NULL){ 769 elements* cursor=my_service->outputs; 770 while(cursor->next!=NULL) 771 cursor=cursor->next; 772 if(nested_level>1){ 773 for(int j=0;j<nested_level-1;j++){ 774 cursor=cursor->child; 775 while(cursor->next!=NULL) 776 cursor=cursor->next; 777 } 778 } 779 addMapToMap(&cursor->content,current_content); 780 freeMap(¤t_content); 781 free(current_content); 782 current_content=NULL; 783 } 784 } 785 700 786 #ifdef DEBUG_SERVICE_CONF 701 787 fprintf(stderr,"ADD TO OUTPUTS Elements\n"); … … 705 791 free(current_element); 706 792 current_element=NULL; 707 current_element=(elements*)malloc(ELEMENTS_SIZE);793 708 794 char *cen=zStrdup($1); 709 current_element->name=(char*)malloc((strlen(cen)-1)*sizeof(char));710 795 cen[strlen(cen)-1]=0; 711 796 cen+=1; 712 sprintf(current_element->name,"%s",cen);797 current_element=createElements(cen); 713 798 cen-=1; 714 799 free(cen); 715 current_element->content=NULL;716 current_element->metadata=NULL;717 current_element->format=NULL;718 current_element->defaults=NULL;719 current_element->supported=NULL;720 current_element->next=NULL;721 800 } 722 801 else{ … … 727 806 if($1!=NULL){ 728 807 char *cen=zStrdup($1); 729 current_element->name=(char*)malloc((strlen(cen))*sizeof(char*));730 808 cen[strlen(cen)-1]=0; 731 809 #ifdef DEBUG … … 733 811 #endif 734 812 cen+=1; 735 s printf(current_element->name,"%s",cen);813 setElementsName(¤t_element,cen); 736 814 cen-=1; 737 815 free(cen); 738 current_element->content=NULL;739 current_element->metadata=NULL;740 current_element->format=NULL;741 current_element->defaults=NULL;742 current_element->supported=NULL;743 current_element->next=NULL;744 816 } 745 817 } … … 780 852 } 781 853 #ifdef DEBUG_SERVICE_CONF 782 fprintf(stderr,"(STARTING)FREE current_element\n"); 783 #endif 854 fprintf(stderr,"(STARTING)FREE current_element %s\n",file); 855 #endif 856 fflush(stderr); 857 fflush(stdout); 784 858 if(current_element!=NULL){ 785 859 freeElements(¤t_element); … … 797 871 wait_outputs=-1; 798 872 wait_data=false; 873 wait_nested=false; 799 874 //data=-1; 800 875 ::data=-1; // knut: add namespace to avoid ambiguous symbol … … 831 906 fprintf(stderr,"(DATAOUTPUTS - %d) COPY current_element\n",__LINE__); 832 907 #endif 833 addToElements(&my_service->outputs,current_element); 908 if(wait_nested){ 909 elements* cursor=my_service->outputs; 910 while(cursor->next!=NULL) 911 cursor=cursor->next; 912 if(nested_level>1){ 913 for(int j=0;j<nested_level-1;j++){ 914 cursor=cursor->child; 915 while(cursor->next!=NULL) 916 cursor=cursor->next; 917 } 918 } 919 if(cursor->child==NULL){ 920 cursor->child=dupElements(current_element); 921 }else 922 addToElements(&cursor->child,current_element); 923 }else 924 addToElements(&my_service->outputs,current_element); 834 925 } 835 926 #ifdef DEBUG_SERVICE_CONF
Note: See TracChangeset
for help on using the changeset viewer.