diff options
author | Ondřej Surý <ondrej@sury.org> | 2013-06-28 12:59:40 +0200 |
---|---|---|
committer | Ondřej Surý <ondrej@sury.org> | 2013-06-28 12:59:40 +0200 |
commit | 124965832295a277b9ca6ae9fac4f45a74a36b2a (patch) | |
tree | f299e2335863f74e0be0707f84b85211baaf2d03 /src/common/print.h | |
parent | 3d2d198c71a6b844b60fa9ef68801b66bba93361 (diff) | |
download | knot-upstream/1.3.0_rc3.tar.gz |
New upstream version 1.3.0~rc3upstream/1.3.0_rc3
Diffstat (limited to 'src/common/print.h')
-rw-r--r-- | src/common/print.h | 67 |
1 files changed, 50 insertions, 17 deletions
diff --git a/src/common/print.h b/src/common/print.h index 482f55e..bd67610 100644 --- a/src/common/print.h +++ b/src/common/print.h @@ -30,42 +30,75 @@ #ifndef _KNOTD_COMMON_PRINT_H_ #define _KNOTD_COMMON_PRINT_H_ +#include <sys/time.h> +#include <stdint.h> + typedef int (*printf_t)(const char *fmt, ...); /*! - * \brief Prints the given data as hexadecimal characters. + * \brief Prints the given data as hexadecimal character string. Each hexa-pair + * contains leading 0x string. + * + * \param data Data to print. + * \param length Size of the \a data array. + */ +void hex_print(const uint8_t *data, unsigned length); + +/*! + * \brief Prints the given data as hexadecimal character string. + * + * \param data Data to print. + * \param length Size of the \a data array. + */ +void short_hex_print(const uint8_t *data, unsigned length); + +/*! + * \brief Prints the given data as text character string. Unprintable characters + * are replaced with a space. * - * \param data Data to print. - * \param length Size of the \a data array. + * \param data Data to print. + * \param length Size of the \a data array. */ -void hex_print(const char *data, int length); +void txt_print(const uint8_t *data, unsigned length); /*! - * \brief Prints the given data as hexadecimal characters using the given - * handler. + * \brief Prints the given data array as a specified character string using + * the given handler. * - * \param data Data to print. - * \param length Size of the \a data array. - * \param print_handler Handler for printing. + * \param data Data to print. + * \param length Size of the \a data array. + * \param print_handler Handler for printing. + * \param type Character type ('x': hex, 't': txt, otherwise: 0xXX). */ -void hex_printf(const char *data, int length, printf_t print_handler); +void array_printf(const uint8_t *data, const unsigned length, + printf_t print_handler, const char type); /*! * \brief Prints the given data as a bitmap. * - * \param data Data to print. - * \param length Size of the \a data array. + * \param data Data to print. + * \param length Size of the \a data array. */ -void bit_print(const char *data, int length); +void bit_print(const uint8_t *data, unsigned length); /*! * \brief Prints the given data as a bitmap using the given handler. * - * \param data Data to print. - * \param length Size of the \a data array. - * \param print_handler Handler for printing. + * \param data Data to print. + * \param length Size of the \a data array. + * \param print_handler Handler for printing. + */ +void bit_printf(const uint8_t *data, unsigned length, printf_t print_handler); + +/*! + * \brief Get time diff in miliseconds. + * + * \param begin + * \param end + * + * \return time diff */ -void bit_printf(const char *data, int length, printf_t print_handler); +float time_diff(struct timeval *begin, struct timeval *end); #endif /* _KNOTD_COMMON_PRINT_H_ */ |