Changeset 9 for trunk/zoo-kernel/main_conf_read.y
- Timestamp:
- Sep 14, 2010, 2:04:55 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/zoo-kernel/main_conf_read.y
r1 r9 5 5 **/ 6 6 //====================================================== 7 8 9 7 10 8 #include <string> … … 23 21 static char* curr_key; 24 22 static int debug=0; 25 //static int data=-1;26 23 static int previous_data=0; 27 24 static int current_data=0; 28 //static char* myFinalObjectAsJSON="{";29 // namespace30 25 using namespace std; 31 26 … … 43 38 44 39 extern int crlex(void); 45 40 extern int crlex_destroy(void); 46 41 47 42 %} … … 128 123 : STag contentetoile ETag 129 124 { 130 131 132 133 134 135 136 137 138 139 140 141 125 /* les non terminaux rendent les valeurs de leur identifiants de balise */ 126 /* en char*, donc on peut comparer ces valeurs avec la fonction C++ strcmp(const char*;const char*) */ 127 /* de string */ 128 if (strcmp($1,$3) != 0) 129 { 130 crerror("Opening and ending tag mismatch"); 131 printf("\n ::details : tag '%s' et '%s' \n",$1,$3); 132 return 1; 133 // on retourne different de 0 134 // sinon yyparse rendra 0 135 // et dans le main on croira a le fichier xml est valide ! 136 } 142 137 } 143 138 // pour neutre … … 266 261 if(current_content==NULL) 267 262 current_content=createMap(curr_key,$1); 268 else 263 else{ 269 264 addToMap(current_content,curr_key,$1); 265 } 270 266 if(debug){ 271 267 printf("EPAIR FOUND !! \n"); … … 279 275 280 276 processid 281 277 : ANID { 282 278 if(current_maps->name!=NULL){ 283 current_maps->content=current_content; 284 current_maps->next=(maps*)malloc(MAP_SIZE); 279 addMapToMap(¤t_maps->content,current_content); 280 freeMap(¤t_content); 281 free(current_content); 282 current_maps->next=NULL; 283 current_maps->next=(maps*)malloc(MAPS_SIZE); 284 current_maps->next->name=strdup($1); 285 current_maps->next->content=NULL; 286 current_maps->next->next=NULL; 285 287 current_maps=current_maps->next; 286 current_maps->name=strdup($1); 288 current_content=current_maps->content; 289 } 290 else{ 291 current_maps->name=(char*)malloc((strlen($1)+1)*sizeof(char)); 292 snprintf(current_maps->name,(strlen($1)+1),"%s",$1); 293 current_maps->content=NULL; 294 current_maps->next=NULL; 287 295 current_content=NULL; 288 296 } 289 else{290 current_maps->name=strdup($1);291 }292 297 } 293 298 ; … … 310 315 //====================================================== 311 316 int conf_read(char* file,maps* my_map){ 312 /* mode debug ou pas : */313 /* 1 = debug , 0 = normal */314 //yydebug = 1;315 317 316 318 crin = fopen(file,"r"); … … 320 322 } 321 323 322 //my_map=(maps*)malloc(sizeof(maps*));323 324 my_maps=my_map; 324 325 my_maps->name=NULL; … … 326 327 327 328 int resultatYYParse = crparse() ; 328 329 if(current_content!=NULL) 330 current_maps->content=current_content; 331 332 //dumpMaps(my_maps); 329 if(current_content!=NULL){ 330 addMapToMap(¤t_maps->content,current_content); 331 current_maps->next=NULL; 332 freeMap(¤t_content); 333 free(current_content); 334 } 333 335 334 336 fclose(crin); 337 crlex_destroy(); 338 335 339 return resultatYYParse; 336 340 } 337 341 338 342 339 void usage(void)340 {341 printf("usage : $./test1 <fichier_de_configuration_principale>\n") ;342 }343 343 //====================================================== 344 344 // FIN //
Note: See TracChangeset
for help on using the changeset viewer.