00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 #ifndef _I_REC_CORE_H_
00025 #define _I_REC_CORE_H_
00026 
00027 #include "Diags.h"
00028 
00029 #include "I_RecDefs.h"
00030 #include "I_RecAlarms.h"
00031 #include "I_RecSignals.h"
00032 #include "I_RecEvents.h"
00033 
00034 
00035 
00036 
00037 
00038 int RecSetDiags(Diags * diags);
00039 
00040 
00041 
00042 
00043 typedef void (*RecConfigEntryCallback)(RecT rec_type, RecDataT data_type, const char * name, const char * value, bool inc_version);
00044 
00045 void RecConfigFileInit(void);
00046 int RecConfigFileParse(const char * path, RecConfigEntryCallback handler, bool inc_version);
00047 
00048 
00049 
00050 char * RecConfigReadRuntimeDir();
00051 
00052 
00053 
00054 char * RecConfigReadSnapshotDir();
00055 
00056 
00057 
00058 char * RecConfigReadLogDir();
00059 
00060 
00061 
00062 char * RecConfigReadBinDir();
00063 
00064 
00065 
00066 
00067 char * RecConfigReadConfigPath(const char * file_variable, const char * default_value = NULL);
00068 
00069 
00070 char * RecConfigReadPrefixPath(const char * file_variable, const char * default_value = NULL);
00071 
00072 
00073 
00074 char * RecConfigReadPersistentStatsPath();
00075 
00076 
00077 
00078 const char * RecConfigOverrideFromEnvironment(const char * name, const char * value);
00079 
00080 
00081 
00082 
00083 int _RecRegisterStatInt(RecT rec_type, const char *name, RecInt data_default, RecPersistT persist_type);
00084 #define RecRegisterStatInt(rec_type, name, data_default, persist_type) _RecRegisterStatInt((rec_type), (name), (data_default), REC_PERSISTENCE_TYPE(persist_type))
00085 
00086 int _RecRegisterStatFloat(RecT rec_type, const char *name, RecFloat data_default, RecPersistT persist_type);
00087 #define RecRegisterStatFloat(rec_type, name, data_default, persist_type) _RecRegisterStatFloat((rec_type), (name), (data_default), REC_PERSISTENCE_TYPE(persist_type))
00088 
00089 int _RecRegisterStatString(RecT rec_type, const char *name, RecString data_default, RecPersistT persist_type);
00090 #define RecRegisterStatString(rec_type, name, data_default, persist_type) _RecRegisterStatString((rec_type), (name), (data_default), REC_PERSISTENCE_TYPE(persist_type))
00091 
00092 int _RecRegisterStatCounter(RecT rec_type, const char *name, RecCounter data_default, RecPersistT persist_type);
00093 #define RecRegisterStatCounter(rec_type, name, data_default, persist_type) _RecRegisterStatCounter((rec_type), (name), (data_default), REC_PERSISTENCE_TYPE(persist_type))
00094 
00095 
00096 
00097 
00098 
00099 int RecRegisterConfigInt(RecT rec_type, const char *name,
00100                          RecInt data_default, RecUpdateT update_type,
00101                          RecCheckT check_type, const char *ccheck_regex, RecAccessT access_type = RECA_NULL);
00102 
00103 int RecRegisterConfigFloat(RecT rec_type, const char *name,
00104                            RecFloat data_default, RecUpdateT update_type,
00105                            RecCheckT check_type, const char *check_regex, RecAccessT access_type = RECA_NULL);
00106 
00107 int RecRegisterConfigString(RecT rec_type, const char *name,
00108                             const char *data_default, RecUpdateT update_type,
00109                             RecCheckT check_type, const char *check_regex, RecAccessT access_type = RECA_NULL);
00110 
00111 int RecRegisterConfigCounter(RecT rec_type, const char *name,
00112                              RecCounter data_default, RecUpdateT update_type,
00113                              RecCheckT check_type, const char *check_regex, RecAccessT access_type = RECA_NULL);
00114 
00115 
00116 
00117 
00118 
00119 int RecLinkConfigInt(const char *name, RecInt * rec_int);
00120 int RecLinkConfigInt32(const char *name, int32_t * p_int32);
00121 int RecLinkConfigUInt32(const char *name, uint32_t * p_uint32);
00122 int RecLinkConfigFloat(const char *name, RecFloat * rec_float);
00123 int RecLinkConfigCounter(const char *name, RecCounter * rec_counter);
00124 int RecLinkConfigString(const char *name, RecString * rec_string);
00125 int RecLinkConfigByte(const char *name, RecByte * rec_byte);
00126 int RecLinkConfigBool(const char *name, RecBool * rec_byte);
00127 
00128 int RecRegisterConfigUpdateCb(const char *name, RecConfigUpdateCb update_cb, void *cookie);
00129 int RecRegisterRawStatUpdateFunc(const char *name, RecRawStatBlock * rsb, int id, RecStatUpdateFunc update_func, void *cookie);
00130 
00131 
00132 
00133 
00134 
00135 
00136 
00137 
00138 
00139 
00140 
00141 
00142 
00143 int RecSetRecordConvert(const char *name, const RecString rec_string, bool lock = true, bool inc_version = true);
00144 int RecSetRecordInt(const char *name, RecInt rec_int, bool lock = true, bool inc_version = true);
00145 int RecSetRecordFloat(const char *name, RecFloat rec_float, bool lock = true, bool inc_version = true);
00146 int RecSetRecordString(const char *name, const RecString rec_string, bool lock = true, bool inc_version = true);
00147 int RecSetRecordCounter(const char *name, RecCounter rec_counter, bool lock = true, bool inc_version = true);
00148 
00149 int RecGetRecordInt(const char *name, RecInt * rec_int, bool lock = true);
00150 int RecGetRecordFloat(const char *name, RecFloat * rec_float, bool lock = true);
00151 int RecGetRecordString(const char *name, char *buf, int buf_len, bool lock = true);
00152 int RecGetRecordString_Xmalloc(const char *name, RecString * rec_string, bool lock = true);
00153 int RecGetRecordCounter(const char *name, RecCounter * rec_counter, bool lock = true);
00154 
00155 int RecGetRecordByte(const char *name, RecByte * rec_byte, bool lock = true);
00156 
00157 int RecGetRecordBool(const char *name, RecBool * rec_byte, bool lock = true);
00158 
00159 
00160 
00161 
00162 int RecGetRecordType(const char *name, RecT * rec_type, bool lock = true);
00163 int RecGetRecordDataType(const char *name, RecDataT * data_type, bool lock = true);
00164 int RecGetRecordPersistenceType(const char *name, RecPersistT * persist_type, bool lock = true);
00165 int RecGetRecordOrderAndId(const char *name, int *order, int *id, bool lock = true);
00166 
00167 int RecGetRecordUpdateType(const char *name, RecUpdateT * update_type, bool lock = true);
00168 int RecGetRecordCheckType(const char *name, RecCheckT * check_type, bool lock = true);
00169 int RecGetRecordCheckExpr(const char *name, char **check_expr, bool lock = true);
00170 int RecGetRecordDefaultDataString_Xmalloc(char *name, char **buf, bool lock = true);
00171 
00172 int RecGetRecordAccessType(const char *name, RecAccessT * secure, bool lock = true);
00173 int RecSetRecordAccessType(const char *name, RecAccessT secure, bool lock = true);
00174 
00175 void RecGetRecordTree(char *subtree = NULL);
00176 void RecGetRecordList(char *, char ***, int *);
00177 int RecGetRecordPrefix_Xmalloc(char *prefix, char **result, int *result_len);
00178 
00179 
00180 
00181 
00182 
00183 
00184 
00185 void RecSignalManager(int id, const char * , size_t);
00186 
00187 static inline void
00188 RecSignalManager(int id, const char * str) {
00189   RecSignalManager(id, str, strlen(str + 1));
00190 }
00191 
00192 
00193 void RecSignalWarning(int sig, const char * fmt, ...)
00194   TS_PRINTFLIKE(2, 3);
00195 
00196 
00197 
00198 
00199 #define REC_ReadConfigInt32(_var,_config_var_name) do { \
00200   RecInt tmp = 0; \
00201   RecGetRecordInt(_config_var_name, (RecInt*) &tmp); \
00202   _var = (int32_t)tmp; \
00203 } while (0)
00204 
00205 #define REC_ReadConfigInteger(_var,_config_var_name) do { \
00206   RecInt tmp = 0; \
00207   RecGetRecordInt(_config_var_name, &tmp); \
00208   _var = tmp; \
00209 } while (0)
00210 
00211 #define REC_ReadConfigFloat(_var,_config_var_name) do { \
00212   RecFloat tmp = 0; \
00213   RecGetRecordFloat(_config_var_name, &tmp); \
00214   _var = tmp; \
00215 } while (0)
00216 
00217 #define REC_ReadConfigStringAlloc(_var,_config_var_name) \
00218   RecGetRecordString_Xmalloc(_config_var_name, (RecString*)&_var)
00219 
00220 #define REC_ReadConfigString(_var, _config_var_name, _len) \
00221   RecGetRecordString(_config_var_name, _var, _len)
00222 
00223 #define REC_RegisterConfigUpdateFunc(_config_var_name, func, flag) \
00224   RecRegisterConfigUpdateCb(_config_var_name, func, flag)
00225 
00226 #define REC_EstablishStaticConfigInteger(_var, _config_var_name) do { \
00227   RecLinkConfigInt(_config_var_name, &_var); \
00228   _var = (int64_t)REC_ConfigReadInteger(_config_var_name); \
00229 } while (0)
00230 
00231 #define REC_EstablishStaticConfigInt32(_var, _config_var_name) do { \
00232   RecLinkConfigInt32(_config_var_name, &_var); \
00233   _var = (int32_t)REC_ConfigReadInteger(_config_var_name); \
00234 } while (0)
00235 
00236 #define REC_EstablishStaticConfigInt32U(_var, _config_var_name) do { \
00237   RecLinkConfigUInt32(_config_var_name, &_var); \
00238   _var = (int32_t)REC_ConfigReadInteger(_config_var_name); \
00239 } while (0)
00240 
00241 
00242 
00243 
00244 
00245 
00246 
00247 
00248 #define REC_EstablishStaticConfigStringAlloc(_var, _config_var_name) do { \
00249   if (RecLinkConfigString(_config_var_name, &_var) == REC_ERR_OKAY) \
00250     ats_free(_var);                                                    \
00251   _var = (RecString)REC_ConfigReadString(_config_var_name); \
00252 } while (0)
00253 
00254 #define REC_EstablishStaticConfigFloat(_var, _config_var_name) do { \
00255   RecLinkConfigFloat(_config_var_name, &_var); \
00256   _var = (RecFloat)REC_ConfigReadFloat(_config_var_name); \
00257 } while (0)
00258 
00259 
00260 
00261 #define REC_EstablishStaticConfigByte(_var, _config_var_name) do { \
00262     RecLinkConfigByte(_config_var_name, &_var); \
00263     _var = (RecByte)REC_ConfigReadInteger(_config_var_name);    \
00264   } while (0)
00265 
00266 
00267 
00268 #define REC_EstablishStaticConfigBool(_var, _config_var_name) do { \
00269     RecLinkConfigBool(_config_var_name, &_var); \
00270     _var = 0 != REC_ConfigReadInteger(_config_var_name);    \
00271   } while (0)
00272 
00273 RecInt REC_ConfigReadInteger(const char *name);
00274 char *REC_ConfigReadString(const char *name);
00275 RecFloat REC_ConfigReadFloat(const char *name);
00276 RecCounter REC_ConfigReadCounter(const char *name);
00277 
00278 
00279 RecInt REC_readInteger(const char *name, bool * found, bool lock = true);
00280 RecFloat REC_readFloat(char *name, bool * found, bool lock = true);
00281 RecCounter REC_readCounter(char *name, bool * found, bool lock = true);
00282 RecString REC_readString(const char *name, bool * found, bool lock = true);
00283 
00284 
00285 
00286 
00287 int RecResetStatRecord(const char *name);
00288 int RecResetStatRecord(RecT type = RECT_NULL, bool all = false);
00289 
00290 
00291 
00292 
00293 
00294 int RecSetSyncRequired(char *name, bool lock = true);
00295 
00296 
00297 
00298 
00299 typedef void *(*RecManagerCb) (void *opaque_cb_data, char *data_raw, int data_len);
00300 int RecRegisterManagerCb(int _signal, RecManagerCb _fn, void *_data = NULL);
00301 
00302 void RecResizeAdditional(int add);
00303 
00304 #endif