diff --git a/src/lib66/environ/env_compute.c b/src/lib66/environ/env_compute.c index fb2399e6e471b766bc4b48f8f9c89eb306a725d2..3d7c6b77c99e2369a3f14d38c5ff9c4df4bfb2da 100644 --- a/src/lib66/environ/env_compute.c +++ b/src/lib66/environ/env_compute.c @@ -21,21 +21,23 @@ #include <skalibs/stralloc.h> #include <66/environ.h> +#include <66/service.h> #include <66/parser.h> -int env_compute(stralloc *result,sv_alltype *sv, uint8_t conf) +int env_compute(stralloc *result, resolve_service_t *res) { log_flow() ; int r ; - char *version = keep.s + sv->cname.version ; - char *svconf = keep.s + sv->srconf ; - char *name = keep.s + sv->cname.name ; + uint32_t conf = res->environ.env_overwrite ; + char *version = res->sa.s + res->version ; + char *svconf = res->sa.s + res->environ.envdir ; + char *name = res->sa.s + res->name ; size_t svconf_len = strlen(svconf), version_len = strlen(version) ; char src[svconf_len + 1 + version_len + 1] ; - auto_strings(src,svconf,"/",version) ; + auto_strings(src, svconf, "/", version) ; /** previous version, this is the current version before * the switch with env_make_symlink() */ @@ -45,40 +47,40 @@ int env_compute(stralloc *result,sv_alltype *sv, uint8_t conf) /** store current configure file version before the switch * of the symlink with the env_make_symlink() function */ - r = env_find_current_version(&pversion,svconf) ; + r = env_find_current_version(&pversion, svconf) ; if (r == -1) - log_warnu_return(LOG_EXIT_ZERO,"find previous configuration file version") ; + log_warnu_return(LOG_EXIT_ZERO, "find previous configuration file version") ; - if(!env_make_symlink(sv)) + if(!env_make_symlink(res)) return 0 ; /** !r means that previous version doesn't exist, no need to import anything */ if (r && !conf) { - r = env_find_current_version(&fversion,svconf) ; + r = env_find_current_version(&fversion, svconf) ; /** should never happen, the env_make_symlink() die in case of error */ if (r <= 0) - log_warnu_return(LOG_EXIT_ZERO,"find current configuration file version") ; + log_warnu_return(LOG_EXIT_ZERO, "find current configuration file version") ; char pv[pversion.len + 1] ; char fv[fversion.len + 1] ; - if (!ob_basename(pv,pversion.s)) - log_warnu_return(LOG_EXIT_ZERO,"get basename of: ",pversion.s) ; + if (!ob_basename(pv, pversion.s)) + log_warnu_return(LOG_EXIT_ZERO, "get basename of: ", pversion.s) ; - if (!ob_basename(fv,fversion.s)) - log_warnu_return(LOG_EXIT_ZERO,"get basename of: ",fversion.s) ; + if (!ob_basename(fv, fversion.s)) + log_warnu_return(LOG_EXIT_ZERO, "get basename of: ", fversion.s) ; - if (!env_import_version_file(name,svconf,pv,fv,sv->cname.itype)) + if (!env_import_version_file(name, svconf, pv, fv, res->type)) return 0 ; } if (!auto_stra(result, \ "## [STARTWARN]\n## DO NOT MODIFY THIS FILE, IT OVERWRITTEN AT UPGRADE TIME.\n## Uses \'66-env ", \ - name,"\' command instead.\n## Or make a copy of this file at ",src,"/",name, \ - " and modify it.\n## [ENDWARN]\n",sv->saenv.s)) + name,"\' command instead.\n## Or make a copy of this file at ", src, "/", name, \ + " and modify it.\n## [ENDWARN]\n", res->sa.s + res->environ.env)) log_warnu_return(LOG_EXIT_ZERO,"stralloc") ; stralloc_free(&pversion) ; diff --git a/src/lib66/environ/env_make_symlink.c b/src/lib66/environ/env_make_symlink.c index e47a5e4aab3cbe9a57e21931647680fc11588689..ca4c0857ff5ab7282f088b9e4a31d0cc06773813 100644 --- a/src/lib66/environ/env_make_symlink.c +++ b/src/lib66/environ/env_make_symlink.c @@ -23,14 +23,15 @@ #include <66/environ.h> #include <66/parser.h> #include <66/constants.h> +#include <66/service.h> -int env_make_symlink(sv_alltype *sv) +int env_make_symlink(resolve_service_t *res) { log_flow() ; /** svconf-> /etc/66/conf/<service_name> */ - char *svconf = keep.s + sv->srconf ; - char *version = keep.s + sv->cname.version ; + char *svconf = res->sa.s + res->environ.envdir ; + char *version = res->sa.s + res->version ; size_t version_len = strlen(version), svconf_len = strlen(svconf) ; char sym_version[svconf_len + SS_SYM_VERSION_LEN + 1] ; diff --git a/src/lib66/environ/env_prepare_for_write.c b/src/lib66/environ/env_prepare_for_write.c index 0a5082cb7c1735a7590a4ba5966a8c02c8ca8f64..49063b782d82805273a9bc87abc511df05c5b84c 100644 --- a/src/lib66/environ/env_prepare_for_write.c +++ b/src/lib66/environ/env_prepare_for_write.c @@ -23,30 +23,27 @@ #include <66/environ.h> #include <66/constants.h> +#include <66/service.h> #include <66/parser.h> - -int env_prepare_for_write(stralloc *name, stralloc *dst, stralloc *contents, sv_alltype *sv,uint8_t conf) +int env_prepare_for_write(stralloc *dst, stralloc *contents, resolve_service_t *res) { log_flow() ; - char *svconf = keep.s + sv->srconf ; - size_t svconf_len = strlen(svconf) ; - char sym[svconf_len + SS_SYM_VERSION_LEN + 1] ; + char *conf = res->sa.s + res->environ.envdir ; + size_t conflen = strlen(conf) ; + char sym[conflen + SS_SYM_VERSION_LEN + 1] ; - auto_strings(sym,svconf,SS_SYM_VERSION) ; + auto_strings(sym, conf, SS_SYM_VERSION) ; - if (!env_compute(contents,sv,conf)) - log_warnu_return(LOG_EXIT_ZERO,"compute environment") ; + if (!env_compute(contents, res)) + log_warnu_return(LOG_EXIT_ZERO, "compute environment") ; if (sareadlink(dst, sym) == -1) - log_warnusys_return(LOG_EXIT_ZERO,"read link of: ",sym) ; + log_warnusys_return(LOG_EXIT_ZERO, "read link of: ", sym) ; if (!stralloc_0(dst)) - log_warnusys_return(LOG_EXIT_ZERO,"stralloc") ; - - if (!auto_stra(name,".",keep.s + sv->cname.name)) - log_warnusys_return(LOG_EXIT_ZERO,"stralloc") ; + log_warnusys_return(LOG_EXIT_ZERO, "stralloc") ; return 1 ; } diff --git a/src/lib66/environ/env_resolve_conf.c b/src/lib66/environ/env_resolve_conf.c index 842814b4db575cc19b4cc90b7491df65fd6463e8..26317898a17cf15ad75092360127d24029639ab5 100644 --- a/src/lib66/environ/env_resolve_conf.c +++ b/src/lib66/environ/env_resolve_conf.c @@ -13,7 +13,6 @@ */ #include <sys/types.h> -#include <string.h> #include <oblibs/log.h> #include <oblibs/string.h>