Merged from silc_1_0_branch.
[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         char *host4, *host6; /* dito */
13 } RESOLVED_IP_REC;
14
15 typedef struct {
16         int namelen;
17         char *name;
18
19         int error;
20         int errlen;
21         char *errorstr;
22 } RESOLVED_NAME_REC;
23
24 typedef void (*NET_CALLBACK) (GIOChannel *, void *);
25 typedef void (*NET_HOST_CALLBACK) (RESOLVED_NAME_REC *, void *);
26
27 /* nonblocking gethostbyname(), PID of the resolver child is returned. */
28 int net_gethostbyname_nonblock(const char *addr, GIOChannel *pipe,
29                                int reverse_lookup);
30 /* Get host's name, call func when finished */
31 int net_gethostbyaddr_nonblock(IPADDR *ip, NET_HOST_CALLBACK func, void *data);
32 /* get the resolved IP address. returns -1 if some error occured with read() */
33 int net_gethostbyname_return(GIOChannel *pipe, RESOLVED_IP_REC *rec);
34
35 /* Connect to server, call func when finished */
36 int net_connect_nonblock(const char *server, int port, const IPADDR *my_ip,
37                          NET_CALLBACK func, void *data);
38 /* Kill the resolver child */
39 void net_disconnect_nonblock(int pid);
40
41 #endif