]> git.notmuchmail.org Git - notmuch/blob - util/hex-escape.h
util: run uncrustify
[notmuch] / util / hex-escape.h
1 #ifndef _HEX_ESCAPE_H
2 #define _HEX_ESCAPE_H
3
4 #ifdef __cplusplus
5 extern "C" {
6 #endif
7
8 typedef enum hex_status {
9     HEX_SUCCESS = 0,
10     HEX_SYNTAX_ERROR,
11     HEX_OUT_OF_MEMORY
12 } hex_status_t;
13
14 /*
15  * The API for hex_encode() and hex_decode() is modelled on that for
16  * getline.
17  *
18  * If 'out' points to a NULL pointer a char array of the appropriate
19  * size is allocated using talloc, and out_size is updated.
20  *
21  * If 'out' points to a non-NULL pointer, it assumed to describe an
22  * existing char array, with the size given in *out_size.  This array
23  * may be resized by talloc_realloc if needed; in this case *out_size
24  * will also be updated.
25  *
26  * Note that it is an error to pass a NULL pointer for any parameter
27  * of these routines.
28  */
29
30 hex_status_t
31 hex_encode (void *talloc_ctx, const char *in, char **out,
32             size_t *out_size);
33
34 hex_status_t
35 hex_decode (void *talloc_ctx, const char *in, char **out,
36             size_t *out_size);
37
38 /*
39  * Non-allocating hex decode to decode 's' in-place. The length of the
40  * result is always equal to or shorter than the length of the
41  * original.
42  */
43 hex_status_t
44 hex_decode_inplace (char *s);
45
46 #ifdef __cplusplus
47 }
48 #endif
49
50 #endif