Skip to content
Snippets Groups Projects
Commit 71db2710 authored by Eric Vidal's avatar Eric Vidal :speech_balloon:
Browse files

add tree_issupervised function and its resolve field

parent 9807eab8
No related branches found
No related tags found
No related merge requests found
......@@ -43,18 +43,19 @@ struct resolve_tree_s
uint32_t requiredby ;
uint32_t allow ;
uint32_t groups ;
uint32_t contents ;//not used
uint32_t contents ;
uint32_t ndepends ;
uint32_t nrequiredby ;
uint32_t nallow ;
uint32_t ngroups ; //not really useful for now, we accept only one group
uint32_t ncontents ; //not used
uint32_t ncontents ;
uint32_t init ;//not initialized->0, initialized->1
uint32_t supervised ;//not superviseded->0, supervised->1
uint32_t disen ;//disable->0, enable->1
} ;
#define RESOLVE_TREE_ZERO { 0,STRALLOC_ZERO,0,0,0,0,0,0,0,0,0,0,0,0,0 }
#define RESOLVE_TREE_ZERO { 0,STRALLOC_ZERO,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }
typedef enum resolve_tree_enum_e resolve_tree_enum_t, *resolve_tree_enum_t_ref;
enum resolve_tree_enum_e
......@@ -71,6 +72,7 @@ enum resolve_tree_enum_e
E_RESOLVE_TREE_NGROUPS,
E_RESOLVE_TREE_NCONTENTS,
E_RESOLVE_TREE_INIT,
E_RESOLVE_TREE_SUPERVISED,
E_RESOLVE_TREE_DISEN,
E_RESOLVE_TREE_ENDOFKEY
} ;
......@@ -149,6 +151,11 @@ extern int tree_iscurrent(char const *base, char const *treename) ;
* @Return -1 on system error */
extern int tree_isinitialized(char const *base, char const *treename) ;
/** @Return 1 on success
* @Return 0 on fail
* @Return -1 on system error */
extern int tree_issupervised(char const *base, char const *treename) ;
/** @Return 1 on success
* @Return 0 if not valid
* @Return -1 on system error */
......
......@@ -377,13 +377,14 @@ int ssexec_inresolve(int argc, char const *const *argv, ssexec_t *info)
"ngroups",
"ncontents",
"init" ,
"disen", // 13
"supervised",
"disen", // 14
// Master
"enabled",
"current",
"contents",
"nenabled",
"ncontents" // 18
"ncontents" // 19
} ;
resolve_wrapper_t_ref wres = 0 ;
......@@ -426,17 +427,18 @@ int ssexec_inresolve(int argc, char const *const *argv, ssexec_t *info)
info_display_int(fields[9], tres.ngroups) ;
info_display_int(fields[10], tres.ncontents) ;
info_display_int(fields[11], tres.init) ;
info_display_int(fields[12], tres.disen) ;
info_display_int(fields[12], tres.supervised) ;
info_display_int(fields[13], tres.disen) ;
} else {
info_display_string(fields[0], mres.sa.s, mres.name, 1) ;
info_display_string(fields[3], mres.sa.s, mres.allow, 1) ;
info_display_string(fields[13], mres.sa.s, mres.enabled, 1) ;
info_display_string(fields[14], mres.sa.s, mres.current, 1) ;
info_display_string(fields[15], mres.sa.s, mres.contents, 1) ;
info_display_int(fields[16], mres.nenabled) ;
info_display_int(fields[17], mres.ncontents) ;
info_display_string(fields[14], mres.sa.s, mres.enabled, 1) ;
info_display_string(fields[15], mres.sa.s, mres.current, 1) ;
info_display_string(fields[16], mres.sa.s, mres.contents, 1) ;
info_display_int(fields[17], mres.nenabled) ;
info_display_int(fields[18], mres.ncontents) ;
}
resolve_free(wres) ;
......
......@@ -3,6 +3,7 @@ tree_get_permissions.o
tree_iscurrent.o
tree_isenabled.o
tree_isinitialized.o
tree_issupervised.o
tree_isvalid.o
tree_ongroups.o
tree_resolve_array_search.o
......
/*
* tree_issupervised.c
*
* Copyright (c) 2018-2021 Eric Vidal <eric@obarun.org>
*
* All rights reserved.
*
* This file is part of Obarun. It is subject to the license terms in
* the LICENSE file found in the top-level directory of this
* distribution.
* This file may not be copied, modified, propagated, or distributed
* except according to the terms contained in the LICENSE file./
*/
#include <string.h>
#include <oblibs/string.h>
#include <oblibs/log.h>
#include <66/constants.h>
#include <66/resolve.h>
#include <66/tree.h>
int tree_issupervised(char const *base, char const *treename)
{
log_flow() ;
int e = -1 ;
resolve_tree_t tres = RESOLVE_TREE_ZERO ;
resolve_wrapper_t_ref wres = resolve_set_struct(DATA_TREE, &tres) ;
if (!resolve_read_g(wres, base, treename))
goto err ;
if (tres.supervised)
e = 1 ;
else
e = 0 ;
err:
resolve_free(wres) ;
return e ;
}
......@@ -46,6 +46,7 @@ int tree_resolve_copy(resolve_tree_t *dst, resolve_tree_t *tres)
dst->ngroups = tres->ngroups ;
dst->ncontents = tres->ncontents ;
dst->init = tres->init ;
dst->supervised = tres->supervised ;
dst->disen = tres->disen ;
return 1 ;
......
......@@ -83,6 +83,11 @@ int tree_resolve_get_field_tosa(stralloc *sa, resolve_tree_t *tres, resolve_tree
str = fmt ;
break ;
case E_RESOLVE_TREE_SUPERVISED:
fmt[uint32_fmt(fmt,tres->supervised)] = 0 ;
str = fmt ;
break ;
case E_RESOLVE_TREE_DISEN:
fmt[uint32_fmt(fmt,tres->disen)] = 0 ;
str = fmt ;
......
......@@ -36,6 +36,7 @@ resolve_field_table_t resolve_tree_field_table[] = {
[E_RESOLVE_TREE_NGROUPS] = { .field = "ngroups" },
[E_RESOLVE_TREE_NCONTENTS] = { .field = "ncontents" },
[E_RESOLVE_TREE_INIT] = { .field = "init" },
[E_RESOLVE_TREE_SUPERVISED] = { .field = "supervised" },
[E_RESOLVE_TREE_DISEN] = { .field = "disen" },
[E_RESOLVE_TREE_ENDOFKEY] = { .field = 0 }
} ;
......@@ -117,6 +118,13 @@ int tree_resolve_modify_field(resolve_tree_t *tres, uint8_t field, char const *d
tres->init = ifield ;
break ;
case E_RESOLVE_TREE_SUPERVISED:
if (!data)
data = "0" ;
if (!uint0_scan(data, &ifield)) goto err ;
tres->supervised = ifield ;
break ;
case E_RESOLVE_TREE_DISEN:
if (!data)
data = "0" ;
......
......@@ -83,6 +83,10 @@ int tree_resolve_read_cdb(cdb *c, resolve_tree_t *tres)
x = resolve_find_cdb(&tmp,c,"init") ;
tres->init = x ;
/* supervised */
x = resolve_find_cdb(&tmp,c,"supervised") ;
tres->supervised = x ;
/* disen */
x = resolve_find_cdb(&tmp,c,"disen") ;
tres->disen = x ;
......
......@@ -61,6 +61,9 @@ int tree_resolve_write_cdb(cdbmaker *c, resolve_tree_t *tres)
/* init */
!resolve_add_cdb_uint(c,"init",tres->init) ||
/* supervised */
!resolve_add_cdb_uint(c,"supervised",tres->supervised) ||
/* disen */
!resolve_add_cdb_uint(c,"disen",tres->disen)) return 0 ;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment