quickjs-tart

quickjs-based runtime for wallet-core logic
Log | Files | Refs | README | LICENSE

ares_data.h (3970B)


      1 /* MIT License
      2  *
      3  * Copyright (c) 2009 Daniel Stenberg
      4  *
      5  * Permission is hereby granted, free of charge, to any person obtaining a copy
      6  * of this software and associated documentation files (the "Software"), to deal
      7  * in the Software without restriction, including without limitation the rights
      8  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
      9  * copies of the Software, and to permit persons to whom the Software is
     10  * furnished to do so, subject to the following conditions:
     11  *
     12  * The above copyright notice and this permission notice (including the next
     13  * paragraph) shall be included in all copies or substantial portions of the
     14  * Software.
     15  *
     16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
     17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
     18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
     19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
     20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
     21  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
     22  * SOFTWARE.
     23  *
     24  * SPDX-License-Identifier: MIT
     25  */
     26 #ifndef __ARES_DATA_H
     27 #define __ARES_DATA_H
     28 
     29 typedef enum {
     30   ARES_DATATYPE_UNKNOWN = 1, /* unknown data type     - introduced in 1.7.0 */
     31   ARES_DATATYPE_SRV_REPLY,   /* struct ares_srv_reply - introduced in 1.7.0 */
     32   ARES_DATATYPE_TXT_REPLY,   /* struct ares_txt_reply - introduced in 1.7.0 */
     33   ARES_DATATYPE_TXT_EXT,     /* struct ares_txt_ext   - introduced in 1.11.0 */
     34   ARES_DATATYPE_ADDR_NODE,   /* struct ares_addr_node - introduced in 1.7.1 */
     35   ARES_DATATYPE_MX_REPLY,    /* struct ares_mx_reply   - introduced in 1.7.2 */
     36   ARES_DATATYPE_NAPTR_REPLY, /* struct ares_naptr_reply - introduced in 1.7.6 */
     37   ARES_DATATYPE_SOA_REPLY,   /* struct ares_soa_reply - introduced in 1.9.0 */
     38   ARES_DATATYPE_URI_REPLY,   /* struct ares_uri_reply */
     39 #if 0
     40   ARES_DATATYPE_ADDR6TTL,     /* struct ares_addrttl   */
     41   ARES_DATATYPE_ADDRTTL,      /* struct ares_addr6ttl  */
     42   ARES_DATATYPE_HOSTENT,      /* struct hostent        */
     43   ARES_DATATYPE_OPTIONS,      /* struct ares_options   */
     44 #endif
     45   ARES_DATATYPE_ADDR_PORT_NODE, /* struct ares_addr_port_node - introduced
     46                                    in 1.11.0 */
     47   ARES_DATATYPE_CAA_REPLY, /* struct ares_caa_reply   - introduced in 1.17 */
     48   ARES_DATATYPE_LAST       /* not used              - introduced in 1.7.0 */
     49 } ares_datatype;
     50 
     51 #define ARES_DATATYPE_MARK 0xbead
     52 
     53 /*
     54  * ares_data struct definition is internal to c-ares and shall not
     55  * be exposed by the public API in order to allow future changes
     56  * and extensions to it without breaking ABI.  This will be used
     57  * internally by c-ares as the container of multiple types of data
     58  * dynamically allocated for which a reference will be returned
     59  * to the calling application.
     60  *
     61  * c-ares API functions returning a pointer to c-ares internally
     62  * allocated data will actually be returning an interior pointer
     63  * into this ares_data struct.
     64  *
     65  * All this is 'invisible' to the calling application, the only
     66  * requirement is that this kind of data must be free'ed by the
     67  * calling application using ares_free_data() with the pointer
     68  * it has received from a previous c-ares function call.
     69  */
     70 
     71 struct ares_data {
     72   ares_datatype type; /* Actual data type identifier. */
     73   unsigned int  mark; /* Private ares_data signature. */
     74 
     75   union {
     76     struct ares_txt_reply      txt_reply;
     77     struct ares_txt_ext        txt_ext;
     78     struct ares_srv_reply      srv_reply;
     79     struct ares_addr_node      addr_node;
     80     struct ares_addr_port_node addr_port_node;
     81     struct ares_mx_reply       mx_reply;
     82     struct ares_naptr_reply    naptr_reply;
     83     struct ares_soa_reply      soa_reply;
     84     struct ares_caa_reply      caa_reply;
     85     struct ares_uri_reply      uri_reply;
     86   } data;
     87 };
     88 
     89 void *ares_malloc_data(ares_datatype type);
     90 
     91 
     92 #endif /* __ARES_DATA_H */