aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorE. Westbrook <github@westbrook.io>2019-02-25 15:58:54 -0700
committerE. Westbrook <github@westbrook.io>2019-02-25 15:58:54 -0700
commit731b23bc891fdf6136af7457972b8a8f8f1b55ec (patch)
tree2a59c13fdbf90746a78eb2f6c824ced790d16f8d
parent395729d4314dfeda2a095760cf2de042af7581f8 (diff)
downloadluasocket-731b23bc891fdf6136af7457972b8a8f8f1b55ec.tar.gz
luasocket-731b23bc891fdf6136af7457972b8a8f8f1b55ec.tar.bz2
luasocket-731b23bc891fdf6136af7457972b8a8f8f1b55ec.zip
inet.c: use LUASOCKET_PRIVATE
-rw-r--r--src/inet.c26
1 files changed, 14 insertions, 12 deletions
diff --git a/src/inet.c b/src/inet.c
index f4c8404..bed8a7c 100644
--- a/src/inet.c
+++ b/src/inet.c
@@ -2,6 +2,8 @@
2* Internet domain functions 2* Internet domain functions
3* LuaSocket toolkit 3* LuaSocket toolkit
4\*=========================================================================*/ 4\*=========================================================================*/
5#include "luasocket.h"
6
5#include <stdio.h> 7#include <stdio.h>
6#include <stdlib.h> 8#include <stdlib.h>
7#include <string.h> 9#include <string.h>
@@ -38,7 +40,7 @@ static luaL_Reg func[] = {
38/*-------------------------------------------------------------------------*\ 40/*-------------------------------------------------------------------------*\
39* Initializes module 41* Initializes module
40\*-------------------------------------------------------------------------*/ 42\*-------------------------------------------------------------------------*/
41int inet_open(lua_State *L) 43LUASOCKET_PRIVATE int inet_open(lua_State *L)
42{ 44{
43 lua_pushstring(L, "dns"); 45 lua_pushstring(L, "dns");
44 lua_newtable(L); 46 lua_newtable(L);
@@ -143,7 +145,7 @@ static int inet_global_toip(lua_State *L)
143 return 2; 145 return 2;
144} 146}
145 147
146int inet_optfamily(lua_State* L, int narg, const char* def) 148LUASOCKET_PRIVATE int inet_optfamily(lua_State* L, int narg, const char* def)
147{ 149{
148 static const char* optname[] = { "unspec", "inet", "inet6", NULL }; 150 static const char* optname[] = { "unspec", "inet", "inet6", NULL };
149 static int optvalue[] = { AF_UNSPEC, AF_INET, AF_INET6, 0 }; 151 static int optvalue[] = { AF_UNSPEC, AF_INET, AF_INET6, 0 };
@@ -151,7 +153,7 @@ int inet_optfamily(lua_State* L, int narg, const char* def)
151 return optvalue[luaL_checkoption(L, narg, def, optname)]; 153 return optvalue[luaL_checkoption(L, narg, def, optname)];
152} 154}
153 155
154int inet_optsocktype(lua_State* L, int narg, const char* def) 156LUASOCKET_PRIVATE int inet_optsocktype(lua_State* L, int narg, const char* def)
155{ 157{
156 static const char* optname[] = { "stream", "dgram", NULL }; 158 static const char* optname[] = { "stream", "dgram", NULL };
157 static int optvalue[] = { SOCK_STREAM, SOCK_DGRAM, 0 }; 159 static int optvalue[] = { SOCK_STREAM, SOCK_DGRAM, 0 };
@@ -242,7 +244,7 @@ static int inet_global_gethostname(lua_State *L)
242/*-------------------------------------------------------------------------*\ 244/*-------------------------------------------------------------------------*\
243* Retrieves socket peer name 245* Retrieves socket peer name
244\*-------------------------------------------------------------------------*/ 246\*-------------------------------------------------------------------------*/
245int inet_meth_getpeername(lua_State *L, p_socket ps, int family) 247LUASOCKET_PRIVATE int inet_meth_getpeername(lua_State *L, p_socket ps, int family)
246{ 248{
247 int err; 249 int err;
248 struct sockaddr_storage peer; 250 struct sockaddr_storage peer;
@@ -276,7 +278,7 @@ int inet_meth_getpeername(lua_State *L, p_socket ps, int family)
276/*-------------------------------------------------------------------------*\ 278/*-------------------------------------------------------------------------*\
277* Retrieves socket local name 279* Retrieves socket local name
278\*-------------------------------------------------------------------------*/ 280\*-------------------------------------------------------------------------*/
279int inet_meth_getsockname(lua_State *L, p_socket ps, int family) 281LUASOCKET_PRIVATE int inet_meth_getsockname(lua_State *L, p_socket ps, int family)
280{ 282{
281 int err; 283 int err;
282 struct sockaddr_storage peer; 284 struct sockaddr_storage peer;
@@ -352,7 +354,7 @@ static void inet_pushresolved(lua_State *L, struct hostent *hp)
352/*-------------------------------------------------------------------------*\ 354/*-------------------------------------------------------------------------*\
353* Tries to create a new inet socket 355* Tries to create a new inet socket
354\*-------------------------------------------------------------------------*/ 356\*-------------------------------------------------------------------------*/
355const char *inet_trycreate(p_socket ps, int family, int type, int protocol) { 357LUASOCKET_PRIVATE const char *inet_trycreate(p_socket ps, int family, int type, int protocol) {
356 const char *err = socket_strerror(socket_create(ps, family, type, protocol)); 358 const char *err = socket_strerror(socket_create(ps, family, type, protocol));
357 if (err == NULL && family == AF_INET6) { 359 if (err == NULL && family == AF_INET6) {
358 int yes = 1; 360 int yes = 1;
@@ -364,7 +366,7 @@ const char *inet_trycreate(p_socket ps, int family, int type, int protocol) {
364/*-------------------------------------------------------------------------*\ 366/*-------------------------------------------------------------------------*\
365* "Disconnects" a DGRAM socket 367* "Disconnects" a DGRAM socket
366\*-------------------------------------------------------------------------*/ 368\*-------------------------------------------------------------------------*/
367const char *inet_trydisconnect(p_socket ps, int family, p_timeout tm) 369LUASOCKET_PRIVATE const char *inet_trydisconnect(p_socket ps, int family, p_timeout tm)
368{ 370{
369 switch (family) { 371 switch (family) {
370 case AF_INET: { 372 case AF_INET: {
@@ -391,7 +393,7 @@ const char *inet_trydisconnect(p_socket ps, int family, p_timeout tm)
391/*-------------------------------------------------------------------------*\ 393/*-------------------------------------------------------------------------*\
392* Tries to connect to remote address (address, port) 394* Tries to connect to remote address (address, port)
393\*-------------------------------------------------------------------------*/ 395\*-------------------------------------------------------------------------*/
394const char *inet_tryconnect(p_socket ps, int *family, const char *address, 396LUASOCKET_PRIVATE const char *inet_tryconnect(p_socket ps, int *family, const char *address,
395 const char *serv, p_timeout tm, struct addrinfo *connecthints) 397 const char *serv, p_timeout tm, struct addrinfo *connecthints)
396{ 398{
397 struct addrinfo *iterator = NULL, *resolved = NULL; 399 struct addrinfo *iterator = NULL, *resolved = NULL;
@@ -437,7 +439,7 @@ const char *inet_tryconnect(p_socket ps, int *family, const char *address,
437/*-------------------------------------------------------------------------*\ 439/*-------------------------------------------------------------------------*\
438* Tries to accept a socket 440* Tries to accept a socket
439\*-------------------------------------------------------------------------*/ 441\*-------------------------------------------------------------------------*/
440const char *inet_tryaccept(p_socket server, int family, p_socket client, 442LUASOCKET_PRIVATE const char *inet_tryaccept(p_socket server, int family, p_socket client,
441 p_timeout tm) { 443 p_timeout tm) {
442 socklen_t len; 444 socklen_t len;
443 t_sockaddr_storage addr; 445 t_sockaddr_storage addr;
@@ -453,7 +455,7 @@ const char *inet_tryaccept(p_socket server, int family, p_socket client,
453/*-------------------------------------------------------------------------*\ 455/*-------------------------------------------------------------------------*\
454* Tries to bind socket to (address, port) 456* Tries to bind socket to (address, port)
455\*-------------------------------------------------------------------------*/ 457\*-------------------------------------------------------------------------*/
456const char *inet_trybind(p_socket ps, int *family, const char *address, 458LUASOCKET_PRIVATE const char *inet_trybind(p_socket ps, int *family, const char *address,
457 const char *serv, struct addrinfo *bindhints) { 459 const char *serv, struct addrinfo *bindhints) {
458 struct addrinfo *iterator = NULL, *resolved = NULL; 460 struct addrinfo *iterator = NULL, *resolved = NULL;
459 const char *err = NULL; 461 const char *err = NULL;
@@ -497,7 +499,7 @@ const char *inet_trybind(p_socket ps, int *family, const char *address,
497* Some systems do not provide these so that we provide our own. 499* Some systems do not provide these so that we provide our own.
498\*-------------------------------------------------------------------------*/ 500\*-------------------------------------------------------------------------*/
499#ifdef LUASOCKET_INET_ATON 501#ifdef LUASOCKET_INET_ATON
500int inet_aton(const char *cp, struct in_addr *inp) 502LUASOCKET_PRIVATE int inet_aton(const char *cp, struct in_addr *inp)
501{ 503{
502 unsigned int a = 0, b = 0, c = 0, d = 0; 504 unsigned int a = 0, b = 0, c = 0, d = 0;
503 int n = 0, r; 505 int n = 0, r;
@@ -519,7 +521,7 @@ int inet_aton(const char *cp, struct in_addr *inp)
519#endif 521#endif
520 522
521#ifdef LUASOCKET_INET_PTON 523#ifdef LUASOCKET_INET_PTON
522int inet_pton(int af, const char *src, void *dst) 524LUASOCKET_PRIVATE int inet_pton(int af, const char *src, void *dst)
523{ 525{
524 struct addrinfo hints, *res; 526 struct addrinfo hints, *res;
525 int ret = 1; 527 int ret = 1;