diff --git a/src/include/66/parser.h b/src/include/66/parser.h index 505b782c5cb4fc49e2c8b8892ef8c52bd596fa0c..0119b89be4a370619c79f72472d85f640f826a3f 100644 --- a/src/include/66/parser.h +++ b/src/include/66/parser.h @@ -34,7 +34,7 @@ extern stralloc keep ; extern stralloc deps ; -extern genalloc gadeps ; +//extern genalloc gadeps ; extern genalloc gasv ; typedef enum actions_e actions_t, *actions_t_ref ; @@ -293,7 +293,7 @@ extern int write_exec(sv_alltype *sv, sv_exec *exec,char const *name,char const extern int write_uint(char const *dst, char const *name, uint32_t ui) ; extern int write_logger(sv_alltype *sv, sv_execlog *log,char const *name, char const *dst, int mode, uint8_t force) ; extern int write_consprod(sv_alltype *sv,char const *prodname,char const *consname,char const *proddst,char const *consdst) ; -extern int write_dependencies(unsigned int nga,unsigned int idga,char const *dst,char const *filename, genalloc *ga) ; +extern int write_dependencies(unsigned int nga,unsigned int idga,char const *dst,char const *filename) ; extern int write_env(char const *name,stralloc *sa,char const *dst) ; #endif diff --git a/src/lib66/parser_enabled.c b/src/lib66/parser_enabled.c index 0ab69cd8d909d05ceeabf8e6c26a12a47c6ef5bb..4fb613009a41bc819a334f97c7fac7bad1e0f081 100644 --- a/src/lib66/parser_enabled.c +++ b/src/lib66/parser_enabled.c @@ -100,6 +100,29 @@ int parse_service_deps(ssexec_t *info,stralloc *parsed_list, sv_alltype *sv_befo stralloc newsv = STRALLOC_ZERO ; if (sv_before->cname.nga) { + + size_t id = sv_before->cname.idga, nid = sv_before->cname.nga ; + for (;nid; id += strlen(deps.s + id) + 1, nid--) + { + newsv.len = 0 ; + if (sv_before->cname.itype != BUNDLE) + { + VERBO3 strerr_warni4x("Service : ",sv, " depends on : ",deps.s+id) ; + }else VERBO3 strerr_warni5x("Bundle : ",sv, " contents : ",deps.s+id," as service") ; + dname = deps.s+id ; + if (!ss_resolve_src_path(&newsv,dname,info)) + { + VERBO3 strerr_warnwu2x("resolve source path of: ",dname) ; + stralloc_free(&newsv) ; + return 0 ; + } + if (!parse_service_before(info,parsed_list,newsv.s,nbsv,sasv,force,&exist)) + { + stralloc_free(&newsv) ; + return 0 ; + } + } + /* for (int i = 0;i < sv_before->cname.nga;i++) { newsv.len = 0 ; @@ -120,7 +143,7 @@ int parse_service_deps(ssexec_t *info,stralloc *parsed_list, sv_alltype *sv_befo stralloc_free(&newsv) ; return 0 ; } - } + }*/ } else VERBO3 strerr_warni2x(sv,": haven't dependencies") ; stralloc_free(&newsv) ; @@ -164,6 +187,7 @@ int parse_service_before(ssexec_t *info,stralloc *parsed_list, char const *sv,un memcpy(svpath,svsrc,svsrclen) ; memcpy(svpath + svsrclen,svname,svnamelen) ; + svpath[svsrclen + svnamelen] = 0 ; if (sastr_cmp(parsed_list,svpath) >= 0) { diff --git a/src/lib66/parser_utils.c b/src/lib66/parser_utils.c index 5c57d87ed1430f3a673221271a697d3b98f7468f..af65e3bd6b760d2e1fa8fdeed1d0fe69a2ccff7a 100644 --- a/src/lib66/parser_utils.c +++ b/src/lib66/parser_utils.c @@ -44,7 +44,7 @@ stralloc keep = STRALLOC_ZERO ;//sv_alltype data stralloc deps = STRALLOC_ZERO ;//sv_name depends -genalloc gadeps = GENALLOC_ZERO ;//unsigned int, pos in deps +//genalloc gadeps = GENALLOC_ZERO ;//unsigned int, pos in deps genalloc gasv = GENALLOC_ZERO ;//sv_alltype general /********************************** @@ -93,7 +93,7 @@ void freed_parser(void) { stralloc_free(&keep) ; stralloc_free(&deps) ; - genalloc_free(unsigned int,&gadeps) ; +// genalloc_free(unsigned int,&gadeps) ; for (unsigned int i = 0 ; i < genalloc_len(sv_alltype,&gasv) ; i++) sv_alltype_free(&genalloc_s(sv_alltype,&gasv)[i]) ; } @@ -643,10 +643,9 @@ int keep_common(sv_alltype *service,keynocheck *nocheck,int svtype) return 0 ; } if (!get_clean_val(nocheck)) return 0 ; - service->cname.idga = genalloc_len(unsigned int,&gadeps) ; + service->cname.idga = deps.len ; for (;pos < *chlen; pos += strlen(chval + pos)+1) { - if (!genalloc_append(unsigned int,&gadeps,&deps.len)) retstralloc(0,"parse_common") ; if (!stralloc_catb(&deps,chval + pos,strlen(chval + pos) + 1)) retstralloc(0,"parse_common") ; service->cname.nga++ ; } @@ -658,10 +657,9 @@ int keep_common(sv_alltype *service,keynocheck *nocheck,int svtype) return 0 ; } if (!get_clean_val(nocheck)) return 0 ; - service->cname.idga = genalloc_len(unsigned int,&gadeps) ; + service->cname.idga = deps.len ; for (;pos < *chlen; pos += strlen(chval + pos) + 1) { - if (!genalloc_append(unsigned int,&gadeps,&deps.len)) retstralloc(0,"parse_common") ; if (!stralloc_catb(&deps,chval + pos,strlen(chval + pos) + 1)) retstralloc(0,"parse_common") ; service->cname.nga++ ; } @@ -762,10 +760,9 @@ int keep_logger(sv_execlog *log,keynocheck *nocheck) break ; case DEPENDS: if (!get_clean_val(nocheck)) return 0 ; - log->idga = genalloc_len(unsigned int,&gadeps) ; + log->idga = deps.len ; for (;pos < *chlen; pos += strlen(chval + pos) + 1) { - if (!genalloc_append(unsigned int,&gadeps,&deps.len)) retstralloc(0,"parse_logger") ; if (!stralloc_catb(&deps,chval + pos,strlen(chval + pos) + 1)) retstralloc(0,"parse_logger") ; log->nga++ ; } diff --git a/src/lib66/parser_write.c b/src/lib66/parser_write.c index 5705daace04245d29934ffa794f872fc5a842cc7..fe92293d697e58fc05e4a5ae27bf47fd1c0834e7 100644 --- a/src/lib66/parser_write.c +++ b/src/lib66/parser_write.c @@ -253,7 +253,7 @@ int write_longrun(sv_alltype *sv,char const *dst, uint8_t force, uint8_t conf) } /** dependencies */ - if (!write_dependencies(sv->cname.nga,sv->cname.idga, dst, "dependencies", &gadeps)) + if (!write_dependencies(sv->cname.nga,sv->cname.idga, dst, "dependencies")) { VERBO3 strerr_warnwu3x("write: ",dst,"/dependencies") ; return 0 ; @@ -287,7 +287,7 @@ int write_oneshot(sv_alltype *sv,char const *dst,uint8_t conf) } } - if (!write_dependencies(sv->cname.nga,sv->cname.idga, dst, "dependencies", &gadeps)) + if (!write_dependencies(sv->cname.nga,sv->cname.idga, dst, "dependencies")) { VERBO3 strerr_warnwu3x("write: ",dst,"/dependencies") ; return 0 ; @@ -305,7 +305,7 @@ int write_bundle(sv_alltype *sv, char const *dst) return 0 ; } /** contents file*/ - if (!write_dependencies(sv->cname.nga,sv->cname.idga, dst, "contents", &gadeps)) + if (!write_dependencies(sv->cname.nga,sv->cname.idga, dst, "contents")) { VERBO3 strerr_warnwu3x("write: ",dst,"/contents") ; return 0 ; @@ -389,7 +389,7 @@ int write_logger(sv_alltype *sv, sv_execlog *log,char const *name, char const *d /** dependencies*/ if (log->nga) { - if (!write_dependencies(log->nga,log->idga,ddst.s,"dependencies",&gadeps)) + if (!write_dependencies(log->nga,log->idga,ddst.s,"dependencies")) { VERBO3 strerr_warnwu3x("write: ",ddst.s,"/dependencies") ; return 0 ; @@ -876,17 +876,22 @@ int write_exec(sv_alltype *sv, sv_exec *exec,char const *file,char const *dst,in return 1 ; } -int write_dependencies(unsigned int nga,unsigned int idga,char const *dst,char const *filename, genalloc *ga) +int write_dependencies(unsigned int nga,unsigned int idga,char const *dst,char const *filename) { stralloc contents = STRALLOC_ZERO ; - stralloc namedeps = STRALLOC_ZERO ; - - for (unsigned int i = 0; i < nga; i++) + //stralloc namedeps = STRALLOC_ZERO ; + size_t id = idga, nid = nga ; + for (;nid; id += strlen(deps.s + id) + 1, nid--) + { + if (!stralloc_cats(&contents,deps.s + id) || + !stralloc_cats(&contents,"\n")) retstralloc(0,"write_dependencies") ; + } + /*for (unsigned int i = 0; i < nga; i++) { if (!stralloc_obreplace(&namedeps,deps.s+genalloc_s(unsigned int,ga)[idga+i])) return 0 ; if (!stralloc_cats(&contents,namedeps.s)) retstralloc(0,"write_dependencies") ; - if (!stralloc_cats(&contents,"\n")) retstralloc(0,"write_dependencies") ; - } + if (!stralloc_cats(&contents,"\n")) + }*/ if (contents.len) { @@ -898,11 +903,11 @@ int write_dependencies(unsigned int nga,unsigned int idga,char const *dst,char c } stralloc_free(&contents) ; - stralloc_free(&namedeps) ; + //stralloc_free(&namedeps) ; return 1 ; err: stralloc_free(&contents) ; - stralloc_free(&namedeps) ; + //stralloc_free(&namedeps) ; return 0 ; } diff --git a/src/lib66/resolve.c b/src/lib66/resolve.c index c6861961ecf8e5665fb5dd990ccbe6a772ce47a3..7ef0d716f9db9ce8c18b9ce95c5f9f8fe5dfe728 100644 --- a/src/lib66/resolve.c +++ b/src/lib66/resolve.c @@ -651,13 +651,19 @@ int ss_resolve_setnwrite(sv_alltype *services, ssexec_t *info, char const *dst) if (res.ndeps) { - for (unsigned int i = 0; i < res.ndeps; i++) + size_t id = services->cname.idga, nid = res.ndeps ; + for (;nid; id += strlen(deps.s + id) + 1, nid--) + { + if (!stralloc_catb(&final,deps.s + id,strlen(deps.s + id)) || + !stralloc_catb(&final," ",1)) retstralloc(0,"write_dependencies") ; + } + /*for (unsigned int i = 0; i < res.ndeps; i++) { if (!stralloc_obreplace(&namedeps,deps.s+genalloc_s(unsigned int,&gadeps)[services->cname.idga+i])) goto err ; namedeps.len--; if (!stralloc_catb(&final,namedeps.s,namedeps.len)) { VERBO1 warnstralloc("ss_resolve_setnwrite") ; goto err ; } if (!stralloc_catb(&final," ",1)) {VERBO1 warnstralloc("ss_resolve_setnwrite") ; goto err ; } - } + }*/ final.len-- ; if (!stralloc_0(&final)){ VERBO1 warnstralloc("ss_resolve_setnwrite") ; goto err ; } res.deps = ss_resolve_add_string(&res,final.s) ;