File: hex-escape.h

package info (click to toggle)
notmuch 0.40-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 7,120 kB
  • sloc: sh: 22,063; ansic: 14,938; lisp: 9,090; cpp: 8,030; python: 6,342; perl: 391; makefile: 231; javascript: 34; ruby: 9
file content (50 lines) | stat: -rw-r--r-- 1,159 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#ifndef _HEX_ESCAPE_H
#define _HEX_ESCAPE_H

#ifdef __cplusplus
extern "C" {
#endif

typedef enum {
    HEX_SUCCESS = 0,
    HEX_SYNTAX_ERROR,
    HEX_OUT_OF_MEMORY
} hex_status_t;

/*
 * The API for hex_encode() and hex_decode() is modelled on that for
 * getline.
 *
 * If 'out' points to a NULL pointer a char array of the appropriate
 * size is allocated using talloc, and out_size is updated.
 *
 * If 'out' points to a non-NULL pointer, it assumed to describe an
 * existing char array, with the size given in *out_size.  This array
 * may be resized by talloc_realloc if needed; in this case *out_size
 * will also be updated.
 *
 * Note that it is an error to pass a NULL pointer for any parameter
 * of these routines.
 */

hex_status_t
hex_encode (void *talloc_ctx, const char *in, char **out,
	    size_t *out_size);

hex_status_t
hex_decode (void *talloc_ctx, const char *in, char **out,
	    size_t *out_size);

/*
 * Non-allocating hex decode to decode 's' in-place. The length of the
 * result is always equal to or shorter than the length of the
 * original.
 */
hex_status_t
hex_decode_inplace (char *s);

#ifdef __cplusplus
}
#endif

#endif