Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
F
FMC DEL 1ns 4cha - Software
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
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
FMC DEL 1ns 4cha - Software
Commits
4d77a253
Commit
4d77a253
authored
Mar 20, 2014
by
Alessandro Rubini
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tools: all tools get '-h' and '--help'
Signed-off-by:
Alessandro Rubini
<
rubini@gnudd.com
>
parent
45a401c8
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
53 additions
and
14 deletions
+53
-14
fmc-fdelay-board-time.c
tools/fmc-fdelay-board-time.c
+14
-7
fmc-fdelay-list.c
tools/fmc-fdelay-list.c
+11
-0
fmc-fdelay-term.c
tools/fmc-fdelay-term.c
+12
-5
tools-common.h
tools/tools-common.h
+16
-2
No files found.
tools/fmc-fdelay-board-time.c
View file @
4d77a253
...
...
@@ -8,6 +8,15 @@
#include "tools-common.h"
static
void
help
(
char
*
name
)
{
fprintf
(
stderr
,
"%s: Use
\"
%s [-i <index>] [-d <dev>] <cmd>
\"\n
"
,
name
,
name
);
fprintf
(
stderr
,
" cmd is one of
\"
get
\"
,
\"
host
\"
, "
"
\"
local
\"
,
\"
wr
\"
or a floating point time in secs
\n
"
);
exit
(
1
);
}
int
main
(
int
argc
,
char
**
argv
)
{
struct
fdelay_board
*
b
;
...
...
@@ -18,6 +27,9 @@ int main(int argc, char **argv)
/* Standard part of the file (repeated code) */
if
(
tools_need_help
(
argc
,
argv
))
help
(
argv
[
0
]);
nboards
=
fdelay_init
();
if
(
nboards
<
0
)
{
...
...
@@ -41,13 +53,8 @@ int main(int argc, char **argv)
}
/* Parse the mandatory extra argument */
if
(
optind
!=
argc
-
1
)
{
fprintf
(
stderr
,
"%s: Use
\"
%s [-i <index>] [-d <dev>] <cmd>
\"\n
"
,
argv
[
0
],
argv
[
0
]);
fprintf
(
stderr
,
" cmd is one of
\"
get
\"
,
\"
host
\"
, "
"
\"
local
\"
,
\"
wr
\"
or a floating point time in secs
\n
"
);
exit
(
1
);
}
if
(
optind
!=
argc
-
1
)
help
(
argv
[
0
]);
s
=
argv
[
optind
];
/* Crappy parser */
if
(
!
strcmp
(
s
,
"get"
))
...
...
tools/fmc-fdelay-list.c
View file @
4d77a253
...
...
@@ -7,12 +7,23 @@
#define FDELAY_INTERNAL
/* hack... */
#include "fdelay-lib.h"
#include "tools-common.h"
static
void
help
(
char
*
name
)
{
fprintf
(
stderr
,
"%s: Lists boards, takes no arguments
\n
"
,
name
);
exit
(
1
);
}
int
main
(
int
argc
,
char
**
argv
)
{
int
i
,
j
;
struct
__fdelay_board
*
b
;
struct
fdelay_board
*
ub
;
if
(
tools_need_help
(
argc
,
argv
))
help
(
argv
[
0
]);
if
(
argc
>
1
)
{
fprintf
(
stderr
,
"%s: too many arguments (none expected)
\n
"
,
argv
[
0
]);
...
...
tools/fmc-fdelay-term.c
View file @
4d77a253
...
...
@@ -8,6 +8,13 @@
#include "tools-common.h"
static
void
help
(
char
*
name
)
{
fprintf
(
stderr
,
"%s: Use
\"
%s [-i <index>] [-d <dev>] 1|0
\n
"
,
name
,
name
);
exit
(
1
);
}
int
main
(
int
argc
,
char
**
argv
)
{
struct
fdelay_board
*
b
;
...
...
@@ -16,6 +23,9 @@ int main(int argc, char **argv)
/* Standard part of the file (repeated code) */
if
(
tools_need_help
(
argc
,
argv
))
help
(
argv
[
0
]);
nboards
=
fdelay_init
();
if
(
nboards
<
0
)
{
...
...
@@ -39,11 +49,8 @@ int main(int argc, char **argv)
}
/* Parse the mandatory extra argument */
if
(
optind
!=
argc
-
1
)
{
fprintf
(
stderr
,
"%s: Use
\"
%s [-i <index>] [-d <dev>] 1|0
\n
"
,
argv
[
0
],
argv
[
0
]);
exit
(
1
);
}
if
(
optind
!=
argc
-
1
)
help
(
argv
[
0
]);
newval
=
-
1
;
if
(
!
strcmp
(
argv
[
optind
],
"0"
))
newval
=
0
;
...
...
tools/tools-common.h
View file @
4d77a253
/*
* Simple code that is repeated over several tools
*/
/* Simple code that is repeated over severa
l tools */
static
void
help
(
char
*
name
);
/* This is mandatory in al
l tools */
static
inline
void
tools_getopt_d_i
(
int
argc
,
char
**
argv
,
int
*
dev
,
int
*
index
)
...
...
@@ -7,7 +10,7 @@ static inline void tools_getopt_d_i(int argc, char **argv,
char
*
rest
;
int
opt
;
while
((
opt
=
getopt
(
argc
,
argv
,
"d:i:"
))
!=
-
1
)
{
while
((
opt
=
getopt
(
argc
,
argv
,
"d:i:
h
"
))
!=
-
1
)
{
switch
(
opt
)
{
case
'i'
:
*
index
=
strtol
(
optarg
,
&
rest
,
0
);
...
...
@@ -25,6 +28,17 @@ static inline void tools_getopt_d_i(int argc, char **argv,
exit
(
1
);
}
break
;
case
'h'
:
help
(
argv
[
0
]);
}
}
}
static
inline
int
tools_need_help
(
int
argc
,
char
**
argv
)
{
if
(
argc
!=
2
)
return
0
;
if
(
!
strcmp
(
argv
[
1
],
"--help"
))
return
1
;
return
0
;
}
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