# HG changeset patch # User David Demelier # Date 1326556071 -3600 # Node ID 85ddc81848bda46a5a6d3e6201504b903b54ebd5 # Parent d534fdcbb319821a3ba150521bc2d5debfedf4c3 Add a little helper in ini.c to find an option diff -r d534fdcbb319 -r 85ddc81848bd ini.c --- a/ini.c Fri Jan 13 22:48:08 2012 +0100 +++ b/ini.c Sat Jan 14 16:47:51 2012 +0100 @@ -113,6 +113,22 @@ } /* + * Find an option from the config, by section name and option name. + * Returns the option or NULL if not found. + */ + +INI_Option * +ini_find(const INI_Config *config, const char *sname, const char *oname) +{ + INI_Section *sc; + + if ((sc = ini_select_section(config, sname))) + return ini_select_option(sc, oname); + + return NULL; +} + +/* * Return the last error or "No error" if there is not error at all. */ diff -r d534fdcbb319 -r 85ddc81848bd ini.h --- a/ini.h Fri Jan 13 22:48:08 2012 +0100 +++ b/ini.h Sat Jan 14 16:47:51 2012 +0100 @@ -84,6 +84,9 @@ INI_Option * ini_select_option(const INI_Section *, const char *); +INI_Option * +ini_find(const INI_Config *, const char *, const char *); + void ini_free(INI_Config *, int, int);