summaryrefslogtreecommitdiff
path: root/doc/usage.texi
blob: 991bfd1d13c1945f47b7fefa11b964d9d18b18e3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105


@c This file is part of the CConf manual. See cconf.texi for a GPL
@c license header.

@chapter Using CConf In Your Project

This Chapter overviews how to use cconf in your own package.

@menu
* Installation::                Installing CConf
* Integration::                 Integrating CConf Into Your Package
* Example::                     An Example of Using CConf
@end menu

@node Installation, Integration, Usage, Usage
@section Installing CConf

CConf is hosted on GNU Savannah. Go to the CConf project page, and then
go to the git source repository. Releases can be found in the CGit
interface.

To install the package, simply follow GNU standard build proceedures.

@file{bash}
@example
$ tar -xvf cconf-1.0.tar.gz
...
$ cd cconf-1.0
$ ./configure --prefix=@file{/path/to/prefix/}
...
$ make
...
# make install
@end example

This will configure the package with no options, compile the package, and
install the package to your selected prefix. Depending on the prefix, it may be
necessary to install with root.

The only defined configuration option provided by CConf is
@code{--enable-pthreads}. This allows access to some asynchronous API functions
that otherwise would not be built. Other than that, see
@code{./configure --help} for a more detailed listing of options.

For a more indepth guide to installing, read the INSTALL file in the root
directory.

@node Integration, Example, Installation, Usage
@section Integrating CConf Into Your Package

CConf's API is found in a distributed shared library. The package does also build
a static library if configured to do so. Make sure that, if you do not install the
package into a standard linker path, you add the prefix that you installed into to
the @file{/etc/ld.so.conf/} file. Once you have done that, then run @code{# ldconfig}.
This way, it is easier to link against the library.

To link against the library, compile with the following flags:
@code{$ gcc foo.c -o foo -lcconf}. This will link the shared library into your package.

In addition to linking against the shared library, it is important to include the
necessary header file. The main header file used is @file{$PREFIX/include/cconf/cconf.h}.
To include this file, add @code{#include <cconf/cconf.h>} to your source file.

Once you have completed these step, you are ready to use CConf in your project.

@node Example,  , Integration, Usage
@section Example

Here is an example using everything just shown.

@file{foo.c}
@example
#include <stdio.h>
#include <cconf/cconf.h>

int main(void)
@{
  cconf_t *cconf = cconf_new();

  ...

  cconf_free(cconf);

  return 0;
@}
@end example

@file{bash}
@example
$ gcc foo.c -o foo -lcconf
...
$ ./foo
$ 
@end example

As far as output goes, this program does nothing. However, it does integrate CConf.
Note the include statement at the top which includes the necessary header files.
In addition, the file is compiled with the shared library.

What the actual functions and data structures will be coverd in the chapter
C Programming with CConf. But first, it is important to under stand how the CConf
configuration file format works.