+ str = database_get_data(conf_node, "toplevel_access", RECDB_QSTRING);
+ unsigned int toplevel_access = atoi(str);
+ hostserv_conf.toplevel_access = (toplevel_access ? toplevel_access : 600);
+
+ str = database_get_data(conf_node, "fallback_other_assignment", RECDB_QSTRING);
+ hostserv_conf.fallback_other_assignment = (atoi(str) ? 1 : 0);
+
+ str = database_get_data(conf_node, "manager_can_del_toplevel", RECDB_QSTRING);
+ hostserv_conf.manager_can_del_toplevel = (atoi(str) ? 1 : 0);
+
+ str = database_get_data(conf_node, "manager_can_del_secondlevel", RECDB_QSTRING);
+ hostserv_conf.manager_can_del_secondlevel = (atoi(str) ? 1 : 0);
+
+ str = database_get_data(conf_node, "manager_can_rename_toplevel", RECDB_QSTRING);
+ hostserv_conf.manager_can_rename_toplevel = (atoi(str) ? 1 : 0);
+
+ str = database_get_data(conf_node, "manager_can_rename_secondlevel", RECDB_QSTRING);
+ hostserv_conf.manager_can_rename_secondlevel = (atoi(str) ? 1 : 0);
+
+ str = database_get_data(conf_node, "manager_toplevel_can_oset", RECDB_QSTRING);
+ hostserv_conf.manager_toplevel_can_oset = (atoi(str) ? 1 : 0);
+
+ str = database_get_data(conf_node, "manager_secondlevel_can_oset", RECDB_QSTRING);
+ hostserv_conf.manager_secondlevel_can_oset = (atoi(str) ? 1 : 0);
+}
+
+static int hostserv_saxdb_read_secondlevel(const char *name, void *data, UNUSED_ARG(void *extra));
+static int hostserv_saxdb_read_assignments(const char *name, void *data, UNUSED_ARG(void *extra));
+
+static int hostserv_saxdb_read_toplevel(const char *name, void *data, UNUSED_ARG(void *extra)) {
+ struct record_data *rd = data;
+ struct hs_toplevel *tlfh;
+ struct hs_manager *managerTL;
+ struct hs_user *user;
+ struct dict *object;
+
+ if (rd->type == RECDB_OBJECT) {
+ dict_t db = GET_RECORD_OBJECT(rd);
+ dict_iterator_t it;
+
+ tlfh = hs_add_toplevel(name);
+
+ if ((object = database_get_data(db, KEY_MANAGERS, RECDB_OBJECT))) {
+ for (it = dict_first(object); it; it = iter_next(it)) {
+ user = hs_get_user(get_handle_info(iter_key(it)), 1);
+ //rd = iter_data(it);
+ /* nothing in here, yet */
+ managerTL = hs_add_manager_toplevel(tlfh, user);
+ if (database_get_data(db, KEY_ACTIVE, RECDB_QSTRING))
+ managerTL->active = 1;
+ else
+ managerTL->active = 0;
+ }
+ }
+
+ if ((object = database_get_data(db, KEY_SECONDLEVEL, RECDB_OBJECT)))
+ dict_foreach(object, hostserv_saxdb_read_secondlevel, tlfh);
+ }
+ return 0;
+}
+
+static int hostserv_saxdb_read_secondlevel(const char *name, void *data, UNUSED_ARG(void *extra)) {
+ struct record_data *rd = data;
+ struct hs_toplevel *tlfh = extra;
+ struct hs_secondlevel *slfh;
+ struct hs_manager *managerSL;
+ struct hs_user *user;
+ struct dict *object;
+
+ if (rd->type == RECDB_OBJECT) {
+ dict_t db = GET_RECORD_OBJECT(rd);
+ dict_iterator_t it;
+
+ slfh = hs_add_secondlevel(tlfh, name);
+
+ if ((object = database_get_data(db, KEY_MANAGERS, RECDB_OBJECT))) {
+ for (it = dict_first(object); it; it = iter_next(it)) {
+ user = hs_get_user(get_handle_info(iter_key(it)), 1);
+ //rd = iter_data(it);
+ /* nothing in here, yet */
+ managerSL = hs_add_manager_secondlevel(slfh, user);
+ if (database_get_data(db, KEY_ACTIVE, RECDB_QSTRING))
+ managerSL->active = 1;
+ else
+ managerSL->active = 0;
+ }
+ }
+
+ if ((object = database_get_data(db, KEY_ASSIGNMENTS, RECDB_OBJECT)))
+ dict_foreach(object, hostserv_saxdb_read_assignments, slfh);
+ }
+ return 0;
+}
+
+static int hostserv_saxdb_read_assignments(const char *name, void *data, UNUSED_ARG(void *extra)) {
+ struct record_data *rd = data;
+ struct hs_secondlevel *slfh = extra;
+ struct hs_user *user;
+ int active;
+
+ if (rd->type == RECDB_OBJECT) {
+ dict_t db = GET_RECORD_OBJECT(rd);
+
+ user = hs_get_user(get_handle_info(name), 1);
+ active = (database_get_data(db, KEY_ACTIVE, RECDB_QSTRING) ? HS_ASSIGNMENTSTATE_ON : HS_ASSIGNMENTSTATE_OFF);
+
+ hs_add_assignment(slfh, user, active);
+ }
+
+ return 0;
+}
+
+static int
+hostserv_saxdb_read(struct dict *db)
+{
+ struct dict *object;
+
+ if ((object = database_get_data(db, KEY_TOPLEVEL, RECDB_OBJECT)))
+ dict_foreach(object, hostserv_saxdb_read_toplevel, NULL);
+
+ return 1;
+}
+
+static int
+hostserv_saxdb_write(struct saxdb_context *ctx)
+{
+ struct hs_toplevel *tlfh;
+ struct hs_secondlevel *slfh;
+ struct hs_assignment *assng;
+ struct hs_manager *manager;
+
+ saxdb_start_record(ctx, KEY_TOPLEVEL, 1);
+ for(tlfh = toplevels; tlfh; tlfh = tlfh->next) {
+ saxdb_start_record(ctx, tlfh->fakehost, 1);
+
+ saxdb_start_record(ctx, KEY_MANAGERS, 1);
+ for(manager = tlfh->managers; manager; manager = manager->next) {
+ saxdb_start_record(ctx, manager->user->hi->handle, 0);
+ //additional manager information?
+ if(manager->active)
+ saxdb_write_int(ctx, KEY_ACTIVE, manager->active);
+ saxdb_end_record(ctx);
+ }
+ saxdb_end_record(ctx);
+
+ saxdb_start_record(ctx, KEY_SECONDLEVEL, 1);
+ for(slfh = tlfh->secondlevel; slfh; slfh = slfh->next) {
+ saxdb_start_record(ctx, slfh->fakehost, 1);
+
+ saxdb_start_record(ctx, KEY_MANAGERS, 1);
+ for(manager = slfh->managers; manager; manager = manager->next) {
+ saxdb_start_record(ctx, manager->user->hi->handle, 0);
+ //additional manager information?
+ if(manager->active)
+ saxdb_write_int(ctx, KEY_ACTIVE, manager->active);
+ saxdb_end_record(ctx);
+ }
+ saxdb_end_record(ctx);
+
+ saxdb_start_record(ctx, KEY_ASSIGNMENTS, 1);
+ for(assng = slfh->assignments; assng; assng = assng->next) {
+ saxdb_start_record(ctx, assng->user->hi->handle, 0);
+ //additional assignment information?
+ if(assng->active)
+ saxdb_write_int(ctx, KEY_ACTIVE, assng->active);
+ saxdb_end_record(ctx);
+ }
+ saxdb_end_record(ctx);
+
+ saxdb_end_record(ctx);
+ }
+ saxdb_end_record(ctx);
+
+ saxdb_end_record(ctx);
+ }
+ saxdb_end_record(ctx);
+
+ return 0;