Ignore:
Timestamp:
Sep 14, 2010, 2:04:55 PM (14 years ago)
Author:
djay
Message:

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:
1 edited

Legend:

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

    r1 r9  
    4040#define true 1
    4141#define false -1
     42
    4243#define SERVICE_ACCEPTED 0
    4344#define SERVICE_STARTED 1
     
    4546#define SERVICE_SUCCEEDED 3
    4647#define SERVICE_FAILED 4
     48
    4749#define ELEMENTS_SIZE (sizeof(char*)+(((2*sizeof(char*))+sizeof(maps*))*2)+sizeof(char*)+(((2*sizeof(char*))+sizeof(iotype*))*2)+sizeof(elements*))
    48 #define MAP_SIZE (2*sizeof(char*))+sizeof(map*)
    49 #define MAPS_SIZE (2*sizeof(char*))+sizeof(map*)+sizeof(maps*)
    50 
    51 
    52   static char* mtoupper(char* str){
     50#define MAP_SIZE (2*sizeof(char*))+sizeof(NULL)
     51#define IOTYPE_SIZE MAP_SIZE+sizeof(NULL)
     52#define MAPS_SIZE (2*sizeof(char*))+sizeof(map*)+MAP_SIZE
     53#define SERVICE_SIZE (ELEMENTS_SIZE*2)+(MAP_SIZE*2)+sizeof(char*)
     54
     55
     56  /*  static char* mtoupper(char* str){
    5357    char* tmp=strdup(str);
    5458    if(tmp){
     
    6367      tmp[0]=0;
    6468    return tmp;
    65   }
    66 
     69    }*/
     70
     71  /**
     72   * \struct maps
     73   * \brief linked list of map pointer
     74   *
     75   * Small object to store WPS KVP set.
     76   */
    6777  typedef struct maps{
    68     char* name;
    69     struct map* content;
    70     struct maps* next;
     78    char* name;         
     79    struct map* content; 
     80    struct maps* next;   
    7181  } maps;
    7282
     83  /**
     84   * \struct map
     85   * \brief KVP linked list
     86   *
     87   * Deal with WPS KVP (name,value).
     88   */
    7389  typedef struct map{
    74     char* name;
    75     char* value;
    76     struct map* next;
     90    char* name;       /* The key */
     91    char* value;      /* The value */
     92    struct map* next; /* Next couple */
    7793  } map;
    7894
     
    8399#endif
    84100
    85   static void* _dumpMap(map* t){
     101  static void _dumpMap(map* t){
    86102    if(t!=NULL){
    87103      fprintf(stderr,"[%s] => [%s] \n",t->name,t->value);
     
    91107      fflush(stderr);
    92108    }
    93     return NULL;
    94   }
    95 
    96   static void* dumpMap(map* t){
     109  }
     110
     111  static void dumpMap(map* t){
    97112    map* tmp=t;
    98113    while(tmp!=NULL){
     
    100115      tmp=tmp->next;
    101116    }
    102     return NULL;
    103117  }
    104118
     
    112126  }
    113127
    114   static map* createMap(char* name,char* value){
     128  static map* createMap(const char* name,const char* value){
    115129    map* tmp=(map *)malloc(MAP_SIZE);
    116130    tmp->name=strdup(name);
     
    130144  }
    131145   
    132   static bool hasKey(map* m,char *key){
     146  static bool hasKey(map* m,const char *key){
    133147    map* tmp=m;
    134148    while(tmp!=NULL){
    135       if(strcmp(mtoupper(tmp->name),mtoupper(key))==0)
     149      if(strncasecmp(tmp->name,key,strlen(key))==0)
    136150        return true;
    137151      tmp=tmp->next;
     
    143157  }
    144158
    145   static maps* getMaps(maps* m,char *key){
     159  static maps* getMaps(maps* m,const char *key){
    146160    maps* tmp=m;
    147161    while(tmp!=NULL){
    148       if(strcmp(mtoupper(tmp->name),mtoupper(key))==0)
     162      if(strncasecmp(tmp->name,key,strlen(key))==0){
    149163        return tmp;
     164      }
    150165      tmp=tmp->next;
    151166    }
     
    153168  }
    154169
    155   static map* getMap(map* m,char *key){
     170  static map* getMap(map* m,const char *key){
    156171    map* tmp=m;
    157172    while(tmp!=NULL){
    158       if(strcmp(mtoupper(tmp->name),mtoupper(key))==0)
     173      if(strncasecmp(tmp->name,key,strlen(key))==0){
    159174        return tmp;
     175      }
    160176      tmp=tmp->next;
    161177    }
     
    166182    maps* _tmpm=getMaps(m,key);
    167183    if(_tmpm!=NULL){
    168       map* tmpm=getMap(_tmpm->content,mtoupper(subkey));
    169       return tmpm;
     184      map* _ztmpm=getMap(_tmpm->content,subkey);
     185      return _ztmpm;
    170186    }
    171187    else return NULL;
    172188  }
    173189
    174   static void* freeMap(map** mo){
     190  static void freeMap(map** mo){
    175191    map* _cursor=*mo;
    176192    if(_cursor!=NULL){
     193#ifdef DEBUG
     194      fprintf(stderr,"freeMap\n");
     195#endif
    177196      free(_cursor->name);
    178197      free(_cursor->value);
     
    182201      }
    183202    }
    184         return NULL;
    185   }
    186 
     203  }
     204
     205  static void freeMaps(maps** mo){
     206    maps* _cursor=*mo;
     207    fflush(stderr);
     208    if(_cursor && _cursor!=NULL){
     209#ifdef DEBUG
     210      fprintf(stderr,"freeMaps\n");
     211#endif
     212      free(_cursor->name);
     213      if(_cursor->content!=NULL){
     214        freeMap(&_cursor->content);
     215        free(_cursor->content);
     216      }
     217      if(_cursor->next!=NULL){
     218        freeMaps(&_cursor->next);
     219        free(_cursor->next);
     220      }
     221    }
     222  }
    187223
    188224  typedef struct iotype{
     
    217253    elements* tmp=e;
    218254    while(tmp!=NULL){
    219       mtoupper(key);
    220       mtoupper(tmp->name);
    221       if(strcmp(key,tmp->name)==0)
     255      if(strncasecmp(key,tmp->name,strlen(key))==0)
    222256        return true;
    223257      tmp=tmp->next;
     
    229263    elements* tmp=m;
    230264    while(tmp!=NULL){
    231       mtoupper(tmp->name);
    232       mtoupper(key);
    233       if(strcmp(tmp->name,key)==0)
     265      if(strncasecmp(tmp->name,key,strlen(tmp->name))==0)
    234266        return tmp;
    235267      tmp=tmp->next;
     
    239271
    240272
    241   static void* freeIOType(iotype** i){
     273  static void freeIOType(iotype** i){
    242274    iotype* _cursor=*i;
    243275    if(_cursor!=NULL){
    244276      freeMap(&_cursor->content);
    245277      free(_cursor->content);
    246       freeIOType(&_cursor->next);
    247       free(_cursor->next);
    248     }
    249         return NULL;
     278      if(_cursor->next!=NULL){
     279        freeIOType(&_cursor->next);
     280        free(_cursor->next);
     281      }
     282    }
    250283  }
    251284
     
    253286    elements* tmp=*e;
    254287    if(tmp!=NULL){
    255 #ifdef DEBUG
    256       fprintf(stderr,"FREE 1");
    257 #endif
    258288      free(tmp->name);
    259289      freeMap(&tmp->content);
    260 #ifdef DEBUG
    261       fprintf(stderr,"FREE 2");
    262 #endif
    263290      free(tmp->content);
    264291      freeMap(&tmp->metadata);
    265 #ifdef DEBUG
    266       fprintf(stderr,"FREE 3");
    267 #endif
    268292      free(tmp->metadata);
    269 #ifdef DEBUG
    270       fprintf(stderr,"FREE 4");
    271 #endif
    272293      free(tmp->format);
    273294      freeIOType(&tmp->defaults);
    274 #ifdef DEBUG
    275       fprintf(stderr,"FREE 5");
    276 #endif
    277295      if(tmp->defaults!=NULL)
    278296        free(tmp->defaults);
    279297      freeIOType(&tmp->supported);
    280 #ifdef DEBUG
    281       fprintf(stderr,"FREE 6");
    282 #endif
    283298      if(tmp->supported!=NULL)
    284299        free(tmp->supported);
    285       tmp=tmp->next;
    286     }
    287   }
    288 
    289   static void* freeService(service** s){
     300      freeElements(&tmp->next);
     301    }
     302  }
     303
     304  static void freeService(service** s){
    290305    service* tmp=*s;
    291306    if(tmp!=NULL){
     307      if(tmp->name!=NULL)
     308        free(tmp->name);
    292309      freeMap(&tmp->content);
    293310      if(tmp->content!=NULL)
     
    305322  }
    306323
    307   static void* addMapToMap(map** mo,map* mi){
    308     map* tmp=mi;
    309     map* _cursor=*mo;
    310     while(tmp!=NULL){
    311       if(_cursor==NULL){
    312         *mo=(map*)malloc(MAP_SIZE);
    313         *mo=createMap(tmp->name,tmp->value);
    314         _cursor=*mo;
    315         _cursor->next=NULL;
    316       }
    317       else{
    318         while(_cursor->next!=NULL)
    319           _cursor=_cursor->next;
    320         _cursor->next=createMap(tmp->name,tmp->value);
    321       }
    322       tmp=tmp->next;
    323     }
    324     return NULL;
    325   }
    326 
    327   static void* addMapsToMaps(maps** mo,maps* mi){
    328     maps* tmp=mi;
    329     maps* _cursor=*mo;
    330     while(tmp!=NULL){
    331       if(_cursor==NULL){
    332         *mo=(maps*)malloc(MAP_SIZE);
    333         *mo=mi;
    334         _cursor=*mo;
    335       }
    336       else{
    337         while(_cursor->next!=NULL)
    338           _cursor=_cursor->next;
    339         _cursor->next=tmp;
    340       }
    341       tmp=tmp->next;
    342     }
    343     return NULL;
    344   }
    345 
    346   static void* addMapToIotype(iotype** io,map* mi){
    347     iotype* tmp=*io;
    348     while(tmp!=NULL){
    349       fprintf(stderr,">> CURRENT MAP");
    350       dumpMap(tmp->content);
    351       tmp=tmp->next;
    352     }
    353     tmp=(iotype*)malloc(ELEMENTS_SIZE);
    354     tmp->content=NULL;
    355     tmp->next=NULL;
    356     addMapToMap(&tmp->content,mi);
    357     return NULL;
    358   }
    359 
    360   static void* addToMap(map* m,char* n,char* v){
     324  static void addToMap(map* m,const char* n,const char* v){
    361325    if(hasKey(m,n)==false){
    362326      map* _cursor=m;
     
    367331    else{
    368332      map *tmp=getMap(m,n);
     333      if(tmp->value!=NULL)
     334        free(tmp->value);
    369335      tmp->value=strdup(v);
    370336    }
    371     return NULL;
    372   }
    373 
    374 
    375   static void* dumpElements(elements* e){
     337  }
     338
     339  static void addMapToMap(map** mo,map* mi){
     340    map* tmp=mi;
     341    map* _cursor=*mo;
     342    if(tmp==NULL){
     343      if(_cursor!=NULL){
     344        while(_cursor!=NULL)
     345          _cursor=_cursor->next;
     346        _cursor=NULL;
     347      }else
     348        *mo=NULL;
     349    }
     350    while(tmp!=NULL){
     351      if(_cursor==NULL){
     352        if(*mo==NULL)
     353          *mo=createMap(tmp->name,tmp->value);
     354        else
     355          addToMap(*mo,tmp->name,tmp->value);
     356      }
     357      else{
     358#ifdef DEBUG
     359        fprintf(stderr,"_CURSOR\n");
     360        dumpMap(_cursor);
     361#endif
     362        while(_cursor!=NULL)
     363          _cursor=_cursor->next;
     364        _cursor=createMap(tmp->name,tmp->value);
     365        _cursor->next=NULL;
     366      }
     367      tmp=tmp->next;
     368#ifdef DEBUG
     369      fprintf(stderr,"MO\n");
     370      dumpMap(*mo);
     371#endif
     372    }
     373  }
     374
     375  static void addMapToIoType(iotype** io,map* mi){
     376    iotype* tmp=*io;
     377    while(tmp!=NULL){
     378#ifdef DEBUG
     379      fprintf(stderr,">> CURRENT MAP");
     380      dumpMap(tmp->content);
     381#endif
     382      tmp=tmp->next;
     383    }
     384#ifdef DEBUG
     385    fprintf(stderr,">> %s %i\n",__FILE__,__LINE__);
     386    fflush(stderr);
     387#endif
     388    tmp=(iotype*)malloc(IOTYPE_SIZE);
     389#ifdef DEBUG
     390    fprintf(stderr,">> %s %i\n",__FILE__,__LINE__);
     391    fflush(stderr);
     392#endif
     393    tmp->content=NULL;
     394#ifdef DEBUG
     395    fprintf(stderr,">> %s %i\n",__FILE__,__LINE__);
     396    fflush(stderr);
     397#endif
     398    addMapToMap(&tmp->content,mi);
     399#ifdef DEBUG
     400    fprintf(stderr,">> %s %i\n",__FILE__,__LINE__);
     401    fflush(stderr);
     402#endif
     403    dumpMap(tmp->content);
     404    tmp->next=NULL;
     405  }
     406
     407
     408  static maps* dupMaps(maps** mo){
     409    maps* _cursor=*mo;
     410    maps* res=NULL;
     411    if(_cursor!=NULL){
     412      res=(maps*)malloc(MAPS_SIZE);
     413      res->name=strdup(_cursor->name);
     414      res->content=NULL;
     415      res->next=NULL;
     416      map* mc=_cursor->content;
     417      if(mc!=NULL){
     418        addMapToMap(&res->content,mc);
     419      }
     420      res->next=dupMaps(&_cursor->next);
     421    }
     422    return res;
     423  }
     424
     425  static void addMapsToMaps(maps** mo,maps* mi){
     426    maps* tmp=mi;
     427    maps* _cursor=*mo;
     428    while(tmp!=NULL){
     429      if(_cursor==NULL){
     430        *mo=dupMaps(&mi);
     431        (*mo)->next=NULL;
     432      }
     433      else{
     434        while(_cursor->next!=NULL)
     435          _cursor=_cursor->next;
     436        _cursor->next=dupMaps(&tmp);
     437      }
     438      tmp=tmp->next;
     439    }
     440  }
     441
     442
     443  static void dumpElements(elements* e){
    376444    elements* tmp=e;
    377445    while(tmp!=NULL){
     
    401469      tmp=tmp->next;
    402470    }
    403     return NULL;
    404   }
    405 
     471  }
    406472
    407473  static elements* dupElements(elements* e){
    408     if(e!=NULL){
    409 #ifdef DEBUG
     474    elements* cursor=e;
     475    elements* tmp=NULL;
     476    if(cursor!=NULL){
     477#ifdef DEBUG
     478      fprintf(stderr,">> %s %i\n",__FILE__,__LINE__);
    410479      dumpElements(e);
    411 #endif
    412       elements* tmp=(elements*)malloc(ELEMENTS_SIZE);
     480      fprintf(stderr,">> %s %i\n",__FILE__,__LINE__);
     481#endif
     482      tmp=(elements*)malloc(ELEMENTS_SIZE);
    413483      tmp->name=strdup(e->name);
    414484      tmp->content=NULL;
     
    418488      tmp->format=strdup(e->format);
    419489      if(e->defaults!=NULL){
    420         tmp->defaults=(iotype*)malloc(MAP_SIZE);
     490        tmp->defaults=(iotype*)malloc(IOTYPE_SIZE);
    421491        tmp->defaults->content=NULL;
     492        addMapToMap(&tmp->defaults->content,e->defaults->content);
    422493        tmp->defaults->next=NULL;
    423         addMapToMap(&tmp->defaults->content,e->defaults->content);
    424         while(e->defaults->next!=NULL){
    425           tmp->defaults->next=(iotype*)malloc(MAP_SIZE);
    426           addMapToMap(&tmp->defaults->next->content,e->defaults->content);
    427         }
    428       }
     494#ifdef DEBUG
     495        fprintf(stderr,">> %s %i\n",__FILE__,__LINE__);
     496        dumpMap(tmp->defaults->content);
     497#endif
     498      }else
     499        tmp->defaults=NULL;
    429500      if(e->supported!=NULL){
    430         tmp->supported=(iotype*)malloc(MAP_SIZE);
     501        tmp->supported=(iotype*)malloc(IOTYPE_SIZE);
    431502        tmp->supported->content=NULL;
    432503        tmp->supported->next=NULL;
    433504        addMapToMap(&tmp->supported->content,e->supported->content);
     505        iotype *etmp=*(&tmp->supported->next) ;
    434506        iotype *tmp2=e->supported->next;
    435507        while(tmp2!=NULL){
    436           tmp->supported->next=(iotype*)malloc(MAP_SIZE);
    437           addMapToMap(&tmp->supported->next->content,tmp2->content);
     508          etmp=(iotype*)malloc(IOTYPE_SIZE);
     509          etmp->content=NULL;
     510          addMapToMap(&etmp->content,tmp2->content);
     511          etmp->next=NULL;
     512#ifdef DEBUG
     513          fprintf(stderr,">> %s %i\n",__FILE__,__LINE__);
     514          dumpMap(tmp->defaults->content);
     515#endif
    438516          tmp2=tmp2->next;
     517          etmp=etmp->next;
    439518        }
    440519      }
    441       tmp->next=NULL;
    442       return tmp;
    443     }
    444     return NULL;
    445   }
    446 
    447   static void* addToElements(elements* m,elements* e){
    448     elements* _cursor=m;
     520      else
     521        tmp->supported=NULL;
     522      tmp->next=dupElements(cursor->next);
     523    }
     524    return tmp;
     525  }
     526
     527  static void addToElements(elements** m,elements* e){
     528    elements* _cursor=*m;
    449529    elements* tmp=e;
    450530    if(_cursor==NULL){
    451       m=dupElements(tmp);
    452       return NULL;
    453     }
    454     while(_cursor->next!=NULL)
    455       _cursor=_cursor->next;
    456     _cursor->next=dupElements(tmp);
    457     return NULL;
    458   }
    459 
    460   static void* dumpService(service* s){
     531      *m=dupElements(tmp);
     532    }else{
     533      while(_cursor->next!=NULL)
     534        _cursor=_cursor->next;
     535      _cursor->next=dupElements(tmp);
     536    }
     537  }
     538
     539  static void dumpService(service* s){
    461540    fprintf(stderr,"++++++++++++++++++\nSERVICE [%s]\n++++++++++++++++++\n",s->name);
    462541    if(s->content!=NULL){
     
    475554    }
    476555    fprintf(stderr,"++++++++++++++++++\n");
    477     return NULL;
    478   }
    479 
    480   static void* mapsToCharXXX(maps* m,char*** c){
     556  }
     557
     558  static void mapsToCharXXX(maps* m,char*** c){
    481559    maps* tm=m;
    482560    int i=0;
     
    506584    }
    507585    memcpy(c,tmp,10*10*1024);
    508         return NULL;
    509   }
    510 
    511   static void* charxxxToMaps(char*** c,maps**m){
     586  }
     587
     588  static void charxxxToMaps(char*** c,maps**m){
    512589    maps* trorf=*m;
    513590    int i,j;
     
    526603          trorf->content=createMap(tmp[i][j],tmp[i][j+1]);
    527604        else
    528         addMapToMap(&trorf->content,createMap(tmp[i][j],tmp[i][j+1]));
     605          addToMap(trorf->content,tmp[i][j],tmp[i][j+1]);
    529606      }
    530607      trorf=trorf->next;
    531608    }
    532609    m=&trorf;
    533     return NULL;
    534610  }
    535611
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