#define LND_DOM_NETDUDE enum LND_PrefsType; void (*LND_PrefsCallback) (LND_PrefsDomain *domain, void *user_data); #define LND_UNUSED void libnd_prefs_init (void); void libnd_prefs_load (void); int libnd_prefs_save (void); void libnd_prefs_apply (void); const char* libnd_prefs_get_netdude_dir (void); const char* libnd_prefs_get_config_file (void); const char* libnd_prefs_get_plugin_dir_global (void); const char* libnd_prefs_get_plugin_dir_user (void); const char* libnd_prefs_get_proto_dir_global (void); const char* libnd_prefs_get_proto_dir_user (void); LND_PrefsDomain* libnd_prefs_add_domain (const char *domain, LND_PrefsEntry *entries, int num_entries); LND_PrefsDomain* libnd_prefs_get_domain (const char *domain); void libnd_prefs_domain_add_apply_cb (LND_PrefsDomain *domain, LND_PrefsCallback apply_cb); void libnd_prefs_foreach_domain (LND_PrefsCallback callback, void *user_data); void libnd_prefs_set_str_item (const char *domain, const char *key, const char *data); void libnd_prefs_set_flt_item (const char *domain, const char *key, float data); void libnd_prefs_set_int_item (const char *domain, const char *key, int data); void libnd_prefs_del_item (const char *domain, const char *key); gboolean libnd_prefs_get_str_item (const char *domain, const char *key, char **result); gboolean libnd_prefs_get_flt_item (const char *domain, const char *key, float *result); gboolean libnd_prefs_get_int_item (const char *domain, const char *key, int *result); |
typedef enum { LND_PREFS_INT = 1, LND_PREFS_FLT = 2, LND_PREFS_STR = 3, LND_PREFS_UNK = 4 } LND_PrefsType; |
void (*LND_PrefsCallback) (LND_PrefsDomain *domain, void *user_data); |
This is the signature of functions passed to libnd_prefs_add_domain()
that get called when the user applies changes in preference settings.
the preferences domain that got updated.
arbitrary user data.
void libnd_prefs_load (void); |
This initializes the preferences as they're found in the user's config file, which is created if it doesn't yet exist. Called during Netdude startup. You don't need this.
void libnd_prefs_apply (void); |
This function iterates over the registered preferences domains and calls the apply callbacks registered for each of these domains.
const char* libnd_prefs_get_netdude_dir (void); |
The function returns a pointer to static memory containing the directory to the user's Netdude directory, where preferences and locally-installed plugins are stored.
user's Netdude directory.
const char* libnd_prefs_get_config_file (void); |
The function returns a pointer to static memory containing the name of the user's Netdude config file.
config file name.
const char* libnd_prefs_get_plugin_dir_global (void); |
The function returns a pointer to static memory containing the name of the system-wide feature plugin directory.
global plugin directory.
const char* libnd_prefs_get_plugin_dir_user (void); |
The function returns a pointer to static memory containing the name of the user's feature plugin directory.
user's plugin directory.
const char* libnd_prefs_get_proto_dir_global (void); |
The function returns a pointer to static memory containing the name of the system-wide protocol plugin directory.
global protocol plugin directory.
const char* libnd_prefs_get_proto_dir_user (void); |
The function returns a pointer to static memory containing the name of the user's protocol plugin directory.
user's plugin directory.
LND_PrefsDomain* libnd_prefs_add_domain (const char *domain, LND_PrefsEntry *entries, int num_entries); |
Adds a new domain of configuration items, created from the given preference entries, to the configuration system. The new preferences domain is returned as well as registered.
name of the domain.
array of LND_PrefsEntry structures describing preference settings.
length of entries.
new preferences domain.
LND_PrefsDomain* libnd_prefs_get_domain (const char *domain); |
The function looks up and returns the domain namend domain if possible.
name of the domain to find.
discovered domain, or NULL if no such domain was found.
void libnd_prefs_domain_add_apply_cb (LND_PrefsDomain *domain, LND_PrefsCallback apply_cb); |
The function registers apply_cb for domain, so that apply_cb is called whenever new configuration settings are to be applied.
domain to add callback to.
the callback to register.
void libnd_prefs_foreach_domain (LND_PrefsCallback callback, void *user_data); |
The function iterates over all registered configuration domains, passing each to callback, alongside with user_data.
callback to call for each domain.
arbitrary data passed to callback.
void libnd_prefs_set_str_item (const char *domain, const char *key, const char *data); |
The function stores data as the value of key in the preferences database.
domain of item.
name of the item.
new value of key.
void libnd_prefs_set_flt_item (const char *domain, const char *key, float data); |
The function stores data as the value of key in the preferences database.
domain of item.
name of the item.
new value of key.
void libnd_prefs_set_int_item (const char *domain, const char *key, int data); |
The function stores data as the value of key in the preferences database.
domain of item.
name of the item.
new value of key.
void libnd_prefs_del_item (const char *domain, const char *key); |
The function removes the preference item from the database.
domain of item.
name of the item.
gboolean libnd_prefs_get_str_item (const char *domain, const char *key, char **result); |
The function retrieves the specified preference item and stores it in result.
domain of item.
name of item.
pointer to result.
TRUE on success, FALSE otherwise.
gboolean libnd_prefs_get_flt_item (const char *domain, const char *key, float *result); |
The function retrieves the specified preference item and stores it in result.
domain of item.
name of item.
pointer to result.
TRUE on success, FALSE otherwise.
gboolean libnd_prefs_get_int_item (const char *domain, const char *key, int *result); |
The function retrieves the specified preference item and stores it in result.
domain of item.
name of item.
pointer to result.
TRUE on success, FALSE otherwise.