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
7
Merge Requests
7
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
76e0d3e4
Commit
76e0d3e4
authored
Apr 22, 2020
by
Tomasz Wlostowski
Committed by
Grzegorz Daniluk
Apr 24, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
shell: moved fromhex/fromdec functions to lib/util.c
parent
248230af
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
59 additions
and
59 deletions
+59
-59
shell.h
include/shell.h
+0
-3
util.h
include/util.h
+4
-0
util.c
lib/util.c
+55
-0
shell.c
shell/shell.c
+0
-56
No files found.
include/shell.h
View file @
76e0d3e4
...
...
@@ -12,9 +12,6 @@
extern
int
wrc_ui_mode
;
extern
int
wrc_stat_running
;
const
char
*
fromhex
(
const
char
*
hex
,
int
*
v
);
const
char
*
fromhex64
(
const
char
*
hex
,
int64_t
*
v
);
const
char
*
fromdec
(
const
char
*
dec
,
int
*
v
);
void
decode_mac
(
const
char
*
str
,
unsigned
char
*
mac
);
char
*
format_mac
(
char
*
s
,
const
unsigned
char
*
mac
);
void
decode_ip
(
const
char
*
str
,
unsigned
char
*
ip
);
...
...
include/util.h
View file @
76e0d3e4
...
...
@@ -43,6 +43,10 @@ int tmo_init(timeout_t *tmo, uint32_t milliseconds);
int
tmo_restart
(
timeout_t
*
tmo
);
int
tmo_expired
(
timeout_t
*
tmo
);
const
char
*
fromhex
(
const
char
*
hex
,
int
*
v
);
const
char
*
fromhex64
(
const
char
*
hex
,
int64_t
*
v
);
const
char
*
fromdec
(
const
char
*
dec
,
int
*
v
);
static
inline
int
within_range
(
int
x
,
int
minval
,
int
maxval
,
int
wrap
)
{
int
rv
;
...
...
lib/util.c
View file @
76e0d3e4
...
...
@@ -143,3 +143,58 @@ int tmo_expired(timeout_t *tmo)
return
(
timer_get_tics
()
-
tmo
->
start_tics
>
tmo
->
timeout
);
}
const
char
*
fromhex64
(
const
char
*
hex
,
int64_t
*
v
)
{
int64_t
o
=
0
;
int
sign
=
1
;
if
(
hex
&&
*
hex
==
'-'
)
{
sign
=
-
1
;
hex
++
;
}
for
(;
hex
&&
*
hex
;
++
hex
)
{
if
(
*
hex
>=
'0'
&&
*
hex
<=
'9'
)
{
o
=
(
o
<<
4
)
+
(
*
hex
-
'0'
);
}
else
if
(
*
hex
>=
'A'
&&
*
hex
<=
'F'
)
{
o
=
(
o
<<
4
)
+
(
*
hex
-
'A'
)
+
10
;
}
else
if
(
*
hex
>=
'a'
&&
*
hex
<=
'f'
)
{
o
=
(
o
<<
4
)
+
(
*
hex
-
'a'
)
+
10
;
}
else
{
break
;
}
}
*
v
=
o
*
sign
;
return
hex
;
}
const
char
*
fromhex
(
const
char
*
hex
,
int
*
v
)
{
const
char
*
ret
;
int64_t
v64
;
ret
=
fromhex64
(
hex
,
&
v64
);
*
v
=
(
int
)
v64
;
return
ret
;
}
const
char
*
fromdec
(
const
char
*
dec
,
int
*
v
)
{
int
o
=
0
,
sign
=
1
;
if
(
dec
&&
*
dec
==
'-'
)
{
sign
=
-
1
;
dec
++
;
}
for
(;
dec
&&
*
dec
;
++
dec
)
{
if
(
*
dec
>=
'0'
&&
*
dec
<=
'9'
)
{
o
=
(
o
*
10
)
+
(
*
dec
-
'0'
);
}
else
{
break
;
}
}
*
v
=
o
*
sign
;
return
dec
;
}
shell/shell.c
View file @
76e0d3e4
...
...
@@ -246,62 +246,6 @@ int shell_interactive()
return
0
;
}
const
char
*
fromhex64
(
const
char
*
hex
,
int64_t
*
v
)
{
int64_t
o
=
0
;
int
sign
=
1
;
if
(
hex
&&
*
hex
==
'-'
)
{
sign
=
-
1
;
hex
++
;
}
for
(;
hex
&&
*
hex
;
++
hex
)
{
if
(
*
hex
>=
'0'
&&
*
hex
<=
'9'
)
{
o
=
(
o
<<
4
)
+
(
*
hex
-
'0'
);
}
else
if
(
*
hex
>=
'A'
&&
*
hex
<=
'F'
)
{
o
=
(
o
<<
4
)
+
(
*
hex
-
'A'
)
+
10
;
}
else
if
(
*
hex
>=
'a'
&&
*
hex
<=
'f'
)
{
o
=
(
o
<<
4
)
+
(
*
hex
-
'a'
)
+
10
;
}
else
{
break
;
}
}
*
v
=
o
*
sign
;
return
hex
;
}
const
char
*
fromhex
(
const
char
*
hex
,
int
*
v
)
{
const
char
*
ret
;
int64_t
v64
;
ret
=
fromhex64
(
hex
,
&
v64
);
*
v
=
(
int
)
v64
;
return
ret
;
}
const
char
*
fromdec
(
const
char
*
dec
,
int
*
v
)
{
int
o
=
0
,
sign
=
1
;
if
(
dec
&&
*
dec
==
'-'
)
{
sign
=
-
1
;
dec
++
;
}
for
(;
dec
&&
*
dec
;
++
dec
)
{
if
(
*
dec
>=
'0'
&&
*
dec
<=
'9'
)
{
o
=
(
o
*
10
)
+
(
*
dec
-
'0'
);
}
else
{
break
;
}
}
*
v
=
o
*
sign
;
return
dec
;
}
static
char
shell_init_cmd
[]
=
CONFIG_INIT_COMMAND
;
static
int
build_init_readcmd
(
uint8_t
*
cmd
,
int
maxlen
)
...
...
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