The Assimilation Monitoring Project
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
configcontext.h
Go to the documentation of this file.
1 
26 #ifndef _CONFIGCONTEXT_H
27 #define _CONFIGCONTEXT_H
28 #include <projectcommon.h>
29 #include <assimobj.h>
30 #include <netaddr.h>
31 #include <signframe.h>
32 #include <address_family_numbers.h>
33 
36 
41 
43 
45  CFG_EEXIST, // Name does not exist
46  CFG_NULL, // JSON null object
47  CFG_BOOL, // JSON boolean object
48  CFG_INT64, // Signed 64-bit Integer
49  CFG_STRING, // String
50  CFG_FLOAT, // Floating point
51  CFG_ARRAY, // JSON Array
52  CFG_CFGCTX, // ConfigContext (recursive) object
53  CFG_NETADDR, // NetAddr object
54  CFG_FRAME, // Frame object
55 };
56 typedef struct _ConfigValue ConfigValue;
57 struct _ConfigValue {
60  union {
61  gint64 intvalue; // Or boolean
62  double floatvalue;
63  GSList* arrayvalue; // Each element pointing to a ConfigValue object
64  char* strvalue; // A string
65  ConfigContext* cfgctxvalue; // Another ConfigContext object
66  NetAddr* addrvalue; // A NetAddr value
67  Frame* framevalue; // A Frame value
68  }u;
69 };
70 
73  GHashTable* _values;
74  gint64 (*getint)(const ConfigContext*, const char *name);
75  void (*setint)(ConfigContext*, const char *name, gint value);
76  gboolean (*getbool)(const ConfigContext*, const char *name);
77  void (*setbool)(ConfigContext*, const char *name, gboolean);
78  double (*getdouble)(const ConfigContext*, const char *name);
79  void (*setdouble)(ConfigContext*, const char *name, double value);
80  GSList* (*getarray)(const ConfigContext*, const char *name);
81  void (*setarray)(ConfigContext*, const char *name, GSList*);
82  const char* (*getstring)(const ConfigContext*, const char *name);
83  void (*setstring)(ConfigContext*, const char *name, const char *value);
84  Frame* (*getframe)(const ConfigContext*, const char*);
85  void (*setframe)(ConfigContext*, const char*,Frame*);
86  NetAddr* (*getaddr)(const ConfigContext*, const char* name);
87  void (*setaddr)(ConfigContext*,const char *,NetAddr*);
88  ConfigContext* (*getconfig)(const ConfigContext*, const char* name);
89  void (*setconfig)(ConfigContext*,const char *,ConfigContext*);
90  enum ConfigValType
91  (*gettype)(const ConfigContext*, const char *);
92  ConfigValue* (*getvalue)(const ConfigContext*, const char *);
93  char* (*getstr)(const ConfigContext*, const char *);
94  guint (*keycount)(const ConfigContext*);
95  GSList* (*keys)(const ConfigContext*);
96 };
97 WINEXPORT ConfigContext* configcontext_new(gsize objsize); // ConfigContext constructor
98 WINEXPORT ConfigContext* configcontext_new_JSON_string(const char * jsontext);// Constructor
99 
100 #define CONFIG_DEFAULT_DEADTIME 30
101 #define CONFIG_DEFAULT_HBTIME 3
102 #define CONFIG_DEFAULT_WARNTIME 10
103 #define CONFIG_DEFAULT_HBPORT 1984
104 #define CONFIG_DEFAULT_CMAPORT 1984
105 #define CONFIG_DEFAULT_ADDR {127,0,0,1}
106 #define CONFIG_DEFAULT_ADDRTYPE ADDR_FAMILY_IPV4
107 #define CONFIG_DEFAULT_SIGNFRAME_TYPE G_CHECKSUM_SHA256
108 
109 #define CONFIGNAME_DEADTIME "deadtime"
110 #define CONFIGNAME_WARNTIME "warntime"
111 #define CONFIGNAME_HBTIME "hbtime"
112 #define CONFIGNAME_HBPORT "hbport"
113 #define CONFIGNAME_CMAPORT "cmaport"
114 #define CONFIGNAME_CMAINIT "cmainit"
115 
116 #define CONFIGNAME_CMAADDR "cmaaddr"
117 #define CONFIGNAME_CMADISCOVER "cmadisc"
118 #define CONFIGNAME_CMAFAIL "cmafail"
119 #define CONFIGNAME_OUTSIG "outsig"
120 #define CONFIGNAME_CRYPT "crypt"
121 #define CONFIGNAME_COMPRESS "compress"
122 
123 
124 #define CONFIGINTDEFAULTS { \
125  {CONFIGNAME_DEADTIME, CONFIG_DEFAULT_DEADTIME}, \
126  {CONFIGNAME_WARNTIME, CONFIG_DEFAULT_WARNTIME}, \
127  {CONFIGNAME_HBTIME, CONFIG_DEFAULT_HBTIME}, \
128  {CONFIGNAME_HBPORT, CONFIG_DEFAULT_HBPORT}, \
129  {CONFIGNAME_CMAPORT, CONFIG_DEFAULT_CMAPORT}, \
130  }
131 
132 #endif /* _CONFIGCONTEXT_H */