From c62750fee242ca18e087646dda1aedf9f750e0cb Mon Sep 17 00:00:00 2001 From: chenguoping Date: Mon, 2 Sep 2019 11:51:45 +0800 Subject: [PATCH 1/4] add NULL check in dictionary_get --- html/doxygen.css | 545 ----------------------------------- html/doxygen.png | Bin 1281 -> 0 bytes html/globals_func.html | 64 ----- html/index.html | 101 ------- html/iniparser_8h.html | 583 -------------------------------------- html/iniparser_8main.html | 19 -- html/tab_b.gif | Bin 35 -> 0 bytes html/tab_l.gif | Bin 706 -> 0 bytes html/tab_r.gif | Bin 2585 -> 0 bytes html/tabs.css | 105 ------- src/dictionary.c | 3 +- test/test_dictionary.c | 49 ++++ 12 files changed, 51 insertions(+), 1418 deletions(-) delete mode 100644 html/doxygen.css delete mode 100644 html/doxygen.png delete mode 100644 html/globals_func.html delete mode 100644 html/index.html delete mode 100644 html/iniparser_8h.html delete mode 100644 html/iniparser_8main.html delete mode 100644 html/tab_b.gif delete mode 100644 html/tab_l.gif delete mode 100644 html/tab_r.gif delete mode 100644 html/tabs.css diff --git a/html/doxygen.css b/html/doxygen.css deleted file mode 100644 index d6aaf28..0000000 --- a/html/doxygen.css +++ /dev/null @@ -1,545 +0,0 @@ -/* The standard CSS for doxygen */ - -body, table, div, p, dl { - font-family: Lucida Grande, Verdana, Geneva, Arial, sans-serif; - font-size: 12px; -} - -/* @group Heading Levels */ - -h1 { - text-align: center; - font-size: 150%; -} - -h2 { - font-size: 120%; -} - -h3 { - font-size: 100%; -} - -dt { - font-weight: bold; -} - -div.multicol { - -moz-column-gap: 1em; - -webkit-column-gap: 1em; - -moz-column-count: 3; - -webkit-column-count: 3; -} - -p.startli, p.startdd, p.starttd { - margin-top: 2px; -} - -p.endli { - margin-bottom: 0px; -} - -p.enddd { - margin-bottom: 4px; -} - -p.endtd { - margin-bottom: 2px; -} - -/* @end */ - -caption { - font-weight: bold; -} - -span.legend { - font-size: 70%; - text-align: center; -} - -h3.version { - font-size: 90%; - text-align: center; -} - -div.qindex, div.navtab{ - background-color: #e8eef2; - border: 1px solid #84b0c7; - text-align: center; - margin: 2px; - padding: 2px; -} - -div.qindex, div.navpath { - width: 100%; - line-height: 140%; -} - -div.navtab { - margin-right: 15px; -} - -/* @group Link Styling */ - -a { - color: #153788; - font-weight: normal; - text-decoration: none; -} - -.contents a:visited { - color: #1b77c5; -} - -a:hover { - text-decoration: underline; -} - -a.qindex { - font-weight: bold; -} - -a.qindexHL { - font-weight: bold; - background-color: #6666cc; - color: #ffffff; - border: 1px double #9295C2; -} - -.contents a.qindexHL:visited { - color: #ffffff; -} - -a.el { - font-weight: bold; -} - -a.elRef { -} - -a.code { - color: #3030f0; -} - -a.codeRef { - color: #3030f0; -} - -/* @end */ - -dl.el { - margin-left: -1cm; -} - -.fragment { - font-family: monospace, fixed; - font-size: 105%; -} - -pre.fragment { - border: 1px solid #CCCCCC; - background-color: #f5f5f5; - padding: 4px 6px; - margin: 4px 8px 4px 2px; - overflow: auto; - word-wrap: break-word; - font-size: 9pt; - line-height: 125%; -} - -div.ah { - background-color: black; - font-weight: bold; - color: #ffffff; - margin-bottom: 3px; - margin-top: 3px -} - -div.groupHeader { - margin-left: 16px; - margin-top: 12px; - margin-bottom: 6px; - font-weight: bold; -} - -div.groupText { - margin-left: 16px; - font-style: italic; -} - -body { - background: white; - color: black; - margin-right: 20px; - margin-left: 20px; -} - -td.indexkey { - background-color: #e8eef2; - font-weight: bold; - border: 1px solid #CCCCCC; - margin: 2px 0px 2px 0; - padding: 2px 10px; -} - -td.indexvalue { - background-color: #e8eef2; - border: 1px solid #CCCCCC; - padding: 2px 10px; - margin: 2px 0px; -} - -tr.memlist { - background-color: #f0f0f0; -} - -p.formulaDsp { - text-align: center; -} - -img.formulaDsp { - -} - -img.formulaInl { - vertical-align: middle; -} - -div.center { - text-align: center; - margin-top: 0px; - margin-bottom: 0px; - padding: 0px; -} - -div.center img { - border: 0px; -} - -img.footer { - border: 0px; - vertical-align: middle; -} - -/* @group Code Colorization */ - -span.keyword { - color: #008000 -} - -span.keywordtype { - color: #604020 -} - -span.keywordflow { - color: #e08000 -} - -span.comment { - color: #800000 -} - -span.preprocessor { - color: #806020 -} - -span.stringliteral { - color: #002080 -} - -span.charliteral { - color: #008080 -} - -span.vhdldigit { - color: #ff00ff -} - -span.vhdlchar { - color: #000000 -} - -span.vhdlkeyword { - color: #700070 -} - -span.vhdllogic { - color: #ff0000 -} - -/* @end */ - -.search { - color: #003399; - font-weight: bold; -} - -form.search { - margin-bottom: 0px; - margin-top: 0px; -} - -input.search { - font-size: 75%; - color: #000080; - font-weight: normal; - background-color: #e8eef2; -} - -td.tiny { - font-size: 75%; -} - -.dirtab { - padding: 4px; - border-collapse: collapse; - border: 1px solid #84b0c7; -} - -th.dirtab { - background: #e8eef2; - font-weight: bold; -} - -hr { - height: 0px; - border: none; - border-top: 1px solid #666; -} - -hr.footer { - height: 1px; -} - -/* @group Member Descriptions */ - -.mdescLeft, .mdescRight, -.memItemLeft, .memItemRight, -.memTemplItemLeft, .memTemplItemRight, .memTemplParams { - background-color: #FAFAFA; - border: none; - margin: 4px; - padding: 1px 0 0 8px; -} - -.mdescLeft, .mdescRight { - padding: 0px 8px 4px 8px; - color: #555; -} - -.memItemLeft, .memItemRight, .memTemplParams { - border-top: 1px solid #ccc; -} - -.memItemLeft, .memTemplItemLeft { - white-space: nowrap; -} - -.memTemplParams { - color: #606060; - white-space: nowrap; -} - -/* @end */ - -/* @group Member Details */ - -/* Styles for detailed member documentation */ - -.memtemplate { - font-size: 80%; - color: #606060; - font-weight: normal; - margin-left: 3px; -} - -.memnav { - background-color: #e8eef2; - border: 1px solid #84b0c7; - text-align: center; - margin: 2px; - margin-right: 15px; - padding: 2px; -} - -.memitem { - padding: 0; - margin-bottom: 10px; -} - -.memname { - white-space: nowrap; - font-weight: bold; - margin-left: 6px; -} - -.memproto { - border-top: 1px solid #84b0c7; - border-left: 1px solid #84b0c7; - border-right: 1px solid #84b0c7; - padding: 0; - background-color: #d5e1e8; - font-weight: bold; - /* firefox specific markup */ - background-image: -moz-linear-gradient(rgba(228, 233, 245, 1.0) 0%, rgba(193, 205, 232, 1.0) 100%); - -moz-box-shadow: rgba(0, 0, 0, 0.15) 5px 5px 5px; - -moz-border-radius-topright: 8px; - -moz-border-radius-topleft: 8px; - /* webkit specific markup */ - background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from(rgba(228, 233, 245, 1.0)), to(rgba(193, 205, 232, 1.0))); - -webkit-box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.15); - -webkit-border-top-right-radius: 8px; - -webkit-border-top-left-radius: 8px; - -} - -.memdoc { - border-bottom: 1px solid #84b0c7; - border-left: 1px solid #84b0c7; - border-right: 1px solid #84b0c7; - padding: 2px 5px; - background-color: #eef3f5; - border-top-width: 0; - /* firefox specific markup */ - -moz-border-radius-bottomleft: 8px; - -moz-border-radius-bottomright: 8px; - -moz-box-shadow: rgba(0, 0, 0, 0.15) 5px 5px 5px; - /* webkit specific markup */ - -webkit-border-bottom-left-radius: 8px; - -webkit-border-bottom-right-radius: 8px; - -webkit-box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.15); -} - -.paramkey { - text-align: right; -} - -.paramtype { - white-space: nowrap; -} - -.paramname { - color: #602020; - white-space: nowrap; -} -.paramname em { - font-style: normal; -} - -/* @end */ - -/* @group Directory (tree) */ - -/* for the tree view */ - -.ftvtree { - font-family: sans-serif; - margin: 0.5em; -} - -/* these are for tree view when used as main index */ - -.directory { - font-size: 9pt; - font-weight: bold; -} - -.directory h3 { - margin: 0px; - margin-top: 1em; - font-size: 11pt; -} - -/* -The following two styles can be used to replace the root node title -with an image of your choice. Simply uncomment the next two styles, -specify the name of your image and be sure to set 'height' to the -proper pixel height of your image. -*/ - -/* -.directory h3.swap { - height: 61px; - background-repeat: no-repeat; - background-image: url("yourimage.gif"); -} -.directory h3.swap span { - display: none; -} -*/ - -.directory > h3 { - margin-top: 0; -} - -.directory p { - margin: 0px; - white-space: nowrap; -} - -.directory div { - display: none; - margin: 0px; -} - -.directory img { - vertical-align: -30%; -} - -/* these are for tree view when not used as main index */ - -.directory-alt { - font-size: 100%; - font-weight: bold; -} - -.directory-alt h3 { - margin: 0px; - margin-top: 1em; - font-size: 11pt; -} - -.directory-alt > h3 { - margin-top: 0; -} - -.directory-alt p { - margin: 0px; - white-space: nowrap; -} - -.directory-alt div { - display: none; - margin: 0px; -} - -.directory-alt img { - vertical-align: -30%; -} - -/* @end */ - -address { - font-style: normal; - color: #333; -} - -table.doxtable { - border-collapse:collapse; -} - -table.doxtable td, table.doxtable th { - border: 1px solid #153788; - padding: 3px 7px 2px; -} - -table.doxtable th { - background-color: #254798; - color: #FFFFFF; - font-size: 110%; - padding-bottom: 4px; - padding-top: 5px; - text-align:left; -} - diff --git a/html/doxygen.png b/html/doxygen.png deleted file mode 100644 index f0a274bbaffdd67f6d784c894d9cf28729db0e14..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1281 zcmaJ>ZA?>F7(Vx-ms?uoS`b@hdRtpo6o^%HU>M$hfGrBvQnk$LE?p^P!kn&ikhyq! zX~V@&tPF5Qt@V?oTL96Bi%aRiwbe1)9DWQI#?)=HxS7QSw`J`5fAJ*eJbB;uNuKA& zdERDo*{Y<(If(#(B$Lr#;nB(8Y#ia=ZCeW?JfPLuQY`=@cW$k}Rivq|vbxGrRq1Tl9;+(gNt?}UtVKM2`T5t1jLzuL@0UIs`S#vlhl4)^ zLgSYrPj@$+`|j?eSbXTmiHGkWxV8V}BzNR?pl9k_s4pDu9vd5a_UzZEPk)}Ad{AV_ zzddrjrh4=Imr`E06;LY{)YYt?o}L~H@7C}F^WB!Ra=v`Q0bj{>5&$66CWF>mf6vjP z2N>RRY6ZYa=K`76>+|_)Xdwko+7wv}7cN|btOhWb(*{sta~6b?S8Omrxw}!4`NhGr zZVpNqpu1@BE`QGWNTpEpcJVW5izu~2B^GlM?1(OPg)zwW;QcP@Ltcclm>XbJL9C|j z=9!2?ua=uIlf0%AndzHsRC}IyTL$EhAee(fdKB`?27KeS^2M8M_7b~PiCFO&r5LC7 z7gl1*a<8;SjNaw#h=843_AV9iZbWQOAp5YOC^&_F*9K0> zB|6%IDb?aM#3viTxkLU4aXg&@+CkNTOnQ1iMP*^?b|^lJy$4C)Zk4isV!|RZ*XhXh zw8q3$=*0LeGC!XI_Wc?dkT~3+*Gu%%yIqP+Wr3H$=&ROMQU6q}Ag^P~>c5vAEO;a- z_dK-3PPeKar%)6$j~vI2#*-YH!1h6HYVtwCX5_wM`iF#UKz&&@9Oo5w3%XGYrX zW>dY~)SG-((Yim%`InwgTvyRC?e=Wh^8KCao!R6Eg&TpVWUY1sN~4G}V?nFnEGo-; zHZ_$eW9-GnC%^WS9b z@p;-$oH#MtC0v>Q$HX%4^JdFdO$0cbv-W)Q TtK}Eh@>>I#ipmV1>S*>q-hkC} diff --git a/html/globals_func.html b/html/globals_func.html deleted file mode 100644 index 429cf31..0000000 --- a/html/globals_func.html +++ /dev/null @@ -1,64 +0,0 @@ - - - - -iniparser: Data Fields - - - - - -
- -
-
-
-
Generated on Wed Mar 2 22:04:59 2011 for iniparser by  - -doxygen 1.6.3
- - diff --git a/html/index.html b/html/index.html deleted file mode 100644 index 92b5684..0000000 --- a/html/index.html +++ /dev/null @@ -1,101 +0,0 @@ - - - - -iniparser: iniparser documentation - - - - - -
-

iniparser documentation

4.0

-Introduction

-

iniParser is a simple C library offering ini file parsing services. The library is pretty small (less than 1500 lines of C) and robust, and does not depend on any other external library to compile. It is written in ANSI C and should compile on most platforms without difficulty.

-

-What is an ini file?

-

An ini file is an ASCII file describing simple parameters (character strings, integers, floating-point values or booleans) in an explicit format, easy to use and modify for users.

-

An ini file is segmented into Sections, declared by the following syntax:

-
-    [Section Name]
-	

i.e. the section name enclosed in square brackets, alone on a line. Sections names are allowed to contain any character but square brackets or linefeeds.

-

In any section are zero or more variables, declared with the following syntax:

-
-    Key = value ; comment
-	

The key is any string (possibly containing blanks). The value is any character on the right side of the equal sign. Values can be given enclosed with quotes. If no quotes are present, the value is understood as containing all characters between the first and the last non-blank characters before the comment. The following declarations are identical:

-
-    Hello = "this is a long string value" ; comment
-    Hello = this is a long string value ; comment
-	

The semicolon and comment at the end of the line are optional. If there is a comment, it starts from the first character after the semicolon up to the end of the line.

-

Multi-line values can be provided by ending the line with a backslash (\).

-
-    Multiple = Line 1 \
-    Line 2 \
-    Line 3 \
-    Line 4 ; comment
-    

This would yield: "multiple" <- "Line1 Line2 Line3 Line4"

-

Comments in an ini file are:

-
    -
  • Lines starting with a hash sign
  • -
  • Blank lines (only blanks or tabs)
  • -
  • Comments given on value lines after the semicolon (if present)
  • -
-

-Compiling/installing the library

-

Edit the Makefile to indicate the C compiler you want to use, the options to provide to compile ANSI C, and possibly the options to pass to the ar program on your machine to build a library (.a) from a set of object (.o) files.

-

Defaults are set for the gcc compiler and the standard ar library builder.

-

Type 'make', that should do it.

-

To use the library in your programs, add the following line on top of your module:

-
    #include "iniparser.h"
-

And link your program with the iniparser library by adding -liniparser.a to the compile line.

-

See the file test/initest.c for an example.

-

iniparser is an ANSI C library. If you want to compile it with a C++ compiler you will likely run into compatibility issues. Headers probably have to include the extern "C" hack and function prototypes will want to add some const here and there to keep the compiler happy. This job is left to the reader as there are too many C++ compilers around, each with its own requirements as to what represents acceptable C code in a C++ environment. You have been warned.

-

-Library reference

-

The library is completely documented in its header file. On-line documentation has been generated and can be consulted here:

- -

-Using the parser

-

Comments are discarded by the parser. Then sections are identified, and in each section a new entry is created for every keyword found. The keywords are stored with the following syntax:

-
-    [Section]
-    Keyword = value ; comment
-	

is converted to the following key pair:

-
-    ("section:keyword", "value")
-	

This means that if you want to retrieve the value that was stored in the section called Pizza, in the keyword Cheese, you would make a request to the dictionary for "pizza:cheese". All section and keyword names are converted to lowercase before storage in the structure. The value side is conserved as it has been parsed, though.

-

Section names are also stored in the structure. They are stored using as key the section name, and a NULL associated value. They can be queried through iniparser_find_entry().

-

To launch the parser, use the function called iniparser_load(), which takes an input file name and returns a newly allocated dictionary structure. This latter object should remain opaque to the user and only accessed through the following accessor functions:

- -

Finally, discard this structure using iniparser_freedict().

-

All values parsed from the ini file are stored as strings. The accessors are just converting these strings to the requested type on the fly, but you could basically perform this conversion by yourself after having called the string accessor.

-

Notice that iniparser_getboolean() will return an integer (0 or 1), trying to make sense of what was found in the file. Strings starting with "y", "Y", "t", "T" or "1" are considered true values (return 1), strings starting with "n", "N", "f", "F", "0" are considered false (return 0). This allows some flexibility in handling of boolean answers.

-

If you want to add extra information into the structure that was not present in the ini file, you can use iniparser_set() to insert a string.

-

If you want to add a section to the structure, add a key with a NULL value. Example:

-
-    iniparser_set(ini, "section", NULL);
-    iniparser_set(ini, "section:key1", NULL);
-    iniparser_set(ini, "section:key2", NULL);
-    

-A word about the implementation

-

The dictionary structure is a pretty simple dictionary implementation which might find some uses in other applications. If you are curious, look into the source.

-

-Known defects

-

The dictionary structure is extremely unefficient for searching as keys are sorted in the same order as they are read from the ini file, which is convenient when dumping back to a file. The simplistic first-approach linear search implemented there can become a bottleneck if you have a very large number of keys.

-

People who need to load large amounts of data from an ini file should definitely turn to more appropriate solutions: sqlite3 or similar. There are otherwise many other dictionary implementations available on the net to replace this one.

-

-Authors

-

Nicolas Devillard (ndevilla AT free DOT fr).

-
-
Generated on Sun Jun 12 19:07:18 2016 for iniparser by  - -doxygen 1.8.11
- - diff --git a/html/iniparser_8h.html b/html/iniparser_8h.html deleted file mode 100644 index a909c4b..0000000 --- a/html/iniparser_8h.html +++ /dev/null @@ -1,583 +0,0 @@ - - - - -iniparser: iniparser.h File Reference - - - - - -
-

iniparser.h File Reference

-

Parser for ini files. -More...

- - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Functions

int iniparser_getnsec (dictionary *d)
 Get number of sections in a dictionary.
char * iniparser_getsecname (dictionary *d, int n)
 Get name for section n in a dictionary.
void iniparser_dump_ini (dictionary *d, FILE *f)
 Save a dictionary to a loadable ini file.
void iniparser_dump (dictionary *d, FILE *f)
 Dump a dictionary to an opened file pointer.
char * iniparser_getstring (dictionary *d, char *key, char *def)
 Get the string associated to a key.
int iniparser_getint (dictionary *d, char *key, int notfound)
 Get the string associated to a key, convert to an int.
double iniparser_getdouble (dictionary *d, char *key, double notfound)
 Get the string associated to a key, convert to a double.
int iniparser_getboolean (dictionary *d, char *key, int notfound)
 Get the string associated to a key, convert to a boolean.
int iniparser_set (dictionary *ini, char *entry, char *val)
 Set an entry in a dictionary.
void iniparser_unset (dictionary *ini, char *entry)
 Delete an entry in a dictionary.
int iniparser_find_entry (dictionary *ini, char *entry)
 Finds out if a given entry exists in a dictionary.
dictionary * iniparser_load (char *ininame)
 Parse an ini file and return an allocated dictionary object.
void iniparser_freedict (dictionary *d)
 Free all memory associated to an ini dictionary.
-

Detailed Description

-

Parser for ini files.

-
Author:
N. Devillard
-
Date:
Sep 2007
-
Version:
3.0
-

Function Documentation

- -
-
- - - - - - - - - - - - - - - - - - -
void iniparser_dump (dictionary *  d,
FILE *  f 
)
-
-
- -

Dump a dictionary to an opened file pointer.

-
Parameters:
- - - -
d Dictionary to dump.
f Opened file pointer to dump to.
-
-
-
Returns:
void
-

This function prints out the contents of a dictionary, one element by line, onto the provided file pointer. It is OK to specify stderr or stdout as output files. This function is meant for debugging purposes mostly.

- -
-
- -
-
- - - - - - - - - - - - - - - - - - -
void iniparser_dump_ini (dictionary *  d,
FILE *  f 
)
-
-
- -

Save a dictionary to a loadable ini file.

-
Parameters:
- - - -
d Dictionary to dump
f Opened file pointer to dump to
-
-
-
Returns:
void
-

This function dumps a given dictionary into a loadable ini file. It is Ok to specify stderr or stdout as output files.

- -
-
- -
-
- - - - - - - - - - - - - - - - - - -
int iniparser_find_entry (dictionary *  ini,
char *  entry 
)
-
-
- -

Finds out if a given entry exists in a dictionary.

-
Parameters:
- - - -
ini Dictionary to search
entry Name of the entry to look for
-
-
-
Returns:
integer 1 if entry exists, 0 otherwise
-

Finds out if a given entry exists in the dictionary. Since sections are stored as keys with NULL associated values, this is the only way of querying for the presence of sections in a dictionary.

- -
-
- -
-
- - - - - - - - - -
void iniparser_freedict (dictionary *  d ) 
-
-
- -

Free all memory associated to an ini dictionary.

-
Parameters:
- - -
d Dictionary to free
-
-
-
Returns:
void
-

Free all memory associated to an ini dictionary. It is mandatory to call this function before the dictionary object gets out of the current context.

- -
-
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - -
int iniparser_getboolean (dictionary *  d,
char *  key,
int  notfound 
)
-
-
- -

Get the string associated to a key, convert to a boolean.

-
Parameters:
- - - - -
d Dictionary to search
key Key string to look for
notfound Value to return in case of error
-
-
-
Returns:
integer
-

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.

-

A true boolean is found if one of the following is matched:

-
    -
  • A string starting with 'y'
  • -
  • A string starting with 'Y'
  • -
  • A string starting with 't'
  • -
  • A string starting with 'T'
  • -
  • A string starting with '1'
  • -
-

A false boolean is found if one of the following is matched:

-
    -
  • A string starting with 'n'
  • -
  • A string starting with 'N'
  • -
  • A string starting with 'f'
  • -
  • A string starting with 'F'
  • -
  • A string starting with '0'
  • -
-

The notfound value returned if no boolean is identified, does not necessarily have to be 0 or 1.

- -
-
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - -
double iniparser_getdouble (dictionary *  d,
char *  key,
double  notfound 
)
-
-
- -

Get the string associated to a key, convert to a double.

-
Parameters:
- - - - -
d Dictionary to search
key Key string to look for
notfound Value to return in case of error
-
-
-
Returns:
double
-

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.

- -
-
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - -
int iniparser_getint (dictionary *  d,
char *  key,
int  notfound 
)
-
-
- -

Get the string associated to a key, convert to an int.

-
Parameters:
- - - - -
d Dictionary to search
key Key string to look for
notfound Value to return in case of error
-
-
-
Returns:
integer
-

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_getnsec (dictionary *  d ) 
-
-
- -

Get number of sections in a dictionary.

-
Parameters:
- - -
d Dictionary to examine
-
-
-
Returns:
int Number of sections found in dictionary
-

This function returns the number of sections found in a dictionary. The test to recognize sections is done on the string stored in the dictionary: a section name is given as "section" whereas a key is stored as "section:key", thus the test looks for entries that do not contain a colon.

-

This clearly fails in the case a section name contains a colon, but this should simply be avoided.

-

This function returns -1 in case of error.

- -
-
- -
-
- - - - - - - - - - - - - - - - - - -
char* iniparser_getsecname (dictionary *  d,
int  n 
)
-
-
- -

Get name for section n in a dictionary.

-
Parameters:
- - - -
d Dictionary to examine
n Section number (from 0 to nsec-1).
-
-
-
Returns:
Pointer to char string
-

This function locates the n-th section in a dictionary and returns its name as a pointer to a string statically allocated inside the dictionary. Do not free or modify the returned string!

-

This function returns NULL in case of error.

- -
-
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - -
char* iniparser_getstring (dictionary *  d,
char *  key,
char *  def 
)
-
-
- -

Get the string associated to a key.

-
Parameters:
- - - - -
d Dictionary to search
key Key string to look for
def Default value to return if key not found.
-
-
-
Returns:
pointer to statically allocated character string
-

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 pointer passed as 'def' is returned. The returned char pointer is pointing to a string allocated in the dictionary, do not free or modify it.

- -
-
- -
-
- - - - - - - - - -
dictionary* iniparser_load (char *  ininame ) 
-
-
- -

Parse an ini file and return an allocated dictionary object.

-
Parameters:
- - -
ininame Name of the ini file to read.
-
-
-
Returns:
Pointer to newly allocated dictionary
-

This is the parser for ini files. This function is called, providing the name of the file to be read. It returns a dictionary object that should not be accessed directly, but through accessor functions instead.

-

The returned dictionary must be freed using iniparser_freedict().

- -
-
- -
-
- - - - - - - - - - - - - - - - - - - - - - - - -
int iniparser_set (dictionary *  ini,
char *  entry,
char *  val 
)
-
-
- -

Set an entry in a dictionary.

-
Parameters:
- - - - -
ini Dictionary to modify.
entry Entry to modify (entry name)
val New value to associate to the entry.
-
-
-
Returns:
int 0 if Ok, -1 otherwise.
-

If the given entry can be found in the dictionary, it is modified to contain the provided value. If it cannot be found, -1 is returned. It is Ok to set val to NULL.

- -
-
- -
-
- - - - - - - - - - - - - - - - - - -
void iniparser_unset (dictionary *  ini,
char *  entry 
)
-
-
- -

Delete an entry in a dictionary.

-
Parameters:
- - - -
ini Dictionary to modify
entry Entry to delete (entry name)
-
-
-
Returns:
void
-

If the given entry can be found, it is deleted from the dictionary.

- -
-
-
-
Generated on Wed Mar 2 22:04:59 2011 for iniparser by  - -doxygen 1.6.3
- - diff --git a/html/iniparser_8main.html b/html/iniparser_8main.html deleted file mode 100644 index 3761667..0000000 --- a/html/iniparser_8main.html +++ /dev/null @@ -1,19 +0,0 @@ - - - - -iniparser: iniparser.main File Reference - - - - - -
-

iniparser.main File Reference

-
-
-
Generated on Wed Mar 2 22:04:59 2011 for iniparser by  - -doxygen 1.6.3
- - diff --git a/html/tab_b.gif b/html/tab_b.gif deleted file mode 100644 index 0d623483ffdf5f9f96900108042a7ab0643fe2a3..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 35 ncmZ?wbhEHbWMp7uXkcJy*>IeJfk6j|fqX^=1|}vKMh0sDa2W*H diff --git a/html/tab_l.gif b/html/tab_l.gif deleted file mode 100644 index 9b1e6337c9299a700401a2a78a2c6ffced475216..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 706 zcmZ?wbhEHbZT`}F1e&(Gg}Y(8=I;HA5#Z$3JI=gGB)FQ#odI(O&E^@q;x zK6mr*m3xOS-#u~t!I@i+u0DKm^U160k6t`|^WpV}&n+8{U%dD9&a>B#U%!9-@yol< zU%&tQ{rk_K|NsC0`}dE5ET99@1@a36+kb~?0UJ*yc&I3X_m z!ND^5$O7$#8OFRuDhG}!?8z?cdZK&!`PWjdR;Aj^wZ` zeK{IEYHBJ)6K8VIp1`BVt++swf6j+=L{p1*nO(VhE`pFexG@5$|>uaCcd z`0m=9m+yak{QmXN#Sc$^{$X9h9&q2jiKAI|&T)a;PPx2K9p`YIdw8HtR5k2Q$2-O2 z*;3y{MQ-RnJTgJfI&R5|O)AHxDf_00XbPvDZPy4t=hHd)nfLPvms&O`Ok(sD()5v$ z5U@&h;a=#xbxVbo2~X&Xj0Ie(f{v>vERH+qC+nTG=B8Nca=wU-O$?1&vUgV~9=!H; zx>3p9Yn%*<>t~sk+&0xfyS8RsPfYBd<~wWK%j-LmpU>O7yX^h#UCp1x-p#i7@bE;py8XI6 zmY<)m>~)W~yIWcMVoiPg{duuf<*)9qZ9l$m*Ph&W&$jlv*Vpa+{pH@n=IQ$L?0$ax ec60Ul|8o2P|NVbd{6P)#weSbE3}s?04AuZvx_~SI diff --git a/html/tab_r.gif b/html/tab_r.gif deleted file mode 100644 index ce9dd9f533cb5486d6941844f442b59d4a9e9175..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2585 zcmbV}`9Bkk1ILFF--w5zJc=ZZT(zjE=;2|_S)Qm~rCWz1Pc)KPl;jv%A#&v2*x}yc zmf2~Jm~&=xjJY?PqwIN}f8qQ2{r$uH{c*nJbmr{cR5??*egHrs-B=MzCF`3%e{FAW z{oL5xTHn~5TM{jaB;@|_Ue5F&Zb@p(kMyG{*;gWDg zyeL|eZf7Qd8=#bXzSiR{yzRgLSj-fJS8>lBjVHN z^o-0eS=nE6a`W;LChBs=`+QAJP~{b93>H^eRb5kCSC1zUNezun%`L5M?RDzv#%jk7 zYVRX=vATPD`+oEfum^{RM@GjuP?-r=yh0!p;Vx^T9G7~`7%5ydH%70=jyJ;;`d;hv92x3R=z{xp+Lg2!*@OK*K15-t&okoPtSED)h&$RLxdbA zseWm^C3d%-yRNi-ryk^!ek+C`n&~cd$#ZWct_cUL{l~i+Nzx^5d!n94(>bW-iL~Rl z&8r)?q|1DIo=0=judQ{FaGcfLERz8gfn3-Qt<2lksh{mzpT}DXxUuR^z=^key&q4! z+wWI45vL0k$R^(F#{qfqhUsN@WA+w-V?LPH33!Q?WFSB3)WBojE@hK41Nb?KfS+Qo zXgrzfsP$wr4Qzy*{OD>uJBjdgGM@VMml5)2f~_}lD*YyOb}Hjeobhz#4c`w(l^>KK zr?Ud;W~Z}*w;%hZ|2^p^+f06gJDJQD zeIhGADbDmm&6arh(q>EZ<7mjzg7l|z$hRL8=1>)Nv=S7CY$B}iYJ&*T_-T_OG*L1q ztZ3Lana33?y3AKnyq^YCF|4x%Rb5WU&2qcl{TFKey%QJeMxn^SdT!hZ5+0i1zeusiYVp-phBl7b5+Px-X&LhByq z0F&<;K0l2+v>qiHlXb#$jXMv$uK-dEGE9L~qtdU(XeRXmvu*K2Q&6!fD**JxYP4b4BR7FdJ$Qx9G9`J%-_X!a#LGpp3g9)VWytGCa;7`S1_e8F~!R+aSJ zOF17p2`H?2kPs8Q`_;U}+D%3p zs2-0BTqFwpUoBk`?P;iPQ(IbEA|JmMx!P&YYG|R@S=5Mnw;-?A6rEEVyV%d7{iU4a zNk`i!%F(Ykpm`}#oH;BjY->@b8vQedv;pza2FL&*6ufjd+*3Ute&>kes~TU?^KkojsTh(o~(3tk1Y6>4(yn( z#U*ID9@eg-beKo1B;HXe+}{Z%n@7m0+yxivuqk9~;!1LGQlah)xYK4>wgL}l6dsaN zIxlRlq`*`j9PG4*0hD6YV_b_2w5b#)o7J?`q#{GjvvKlD`T*dWcZx<-s(ZvLB44E# z=!|sw!?)@%y$oRNL#25WS3lzdii}TuQ3?CLnvQ1_n};2sT_;Y;#d3=+-(O% zMN$>O!3;ke(UuLR%h_&)N zs^!-@A>QR}4yB1bPp`9S19ikTbZ~O{&FF-yHK{En;mmShDUIEw03`j(DBIsM}Rjki2J#SQa3gFZTKBPDeIiLt9Z z%bL3(B@Qw%(B`wSMS~dPh$=R`(}lBoFXKy(s|*{#ru$wjsBc_O#zxNk9w+UUHmx(U zmJ8+M+ndtnZ<7|VU9Mbt61zpo9T&3%Wx&XII=#QJxjR`CZf22ac3d51Z?GD%LEe_&*t46Qf;4`bZ7p2K(Ab5>GfT^}4! zBT&HZD`^PEgWoI&{~o-ID0F?O`75sm(87x%A{(}Ch1)QlzdJ)1B-eqe5a(weg0`4lQIf1evjvbBY50DVbzO7CLf|vP z2#0(U-|jZ`H{y5N^o7%iK6H>_HEGN->U6^!)1{XpJV!!4(Ig7wzZQ*9WYF4X1rG0x z=1uA@i`rIAciubDC{;~b(|&|A@xkjRP5aRcvRU9tvIm}jDB6J eQ0-6-y)mpwdT=ayS0tBxKDA*~;EWmo diff --git a/html/tabs.css b/html/tabs.css deleted file mode 100644 index a444163..0000000 --- a/html/tabs.css +++ /dev/null @@ -1,105 +0,0 @@ -/* tabs styles, based on http://www.alistapart.com/articles/slidingdoors */ - -DIV.tabs -{ - float : left; - width : 100%; - background : url("tab_b.gif") repeat-x bottom; - margin-bottom : 4px; -} - -DIV.tabs UL -{ - margin : 0px; - padding-left : 10px; - list-style : none; -} - -DIV.tabs LI, DIV.tabs FORM -{ - display : inline; - margin : 0px; - padding : 0px; -} - -DIV.tabs FORM -{ - float : right; -} - -DIV.tabs A -{ - float : left; - background : url("tab_r.gif") no-repeat right top; - border-bottom : 1px solid #84B0C7; - font-size : 80%; - font-weight : bold; - text-decoration : none; -} - -DIV.tabs A:hover -{ - background-position: 100% -150px; -} - -DIV.tabs A:link, DIV.tabs A:visited, -DIV.tabs A:active, DIV.tabs A:hover -{ - color: #1A419D; -} - -DIV.tabs SPAN -{ - float : left; - display : block; - background : url("tab_l.gif") no-repeat left top; - padding : 5px 9px; - white-space : nowrap; -} - -DIV.tabs #MSearchBox -{ - float : right; - display : inline; - font-size : 1em; -} - -DIV.tabs TD -{ - font-size : 80%; - font-weight : bold; - text-decoration : none; -} - - - -/* Commented Backslash Hack hides rule from IE5-Mac \*/ -DIV.tabs SPAN {float : none;} -/* End IE5-Mac hack */ - -DIV.tabs A:hover SPAN -{ - background-position: 0% -150px; -} - -DIV.tabs LI.current A -{ - background-position: 100% -150px; - border-width : 0px; -} - -DIV.tabs LI.current SPAN -{ - background-position: 0% -150px; - padding-bottom : 6px; -} - -DIV.navpath -{ - background : none; - border : none; - border-bottom : 1px solid #84B0C7; - text-align : center; - margin : 2px; - padding : 2px; -} diff --git a/src/dictionary.c b/src/dictionary.c index cb7ccd4..5f4de0d 100644 --- a/src/dictionary.c +++ b/src/dictionary.c @@ -210,7 +210,8 @@ const char * dictionary_get(const dictionary * d, const char * key, const char * { unsigned hash ; ssize_t i ; - + if(d == NULL || key == NULL) + return def ; hash = dictionary_hash(key); for (i=0 ; isize ; i++) { if (d->key[i]==NULL) diff --git a/test/test_dictionary.c b/test/test_dictionary.c index 250c878..d1b89c4 100644 --- a/test/test_dictionary.c +++ b/test/test_dictionary.c @@ -238,3 +238,52 @@ void Test_dictionary_dump(CuTest *tc) dictionary_del(dic); } + +void Test_dictionary_get(CuTest *tc) +{ + dictionary *dic; + int i, j; + char sec_name[32]; + char key_name[64]; + + /*NULL test*/ + CuAssertPtrEquals(tc, NULL, dictionary_get(NULL, NULL, NULL)); + CuAssertPtrEquals(tc, NULL, dictionary_get(NULL, "string", NULL)); + + /*Check the def return element*/ + dic = dictionary_new(DICTMINSZ); + CuAssertPtrNotNull(tc, dic); + CuAssertPtrEquals(tc, NULL, dictionary_get(dic, "dummy", NULL)); + CuAssertStrEquals(tc, "def", dictionary_get(dic, NULL, "def")); + CuAssertStrEquals(tc, "def", dictionary_get(dic, "dummy", "def")); + + /*Populate the dictionary*/ + for (i = 1; i < 3; ++i) + { + sprintf(sec_name, "sec%d", i); + dictionary_set(dic, sec_name, ""); + for (j = 1; j < 5; ++j) + { + sprintf(key_name, "%s:key%d", sec_name, j); + dictionary_set(dic, key_name, "dummy_value"); + CuAssertStrEquals(tc, "dummy_value", + dictionary_get(dic, key_name, "string")); + } + } + + /*Test get dictionary section value*/ + CuAssertStrEquals(tc, "", + dictionary_get(dic, "sec1", NULL)); + CuAssertStrEquals(tc, "", + dictionary_get(dic, "sec1", "def")); + + /*delete and set a key in a dictionary*/ + dictionary_unset(dic, "sec1:key4"); + CuAssertStrEquals(tc, "def", + dictionary_get(dic, "sec1:key4", "def")); + dictionary_set(dic, "sec1:key4", "dummy_value"); + CuAssertStrEquals(tc, "dummy_value", + dictionary_get(dic, "sec1:key4", "def")); + + dictionary_del(dic); +} From a817973177bce835344078d1a1d99d37fefd5588 Mon Sep 17 00:00:00 2001 From: zrrto <2516122612@qq.com> Date: Mon, 2 Sep 2019 14:36:13 +0800 Subject: [PATCH 2/4] Update test_dictionary.c --- test/test_dictionary.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/test/test_dictionary.c b/test/test_dictionary.c index d1b89c4..5fa8210 100644 --- a/test/test_dictionary.c +++ b/test/test_dictionary.c @@ -184,9 +184,6 @@ void Test_dictionary_unset(CuTest *tc) CuAssertStrEquals(tc, dic1_dump, dic2_dump); free(dic1_dump); free(dic2_dump); - - dictionary_del(dic1); - dictionary_del(dic2); } void Test_dictionary_dump(CuTest *tc) From 0783d748aec60a5cb27773810e565592137f949b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20M=C3=B6llendorf?= Date: Sun, 3 Mar 2024 20:44:30 +0100 Subject: [PATCH 3/4] Only run when pushing on master --- .github/workflows/trigger-gitlab-ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/trigger-gitlab-ci.yml b/.github/workflows/trigger-gitlab-ci.yml index 3c8fcbf..dfd5144 100644 --- a/.github/workflows/trigger-gitlab-ci.yml +++ b/.github/workflows/trigger-gitlab-ci.yml @@ -2,6 +2,8 @@ name: trigger-gitlab-ci run-name: ${{ github.event_name }} triggered by ${{ github.actor }} on: [push] + branches: + - master jobs: trigger-gitlab-ci: From ac87cc7f05cdad46d270add3b21828aa446400ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20M=C3=B6llendorf?= Date: Sun, 3 Mar 2024 20:47:27 +0100 Subject: [PATCH 4/4] Fix Github action --- .github/workflows/trigger-gitlab-ci.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/trigger-gitlab-ci.yml b/.github/workflows/trigger-gitlab-ci.yml index dfd5144..8cd4d11 100644 --- a/.github/workflows/trigger-gitlab-ci.yml +++ b/.github/workflows/trigger-gitlab-ci.yml @@ -1,9 +1,10 @@ name: trigger-gitlab-ci run-name: ${{ github.event_name }} triggered by ${{ github.actor }} -on: [push] - branches: - - master +on: + push: + branches: + - master jobs: trigger-gitlab-ci: