Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Xiph.Org
Icecast-Server
Commits
98994138
Commit
98994138
authored
Nov 20, 2015
by
Joseph Wallace
Browse files
Add parser for bodies of Integer elements.
parent
f461ff67
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/format_ebml.c
View file @
98994138
...
...
@@ -111,6 +111,11 @@ static int ebml_parse_tag(unsigned char *buffer,
static
int
ebml_parse_var_int
(
unsigned
char
*
buffer
,
unsigned
char
*
buffer_end
,
unsigned
long
long
*
out_value
);
static
int
ebml_parse_sized_int
(
unsigned
char
*
buffer
,
unsigned
char
*
buffer_end
,
int
len
,
int
is_signed
,
unsigned
long
long
*
out_value
);
int
format_ebml_get_plugin
(
source_t
*
source
)
{
...
...
@@ -769,3 +774,42 @@ static int ebml_parse_var_int(unsigned char *buffer,
return
size
;
}
/* Parse a normal int that may be from 1-8 bytes long.
* Returns 0 if there's not enough space to read the number;
* Returns -1 if the number is mis-sized.
* Else, returns the length of the number in bytes and writes the
* value to *out_value.
*/
static
int
ebml_parse_sized_int
(
unsigned
char
*
buffer
,
unsigned
char
*
buffer_end
,
int
len
,
int
is_signed
,
unsigned
long
long
*
out_value
)
{
long
long
value
;
int
i
;
if
(
len
<
1
||
len
>
8
)
{
ICECAST_LOG_DEBUG
(
"Sized int of %i bytes"
,
len
);
return
-
1
;
}
if
(
buffer
+
len
>=
buffer_end
)
{
return
0
;
}
if
(
is_signed
&&
((
signed
char
)
buffer
[
0
])
<
0
)
{
value
=
-
1
;
}
else
{
value
=
0
;
}
for
(
i
=
0
;
i
<
len
;
i
++
)
{
value
=
(
value
<<
8
)
+
((
unsigned
char
)
buffer
[
i
]);
}
*
out_value
=
value
;
return
len
;
}
Write
Preview
Supports
Markdown
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!
Cancel
Please
register
or
sign in
to comment