libnd_prefs

Name

libnd_prefs -- 

Synopsis

#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);

Description

Details

LND_DOM_NETDUDE

#define LND_DOM_NETDUDE   "libnetdude"


enum LND_PrefsType

typedef enum
{
  LND_PREFS_INT = 1,
  LND_PREFS_FLT = 2,
  LND_PREFS_STR = 3,
  LND_PREFS_UNK = 4
} LND_PrefsType;


LND_PrefsCallback ()

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.

domain :

the preferences domain that got updated.

user_data :

arbitrary user data.


LND_UNUSED

#define LND_UNUSED 0


libnd_prefs_init ()

void                libnd_prefs_init                    (void);


libnd_prefs_load ()

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.


libnd_prefs_save ()

int                 libnd_prefs_save                    (void);

Returns :

TRUE on success, FALSE otherwise.


libnd_prefs_apply ()

void                libnd_prefs_apply                   (void);

This function iterates over the registered preferences domains and calls the apply callbacks registered for each of these domains.


libnd_prefs_get_netdude_dir ()

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.

Returns :

user's Netdude directory.


libnd_prefs_get_config_file ()

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.

Returns :

config file name.


libnd_prefs_get_plugin_dir_global ()

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.

Returns :

global plugin directory.


libnd_prefs_get_plugin_dir_user ()

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.

Returns :

user's plugin directory.


libnd_prefs_get_proto_dir_global ()

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.

Returns :

global protocol plugin directory.


libnd_prefs_get_proto_dir_user ()

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.

Returns :

user's plugin directory.


libnd_prefs_add_domain ()

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.

domain :

name of the domain.

entries :

array of LND_PrefsEntry structures describing preference settings.

num_entries :

length of entries.

Returns :

new preferences domain.


libnd_prefs_get_domain ()

LND_PrefsDomain *   libnd_prefs_get_domain              (const char *domain);

The function looks up and returns the domain namend domain if possible.

domain :

name of the domain to find.

Returns :

discovered domain, or NULL if no such domain was found.


libnd_prefs_domain_add_apply_cb ()

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 :

domain to add callback to.

apply_cb :

the callback to register.


libnd_prefs_foreach_domain ()

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 :

callback to call for each domain.

user_data :

arbitrary data passed to callback.


libnd_prefs_set_str_item ()

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 :

domain of item.

key :

name of the item.

data :

new value of key.


libnd_prefs_set_flt_item ()

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 :

domain of item.

key :

name of the item.

data :

new value of key.


libnd_prefs_set_int_item ()

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 :

domain of item.

key :

name of the item.

data :

new value of key.


libnd_prefs_del_item ()

void                libnd_prefs_del_item                (const char *domain,
                                                         const char *key);

The function removes the preference item from the database.

domain :

domain of item.

key :

name of the item.


libnd_prefs_get_str_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 :

domain of item.

key :

name of item.

result :

pointer to result.

Returns :

TRUE on success, FALSE otherwise.


libnd_prefs_get_flt_item ()

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 :

domain of item.

key :

name of item.

result :

pointer to result.

Returns :

TRUE on success, FALSE otherwise.


libnd_prefs_get_int_item ()

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 :

domain of item.

key :

name of item.

result :

pointer to result.

Returns :

TRUE on success, FALSE otherwise.