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
477af15c
Commit
477af15c
authored
Feb 15, 2007
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use size_t or ssize_t when appropriate
parent
6a07fcd8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
55 deletions
+41
-55
include/vlc_network.h
include/vlc_network.h
+6
-6
src/network/io.c
src/network/io.c
+35
-49
No files found.
include/vlc_network.h
View file @
477af15c
...
...
@@ -125,24 +125,24 @@ struct virtual_socket_t
};
#define net_Read(a,b,c,d,e,f) __net_Read(VLC_OBJECT(a),b,c,d,e,f)
VLC_EXPORT
(
int
,
__net_Read
,
(
vlc_object_t
*
p_this
,
int
fd
,
const
v_socket_t
*
,
uint8_t
*
p_data
,
in
t
i_data
,
vlc_bool_t
b_retry
)
);
VLC_EXPORT
(
ssize_t
,
__net_Read
,
(
vlc_object_t
*
p_this
,
int
fd
,
const
v_socket_t
*
,
uint8_t
*
p_data
,
size_
t
i_data
,
vlc_bool_t
b_retry
)
);
#define net_ReadNonBlock(a,b,c,d,e,f) __net_ReadNonBlock(VLC_OBJECT(a),b,c,d,e,f)
VLC_EXPORT
(
int
,
__net_ReadNonBlock
,
(
vlc_object_t
*
p_this
,
int
fd
,
const
v_socket_t
*
,
uint8_t
*
p_data
,
in
t
i_data
,
mtime_t
i_wait
)
);
VLC_EXPORT
(
ssize_t
,
__net_ReadNonBlock
,
(
vlc_object_t
*
p_this
,
int
fd
,
const
v_socket_t
*
,
uint8_t
*
p_data
,
size_
t
i_data
,
mtime_t
i_wait
)
);
#define net_Select(a,b,c,d,e,f) __net_Select(VLC_OBJECT(a),b,c,d,e,f)
VLC_EXPORT
(
int
,
__net_Select
,
(
vlc_object_t
*
p_this
,
const
int
*
pi_fd
,
int
i_fd
,
uint8_t
*
p_data
,
in
t
i_data
,
mtime_t
i_wait
)
);
VLC_EXPORT
(
ssize_t
,
__net_Select
,
(
vlc_object_t
*
p_this
,
const
int
*
pi_fd
,
int
i_fd
,
uint8_t
*
p_data
,
size_
t
i_data
,
mtime_t
i_wait
)
);
#define net_Write(a,b,c,d,e) __net_Write(VLC_OBJECT(a),b,c,d,e)
VLC_EXPORT
(
int
,
__net_Write
,
(
vlc_object_t
*
p_this
,
int
fd
,
const
v_socket_t
*
,
const
uint8_t
*
p_data
,
in
t
i_data
)
);
VLC_EXPORT
(
ssize_t
,
__net_Write
,
(
vlc_object_t
*
p_this
,
int
fd
,
const
v_socket_t
*
,
const
uint8_t
*
p_data
,
size_
t
i_data
)
);
#define net_Gets(a,b,c) __net_Gets(VLC_OBJECT(a),b,c)
VLC_EXPORT
(
char
*
,
__net_Gets
,
(
vlc_object_t
*
p_this
,
int
fd
,
const
v_socket_t
*
)
);
VLC_EXPORT
(
in
t
,
net_Printf
,
(
vlc_object_t
*
p_this
,
int
fd
,
const
v_socket_t
*
,
const
char
*
psz_fmt
,
...
)
);
VLC_EXPORT
(
ssize_
t
,
net_Printf
,
(
vlc_object_t
*
p_this
,
int
fd
,
const
v_socket_t
*
,
const
char
*
psz_fmt
,
...
)
);
#define net_vaPrintf(a,b,c,d,e) __net_vaPrintf(VLC_OBJECT(a),b,c,d,e)
VLC_EXPORT
(
in
t
,
__net_vaPrintf
,
(
vlc_object_t
*
p_this
,
int
fd
,
const
v_socket_t
*
,
const
char
*
psz_fmt
,
va_list
args
)
);
VLC_EXPORT
(
ssize_
t
,
__net_vaPrintf
,
(
vlc_object_t
*
p_this
,
int
fd
,
const
v_socket_t
*
,
const
char
*
psz_fmt
,
va_list
args
)
);
#ifndef HAVE_INET_PTON
...
...
src/network/io.c
View file @
477af15c
...
...
@@ -402,13 +402,13 @@ error:
* If b_retry is true, then we repeat until we have read the right amount of
* data
*****************************************************************************/
in
t
__net_Read
(
vlc_object_t
*
restrict
p_this
,
int
fd
,
const
v_socket_t
*
restrict
p_vs
,
uint8_t
*
restrict
p_data
,
int
i_data
,
vlc_bool_t
b_retry
)
ssize_
t
__net_Read
(
vlc_object_t
*
restrict
p_this
,
int
fd
,
const
v_socket_t
*
restrict
p_vs
,
uint8_t
*
restrict
buf
,
size_t
len
,
vlc_bool_t
b_retry
)
{
return
net_ReadInner
(
p_this
,
1
,
&
(
int
){
fd
},
&
(
const
v_socket_t
*
){
p_vs
},
p_data
,
i_data
,
-
1
,
b_retry
);
&
(
const
v_socket_t
*
){
p_vs
},
buf
,
len
,
-
1
,
b_retry
);
}
...
...
@@ -417,13 +417,13 @@ int __net_Read( vlc_object_t *restrict p_this, int fd,
*****************************************************************************
* Read from a network socket, non blocking mode (with timeout)
*****************************************************************************/
in
t
__net_ReadNonBlock
(
vlc_object_t
*
restrict
p_this
,
int
fd
,
const
v_socket_t
*
restrict
p_vs
,
uint8_t
*
restrict
p_data
,
int
i_data
,
mtime_t
i_wait
)
ssize_
t
__net_ReadNonBlock
(
vlc_object_t
*
restrict
p_this
,
int
fd
,
const
v_socket_t
*
restrict
p_vs
,
uint8_t
*
restrict
buf
,
size_t
len
,
mtime_t
i_wait
)
{
return
net_ReadInner
(
p_this
,
1
,
&
(
int
){
fd
},
&
(
const
v_socket_t
*
){
p_vs
},
p_data
,
i_data
,
i_wait
/
1000
,
VLC_FALSE
);
buf
,
len
,
i_wait
/
1000
,
VLC_FALSE
);
}
...
...
@@ -433,69 +433,48 @@ int __net_ReadNonBlock( vlc_object_t *restrict p_this, int fd,
* Read from several sockets (with timeout). Takes data from the first socket
* that has some.
*****************************************************************************/
int
__net_Select
(
vlc_object_t
*
restrict
p_this
,
const
int
*
restrict
pi_fd
,
int
i_fd
,
uint8_t
*
restrict
p_data
,
int
i_data
,
mtime_t
i_wait
)
ssize_t
__net_Select
(
vlc_object_t
*
restrict
p_this
,
const
int
*
restrict
fds
,
int
nfd
,
uint8_t
*
restrict
buf
,
size_t
len
,
mtime_t
i_wait
)
{
const
v_socket_t
*
vsv
[
i_
fd
];
const
v_socket_t
*
vsv
[
n
fd
];
memset
(
vsv
,
0
,
sizeof
(
vsv
)
);
return
net_ReadInner
(
p_this
,
i_fd
,
pi_fd
,
vsv
,
p_data
,
i_data
,
return
net_ReadInner
(
p_this
,
nfd
,
fds
,
vsv
,
buf
,
len
,
i_wait
/
1000
,
VLC_FALSE
);
}
/* Write exact amount requested */
in
t
__net_Write
(
vlc_object_t
*
p_this
,
int
fd
,
const
v_socket_t
*
p_vs
,
const
uint8_t
*
p_data
,
in
t
i_data
)
ssize_
t
__net_Write
(
vlc_object_t
*
p_this
,
int
fd
,
const
v_socket_t
*
p_vs
,
const
uint8_t
*
p_data
,
size_
t
i_data
)
{
size_t
i_total
=
0
;
while
(
i_data
>
0
)
{
if
(
p_this
->
b_die
)
return
i_total
;
break
;
#ifdef HAVE_POLL
struct
pollfd
ufd
[
1
];
memset
(
ufd
,
0
,
sizeof
(
ufd
));
ufd
[
0
].
fd
=
fd
;
ufd
[
0
].
events
=
POLLOUT
;
int
val
=
poll
(
ufd
,
1
,
500
);
if
((
val
>
0
)
&&
(
ufd
[
0
].
revents
&
POLLERR
)
&&
(
i_total
>
0
))
return
i_total
;
// error will be dequeued separately on next call
#else
fd_set
set
;
FD_ZERO
(
&
set
);
#if !defined(WIN32) && !defined(UNDER_CE)
if
(
fd
>=
FD_SETSIZE
)
{
/* We don't want to overflow select() fd_set */
msg_Err
(
p_this
,
"select set overflow"
);
return
-
1
;
}
#endif
FD_SET
(
fd
,
&
set
);
int
val
=
select
(
fd
+
1
,
NULL
,
&
set
,
NULL
,
&
(
struct
timeval
){
0
,
500000
});
#endif
switch
(
val
)
{
case
-
1
:
if
(
errno
!=
EINTR
)
{
msg_Err
(
p_this
,
"Write error: %s"
,
net_strerror
(
net_errno
));
return
i_total
?
(
int
)
i_total
:
-
1
;
}
msg_Err
(
p_this
,
"Write error: %s"
,
net_strerror
(
net_errno
));
goto
out
;
case
0
:
continue
;
}
if
((
ufd
[
0
].
revents
&
POLLERR
)
&&
(
i_total
>
0
))
return
i_total
;
// error will be dequeued separately on next call
if
(
p_vs
!=
NULL
)
val
=
p_vs
->
pf_send
(
p_vs
->
p_sys
,
p_data
,
i_data
);
else
...
...
@@ -506,7 +485,10 @@ int __net_Write( vlc_object_t *p_this, int fd, const v_socket_t *p_vs,
#endif
if
(
val
==
-
1
)
return
i_total
?
(
int
)
i_total
:
-
1
;
{
msg_Err
(
p_this
,
"Write error: %s"
,
net_strerror
(
net_errno
));
break
;
}
if
(
val
==
0
)
return
i_total
;
...
...
@@ -515,7 +497,11 @@ int __net_Write( vlc_object_t *p_this, int fd, const v_socket_t *p_vs,
i_total
+=
val
;
}
return
i_total
;
out:
if
((
i_total
>
0
)
||
(
i_data
==
0
))
return
i_total
;
return
-
1
;
}
char
*
__net_Gets
(
vlc_object_t
*
p_this
,
int
fd
,
const
v_socket_t
*
p_vs
)
...
...
@@ -558,8 +544,8 @@ char *__net_Gets( vlc_object_t *p_this, int fd, const v_socket_t *p_vs )
return
psz_line
;
}
in
t
net_Printf
(
vlc_object_t
*
p_this
,
int
fd
,
const
v_socket_t
*
p_vs
,
const
char
*
psz_fmt
,
...
)
ssize_
t
net_Printf
(
vlc_object_t
*
p_this
,
int
fd
,
const
v_socket_t
*
p_vs
,
const
char
*
psz_fmt
,
...
)
{
int
i_ret
;
va_list
args
;
...
...
@@ -570,8 +556,8 @@ int net_Printf( vlc_object_t *p_this, int fd, const v_socket_t *p_vs,
return
i_ret
;
}
in
t
__net_vaPrintf
(
vlc_object_t
*
p_this
,
int
fd
,
const
v_socket_t
*
p_vs
,
const
char
*
psz_fmt
,
va_list
args
)
ssize_
t
__net_vaPrintf
(
vlc_object_t
*
p_this
,
int
fd
,
const
v_socket_t
*
p_vs
,
const
char
*
psz_fmt
,
va_list
args
)
{
char
*
psz
;
int
i_size
,
i_ret
;
...
...
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