Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
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
Commits
5318fb66
Commit
5318fb66
authored
Feb 13, 2012
by
Samuel Pitoiset
Committed by
Rafaël Carré
Feb 14, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Audioscrobbler: Replace ParseURL() by vlc_UrlParse().
Signed-off-by:
Rafaël Carré
<
funman@videolan.org
>
parent
1582699a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
86 deletions
+9
-86
modules/misc/audioscrobbler.c
modules/misc/audioscrobbler.c
+9
-86
No files found.
modules/misc/audioscrobbler.c
View file @
5318fb66
...
...
@@ -77,9 +77,7 @@ struct intf_sys_t
vlc_cond_t
wait
;
/**< song to submit event */
/* submission of played songs */
char
*
psz_submit_host
;
/**< where to submit data */
int
i_submit_port
;
/**< port to which submit */
char
*
psz_submit_file
;
/**< file to which submit */
vlc_url_t
p_submit_url
;
/**< where to submit data */
/* submission of playing song */
#if 0 //NOT USED
...
...
@@ -451,8 +449,7 @@ static void Close(vlc_object_t *p_this)
int
i
;
for
(
i
=
0
;
i
<
p_sys
->
i_songs
;
i
++
)
DeleteSong
(
&
p_sys
->
p_queue
[
i
]);
free
(
p_sys
->
psz_submit_host
);
free
(
p_sys
->
psz_submit_file
);
vlc_UrlClean
(
&
p_sys
->
p_submit_url
);
#if 0 //NOT USED
free(p_sys->psz_nowp_host);
free(p_sys->psz_nowp_file);
...
...
@@ -462,69 +459,6 @@ static void Close(vlc_object_t *p_this)
free
(
p_sys
);
}
/*****************************************************************************
* ParseURL : Split an http:// URL into host, file, and port
*
* Example: "62.216.251.205:80/protocol_1.2"
* will be split into "62.216.251.205", 80, "protocol_1.2"
*
* psz_url will be freed before returning
* *psz_file & *psz_host will be freed before use
*
* Return value:
* VLC_ENOMEM Out Of Memory
* VLC_EGENERIC Invalid url provided
* VLC_SUCCESS Success
*****************************************************************************/
static
int
ParseURL
(
char
*
psz_url
,
char
**
psz_host
,
char
**
psz_file
,
int
*
i_port
)
{
size_t
i_pos
;
size_t
i_len
=
strlen
(
psz_url
);
bool
b_no_port
=
false
;
FREENULL
(
*
psz_host
);
FREENULL
(
*
psz_file
);
i_pos
=
strcspn
(
psz_url
,
":"
);
if
(
i_pos
==
i_len
)
{
*
i_port
=
80
;
i_pos
=
strcspn
(
psz_url
,
"/"
);
b_no_port
=
true
;
}
*
psz_host
=
strndup
(
psz_url
,
i_pos
);
if
(
!*
psz_host
)
return
VLC_ENOMEM
;
if
(
!
b_no_port
)
{
i_pos
++
;
/* skip the ':' */
*
i_port
=
atoi
(
psz_url
+
i_pos
);
if
(
*
i_port
<=
0
)
{
FREENULL
(
*
psz_host
);
return
VLC_EGENERIC
;
}
i_pos
=
strcspn
(
psz_url
,
"/"
);
}
if
(
i_pos
==
i_len
)
return
VLC_EGENERIC
;
i_pos
++
;
/* skip the '/' */
*
psz_file
=
strdup
(
psz_url
+
i_pos
);
if
(
!*
psz_file
)
{
FREENULL
(
*
psz_host
);
return
VLC_ENOMEM
;
}
return
VLC_SUCCESS
;
}
/*****************************************************************************
* Handshake : Init audioscrobbler connection
*****************************************************************************/
...
...
@@ -716,21 +650,10 @@ static int Handshake(intf_thread_t *p_this)
if
(
!
psz_url
)
goto
oom
;
int
ret
=
ParseURL
(
psz_url
,
&
p_sys
->
psz_submit_host
,
&
p_sys
->
psz_submit_file
,
&
p_sys
->
i_submit_port
);
/* parse the submission url */
vlc_UrlParse
(
&
p_sys
->
p_submit_url
,
psz_url
,
0
);
free
(
psz_url
);
switch
(
ret
)
{
case
VLC_ENOMEM
:
goto
oom
;
case
VLC_EGENERIC
:
goto
proto
;
case
VLC_SUCCESS
:
default:
break
;
}
return
VLC_SUCCESS
;
oom:
...
...
@@ -879,8 +802,8 @@ static void Run(intf_thread_t *p_intf)
}
vlc_mutex_unlock
(
&
p_sys
->
lock
);
int
i_post_socket
=
net_ConnectTCP
(
p_intf
,
p_sys
->
p
sz_submit
_host
,
p_sys
->
i_submit
_port
);
int
i_post_socket
=
net_ConnectTCP
(
p_intf
,
p_sys
->
p
_submit_url
.
psz
_host
,
p_sys
->
p_submit_url
.
i
_port
);
if
(
i_post_socket
==
-
1
)
{
...
...
@@ -893,7 +816,7 @@ static void Run(intf_thread_t *p_intf)
/* we transmit the data */
int
i_net_ret
=
net_Printf
(
p_intf
,
i_post_socket
,
NULL
,
"POST
/
%s HTTP/1.1
\n
"
"POST %s HTTP/1.1
\n
"
"Accept-Encoding: identity
\n
"
"Content-length: %zu
\n
"
"Connection: close
\n
"
...
...
@@ -903,8 +826,8 @@ static void Run(intf_thread_t *p_intf)
"
\r\n
"
"%s
\r\n
"
"
\r\n
"
,
p_sys
->
p
sz_submit_file
,
strlen
(
psz_submit
),
p_sys
->
p
sz_submit
_host
,
psz_submit
p_sys
->
p
_submit_url
.
psz_path
,
strlen
(
psz_submit
),
p_sys
->
p
_submit_url
.
psz
_host
,
psz_submit
);
free
(
psz_submit
);
...
...
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