quickjs-tart

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

ares_dns_multistring.h (3670B)


      1 /* MIT License
      2  *
      3  * Copyright (c) 2024 Brad House
      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_DNS_MULTISTRING_H
     27 #define __ARES_DNS_MULTISTRING_H
     28 
     29 #include "ares_buf.h"
     30 
     31 struct ares_dns_multistring;
     32 typedef struct ares_dns_multistring ares_dns_multistring_t;
     33 
     34 ares_dns_multistring_t             *ares_dns_multistring_create(void);
     35 void          ares_dns_multistring_clear(ares_dns_multistring_t *strs);
     36 void          ares_dns_multistring_destroy(ares_dns_multistring_t *strs);
     37 ares_status_t ares_dns_multistring_swap_own(ares_dns_multistring_t *strs,
     38                                             size_t idx, unsigned char *str,
     39                                             size_t len);
     40 ares_status_t ares_dns_multistring_del(ares_dns_multistring_t *strs,
     41                                        size_t                  idx);
     42 ares_status_t ares_dns_multistring_add_own(ares_dns_multistring_t *strs,
     43                                            unsigned char *str, size_t len);
     44 size_t        ares_dns_multistring_cnt(const ares_dns_multistring_t *strs);
     45 const unsigned char *
     46   ares_dns_multistring_get(const ares_dns_multistring_t *strs, size_t idx,
     47                            size_t *len);
     48 const unsigned char *ares_dns_multistring_combined(ares_dns_multistring_t *strs,
     49                                                    size_t                 *len);
     50 
     51 /*! Parse an array of character strings as defined in RFC1035, as binary,
     52  *  however, for convenience this does guarantee a NULL terminator (that is
     53  *  not included in the length for each value).
     54  *
     55  *  \param[in]  buf                initialized buffer object
     56  *  \param[in]  remaining_len      maximum length that should be used for
     57  *                                 parsing the string, this is often less than
     58  *                                 the remaining buffer and is based on the RR
     59  *                                 record length.
     60  *  \param[out] strs               Pointer passed by reference to be filled in
     61  *                                 with
     62  *                                 the array of values.
     63  *  \param[out] validate_printable Validate the strings contain only printable
     64  *                                 data.
     65  *  \return ARES_SUCCESS on success
     66  */
     67 ares_status_t        ares_dns_multistring_parse_buf(ares_buf_t *buf,
     68                                                     size_t      remaining_len,
     69                                                     ares_dns_multistring_t **strs,
     70                                                     ares_bool_t validate_printable);
     71 
     72 #endif