luasandbox  1.4.0
Generic Lua sandbox for dynamic data analysis
string.h
Go to the documentation of this file.
1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4  * License, v. 2.0. If a copy of the MPL was not distributed with this
5  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 
7 /** Heka message string @file */
8 
9 #ifndef luasandbox_util_string_h_
10 #define luasandbox_util_string_h_
11 
12 #include "util.h"
13 
14 typedef struct lsb_const_string
15 {
16  const char *s;
17  size_t len;
19 
20 
21 #ifdef __cplusplus
22 extern "C"
23 {
24 #endif
25 
26 /**
27  * Initializes the struct to zero.
28  *
29  * @param s Pointer to the struct
30  *
31  */
33 
34 
35 /**
36  * Lua string unescape. The returned string is always NUL terminated, but can
37  * contain other NULs in its body.
38  *
39  * @param d Pointer to the destination array where the content is to be
40  * unescaped.
41  * @param s C string to be unescaped
42  * @param dlen The length of the destination array (must be 1 byte larger than
43  * the source string (for inclusion of the NUL terminator). After
44  * successful conversion the final length of the escaped string is
45  * written back to this value as it may not equal strlen(d).
46  *
47  * @return char* A pointer to d or NULL on error.
48  */
50 char* lsb_lua_string_unescape(char *d, const char *s, size_t *dlen);
51 
52 #ifdef __cplusplus
53 }
54 #endif
55 
56 #endif
size_t len
Definition: string.h:17
struct lsb_const_string lsb_const_string
const char * s
Definition: string.h:16
LSB_UTIL_EXPORT void lsb_init_const_string(lsb_const_string *s)
Initializes the struct to zero.
Shared types and structures.
#define LSB_UTIL_EXPORT
Definition: util.h:28
LSB_UTIL_EXPORT char * lsb_lua_string_unescape(char *d, const char *s, size_t *dlen)
Lua string unescape.