Skip to content

Commit

Permalink
Correct compilation errors on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
trink committed Feb 5, 2016
1 parent a91243f commit 026897e
Show file tree
Hide file tree
Showing 13 changed files with 33 additions and 27 deletions.
4 changes: 3 additions & 1 deletion CMakeLists.txt
Expand Up @@ -42,7 +42,6 @@ set(LIB_INSTALL_DIR lib/)
set(INCLUDE_INSTALL_DIR include/)

include_directories("${EP_BASE}/include")
include_directories("${CMAKE_SOURCE_DIR}/include")
install(DIRECTORY "${CMAKE_SOURCE_DIR}/modules/" DESTINATION ${LIB_INSTALL_DIR}${PROJECT_NAME}/modules COMPONENT core)
install(FILES "${CMAKE_SOURCE_DIR}/README.md" DESTINATION share/doc/${PROJECT_NAME} COMPONENT core)

Expand All @@ -63,3 +62,6 @@ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/luasandboxConfig.cmake ${CMAKE_CURRENT
DESTINATION ${INSTALL_CMAKE_DIR} COMPONENT core)

add_subdirectory(src)
add_custom_target(copy_includes
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/include ${EP_BASE}/include)
add_dependencies(luasandboxutil copy_includes)
8 changes: 4 additions & 4 deletions include/luasandbox.h
Expand Up @@ -60,15 +60,15 @@ typedef enum {

typedef struct lsb_lua_sandbox lsb_lua_sandbox;

LSB_EXPORT extern lsb_err_id LSB_ERR_INIT;
LSB_EXPORT extern lsb_err_id LSB_ERR_LUA;
LSB_EXPORT extern lsb_err_id LSB_ERR_TERMINATED;

#ifdef __cplusplus
extern "C"
{
#endif

LSB_EXPORT extern lsb_err_id LSB_ERR_INIT;
LSB_EXPORT extern lsb_err_id LSB_ERR_LUA;
LSB_EXPORT extern lsb_err_id LSB_ERR_TERMINATED;

/**
* Allocates and initializes the structure around the Lua sandbox allowing
* full specification of the sandbox configuration using a Lua configuration
Expand Down
4 changes: 2 additions & 2 deletions include/luasandbox/error.h
Expand Up @@ -11,8 +11,8 @@

// See Identify your Errors better with char[]
// http://accu.org/index.php/journals/2184
typedef char const lsb_err_id[];
typedef char const *lsb_err_value;
typedef const char lsb_err_id[];
typedef const char *lsb_err_value;
#define lsb_err_string(s) s ? s : "<no error>"

typedef void (*lsb_logger)(const char *component,
Expand Down
4 changes: 2 additions & 2 deletions include/luasandbox/heka/sandbox.h
Expand Up @@ -33,8 +33,6 @@

#define LSB_HEKA_MAX_MESSAGE_SIZE "max_message_size"

LSB_HEKA_EXPORT extern lsb_err_id LSB_ERR_HEKA_INPUT;

enum lsb_heka_pm_rv {
LSB_HEKA_PM_SENT = 0,
LSB_HEKA_PM_FAIL = -1,
Expand Down Expand Up @@ -66,6 +64,8 @@ extern "C"
{
#endif

LSB_HEKA_EXPORT extern lsb_err_id LSB_ERR_HEKA_INPUT;

/**
* inject_message callback function provided by the host. Only one (or neither)
* of the checkpoint values will be set in a call. Numeric checkpoints can have
Expand Down
8 changes: 4 additions & 4 deletions include/luasandbox/util/util.h
Expand Up @@ -27,15 +27,15 @@
#endif
#endif

#ifdef __cplusplus
extern "C" {
#endif

LSB_UTIL_EXPORT extern lsb_err_id LSB_ERR_UTIL_NULL;
LSB_UTIL_EXPORT extern lsb_err_id LSB_ERR_UTIL_OOM;
LSB_UTIL_EXPORT extern lsb_err_id LSB_ERR_UTIL_FULL;
LSB_UTIL_EXPORT extern lsb_err_id LSB_ERR_UTIL_PRANGE;

#ifdef __cplusplus
extern "C" {
#endif

/**
* Hacker's Delight - Henry S. Warren, Jr. page 48
*
Expand Down
2 changes: 0 additions & 2 deletions src/CMakeLists.txt
Expand Up @@ -11,9 +11,7 @@ luasandbox_serialize.c
set ( CMAKE_SKIP_BUILD_RPATH FALSE CACHE STRING "" FORCE )
set ( CMAKE_BUILD_WITH_INSTALL_RPATH FALSE CACHE STRING "" FORCE )

add_custom_target(copy_includes COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/include ${EP_BASE}/include)
add_library(luasandbox SHARED ${LUA_SANDBOX_SRC})
add_dependencies(luasandbox copy_includes)

add_dependencies(lua_bloom_filter luasandbox)
add_dependencies(lua_circular_buffer luasandbox)
Expand Down
2 changes: 1 addition & 1 deletion src/heka/CMakeLists.txt
Expand Up @@ -11,7 +11,7 @@ stream_reader.c

add_library(luasandboxheka SHARED ${HEKA_SRC})
set_target_properties(luasandboxheka PROPERTIES VERSION ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH} SOVERSION 0)
target_compile_definitions(luasandboxheka PUBLIC -Dluasandboxheka_EXPORTS)
target_compile_definitions(luasandboxheka PRIVATE -Dluasandboxheka_EXPORTS)
target_link_libraries(luasandboxheka luasandbox)
if(WIN32)
target_link_libraries(luasandboxheka ws2_32)
Expand Down
2 changes: 1 addition & 1 deletion src/heka/message.c
Expand Up @@ -330,7 +330,7 @@ static lsb_err_value
encode_field_array(lsb_lua_sandbox *lsb, lsb_output_buffer *ob, int t,
const char *representation, int value_type)
{
lsb_err_value ret;
lsb_err_value ret = NULL;
int first = (int)lua_objlen(lsb->lua, -1);
int multiple = first > 1 ? first : 0;
size_t len_pos = 0;
Expand Down
5 changes: 4 additions & 1 deletion src/heka/sandbox.c
Expand Up @@ -23,6 +23,7 @@

#ifdef _WIN32
#include <winsock2.h>
#define snprintf _snprintf
#else
#include <unistd.h>
#endif
Expand Down Expand Up @@ -499,7 +500,9 @@ int lsb_heka_pm_input(lsb_heka_sandbox *hsb,
const char *cp_string,
bool profile)
{
if (!hsb || hsb->type != 'i') return 1;
if (!hsb || hsb->type != 'i') {
return 1;
}

lsb_err_value ret = lsb_pcall_setup(hsb->lsb, pm_func_name);
if (ret) {
Expand Down
7 changes: 3 additions & 4 deletions src/luasandbox.c
Expand Up @@ -23,10 +23,9 @@
#include "luasandbox_impl.h"
#include "luasandbox_serialize.h"


lsb_err_id LSB_ERR_INIT = "already initialized";
lsb_err_id LSB_ERR_LUA = "lua error"; // use lsb_get_error for more detail
lsb_err_id LSB_ERR_TERMINATED = "sandbox already terminated";
lsb_err_id LSB_ERR_INIT = "already initialized";
lsb_err_id LSB_ERR_LUA = "lua error"; // use lsb_get_error for details
lsb_err_id LSB_ERR_TERMINATED = "sandbox already terminated";

static jmp_buf g_jbuf;

Expand Down
2 changes: 1 addition & 1 deletion src/util/CMakeLists.txt
Expand Up @@ -15,7 +15,7 @@ util.c

add_library(luasandboxutil SHARED ${UTIL_SRC})
set_target_properties(luasandboxutil PROPERTIES VERSION ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH} SOVERSION 0)
target_compile_definitions(luasandboxutil PUBLIC -Dluasandboxutil_EXPORTS)
target_compile_definitions(luasandboxutil PRIVATE -Dluasandboxutil_EXPORTS)

if(LIBM_LIBRARY)
target_link_libraries(luasandboxutil ${LIBM_LIBRARY})
Expand Down
8 changes: 6 additions & 2 deletions src/util/output_buffer.c
Expand Up @@ -77,7 +77,9 @@ lsb_err_value lsb_expand_output_buffer(lsb_output_buffer *b, size_t needed)

lsb_err_value lsb_outputc(lsb_output_buffer *b, char ch)
{
if (!b) return LSB_ERR_UTIL_NULL;
if (!b) {
return LSB_ERR_UTIL_NULL;
}
lsb_err_value ret = lsb_expand_output_buffer(b, 2);
if (ret) return ret;

Expand Down Expand Up @@ -143,7 +145,9 @@ lsb_err_value lsb_outputf(lsb_output_buffer *b, const char *fmt, ...)

lsb_err_value lsb_outputs(lsb_output_buffer *b, const char *str, size_t len)
{
if (!b) return LSB_ERR_UTIL_NULL;
if (!b) {
return LSB_ERR_UTIL_NULL;
}
lsb_err_value ret = lsb_expand_output_buffer(b, len + 1);
if (ret) return ret;

Expand Down
4 changes: 2 additions & 2 deletions src/util/util.c
Expand Up @@ -6,6 +6,8 @@

/** General purpose utility functions @file */

#include "luasandbox/util/util.h"

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
Expand All @@ -23,8 +25,6 @@
#include <mach/mach_time.h>
#endif

#include "luasandbox/util/util.h"

lsb_err_id LSB_ERR_UTIL_NULL = "pointer is NULL";
lsb_err_id LSB_ERR_UTIL_OOM = "memory allocation failed";
lsb_err_id LSB_ERR_UTIL_FULL = "buffer full";
Expand Down

0 comments on commit 026897e

Please sign in to comment.