Merge branch 'tizen' into tizen_base
[platform/upstream/c-ares.git] / ares_create_query.3
1 .\"
2 .\" Copyright 1998 by the Massachusetts Institute of Technology.
3 .\"
4 .\" Permission to use, copy, modify, and distribute this
5 .\" software and its documentation for any purpose and without
6 .\" fee is hereby granted, provided that the above copyright
7 .\" notice appear in all copies and that both that copyright
8 .\" notice and this permission notice appear in supporting
9 .\" documentation, and that the name of M.I.T. not be used in
10 .\" advertising or publicity pertaining to distribution of the
11 .\" software without specific, written prior permission.
12 .\" M.I.T. makes no representations about the suitability of
13 .\" this software for any purpose.  It is provided "as is"
14 .\" without express or implied warranty.
15 .\"
16 .TH ARES_CREATE_QUERY 3 "17 Aug 2012"
17 .SH NAME
18 ares_create_query \- Compose a single-question DNS query buffer
19 .SH SYNOPSIS
20 .nf
21 #include <ares.h>
22
23 int ares_create_query(const char *\fIname\fP,
24                       int \fIdnsclass\fP,
25                       int \fItype\fP,
26                       unsigned short \fIid\fP,
27                       int \fIrd\fP,
28                       unsigned char **\fIbuf\fP,
29                       int *\fIbuflen\fP,
30                       int \fImax_udp_size\fP)
31 .fi
32 .SH DESCRIPTION
33 The \fIares_create_query(3)\fP function composes a DNS query with a single
34 question.  The parameter \fIname\fP gives the query name as a NUL-terminated C
35 string of period-separated labels optionally ending with a period; periods and
36 backslashes within a label must be escaped with a backlash.
37
38 The parameters \fIdnsclass\fP and \fItype\fP give the class and type of the
39 query using the values defined in \fB<arpa/nameser.h>\fP.
40
41 The parameter \fIid\fP gives a 16-bit identifier for the query.
42
43 The parameter \fIrd\fP should be nonzero if recursion is desired, zero if not.
44
45 The query will be placed in an allocated buffer, a pointer to which will be
46 stored in the variable pointed to by \fIbuf\fP, and the length of which will
47 be stored in the variable pointed to by \fIbuflen\fP.
48
49 It is the caller's responsibility to free this buffer using
50 \fIares_free_string(3)\fP when it is no longer needed.  The parameter
51 \fImax_udp_size\fP should be nonzero to activate EDNS. Usage of
52 \fIares_create_query(3)\fP\ with \fImax_udp_size\fP set to zero is equivalent
53 to using \fIares_mkquery(3)\fP.
54 .SH RETURN VALUES
55 .B ares_create_query
56 can return any of the following values:
57 .TP 15
58 .B ARES_SUCCESS
59 Construction of the DNS query succeeded.
60 .TP 15
61 .B ARES_EBADNAME
62 The query name
63 .I name
64 could not be encoded as a domain name, either because it contained a
65 zero-length label or because it contained a label of more than 63
66 characters.
67 .TP 15
68 .B ARES_ENOMEM
69 Memory was exhausted.
70 .SH AVAILABILITY
71 Added in c-ares 1.10.0
72 .SH SEE ALSO
73 .BR ares_expand_name (3),
74 .BR ares_free_string (3),
75 .BR ares_mkquery (3)
76 .SH AUTHOR