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

Last change on this file since 9 was 9, checked in by djay, 14 years ago

Update of both ZOO Kernel and ZOO Services (ogr base-vect-ops ServicesProvider?).
All the ZCFG files have been corrected to remove all references to wrong metadata (Test = Demo) to avoid validation issues.
Main Memory leaks has been removed from this version.
Addition of the Simplify Service in the C ogr base-vect-ops ServicesProvider? and addition of the Python version (without Simplify).
Update of the configure.ac and Makefile.in to follow dicussions on the mailing list and ensure to use our cgic206 and not another one, path to our cgic library is now directly in the Makefile.in file.
Accept the "-" character to name inputs, to solve issue on GRASS 7 integration.
Addition of the extension keyword for ZCFG file to be able to store resulting outputs in a file name using the extension suffix.
This version after a testing period shall be considerate as 1.0.1 version of the ZOO Project.

File size: 23.3 KB
Line 
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>
15  //#include <vector>
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);
67extern int srlex_destroy(void);
68
69//vector<char*> lattribute;
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  /*if (strcasecmp($1,$3) != 0)
136    {
137      fprintf(stderr,"Opening and ending tag mismatch\n  ::details : tag '%s' et '%s' \n",$1,$3);
138      //lattribute.clear();
139      //return 1;
140      }*/
141  free($3);
142}
143// pour neutre
144// on a rien a faire, meme pas renvoyer l identificateur de balise
145// vu qu'il n y a pas de comparaison d'identificateurs avec un balise jumelle .
146 | EmptyElemTag          {}
147 ;
148//======================================================
149// STag
150//======================================================
151// regle 40
152// BALISE OUVRANTE
153// on est obligé de faire appel a infcar et supcar
154// pour acceder aux start conditions DANSBALISE et INITIAL
155//======================================================
156STag
157: INFCAR ID Attributeetoile SUPCAR
158{
159  /* l'astuce consiste a vider le contenu du vector ici !! */
160  /* parce que cet element est reconnu AVANT la balise fermante */
161  /* et APRES l'analyse des eventuelles balises internes ou successeur */
162  //lattribute.clear();
163
164  if(my_service->content==NULL){
165#ifdef DEBUG_SERVICE_CONF
166    fprintf(stderr,"NO CONTENT\n");
167#endif
168    addMapToMap(&my_service->content,current_content);
169    freeMap(&current_content);
170    free(current_content);
171    current_content=NULL;
172    my_service->metadata=NULL;
173    wait_maincontent=false;
174  }
175
176  if(strncasecmp($2,"DataInputs",10)==0){
177    if(wait_mainmetadata==true){
178      addMapToMap(&my_service->metadata,current_content);
179      freeMap(&current_content);
180      free(current_content);
181      current_content=NULL;
182    }
183    if(current_element==NULL){
184#ifdef DEBUG_SERVICE_CONF
185      fprintf(stderr,"(DATAINPUTS - 184) FREE current_element\n");
186#endif
187      freeElements(&current_element);
188      free(current_element);
189      current_element=NULL;
190#ifdef DEBUG_SERVICE_CONF
191      fprintf(stderr,"(DATAINPUTS - 186) ALLOCATE current_element\n");
192#endif
193      current_element=NULL;
194      current_element=(elements*)malloc(ELEMENTS_SIZE);
195      current_element->name=NULL;
196      current_element->content=NULL;
197      current_element->metadata=NULL;
198      current_element->format=NULL;
199      current_element->defaults=NULL;
200      current_element->supported=NULL;
201      current_element->next=NULL;
202    }
203    wait_inputs=true;
204    current_data=1;
205    previous_data=1;
206  }
207  else
208    if(strncasecmp($2,"DataOutputs",11)==0){
209      if(wait_inputs==true){
210#ifdef DEBUG_SERVICE_CONF
211        fprintf(stderr,"(DATAOUTPUTS) DUP INPUTS current_element\n");
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){
219          my_service->inputs=dupElements(current_element);
220          my_service->inputs->next=NULL;
221        }
222        else
223          addToElements(&my_service->inputs,current_element);
224#ifdef DEBUG_SERVICE_CONF
225        fprintf(stderr,"CURRENT_ELEMENT\n");
226        dumpElements(current_element);
227        fprintf(stderr,"SERVICE INPUTS\n");
228        dumpElements(my_service->inputs);
229        fprintf(stderr,"(DATAOUTPUTS) FREE current_element\n");
230#endif
231        freeElements(&current_element);
232        free(current_element);
233        current_element=NULL;
234        wait_inputs=false;
235      }
236      if(current_element==NULL){
237#ifdef DEBUG_SERVICE_CONF
238        fprintf(stderr,"(DATAOUTPUTS - 206) ALLOCATE current_element (%s)\n",$2);
239#endif
240        current_element=(elements*)malloc(ELEMENTS_SIZE);
241        current_element->name=NULL;
242        current_element->content=NULL;
243        current_element->metadata=NULL;
244        current_element->format=NULL;
245        current_element->defaults=NULL;
246        current_element->supported=NULL;
247        current_element->next=NULL;
248      }
249      wait_outputs=true;
250      current_data=2;
251      previous_data=1;
252    }
253    else
254      if(strncasecmp($2,"MetaData",8)==0){
255        current_data=3;
256        if(current_element!=NULL){
257          wait_metadata=true;
258#ifdef DEBUG_SERVICE_CONF
259          fprintf(stderr,"add current_content to current_element->content\n");
260          fprintf(stderr,"LINE 247");
261#endif
262          addMapToMap(&current_element->content,current_content);
263          freeMap(&current_content);
264          free(current_content);
265        }
266        else{
267          wait_mainmetadata=true;
268        }
269        current_content=NULL;
270      }
271      else
272        if(strncasecmp($2,"ComplexData",11)==0 || strncasecmp($2,"LiteralData",10)==0
273           || strncasecmp($2,"ComplexOutput",13)==0 || strncasecmp($2,"LiteralOutput",12)==0){
274          current_data=4;
275          if(wait_metadata==true){
276            if(current_content!=NULL){
277              addMapToMap(&current_element->metadata,current_content);
278              current_element->next=NULL;
279              current_element->format=$2;
280              current_element->defaults=NULL;
281              current_element->supported=NULL;
282              freeMap(&current_content);
283              free(current_content);
284            }
285          }else{
286            // No MainMetaData
287            addMapToMap(&current_element->content,current_content);
288            freeMap(&current_content);
289            free(current_content);
290            current_element->metadata=NULL;
291            current_element->next=NULL;
292            current_element->format=$2;
293            current_element->defaults=NULL;
294            current_element->supported=NULL;
295          }
296          current_content=NULL;
297          wait_metadata=false;
298        }
299        else
300          if(strncasecmp($2,"Default",7)==0){
301            wait_defaults=true;
302            current_data=5;
303          }
304          else
305            if(strncasecmp($2,"Supported",9)==0){
306              wait_supporteds=true;
307              if(wait_defaults==true){
308                defaultsc++;
309                freeMap(&current_content);
310                current_content=NULL;
311              }
312              current_data=5;
313            }
314#ifdef DEBUG_SERVICE_CONF
315  printf("* Identifiant : %s\n",$2);
316#endif
317  /* et on renvoie l'identifiant de balise afin de pouvoir le comparer */
318  /* avec la balise jumelle fermante ! */
319  $$ = $2 ;
320  /*if($2!=NULL)
321    free($2);*/
322}
323 ;
324//======================================================
325// Attributeetoile
326//======================================================
327// regle 41
328// une liste qui peut etre vide d'attributs
329// utiliser la récursivité a gauche
330//======================================================
331Attributeetoile
332 : Attributeetoile attribute  {}
333 |                                {/* Epsilon */}
334 ;
335//======================================================
336// attribute
337//======================================================
338// regle 41
339// un attribut est compose d'un identifiant
340// d'un "="
341// et d'une définition de chaine de caractere
342// ( "xxx" ou 'xxx' )
343//======================================================
344attribute
345 : ID Eq ATTVALUE               
346{
347        // on verifie que les attributst ne sont pas en double
348        // sinon on ajoute au vector
349#ifdef DEBUG_SERVICE_CONF
350  printf ("attribute : %s\n",$1) ;
351#endif
352  /*for(int i=0;i < lattribute.size(); i++)
353    {
354      if (strcmp($1,lattribute.at(i)) == 0)
355        {
356          fprintf (stderr,"attributs identiques : %d -- %s , %s",i,lattribute.at(i),$1) ;
357        }
358    }
359    lattribute.push_back($1);*/
360  free($1);
361}
362 ;
363//======================================================
364// EmptyElemTag
365//======================================================
366// regle 44
367// ICI ON DEFINIT NEUTRE
368// on ne renvoie pas de char*
369// parce qu'il n'y a pas de comparaisons a faire
370// avec un identifiant d'une balise jumelle
371//======================================================
372EmptyElemTag
373 : INFCAR ID Attributeetoile SLASH SUPCAR       {/*lattribute.clear();/* voir Stag */}
374 ;
375//======================================================
376// ETag
377//======================================================
378// regle 42
379// BALISE FERMANTE
380// les separateurs après ID sont filtrés
381//======================================================
382ETag
383 : INFCAR SLASH ID SUPCAR
384{
385  if(strcmp($3,"DataInputs")==0){
386    current_data=1;
387  }
388  if(strcmp($3,"DataOutputs")==0){
389    current_data=2;
390  }
391  if(strcmp($3,"MetaData")==0){
392    current_data=previous_data;
393  }
394  if(strcmp($3,"ComplexData")==0 || strcmp($3,"LiteralData")==0
395     || strcmp($3,"ComplexOutput")==0 || strcmp($3,"LiteralOutput")==0){
396    current_content=NULL;
397  }
398  if(strcmp($3,"Default")==0){
399    current_data=previous_data;
400    if(current_element->defaults==NULL){
401      current_element->defaults=(iotype*)malloc(IOTYPE_SIZE);
402      current_element->defaults->content=NULL;
403    }
404    addMapToMap(&current_element->defaults->content,current_content);
405    freeMap(&current_content);
406    free(current_content);
407    current_element->defaults->next=NULL;
408    wait_defaults=false;
409    current_content=NULL;
410    current_element->supported=NULL;
411  }
412  if(strcmp($3,"Supported")==0){
413    current_data=previous_data;
414    if(current_element->supported==NULL){
415      //addMapToIoType(&current_element->supported,current_content);
416      current_element->supported=(iotype*)malloc(IOTYPE_SIZE);
417      current_element->supported->content=NULL;
418      addMapToMap(&current_element->supported->content,current_content);
419      freeMap(&current_content);
420      free(current_content);
421      current_element->supported->next=NULL;
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(&current_element->supported,current_content);
430      /*iotype* iotmp=*(&current_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(&current_content);
444      free(current_content);
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
453    }
454    current_content=NULL;
455  }
456  /* on renvoie l'identifiant de la balise pour pouvoir comparer les 2 */
457  /* /!\ une balise fermante n'a pas d'attributs (c.f. : W3C) */
458  $$ = $3;
459}
460 ;
461//======================================================
462// contentetoile
463//======================================================
464// regle 43
465// ENTRE 2 BALISES
466// entre 2 balises, on peut avoir :
467// --- OUVRANTE CONTENU FERMANTE (recursivement !)
468// --- DU TEXTE quelconque
469// --- COMMENTS
470// --- DES PROCESSES INSTRUCTIONS
471// --- /!\ il peut y avoir une processing instruction invalide ! <?xml
472// --- EPSILON
473// ### et/ou tout ca a la suite en nombre indeterminé
474// ### donc c'est un operateur etoile (*)
475//======================================================
476contentetoile
477: contentetoile element           {}
478 | contentetoile PIERROR                  {srerror("processing instruction <?xml ?> impossible\n");}
479 | contentetoile PI                       {}
480///// on filtre les commentaires | contentetoile comment              {}
481 | contentetoile NEWLINE {/*printf("NEWLINE FOUND !!");*/}
482 | contentetoile pair {}
483 | contentetoile processid {}
484 | contentetoile texteinterbalise         {}
485 | contentetoile CDATA {} 
486 | {/* Epsilon */}
487 ;
488//======================================================
489// texteinterbalise
490//======================================================
491// regle 14
492// DU TEXTE quelconque
493// c'est du CHARDATA
494// il y a eut un probleme avec ID,
495// on a mis des starts conditions,
496// maintenant on croise les ID dans les dbalises
497// et des CHARDATA hors des balises
498//======================================================
499texteinterbalise
500 : CHARDATA             {}
501 ;
502//======================================================
503
504pair: PAIR {  if(debug) fprintf(stderr,"PAIR FOUND !!\n");if(curr_key!=NULL){free(curr_key);curr_key=NULL;} }
505| EPAIR {
506#ifdef DEBUG_SERVICE_CONF
507    fprintf(stderr,"EPAIR FOUND !! \n");
508    fprintf(stderr,"[%s=>%s]\n",curr_key,$1);
509    fprintf(stderr,"[ZOO: service_conf.y line 482 free(%s)]\n",curr_key);
510    dumpMap(current_content);
511    fflush(stderr);
512#endif
513  if(current_content==NULL){
514#ifdef DEBUG_SERVICE_CONF
515    fprintf(stderr,"[ZOO: service_conf.y line 482 free(%s)]\n",curr_key);
516#endif
517    current_content=createMap(curr_key,$1);
518#ifdef DEBUG_SERVICE_CONF
519    fprintf(stderr,"[ZOO: service_conf.y line 482 free(%s)]\n",curr_key);
520#endif
521    //current_content->next=NULL;
522  }
523  else{
524#ifdef DEBUG_SERVICE_CONF
525    dumpMap(current_content);
526    fprintf(stderr,"addToMap(current_content,%s,%s) !! \n",curr_key,$1);
527#endif
528    addToMap(current_content,curr_key,$1);
529#ifdef DEBUG_SERVICE_CONF
530    fprintf(stderr,"addToMap(current_content,%s,%s) end !! \n",curr_key,$1);
531#endif   
532  }
533#ifdef DEBUG_SERVICE_CONF
534  fprintf(stderr,"EPAIR FOUND !! \n");
535  fprintf(stderr,"[%s=>%s]\n",curr_key,$1);
536  fprintf(stderr,"[ZOO: service_conf.y line 505 free(%s)]\n",curr_key);
537  fflush(stderr);
538#endif
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"); }
545 ;
546
547
548processid
549: ANID  {
550  if(data==-1){
551    data=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);
559    my_service->content=NULL;
560    my_service->metadata=NULL;
561    my_service->inputs=NULL;
562    my_service->outputs=NULL;
563  } else {
564    if(current_data==1){
565      if(my_service->content!=NULL && current_element->name!=NULL){
566        if(my_service->inputs==NULL){
567          my_service->inputs=dupElements(current_element);
568          my_service->inputs->next=NULL;
569          tmp_count++;
570        }
571        else{
572          addToElements(&my_service->inputs,current_element);
573        }
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__);
578        dumpElements(my_service->inputs);
579#endif
580        freeElements(&current_element);
581        free(current_element);
582        current_element=NULL;
583#ifdef DEBUG_SERVICE_CONF
584        fprintf(stderr,"(DATAINPUTS - 489) ALLOCATE current_element\n");
585#endif
586        current_element=(elements*)malloc(ELEMENTS_SIZE);
587        current_element->name=NULL;
588        current_element->content=NULL;
589        current_element->metadata=NULL;
590        current_element->format=NULL;
591        current_element->defaults=NULL;
592        current_element->supported=NULL;
593        current_element->next=NULL;
594      }
595      if(current_element->name==NULL){
596#ifdef DEBUG_SERVICE_CONF
597        fprintf(stderr,"NAME IN %s (current - %s)\n",
598                $1,current_element->name);
599#endif
600        wait_inputs=true;
601#ifdef DEBUG_SERVICE_CONF
602        fprintf(stderr,"(DATAINPUTS - 501) SET NAME OF current_element\n");
603#endif
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);
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    else
626      if(current_data==2){
627        if(wait_inputs==true){
628          fprintf(stderr,"dup INPUTS\n");
629          if(current_element->name!=NULL){
630            if(my_service->inputs==NULL){
631              my_service->inputs=dupElements(current_element);
632              my_service->inputs->next=NULL;
633            }
634            else{
635#ifdef DEBUG_SERVICE_CONF
636              fprintf(stderr,"LAST NAME IN %s (current - %s)\n",$1,current_element->name);
637#endif
638              addToElements(&my_service->inputs,current_element);
639            }
640#ifdef DEBUG_SERVICE_CONF
641            dumpElements(current_element);
642            fprintf(stderr,"(DATAOUTPUTS) FREE current_element %s %i\n",__FILE__,__LINE__);
643#endif
644            freeElements(&current_element);
645            free(current_element);
646            current_element=NULL;
647#ifdef DEBUG_SERVICE_CONF
648            fprintf(stderr,"(DATAOUTPUTS) ALLOCATE current_element %s %i\n",__FILE__,__LINE__);
649#endif
650            current_element=(elements*)malloc(ELEMENTS_SIZE);
651            current_element->name=NULL;
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          }
659          if(current_element->name==NULL){
660#ifdef DEBUG_SERVICE_CONF
661            fprintf(stderr,"NAME OUT %s\n",$1);
662            fprintf(stderr,"(DATAOUTPUTS - 545) SET NAME OF current_element\n");
663#endif
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);
671            current_element->content=NULL;
672            current_element->metadata=NULL;
673            current_element->format=NULL;
674            current_element->defaults=NULL;
675            current_element->supported=NULL;
676            current_element->next=NULL;
677          }
678          wait_inputs=false;
679          dumpMap(current_content);
680          current_content=NULL;
681        }
682        else
683          if(current_element->name==NULL){
684#ifdef DEBUG_SERVICE_CONF
685            fprintf(stderr,"NAME OUT %s\n",$1);
686            fprintf(stderr,"(DATAOUTPUTS - 545) SET NAME OF current_element\n");
687#endif
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);
698            current_element->content=NULL;
699            current_element->metadata=NULL;
700            current_element->format=NULL;
701            current_element->defaults=NULL;
702            current_element->supported=NULL;
703            current_element->next=NULL;
704          }
705        wait_outputs=true;
706      }
707  }
708 }
709 ;
710
711%%
712
713// srerror
714//======================================================
715/* fonction qui affiche l erreur si il y en a une */
716//======================================================
717void srerror(char *s)
718{
719  if(debug)
720    fprintf(stderr,"\nligne %d : %s\n",srlineno,s);
721}
722
723/**
724 * getServiceFromFile :
725 * set service given as second parameter with informations extracted from the
726 * definition file.
727 */
728int getServiceFromFile(char* file,service** service){
729
730  freeMap(&previous_content);
731  previous_content=NULL;
732  freeMap(&current_content);
733  current_content=NULL;
734  freeMap(&scontent);
735#ifdef DEBUG_SERVICE_CONF
736  fprintf(stderr,"(STARTING)FREE current_element\n");
737#endif
738  freeElements(&current_element);
739  current_element=NULL;
740#ifdef DEBUG_SERVICE_CONF
741  fprintf(stderr,"(STARTING)FREE my_service\n");
742#endif
743  //freeService(&my_service);
744  //free(my_service);
745#ifdef DEBUG_SERVICE_CONF
746  fprintf(stderr,"(STARTING)FREE my_service done\n");
747#endif
748  my_service=NULL;
749  scontent=NULL;
750
751  wait_maincontent=true;
752  wait_mainmetadata=false;
753  wait_metadata=false;
754  wait_inputs=false;
755  wait_defaults=false;
756  wait_supporteds=false;
757  wait_outputs=false;
758  wait_data=false;
759  data=-1;
760  previous_data=1;
761  current_data=0;
762 
763  my_service=*service;
764
765  srin = fopen(file,"r");
766  if (srin==NULL){
767    fprintf(stderr,"error : le fichier specifie n'existe pas ou n'est pas accessible en lecture\n") ;
768    return -1;
769  }
770
771  int resultatYYParse = srparse() ;
772 
773  if(wait_outputs==true && current_element->name!=NULL){
774    if(my_service->outputs==NULL){     
775#ifdef DEBUG_SERVICE_CONF
776      fprintf(stderr,"(DATAOUTPUTS - 623) DUP current_element\n");
777#endif
778      my_service->outputs=dupElements(current_element);
779      my_service->outputs->next=NULL;
780      freeElements(&current_element);
781      free(current_element);
782      current_element=NULL;
783    }
784    else{
785#ifdef DEBUG_SERVICE_CONF
786      fprintf(stderr,"(DATAOUTPUTS - 628) COPY current_element\n");
787#endif
788      addToElements(&my_service->outputs,current_element);
789    }
790#ifdef DEBUG_SERVICE_CONF
791    fprintf(stderr,"(DATAOUTPUTS - 631) FREE current_element\n");
792#endif
793    freeElements(&current_element);
794    free(current_element);
795    current_element=NULL;
796  }
797  if(current_element!=NULL){
798    freeElements(&current_element);
799    fprintf(stderr,"LINE 709");
800    free(current_element);
801    current_element=NULL;
802  }
803  if(current_content!=NULL){
804    freeMap(&current_content);
805    fprintf(stderr,"LINE 715");
806    free(current_content);
807    current_content=NULL;
808  }
809  fclose(srin);
810#ifdef DEBUG_SERVICE_CONF
811  dumpService(my_service);
812#endif
813  *service=my_service;
814
815  srlex_destroy();
816  return resultatYYParse;
817}
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