diff --git a/src/include/66/info.h b/src/include/66/info.h index e00361daa1f3e7eb05cb9d2a800d64c05bfe96a6..5475b5a6d00c7f0c97c5c172d2d76a6937a1cf62 100644 --- a/src/include/66/info.h +++ b/src/include/66/info.h @@ -28,7 +28,7 @@ #define INFO_FIELD_MAXLEN 30 #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 struct depth_s depth_t ; @@ -81,8 +81,8 @@ extern void info_display_nline(char const *field,char const *str) ; 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_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) ; +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) ; +extern int info_graph_display_tree(char const *name) ; #endif diff --git a/src/lib66/exec/ssexec_inservice.c b/src/lib66/exec/ssexec_inservice.c index 09d868f5a5fe9017eb3dcbd5576db7631f459d5b..1388d05e783f78d7540047bfde9ae250be23a8fb 100644 --- a/src/lib66/exec/ssexec_inservice.c +++ b/src/lib66/exec/ssexec_inservice.c @@ -253,7 +253,7 @@ static void info_display_status(char const *field,resolve_service_t *res) 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") ; if (buffer_putsflush(buffer_1,"") == -1) @@ -317,12 +317,12 @@ static void info_display_requiredby(char const *field, resolve_service_t *res) if (GRAPH) { - if (!bprintf(buffer_1,"%s\n","/")) + if (!bprintf(buffer_1,"%s\n","\\")) log_dieusys(LOG_EXIT_SYS,"write to stdout") ; 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") ; goto freed ; @@ -349,7 +349,7 @@ static void info_display_requiredby(char const *field, resolve_service_t *res) empty: if (GRAPH) { - if (!bprintf(buffer_1,"%s\n","/")) + if (!bprintf(buffer_1,"%s\n","\\")) 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)) log_dieusys(LOG_EXIT_SYS,"write to stdout") ; @@ -394,12 +394,12 @@ static void info_display_deps(char const *field, resolve_service_t *res) if (GRAPH) { - if (!bprintf(buffer_1,"%s\n","/")) + if (!bprintf(buffer_1,"%s\n","\\")) log_dieusys(LOG_EXIT_SYS,"write to stdout") ; 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") ; goto freed ; @@ -424,7 +424,7 @@ static void info_display_deps(char const *field, resolve_service_t *res) empty: if (GRAPH) { - if (!bprintf(buffer_1,"%s\n","/")) + if (!bprintf(buffer_1,"%s\n","\\")) 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)) diff --git a/src/lib66/info/info_graph_display.c b/src/lib66/info/info_graph_display.c index c7ff2ad0766ae08d08a2679970a7776e405dec0e..10bff9e9a05d6927dcc888e48fef022e77c0077a 100644 --- a/src/lib66/info/info_graph_display.c +++ b/src/lib66/info/info_graph_display.c @@ -19,7 +19,7 @@ #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() ; @@ -46,7 +46,7 @@ int info_graph_display(char const *name, char const *obj, info_graph_func *func, style->indent * (depth->level - level), "", \ tip)) return 0 ; - int r = (*func)(name, obj) ; + int r = (*func)(name) ; if (!r) return 0 ; if (buffer_putsflush(buffer_1,"\n") < 0) return 0 ; diff --git a/src/lib66/info/info_graph_display_service.c b/src/lib66/info/info_graph_display_service.c index 4f1cc5d583bf503a1c92e579aa8185cdc6de4662..94788903350c7528936864228a0b5b415755d2ff 100644 --- a/src/lib66/info/info_graph_display_service.c +++ b/src/lib66/info/info_graph_display_service.c @@ -89,19 +89,21 @@ int info_graph_display_service(char const *name, char const *obj) 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, \ ppid, \ 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", \ 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 ; err = 1 ; diff --git a/src/lib66/info/info_graph_display_tree.c b/src/lib66/info/info_graph_display_tree.c index f9233130132a0ce3e4625845d351e74258d195c4..5ecbb90dfd07450d41bb2d63ede1e39d12369849 100644 --- a/src/lib66/info/info_graph_display_tree.c +++ b/src/lib66/info/info_graph_display_tree.c @@ -28,7 +28,7 @@ #include <66/constants.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() ; @@ -67,21 +67,31 @@ int info_graph_display_tree(char const *name, char const *obj) if (init < 0) goto freed ; + int up = tres.supervised ; + if (up < 0) + goto freed ; + int enabled = tree_isenabled(base, name) ; if (enabled < 0) 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 ? "Initialized" : "Unitialized", \ log_color->off, \ - enabled ? log_color->valid : log_color->error, \ - enabled ? "Enabled" : "Disabled", \ + up ? log_color->valid : log_color->error, \ + up ? "Up" : "Down", \ log_color->off, \ - name)) + + enabled ? log_color->valid : log_color->warning, \ + enabled ? "Enabled" : "Disabled", \ + log_color->off)) + goto freed ; err = 1 ; diff --git a/src/lib66/info/info_walk.c b/src/lib66/info/info_walk.c index b5fd1a8e16ffce1dd2467e2e6e0ced44b01b008f..bc6d72b9827a1a82e89d1f4aa7945712949acf4a 100644 --- a/src/lib66/info/info_walk.c +++ b/src/lib66/info/info_walk.c @@ -23,7 +23,7 @@ #include <66/info.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() ; @@ -40,7 +40,7 @@ int info_walk(graph_t *g, char const *name, char const *obj, info_graph_func *fu stralloc_free(&sa) ; return e ; } - count = sastr_len(&sa) ; + count = sastr_nelement(&sa) ; } else { @@ -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 ; 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 ; if (graph_matrix_get_edge_g_sorted_sa(&sa, g, name, requiredby, 0) == -1) goto err ; - if (sa.len) - { - depth_t d = - { + if (sa.len) { + + depth_t d = { depth, NULL, depth->level + 1 } ; depth->next = &d; - if(last) - { - if(depth->prev) - { + if(last) { + + if(depth->prev) { + depth->prev->next = &d; d.prev = depth->prev; depth = &d; - } else 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 ; depth->next = NULL ; }