source: trunk/zoo-kernel/service.c @ 1

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

Initial ZOO SVN Repository Import.

File size: 1002 bytes
Line 
1#include "service.h"
2
3map* createMap(char* name,char* value){
4  map* tmp=(map *)malloc(sizeof(map*));
5  tmp->name=strdup(name);
6  tmp->value=strdup(value);
7  tmp->next=NULL;
8  return tmp;
9}
10
11bool hasKey(map* m,char *key){
12  map* tmp=m;
13  while(tmp!=NULL){
14    if(strcmp(tmp->name,key)==0)
15      return true;
16    tmp=tmp->next;
17  }
18#ifdef DEBUG_MAP
19  printf("NOT FOUND \n");
20#endif
21  return false;
22}
23
24map* getMap(map* m,char *key){
25  map* tmp=m;
26  while(tmp!=NULL){
27    if(strcmp(tmp->name,key)==0)
28      return tmp;
29    tmp=tmp->next;
30  }
31  return NULL;
32}
33
34void* addToMap(map* m,char* n,char* v){
35  if(hasKey(m,n)==false){
36    map* _cursor=m;
37    while(_cursor->next)
38      _cursor=_cursor->next;
39    _cursor->next=createMap(n,v);
40  }
41  else{
42    map *tmp=getMap(m,n);
43    tmp->value=strdup(v);
44  }
45}
46
47void* _dumpMap(map* t){
48  fprintf(stderr,"[%s] => [%s] \n",t->name,t->value);
49  fflush(stderr);
50}
51
52void* dumpMap(map* t){
53  map* tmp=t;
54  while(tmp!=NULL){
55    _dumpMap(tmp);
56    tmp=tmp->next;
57  }
58}
Note: See TracBrowser for help on using the repository browser.

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