diff --git a/src/66/66-inservice.c b/src/66/66-inservice.c index 89550ebcf201f6d0220c850caadbed4d052fc20a..7e56c6ee9a0572a634a416dcfd5db7ede863148a 100644 --- a/src/66/66-inservice.c +++ b/src/66/66-inservice.c @@ -340,32 +340,12 @@ static void info_display_live(char const *field,resolve_service_t *res) if (NOFIELD) info_display_field_name(field) ; info_display_string(res->sa.s + res->runat) ; } - - -/* -int graph_service_compute_deps(stralloc *deps, char const *str) -{ - stralloc tmp = STRALLOC_ZERO ; - size_t pos = 0 ; - - if (!sastr_clean_string(&tmp,str)) - log_warnu_return(LOG_EXIT_ZERO,"rebuild dependencies list") ; - - FOREACH_SASTR(&tmp,pos) { - - if (!sastr_add_string(deps, tmp.s + pos)) - return 0 ; - } - - stralloc_free(&tmp) ; - - return 1 ; -} -*/ - - - - +/** + * + * + * bugged function + * + * void ss_graph_matrix_add_classic(graph_t *g, genalloc *gares) { size_t pos = 0, bpos = 0, ccount = 0 ; @@ -388,7 +368,7 @@ void ss_graph_matrix_add_classic(graph_t *g, genalloc *gares) char *str = genalloc_s(resolve_service_t, gares)[cl[pos]].sa.s ; char *sv = str + genalloc_s(resolve_service_t, gares)[cl[pos]].name ; -printf("sv::%s\n",sv) ; + graph_array_reverse(g->sort, g->sort_count) ; for (bpos = 0 ; bpos < g->sort_count ; bpos++) { @@ -420,84 +400,7 @@ printf("sv::%s\n",sv) ; } } - -/** what = 0 -> only classic - * what = 1 -> only atomic - * what = 2 -> both - * @Return 0 on fail - * - * This function append the logger to @gares is case of classic service. */ -int ss_tree_get_sv_resolve(genalloc *gares, char const *dir, uint8_t what) -{ - log_flow() ; - - stralloc sa = STRALLOC_ZERO ; - resolve_service_t res = RESOLVE_SERVICE_ZERO ; - resolve_wrapper_t_ref wres = resolve_set_struct(SERVICE_STRUCT, &res) ; - resolve_service_t reslog = RESOLVE_SERVICE_ZERO ; - resolve_wrapper_t_ref wreslog = resolve_set_struct(SERVICE_STRUCT, &reslog) ; - - int e = 0 ; - size_t dirlen = strlen(dir), pos = 0 ; - - char solve[dirlen + SS_RESOLVE_LEN + 1] ; - - auto_strings(solve, dir, SS_RESOLVE) ; - - char const *exclude[2] = { SS_MASTER + 1, 0 } ; - if (!sastr_dir_get(&sa,solve,exclude,S_IFREG)) - goto err ; - - FOREACH_SASTR(&sa, pos) { - - char *name = sa.s + pos ; - - if (!resolve_check(dir,name)) - goto err ; - - if (!resolve_read(wres,dir,name)) - goto err ; - - if (resolve_search(gares,name, SERVICE_STRUCT) == -1) { - - if ((!what || what == 2) && (res.type == TYPE_CLASSIC)) { - - if (res.logger) { - - if (!resolve_read(wreslog, dir, res.sa.s + res.logger)) - goto err ; - - if (resolve_search(gares,res.sa.s + res.logger, SERVICE_STRUCT) == -1) { - - if (!resolve_append(gares,wreslog)) - goto err ; - } - } - - if (!resolve_append(gares,wres)) - goto err ; - - continue ; - } - - if (what) { - - if (!resolve_append(gares,wres)) - goto err ; - } - } - } - - e = 1 ; - err: - stralloc_free(&sa) ; - resolve_free(wres) ; - resolve_free(wreslog) ; - return e ; -} - - - +*/ static void info_display_requiredby(char const *field, resolve_service_t *res) { @@ -530,7 +433,7 @@ static void info_display_requiredby(char const *field, resolve_service_t *res) if (!info_walk(&graph, res->sa.s + res->name, res->sa.s + res->treename, &info_graph_display_service, 1, REVERSE, &d, padding, STYLE)) log_dieu(LOG_EXIT_SYS,"display the requiredby list") ; - return ; + goto freed ; } else { @@ -548,7 +451,7 @@ static void info_display_requiredby(char const *field, resolve_service_t *res) info_display_list(field,&deps) ; - return ; + goto freed ; } empty: @@ -564,6 +467,8 @@ static void info_display_requiredby(char const *field, resolve_service_t *res) if (!bprintf(buffer_1,"%s%s%s\n",log_color->warning,"None",log_color->off)) log_dieusys(LOG_EXIT_SYS,"write to stdout") ; } + freed: + graph_free_all(&graph) ; } static void info_display_deps(char const *field, resolve_service_t *res) @@ -634,6 +539,7 @@ static void info_display_deps(char const *field, resolve_service_t *res) } freed: + graph_free_all(&graph) ; stralloc_free(&deps) ; } diff --git a/src/66/66-intree.c b/src/66/66-intree.c index 37983851d85316ceec00bda8b83d2fac5e20007b..a9f843865ed5fdff72531b03a7522d03189ffc9c 100644 --- a/src/66/66-intree.c +++ b/src/66/66-intree.c @@ -222,33 +222,6 @@ static void info_display_order(char const *field,char const *treename) stralloc_free(&tmp) ; } -static void info_get_graph_src(ss_resolve_graph_t *graph,char const *src,unsigned int reverse) -{ - size_t srclen = strlen(src), pos ; - - stralloc sa = STRALLOC_ZERO ; - genalloc gares = GENALLOC_ZERO ; - char const *exclude[2] = { SS_MASTER + 1, 0 } ; - - char solve[srclen + SS_RESOLVE_LEN + 1] ; - memcpy(solve,src,srclen) ; - memcpy(solve + srclen, SS_RESOLVE,SS_RESOLVE_LEN) ; - solve[srclen + SS_RESOLVE_LEN] = 0 ; - - if (!sastr_dir_get(&sa,solve,exclude,S_IFREG)) - log_dieusys(LOG_EXIT_SYS,"get source service file at: ",solve) ; - - if (!service_resolve_sort_bytype(&gares,&sa,src)) - log_dieu(LOG_EXIT_SYS,"sort list by type") ; - - for (pos = 0 ; pos < genalloc_len(resolve_service_t,&gares) ; pos++) - if (!ss_resolve_graph_build(graph,&genalloc_s(resolve_service_t,&gares)[pos],src,reverse)) - log_dieu(LOG_EXIT_SYS,"build the graph from: ",src) ; - - resolve_deep_free(SERVICE_STRUCT, &gares) ; - stralloc_free(&sa) ; -} - static void info_display_allow(char const *field, char const *treename) { if (NOFIELD) info_display_field_name(field) ; @@ -321,7 +294,7 @@ static void info_display_symlink(char const *field, char const *treename) static void info_display_contents(char const *field, char const *treename) { - int r ; + size_t padding = 1, treenamelen = strlen(treename) ; graph_t graph = GRAPH_ZERO ; stralloc sa = STRALLOC_ZERO ; @@ -336,7 +309,8 @@ static void info_display_contents(char const *field, char const *treename) if (!graph_service_build_bytree(&graph, tmp, 2)) log_dieu(LOG_EXIT_SYS,"build the graph dependencies") ; - graph_matrix_sort_tosa(&sa, &graph) ; + if (!graph_matrix_sort_tosa(&sa, &graph)) + log_dieu(LOG_EXIT_SYS, "get the dependencies list") ; if (!sa.len) goto empty ; @@ -354,18 +328,11 @@ static void info_display_contents(char const *field, char const *treename) } 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 (!sastr_reverse(&deps)) + if (!sastr_reverse(&sa)) log_dieu(LOG_EXIT_SYS,"reverse the dependencies list") ; - info_display_list(field,&deps) ; + info_display_list(field,&sa) ; goto freed ; } @@ -385,10 +352,8 @@ static void info_display_contents(char const *field, char const *treename) } freed: - stralloc_free(&deps) ; - - - + graph_free_all(&graph) ; + stralloc_free(&sa) ; } static void info_display_all(char const *treename,int *what)