Changeset 607 for trunk/zoo-project/zoo-kernel/service_conf.y
- Timestamp:
- Mar 12, 2015, 3:14:52 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/zoo-project/zoo-kernel/service_conf.y
r539 r607 1 %{ 2 //====================================================== 3 /** 1 /* 4 2 * Thx to Jean-Marie CODOL and Naitan GROLLEMUND 5 3 * copyright 2009 GeoLabs SARL … … 7 5 * 8 6 */ 9 //====================================================== 7 %{ 10 8 11 9 #include <string> … … 22 20 static bool wait_defaults=false; 23 21 static bool wait_supporteds=false; 24 static bool wait_outputs= false;22 static bool wait_outputs=-1; 25 23 static bool wait_data=false; 26 24 static service* my_service=NULL; … … 34 32 // namespace 35 33 using namespace std; 36 //======================================================37 34 38 35 // srerror 39 36 void srerror(const char *s); 40 //======================================================41 37 42 38 // usage () 43 39 void usage(void) ; 44 //======================================================45 40 46 41 // srdebug 47 42 extern int srdebug; 48 //======================================================49 43 50 44 extern char srtext[]; … … 52 46 // srlineno 53 47 extern int srlineno; 54 //======================================================55 48 56 49 // srin 57 50 extern FILE* srin; 58 //======================================================59 51 60 52 // srlex 61 53 extern int srlex(void); 62 54 extern int srlex_destroy(void); 63 64 //vector<char*> lattribute;65 55 66 56 %} … … 76 66 /* STARTXMLDECL et ENDXMLDECL qui sont <?xml et ?>*/ 77 67 %token STARTXMLDECL ENDXMLDECL 78 //====================================================== 68 79 69 /* version="xxx" et encoding="xxx" */ 80 70 %token VERSIONDECL ENCODINGDECL SDDECL 81 //====================================================== 71 82 72 /* < et > */ 83 73 %token INFCAR SUPCAR 84 //====================================================== 74 85 75 /* / = a1 texte "texte" */ 86 76 %token SLASH Eq CHARDATA ATTVALUE PAIR SPAIR EPAIR ANID … … 88 78 %type <chaine> EPAIR 89 79 %type <chaine> SPAIR 90 //====================================================== 80 91 81 /* <!-- xxx -> <? xxx yyy ?> */ 92 82 %token PI PIERROR /** COMMENT **/ 93 //====================================================== 83 94 84 /* <!-- xxx -> <? xxx yyy ?> */ 95 85 %token ERREURGENERALE CDATA WHITESPACE NEWLINE … … 97 87 %type <s> ETag 98 88 %type <s> ANID 99 //====================================================== 100 // %start 101 //====================================================== 89 90 // % start 102 91 103 92 %% 104 // document <//=== 105 //====================================================== 93 // document 106 94 // regle 1 107 95 // on est a la racine du fichier xml 108 //======================================================109 96 document 110 97 : miscetoile element miscetoile {} … … 118 105 ; 119 106 // element 120 //======================================================121 107 // regle 39 122 108 // OUVRANTE CONTENU FERMANTE obligatoirement … … 124 110 // on ne peut pas avoir Epsilon 125 111 // un fichier xml ne peut pas etre vide ou seulement avec un prolog 126 //======================================================127 112 element 128 113 : STag contentetoile ETag … … 136 121 ; 137 122 138 //======================================================139 123 // STag 140 //======================================================141 124 // regle 40 142 125 // BALISE OUVRANTE 143 126 // on est obligé de faire appel a infcar et supcar 144 127 // pour acceder aux start conditions DANSBALISE et INITIAL 145 //======================================================146 128 STag 147 129 : INFCAR ID Attributeetoile SUPCAR … … 150 132 fprintf(stderr,"(%s %d) %s\n",__FILE__,__LINE__,$2); 151 133 fflush(stderr); 134 dumpMap(current_content); 152 135 #endif 153 136 if(my_service->content==NULL){ … … 163 146 } 164 147 if(strncasecmp($2,"DataInputs",10)==0){ 165 if(wait_mainmetadata==true ){148 if(wait_mainmetadata==true && current_content!=NULL){ 166 149 addMapToMap(&my_service->metadata,current_content); 167 150 freeMap(¤t_content); … … 238 221 current_element->next=NULL; 239 222 } 240 wait_outputs= true;223 wait_outputs=1; 241 224 current_data=2; 242 225 previous_data=2; … … 323 306 ; 324 307 325 //======================================================326 308 // Attributeetoile 327 //======================================================328 309 // regle 41 329 310 // une liste qui peut etre vide d'attributs 330 311 // utiliser la récursivité a gauche 331 //======================================================332 312 Attributeetoile 333 313 : Attributeetoile attribute {} … … 335 315 ; 336 316 337 //======================================================338 317 // attribute 339 //======================================================340 318 // regle 41 341 319 // un attribut est compose d'un identifiant … … 343 321 // et d'une définition de chaine de caractere 344 322 // ( "xxx" ou 'xxx' ) 345 //======================================================346 323 attribute 347 324 : ID Eq ATTVALUE … … 353 330 ; 354 331 355 //======================================================356 332 // EmptyElemTag 357 //======================================================358 333 // regle 44 359 334 // ICI ON DEFINIT NEUTRE … … 361 336 // parce qu'il n'y a pas de comparaisons a faire 362 337 // avec un identifiant d'une balise jumelle 363 //======================================================364 338 EmptyElemTag 365 339 : INFCAR ID Attributeetoile SLASH SUPCAR { … … 386 360 ; 387 361 388 //======================================================389 362 // ETag 390 //======================================================391 // regle 42392 363 // BALISE FERMANTE 393 364 // les separateurs après ID sont filtrés 394 //======================================================395 365 ETag 396 366 : INFCAR SLASH ID SUPCAR … … 401 371 if(strcmp($3,"DataInputs")==0){ 402 372 current_data=1; 373 if(current_content!=NULL){ 374 if(current_element->content==NULL){ 375 addMapToMap(¤t_element->content,current_content); 376 } 377 freeMap(¤t_content); 378 free(current_content); 379 current_content=NULL; 380 } 381 if(current_element!=NULL){ 382 if(my_service->content!=NULL && current_element->name!=NULL){ 383 if(my_service->inputs==NULL){ 384 my_service->inputs=dupElements(current_element); 385 my_service->inputs->next=NULL; 386 tmp_count++; 387 } 388 else{ 389 addToElements(&my_service->inputs,current_element); 390 } 391 freeElements(¤t_element); 392 free(current_element); 393 current_element=NULL; 394 } 395 } 403 396 } 404 397 if(strcmp($3,"DataOutputs")==0){ … … 489 482 ; 490 483 491 //======================================================492 484 // texteinterbalise 493 //======================================================494 485 // regle 14 495 486 // DU TEXTE quelconque … … 499 490 // maintenant on croise les ID dans les dbalises 500 491 // et des CHARDATA hors des balises 501 //======================================================502 492 texteinterbalise 503 493 : CHARDATA {} 504 494 ; 505 //======================================================506 495 507 496 pair: PAIR { if(debug) fprintf(stderr,"PAIR FOUND !!\n");if(curr_key!=NULL){free(curr_key);curr_key=NULL;} } … … 637 626 else 638 627 if(current_data==2){ 639 wait_outputs= true;628 wait_outputs=1; 640 629 if(wait_inputs){ 641 630 if(current_element!=NULL && current_element->name!=NULL){ … … 746 735 } 747 736 wait_inputs=false; 748 wait_outputs= true;737 wait_outputs=1; 749 738 //wait_outputs=true; 750 739 } … … 755 744 %% 756 745 757 // srerror 758 //====================================================== 759 /* fonction qui affiche l erreur si il y en a une */ 760 //====================================================== 746 /** 747 * Print on stderr the message and the line number of the error which occured. 748 * 749 * @param s the error message 750 */ 761 751 void srerror(const char *s) 762 752 { … … 766 756 767 757 /** 768 * getServiceFromFile : 769 * set service given as second parameter with informations extracted from the 770 * definition file. 758 * Parse a ZCFG file and fill the service structure. 759 * 760 * @param conf the conf maps containing the main.cfg settings 761 * @param file the fullpath to the ZCFG file 762 * @param service the service structure to fill 763 * @return 0 on success, -1 on failure 771 764 */ 772 765 int getServiceFromFile(maps* conf,const char* file,service** service){ … … 792 785 wait_defaults=false; 793 786 wait_supporteds=false; 794 wait_outputs= false;787 wait_outputs=-1; 795 788 wait_data=false; 796 789 data=-1; … … 810 803 #ifdef DEBUG_SERVICE_CONF 811 804 fprintf(stderr,"RESULT: %d %d\n",resultatYYParse,wait_outputs); 812 #endif 813 if(wait_outputs && current_element!=NULL && current_element->name!=NULL){ 814 if(my_service->outputs==NULL){ 805 dumpElements(current_element); 806 #endif 807 if(wait_outputs>0 && current_element!=NULL && current_element->name!=NULL){ 808 if(my_service->outputs==NULL){ 815 809 #ifdef DEBUG_SERVICE_CONF 816 810 fprintf(stderr,"(DATAOUTPUTS - %d) DUP current_element\n",__LINE__); … … 840 834 current_element=NULL; 841 835 } 836 int contentOnly=-1; 842 837 if(current_content!=NULL){ 838 if(my_service->content==NULL){ 839 addMapToMap(&my_service->content,current_content); 840 contentOnly=1; 841 } 843 842 freeMap(¤t_content); 844 843 free(current_content); … … 849 848 dumpService(my_service); 850 849 #endif 851 if(wait_outputs<0 || my_service==NULL || my_service->name==NULL || my_service->content==NULL || my_service->outputs==NULL){ 852 fprintf(stderr,"%s %d\n",__FILE__,__LINE__); 850 if(contentOnly<0 && ((wait_outputs<0 && current_data==2 && my_service->outputs==NULL) || my_service==NULL || my_service->name==NULL || my_service->content==NULL)){ 853 851 setMapInMaps(conf,"lenv","message",srlval.chaine); 854 852 #ifndef WIN32
Note: See TracChangeset
for help on using the changeset viewer.