From: Yehuda Sadeh Date: Wed, 21 Jan 2009 22:23:15 +0000 (-0800) Subject: confutils: adding missing file X-Git-Tag: v0.7~342 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=1acf016c51639348c275ff257ec356b13271befc;p=ceph.git confutils: adding missing file --- diff --git a/src/common/ConfUtils.h b/src/common/ConfUtils.h new file mode 100644 index 000000000000..fa891d8a8eac --- /dev/null +++ b/src/common/ConfUtils.h @@ -0,0 +1,35 @@ +#ifndef __CONFUTILS_H +#define __CONFUTILS_H + +#include +#include +#include + +typedef std::map ConfMap; +typedef std::map ConfUnsortedMap; +typedef std::map SectionMap; + +class ConfFile { + int fd; + char *filename; + SectionMap sections; + std::list list; + + struct conf_line *_find_var(char *section, char* var); +public: + ConfFile(char *fname) : filename(strdup(fname)) {} + ~ConfFile() { free(filename); } + + int parse(); + int read_int(char *section, char *var, int *val, int def_val); + int read_bool(char *section, char *var, bool *val, bool def_val); + int read_str(char *section, char *var, char *val, int size, char *def_val); + int read_str_alloc(char *section, char *var, char **val, char *def_val); + int read_float(char *section, char *var, float *val, float def_val); + + int write_int(char *section, char *var, int val); + + void dump(); +}; + +#endif