This section contains ini file handling support.
More...
|
typedef void * | ruIni |
| An opaque type representing an ini object. More...
|
|
|
RUAPI ruIni | ruIniFree (ruIni ini) |
| Frees the given ini object and its members. More...
|
|
RUAPI ruIni | ruIniNew (void) |
| Create a new empty ini object. More...
|
|
RUAPI int32_t | ruIniWrite (ruIni iniOb, trans_chars filename) |
| Writes given ini object into given filename. More...
|
|
RUAPI int32_t | ruIniRead (trans_chars filename, ruIni *iniOb) |
| Parse given INI-style file. May have [section]s, name=value pairs (whitespace stripped), and comments starting with ';' (semicolon). Section is "" if name=value pair parsed before any section heading. name:value pairs are also supported as a concession to Python's configparser. More...
|
|
RUAPI int32_t | ruIniSections (ruIni iniOb, ruList *sections) |
| Returns a list of sections from the given ini object. More...
|
|
RUAPI int32_t | ruIniKeys (ruIni iniOb, trans_chars section, ruList *keys) |
| Returns a list of keys from given section or global. More...
|
|
RUAPI perm_chars | ruIniGetDef (ruIni iniOb, trans_chars section, trans_chars key, trans_chars def, int32_t *code) |
| Retrieves a value or given default from the given ini object. More...
|
|
RUAPI int32_t | ruIniGet (ruIni iniOb, trans_chars section, trans_chars key, perm_chars *value) |
| Retrieves a value from the given ini object. More...
|
|
RUAPI int32_t | ruIniSet (ruIni iniOb, trans_chars section, trans_chars key, trans_chars value) |
| Set a value in the given ini object. More...
|
|
This section contains ini file handling support.
Example:
const char* inipath = "/path/to/file.ini";
const char* name = NULL;
ret =
ruIniGet(cf, NULL,
"username", &name);
printf("Username: %s", name);
ret =
ruIniSet(cf, NULL,
"password",
"secret");
RUAPI int32_t ruIniSet(ruIni iniOb, trans_chars section, trans_chars key, trans_chars value)
Set a value in the given ini object.
RUAPI int32_t ruIniGet(ruIni iniOb, trans_chars section, trans_chars key, perm_chars *value)
Retrieves a value from the given ini object.
RUAPI int32_t ruIniWrite(ruIni iniOb, trans_chars filename)
Writes given ini object into given filename.
RUAPI ruIni ruIniFree(ruIni ini)
Frees the given ini object and its members.
void * ruIni
An opaque type representing an ini object.
Definition: ini.h:56
RUAPI int32_t ruIniRead(trans_chars filename, ruIni *iniOb)
Parse given INI-style file. May have [section]s, name=value pairs (whitespace stripped),...
◆ ruIni
An opaque type representing an ini object.
◆ ruIniFree()
Frees the given ini object and its members.
- Parameters
-
- Returns
- NULL
◆ ruIniGet()
Retrieves a value from the given ini object.
- Parameters
-
iniOb | Object to get value from |
section | Section to get value from. NULL for no section. |
key | Key name. |
value | Where the value will be stored. Caller should copy as needed |
- Returns
- RUE_OK on success else an error code
◆ ruIniGetDef()
Retrieves a value or given default from the given ini object.
- Parameters
-
iniOb | Object to get value from |
section | Section to get value from. NULL for no section. |
key | Key name. |
def | Will be returned if not NULL and value is NULL or empty string. |
code | Optional, where to store the return code of the operation |
- Returns
- The found value or def if the value was not found or blank.
◆ ruIniKeys()
Returns a list of keys from given section or global.
- Parameters
-
iniOb | Object to get sections from |
section | Section to get keys from or NULL for global keys |
keys | List of keys to be freed by caller after use. |
- Returns
- RUE_OK on success else an error code
◆ ruIniNew()
RUAPI ruIni ruIniNew |
( |
void |
| ) |
|
Create a new empty ini object.
- Returns
- The object
◆ ruIniRead()
Parse given INI-style file. May have [section]s, name=value pairs (whitespace stripped), and comments starting with ';' (semicolon). Section is "" if name=value pair parsed before any section heading. name:value pairs are also supported as a concession to Python's configparser.
For each name=value pair parsed, call handler function with given user pointer as well as section, name, and value (data only valid for duration of handler call). Handler should return nonzero on success, zero on error.
- Parameters
-
filename | path to file to parse |
iniOb | Where the result ruIni object will be stored. Free with ruIniFree. |
- Returns
- RUE_OK on success else an error code
◆ ruIniSections()
RUAPI int32_t ruIniSections |
( |
ruIni |
iniOb, |
|
|
ruList * |
sections |
|
) |
| |
Returns a list of sections from the given ini object.
- Parameters
-
iniOb | Object to get sections from |
sections | List of sections to be freed by caller after use. |
- Returns
- RUE_OK on success else an error code
◆ ruIniSet()
Set a value in the given ini object.
- Parameters
-
iniOb | Object to set value in |
section | Section to set value in. NULL for no section. |
key | Key name |
value | The value to set. Use blank for an empty entry and NULL to remove |
- Returns
- RUE_OK on success else an error code
◆ ruIniWrite()
Writes given ini object into given filename.
- Parameters
-
iniOb | Ini object to write |
filename | Path to ini file |
- Returns
- RUE_OK on success else an error code