ccl  0.1.1
Data Structures | Typedefs | Functions
ccl.h File Reference

The ccl library interface. More...

#include "ccl/bst.h"

Go to the source code of this file.

Data Structures

struct  ccl_pair_t
 A key/value pair found in a configuration file. More...
 
struct  ccl_t
 Data structure encapsulating a parsed configuration file. More...
 

Typedefs

typedef struct ccl_t ccl_t
 

Functions

int ccl_parse (struct ccl_t *data, const char *path)
 Parse a configuration file. More...
 
void ccl_release (struct ccl_t *data)
 Release memory associated with a configuration file. More...
 
const char * ccl_get (const struct ccl_t *data, const char *key)
 Extract a value from a configuration file. More...
 
const struct ccl_pair_tccl_iterate (struct ccl_t *data)
 Iterate through all key/value pairs in a configuration file. More...
 
void ccl_reset (struct ccl_t *data)
 Reset a configuration file iterator. More...
 
struct ccl_pair_tccl_set (const struct ccl_t *data, const char *key, const char *value)
 Set a value in a configuration file. More...
 

Detailed Description

The ccl library interface.

Function Documentation

const char* ccl_get ( const struct ccl_t data,
const char *  key 
)

Extract a value from a configuration file.

This function searches the parsed configuration file data for key, and returns the value associated with that key.
If key was found in the configuration file, the returned value will never be 0.
The value returned belongs to ccl, and should not be free'd.

Parameters
dataThe ccl_t to query
keyThe key to query
Returns
The value associated with key, or 0 if key was not found
const struct ccl_pair_t* ccl_iterate ( struct ccl_t data)

Iterate through all key/value pairs in a configuration file.

This function allows iteration through all key/value pairs in a configuration file.
This function maintains internal state; to reset the iterator call ccl_reset.
The value returned belongs to ccl, and should not be free'd.

Parameters
dataThe ccl_t to query
Returns
A key/value pair, or 0 if no more exist in data
int ccl_parse ( struct ccl_t data,
const char *  path 
)

Parse a configuration file.

This function will attempt to parse the configuration file path, using the comment, separator, and quote characters specified in data. This function allocates memory; use ccl_release to clean up.

Parameters
dataThe ccl_t in which to store the parsed data
pathThe file to parse
Returns
0 if successful, nonzero otherwise
void ccl_release ( struct ccl_t data)

Release memory associated with a configuration file.

This function frees any dynamically-allocated memory in data.

Parameters
dataThe ccl_t that is no longer needed
void ccl_reset ( struct ccl_t data)

Reset a configuration file iterator.

This function resets the internal iterator in data to the first key/value pair.

Parameters
dataThe ccl_t to reset
struct ccl_pair_t* ccl_set ( const struct ccl_t data,
const char *  key,
const char *  value 
)

Set a value in a configuration file.

This function sets a value in data as though it were read from a configuration file. If not 0, the value returned no longer belongs to ccl and should be free'd, including the internal key and value pointers.

Parameters
dataThe ccl_t to which the key/value pair should be addded.
keyThe key
valueThe value
Returns
The key/value pair that was replaced, or 0 if none.