1 /*	$NetBSD: hex_code.h,v 1.4 2022/10/08 16:12:50 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 
27 #define HEX_DECODE_FLAG_NONE	(0)
28 #define HEX_DECODE_FLAG_ALLOW_COLON	(1<<0)
29 
30 extern VSTRING *hex_encode(VSTRING *, const char *, ssize_t);
31 extern VSTRING *WARN_UNUSED_RESULT hex_decode(VSTRING *, const char *, ssize_t);
32 extern VSTRING *hex_encode_opt(VSTRING *, const char *, ssize_t, int);
33 extern VSTRING *WARN_UNUSED_RESULT hex_decode_opt(VSTRING *, const char *, ssize_t, int);
34 
35 #define hex_encode(res, in, len) \
36 	hex_encode_opt((res), (in), (len), HEX_ENCODE_FLAG_NONE)
37 #define hex_decode(res, in, len) \
38 	hex_decode_opt((res), (in), (len), HEX_DECODE_FLAG_NONE)
39 
40 /* LICENSE
41 /* .ad
42 /* .fi
43 /*	The Secure Mailer license must be distributed with this software.
44 /* AUTHOR(S)
45 /*	Wietse Venema
46 /*	IBM T.J. Watson Research
47 /*	P.O. Box 704
48 /*	Yorktown Heights, NY 10598, USA
49 /*
50 /*	Wietse Venema
51 /*	Google, Inc.
52 /*	111 8th Avenue
53 /*	New York, NY 10011, USA
54 /*--*/
55 
56 #endif
57