upload tizen1.0 source
[pkgs/e/elektra.git] / doc / apiexample.xml
1 <!--
2 $Id$
3 -->
4         <bridgehead id="exprm">Example program</bridgehead>
5         <para>Here is an example of how to use the Elektra API. This program will get all keys that matter under <varname>system/sw/MyApp</varname> manipulate some, and re-save them.</para>
6         &csource;
7         <para> Things to note in this source:</para>
8         <orderedlist>
9                 <listitem><simpara>The keys are manipulated in <function>changeConfig()</function> after we called <function>kdbClose()</function>. You don't need the key database to be open to manipulate keys.</simpara></listitem>
10                 <listitem><simpara>We called <function>kdbOpen()</function> again in <function>saveConfig()</function>, to prepare to commit the changes.</simpara></listitem>
11                 <listitem><simpara>We called <function>ksClose()</function> in the end to free all memory resources we used.</simpara></listitem>
12         </orderedlist>
13         
14
15         
16         <bridgehead id="linking">Compiling and Linking</bridgehead>
17         <para>All Elektra methods are declared in the <filename>/usr/include/kdb.h</filename> file and defined in the <filename>/lib/libelektra.so</filename> library. So to compile it you simply need to:</para><screen><prompt>bash$ </prompt><command>cc `pkg-config --libs elektra` -o myapp myapp.c</command></screen>
18         <para>or, if you don't have <command>pkg-config</command>:</para><screen><prompt>bash$ </prompt><command>cc -L /lib -lelektra -o myapp myapp.c</command></screen>
19