Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Export a few internal symbols to make lua-sec compile #145

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ int buffer_open(lua_State *L) {
/*-------------------------------------------------------------------------*\
* Initializes C structure
\*-------------------------------------------------------------------------*/
void buffer_init(p_buffer buf, p_io io, p_timeout tm) {
LUASOCKET_API void buffer_init(p_buffer buf, p_io io, p_timeout tm) {
buf->first = buf->last = 0;
buf->io = io;
buf->tm = tm;
Expand All @@ -50,7 +50,7 @@ void buffer_init(p_buffer buf, p_io io, p_timeout tm) {
/*-------------------------------------------------------------------------*\
* object:getstats() interface
\*-------------------------------------------------------------------------*/
int buffer_meth_getstats(lua_State *L, p_buffer buf) {
LUASOCKET_API int buffer_meth_getstats(lua_State *L, p_buffer buf) {
lua_pushnumber(L, (lua_Number) buf->received);
lua_pushnumber(L, (lua_Number) buf->sent);
lua_pushnumber(L, timeout_gettime() - buf->birthday);
Expand All @@ -60,7 +60,7 @@ int buffer_meth_getstats(lua_State *L, p_buffer buf) {
/*-------------------------------------------------------------------------*\
* object:setstats() interface
\*-------------------------------------------------------------------------*/
int buffer_meth_setstats(lua_State *L, p_buffer buf) {
LUASOCKET_API int buffer_meth_setstats(lua_State *L, p_buffer buf) {
buf->received = (long) luaL_optnumber(L, 2, (lua_Number) buf->received);
buf->sent = (long) luaL_optnumber(L, 3, (lua_Number) buf->sent);
if (lua_isnumber(L, 4)) buf->birthday = timeout_gettime() - lua_tonumber(L, 4);
Expand All @@ -71,7 +71,7 @@ int buffer_meth_setstats(lua_State *L, p_buffer buf) {
/*-------------------------------------------------------------------------*\
* object:send() interface
\*-------------------------------------------------------------------------*/
int buffer_meth_send(lua_State *L, p_buffer buf) {
LUASOCKET_API int buffer_meth_send(lua_State *L, p_buffer buf) {
int top = lua_gettop(L);
int err = IO_DONE;
size_t size = 0, sent = 0;
Expand Down Expand Up @@ -104,7 +104,7 @@ int buffer_meth_send(lua_State *L, p_buffer buf) {
/*-------------------------------------------------------------------------*\
* object:receive() interface
\*-------------------------------------------------------------------------*/
int buffer_meth_receive(lua_State *L, p_buffer buf) {
LUASOCKET_API int buffer_meth_receive(lua_State *L, p_buffer buf) {
int err = IO_DONE, top = lua_gettop(L);
luaL_Buffer b;
size_t size;
Expand Down Expand Up @@ -153,7 +153,7 @@ int buffer_meth_receive(lua_State *L, p_buffer buf) {
/*-------------------------------------------------------------------------*\
* Determines if there is any data in the read buffer
\*-------------------------------------------------------------------------*/
int buffer_isempty(p_buffer buf) {
LUASOCKET_API int buffer_isempty(p_buffer buf) {
return buf->first >= buf->last;
}

Expand Down
2 changes: 1 addition & 1 deletion src/io.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
/*-------------------------------------------------------------------------*\
* Initializes C structure
\*-------------------------------------------------------------------------*/
void io_init(p_io io, p_send send, p_recv recv, p_error error, void *ctx) {
LUASOCKET_API void io_init(p_io io, p_send send, p_recv recv, p_error error, void *ctx) {
io->send = send;
io->recv = recv;
io->error = error;
Expand Down
6 changes: 3 additions & 3 deletions src/timeout.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ static luaL_Reg func[] = {
/*-------------------------------------------------------------------------*\
* Initialize structure
\*-------------------------------------------------------------------------*/
void timeout_init(p_timeout tm, double block, double total) {
LUASOCKET_API void timeout_init(p_timeout tm, double block, double total) {
tm->block = block;
tm->total = total;
}
Expand Down Expand Up @@ -111,7 +111,7 @@ double timeout_getretry(p_timeout tm) {
* Input
* tm: timeout control structure
\*-------------------------------------------------------------------------*/
p_timeout timeout_markstart(p_timeout tm) {
LUASOCKET_API p_timeout timeout_markstart(p_timeout tm) {
tm->start = timeout_gettime();
return tm;
}
Expand Down Expand Up @@ -158,7 +158,7 @@ int timeout_open(lua_State *L) {
* time: time out value in seconds
* mode: "b" for block timeout, "t" for total timeout. (default: b)
\*-------------------------------------------------------------------------*/
int timeout_meth_settimeout(lua_State *L, p_timeout tm) {
LUASOCKET_API int timeout_meth_settimeout(lua_State *L, p_timeout tm) {
double t = luaL_optnumber(L, 2, -1);
const char *mode = luaL_optstring(L, 3, "b");
switch (*mode) {
Expand Down
12 changes: 6 additions & 6 deletions src/usocket.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#define WAITFD_R POLLIN
#define WAITFD_W POLLOUT
#define WAITFD_C (POLLIN|POLLOUT)
int socket_waitfd(p_socket ps, int sw, p_timeout tm) {
LUASOCKET_API int socket_waitfd(p_socket ps, int sw, p_timeout tm) {
int ret;
struct pollfd pfd;
pfd.fd = *ps;
Expand Down Expand Up @@ -75,7 +75,7 @@ int socket_waitfd(p_socket ps, int sw, p_timeout tm) {
/*-------------------------------------------------------------------------*\
* Initializes module
\*-------------------------------------------------------------------------*/
int socket_open(void) {
LUASOCKET_API int socket_open(void) {
/* instals a handler to ignore sigpipe or it will crash us */
signal(SIGPIPE, SIG_IGN);
return 1;
Expand All @@ -91,7 +91,7 @@ int socket_close(void) {
/*-------------------------------------------------------------------------*\
* Close and inutilize socket
\*-------------------------------------------------------------------------*/
void socket_destroy(p_socket ps) {
LUASOCKET_API void socket_destroy(p_socket ps) {
if (*ps != SOCKET_INVALID) {
close(*ps);
*ps = SOCKET_INVALID;
Expand Down Expand Up @@ -354,7 +354,7 @@ int socket_read(p_socket ps, char *data, size_t count, size_t *got, p_timeout tm
/*-------------------------------------------------------------------------*\
* Put socket into blocking mode
\*-------------------------------------------------------------------------*/
void socket_setblocking(p_socket ps) {
LUASOCKET_API void socket_setblocking(p_socket ps) {
int flags = fcntl(*ps, F_GETFL, 0);
flags &= (~(O_NONBLOCK));
fcntl(*ps, F_SETFL, flags);
Expand All @@ -363,7 +363,7 @@ void socket_setblocking(p_socket ps) {
/*-------------------------------------------------------------------------*\
* Put socket into non-blocking mode
\*-------------------------------------------------------------------------*/
void socket_setnonblocking(p_socket ps) {
LUASOCKET_API void socket_setnonblocking(p_socket ps) {
int flags = fcntl(*ps, F_GETFL, 0);
flags |= O_NONBLOCK;
fcntl(*ps, F_SETFL, flags);
Expand Down Expand Up @@ -400,7 +400,7 @@ const char *socket_hoststrerror(int err) {
}
}

const char *socket_strerror(int err) {
LUASOCKET_API const char *socket_strerror(int err) {
if (err <= 0) return io_strerror(err);
switch (err) {
case EADDRINUSE: return PIE_ADDRINUSE;
Expand Down