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
93c18f57
Commit
93c18f57
authored
2 years ago
by
Eric Vidal
Browse files
Options
Downloads
Patches
Plain Diff
adapt ssexec_inservice to new API function
parent
1d350ce9
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_inservice.c
+71
-155
71 additions, 155 deletions
src/lib66/exec/ssexec_inservice.c
src/lib66/info/info_graph_display_service.c
+37
-50
37 additions, 50 deletions
src/lib66/info/info_graph_display_service.c
with
108 additions
and
205 deletions
src/lib66/exec/ssexec_inservice.c
+
71
−
155
View file @
93c18f57
...
@@ -88,7 +88,6 @@ static void info_display_live(char const *field, resolve_service_t *res) ;
...
@@ -88,7 +88,6 @@ 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_deps
(
char
const
*
field
,
resolve_service_t
*
res
)
;
static
void
info_display_requiredby
(
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_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_start
(
char
const
*
field
,
resolve_service_t
*
res
)
;
static
void
info_display_stop
(
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_envat
(
char
const
*
field
,
resolve_service_t
*
res
)
;
...
@@ -99,17 +98,7 @@ static void info_display_logfile(char const *field, resolve_service_t *res) ;
...
@@ -99,17 +98,7 @@ static void info_display_logfile(char const *field, resolve_service_t *res) ;
info_graph_style
*
S_STYLE
=
&
graph_default
;
info_graph_style
*
S_STYLE
=
&
graph_default
;
static
ssexec_t_ref
pinfo
=
0
;
#include
<stdio.h>
// a effacer
info_opts_map_t
const
opts_sv_table
[]
=
info_opts_map_t
const
opts_sv_table
[]
=
{
{
...
@@ -123,19 +112,18 @@ info_opts_map_t const opts_sv_table[] =
...
@@ -123,19 +112,18 @@ info_opts_map_t const opts_sv_table[] =
{
.
str
=
"live"
,
.
svfunc
=
&
info_display_live
,
.
id
=
7
},
{
.
str
=
"live"
,
.
svfunc
=
&
info_display_live
,
.
id
=
7
},
{
.
str
=
"depends"
,
.
svfunc
=
&
info_display_deps
,
.
id
=
8
},
{
.
str
=
"depends"
,
.
svfunc
=
&
info_display_deps
,
.
id
=
8
},
{
.
str
=
"requiredby"
,
.
svfunc
=
&
info_display_requiredby
,
.
id
=
9
},
{
.
str
=
"requiredby"
,
.
svfunc
=
&
info_display_requiredby
,
.
id
=
9
},
{
.
str
=
"extdepends"
,
.
svfunc
=
&
info_display_extdeps
,
.
id
=
10
},
{
.
str
=
"optsdepends"
,
.
svfunc
=
&
info_display_optsdeps
,
.
id
=
10
},
{
.
str
=
"optsdepends"
,
.
svfunc
=
&
info_display_optsdeps
,
.
id
=
11
},
{
.
str
=
"start"
,
.
svfunc
=
&
info_display_start
,
.
id
=
11
},
{
.
str
=
"start"
,
.
svfunc
=
&
info_display_start
,
.
id
=
12
},
{
.
str
=
"stop"
,
.
svfunc
=
&
info_display_stop
,
.
id
=
12
},
{
.
str
=
"stop"
,
.
svfunc
=
&
info_display_stop
,
.
id
=
13
},
{
.
str
=
"envat"
,
.
svfunc
=
&
info_display_envat
,
.
id
=
13
},
{
.
str
=
"envat"
,
.
svfunc
=
&
info_display_envat
,
.
id
=
14
},
{
.
str
=
"envfile"
,
.
svfunc
=
&
info_display_envfile
,
.
id
=
14
},
{
.
str
=
"envfile"
,
.
svfunc
=
&
info_display_envfile
,
.
id
=
15
},
{
.
str
=
"logname"
,
.
svfunc
=
&
info_display_logname
,
.
id
=
15
},
{
.
str
=
"logname"
,
.
svfunc
=
&
info_display_logname
,
.
id
=
16
},
{
.
str
=
"logdst"
,
.
svfunc
=
&
info_display_logdst
,
.
id
=
16
},
{
.
str
=
"logdst"
,
.
svfunc
=
&
info_display_logdst
,
.
id
=
17
},
{
.
str
=
"logfile"
,
.
svfunc
=
&
info_display_logfile
,
.
id
=
17
},
{
.
str
=
"logfile"
,
.
svfunc
=
&
info_display_logfile
,
.
id
=
18
},
{
.
str
=
0
,
.
svfunc
=
0
,
.
id
=
-
1
}
{
.
str
=
0
,
.
svfunc
=
0
,
.
id
=
-
1
}
}
;
}
;
#define MAXOPTS
20
#define MAXOPTS
19
#define checkopts(n) if (n >= MAXOPTS) log_die(LOG_EXIT_USER, "too many options")
#define checkopts(n) if (n >= MAXOPTS) log_die(LOG_EXIT_USER, "too many options")
#define DELIM ','
#define DELIM ','
...
@@ -174,11 +162,9 @@ char *print_nlog(char *str, int n)
...
@@ -174,11 +162,9 @@ char *print_nlog(char *str, int n)
static
void
info_display_string
(
char
const
*
str
)
static
void
info_display_string
(
char
const
*
str
)
{
{
if
(
!
bprintf
(
buffer_1
,
"%s"
,
str
))
if
(
!
bprintf
(
buffer_1
,
"%s"
,
str
)
||
log_dieusys
(
LOG_EXIT_SYS
,
"write to stdout"
)
;
buffer_putsflush
(
buffer_1
,
"
\n
"
)
==
-
1
)
log_dieusys
(
LOG_EXIT_SYS
,
"write to stdout"
)
;
if
(
buffer_putsflush
(
buffer_1
,
"
\n
"
)
==
-
1
)
log_dieusys
(
LOG_EXIT_SYS
,
"write to stdout"
)
;
}
}
static
void
info_display_name
(
char
const
*
field
,
resolve_service_t
*
res
)
static
void
info_display_name
(
char
const
*
field
,
resolve_service_t
*
res
)
...
@@ -190,16 +176,7 @@ static void info_display_name(char const *field, resolve_service_t *res)
...
@@ -190,16 +176,7 @@ static void info_display_name(char const *field, resolve_service_t *res)
static
void
info_display_version
(
char
const
*
field
,
resolve_service_t
*
res
)
static
void
info_display_version
(
char
const
*
field
,
resolve_service_t
*
res
)
{
{
if
(
NOFIELD
)
info_display_field_name
(
field
)
;
if
(
NOFIELD
)
info_display_field_name
(
field
)
;
/** tempory check here, it not mandatory for the moment*/
info_display_string
(
res
->
sa
.
s
+
res
->
version
)
;
if
(
res
->
version
>
0
)
{
info_display_string
(
res
->
sa
.
s
+
res
->
version
)
;
}
else
{
if
(
!
bprintf
(
buffer_1
,
"%s%s%s
\n
"
,
log_color
->
warning
,
"None"
,
log_color
->
off
))
log_dieusys
(
LOG_EXIT_SYS
,
"write to stdout"
)
;
}
}
}
static
void
info_display_intree
(
char
const
*
field
,
resolve_service_t
*
res
)
static
void
info_display_intree
(
char
const
*
field
,
resolve_service_t
*
res
)
...
@@ -215,11 +192,10 @@ static void info_get_status(resolve_service_t *res)
...
@@ -215,11 +192,10 @@ static void info_get_status(resolve_service_t *res)
pid_t
pid
;
pid_t
pid
;
ss_state_t
sta
=
STATE_ZERO
;
ss_state_t
sta
=
STATE_ZERO
;
int
warn_color
=
0
;
int
warn_color
=
0
;
if
(
res
->
type
==
TYPE_CLASSIC
)
if
(
res
->
type
==
TYPE_CLASSIC
)
{
{
r
=
s6_svc_ok
(
res
->
sa
.
s
+
res
->
live
.
scandir
)
;
r
=
s6_svc_ok
(
res
->
sa
.
s
+
res
->
live
.
scandir
)
;
if
(
r
!=
1
)
if
(
r
!=
1
)
{
{
if
(
!
bprintf
(
buffer_1
,
"%s%s%s
\n
"
,
log_color
->
warning
,
"None"
,
log_color
->
off
))
if
(
!
bprintf
(
buffer_1
,
"%s%s%s
\n
"
,
log_color
->
warning
,
"None"
,
log_color
->
off
))
log_dieusys
(
LOG_EXIT_SYS
,
"write to stdout"
)
;
log_dieusys
(
LOG_EXIT_SYS
,
"write to stdout"
)
;
return
;
return
;
...
@@ -237,48 +213,32 @@ static void info_get_status(resolve_service_t *res)
...
@@ -237,48 +213,32 @@ static void info_get_status(resolve_service_t *res)
if
(
wstat
)
if
(
wstat
)
log_dieu
(
LOG_EXIT_SYS
,
"status for service: "
,
res
->
sa
.
s
+
res
->
name
)
;
log_dieu
(
LOG_EXIT_SYS
,
"status for service: "
,
res
->
sa
.
s
+
res
->
name
)
;
}
else
}
else
{
{
char
*
ste
=
res
->
sa
.
s
+
res
->
path
.
home
;
char
*
ste
=
res
->
sa
.
s
+
res
->
path
.
home
;
char
*
name
=
res
->
sa
.
s
+
res
->
name
;
char
*
name
=
res
->
sa
.
s
+
res
->
name
;
char
*
status
=
0
;
char
*
status
=
0
;
if
(
!
state_check
(
ste
,
SS_STATUS
))
{
status
=
"unitialized"
;
goto
dis
;
}
if
(
!
state_read
(
&
sta
,
ste
,
name
))
if
(
!
state_read
(
&
sta
,
ste
,
name
))
log_dieusys
(
LOG_EXIT_SYS
,
"read state of: "
,
name
)
;
log_dieusys
(
LOG_EXIT_SYS
,
"read state of: "
,
name
)
;
if
(
sta
.
toinit
)
{
if
(
!
service_is
(
&
sta
,
STATE_FLAGS_TOINIT
))
{
status
=
"unitialized"
;
status
=
"unitialized"
;
}
/*
}
else
if
(
!
service_is
(
&
sta
,
STATE_FLAGS_ISUP
))
{
*
*
*
*
*
* A revoir sta.statedir n'exist pas
*
*
*
*
*
else if (!sta.statedir)
{
status
=
"down"
;
status
=
"down"
;
warn_color
=
1
;
warn_color
=
1
;
}
else
if (sta.statedir)
}
else
{
{
status
=
"up"
;
status
=
"up"
;
warn_color
=
2
;
warn_color
=
2
;
}
*/
}
dis:
if
(
!
bprintf
(
buffer_1
,
"%s%s%s
\n
"
,
warn_color
>
1
?
log_color
->
valid
:
warn_color
?
log_color
->
error
:
log_color
->
warning
,
status
,
log_color
->
off
))
if
(
!
bprintf
(
buffer_1
,
"%s%s%s
\n
"
,
warn_color
>
1
?
log_color
->
valid
:
warn_color
?
log_color
->
error
:
log_color
->
warning
,
status
,
log_color
->
off
))
log_dieusys
(
LOG_EXIT_SYS
,
"write to stdout"
)
;
log_dieusys
(
LOG_EXIT_SYS
,
"write to stdout"
)
;
}
}
}
}
...
@@ -290,10 +250,11 @@ static void info_display_status(char const *field,resolve_service_t *res)
...
@@ -290,10 +250,11 @@ static void info_display_status(char const *field,resolve_service_t *res)
if
(
NOFIELD
)
info_display_field_name
(
field
)
;
if
(
NOFIELD
)
info_display_field_name
(
field
)
;
if
(
state_read
(
&
ste
,
res
->
sa
.
s
+
res
->
path
.
home
,
res
->
sa
.
s
+
res
->
name
))
if
(
!
state_read
(
&
ste
,
res
->
sa
.
s
+
res
->
path
.
home
,
res
->
sa
.
s
+
res
->
name
))
log_dieusys
(
LOG_EXIT_SYS
,
"read state file of: "
,
res
->
sa
.
s
+
res
->
name
)
;
log_dieusys
(
LOG_EXIT_SYS
,
"read state file of: "
,
res
->
sa
.
s
+
res
->
name
)
;
disen
=
FLAGS_ISSET
(
ste
.
isenabled
,
STATE_FLAGS_TRUE
)
;
disen
=
service_is
(
&
ste
,
STATE_FLAGS_ISENABLED
)
;
if
(
!
bprintf
(
buffer_1
,
"%s%s%s%s"
,
disen
?
log_color
->
valid
:
log_color
->
error
,
disen
?
"enabled"
:
"disabled"
,
log_color
->
off
,
", "
))
if
(
!
bprintf
(
buffer_1
,
"%s%s%s%s"
,
disen
?
log_color
->
valid
:
log_color
->
error
,
disen
?
"enabled"
:
"disabled"
,
log_color
->
off
,
", "
))
log_dieusys
(
LOG_EXIT_SYS
,
"write to stdout"
)
;
log_dieusys
(
LOG_EXIT_SYS
,
"write to stdout"
)
;
...
@@ -333,18 +294,19 @@ static void info_display_requiredby(char const *field, resolve_service_t *res)
...
@@ -333,18 +294,19 @@ static void info_display_requiredby(char const *field, resolve_service_t *res)
size_t
padding
=
1
;
size_t
padding
=
1
;
int
r
;
int
r
;
graph_t
graph
=
GRAPH_ZERO
;
graph_t
graph
=
GRAPH_ZERO
;
unsigned
int
areslen
=
0
;
resolve_service_t
ares
[
SS_MAX_SERVICE
]
;
stralloc
deps
=
STRALLOC_ZERO
;
stralloc
deps
=
STRALLOC_ZERO
;
if
(
NOFIELD
)
padding
=
info_display_field_name
(
field
)
;
if
(
NOFIELD
)
padding
=
info_display_field_name
(
field
)
;
else
{
field
=
0
;
padding
=
0
;
}
else
{
field
=
0
;
padding
=
0
;
}
size_t
treelen
=
strlen
(
res
->
sa
.
s
+
res
->
path
.
tree
)
;
graph_build_service
(
&
graph
,
ares
,
&
areslen
,
pinfo
,
STATE_FLAGS_TOPROPAGATE
|
STATE_FLAGS_WANTUP
)
;
char
solve
[
treelen
+
SS_SVDIRS_LEN
+
1
]
;
auto_strings
(
solve
,
res
->
sa
.
s
+
res
->
path
.
tree
,
SS_SVDIRS
)
;
if
(
!
graph
_build_service_bytree
(
&
graph
,
solve
,
2
,
0
)
)
if
(
!
graph
.
mlen
)
log_die
u
(
LOG_EXIT_
SYS
,
"build the graph dependencies
"
)
;
log_die
(
LOG_EXIT_
USER
,
"services selection is not available -- please make a bug report
"
)
;
unsigned
int
list
[
graph
.
mlen
]
;
unsigned
int
list
[
graph
.
mlen
]
;
...
@@ -410,13 +372,18 @@ static void info_display_deps(char const *field, resolve_service_t *res)
...
@@ -410,13 +372,18 @@ static void info_display_deps(char const *field, resolve_service_t *res)
size_t
padding
=
1
;
size_t
padding
=
1
;
graph_t
graph
=
GRAPH_ZERO
;
graph_t
graph
=
GRAPH_ZERO
;
unsigned
int
areslen
=
0
;
resolve_service_t
ares
[
SS_MAX_SERVICE
]
;
stralloc
deps
=
STRALLOC_ZERO
;
stralloc
deps
=
STRALLOC_ZERO
;
if
(
NOFIELD
)
padding
=
info_display_field_name
(
field
)
;
if
(
NOFIELD
)
padding
=
info_display_field_name
(
field
)
;
else
{
field
=
0
;
padding
=
0
;
}
else
{
field
=
0
;
padding
=
0
;
}
if
(
!
graph_build_service_bytree
(
&
graph
,
res
->
sa
.
s
+
res
->
path
.
tree
,
2
,
0
))
graph_build_service
(
&
graph
,
ares
,
&
areslen
,
pinfo
,
STATE_FLAGS_TOPROPAGATE
|
STATE_FLAGS_WANTUP
)
;
log_dieu
(
LOG_EXIT_SYS
,
"build the graph dependencies"
)
;
if
(
!
graph
.
mlen
)
log_die
(
LOG_EXIT_USER
,
"services selection is not available -- please make a bug report"
)
;
unsigned
int
list
[
graph
.
mlen
]
;
unsigned
int
list
[
graph
.
mlen
]
;
...
@@ -489,7 +456,6 @@ static void info_display_with_source_tree(stralloc *list,resolve_service_t *res)
...
@@ -489,7 +456,6 @@ static void info_display_with_source_tree(stralloc *list,resolve_service_t *res)
if
(
!
auto_stra
(
&
src
,
home
.
s
))
log_die_nomem
(
"stralloc"
)
;
if
(
!
auto_stra
(
&
src
,
home
.
s
))
log_die_nomem
(
"stralloc"
)
;
newlen
=
src
.
len
;
newlen
=
src
.
len
;
if
(
!
sastr_dir_get
(
&
ntree
,
home
.
s
,
exclude
,
S_IFDIR
))
if
(
!
sastr_dir_get
(
&
ntree
,
home
.
s
,
exclude
,
S_IFDIR
))
log_dieu
(
LOG_EXIT_SYS
,
"get list of trees of: "
,
home
.
s
)
;
log_dieu
(
LOG_EXIT_SYS
,
"get list of trees of: "
,
home
.
s
)
;
...
@@ -561,67 +527,38 @@ static void info_display_optsdeps(char const *field, resolve_service_t *res)
...
@@ -561,67 +527,38 @@ static void info_display_optsdeps(char const *field, resolve_service_t *res)
stralloc_free
(
&
salist
)
;
stralloc_free
(
&
salist
)
;
}
}
static
void
info_display_
extdeps
(
char
const
*
field
,
resolve_service_t
*
res
)
static
void
info_display_
start
(
char
const
*
field
,
resolve_service_t
*
res
)
{
{
/*
stralloc salist = STRALLOC_ZERO ;
if
(
NOFIELD
)
info_display_field_name
(
field
)
;
if
(
NOFIELD
)
info_display_field_name
(
field
)
;
else
field
=
0
;
else
field
=
0
;
if (!res->nextdeps) goto empty ;
size_t
padding
=
info_length_from_wchar
(
field
)
+
1
;
if
(
field
)
if (!sastr_clean_string(&salist,res->sa.s + res->extdeps))
if
(
!
bprintf
(
buffer_1
,
"
\n
%*s"
,
padding
,
""
))
log_dieu(LOG_EXIT_SYS,"build dependencies list") ;
info_display_with_source_tree(&salist,res) ;
if (REVERSE)
if (!sastr_reverse(&salist))
log_dieu(LOG_EXIT_SYS,"reverse dependencies list") ;
info_display_list(field,&salist) ;
goto freed ;
empty:
if (!bprintf(buffer_1,"%s%s%s\n",log_color->warning,"None",log_color->off))
log_dieusys
(
LOG_EXIT_SYS
,
"write to stdout"
)
;
log_dieusys
(
LOG_EXIT_SYS
,
"write to stdout"
)
;
freed:
stralloc_free(&salist) ;
*/
}
static
void
info_display_start
(
char
const
*
field
,
resolve_service_t
*
res
)
{
if
(
NOFIELD
)
info_display_field_name
(
field
)
;
else
field
=
0
;
if
(
res
->
execute
.
run
.
run_user
)
if
(
res
->
execute
.
run
.
run_user
)
{
info_display_nline
(
field
,
res
->
sa
.
s
+
res
->
execute
.
run
.
run_user
)
;
info_display_nline
(
field
,
res
->
sa
.
s
+
res
->
execute
.
run
.
run_user
)
;
}
else
else
{
if
(
!
bprintf
(
buffer_1
,
"%s%s%s
\n
"
,
log_color
->
warning
,
"None"
,
log_color
->
off
))
if
(
!
bprintf
(
buffer_1
,
"%s%s%s
\n
"
,
log_color
->
warning
,
"None"
,
log_color
->
off
))
log_dieusys
(
LOG_EXIT_SYS
,
"write to stdout"
)
;
log_dieusys
(
LOG_EXIT_SYS
,
"write to stdout"
)
;
}
}
}
static
void
info_display_stop
(
char
const
*
field
,
resolve_service_t
*
res
)
static
void
info_display_stop
(
char
const
*
field
,
resolve_service_t
*
res
)
{
{
if
(
NOFIELD
)
info_display_field_name
(
field
)
;
if
(
NOFIELD
)
info_display_field_name
(
field
)
;
else
field
=
0
;
else
field
=
0
;
size_t
padding
=
info_length_from_wchar
(
field
)
+
1
;
if
(
field
)
if
(
!
bprintf
(
buffer_1
,
"
\n
%*s"
,
padding
,
""
))
log_dieusys
(
LOG_EXIT_SYS
,
"write to stdout"
)
;
if
(
res
->
execute
.
finish
.
run_user
)
if
(
res
->
execute
.
finish
.
run_user
)
{
info_display_nline
(
field
,
res
->
sa
.
s
+
res
->
execute
.
finish
.
run_user
)
;
info_display_nline
(
field
,
res
->
sa
.
s
+
res
->
execute
.
finish
.
run_user
)
;
}
else
else
{
if
(
!
bprintf
(
buffer_1
,
"%s%s%s
\n
"
,
log_color
->
warning
,
"None"
,
log_color
->
off
))
if
(
!
bprintf
(
buffer_1
,
"%s%s%s
\n
"
,
log_color
->
warning
,
"None"
,
log_color
->
off
))
log_dieusys
(
LOG_EXIT_SYS
,
"write to stdout"
)
;
log_dieusys
(
LOG_EXIT_SYS
,
"write to stdout"
)
;
}
}
}
static
void
info_display_envat
(
char
const
*
field
,
resolve_service_t
*
res
)
static
void
info_display_envat
(
char
const
*
field
,
resolve_service_t
*
res
)
...
@@ -896,9 +833,10 @@ static void info_parse_options(char const *str,int *what)
...
@@ -896,9 +833,10 @@ static void info_parse_options(char const *str,int *what)
int
ssexec_inservice
(
int
argc
,
char
const
*
const
*
argv
,
ssexec_t
*
info
)
int
ssexec_inservice
(
int
argc
,
char
const
*
const
*
argv
,
ssexec_t
*
info
)
{
{
unsigned
int
legacy
=
1
;
unsigned
int
legacy
=
1
;
int
found
=
0
;
int
r
=
0
;
int
what
[
MAXOPTS
]
=
{
0
}
;
int
what
[
MAXOPTS
]
=
{
0
}
;
pinfo
=
info
;
uid_t
owner
;
uid_t
owner
;
char
ownerstr
[
UID_FMT
]
;
char
ownerstr
[
UID_FMT
]
;
...
@@ -924,7 +862,6 @@ int ssexec_inservice(int argc, char const *const *argv, ssexec_t *info)
...
@@ -924,7 +862,6 @@ int ssexec_inservice(int argc, char const *const *argv, ssexec_t *info)
"Live"
,
"Live"
,
"Dependencies"
,
"Dependencies"
,
"Required by"
,
"Required by"
,
"External dependencies"
,
"Optional dependencies"
,
"Optional dependencies"
,
"Start script"
,
"Start script"
,
"Stop script"
,
"Stop script"
,
...
@@ -982,39 +919,18 @@ int ssexec_inservice(int argc, char const *const *argv, ssexec_t *info)
...
@@ -982,39 +919,18 @@ int ssexec_inservice(int argc, char const *const *argv, ssexec_t *info)
if
(
!
set_ownersysdir
(
&
home
,
owner
))
log_dieusys
(
LOG_EXIT_SYS
,
"set owner directory"
)
;
if
(
!
set_ownersysdir
(
&
home
,
owner
))
log_dieusys
(
LOG_EXIT_SYS
,
"set owner directory"
)
;
if
(
!
auto_stra
(
&
home
,
SS_SYSTEM
,
"/"
))
log_die_nomem
(
"stralloc"
)
;
if
(
!
auto_stra
(
&
home
,
SS_SYSTEM
,
"/"
))
log_die_nomem
(
"stralloc"
)
;
/*
r
=
service_is_g
(
atree
,
svname
,
STATE_FLAGS_ISPARSED
)
;
*
if
(
r
<
0
)
*
log_dieusys
(
LOG_EXIT_SYS
,
"get information of service: "
,
svname
,
" -- please make a bug report"
)
;
* sortie a revoir pour le passage vers service_is_g
*
if
(
!
r
)
{
*
/** nothing to do */
* */
log_1_warn
(
"unknown service: "
,
svname
)
;
found
=
service_is_g
(
atree
,
svname
,
STATE_FLAGS_ISENABLED
)
;
if
(
found
==
-
1
)
log_dieusys
(
LOG_EXIT_SYS
,
"resolve tree source of service: "
,
svname
)
;
else
if
(
!
found
)
{
log_info
(
"no tree exist yet"
)
;
goto
freed
;
goto
freed
;
}
}
else
if
(
found
>
2
)
{
log_die
(
LOG_EXIT_SYS
,
svname
,
" is set on different tree -- please use -t options"
)
;
if
(
!
resolve_read_g
(
wres
,
info
->
base
.
s
,
svname
))
}
log_dieusys
(
LOG_EXIT_SYS
,
"read resolve file of: "
,
svname
)
;
else
if
(
found
==
1
)
log_die
(
LOG_EXIT_SYS
,
"unknown service: "
,
svname
)
;
/**
*
*
*
* le src.s est vide ducon
*
* a revoir
*
*
*
*
*
* */
if
(
!
resolve_read
(
wres
,
src
.
s
,
svname
))
log_dieusys
(
LOG_EXIT_SYS
,
"read resolve file of: "
,
svname
)
;
info_display_all
(
&
res
,
what
)
;
info_display_all
(
&
res
,
what
)
;
...
...
This diff is collapsed.
Click to expand it.
src/lib66/info/info_graph_display_service.c
+
37
−
50
View file @
93c18f57
...
@@ -13,16 +13,18 @@
...
@@ -13,16 +13,18 @@
* */
* */
#include
<stdint.h>
#include
<stdint.h>
#include
<unistd.h>
#include
<oblibs/log.h>
#include
<oblibs/log.h>
#include
<skalibs/stralloc.h>
#include
<skalibs/lolstdio.h>
#include
<skalibs/lolstdio.h>
#include
<skalibs/
buffer
.h>
#include
<skalibs/
types
.h>
#include
<66/info.h>
#include
<66/service.h>
#include
<66/service.h>
#include
<66/tree.h>
#include
<66/utils.h>
#include
<66/resolve.h>
#include
<66/config.h>
#include
<66/constants.h>
#include
<66/state.h>
#include
<66/state.h>
#include
<66/enum.h>
#include
<66/enum.h>
...
@@ -32,69 +34,56 @@ int info_graph_display_service(char const *name, char const *obj)
...
@@ -32,69 +34,56 @@ int info_graph_display_service(char const *name, char const *obj)
{
{
log_flow
()
;
log_flow
()
;
stralloc
tree
=
STRALLOC_ZERO
;
int
err
=
0
;
uint8_t
pid_color
=
0
;
char
str_pid
[
UINT_FMT
]
;
char
*
ppid
;
ss_state_t
sta
=
STATE_ZERO
;
s6_svstatus_t
status
=
S6_SVSTATUS_ZERO
;
resolve_service_t
res
=
RESOLVE_SERVICE_ZERO
;
resolve_service_t
res
=
RESOLVE_SERVICE_ZERO
;
resolve_wrapper_t_ref
wres
=
resolve_set_struct
(
DATA_SERVICE
,
&
res
)
;
resolve_wrapper_t_ref
wres
=
resolve_set_struct
(
DATA_SERVICE
,
&
res
)
;
int
r
=
service_intree
(
&
tree
,
name
,
obj
),
err
=
0
;
char
base
[
SS_MAX_PATH_LEN
+
SS_SYSTEM_LEN
+
1
]
;
if
(
r
!=
2
)
{
if
(
!
set_ownersysdir_stack
(
base
,
getuid
()))
if
(
r
==
1
)
log_warn_return
(
LOG_EXIT_ZERO
,
"set owner directory"
)
;
log_warnu
(
"find: "
,
name
,
" at tree: "
,
!
obj
?
tree
.
s
:
obj
)
;
if
(
r
>
2
)
log_1_warn
(
name
,
" is set on different tree -- please use -t options"
)
;
if
(
!
resolve_read_g
(
wres
,
base
,
name
))
{
log_warnu
(
"read resolve file of: "
,
name
)
;
goto
freed
;
goto
freed
;
}
}
if
(
!
resolve_check
(
tree
.
s
,
name
))
if
(
!
state_read
(
&
sta
,
res
.
sa
.
s
+
res
.
path
.
home
,
name
))
{
log_warnusys
(
"read state of: "
,
name
)
;
goto
freed
;
goto
freed
;
}
if
(
!
resolve_read
(
wres
,
tree
.
s
,
name
))
if
(
res
.
type
==
TYPE_CLASSIC
)
{
goto
freed
;
char
str_pid
[
UINT_FMT
]
;
uint8_t
pid_color
=
0
;
char
*
ppid
;
ss_state_t
sta
=
STATE_ZERO
;
s6_svstatus_t
status
=
S6_SVSTATUS_ZERO
;
if
(
res
.
type
==
TYPE_CLASSIC
||
res
.
type
==
TYPE_LONGRUN
)
{
s6_svstatus_read
(
res
.
sa
.
s
+
res
.
runat
,
&
status
)
;
s6_svstatus_read
(
res
.
sa
.
s
+
res
.
live
.
scandir
,
&
status
)
;
pid_color
=
!
status
.
pid
?
1
:
2
;
pid_color
=
!
status
.
pid
?
1
:
2
;
str_pid
[
uint_fmt
(
str_pid
,
status
.
pid
)]
=
0
;
str_pid
[
uint_fmt
(
str_pid
,
status
.
pid
)]
=
0
;
ppid
=
&
str_pid
[
0
]
;
ppid
=
&
str_pid
[
0
]
;
}
else
{
}
else
{
char
*
ste
=
res
.
sa
.
s
+
res
.
state
;
if
(
!
service_is
(
&
sta
,
STATE_FLAGS_TOINIT
))
{
char
*
name
=
res
.
sa
.
s
+
res
.
name
;
if
(
!
state_check
(
ste
,
name
))
{
ppid
=
"unitialized"
;
ppid
=
"unitialized"
;
goto
dis
;
goto
dis
;
}
if
(
!
state_read
(
&
sta
,
ste
,
name
))
{
}
else
if
(
!
service_is
(
&
sta
,
STATE_FLAGS_ISUP
))
{
log_warnu
(
"read state of: "
,
name
)
;
goto
freed
;
}
if
(
sta
.
init
)
{
ppid
=
"unitialized"
;
goto
dis
;
}
else
if
(
!
sta
.
state
)
{
ppid
=
"down"
;
ppid
=
"down"
;
pid_color
=
1
;
pid_color
=
1
;
}
else
if
(
sta
.
state
)
{
}
else
{
ppid
=
"up"
;
ppid
=
"up"
;
pid_color
=
2
;
pid_color
=
2
;
}
}
}
}
...
@@ -102,25 +91,23 @@ int info_graph_display_service(char const *name, char const *obj)
...
@@ -102,25 +91,23 @@ int info_graph_display_service(char const *name, char const *obj)
if
(
!
bprintf
(
buffer_1
,
"(%s%s%s,%s%s%s,%s) %s"
,
\
if
(
!
bprintf
(
buffer_1
,
"(%s%s%s,%s%s%s,%s) %s"
,
\
pid_color
>
1
?
log_color
->
valid
:
pid_color
?
log_color
->
error
:
log_color
->
warning
,
\
pid_color
>
1
?
log_color
->
valid
:
pid_color
?
log_color
->
error
:
log_color
->
warning
,
\
ppid
,
\
ppid
,
\
log_color
->
off
,
\
log_color
->
off
,
\
res
.
disen
?
log_color
->
off
:
log_color
->
error
,
\
service_is
(
&
sta
,
STATE_FLAGS_ISENABLED
)
?
log_color
->
off
:
log_color
->
error
,
\
res
.
disen
?
"Enabled"
:
"Disabled"
,
\
service_is
(
&
sta
,
STATE_FLAGS_ISENABLED
)
?
"Enabled"
:
"Disabled"
,
\
log_color
->
off
,
\
log_color
->
off
,
\
get_key_by_enum
(
ENUM_TYPE
,
res
.
type
),
\
get_key_by_enum
(
ENUM_TYPE
,
res
.
type
),
\
name
))
name
))
goto
freed
;
goto
freed
;
err
=
1
;
err
=
1
;
freed:
freed:
resolve_free
(
wres
)
;
resolve_free
(
wres
)
;
stralloc_free
(
&
tree
)
;
return
err
;
return
err
;
}
}
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