Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
BitchX
GitHub Repository: BitchX/BitchX1.3
Path: blob/master/include/cdns.h
1069 views
1
/* $Id: cdns.h 3 2008-02-25 09:49:14Z keaston $ */
2
3
/*
4
* cdns.h: header for cdns.c
5
*/
6
7
#ifndef _CDNS_H_
8
#define _CDNS_H_
9
10
/* We gotta know about the fd_set type, so we gonna inclue this */
11
#include "irc.h"
12
13
#include "struct.h"
14
#include "newio.h"
15
#endif
16
17
#define MAXALIASES 35
18
#define MAXADDRS 35
19
20
typedef struct _hent {
21
char *h_name; /* official name of host */
22
char *h_aliases[MAXALIASES]; /* alias list */
23
int h_addrtype; /* host address type */
24
int h_length; /* length of address */
25
/* list of addresses from name server */
26
struct in_addr h_addr_list[MAXADDRS];
27
#define h_addr h_addr_list[0] /* address, for backward compatiblity */
28
} my_hostent;
29
30
typedef struct dns_struct {
31
/* 'in': This is the string we want to resolve. It can be
32
* either a host or ip. The string WILL be malloc'ed by
33
* the "add" function. Do NOT malloc or free this variable!
34
*/
35
char *in;
36
37
/* 'out': This is our "resolved" string. It can be
38
* either a host or ip. The string WILL be malloc'ed by
39
* the internal resolver. Do NOT malloc or free this variable!
40
*/
41
char *out;
42
43
/* alias: this is passed to the alias parser which then interpret's
44
* the output.
45
*/
46
char *alias;
47
48
/* 'callback': This is our callback function. When our 'in' gets
49
* resolved, we will call this function, with this structure
50
* as our parameter. Do NOT malloc or free this variable.
51
*/
52
void (*callback) (struct dns_struct *); /* Our callback function */
53
54
/* 'callinfo': This allows us to store information that you might
55
* need for later use when in your 'callback' function. This is
56
* just a void pointer, so you MUST malloc any of the data you want to
57
* store here. Once you are done with this variable, you must
58
* free it!!! BEWARE BEWARE, YOU MUST FREE THIS VARIABLE YOURSELF!
59
*/
60
void *callinfo;
61
62
/* 'ip': Internally used, to find out what the 'out' variable is.
63
* ie, is it a host, or is it ip
64
*/
65
int ip;
66
67
/* hostentr: A copy of the hostent structure returned from the
68
* name server. I am adding it here to extend the ability to
69
* read multiple IPs. Although this is not generally necessary.
70
* - Brian Smith
71
*/
72
my_hostent *hostentr;
73
74
/* 'next': Internally used. our "next" pointer. */
75
struct dns_struct *next;
76
} DNS_QUEUE;
77
78
void start_dns(void);
79
void stop_dns(void);
80
void kill_dns(void);
81
void set_dns_output_fd(fd_set *);
82
void dns_check(fd_set *);
83
void check_dns_queue(void);
84
void add_to_dns_queue(char *, void (*) (DNS_QUEUE *), char *, void *, int);
85
my_hostent *duphostent(struct hostent *orig);
86
void freemyhostent(my_hostent *freeme);
87
88
#define DNS_URGENT 1
89
#define DNS_NORMAL 2
90
91
#define Q_NEXT(tmp) ((tmp)->next)
92
#define Q_OPEN(headp, tailp) (*(headp) = *(tailp) = NULL)
93
94
95