Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
I
iproute2
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
iproute2
Commits
30d10db5
Commit
30d10db5
authored
Dec 20, 2011
by
Hagen Paul Pfeifer
Committed by
Stephen Hemminger
Jan 19, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
utils: add s32 parser
Signed-off-by:
Hagen Paul Pfeifer
<
hagen@jauu.net
>
parent
aa38c3ee
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
0 deletions
+20
-0
include/utils.h
include/utils.h
+1
-0
lib/utils.c
lib/utils.c
+19
-0
No files found.
include/utils.h
View file @
30d10db5
...
...
@@ -85,6 +85,7 @@ extern int get_time_rtt(unsigned *val, const char *arg, int *raw);
#define get_short get_s16
extern
int
get_u64
(
__u64
*
val
,
const
char
*
arg
,
int
base
);
extern
int
get_u32
(
__u32
*
val
,
const
char
*
arg
,
int
base
);
extern
int
get_s32
(
__s32
*
val
,
const
char
*
arg
,
int
base
);
extern
int
get_u16
(
__u16
*
val
,
const
char
*
arg
,
int
base
);
extern
int
get_s16
(
__s16
*
val
,
const
char
*
arg
,
int
base
);
extern
int
get_u8
(
__u8
*
val
,
const
char
*
arg
,
int
base
);
...
...
lib/utils.c
View file @
30d10db5
...
...
@@ -25,6 +25,7 @@
#include <linux/pkt_sched.h>
#include <time.h>
#include <sys/time.h>
#include <errno.h>
#include "utils.h"
...
...
@@ -198,6 +199,24 @@ int get_u8(__u8 *val, const char *arg, int base)
return
0
;
}
int
get_s32
(
__s32
*
val
,
const
char
*
arg
,
int
base
)
{
long
res
;
char
*
ptr
;
errno
=
0
;
if
(
!
arg
||
!*
arg
)
return
-
1
;
res
=
strtol
(
arg
,
&
ptr
,
base
);
if
(
ptr
==
arg
||
*
ptr
||
((
res
==
LONG_MIN
||
res
==
LONG_MAX
)
&&
errno
==
ERANGE
)
||
res
>
INT32_MAX
||
res
<
INT32_MIN
)
return
-
1
;
*
val
=
res
;
return
0
;
}
int
get_s16
(
__s16
*
val
,
const
char
*
arg
,
int
base
)
{
long
res
;
...
...
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