2 /* Copyright Gerhard Rieger and contributors (see file CHANGES) */
3 /* Published under the GNU General Public License V.2, see file COPYING */
5 #ifndef __utils_h_included
6 #define __utils_h_included 1
8 /* a generic name table entry */
14 #if !HAVE_PROTOTYPE_LIB_memrchr
15 extern void *memrchr(const void *s
, int c
, size_t n
);
17 extern void *memdup(const void *src
, size_t n
);
18 #if !HAVE_PROTOTYPE_LIB_strndup
19 extern char *strndup(const char *s
, size_t n
);
22 extern int setenv(const char *name
, const char *value
, int overwrite
);
23 #endif /* !HAVE_SETENV */
25 extern const struct wordent
*keyw(const struct wordent
*keywds
, const char *name
, unsigned int nkeys
);
28 #define XIOSAN_ZERO_MASK 0x000f
29 #define XIOSAN_ZERO_DEFAULT 0x0000
30 #define XIOSAN_ZERO_DOT 0x0001
31 #define XIOSAN_ZERO_BACKSLASH_OCT_3 0x0002
32 #define XIOSAN_ZERO_BACKSLASH_OCT_4 0x0003
33 #define XIOSAN_ZERO_BACKSLASHX_HEX_UP 0x0004
34 #define XIOSAN_ZERO_BACKSLASHX_HEX_LOW 0x0005
35 #define XIOSAN_ZERO_PERCENT_HEX_UP 0x0006
36 #define XIOSAN_ZERO_PERCENT_HEX_LOW 0x0007
37 #define XIOSAN_CONTROL_MASK 0x00f0
38 #define XIOSAN_CONTROL_DEFAULT 0x0000
39 #define XIOSAN_CONTROL_DOT 0x0010
40 #define XIOSAN_CONTROL_BACKSLASH_OCT_3 0x0020
41 #define XIOSAN_CONTROL_BACKSLASH_OCT_4 0x0030
42 #define XIOSAN_CONTROL_BACKSLASHX_HEX_UP 0x0040
43 #define XIOSAN_CONTROL_BACKSLASHX_HEX_LOW 0x0050
44 #define XIOSAN_CONTROL_PERCENT_HEX_UP 0x0060
45 #define XIOSAN_CONTROL_PERCENT_HEX_LOW 0x0070
46 #define XIOSAN_UNPRINT_MASK 0x0f00
47 #define XIOSAN_UNPRINT_DEFAULT 0x0000
48 #define XIOSAN_UNPRINT_DOT 0x0100
49 #define XIOSAN_UNPRINT_BACKSLASH_OCT_3 0x0200
50 #define XIOSAN_UNPRINT_BACKSLASH_OCT_4 0x0300
51 #define XIOSAN_UNPRINT_BACKSLASHX_HEX_UP 0x0400
52 #define XIOSAN_UNPRINT_BACKSLASHX_HEX_LOW 0x0500
53 #define XIOSAN_UNPRINT_PERCENT_HEX_UP 0x0600
54 #define XIOSAN_UNPRINT_PERCENT_HEX_LOW 0x0700
55 #define XIOSAN_DEFAULT_MASK 0xf000
56 #define XIOSAN_DEFAULT_BACKSLASH_DOT 0x1000
57 #define XIOSAN_DEFAULT_BACKSLASH_OCT_3 0x2000
58 #define XIOSAN_DEFAULT_BACKSLASH_OCT_4 0x3000
59 #define XIOSAN_DEFAULT_BACKSLASHX_HEX_UP 0x4000
60 #define XIOSAN_DEFAULT_BACKSLASHX_HEX_LOW 0x5000
61 #define XIOSAN_DEFAULT_PERCENT_HEX_UP 0x6000
62 #define XIOSAN_DEFAULT_PERCENT_HEX_LOW 0x7000
65 char *sanitize_string(const char *data
, /* input data */
66 size_t bytes
, /* length of input data, >=0 */
67 char *coded
, /* output buffer, must be long enough */
70 char *xiosubstr(char *scratch
, const char *str
, size_t from
, size_t len
);
73 int xio_snprintf(char *str
, size_t size
, const char *format
, ...);
75 #endif /* !defined(__utils_h_included) */