Warning: Can't use blame annotator:
svn blame failed on trunk/zoo-project/zoo-kernel/service_conf.y: 200029 - Couldn't perform atomic initialization
20014 - Can't find a temporary directory: Internal error

source: trunk/zoo-project/zoo-kernel/service_conf.y @ 619

Last change on this file since 619 was 618, checked in by djay, 10 years ago

Fix for OTB support when input was passed by value rather than reference.

File size: 23.3 KB
RevLine 
1/*
2 * Thx to Jean-Marie CODOL and Naitan GROLLEMUND
3 * copyright 2009 GeoLabs SARL
4 * Author : Gérald FENOY
5 *
6 */
7%{
8
9#include <string>
10#include <stdio.h>
11#include <ctype.h>
12#include <service.h>
13
14static int tmp_count=1;
15static int defaultsc=0;
16static bool wait_maincontent=true;
17static bool wait_mainmetadata=false;
18static bool wait_metadata=false;
19static bool wait_inputs=false;
20static bool wait_defaults=false;
21static bool wait_supporteds=false;
22static bool wait_outputs=false;
23static bool wait_data=false;
24static service* my_service=NULL;
25static map* current_content=NULL;
26static elements* current_element=NULL;
27static char* curr_key;
28static int debug=0;
29static int data=-1;
30static int previous_data=0;
31static int current_data=0;
32// namespace
33using namespace std;
34
35// srerror
36void srerror(const char *s);
37
38// usage ()
39void usage(void) ;
40
41// srdebug
42extern int srdebug;
43
44extern char srtext[];
45
46// srlineno
47extern int srlineno;
48
49// srin
50extern FILE* srin;
51
52// srlex
53extern int srlex(void);
54extern int srlex_destroy(void);
55
56%}
57
58
59
60%union
61{char * s;char* chaine;char* key;char* val;}
62
63// jetons //
64%token <s> ID
65%token <s> CHAINE
66/* STARTXMLDECL et ENDXMLDECL qui sont <?xml et ?>*/
67%token STARTXMLDECL ENDXMLDECL
68
69/* version="xxx" et encoding="xxx" */
70%token VERSIONDECL ENCODINGDECL SDDECL
71
72/* < et > */
73%token INFCAR SUPCAR
74
75/* / = a1  texte "texte" */
76%token SLASH Eq CHARDATA ATTVALUE PAIR SPAIR EPAIR ANID
77%type <chaine> PAIR
78%type <chaine> EPAIR
79%type <chaine> SPAIR
80
81/* <!-- xxx -> <? xxx yyy ?> */
82%token PI PIERROR /** COMMENT **/
83
84/* <!-- xxx -> <? xxx yyy ?> */
85%token ERREURGENERALE CDATA WHITESPACE NEWLINE
86%type <s> STag
87%type <s> ETag
88%type <s> ANID
89
90// % start
91
92%%
93// document
94// regle 1
95// on est a la racine du fichier xml
96document
97 : miscetoile element miscetoile {}
98 | contentetoile processid contentetoile document {}
99 ;
100
101miscetoile
102 : miscetoile PIERROR {  srerror("processing instruction begining with <?xml ?> impossible\n");}
103 | miscetoile PI {}
104 | {}
105 ;
106// element
107// regle 39
108// OUVRANTE CONTENU FERMANTE obligatoirement
109// ou neutre
110// on ne peut pas avoir Epsilon
111// un fichier xml ne peut pas etre vide ou seulement avec un prolog
112element
113 : STag contentetoile ETag     
114{
115}
116
117// pour neutre
118// on a rien a faire, meme pas renvoyer l identificateur de balise
119// vu qu'il n y a pas de comparaison d'identificateurs avec un balise jumelle .
120 | EmptyElemTag          {}
121 ;
122
123// STag
124// regle 40
125// BALISE OUVRANTE
126// on est obligé de faire appel a infcar et supcar
127// pour acceder aux start conditions DANSBALISE et INITIAL
128STag
129: INFCAR ID Attributeetoile SUPCAR
130{
131#ifdef DEBUG_SERVICE_CONF
132  fprintf(stderr,"(%s %d) %s\n",__FILE__,__LINE__,$2);
133  fflush(stderr);
134  dumpMap(current_content);
135#endif
136  if(my_service->content==NULL){
137#ifdef DEBUG_SERVICE_CONF
138    fprintf(stderr,"NO CONTENT\n");
139#endif
140    addMapToMap(&my_service->content,current_content);
141    freeMap(&current_content);
142    free(current_content);
143    current_content=NULL;
144    my_service->metadata=NULL;
145    wait_maincontent=false;
146  }
147  if(strncasecmp($2,"DataInputs",10)==0){
148    if(wait_mainmetadata==true && current_content!=NULL){
149      addMapToMap(&my_service->metadata,current_content);
150      freeMap(&current_content);
151      free(current_content);
152      current_content=NULL;
153      wait_mainmetadata=false;
154    }
155    if(current_element==NULL){
156#ifdef DEBUG_SERVICE_CONF
157      fprintf(stderr,"(DATAINPUTS - %d) FREE current_element\n",__LINE__);
158#endif
159      freeElements(&current_element);
160      free(current_element);
161#ifdef DEBUG_SERVICE_CONF
162      fprintf(stderr,"(DATAINPUTS - %d) ALLOCATE current_element\n",__LINE__);
163#endif
164      current_element=NULL;
165      current_element=(elements*)malloc(ELEMENTS_SIZE);
166      current_element->name=NULL;
167      current_element->content=NULL;
168      current_element->metadata=NULL;
169      current_element->format=NULL;
170      current_element->defaults=NULL;
171      current_element->supported=NULL;
172      current_element->next=NULL;
173    }
174    wait_inputs=true;
175    current_data=1;
176    previous_data=1;
177  }
178  else
179    if(strncasecmp($2,"DataOutputs",11)==0){
180      if(wait_inputs==true){
181#ifdef DEBUG_SERVICE_CONF
182        fprintf(stderr,"(DATAOUTPUTS %d) DUP INPUTS current_element\n",__LINE__);
183        fprintf(stderr,"CURRENT_ELEMENT\n");
184        dumpElements(current_element);
185        fprintf(stderr,"SERVICE INPUTS\n");
186        dumpElements(my_service->inputs);
187        dumpService(my_service);
188#endif 
189        if(my_service->inputs==NULL && current_element!=NULL && current_element->name!=NULL){
190          my_service->inputs=dupElements(current_element);
191          my_service->inputs->next=NULL;
192          freeElements(&current_element);
193        }
194        else if(current_element!=NULL && current_element->name!=NULL){
195          addToElements(&my_service->inputs,current_element);
196          freeElements(&current_element);
197        }
198#ifdef DEBUG_SERVICE_CONF
199        fprintf(stderr,"CURRENT_ELEMENT\n");
200        dumpElements(current_element);
201        fprintf(stderr,"SERVICE INPUTS\n");
202        dumpElements(my_service->inputs);
203        fprintf(stderr,"(DATAOUTPUTS) FREE current_element\n");
204#endif
205        free(current_element);
206        current_element=NULL;
207        wait_inputs=false;
208      }
209      if(current_element==NULL){
210#ifdef DEBUG_SERVICE_CONF
211        fprintf(stderr,"(DATAOUTPUTS - %d) ALLOCATE current_element (%s)\n",__LINE__,$2);
212        fflush(stderr);
213#endif
214        current_element=(elements*)malloc(ELEMENTS_SIZE);
215        current_element->name=NULL;
216        current_element->content=NULL;
217        current_element->metadata=NULL;
218        current_element->format=NULL;
219        current_element->defaults=NULL;
220        current_element->supported=NULL;
221        current_element->next=NULL;
222      }
223      wait_outputs=1;
224      current_data=2;
225      previous_data=2;
226    }
227    else
228      if(strncasecmp($2,"MetaData",8)==0){
229        previous_data=current_data;
230        current_data=3;
231        if(current_element!=NULL){
232#ifdef DEBUG_SERVICE_CONF
233          fprintf(stderr,"add current_content to current_element->content\n");
234          fprintf(stderr,"LINE %d",__LINE__);
235#endif
236          addMapToMap(&current_element->content,current_content);
237          freeMap(&current_content);
238          free(current_content);
239          if(previous_data==1 || previous_data==2)
240            wait_metadata=true;
241          else
242            wait_mainmetadata=true;
243        }
244        else{
245          if(previous_data==1 || previous_data==2)
246            wait_metadata=true;
247          else
248            wait_mainmetadata=true;
249        }
250        current_content=NULL;
251      }
252      else
253        if(strncasecmp($2,"ComplexData",11)==0 || strncasecmp($2,"LiteralData",10)==0
254           || strncasecmp($2,"ComplexOutput",13)==0 || strncasecmp($2,"LiteralOutput",12)==0
255           || strncasecmp($2,"BoundingBoxOutput",13)==0 || strncasecmp($2,"BoundingBoxData",12)==0){
256          current_data=4;
257          if(wait_metadata==true){
258            if(current_content!=NULL){
259#ifdef DEBUG_SERVICE_CONF
260              fprintf(stderr,"add current_content to current_element->content\n");
261              fprintf(stderr,"LINE %d",__LINE__);
262#endif
263              addMapToMap(&current_element->metadata,current_content);
264              current_element->next=NULL;
265              if($2!=NULL)
266                current_element->format=zStrdup($2);
267             
268              current_element->defaults=NULL;
269              current_element->supported=NULL;
270              freeMap(&current_content);
271              free(current_content);
272            }
273          }else{
274            // No MainMetaData
275            addMapToMap(&current_element->content,current_content);
276            freeMap(&current_content);
277            free(current_content);
278            current_element->metadata=NULL;
279            current_element->next=NULL;
280            if($2!=NULL)
281              current_element->format=zStrdup($2);
282            current_element->defaults=NULL;
283            current_element->supported=NULL;
284          }
285          current_content=NULL;
286          wait_metadata=false;
287        }
288        else
289          if(strncasecmp($2,"Default",7)==0){
290            wait_defaults=true;
291            current_data=5;
292          }
293          else
294            if(strncasecmp($2,"Supported",9)==0){
295              wait_supporteds=true;
296              if(wait_defaults==true){
297                defaultsc++;
298              }
299              current_data=5;
300            }
301#ifdef DEBUG_SERVICE_CONF
302  printf("* Identifiant : %s\n",$2);
303  fflush(stdout);
304#endif
305}
306 ;
307
308// Attributeetoile
309// regle 41
310// une liste qui peut etre vide d'attributs
311// utiliser la récursivité a gauche
312Attributeetoile
313 : Attributeetoile attribute  {}
314 |                                {/* Epsilon */}
315 ;
316
317// attribute
318// regle 41
319// un attribut est compose d'un identifiant
320// d'un "="
321// et d'une définition de chaine de caractere
322// ( "xxx" ou 'xxx' )
323attribute
324 : ID Eq ATTVALUE               
325{
326#ifdef DEBUG_SERVICE_CONF
327  printf ("attribute : %s\n",$1) ;
328#endif
329}
330 ;
331
332// EmptyElemTag
333// regle 44
334// ICI ON DEFINIT NEUTRE
335// on ne renvoie pas de char*
336// parce qu'il n'y a pas de comparaisons a faire
337// avec un identifiant d'une balise jumelle
338EmptyElemTag
339 : INFCAR ID Attributeetoile SLASH SUPCAR       {
340#ifdef DEBUG_SERVICE_CONF
341  fprintf(stderr,"(%s %d)\n",__FILE__,__LINE__);
342#endif
343   if(strncasecmp($2,"Default",7)==0){
344     wait_defaults=false;
345     current_data=previous_data;
346     if(current_element->defaults==NULL){
347       current_element->defaults=(iotype*)malloc(IOTYPE_SIZE);
348       current_element->defaults->content=NULL;
349     }
350     addMapToMap(&current_element->defaults->content,current_content);
351     freeMap(&current_content);
352     free(current_content);
353     current_element->defaults->next=NULL;
354     wait_defaults=false;
355     current_content=NULL;
356     current_element->supported=NULL;
357     current_element->next=NULL;
358   }
359 }
360 ;
361
362// ETag
363// BALISE FERMANTE
364// les separateurs après ID sont filtrés
365ETag
366 : INFCAR SLASH ID SUPCAR
367{
368#ifdef DEBUG_SERVICE_CONF
369  fprintf(stderr,"(%s %d)\n",__FILE__,__LINE__);
370#endif
371  if(strcmp($3,"DataInputs")==0){
372    current_data=1;
373    if(current_content!=NULL){
374      if(current_element->content==NULL){
375        addMapToMap(&current_element->content,current_content);
376      }
377      freeMap(&current_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(&current_element);
392        free(current_element);
393        current_element=NULL;
394      }
395    }
396  }
397  if(strcmp($3,"DataOutputs")==0){
398    current_data=2;
399  }
400  if(strcmp($3,"MetaData")==0){
401    current_data=previous_data;
402  }
403  if(strcmp($3,"ComplexData")==0 || strcmp($3,"LiteralData")==0
404     || strcmp($3,"ComplexOutput")==0 || strcmp($3,"LiteralOutput")==0){
405    current_content=NULL;
406  }
407  if(strcmp($3,"Default")==0){
408    current_data=previous_data;
409    if(current_element->defaults==NULL){
410      current_element->defaults=(iotype*)malloc(IOTYPE_SIZE);
411      current_element->defaults->content=NULL;
412    }
413    addMapToMap(&current_element->defaults->content,current_content);
414    freeMap(&current_content);
415    free(current_content);
416    current_element->defaults->next=NULL;
417    wait_defaults=false;
418    current_content=NULL;
419    current_element->supported=NULL;
420    current_element->next=NULL;
421  }
422  if(strcmp($3,"Supported")==0){
423    current_data=previous_data;
424    if(current_element->supported==NULL){
425      if(current_content!=NULL){
426        current_element->supported=(iotype*)malloc(IOTYPE_SIZE);
427        current_element->supported->content=NULL;
428        addMapToMap(&current_element->supported->content,current_content);
429        freeMap(&current_content);
430        free(current_content);
431        current_element->supported->next=NULL;
432        current_content=NULL;
433      }else{
434        current_element->supported=NULL;
435        current_element->next=NULL;
436      }
437    }
438    else{
439#ifdef DEBUG_SERVICE_CONF
440      fprintf(stderr,"SECOND SUPPORTED FORMAT !!!!\n");
441#endif
442      addMapToIoType(&current_element->supported,current_content);
443      freeMap(&current_content);
444      free(current_content);
445      current_content=NULL;
446#ifdef DEBUG_SERVICE_CONF
447      dumpElements(current_element);
448      fprintf(stderr,"SECOND SUPPORTED FORMAT !!!!\n");
449#endif
450    }
451    current_content=NULL;
452  }
453}
454 ;
455
456//======================================================
457// contentetoile
458//======================================================
459// regle 43
460// ENTRE 2 BALISES
461// entre 2 balises, on peut avoir :
462// --- OUVRANTE CONTENU FERMANTE (recursivement !)
463// --- DU TEXTE quelconque
464// --- COMMENTS
465// --- DES PROCESSES INSTRUCTIONS
466// --- /!\ il peut y avoir une processing instruction invalide ! <?xml
467// --- EPSILON
468// ### et/ou tout ca a la suite en nombre indeterminé
469// ### donc c'est un operateur etoile (*)
470//======================================================
471contentetoile
472: contentetoile element           {}
473 | contentetoile PIERROR                  {srerror("processing instruction <?xml ?> impossible\n");}
474 | contentetoile PI                       {}
475///// on filtre les commentaires | contentetoile comment              {}
476 | contentetoile NEWLINE {/*printf("NEWLINE FOUND !!");*/}
477 | contentetoile pair {}
478 | contentetoile processid {}
479 | contentetoile texteinterbalise         {}
480 | contentetoile CDATA {} 
481 | {/* Epsilon */}
482 ;
483
484// texteinterbalise
485// regle 14
486// DU TEXTE quelconque
487// c'est du CHARDATA
488// il y a eut un probleme avec ID,
489// on a mis des starts conditions,
490// maintenant on croise les ID dans les dbalises
491// et des CHARDATA hors des balises
492texteinterbalise
493 : CHARDATA             {}
494 ;
495
496pair: PAIR { if(debug) fprintf(stderr,"PAIR FOUND !!\n");if(curr_key!=NULL){free(curr_key);curr_key=NULL;} }
497| EPAIR {
498#ifdef DEBUG_SERVICE_CONF
499  fprintf(stderr,"(%s %d)\n",__FILE__,__LINE__);
500  fprintf(stderr,"EPAIR FOUND !! \n");
501  fprintf(stderr,"[%s=>%s]\n",curr_key,$1);
502  fprintf(stderr,"[ZOO: service_conf.y line %d free(%s)]\n",__LINE__,curr_key);
503  dumpMap(current_content);
504  fflush(stderr);
505#endif
506  if($1!=NULL && curr_key!=NULL){
507    if(current_content==NULL){
508#ifdef DEBUG_SERVICE_CONF
509      fprintf(stderr,"[ZOO: service_conf.y line %d free(%s)]\n",__LINE__,curr_key);
510#endif
511      current_content=createMap(curr_key,$1);
512#ifdef DEBUG_SERVICE_CONF
513      fprintf(stderr,"[ZOO: service_conf.y line %d free(%s)]\n",__LINE__,curr_key);
514#endif
515    }
516    else{
517#ifdef DEBUG_SERVICE_CONF
518      dumpMap(current_content);
519      fprintf(stderr,"addToMap(current_content,%s,%s) !! \n",curr_key,$1);
520#endif
521      addToMap(current_content,curr_key,$1);
522#ifdef DEBUG_SERVICE_CONF
523      fprintf(stderr,"addToMap(current_content,%s,%s) end !! \n",curr_key,$1);
524#endif   
525    }
526  }
527#ifdef DEBUG_SERVICE_CONF
528  fprintf(stderr,"[%s=>%s]\n",curr_key,$1);
529  fprintf(stderr,"[ZOO: service_conf.y line %d free(%s)]\n",__LINE__,curr_key);
530  dumpMap(current_content);
531  fflush(stderr);
532#endif
533  if(curr_key!=NULL){
534    free(curr_key);
535    curr_key=NULL;
536  }
537  }
538| SPAIR  { if(curr_key!=NULL) {free(curr_key);curr_key=NULL;} if($1!=NULL) curr_key=zStrdup($1);if(debug) fprintf(stderr,"SPAIR FOUND !!\n"); }
539 ;
540
541
542processid
543: ANID  {
544#ifdef DEBUG_SERVICE_CONF
545  fprintf(stderr,"(%s %d)\n",__FILE__,__LINE__);
546#endif
547  if(data==-1){
548    data=1;
549    if($1!=NULL){
550      char *cen=zStrdup($1);
551      my_service->name=(char*)malloc((strlen(cen)-1)*sizeof(char*));
552      cen[strlen(cen)-1]=0;
553      cen+=1;
554      sprintf(my_service->name,"%s",cen);
555      cen-=1;
556      free(cen);
557      my_service->content=NULL;
558      my_service->metadata=NULL;
559      my_service->inputs=NULL;
560      my_service->outputs=NULL;
561    }
562  } else {
563    if(current_data==1){
564      if(my_service->content!=NULL && current_element->name!=NULL){
565        if(my_service->inputs==NULL){
566          my_service->inputs=dupElements(current_element);
567          my_service->inputs->next=NULL;
568          tmp_count++;
569        }
570        else{
571          addToElements(&my_service->inputs,current_element);
572        }
573#ifdef DEBUG_SERVICE_CONF
574        fprintf(stderr,"(%s %d)FREE current_element (after adding to allread existing inputs)",__FILE__,__LINE__);
575        dumpElements(current_element);
576        fprintf(stderr,"(%s %d)FREE current_element (after adding to allread existing inputs)",__FILE__,__LINE__);
577        dumpElements(my_service->inputs);
578#endif
579        freeElements(&current_element);
580        free(current_element);
581        current_element=NULL;
582#ifdef DEBUG_SERVICE_CONF
583        fprintf(stderr,"(DATAINPUTS - 489) ALLOCATE current_element\n");
584#endif
585        current_element=(elements*)malloc(ELEMENTS_SIZE);
586        current_element->name=NULL;
587        current_element->content=NULL;
588        current_element->metadata=NULL;
589        current_element->format=NULL;
590        current_element->defaults=NULL;
591        current_element->supported=NULL;
592        current_element->next=NULL;
593      }
594      if(current_element->name==NULL){
595#ifdef DEBUG_SERVICE_CONF
596        fprintf(stderr,"NAME IN %s (current - %s)\n",
597                $1,current_element->name);
598#endif
599        wait_inputs=true;
600#ifdef DEBUG_SERVICE_CONF
601        fprintf(stderr,"(DATAINPUTS - 501) SET NAME OF current_element\n");
602#endif
603        if($1!=NULL){
604          char *cen=zStrdup($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);
611#ifdef DEBUG_SERVICE_CONF
612          fprintf(stderr,"NAME IN %s (current - %s)\n",$1,current_element->name);
613#endif
614          current_element->content=NULL;
615          current_element->metadata=NULL;
616          current_element->format=NULL;
617          current_element->defaults=NULL;
618          current_element->supported=NULL;
619          current_element->next=NULL;
620#ifdef DEBUG_SERVICE_CONF
621          fprintf(stderr,"NAME IN %s (current - %s)\n",$1,current_element->name);
622#endif
623        }
624      }
625    }
626    else
627      if(current_data==2){
628        wait_outputs=1;
629        if(wait_inputs){
630          if(current_element!=NULL && current_element->name!=NULL){
631            if(my_service->outputs==NULL){
632              my_service->outputs=dupElements(current_element);
633              my_service->outputs->next=NULL;
634            }
635            else{
636#ifdef DEBUG_SERVICE_CONF
637              fprintf(stderr,"LAST NAME IN %s (current - %s)\n",$1,current_element->name);
638#endif
639              addToElements(&my_service->outputs,current_element);
640            }
641#ifdef DEBUG_SERVICE_CONF
642            dumpElements(current_element);
643            fprintf(stderr,"(DATAOUTPUTS) FREE current_element %s %i\n",__FILE__,__LINE__);
644#endif
645            freeElements(&current_element);
646            free(current_element);
647            current_element=NULL;
648#ifdef DEBUG_SERVICE_CONF
649            fprintf(stderr,"(DATAOUTPUTS -%d) ALLOCATE current_element %s \n",__LINE__,__FILE__);
650#endif
651            current_element=(elements*)malloc(ELEMENTS_SIZE);
652            current_element->name=NULL;
653            current_element->content=NULL;
654            current_element->metadata=NULL;
655            current_element->format=NULL;
656            current_element->defaults=NULL;
657            current_element->supported=NULL;
658            current_element->next=NULL;
659          }
660          if(current_element->name==NULL){
661#ifdef DEBUG_SERVICE_CONF
662            fprintf(stderr,"NAME OUT %s\n",$1);
663            fprintf(stderr,"(DATAOUTPUTS - %d) SET NAME OF current_element\n",__LINE__);
664#endif
665            if($1!=NULL){
666              char *cen=zStrdup($1);
667              current_element->name=(char*)malloc((strlen(cen)-1)*sizeof(char));
668              cen[strlen(cen)-1]=0;
669              cen+=1;
670              sprintf(current_element->name,"%s",cen);
671              cen-=1;
672              free(cen);
673              current_element->content=NULL;
674              current_element->metadata=NULL;
675              current_element->format=NULL;
676              current_element->defaults=NULL;
677              current_element->supported=NULL;
678              current_element->next=NULL;
679            }
680          }
681
682          current_content=NULL;
683        }
684        else
685          if(current_element!=NULL && current_element->name!=NULL){
686            if(my_service->outputs==NULL)
687              my_service->outputs=dupElements(current_element);
688            else
689              addToElements(&my_service->outputs,current_element);
690#ifdef DEBUG_SERVICE_CONF
691            fprintf(stderr,"ADD TO OUTPUTS Elements\n");
692            dupElements(current_element);
693#endif
694            freeElements(&current_element);
695            free(current_element);
696            current_element=NULL;
697            current_element=(elements*)malloc(ELEMENTS_SIZE);
698            char *cen=zStrdup($1);
699            current_element->name=(char*)malloc((strlen(cen)-1)*sizeof(char));
700            cen[strlen(cen)-1]=0;
701            cen+=1;
702            sprintf(current_element->name,"%s",cen);
703            cen-=1;
704            free(cen);
705            current_element->content=NULL;
706            current_element->metadata=NULL;
707            current_element->format=NULL;
708            current_element->defaults=NULL;
709            current_element->supported=NULL;
710            current_element->next=NULL;
711          }
712          else{
713#ifdef DEBUG_SERVICE_CONF
714            fprintf(stderr,"NAME OUT %s\n",$1);
715            fprintf(stderr,"(DATAOUTPUTS - %d) SET NAME OF current_element %s\n",__LINE__,$1);
716#endif
717            if($1!=NULL){
718              char *cen=zStrdup($1);
719              current_element->name=(char*)malloc((strlen(cen))*sizeof(char*));
720              cen[strlen(cen)-1]=0;
721#ifdef DEBUG
722              fprintf(stderr,"tmp %s\n",cen);
723#endif
724              cen+=1;
725              sprintf(current_element->name,"%s",cen);
726              cen-=1;
727              free(cen);
728              current_element->content=NULL;
729              current_element->metadata=NULL;
730              current_element->format=NULL;
731              current_element->defaults=NULL;
732              current_element->supported=NULL;
733              current_element->next=NULL;
734            }
735          }
736        wait_inputs=false;
737        wait_outputs=1;
738        //wait_outputs=true;
739      }
740  }
741 }
742 ;
743
744%%
745
746/**
747 * Print on stderr the message and the line number of the error which occured.
748 *
749 * @param s the error message
750 */
751void srerror(const char *s)
752{
753  if(debug)
754    fprintf(stderr,"\nligne %d : %s\n",srlineno,s);
755}
756
757/**
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
764 */
765int getServiceFromFile(maps* conf,const char* file,service** service){
766  if(current_content!=NULL){
767    freeMap(&current_content);
768    free(current_content);
769    current_content=NULL;
770  }
771#ifdef DEBUG_SERVICE_CONF
772  fprintf(stderr,"(STARTING)FREE current_element\n");
773#endif
774  if(current_element!=NULL){
775    freeElements(&current_element);
776    free(current_element);
777    current_element=NULL;
778  }
779  my_service=NULL;
780
781  wait_maincontent=true;
782  wait_mainmetadata=false;
783  wait_metadata=false;
784  wait_inputs=false;
785  wait_defaults=false;
786  wait_supporteds=false;
787  wait_outputs=-1;
788  wait_data=false;
789  data=-1;
790  previous_data=1;
791  current_data=0;
792 
793  my_service=*service;
794
795  srin = fopen(file,"r");
796  if (srin==NULL){
797    setMapInMaps(conf,"lenv","message","file not found");
798    return -1;
799  }
800
801  int resultatYYParse = srparse() ;
802
803#ifdef DEBUG_SERVICE_CONF
804  fprintf(stderr,"RESULT: %d %d\n",resultatYYParse,wait_outputs);
805  dumpElements(current_element);
806#endif
807  if(wait_outputs && current_element!=NULL && current_element->name!=NULL){
808    if(my_service->outputs==NULL){ 
809#ifdef DEBUG_SERVICE_CONF
810      fprintf(stderr,"(DATAOUTPUTS - %d) DUP current_element\n",__LINE__);
811#endif
812      my_service->outputs=dupElements(current_element);
813      my_service->outputs->next=NULL;
814    }
815    else{
816#ifdef DEBUG_SERVICE_CONF
817      fprintf(stderr,"(DATAOUTPUTS - %d) COPY current_element\n",__LINE__);
818#endif
819      addToElements(&my_service->outputs,current_element);
820    }
821#ifdef DEBUG_SERVICE_CONF
822    fprintf(stderr,"(DATAOUTPUTS - %d) FREE current_element\n",__LINE__);
823#endif
824    freeElements(&current_element);
825    free(current_element);
826    current_element=NULL;
827#ifdef DEBUG_SERVICE_CONF
828    fprintf(stderr,"(DATAOUTPUTS - %d) FREE current_element\n",__LINE__);
829#endif
830  }
831  if(current_element!=NULL){
832    freeElements(&current_element);
833    free(current_element);
834    current_element=NULL;
835  }
836  int contentOnly=false;
837  if(current_content!=NULL){
838    if(my_service->content==NULL){
839      addMapToMap(&my_service->content,current_content);
840      contentOnly=true;
841      wait_maincontent=false;
842    }
843    freeMap(&current_content);
844    free(current_content);
845    current_content=NULL;
846  }
847  fclose(srin);
848#ifdef DEBUG_SERVICE_CONF
849  dumpService(my_service);
850#endif
851  if(wait_maincontent==true || (contentOnly==false && ((!wait_outputs && current_data==2 && my_service->outputs==NULL) || my_service==NULL || my_service->name==NULL || my_service->content==NULL))){
852    setMapInMaps(conf,"lenv","message",srlval.chaine);
853#ifndef WIN32
854    srlex_destroy();
855#endif
856    return -1;
857  }
858  else
859    *service=my_service;
860
861#ifndef WIN32
862  srlex_destroy();
863#endif
864  return resultatYYParse;
865}
Note: See TracBrowser for help on using the repository browser.

Search

ZOO Sponsors

http://www.zoo-project.org/trac/chrome/site/img/geolabs-logo.pnghttp://www.zoo-project.org/trac/chrome/site/img/neogeo-logo.png http://www.zoo-project.org/trac/chrome/site/img/apptech-logo.png http://www.zoo-project.org/trac/chrome/site/img/3liz-logo.png http://www.zoo-project.org/trac/chrome/site/img/gateway-logo.png

Become a sponsor !

Knowledge partners

http://www.zoo-project.org/trac/chrome/site/img/ocu-logo.png http://www.zoo-project.org/trac/chrome/site/img/gucas-logo.png http://www.zoo-project.org/trac/chrome/site/img/polimi-logo.png http://www.zoo-project.org/trac/chrome/site/img/fem-logo.png http://www.zoo-project.org/trac/chrome/site/img/supsi-logo.png http://www.zoo-project.org/trac/chrome/site/img/cumtb-logo.png

Become a knowledge partner

Related links

http://zoo-project.org/img/ogclogo.png http://zoo-project.org/img/osgeologo.png