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

add info_graph_display_tree() function

parent 49203b60
No related branches found
No related tags found
No related merge requests found
......@@ -80,9 +80,9 @@ extern void info_display_list(char const *field, stralloc *list) ;
extern void info_display_nline(char const *field,char const *str) ;
extern depth_t info_graph_init(void) ;
extern int info_graph_display_service(char const *name, char const *obj) ;
extern int info_graph_display(char const *name, char const *obj, info_graph_func *func, depth_t *depth, int last, int padding, info_graph_style *style) ;
extern int info_walk(graph_t *g, char const *name, char const *obj, info_graph_func *func, uint8_t requiredby, uint8_t reverse, depth_t *depth, int padding, info_graph_style *style) ;
extern int info_graph_display(char const *name, char const *obj, info_graph_func *func, depth_t *depth, int last, int padding, info_graph_style *style) ;
extern int info_graph_display_service(char const *name, char const *obj) ;
extern int info_graph_display_tree(char const *name, char const *obj) ;
#endif
......@@ -33,6 +33,8 @@
#include <66/resolve.h>
#include <66/state.h>
#include <66/utils.h>
#include <66/constants.h>
unsigned int MAXDEPTH = 1 ;
......@@ -224,13 +226,83 @@ depth_t info_graph_init(void)
return d ;
}
int info_graph_display_tree(char const *name, char const *obj)
{
log_flow() ;
int err = 0 ;
stralloc sa = STRALLOC_ZERO ;
resolve_tree_t tres = RESOLVE_TREE_ZERO ;
resolve_wrapper_t_ref wres = resolve_set_struct(DATA_TREE, &tres) ;
uid_t owner = getuid() ;
if (!set_ownersysdir(&sa, owner)) {
log_warnusys("set owner directory") ;
resolve_free(wres) ;
stralloc_free(&sa) ;
return err ;
}
char base[sa.len + 1] ;
auto_strings(base, sa.s) ;
if (tree_isvalid(sa.s, name) <= 0) {
log_warn("invalide tree: ", name) ;
goto freed ;
}
if (!auto_stra(&sa, SS_SYSTEM))
goto freed ;
if (!resolve_check(sa.s, name))
goto freed ;
if (!resolve_read(wres, sa.s, name))
goto freed ;
sa.len = 0 ;
int r = set_livedir(&sa) ;
if (r <= 0)
goto freed ;
int init = tree_isinitialized(sa.s, name, owner) ;
int enabled = tree_isenabled(base, name) ;
if (enabled < 0)
goto freed ;
if (!bprintf(buffer_1,"(%s%s%s,%s%s%s) %s", \
init ? log_color->valid : log_color->warning, \
init ? "Initialized" : "Unitialized", \
log_color->off, \
enabled ? log_color->valid : log_color->error, \
enabled ? "Enabled" : "Disabled", \
log_color->off, \
name))
goto freed ;
err = 1 ;
freed:
resolve_free(wres) ;
stralloc_free(&sa) ;
return err ;
}
int info_graph_display_service(char const *name, char const *obj)
{
log_flow() ;
stralloc tree = STRALLOC_ZERO ;
resolve_service_t res = RESOLVE_SERVICE_ZERO ;
resolve_wrapper_t_ref wres = resolve_set_struct(SERVICE_STRUCT, &res) ;
resolve_wrapper_t_ref wres = resolve_set_struct(DATA_SERVICE, &res) ;
int r = service_intree(&tree, name, obj), err = 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