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
1908e010
Commit
1908e010
authored
Apr 23, 2014
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lua: do not pass -1 to read/write/recv/send
parent
e39e93a4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
11 deletions
+12
-11
modules/lua/libs/net.c
modules/lua/libs/net.c
+12
-11
No files found.
modules/lua/libs/net.c
View file @
1908e010
...
...
@@ -280,21 +280,22 @@ static int vlclua_net_close( lua_State *L )
static
int
vlclua_net_send
(
lua_State
*
L
)
{
int
i_fd
=
luaL_checkint
(
L
,
1
);
int
fd
=
vlclua_fd_get
(
L
,
luaL_checkint
(
L
,
1
)
);
size_t
i_len
;
const
char
*
psz_buffer
=
luaL_checklstring
(
L
,
2
,
&
i_len
);
i_len
=
luaL_optint
(
L
,
3
,
i_len
);
i_len
=
send
(
vlclua_fd_get
(
L
,
i_fd
),
psz_buffer
,
i_len
,
0
);
lua_pushinteger
(
L
,
i_len
);
lua_pushinteger
(
L
,
(
fd
!=
-
1
)
?
send
(
fd
,
psz_buffer
,
i_len
,
0
)
:
-
1
);
return
1
;
}
static
int
vlclua_net_recv
(
lua_State
*
L
)
{
int
i_fd
=
luaL_checkint
(
L
,
1
);
int
fd
=
vlclua_fd_get
(
L
,
luaL_checkint
(
L
,
1
)
);
size_t
i_len
=
luaL_optint
(
L
,
2
,
1
);
char
psz_buffer
[
i_len
];
ssize_t
i_ret
=
recv
(
vlclua_fd_get
(
L
,
i_fd
),
psz_buffer
,
i_len
,
0
);
ssize_t
i_ret
=
(
fd
!=
-
1
)
?
recv
(
fd
,
psz_buffer
,
i_len
,
0
)
:
-
1
;
if
(
i_ret
>
0
)
lua_pushlstring
(
L
,
psz_buffer
,
i_ret
);
else
...
...
@@ -372,22 +373,22 @@ static int vlclua_fd_open( lua_State *L )
static
int
vlclua_fd_write
(
lua_State
*
L
)
{
int
i_fd
=
luaL_checkint
(
L
,
1
);
int
fd
=
vlclua_fd_get
(
L
,
luaL_checkint
(
L
,
1
)
);
size_t
i_len
;
ssize_t
i_ret
;
const
char
*
psz_buffer
=
luaL_checklstring
(
L
,
2
,
&
i_len
);
i_len
=
luaL_optint
(
L
,
3
,
i_len
);
i_ret
=
write
(
vlclua_fd_get
(
L
,
i_fd
),
psz_buffer
,
i_len
);
lua_pushinteger
(
L
,
i_ret
);
lua_pushinteger
(
L
,
(
fd
!=
-
1
)
?
write
(
fd
,
psz_buffer
,
i_len
)
:
-
1
);
return
1
;
}
static
int
vlclua_fd_read
(
lua_State
*
L
)
{
int
i_fd
=
luaL_checkint
(
L
,
1
);
int
fd
=
vlclua_fd_get
(
L
,
luaL_checkint
(
L
,
1
)
);
size_t
i_len
=
luaL_optint
(
L
,
2
,
1
);
char
psz_buffer
[
i_len
];
ssize_t
i_ret
=
read
(
vlclua_fd_get
(
L
,
i_fd
),
psz_buffer
,
i_len
);
ssize_t
i_ret
=
(
fd
!=
-
1
)
?
read
(
fd
,
psz_buffer
,
i_len
)
:
-
1
;
if
(
i_ret
>
0
)
lua_pushlstring
(
L
,
psz_buffer
,
i_ret
);
else
...
...
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