The purpose of the DAX is to access the settings in the configuration database. It is mainly used during commit time.
The following is taken from the DAX documentations and it shows what dax_ does.
Example 1: Setting up daemon to open, read, and close the UI database
#include <feature/jexample_sequence.h> #include <feature/jexample_out.h> boolean mydaemon_read_config (boolean do_check) { const char *err; boolean status; int myint; err = dax_open_db(NULL, DAE_MYDAE, PACKAGE_NAME, SEQUENCE_NUMBER, do_check); if (err) { dax_error(NULL, "Opening configuration database: %s", error); return FALSE; } status = mydaemon_config_knobs(do_check); err = dax_close_db(); if (err) { dax_error(NULL, "Closing configuration database: %s", err); } return status; }
Example 2: Fetching values using the dax_get_* api
/* */ /* Reads configuration under [system knobs1], if do_check is */ /* TRUE, we simply do a check, otherwise we configure the knobs. */ /* */ boolean mydaemon_config_knobs (boolean do_check) { int knob_int; char knob_str[KNOB_STR_SZ]; const char *knob_path[] = { "system", "knobs", NULL }; ddl_handle_t *dop; if (!dax_get_object_by_path(NULL, knob_path, &dop, FALSE)) { if (!do_check) { /* knobs not configured, do something about it. */ } return TRUE; } knob_int = DEFAULT_KNOB_INT; dax_get_int_by_name(dop, "knob-int", &knob_int); strncpy(knob_str, DEFAULT_KNOB_STR, sizeof(knob_str)); dax_get_stringr_by_name(dop, "knob-str", &knob_str, sizeof(knob_str)); dax_release_object(&dop); if (do_check) return TRUE; /* Not a check set internal state. */ mydaemon_set_knob(knob_int, knob_str); return TRUE; }
Example 3: Walking container items
Containers are defined in the ddl as 'type setof foo_object' for by the flag "setof' statement. Note the 'delta-list' flag. This is required if you want mgd to store 'delete' information. Otherwise the UI will treat a delete as if you deleted the entire list and recreated it. ie. it'll send a DAX_ITEM_DELETE_ALL message, then a DAX_ITEM_CHANGED message for all configured items.
Example knob.cnf.ddl file object knob-keys { flag autosort list delta-list; attirbute knob-key-name { flag nokeyword identifier; type string; } attribute key-string-value { type string; } }