hex.c File Reference

#include <config.h>
#include <ctype.h>
#include <isc/buffer.h>
#include <isc/hex.h>
#include <isc/lex.h>
#include <isc/string.h>
#include <isc/util.h>

Go to the source code of this file.

Data Structures

struct  hex_decode_ctx_t
 State of a hex decoding process in progress. More...

Defines

#define RETERR(x)

Functions

static isc_result_t str_totext (const char *source, isc_buffer_t *target)
static isc_result_t mem_tobuffer (isc_buffer_t *target, void *base, unsigned int length)
isc_result_t isc_hex_totext (isc_region_t *source, int wordlength, const char *wordbreak, isc_buffer_t *target)
 Convert data into hex encoded text.
static void hex_decode_init (hex_decode_ctx_t *ctx, int length, isc_buffer_t *target)
static isc_result_t hex_decode_char (hex_decode_ctx_t *ctx, int c)
static isc_result_t hex_decode_finish (hex_decode_ctx_t *ctx)
isc_result_t isc_hex_tobuffer (isc_lex_t *lexer, isc_buffer_t *target, int length)
 Convert hex encoded text from a lexer context into data.
isc_result_t isc_hex_decodestring (const char *cstr, isc_buffer_t *target)
 Decode a null-terminated hex string.

Variables

static const char hex [] = "0123456789ABCDEF"


Detailed Description

Definition in file hex.c.


Define Documentation

#define RETERR (  ) 

Value:

do { \
        isc_result_t _r = (x); \
        if (_r != ISC_R_SUCCESS) \
                return (_r); \
        } while (0)

Definition at line 32 of file hex.c.


Function Documentation

static isc_result_t str_totext ( const char *  source,
isc_buffer_t target 
) [static]

Definition at line 176 of file hex.c.

References isc_region::base, isc_buffer_add, isc_buffer_availableregion, ISC_R_NOSPACE, ISC_R_SUCCESS, and isc_region::length.

static isc_result_t mem_tobuffer ( isc_buffer_t target,
void *  base,
unsigned int  length 
) [static]

Definition at line 192 of file hex.c.

References isc_region::base, isc_buffer_add, isc_buffer_availableregion, ISC_R_NOSPACE, ISC_R_SUCCESS, and isc_region::length.

isc_result_t isc_hex_totext ( isc_region_t source,
int  wordlength,
const char *  wordbreak,
isc_buffer_t target 
)

Convert data into hex encoded text.

Notes:

Requires: Ensures:

Definition at line 51 of file hex.c.

References isc_region::base, hex, ISC_R_SUCCESS, isc_region_consume, isc_region::length, RETERR, and str_totext().

Referenced by generate_salt(), totext_cds(), totext_dlv(), totext_ds(), totext_hip(), totext_nsec3(), totext_nsec3param(), totext_sshfp(), totext_tlsa(), and unknown_totext().

static void hex_decode_init ( hex_decode_ctx_t ctx,
int  length,
isc_buffer_t target 
) [inline, static]

Definition at line 89 of file hex.c.

References hex_decode_ctx_t::digits, hex_decode_ctx_t::length, and hex_decode_ctx_t::target.

Referenced by isc_hex_decodestring(), and isc_hex_tobuffer().

static isc_result_t hex_decode_char ( hex_decode_ctx_t ctx,
int  c 
) [inline, static]

Definition at line 97 of file hex.c.

References hex_decode_ctx_t::digits, hex, ISC_R_BADHEX, ISC_R_SUCCESS, hex_decode_ctx_t::length, mem_tobuffer(), RETERR, s, hex_decode_ctx_t::target, and hex_decode_ctx_t::val.

Referenced by isc_hex_decodestring(), and isc_hex_tobuffer().

static isc_result_t hex_decode_finish ( hex_decode_ctx_t ctx  )  [inline, static]

Definition at line 120 of file hex.c.

References hex_decode_ctx_t::digits, ISC_R_BADHEX, ISC_R_SUCCESS, ISC_R_UNEXPECTEDEND, and hex_decode_ctx_t::length.

Referenced by isc_hex_decodestring(), and isc_hex_tobuffer().

isc_result_t isc_hex_tobuffer ( isc_lex_t lexer,
isc_buffer_t target,
int  length 
)

Convert hex encoded text from a lexer context into data.

Requires:

Ensures:

Definition at line 129 of file hex.c.

References isc_tokenvalue_t::as_textregion, isc_textregion::base, hex_decode_char(), hex_decode_finish(), hex_decode_init(), ISC_FALSE, isc_lex_getmastertoken(), isc_lex_ungettoken(), ISC_R_SUCCESS, isc_tokentype_string, ISC_TRUE, isc_textregion::length, hex_decode_ctx_t::length, RETERR, token, isc_token::type, and isc_token::value.

Referenced by fromtext_cds(), fromtext_dlv(), fromtext_ds(), fromtext_sshfp(), fromtext_tlsa(), and unknown_fromtext().

isc_result_t isc_hex_decodestring ( const char *  cstr,
isc_buffer_t target 
)

Decode a null-terminated hex string.

Requires:

Returns: Other error returns are any possible error code from: isc_lex_create(), isc_lex_openbuffer(), isc_hex_tobuffer().

Definition at line 159 of file hex.c.

References hex_decode_char(), hex_decode_finish(), hex_decode_init(), ISC_R_SUCCESS, and RETERR.

Referenced by check_options(), fromtext_hip(), fromtext_nsec3(), fromtext_nsec3param(), load_configuration(), main(), ns_server_signing(), save_opt(), and setup_lookup().


Variable Documentation

const char hex[] = "0123456789ABCDEF" [static]

Definition at line 48 of file hex.c.

Referenced by dns_zone_addnsec3chain(), hex_decode_char(), isc_hex_totext(), log_nsid(), and nibbles().


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