Changeset 217 for branches/branch-1.2/zoo-kernel/service.h
- Timestamp:
- May 31, 2011, 3:30:49 AM (13 years ago)
- Location:
- branches/branch-1.2
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/branch-1.2
-
branches/branch-1.2/zoo-kernel/service.h
r109 r217 28 28 #pragma once 29 29 30 #ifdef WIN32 31 #define strncasecmp strnicmp 32 #define strcasecmp stricmp 33 #define snprintf sprintf_s 34 #endif 35 30 36 #ifdef __cplusplus 31 37 extern "C" { … … 55 61 #define SHMSZ 27 56 62 63 64 /** 65 * \struct map 66 * \brief KVP linked list 67 * 68 * Deal with WPS KVP (name,value). 69 * A map is defined as: 70 * - name : a key, 71 * - value: a value, 72 * - next : a pointer to the next map if any. 73 */ 74 typedef struct map{ 75 char* name; 76 char* value; 77 struct map* next; 78 } map; 79 80 #ifdef WIN32 81 #define NULLMAP ((map*) 0) 82 #else 83 #define NULLMAP NULL 84 #endif 85 57 86 /** 58 87 * \struct maps … … 60 89 * 61 90 * Small object to store WPS KVP set. 91 * Maps is defined as: 92 * - a name, 93 * - a content map, 94 * - a pointer to the next maps if any. 62 95 */ 63 96 typedef struct maps{ … … 68 101 69 102 /** 70 * \struct map 71 * \brief KVP linked list 72 * 73 * Deal with WPS KVP (name,value). 103 * \brief Dump a map on stderr 74 104 */ 75 typedef struct map{76 char* name; /* The key */77 char* value; /* The value */78 struct map* next; /* Next couple */79 } map;80 81 #ifdef WIN3282 #define NULLMAP ((map*) 0)83 #else84 #define NULLMAP NULL85 #endif86 87 105 static void _dumpMap(map* t){ 88 106 if(t!=NULL){ … … 181 199 } 182 200 183 static map* getMapFromMaps(maps* m,char* key,char* subkey){ 201 static map* getLastMap(map* m){ 202 map* tmp=m; 203 while(tmp!=NULL){ 204 if(tmp->next==NULL){ 205 return tmp; 206 } 207 tmp=tmp->next; 208 } 209 return NULL; 210 } 211 212 static map* getMapFromMaps(maps* m,const char* key,const char* subkey){ 184 213 maps* _tmpm=getMaps(m,key); 185 214 if(_tmpm!=NULL){ … … 189 218 else return NULL; 190 219 } 220 221 static char* getMapsAsKVP(maps* m,int length,int type){ 222 char *dataInputsKVP=(char*) malloc(length*sizeof(char)); 223 maps* curs=m; 224 int i=0; 225 while(curs!=NULL){ 226 if(i==0) 227 if(type==0) 228 sprintf(dataInputsKVP,"%s=",curs->name); 229 else 230 sprintf(dataInputsKVP,"%s",curs->name); 231 else{ 232 char *temp=strdup(dataInputsKVP); 233 if(type==0) 234 sprintf(dataInputsKVP,"%s;%s=",temp,curs->name); 235 else 236 sprintf(dataInputsKVP,"%s;%s",temp,curs->name); 237 free(temp); 238 } 239 map* icurs=curs->content; 240 if(type==0){ 241 map* tmp=getMap(curs->content,"value"); 242 char *temp=strdup(dataInputsKVP); 243 if(getMap(m->content,"xlink:href")!=NULL) 244 sprintf(dataInputsKVP,"%sReference",temp); 245 else 246 sprintf(dataInputsKVP,"%s%s",temp,icurs->value); 247 free(temp); 248 } 249 int j=0; 250 while(icurs!=NULL){ 251 if(strcasecmp(icurs->name,"value")!=0 && 252 strcasecmp(icurs->name,"Reference")!=0 && 253 strcasecmp(icurs->name,"minOccurs")!=0 && 254 strcasecmp(icurs->name,"maxOccurs")!=0 && 255 strcasecmp(icurs->name,"inRequest")!=0){ 256 char *itemp=strdup(dataInputsKVP); 257 sprintf(dataInputsKVP,"%s@%s=%s",itemp,icurs->name,icurs->value); 258 free(itemp); 259 } 260 icurs=icurs->next; 261 } 262 curs=curs->next; 263 i++; 264 } 265 return dataInputsKVP; 266 } 267 191 268 192 269 static void freeMap(map** mo){ … … 224 301 } 225 302 303 /** 304 * \brief Not named linked list 305 * 306 * Used to store informations about formats, such as mimeType, encoding ... 307 * 308 * An iotype is defined as : 309 * - a content map, 310 * - a pointer to the next iotype if any. 311 */ 226 312 typedef struct iotype{ 227 313 struct map* content; … … 229 315 } iotype; 230 316 317 /** 318 * \brief Metadata information about input or output. 319 * 320 * The elements are used to store metadata informations defined in the ZCFG. 321 * 322 * An elements is defined as : 323 * - a name, 324 * - a content map, 325 * - a metadata map, 326 * - a format (possible values are LiteralData, ComplexData or 327 * BoundingBoxData), 328 * - a default iotype, 329 * - a pointer to the next elements id any. 330 */ 231 331 typedef struct elements{ 232 332 char* name; … … 252 352 } services; 253 353 254 static bool hasElement(elements* e,c har* key){354 static bool hasElement(elements* e,const char* key){ 255 355 elements* tmp=e; 256 356 while(tmp!=NULL){ … … 476 576 477 577 478 static void setMapInMaps(maps* m,c har* key,char* subkey,char *value){578 static void setMapInMaps(maps* m,const char* key,const char* subkey,const char *value){ 479 579 maps* _tmpm=getMaps(m,key); 480 580 if(_tmpm!=NULL){ 481 581 map* _ztmpm=getMap(_tmpm->content,subkey); 482 582 if(_ztmpm!=NULL){ 483 free(_ztmpm->value); 583 if(_ztmpm->value!=NULL) 584 free(_ztmpm->value); 484 585 _ztmpm->value=strdup(value); 485 586 }else{
Note: See TracChangeset
for help on using the changeset viewer.