Changeset 9 for trunk/zoo-kernel/service_conf.y
- Timestamp:
- Sep 14, 2010, 2:04:55 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/zoo-kernel/service_conf.y
r1 r9 13 13 #include <ctype.h> 14 14 #include <service.h> 15 #include <vector>15 //#include <vector> 16 16 17 17 static int tmp_count=1; … … 65 65 // srlex 66 66 extern int srlex(void); 67 68 vector<char*> lattribute; 67 extern int srlex_destroy(void); 68 69 //vector<char*> lattribute; 69 70 70 71 %} … … 132 133 : STag contentetoile ETag 133 134 { 134 if (strcmp($1,$3) != 0)135 /*if (strcasecmp($1,$3) != 0) 135 136 { 136 //srerror("Opening and ending tag mismatch");137 137 fprintf(stderr,"Opening and ending tag mismatch\n ::details : tag '%s' et '%s' \n",$1,$3); 138 lattribute.clear();138 //lattribute.clear(); 139 139 //return 1; 140 } 140 }*/ 141 free($3); 141 142 } 142 143 // pour neutre … … 159 160 /* parce que cet element est reconnu AVANT la balise fermante */ 160 161 /* et APRES l'analyse des eventuelles balises internes ou successeur */ 161 lattribute.clear();162 162 //lattribute.clear(); 163 163 164 if(my_service->content==NULL){ 164 165 #ifdef DEBUG_SERVICE_CONF 165 166 fprintf(stderr,"NO CONTENT\n"); 166 167 #endif 167 //addMapToMap(&my_service->content,current_content);168 //freeMap(¤t_content);169 my_service->content=current_content;168 addMapToMap(&my_service->content,current_content); 169 freeMap(¤t_content); 170 free(current_content); 170 171 current_content=NULL; 171 172 my_service->metadata=NULL; … … 173 174 } 174 175 175 if(str cmp($2,"DataInputs")==0){176 if(strncasecmp($2,"DataInputs",10)==0){ 176 177 if(wait_mainmetadata==true){ 177 if(my_service->metadata==NULL) 178 my_service->metadata=current_content; 179 else{ 180 addMapToMap(&my_service->metadata,current_content); 181 freeMap(¤t_content); 182 } 178 addMapToMap(&my_service->metadata,current_content); 179 freeMap(¤t_content); 180 free(current_content); 183 181 current_content=NULL; 184 182 } … … 208 206 } 209 207 else 210 if(str cmp($2,"DataOutputs")==0){208 if(strncasecmp($2,"DataOutputs",11)==0){ 211 209 if(wait_inputs==true){ 212 210 #ifdef DEBUG_SERVICE_CONF 213 211 fprintf(stderr,"(DATAOUTPUTS) DUP INPUTS current_element\n"); 214 #endif 215 if(my_service->inputs==NULL) 212 fprintf(stderr,"CURRENT_ELEMENT\n"); 213 dumpElements(current_element); 214 fprintf(stderr,"SERVICE INPUTS\n"); 215 dumpElements(my_service->inputs); 216 dumpService(my_service); 217 #endif 218 if(my_service->inputs==NULL){ 216 219 my_service->inputs=dupElements(current_element); 220 my_service->inputs->next=NULL; 221 } 217 222 else 218 addToElements(my_service->inputs,current_element); 219 #ifdef DEBUG_SERVICE_CONF 223 addToElements(&my_service->inputs,current_element); 224 #ifdef DEBUG_SERVICE_CONF 225 fprintf(stderr,"CURRENT_ELEMENT\n"); 220 226 dumpElements(current_element); 227 fprintf(stderr,"SERVICE INPUTS\n"); 221 228 dumpElements(my_service->inputs); 222 229 fprintf(stderr,"(DATAOUTPUTS) FREE current_element\n"); … … 245 252 } 246 253 else 247 if(str cmp($2,"MetaData")==0){254 if(strncasecmp($2,"MetaData",8)==0){ 248 255 current_data=3; 249 256 if(current_element!=NULL){ … … 263 270 } 264 271 else 265 if(str cmp($2,"ComplexData")==0 || strcmp($2,"LiteralData")==0266 || strcmp($2,"ComplexOutput")==0 || strcmp($2,"LiteralOutput")==0){272 if(strncasecmp($2,"ComplexData",11)==0 || strncasecmp($2,"LiteralData",10)==0 273 || strncasecmp($2,"ComplexOutput",13)==0 || strncasecmp($2,"LiteralOutput",12)==0){ 267 274 current_data=4; 268 275 if(wait_metadata==true){ 269 276 if(current_content!=NULL){ 270 current_element->metadata=current_content;277 addMapToMap(¤t_element->metadata,current_content); 271 278 current_element->next=NULL; 272 279 current_element->format=$2; 273 280 current_element->defaults=NULL; 281 current_element->supported=NULL; 282 freeMap(¤t_content); 283 free(current_content); 274 284 } 275 }else{ // No MainMetaData276 // addMapToMap(¤t_element->content,current_content);277 //freeMap(¤t_content);278 //free(current_content);279 current_element->content=current_content;285 }else{ 286 // No MainMetaData 287 addMapToMap(¤t_element->content,current_content); 288 freeMap(¤t_content); 289 free(current_content); 280 290 current_element->metadata=NULL; 281 291 current_element->next=NULL; 282 292 current_element->format=$2; 283 293 current_element->defaults=NULL; 294 current_element->supported=NULL; 284 295 } 285 296 current_content=NULL; … … 287 298 } 288 299 else 289 if(str cmp($2,"Default")==0){300 if(strncasecmp($2,"Default",7)==0){ 290 301 wait_defaults=true; 291 302 current_data=5; 292 303 } 293 304 else 294 if(str cmp($2,"Supported")==0){305 if(strncasecmp($2,"Supported",9)==0){ 295 306 wait_supporteds=true; 296 307 if(wait_defaults==true){ … … 304 315 printf("* Identifiant : %s\n",$2); 305 316 #endif 306 307 317 /* et on renvoie l'identifiant de balise afin de pouvoir le comparer */ 308 318 /* avec la balise jumelle fermante ! */ 309 319 $$ = $2 ; 320 /*if($2!=NULL) 321 free($2);*/ 310 322 } 311 323 ; … … 338 350 printf ("attribute : %s\n",$1) ; 339 351 #endif 340 for(int i=0;i < lattribute.size(); i++)352 /*for(int i=0;i < lattribute.size(); i++) 341 353 { 342 354 if (strcmp($1,lattribute.at(i)) == 0) 343 355 { 344 356 fprintf (stderr,"attributs identiques : %d -- %s , %s",i,lattribute.at(i),$1) ; 345 //srerror("attribut redondant !:");346 357 } 347 358 } 348 lattribute.push_back($1); 359 lattribute.push_back($1);*/ 360 free($1); 349 361 } 350 362 ; … … 359 371 //====================================================== 360 372 EmptyElemTag 361 : INFCAR ID Attributeetoile SLASH SUPCAR { lattribute.clear();/* voir Stag */}373 : INFCAR ID Attributeetoile SLASH SUPCAR {/*lattribute.clear();/* voir Stag */} 362 374 ; 363 375 //====================================================== … … 387 399 current_data=previous_data; 388 400 if(current_element->defaults==NULL){ 389 current_element->defaults=(iotype*)malloc(MAP_SIZE); 390 } 391 current_element->defaults->content=current_content; 401 current_element->defaults=(iotype*)malloc(IOTYPE_SIZE); 402 current_element->defaults->content=NULL; 403 } 404 addMapToMap(¤t_element->defaults->content,current_content); 405 freeMap(¤t_content); 406 free(current_content); 392 407 current_element->defaults->next=NULL; 393 408 wait_defaults=false; … … 398 413 current_data=previous_data; 399 414 if(current_element->supported==NULL){ 400 current_element->supported=(iotype*)malloc(MAP_SIZE); 401 current_element->supported->content=current_content; 415 //addMapToIoType(¤t_element->supported,current_content); 416 current_element->supported=(iotype*)malloc(IOTYPE_SIZE); 417 current_element->supported->content=NULL; 418 addMapToMap(¤t_element->supported->content,current_content); 419 freeMap(¤t_content); 420 free(current_content); 402 421 current_element->supported->next=NULL; 403 /** 404 * Need to free this ressource (HERE ?) 422 current_content=NULL; 423 } 424 else{ 425 #ifdef DEBUG 426 // Currently we support only one supported format 427 fprintf(stderr,"SECOND SUPPORTED FORMAT !!!!\n"); 428 #endif 429 //addMapToIoType(¤t_element->supported,current_content); 430 /*iotype* iotmp=*(¤t_element->supported); 431 while(iotmp!=NULL){ 432 dumpMap(iotmp->content); 433 iotmp=iotmp->next; 434 } 435 iotmp=(iotype*)malloc(IOTYPE_SIZE); 436 iotmp->content=NULL; 437 addMapToMap(&iotmp->content,current_content); 438 iotmp->next=NULL; 439 dumpElements(current_element); 440 fprintf(stderr,"SECOND SUPPORTED FORMAT MAP START !!!!\n"); 441 dumpMap(current_content); 442 fprintf(stderr,"SECOND SUPPORTED FORMAT MAP END !!!!\n");*/ 443 freeMap(¤t_content); 405 444 free(current_content); 406 */ 407 } 408 else{ 409 /*current_element->supported->next=(iotype*)malloc(sizeof(iotype*)); 410 current_element->supported->next->content=NULL; 411 current_element->supported->next->next=NULL; 412 iotype* tmp1=current_element->supported; 413 while(tmp1!=NULL){ 414 addMapToMap(¤t_element->supported->next->content,current_content); 415 freeMap(¤t_content); 416 #ifdef DEBUG_SERVICE_CONF 417 fprintf(stderr,"LINE 409"); 418 #endif 419 free(current_content); 420 current_content=NULL; 421 tmp1=tmp1->next; 422 }*/ 445 current_content=NULL; 446 /*freeMap(&iotmp->content); 447 free(&iotmp->content); 448 free(iotype);*/ 449 #ifdef DEBUG 450 // Currently we support only one supported format 451 fprintf(stderr,"SECOND SUPPORTED FORMAT !!!!\n"); 452 #endif 423 453 } 424 454 current_content=NULL; … … 472 502 //====================================================== 473 503 474 pair: PAIR { if(debug) fprintf(stderr,"PAIR FOUND !!\n"); }504 pair: PAIR { if(debug) fprintf(stderr,"PAIR FOUND !!\n");if(curr_key!=NULL){free(curr_key);curr_key=NULL;} } 475 505 | EPAIR { 476 506 #ifdef DEBUG_SERVICE_CONF … … 495 525 dumpMap(current_content); 496 526 fprintf(stderr,"addToMap(current_content,%s,%s) !! \n",curr_key,$1); 497 498 #endif 499 //map* tmp1=createMap(curr_key,$1); 527 #endif 500 528 addToMap(current_content,curr_key,$1); 501 //freeMap(&tmp1);502 //free(tmp1);503 529 #ifdef DEBUG_SERVICE_CONF 504 530 fprintf(stderr,"addToMap(current_content,%s,%s) end !! \n",curr_key,$1); 505 531 #endif 506 532 } 507 //free(curr_key);508 curr_key=NULL;509 533 #ifdef DEBUG_SERVICE_CONF 510 534 fprintf(stderr,"EPAIR FOUND !! \n"); … … 513 537 fflush(stderr); 514 538 #endif 515 } 516 | SPAIR { curr_key=$1; if(debug) fprintf(stderr,"SPAIR FOUND !!\n"); } 539 if(curr_key!=NULL){ 540 free(curr_key); 541 curr_key=NULL; 542 } 543 } 544 | SPAIR { curr_key=strdup($1);/*free($1);*/if(debug) fprintf(stderr,"SPAIR FOUND !!\n"); } 517 545 ; 518 546 … … 522 550 if(data==-1){ 523 551 data=1; 524 my_service->name=$1; 552 char *cen=strdup($1); 553 my_service->name=(char*)malloc((strlen(cen)-1)*sizeof(char*)); 554 cen[strlen(cen)-1]=0; 555 cen+=1; 556 sprintf(my_service->name,"%s",cen); 557 cen-=1; 558 free(cen); 525 559 my_service->content=NULL; 526 560 my_service->metadata=NULL; … … 530 564 if(current_data==1){ 531 565 if(my_service->content!=NULL && current_element->name!=NULL){ 532 //fprintf(stderr,"ELEMENT (%s)",current_element->name);533 566 if(my_service->inputs==NULL){ 534 #ifdef DEBUG_SERVICE_CONF535 fprintf(stderr,"count (%i) (%s)\n",tmp_count%2,$1);536 fflush(stderr);537 #endif538 //if(tmp_count==1){539 #ifdef DEBUG_SERVICE_CONF540 fprintf(stderr,"(DATAINPUTS - 464)DUP current_element\n");541 dumpElements(current_element);542 #endif543 567 my_service->inputs=dupElements(current_element); 544 #ifdef DEBUG_SERVICE_CONF 545 fprintf(stderr,"(DATAINPUTS - 466)FREE current_element\n"); 546 #endif 547 freeElements(¤t_element); 548 current_element=NULL; 568 my_service->inputs->next=NULL; 549 569 tmp_count++; 550 570 } 551 571 else{ 552 addToElements(my_service->inputs,current_element); 553 #ifdef DEBUG_SERVICE_CONF 554 fprintf(stderr,"(DATAINPUTS - 6)FREE current_element (after adding to allread existing inputs)"); 555 #endif 556 freeElements(¤t_element); 572 addToElements(&my_service->inputs,current_element); 557 573 } 558 574 #ifdef DEBUG_SERVICE_CONF 575 fprintf(stderr,"(%s %d)FREE current_element (after adding to allread existing inputs)",__FILE__,__LINE__); 576 dumpElements(current_element); 577 fprintf(stderr,"(%s %d)FREE current_element (after adding to allread existing inputs)",__FILE__,__LINE__); 559 578 dumpElements(my_service->inputs); 560 579 #endif 580 freeElements(¤t_element); 561 581 free(current_element); 562 582 current_element=NULL; … … 582 602 fprintf(stderr,"(DATAINPUTS - 501) SET NAME OF current_element\n"); 583 603 #endif 584 current_element->name=strdup($1); 604 char *cen=strdup($1); 605 current_element->name=(char*)malloc((strlen(cen)-1)*sizeof(char*)); 606 cen[strlen(cen)-1]=0; 607 cen+=1; 608 sprintf(current_element->name,"%s",cen); 609 cen-=1; 610 free(cen); 585 611 #ifdef DEBUG_SERVICE_CONF 586 612 fprintf(stderr,"NAME IN %s (current - %s)\n",$1,current_element->name); … … 604 630 if(my_service->inputs==NULL){ 605 631 my_service->inputs=dupElements(current_element); 632 my_service->inputs->next=NULL; 606 633 } 607 634 else{ … … 609 636 fprintf(stderr,"LAST NAME IN %s (current - %s)\n",$1,current_element->name); 610 637 #endif 611 addToElements( my_service->inputs,current_element);638 addToElements(&my_service->inputs,current_element); 612 639 } 613 640 #ifdef DEBUG_SERVICE_CONF 614 641 dumpElements(current_element); 615 fprintf(stderr,"(DATAOUTPUTS - 531) FREE current_element\n");642 fprintf(stderr,"(DATAOUTPUTS) FREE current_element %s %i\n",__FILE__,__LINE__); 616 643 #endif 617 644 freeElements(¤t_element); 618 free(¤t_element); 619 #ifdef DEBUG_SERVICE_CONF 620 fprintf(stderr,"free OUTPUTS\n"); 621 #endif 645 free(current_element); 622 646 current_element=NULL; 623 647 #ifdef DEBUG_SERVICE_CONF 624 fprintf(stderr,"(DATAOUTPUTS - 536) ALLOCATE current_element\n");648 fprintf(stderr,"(DATAOUTPUTS) ALLOCATE current_element %s %i\n",__FILE__,__LINE__); 625 649 #endif 626 650 current_element=(elements*)malloc(ELEMENTS_SIZE); … … 638 662 fprintf(stderr,"(DATAOUTPUTS - 545) SET NAME OF current_element\n"); 639 663 #endif 640 current_element->name=strdup($1); 664 char *cen=strdup($1); 665 current_element->name=(char*)malloc((strlen(cen)-1)*sizeof(char*)); 666 cen[strlen(cen)-1]=0; 667 cen+=1; 668 sprintf(current_element->name,"%s",cen); 669 cen-=1; 670 free(cen); 641 671 current_element->content=NULL; 642 672 current_element->metadata=NULL; … … 647 677 } 648 678 wait_inputs=false; 679 dumpMap(current_content); 649 680 current_content=NULL; 650 681 } … … 655 686 fprintf(stderr,"(DATAOUTPUTS - 545) SET NAME OF current_element\n"); 656 687 #endif 657 current_element->name=strdup($1); 688 char *cen=strdup($1); 689 current_element->name=(char*)malloc((strlen(cen)-1)*sizeof(char*)); 690 cen[strlen(cen)-1]=0; 691 #ifdef DEBUG 692 fprintf(stderr,"tmp %s\n",cen); 693 #endif 694 cen+=1; 695 sprintf(current_element->name,"%s",cen); 696 cen-=1; 697 free(cen); 658 698 current_element->content=NULL; 659 699 current_element->metadata=NULL; … … 726 766 if (srin==NULL){ 727 767 fprintf(stderr,"error : le fichier specifie n'existe pas ou n'est pas accessible en lecture\n") ; 728 return 22; 729 } 730 731 //printf(" "); 768 return -1; 769 } 770 732 771 int resultatYYParse = srparse() ; 733 772 … … 738 777 #endif 739 778 my_service->outputs=dupElements(current_element); 779 my_service->outputs->next=NULL; 780 freeElements(¤t_element); 781 free(current_element); 740 782 current_element=NULL; 741 783 } … … 744 786 fprintf(stderr,"(DATAOUTPUTS - 628) COPY current_element\n"); 745 787 #endif 746 addToElements( my_service->outputs,current_element);788 addToElements(&my_service->outputs,current_element); 747 789 } 748 790 #ifdef DEBUG_SERVICE_CONF … … 750 792 #endif 751 793 freeElements(¤t_element); 794 free(current_element); 795 current_element=NULL; 752 796 } 753 797 if(current_element!=NULL){ 754 798 freeElements(¤t_element); 755 799 fprintf(stderr,"LINE 709"); 756 //free(current_element);800 free(current_element); 757 801 current_element=NULL; 758 802 } … … 760 804 freeMap(¤t_content); 761 805 fprintf(stderr,"LINE 715"); 762 //free(current_content);806 free(current_content); 763 807 current_content=NULL; 764 808 } … … 769 813 *service=my_service; 770 814 815 srlex_destroy(); 771 816 return resultatYYParse; 772 817 }
Note: See TracChangeset
for help on using the changeset viewer.