From 8e4728af3a2e05d605bc93b3eecbc906a233b4e6 Mon Sep 17 00:00:00 2001 From: obarun <eric@obarun.org> Date: Fri, 17 Feb 2023 21:01:49 +1100 Subject: [PATCH] remove unused functions --- src/lib66/graph/deps-lib/deps | 3 - src/lib66/graph/graph_build_service_bytree.c | 156 ------------------ .../graph_build_service_bytree_from_src.c | 112 ------------- .../graph/graph_build_service_from_list.c | 95 ----------- .../service/service_resolve_from_cmdline.c | 82 --------- .../service/service_resolve_sort_bytype.c | 99 ----------- 6 files changed, 547 deletions(-) delete mode 100644 src/lib66/graph/graph_build_service_bytree.c delete mode 100644 src/lib66/graph/graph_build_service_bytree_from_src.c delete mode 100644 src/lib66/graph/graph_build_service_from_list.c delete mode 100644 src/lib66/service/service_resolve_from_cmdline.c delete mode 100644 src/lib66/service/service_resolve_sort_bytype.c diff --git a/src/lib66/graph/deps-lib/deps b/src/lib66/graph/deps-lib/deps index 56b8909b..021c9492 100644 --- a/src/lib66/graph/deps-lib/deps +++ b/src/lib66/graph/deps-lib/deps @@ -1,7 +1,4 @@ graph_build_service.o -graph_build_service_bytree.o -graph_build_service_bytree_from_src.o -graph_build_service_from_list.o graph_build_tree.o graph_compute_dependencies.o graph_remove_deps.o diff --git a/src/lib66/graph/graph_build_service_bytree.c b/src/lib66/graph/graph_build_service_bytree.c deleted file mode 100644 index 35bbb4e3..00000000 --- a/src/lib66/graph/graph_build_service_bytree.c +++ /dev/null @@ -1,156 +0,0 @@ -/* - * graph_build_service_bytree.c - * - * Copyright (c) 2018-2022 Eric Vidal <eric@obarun.org> - * - * All rights reserved. - * - * This file is part of Obarun. It is subject to the license terms in - * the LICENSE file found in the top-level directory of this - * distribution. - * This file may not be copied, modified, propagated, or distributed - * except according to the terms contained in the LICENSE file./ - */ - -#include <stdint.h> -#include <string.h> - -#include <oblibs/log.h> -#include <oblibs/graph.h> -#include <oblibs/string.h> -#include <oblibs/sastr.h> - -#include <skalibs/stralloc.h> - -#include <66/resolve.h> -#include <66/constants.h> -#include <66/service.h> -#include <66/enum.h> -#include <66/graph.h> -#include <66/state.h> - -/* - * - * Need to be review entirely - * - * */ -/** @tree: absolute path of the tree including SS_SVDIRS - * what = 0 -> classic - * what = 1 -> atomic and bundle - * what > 1 -> module */ -int graph_build_service_bytree(graph_t *g, char const *tree, uint8_t what, uint8_t is_supervised) -{ - log_flow() ; - - int e = 0, pos = 0 ; - stralloc sa = STRALLOC_ZERO ; - resolve_service_t res = RESOLVE_SERVICE_ZERO ; - resolve_wrapper_t_ref wres = resolve_set_struct(DATA_SERVICE, &res) ; - - resolve_service_master_t mres = RESOLVE_SERVICE_MASTER_ZERO ; - resolve_wrapper_t_ref mwres = resolve_set_struct(DATA_SERVICE_MASTER, &mres) ; - - if (!resolve_read(mwres, tree, SS_MASTER + 1)) { - log_warnu("read resolve Master service file of tree: ", tree) ; - goto err ; - } - /** - * - * - * a revoir ici les checks en fonction des appels qui sont fait - * notamment par 66-inservice, 66-intree - * - * - * - * */ - if (what == 2) - if (mres.ncontents) - if (!auto_stra(&sa, mres.sa.s + mres.contents)) - goto err ; - - if (!what) - if (mres.nclassic) - if (!auto_stra(&sa, mres.sa.s + mres.classic)) - goto err ; - - if (what > 1) - if (mres.nmodule) - if (!auto_stra(&sa, mres.sa.s + mres.module)) - goto err ; - - if (what == 1) { - - if (mres.nbundle) - if (!auto_stra(&sa, mres.sa.s + mres.bundle)) - goto err ; - - if (mres.noneshot) - if (!auto_stra(&sa, mres.sa.s + mres.oneshot)) - goto err ; - } - - if (!sastr_clean_string_flush_sa(&sa, sa.s)) - goto err ; - - FOREACH_SASTR(&sa, pos) { - - char *service = sa.s + pos ; - - if (!resolve_read(wres, tree, service)) - goto err ; - - if (is_supervised) { - - char atree[strlen(res.sa.s + res.treename) + 1] ; - - if (!service_is_g(atree, service, STATE_FLAGS_ISSUPERVISED)) - continue ; - } - - char *str = res.sa.s ; - - if (!graph_vertex_add(g, service)) { - log_warnu("add vertex: ", service) ; - goto err ; - } - - if (res.dependencies.ndepends) { - - if (!graph_compute_dependencies(g, service,str + res.dependencies.depends, 0)) { - log_warnu("add dependencies of service: ",service) ; - goto err ; - } - } - - if (res.dependencies.nrequiredby) { - - if (!graph_compute_dependencies(g, service, str + res.dependencies.requiredby, 1)) { - log_warnu("add requiredby of service: ", service) ; - goto err ; - } - } - } - - if (!graph_matrix_build(g)) { - log_warnu("build the graph") ; - goto err ; - } - - if (!graph_matrix_analyze_cycle(g)) { - log_warn("found cycle") ; - goto err ; - } - - if (!graph_matrix_sort(g)) { - log_warnu("sort the graph") ; - goto err ; - } - - e = 1 ; - - err: - resolve_free(wres) ; - resolve_free(mwres) ; - stralloc_free(&sa) ; - return e ; -} diff --git a/src/lib66/graph/graph_build_service_bytree_from_src.c b/src/lib66/graph/graph_build_service_bytree_from_src.c deleted file mode 100644 index 2a9972f8..00000000 --- a/src/lib66/graph/graph_build_service_bytree_from_src.c +++ /dev/null @@ -1,112 +0,0 @@ -/* - * graph_build_service_bytree_from_src.c - * - * Copyright (c) 2018-2021 Eric Vidal <eric@obarun.org> - * - * All rights reserved. - * - * This file is part of Obarun. It is subject to the license terms in - * the LICENSE file found in the top-level directory of this - * distribution. - * This file may not be copied, modified, propagated, or distributed - * except according to the terms contained in the LICENSE file./ - */ - -#include <stdint.h> -#include <string.h> - -#include <oblibs/log.h> -#include <oblibs/string.h> -#include <oblibs/sastr.h> - -#include <66/resolve.h> -#include <66/service.h> -#include <66/constants.h> -#include <66/enum.h> -#include <66/graph.h> - -/** @tsrc: absolute path of the tree including SS_SVDIRS - * what = 0 -> classic - * what = 1 -> atomic and bundle - * what > 1 -> module */ -int graph_build_service_bytree_from_src(graph_t *g, char const *src, uint8_t what) -{ - log_flow() ; - - int e = 0 ; - stralloc sa = STRALLOC_ZERO ; - resolve_service_t res = RESOLVE_SERVICE_ZERO ; - resolve_wrapper_t_ref wres = resolve_set_struct(DATA_SERVICE, &res) ; - - size_t srclen = strlen(src), pos = 0 ; - char solve[srclen + SS_RESOLVE_LEN + 1] ; - - auto_strings(solve, src, SS_RESOLVE) ; - - char const *exclude[2] = { SS_MASTER + 1, 0 } ; - - if (!sastr_dir_get(&sa,solve,exclude,S_IFREG)) - goto err ; - - solve[srclen] = 0 ; - - /** can be needed for 66-inservice and 66-intree. - * TODO: try to avoid it - * */ - if (!service_resolve_sort_bytype(&sa, solve)) - goto err ; - - FOREACH_SASTR(&sa, pos) { - - char *service = sa.s + pos ; - - if (!resolve_read(wres, solve, service)) - goto err ; - - char *str = res.sa.s ; - - if (!graph_vertex_add(g, service)) { - log_warnu("add vertex: ", service) ; - goto err ; - } - - if (res.dependencies.ndepends) { - - if (!graph_compute_dependencies(g, service,str + res.dependencies.depends, 0)) { - log_warnu("add dependencies of service: ",service) ; - goto err ; - } - } - - if (res.dependencies.nrequiredby) { - - if (!graph_compute_dependencies(g, service, str + res.dependencies.requiredby, 1)) { - log_warnu("add requiredby of service: ", service) ; - goto err ; - } - } - } - - if (!graph_matrix_build(g)) { - log_warnu("build the graph") ; - goto err ; - } - - if (!graph_matrix_analyze_cycle(g)) { - log_warn("found cycle") ; - goto err ; - } - - if (!graph_matrix_sort(g)) { - log_warnu("sort the graph") ; - goto err ; - } - - e = 1 ; - - err: - resolve_free(wres) ; - stralloc_free(&sa) ; - return e ; -} - diff --git a/src/lib66/graph/graph_build_service_from_list.c b/src/lib66/graph/graph_build_service_from_list.c deleted file mode 100644 index c9f65bee..00000000 --- a/src/lib66/graph/graph_build_service_from_list.c +++ /dev/null @@ -1,95 +0,0 @@ -/* - * graph_build_service_from_list.c - * - * Copyright (c) 2018-2022 Eric Vidal <eric@obarun.org> - * - * All rights reserved. - * - * This file is part of Obarun. It is subject to the license terms in - * the LICENSE file found in the top-level directory of this - * distribution. - * This file may not be copied, modified, propagated, or distributed - * except according to the terms contained in the LICENSE file./ - */ - -#include <string.h> -#include <stdlib.h> - -#include <oblibs/log.h> -#include <oblibs/string.h> -#include <oblibs/graph.h> - -#include <skalibs/genalloc.h> - -#include <66/config.h> -#include <66/graph.h> -#include <66/service.h> -#include <66/resolve.h> -#include <66/constants.h> -#include <66/state.h> - -int graph_build_service_from_list(char const *const *list, char const *base, graph_t *graph, resolve_service_t *ares, uint8_t requiredby) -{ - log_flow() ; - - - unsigned int areslen = 0, e = 0 ; - char atree[SS_MAX_TREENAME + 1] ; - - for (; *list ; list++) { - - int found = 0 ; - unsigned int pos = 0, ndeps = 0 ; - unsigned int alist[graph->mlen] ; - char const *name = *list ; - - resolve_service_t res = RESOLVE_SERVICE_ZERO ; - resolve_wrapper_t_ref wres = resolve_set_struct(DATA_SERVICE, &res) ; - - graph_array_init_single(alist, graph->mlen) ; - - resolve_service_t cp = RESOLVE_SERVICE_ZERO ; - - if (!resolve_read_g(wres, base, name)) - goto err ; - - if (!service_resolve_copy(&cp, &res)) - goto err ; - - if (service_resolve_array_search(ares, areslen, name) < 0) - ares[areslen++] = cp ; - - ndeps = graph_matrix_get_edge_g_list(alist, graph, name, requiredby, 1) ; - if (ndeps < 0) - goto err ; - - for (; pos < ndeps ; pos++) { - - char *name = graph->data.s + genalloc_s(graph_hash_t, &graph->hash)[alist[pos]].vertex ; - - if (service_resolve_array_search(ares, areslen, name) < 0) { - - resolve_service_t cp = RESOLVE_SERVICE_ZERO ; - - found = service_is_g(atree, name, STATE_FLAGS_ISPARSED) ; - if (found <= 0) - goto err ; - - if (!resolve_read_g(wres, base, name)) - goto err ; - - if (!service_resolve_copy(&cp, &res)) - goto err ; - - ares[areslen++] = cp ; - } - } - resolve_free(wres) ; - } - - e = areslen ; - - err: - - return e ; -} diff --git a/src/lib66/service/service_resolve_from_cmdline.c b/src/lib66/service/service_resolve_from_cmdline.c deleted file mode 100644 index 0e1c6b27..00000000 --- a/src/lib66/service/service_resolve_from_cmdline.c +++ /dev/null @@ -1,82 +0,0 @@ -/* - * resolve_from_cmdline.c - * - * Copyright (c) 2018-2021 Eric Vidal <eric@obarun.org> - * - * All rights reserved. - * - * This file is part of Obarun. It is subject to the license terms in - * the LICENSE file found in the top-level directory of this - * distribution. - * This file may not be copied, modified, propagated, or distributed - * except according to the terms contained in the LICENSE file./ - */ - -#include <stdint.h> - -#include <oblibs/log.h> -#include <oblibs/string.h> -#include <oblibs/graph.h> - -#include <skalibs/genalloc.h> - -#include <66/resolve.h> -#include <66/service.h> -#include <66/graph.h> -#include <66/ssexec.h> -#include <66/constants.h> - -int service_resolve_from_cmdline(resolve_service_t *ares, graph_t *graph, ssexec_t *info, char const *const *argv, uint8_t requiredby) -{ - - resolve_service_t res = RESOLVE_SERVICE_ZERO ; - resolve_wrapper_t_ref wres = 0 ; - unsigned int areslen = 0 ; - - for (; *argv ; argv++) { - - unsigned int pos = 0, *alist = 0, ndeps = 0 ; - char const *name = *argv ; - - wres = resolve_set_struct(DATA_SERVICE, &res) ; - - if (resolve_read_g(wres, info->base.s, name) <= 0) - log_dieusys(LOG_EXIT_SYS,"read resolve file of: ", name) ; - - resolve_service_t cp = RESOLVE_SERVICE_ZERO ; - - if (!service_resolve_copy(&cp, &res)) - log_dieusys(LOG_EXIT_SYS,"copy resolve file of: ", name) ; - - if (service_resolve_array_search(ares, areslen, name) < 0) - ares[areslen++] = cp ; - - ndeps = graph_matrix_get_edge_g_list(alist, graph, name, requiredby, 1) ; - - if (ndeps < 0) - log_dieu(LOG_EXIT_SYS, "get dependencies of service: ", name) ; - - for (; pos < ndeps ; pos++) { - - char *name = graph->data.s + genalloc_s(graph_hash_t, &graph->hash)[alist[pos]].vertex ; - - resolve_service_t dres = RESOLVE_SERVICE_ZERO ; - wres = resolve_set_struct(DATA_SERVICE, &dres) ; - - if (!service_resolve_array_search(ares, areslen, name)) { - - if (resolve_read_g(wres, info->base.s, name) <= 0) - log_dieusys(LOG_EXIT_SYS,"read resolve file of: ",name) ; - - ares[areslen++] = dres ; - } - - resolve_free(wres) ; - } - - resolve_free(wres) ; - } - - - return areslen ; -} diff --git a/src/lib66/service/service_resolve_sort_bytype.c b/src/lib66/service/service_resolve_sort_bytype.c deleted file mode 100644 index 619197e3..00000000 --- a/src/lib66/service/service_resolve_sort_bytype.c +++ /dev/null @@ -1,99 +0,0 @@ -/* - * service_resolve_sort_bytype.c - * - * Copyright (c) 2018-2021 Eric Vidal <eric@obarun.org> - * - * All rights reserved. - * - * This file is part of Obarun. It is subject to the license terms in - * the LICENSE file found in the top-level directory of this - * distribution. - * This file may not be copied, modified, propagated, or distributed - * except according to the terms contained in the LICENSE file./ - */ -#include <string.h> - -#include <oblibs/log.h> -#include <oblibs/sastr.h> - -#include <skalibs/stralloc.h> - -#include <66/resolve.h> -#include <66/enum.h> -#include <66/service.h> -/*** - * - * - * - * may not be used anymore - * - * - * - * - * */ -int service_resolve_sort_bytype(stralloc *list, char const *src) -{ - log_flow() ; - - size_t pos = 0, len = list->len ; - int e = 0 ; - - char tmp[len + 1] ; - - sastr_to_char(tmp, list) ; - - resolve_service_t res = RESOLVE_SERVICE_ZERO ; - - resolve_wrapper_t_ref wres = resolve_set_struct(DATA_SERVICE, &res) ; - - size_t classic_list = 0, module_list = 0 ; - - list->len = 0 ; - - for (; pos < len ; pos += strlen(tmp + pos) + 1) { - - size_t nlen = strlen(tmp + pos) + 1 ; - char *name = tmp + pos ; - - if (!resolve_read(wres, src, name)) - log_warnu_return(LOG_EXIT_ZERO,"read resolve file of: ", src, name) ; - - switch (res.type) { - - case TYPE_CLASSIC: - - if (!stralloc_insertb(list, 0, name, strlen(name) + 1)) - goto err ; - - classic_list += nlen ; - module_list = classic_list ; - - break ; - - case TYPE_MODULE: - - if (!stralloc_insertb(list, classic_list, name, strlen(name) + 1)) - goto err ; - - module_list += nlen ; - - break ; - - case TYPE_BUNDLE: - case TYPE_ONESHOT: - - if (!stralloc_insertb(list, module_list, name, strlen(name) + 1)) - goto err ; - - break ; - - default: log_warn_return(LOG_EXIT_ZERO,"unknown action") ; - } - } - - e = 1 ; - - err: - resolve_free(wres) ; - return e ; -} -- GitLab