Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
S
Software for White Rabbit PTP Core
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
32
Issues
32
List
Board
Labels
Milestones
Merge Requests
4
Merge Requests
4
CI / CD
CI / CD
Pipelines
Schedules
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
Software for White Rabbit PTP Core
Commits
d0c910dc
Commit
d0c910dc
authored
Oct 27, 2016
by
Alessandro Rubini
Committed by
Grzegorz Daniluk
Feb 16, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
shell/cmd_ptp: use a data structure for arguments
Signed-off-by:
Alessandro Rubini
<
rubini@gnudd.com
>
parent
70acb06b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
7 deletions
+16
-7
cmd_ptp.c
shell/cmd_ptp.c
+16
-7
No files found.
shell/cmd_ptp.c
View file @
d0c910dc
...
...
@@ -6,19 +6,28 @@
#include <errno.h>
#include <string.h>
#include <wrpc.h>
#include "wrc_ptp.h"
#include "shell.h"
struct
subcmd
{
char
*
name
;
int
(
*
fun
)(
int
);
int
arg
;
}
subcmd
[]
=
{
{
"start"
,
wrc_ptp_run
,
1
},
{
"stop"
,
wrc_ptp_run
,
0
},
};
static
int
cmd_ptp
(
const
char
*
args
[])
{
if
(
!
strcasecmp
(
args
[
0
],
"start"
))
return
wrc_ptp_start
();
else
if
(
!
strcasecmp
(
args
[
0
],
"stop"
))
return
wrc_ptp_stop
();
else
return
-
EINVAL
;
int
i
;
struct
subcmd
*
c
;
return
0
;
for
(
i
=
0
,
c
=
subcmd
;
i
<
ARRAY_SIZE
(
subcmd
);
i
++
,
c
++
)
if
(
!
strcasecmp
(
args
[
0
],
c
->
name
))
return
c
->
fun
(
c
->
arg
);
return
-
EINVAL
;
}
DEFINE_WRC_COMMAND
(
ptp
)
=
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment