summaryrefslogtreecommitdiff
path: root/source3/iniparser/src/iniparser.c
diff options
context:
space:
mode:
authorLars Müller <lmuelle@samba.org>2007-05-27 15:58:19 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:22:51 -0500
commite5e33247ff9abe01a87bd7b8ebd050c549e2814f (patch)
tree3266f7257f09f87cd76a2632d2f68309edb58f8d /source3/iniparser/src/iniparser.c
parent40a3b796ceac468b887b981422680a8139142a07 (diff)
downloadsamba-e5e33247ff9abe01a87bd7b8ebd050c549e2814f.tar.gz
samba-e5e33247ff9abe01a87bd7b8ebd050c549e2814f.tar.bz2
samba-e5e33247ff9abe01a87bd7b8ebd050c549e2814f.zip
r23166: Bring samba.org's iniparser copy in sync with the upstream version 2.17.
(This used to be commit 3fa98245d98436a0f042ffca9bf102e9f920bace)
Diffstat (limited to 'source3/iniparser/src/iniparser.c')
-rw-r--r--source3/iniparser/src/iniparser.c24
1 files changed, 19 insertions, 5 deletions
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);
}