Xiqual 0.9.1

In file xitools/cfg_loadprefs.c:

extern List* cfg_loadprefs

(ulong tag1,
  ... )

Load preferences from an INI-style file.


Load preferences from an INI-style file. The minimum configuration file accepted has one line with a variable name on it:


A standalone variable like this would be considered a boolean variable. When loaded into memory, you would be returned a List containing only one preferences section, with no name.

A larger file should be divided into sections, like this:

something = something else

The List returned from cfg_loadprefs() would now contain one preferences section named "main", with two variable - mybool is a boolean (set to TRUE), and the second variable would be named "something", a string variable set to "something else".

Whenever a new set of square brackets are encountered, the name between them is used in a new preferences section. All the following variables will be added to that until yet another section name is found.

Legal variable names are anything not containing whatever your system considers whitespace.

Accepted tags:

PREFS_FILENAME: Name of file to load. Required.

PREFS_STRINGS: Load all data as string variables.

PREFS_STRING_HOOK, PREFS_VALUE_HOOK: Normally, variables are tokenised to include the whole string (for string variables) or get numbers until atoi() returns (integers). Use these tags to specify an alternate function to handle the processing of the value. Useful if a string contains multiple filenames, or several numbers to process.

A variable structure will not be created, but the hook gets the name of the variable that otherwise would be created, along with the preferences section pointer and a string containing the rest of the line. You will then need to duplicate any strings passed with strdup().

The hook functions are declared as such in the sourcecode:

void (*strhook)(struct preferences *section, char *varname, char *values);

void (*valhook)(struct preferences *section, char *varname, char *values);

Ronny Bangsund
See Also:
preferences, variable, cfg_findsection(), cfg_findvar(), list_free() strtok(), atoi(), strdup()

Alphabetic index

This page was generated with the help of DOC++.