diff --git a/src/66/66-inresolve.c b/src/66/66-inresolve.c index e607a05e2a1ce51e17b84c806a540574dbf2eaf6..8c4f74c65f56809cb82ffa50961bceccec009491 100644 --- a/src/66/66-inresolve.c +++ b/src/66/66-inresolve.c @@ -86,8 +86,10 @@ int main(int argc, char const *const *argv) { int found = 0 ; uint8_t logger = 0 ; - ss_resolve_t res = RESOLVE_ZERO ; - ss_resolve_t lres = RESOLVE_ZERO ; + resolve_service_t res = RESOLVE_SERVICE_ZERO ; + resolve_wrapper_t_ref wres = resolve_set_struct(SERVICE_STRUCT, &res) ; + resolve_service_t lres = RESOLVE_SERVICE_ZERO ; + resolve_wrapper_t_ref lwres = resolve_set_struct(SERVICE_STRUCT, &lres) ; stralloc satree = STRALLOC_ZERO ; stralloc src = STRALLOC_ZERO ; stralloc tmp = STRALLOC_ZERO ; @@ -152,7 +154,7 @@ int main(int argc, char const *const *argv) if (!argc) log_usage(USAGE) ; svname = *argv ; - found = ss_resolve_svtree(&src,svname,tname) ; + found = service_resolve_svtree(&src,svname,tname) ; if (found == -1) log_dieu(LOG_EXIT_SYS,"resolve tree source of sv: ",svname) ; else if (!found) { log_info("no tree exist yet") ; @@ -163,7 +165,7 @@ int main(int argc, char const *const *argv) } else if (found == 1) log_die(LOG_EXIT_SYS,"unknown service: ",svname) ; - if (!ss_resolve_read(&res,src.s,svname)) log_dieusys(111,"read resolve file") ; + if (!resolve_read(wres,src.s,svname)) log_dieusys(111,"read resolve file") ; info_field_align(buf,fields,field_suffix,MAXOPTS) ; @@ -199,7 +201,7 @@ int main(int argc, char const *const *argv) if (res.logger && logger) { - if (!ss_resolve_read(&lres,src.s,res.sa.s + res.logger)) log_dieusys(111,"read resolve file of: ",res.sa.s + res.logger) ; + if (!resolve_read(lwres,src.s,res.sa.s + res.logger)) log_dieusys(111,"read resolve file of: ",res.sa.s + res.logger) ; if (buffer_putsflush(buffer_1,"\n") == -1) log_dieusys(LOG_EXIT_SYS,"write to stdout") ; @@ -229,8 +231,8 @@ int main(int argc, char const *const *argv) } freed: - ss_resolve_free(&res) ; - ss_resolve_free(&lres) ; + resolve_free(wres) ; + resolve_free(lwres) ; stralloc_free(&satree) ; stralloc_free(&src) ; stralloc_free(&tmp) ; diff --git a/src/66/66-inservice.c b/src/66/66-inservice.c index 334155f3560f5bac3b457718e7c8a8dd418c14be..41bac07e1f615e437c7beac368286c2e31495614 100644 --- a/src/66/66-inservice.c +++ b/src/66/66-inservice.c @@ -56,25 +56,25 @@ static stralloc home = STRALLOC_ZERO ;// /var/lib/66/system or ${HOME}/system static wchar_t const field_suffix[] = L" :" ; static char fields[INFO_NKEY][INFO_FIELD_MAXLEN] = {{ 0 }} ; static void info_display_string(char const *str) ; -static void info_display_name(char const *field, ss_resolve_t *res) ; -static void info_display_intree(char const *field, ss_resolve_t *res) ; -static void info_display_status(char const *field, ss_resolve_t *res) ; -static void info_display_type(char const *field, ss_resolve_t *res) ; -static void info_display_description(char const *field, ss_resolve_t *res) ; -static void info_display_version(char const *field, ss_resolve_t *res) ; -static void info_display_source(char const *field, ss_resolve_t *res) ; -static void info_display_live(char const *field, ss_resolve_t *res) ; -static void info_display_deps(char const *field, ss_resolve_t *res) ; -static void info_display_requiredby(char const *field, ss_resolve_t *res) ; -static void info_display_optsdeps(char const *field, ss_resolve_t *res) ; -static void info_display_extdeps(char const *field, ss_resolve_t *res) ; -static void info_display_start(char const *field, ss_resolve_t *res) ; -static void info_display_stop(char const *field, ss_resolve_t *res) ; -static void info_display_envat(char const *field, ss_resolve_t *res) ; -static void info_display_envfile(char const *field, ss_resolve_t *res) ; -static void info_display_logname(char const *field, ss_resolve_t *res) ; -static void info_display_logdst(char const *field, ss_resolve_t *res) ; -static void info_display_logfile(char const *field, ss_resolve_t *res) ; +static void info_display_name(char const *field, resolve_service_t *res) ; +static void info_display_intree(char const *field, resolve_service_t *res) ; +static void info_display_status(char const *field, resolve_service_t *res) ; +static void info_display_type(char const *field, resolve_service_t *res) ; +static void info_display_description(char const *field, resolve_service_t *res) ; +static void info_display_version(char const *field, resolve_service_t *res) ; +static void info_display_source(char const *field, resolve_service_t *res) ; +static void info_display_live(char const *field, resolve_service_t *res) ; +static void info_display_deps(char const *field, resolve_service_t *res) ; +static void info_display_requiredby(char const *field, resolve_service_t *res) ; +static void info_display_optsdeps(char const *field, resolve_service_t *res) ; +static void info_display_extdeps(char const *field, resolve_service_t *res) ; +static void info_display_start(char const *field, resolve_service_t *res) ; +static void info_display_stop(char const *field, resolve_service_t *res) ; +static void info_display_envat(char const *field, resolve_service_t *res) ; +static void info_display_envfile(char const *field, resolve_service_t *res) ; +static void info_display_logname(char const *field, resolve_service_t *res) ; +static void info_display_logdst(char const *field, resolve_service_t *res) ; +static void info_display_logfile(char const *field, resolve_service_t *res) ; ss_resolve_graph_style *STYLE = &graph_default ; @@ -87,8 +87,6 @@ ss_resolve_graph_style *STYLE = &graph_default ; -#include <oblibs/graph.h> - @@ -100,9 +98,10 @@ typedef ss_info_graph_func *ss_info_graph_func_t_ref ; int ss_info_graph_display_service(char const *name, char const *obj) { stralloc tree = STRALLOC_ZERO ; - ss_resolve_t res = RESOLVE_ZERO ; + resolve_service_t res = RESOLVE_SERVICE_ZERO ; + resolve_wrapper_t_ref wres = resolve_set_struct(SERVICE_STRUCT, &res) ; - int r = ss_resolve_svtree(&tree, name, obj), err = 0 ; + int r = service_resolve_svtree(&tree, name, obj), err = 0 ; if (r != 2) { if (r == 1) @@ -113,10 +112,10 @@ int ss_info_graph_display_service(char const *name, char const *obj) goto freed ; } - if (!ss_resolve_check(tree.s, name)) + if (!resolve_check(tree.s, name)) goto freed ; - if (!ss_resolve_read(&res, tree.s, name)) + if (!resolve_read(wres, tree.s, name)) goto freed ; char str_pid[UINT_FMT] ; @@ -136,13 +135,13 @@ int ss_info_graph_display_service(char const *name, char const *obj) char *ste = res.sa.s + res.state ; char *name = res.sa.s + res.name ; - if (!ss_state_check(ste,name)) { + if (!state_check(ste,name)) { ppid = "unitialized" ; goto dis ; } - if (!ss_state_read(&sta,ste,name)) { + if (!state_read(&sta,ste,name)) { log_warnu("read state of: ",name) ; goto freed ; @@ -184,7 +183,7 @@ int ss_info_graph_display_service(char const *name, char const *obj) err = 1 ; freed: - ss_resolve_free(&res) ; + resolve_free(wres) ; stralloc_free(&tree) ; return err ; @@ -544,13 +543,13 @@ static void info_display_string(char const *str) log_dieusys(LOG_EXIT_SYS,"write to stdout") ; } -static void info_display_name(char const *field, ss_resolve_t *res) +static void info_display_name(char const *field, resolve_service_t *res) { if (NOFIELD) info_display_field_name(field) ; info_display_string(res->sa.s + res->name) ; } -static void info_display_version(char const *field,ss_resolve_t *res) +static void info_display_version(char const *field,resolve_service_t *res) { if (NOFIELD) info_display_field_name(field) ; /** tempory check here, it not mandatory for the moment*/ @@ -565,13 +564,13 @@ static void info_display_version(char const *field,ss_resolve_t *res) } } -static void info_display_intree(char const *field,ss_resolve_t *res) +static void info_display_intree(char const *field,resolve_service_t *res) { if (NOFIELD) info_display_field_name(field) ; info_display_string(res->sa.s + res->treename) ; } -static void info_get_status(ss_resolve_t *res) +static void info_get_status(resolve_service_t *res) { int r ; int wstat ; @@ -606,13 +605,13 @@ static void info_get_status(ss_resolve_t *res) char *ste = res->sa.s + res->state ; char *name = res->sa.s + res->name ; char *status = 0 ; - if (!ss_state_check(ste,name)) + if (!state_check(ste,name)) { status = "unitialized" ; goto dis ; } - if (!ss_state_read(&sta,ste,name)) + if (!state_read(&sta,ste,name)) log_dieusys(LOG_EXIT_SYS,"read state of: ",name) ; if (sta.init) { @@ -634,7 +633,7 @@ static void info_get_status(ss_resolve_t *res) } } -static void info_display_status(char const *field,ss_resolve_t *res) +static void info_display_status(char const *field,resolve_service_t *res) { if (NOFIELD) info_display_field_name(field) ; @@ -649,25 +648,25 @@ static void info_display_status(char const *field,ss_resolve_t *res) } -static void info_display_type(char const *field,ss_resolve_t *res) +static void info_display_type(char const *field,resolve_service_t *res) { if (NOFIELD) info_display_field_name(field) ; info_display_string(get_key_by_enum(ENUM_TYPE,res->type)) ; } -static void info_display_description(char const *field,ss_resolve_t *res) +static void info_display_description(char const *field,resolve_service_t *res) { if (NOFIELD) info_display_field_name(field) ; info_display_string(res->sa.s + res->description) ; } -static void info_display_source(char const *field,ss_resolve_t *res) +static void info_display_source(char const *field,resolve_service_t *res) { if (NOFIELD) info_display_field_name(field) ; info_display_string(res->sa.s + res->src) ; } -static void info_display_live(char const *field,ss_resolve_t *res) +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) ; @@ -722,9 +721,9 @@ void ss_graph_matrix_add_classic(graph_t *g, genalloc *gares) size_t pos = 0, bpos = 0, ccount = 0 ; size_t cl[SS_MAX_SERVICE] ; - for (; pos < genalloc_len(ss_resolve_t, gares) ; pos++) { + for (; pos < genalloc_len(resolve_service_t, gares) ; pos++) { - ss_resolve_t_ref res = &genalloc_s(ss_resolve_t, gares)[pos] ; + resolve_service_t_ref res = &genalloc_s(resolve_service_t, gares)[pos] ; if (res->type == TYPE_CLASSIC) { @@ -737,8 +736,8 @@ void ss_graph_matrix_add_classic(graph_t *g, genalloc *gares) for (pos = 0 ; pos < ccount ; pos++) { - char *str = genalloc_s(ss_resolve_t, gares)[cl[pos]].sa.s ; - char *sv = str + genalloc_s(ss_resolve_t, gares)[cl[pos]].name ; + char *str = genalloc_s(resolve_service_t, gares)[cl[pos]].sa.s ; + char *sv = str + genalloc_s(resolve_service_t, gares)[cl[pos]].name ; graph_array_reverse(g->sort, g->sort_count) ; @@ -746,8 +745,8 @@ void ss_graph_matrix_add_classic(graph_t *g, genalloc *gares) char *service = g->data.s + genalloc_s(graph_hash_t,&g->hash)[g->sort[bpos]].vertex ; - int idx = ss_resolve_search(gares, service) ; - if (genalloc_s(ss_resolve_t, gares)[idx].type == TYPE_CLASSIC || + int idx = resolve_search(gares, service, SERVICE_STRUCT) ; + if (genalloc_s(resolve_service_t, gares)[idx].type == TYPE_CLASSIC || !strcmp(service, sv)) continue ; @@ -783,8 +782,10 @@ int ss_tree_get_sv_resolve(genalloc *gares, char const *dir, uint8_t what) log_flow() ; stralloc sa = STRALLOC_ZERO ; - ss_resolve_t res = RESOLVE_ZERO ; - ss_resolve_t reslog = RESOLVE_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 ; @@ -801,29 +802,29 @@ int ss_tree_get_sv_resolve(genalloc *gares, char const *dir, uint8_t what) char *name = sa.s + pos ; - if (!ss_resolve_check(dir,name)) + if (!resolve_check(dir,name)) goto err ; - if (!ss_resolve_read(&res,dir,name)) + if (!resolve_read(wres,dir,name)) goto err ; - if (ss_resolve_search(gares,name) == -1) { + if (resolve_search(gares,name, SERVICE_STRUCT) == -1) { if ((!what || what == 2) && (res.type == TYPE_CLASSIC)) { if (res.logger) { - if (!ss_resolve_read(&reslog, dir, res.sa.s + res.logger)) + if (!resolve_read(wreslog, dir, res.sa.s + res.logger)) goto err ; - if (ss_resolve_search(gares,res.sa.s + res.logger) == -1) { + if (resolve_search(gares,res.sa.s + res.logger, SERVICE_STRUCT) == -1) { - if (!ss_resolve_append(gares,&reslog)) + if (!resolve_append(gares,wreslog)) goto err ; } } - if (!ss_resolve_append(gares,&res)) + if (!resolve_append(gares,wres)) goto err ; continue ; @@ -831,7 +832,7 @@ int ss_tree_get_sv_resolve(genalloc *gares, char const *dir, uint8_t what) if (what) { - if (!ss_resolve_append(gares,&res)) + if (!resolve_append(gares,wres)) goto err ; } } @@ -840,8 +841,8 @@ int ss_tree_get_sv_resolve(genalloc *gares, char const *dir, uint8_t what) e = 1 ; err: stralloc_free(&sa) ; - ss_resolve_free(&res) ; - ss_resolve_free(&reslog) ; + resolve_free(wres) ; + resolve_free(wreslog) ; return e ; } @@ -860,14 +861,14 @@ static void ss_graph_matrix_build_bytree(graph_t *g, char const *tree, uint8_t w if (!ss_tree_get_sv_resolve(&gares, src, what)) log_dieu(LOG_EXIT_SYS,"get resolve files of tree: ", tree) ; - if (genalloc_len(ss_resolve_t, &gares) >= SS_MAX_SERVICE) + if (genalloc_len(resolve_service_t, &gares) >= SS_MAX_SERVICE) log_die(LOG_EXIT_SYS, "too many services to handle") ; pos = 0 ; - for (; pos < genalloc_len(ss_resolve_t, &gares) ; pos++) { + for (; pos < genalloc_len(resolve_service_t, &gares) ; pos++) { - ss_resolve_t_ref res = &genalloc_s(ss_resolve_t, &gares)[pos] ; + resolve_service_t_ref res = &genalloc_s(resolve_service_t, &gares)[pos] ; char *str = res->sa.s ; @@ -915,7 +916,7 @@ static void ss_graph_matrix_build_bytree(graph_t *g, char const *tree, uint8_t w -static void info_display_requiredby(char const *field, ss_resolve_t *res) +static void info_display_requiredby(char const *field, resolve_service_t *res) { size_t padding = 1 ; int r ; @@ -989,7 +990,7 @@ static void info_display_requiredby(char const *field, ss_resolve_t *res) } } -static void info_display_deps(char const *field, ss_resolve_t *res) +static void info_display_deps(char const *field, resolve_service_t *res) { int r ; size_t padding = 1 ; @@ -1059,7 +1060,7 @@ static void info_display_deps(char const *field, ss_resolve_t *res) stralloc_free(&deps) ; } -static void info_display_with_source_tree(stralloc *list,ss_resolve_t *res) +static void info_display_with_source_tree(stralloc *list,resolve_service_t *res) { size_t pos = 0, lpos = 0, newlen = 0 ; stralloc svlist = STRALLOC_ZERO ; @@ -1114,7 +1115,7 @@ static void info_display_with_source_tree(stralloc *list,ss_resolve_t *res) stralloc_free (&tmp) ; } -static void info_display_optsdeps(char const *field, ss_resolve_t *res) +static void info_display_optsdeps(char const *field, resolve_service_t *res) { stralloc salist = STRALLOC_ZERO ; @@ -1144,7 +1145,7 @@ static void info_display_optsdeps(char const *field, ss_resolve_t *res) stralloc_free(&salist) ; } -static void info_display_extdeps(char const *field, ss_resolve_t *res) +static void info_display_extdeps(char const *field, resolve_service_t *res) { stralloc salist = STRALLOC_ZERO ; @@ -1174,7 +1175,7 @@ static void info_display_extdeps(char const *field, ss_resolve_t *res) stralloc_free(&salist) ; } -static void info_display_start(char const *field,ss_resolve_t *res) +static void info_display_start(char const *field,resolve_service_t *res) { if (NOFIELD) info_display_field_name(field) ; else field = 0 ; @@ -1189,7 +1190,7 @@ static void info_display_start(char const *field,ss_resolve_t *res) } } -static void info_display_stop(char const *field,ss_resolve_t *res) +static void info_display_stop(char const *field,resolve_service_t *res) { if (NOFIELD) info_display_field_name(field) ; else field = 0 ; @@ -1205,7 +1206,7 @@ static void info_display_stop(char const *field,ss_resolve_t *res) } -static void info_display_envat(char const *field,ss_resolve_t *res) +static void info_display_envat(char const *field,resolve_service_t *res) { if (NOFIELD) info_display_field_name(field) ; stralloc salink = STRALLOC_ZERO ; @@ -1241,7 +1242,7 @@ static void info_display_envat(char const *field,ss_resolve_t *res) stralloc_free(&salink) ; } -static void info_display_envfile(char const *field,ss_resolve_t *res) +static void info_display_envfile(char const *field,resolve_service_t *res) { if (NOFIELD) info_display_field_name(field) ; else field = 0 ; @@ -1342,7 +1343,7 @@ static void info_display_envfile(char const *field,ss_resolve_t *res) stralloc_free(&salink) ; } -static void info_display_logname(char const *field,ss_resolve_t *res) +static void info_display_logname(char const *field,resolve_service_t *res) { if (NOFIELD) info_display_field_name(field) ; if (res->type == TYPE_CLASSIC || res->type == TYPE_LONGRUN) @@ -1361,7 +1362,7 @@ static void info_display_logname(char const *field,ss_resolve_t *res) log_dieusys(LOG_EXIT_SYS,"write to stdout") ; } -static void info_display_logdst(char const *field,ss_resolve_t *res) +static void info_display_logdst(char const *field,resolve_service_t *res) { if (NOFIELD) info_display_field_name(field) ; if (res->type != TYPE_BUNDLE || res->type != TYPE_MODULE) @@ -1380,7 +1381,7 @@ static void info_display_logdst(char const *field,ss_resolve_t *res) log_dieusys(LOG_EXIT_SYS,"write to stdout") ; } -static void info_display_logfile(char const *field,ss_resolve_t *res) +static void info_display_logfile(char const *field,resolve_service_t *res) { if (NOFIELD) info_display_field_name(field) ; if (res->type != TYPE_BUNDLE || res->type != TYPE_MODULE) @@ -1436,7 +1437,7 @@ static void info_display_logfile(char const *field,ss_resolve_t *res) log_dieusys(LOG_EXIT_SYS,"write to stdout") ; } -static void info_display_all(ss_resolve_t *res,int *what) +static void info_display_all(resolve_service_t *res,int *what) { unsigned int i = 0 ; @@ -1483,7 +1484,8 @@ int main(int argc, char const *const *argv, char const *const *envp) uid_t owner ; char ownerstr[UID_FMT] ; - ss_resolve_t res = RESOLVE_ZERO ; + resolve_service_t res = RESOLVE_SERVICE_ZERO ; + resolve_wrapper_t_ref wres = resolve_set_struct(SERVICE_STRUCT, &res) ; stralloc satree = STRALLOC_ZERO ; log_color = &log_color_disable ; @@ -1571,7 +1573,7 @@ int main(int argc, char const *const *argv, char const *const *envp) if (!set_ownersysdir(&home,owner)) log_dieusys(LOG_EXIT_SYS, "set owner directory") ; if (!auto_stra(&home,SS_SYSTEM,"/")) log_die_nomem("stralloc") ; - found = ss_resolve_svtree(&src,svname,tname) ; + found = service_resolve_svtree(&src,svname,tname) ; if (found == -1) log_dieu(LOG_EXIT_SYS,"resolve tree source of service: ",svname) ; else if (!found) { @@ -1583,7 +1585,7 @@ int main(int argc, char const *const *argv, char const *const *envp) } else if (found == 1) log_die(LOG_EXIT_SYS,"unknown service: ",svname) ; - if (!ss_resolve_read(&res,src.s,svname)) + if (!resolve_read(wres,src.s,svname)) log_dieusys(LOG_EXIT_SYS,"read resolve file of: ",svname) ; info_display_all(&res,what) ; @@ -1593,7 +1595,7 @@ int main(int argc, char const *const *argv, char const *const *envp) freed: - ss_resolve_free(&res) ; + resolve_free(wres) ; stralloc_free(&src) ; stralloc_free(&home) ; stralloc_free(&satree) ; diff --git a/src/66/66-instate.c b/src/66/66-instate.c index 799bcdfbdd7b45f2cd148c341368ba191a4a259b..7d72d828afe22b2d5598d6e75d919e70b9bccb17 100644 --- a/src/66/66-instate.c +++ b/src/66/66-instate.c @@ -87,7 +87,8 @@ int main(int argc, char const *const *argv) { int found = 0 ; uint8_t logger = 0 ; - ss_resolve_t res = RESOLVE_ZERO ; + resolve_service_t res = RESOLVE_SERVICE_ZERO ; + resolve_wrapper_t_ref wres = resolve_set_struct(SERVICE_STRUCT, &res) ; stralloc satree = STRALLOC_ZERO ; stralloc src = STRALLOC_ZERO ; stralloc tmp = STRALLOC_ZERO ; @@ -131,7 +132,7 @@ int main(int argc, char const *const *argv) if (!argc) log_usage(USAGE) ; svname = *argv ; - found = ss_resolve_svtree(&src,svname,tname) ; + found = service_resolve_svtree(&src,svname,tname) ; if (found == -1) log_dieu(LOG_EXIT_SYS,"resolve tree source of sv: ",svname) ; else if (!found) { log_info("no tree exist yet") ; @@ -142,14 +143,14 @@ int main(int argc, char const *const *argv) } else if (found == 1) log_die(LOG_EXIT_SYS,"unknown service: ",svname) ; - if (!ss_resolve_read(&res,src.s,svname)) log_dieusys(111,"read resolve file of: ",src.s,"/.resolve/",svname) ; + if (!resolve_read(wres,src.s,svname)) log_dieusys(111,"read resolve file of: ",src.s,"/.resolve/",svname) ; info_field_align(buf,fields,field_suffix,MAXOPTS) ; ste = res.sa.s + res.state ; - if (!ss_state_check(ste,svname)) log_diesys(111,"unitialized service: ",svname) ; - if (!ss_state_read(&sta,ste,svname)) log_dieusys(111,"read state file of: ",ste,"/",svname) ; + if (!state_check(ste,svname)) log_diesys(111,"unitialized service: ",svname) ; + if (!state_read(&sta,ste,svname)) log_dieusys(111,"read state file of: ",ste,"/",svname) ; info_display_string(fields[5],svname) ; info_display_int(fields[0],sta.reload) ; @@ -161,8 +162,8 @@ int main(int argc, char const *const *argv) if (res.logger && logger) { svname = res.sa.s + res.logger ; - if (!ss_state_check(ste,svname)) log_dieusys(111,"unitialized: ",svname) ; - if (!ss_state_read(&sta,ste,svname)) log_dieusys(111,"read state file of: ",ste,"/",svname) ; + if (!state_check(ste,svname)) log_dieusys(111,"unitialized: ",svname) ; + if (!state_read(&sta,ste,svname)) log_dieusys(111,"read state file of: ",ste,"/",svname) ; if (buffer_putsflush(buffer_1,"\n") == -1) log_dieusys(LOG_EXIT_SYS,"write to stdout") ; @@ -177,7 +178,7 @@ int main(int argc, char const *const *argv) } freed: - ss_resolve_free(&res) ; + resolve_free(wres) ; stralloc_free(&satree) ; stralloc_free(&src) ; stralloc_free(&tmp) ; diff --git a/src/66/66-intree.c b/src/66/66-intree.c index 2edb3e61884e3149c93cddf4797c39cd08d25231..605d2e9daa4fd433e82db203ad94660cfa76f7c2 100644 --- a/src/66/66-intree.c +++ b/src/66/66-intree.c @@ -39,6 +39,7 @@ #include <66/tree.h> #include <66/enum.h> #include <66/resolve.h> +#include <66/service.h> #include <66/backup.h> static unsigned int REVERSE = 0 ; @@ -236,14 +237,14 @@ static void info_get_graph_src(ss_resolve_graph_t *graph,char const *src,unsigne if (!sastr_dir_get(&sa,solve,exclude,S_IFREG)) log_dieusys(LOG_EXIT_SYS,"get source service file at: ",solve) ; - if (!ss_resolve_sort_bytype(&gares,&sa,src)) + if (!service_resolve_sort_bytype(&gares,&sa,src)) log_dieu(LOG_EXIT_SYS,"sort list by type") ; - for (pos = 0 ; pos < genalloc_len(ss_resolve_t,&gares) ; pos++) - if (!ss_resolve_graph_build(graph,&genalloc_s(ss_resolve_t,&gares)[pos],src,reverse)) + 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) ; - genalloc_deepfree(ss_resolve_t,&gares,ss_resolve_free) ; + resolve_deep_free(SERVICE_STRUCT, &gares) ; stralloc_free(&sa) ; } @@ -321,7 +322,8 @@ static void info_display_contents(char const *field, char const *treename) { int r ; size_t padding = 1, treenamelen = strlen(treename) ; - ss_resolve_t res = RESOLVE_ZERO ; + resolve_service_t res = RESOLVE_SERVICE_ZERO ; + resolve_wrapper_t_ref wres = resolve_set_struct(SERVICE_STRUCT,&res) ; ss_resolve_graph_t graph = RESOLVE_GRAPH_ZERO ; stralloc salist = STRALLOC_ZERO ; @@ -336,16 +338,16 @@ static void info_display_contents(char const *field, char const *treename) if (NOFIELD) padding = info_display_field_name(field) ; else { field = 0 ; padding = 0 ; } - if (!genalloc_len(ss_resolve_t,&graph.name)) goto empty ; + if (!genalloc_len(resolve_service_t,&graph.name)) goto empty ; r = ss_resolve_graph_publish(&graph,0) ; if (r < 0) log_die(LOG_EXIT_USER,"cyclic graph detected at tree: ", treename) ; else if (!r) log_dieusys(LOG_EXIT_SYS,"publish service graph of tree: ",treename) ; - for (size_t i = 0 ; i < genalloc_len(ss_resolve_t,&graph.sorted) ; i++) + for (size_t i = 0 ; i < genalloc_len(resolve_service_t,&graph.sorted) ; i++) { - char *string = genalloc_s(ss_resolve_t,&graph.sorted)[i].sa.s ; - char *name = string + genalloc_s(ss_resolve_t,&graph.sorted)[i].name ; + char *string = genalloc_s(resolve_service_t,&graph.sorted)[i].sa.s ; + char *name = string + genalloc_s(resolve_service_t,&graph.sorted)[i].name ; if (!stralloc_catb(&salist,name,strlen(name)+1)) log_die_nomem("stralloc") ; } @@ -355,9 +357,9 @@ static void info_display_contents(char const *field, char const *treename) 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") ; - ss_resolve_init(&res) ; + resolve_init(wres) ; res.ndeps = el ; - res.deps = ss_resolve_add_string(&res,salist.s) ; + res.deps = resolve_add_string(wres,salist.s) ; if (!info_graph_init(&res,tmp,REVERSE, padding, STYLE)) log_die(LOG_EXIT_SYS,"display graph of: ",treename) ; goto freed ; @@ -386,7 +388,7 @@ static void info_display_contents(char const *field, char const *treename) if (buffer_putsflush(buffer_1,"\n") == -1) log_dieusys(LOG_EXIT_SYS,"write to stdout") ; freed: - ss_resolve_free(&res) ; + resolve_free(wres) ; ss_resolve_graph_free(&graph) ; stralloc_free(&salist) ; } diff --git a/src/include/66/info.h b/src/include/66/info.h index aef8c5c09987539b733d3eb13d4bc49204d08041..626b40b3bf3940a89a083742489318ae7c0725df 100644 --- a/src/include/66/info.h +++ b/src/include/66/info.h @@ -18,7 +18,7 @@ #include <oblibs/log.h> #include <66/enum.h> -#include <66/resolve.h> +#include <66/service.h> #ifndef SS_INFO_H @@ -37,7 +37,7 @@ struct depth_s typedef void info_opts_func_t (char const *field,char const *treename) ; typedef info_opts_func_t *info_opts_func_t_ref ; -typedef void info_opts_svfunc_t (char const *field,ss_resolve_t *res) ; +typedef void info_opts_svfunc_t (char const *field,resolve_service_t *res) ; typedef info_opts_svfunc_t *info_opts_svfunc_t_ref ; typedef struct info_opts_map_s info_opts_map_t ; @@ -71,9 +71,9 @@ extern ss_resolve_graph_style graph_default ; extern void info_field_align (char buf[][INFO_FIELD_MAXLEN],char fields[][INFO_FIELD_MAXLEN],wchar_t const field_suffix[],size_t buflen) ; extern int info_getcols_fd(int fd) ; extern size_t info_length_from_wchar(char const *str) ; -extern void info_graph_display(ss_resolve_t *res, depth_t *depth, int last,int padding, ss_resolve_graph_style *style) ; -extern int info_graph_init (ss_resolve_t *res,char const *src,unsigned int reverse, int padding, ss_resolve_graph_style *style) ; -extern int info_walk(ss_resolve_t *res,char const *src,int reverse, depth_t *depth, int padding, ss_resolve_graph_style *style) ; +extern void info_graph_display(resolve_service_t *res, depth_t *depth, int last,int padding, ss_resolve_graph_style *style) ; +extern int info_graph_init (resolve_service_t *res,char const *src,unsigned int reverse, int padding, ss_resolve_graph_style *style) ; +extern int info_walk(resolve_service_t *res,char const *src,int reverse, depth_t *depth, int padding, ss_resolve_graph_style *style) ; extern size_t info_display_field_name(char const *field) ; extern void info_display_list(char const *field, stralloc *list) ; extern void info_display_nline(char const *field,char const *str) ; diff --git a/src/include/66/svc.h b/src/include/66/svc.h index 8c6cdb487c8ebc664d8d71525afa8cf800a54547..f103c8185e058f57c0ba4fe684bf6ed65de3dc71 100644 --- a/src/include/66/svc.h +++ b/src/include/66/svc.h @@ -20,13 +20,13 @@ #include <skalibs/genalloc.h> #include <s6/ftrigr.h> -#include <66/resolve.h> +#include <66/service.h> #include <66/ssexec.h> typedef struct ss_resolve_sig_s ss_resolve_sig_t, *ss_resolve_sig_t_ref ; struct ss_resolve_sig_s { - ss_resolve_t res ; + resolve_service_t res ; unsigned int notify ; unsigned int ndeath; tain deadline ; @@ -39,7 +39,7 @@ struct ss_resolve_sig_s #define RESOLVE_SIG_ZERO \ { \ - .res = RESOLVE_ZERO, \ + .res = RESOLVE_SERVICE_ZERO, \ .notify = 0, \ .ndeath = 3, \ .deadline = TAIN_ZERO, \ diff --git a/src/lib66/parse_module.c b/src/lib66/parse_module.c index 915eb483ab33d71f889edb6fd46e4326f50870f6..1ad8206ff64e8878aec41eed82ff1003866f472e 100644 --- a/src/lib66/parse_module.c +++ b/src/lib66/parse_module.c @@ -178,7 +178,7 @@ int parse_module(sv_alltype *alltype, ssexec_t *info, stralloc *parsed_list, uin minsta = insta ; - if (!ss_resolve_module_path(&sdir, &tmp, sv, src, info->owner)) + if (!module_path(&sdir, &tmp, sv, src, info->owner)) log_dieu(LOG_EXIT_SYS,"resolve source of module: ",sv); /** check mandatory directories: @@ -256,7 +256,7 @@ int parse_module(sv_alltype *alltype, ssexec_t *info, stralloc *parsed_list, uin for (; nid ; id += strlen(keep.s + id) + 1, nid--) { char *name = keep.s + id ; - if (ss_resolve_src_path(&list, name, info->owner,0) < 1) + if (service_frontend_path(&list, name, info->owner,0) < 1) log_die(LOG_EXIT_SYS, "resolve source path of: ", name) ; } } @@ -314,22 +314,21 @@ int parse_module(sv_alltype *alltype, ssexec_t *info, stralloc *parsed_list, uin /** we can't know the origin of the instanciated service. * Search first at service@ directory, if it not found - * pass through the classic ss_resolve_src_path() */ + * pass through the classic service_frontend_path() */ pbname = bname ; if (!already_parsed) { - int found = 0 ; size_t l = strlen(permanent_sdir) ; char tmp[l + SS_MODULE_SERVICE_INSTANCE_LEN + 2] ; auto_strings(tmp, permanent_sdir, SS_MODULE_SERVICE_INSTANCE + 1, "/") ; - r = ss_resolve_src(&addonsv, pbname, tmp, &found) ; + r = service_frontend_src(&addonsv, pbname, tmp) ; if (r == -1) log_dieusys(LOG_EXIT_SYS,"parse source directory: ", tmp) ; if (!r) { - if (ss_resolve_src_path(&addonsv, pbname, info->owner, 0) < 1) + if (service_frontend_path(&addonsv, pbname, info->owner, 0) < 1) log_dieu(LOG_EXIT_SYS,"resolve source path of: ", pbname) ; } svname = addonsv.s ; diff --git a/src/lib66/parse_service.c b/src/lib66/parse_service.c index 6c49e57b76daa01e072517f31c5e93c59a18192f..7ca46c27b9720526ded256b81ca6c42487e693c1 100644 --- a/src/lib66/parse_service.c +++ b/src/lib66/parse_service.c @@ -209,7 +209,7 @@ int parse_service(char const *sv, stralloc *parsed_list, ssexec_t *info, uint8_t if (!get_svtype(&alltype, frontend.s)) log_die(LOG_EXIT_USER, "invalid value for key: ", get_key_by_enum(ENUM_KEY_SECTION_MAIN, KEY_MAIN_TYPE), " at frontend service: ", sv) ; - /** contents of directory should be listed by ss_resolve_src_path + /** contents of directory should be listed by service_frontend_path * except for module type */ if (scan_mode(sv,S_IFDIR) == 1 && alltype.cname.itype != TYPE_MODULE) goto freed ; @@ -252,7 +252,7 @@ int parse_service_deps(sv_alltype *alltype, ssexec_t *info, stralloc *parsed_lis } else log_trace("bundle: ", keep.s + alltype->cname.name, " contents: ", deps.s + id," as service") ; - r = ss_resolve_src_path(&sa, deps.s + id, info->owner, directory_forced) ; + r = service_frontend_path(&sa, deps.s + id, info->owner, directory_forced) ; if (r < 1) goto err ;//don't warn here, the ss_revolve_src_path do it if (!parse_service(sa.s, parsed_list, info, force, alltype->overwrite_conf)) @@ -303,7 +303,7 @@ int parse_service_optsdeps(stralloc *rebuild, sv_alltype *alltype, ssexec_t *inf continue ; } - r = ss_resolve_src_path(&sa, deps.s + id, info->owner, directory_forced) ; + r = service_frontend_path(&sa, deps.s + id, info->owner, directory_forced) ; if (r == -1) goto err ; diff --git a/src/lib66/parser_write.c b/src/lib66/parser_write.c index 705265a8902837f4c612980410ee459b15866c81..f7fdefe7be04cf0a1fa63397c5d8d0233a886679 100644 --- a/src/lib66/parser_write.c +++ b/src/lib66/parser_write.c @@ -56,13 +56,14 @@ int write_services(sv_alltype *sv, char const *workdir, uint8_t force, uint8_t c int type = sv->cname.itype ; { - ss_resolve_t res = RESOLVE_ZERO ; - if (ss_resolve_check(workdir,name)) + resolve_service_t res = RESOLVE_SERVICE_ZERO ; + resolve_wrapper_t_ref wres = resolve_set_struct(SERVICE_STRUCT, &res) ; + if (resolve_check(workdir,name)) { - if (!ss_resolve_read(&res,workdir,name)) log_dieusys(LOG_EXIT_SYS,"read resolve file of: ",name) ; + if (!resolve_read(wres,workdir,name)) log_dieusys(LOG_EXIT_SYS,"read resolve file of: ",name) ; if (res.type != type && res.disen) log_die(LOG_EXIT_SYS,"Detection of incompatible type format for: ",name," -- current: ",get_key_by_enum(ENUM_TYPE,type)," previous: ",get_key_by_enum(ENUM_TYPE,res.type)) ; } - ss_resolve_free(&res) ; + resolve_free(wres) ; } size_t wnamelen ; diff --git a/src/lib66/rc_init.c b/src/lib66/rc_init.c index 863c149aa2529d69ca60441b87188aafbd4bd0b9..7db9829e2b003d07f64b05968c81b27ee04cb8a7 100644 --- a/src/lib66/rc_init.c +++ b/src/lib66/rc_init.c @@ -33,6 +33,7 @@ #include <66/constants.h> #include <66/utils.h> #include <66/state.h> +#include <66/service.h> #include <s6-rc/config.h> @@ -43,15 +44,16 @@ int rc_init(ssexec_t *info, char const *const *envp) { log_flow() ; - int r, wstat, empty = 0 ; + int r, wstat, empty = 0, e = 0 ; pid_t pid ; size_t pos = 0 ; ss_state_t sta = STATE_ZERO ; stralloc sares = STRALLOC_ZERO ; - ss_resolve_t res = RESOLVE_ZERO ; + resolve_service_t res = RESOLVE_SERVICE_ZERO ; + resolve_wrapper_t_ref wres = resolve_set_struct(SERVICE_STRUCT, &res) ; stralloc sasvc = STRALLOC_ZERO ; - genalloc gares = GENALLOC_ZERO ; //ss_resolve_t type + genalloc gares = GENALLOC_ZERO ; //resolve_service_t type char svdir[info->tree.len + SS_SVDIRS_LEN + SS_DB_LEN + 1 + info->treename.len + 1] ; char ltree[info->livetree.len + 1 + info->treename.len + 1] ; @@ -74,18 +76,18 @@ int rc_init(ssexec_t *info, char const *const *envp) if (chown(info->livetree.s,info->owner,gidowner) < 0){ log_warnusys("chown directory: ",info->livetree.s) ; goto err ; } } - if (!ss_resolve_pointo(&sares,info,SS_NOTYPE,SS_RESOLVE_SRC)) + if (!sa_pointo(&sares,info,SS_NOTYPE,SS_RESOLVE_SRC)) { log_warnu("set revolve pointer to source") ; goto err ; } - if (!ss_resolve_check(sares.s,SS_MASTER +1)) { log_warnu("find inner bundle -- please make a bug report") ; goto err ; } - if (!ss_resolve_read(&res,sares.s,SS_MASTER + 1)) { log_warnusys("read resolve file of inner bundle") ; goto err ; } + if (!resolve_check(sares.s,SS_MASTER +1)) { log_warnu("find inner bundle -- please make a bug report") ; goto err ; } + if (!resolve_read(wres,sares.s,SS_MASTER + 1)) { log_warnusys("read resolve file of inner bundle") ; goto err ; } if (!res.ndeps) { log_info("Initialization: no atomic services into tree: ",info->treename.s) ; empty = 1 ; goto end ; } - if (!ss_resolve_create_live(info)) { log_warnusys("create live state") ; goto err ; } + if (!create_live(info)) { log_warnusys("create live state") ; goto err ; } memcpy(svdir,info->tree.s,info->tree.len) ; memcpy(svdir + info->tree.len ,SS_SVDIRS ,SS_SVDIRS_LEN) ; @@ -131,21 +133,22 @@ int rc_init(ssexec_t *info, char const *const *envp) for (; pos < sasvc.len ; pos += strlen(sasvc.s + pos) +1) { char *name = sasvc.s + pos ; - ss_resolve_t tmp = RESOLVE_ZERO ; - if (!ss_resolve_check(sares.s,name)){ log_warnsys("unknown service: ",name) ; goto err ; } - if (!ss_resolve_read(&tmp,sares.s,name)) { log_warnusys("read resolve file of: ",name) ; goto err ; } - if (!ss_resolve_add_deps(&gares,&tmp,sares.s)) { log_warnusys("resolve dependencies of: ",name) ; goto err ; } - ss_resolve_free(&tmp) ; + resolve_service_t tmp = RESOLVE_SERVICE_ZERO ; + resolve_wrapper_t_ref wres = resolve_set_struct(SERVICE_STRUCT, &tmp) ; + if (!resolve_check(sares.s,name)){ log_warnsys("unknown service: ",name) ; goto err ; } + if (!resolve_read(wres,sares.s,name)) { log_warnusys("read resolve file of: ",name) ; goto err ; } + if (!service_resolve_add_deps(&gares,&tmp,sares.s)) { log_warnusys("resolve dependencies of: ",name) ; goto err ; } + resolve_free(wres) ; } - for (pos = 0 ; pos < genalloc_len(ss_resolve_t,&gares) ; pos++) + for (pos = 0 ; pos < genalloc_len(resolve_service_t,&gares) ; pos++) { - char const *string = genalloc_s(ss_resolve_t,&gares)[pos].sa.s ; - char const *name = string + genalloc_s(ss_resolve_t,&gares)[pos].name ; - char const *state = string + genalloc_s(ss_resolve_t,&gares)[pos].state ; + char const *string = genalloc_s(resolve_service_t,&gares)[pos].sa.s ; + char const *name = string + genalloc_s(resolve_service_t,&gares)[pos].name ; + char const *state = string + genalloc_s(resolve_service_t,&gares)[pos].state ; log_trace("Write state file of: ",name) ; - if (!ss_state_write(&sta,state,name)) + if (!state_write(&sta,state,name)) { log_warnusys("write state file of: ",name) ; goto err ; @@ -154,16 +157,13 @@ int rc_init(ssexec_t *info, char const *const *envp) } end: - genalloc_deepfree(ss_resolve_t,&gares,ss_resolve_free) ; - stralloc_free(&sasvc) ; - ss_resolve_free(&res) ; - stralloc_free(&sares) ; - return empty ? 2 : 1 ; + + e = empty ? 2 : 1 ; err: - genalloc_deepfree(ss_resolve_t,&gares,ss_resolve_free) ; + resolve_deep_free(SERVICE_STRUCT, &gares) ; stralloc_free(&sasvc) ; - ss_resolve_free(&res) ; + resolve_free(wres) ; stralloc_free(&sares) ; - return 0 ; + return e ; } diff --git a/src/lib66/rc_manage.c b/src/lib66/rc_manage.c index 551b6085effd5cfd321082585e135b8ff2ac2875..f98fdb4772dda4b7dd164fbf728b259087c93cc7 100644 --- a/src/lib66/rc_manage.c +++ b/src/lib66/rc_manage.c @@ -60,7 +60,7 @@ int rc_manage(ssexec_t *info,genalloc *ga) memcpy(live + info->livetree.len + 1,info->treename.s,info->treename.len) ; live[info->livetree.len + 1 + info->treename.len] = 0 ; - if (!ss_resolve_pointo(&sares,info,TYPE_LONGRUN,SS_RESOLVE_SRC)) + if (!sa_pointo(&sares,info,TYPE_LONGRUN,SS_RESOLVE_SRC)) { log_warnusys("set revolve pointer to source") ; goto err ; @@ -72,12 +72,12 @@ int rc_manage(ssexec_t *info,genalloc *ga) if (!stralloc_cats(&sares,SS_SVDIRS)) goto err ; if (!stralloc_cats(&sares,"/")) goto err ; newlen = sares.len ; - for (unsigned int i = 0 ; i < genalloc_len(ss_resolve_t,ga) ; i++) + for (unsigned int i = 0 ; i < genalloc_len(resolve_service_t,ga) ; i++) { - char const *string = genalloc_s(ss_resolve_t,ga)[i].sa.s ; - char const *name = string + genalloc_s(ss_resolve_t,ga)[i].name ; - char const *runat = string + genalloc_s(ss_resolve_t,ga)[i].runat ; - int type = genalloc_s(ss_resolve_t,ga)[i].type ; + char const *string = genalloc_s(resolve_service_t,ga)[i].sa.s ; + char const *name = string + genalloc_s(resolve_service_t,ga)[i].name ; + char const *runat = string + genalloc_s(resolve_service_t,ga)[i].runat ; + int type = genalloc_s(resolve_service_t,ga)[i].type ; //do not try to copy a bundle or oneshot, this is already done. if (type != TYPE_LONGRUN) continue ; sares.len = newlen ; @@ -98,13 +98,13 @@ int rc_manage(ssexec_t *info,genalloc *ga) goto err ; } } - for (unsigned int i = 0 ; i < genalloc_len(ss_resolve_t,ga) ; i++) + for (unsigned int i = 0 ; i < genalloc_len(resolve_service_t,ga) ; i++) { - char const *string = genalloc_s(ss_resolve_t,ga)[i].sa.s ; - char const *name = string + genalloc_s(ss_resolve_t,ga)[i].name ; - char const *state = string + genalloc_s(ss_resolve_t,ga)[i].state ; + char const *string = genalloc_s(resolve_service_t,ga)[i].sa.s ; + char const *name = string + genalloc_s(resolve_service_t,ga)[i].name ; + char const *state = string + genalloc_s(resolve_service_t,ga)[i].state ; log_trace("Write state file of: ",name) ; - if (!ss_state_write(&sta,state,name)) + if (!state_write(&sta,state,name)) { log_warnusys("write state file of: ",name) ; goto err ; diff --git a/src/lib66/rc_send.c b/src/lib66/rc_send.c index 7b4f800dd187f4477f012c716a924444f3e61f8f..53483c0360935d3ee2f4cc22334e989f059c0f35 100644 --- a/src/lib66/rc_send.c +++ b/src/lib66/rc_send.c @@ -28,15 +28,15 @@ int rc_send(ssexec_t *info,genalloc *ga,char const *sig,char const *const *envp) log_flow() ; size_t i = 0 ; - int nargc = 3 + genalloc_len(ss_resolve_t,ga) ; + int nargc = 3 + genalloc_len(resolve_service_t,ga) ; char const *newargv[nargc] ; unsigned int m = 0 ; newargv[m++] = "fake_name" ; newargv[m++] = sig ; - for (; i < genalloc_len(ss_resolve_t,ga) ; i++) - newargv[m++] = genalloc_s(ss_resolve_t,ga)[i].sa.s + genalloc_s(ss_resolve_t,ga)[i].name ; + for (; i < genalloc_len(resolve_service_t,ga) ; i++) + newargv[m++] = genalloc_s(resolve_service_t,ga)[i].sa.s + genalloc_s(resolve_service_t,ga)[i].name ; newargv[m++] = 0 ; diff --git a/src/lib66/rc_unsupervise.c b/src/lib66/rc_unsupervise.c index e3fab7d344d809a668172924863440fe16868040..eb6a20fe4d53707258920c1286ee4633b5aed002 100644 --- a/src/lib66/rc_unsupervise.c +++ b/src/lib66/rc_unsupervise.c @@ -36,7 +36,7 @@ int rc_unsupervise(ssexec_t *info,genalloc *ga,char const *sig,char const *const log_flow() ; size_t i = 0 ; - ss_resolve_t_ref pres ; + resolve_service_t_ref pres ; stralloc sares = STRALLOC_ZERO ; ss_state_t sta = STATE_ZERO ; @@ -63,22 +63,22 @@ int rc_unsupervise(ssexec_t *info,genalloc *ga,char const *sig,char const *const goto err ; } - for (; i < genalloc_len(ss_resolve_t,ga) ; i++) + for (; i < genalloc_len(resolve_service_t,ga) ; i++) { - char const *string = genalloc_s(ss_resolve_t,ga)[i].sa.s ; - char const *name = string + genalloc_s(ss_resolve_t,ga)[i].name ; - log_trace("delete directory service: ",string + genalloc_s(ss_resolve_t,ga)[i].runat) ; + char const *string = genalloc_s(resolve_service_t,ga)[i].sa.s ; + char const *name = string + genalloc_s(resolve_service_t,ga)[i].name ; + log_trace("delete directory service: ",string + genalloc_s(resolve_service_t,ga)[i].runat) ; s6rc_servicedir_unsupervise(live,prefix,name,0) ; - if (rm_rf(string + genalloc_s(ss_resolve_t,ga)[i].runat) < 0) goto err ; + if (rm_rf(string + genalloc_s(resolve_service_t,ga)[i].runat) < 0) goto err ; } - if (!ss_resolve_pointo(&sares,info,SS_NOTYPE,SS_RESOLVE_SRC)) + if (!sa_pointo(&sares,info,SS_NOTYPE,SS_RESOLVE_SRC)) { log_warnusys("set revolve pointer to source") ; goto err ; } - for (i = 0 ; i < genalloc_len(ss_resolve_t,ga) ; i++) + for (i = 0 ; i < genalloc_len(resolve_service_t,ga) ; i++) { - pres = &genalloc_s(ss_resolve_t,ga)[i] ; + pres = &genalloc_s(resolve_service_t,ga)[i] ; char const *string = pres->sa.s ; char const *name = string + pres->name ; char const *state = string + pres->state ; @@ -86,19 +86,19 @@ int rc_unsupervise(ssexec_t *info,genalloc *ga,char const *sig,char const *const if (!pres->disen) { log_trace("Delete resolve file of: ",name) ; - ss_resolve_rmfile(sares.s,name) ; + resolve_rmfile(sares.s,name) ; log_trace("Delete state file of: ",name) ; - ss_state_rmfile(state,name) ; + state_rmfile(state,name) ; } else { - ss_state_setflag(&sta,SS_FLAGS_RELOAD,SS_FLAGS_FALSE) ; - ss_state_setflag(&sta,SS_FLAGS_INIT,SS_FLAGS_TRUE) ; - // ss_state_setflag(&sta,SS_FLAGS_UNSUPERVISE,SS_FLAGS_FALSE) ; - ss_state_setflag(&sta,SS_FLAGS_STATE,SS_FLAGS_FALSE) ; - ss_state_setflag(&sta,SS_FLAGS_PID,SS_FLAGS_FALSE) ; + state_setflag(&sta,SS_FLAGS_RELOAD,SS_FLAGS_FALSE) ; + state_setflag(&sta,SS_FLAGS_INIT,SS_FLAGS_TRUE) ; + // state_setflag(&sta,SS_FLAGS_UNSUPERVISE,SS_FLAGS_FALSE) ; + state_setflag(&sta,SS_FLAGS_STATE,SS_FLAGS_FALSE) ; + state_setflag(&sta,SS_FLAGS_PID,SS_FLAGS_FALSE) ; log_trace("Write state file of: ",name) ; - if (!ss_state_write(&sta,state,name)) + if (!state_write(&sta,state,name)) { log_warnusys("write state file of: ",name) ; goto err ; diff --git a/src/lib66/ss_resolve_graph.c b/src/lib66/ss_resolve_graph.c index 277fe46b30432646003bc794ef2cc37a92471fd1..f959c6091ce726d548a6fee29b82a0e92b0b3615 100644 --- a/src/lib66/ss_resolve_graph.c +++ b/src/lib66/ss_resolve_graph.c @@ -16,6 +16,7 @@ #include <string.h> #include <stdint.h> +#include <stdlib.h> #include <oblibs/string.h> #include <oblibs/directory.h> @@ -27,6 +28,7 @@ #include <66/constants.h> #include <66/utils.h> +#include <66/service.h> void ss_resolve_graph_ndeps_free(ss_resolve_graph_ndeps_t *graph) { @@ -39,9 +41,9 @@ void ss_resolve_graph_free(ss_resolve_graph_t *graph) { log_flow() ; - genalloc_deepfree(ss_resolve_t,&graph->name,ss_resolve_free) ; + resolve_deep_free(SERVICE_STRUCT, &graph->name) ; genalloc_deepfree(ss_resolve_graph_ndeps_t,&graph->cp,ss_resolve_graph_ndeps_free) ; - genalloc_free(ss_resolve_t,&graph->sorted) ; + genalloc_free(resolve_service_t,&graph->sorted) ; } int ss_resolve_dfs(ss_resolve_graph_t *graph, unsigned int idx, visit *c,unsigned int *ename,unsigned int *edeps) @@ -70,7 +72,7 @@ int ss_resolve_dfs(ss_resolve_graph_t *graph, unsigned int idx, visit *c,unsigne } } c[idx] = SS_BLACK ; - if (!genalloc_insertb(ss_resolve_t, &graph->sorted, 0, &genalloc_s(ss_resolve_t,&graph->name)[idx],1)) + if (!genalloc_insertb(resolve_service_t, &graph->sorted, 0, &genalloc_s(resolve_service_t,&graph->name)[idx],1)) log_warnusys_return(LOG_EXIT_SYS,"genalloc") ; } end: @@ -92,8 +94,8 @@ int ss_resolve_graph_sort(ss_resolve_graph_t *graph) if ((c[i] == SS_WHITE) && ss_resolve_dfs(graph,genalloc_s(ss_resolve_graph_ndeps_t,&graph->cp)[i].idx,c,&ename,&edeps)) { int data = genalloc_s(uint32_t,&genalloc_s(ss_resolve_graph_ndeps_t,&graph->cp)[ename].ndeps)[edeps] ; - char *name = genalloc_s(ss_resolve_t,&graph->name)[ename].sa.s + genalloc_s(ss_resolve_t,&graph->name)[ename].name ; - char *deps = genalloc_s(ss_resolve_t,&graph->name)[data].sa.s + genalloc_s(ss_resolve_t,&graph->name)[data].name ; + char *name = genalloc_s(resolve_service_t,&graph->name)[ename].sa.s + genalloc_s(resolve_service_t,&graph->name)[ename].name ; + char *deps = genalloc_s(resolve_service_t,&graph->name)[data].sa.s + genalloc_s(resolve_service_t,&graph->name)[data].name ; log_warn_return(LOG_EXIT_LESSONE,"resolution of : ",name,": encountered a cycle involving service: ",deps) ; } } @@ -109,19 +111,19 @@ int ss_resolve_graph_publish(ss_resolve_graph_t *graph,unsigned int reverse) size_t a = 0 , b = 0 ; stralloc sa = STRALLOC_ZERO ; - for (; a < genalloc_len(ss_resolve_t,&graph->name) ; a++) + for (; a < genalloc_len(resolve_service_t,&graph->name) ; a++) { ss_resolve_graph_ndeps_t rescp = RESOLVE_GRAPH_NDEPS_ZERO ; rescp.idx = a ; - if (genalloc_s(ss_resolve_t,&graph->name)[a].ndeps) + if (genalloc_s(resolve_service_t,&graph->name)[a].ndeps) { sa.len = 0 ; - if (!sastr_clean_string(&sa, genalloc_s(ss_resolve_t,&graph->name)[a].sa.s + genalloc_s(ss_resolve_t,&graph->name)[a].deps)) goto err ; + if (!sastr_clean_string(&sa, genalloc_s(resolve_service_t,&graph->name)[a].sa.s + genalloc_s(resolve_service_t,&graph->name)[a].deps)) goto err ; for (b = 0 ; b < sa.len ; b += strlen(sa.s + b) + 1) { char *deps = sa.s + b ; - r = ss_resolve_search(&graph->name,deps) ; + r = resolve_search(&graph->name,deps, SERVICE_STRUCT) ; if (r >= 0) { if (!genalloc_append(uint32_t,&rescp.ndeps,&r)) goto err ; @@ -133,7 +135,7 @@ int ss_resolve_graph_publish(ss_resolve_graph_t *graph,unsigned int reverse) } if (ss_resolve_graph_sort(graph) < 0) { ret = -1 ; goto err ; } - if (!reverse) genalloc_reverse(ss_resolve_t,&graph->sorted) ; + if (!reverse) genalloc_reverse(resolve_service_t,&graph->sorted) ; stralloc_free(&sa) ; return 1 ; @@ -142,42 +144,45 @@ int ss_resolve_graph_publish(ss_resolve_graph_t *graph,unsigned int reverse) return ret ; } -int ss_resolve_graph_build(ss_resolve_graph_t *graph,ss_resolve_t *res,char const *src,unsigned int reverse) +int ss_resolve_graph_build(ss_resolve_graph_t *graph,resolve_service_t *res,char const *src,unsigned int reverse) { log_flow() ; + int r, e = 0 ; char *string = res->sa.s ; char *name = string + res->name ; + resolve_wrapper_t_ref wres = resolve_set_struct(SERVICE_STRUCT, res) ; - int r = ss_resolve_search(&graph->name,name) ; + r = resolve_search(&graph->name, name, SERVICE_STRUCT) ; if (r < 0) { if (!obstr_equal(name,SS_MASTER+1)) { - if(!ss_resolve_append(&graph->name,res)) { + if(!resolve_append(&graph->name,wres)) { log_warnu("append: ", name) ; goto err ; } } if (!reverse) { - if (!ss_resolve_add_deps(&graph->name,res,src)) { + if (!service_resolve_add_deps(&graph->name,res,src)) { log_warnu("add dependencies of: ", name) ; goto err ; } } else { - if (!ss_resolve_add_rdeps(&graph->name,res,src)) { + if (!service_resolve_add_rdeps(&graph->name,res,src)) { log_warnu("add reverse dependencies of: ", name) ; goto err ; } } } - return 1 ; + e = 1 ; err: - return 0 ; + free(wres) ; + return e ; } /** what = 0 -> only classic * what = 1 -> only atomic @@ -188,7 +193,8 @@ int ss_resolve_graph_src(ss_resolve_graph_t *graph, char const *dir, unsigned in log_flow() ; stralloc sa = STRALLOC_ZERO ; - ss_resolve_t res = RESOLVE_ZERO ; + resolve_service_t res = RESOLVE_SERVICE_ZERO ; + resolve_wrapper_t_ref wres = resolve_set_struct(SERVICE_STRUCT, &res) ; size_t dirlen = strlen(dir), pos = 0 ; char const *exclude[2] = { 0 } ; @@ -213,8 +219,8 @@ int ss_resolve_graph_src(ss_resolve_graph_t *graph, char const *dir, unsigned in for (;pos < sa.len; pos += strlen(sa.s + pos) + 1) { char *name = sa.s + pos ; - if (!ss_resolve_check(dir,name)) goto err ; - if (!ss_resolve_read(&res,dir,name)) goto err ; + if (!resolve_check(dir,name)) goto err ; + if (!resolve_read(wres,dir,name)) goto err ; if (!ss_resolve_graph_build(graph,&res,dir,reverse)) { log_warnu("resolve dependencies of service: ",name) ; @@ -223,10 +229,10 @@ int ss_resolve_graph_src(ss_resolve_graph_t *graph, char const *dir, unsigned in } stralloc_free(&sa) ; - ss_resolve_free(&res) ; + resolve_free(wres) ; return 1 ; err: stralloc_free(&sa) ; - ss_resolve_free(&res) ; + resolve_free(wres) ; return 0 ; } diff --git a/src/lib66/ssexec_dbctl.c b/src/lib66/ssexec_dbctl.c index a0207afed32a86e5e10c8860739a122c02063f27..91f82ec5cc0bc694ed055ead84de1a6e74cff9b8 100644 --- a/src/lib66/ssexec_dbctl.c +++ b/src/lib66/ssexec_dbctl.c @@ -36,6 +36,7 @@ #include <66/resolve.h> #include <66/ssexec.h> #include <66/state.h> +#include <66/service.h> static unsigned int DEADLINE = 0 ; @@ -48,18 +49,18 @@ static void rebuild_list(ss_resolve_graph_t *graph,ssexec_t *info, int what) genalloc gatmp = GENALLOC_ZERO ; ss_state_t sta = STATE_ZERO ; - for (unsigned int i = 0 ; i < genalloc_len(ss_resolve_t,&graph->sorted) ; i++) + for (unsigned int i = 0 ; i < genalloc_len(resolve_service_t,&graph->sorted) ; i++) { - char *string = genalloc_s(ss_resolve_t,&graph->sorted)[i].sa.s ; - char *name = string + genalloc_s(ss_resolve_t,&graph->sorted)[i].name ; - char *runat = string + genalloc_s(ss_resolve_t,&graph->sorted)[i].runat ; - char *state = string + genalloc_s(ss_resolve_t,&graph->sorted)[i].state ; - if (!ss_state_check(state,name)) log_die(LOG_EXIT_SYS,"unitialized service: ",name) ; - if (!ss_state_read(&sta,state,name)) log_dieusys(LOG_EXIT_SYS,"read state of: ",name) ; + char *string = genalloc_s(resolve_service_t,&graph->sorted)[i].sa.s ; + char *name = string + genalloc_s(resolve_service_t,&graph->sorted)[i].name ; + char *runat = string + genalloc_s(resolve_service_t,&graph->sorted)[i].runat ; + char *state = string + genalloc_s(resolve_service_t,&graph->sorted)[i].state ; + if (!state_check(state,name)) log_die(LOG_EXIT_SYS,"unitialized service: ",name) ; + if (!state_read(&sta,state,name)) log_dieusys(LOG_EXIT_SYS,"read state of: ",name) ; if (sta.init) log_die(LOG_EXIT_SYS,"unitialized service: ",name) ; - int type = genalloc_s(ss_resolve_t,&graph->sorted)[i].type ; - if (type == TYPE_LONGRUN && genalloc_s(ss_resolve_t,&graph->sorted)[i].disen) + int type = genalloc_s(resolve_service_t,&graph->sorted)[i].type ; + if (type == TYPE_LONGRUN && genalloc_s(resolve_service_t,&graph->sorted)[i].disen) { if (!s6_svstatus_read(runat,&status)) log_dieusys(LOG_EXIT_SYS,"read status of: ",runat) ; isup = status.pid && !status.flagfinishing ; @@ -77,7 +78,7 @@ static void rebuild_list(ss_resolve_graph_t *graph,ssexec_t *info, int what) } else { - if (!sta.state && what || !genalloc_s(ss_resolve_t,&graph->sorted)[i].disen) + if (!sta.state && what || !genalloc_s(resolve_service_t,&graph->sorted)[i].disen) { log_info("Already down: ",name) ; continue ; @@ -88,10 +89,10 @@ static void rebuild_list(ss_resolve_graph_t *graph,ssexec_t *info, int what) continue ; } } - genalloc_append(ss_resolve_t,&gatmp,&genalloc_s(ss_resolve_t,&graph->sorted)[i]) ; + genalloc_append(resolve_service_t,&gatmp,&genalloc_s(resolve_service_t,&graph->sorted)[i]) ; } - genalloc_copy(ss_resolve_t,&graph->sorted,&gatmp) ; - genalloc_free(ss_resolve_t,&gatmp) ; + genalloc_copy(resolve_service_t,&graph->sorted,&gatmp) ; + genalloc_free(resolve_service_t,&gatmp) ; } /* signal = 0 -> reload @@ -108,10 +109,10 @@ static int check_status(genalloc *gares,ssexec_t *info,int signal) if (!signal) reload = 1 ; else if (signal == 1) up = 1 ; - for (unsigned int i = 0 ; i < genalloc_len(ss_resolve_t,gares) ; i++) + for (unsigned int i = 0 ; i < genalloc_len(resolve_service_t,gares) ; i++) { int nret = 0 ; - ss_resolve_t_ref pres = &genalloc_s(ss_resolve_t,gares)[i] ; + resolve_service_t_ref pres = &genalloc_s(resolve_service_t,gares)[i] ; char const *name = pres->sa.s + pres->name ; char const *state = pres->sa.s + pres->state ; /** do not touch the Master resolve file*/ @@ -124,44 +125,44 @@ static int check_status(genalloc *gares,ssexec_t *info,int signal) { if ((!WEXITSTATUS(status.wstat) && !WIFSIGNALED(status.wstat)) || (WIFSIGNALED(status.wstat) && !WEXITSTATUS(status.wstat) && (WTERMSIG(status.wstat) == 15 ))) { - ss_state_setflag(&sta,SS_FLAGS_PID,status.pid) ; - ss_state_setflag(&sta,SS_FLAGS_STATE,SS_FLAGS_TRUE) ; + state_setflag(&sta,SS_FLAGS_PID,status.pid) ; + state_setflag(&sta,SS_FLAGS_STATE,SS_FLAGS_TRUE) ; } else { log_warnu("start: ",name) ; nret = 1 ; - ss_state_setflag(&sta,SS_FLAGS_PID,SS_FLAGS_FALSE) ; - ss_state_setflag(&sta,SS_FLAGS_STATE,SS_FLAGS_FALSE) ; + state_setflag(&sta,SS_FLAGS_PID,SS_FLAGS_FALSE) ; + state_setflag(&sta,SS_FLAGS_STATE,SS_FLAGS_FALSE) ; } } else { if ((!WEXITSTATUS(status.wstat) && !WIFSIGNALED(status.wstat)) || (WIFSIGNALED(status.wstat) && !WEXITSTATUS(status.wstat) && (WTERMSIG(status.wstat) == 15 ))) { - ss_state_setflag(&sta,SS_FLAGS_PID,SS_FLAGS_FALSE) ; - ss_state_setflag(&sta,SS_FLAGS_STATE,SS_FLAGS_FALSE) ; + state_setflag(&sta,SS_FLAGS_PID,SS_FLAGS_FALSE) ; + state_setflag(&sta,SS_FLAGS_STATE,SS_FLAGS_FALSE) ; } else { log_warnu("stop: ",name) ; - ss_state_setflag(&sta,SS_FLAGS_PID,status.pid) ; - ss_state_setflag(&sta,SS_FLAGS_STATE,SS_FLAGS_TRUE) ; + state_setflag(&sta,SS_FLAGS_PID,status.pid) ; + state_setflag(&sta,SS_FLAGS_STATE,SS_FLAGS_TRUE) ; nret = 1 ; } } } if (nret) ret = 111 ; - ss_state_setflag(&sta,SS_FLAGS_RELOAD,SS_FLAGS_FALSE) ; - ss_state_setflag(&sta,SS_FLAGS_INIT,SS_FLAGS_FALSE) ; - // ss_state_setflag(&sta,SS_FLAGS_UNSUPERVISE,SS_FLAGS_FALSE) ; + state_setflag(&sta,SS_FLAGS_RELOAD,SS_FLAGS_FALSE) ; + state_setflag(&sta,SS_FLAGS_INIT,SS_FLAGS_FALSE) ; + // state_setflag(&sta,SS_FLAGS_UNSUPERVISE,SS_FLAGS_FALSE) ; if (pres->type == TYPE_BUNDLE || pres->type == TYPE_ONESHOT) { - if (up) ss_state_setflag(&sta,SS_FLAGS_STATE,SS_FLAGS_TRUE) ; - else ss_state_setflag(&sta,SS_FLAGS_STATE,SS_FLAGS_FALSE) ; + if (up) state_setflag(&sta,SS_FLAGS_STATE,SS_FLAGS_TRUE) ; + else state_setflag(&sta,SS_FLAGS_STATE,SS_FLAGS_FALSE) ; } log_trace("Write state file of: ",name) ; - if (!ss_state_write(&sta,state,name)) + if (!state_write(&sta,state,name)) { log_warnusys("write state file of: ",name) ; ret = 111 ; @@ -181,7 +182,7 @@ static pid_t send(genalloc *gasv, char const *livetree, char const *signal,char tain_now_g() ; tain_add_g(&deadline, &deadline) ; - char const *newargv[10 + genalloc_len(ss_resolve_t,gasv)] ; + char const *newargv[10 + genalloc_len(resolve_service_t,gasv)] ; unsigned int m = 0 ; char fmt[UINT_FMT] ; fmt[uint_fmt(fmt, VERBOSITY)] = 0 ; @@ -199,8 +200,8 @@ static pid_t send(genalloc *gasv, char const *livetree, char const *signal,char newargv[m++] = signal ; newargv[m++] = "change" ; - for (unsigned int i = 0 ; i < genalloc_len(ss_resolve_t,gasv); i++) - newargv[m++] = genalloc_s(ss_resolve_t,gasv)[i].sa.s + genalloc_s(ss_resolve_t,gasv)[i].name ; + for (unsigned int i = 0 ; i < genalloc_len(resolve_service_t,gasv); i++) + newargv[m++] = genalloc_s(resolve_service_t,gasv)[i].sa.s + genalloc_s(resolve_service_t,gasv)[i].name ; newargv[m++] = 0 ; @@ -222,11 +223,12 @@ int ssexec_dbctl(int argc, char const *const *argv,char const *const *envp,ssexe char *signal = 0 ; char *mainsv = SS_MASTER + 1 ; - genalloc gares = GENALLOC_ZERO ; //ss_resolve_t + genalloc gares = GENALLOC_ZERO ; //resolve_service_t stralloc tmp = STRALLOC_ZERO ; stralloc sares = STRALLOC_ZERO ; ss_resolve_graph_t graph = RESOLVE_GRAPH_ZERO ; - ss_resolve_t res = RESOLVE_ZERO ; + resolve_service_t res = RESOLVE_SERVICE_ZERO ; + resolve_wrapper_t_ref wres = resolve_set_struct(SERVICE_STRUCT, &res) ; up = down = reload = ret = reverse = 0 ; @@ -258,21 +260,21 @@ int ssexec_dbctl(int argc, char const *const *argv,char const *const *envp,ssexe } else signal = "-u" ; - if (!ss_resolve_pointo(&sares,info,SS_NOTYPE,SS_RESOLVE_SRC)) log_dieusys(LOG_EXIT_SYS,"set revolve pointer to source") ; + if (!sa_pointo(&sares,info,SS_NOTYPE,SS_RESOLVE_SRC)) log_dieusys(LOG_EXIT_SYS,"set revolve pointer to source") ; if (argc < 1) { - if (!ss_resolve_check(sares.s,mainsv)) log_diesys(LOG_EXIT_SYS,"inner bundle doesn't exit -- please make a bug report") ; - if (!ss_resolve_read(&res,sares.s,mainsv)) log_dieusys(LOG_EXIT_SYS,"read resolve file of inner bundle") ; + if (!resolve_check(sares.s,mainsv)) log_diesys(LOG_EXIT_SYS,"inner bundle doesn't exit -- please make a bug report") ; + if (!resolve_read(wres,sares.s,mainsv)) log_dieusys(LOG_EXIT_SYS,"read resolve file of inner bundle") ; if (res.ndeps) { - if (!ss_resolve_append(&gares,&res)) log_dieusys(LOG_EXIT_SYS,"append services selection with inner bundle") ; + if (!resolve_append(&gares,wres)) log_dieusys(LOG_EXIT_SYS,"append services selection with inner bundle") ; } else { log_info("nothing to do") ; - ss_resolve_free(&res) ; + resolve_free(wres) ; goto freed ; } @@ -282,10 +284,10 @@ int ssexec_dbctl(int argc, char const *const *argv,char const *const *envp,ssexe for(;*argv;argv++) { char const *name = *argv ; - if (!ss_resolve_check(sares.s,name)) log_diesys(LOG_EXIT_SYS,"unknown service: ",name) ; - if (!ss_resolve_read(&res,sares.s,name)) log_dieusys(LOG_EXIT_SYS,"read resolve file of: ",name) ; + if (!resolve_check(sares.s,name)) log_diesys(LOG_EXIT_SYS,"unknown service: ",name) ; + if (!resolve_read(wres,sares.s,name)) log_dieusys(LOG_EXIT_SYS,"read resolve file of: ",name) ; if (res.type == TYPE_CLASSIC) log_die(LOG_EXIT_SYS,name," has type classic") ; - if (!ss_resolve_append(&gares,&res)) log_dieusys(LOG_EXIT_SYS,"append services selection with: ", name) ; + if (!resolve_append(&gares,wres)) log_dieusys(LOG_EXIT_SYS,"append services selection with: ", name) ; } } @@ -300,9 +302,9 @@ int ssexec_dbctl(int argc, char const *const *argv,char const *const *envp,ssexe if (reload) { reverse = 1 ; - for (unsigned int i = 0 ; i < genalloc_len(ss_resolve_t,&gares) ; i++) + for (unsigned int i = 0 ; i < genalloc_len(resolve_service_t,&gares) ; i++) { - if (!ss_resolve_graph_build(&graph,&genalloc_s(ss_resolve_t,&gares)[i],sares.s,reverse)) log_dieusys(LOG_EXIT_SYS,"build services graph") ; + if (!ss_resolve_graph_build(&graph,&genalloc_s(resolve_service_t,&gares)[i],sares.s,reverse)) log_dieusys(LOG_EXIT_SYS,"build services graph") ; } r = ss_resolve_graph_publish(&graph,reverse) ; if (r < 0) log_die(LOG_EXIT_SYS,"cyclic dependencies detected") ; @@ -325,15 +327,15 @@ int ssexec_dbctl(int argc, char const *const *argv,char const *const *envp,ssexe if (down) reverse = 1 ; else reverse = 0 ; - for (unsigned int i = 0 ; i < genalloc_len(ss_resolve_t,&gares) ; i++) + for (unsigned int i = 0 ; i < genalloc_len(resolve_service_t,&gares) ; i++) { int ireverse = reverse ; - int logname = get_rstrlen_until(genalloc_s(ss_resolve_t,&gares)[i].sa.s + genalloc_s(ss_resolve_t,&gares)[i].name,SS_LOG_SUFFIX) ; - if (logname > 0 && (!ss_resolve_cmp(&gares,genalloc_s(ss_resolve_t,&gares)[i].sa.s + genalloc_s(ss_resolve_t,&gares)[i].logassoc)) && down) + int logname = get_rstrlen_until(genalloc_s(resolve_service_t,&gares)[i].sa.s + genalloc_s(resolve_service_t,&gares)[i].name,SS_LOG_SUFFIX) ; + if (logname > 0 && (!resolve_cmp(&gares,genalloc_s(resolve_service_t,&gares)[i].sa.s + genalloc_s(resolve_service_t,&gares)[i].logassoc, SERVICE_STRUCT)) && down) ireverse = 1 ; if (reload) ireverse = 1 ; - if (!ss_resolve_graph_build(&graph,&genalloc_s(ss_resolve_t,&gares)[i],sares.s,ireverse)) log_dieusys(LOG_EXIT_SYS,"build services graph") ; + if (!ss_resolve_graph_build(&graph,&genalloc_s(resolve_service_t,&gares)[i],sares.s,ireverse)) log_dieusys(LOG_EXIT_SYS,"build services graph") ; } r = ss_resolve_graph_publish(&graph,reverse) ; if (r < 0) log_die(LOG_EXIT_SYS,"cyclic dependencies detected") ; @@ -354,8 +356,8 @@ int ssexec_dbctl(int argc, char const *const *argv,char const *const *envp,ssexe stralloc_free(&tmp) ; stralloc_free(&sares) ; ss_resolve_graph_free(&graph) ; - ss_resolve_free(&res) ; - genalloc_deepfree(ss_resolve_t,&gares,ss_resolve_free) ; + resolve_free(wres) ; + resolve_deep_free(SERVICE_STRUCT, &gares) ; return ret ; } diff --git a/src/lib66/ssexec_disable.c b/src/lib66/ssexec_disable.c index efd4916faf50010268fb6e555fd14122aa958c23..578c1396cbbf9af5a5c0f74f58ecdec46a6c4b64 100644 --- a/src/lib66/ssexec_disable.c +++ b/src/lib66/ssexec_disable.c @@ -15,6 +15,7 @@ #include <string.h> #include <errno.h> #include <stdint.h> +#include <stdlib.h> #include <oblibs/obgetopt.h> #include <oblibs/log.h> @@ -32,6 +33,7 @@ #include <66/svc.h> #include <66/state.h> #include <66/utils.h> +#include <66/service.h> static stralloc workdir = STRALLOC_ZERO ; static uint8_t FORCE = 0 ; @@ -46,20 +48,21 @@ static void cleanup(void) errno = e ; } -int svc_remove(genalloc *tostop,ss_resolve_t *res, char const *src,ssexec_t *info) +int svc_remove(genalloc *tostop,resolve_service_t *res, char const *src,ssexec_t *info) { log_flow() ; unsigned int i = 0 ; - int r ; + int r, e = 0 ; genalloc rdeps = GENALLOC_ZERO ; stralloc dst = STRALLOC_ZERO ; - ss_resolve_t cp = RESOLVE_ZERO ; + resolve_service_t cp = RESOLVE_SERVICE_ZERO ; + resolve_wrapper_t_ref wres = resolve_set_struct(SERVICE_STRUCT, &cp) ; ss_state_t sta = STATE_ZERO ; size_t newlen ; char *name = res->sa.s + res->name ; - if (!ss_resolve_copy(&cp,res)) + if (!service_resolve_copy(&cp,res)) { log_warnusys("copy resolve file") ; goto err ; @@ -77,7 +80,7 @@ int svc_remove(genalloc *tostop,ss_resolve_t *res, char const *src,ssexec_t *inf if (!FORCE) { - if (!ss_resolve_add_rdeps(&rdeps,&cp,src)) + if (!service_resolve_add_rdeps(&rdeps,&cp,src)) { log_warnusys("resolve recursive dependencies of: ",name) ; goto err ; @@ -85,20 +88,21 @@ int svc_remove(genalloc *tostop,ss_resolve_t *res, char const *src,ssexec_t *inf } else { - if (!ss_resolve_append(&rdeps,&cp)) goto err ; + if (!resolve_append(&rdeps,wres)) goto err ; } - if (!ss_resolve_add_logger(&rdeps,src)) + if (!service_resolve_add_logger(&rdeps,src)) { log_warnusys("resolve logger") ; goto err ; } - ss_resolve_free(&cp) ; + resolve_free(wres) ; - for (;i < genalloc_len(ss_resolve_t,&rdeps) ; i++) + for (;i < genalloc_len(resolve_service_t,&rdeps) ; i++) { - ss_resolve_t_ref pres = &genalloc_s(ss_resolve_t,&rdeps)[i] ; + resolve_service_t_ref pres = &genalloc_s(resolve_service_t,&rdeps)[i] ; + resolve_wrapper_t_ref dwres = resolve_set_struct(SERVICE_STRUCT, pres) ; char *str = pres->sa.s ; char *name = str + pres->name ; char *ste = str + pres->state ; @@ -115,27 +119,27 @@ int svc_remove(genalloc *tostop,ss_resolve_t *res, char const *src,ssexec_t *inf /** r == -1 means the state file is not present, * r > 0 means service need to be initialized, * so not initialized at all.*/ - r = ss_state_check_flags(ste,name,SS_FLAGS_INIT) ; + r = state_check_flags(ste,name,SS_FLAGS_INIT) ; if (!r) { /** modify the resolve file for 66-stop*/ pres->disen = 0 ; log_trace("Write resolve file of: ",name) ; - if (!ss_resolve_write(pres,src,name)) + if (!resolve_write(dwres,src,name)) { log_warnusys("write resolve file of: ",name) ; goto err ; } - if (!ss_state_read(&sta,ste,name)) { + if (!state_read(&sta,ste,name)) { log_warnusys("read state of: ",name) ; goto err ; } - ss_state_setflag(&sta,SS_FLAGS_RELOAD,SS_FLAGS_FALSE) ; - ss_state_setflag(&sta,SS_FLAGS_INIT,SS_FLAGS_FALSE) ; - ss_state_setflag(&sta,SS_FLAGS_UNSUPERVISE,SS_FLAGS_TRUE) ; + state_setflag(&sta,SS_FLAGS_RELOAD,SS_FLAGS_FALSE) ; + state_setflag(&sta,SS_FLAGS_INIT,SS_FLAGS_FALSE) ; + state_setflag(&sta,SS_FLAGS_UNSUPERVISE,SS_FLAGS_TRUE) ; log_trace("Write state file of: ",name) ; - if (!ss_state_write(&sta,ste,name)) + if (!state_write(&sta,ste,name)) { log_warnusys("write state file of: ",name) ; goto err ; @@ -166,21 +170,21 @@ int svc_remove(genalloc *tostop,ss_resolve_t *res, char const *src,ssexec_t *inf } log_trace("Delete resolve file of: ",name) ; - ss_resolve_rmfile(src,name) ; + resolve_rmfile(src,name) ; } - if (!ss_resolve_cmp(tostop,name)) - if (!ss_resolve_append(tostop,pres)) goto err ; + if (!resolve_cmp(tostop, name, SERVICE_STRUCT)) + if (!resolve_append(tostop,wres)) goto err ; + + free(dwres) ; } - genalloc_deepfree(ss_resolve_t,&rdeps,ss_resolve_free) ; - stralloc_free(&dst) ; - return 1 ; + e = 1 ; err: - ss_resolve_free(&cp) ; - genalloc_deepfree(ss_resolve_t,&rdeps,ss_resolve_free) ; + resolve_free(wres) ; + resolve_deep_free(SERVICE_STRUCT, &rdeps) ; stralloc_free(&dst) ; - return 0 ; + return e ; } int ssexec_disable(int argc, char const *const *argv,char const *const *envp,ssexec_t *info) @@ -188,10 +192,11 @@ int ssexec_disable(int argc, char const *const *argv,char const *const *envp,sse int r, logname ; unsigned int nlongrun, nclassic, stop, force ; - genalloc tostop = GENALLOC_ZERO ;//ss_resolve_t - genalloc gares = GENALLOC_ZERO ; //ss_resolve_t - ss_resolve_t res = RESOLVE_ZERO ; - ss_resolve_t_ref pres ; + genalloc tostop = GENALLOC_ZERO ;//resolve_service_t + genalloc gares = GENALLOC_ZERO ; //resolve_service_t + resolve_service_t res = RESOLVE_SERVICE_ZERO ; + resolve_service_t_ref pres ; + resolve_wrapper_t_ref wres = resolve_set_struct(SERVICE_STRUCT, &res) ; r = nclassic = nlongrun = stop = logname = force = 0 ; @@ -222,16 +227,16 @@ int ssexec_disable(int argc, char const *const *argv,char const *const *envp,sse for (;*argv;argv++) { char const *name = *argv ; - if (!ss_resolve_check(workdir.s,name)) + if (!resolve_check(workdir.s,name)) log_info_nclean_return(LOG_EXIT_ZERO,&cleanup,name," is not enabled") ; - if (!ss_resolve_read(&res,workdir.s,name)) + if (!resolve_read(wres,workdir.s,name)) log_dieusys_nclean(LOG_EXIT_SYS,&cleanup,"read resolve file of: ",name) ; if (REMOVE) { stralloc sa = STRALLOC_ZERO ; - r = ss_resolve_svtree(&sa,name,0) ; + r = service_resolve_svtree(&sa,name,0) ; if (r > 2) log_dieu_nclean(LOG_EXIT_SYS,&cleanup,"use -R option -- ",name," is set on different tree") ; stralloc_free(&sa) ; @@ -244,14 +249,14 @@ int ssexec_disable(int argc, char const *const *argv,char const *const *envp,sse } else { - if (!ss_resolve_append(&gares,&res)) + if (!resolve_append(&gares,wres)) log_dieusys_nclean(LOG_EXIT_SYS,&cleanup,"append services selection with: ",name) ; } } - for(unsigned int i = 0 ; i < genalloc_len(ss_resolve_t,&gares) ; i++) + for(unsigned int i = 0 ; i < genalloc_len(resolve_service_t,&gares) ; i++) { - pres = &genalloc_s(ss_resolve_t,&gares)[i] ; + pres = &genalloc_s(resolve_service_t,&gares)[i] ; char *string = pres->sa.s ; char *name = string + pres->name ; char *state = string + pres->state ; @@ -266,7 +271,7 @@ int ssexec_disable(int argc, char const *const *argv,char const *const *envp,sse * Also, the remove option can be only used if the service is not marked initialized too.*/ if (FORCE || REMOVE) { - r = ss_state_check_flags(state,name,SS_FLAGS_INIT) ; + r = state_check_flags(state,name,SS_FLAGS_INIT) ; if (!r) log_die_nclean(LOG_EXIT_USER,&cleanup,name," is marked initialized -- ",FORCE ? "-F" : "-R"," is not allowed") ; @@ -286,7 +291,7 @@ int ssexec_disable(int argc, char const *const *argv,char const *const *envp,sse log_die_nclean(LOG_EXIT_USER,&cleanup,"nice try peon") ; logname = get_rstrlen_until(name,SS_LOG_SUFFIX) ; - if (logname > 0 && (!ss_resolve_cmp(&gares,string + pres->logassoc))) + if (logname > 0 && (!resolve_cmp(&gares, string + pres->logassoc, SERVICE_STRUCT))) log_die_nclean(LOG_EXIT_USER,&cleanup,"logger detected - disabling is not allowed") ; if (!pres->disen && !FORCE) @@ -321,7 +326,7 @@ int ssexec_disable(int argc, char const *const *argv,char const *const *envp,sse if (r < 0) log_die(LOG_EXIT_USER,"cyclic graph detected") ; log_dieusys(LOG_EXIT_SYS,"publish service graph") ; } - if (!ss_resolve_write_master(info,&graph,workdir.s,1)) + if (!service_resolve_write_master(info,&graph,workdir.s,1)) log_dieusys_nclean(LOG_EXIT_SYS,&cleanup,"update inner bundle") ; ss_resolve_graph_free(&graph) ; @@ -339,34 +344,34 @@ int ssexec_disable(int argc, char const *const *argv,char const *const *envp,sse cleanup() ; stralloc_free(&workdir) ; - ss_resolve_free(&res) ; - genalloc_deepfree(ss_resolve_t,&gares,ss_resolve_free) ; + resolve_free(wres) ; + resolve_deep_free(SERVICE_STRUCT, &gares) ; - for (unsigned int i = 0 ; i < genalloc_len(ss_resolve_t,&tostop); i++) - log_info("Disabled successfully: ",genalloc_s(ss_resolve_t,&tostop)[i].sa.s + genalloc_s(ss_resolve_t,&tostop)[i].name) ; + for (unsigned int i = 0 ; i < genalloc_len(resolve_service_t,&tostop); i++) + log_info("Disabled successfully: ",genalloc_s(resolve_service_t,&tostop)[i].sa.s + genalloc_s(resolve_service_t,&tostop)[i].name) ; - if (stop && genalloc_len(ss_resolve_t,&tostop)) + if (stop && genalloc_len(resolve_service_t,&tostop)) { - int nargc = 3 + genalloc_len(ss_resolve_t,&tostop) ; + int nargc = 3 + genalloc_len(resolve_service_t,&tostop) ; char const *newargv[nargc] ; unsigned int m = 0 ; newargv[m++] = "fake_name" ; newargv[m++] = "-u" ; - for (unsigned int i = 0 ; i < genalloc_len(ss_resolve_t,&tostop); i++) - newargv[m++] = genalloc_s(ss_resolve_t,&tostop)[i].sa.s + genalloc_s(ss_resolve_t,&tostop)[i].name ; + for (unsigned int i = 0 ; i < genalloc_len(resolve_service_t,&tostop); i++) + newargv[m++] = genalloc_s(resolve_service_t,&tostop)[i].sa.s + genalloc_s(resolve_service_t,&tostop)[i].name ; newargv[m++] = 0 ; if (ssexec_stop(nargc,newargv,envp,info)) { - genalloc_deepfree(ss_resolve_t,&tostop,ss_resolve_free) ; + resolve_deep_free(SERVICE_STRUCT, &tostop) ; return 111 ; } } - genalloc_deepfree(ss_resolve_t,&tostop,ss_resolve_free) ; + resolve_deep_free(SERVICE_STRUCT, &tostop) ; return 0 ; } diff --git a/src/lib66/ssexec_enable.c b/src/lib66/ssexec_enable.c index 683f7d551223c061e65980a8d03b84793755075f..4ef606cf6016c748994d678cfc81abce593bdcf2 100644 --- a/src/lib66/ssexec_enable.c +++ b/src/lib66/ssexec_enable.c @@ -39,6 +39,7 @@ #include <66/environ.h> #include <66/service.h> + static stralloc workdir = STRALLOC_ZERO ; stralloc PARSED_LIST = STRALLOC_ZERO ; @@ -158,7 +159,7 @@ void start_write(stralloc *tostart,unsigned int *nclassic,unsigned int *nlongrun name = keep.s + sv->cname.name ; log_trace("write resolve file of: ",name) ; - if (!ss_resolve_setnwrite(sv,info,workdir)) + if (!service_resolve_setnwrite(sv,info,workdir)) log_dieu_nclean(LOG_EXIT_SYS,&ssexec_enable_cleanup,"write revolve file for: ",name) ; if (sastr_cmp(tostart,name) == -1) @@ -183,8 +184,10 @@ void start_write(stralloc *tostart,unsigned int *nclassic,unsigned int *nlongrun int r ; size_t pos = 0, gpos = 0 ; size_t workdirlen = strlen(workdir) ; - ss_resolve_t res = RESOLVE_ZERO ; - ss_resolve_t dres = RESOLVE_ZERO ; + resolve_service_t res = RESOLVE_SERVICE_ZERO ; + resolve_service_t dres = RESOLVE_SERVICE_ZERO ; + resolve_wrapper_t_ref wres = resolve_set_struct(SERVICE_STRUCT, &res) ; + resolve_wrapper_t_ref dwres = resolve_set_struct(SERVICE_STRUCT, &dres) ; stralloc salist = STRALLOC_ZERO ; genalloc gamodule = GENALLOC_ZERO ; ss_resolve_graph_t mgraph = RESOLVE_GRAPH_ZERO ; @@ -199,7 +202,7 @@ void start_write(stralloc *tostart,unsigned int *nclassic,unsigned int *nlongrun char dst[workdirlen + SS_DB_LEN + SS_SRC_LEN + 1 + namelen + 1]; auto_strings(dst,workdir,SS_DB,SS_SRC,"/",name) ; - if (!ss_resolve_read(&res,workdir,name)) { + if (!resolve_read(wres,workdir,name)) { err_msg = "read resolve file of: " ; goto err ; } @@ -213,16 +216,16 @@ void start_write(stralloc *tostart,unsigned int *nclassic,unsigned int *nlongrun gpos = 0 ; FOREACH_SASTR(&salist,gpos) { - if (!ss_resolve_read(&dres,workdir,salist.s + gpos)) { + if (!resolve_read(dwres,workdir,salist.s + gpos)) { err_msg = "read resolve file of: " ; goto err ; } if (dres.type != TYPE_CLASSIC) { - if (ss_resolve_search(&gamodule,name) == -1) + if (resolve_search(&gamodule, name, SERVICE_STRUCT) == -1) { - if (!ss_resolve_append(&gamodule,&dres)) + if (!resolve_append(&gamodule,dwres)) { err_msg = "append genalloc with: " ; goto err ; @@ -232,9 +235,9 @@ void start_write(stralloc *tostart,unsigned int *nclassic,unsigned int *nlongrun } } - for (gpos = 0 ; gpos < genalloc_len(ss_resolve_t,&gamodule) ; gpos++) + for (gpos = 0 ; gpos < genalloc_len(resolve_service_t,&gamodule) ; gpos++) { - if (!ss_resolve_graph_build(&mgraph,&genalloc_s(ss_resolve_t,&gamodule)[gpos],workdir,0)) + if (!ss_resolve_graph_build(&mgraph,&genalloc_s(resolve_service_t,&gamodule)[gpos],workdir,0)) { err_msg = "build the graph of: " ; goto err ; @@ -253,10 +256,10 @@ void start_write(stralloc *tostart,unsigned int *nclassic,unsigned int *nlongrun } salist.len = 0 ; - for (gpos = 0 ; gpos < genalloc_len(ss_resolve_t,&mgraph.sorted) ; gpos++) + for (gpos = 0 ; gpos < genalloc_len(resolve_service_t,&mgraph.sorted) ; gpos++) { - char *string = genalloc_s(ss_resolve_t,&mgraph.sorted)[gpos].sa.s ; - char *name = string + genalloc_s(ss_resolve_t,&mgraph.sorted)[gpos].name ; + char *string = genalloc_s(resolve_service_t,&mgraph.sorted)[gpos].sa.s ; + char *name = string + genalloc_s(resolve_service_t,&mgraph.sorted)[gpos].name ; if (!auto_stra(&salist,name,"\n")) { err_msg = "append stralloc for: " ; @@ -271,7 +274,7 @@ void start_write(stralloc *tostart,unsigned int *nclassic,unsigned int *nlongrun goto err ; } - genalloc_deepfree(ss_resolve_t,&gamodule,ss_resolve_free) ; + resolve_deep_free(SERVICE_STRUCT, &gamodule) ; ss_resolve_graph_free(&mgraph) ; } @@ -280,10 +283,10 @@ void start_write(stralloc *tostart,unsigned int *nclassic,unsigned int *nlongrun return ; err: - genalloc_deepfree(ss_resolve_t,&gamodule,ss_resolve_free) ; + resolve_deep_free(SERVICE_STRUCT, &gamodule) ; ss_resolve_graph_free(&mgraph) ; - ss_resolve_free(&res) ; - ss_resolve_free(&dres) ; + resolve_free(wres) ; + resolve_free(dwres) ; stralloc_free(&salist) ; log_dieu_nclean(LOG_EXIT_SYS,&ssexec_enable_cleanup,err_msg,name) ; } @@ -346,7 +349,7 @@ int ssexec_enable(int argc, char const *const *argv,char const *const *envp,ssex directory_forced = dname ; } else sv = *argv ; - if (ss_resolve_src_path(&sasrc,sv,info->owner,!directory_forced ? 0 : directory_forced) < 1) + if (service_frontend_path(&sasrc,sv,info->owner,!directory_forced ? 0 : directory_forced) < 1) log_dieu(LOG_EXIT_SYS,"resolve source path of: ",*argv) ; } @@ -385,7 +388,7 @@ int ssexec_enable(int argc, char const *const *argv,char const *const *envp,ssex if (r < 0) log_die(LOG_EXIT_USER,"cyclic graph detected") ; log_dieusys(LOG_EXIT_SYS,"publish service graph") ; } - if (!ss_resolve_write_master(info,&graph,workdir.s,0)) + if (!service_resolve_write_master(info,&graph,workdir.s,0)) log_dieusys_nclean(LOG_EXIT_SYS,&ssexec_enable_cleanup,"update inner bundle") ; ss_resolve_graph_free(&graph) ; diff --git a/src/lib66/ssexec_env.c b/src/lib66/ssexec_env.c index d383b8b907694ae1f56eefab4958e13e85c94fa2..a57809e40ce83d6761e1fbf5208e8d9ec598114f 100644 --- a/src/lib66/ssexec_env.c +++ b/src/lib66/ssexec_env.c @@ -213,7 +213,8 @@ int ssexec_env(int argc, char const *const *argv,char const *const *envp,ssexec_ stralloc eversion = STRALLOC_ZERO ; stralloc savar = STRALLOC_ZERO ; stralloc salist = STRALLOC_ZERO ; - ss_resolve_t res = RESOLVE_ZERO ; + resolve_service_t res = RESOLVE_SERVICE_ZERO ; + resolve_wrapper_t_ref wres = resolve_set_struct(SERVICE_STRUCT, &res) ; uint8_t todo = T_UNSET ; @@ -293,7 +294,7 @@ int ssexec_env(int argc, char const *const *argv,char const *const *envp,ssexec_ treename = !info->opt_tree ? 0 : info->treename.s ; - r = ss_resolve_svtree(&sasrc,sv,treename) ; + r = service_resolve_svtree(&sasrc,sv,treename) ; if (r == -1) log_dieu(LOG_EXIT_SYS,"resolve tree source of sv: ",sv) ; else if (!r) { log_info("no tree exist yet") ; @@ -304,7 +305,7 @@ int ssexec_env(int argc, char const *const *argv,char const *const *envp,ssexec_ } else if (r == 1) log_die(LOG_EXIT_SYS,"unknown service: ",sv, !info->opt_tree ? " in current tree: " : " in tree: ", info->treename.s) ; - if (!ss_resolve_read(&res,sasrc.s,sv)) + if (!resolve_read(wres,sasrc.s,sv)) log_dieusys(LOG_EXIT_SYS,"read resolve file of: ",sv) ; if (!res.srconf) { @@ -433,7 +434,7 @@ int ssexec_env(int argc, char const *const *argv,char const *const *envp,ssexec_ stralloc_free(&eversion) ; stralloc_free(&savar) ; stralloc_free(&salist) ; - ss_resolve_free(&res) ; + resolve_free(wres) ; return 0 ; } diff --git a/src/lib66/ssexec_init.c b/src/lib66/ssexec_init.c index bdb153fbb210a5ba05ec9993cdcfa5261db7340f..e1a140161505cd108889fd6c29169938a7ec4031 100644 --- a/src/lib66/ssexec_init.c +++ b/src/lib66/ssexec_init.c @@ -43,10 +43,9 @@ int ssexec_init(int argc, char const *const *argv,char const *const *envp,ssexec int r, db, classic, earlier ; ssize_t i = 0, logname = 0 ; - genalloc gares = GENALLOC_ZERO ; //ss_resolve_t type + genalloc gares = GENALLOC_ZERO ; //resolve_service_t type stralloc sares = STRALLOC_ZERO ; stralloc sasvc = STRALLOC_ZERO ; - ss_resolve_t res = RESOLVE_ZERO ; ss_state_t sta = STATE_ZERO ; char const *exclude[1] = { 0 } ; @@ -100,49 +99,50 @@ int ssexec_init(int argc, char const *const *argv,char const *const *envp,ssexec goto follow ; } - if (!ss_resolve_pointo(&sares,info,SS_NOTYPE,SS_RESOLVE_SRC)) + if (!sa_pointo(&sares,info,SS_NOTYPE,SS_RESOLVE_SRC)) log_dieu(LOG_EXIT_SYS,"set revolve pointer to source") ; for (i = 0;i < sasvc.len; i += strlen(sasvc.s + i) + 1) { char *name = sasvc.s + i ; - ss_resolve_t tmp = RESOLVE_ZERO ; - if (!ss_resolve_check(sares.s,name)) log_diesys(LOG_EXIT_USER,"unknown service: ",name) ; - if (!ss_resolve_read(&tmp,sares.s,name)) log_dieusys(LOG_EXIT_SYS,"read resolve file of: ",name) ; - if (!ss_resolve_add_deps(&gares,&tmp,sares.s)) log_dieusys(LOG_EXIT_SYS,"resolve dependencies of: ",name) ; - ss_resolve_free(&tmp) ; + resolve_service_t res = RESOLVE_SERVICE_ZERO ; + resolve_wrapper_t_ref wres = resolve_set_struct(SERVICE_STRUCT, &res) ; + if (!resolve_check(sares.s,name)) log_diesys(LOG_EXIT_USER,"unknown service: ",name) ; + if (!resolve_read(wres,sares.s,name)) log_dieusys(LOG_EXIT_SYS,"read resolve file of: ",name) ; + if (!service_resolve_add_deps(&gares,&res,sares.s)) log_dieusys(LOG_EXIT_SYS,"resolve dependencies of: ",name) ; + resolve_free(wres) ; } if (!earlier) { /** reverse to start first the logger */ - genalloc_reverse(ss_resolve_t,&gares) ; + genalloc_reverse(resolve_service_t,&gares) ; if (!svc_init(info,svdir,&gares)) log_dieu(LOG_EXIT_SYS,"initiate service of tree: ",info->treename.s) ; } else { - if (!ss_resolve_create_live(info)) log_dieusys(LOG_EXIT_SYS,"create live state") ; - for (i = 0 ; i < genalloc_len(ss_resolve_t,&gares) ; i++) + if (!create_live(info)) log_dieusys(LOG_EXIT_SYS,"create live state") ; + for (i = 0 ; i < genalloc_len(resolve_service_t,&gares) ; i++) { logname = 0 ; - char *string = genalloc_s(ss_resolve_t,&gares)[i].sa.s ; - char *name = string + genalloc_s(ss_resolve_t,&gares)[i].name ; + char *string = genalloc_s(resolve_service_t,&gares)[i].sa.s ; + char *name = string + genalloc_s(resolve_service_t,&gares)[i].name ; size_t namelen = strlen(name) ; logname = get_rstrlen_until(name,SS_LOG_SUFFIX) ; - if (logname > 0) name = string + genalloc_s(ss_resolve_t,&gares)[i].logassoc ; + if (logname > 0) name = string + genalloc_s(resolve_service_t,&gares)[i].logassoc ; char tocopy[dirlen + 1 + namelen + 1] ; memcpy(tocopy,svdir,dirlen) ; tocopy[dirlen] = '/' ; memcpy(tocopy + dirlen + 1, name, namelen) ; tocopy[dirlen + 1 + namelen] = 0 ; - if (!hiercopy(tocopy,string + genalloc_s(ss_resolve_t,&gares)[i].runat)) log_dieusys(LOG_EXIT_SYS,"copy earlier service: ",tocopy," to: ",string + genalloc_s(ss_resolve_t,&gares)[i].runat) ; - ss_state_setflag(&sta,SS_FLAGS_RELOAD,SS_FLAGS_FALSE) ; - ss_state_setflag(&sta,SS_FLAGS_INIT,SS_FLAGS_FALSE) ; - // ss_state_setflag(&sta,SS_FLAGS_UNSUPERVISE,SS_FLAGS_FALSE) ; - ss_state_setflag(&sta,SS_FLAGS_STATE,SS_FLAGS_UNKNOWN) ; - ss_state_setflag(&sta,SS_FLAGS_PID,SS_FLAGS_UNKNOWN) ; - if (!ss_state_write(&sta,string + genalloc_s(ss_resolve_t,&gares)[i].state,name)) log_dieusys(LOG_EXIT_SYS,"write state file of: ",name) ; - log_info("Initialized successfully: ", logname < 0 ? name : string + genalloc_s(ss_resolve_t,&gares)[i].logreal) ; + if (!hiercopy(tocopy,string + genalloc_s(resolve_service_t,&gares)[i].runat)) log_dieusys(LOG_EXIT_SYS,"copy earlier service: ",tocopy," to: ",string + genalloc_s(resolve_service_t,&gares)[i].runat) ; + state_setflag(&sta,SS_FLAGS_RELOAD,SS_FLAGS_FALSE) ; + state_setflag(&sta,SS_FLAGS_INIT,SS_FLAGS_FALSE) ; + // state_setflag(&sta,SS_FLAGS_UNSUPERVISE,SS_FLAGS_FALSE) ; + state_setflag(&sta,SS_FLAGS_STATE,SS_FLAGS_UNKNOWN) ; + state_setflag(&sta,SS_FLAGS_PID,SS_FLAGS_UNKNOWN) ; + if (!state_write(&sta,string + genalloc_s(resolve_service_t,&gares)[i].state,name)) log_dieusys(LOG_EXIT_SYS,"write state file of: ",name) ; + log_info("Initialized successfully: ", logname < 0 ? name : string + genalloc_s(resolve_service_t,&gares)[i].logreal) ; } } } @@ -151,8 +151,7 @@ int ssexec_init(int argc, char const *const *argv,char const *const *envp,ssexec stralloc_free(&sares) ; stralloc_free(&sasvc) ; - ss_resolve_free(&res) ; - genalloc_deepfree(ss_resolve_t,&gares,ss_resolve_free) ; + resolve_deep_free(SERVICE_STRUCT, &gares) ; /** db already initiated? */ if (db) diff --git a/src/lib66/ssexec_start.c b/src/lib66/ssexec_start.c index 38c0c3bd3cd6cd7602d82d6fcd408ff671e34683..b41133218bcafdbec418dd6b9765244c102de89c 100644 --- a/src/lib66/ssexec_start.c +++ b/src/lib66/ssexec_start.c @@ -13,7 +13,7 @@ */ #include <string.h> -//#include <stdio.h> +#include <stdlib.h> #include <oblibs/obgetopt.h> #include <oblibs/log.h> @@ -31,6 +31,7 @@ #include <66/resolve.h> #include <66/rc.h> #include <66/state.h> +#include <66/service.h> static int empty = 0 ; static unsigned int RELOAD = 0 ; @@ -52,12 +53,12 @@ int svc_sanitize(ssexec_t *info, char const *const *envp) int r ; stralloc sares = STRALLOC_ZERO ; - if (!ss_resolve_pointo(&sares,info,TYPE_CLASSIC,SS_RESOLVE_SRC)) + if (!sa_pointo(&sares,info,TYPE_CLASSIC,SS_RESOLVE_SRC)) { log_warnu("set revolve pointer to source") ; goto err; } - if (genalloc_len(ss_resolve_t,&graph_reload_cl.name)) + if (genalloc_len(resolve_service_t,&graph_reload_cl.name)) { //reverse = 1 ; r = ss_resolve_graph_publish(&graph_reload_cl,reverse) ; @@ -70,7 +71,7 @@ int svc_sanitize(ssexec_t *info, char const *const *envp) if (!svc_unsupervise(info,&graph_reload_cl.sorted,"-d",envp)) goto err ; - genalloc_reverse(ss_resolve_t,&graph_reload_cl.sorted) ; + genalloc_reverse(resolve_service_t,&graph_reload_cl.sorted) ; if (!svc_init(info,sares.s,&graph_reload_cl.sorted)) { log_warnu("iniatiate service list") ; @@ -78,7 +79,7 @@ int svc_sanitize(ssexec_t *info, char const *const *envp) } goto end ; } - if (genalloc_len(ss_resolve_t,&graph_init_cl.name)) + if (genalloc_len(resolve_service_t,&graph_init_cl.name)) { r = ss_resolve_graph_publish(&graph_init_cl,reverse) ; if (r < 0 || !r) @@ -125,12 +126,12 @@ int rc_sanitize(ssexec_t *info, char const *const *envp) else if (r > 1) { empty = 1 ; goto end ; } done = 1 ; } - if (!ss_resolve_pointo(&sares,info,SS_NOTYPE,SS_RESOLVE_SRC)) + if (!sa_pointo(&sares,info,SS_NOTYPE,SS_RESOLVE_SRC)) { log_warnu("set revolve pointer to source") ; goto err; } - if (genalloc_len(ss_resolve_t,&graph_init_rc.name) && !done) + if (genalloc_len(resolve_service_t,&graph_init_rc.name) && !done) { int ireverse = 0 ; r = ss_resolve_graph_publish(&graph_init_rc,ireverse) ; @@ -145,7 +146,7 @@ int rc_sanitize(ssexec_t *info, char const *const *envp) goto err ; } } - if (genalloc_len(ss_resolve_t,&graph_reload_rc.name)) + if (genalloc_len(resolve_service_t,&graph_reload_rc.name)) { r = ss_resolve_graph_publish(&graph_reload_rc,reverse) ; if (r < 0 || !r) @@ -216,9 +217,10 @@ int ssexec_start(int argc, char const *const *argv,char const *const *envp,ssexe int cl, rc, logname ; stralloc sares = STRALLOC_ZERO ; stralloc sasta = STRALLOC_ZERO ; - genalloc gares = GENALLOC_ZERO ; //ss_resolve_t - ss_resolve_t_ref pres ; - ss_resolve_t res = RESOLVE_ZERO ; + genalloc gares = GENALLOC_ZERO ; //resolve_service_t + resolve_service_t_ref pres ; + resolve_service_t res = RESOLVE_SERVICE_ZERO ; + resolve_wrapper_t_ref wres = resolve_set_struct(SERVICE_STRUCT, &res) ; ss_state_t sta = STATE_ZERO ; cl = rc = logname = 0 ; @@ -246,19 +248,19 @@ int ssexec_start(int argc, char const *const *argv,char const *const *envp,ssexe if ((scandir_ok(info->scandir.s)) !=1 ) log_diesys(LOG_EXIT_SYS,"scandir: ", info->scandir.s," is not running") ; - if (!ss_resolve_pointo(&sasta,info,SS_NOTYPE,SS_RESOLVE_STATE)) log_dieusys(LOG_EXIT_SYS,"set revolve pointer to state") ; + if (!sa_pointo(&sasta,info,SS_NOTYPE,SS_RESOLVE_STATE)) log_dieusys(LOG_EXIT_SYS,"set revolve pointer to state") ; /** the tree may not initialized already, check it and create * the live directory if it's the case */ if (!scan_mode(sasta.s,S_IFDIR)) - if (!ss_resolve_create_live(info)) log_dieusys(LOG_EXIT_SYS,"create live state") ; + if (!create_live(info)) log_dieusys(LOG_EXIT_SYS,"create live state") ; - if (!ss_resolve_pointo(&sares,info,SS_NOTYPE,SS_RESOLVE_SRC)) log_dieusys(LOG_EXIT_SYS,"set revolve pointer to source") ; + if (!sa_pointo(&sares,info,SS_NOTYPE,SS_RESOLVE_SRC)) log_dieusys(LOG_EXIT_SYS,"set revolve pointer to source") ; for (;*argv;argv++) { char const *name = *argv ; - if (!ss_resolve_check(sares.s,name)) log_info_return(LOG_EXIT_ZERO,name," is not enabled") ; - if (!ss_resolve_read(&res,sares.s,name)) log_dieusys(LOG_EXIT_SYS,"read resolve file of: ",name) ; + if (!resolve_check(sares.s,name)) log_info_return(LOG_EXIT_ZERO,name," is not enabled") ; + if (!resolve_read(wres,sares.s,name)) log_dieusys(LOG_EXIT_SYS,"read resolve file of: ",name) ; if (res.type == TYPE_MODULE) { if (!module_in_cmdline(&gares,&res,sares.s)) @@ -266,26 +268,27 @@ int ssexec_start(int argc, char const *const *argv,char const *const *envp,ssexe } else { - if (!ss_resolve_append(&gares,&res)) + if (!resolve_append(&gares,wres)) log_dieusys(LOG_EXIT_SYS,"append services selection with: ",name) ; } } - for (unsigned int i = 0 ; i < genalloc_len(ss_resolve_t,&gares) ; i++) + for (unsigned int i = 0 ; i < genalloc_len(resolve_service_t,&gares) ; i++) { int init = 0 ; int reload = 0 ; int reverse = 0 ; - pres = &genalloc_s(ss_resolve_t,&gares)[i] ; + pres = &genalloc_s(resolve_service_t,&gares)[i] ; + resolve_wrapper_t_ref wres = resolve_set_struct(SERVICE_STRUCT, pres) ; char *string = pres->sa.s ; char *name = string + pres->name ; logname = 0 ; - if (!ss_state_check(sasta.s,name)) + if (!state_check(sasta.s,name)) { init = 1 ; goto append ; } - else if (!ss_state_read(&sta,sasta.s,name)) log_dieusys(LOG_EXIT_SYS,"read state file of: ",name) ; + else if (!state_read(&sta,sasta.s,name)) log_dieusys(LOG_EXIT_SYS,"read state file of: ",name) ; if (obstr_equal(name,SS_MASTER + 1)) goto append ; @@ -293,7 +296,7 @@ int ssexec_start(int argc, char const *const *argv,char const *const *envp,ssexe log_die(LOG_EXIT_USER,"service: ",name," was disabled, you can only stop it") ; logname = get_rstrlen_until(name,SS_LOG_SUFFIX) ; - if (logname > 0 && (!ss_resolve_cmp(&gares,string + pres->logassoc))) + if (logname > 0 && (!resolve_cmp(&gares, string + pres->logassoc, SERVICE_STRUCT))) { if (RELOAD > 1) log_die(LOG_EXIT_SYS,"-R signal is not allowed to a logger") ; if (sta.init) reverse = 1 ; @@ -308,16 +311,16 @@ int ssexec_start(int argc, char const *const *argv,char const *const *envp,ssexe if (reload) { reverse = 1 ; - if (!ss_resolve_graph_build(&graph_reload_cl,&genalloc_s(ss_resolve_t,&gares)[i],sares.s,reverse)) + if (!ss_resolve_graph_build(&graph_reload_cl,&genalloc_s(resolve_service_t,&gares)[i],sares.s,reverse)) log_dieusys(LOG_EXIT_SYS,"build services graph") ; } else if (init) { reverse = 0 ; - if (!ss_resolve_graph_build(&graph_init_cl,&genalloc_s(ss_resolve_t,&gares)[i],sares.s,reverse)) + if (!ss_resolve_graph_build(&graph_init_cl,&genalloc_s(resolve_service_t,&gares)[i],sares.s,reverse)) log_dieusys(LOG_EXIT_SYS,"build services graph") ; } - if (!ss_resolve_append(&nclassic,pres)) log_dieusys(LOG_EXIT_SYS,"append services selection with: ",name) ; + if (!resolve_append(&nclassic,wres)) log_dieusys(LOG_EXIT_SYS,"append services selection with: ",name) ; cl++ ; } else @@ -325,18 +328,19 @@ int ssexec_start(int argc, char const *const *argv,char const *const *envp,ssexe if (reload) { reverse = 1 ; - if (!ss_resolve_graph_build(&graph_reload_rc,&genalloc_s(ss_resolve_t,&gares)[i],sares.s,reverse)) + if (!ss_resolve_graph_build(&graph_reload_rc,&genalloc_s(resolve_service_t,&gares)[i],sares.s,reverse)) log_dieusys(LOG_EXIT_SYS,"build services graph") ; } else if (init) { reverse = 0 ; - if (!ss_resolve_graph_build(&graph_init_rc,&genalloc_s(ss_resolve_t,&gares)[i],sares.s,reverse)) + if (!ss_resolve_graph_build(&graph_init_rc,&genalloc_s(resolve_service_t,&gares)[i],sares.s,reverse)) log_dieusys(LOG_EXIT_SYS,"build services graph") ; } - if (!ss_resolve_append(&nrc,pres)) log_dieusys(LOG_EXIT_SYS,"append services selection with: ",name) ; + if (!resolve_append(&nrc,wres)) log_dieusys(LOG_EXIT_SYS,"append services selection with: ",name) ; rc++; } + free(wres) ; } if (cl) @@ -360,7 +364,7 @@ int ssexec_start(int argc, char const *const *argv,char const *const *envp,ssexe if (!svc_switch_to(info,SS_SWSRC)) log_dieu(LOG_EXIT_SYS,"switch classic service list of: ",info->treename.s," to source") ; - genalloc_deepfree(ss_resolve_t,&nclassic,ss_resolve_free) ; + resolve_deep_free(SERVICE_STRUCT, &nclassic) ; } if (rc) { @@ -376,12 +380,12 @@ int ssexec_start(int argc, char const *const *argv,char const *const *envp,ssexe if (!db_switch_to(info,envp,SS_SWSRC)) log_dieu(LOG_EXIT_SYS,"switch atomic services list of: ",info->treename.s," to source") ; } - genalloc_deepfree(ss_resolve_t,&nrc,ss_resolve_free) ; + resolve_deep_free(SERVICE_STRUCT, &nrc) ; } stralloc_free(&sares) ; stralloc_free(&sasta) ; - genalloc_deepfree(ss_resolve_t,&gares,ss_resolve_free) ; - ss_resolve_free(&res) ; + resolve_deep_free(SERVICE_STRUCT, &gares) ; + resolve_free(wres) ; return 0 ; } diff --git a/src/lib66/ssexec_stop.c b/src/lib66/ssexec_stop.c index e33b9f378d98c3bbd0dc0310171de477fa59cd48..66381ed77d1a64fd84803740ab88e401ff1d0567 100644 --- a/src/lib66/ssexec_stop.c +++ b/src/lib66/ssexec_stop.c @@ -28,6 +28,7 @@ #include <66/rc.h> #include <66/ssexec.h> #include <66/resolve.h> +#include <66/service.h> #include <66/state.h> static unsigned int DEADLINE = 0 ; @@ -46,7 +47,7 @@ int svc_down(ssexec_t *info, char const *const *envp) unsigned int reverse = 1 ; int r ; - if (genalloc_len(ss_resolve_t,&graph_unsup_cl.name)) + if (genalloc_len(resolve_service_t,&graph_unsup_cl.name)) { UNSUP = 1 ; r = ss_resolve_graph_publish(&graph_unsup_cl,reverse) ; @@ -83,7 +84,7 @@ int rc_down(ssexec_t *info, char const *const *envp) unsigned int reverse = 1 ; int r ; - if (genalloc_len(ss_resolve_t,&graph_unsup_rc.name)) + if (genalloc_len(resolve_service_t,&graph_unsup_rc.name)) { UNSUP = 1 ; r = ss_resolve_graph_publish(&graph_unsup_rc,reverse) ; @@ -125,9 +126,10 @@ int ssexec_stop(int argc, char const *const *argv,char const *const *envp,ssexec int cl, rc, sigopt ; stralloc sares = STRALLOC_ZERO ; - genalloc gares = GENALLOC_ZERO ; //ss_resolve_t - ss_resolve_t_ref pres ; - ss_resolve_t res = RESOLVE_ZERO ; + genalloc gares = GENALLOC_ZERO ; //resolve_service_t + resolve_service_t_ref pres ; + resolve_service_t res = RESOLVE_SERVICE_ZERO ; + resolve_wrapper_t_ref wres = resolve_set_struct(SERVICE_STRUCT, &res) ; ss_state_t sta = STATE_ZERO ; cl = rc = sigopt = 0 ; @@ -156,13 +158,13 @@ int ssexec_stop(int argc, char const *const *argv,char const *const *envp,ssexec if ((scandir_ok(info->scandir.s)) !=1 ) log_diesys(LOG_EXIT_SYS,"scandir: ", info->scandir.s," is not running") ; - if (!ss_resolve_pointo(&sares,info,SS_NOTYPE,SS_RESOLVE_SRC)) log_dieusys(LOG_EXIT_SYS,"set revolve pointer to source") ; + if (!sa_pointo(&sares,info,SS_NOTYPE,SS_RESOLVE_SRC)) log_dieusys(LOG_EXIT_SYS,"set revolve pointer to source") ; for (;*argv;argv++) { char const *name = *argv ; - if (!ss_resolve_check(sares.s,name)) log_info_return(LOG_EXIT_ZERO,name," is not enabled") ; - if (!ss_resolve_read(&res,sares.s,name)) log_dieusys(LOG_EXIT_SYS,"read resolve file of: ",name) ; + if (!resolve_check(sares.s,name)) log_info_return(LOG_EXIT_ZERO,name," is not enabled") ; + if (!resolve_read(wres,sares.s,name)) log_dieusys(LOG_EXIT_SYS,"read resolve file of: ",name) ; if (res.type == TYPE_MODULE) { if (!module_in_cmdline(&gares,&res,sares.s)) @@ -170,21 +172,21 @@ int ssexec_stop(int argc, char const *const *argv,char const *const *envp,ssexec } else { - if (!ss_resolve_append(&gares,&res)) + if (!resolve_append(&gares,wres)) log_dieusys(LOG_EXIT_SYS,"append resolve file of: ",name) ; } } - for (unsigned int i = 0 ; i < genalloc_len(ss_resolve_t,&gares) ; i++) + for (unsigned int i = 0 ; i < genalloc_len(resolve_service_t,&gares) ; i++) { int unsup = 0 , reverse = 1 ; - pres = &genalloc_s(ss_resolve_t,&gares)[i] ; + pres = &genalloc_s(resolve_service_t,&gares)[i] ; char const *string = pres->sa.s ; char const *name = string + pres->name ; char const *state = string + pres->state ; - if (!ss_state_check(state,name)) log_die(LOG_EXIT_USER,name," : is not initialized") ; - else if (!ss_state_read(&sta,state,name)) log_dieusys(LOG_EXIT_SYS,"read state file of: ",name) ; + if (!state_check(state,name)) log_die(LOG_EXIT_USER,name," : is not initialized") ; + else if (!state_read(&sta,state,name)) log_dieusys(LOG_EXIT_SYS,"read state file of: ",name) ; int logname = get_rstrlen_until(name,SS_LOG_SUFFIX) ; @@ -195,7 +197,7 @@ int ssexec_stop(int argc, char const *const *argv,char const *const *envp,ssexec } /** logger cannot be unsupervised alone */ - if (logname > 0 && (!ss_resolve_cmp(&gares,string + pres->logassoc))) + if (logname > 0 && (!resolve_cmp(&gares,string + pres->logassoc, SERVICE_STRUCT))) { if (UNSUP) log_die(LOG_EXIT_SYS,"logger detected - unsupervise request is not allowed") ; } @@ -206,12 +208,12 @@ int ssexec_stop(int argc, char const *const *argv,char const *const *envp,ssexec { if (unsup) { - if (!ss_resolve_graph_build(&graph_unsup_cl,&genalloc_s(ss_resolve_t,&gares)[i],sares.s,reverse)) + if (!ss_resolve_graph_build(&graph_unsup_cl,&genalloc_s(resolve_service_t,&gares)[i],sares.s,reverse)) log_dieusys(LOG_EXIT_SYS,"build services graph") ; - if (!ss_resolve_add_logger(&graph_unsup_cl.name,sares.s)) + if (!service_resolve_add_logger(&graph_unsup_cl.name,sares.s)) log_dieusys(LOG_EXIT_SYS,"append service selection with logger") ; } - if (!ss_resolve_graph_build(&graph_cl,&genalloc_s(ss_resolve_t,&gares)[i],sares.s,reverse)) + if (!ss_resolve_graph_build(&graph_cl,&genalloc_s(resolve_service_t,&gares)[i],sares.s,reverse)) log_dieusys(LOG_EXIT_SYS,"build services graph") ; cl++ ; } @@ -219,12 +221,12 @@ int ssexec_stop(int argc, char const *const *argv,char const *const *envp,ssexec { if (unsup) { - if (!ss_resolve_graph_build(&graph_unsup_rc,&genalloc_s(ss_resolve_t,&gares)[i],sares.s,reverse)) + if (!ss_resolve_graph_build(&graph_unsup_rc,&genalloc_s(resolve_service_t,&gares)[i],sares.s,reverse)) log_dieusys(LOG_EXIT_SYS,"build services graph") ; - if (!ss_resolve_add_logger(&graph_unsup_rc.name,sares.s)) + if (!service_resolve_add_logger(&graph_unsup_rc.name,sares.s)) log_dieusys(LOG_EXIT_SYS,"append service selection with logger") ; } - if (!ss_resolve_graph_build(&graph_rc,&genalloc_s(ss_resolve_t,&gares)[i],sares.s,reverse)) + if (!ss_resolve_graph_build(&graph_rc,&genalloc_s(resolve_service_t,&gares)[i],sares.s,reverse)) log_dieusys(LOG_EXIT_SYS,"build services graph") ; rc++; } @@ -260,8 +262,8 @@ int ssexec_stop(int argc, char const *const *argv,char const *const *envp,ssexec log_dieu(LOG_EXIT_SYS,"send signal to scandir: ", info->scandir.s) ; } stralloc_free(&sares) ; - ss_resolve_free(&res) ; - genalloc_deepfree(ss_resolve_t,&gares,ss_resolve_free) ; + resolve_free(wres) ; + resolve_deep_free(SERVICE_STRUCT, &gares) ; return 0 ; } diff --git a/src/lib66/ssexec_svctl.c b/src/lib66/ssexec_svctl.c index 9c347da8d62a8e681949baec15ccab85361a3644..d4d3ad7b125554b0d92bf6f5a2f5f9a8f751a9a2 100644 --- a/src/lib66/ssexec_svctl.c +++ b/src/lib66/ssexec_svctl.c @@ -44,6 +44,7 @@ #include <66/ssexec.h> #include <66/resolve.h> #include <66/state.h> +#include <66/service.h> unsigned int SV_DEADLINE = 3000 ; unsigned int DEATHSV = 5 ; @@ -212,33 +213,33 @@ static void write_state(ss_resolve_sig_t *svc) { if (svc->state <= 1) { - ss_state_setflag(&sta,SS_FLAGS_PID,svc->pid) ; - ss_state_setflag(&sta,SS_FLAGS_STATE,SS_FLAGS_TRUE) ; + state_setflag(&sta,SS_FLAGS_PID,svc->pid) ; + state_setflag(&sta,SS_FLAGS_STATE,SS_FLAGS_TRUE) ; } else { - ss_state_setflag(&sta,SS_FLAGS_PID,SS_FLAGS_FALSE) ; - ss_state_setflag(&sta,SS_FLAGS_STATE,SS_FLAGS_FALSE) ; + state_setflag(&sta,SS_FLAGS_PID,SS_FLAGS_FALSE) ; + state_setflag(&sta,SS_FLAGS_STATE,SS_FLAGS_FALSE) ; } } else { if (svc->state <=1) { - ss_state_setflag(&sta,SS_FLAGS_PID,SS_FLAGS_FALSE) ; - ss_state_setflag(&sta,SS_FLAGS_STATE,SS_FLAGS_FALSE) ; + state_setflag(&sta,SS_FLAGS_PID,SS_FLAGS_FALSE) ; + state_setflag(&sta,SS_FLAGS_STATE,SS_FLAGS_FALSE) ; } else { - ss_state_setflag(&sta,SS_FLAGS_PID,svc->pid) ; - ss_state_setflag(&sta,SS_FLAGS_STATE,SS_FLAGS_TRUE) ; + state_setflag(&sta,SS_FLAGS_PID,svc->pid) ; + state_setflag(&sta,SS_FLAGS_STATE,SS_FLAGS_TRUE) ; } } - ss_state_setflag(&sta,SS_FLAGS_RELOAD,SS_FLAGS_FALSE) ; - ss_state_setflag(&sta,SS_FLAGS_INIT,SS_FLAGS_FALSE) ; -// ss_state_setflag(&sta,SS_FLAGS_UNSUPERVISE,SS_FLAGS_FALSE) ; + state_setflag(&sta,SS_FLAGS_RELOAD,SS_FLAGS_FALSE) ; + state_setflag(&sta,SS_FLAGS_INIT,SS_FLAGS_FALSE) ; +// state_setflag(&sta,SS_FLAGS_UNSUPERVISE,SS_FLAGS_FALSE) ; log_trace("Write state file of: ",sv) ; - if (!ss_state_write(&sta,state,sv)) + if (!state_write(&sta,state,sv)) log_warnusys("write state file of: ",sv) ; } @@ -497,7 +498,8 @@ int ssexec_svctl(int argc, char const *const *argv,char const *const *envp,ssexe genalloc gakeep = GENALLOC_ZERO ; //type ss_resolve_sig stralloc sares = STRALLOC_ZERO ; ss_resolve_graph_t graph = RESOLVE_GRAPH_ZERO ; - ss_resolve_t res = RESOLVE_ZERO ; + resolve_service_t res = RESOLVE_SERVICE_ZERO ; + resolve_wrapper_t_ref wres = resolve_set_struct(SERVICE_STRUCT, &res) ; ss_state_t sta = STATE_ZERO ; char *sig = 0 ; @@ -540,15 +542,15 @@ int ssexec_svctl(int argc, char const *const *argv,char const *const *envp,ssexe if (argc < 1 || (SIGNAL < 0)) log_usage(usage_svctl) ; if (info->timeout) tsv = info->timeout ; if ((scandir_ok(info->scandir.s)) !=1 ) log_diesys(LOG_EXIT_SYS,"scandir: ", info->scandir.s," is not running") ; - if (!ss_resolve_pointo(&sares,info,SS_NOTYPE,SS_RESOLVE_SRC)) log_dieusys(LOG_EXIT_SYS,"set revolve pointer to source") ; + if (!sa_pointo(&sares,info,SS_NOTYPE,SS_RESOLVE_SRC)) log_dieusys(LOG_EXIT_SYS,"set revolve pointer to source") ; if (SIGNAL > SIGR) reverse = 1 ; for(;*argv;argv++) { char const *name = *argv ; int logname = 0 ; logname = get_rstrlen_until(name,SS_LOG_SUFFIX) ; - if (!ss_resolve_check(sares.s,name)) log_diesys(LOG_EXIT_SYS,"unknown service: ",name) ; - if (!ss_resolve_read(&res,sares.s,name)) log_dieusys(LOG_EXIT_SYS,"read resolve file of: ",name) ; + if (!resolve_check(sares.s,name)) log_diesys(LOG_EXIT_SYS,"unknown service: ",name) ; + if (!resolve_read(wres,sares.s,name)) log_dieusys(LOG_EXIT_SYS,"read resolve file of: ",name) ; if (res.type >= TYPE_BUNDLE) log_die(LOG_EXIT_SYS,name," has type ",get_key_by_enum(ENUM_TYPE,res.type)) ; if (SIGNAL == SIGR && logname < 0) reverse = 1 ; if (!ss_resolve_graph_build(&graph,&res,sares.s,reverse)) log_dieusys(LOG_EXIT_SYS,"build services graph") ; @@ -558,10 +560,10 @@ int ssexec_svctl(int argc, char const *const *argv,char const *const *envp,ssexe if (r < 0) log_die(LOG_EXIT_SYS,"cyclic dependencies detected") ; if (!r) log_dieusys(LOG_EXIT_SYS,"publish service graph") ; - for(unsigned int i = 0 ; i < genalloc_len(ss_resolve_t,&graph.sorted) ; i++) + for(unsigned int i = 0 ; i < genalloc_len(resolve_service_t,&graph.sorted) ; i++) { ss_resolve_sig_t sv_signal = RESOLVE_SIG_ZERO ; - sv_signal.res = genalloc_s(ss_resolve_t,&graph.sorted)[i] ; + sv_signal.res = genalloc_s(resolve_service_t,&graph.sorted)[i] ; char *string = sv_signal.res.sa.s ; char *svok = string + sv_signal.res.runat ; char *state = string + sv_signal.res.state ; @@ -569,8 +571,8 @@ int ssexec_svctl(int argc, char const *const *argv,char const *const *envp,ssexe size_t svoklen = strlen(svok) ; char file[svoklen + SS_NOTIFICATION_LEN + 1 + 1] ; memcpy(file,svok,svoklen) ; - if (!ss_state_check(state,string + sv_signal.res.name)) log_die(LOG_EXIT_SYS,"unitialized service: ",string + sv_signal.res.name) ; - if (!ss_state_read(&sta,state,string + sv_signal.res.name)) log_dieusys(LOG_EXIT_SYS,"read state of: ",string + sv_signal.res.name) ; + if (!state_check(state,string + sv_signal.res.name)) log_die(LOG_EXIT_SYS,"unitialized service: ",string + sv_signal.res.name) ; + if (!state_read(&sta,state,string + sv_signal.res.name)) log_dieusys(LOG_EXIT_SYS,"read state of: ",string + sv_signal.res.name) ; if (sta.init) log_die(LOG_EXIT_SYS,"unitialized service: ",string + sv_signal.res.name) ; if (!s6_svstatus_read(svok,&status)) log_dieusys(LOG_EXIT_SYS,"read status of: ",svok) ; isup = status.pid && !status.flagfinishing ; @@ -696,7 +698,7 @@ int ssexec_svctl(int argc, char const *const *argv,char const *const *envp,ssexe stralloc_free(&sares) ; ss_resolve_graph_free(&graph) ; genalloc_free(ss_resolve_sig_t,&gakeep) ; - ss_resolve_free(&res) ; + resolve_free(wres) ; return (!ret) ? 111 : 0 ; } diff --git a/src/lib66/ssexec_tree.c b/src/lib66/ssexec_tree.c index 8d1c1f787a3f3d17d1efd959c887e514dbd6a488..daa64a9c5ebcce56495392f798786a904ea069d4 100644 --- a/src/lib66/ssexec_tree.c +++ b/src/lib66/ssexec_tree.c @@ -40,6 +40,7 @@ #include <66/db.h> #include <66/enum.h> #include <66/state.h> +#include <66/service.h> #include <66/resolve.h> #include <s6/supervise.h> @@ -288,16 +289,17 @@ void create_tree(ssexec_t *info) char const *tree = info->tree.s, *treename = info->treename.s ; char dst[treelen + SS_SVDIRS_LEN + SS_DB_LEN + SS_SRC_LEN + 16 + 1] ; - ss_resolve_t res = RESOLVE_ZERO ; - ss_resolve_init(&res) ; + resolve_service_t res = RESOLVE_SERVICE_ZERO ; + resolve_wrapper_t_ref wres = resolve_set_struct(SERVICE_STRUCT, &res) ; + resolve_init(wres) ; auto_strings(dst, tree) ; newlen = treelen ; - res.name = ss_resolve_add_string(&res,SS_MASTER+1) ; - res.description = ss_resolve_add_string(&res,"inner bundle - do not use it") ; - res.tree = ss_resolve_add_string(&res,dst) ; - res.treename = ss_resolve_add_string(&res,treename) ; + res.name = resolve_add_string(wres,SS_MASTER+1) ; + res.description = resolve_add_string(wres,"inner bundle - do not use it") ; + res.tree = resolve_add_string(wres,dst) ; + res.treename = resolve_add_string(wres,treename) ; res.type = TYPE_BUNDLE ; res.disen = 1 ; @@ -310,12 +312,12 @@ void create_tree(ssexec_t *info) auto_create(dst, SS_RESOLVE, newlen) ; dst[newlen] = 0 ; log_trace("write resolve file of inner bundle") ; - if (!ss_resolve_write(&res,dst,SS_MASTER+1)) { + if (!resolve_write(wres,dst,SS_MASTER+1)) { - ss_resolve_free(&res) ; + resolve_free(wres) ; log_dieusys_nclean(LOG_EXIT_SYS,&cleanup,"write resolve file of inner bundle") ; } - ss_resolve_free(&res) ; + resolve_free(wres) ; char sym[newlen + 1 + SS_SYM_SVC_LEN + 1] ; char dstsym[newlen + SS_SVC_LEN + 1] ; @@ -509,24 +511,25 @@ void tree_enable_disable(ssexec_t *info, uint8_t action) } -void tree_modify_resolve(ss_resolve_t *res,ss_resolve_enum_t field,char const *regex,char const *by) +void tree_modify_resolve(resolve_service_t *res, resolve_service_enum_t field,char const *regex,char const *by) { log_flow() ; stralloc sa = STRALLOC_ZERO ; - ss_resolve_t modif = RESOLVE_ZERO ; + resolve_service_t modif = RESOLVE_SERVICE_ZERO ; + resolve_wrapper_t_ref wres = resolve_set_struct(SERVICE_STRUCT, &modif) ; - log_trace("modify field: ",ss_resolve_field_table[field].field," of service: ",res->sa.s + res->name) ; + log_trace("modify field: ", resolve_service_field_table[field].field," of service: ",res->sa.s + res->name) ; - if (!ss_resolve_copy(&modif,res)) + if (!service_resolve_copy(&modif,res)) log_dieu_nclean(LOG_EXIT_SYS,&cleanup,"copy resolve file of: ", res->sa.s + res->name) ; - if (!ss_resolve_put_field_to_sa(&sa,&modif, field)) - log_dieusys_nclean(LOG_EXIT_SYS,&cleanup,"get copy of field: ",ss_resolve_field_table[field].field) ; + if (!service_resolve_field_to_sa(&sa,&modif, field)) + log_dieusys_nclean(LOG_EXIT_SYS,&cleanup,"get copy of field: ",resolve_service_field_table[field].field) ; if (sa.len) { if (!sastr_replace(&sa,regex,by)) - log_dieu_nclean(LOG_EXIT_SYS,&cleanup,"replace field: ",ss_resolve_field_table[field].field) ; + log_dieu_nclean(LOG_EXIT_SYS,&cleanup,"replace field: ",resolve_service_field_table[field].field) ; if (!stralloc_0(&sa)) log_dieu_nclean(LOG_EXIT_SYS,&cleanup,"stralloc") ; @@ -534,15 +537,15 @@ void tree_modify_resolve(ss_resolve_t *res,ss_resolve_enum_t field,char const *r sa.len-- ; } - if (!ss_resolve_modify_field(&modif,field,sa.s)) - log_dieusys_nclean(LOG_EXIT_SYS,&cleanup,"modify field: ",ss_resolve_field_table[field].field) ; + if (!service_resolve_modify_field(&modif,field,sa.s)) + log_dieusys_nclean(LOG_EXIT_SYS,&cleanup,"modify field: ",resolve_service_field_table[field].field) ; - if (!ss_resolve_copy(res,&modif)) + if (!service_resolve_copy(res,&modif)) log_dieu_nclean(LOG_EXIT_SYS,&cleanup,"copy resolve file of: ",res->sa.s + res->name) ; stralloc_free(&sa) ; - ss_resolve_free(&modif) ; + resolve_free(wres) ; } void tree_remove(ssexec_t *info) @@ -643,7 +646,7 @@ static void tree_parse_options(tree_opts_t *opts, char const *str) opts->depends = TREE_SAOPTS.len ; if (!sastr_add_string(&TREE_SAOPTS, val)) - log_dienomem("stralloc") ; + log_die_nomem("stralloc") ; break ; @@ -651,7 +654,7 @@ static void tree_parse_options(tree_opts_t *opts, char const *str) opts->requiredby = TREE_SAOPTS.len ; if (!sastr_add_string(&TREE_SAOPTS, val)) - log_dienomem("stralloc") ; + log_die_nomem("stralloc") ; break ; @@ -659,7 +662,7 @@ static void tree_parse_options(tree_opts_t *opts, char const *str) opts->rename = TREE_SAOPTS.len ; if (!sastr_add_string(&TREE_SAOPTS, val)) - log_dienomem("stralloc") ; + log_die_nomem("stralloc") ; break ; @@ -729,7 +732,7 @@ int ssexec_tree(int argc, char const *const *argv,char const *const *envp,ssexec if (argc < 1) log_usage(usage_tree) ; // make create the default option - if (!current && !create && !allow && !deny && !enable && !disable && !remove && !snap && (opt.rename >= 0)) + if (!current && !create && !allow && !deny && !enable && !disable && !remove && !snap && (opts.rename >= 0)) create = 1 ; info->treename.len = 0 ; @@ -878,7 +881,8 @@ int ssexec_tree(int argc, char const *const *argv,char const *const *envp,ssexec if (snap) { stralloc salist = STRALLOC_ZERO ; - ss_resolve_t res = RESOLVE_ZERO ; + resolve_service_t res = RESOLVE_SERVICE_ZERO ; + resolve_wrapper_t_ref wres = resolve_set_struct(SERVICE_STRUCT, &res) ; char const *exclude[1] = { 0 } ; size_t syslen = info->base.len + SS_SYSTEM_LEN ; @@ -931,15 +935,15 @@ int ssexec_tree(int argc, char const *const *argv,char const *const *envp,ssexec char *name = salist.s + pos ; - if (!ss_resolve_read(&res,clone_res,name)) + if (!resolve_read(wres,clone_res,name)) log_dieusys_nclean(LOG_EXIT_SYS,&cleanup,"read resolve file of: ",src_resolve,"/",name) ; - tree_modify_resolve(&res,SS_RESOLVE_ENUM_RUNAT,tree,clone.s) ; - tree_modify_resolve(&res,SS_RESOLVE_ENUM_TREENAME,tree,clone.s) ; - tree_modify_resolve(&res,SS_RESOLVE_ENUM_TREE,tree,clone.s) ; - tree_modify_resolve(&res,SS_RESOLVE_ENUM_STATE,tree,clone.s) ; + tree_modify_resolve(&res,SERVICE_ENUM_RUNAT,tree,clone.s) ; + tree_modify_resolve(&res,SERVICE_ENUM_TREENAME,tree,clone.s) ; + tree_modify_resolve(&res,SERVICE_ENUM_TREE,tree,clone.s) ; + tree_modify_resolve(&res,SERVICE_ENUM_STATE,tree,clone.s) ; - if (!ss_resolve_write(&res,clone_res,name)) + if (!resolve_write(wres,clone_res,name)) log_dieusys_nclean(LOG_EXIT_SYS,&cleanup,"write resolve file of: ",src_resolve,"/",name) ; } @@ -973,15 +977,15 @@ int ssexec_tree(int argc, char const *const *argv,char const *const *envp,ssexec char *name = salist.s + pos ; - if (!ss_resolve_read(&res,clone_backup,name)) + if (!resolve_read(wres,clone_backup,name)) log_dieusys_nclean(LOG_EXIT_SYS,&cleanup,"read resolve file of: ",src_resolve_backup,"/",name) ; - tree_modify_resolve(&res,SS_RESOLVE_ENUM_RUNAT,tree,clone.s) ; - tree_modify_resolve(&res,SS_RESOLVE_ENUM_TREENAME,tree,clone.s) ; - tree_modify_resolve(&res,SS_RESOLVE_ENUM_TREE,tree,clone.s) ; - tree_modify_resolve(&res,SS_RESOLVE_ENUM_STATE,tree,clone.s) ; + tree_modify_resolve(&res,SERVICE_ENUM_RUNAT,tree,clone.s) ; + tree_modify_resolve(&res,SERVICE_ENUM_TREENAME,tree,clone.s) ; + tree_modify_resolve(&res,SERVICE_ENUM_TREE,tree,clone.s) ; + tree_modify_resolve(&res,SERVICE_ENUM_STATE,tree,clone.s) ; - if (!ss_resolve_write(&res,clone_backup,name)) + if (!resolve_write(wres,clone_backup,name)) log_dieusys_nclean(LOG_EXIT_SYS,&cleanup,"write resolve file of: ",src_resolve,"/",name) ; } // rename db @@ -997,7 +1001,7 @@ int ssexec_tree(int argc, char const *const *argv,char const *const *envp,ssexec } stralloc_free(&salist) ; - ss_resolve_free(&res) ; + resolve_free(wres) ; log_info("Cloned successfully: ",tree," to ",clone.s) ; } diff --git a/src/lib66/svc_init.c b/src/lib66/svc_init.c index a4642b20a6da1fbfc3489aa12ee8f438a933c5b0..a79cfc2410a13d6b2bea4df4bb58181216d0c3fa 100644 --- a/src/lib66/svc_init.c +++ b/src/lib66/svc_init.c @@ -59,19 +59,19 @@ int svc_init(ssexec_t *info,char const *src, genalloc *ga) if (!ftrigr_startf(&fifo, &deadline, &STAMP)) goto err ; - if (!ss_resolve_create_live(info)) { log_warnusys("create live state") ; goto err ; } + if (!create_live(info)) { log_warnusys("create live state") ; goto err ; } - for (i = 0 ; i < genalloc_len(ss_resolve_t,ga); i++) + for (i = 0 ; i < genalloc_len(resolve_service_t,ga); i++) { logname = 0 ; - char *string = genalloc_s(ss_resolve_t,ga)[i].sa.s ; - char *name = string + genalloc_s(ss_resolve_t,ga)[i].name ; - char *state = string + genalloc_s(ss_resolve_t,ga)[i].state ; - if (s6_svc_ok(string + genalloc_s(ss_resolve_t,ga)[i].runat)) + char *string = genalloc_s(resolve_service_t,ga)[i].sa.s ; + char *name = string + genalloc_s(resolve_service_t,ga)[i].name ; + char *state = string + genalloc_s(resolve_service_t,ga)[i].state ; + if (s6_svc_ok(string + genalloc_s(resolve_service_t,ga)[i].runat)) { log_info("Initialization aborted -- ",name," already initialized") ; log_trace("Write state file of: ",name) ; - if (!ss_state_write(&sta,state,name)) + if (!state_write(&sta,state,name)) { log_warnusys("write state file of: ",name) ; goto err ; @@ -79,7 +79,7 @@ int svc_init(ssexec_t *info,char const *src, genalloc *ga) continue ; } logname = get_rstrlen_until(name,SS_LOG_SUFFIX) ; - if (logname > 0) name = string + genalloc_s(ss_resolve_t,ga)[i].logassoc ; + if (logname > 0) name = string + genalloc_s(resolve_service_t,ga)[i].logassoc ; namelen = strlen(name) ; srclen = strlen(src) ; @@ -89,13 +89,13 @@ int svc_init(ssexec_t *info,char const *src, genalloc *ga) memcpy(svsrc + srclen + 1,name,namelen) ; svsrc[srclen + 1 + namelen] = 0 ; - if (logname > 0) svscanlen = strlen(string + genalloc_s(ss_resolve_t,ga)[i].runat) - SS_LOG_SUFFIX_LEN ; - else svscanlen = strlen(string + genalloc_s(ss_resolve_t,ga)[i].runat) ; + if (logname > 0) svscanlen = strlen(string + genalloc_s(resolve_service_t,ga)[i].runat) - SS_LOG_SUFFIX_LEN ; + else svscanlen = strlen(string + genalloc_s(resolve_service_t,ga)[i].runat) ; char svscan[svscanlen + 6 + 1] ; - memcpy(svscan,string + genalloc_s(ss_resolve_t,ga)[i].runat,svscanlen) ; + memcpy(svscan,string + genalloc_s(resolve_service_t,ga)[i].runat,svscanlen) ; svscan[svscanlen] = 0 ; - log_trace("init service: ", string + genalloc_s(ss_resolve_t,ga)[i].name) ; + log_trace("init service: ", string + genalloc_s(resolve_service_t,ga)[i].name) ; /** if logger was created do not pass here to avoid to erase * the fifo of the logger*/ if (!scan_mode(svscan,S_IFDIR)) @@ -109,8 +109,8 @@ int svc_init(ssexec_t *info,char const *src, genalloc *ga) } /** if logger you need to copy again the real path */ - svscanlen = strlen(string + genalloc_s(ss_resolve_t,ga)[i].runat) ; - memcpy(svscan,string + genalloc_s(ss_resolve_t,ga)[i].runat,svscanlen) ; + svscanlen = strlen(string + genalloc_s(resolve_service_t,ga)[i].runat) ; + memcpy(svscan,string + genalloc_s(resolve_service_t,ga)[i].runat,svscanlen) ; svscan[svscanlen] = 0 ; /** if logger and the reload was asked the folder xxx/log doesn't exist * check it and create again if doesn't exist */ @@ -131,7 +131,7 @@ int svc_init(ssexec_t *info,char const *src, genalloc *ga) memcpy(svscan + svscanlen, "/down", 5) ; svscan[svscanlen + 5] = 0 ; - if (!genalloc_s(ss_resolve_t,ga)[i].down) + if (!genalloc_s(resolve_service_t,ga)[i].down) { if (!sastr_add_string(&sadown,svscan)) { @@ -183,14 +183,14 @@ int svc_init(ssexec_t *info,char const *src, genalloc *ga) if (unlink(sadown.s + pos) < 0 && errno != ENOENT) goto err ; } - for (pos = 0 ; pos < genalloc_len(ss_resolve_t,ga) ; pos++) + for (pos = 0 ; pos < genalloc_len(resolve_service_t,ga) ; pos++) { - char const *string = genalloc_s(ss_resolve_t,ga)[pos].sa.s ; - char const *name = string + genalloc_s(ss_resolve_t,ga)[pos].name ; - char const *state = string + genalloc_s(ss_resolve_t,ga)[pos].state ; + char const *string = genalloc_s(resolve_service_t,ga)[pos].sa.s ; + char const *name = string + genalloc_s(resolve_service_t,ga)[pos].name ; + char const *state = string + genalloc_s(resolve_service_t,ga)[pos].state ; log_trace("Write state file of: ",name) ; - if (!ss_state_write(&sta,state,name)) + if (!state_write(&sta,state,name)) { log_warnusys("write state file of: ",name) ; goto err ; diff --git a/src/lib66/svc_send.c b/src/lib66/svc_send.c index 233b253efc5a5a108b5d0d89d1090ac728a3cf6e..d3c54beebaa4d71ccf960c8c665236e78dac6df4 100644 --- a/src/lib66/svc_send.c +++ b/src/lib66/svc_send.c @@ -28,15 +28,15 @@ int svc_send(ssexec_t *info,genalloc *ga,char const *sig,char const *const *envp log_flow() ; size_t i = 0 ; - int nargc = 3 + genalloc_len(ss_resolve_t,ga) ; + int nargc = 3 + genalloc_len(resolve_service_t,ga) ; char const *newargv[nargc] ; unsigned int m = 0 ; newargv[m++] = "fake_name" ; newargv[m++] = sig ; - for (; i < genalloc_len(ss_resolve_t,ga) ; i++) - newargv[m++] = genalloc_s(ss_resolve_t,ga)[i].sa.s + genalloc_s(ss_resolve_t,ga)[i].name ; + for (; i < genalloc_len(resolve_service_t,ga) ; i++) + newargv[m++] = genalloc_s(resolve_service_t,ga)[i].sa.s + genalloc_s(resolve_service_t,ga)[i].name ; newargv[m++] = 0 ; diff --git a/src/lib66/svc_unsupervise.c b/src/lib66/svc_unsupervise.c index c406707624a94170d97afb7bd86835cd57a816a7..5d966b46d49a4f14cf29ac5f0f95173e71a3af69 100644 --- a/src/lib66/svc_unsupervise.c +++ b/src/lib66/svc_unsupervise.c @@ -33,7 +33,7 @@ int svc_unsupervise(ssexec_t *info,genalloc *ga,char const *sig,char const *cons size_t i = 0 ; ss_state_t sta = STATE_ZERO ; - ss_resolve_t_ref pres ; + resolve_service_t_ref pres ; stralloc sares = STRALLOC_ZERO ; if (!svc_send(info,ga,sig,envp)) @@ -42,24 +42,24 @@ int svc_unsupervise(ssexec_t *info,genalloc *ga,char const *sig,char const *cons goto err ; } - for (; i < genalloc_len(ss_resolve_t,ga) ; i++) + for (; i < genalloc_len(resolve_service_t,ga) ; i++) { - char const *string = genalloc_s(ss_resolve_t,ga)[i].sa.s ; - log_trace("delete directory service: ",string + genalloc_s(ss_resolve_t,ga)[i].runat) ; - if (rm_rf(string + genalloc_s(ss_resolve_t,ga)[i].runat) < 0) + char const *string = genalloc_s(resolve_service_t,ga)[i].sa.s ; + log_trace("delete directory service: ",string + genalloc_s(resolve_service_t,ga)[i].runat) ; + if (rm_rf(string + genalloc_s(resolve_service_t,ga)[i].runat) < 0) { - log_warnusys("delete: ",string + genalloc_s(ss_resolve_t,ga)[i].runat) ; + log_warnusys("delete: ",string + genalloc_s(resolve_service_t,ga)[i].runat) ; goto err ; } } - if (!ss_resolve_pointo(&sares,info,SS_NOTYPE,SS_RESOLVE_SRC)) + if (!sa_pointo(&sares,info,SS_NOTYPE,SS_RESOLVE_SRC)) { log_warnusys("set revolve pointer to source") ; goto err ; } - for (i = 0 ; i < genalloc_len(ss_resolve_t,ga) ; i++) + for (i = 0 ; i < genalloc_len(resolve_service_t,ga) ; i++) { - pres = &genalloc_s(ss_resolve_t,ga)[i] ; + pres = &genalloc_s(resolve_service_t,ga)[i] ; char const *string = pres->sa.s ; char const *name = string + pres->name ; char const *state = string + pres->state ; @@ -67,19 +67,19 @@ int svc_unsupervise(ssexec_t *info,genalloc *ga,char const *sig,char const *cons if (!pres->disen) { log_trace("Delete resolve file of: ",name) ; - ss_resolve_rmfile(sares.s,name) ; + resolve_rmfile(sares.s,name) ; log_trace("Delete state file of: ",name) ; - ss_state_rmfile(state,name) ; + state_rmfile(state,name) ; } else { - ss_state_setflag(&sta,SS_FLAGS_RELOAD,SS_FLAGS_FALSE) ; - ss_state_setflag(&sta,SS_FLAGS_INIT,SS_FLAGS_TRUE) ; - // ss_state_setflag(&sta,SS_FLAGS_UNSUPERVISE,SS_FLAGS_FALSE) ; - ss_state_setflag(&sta,SS_FLAGS_STATE,SS_FLAGS_FALSE) ; - ss_state_setflag(&sta,SS_FLAGS_PID,SS_FLAGS_FALSE) ; + state_setflag(&sta,SS_FLAGS_RELOAD,SS_FLAGS_FALSE) ; + state_setflag(&sta,SS_FLAGS_INIT,SS_FLAGS_TRUE) ; + // state_setflag(&sta,SS_FLAGS_UNSUPERVISE,SS_FLAGS_FALSE) ; + state_setflag(&sta,SS_FLAGS_STATE,SS_FLAGS_FALSE) ; + state_setflag(&sta,SS_FLAGS_PID,SS_FLAGS_FALSE) ; log_trace("Write state file of: ",name) ; - if (!ss_state_write(&sta,state,name)) + if (!state_write(&sta,state,name)) { log_warnusys("write state file of: ",name) ; goto err ; diff --git a/src/lib66/tree_copy_tmp.c b/src/lib66/tree_copy_tmp.c index 35e6ed1353180f8ccb33b1bfd10de8ea33523f93..9d17c5146f6a71232434553da8f01e9b84e65b16 100644 --- a/src/lib66/tree_copy_tmp.c +++ b/src/lib66/tree_copy_tmp.c @@ -28,6 +28,7 @@ #include <66/enum.h> #include <66/utils.h> #include <66/ssexec.h> +#include <66/resolve.h> void err(unsigned int *e, unsigned int msg,char const *resolve,char const *swap, char const *svdir) { @@ -67,12 +68,12 @@ int tree_copy_tmp(char const *workdir, ssexec_t *info) /** svc */ if (rm_rf(svdir) < 0) { - if (!ss_resolve_pointo(&saresolve,info,TYPE_CLASSIC,SS_RESOLVE_SRC)) + if (!sa_pointo(&saresolve,info,TYPE_CLASSIC,SS_RESOLVE_SRC)) { err(&e,0,saresolve.s,swap.s,svdir) ; goto err ; } - if (!ss_resolve_pointo(&swap,info,TYPE_CLASSIC,SS_RESOLVE_BACK)) + if (!sa_pointo(&swap,info,TYPE_CLASSIC,SS_RESOLVE_BACK)) { err(&e,1,saresolve.s,swap.s,svdir) ; goto err ; @@ -91,12 +92,12 @@ int tree_copy_tmp(char const *workdir, ssexec_t *info) svdir[svdirlen + SS_DB_LEN] = 0 ; if (rm_rf(svdir) < 0) { - if (!ss_resolve_pointo(&saresolve,info,TYPE_LONGRUN,SS_RESOLVE_SRC)) + if (!sa_pointo(&saresolve,info,TYPE_LONGRUN,SS_RESOLVE_SRC)) { err(&e,0,saresolve.s,swap.s,svdir) ; goto err ; } - if (!ss_resolve_pointo(&swap,info,TYPE_LONGRUN,SS_RESOLVE_BACK)) + if (!sa_pointo(&swap,info,TYPE_LONGRUN,SS_RESOLVE_BACK)) { err(&e,1,saresolve.s,swap.s,svdir) ; goto err ; @@ -116,7 +117,7 @@ int tree_copy_tmp(char const *workdir, ssexec_t *info) if (rm_rf(svdir) < 0) { - if (!ss_resolve_pointo(&saresolve,info,SS_NOTYPE,SS_RESOLVE_SRC)) + if (!sa_pointo(&saresolve,info,SS_NOTYPE,SS_RESOLVE_SRC)) { err(&e,0,saresolve.s,swap.s,svdir) ; goto err ; @@ -125,7 +126,7 @@ int tree_copy_tmp(char const *workdir, ssexec_t *info) if (!stralloc_cats(&saresolve,SS_RESOLVE)) log_warnsys_return(LOG_EXIT_ZERO,"tree_copy_tmp") ; if (!stralloc_0(&saresolve)) log_warnsys_return(LOG_EXIT_ZERO,"tree_copy_tmp") ; - if (!ss_resolve_pointo(&swap,info,SS_NOTYPE,SS_RESOLVE_BACK)) + if (!sa_pointo(&swap,info,SS_NOTYPE,SS_RESOLVE_BACK)) { err(&e,1,saresolve.s,swap.s,svdir) ; goto err ; @@ -147,12 +148,12 @@ int tree_copy_tmp(char const *workdir, ssexec_t *info) if (!hiercopy(workdir,svdir)) { - if (!ss_resolve_pointo(&saresolve,info,SS_NOTYPE,SS_RESOLVE_SRC)) + if (!sa_pointo(&saresolve,info,SS_NOTYPE,SS_RESOLVE_SRC)) { err(&e,0,saresolve.s,swap.s,svdir) ; goto err ; } - if (!ss_resolve_pointo(&swap,info,SS_NOTYPE,SS_RESOLVE_BACK)) + if (!sa_pointo(&swap,info,SS_NOTYPE,SS_RESOLVE_BACK)) { err(&e,1,saresolve.s,swap.s,svdir) ; goto err ; diff --git a/src/lib66/tree_seed.c b/src/lib66/tree_seed.c index 7e0a4f15cc85cdd826102aaaf672fe35743f552e..28b96e37f22e305f00673c321e13ced85c35316d 100644 --- a/src/lib66/tree_seed.c +++ b/src/lib66/tree_seed.c @@ -354,8 +354,8 @@ int tree_seed_ismandatory(tree_seed_t *seed, uint8_t check_service) char *s = sv.s + pos ; - // ss_resolve_src already warn user - if (!ss_resolve_src_path(&sasrc,s, uid, 0)) { + // service_frontend_src already warn user + if (!service_frontend_path(&sasrc,s, uid, 0)) { stralloc_free(&sasrc) ; goto err ;