Ignore:
Timestamp:
Apr 23, 2014, 3:05:01 AM (10 years ago)
Author:
djay
Message:

Add the optional YAML ZCFG support #4 and the zcfg2yaml converter. Return error messages that enable the service provider to quickly identify the root cause of errors due to configuration file syntax #90. Fix logic in addMapToMap #91. Enable multiple range definition using default and supported blocks. Add the lastest revision number in version.h (available from Python ZOO-API as zoo.VERSION).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/zoo-project/zoo-kernel/service.h

    r458 r465  
    8282#define SHMSZ     27
    8383
     84#include "version.h"
    8485
    8586#ifdef DEBUG_STACK
     
    133134  static void _dumpMap(map* t){
    134135    if(t!=NULL){
    135       fprintf(stderr,"[%s] => [%s] \n",t->name,t->value);
     136      fprintf(stderr,"%s: %s\n",t->name,t->value);
    136137      fflush(stderr);
    137138        }else{
     
    437438    map* tmp=mi;
    438439    map* _cursor=*mo;
    439     if(tmp==NULL){
    440       if(_cursor!=NULL){
    441         while(_cursor!=NULL)
    442           _cursor=_cursor->next;
    443         _cursor=NULL;
    444       }else
    445         *mo=NULL;
    446     }
    447440    while(tmp!=NULL){
    448441      if(_cursor==NULL){
    449         if(*mo==NULL)
    450           *mo=createMap(tmp->name,tmp->value);
    451         else
    452           addToMap(*mo,tmp->name,tmp->value);
     442        *mo=createMap(tmp->name,tmp->value);
     443        (*mo)->next=NULL;
    453444      }
    454445      else{
     
    457448        dumpMap(_cursor);
    458449#endif
    459         while(_cursor!=NULL)
     450        while(_cursor->next!=NULL)
    460451          _cursor=_cursor->next;
    461         _cursor=createMap(tmp->name,tmp->value);
    462         _cursor->next=NULL;
    463       }
     452        map* tmp1=getMap(_cursor,tmp->name);
     453        if(tmp1==NULL)
     454          _cursor->next=createMap(tmp->name,tmp->value);
     455        else{
     456          free(tmp1->value);
     457          tmp1->value=zStrdup(tmp->value);
     458        }
     459      }
     460      _cursor=*mo;
    464461      tmp=tmp->next;
    465462#ifdef DEBUG
     
    568565      if(_cursor==NULL){
    569566        *mo=dupMaps(&mi);
    570         (*mo)->next=NULL;
    571567      }
    572568      else{
     569        maps* tmp1=getMaps(*mo,tmp->name);
    573570        while(_cursor->next!=NULL)
    574571          _cursor=_cursor->next;
    575         _cursor->next=dupMaps(&tmp);
     572        if(tmp1==NULL)
     573          _cursor->next=dupMaps(&tmp);
     574        else
     575          addMapToMap(&tmp1->content,tmp->content);
     576        _cursor=*mo;
    576577      }
    577578      tmp=tmp->next;
     
    603604    else
    604605      sprintf(tmp,"%s",key);
    605     map* tmpSize=getMapArray(m,"size",index);
     606    map* tmpSize=getMapArray(m,(char*)"size",index);
    606607    if(tmpSize!=NULL && strncasecmp(key,"value",5)==0){
    607608#ifdef DEBUG
    608609      fprintf(stderr,"%s\n",tmpSize->value);
    609610#endif
    610       map* ptr=getMapOrFill(m,tmp,"");
     611      map* ptr=getMapOrFill(m,tmp,(char *)"");
    611612      free(ptr->value);
    612613      ptr->value=(char*)malloc((atoi(tmpSize->value)+1)*sizeof(char));
     
    618619
    619620  static map* getMapType(map* mt){
    620     map* tmap=getMap(mt,"mimeType");
     621    map* tmap=getMap(mt,(char *)"mimeType");
    621622    if(tmap==NULL){
    622623      tmap=getMap(mt,"dataType");
     
    646647
    647648    char *tmpV[8]={
    648       "size",
    649       "value",
    650       "uom",
    651       "Reference",
    652       "xlink:href",
     649      (char*)"size",
     650      (char*)"value",
     651      (char*)"uom",
     652      (char*)"Reference",
     653      (char*)"xlink:href",
    653654      typ,
    654       "schema",
    655       "encoding"
     655      (char*)"schema",
     656      (char*)"encoding"
    656657    };
    657658    sprintf(tmpLen,"%d",len+1);
     
    730731  }
    731732
     733  static void dumpElementsAsYAML(elements* e){
     734    elements* tmp=e;
     735    while(tmp!=NULL){
     736      for(int i=0;i<2;i++)
     737        fprintf(stderr," ");
     738      fprintf(stderr,"%s:\n",tmp->name);
     739      map* mcurs=tmp->content;
     740      while(mcurs!=NULL){
     741        for(int i=0;i<4;i++)
     742          fprintf(stderr," ");
     743        _dumpMap(mcurs);
     744        mcurs=mcurs->next;
     745      }
     746      mcurs=tmp->metadata;
     747      if(mcurs!=NULL){
     748        for(int i=0;i<4;i++)
     749          fprintf(stderr," ");
     750        fprintf(stderr,"MetaData:\n");
     751        while(mcurs!=NULL){
     752          for(int i=0;i<6;i++)
     753            fprintf(stderr," ");
     754          _dumpMap(mcurs);
     755          mcurs=mcurs->next;
     756        }
     757      }
     758      for(int i=0;i<4;i++)
     759        fprintf(stderr," ");
     760      fprintf(stderr,"%s:\n",tmp->format);
     761      iotype* tmpio=tmp->defaults;
     762      int ioc=0;
     763      while(tmpio!=NULL){
     764        for(int i=0;i<6;i++)
     765          fprintf(stderr," ");
     766        fprintf(stderr,"default:\n");
     767        mcurs=tmpio->content;
     768        while(mcurs!=NULL){
     769          for(int i=0;i<8;i++)
     770            fprintf(stderr," ");
     771          if(strcasecmp(mcurs->name,"range")==0){
     772            fprintf(stderr,"range: \"%s\"\n",mcurs->value);
     773          }else
     774            _dumpMap(mcurs);
     775          mcurs=mcurs->next;
     776        }
     777        tmpio=tmpio->next;
     778        ioc++;
     779      }
     780      tmpio=tmp->supported;
     781      ioc=0;
     782      while(tmpio!=NULL){
     783        for(int i=0;i<6;i++)
     784          fprintf(stderr," ");
     785        fprintf(stderr,"supported:\n");
     786        mcurs=tmpio->content;
     787        while(mcurs!=NULL){
     788          for(int i=0;i<8;i++)
     789            fprintf(stderr," ");
     790          if(strcasecmp(mcurs->name,"range")==0){
     791            fprintf(stderr,"range: \"%s\"\n",mcurs->value);
     792          }else
     793            _dumpMap(mcurs);
     794          mcurs=mcurs->next;
     795        }
     796        tmpio=tmpio->next;
     797        ioc++;
     798      }
     799      tmp=tmp->next;
     800    }
     801  }
     802
     803
    732804  static elements* dupElements(elements* e){
    733805    elements* cursor=e;
     
    805877    }
    806878    fprintf(stderr,"++++++++++++++++++\n");
     879  }
     880
     881  static void dumpServiceAsYAML(service* s){
     882    int level=0;
     883    fprintf(stderr,"# %s\n\n",s->name);
     884    if(s->content!=NULL){
     885      map* mcurs=s->content;
     886      dumpMap(mcurs);
     887      mcurs=s->metadata;
     888      if(mcurs!=NULL){
     889        fprintf(stderr,"MetaData:\n");
     890        while(mcurs!=NULL){
     891          for(int i=0;i<2;i++)
     892            fprintf(stderr," ");
     893          _dumpMap(mcurs);
     894          mcurs=mcurs->next;
     895        }
     896      }
     897    }
     898    if(s->inputs!=NULL){
     899      fprintf(stderr,"\ninputs:\n",s->name);
     900      dumpElementsAsYAML(s->inputs);
     901    }
     902    if(s->outputs!=NULL){
     903      fprintf(stderr,"\noutputs:\n",s->name);
     904      dumpElementsAsYAML(s->outputs);
     905    }
    807906  }
    808907
Note: See TracChangeset for help on using the changeset viewer.

Search

Context Navigation

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