hex.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2004-2008  Internet Systems Consortium, Inc. ("ISC")
00003  * Copyright (C) 2000, 2001  Internet Software Consortium.
00004  *
00005  * Permission to use, copy, modify, and/or distribute this software for any
00006  * purpose with or without fee is hereby granted, provided that the above
00007  * copyright notice and this permission notice appear in all copies.
00008  *
00009  * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
00010  * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
00011  * AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
00012  * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
00013  * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
00014  * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
00015  * PERFORMANCE OF THIS SOFTWARE.
00016  */
00017 
00018 /* $Id: hex.h,v 1.13 2008/09/25 04:02:39 tbox Exp $ */
00019 
00020 #ifndef ISC_HEX_H
00021 #define ISC_HEX_H 1
00022 
00023 /*! \file isc/hex.h */
00024 
00025 #include <isc/lang.h>
00026 #include <isc/types.h>
00027 
00028 ISC_LANG_BEGINDECLS
00029 
00030 /***
00031  *** Functions
00032  ***/
00033 
00034 isc_result_t
00035 isc_hex_totext(isc_region_t *source, int wordlength,
00036                const char *wordbreak, isc_buffer_t *target);
00037 /*!<
00038  * \brief Convert data into hex encoded text.
00039  *
00040  * Notes:
00041  *\li   The hex encoded text in 'target' will be divided into
00042  *      words of at most 'wordlength' characters, separated by
00043  *      the 'wordbreak' string.  No parentheses will surround
00044  *      the text.
00045  *
00046  * Requires:
00047  *\li   'source' is a region containing binary data
00048  *\li   'target' is a text buffer containing available space
00049  *\li   'wordbreak' points to a null-terminated string of
00050  *              zero or more whitespace characters
00051  *
00052  * Ensures:
00053  *\li   target will contain the hex encoded version of the data
00054  *      in source.  The 'used' pointer in target will be advanced as
00055  *      necessary.
00056  */
00057 
00058 isc_result_t
00059 isc_hex_decodestring(const char *cstr, isc_buffer_t *target);
00060 /*!<
00061  * \brief Decode a null-terminated hex string.
00062  *
00063  * Requires:
00064  *\li   'cstr' is non-null.
00065  *\li   'target' is a valid buffer.
00066  *
00067  * Returns:
00068  *\li   #ISC_R_SUCCESS  -- the entire decoded representation of 'cstring'
00069  *                         fit in 'target'.
00070  *\li   #ISC_R_BADHEX -- 'cstr' is not a valid hex encoding.
00071  *
00072  *      Other error returns are any possible error code from:
00073  *              isc_lex_create(),
00074  *              isc_lex_openbuffer(),
00075  *              isc_hex_tobuffer().
00076  */
00077 
00078 isc_result_t
00079 isc_hex_tobuffer(isc_lex_t *lexer, isc_buffer_t *target, int length);
00080 /*!<
00081  * \brief Convert hex encoded text from a lexer context into data.
00082  *
00083  * Requires:
00084  *\li   'lex' is a valid lexer context
00085  *\li   'target' is a buffer containing binary data
00086  *\li   'length' is an integer
00087  *
00088  * Ensures:
00089  *\li   target will contain the data represented by the hex encoded
00090  *      string parsed by the lexer.  No more than length bytes will be read,
00091  *      if length is positive.  The 'used' pointer in target will be
00092  *      advanced as necessary.
00093  */
00094 
00095 
00096 ISC_LANG_ENDDECLS
00097 
00098 #endif /* ISC_HEX_H */

Generated on Tue Apr 28 17:41:04 2015 by Doxygen 1.5.4 for BIND9 Internals 9.11.0pre-alpha