"Fossies" - the Fresh Open Source Software Archive

Member "bind-9.16.7/lib/isc/include/isc/hex.h" (4 Sep 2020, 2804 Bytes) of package /linux/misc/dns/bind9/9.16.7/bind-9.16.7.tar.xz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "hex.h" see the Fossies "Dox" file reference documentation.

    1 /*
    2  * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
    3  *
    4  * This Source Code Form is subject to the terms of the Mozilla Public
    5  * License, v. 2.0. If a copy of the MPL was not distributed with this
    6  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
    7  *
    8  * See the COPYRIGHT file distributed with this work for additional
    9  * information regarding copyright ownership.
   10  */
   11 
   12 #ifndef ISC_HEX_H
   13 #define ISC_HEX_H 1
   14 
   15 /*! \file isc/hex.h */
   16 
   17 #include <isc/lang.h>
   18 #include <isc/types.h>
   19 
   20 ISC_LANG_BEGINDECLS
   21 
   22 /***
   23  *** Functions
   24  ***/
   25 
   26 isc_result_t
   27 isc_hex_totext(isc_region_t *source, int wordlength, const char *wordbreak,
   28            isc_buffer_t *target);
   29 /*!<
   30  * \brief Convert data into hex encoded text.
   31  *
   32  * Notes:
   33  *\li   The hex encoded text in 'target' will be divided into
   34  *  words of at most 'wordlength' characters, separated by
   35  *  the 'wordbreak' string.  No parentheses will surround
   36  *  the text.
   37  *
   38  * Requires:
   39  *\li   'source' is a region containing binary data
   40  *\li   'target' is a text buffer containing available space
   41  *\li   'wordbreak' points to a null-terminated string of
   42  *      zero or more whitespace characters
   43  *
   44  * Ensures:
   45  *\li   target will contain the hex encoded version of the data
   46  *  in source.  The 'used' pointer in target will be advanced as
   47  *  necessary.
   48  */
   49 
   50 isc_result_t
   51 isc_hex_decodestring(const char *cstr, isc_buffer_t *target);
   52 /*!<
   53  * \brief Decode a null-terminated hex string.
   54  *
   55  * Requires:
   56  *\li   'cstr' is non-null.
   57  *\li   'target' is a valid buffer.
   58  *
   59  * Returns:
   60  *\li   #ISC_R_SUCCESS  -- the entire decoded representation of 'cstring'
   61  *             fit in 'target'.
   62  *\li   #ISC_R_BADHEX -- 'cstr' is not a valid hex encoding.
   63  *
   64  *  Other error returns are any possible error code from:
   65  *      isc_lex_create(),
   66  *      isc_lex_openbuffer(),
   67  *      isc_hex_tobuffer().
   68  */
   69 
   70 isc_result_t
   71 isc_hex_tobuffer(isc_lex_t *lexer, isc_buffer_t *target, int length);
   72 /*!<
   73  * \brief Convert hex-encoded text from a lexer context into
   74  * `target`. If 'length' is non-negative, it is the expected number of
   75  * encoded octets to convert.
   76  *
   77  * If 'length' is -1 then 0 or more encoded octets are expected.
   78  * If 'length' is -2 then 1 or more encoded octets are expected.
   79  *
   80  * Returns:
   81  *\li   #ISC_R_BADHEX -- invalid hex encoding
   82  *\li   #ISC_R_UNEXPECTEDEND: the text does not contain the expected
   83  *                number of encoded octets.
   84  *
   85  * Requires:
   86  *\li   'lexer' is a valid lexer context
   87  *\li   'target' is a buffer containing binary data
   88  *\li   'length' is -2, -1, or non-negative
   89  *
   90  * Ensures:
   91  *\li   target will contain the data represented by the hex encoded
   92  *  string parsed by the lexer.  No more than `length` octets will
   93  *  be read, if `length` is non-negative.  The 'used' pointer in
   94  *  'target' will be advanced as necessary.
   95  */
   96 
   97 ISC_LANG_ENDDECLS
   98 
   99 #endif /* ISC_HEX_H */