a0e5cddf24630495d753bdec269c51a4b68fc36a
[silc.git] / apps / irssi / src / core / net-nonblock.h
1 #ifndef __NET_NONBLOCK_H
2 #define __NET_NONBLOCK_H
3
4 #include "network.h"
5
6 typedef struct {
7         IPADDR ip4, ip6; /* resolved ip addresses */
8         int error; /* error, 0 = no error, -1 = error: */
9         int errlen; /* error text length */
10         char *errorstr; /* error string - dynamically allocated, you'll
11                            need to free() it yourself unless it's NULL */
12 } RESOLVED_IP_REC;
13
14 typedef struct {
15         int namelen;
16         char *name;
17
18         int error;
19         int errlen;
20         char *errorstr;
21 } RESOLVED_NAME_REC;
22
23 typedef void (*NET_CALLBACK) (GIOChannel *, void *);
24 typedef void (*NET_HOST_CALLBACK) (RESOLVED_NAME_REC *, void *);
25
26 /* nonblocking gethostbyname(), PID of the resolver child is returned. */
27 int net_gethostbyname_nonblock(const char *addr, GIOChannel *pipe);
28 /* Get host's name, call func when finished */
29 int net_gethostbyaddr_nonblock(IPADDR *ip, NET_HOST_CALLBACK func, void *data);
30 /* get the resolved IP address. returns -1 if some error occured with read() */
31 int net_gethostbyname_return(GIOChannel *pipe, RESOLVED_IP_REC *rec);
32
33 /* Connect to server, call func when finished */
34 int net_connect_nonblock(const char *server, int port, const IPADDR *my_ip,
35                          NET_CALLBACK func, void *data);
36 /* Kill the resolver child */
37 void net_disconnect_nonblock(int pid);
38
39 #endif