summaryrefslogtreecommitdiff
path: root/src/map/chrif.c
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/map/chrif.c
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/map/chrif.c')
-rw-r--r--src/map/chrif.c36
1 files changed, 18 insertions, 18 deletions
diff --git a/src/map/chrif.c b/src/map/chrif.c
index 5bd1e436f..f9b6af7f7 100644
--- a/src/map/chrif.c
+++ b/src/map/chrif.c
@@ -219,14 +219,14 @@ void chrif_checkdefaultlogin(void) {
bool chrif_setip(const char* ip) {
char ip_str[16];
- if ( !( chrif->ip = host2ip(ip) ) ) {
+ if (!(chrif->ip = sockt->host2ip(ip))) {
ShowWarning("Failed to Resolve Char Server Address! (%s)\n", ip);
return false;
}
safestrncpy(chrif->ip_str, ip, sizeof(chrif->ip_str));
- ShowInfo("Char Server IP Address : '"CL_WHITE"%s"CL_RESET"' -> '"CL_WHITE"%s"CL_RESET"'.\n", ip, ip2str(chrif->ip, ip_str));
+ ShowInfo("Char Server IP Address : '"CL_WHITE"%s"CL_RESET"' -> '"CL_WHITE"%s"CL_RESET"'.\n", ip, sockt->ip2str(chrif->ip, ip_str));
return true;
}
@@ -542,7 +542,7 @@ void chrif_authreq(struct map_session_data *sd, bool hstandalone) {
struct auth_node *node= chrif->search(sd->bl.id);
if( node != NULL || !chrif->isconnected() ) {
- set_eof(sd->fd);
+ sockt->eof(sd->fd);
return;
}
@@ -980,7 +980,7 @@ void chrif_idbanned(int fd) {
clif->message(sd->fd, tmpstr);
}
- set_eof(sd->fd); // forced to disconnect for the change
+ sockt->eof(sd->fd); // forced to disconnect for the change
map->quit(sd); // Remove leftovers (e.g. autotrading) [Paradox924X]
}
@@ -1232,9 +1232,9 @@ bool chrif_char_offline_nsd(int account_id, int char_id) {
bool chrif_flush(void) {
chrif_check(false);
- set_nonblocking(chrif->fd, 0);
- flush_fifos();
- set_nonblocking(chrif->fd, 1);
+ sockt->set_nonblocking(chrif->fd, 0);
+ sockt->flush_fifos();
+ sockt->set_nonblocking(chrif->fd, 1);
return true;
}
@@ -1286,7 +1286,7 @@ void chrif_update_ip(int fd) {
WFIFOHEAD(fd,6);
- new_ip = host2ip(chrif->ip_str);
+ new_ip = sockt->host2ip(chrif->ip_str);
if (new_ip && new_ip != chrif->ip)
chrif->ip = new_ip; //Update chrif->ip
@@ -1315,7 +1315,7 @@ void chrif_skillid2idx(int fd) {
if( fd == 0 ) fd = chrif->fd;
- if( !session_isValid(fd) )
+ if (!sockt->session_is_valid(fd))
return;
WFIFOHEAD(fd,4 + (MAX_SKILL * 4));
@@ -1340,18 +1340,18 @@ int chrif_parse(int fd) {
// only process data from the char-server
if ( fd != chrif->fd ) {
ShowDebug("chrif_parse: Disconnecting invalid session #%d (is not the char-server)\n", fd);
- do_close(fd);
+ sockt->close(fd);
return 0;
}
if ( session[fd]->flag.eof ) {
- do_close(fd);
+ sockt->close(fd);
chrif->fd = -1;
chrif->on_disconnect();
return 0;
} else if ( session[fd]->flag.ping ) {/* we've reached stall time */
if( DIFF_TICK(sockt->last_tick, session[fd]->rdata_tick) > (sockt->stall_time * 2) ) {/* we can't wait any longer */
- set_eof(fd);
+ sockt->eof(fd);
return 0;
} else if( session[fd]->flag.ping != 2 ) { /* we haven't sent ping out yet */
chrif->keepalive(fd);
@@ -1377,7 +1377,7 @@ int chrif_parse(int fd) {
if (r == 2) return 0; // Didn't have enough data (len==-1)
ShowWarning("chrif_parse: session #%d, intif->parse failed (unrecognized command 0x%.4x).\n", fd, cmd);
- set_eof(fd);
+ sockt->eof(fd);
return 0;
}
@@ -1418,7 +1418,7 @@ int chrif_parse(int fd) {
case 0x2b27: chrif->authfail(fd); break;
default:
ShowError("chrif_parse : unknown packet (session #%d): 0x%x. Disconnecting.\n", fd, cmd);
- set_eof(fd);
+ sockt->eof(fd);
return 0;
}
if ( fd == chrif->fd ) //There's the slight chance we lost the connection during parse, in which case this would segfault if not checked [Skotlex]
@@ -1483,12 +1483,12 @@ int check_connect_char_server(int tid, int64 tick, int id, intptr_t data) {
chrif->state = 0;
- if ( ( chrif->fd = make_connection(chrif->ip, chrif->port,NULL) ) == -1) //Attempt to connect later. [Skotlex]
+ if ((chrif->fd = sockt->make_connection(chrif->ip, chrif->port,NULL)) == -1) //Attempt to connect later. [Skotlex]
return 0;
session[chrif->fd]->func_parse = chrif->parse;
session[chrif->fd]->flag.server = 1;
- realloc_fifo(chrif->fd, FIFOSIZE_SERVERLINK, FIFOSIZE_SERVERLINK);
+ sockt->realloc_fifo(chrif->fd, FIFOSIZE_SERVERLINK, FIFOSIZE_SERVERLINK);
chrif->connect(chrif->fd);
chrif->connected = (chrif->state == 2);
@@ -1529,7 +1529,7 @@ void chrif_send_report(char* buf, int len) {
WFIFOSET(chrif->fd,len + 2);
- flush_fifo(chrif->fd); /* ensure it's sent now. */
+ sockt->flush(chrif->fd); /* ensure it's sent now. */
}
#endif
}
@@ -1601,7 +1601,7 @@ int auth_db_final(DBKey key, DBData *data, va_list ap) {
void do_final_chrif(void)
{
if( chrif->fd != -1 ) {
- do_close(chrif->fd);
+ sockt->close(chrif->fd);
chrif->fd = -1;
}