aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/sendmail/contrib/oldbind.compat.c
blob: 1621a7ba5e80451ed03c3985e6b71b4d6c1d6db1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/*
**  OLDBIND.COMPAT.C
**
**	Very old systems do not have res_query(), res_querydomain() or
**	res_search(), so emulate them here.
**
**	You really ought to be upgrading to a newer version of BIND
**	(4.8.2 or later) rather than be using this.
**
**	J.R. Oldroyd <jr@inset.com>
*/

#include <sys/types.h>
#include <netinet/in.h>
#include <arpa/nameser.h>
#include <resolv.h>

typedef union
{
	HEADER	qb1;
	char	qb2[PACKETSZ];
} querybuf;

res_query(dname, class, type, data, datalen)
	char *		dname;
	int		class;
	int 		type;
	char *		data;
	int		datalen;
{
	int		n;
	querybuf	buf;

	n = res_mkquery(QUERY, dname, class, type, (char *) NULL, 0,
		NULL, (char *) &buf, sizeof buf);
	n = res_send((char *)&buf, n, data, datalen);

	return n;
}

res_querydomain(host, dname, class, type, data, datalen)
	char *		host;
	char *		dname;
	int		class;
	int		type;
	char *		data;
	int		datalen;
{
	int		n;
	querybuf	buf;
	char		dbuf[256];

	strcpy(dbuf, host);
	if (dbuf[strlen(dbuf)-1] != '.')
		strcat(dbuf, ".");
	strcat(dbuf, dname);
	n = res_mkquery(QUERY, dbuf, class, type, (char *) NULL, 0,
		NULL, (char *)&buf, sizeof buf);
	n = res_send((char *) &buf, n, data, datalen);

	return n;
}

res_search(dname, class, type, data, datalen)
	char *		dname;
	int		class;
	int		type;
	char *		data;
	int		datalen;
{
	int		n;
	querybuf	buf;

	n = res_mkquery(QUERY, dname, class, type, (char *)NULL, 0,
		NULL, (char *) &buf, sizeof buf);
	n = res_send((char *) &buf, n, data, datalen);

	return n;
}