From e5e33247ff9abe01a87bd7b8ebd050c549e2814f Mon Sep 17 00:00:00 2001 From: Lars Müller Date: Sun, 27 May 2007 15:58:19 +0000 Subject: r23166: Bring samba.org's iniparser copy in sync with the upstream version 2.17. (This used to be commit 3fa98245d98436a0f042ffca9bf102e9f920bace) --- source3/iniparser/src/dictionary.c | 8 ++++---- source3/iniparser/src/dictionary.h | 4 ++-- source3/iniparser/src/iniparser.c | 24 +++++++++++++++++++----- source3/iniparser/src/iniparser.h | 22 ++++++++++++++++++---- source3/iniparser/src/strlib.c | 8 ++++---- source3/iniparser/src/strlib.h | 8 ++++---- 6 files changed, 51 insertions(+), 23 deletions(-) (limited to 'source3/iniparser/src') diff --git a/source3/iniparser/src/dictionary.c b/source3/iniparser/src/dictionary.c index edbd6f9a35..b9d426dc7e 100644 --- a/source3/iniparser/src/dictionary.c +++ b/source3/iniparser/src/dictionary.c @@ -4,7 +4,7 @@ @file dictionary.c @author N. Devillard @date Aug 2000 - @version $Revision: 1.23 $ + @version $Revision: 1.25 $ @brief Implements a dictionary for string variables. This module implements a simple dictionary object, i.e. a list @@ -14,10 +14,10 @@ /*--------------------------------------------------------------------------*/ /* - $Id: dictionary.c,v 1.23 2002/06/17 09:30:46 ndevilla Exp $ + $Id: dictionary.c,v 1.25 2007-05-27 13:03:43 ndevilla Exp $ $Author: ndevilla $ - $Date: 2002/06/17 09:30:46 $ - $Revision: 1.23 $ + $Date: 2007-05-27 13:03:43 $ + $Revision: 1.25 $ */ /*--------------------------------------------------------------------------- diff --git a/source3/iniparser/src/dictionary.h b/source3/iniparser/src/dictionary.h index dcab6e7511..b332680b04 100644 --- a/source3/iniparser/src/dictionary.h +++ b/source3/iniparser/src/dictionary.h @@ -14,9 +14,9 @@ /*--------------------------------------------------------------------------*/ /* - $Id: dictionary.h,v 1.11 2002/06/17 09:30:46 ndevilla Exp $ + $Id: dictionary.h,v 1.11 2002-06-17 09:30:46 ndevilla Exp $ $Author: ndevilla $ - $Date: 2002/06/17 09:30:46 $ + $Date: 2002-06-17 09:30:46 $ $Revision: 1.11 $ */ diff --git a/source3/iniparser/src/iniparser.c b/source3/iniparser/src/iniparser.c index 0cb452b265..09340876d8 100644 --- a/source3/iniparser/src/iniparser.c +++ b/source3/iniparser/src/iniparser.c @@ -4,16 +4,16 @@ @file iniparser.c @author N. Devillard @date Mar 2000 - @version $Revision: 2.14 $ + @version $Revision: 2.17 $ @brief Parser for ini files. */ /*--------------------------------------------------------------------------*/ /* - $Id: iniparser.c,v 2.14 2002/12/12 10:49:01 ndevilla Exp $ + $Id: iniparser.c,v 2.17 2007-05-27 13:03:43 ndevilla Exp $ $Author: ndevilla $ - $Date: 2002/12/12 10:49:01 $ - $Revision: 2.14 $ + $Date: 2007-05-27 13:03:43 $ + $Revision: 2.17 $ */ /*--------------------------------------------------------------------------- @@ -280,6 +280,20 @@ char * iniparser_getstring(dictionary * d, const char * key, char * def) This function queries a dictionary for a key. A key as read from an ini file is given as "section:key". If the key cannot be found, the notfound value is returned. + + Supported values for integers include the usual C notation + so decimal, octal (starting with 0) and hexadecimal (starting with 0x) + are supported. Examples: + + "42" -> 42 + "042" -> 34 (octal -> decimal) + "0x42" -> 66 (hexa -> decimal) + + Warning: the conversion may overflow in various ways. Conversion is + totally outsourced to strtol(), see the associated man page for overflow + handling. + + Credits: Thanks to A. Becker for suggesting strtol() */ /*--------------------------------------------------------------------------*/ int iniparser_getint(dictionary * d, const char * key, int notfound) @@ -288,7 +302,7 @@ int iniparser_getint(dictionary * d, const char * key, int notfound) str = iniparser_getstring(d, key, INI_INVALID_KEY); if (str==INI_INVALID_KEY) return notfound ; - return atoi(str); + return (int)strtol(str, NULL, 0); } diff --git a/source3/iniparser/src/iniparser.h b/source3/iniparser/src/iniparser.h index 2df8ffe837..5bbd9045cf 100644 --- a/source3/iniparser/src/iniparser.h +++ b/source3/iniparser/src/iniparser.h @@ -4,16 +4,16 @@ @file iniparser.h @author N. Devillard @date Mar 2000 - @version $Revision: 1.20 $ + @version $Revision: 1.23 $ @brief Parser for ini files. */ /*--------------------------------------------------------------------------*/ /* - $Id: iniparser.h,v 1.20 2005/08/19 17:23:21 ndevilla Exp $ + $Id: iniparser.h,v 1.23 2006-09-27 11:03:35 ndevilla Exp $ $Author: ndevilla $ - $Date: 2005/08/19 17:23:21 $ - $Revision: 1.20 $ + $Date: 2006-09-27 11:03:35 $ + $Revision: 1.23 $ */ #ifndef _INIPARSER_H_ @@ -154,6 +154,20 @@ char * iniparser_getstring(dictionary * d, const char * key, char * def); This function queries a dictionary for a key. A key as read from an ini file is given as "section:key". If the key cannot be found, the notfound value is returned. + + Supported values for integers include the usual C notation + so decimal, octal (starting with 0) and hexadecimal (starting with 0x) + are supported. Examples: + + - "42" -> 42 + - "042" -> 34 (octal -> decimal) + - "0x42" -> 66 (hexa -> decimal) + + Warning: the conversion may overflow in various ways. Conversion is + totally outsourced to strtol(), see the associated man page for overflow + handling. + + Credits: Thanks to A. Becker for suggesting strtol() */ /*--------------------------------------------------------------------------*/ int iniparser_getint(dictionary * d, const char * key, int notfound); diff --git a/source3/iniparser/src/strlib.c b/source3/iniparser/src/strlib.c index b954a36cf7..f0d85aea58 100644 --- a/source3/iniparser/src/strlib.c +++ b/source3/iniparser/src/strlib.c @@ -4,7 +4,7 @@ @file strlib.c @author N. Devillard @date Jan 2001 - @version $Revision: 1.8 $ + @version $Revision: 1.9 $ @brief Various string handling routines to complement the C lib. This modules adds a few complementary string routines usually missing @@ -13,10 +13,10 @@ /*--------------------------------------------------------------------------*/ /* - $Id: strlib.c,v 1.8 2002/12/12 10:29:16 ndevilla Exp $ + $Id: strlib.c,v 1.9 2006-09-27 11:04:11 ndevilla Exp $ $Author: ndevilla $ - $Date: 2002/12/12 10:29:16 $ - $Revision: 1.8 $ + $Date: 2006-09-27 11:04:11 $ + $Revision: 1.9 $ */ /*--------------------------------------------------------------------------- diff --git a/source3/iniparser/src/strlib.h b/source3/iniparser/src/strlib.h index 39ca26f1df..cd70a6287d 100644 --- a/source3/iniparser/src/strlib.h +++ b/source3/iniparser/src/strlib.h @@ -4,7 +4,7 @@ @file strlib.h @author N. Devillard @date Jan 2001 - @version $Revision: 1.3 $ + @version $Revision: 1.4 $ @brief Various string handling routines to complement the C lib. This modules adds a few complementary string routines usually missing @@ -13,10 +13,10 @@ /*--------------------------------------------------------------------------*/ /* - $Id: strlib.h,v 1.3 2001/10/19 08:31:41 ndevilla Exp $ + $Id: strlib.h,v 1.4 2006-09-27 11:04:11 ndevilla Exp $ $Author: ndevilla $ - $Date: 2001/10/19 08:31:41 $ - $Revision: 1.3 $ + $Date: 2006-09-27 11:04:11 $ + $Revision: 1.4 $ */ #ifndef _STRLIB_H_ -- cgit