aboutsummaryrefslogtreecommitdiff
path: root/include/dictionary.h
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2024-12-17 13:49:20 +0100
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2024-12-17 13:51:35 +0100
commit2764911eb37dfb302d44bb5b2d5984d662b40c27 (patch)
treebb984452bf180089d8ef3527137ba44cf3a8664d /include/dictionary.h
parente17ffbfb1ab07f8d0d4b864a5f477e119843722d (diff)
Import a more recent version of libiniparser
We use a vendored library for parsing ini files. Our copy of this library has not been updated since 2007. This commit imports the recent version of the ini parsing library from upstream source at https://gitlab.com/iniparser/iniparser Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'include/dictionary.h')
-rw-r--r--include/dictionary.h52
1 files changed, 24 insertions, 28 deletions
diff --git a/include/dictionary.h b/include/dictionary.h
index c7d1790..f459cfe 100644
--- a/include/dictionary.h
+++ b/include/dictionary.h
@@ -3,8 +3,6 @@
/**
@file dictionary.h
@author N. Devillard
- @date Sep 2007
- @version $Revision: 1.12 $
@brief Implements a dictionary for string variables.
This module implements a simple dictionary object, i.e. a list
@@ -13,33 +11,27 @@
*/
/*--------------------------------------------------------------------------*/
-/*
- $Id: dictionary.h,v 1.12 2007-11-23 21:37:00 ndevilla Exp $
- $Author: ndevilla $
- $Date: 2007-11-23 21:37:00 $
- $Revision: 1.12 $
-*/
-
#ifndef _DICTIONARY_H_
#define _DICTIONARY_H_
/*---------------------------------------------------------------------------
- Includes
+ Includes
---------------------------------------------------------------------------*/
#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
/*---------------------------------------------------------------------------
- New types
+ New types
---------------------------------------------------------------------------*/
/*-------------------------------------------------------------------------*/
/**
- @brief Dictionary object
+ @brief Dictionary object
This object contains a list of string/string associations. Each
association is identified by a unique string key. Looking up values
@@ -48,16 +40,16 @@
*/
/*-------------------------------------------------------------------------*/
typedef struct _dictionary_ {
- int n ; /** Number of entries in dictionary */
- int size ; /** Storage size */
- char ** val ; /** List of string values */
- char ** key ; /** List of string keys */
- unsigned * hash ; /** List of hash values for keys */
+ unsigned n ; /** Number of entries in dictionary */
+ size_t size ; /** Storage size */
+ char ** val ; /** List of string values */
+ char ** key ; /** List of string keys */
+ unsigned * hash ; /** List of hash values for keys */
} dictionary ;
/*---------------------------------------------------------------------------
- Function prototypes
+ Function prototypes
---------------------------------------------------------------------------*/
/*-------------------------------------------------------------------------*/
@@ -72,20 +64,20 @@ typedef struct _dictionary_ {
by comparing the key itself in last resort.
*/
/*--------------------------------------------------------------------------*/
-unsigned dictionary_hash(char * key);
+unsigned dictionary_hash(const char * key);
/*-------------------------------------------------------------------------*/
/**
@brief Create a new dictionary object.
@param size Optional initial size of the dictionary.
- @return 1 newly allocated dictionary objet.
+ @return 1 newly allocated dictionary object.
This function allocates a new dictionary object of given size and returns
it. If you do not know in advance (roughly) the number of entries in the
dictionary, give size=0.
*/
/*--------------------------------------------------------------------------*/
-dictionary * dictionary_new(int size);
+dictionary * dictionary_new(size_t size);
/*-------------------------------------------------------------------------*/
/**
@@ -112,7 +104,7 @@ void dictionary_del(dictionary * vd);
dictionary object, you should not try to free it or modify it.
*/
/*--------------------------------------------------------------------------*/
-char * dictionary_get(dictionary * d, char * key, char * def);
+const char * dictionary_get(const dictionary * d, const char * key, const char * def);
/*-------------------------------------------------------------------------*/
@@ -141,7 +133,7 @@ char * dictionary_get(dictionary * d, char * key, char * def);
This function returns non-zero in case of failure.
*/
/*--------------------------------------------------------------------------*/
-int dictionary_set(dictionary * vd, char * key, char * val);
+int dictionary_set(dictionary * vd, const char * key, const char * val);
/*-------------------------------------------------------------------------*/
/**
@@ -154,7 +146,7 @@ int dictionary_set(dictionary * vd, char * key, char * val);
key cannot be found.
*/
/*--------------------------------------------------------------------------*/
-void dictionary_unset(dictionary * d, char * key);
+void dictionary_unset(dictionary * d, const char * key);
/*-------------------------------------------------------------------------*/
@@ -169,6 +161,10 @@ void dictionary_unset(dictionary * d, char * key);
output file pointers.
*/
/*--------------------------------------------------------------------------*/
-void dictionary_dump(dictionary * d, FILE * out);
+void dictionary_dump(const dictionary * d, FILE * out);
+
+#ifdef __cplusplus
+}
+#endif
#endif