Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
6
66
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Eric Vidal
66
Commits
c295a1c5
Commit
c295a1c5
authored
1 year ago
by
Eric Vidal
Browse files
Options
Downloads
Patches
Plain Diff
prefix each interdependences of module by its name
parent
49575e7b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/lib66/module/parse_module.c
+94
-38
94 additions, 38 deletions
src/lib66/module/parse_module.c
with
94 additions
and
38 deletions
src/lib66/module/parse_module.c
+
94
−
38
View file @
c295a1c5
...
...
@@ -33,16 +33,76 @@
#include
<66/constants.h>
#include
<66/instance.h>
#include
<66/utils.h>
#include
<66/parser.h>
#include
<66/parse.h>
#include
<66/sanitize.h>
static
void
convert_tomodule
(
resolve_service_t
*
res
,
char
const
*
module
)
{
resolve_wrapper_t_ref
wres
=
resolve_set_struct
(
DATA_SERVICE
,
res
)
;
stralloc
sa
=
STRALLOC_ZERO
;
size_t
pos
=
0
,
mlen
=
strlen
(
module
)
;
if
(
res
->
dependencies
.
ndepends
)
{
if
(
!
sastr_clean_string
(
&
sa
,
res
->
sa
.
s
+
res
->
dependencies
.
depends
))
log_die_nomem
(
"stralloc"
)
;
size_t
len
=
(
mlen
+
1
+
SS_MAX_TREENAME
+
2
)
*
res
->
dependencies
.
ndepends
;
char
n
[
len
]
;
memset
(
n
,
0
,
len
)
;
FOREACH_SASTR
(
&
sa
,
pos
)
{
auto_strings
(
n
+
strlen
(
n
),
module
,
":"
,
sa
.
s
+
pos
,
" "
)
;
}
n
[
strlen
(
n
)
-
1
]
=
0
;
res
->
dependencies
.
depends
=
resolve_add_string
(
wres
,
n
)
;
}
if
(
res
->
dependencies
.
nrequiredby
)
{
sa
.
len
=
0
;
if
(
!
sastr_clean_string
(
&
sa
,
res
->
sa
.
s
+
res
->
dependencies
.
requiredby
))
log_die_nomem
(
"stralloc"
)
;
size_t
len
=
(
mlen
+
1
+
SS_MAX_TREENAME
+
2
)
*
res
->
dependencies
.
nrequiredby
;
char
n
[
len
]
;
memset
(
n
,
0
,
len
)
;
pos
=
0
;
FOREACH_SASTR
(
&
sa
,
pos
)
{
char
n
[
mlen
+
1
+
strlen
(
sa
.
s
+
pos
)
+
1
]
;
auto_strings
(
n
+
strlen
(
n
),
module
,
":"
,
sa
.
s
+
pos
,
" "
)
;
}
n
[
strlen
(
n
)
-
1
]
=
0
;
res
->
dependencies
.
requiredby
=
resolve_add_string
(
wres
,
n
)
;
}
stralloc_free
(
&
sa
)
;
free
(
wres
)
;
}
void
parse_module
(
resolve_service_t
*
res
,
resolve_service_t
*
ares
,
unsigned
int
*
areslen
,
ssexec_t
*
info
,
uint8_t
force
)
{
log_flow
()
;
int
r
,
insta
=
-
1
;
unsigned
int
residx
=
0
;
size_t
pos
=
0
,
pathlen
=
0
;
char
*
name
=
res
->
sa
.
s
+
res
->
name
;
char
name
[
strlen
(
res
->
sa
.
s
+
res
->
name
)
+
1
]
;
auto_strings
(
name
,
res
->
sa
.
s
+
res
->
name
)
;
char
*
src
=
res
->
sa
.
s
+
res
->
path
.
frontend
;
char
dirname
[
strlen
(
src
)
+
1
]
;
char
path
[
SS_MAX_PATH_LEN
]
;
...
...
@@ -58,15 +118,6 @@ void parse_module(resolve_service_t *res, resolve_service_t *ares, unsigned int
insta
=
instance_check
(
name
)
;
instance_splitname_to_char
(
ainsta
,
name
,
insta
,
0
)
;
size_t
prefixlen
=
strlen
(
name
)
;
char
prefix
[
prefixlen
+
2
]
;
instance_splitname_to_char
(
prefix
,
name
,
insta
,
1
)
;
auto_strings
(
prefix
+
strlen
(
prefix
),
"-"
)
;
prefixlen
=
strlen
(
prefix
)
;
if
(
!
getuid
())
{
auto_strings
(
path
,
SS_SERVICE_ADMDIR
,
name
)
;
...
...
@@ -101,12 +152,14 @@ void parse_module(resolve_service_t *res, resolve_service_t *ares, unsigned int
}
else
{
/** Must reconfigure all services of the module */
if
(
force
<
1
)
{
if
(
!
force
)
{
log_warn
(
"skip configuration of the module: "
,
name
,
" -- already configured"
)
;
goto
deps
;
}
log_trace
(
"remove directory: "
,
path
)
;
if
(
!
dir_rm_rf
(
path
))
log_dieusys
(
LOG_EXIT_SYS
,
"remove: "
,
path
)
;
...
...
@@ -152,6 +205,7 @@ void parse_module(resolve_service_t *res, resolve_service_t *ares, unsigned int
list
.
len
=
0
;
char
const
*
exclude
[
3
]
=
{
SS_MODULE_CONFIG_DIR
+
1
,
SS_MODULE_SERVICE_INSTANCE
+
1
,
0
}
;
if
(
!
sastr_dir_get_recursive
(
&
list
,
t
,
exclude
,
S_IFREG
,
1
))
log_dieusys
(
LOG_EXIT_SYS
,
"get file(s) of module: "
,
name
)
;
...
...
@@ -166,8 +220,8 @@ void parse_module(resolve_service_t *res, resolve_service_t *ares, unsigned int
char
*
dname
=
ll
+
pos
;
char
ainsta
[
pathlen
+
SS_MODULE_SERVICE_INSTANCE_LEN
+
1
+
SS_MAX_SERVICE_NAME
+
1
]
;
size_t
name
len
=
strlen
(
dname
)
;
char
bname
[
name
len
]
;
size_t
d
len
=
strlen
(
dname
)
;
char
bname
[
d
len
]
;
if
(
!
ob_basename
(
bname
,
dname
))
log_dieu
(
LOG_EXIT_SYS
,
"find basename of: "
,
dname
)
;
...
...
@@ -177,49 +231,51 @@ void parse_module(resolve_service_t *res, resolve_service_t *ares, unsigned int
dname
=
ainsta
;
}
if
(
!
sastr_add_string
(
&
list
,
bname
))
log_die_nomem
(
"stralloc"
)
;
if
(
!
strcmp
(
name
,
bname
))
log_die
(
LOG_EXIT_SYS
,
"cyclic call detected -- "
,
name
,
" call "
,
bname
)
;
/** nothing to do with the exit code*/
parse_frontend
(
dname
,
ares
,
areslen
,
info
,
force
,
conf
,
&
residx
,
path
,
bname
)
;
char
n
[
strlen
(
name
)
+
1
+
strlen
(
bname
)
+
1
]
;
wres
=
resolve_set_struct
(
DATA_SERVICE
,
&
ares
[
residx
]
)
;
auto_strings
(
n
,
name
,
":"
,
bname
)
;
ares
[
residx
].
inmodule
=
resolve_add_string
(
wres
,
name
)
;
}
char
deps
[
list
.
len
]
;
if
(
!
sastr_add_string
(
&
list
,
n
))
log_die_nomem
(
"stralloc"
)
;
sastr_to_char
(
deps
,
&
list
)
;
parse_frontend
(
dname
,
ares
,
areslen
,
info
,
force
,
conf
,
path
,
bname
,
name
)
;
}
llen
=
list
.
len
;
sastr_to_char
(
ll
,
&
list
)
;
list
.
len
=
0
;
/* rebuild the dependencies list incorporating the services defined inside
* the module.
for
(
pos
=
0
;
pos
<
llen
;
pos
+=
strlen
(
ll
+
pos
)
+
1
)
{
i
f (res->dependencies.ndepends)
if (
!sastr_clean_string(&list, res->sa.s + res->dependencies.depends)
)
log_die
u
(LOG_EXIT_
SYS, "clean string
") ;
i
nt
aresid
=
service_resolve_array_search
(
ares
,
*
areslen
,
ll
+
pos
)
;
if
(
aresid
<
0
)
log_die
(
LOG_EXIT_
USER
,
"service: "
,
ll
+
pos
,
" not available -- please make a bug report
"
)
;
if
(
ares
[
aresid
].
dependencies
.
ndepends
||
ares
[
aresid
].
dependencies
.
nrequiredby
)
convert_tomodule
(
&
ares
[
aresid
],
name
)
;
if
(
ares
[
aresid
].
logger
.
want
&&
ares
[
aresid
].
type
==
TYPE_CLASSIC
)
{
res->dependencies.depends = parse_compute_list(wres, &list, &res->dependencies.ndepends, 0)
;
char
n
[
strlen
(
ares
[
aresid
].
sa
.
s
+
ares
[
aresid
].
name
)
+
SS_LOG_SUFFIX_LEN
+
1
]
;
list.len = 0 ;
*/
auto_strings
(
n
,
ares
[
aresid
].
sa
.
s
+
ares
[
aresid
].
name
,
SS_LOG_SUFFIX
)
;
wres
=
resolve_set_struct
(
DATA_SERVICE
,
res
)
;
if
(
!
sastr_add_string
(
&
list
,
n
))
log_die_nomem
(
"stralloc"
)
;
}
for
(
pos
=
0
;
pos
<
llen
;
pos
+=
strlen
(
deps
+
pos
)
+
1
)
if
(
!
sastr_add_string
(
&
list
,
deps
+
pos
))
if
(
!
sastr_add_string
(
&
list
,
ll
+
pos
))
log_die_nomem
(
"stralloc"
)
;
}
wres
=
resolve_set_struct
(
DATA_SERVICE
,
res
)
;
res
->
regex
.
contents
=
parse_compute_list
(
wres
,
&
list
,
&
res
->
regex
.
ncontents
,
0
)
;
res
->
dependencies
.
contents
=
parse_compute_list
(
wres
,
&
list
,
&
res
->
dependencies
.
ncontents
,
0
)
;
free
(
wres
)
;
stralloc_free
(
&
list
)
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment