luasandbox  1.4.0
Generic Lua sandbox for dynamic data analysis
string_matcher.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 /** C API for the Lua string pattern matcher @file */
8 
9 #ifndef luasandbox_util_string_matcher_h_
10 #define luasandbox_util_string_matcher_h_
11 
12 #include <stdbool.h>
13 #include <stddef.h>
14 
15 #include "util.h"
16 
17 #ifdef __cplusplus
18 extern "C" {
19 #endif
20 
21 /**
22  * Matches a string using a Lua string match pattern
23  *
24  * @param s String to match
25  * @param len Length of the string
26  * @param p Lua match pattern
27  * http://www.lua.org/manual/5.1/manual.html#pdf-string.match
28  *
29  * @return bool True if the string matches the pattern
30  */
31 LSB_UTIL_EXPORT bool lsb_string_match(const char *s, size_t len, const char *p);
32 
33 
34 /**
35  * Searches for a string literal within a string
36  *
37  * @param s String to search
38  * @param ls Length of the string
39  * @param p Literal match string
40  * @param lp Length of the match string
41  *
42  * @return bool True if the string contains the literal
43  */
44 LSB_UTIL_EXPORT bool lsb_string_find(const char *s, size_t ls, const char *p, size_t lp);
45 
46 #ifdef __cplusplus
47 }
48 #endif
49 
50 #endif
LSB_UTIL_EXPORT bool lsb_string_find(const char *s, size_t ls, const char *p, size_t lp)
Searches for a string literal within a string.
Shared types and structures.
#define LSB_UTIL_EXPORT
Definition: util.h:28
LSB_UTIL_EXPORT bool lsb_string_match(const char *s, size_t len, const char *p)
Matches a string using a Lua string match pattern.