luasandbox  1.4.0
Generic Lua sandbox for dynamic data analysis
sandbox.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 /** Test interface for the generic lua sandbox @file */
8 
9 #ifndef luasandbox_test_sandbox_h_
10 #define luasandbox_test_sandbox_h_
11 
12 #include <stddef.h>
13 
14 #include "../../luasandbox.h"
15 #include "../error.h"
16 
17 #ifdef _WIN32
18 #ifdef luasandboxtest_EXPORTS
19 #define LSB_TEST_EXPORT __declspec(dllexport)
20 #else
21 #define LSB_TEST_EXPORT __declspec(dllimport)
22 #endif
23 #else
24 #if __GNUC__ >= 4
25 #define LSB_TEST_EXPORT __attribute__ ((visibility ("default")))
26 #else
27 #define LSB_TEST_EXPORT
28 #endif
29 #endif
30 
31 #ifdef __cplusplus
32 extern "C"
33 {
34 #endif
35 #include "../lua.h"
36 
37 /**
38  * Global variable to store the test output
39  *
40  */
41 LSB_TEST_EXPORT extern const char *lsb_test_output;
42 
43 /**
44  * Global variable storing the length of the current test output string
45  *
46  */
48 
49 /**
50  * Generaly purpose stderr logger
51  *
52  */
54 
55 /**
56  * Function to emulate processing data
57  *
58  * @param lsb Pointer to a lua sandbox
59  * @param tc Test case number to control how the sandbox state is updated
60  *
61  * @return LSB_TEST_EXPORT int Status value returned from the sandbox
62  */
64 
65 /**
66  * Function to emulate outputting summary data
67  *
68  * @param lsb Pointer to a lua sandbox
69  * @param tc Test case number to control what data is returned and how the state
70  * is updated
71  *
72  * @return LSB_TEST_EXPORT int 0 on success, 1 on failure
73  */
75 
76 /**
77  * Callback for collecting output, places a pointer to the results in the global
78  * lsb_test_output variable )not thread safe)
79  *
80  * @param lua Lua state
81  *
82  * @return LSB_TEST_EXPORT int 0 or lua_error
83  */
85 
86 #ifdef __cplusplus
87 }
88 #endif
89 
90 #endif
struct lsb_lua_sandbox lsb_lua_sandbox
Definition: luasandbox.h:65
LSB_TEST_EXPORT const char * lsb_test_output
Global variable to store the test output.
LSB_TEST_EXPORT int lsb_test_process(lsb_lua_sandbox *lsb, double tc)
Function to emulate processing data.
#define LSB_TEST_EXPORT
Definition: sandbox.h:27
struct lua_State lua_State
Definition: lua.h:50
LSB_TEST_EXPORT int lsb_test_report(lsb_lua_sandbox *lsb, double tc)
Function to emulate outputting summary data.
LSB_TEST_EXPORT size_t lsb_test_output_len
Global variable storing the length of the current test output string.
LSB_TEST_EXPORT int lsb_test_write_output(lua_State *lua)
Callback for collecting output, places a pointer to the results in the global lsb_test_output variabl...
LSB_TEST_EXPORT lsb_logger lsb_test_logger
Generaly purpose stderr logger.