--- sbbs/src/xpdev/ini_file.h 2018/04/24 16:41:24 1.1.1.1 +++ sbbs/src/xpdev/ini_file.h 2018/04/24 16:45:29 1.1.1.2 @@ -1,14 +1,14 @@ /* ini_file.h */ -/* Functions to parse ini files */ +/* Functions to parse ini (initialization / configuration) files */ -/* $Id: ini_file.h,v 1.1.1.1 2018/04/24 16:41:24 root Exp $ */ +/* $Id: ini_file.h,v 1.1.1.2 2018/04/24 16:45:29 root Exp $ */ /**************************************************************************** * @format.tab-size 4 (Plain Text/Source Code File Header) * * @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) * * * - * Copyright 2005 Rob Swindell - http://www.synchro.net/copyright.html * + * Copyright 2011 Rob Swindell - http://www.synchro.net/copyright.html * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public License * @@ -79,6 +79,9 @@ str_list_t iniLogLevelStringList(void); /* These functions read a single key of the specified type */ char* iniReadString(FILE*, const char* section, const char* key ,const char* deflt, char* value); +/* If the key doesn't exist, iniReadExistingString just returns NULL */ +char* iniReadExistingString(FILE*, const char* section, const char* key + ,const char* deflt, char* value); str_list_t iniReadStringList(FILE*, const char* section, const char* key ,const char* sep, const char* deflt); long iniReadInteger(FILE*, const char* section, const char* key @@ -87,8 +90,8 @@ ushort iniReadShortInt(FILE*, const cha ,ushort deflt); ulong iniReadLongInt(FILE*, const char* section, const char* key ,ulong deflt); -ulong iniReadBytes(FILE*, const char* section, const char* key - ,ulong unit, ulong deflt); +int64_t iniReadBytes(FILE*, const char* section, const char* key + ,ulong unit, int64_t deflt); double iniReadFloat(FILE*, const char* section, const char* key ,double deflt); BOOL iniReadBool(FILE*, const char* section, const char* key @@ -97,6 +100,8 @@ time_t iniReadDateTime(FILE*, const cha ,time_t deflt); unsigned iniReadEnum(FILE*, const char* section, const char* key ,str_list_t names, unsigned deflt); +unsigned* iniReadEnumList(FILE*, const char* section, const char* key + ,str_list_t names, unsigned* count, const char* sep, const char* deflt); long iniReadNamedInt(FILE*, const char* section, const char* key ,named_long_t*, long deflt); double iniReadNamedFloat(FILE*, const char* section, const char* key @@ -127,7 +132,10 @@ named_string_t** iniGetNamedStringList(str_list_t list, const char* section); char* iniGetString(str_list_t, const char* section, const char* key - ,const char* deflt, char* value); + ,const char* deflt, char* value /* may be NULL */); +/* If the key doesn't exist, iniGetExistingString just returns NULL */ +char* iniGetExistingString(str_list_t, const char* section, const char* key + ,const char* deflt, char* value /* may be NULL */); str_list_t iniGetStringList(str_list_t, const char* section, const char* key ,const char* sep, const char* deflt); long iniGetInteger(str_list_t, const char* section, const char* key @@ -136,8 +144,8 @@ ushort iniGetShortInt(str_list_t, const ,ushort deflt); ulong iniGetLongInt(str_list_t, const char* section, const char* key ,ulong deflt); -ulong iniGetBytes(str_list_t, const char* section, const char* key - ,ulong unit, ulong deflt); +int64_t iniGetBytes(str_list_t, const char* section, const char* key + ,ulong unit, int64_t deflt); double iniGetFloat(str_list_t, const char* section, const char* key ,double deflt); BOOL iniGetBool(str_list_t, const char* section, const char* key @@ -146,12 +154,15 @@ time_t iniGetDateTime(str_list_t, const ,time_t deflt); unsigned iniGetEnum(str_list_t, const char* section, const char* key ,str_list_t names, unsigned deflt); +unsigned* iniGetEnumList(str_list_t, const char* section, const char* key + ,str_list_t names, unsigned* count, const char* sep, const char* deflt); long iniGetNamedInt(str_list_t, const char* section, const char* key ,named_long_t*, long deflt); double iniGetNamedFloat(str_list_t, const char* section, const char* key ,named_double_t*, double deflt); ulong iniGetBitField(str_list_t, const char* section, const char* key ,ini_bitdesc_t* bitdesc, ulong deflt); +str_list_t iniGetSection(str_list_t, const char *section); #define iniGetLogLevel(l,s,k,d) iniGetEnum(l,s,k,iniLogLevelStringList(),d) #if !defined(NO_SOCKET_SUPPORT) @@ -175,7 +186,7 @@ char* iniSetShortInt(str_list_t*, const ,ini_style_t*); char* iniSetLongInt(str_list_t*, const char* section, const char* key, ulong value ,ini_style_t*); -char* iniSetBytes(str_list_t*, const char* section, const char* key, ulong unit, ulong value +char* iniSetBytes(str_list_t*, const char* section, const char* key, ulong unit, int64_t value ,ini_style_t*); char* iniSetHexInt(str_list_t*, const char* section, const char* key, ulong value ,ini_style_t*); @@ -187,6 +198,8 @@ char* iniSetDateTime(str_list_t*, const ,ini_style_t*); char* iniSetEnum(str_list_t*, const char* section, const char* key, str_list_t names ,unsigned value, ini_style_t*); +char* iniSetEnumList(str_list_t*, const char* section, const char* key + ,const char* sep, str_list_t names, unsigned* values, unsigned count, ini_style_t*); char* iniSetNamedInt(str_list_t*, const char* section, const char* key, named_long_t* ,long value, ini_style_t*); char* iniSetNamedFloat(str_list_t*, const char* section, const char* key, named_double_t* @@ -206,11 +219,17 @@ size_t iniAppendSection(str_list_t*, co BOOL iniSectionExists(str_list_t, const char* section); BOOL iniKeyExists(str_list_t, const char* section, const char* key); BOOL iniValueExists(str_list_t, const char* section, const char* key); +char* iniPopKey(str_list_t*, const char* section, const char* key, char* value); BOOL iniRemoveKey(str_list_t*, const char* section, const char* key); BOOL iniRemoveValue(str_list_t*, const char* section, const char* key); BOOL iniRemoveSection(str_list_t*, const char* section); BOOL iniRenameSection(str_list_t*, const char* section, const char* newname); +/* + * Too handy to leave internal + */ +unsigned* parseEnumList(const char* values, const char* sep, str_list_t names, unsigned* count); + #if defined(__cplusplus) } #endif