00001 #include "jsoc.h"
00002 #include "defs.h"
00003 #include "hcontainer.h"
00004
00005 #define kMAXKEYSIZE 64
00006 #define kMAXVALSIZE 128
00007
00008 HContainer_t *gDefs = NULL;
00009
00010 void InitGDefs()
00011 {
00012 if (!gDefs)
00013 {
00014 gDefs = malloc(sizeof(HContainer_t));
00015 if (gDefs)
00016 {
00017 hcon_init(gDefs, kMAXVALSIZE, kMAXKEYSIZE, NULL, NULL);
00018 }
00019 }
00020 }
00021
00022 void defs_term()
00023 {
00024 if (gDefs)
00025 {
00026 hcon_destroy(&gDefs);
00027 }
00028 }
00029
00030 const char *defs_getval(const char *key)
00031 {
00032 const char *ret = NULL;
00033
00034 if (gDefs && key)
00035 {
00036 ret = hcon_lookup(gDefs, key);
00037 }
00038
00039 if (!ret)
00040 {
00041 fprintf(stderr, "DEF ERROR: Definition ID '%s' undefined.\n", key);
00042 }
00043
00044 return ret;
00045 }