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

pass through new graph function

parent 2e129c0a
No related branches found
No related tags found
No related merge requests found
...@@ -41,6 +41,7 @@ ...@@ -41,6 +41,7 @@
#include <66/resolve.h> #include <66/resolve.h>
#include <66/service.h> #include <66/service.h>
#include <66/backup.h> #include <66/backup.h>
#include <66/graph.h>
static unsigned int REVERSE = 0 ; static unsigned int REVERSE = 0 ;
static unsigned int NOFIELD = 1 ; static unsigned int NOFIELD = 1 ;
...@@ -322,54 +323,50 @@ static void info_display_contents(char const *field, char const *treename) ...@@ -322,54 +323,50 @@ static void info_display_contents(char const *field, char const *treename)
{ {
int r ; int r ;
size_t padding = 1, treenamelen = strlen(treename) ; size_t padding = 1, treenamelen = strlen(treename) ;
resolve_service_t res = RESOLVE_SERVICE_ZERO ; graph_t graph = GRAPH_ZERO ;
resolve_wrapper_t_ref wres = resolve_set_struct(SERVICE_STRUCT,&res) ; stralloc sa = STRALLOC_ZERO ;
ss_resolve_graph_t graph = RESOLVE_GRAPH_ZERO ;
stralloc salist = STRALLOC_ZERO ;
char tmp[src.len + treenamelen + SS_SVDIRS_LEN + 1] ; char tmp[src.len + treenamelen + SS_SVDIRS_LEN + 1] ;
memcpy(tmp,src.s,src.len) ;
memcpy(tmp + src.len,treename,treenamelen) ;
memcpy(tmp + src.len + treenamelen,SS_SVDIRS,SS_SVDIRS_LEN) ;
tmp[src.len + treenamelen + SS_SVDIRS_LEN] = 0 ;
info_get_graph_src(&graph,tmp,0) ;
if (NOFIELD) padding = info_display_field_name(field) ; if (NOFIELD) padding = info_display_field_name(field) ;
else { field = 0 ; padding = 0 ; } else { field = 0 ; padding = 0 ; }
if (!genalloc_len(resolve_service_t,&graph.name)) goto empty ; auto_strings(tmp, src.s, treename) ;
r = ss_resolve_graph_publish(&graph,0) ; if (!graph_service_build_bytree(&graph, tmp, 2))
if (r < 0) log_die(LOG_EXIT_USER,"cyclic graph detected at tree: ", treename) ; log_dieu(LOG_EXIT_SYS,"build the graph dependencies") ;
else if (!r) log_dieusys(LOG_EXIT_SYS,"publish service graph of tree: ",treename) ;
for (size_t i = 0 ; i < genalloc_len(resolve_service_t,&graph.sorted) ; i++) graph_matrix_sort_tosa(&sa, &graph) ;
{
char *string = genalloc_s(resolve_service_t,&graph.sorted)[i].sa.s ; if (!sa.len) goto empty ;
char *name = string + genalloc_s(resolve_service_t,&graph.sorted)[i].name ;
if (!stralloc_catb(&salist,name,strlen(name)+1)) log_die_nomem("stralloc") ;
}
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") ;
size_t el = sastr_len(&salist) ;
if (!sastr_rebuild_in_oneline(&salist)) log_dieu(LOG_EXIT_SYS,"rebuild dependencies list") ; depth_t d = info_graph_init() ;
resolve_init(wres) ;
res.ndeps = el ; if (!info_walk(&graph, 0, treename, &info_graph_display_service, 0, REVERSE, &d, padding, STYLE))
res.deps = resolve_add_string(wres,salist.s) ; log_dieu(LOG_EXIT_SYS,"display the graph dependencies") ;
if (!info_graph_init(&res,tmp,REVERSE, padding, STYLE))
log_die(LOG_EXIT_SYS,"display graph of: ",treename) ;
goto freed ; goto freed ;
} }
else else
{ {
r = graph_matrix_sort_tosa(&deps,&graph) ;
if (!r)
log_dieu(LOG_EXIT_SYS, "get the dependencies list") ;
if (!deps.len)
goto empty ;
if (REVERSE) if (REVERSE)
if (!sastr_reverse(&salist)) if (!sastr_reverse(&deps))
log_dieusys(LOG_EXIT_SYS,"reverse dependencies list") ; log_dieu(LOG_EXIT_SYS,"reverse the dependencies list") ;
info_display_list(field,&salist) ;
info_display_list(field,&deps) ;
goto freed ; goto freed ;
} }
empty: empty:
...@@ -377,20 +374,21 @@ static void info_display_contents(char const *field, char const *treename) ...@@ -377,20 +374,21 @@ static void info_display_contents(char const *field, char const *treename)
{ {
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",padding,"",STYLE->last,"None"))
if (!bprintf(buffer_1,"%*s%s%s%s%s\n",padding, "", 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") ;
} }
else else
{ {
if (!bprintf(buffer_1,"%s","None")) if (!bprintf(buffer_1,"%s%s%s\n",log_color->warning,"None",log_color->off))
log_dieusys(LOG_EXIT_SYS,"write to stdout") ; log_dieusys(LOG_EXIT_SYS,"write to stdout") ;
} }
if (buffer_putsflush(buffer_1,"\n") == -1)
log_dieusys(LOG_EXIT_SYS,"write to stdout") ;
freed: freed:
resolve_free(wres) ; stralloc_free(&deps) ;
ss_resolve_graph_free(&graph) ;
stralloc_free(&salist) ;
} }
static void info_display_all(char const *treename,int *what) static void info_display_all(char const *treename,int *what)
......
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