Skip to content

Commit

Permalink
Commit #122
Browse files Browse the repository at this point in the history
  • Loading branch information
madmurphy committed Oct 12, 2018
1 parent 8b52f0b commit fee34ef
Show file tree
Hide file tree
Showing 22 changed files with 135 additions and 77 deletions.
12 changes: 12 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@ Change Log {#changelog}
=======================


## 1.7.2 -- 2018-10-12

Changes:

* Code review (`load_ini_path()` -- see issue
[#6](https://github.com/madmurphy/libconfini/issues/6) concerning file
access under Microsoft Windows)
* Documentation -- see issues
[#5](https://github.com/madmurphy/libconfini/issues/5) and
[#6](https://github.com/madmurphy/libconfini/issues/6)


## 1.7.1 -- 2018-10-08

Changes:
Expand Down
14 changes: 10 additions & 4 deletions INSTALL
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
On most Unix-like systems, you should be able to install libconfini using
the following common steps:
On most Unix-like systems, you should be able to install libconfini using the
following common steps:

./configure
make
make install

If you need to customize the target directories, or otherwise adjust the
build setting, use
If you need to customize the target directories, or otherwise adjust the build
setting, use

./configure --help

to list the configure options.

If the `configure` script is missing from your package you need to create it by
running the `autogen.sh` script. Use the `--noconfigure` parameter in order to
prevent `autogen.sh` from running automatically `configure` immediately after
having generated it.

2 changes: 1 addition & 1 deletion MANUAL.md
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ static int callback (IniDispatch * dispatch, void * v_null) {
int main () {
FILE * const ini_file = fopen("ini_files/example.conf", "r");
FILE * const ini_file = fopen("ini_files/example.conf", "rb");
if (ini_file == NULL) {
Expand Down
1 change: 0 additions & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ if ENABLE_DOC

dist_doc_DATA += docs/manual.html \
ChangeLog \
INSTALL \
NEWS \
README

Expand Down
6 changes: 6 additions & 0 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,12 @@ make
make install
~~~~~~~~~~~~

If the `configure` script is missing from your package you need to generate it
by running the `autogen.sh` script. By default `autogen.sh` will also run the
`configure` script immediately after having generated it, so you may directly
type the `make` command directly after `autogen.sh`. To list different options
use `autogen.sh --help`.

An unofficial port of **libconfini** for Cygwin [is also available][5].


Expand Down
61 changes: 35 additions & 26 deletions autogen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,24 @@
DIE=0
CONFIGURE_ARGS=()

for AG_ARG; do
case "${AG_ARG}" in
for __AG_ARG__; do
case "${__AG_ARG__}" in
-h|--help)
echo "Usage: ${0} [option]"
echo
echo 'Options:'
echo " -h|--help Show this help message"
echo " -n|--noconfigure Skip the configure process"
echo
echo 'If this script is invoked without the `--noconfigure'\'' option all unrecognized'
echo 'arguments will be passed to `configure'\''.'
echo 'If this script is invoked without the `--noconfigure` option all unrecognized'
echo 'arguments will be passed to `configure`.'
exit 0
;;
-n|--noconfigure)
NOCONFIGURE='YES'
;;
*)
CONFIGURE_ARGS+=("${AG_ARG}")
CONFIGURE_ARGS+=("${__AG_ARG__}")
;;
esac
done
Expand Down Expand Up @@ -56,23 +56,23 @@ if [ -n "${GNOME2_DIR}" ]; then
fi

(test -f "${srcdir}/configure.ac") || {
echo -n "**Error**: Directory \`${srcdir}' does not look like the"
echo -n "**Error**: Directory \`${srcdir}\` does not look like the"
echo " top-level package directory"
exit 1
}

(autoconf --version) < /dev/null > /dev/null 2>&1 || {
echo
echo "**Error**: You must have \`autoconf' installed."
echo "**Error**: You must have \`autoconf\` installed."
echo "Download the appropriate package for your distribution,"
echo "or get the source tarball at ftp://ftp.gnu.org/pub/gnu/"
DIE=1
}

(grep "^IT_PROG_INTLTOOL" "${srcdir}/configure.ac" >/dev/null) && {
(intltoolize --version) < /dev/null > /dev/null 2>&1 || {
echo
echo "**Error**: You must have \`intltool' installed."
echo
echo "**Error**: You must have \`intltool\` installed."
echo "You can get it from:"
echo " ftp://ftp.gnome.org/pub/GNOME/"
DIE=1
Expand All @@ -82,7 +82,7 @@ fi
(grep "^AM_PROG_XML_I18N_TOOLS" "${srcdir}/configure.ac" >/dev/null) && {
(xml-i18n-toolize --version) < /dev/null > /dev/null 2>&1 || {
echo
echo "**Error**: You must have \`xml-i18n-toolize' installed."
echo "**Error**: You must have \`xml-i18n-toolize\` installed."
echo "You can get it from:"
echo " ftp://ftp.gnome.org/pub/GNOME/"
DIE=1
Expand All @@ -92,7 +92,7 @@ fi
(grep "^LT_INIT" "${srcdir}/configure.ac" >/dev/null) && {
("${LIBTOOL}" --version) < /dev/null > /dev/null 2>&1 || {
echo
echo "**Error**: You must have \`libtool' installed."
echo "**Error**: You must have \`libtool\` installed."
echo "You can get it from: ftp://ftp.gnu.org/pub/gnu/"
DIE=1
}
Expand All @@ -102,15 +102,15 @@ fi
(grep "sed.*POTFILES" "${srcdir}/configure.ac") > /dev/null || \
(glib-gettextize --version) < /dev/null > /dev/null 2>&1 || {
echo
echo "**Error**: You must have \`glib' installed."
echo "**Error**: You must have \`glib\` installed."
echo "You can get it from: ftp://ftp.gtk.org/pub/gtk"
DIE=1
}
}

(automake --version) < /dev/null > /dev/null 2>&1 || {
echo
echo "**Error**: You must have \`automake' installed."
echo "**Error**: You must have \`automake\` installed."
echo "You can get it from: ftp://ftp.gnu.org/pub/gnu/"
DIE=1
NO_AUTOMAKE=yes
Expand All @@ -120,7 +120,7 @@ fi
# if no automake, don't bother testing for aclocal
test -n "${NO_AUTOMAKE}" || (aclocal --version) < /dev/null > /dev/null 2>&1 || {
echo
echo "**Error**: Missing \`aclocal'. The version of \`automake'"
echo "**Error**: Missing \`aclocal\`. The version of \`automake\`"
echo "installed doesn't appear recent enough."
echo "You can get automake from ftp://ftp.gnu.org/pub/gnu/"
DIE=1
Expand All @@ -131,16 +131,26 @@ if test "${DIE}" -eq 1; then
fi

if test "x${NOCONFIGURE}" = x; then
echo "I am going to prepare the build system and then run the \`configure' script."
echo 'I am going to prepare the build system and then run the `configure` script. If'
echo 'you wish differently, please specify the `--noconfigure` argument on the'
echo "\`${0}\` command line."
if test -z "$*"; then
echo
echo "**Warning**: I am going to run \`configure' with no arguments."
echo "If you wish to pass any to it, please specify them on the"
echo "\`${0}' command line."
echo '**Warning**: I am going to run `configure` with no arguments.'
echo 'If you wish to pass any to it, please specify them on the'
echo "\`${0}\` command line."
echo
fi
else
echo "I am going to prepare the build system without running the \`configure' script."
echo 'I am going to prepare the build system without running the `configure` script.'
if test ${#CONFIGURE_ARGS[@]} -gt 0; then
echo
echo '**Warning**: The following arguments will be ignored:'
for __IDX__ in ${!CONFIGURE_ARGS[@]}; do
echo " $((__IDX__ + 1)). \`${CONFIGURE_ARGS[$__IDX__]}\`"
done
echo
fi
fi

echo 'Preparing the build system... please wait'
Expand All @@ -151,8 +161,7 @@ case "${CC}" in
;;
esac

for coin in `find "${srcdir}" -path "${srcdir}/CVS" -prune -o -name configure.ac -print`
do
for coin in `find "${srcdir}" -path "${srcdir}/CVS" -prune -o -name configure.ac -print`; do
dr=`dirname "${coin}"`
if test -f "${dr}/NO-AUTO-GEN"; then
echo "skipping ${dr} -- flagged as no auto-gen"
Expand All @@ -179,7 +188,7 @@ do
xml-i18n-toolize --copy --force --automake
fi
if grep "^LT_INIT" configure.ac >/dev/null; then
if test -z "${NO_LIBTOOLIZE}" ; then
if test -z "${NO_LIBTOOLIZE}" ; then
echo "Running libtoolize..."
"${LIBTOOLIZE}" --force --copy
fi
Expand All @@ -200,14 +209,14 @@ done

if test "x${NOCONFIGURE}" = x; then
echo -n "Running ${srcdir}/configure"
for CF_ARG in "${CONFIGURE_ARGS[@]}"; do
echo -n " [${CF_ARG}]"
for __CF_ARG__ in "${CONFIGURE_ARGS[@]}"; do
echo -n " [${__CF_ARG__}]"
done
echo " ..."
"${srcdir}/configure" "${CONFIGURE_ARGS[@]}" \
&& echo 'Now type `make'\'' to compile.' || exit 1
&& echo 'Now type `make` to compile.' || exit 1
else
echo 'Skipping configure process. Type `configure --help'\'' to list the configure'
echo 'Skipping configure process. Type `configure --help` to list the configure'
echo 'options.'
fi

4 changes: 2 additions & 2 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ AC_CONFIG_HEADERS([config.h])
AC_CONFIG_MACRO_DIR([m4])

AC_ARG_ENABLE([doc],
[AS_HELP_STRING([--enable-doc], [Create package with documentation @<:@default=yes@:>@])],
[AS_HELP_STRING([--disable-doc], [Create package without documentation @<:@default=no@:>@])],
[:],
[enable_doc=yes]
)

AC_ARG_ENABLE([examples],
[AS_HELP_STRING([--enable-examples], [Create package with examples @<:@default=yes@:>@])],
[AS_HELP_STRING([--disable-examples], [Create package without examples @<:@default=no@:>@])],
[:],
[enable_examples=yes]
)
Expand Down
6 changes: 6 additions & 0 deletions docs/html/changelog.html
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@
</div><!--header-->
<div class="contents">
<div class="textblock"><p>Record of notable changes</p>
<h2>1.7.2 &ndash; 2018-10-12</h2>
<p>Changes:</p>
<ul>
<li>Code review (<code><a class="el" href="confini_8c.html#a307e84bd8a6775c4e8d9c00736e201ab" title="Parses an INI file and dispatches its content using a path as argument. ">load_ini_path()</a></code> &ndash; see issue <a href="https://github.com/madmurphy/libconfini/issues/6">#6</a> concerning file access under Microsoft Windows)</li>
<li>Documentation &ndash; see issues <a href="https://github.com/madmurphy/libconfini/issues/5">#5</a> and <a href="https://github.com/madmurphy/libconfini/issues/6">#6</a></li>
</ul>
<h2>1.7.1 &ndash; 2018-10-08</h2>
<p>Changes:</p>
<ul>
Expand Down
5 changes: 3 additions & 2 deletions docs/html/confini_8c.html
Original file line number Diff line number Diff line change
Expand Up @@ -1561,9 +1561,10 @@ <h2 class="memtitle"><span class="permalink"><a href="#a326e804687b2b46f0a295ae7
</dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>Zero for success, otherwise an error code (see <code>enum</code> <code><a class="el" href="confini_8h.html#a4b42cb63e48154fb799599eccd25ce29" title="Error codes – the actual value of each constant should be considered opaque. ">ConfiniInterruptNo</a></code>)</dd></dl>
<p>The function <code>f_init</code> will be invoked with two arguments: <code>statistics</code> (a pointer to an <code><a class="el" href="structIniStatistics.html" title="Global statistics about an INI file. ">IniStatistics</a></code> object containing some properties about the file read) and <code>init_other</code> (the custom argument <code>user_data</code> previously passed). If <code>f_init</code> returns a non-zero value the caller function will be interrupted.</p>
<p>The <code>ini_file</code> parameter must be a <code>FILE</code> handle with read privileges. In some platforms, such as Microsoft Windows, it might be needed to add the binary specifier to the mode string (<code>"b"</code>) in order to prevent discrepancies between the physical size of the file and its computed size:</p>
<div class="fragment"><div class="line">FILE * my_file = fopen(<span class="stringliteral">&quot;example.conf&quot;</span>, <span class="stringliteral">&quot;rb&quot;</span>);</div></div><!-- fragment --><p>The function <code>f_init</code> will be invoked with two arguments: <code>statistics</code> (a pointer to an <code><a class="el" href="structIniStatistics.html" title="Global statistics about an INI file. ">IniStatistics</a></code> object containing some properties about the file read) and <code>init_other</code> (the custom argument <code>user_data</code> previously passed). If <code>f_init</code> returns a non-zero value the caller function will be interrupted.</p>
<p>The function <code>f_foreach</code> will be invoked with two arguments: <code>dispatch</code> (a pointer to an <code><a class="el" href="structIniDispatch.html" title="Dispatch of a single INI node. ">IniDispatch</a></code> object containing the parsed member of the INI file) and <code>foreach_other</code> (the custom argument <code>user_data</code> previously passed). If <code>f_foreach</code> returns a non-zero value the caller function will be interrupted.</p>
<div class="fragment"><div class="line"><span class="comment">/* examples/topics/load_ini_file.c */</span></div><div class="line"></div><div class="line"><span class="preprocessor">#include &lt;stdio.h&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="confini_8h.html">confini.h</a>&gt;</span></div><div class="line"></div><div class="line"><span class="keyword">static</span> <span class="keywordtype">int</span> callback (<a class="code" href="structIniDispatch.html">IniDispatch</a> * dispatch, <span class="keywordtype">void</span> * v_null) {</div><div class="line"></div><div class="line"> printf(</div><div class="line"> <span class="stringliteral">&quot;DATA: %s\nVALUE: %s\nNODE TYPE: %d\n\n&quot;</span>,</div><div class="line"> dispatch-&gt;<a class="code" href="structIniDispatch.html#a3821b15b23e587eca172763dd4acd954">data</a>, dispatch-&gt;<a class="code" href="structIniDispatch.html#a8d7eb3387ff5ecb79900fae717234d16">value</a>, dispatch-&gt;<a class="code" href="structIniDispatch.html#a7f6ebc6713aae413c4157ce68008a8a8">type</a></div><div class="line"> );</div><div class="line"></div><div class="line"> <span class="keywordflow">return</span> 0;</div><div class="line"></div><div class="line">}</div><div class="line"></div><div class="line"><span class="keywordtype">int</span> main () {</div><div class="line"></div><div class="line"> FILE * <span class="keyword">const</span> ini_file = fopen(<span class="stringliteral">&quot;ini_files/example.conf&quot;</span>, <span class="stringliteral">&quot;r&quot;</span>);</div><div class="line"></div><div class="line"> <span class="keywordflow">if</span> (ini_file == NULL) {</div><div class="line"></div><div class="line"> fprintf(stderr, <span class="stringliteral">&quot;File doesn&#39;t exist :-(\n&quot;</span>);</div><div class="line"> <span class="keywordflow">return</span> 1;</div><div class="line"></div><div class="line"> }</div><div class="line"></div><div class="line"> <span class="keywordflow">if</span> (<a class="code" href="confini_8c.html#a326e804687b2b46f0a295ae724d84628">load_ini_file</a>(ini_file, <a class="code" href="confini_8h.html#aafa50d590c715f37b74fa5938a35a56f">INI_DEFAULT_FORMAT</a>, NULL, callback, NULL)) {</div><div class="line"></div><div class="line"> fprintf(stderr, <span class="stringliteral">&quot;Sorry, something went wrong :-(\n&quot;</span>);</div><div class="line"> <span class="keywordflow">return</span> 1;</div><div class="line"></div><div class="line"> }</div><div class="line"></div><div class="line"> fclose(ini_file);</div><div class="line"></div><div class="line"> <span class="keywordflow">return</span> 0;</div><div class="line"></div><div class="line">}</div><div class="line"></div></div><!-- fragment -->
<div class="fragment"><div class="line"><span class="comment">/* examples/topics/load_ini_file.c */</span></div><div class="line"></div><div class="line"><span class="preprocessor">#include &lt;stdio.h&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="confini_8h.html">confini.h</a>&gt;</span></div><div class="line"></div><div class="line"><span class="keyword">static</span> <span class="keywordtype">int</span> callback (<a class="code" href="structIniDispatch.html">IniDispatch</a> * dispatch, <span class="keywordtype">void</span> * v_null) {</div><div class="line"></div><div class="line"> printf(</div><div class="line"> <span class="stringliteral">&quot;DATA: %s\nVALUE: %s\nNODE TYPE: %d\n\n&quot;</span>,</div><div class="line"> dispatch-&gt;<a class="code" href="structIniDispatch.html#a3821b15b23e587eca172763dd4acd954">data</a>, dispatch-&gt;<a class="code" href="structIniDispatch.html#a8d7eb3387ff5ecb79900fae717234d16">value</a>, dispatch-&gt;<a class="code" href="structIniDispatch.html#a7f6ebc6713aae413c4157ce68008a8a8">type</a></div><div class="line"> );</div><div class="line"></div><div class="line"> <span class="keywordflow">return</span> 0;</div><div class="line"></div><div class="line">}</div><div class="line"></div><div class="line"><span class="keywordtype">int</span> main () {</div><div class="line"></div><div class="line"> FILE * <span class="keyword">const</span> ini_file = fopen(<span class="stringliteral">&quot;ini_files/example.conf&quot;</span>, <span class="stringliteral">&quot;rb&quot;</span>);</div><div class="line"></div><div class="line"> <span class="keywordflow">if</span> (ini_file == NULL) {</div><div class="line"></div><div class="line"> fprintf(stderr, <span class="stringliteral">&quot;File doesn&#39;t exist :-(\n&quot;</span>);</div><div class="line"> <span class="keywordflow">return</span> 1;</div><div class="line"></div><div class="line"> }</div><div class="line"></div><div class="line"> <span class="keywordflow">if</span> (<a class="code" href="confini_8c.html#a326e804687b2b46f0a295ae724d84628">load_ini_file</a>(ini_file, <a class="code" href="confini_8h.html#aafa50d590c715f37b74fa5938a35a56f">INI_DEFAULT_FORMAT</a>, NULL, callback, NULL)) {</div><div class="line"></div><div class="line"> fprintf(stderr, <span class="stringliteral">&quot;Sorry, something went wrong :-(\n&quot;</span>);</div><div class="line"> <span class="keywordflow">return</span> 1;</div><div class="line"></div><div class="line"> }</div><div class="line"></div><div class="line"> fclose(ini_file);</div><div class="line"></div><div class="line"> <span class="keywordflow">return</span> 0;</div><div class="line"></div><div class="line">}</div><div class="line"></div></div><!-- fragment -->
</div>
</div>
<a id="a307e84bd8a6775c4e8d9c00736e201ab"></a>
Expand Down
Loading

0 comments on commit fee34ef

Please sign in to comment.