1 /* $NetBSD: hex_code.h,v 1.6 2026/05/09 18:49:22 christos Exp $ */ 2 3 #ifndef _HEX_CODE_H_INCLUDED_ 4 #define _HEX_CODE_H_INCLUDED_ 5 6 /*++ 7 /* NAME 8 /* hex_code 3h 9 /* SUMMARY 10 /* encode/decode data, hexadecimal style 11 /* SYNOPSIS 12 /* #include <hex_code.h> 13 /* DESCRIPTION 14 /* .nf 15 16 /* 17 * Utility library. 18 */ 19 #include <vstring.h> 20 21 /* 22 * External interface. 23 */ 24 #define HEX_ENCODE_FLAG_NONE (0) 25 #define HEX_ENCODE_FLAG_USE_COLON (1<<0) 26 #define HEX_ENCODE_FLAG_APPEND (1<<1) 27 #define HEX_ENCODE_FLAG_LOWERCASE (1<<2) 28 29 #define HEX_DECODE_FLAG_NONE (0) 30 #define HEX_DECODE_FLAG_ALLOW_COLON (1<<0) 31 32 extern VSTRING *hex_encode(VSTRING *, const char *, ssize_t); 33 extern VSTRING *WARN_UNUSED_RESULT hex_decode(VSTRING *, const char *, ssize_t); 34 extern VSTRING *hex_encode_opt(VSTRING *, const char *, ssize_t, int); 35 extern VSTRING *WARN_UNUSED_RESULT hex_decode_opt(VSTRING *, const char *, ssize_t, int); 36 37 #define hex_encode(res, in, len) \ 38 hex_encode_opt((res), (in), (len), HEX_ENCODE_FLAG_NONE) 39 #define hex_decode(res, in, len) \ 40 hex_decode_opt((res), (in), (len), HEX_DECODE_FLAG_NONE) 41 42 /* LICENSE 43 /* .ad 44 /* .fi 45 /* The Secure Mailer license must be distributed with this software. 46 /* AUTHOR(S) 47 /* Wietse Venema 48 /* IBM T.J. Watson Research 49 /* P.O. Box 704 50 /* Yorktown Heights, NY 10598, USA 51 /* 52 /* Wietse Venema 53 /* Google, Inc. 54 /* 111 8th Avenue 55 /* New York, NY 10011, USA 56 /* 57 /* Wietse Venema 58 /* porcupine.org 59 /*--*/ 60 61 #endif 62