source: trunk/zoo-kernel/service_conf.y @ 110

Last change on this file since 110 was 104, checked in by djay, 13 years ago

Fix main MetaData? gesture.

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