OpenCBM
|
Shared library / DLL for accessing the driver Read configuration file. More...
Go to the source code of this file.
Typedefs | |
typedef struct opencbm_configuration_s * | opencbm_configuration_handle |
Handle to a configuration file. | |
typedef int | opencbm_configuration_enum_sections_callback_t (opencbm_configuration_handle Handle, const char Section[], void *Context) |
Callback type for section enumeration. More... | |
typedef int | opencbm_configuration_enum_data_callback_t (opencbm_configuration_handle Handle, const char Section[], const char Entry[], void *Context) |
Callback type for entry enumeration. More... | |
Functions | |
const char * | configuration_get_default_filename (void) |
Get the default filename for the configuration file. More... | |
const char * | configuration_get_default_filename_for_install (unsigned int local_install) |
Get the default filename for the configuration file on installation. More... | |
opencbm_configuration_handle | opencbm_configuration_open (const char *Filename) |
Open the configuration file. More... | |
opencbm_configuration_handle | opencbm_configuration_create (const char *Filename) |
Creates the configuration file for reading and writing. More... | |
int | opencbm_configuration_close (opencbm_configuration_handle Handle) |
Close the configuration file. More... | |
int | opencbm_configuration_flush (opencbm_configuration_handle Handle) |
Flush the configuration file. More... | |
int | opencbm_configuration_get_data (opencbm_configuration_handle Handle, const char Section[], const char Entry[], char **ReturnBuffer) |
Read data from the configuration file. More... | |
int | opencbm_configuration_set_data (opencbm_configuration_handle Handle, const char Section[], const char Entry[], const char Value[]) |
Write/Change data to/in the configuration file. More... | |
int | opencbm_configuration_enum_sections (opencbm_configuration_handle Handle, opencbm_configuration_enum_sections_callback_t Callback, void *Context) |
Enumerate sections in the configuration file. More... | |
int | opencbm_configuration_enum_data (opencbm_configuration_handle Handle, const char Section[], opencbm_configuration_enum_data_callback_t Callback, void *Context) |
Enumerate data in the configuration file. More... | |
Shared library / DLL for accessing the driver Read configuration file.
Definition in file configuration.h.
typedef int opencbm_configuration_enum_data_callback_t(opencbm_configuration_handle Handle, const char Section[], const char Entry[], void *Context) |
Callback type for entry enumeration.
This function type is used as the callback function in opencbm_configuration_enum_data()
Handle | Handle to the configuration file |
Section | Name of the section |
Entry | Name of the enumerated entry |
Context | Context data as given in the call to opencbm_configuration_enum_data(). This data is not interpreted, but forwarded "as is". |
Definition at line 72 of file configuration.h.
typedef int opencbm_configuration_enum_sections_callback_t(opencbm_configuration_handle Handle, const char Section[], void *Context) |
Callback type for section enumeration.
This function type is used as the callback function in opencbm_configuration_enum_sections()
Handle | Handle to the configuration file |
Section | Name of the enumerated section |
Context | Context data as given in the call to opencbm_configuration_enum_sections(). This data is not interpreted, but forwarded "as is". |
Definition at line 45 of file configuration.h.
const char* configuration_get_default_filename | ( | void | ) |
Get the default filename for the configuration file.
Get the default filename of the configuration file.
Definition at line 50 of file LINUX/configuration_name.c.
References cbmlibmisc_strcat(), cbmlibmisc_strdup(), and OPENCBM_DEFAULT_CONFIGURATION_FILE_NAME.
Referenced by opencbm_plugin_get_all_plugin_names(), and opencbm_plugin_install_plugin_data().
const char* configuration_get_default_filename_for_install | ( | unsigned int | DefaultLocation | ) |
Get the default filename for the configuration file on installation.
Get the default filename of the configuration file. This function returns a filename even if no configuration exists yet. This is used for the installation, where the name for the initial configuration file must be found.
DefaultLocation | In case a new file has to be created, give the preference of one of the locations to use. |
Definition at line 224 of file WINDOWS/configuration_name.c.
Referenced by opencbm_plugin_install_generic().
int opencbm_configuration_close | ( | opencbm_configuration_handle | Handle | ) |
Close the configuration file.
Closes the configuration file after it has been used. If it has been changed in the mean time, it is first stored to permanent storage.
Handle | Handle to the opened configuration file, as obtained from opencbm_configuration_open() |
Definition at line 967 of file configuration.c.
References opencbm_configuration_flush().
Referenced by get_all_installed_plugins(), opencbm_plugin_get_all_plugin_names(), opencbm_plugin_install_generic(), and opencbm_plugin_install_plugin_data().
opencbm_configuration_handle opencbm_configuration_create | ( | const char * | Filename | ) |
Creates the configuration file for reading and writing.
Opens the configuration file so it can be used later on with opencbm_configuration_get_data(). If the file does not exist, a new, empty one is created.
Filename | The name of the configuration file to open |
Definition at line 869 of file configuration.c.
References opencbm_configuration_open().
Referenced by opencbm_plugin_install_generic().
int opencbm_configuration_enum_data | ( | opencbm_configuration_handle | Handle, |
const char | Section[], | ||
opencbm_configuration_enum_data_callback_t | Callback, | ||
void * | Data | ||
) |
Enumerate data in the configuration file.
This function enumerates all entries in a given section of the configuration file. For every entry, a given callback function is called.
Handle | Handle to the opened configuration file, as obtained from opencbm_configuration_open(). |
Section | A string which holds the name of the section from where to get the data. |
Callback | The callback function to call with the section name |
Data | Some data which is forwarded to the Callback function. |
Definition at line 1335 of file configuration.c.
References opencbm_configuration_section_s::Entries, opencbm_configuration_entry_s::Name, opencbm_configuration_section_s::Name, and opencbm_configuration_entry_s::Next.
int opencbm_configuration_enum_sections | ( | opencbm_configuration_handle | Handle, |
opencbm_configuration_enum_sections_callback_t | Callback, | ||
void * | Data | ||
) |
Enumerate sections in the configuration file.
This function enumerates all sections in the configuration file. For every section name, a given callback function is called.
Handle | Handle to the opened configuration file, as obtained from opencbm_configuration_open(). |
Callback | The callback function to call with the section name |
Data | Some data which is forwarded to the Callback function. |
Definition at line 1285 of file configuration.c.
References opencbm_configuration_section_s::Name, opencbm_configuration_section_s::Next, and opencbm_configuration_s::Sections.
Referenced by opencbm_plugin_get_all_plugin_names().
int opencbm_configuration_flush | ( | opencbm_configuration_handle | Handle | ) |
Flush the configuration file.
Flushes the configuration file. This is, if it has been changed, it is stored to permanent storage.
Handle | Handle to the opened configuration file, as obtained from opencbm_configuration_open() |
Definition at line 934 of file configuration.c.
References opencbm_configuration_s::Changed.
Referenced by opencbm_configuration_close().
int opencbm_configuration_get_data | ( | opencbm_configuration_handle | Handle, |
const char | Section[], | ||
const char | Entry[], | ||
char ** | ReturnBuffer | ||
) |
Read data from the configuration file.
This function searches for a specific enty in the configuration file and returns the value found there.
Handle | Handle to the opened configuration file, as obtained from opencbm_configuration_open(). |
Section | A string which holds the name of the section from where to get the data. |
Entry | A string which holds the name of the entry to get. |
ReturnBuffer | A buffer which holds the return value on success. If the function returns with something different than 0, the buffer pointer to by ReturnBuffer will not be changed. Can be NULL, cf. note below. |
Definition at line 1226 of file configuration.c.
References cbmlibmisc_strdup(), and opencbm_configuration_entry_s::Value.
Referenced by plugin_is_active().
opencbm_configuration_handle opencbm_configuration_open | ( | const char * | Filename | ) |
Open the configuration file.
Opens the configuration file so it can be used later on with opencbm_configuration_get_data(). If the file does not exist, this function fails.
Filename | The name of the configuration file to open |
If the configuration file does not exist, this function returns NULL.
Definition at line 804 of file configuration.c.
References cbmlibmisc_strcat(), cbmlibmisc_strdup(), cbmlibmisc_strfree(), opencbm_configuration_s::Changed, opencbm_configuration_s::FileName, opencbm_configuration_s::FileNameForWrite, and opencbm_configuration_s::Sections.
Referenced by opencbm_configuration_create(), opencbm_plugin_get_all_plugin_names(), and opencbm_plugin_install_plugin_data().
int opencbm_configuration_set_data | ( | opencbm_configuration_handle | Handle, |
const char | Section[], | ||
const char | Entry[], | ||
const char | Value[] | ||
) |
Write/Change data to/in the configuration file.
This function searches for a specific entry in the configuration file and changes it if it exists. If it does not exist, a new entry is generated.
Handle | Handle to the opened configuration file, as obtained from opencbm_configuration_open(). |
Section | A string which holds the name of the section where to set the data. |
Entry | A string which holds the name of the entry to set. |
Value | A buffer which holds the value of the entry which is to be set. |
Definition at line 1390 of file configuration.c.
References cbmlibmisc_strdup(), cbmlibmisc_strfree(), opencbm_configuration_s::Changed, and opencbm_configuration_entry_s::Value.
Referenced by opencbm_plugin_install_generic(), and opencbm_plugin_install_plugin_data().