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
fb0adc84
Commit
fb0adc84
authored
2 years ago
by
Eric Vidal
Browse files
Options
Downloads
Patches
Plain Diff
always trust resolve files
parent
477e09c0
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/lib66/exec/ssexec_init.c
+3
-6
3 additions, 6 deletions
src/lib66/exec/ssexec_init.c
src/lib66/parse/parse_service.c
+52
-2
52 additions, 2 deletions
src/lib66/parse/parse_service.c
with
55 additions
and
8 deletions
src/lib66/exec/ssexec_init.c
+
3
−
6
View file @
fb0adc84
...
...
@@ -142,7 +142,7 @@ int ssexec_init(int argc, char const *const *argv, ssexec_t *info)
int
r
;
uint8_t
earlier
=
0
;
char
const
*
treename
=
0
;
char
const
*
exclude
[
2
]
=
{
SS_MASTER
+
1
,
0
}
;
stralloc
sa
=
STRALLOC_ZERO
;
...
...
@@ -150,9 +150,8 @@ int ssexec_init(int argc, char const *const *argv, ssexec_t *info)
log_usage
(
usage_init
)
;
treename
=
argv
[
1
]
;
size_t
treenamelen
=
strlen
(
treename
)
;
size_t
treelen
=
info
->
base
.
len
+
SS_SYSTEM_LEN
+
1
+
treenamelen
+
SS_SVDIRS_LEN
+
SS_RESOLVE_LEN
;
size_t
treelen
=
info
->
base
.
len
+
SS_SYSTEM_LEN
+
1
+
treenamelen
+
1
;
char
tree
[
treelen
+
1
]
;
auto_strings
(
tree
,
info
->
base
.
s
,
SS_SYSTEM
,
"/"
,
treename
)
;
...
...
@@ -170,9 +169,7 @@ int ssexec_init(int argc, char const *const *argv, ssexec_t *info)
r
=
svc_scandir_ok
(
info
->
scandir
.
s
)
;
if
(
r
!=
1
)
earlier
=
1
;
auto_strings
(
tree
+
info
->
base
.
len
+
SS_SYSTEM_LEN
+
1
+
treenamelen
,
SS_SVDIRS
,
SS_RESOLVE
)
;
if
(
!
sastr_dir_get
(
&
sa
,
tree
,
exclude
,
S_IFREG
))
if
(
!
resolve_get_field_tosa_g
(
&
sa
,
info
->
base
.
s
,
treename
,
DATA_TREE
,
E_RESOLVE_TREE_CONTENTS
))
log_dieu
(
LOG_EXIT_SYS
,
"get services list from tree: "
,
treename
)
;
if
(
sa
.
len
)
{
...
...
This diff is collapsed.
Click to expand it.
src/lib66/parse/parse_service.c
+
52
−
2
View file @
fb0adc84
...
...
@@ -34,6 +34,7 @@
#include
<66/state.h>
#include
<66/resolve.h>
#include
<66/service.h>
#include
<66/tree.h>
parse_mill_t
MILL_GET_SECTION_NAME
=
\
{
\
...
...
@@ -69,7 +70,7 @@ parse_mill_t MILL_GET_VALUE = \
* At the end, i think that good API to know/acknowledge of a global system state changes should be provide. After all, handling events will appear in the future.
*
*
*
*/
*
void service_master_modify_contents(resolve_service_t *res, resolve_service_master_enum_t ENUM)
{
stralloc sa = STRALLOC_ZERO ;
...
...
@@ -171,6 +172,54 @@ void service_master_modify_contents(resolve_service_t *res, resolve_service_mast
stralloc_free(&sa) ;
resolve_free(wres) ;
}
*/
static
void
service_notify_add_string
(
stralloc
*
sa
,
char
const
*
name
,
char
const
*
str
)
{
if
(
!
sastr_clean_string
(
sa
,
str
))
log_dieu
(
LOG_EXIT_SYS
,
"clean string"
)
;
if
(
!
sastr_add_string
(
sa
,
name
))
log_dieu
(
LOG_EXIT_SYS
,
"clean string"
)
;
if
(
!
sastr_sortndrop_element
(
sa
))
log_dieu
(
LOG_EXIT_SYS
,
"sort string"
)
;
}
static
void
service_notify_tree
(
char
const
*
name
,
char
const
*
base
,
char
const
*
treename
,
uint8_t
field
)
{
resolve_tree_t
tres
=
RESOLVE_TREE_ZERO
;
resolve_wrapper_t_ref
wres
=
resolve_set_struct
(
DATA_TREE
,
&
tres
)
;
stralloc
sa
=
STRALLOC_ZERO
;
log_trace
(
"modify field contents of resolve tree file: "
,
treename
)
;
if
(
!
resolve_read_g
(
wres
,
base
,
treename
))
log_dieusys
(
LOG_EXIT_SYS
,
"read resolve file of tree: "
,
treename
)
;
if
(
field
==
E_RESOLVE_TREE_CONTENTS
)
{
if
(
tres
.
ncontents
)
service_notify_add_string
(
&
sa
,
name
,
tres
.
sa
.
s
+
tres
.
contents
)
;
else
if
(
!
sastr_add_string
(
&
sa
,
name
))
log_dieu
(
LOG_EXIT_SYS
,
"add string"
)
;
tres
.
ncontents
+=
1
;
}
else
goto
freed
;
if
(
!
sastr_rebuild_in_oneline
(
&
sa
))
log_dieu
(
LOG_EXIT_SYS
,
"rebuild stralloc list"
)
;
if
(
!
resolve_modify_field
(
wres
,
field
,
sa
.
s
))
log_dieusys
(
LOG_EXIT_SYS
,
"modify resolve file of: "
,
treename
)
;
if
(
!
resolve_write_g
(
wres
,
base
,
treename
))
log_dieusys
(
LOG_EXIT_SYS
,
"write resolve file of tree: "
,
treename
)
;
freed
:
stralloc_free
(
&
sa
)
;
resolve_free
(
wres
)
;
}
void
parse_service
(
char
const
*
sv
,
ssexec_t
*
info
,
uint8_t
force
,
uint8_t
conf
)
{
...
...
@@ -206,7 +255,8 @@ void parse_service(char const *sv, ssexec_t *info, uint8_t force, uint8_t conf)
if
(
!
state_write
(
&
sta
,
ares
[
pos
].
sa
.
s
+
ares
[
pos
].
path
.
home
,
ares
[
pos
].
sa
.
s
+
ares
[
pos
].
logger
.
name
))
log_dieu
(
LOG_EXIT_SYS
,
"write state file of: "
,
ares
[
pos
].
sa
.
s
+
ares
[
pos
].
logger
.
name
)
;
service_master_modify_contents
(
&
ares
[
pos
],
E_RESOLVE_SERVICE_MASTER_CONTENTS
)
;
//service_master_modify_contents(&ares[pos], E_RESOLVE_SERVICE_MASTER_CONTENTS) ;
service_notify_tree
(
ares
[
pos
].
sa
.
s
+
ares
[
pos
].
name
,
info
->
base
.
s
,
ares
[
pos
].
sa
.
s
+
ares
[
pos
].
treename
,
E_RESOLVE_TREE_CONTENTS
)
;
log_info
(
"Parsed successfully: "
,
ares
[
pos
].
sa
.
s
+
ares
[
pos
].
name
,
" at tree: "
,
ares
[
pos
].
sa
.
s
+
ares
[
pos
].
treename
)
;
}
...
...
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