1968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
2968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold/* Copyright (C) 2009-2010 by Daniel Stenberg
3968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold *
4968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold * Permission to use, copy, modify, and distribute this
5968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold * software and its documentation for any purpose and without
6968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold * fee is hereby granted, provided that the above copyright
7968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold * notice appear in all copies and that both that copyright
8968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold * notice and this permission notice appear in supporting
9968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold * documentation, and that the name of M.I.T. not be used in
10968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold * advertising or publicity pertaining to distribution of the
11968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold * software without specific, written prior permission.
12968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold * M.I.T. makes no representations about the suitability of
13968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold * this software for any purpose.  It is provided "as is"
14968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold * without express or implied warranty.
15968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold */
16968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
17968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldtypedef enum {
18968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  ARES_DATATYPE_UNKNOWN = 1,  /* unknown data type     - introduced in 1.7.0 */
19968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  ARES_DATATYPE_SRV_REPLY,    /* struct ares_srv_reply - introduced in 1.7.0 */
20968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  ARES_DATATYPE_TXT_REPLY,    /* struct ares_txt_reply - introduced in 1.7.0 */
21968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  ARES_DATATYPE_ADDR_NODE,    /* struct ares_addr_node - introduced in 1.7.1 */
22968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  ARES_DATATYPE_MX_REPLY,    /* struct ares_mx_reply   - introduced in 1.7.2 */
23968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#if 0
24968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  ARES_DATATYPE_ADDR6TTL,     /* struct ares_addrttl   */
25968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  ARES_DATATYPE_ADDRTTL,      /* struct ares_addr6ttl  */
26968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  ARES_DATATYPE_HOSTENT,      /* struct hostent        */
27968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  ARES_DATATYPE_OPTIONS,      /* struct ares_options   */
28968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#endif
29968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  ARES_DATATYPE_LAST          /* not used              - introduced in 1.7.0 */
30968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold} ares_datatype;
31968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
32968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold#define ARES_DATATYPE_MARK 0xbead
33968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
34968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold/*
35968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold * ares_data struct definition is internal to c-ares and shall not
36968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold * be exposed by the public API in order to allow future changes
37968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold * and extensions to it without breaking ABI.  This will be used
38968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold * internally by c-ares as the container of multiple types of data
39968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold * dynamically allocated for which a reference will be returned
40968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold * to the calling application.
41968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold *
42968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold * c-ares API functions returning a pointer to c-ares internally
43968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold * allocated data will actually be returning an interior pointer
44968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold * into this ares_data struct.
45968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold *
46968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold * All this is 'invisible' to the calling application, the only
47968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold * requirement is that this kind of data must be free'ed by the
48968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold * calling application using ares_free_data() with the pointer
49968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold * it has received from a previous c-ares function call.
50968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold */
51968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
52968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldstruct ares_data {
53968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  ares_datatype type;  /* Actual data type identifier. */
54968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  unsigned int  mark;  /* Private ares_data signature. */
55968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  union {
56968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    struct ares_txt_reply txt_reply;
57968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    struct ares_srv_reply srv_reply;
58968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    struct ares_addr_node addr_node;
59968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold    struct ares_mx_reply mx_reply;
60968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold  } data;
61968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold};
62968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
63968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldvoid *ares_malloc_data(ares_datatype type);
64968bf19396ad404e89420f5d67900fce13f4186cGilad Arnold
65968bf19396ad404e89420f5d67900fce13f4186cGilad Arnoldares_datatype ares_get_datatype(void * dataptr);
66