Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
Software for White Rabbit PTP Core
Manage
Activity
Members
Labels
Plan
Issues
39
Issue boards
Milestones
Wiki
Code
Merge requests
5
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor 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
Projects
Software for White Rabbit PTP Core
Commits
d0c910dc
Commit
d0c910dc
authored
8 years ago
by
Alessandro Rubini
Committed by
Grzegorz Daniluk
8 years ago
Browse files
Options
Downloads
Patches
Plain Diff
shell/cmd_ptp: use a data structure for arguments
Signed-off-by:
Alessandro Rubini
<
rubini@gnudd.com
>
parent
70acb06b
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
shell/cmd_ptp.c
+16
-7
16 additions, 7 deletions
shell/cmd_ptp.c
with
16 additions
and
7 deletions
shell/cmd_ptp.c
+
16
−
7
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
)
=
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
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