Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-2-2
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc-2-2
Commits
12b89e1f
Commit
12b89e1f
authored
Mar 25, 2007
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Split ExtractURIValue into a research and an extract function
parent
01b3900b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
57 additions
and
38 deletions
+57
-38
modules/control/http/http.h
modules/control/http/http.h
+3
-2
modules/control/http/util.c
modules/control/http/util.c
+54
-36
No files found.
modules/control/http/http.h
View file @
12b89e1f
...
...
@@ -125,8 +125,9 @@ void E_(HandleSeek)( intf_thread_t *p_intf, char *p_value );
/** This function extracts the value for a given argument name
* from an HTTP request */
char
*
E_
(
ExtractURIValue
)(
char
*
psz_uri
,
const
char
*
psz_name
,
char
*
psz_value
,
int
i_value_max
);
char
*
E_
(
ExtractURIValue
)(
char
*
restrict
psz_uri
,
const
char
*
restrict
psz_name
,
char
*
restrict
psz_value
,
size_t
i_value_max
);
/** \todo Describe this function */
int
E_
(
TestURIParam
)(
char
*
psz_uri
,
const
char
*
psz_name
);
...
...
modules/control/http/util.c
View file @
12b89e1f
...
...
@@ -719,10 +719,12 @@ int E_(TestURIParam)( char *psz_uri, const char *psz_name )
return
VLC_FALSE
;
}
char
*
E_
(
ExtractURIValue
)(
char
*
psz_uri
,
const
char
*
psz_name
,
char
*
psz_value
,
int
i_value_max
)
static
char
*
FindURIValue
(
char
*
psz_uri
,
const
char
*
restrict
psz_name
,
size_t
*
restrict
p_len
)
{
char
*
p
=
psz_uri
;
char
*
p
=
psz_uri
,
*
end
;
size_t
len
;
while
(
(
p
=
strstr
(
p
,
psz_name
))
)
{
...
...
@@ -733,50 +735,66 @@ char *E_(ExtractURIValue)( char *psz_uri, const char *psz_name,
p
++
;
}
if
(
p
)
if
(
p
==
NULL
)
{
int
i_len
;
*
p_len
=
0
;
return
NULL
;
}
p
+=
strlen
(
psz_name
);
if
(
*
p
==
'='
)
p
++
;
p
+=
strlen
(
psz_name
);
if
(
*
p
==
'='
)
p
++
;
if
(
strchr
(
p
,
'&'
)
)
{
i_len
=
strchr
(
p
,
'&'
)
-
p
;
}
else
{
/* for POST method */
if
(
strchr
(
p
,
'\n'
)
)
{
i_len
=
strchr
(
p
,
'\n'
)
-
p
;
if
(
i_len
&&
*
(
p
+
i_len
-
1
)
==
'\r'
)
i_len
--
;
}
else
{
i_len
=
strlen
(
p
);
}
}
i_len
=
__MIN
(
i_value_max
-
1
,
i_len
);
if
(
i_len
>
0
)
{
strncpy
(
psz_value
,
p
,
i_len
);
psz_value
[
i_len
]
=
'\0'
;
}
else
{
strncpy
(
psz_value
,
""
,
i_value_max
);
}
p
+=
i_len
;
if
(
(
end
=
strchr
(
p
,
'\n'
)
)
!=
NULL
)
{
/* POST method */
if
(
(
end
>
p
)
&&
(
end
[
-
1
]
==
'\r'
)
)
end
--
;
len
=
end
-
p
;
}
else
{
strncpy
(
psz_value
,
""
,
i_value_max
);
/* GET method */
if
(
(
end
=
strchr
(
p
,
'&'
)
)
!=
NULL
)
len
=
end
-
p
;
else
len
=
strlen
(
p
);
}
*
p_len
=
len
;
return
p
;
}
char
*
E_
(
ExtractURIValue
)(
char
*
restrict
psz_uri
,
const
char
*
restrict
psz_name
,
char
*
restrict
psz_buf
,
size_t
bufsize
)
{
size_t
len
;
char
*
psz_value
=
FindURIValue
(
psz_uri
,
psz_name
,
&
len
);
char
*
psz_next
;
fprintf
(
stderr
,
"%s within %s:
\n
"
,
psz_name
,
psz_uri
);
if
(
psz_value
==
NULL
)
{
if
(
bufsize
>
0
)
*
psz_buf
=
'\0'
;
return
NULL
;
}
psz_next
=
psz_value
+
len
;
if
(
len
>=
bufsize
)
len
=
bufsize
-
1
;
if
(
len
>
0
)
strncpy
(
psz_buf
,
psz_value
,
len
);
if
(
bufsize
>
0
)
psz_buf
[
len
]
=
'\0'
;
fprintf
(
stderr
,
"%s next %s
\n
"
,
psz_buf
,
psz_next
);
return
psz_next
;
}
/* Since the resulting string is smaller we can work in place, so it is
* permitted to have psz == new. new points to the first word of the
* string, the function returns the remaining string. */
...
...
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