summaryrefslogtreecommitdiff
path: root/src/core/net-nonblock.c
diff options
context:
space:
mode:
authorTimo Sirainen <cras@irssi.org>2000-05-25 11:30:47 +0000
committercras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564>2000-05-25 11:30:47 +0000
commit76605ad0aed7e53c4a9dab686474235f547a5837 (patch)
tree078c0ebf5f7099daaa2dcf9ff252f418dedcce34 /src/core/net-nonblock.c
parent487da4174504f797171f12a01636c54272ec6a62 (diff)
downloadirssi-76605ad0aed7e53c4a9dab686474235f547a5837.zip
Added bot plugin, it also has almost-functional botnet.
Changed configure.in's functionality so that you could tell what modules you want to build in main irssi binary and it will create automatically the .c files that need to call the module_init()/deinit() functions. Fixed several minor things.. git-svn-id: http://svn.irssi.org/repos/irssi/trunk@230 dbcabf3a-b0e7-0310-adc4-f8d773084564
Diffstat (limited to 'src/core/net-nonblock.c')
-rw-r--r--src/core/net-nonblock.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/src/core/net-nonblock.c b/src/core/net-nonblock.c
index b6e9264f..86d0f263 100644
--- a/src/core/net-nonblock.c
+++ b/src/core/net-nonblock.c
@@ -39,7 +39,7 @@ SIMPLE_THREAD_REC;
/* nonblocking gethostbyname(), ip (IPADDR) + error (int, 0 = not error) is
written to pipe when found PID of the resolver child is returned */
-int net_gethostname_nonblock(const char *addr, int pipe)
+int net_gethostbyname_nonblock(const char *addr, int pipe)
{
RESOLVED_IP_REC rec;
const char *errorstr;
@@ -60,7 +60,8 @@ int net_gethostname_nonblock(const char *addr, int pipe)
}
/* child */
- rec.error = net_gethostname(addr, &rec.ip);
+ memset(&rec, 0, sizeof(rec));
+ rec.error = net_gethostbyname(addr, &rec.ip);
if (rec.error == 0) {
errorstr = NULL;
} else {
@@ -105,7 +106,7 @@ int net_gethostbyname_return(int pipe, RESOLVED_IP_REC *rec)
if (rec->error) {
/* read error string */
- rec->errorstr = g_malloc(rec->errlen);
+ rec->errorstr = g_malloc(rec->errlen+1);
len = 0;
do {
ret = read(pipe, rec->errorstr+len, rec->errlen-len);
@@ -122,6 +123,13 @@ int net_gethostbyname_return(int pipe, RESOLVED_IP_REC *rec)
return 0;
}
+/* Get host name, call func when finished */
+int net_gethostbyaddr_nonblock(IPADDR *ip, NET_HOST_CALLBACK func, void *data)
+{
+ /*FIXME*/
+ return FALSE;
+}
+
/* Kill the resolver child */
void net_disconnect_nonblock(int pid)
{
@@ -173,7 +181,7 @@ static void simple_readpipe(SIMPLE_THREAD_REC *rec, int pipe)
return;
}
- rec->tag = g_input_add(handle, G_INPUT_WRITE,
+ rec->tag = g_input_add(handle, G_INPUT_READ | G_INPUT_WRITE,
(GInputFunction) simple_init, rec);
}
@@ -192,7 +200,7 @@ int net_connect_nonblock(const char *server, int port, const IPADDR *my_ip, NET_
}
/* start nonblocking host name lookup */
- net_gethostname_nonblock(server, fd[1]);
+ net_gethostbyname_nonblock(server, fd[1]);
rec = g_new0(SIMPLE_THREAD_REC, 1);
rec->port = port;