The qDecoder Project: C/C++ Library

- Main Page
- Data Structures
- Files

- File List
- Globals

# qConfig.c File Reference

Configuration File Handling API. More...

## Defines
#define | _INCLUDE_DIRECTIVE "@INCLUDE "
#define | _VAR '$'
#define | _VAR_OPEN '{'
#define | _VAR_CLOSE '}'
#define | _VAR_CMD '!'
#define | _VAR_ENV '%'
## Functions
Q_ENTRY * | qConfigParseFile (Q_ENTRY *config, const char *filepath, char sepchar)
| Load & parse configuration file.
Q_ENTRY * | qConfigParseStr (Q_ENTRY *config, const char *str, char sepchar)
| Parse string.

## Detailed Description

Configuration File Handling API.

## Function Documentation

Q_ENTRY* qConfigParseFile | ( | Q_ENTRY * | config,
|  | const char * | filepath,
|  | char | sepchar |
| ) |  |  |

Load & parse configuration file.

Parameters:

  | config | a pointer of Q_ENTRY. NULL can be used for empty.
  | filepath | configuration file path
  | sepchar | separater used in configuration file to divice key and value

Returns:
  a pointer of Q_ENTRY in case of successful, otherwise(file not found) returns NULL

Note:
  Configuration file forma

     # a line which starts with # character is comment
     @INCLUDE other.conf          => (include other.conf)
     base = /tmp                  => base = /tmp
     log  = ${base}/log           => /tmp/log (using variable)
     host = ${!/bin/hostname -s}  => arena (external command result)
     path = ${%PATH}              => /usr/bin:/usr/sbin (environment)

       Q_ENTRY *config = qConfigParseFile(NULL, "qdecoder.conf", '=');

Q_ENTRY* qConfigParseStr | ( | Q_ENTRY * | config,
|  | const char * | str,
|  | char | sepchar |
| ) |  |  |

Parse string.

Parameters:

  | config | a pointer of Q_ENTRY. NULL can be used for empty.
  | str | key, value pair strings
  | sepchar | separater used in configuration file to divice key and value

Returns:
  a pointer of Q_ENTRY in case of successful, otherwise(file not found) returns NULL

See also:
  qConfigParseFile

       Q_ENTRY *config = qConfigParseStr(NULL, "key = value\nhello = world", '=');

[Home] [About] [Examples] [Changes] [Download] [SVN Repository] [Install] [Reference]