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

only display service in function of the treename

parent 24a9274c
No related branches found
No related tags found
No related merge requests found
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
#define INFO_FIELD_MAXLEN 30 #define INFO_FIELD_MAXLEN 30
#define INFO_NKEY 150 #define INFO_NKEY 150
typedef int info_graph_func(char const *name, char const *obj) ; typedef int info_graph_func(char const *name) ;
typedef info_graph_func *info_graph_func_t_ref ; typedef info_graph_func *info_graph_func_t_ref ;
typedef struct depth_s depth_t ; typedef struct depth_s depth_t ;
...@@ -81,8 +81,8 @@ extern void info_display_nline(char const *field,char const *str) ; ...@@ -81,8 +81,8 @@ extern void info_display_nline(char const *field,char const *str) ;
extern depth_t info_graph_init(void) ; extern depth_t info_graph_init(void) ;
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_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(char const *name, 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_service(char const *name) ;
extern int info_graph_display_tree(char const *name, char const *obj) ; extern int info_graph_display_tree(char const *name) ;
#endif #endif
...@@ -253,7 +253,7 @@ static void info_display_status(char const *field,resolve_service_t *res) ...@@ -253,7 +253,7 @@ static void info_display_status(char const *field,resolve_service_t *res)
disen = service_is(&ste, STATE_FLAGS_ISENABLED) ; disen = service_is(&ste, STATE_FLAGS_ISENABLED) ;
if (!bprintf(buffer_1,"%s%s%s%s", disen ? log_color->valid : log_color->error, disen ? "enabled" : "disabled", log_color->off, ", ")) if (!bprintf(buffer_1,"%s%s%s%s", disen ? log_color->valid : log_color->warning, disen ? "enabled" : "disabled", log_color->off, ", "))
log_dieusys(LOG_EXIT_SYS,"write to stdout") ; log_dieusys(LOG_EXIT_SYS,"write to stdout") ;
if (buffer_putsflush(buffer_1,"") == -1) if (buffer_putsflush(buffer_1,"") == -1)
...@@ -317,12 +317,12 @@ static void info_display_requiredby(char const *field, resolve_service_t *res) ...@@ -317,12 +317,12 @@ static void info_display_requiredby(char const *field, resolve_service_t *res)
if (GRAPH) { if (GRAPH) {
if (!bprintf(buffer_1,"%s\n","/")) if (!bprintf(buffer_1,"%s\n","\\"))
log_dieusys(LOG_EXIT_SYS,"write to stdout") ; log_dieusys(LOG_EXIT_SYS,"write to stdout") ;
depth_t d = info_graph_init() ; depth_t d = info_graph_init() ;
if (!info_walk(&graph, res->sa.s + res->name, res->sa.s + res->treename, &info_graph_display_service, 1, REVERSE, &d, padding, S_STYLE)) if (!info_walk(&graph, res->sa.s + res->name, 0, &info_graph_display_service, 1, REVERSE, &d, padding, S_STYLE))
log_dieu(LOG_EXIT_SYS,"display the requiredby list") ; log_dieu(LOG_EXIT_SYS,"display the requiredby list") ;
goto freed ; goto freed ;
...@@ -349,7 +349,7 @@ static void info_display_requiredby(char const *field, resolve_service_t *res) ...@@ -349,7 +349,7 @@ static void info_display_requiredby(char const *field, resolve_service_t *res)
empty: empty:
if (GRAPH) if (GRAPH)
{ {
if (!bprintf(buffer_1,"%s\n","/")) if (!bprintf(buffer_1,"%s\n","\\"))
log_dieusys(LOG_EXIT_SYS,"write to stdout") ; log_dieusys(LOG_EXIT_SYS,"write to stdout") ;
if (!bprintf(buffer_1,"%*s%s%s%s%s\n",padding, "", S_STYLE->last, log_color->warning,"None",log_color->off)) if (!bprintf(buffer_1,"%*s%s%s%s%s\n",padding, "", S_STYLE->last, log_color->warning,"None",log_color->off))
log_dieusys(LOG_EXIT_SYS,"write to stdout") ; log_dieusys(LOG_EXIT_SYS,"write to stdout") ;
...@@ -394,12 +394,12 @@ static void info_display_deps(char const *field, resolve_service_t *res) ...@@ -394,12 +394,12 @@ static void info_display_deps(char const *field, resolve_service_t *res)
if (GRAPH) if (GRAPH)
{ {
if (!bprintf(buffer_1,"%s\n","/")) if (!bprintf(buffer_1,"%s\n","\\"))
log_dieusys(LOG_EXIT_SYS,"write to stdout") ; log_dieusys(LOG_EXIT_SYS,"write to stdout") ;
depth_t d = info_graph_init() ; depth_t d = info_graph_init() ;
if (!info_walk(&graph, res->sa.s + res->name, res->sa.s + res->treename, &info_graph_display_service, 0, REVERSE, &d, padding, S_STYLE)) if (!info_walk(&graph, res->sa.s + res->name, 0, &info_graph_display_service, 0, REVERSE, &d, padding, S_STYLE))
log_dieu(LOG_EXIT_SYS,"display the dependencies list") ; log_dieu(LOG_EXIT_SYS,"display the dependencies list") ;
goto freed ; goto freed ;
...@@ -424,7 +424,7 @@ static void info_display_deps(char const *field, resolve_service_t *res) ...@@ -424,7 +424,7 @@ static void info_display_deps(char const *field, resolve_service_t *res)
empty: empty:
if (GRAPH) if (GRAPH)
{ {
if (!bprintf(buffer_1,"%s\n","/")) if (!bprintf(buffer_1,"%s\n","\\"))
log_dieusys(LOG_EXIT_SYS,"write to stdout") ; log_dieusys(LOG_EXIT_SYS,"write to stdout") ;
if (!bprintf(buffer_1,"%*s%s%s%s%s\n",padding, "", S_STYLE->last, log_color->warning,"None",log_color->off)) if (!bprintf(buffer_1,"%*s%s%s%s%s\n",padding, "", S_STYLE->last, log_color->warning,"None",log_color->off))
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
#include <66/info.h> #include <66/info.h>
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) int info_graph_display(char const *name, info_graph_func *func, depth_t *depth, int last, int padding, info_graph_style *style)
{ {
log_flow() ; log_flow() ;
...@@ -46,7 +46,7 @@ int info_graph_display(char const *name, char const *obj, info_graph_func *func, ...@@ -46,7 +46,7 @@ int info_graph_display(char const *name, char const *obj, info_graph_func *func,
style->indent * (depth->level - level), "", \ style->indent * (depth->level - level), "", \
tip)) return 0 ; tip)) return 0 ;
int r = (*func)(name, obj) ; int r = (*func)(name) ;
if (!r) return 0 ; if (!r) return 0 ;
if (buffer_putsflush(buffer_1,"\n") < 0) if (buffer_putsflush(buffer_1,"\n") < 0)
return 0 ; return 0 ;
......
...@@ -89,19 +89,21 @@ int info_graph_display_service(char const *name, char const *obj) ...@@ -89,19 +89,21 @@ int info_graph_display_service(char const *name, char const *obj)
dis: dis:
if (!bprintf(buffer_1,"(%s%s%s,%s%s%s,%s) %s", \ if (!bprintf(buffer_1," %s (%s%s%s,%s%s%s,%s%s%s,%s:%s)", \
name, \
pid_color > 1 ? log_color->valid : pid_color ? log_color->error : log_color->warning, \ pid_color > 1 ? log_color->valid : pid_color ? log_color->error : log_color->warning, \
ppid, \ ppid, \
log_color->off, \ log_color->off, \
service_is(&sta, STATE_FLAGS_ISENABLED) ? log_color->off : log_color->error, \ service_is(&sta, STATE_FLAGS_ISENABLED) ? log_color->off : log_color->warning, \
service_is(&sta, STATE_FLAGS_ISENABLED) ? "Enabled" : "Disabled", \ service_is(&sta, STATE_FLAGS_ISENABLED) ? "Enabled" : "Disabled", \
log_color->off, \ log_color->off, \
get_key_by_enum(ENUM_TYPE,res.type), \ log_color->blue, get_key_by_enum(ENUM_TYPE,res.type), log_color->off, \
name)) "tree", res.sa.s + res.treename ))
goto freed ; goto freed ;
err = 1 ; err = 1 ;
......
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
#include <66/constants.h> #include <66/constants.h>
#include <66/info.h> #include <66/info.h>
int info_graph_display_tree(char const *name, char const *obj) int info_graph_display_tree(char const *name)
{ {
log_flow() ; log_flow() ;
...@@ -67,21 +67,31 @@ int info_graph_display_tree(char const *name, char const *obj) ...@@ -67,21 +67,31 @@ int info_graph_display_tree(char const *name, char const *obj)
if (init < 0) if (init < 0)
goto freed ; goto freed ;
int up = tres.supervised ;
if (up < 0)
goto freed ;
int enabled = tree_isenabled(base, name) ; int enabled = tree_isenabled(base, name) ;
if (enabled < 0) if (enabled < 0)
goto freed ; goto freed ;
if (!bprintf(buffer_1,"(%s%s%s,%s%s%s) %s", \ if (!bprintf(buffer_1," %s (%s%s%s,%s%s%s,%s%s%s)", \
name, \
init ? log_color->valid : log_color->warning, \ init ? log_color->valid : log_color->warning, \
init ? "Initialized" : "Unitialized", \ init ? "Initialized" : "Unitialized", \
log_color->off, \ log_color->off, \
enabled ? log_color->valid : log_color->error, \ up ? log_color->valid : log_color->error, \
enabled ? "Enabled" : "Disabled", \ up ? "Up" : "Down", \
log_color->off, \ log_color->off, \
name))
enabled ? log_color->valid : log_color->warning, \
enabled ? "Enabled" : "Disabled", \
log_color->off))
goto freed ; goto freed ;
err = 1 ; err = 1 ;
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
#include <66/info.h> #include <66/info.h>
#include <66/graph.h> #include <66/graph.h>
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) int info_walk(graph_t *g, char const *name, char const *treename, info_graph_func *func, uint8_t requiredby, uint8_t reverse, depth_t *depth, int padding, info_graph_style *style)
{ {
log_flow() ; log_flow() ;
...@@ -40,7 +40,7 @@ int info_walk(graph_t *g, char const *name, char const *obj, info_graph_func *fu ...@@ -40,7 +40,7 @@ int info_walk(graph_t *g, char const *name, char const *obj, info_graph_func *fu
stralloc_free(&sa) ; stralloc_free(&sa) ;
return e ; return e ;
} }
count = sastr_len(&sa) ; count = sastr_nelement(&sa) ;
} else { } else {
...@@ -70,35 +70,42 @@ int info_walk(graph_t *g, char const *name, char const *obj, info_graph_func *fu ...@@ -70,35 +70,42 @@ int info_walk(graph_t *g, char const *name, char const *obj, info_graph_func *fu
int last = idx + 1 < count ? 0 : 1 ; int last = idx + 1 < count ? 0 : 1 ;
char *name = vertex + pos ; char *name = vertex + pos ;
if (!info_graph_display(name, obj, func, depth, last, padding, style)) if (depth->level == 1 && treename) {
char atree[SS_MAX_TREENAME + 1] ;
service_is_g(atree, name, 0) ;
if (strcmp(treename, atree))
continue ;
}
if (!info_graph_display(name, func, depth, last, padding, style))
goto err ; goto err ;
if (graph_matrix_get_edge_g_sorted_sa(&sa, g, name, requiredby, 0) == -1) if (graph_matrix_get_edge_g_sorted_sa(&sa, g, name, requiredby, 0) == -1)
goto err ; goto err ;
if (sa.len) if (sa.len) {
{
depth_t d = depth_t d = {
{
depth, depth,
NULL, NULL,
depth->level + 1 depth->level + 1
} ; } ;
depth->next = &d; depth->next = &d;
if(last) if(last) {
{
if(depth->prev) if(depth->prev) {
{
depth->prev->next = &d; depth->prev->next = &d;
d.prev = depth->prev; d.prev = depth->prev;
depth = &d; depth = &d;
} }
else else
d.prev = NULL; d.prev = NULL;
} }
if (!info_walk(g, name, obj, func, requiredby, reverse, &d, padding, style)) if (!info_walk(g, name, treename, func, requiredby, reverse, &d, padding, style))
goto err ; goto err ;
depth->next = NULL ; depth->next = NULL ;
} }
......
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