1 #ifndef INCLUDED_ESCAPE_H
2 #define INCLUDED_ESCAPE_H
3 /* vim: set ts=8 sts=4 sw=4 tw=80 noet: */
4 /*======================================================================
5 Copyright (C) 2004,2005,2009 Walter Doekes <walter+tthsum@wjd.nu>
6 This file is part of tthsum.
7 
8 tthsum is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation, either version 3 of the License, or
11 (at your option) any later version.
12 
13 tthsum is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 GNU General Public License for more details.
17 
18 You should have received a copy of the GNU General Public License
19 along with tthsum.  If not, see <http://www.gnu.org/licenses/>.
20 ======================================================================*/
21 
22 /**
23  * Conversion routines to and from \xNN escaping for non-printable characters
24  * (0x00 through 0x1F).
25  */
26 
27 #ifdef __cplusplus
28 extern "C" {
29 #endif /* __cplusplus */
30 
31 /**
32  * Escape all characters below 0x20 and the backslash in a C-string.
33  * The destination dest must be at least 4*strlen(src)+1 characters long.
34  */
35 void strtoctrlesc(char* dest, const char* src);
36 
37 /**
38  * Unescape a string escaped by strtoctrlesc.
39  * The destination dest must be at least strlen(src)+1 characters long.
40  * Returns 0 on success and -1 when an invalid escape sequence is encountered
41  * (and the state of dest will be undefined).
42  */
43 int ctrlesctostr(char* dest, const char* src);
44 
45 #ifdef __cplusplus
46 } /* extern "C" */
47 #endif /* __cplusplus */
48 
49 #endif /* INCLUDED_ESCAPE_H */
50