ares_dns.h: adjust DNS__16BIT and DNS__32BIT macro definitions
[platform/upstream/c-ares.git] / ares_data.h
1
2 /* Copyright (C) 2009-2010 by Daniel Stenberg
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
17 typedef enum {
18   ARES_DATATYPE_UNKNOWN = 1,  /* unknown data type     - introduced in 1.7.0 */
19   ARES_DATATYPE_SRV_REPLY,    /* struct ares_srv_reply - introduced in 1.7.0 */
20   ARES_DATATYPE_TXT_REPLY,    /* struct ares_txt_reply - introduced in 1.7.0 */
21   ARES_DATATYPE_ADDR_NODE,    /* struct ares_addr_node - introduced in 1.7.1 */
22   ARES_DATATYPE_MX_REPLY,    /* struct ares_mx_reply   - introduced in 1.7.2 */
23 #if 0
24   ARES_DATATYPE_ADDR6TTL,     /* struct ares_addrttl   */
25   ARES_DATATYPE_ADDRTTL,      /* struct ares_addr6ttl  */
26   ARES_DATATYPE_HOSTENT,      /* struct hostent        */
27   ARES_DATATYPE_OPTIONS,      /* struct ares_options   */
28 #endif
29   ARES_DATATYPE_LAST          /* not used              - introduced in 1.7.0 */
30 } ares_datatype;
31
32 #define ARES_DATATYPE_MARK 0xbead
33
34 /*
35  * ares_data struct definition is internal to c-ares and shall not
36  * be exposed by the public API in order to allow future changes
37  * and extensions to it without breaking ABI.  This will be used
38  * internally by c-ares as the container of multiple types of data
39  * dynamically allocated for which a reference will be returned
40  * to the calling application.
41  *
42  * c-ares API functions returning a pointer to c-ares internally
43  * allocated data will actually be returning an interior pointer
44  * into this ares_data struct.
45  *
46  * All this is 'invisible' to the calling application, the only
47  * requirement is that this kind of data must be free'ed by the
48  * calling application using ares_free_data() with the pointer
49  * it has received from a previous c-ares function call.
50  */
51
52 struct ares_data {
53   ares_datatype type;  /* Actual data type identifier. */
54   unsigned int  mark;  /* Private ares_data signature. */
55   union {
56     struct ares_txt_reply txt_reply;
57     struct ares_srv_reply srv_reply;
58     struct ares_addr_node addr_node;
59     struct ares_mx_reply mx_reply;
60   } data;
61 };
62
63 void *ares_malloc_data(ares_datatype type);
64
65 ares_datatype ares_get_datatype(void * dataptr);