summaryrefslogtreecommitdiff
path: root/src/common/socket.h
diff options
context:
space:
mode:
authorHaru <haru@dotalux.com>2015-06-18 01:52:38 +0200
committerHaru <haru@dotalux.com>2015-08-15 00:51:38 +0200
commit1034bfb7a390cb21623c3892f4d2304e2458af79 (patch)
tree236ce246af0d248cff51bb85725a735c5aeccb06 /src/common/socket.h
parent747d3b7d5c6056470b1c9d3f41e09e0ed92af6d6 (diff)
downloadhercules-1034bfb7a390cb21623c3892f4d2304e2458af79.tar.gz
hercules-1034bfb7a390cb21623c3892f4d2304e2458af79.tar.bz2
hercules-1034bfb7a390cb21623c3892f4d2304e2458af79.tar.xz
hercules-1034bfb7a390cb21623c3892f4d2304e2458af79.zip
Cleaned up socket interface
- Replaced some macro calls with the proper interface syntax - Removed useless macros and workarounds API changes summary: - WFIFOSET() can now be safely used both inside and outside socket.c - RFIFOSKIP() can now be safely used both inside and outside socket.c - do_close() is now sockt->close() - flush_fifo() is now sockt->flush() - flush_fifos() is now sockt->flush_fifos() - getips() is now sockt->getips() - host2ip() is now sockt->host2ip() - ip2str() is now sockt->ip2str() - ntows() is now sockt->ntows() - make_connection() is now sockt->make_connection() - make_listen_bind() is now sockt->make_listen_bind() - realloc_fifo() is now sockt->realloc_fifo() - realloc_writefifo() is now sockt->realloc_writefifo() - session_isActive() is now sockt->session_is_active() - session_isValid() is now sockt->session_is_valid() - set_defaultparse() is now sockt->set_defaultparse() - set_eof() is now sockt->eof() - set_noblocking() is now sockt->set_noblocking() - str2ip() is now sockt->str2ip() Signed-off-by: Haru <haru@dotalux.com>
Diffstat (limited to 'src/common/socket.h')
-rw-r--r--src/common/socket.h42
1 files changed, 11 insertions, 31 deletions
diff --git a/src/common/socket.h b/src/common/socket.h
index 26b674d43..e7046b0d1 100644
--- a/src/common/socket.h
+++ b/src/common/socket.h
@@ -23,7 +23,7 @@ struct HPluginData;
// socket I/O macros
#define RFIFOHEAD(fd)
-#define WFIFOHEAD(fd, size) do{ if((fd) && session[fd]->wdata_size + (size) > session[fd]->max_wdata ) realloc_writefifo((fd), (size)); }while(0)
+#define WFIFOHEAD(fd, size) do{ if((fd) && session[fd]->wdata_size + (size) > session[fd]->max_wdata ) sockt->realloc_writefifo((fd), (size)); }while(0)
#define RFIFOP(fd,pos) (session[fd]->rdata + session[fd]->rdata_pos + (pos))
#define WFIFOP(fd,pos) (session[fd]->wdata + session[fd]->wdata_size + (pos))
@@ -50,6 +50,9 @@ struct HPluginData;
} \
} while(0)
+#define WFIFOSET(fd, len) (sockt->wfifoset(fd, len))
+#define RFIFOSKIP(fd, len) (sockt->rfifoskip(fd, len))
+
/* [Ind/Hercules] */
#define RFIFO2PTR(fd) (void*)(session[fd]->rdata + session[fd]->rdata_pos)
@@ -159,27 +162,27 @@ struct socket_interface {
int (*make_connection) (uint32 ip, uint16 port, struct hSockOpt *opt);
int (*realloc_fifo) (int fd, unsigned int rfifo_size, unsigned int wfifo_size);
int (*realloc_writefifo) (int fd, size_t addition);
- int (*WFIFOSET) (int fd, size_t len);
- int (*RFIFOSKIP) (int fd, size_t len);
+ int (*wfifoset) (int fd, size_t len);
+ int (*rfifoskip) (int fd, size_t len);
void (*close) (int fd);
/* */
- bool (*session_isValid) (int fd);
- bool (*session_isActive) (int fd);
+ bool (*session_is_valid) (int fd);
+ bool (*session_is_active) (int fd);
/* */
- void (*flush_fifo) (int fd);
+ void (*flush) (int fd);
void (*flush_fifos) (void);
void (*set_nonblocking) (int fd, unsigned long yes);
void (*set_defaultparse) (ParseFunc defaultparse);
/* hostname/ip conversion functions */
uint32 (*host2ip) (const char* hostname);
- const char * (*ip2str) (uint32 ip, char ip_str[16]);
+ const char * (*ip2str) (uint32 ip, char *ip_str);
uint32 (*str2ip) (const char* ip_str);
/* */
uint16 (*ntows) (uint16 netshort);
/* */
int (*getips) (uint32* ips, int max);
/* */
- void (*set_eof) (int fd);
+ void (*eof) (int fd);
uint32 (*lan_subnet_check) (uint32 ip, struct s_subnet *info);
bool (*allowed_ip_check) (uint32 ip);
@@ -194,27 +197,4 @@ struct socket_interface *sockt;
void socket_defaults(void);
#endif // HERCULES_CORE
-/* the purpose of these macros is simply to not make calling them be an annoyance */
-#ifndef H_SOCKET_C
- #define make_listen_bind(ip, port) ( sockt->make_listen_bind(ip, port) )
- #define make_connection(ip, port, opt) ( sockt->make_connection(ip, port, opt) )
- #define realloc_fifo(fd, rfifo_size, wfifo_size) ( sockt->realloc_fifo(fd, rfifo_size, wfifo_size) )
- #define realloc_writefifo(fd, addition) ( sockt->realloc_writefifo(fd, addition) )
- #define WFIFOSET(fd, len) ( sockt->WFIFOSET(fd, len) )
- #define RFIFOSKIP(fd, len) ( sockt->RFIFOSKIP(fd, len) )
- #define do_close(fd) ( sockt->close(fd) )
- #define session_isValid(fd) ( sockt->session_isValid(fd) )
- #define session_isActive(fd) ( sockt->session_isActive(fd) )
- #define flush_fifo(fd) ( sockt->flush_fifo(fd) )
- #define flush_fifos() ( sockt->flush_fifos() )
- #define set_nonblocking(fd, yes) ( sockt->set_nonblocking(fd, yes) )
- #define set_defaultparse(defaultparse) ( sockt->set_defaultparse(defaultparse) )
- #define host2ip(hostname) ( sockt->host2ip(hostname) )
- #define ip2str(ip, ip_str) ( sockt->ip2str(ip, ip_str) )
- #define str2ip(ip_str) ( sockt->str2ip(ip_str) )
- #define ntows(netshort) ( sockt->ntows(netshort) )
- #define getips(ips, max) ( sockt->getips(ips, max) )
- #define set_eof(fd) ( sockt->set_eof(fd) )
-#endif /* H_SOCKET_C */
-
#endif /* COMMON_SOCKET_H */