From e85c28ce148e0740697c76e9751b0d9cacbe67d1 Mon Sep 17 00:00:00 2001 From: blacksirius Date: Sun, 10 Jun 2012 16:04:24 +0000 Subject: - added some missing copyrights - merged (bs-coreoptimize->trunk) generic athena style configuration parser (raconf) - merged (bs-coreoptimize->trunk) threadsafe memory pool (mempool) [i need it for the new 'socket' system] - set svn:eol-style property on newer files were it was missing git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@16263 54d463be-8e91-2dee-dedb-b68131a5f0ec --- src/common/raconf.h | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 src/common/raconf.h (limited to 'src/common/raconf.h') diff --git a/src/common/raconf.h b/src/common/raconf.h new file mode 100644 index 000000000..68a2b51b2 --- /dev/null +++ b/src/common/raconf.h @@ -0,0 +1,59 @@ +// Copyright (c) rAthena Project (www.rathena.org) - Licensed under GNU GPL +// For more information, see LICENCE in the main folder + +#ifndef _rA_CONF_H_ +#define _rA_CONF_H_ + +#include "../common/cbasetypes.h" + +// rAthena generic configuration file parser +// +// Config file Syntax is athena style +// extended with ini style support (including sections) +// +// Comments are started with // or ; (ini style) +// + +typedef struct raconf *raconf; + + +/** + * Parses a rAthna Configuration file + * + * @param file_name path to the file to parse + * + * @returns not NULL incase of success + */ +raconf raconf_parse(const char *file_name); + + +/** + * Frees a Handle received from raconf_parse + * + * @param rc - the handle to free + */ +void raconf_destroy(raconf rc); + + +/** + * Gets the value for Section / Key pair, if key not exists returns _default! + * + */ +bool raconf_getbool(raconf rc, const char *section, const char *key, bool _default); +float raconf_getfloat(raconf rc,const char *section, const char *key, float _default); +int64 raconf_getint(raconf rc, const char *section, const char *key, int64 _default); +const char* raconf_getstr(raconf rc, const char *section, const char *key, const char *_default); + +/** + * Gets the value for Section / Key pair, but has fallback section option if not found in section, + * if not found in both - default gets returned. + * + */ +bool raconf_getboolEx(raconf rc, const char *section, const char *fallback_section, const char *key, bool _default); +float raconf_getfloatEx(raconf rc,const char *section, const char *fallback_section, const char *key, float _default); +int64 raconf_getintEx(raconf rc, const char *section, const char *fallback_section, const char *key, int64 _default); +const char* raconf_getstrEx(raconf rc, const char *section, const char *fallback_section, const char *key, const char *_default); + + + +#endif -- cgit v1.2.3-70-g09d2