Showing preview only (1,076K chars total). Download the full file or copy to clipboard to get everything.
Repository: mozilla-services/lua_sandbox
Branch: main
Commit: 78103a88ff8d
Files: 162
Total size: 1.0 MB
Directory structure:
gitextract_30bp_v8t/
├── .gitattributes
├── .gitignore
├── .travis.yml
├── CMakeLists.txt
├── CODE_OF_CONDUCT.md
├── LICENSE.txt
├── README.md
├── build/
│ ├── functions.sh
│ └── run.sh
├── cmake/
│ ├── doxygen.cmake
│ ├── luasandboxConfig.cmake.in
│ └── mozsvc.cmake
├── covfn.txt
├── docs/
│ ├── cli/
│ │ └── index.md
│ ├── heka/
│ │ ├── analysis.md
│ │ ├── index.md
│ │ ├── input.md
│ │ ├── message.md
│ │ └── output.md
│ ├── index.md
│ ├── sandbox.md
│ └── util/
│ └── message_matcher.md
├── gen_gh_pages.lua
├── include/
│ ├── luasandbox/
│ │ ├── error.h
│ │ ├── heka/
│ │ │ ├── sandbox.h
│ │ │ └── stream_reader.h
│ │ ├── lauxlib.h
│ │ ├── lua.h
│ │ ├── luaconf.h
│ │ ├── lualib.h
│ │ ├── test/
│ │ │ ├── mu_test.h
│ │ │ └── sandbox.h
│ │ └── util/
│ │ ├── heka_message.h
│ │ ├── heka_message_matcher.h
│ │ ├── input_buffer.h
│ │ ├── output_buffer.h
│ │ ├── protobuf.h
│ │ ├── running_stats.h
│ │ ├── string.h
│ │ ├── string_matcher.h
│ │ └── util.h
│ ├── luasandbox.h
│ ├── luasandbox_output.h
│ └── luasandbox_serialize.h
└── src/
├── CMakeLists.txt
├── cli/
│ ├── CMakeLists.txt
│ └── lsb_heka_cat.c
├── heka/
│ ├── CMakeLists.txt
│ ├── message.c
│ ├── message_impl.h
│ ├── read_message_zc.c
│ ├── sandbox.c
│ ├── sandbox_impl.h
│ ├── stream_reader.c
│ └── test/
│ ├── CMakeLists.txt
│ ├── lua/
│ │ ├── aim.lua
│ │ ├── analysis.lua
│ │ ├── decode_message.lua
│ │ ├── decode_message_benchmark.lua
│ │ ├── encode_message.lua
│ │ ├── iim.lua
│ │ ├── input.lua
│ │ ├── oim.lua
│ │ ├── output.lua
│ │ ├── pm_no_return.lua
│ │ ├── read_message.lua
│ │ └── read_message_zc.lua
│ ├── test.h.in
│ └── test_heka_sandbox.c
├── lua/
│ ├── lapi.c
│ ├── lapi.h
│ ├── lauxlib.c
│ ├── lbaselib.c
│ ├── lcode.c
│ ├── lcode.h
│ ├── ldblib.c
│ ├── ldebug.c
│ ├── ldebug.h
│ ├── ldo.c
│ ├── ldo.h
│ ├── ldump.c
│ ├── lfunc.c
│ ├── lfunc.h
│ ├── lgc.c
│ ├── lgc.h
│ ├── linit.c
│ ├── liolib.c
│ ├── llex.c
│ ├── llex.h
│ ├── llimits.h
│ ├── lmathlib.c
│ ├── lmem.c
│ ├── lmem.h
│ ├── loadlib.c
│ ├── lobject.c
│ ├── lobject.h
│ ├── lopcodes.c
│ ├── lopcodes.h
│ ├── loslib.c
│ ├── lparser.c
│ ├── lparser.h
│ ├── lstate.c
│ ├── lstate.h
│ ├── lstring.c
│ ├── lstring.h
│ ├── lstrlib.c
│ ├── ltable.c
│ ├── ltable.h
│ ├── ltablib.c
│ ├── ltm.c
│ ├── ltm.h
│ ├── lundump.c
│ ├── lundump.h
│ ├── lvm.c
│ ├── lvm.h
│ ├── lzio.c
│ └── lzio.h
├── luasandbox.c
├── luasandbox_defines.h
├── luasandbox_impl.h
├── luasandbox_output.c
├── luasandbox_serialize.c
├── test/
│ ├── CMakeLists.txt
│ ├── lua/
│ │ ├── bad_module.lua
│ │ ├── counter.lua
│ │ ├── errors.lua
│ │ ├── no_external_modules.lua
│ │ ├── output.lua
│ │ ├── output_errors.lua
│ │ ├── print.lua
│ │ ├── read_config.lua
│ │ ├── restore.lua
│ │ ├── sandbox_config.lua
│ │ ├── serialize.lua
│ │ ├── serialize_failure.lua
│ │ └── simple.lua
│ ├── output/
│ │ └── serialize.lua51.data
│ ├── sandbox.c
│ └── test_generic_sandbox.c
└── util/
├── CMakeLists.txt
├── heka_message.c
├── heka_message_matcher.c
├── heka_message_matcher_impl.h
├── heka_message_matcher_parser.c
├── heka_message_matcher_parser.leg
├── input_buffer.c
├── output_buffer.c
├── protobuf.c
├── running_stats.c
├── string.c
├── string_matcher.c
├── test/
│ ├── CMakeLists.txt
│ ├── test_heka_message.c
│ ├── test_heka_message_matcher.c
│ ├── test_input_buffer.c
│ ├── test_output_buffer.c
│ ├── test_protobuf.c
│ ├── test_running_stats.c
│ ├── test_string.c
│ ├── test_string_matcher.c
│ └── test_util.c
└── util.c
================================================
FILE CONTENTS
================================================
================================================
FILE: .gitattributes
================================================
*.data text eol=lf
================================================
FILE: .gitignore
================================================
*.preserve
release/
src/test/modules/
Testing
*~
gh-pages/
================================================
FILE: .travis.yml
================================================
language: generic
sudo: required
services:
- docker
env:
matrix:
- DOCKER_IMAGE=centos:7 CMAKE_URL=auto
- DOCKER_IMAGE=debian:8 CMAKE_URL=auto
- DOCKER_IMAGE=debian:8 CC=clang CMAKE_URL=auto
- DOCKER_IMAGE=debian:stretch
- DOCKER_IMAGE=fedora:latest
- DOCKER_IMAGE=ubuntu:latest CMAKE_URL=auto # LTS
- DOCKER_IMAGE=ubuntu:devel
script:
- ./build/run.sh build
================================================
FILE: CMakeLists.txt
================================================
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
cmake_minimum_required(VERSION 3.6 FATAL_ERROR)
project(luasandbox VERSION 1.4.0 LANGUAGES C)
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Generic Lua sandbox for dynamic data analysis")
set(CPACK_PACKAGE_VERSION_MAJOR ${PROJECT_VERSION_MAJOR})
set(CPACK_PACKAGE_VERSION_MINOR ${PROJECT_VERSION_MINOR})
set(CPACK_PACKAGE_VERSION_PATCH ${PROJECT_VERSION_PATCH})
set(CPACK_PACKAGE_CONTACT "Mike Trinkala <trink@mozilla.com>")
set(CPACK_DEBIAN_FILE_NAME "DEB-DEFAULT")
set(CPACK_RPM_FILE_NAME "RPM-DEFAULT")
set(CPACK_RPM_PACKAGE_LICENSE "MPLv2.0")
include(GNUInstallDirs)
if(WIN32)
set(INSTALL_CMAKE_DIR cmake)
set(CMAKE_INSTALL_LIBDIR ${CMAKE_INSTALL_BINDIR})
else()
set(INSTALL_CMAKE_DIR "${CMAKE_INSTALL_DATAROOTDIR}/${PROJECT_NAME}/cmake")
endif()
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
include(mozsvc)
include(CheckFunctionExists)
check_function_exists(clock_gettime HAVE_CLOCK_GETTIME)
if(HAVE_CLOCK_GETTIME)
add_definitions(-DHAVE_CLOCK_GETTIME)
endif()
include(CMakePackageConfigHelpers)
configure_package_config_file(cmake/${PROJECT_NAME}Config.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake
INSTALL_DESTINATION ${INSTALL_CMAKE_DIR}
PATH_VARS CMAKE_INSTALL_INCLUDEDIR CMAKE_INSTALL_LIBDIR)
write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
COMPATIBILITY SameMajorVersion)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
DESTINATION ${INSTALL_CMAKE_DIR})
find_library(LIBM_LIBRARY m)
include_directories("${CMAKE_SOURCE_DIR}/include" "${CMAKE_SOURCE_DIR}/include/luasandbox" )
install(DIRECTORY "${CMAKE_SOURCE_DIR}/include/" DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
install(FILES "${CMAKE_SOURCE_DIR}/README.md" DESTINATION ${CMAKE_INSTALL_DOCDIR})
add_subdirectory(src)
add_dependencies(luasandbox luasandboxutil)
add_dependencies(luasandboxtest luasandbox)
add_dependencies(luasandboxheka luasandboxtest)
================================================
FILE: CODE_OF_CONDUCT.md
================================================
# Community Participation Guidelines
This repository is governed by Mozilla's code of conduct and etiquette guidelines.
For more details, please read the
[Mozilla Community Participation Guidelines](https://www.mozilla.org/about/governance/policies/participation/).
## How to Report
For more information on how to report violations of the Community Participation Guidelines, please read our '[How to Report](https://www.mozilla.org/about/governance/policies/participation/reporting/)' page.
<!--
## Project Specific Etiquette
In some cases, there will be additional project etiquette i.e.: (https://bugzilla.mozilla.org/page.cgi?id=etiquette.html).
Please update for your project.
-->
================================================
FILE: LICENSE.txt
================================================
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
# You can obtain one at http://mozilla.org/MPL/2.0/.
================================================
FILE: README.md
================================================
# Lua Sandbox Library
## Overview
Sandboxes provide a dynamic and isolated execution environment
for data parsing, transformation, and analysis. They allow access to data
without jeopardizing the integrity or performance of the processing
infrastructure. This broadens the audience that the data can be
exposed to and facilitates new uses of the data (i.e. debugging, monitoring,
dynamic provisioning, SLA analysis, intrusion detection, ad-hoc reporting,
etc.)
The Lua sandbox is a library allowing customized control over the Lua execution
environment including functionality like global data preservation/restoration on
shutdown/startup, output collection in textual or binary formats and an array of
parsers for various data types (Nginx, Apache, Syslog, MySQL and many RFC grammars)
These libraries and utilities have been mostly extracted from
[Hindsight](https://github.com/mozilla-services/hindsight). The goal was to
decouple the Heka/Hindsight functionality from any particular infrastructure and
make it embeddable into any tool or language.
### Features
- small - memory requirements are as little as 8 KiB for a basic sandbox
- fast - microsecond execution times
- stateful - ability to resume where it left off after a restart/reboot
- isolated - failures are contained and malfunctioning sandboxes are terminated.
Containment is defined in terms of restriction to the operating system,
file system, libraries, memory use, Lua instruction use, and output size.
[Full Documentation](http://mozilla-services.github.io/lua_sandbox)
## Installation
### Prerequisites
* C compiler (GCC 4.7+, Visual Studio 2013)
* CMake (3.0+) - http://cmake.org/cmake/resources/software.html
* Git http://git-scm.com/download
#### Optional (used for documentation)
* Graphviz (2.28.0) - http://graphviz.org/Download..php
* Doxygen (1.8.11+) - http://www.stack.nl/~dimitri/doxygen/download.html#latestsrc
* gitbook (2.3) - https://www.gitbook.com/
* lua (5.1) - https://www.lua.org/download.html
### CMake Build Instructions
git clone https://github.com/mozilla-services/lua_sandbox.git
cd lua_sandbox
mkdir release
cd release
# UNIX
cmake -DCMAKE_BUILD_TYPE=release ..
make
# Windows Visual Studio 2013
cmake -DCMAKE_BUILD_TYPE=release -G "NMake Makefiles" ..
nmake
ctest
cpack -G TGZ # (DEB|RPM|ZIP)
## Releases
* The main branch is the current release and is considered stable at all
times.
* New versions can be released as frequently as every two weeks (our sprint
cycle). The only exception would be for a high priority patch.
* All active work is flagged with the sprint milestone and tracked in the
project dashboard.
* New releases occur the day after the sprint finishes.
* The version in the dev branch is updated
* The changes are merged into main
* A new tag is created
## Contributions
* All pull requests must be made against the dev branch, direct commits to
main are not permitted.
* All non trivial contributions should start with an issue being filed (if it is
a new feature please propose your design/approach before doing any work as not
all feature requests are accepted).
================================================
FILE: build/functions.sh
================================================
#!/bin/sh
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# Author: Mathieu Parent <math.parent@gmail.com>
# =================================================================
# Show usage
usage() {
echo "Build, test and make packages (optionally using Docker)" >&2
echo " $0 build" >&2
echo "" >&2
echo "Options are passed using environment variables:" >&2
echo " - DOCKER_IMAGE: Run the build in a container (default: <none>)" >&2
echo " - CPACK_GENERATOR: DEB, RPM, TGZ, ... (default guessed)" >&2
echo " - CMAKE_URL: If set, download cmake from it (default: <none>, auto also supported)" >&2
echo " - CMAKE_SHA256: Used to checksum CMAKE_URL (default: <none>)" >&2
echo " - CC: C compiler (default: gcc)" >&2
echo " - CXX: C++ compiler (default: g++)" >&2
}
# =================================================================
# Run command within container
docker_run() {
DOCKER_IMAGE="${DOCKER_IMAGE:-debian:jessie}"
DOCKER_VOLUME="$(dirname "$PWD")"
( set -x
docker pull "$DOCKER_IMAGE"
ret=0
docker run \
--volume "${DOCKER_VOLUME}:${DOCKER_VOLUME}" \
--workdir "$PWD" \
--rm=true --tty=true \
--env "CPACK_GENERATOR=${CPACK_GENERATOR}" \
--env "CMAKE_URL=${CMAKE_URL}" \
--env "CMAKE_SHA256=${CMAKE_SHA256}" \
--env "CC=${CC}" \
--env "CXX=${CXX}" \
--env "DISTRO=${DOCKER_IMAGE}" \
"$DOCKER_IMAGE" \
$@
)
}
# =================================================================
# Guess environment variables
setup_env() {
if [ "$(id -u)" = 0 ]; then
as_root=""
else
as_root="sudo"
fi
if [ -z "${CPACK_GENERATOR}" ]; then
if [ -x "`command -v apt-get 2>/dev/null`" ]; then
CPACK_GENERATOR=DEB
elif [ -x "`command -v rpm 2>/dev/null`" ]; then
CPACK_GENERATOR=RPM
else
CPACK_GENERATOR=TGZ
fi
fi
CC="${CC:-gcc}"
CXX="${CXX:-g++}"
}
# =================================================================
# Install cmake from URL
install_cmake() {
if echo "$PATH" | grep -qF "/cmake-dist/bin:" ; then
# Already done
return
fi
if [ "$CMAKE_URL" = "auto" ]; then
CMAKE_URL="https://cmake.org/files/v3.7/cmake-3.7.1-Linux-x86_64.tar.gz"
CMAKE_SHA256=7b4b7a1d9f314f45722899c0521c261e4bfab4a6b532609e37fef391da6bade2
elif [ -z "$CMAKE_URL" ]; then
echo "Missing env CMAKE_URL"
exit 1
elif [ -z "$CMAKE_SHA256" ]; then
echo "Missing env CMAKE_SHA256"
exit 1
fi
( set -x
wget -O cmake.tar.gz "${CMAKE_URL}"
echo "${CMAKE_SHA256} cmake.tar.gz" > cmake-SHA256.txt
sha256sum --check cmake-SHA256.txt || {
echo 'Checksum error'
exit 1
}
mkdir cmake-dist
cd cmake-dist
tar xzf "../cmake.tar.gz" --strip-components=1
)
PATH="$PWD/cmake-dist/bin:${PATH}"
echo "+PATH=${PATH}"
}
# =================================================================
# Install packages from distribution
# The following substitutions are done:
# - cmake is replaced by downloaded, if CMAKE_URL is set
# - rpm-build is ignored on DEB distributions
# - ca-certificates is ignored on RPM distributions
install_packages() {
local packages
packages="$@"
do_install_cmake=no
if [ -n "$CMAKE_URL" ] && echo " $packages " | grep -qF " cmake "; then
packages="$(echo " $packages " | sed "s/ cmake / wget ca-certificates /")"
do_install_cmake=yes
fi
packages="$(echo " $packages " | sed -e "s/ c-compiler / $CC /" -e "s/ c++-compiler / $CXX /")"
if [ "$CPACK_GENERATOR" = "DEB" ]; then
packages="$(echo "$packages" | sed -e "s/ rpm-build / /" -e "s/ clang++ / clang /")"
( set -x;
$as_root apt-get update
$as_root apt-get install -y $packages
)
elif [ "$CPACK_GENERATOR" = "RPM" ]; then
packages="$(echo "$packages" | sed -e "s/ ca-certificates / /" -e "s/ g++ / gcc-c++ /" -e "s/ clang++ / clang /")"
( set -x;
$as_root yum install -y $packages
)
else
echo "Unhandled CPACK_GENERATOR: $CPACK_GENERATOR" >&2
exit 1
fi
if [ "$do_install_cmake" = "yes" ]; then
install_cmake
fi
}
# =================================================================
# Install all packages from directory
install_packages_from_dir() {
local dir
dir="$1"
if [ ! -d "$dir" ]; then
echo "Not a directory: $dir"
exit 1
fi
if [ "$CPACK_GENERATOR" = "DEB" ]; then
(set -x; $as_root dpkg -i "$dir"/*.deb)
elif [ "$CPACK_GENERATOR" = "RPM" ]; then
(set -x; $as_root rpm -i "$dir"/*.rpm)
else
echo "Unhandled CPACK_GENERATOR: $CPACK_GENERATOR" >&2
exit 1
fi
}
# =================================================================
# Build
build() {
( set -x
rm -rf ./release
# From README.md:
mkdir release
cd release
cmake -DCMAKE_BUILD_TYPE=release ..
make
ctest -V
cpack -G "${CPACK_GENERATOR}"
)
}
# =================================================================
# Main
main() {
if [ -n "$DOCKER_IMAGE" ]; then
docker_run "$0" build
else
setup_env
install_packages c-compiler cmake make rpm-build
if [ "$(basename "$PWD")" != "lua_sandbox" ]; then
local old_dir
local lsb_dir
old_dir="$PWD"
lsb_dir="$(dirname "$old_dir")/lua_sandbox"
echo "+cd $lsb_dir"
cd "$lsb_dir"
build
install_packages_from_dir ./release
echo "+cd $old_dir"
cd "$old_dir"
fi
if [ -n "$build_function" ]; then
"$build_function"
else
build
fi
fi
}
================================================
FILE: build/run.sh
================================================
#!/bin/sh
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# Author: Mathieu Parent <math.parent@gmail.com>
set -e
. "$(dirname $0)/functions.sh"
if [ "$1" != "build" -o $# -ge 2 ]; then
usage
exit 1
fi
build_function=
main
================================================
FILE: cmake/doxygen.cmake
================================================
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
find_package(Doxygen QUIET)
find_program(LUA_EXE lua QUIET)
find_program(PANDOC_EXE pandoc QUIET)
find_program(gitbook gitbook QUIET)
if(DOXYGEN_FOUND AND LUA_EXE AND PANDOC_EXE)
set(DOXYCONF_IN ${CMAKE_SOURCE_DIR}/doxygen.in.conf)
set(DOXYCONF_OUT ${CMAKE_BINARY_DIR}/doxygen.conf)
if(EXISTS ${DOXYCONF_IN})
configure_file(${DOXYCONF_IN} ${DOXYCONF_OUT})
else()
file(WRITE ${DOXYCONF_OUT} "
PROJECT_NAME = \"${PROJECT_NAME}\"
PROJECT_BRIEF = \"${CPACK_PACKAGE_DESCRIPTION_SUMMARY}\"
OUTPUT_DIRECTORY = \"${CMAKE_SOURCE_DIR}/gh-pages\"
HTML_OUTPUT = doxygen
GENERATE_LATEX = NO
GENERATE_TODOLIST = YES
FULL_PATH_NAMES = YES
STRIP_FROM_PATH = \"${CMAKE_SOURCE_DIR}\"
SOURCE_BROWSER = YES
TAB_SIZE = 4
EXTRACT_ALL = YES
JAVADOC_AUTOBRIEF = YES
RECURSIVE = YES
INPUT = \"${CMAKE_SOURCE_DIR}/include\" \"${CMAKE_SOURCE_DIR}/README.md\"
USE_MDFILE_AS_MAINPAGE = \"${CMAKE_SOURCE_DIR}/README.md\"
EXAMPLE_PATH = ${EXAMPLE_PATHS}
IMAGE_PATH = ${IMAGE_PATHS}
BUILTIN_STL_SUPPORT = YES
STRIP_CODE_COMMENTS = NO
SHOW_DIRECTORIES = YES
PROJECT_NUMBER = ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
endif()
add_custom_target(docs ${DOXYGEN_EXECUTABLE} ${DOXYCONF_OUT}
COMMAND lua gen_gh_pages.lua "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}"
"${CMAKE_SOURCE_DIR}" "${CMAKE_BINARY_DIR}" WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
else()
message("The optional documentation tools were not found; the doc target has not been created")
endif()
================================================
FILE: cmake/luasandboxConfig.cmake.in
================================================
set(LUASANDBOX_VERSION x.y.z)
@PACKAGE_INIT@
set_and_check(LUASANDBOX_INCLUDE_DIR "@PACKAGE_CMAKE_INSTALL_INCLUDEDIR@")
set_and_check(LUASANDBOX_LIB_DIR "@PACKAGE_CMAKE_INSTALL_LIBDIR@")
FIND_LIBRARY(LUASANDBOX_UTIL_LIBRARY NAMES luasandboxutil PATHS ${LUASANDBOX_LIB_DIR})
FIND_LIBRARY(LUASANDBOX_LIBRARY NAMES luasandbox PATHS ${LUASANDBOX_LIB_DIR})
FIND_LIBRARY(LUASANDBOX_HEKA_LIBRARY NAMES luasandboxheka PATHS ${LUASANDBOX_LIB_DIR})
FIND_LIBRARY(LUASANDBOX_TEST_LIBRARY NAMES luasandboxtest PATHS ${LUASANDBOX_LIB_DIR})
set(LUASANDBOX_LIBRARIES ${LUASANDBOX_HEKA_LIBRARY} ${LUASANDBOX_LIBRARY} ${LUASANDBOX_UTIL_LIBRARY})
================================================
FILE: cmake/mozsvc.cmake
================================================
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
if(MSVC)
# Predefined Macros: http://msdn.microsoft.com/en-us/library/b0084kay.aspx
# Compiler options: http://msdn.microsoft.com/en-us/library/fwkeyyhe.aspx
# set a high warning level and treat them as errors
set(CMAKE_C_FLAGS "/W3 /WX")
# enable C++ exception handling
set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} /EHs")
# debug multi threaded dll runtime, complete debugging info, runtime error checking
set(CMAKE_C_FLAGS_DEBUG "/MDd /Zi /RTC1")
set(CMAKE_CXX_FLAGS_DEBUG ${CMAKE_C_FLAGS_DEBUG})
# multi threaded dll runtime, optimize for speed, auto inlining
set(CMAKE_C_FLAGS_RELEASE "/MD /O2 /Ob2 /DNDEBUG")
set(CMAKE_CXX_FLAGS_RELEASE ${CMAKE_C_FLAGS_RELEASE})
set(CPACK_GENERATOR "ZIP")
else()
# Predefined Macros: clang|gcc -dM -E -x c /dev/null
# Compiler options: http://gcc.gnu.org/onlinedocs/gcc/Invoking-GCC.html#Invoking-GCC
set(CMAKE_C_FLAGS "-std=gnu11 -pedantic $ENV{CFLAGS} $ENV{CPPFLAGS} -Wall -Wextra -fPIC -fvisibility=hidden")
set(CMAKE_CXX_FLAGS "-std=c++11 -pedantic $ENV{CXXFLAGS} $ENV{CPPFLAGS} -Wall -Wextra -fPIC -isystem /usr/local/include -isystem /opt/local/include")
set(CMAKE_C_FLAGS_DEBUG "-g")
set(CMAKE_CXX_FLAGS_DEBUG ${CMAKE_C_FLAGS_DEBUG})
set(CMAKE_C_FLAGS_RELEASE "-O2 -DNDEBUG")
set(CMAKE_CXX_FLAGS_RELEASE ${CMAKE_C_FLAGS_RELEASE})
set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS_RELEASE} -g -pg")
set(CMAKE_CXX_FLAGS_PROFILE ${CMAKE_C_FLAGS_PROFILE})
set(CPACK_GENERATOR "TGZ")
set(CMAKE_SKIP_BUILD_RPATH FALSE)
set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH FALSE)
endif()
set(CPACK_PACKAGE_VENDOR "Mozilla Services")
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/LICENSE.txt")
if(CMAKE_BUILD_TYPE MATCHES "^[Dd][Ee][Bb][Uu][Gg]$")
set(CPACK_STRIP_FILES FALSE)
else()
set(CPACK_STRIP_FILES TRUE)
endif()
include(CPack)
include(CTest)
include(doxygen)
================================================
FILE: covfn.txt
================================================
Function Source Line FnCov C/D Coverage
------------------------------------------------------------------------------------------------ -------------------------------- ----- ---------------------
add_table_ref(table_ref_array*,const void*,size_t) .../luasandbox_serialize.c 171 1 / 1 1 / 4 = 25%
lsb_create(void*,const char*,const char*,lsb_logger*) ../src/luasandbox.c 428 1 / 1 16 / 42 = 38%
restore_global_data(lsb_lua_sandbox*) .../luasandbox_serialize.c 488 1 / 1 7 / 18 = 38%
lsb_heka_create_input(void*,const char*,const char*,const char*,lsb_logger*,lsb_heka_im_input) ../src/heka/sandbox.c 407 1 / 1 14 / 34 = 41%
lsb_heka_create_analysis(void*,const char*,cons...,const char*,lsb_logger*,lsb_heka_im_analysis) ../src/heka/sandbox.c 598 1 / 1 14 / 34 = 41%
lsb_heka_create_output(void*,const char*,const ... char*,lsb_logger*,lsb_heka_update_checkpoint) ../src/heka/sandbox.c 689 1 / 1 14 / 34 = 41%
serialize_data(lsb_lua_sandbox*,int,lsb_output_buffer*) .../luasandbox_serialize.c 230 1 / 1 9 / 20 = 45%
heka_create_stream_reader(lua_State*) ...rc/heka/stream_reader.c 174 1 / 1 5 / 10 = 50%
lsb_get_output(lsb_lua_sandbox*,size_t*) ../src/luasandbox_output.c 110 1 / 1 2 / 4 = 50%
instruction_manager(lua_State*,lua_Debug*) ../src/luasandbox.c 119 1 / 1 1 / 2 = 50%
read_config(lua_State*) ../src/luasandbox.c 201 1 / 1 1 / 2 = 50%
set_random_seed() ../src/luasandbox.c 400 1 / 1 7 / 12 = 58%
lsb_read_file(const char*) ../src/util/util.c 49 1 / 1 6 / 10 = 60%
heka_encode_message_table(lsb_lua_sandbox*,int) ../src/heka/message.c 874 1 / 1 16 / 26 = 61%
min_expand(MatchState*,const char*,const char*,const char*) ...c/util/string_matcher.c 171 1 / 1 5 / 8 = 62%
encode_field_value(lsb_lua_sandbox*,lsb_output_buffer*,int,const char*,int) ../src/heka/message.c 399 1 / 1 70 / 110 = 63%
preserve_global_data(lsb_lua_sandbox*) .../luasandbox_serialize.c 368 1 / 1 27 / 42 = 64%
lsb_init_heka_message(lsb_heka_message*,int) ../src/util/heka_message.c 429 1 / 1 4 / 6 = 66%
process_fields(lua_State*,const char*,const char*) ../src/heka/message.c 89 1 / 1 55 / 82 = 67%
encode_field_array(lsb_lua_sandbox*,lsb_output_buffer*,int,const char*,int) ../src/heka/message.c 326 1 / 1 19 / 28 = 67%
lsb_heka_pm_input(lsb_heka_sandbox*,double,const char*,_Bool) ../src/heka/sandbox.c 564 1 / 1 11 / 16 = 68%
set_restrictions(lua_State*,lsb_heka_sandbox*) ../src/heka/sandbox.c 308 1 / 1 20 / 29 = 68%
read_string(lua_State*,int,const char*,const char*) ../src/heka/message.c 48 1 / 1 7 / 10 = 70%
lsb_init(lsb_lua_sandbox*,const char*) ../src/luasandbox.c 528 1 / 1 27 / 38 = 71%
check_int(lua_State*,int,const char*,int) ../src/luasandbox.c 254 1 / 1 5 / 7 = 71%
lsb_outputfd(lsb_output_buffer*,double) ...rc/util/output_buffer.c 177 1 / 1 29 / 40 = 72%
encode_fields(lsb_lua_sandbox*,lsb_output_buffer*,char,const char*,int) ../src/heka/message.c 614 1 / 1 27 / 36 = 75%
serialize_kvp(lsb_lua_sandbox*,serialization_data*,size_t) .../luasandbox_serialize.c 288 1 / 1 18 / 24 = 75%
decode_header(char*,size_t,size_t) ../src/util/heka_message.c 25 1 / 1 12 / 16 = 75%
read_message(lua_State*) ../src/heka/sandbox.c 41 1 / 1 6 / 8 = 75%
mm_eval(lua_State*) ../src/heka/sandbox.c 74 1 / 1 6 / 8 = 75%
hsr_decode_message(lua_State*) ...rc/heka/stream_reader.c 27 1 / 1 6 / 8 = 75%
process_varint(lua_State*,const char*,int,int,const char*,const char*) ../src/heka/message.c 68 1 / 1 3 / 4 = 75%
encode_int(lsb_lua_sandbox*,lsb_output_buffer*,char,const char*,int) ../src/heka/message.c 283 1 / 1 3 / 4 = 75%
output(lua_State*) ../src/luasandbox.c 127 1 / 1 3 / 4 = 75%
lsb_stop_sandbox(lsb_lua_sandbox*) ../src/luasandbox.c 621 1 / 1 3 / 4 = 75%
lsb_clear_heka_message(lsb_heka_message*) ../src/util/heka_message.c 443 1 / 1 3 / 4 = 75%
lsb_outputc(lsb_output_buffer*,char) ...rc/util/output_buffer.c 78 1 / 1 3 / 4 = 75%
lsb_outputs(lsb_output_buffer*,const char*,size_t) ...rc/util/output_buffer.c 146 1 / 1 3 / 4 = 75%
lsb_set_tz(const char*) ../src/util/util.c 143 1 / 1 3 / 4 = 75%
lsb_decode_heka_message(lsb_heka_message*,const char*,size_t,lsb_logger*) ../src/util/heka_message.c 207 1 / 1 59 / 77 = 76%
process_message(lsb_heka_sandbox*,lsb_heka_message*,lua_State*,int,_Bool) ../src/heka/sandbox.c 478 1 / 1 33 / 43 = 76%
lsb_pcall_setup(lsb_lua_sandbox*,const char*) ../src/luasandbox.c 721 1 / 1 14 / 18 = 77%
read_string(int,const char*,const char*,lsb_const_string*) ../src/util/heka_message.c 45 1 / 1 8 / 10 = 80%
read_string_value(const char*,const char*,int,lsb_read_value*) ../src/util/heka_message.c 63 1 / 1 8 / 10 = 80%
read_integer_value(const char*,const char*,int,lsb_read_value*) ../src/util/heka_message.c 84 1 / 1 8 / 10 = 80%
check_string(lua_State*,int,const char*,const char*) ../src/luasandbox.c 232 1 / 1 4 / 5 = 80%
matchbalance(MatchState*,const char*,const char*) ...c/util/string_matcher.c 137 1 / 1 13 / 16 = 81%
lsb_outputf(lsb_output_buffer*,const char*,...) ...rc/util/output_buffer.c 92 1 / 1 23 / 28 = 82%
heka_read_message(lua_State*,lsb_heka_message*) ../src/heka/message.c 925 1 / 1 48 / 58 = 82%
heka_decode_message(lua_State*) ../src/heka/message.c 689 1 / 1 54 / 65 = 83%
hsr_find_message(lua_State*) ...rc/heka/stream_reader.c 56 1 / 1 25 / 30 = 83%
lsb_heka_timer_event(lsb_heka_sandbox*,time_t,_Bool) ../src/heka/sandbox.c 811 1 / 1 15 / 18 = 83%
set_missing_headers(lua_State*,int,lsb_heka_sandbox*) ../src/heka/message.c 28 1 / 1 10 / 12 = 83%
lsb_heka_pm_analysis(lsb_heka_sandbox*,lsb_heka_message*,_Bool) ../src/heka/sandbox.c 670 1 / 1 10 / 12 = 83%
ignore_value_type(lsb_lua_sandbox*,serialization_data*,int,lua_CFunction*) .../luasandbox_serialize.c 115 1 / 1 10 / 12 = 83%
inject_message_analysis(lua_State*) ../src/heka/sandbox.c 191 1 / 1 5 / 6 = 83%
lsb_destroy(lsb_lua_sandbox*) ../src/luasandbox.c 634 1 / 1 5 / 6 = 83%
lsb_pb_output_varint(char*,unsigned long long) ../src/util/protobuf.c 56 1 / 1 5 / 6 = 83%
lsb_output(lsb_lua_sandbox*,int,int,int) ../src/luasandbox_output.c 42 1 / 1 27 / 32 = 84%
heka_encode_message(lua_State*) ../src/heka/message.c 816 1 / 1 11 / 13 = 84%
match_class(int,int) ...c/util/string_matcher.c 68 1 / 1 11 / 13 = 84%
match(MatchState*,const char*,const char*) ...c/util/string_matcher.c 183 1 / 1 39 / 46 = 84%
inject_message_input(lua_State*) ../src/heka/sandbox.c 112 1 / 1 18 / 21 = 85%
lsb_heka_pm_output(lsb_heka_sandbox*,lsb_heka_message*,void*,_Bool) ../src/heka/sandbox.c 785 1 / 1 12 / 14 = 85%
lsb_expand_input_buffer(lsb_input_buffer*,size_t) ../src/util/input_buffer.c 49 1 / 1 12 / 14 = 85%
numeric_test(match_node*,double) .../heka_message_matcher.c 67 1 / 1 6 / 7 = 85%
lsb_find_heka_message(lsb_heka_message*,lsb_input_buffer*,_Bool,size_t*,lsb_logger*) ../src/util/heka_message.c 331 1 / 1 31 / 36 = 86%
output_print(lua_State*) ../src/luasandbox.c 143 1 / 1 19 / 22 = 86%
load_sandbox_config(const char*,lsb_logger*) ../src/luasandbox.c 285 1 / 1 19 / 22 = 86%
matchbracketclass(int,const char*,const char*) ...c/util/string_matcher.c 99 1 / 1 19 / 22 = 86%
update_checkpoint(lua_State*) ../src/heka/sandbox.c 275 1 / 1 7 / 8 = 87%
lsb_init_input_buffer(lsb_input_buffer*,size_t) ../src/util/input_buffer.c 20 1 / 1 7 / 8 = 87%
lsb_outputd(lsb_output_buffer*,double) ...rc/util/output_buffer.c 160 1 / 1 7 / 8 = 87%
process_fields(lsb_heka_field*,const char*,const char*) ../src/util/heka_message.c 127 1 / 1 50 / 57 = 87%
copy_table(lua_State*,lua_State*,lsb_logger*) ../src/luasandbox.c 327 1 / 1 22 / 25 = 88%
lsb_expand_output_buffer(lsb_output_buffer*,size_t) ...rc/util/output_buffer.c 52 1 / 1 16 / 18 = 88%
inject_payload(lua_State*) ../src/heka/sandbox.c 216 1 / 1 18 / 20 = 90%
lsb_add_function(lsb_lua_sandbox*,lua_CFunction,const char*) ../src/luasandbox.c 710 1 / 1 9 / 10 = 90%
lsb_init_output_buffer(lsb_output_buffer*,size_t) ...rc/util/output_buffer.c 27 1 / 1 9 / 10 = 90%
eval_node(match_node*,lsb_heka_message*) .../heka_message_matcher.c 89 1 / 1 31 / 34 = 91%
eval_tree(match_node*,match_node*,lsb_heka_message*) .../heka_message_matcher.c 151 1 / 1 22 / 24 = 91%
memory_manager(void*,void*,size_t,size_t) ../src/luasandbox.c 83 1 / 1 11 / 12 = 91%
lsb_read_heka_field(const lsb_heka_message*,lsb_const_string*,int,int,lsb_read_value*) ../src/util/heka_message.c 474 1 / 1 24 / 26 = 92%
classend(const char*) ...c/util/string_matcher.c 43 1 / 1 16 / 17 = 94%
string_test(match_node*,lsb_const_string*) .../heka_message_matcher.c 21 1 / 1 18 / 19 = 94%
encode_string(lsb_lua_sandbox*,lsb_output_buffer*,char,const char*,int) ../src/heka/message.c 254 1 / 1 2 / 2 = 100%
encode_field_object(lsb_lua_sandbox*,lsb_output_buffer*) ../src/heka/message.c 377 1 / 1 4 / 4 = 100%
mm_check(lua_State*) ../src/heka/sandbox.c 58 1 / 1 0 / 0
mm_gc(lua_State*) ../src/heka/sandbox.c 66 1 / 1 0 / 0
mm_create(lua_State*) ../src/heka/sandbox.c 91 1 / 1 4 / 4 = 100%
lsb_heka_stop_sandbox(lsb_heka_sandbox*) ../src/heka/sandbox.c 761 1 / 1 0 / 0
lsb_heka_terminate_sandbox(lsb_heka_sandbox*,const char*) ../src/heka/sandbox.c 767 1 / 1 0 / 0
lsb_heka_destroy_sandbox(lsb_heka_sandbox*) ../src/heka/sandbox.c 773 1 / 1 2 / 2 = 100%
lsb_heka_get_error(lsb_heka_sandbox*) ../src/heka/sandbox.c 853 1 / 1 2 / 2 = 100%
lsb_heka_get_lua_file(lsb_heka_sandbox*) ../src/heka/sandbox.c 859 1 / 1 2 / 2 = 100%
lsb_heka_get_stats(lsb_heka_sandbox*) ../src/heka/sandbox.c 865 1 / 1 2 / 2 = 100%
lsb_heka_is_running(lsb_heka_sandbox*) ../src/heka/sandbox.c 886 1 / 1 4 / 4 = 100%
lsb_heka_get_message(lsb_heka_sandbox*) ../src/heka/sandbox.c 894 1 / 1 2 / 2 = 100%
lsb_heka_get_type(lsb_heka_sandbox*) ../src/heka/sandbox.c 901 1 / 1 2 / 2 = 100%
check_hsr(lua_State*,int) ...rc/heka/stream_reader.c 18 1 / 1 0 / 0
hsr_read_message(lua_State*) ...rc/heka/stream_reader.c 142 1 / 1 6 / 6 = 100%
hsr_gc(lua_State*) ...rc/heka/stream_reader.c 154 1 / 1 0 / 0
libsize(const luaL_Reg*) ../src/luasandbox.c 50 1 / 1 2 / 2 = 100%
preload_modules(lua_State*) ../src/luasandbox.c 57 1 / 1 2 / 2 = 100%
instruction_usage(lsb_lua_sandbox*) ../src/luasandbox.c 113 1 / 1 0 / 0
unprotected_panic(lua_State*) ../src/luasandbox.c 215 1 / 1 0 / 0
get_int(lua_State*,int,const char*) ../src/luasandbox.c 223 1 / 1 0 / 0
stop_hook(lua_State*,lua_Debug*) ../src/luasandbox.c 613 1 / 1 0 / 0
lsb_usage(lsb_lua_sandbox*,lsb_usage_type,lsb_usage_stat) ../src/luasandbox.c 657 1 / 1 10 / 10 = 100%
lsb_get_error(lsb_lua_sandbox*) ../src/luasandbox.c 667 1 / 1 2 / 2 = 100%
lsb_set_error(lsb_lua_sandbox*,const char*) ../src/luasandbox.c 673 1 / 1 4 / 4 = 100%
lsb_get_lua(lsb_lua_sandbox*) ../src/luasandbox.c 686 1 / 1 2 / 2 = 100%
lsb_get_lua_file(lsb_lua_sandbox*) ../src/luasandbox.c 692 1 / 1 2 / 2 = 100%
lsb_get_parent(lsb_lua_sandbox*) ../src/luasandbox.c 698 1 / 1 2 / 2 = 100%
lsb_get_state(lsb_lua_sandbox*) ../src/luasandbox.c 704 1 / 1 2 / 2 = 100%
lsb_pcall_teardown(lsb_lua_sandbox*) ../src/luasandbox.c 745 1 / 1 4 / 4 = 100%
lsb_terminate(lsb_lua_sandbox*,const char*) ../src/luasandbox.c 759 1 / 1 6 / 6 = 100%
lsb_add_output_function(lua_State*,lua_CFunction) ../src/luasandbox_output.c 22 1 / 1 0 / 0
lsb_get_output_function(lua_State*,int) ../src/luasandbox_output.c 30 1 / 1 0 / 0
get_serialize_function(lua_State*,int) .../luasandbox_serialize.c 93 1 / 1 0 / 0
find_table_ref(table_ref_array*,const void*) .../luasandbox_serialize.c 150 1 / 1 4 / 4 = 100%
get_preservation_version(lua_State*) .../luasandbox_serialize.c 196 1 / 1 4 / 4 = 100%
serialize_table(lsb_lua_sandbox*,serialization_data*,size_t) .../luasandbox_serialize.c 215 1 / 1 6 / 6 = 100%
file_exists(const char*) .../luasandbox_serialize.c 477 1 / 1 2 / 2 = 100%
lsb_add_serialize_function(lua_State*,lua_CFunction) .../luasandbox_serialize.c 523 1 / 1 0 / 0
lsb_serialize_binary(lsb_output_buffer*,const void*,size_t) .../luasandbox_serialize.c 531 1 / 1 11 / 11 = 100%
lsb_serialize_double(lsb_output_buffer*,double) .../luasandbox_serialize.c 558 1 / 1 6 / 6 = 100%
read_double_value(const char*,const char*,int,lsb_read_value*) ../src/util/heka_message.c 103 1 / 1 2 / 2 = 100%
process_varint(int,const char*,const char*,long long*) ../src/util/heka_message.c 116 1 / 1 4 / 4 = 100%
lsb_free_heka_message(lsb_heka_message*) ../src/util/heka_message.c 463 1 / 1 2 / 2 = 100%
lsb_write_heka_uuid(lsb_output_buffer*,const char*,size_t) ../src/util/heka_message.c 519 1 / 1 22 / 22 = 100%
lsb_destroy_message_matcher(lsb_message_matcher*) .../heka_message_matcher.c 175 1 / 1 6 / 6 = 100%
lsb_eval_message_matcher(lsb_message_matcher*,lsb_heka_message*) .../heka_message_matcher.c 195 1 / 1 0 / 0
lsb_free_input_buffer(lsb_input_buffer*) ../src/util/input_buffer.c 36 1 / 1 2 / 2 = 100%
lsb_free_output_buffer(lsb_output_buffer*) ...rc/util/output_buffer.c 42 1 / 1 2 / 2 = 100%
lsb_pb_read_key(const char*,int*,int*) ../src/util/protobuf.c 15 1 / 1 8 / 8 = 100%
lsb_pb_write_key(lsb_output_buffer*,unsigned char,unsigned char) ../src/util/protobuf.c 25 1 / 1 2 / 2 = 100%
lsb_pb_read_varint(const char*,const char*,long long*) ../src/util/protobuf.c 36 1 / 1 22 / 22 = 100%
lsb_pb_write_varint(lsb_output_buffer*,unsigned long long) ../src/util/protobuf.c 75 1 / 1 2 / 2 = 100%
lsb_pb_write_bool(lsb_output_buffer*,int) ../src/util/protobuf.c 85 1 / 1 4 / 4 = 100%
lsb_pb_write_double(lsb_output_buffer*,double) ../src/util/protobuf.c 99 1 / 1 2 / 2 = 100%
lsb_pb_write_string(lsb_output_buffer*,char,const char*,size_t) ../src/util/protobuf.c 114 1 / 1 6 / 6 = 100%
lsb_pb_update_field_length(lsb_output_buffer*,size_t) ../src/util/protobuf.c 127 1 / 1 8 / 8 = 100%
lsb_init_running_stats(lsb_running_stats*) ...rc/util/running_stats.c 13 1 / 1 0 / 0
lsb_update_running_stats(lsb_running_stats*,double) ...rc/util/running_stats.c 21 1 / 1 4 / 4 = 100%
lsb_sd_running_stats(lsb_running_stats*) ...rc/util/running_stats.c 37 1 / 1 2 / 2 = 100%
lsb_init_const_string(lsb_const_string*) ../src/util/string.c 11 1 / 1 0 / 0
singlematch(int,const char*,const char*) ...c/util/string_matcher.c 119 1 / 1 4 / 4 = 100%
max_expand(MatchState*,const char*,const char*,const char*) ...c/util/string_matcher.c 156 1 / 1 10 / 10 = 100%
lsb_string_match(const char*,size_t,const char*) ...c/util/string_matcher.c 261 1 / 1 10 / 10 = 100%
lsb_lp2(unsigned long long) ../src/util/util.c 35 1 / 1 2 / 2 = 100%
lsb_get_time() ../src/util/util.c 75 1 / 1 0 / 0
lsb_get_timestamp() ../src/util/util.c 114 1 / 1 0 / 0
------------------------------------------------------------------------------------------------ -------------------------------- ----- ---------------------
Total 100% 1568 / 2029 = 77%
================================================
FILE: docs/cli/index.md
================================================
# Command Line Interface Tools
## lsb_heka_cat
A command-line utility for counting, viewing, filtering, and extracting messages
from a Heka protobuf log/stream.
```
usage: lsb_heka_cat [-t|-c|-h] [-m message_matcher] [-f] [-n #] <FILE>
description:
-t output the messages in text format (default)
-c only output the message count
-h output the messages as a Heka protobuf stream
-f output appended data as the file grows
-n output the last # of messages (simple header check so not 100% accurate)
-m message_matcher expression (default "TRUE")
FILE name of the file to cat or '-' for stdin
notes:
All output is written to stdout and all log/error messages are written to stderr.
```
See the [message matcher](/util/message_matcher.md) documentation for more
details about the message_matcher expression.
================================================
FILE: docs/heka/analysis.md
================================================
# Analysis Sandbox Interface
## Recommendations
Since the sandbox does not run in isolation there are some expectations of how
the host infrastructure behaves. The current recommendations are based on the
Hindsight reference implementation.
## Disabled Functionality
- [base library](http://www.lua.org/manual/5.1/manual.html#5.1)
- collectgarbage, dofile, load, loadfile, loadstring, newproxy
- [coroutine](http://www.lua.org/manual/5.1/manual.html#5.2)
- the entire module is inaccessible
- [string](http://www.lua.org/manual/5.1/manual.html#5.4)
- dump
- [io](http://www.lua.org/manual/5.1/manual.html#5.7)
- the entire module is inaccessible
- [os](http://www.lua.org/manual/5.1/manual.html#5.8)
- getenv, execute, exit, remove, rename, setlocale, tmpname
## Required Lua Functions (called by the host)
### process_message
Called when the host has a message available for analysis. Usually used in
combination with a [message matcher](/util/message_matcher.md) expression.
Recommenation: specify this as a `message_matcher` configuration option.
*Arguments*
* none
*Return*
* status_code (number)
* success (less than or equal to zero)
* fatal error (greater than zero)
* status_message (optional: string) logged when the status code is less than
zero
### timer_event
Called when the host timer expires or on shutdown.
Recommendation: specify this as a `ticker_interval` configuration option.
*Arguments*
* ns (number) - nanosecond timestamp of the function call (it is actually
`time_t * 1e9` to keep the timestamp units consistent so it will only have a
one second resolution)
* shutdown (bool) - true if timer_event is being called due to a shutdown
*Return*
* none
## Available C Functions (called from the plugin)
### read_config
Provides access to the sandbox configuration variables.
*Arguments*
* key (string) - configuration key name
*Return*
* value (string, number, bool, table)
### read_message
Provides access to the Heka message data. Note that both fieldIndex and
arrayIndex are zero-based (i.e. the first element is 0) as opposed to Lua's
standard indexing, which is one-based.
*Arguments*
* variableName (string)
* framed (returns the Heka message protobuf string including the framing
header)
* raw (returns the Heka message protobuf string)
* size (returns the size of the raw Heka message protobuf string)
* Uuid
* Type
* Logger
* Payload
* EnvVersion
* Hostname
* Timestamp
* Severity
* Pid
* Fields[*name*]
* fieldIndex (unsigned) - only used in combination with the Fields variableName
use to retrieve a specific instance of a repeated field *name*; zero indexed
* arrayIndex (unsigned) - only used in combination with the Fields variableName
use to retrieve a specific element out of a field containing an array; zero
indexed
* zeroCopy (bool, optional default false) - returns a userdata place holder for
the message variable (only valid for string types). Non string headers throw an
error during construction, non string fields throw an error on data retrieval.
*Return*
* value (number, string, bool, nil, userdata depending on the type of variable
requested)
### decode_message
Converts a Heka protobuf encoded message string into a Lua table or throws an
error.
*Arguments*
* heka_pb (string, userdata) - Heka protobuf binary string or a zero copy
userdata object containing a Heka protobuf binary string.
*Return*
* msg ([Heka message table (array fields)](message.md#array-based-message-fields))
with the value member always being an array (even if there is only a
single item). This format makes working with the output more consistent. The
wide variation in the inject table formats is to ease the construction of the
message especially when using an LPeg grammar transformation.
### inject_message
Creates a new Heka protocol buffer message using the contents of the specified
Lua table (overwriting whatever is in the payload buffer). `Timestamp`,
`Logger`, `Hostname` and `Pid` are restricted header values. An override
configuration option is provided `restricted_headers`; when true (default) the
headers are always set to the configuration values; when false the headers are
set to the values provided in the message table, if no value is provided it
defaults to the appropriate value.
*Arguments*
* msg ([Heka message table](message.md))
*Return*
* none (throws an error if the table does not match the Heka message schema)
### add_to_payload
Appends the arguments to the payload buffer for incremental construction of the
final payload output (`inject_payload` finalizes the buffer and sends the
message to the infrastructure). This function is a rename of the generic sandbox
output function to improve the readability of the plugin code.
*Arguments*
* arg (number, string, bool, nil, supported userdata)
*Return*
* none (throws an error if arg is an unsupported type)
### inject_payload
This is a wrapper function for `inject_message` that is included for backwards
compatibility. The function creates a new Heka message using the contents of the
payload buffer (pre-populated with `add_to_payload`) and combined with any
additional payload_args passed here. The payload buffer is cleared after the
injection. The `payload_type` and `payload_name` arguments are two pieces of
optional metadata stored is message fields. The resulting message is structured
like this:
```lua
msg = {
Timestamp = <current time>
Uuid = "<auto generated>"
Hostname = "<the Hostname from the config>"
Logger = "<the Logger name from the config>"
Type = "inject_payload"
Payload = "<payload buffer contents>"
Fields = {
payload_type = "txt",
payload_name = "",
}
```
*Arguments*
* payload_type (optional: string, default "txt") - describes the content type of
the injected payload data
* payload_name (optional: string, default "") - names the content to aid in
downstream filtering
* arg3 (optional) -ame type restrictions as `add_to_payload`
* ...
* argN
*Return*
* none (throws an error if arg is an unsupported type)
### Modes of Operation
#### Lock Step
* Receives one call to `process_message`, operates on the message, and returns
success (0) or failure (-1)
#### Example simple counter plugin
```lua
-- cfg
message_matcher = "TRUE"
ticker_interval = 5
```
```lua
-- This Source Code Form is subject to the terms of the Mozilla Public
-- License, v. 2.0. If a copy of the MPL was not distributed with this
-- file, You can obtain one at http://mozilla.org/MPL/2.0/.
local cnt = 0
function process_message()
cnt = cnt + 1
return 0
end
function timer_event()
inject_payload("txt", "count", cnt)
end
```
================================================
FILE: docs/heka/index.md
================================================
# Heka Sandbox Interface
## Overview
This document describes the 1.0 release of the Heka sandbox API built on the
[Generic Sandbox Interface](/sandbox.md). The 1.0 release is a refined
implementation of its predecessor which was developed in
[Heka](https://github.com/mozilla-services/heka). The goal is to decople it from
Go and make it easily embeddable in any language. The Go version of Heka has
been deprecated and replaced by
[Hindsight](https://github.com/mozilla-services/hindsight).
## Sandbox API Changes from the Go Heka Sandbox
There are a few intentional changes between tho original Heka sandbox and this
version.
### Changes
#### Input Sandbox
1. `inject_message` accepts a numeric or string checkpoint as the second
argument
1. `process_message` receives the checkpoint value as the first argument (if it
was provided by `inject_message`).
#### Output Sandbox
1. `process_message` receives a sequence_id as the first argument (if it was
provided by `update_checkpoint`). Extended return codes have been added to
support skipping, retrying, batching, and asynchronous output.
#### Analysis/Output Sandbox
1. `read_message`
* returns `nil` for optional header fields if they don't exist instead of an
empty string or zero
* added a `framed` parameter to retrive the raw message with stream framing
* added a `size` parameter to retrive size of the raw message without having
to copy it down
1. `timer_event` has a second parameter `shutdown` that is set to true when the
sandbox is exiting.
### Additions
#### Input Sandbox
1. [create_stream_reader](input.md#createstreamreader) function was added.
1. [is_running](input.md#is_running) function was added.
#### Output Sandbox
1. [update_checkpoint](output.md#update_checkpoint) was added for batch and
asynchronous processing.
1. [create_message_matcher](output.md#createmessagematcher) function was added.
### Removals
1. The `write_message` API was removed; messages are immutable and this API
broke that rule.
1. The `read_next_field` API was removed; instead the raw message should be
decoded and the Lua table iterated.
### Notes
1. The `read_config` API in unchanged but now has access to the entire sandbox configuration.
================================================
FILE: docs/heka/input.md
================================================
# Input Sandbox Interface
## Recommendations
Since the sandbox does not run in isolation there are some expectations of how
the host infrastructure behaves. The current recommendations are based on the
Hindsight reference implementation.
## Disabled Functionality
- [base library](http://www.lua.org/manual/5.1/manual.html#5.1)
- dofile, load, loadfile, loadstring, newproxy
- [string](http://www.lua.org/manual/5.1/manual.html#5.4)
- dump
- [os](http://www.lua.org/manual/5.1/manual.html#5.8)
- exit, setlocale
## Required Lua Functions (called by the host)
### process_message
Entry point for message creation.
*Arguments*
* checkpoint (nil number, string) - value of the last checkpoint value passed
into `inject_message`
*Return*
* status_code (number)
- success (less than or equal to zero)
- fatal error (greater than zero)
* status_message (optional: string) logged when the status code is less than
zero
## Available C Functions (called from the plugin)
### read_config
Provides access to the sandbox configuration variables.
*Arguments*
* key (string) - configuration key name
*Return*
* value (string, number, bool, table)
### is_running
Provides a synchronization point for collecting statistics and communicating
shutdown status.
*Arguments*
* none
*Return*
* running (boolean) - true if a sandbox state is LSB_RUNNING, false if not or
throws an error if the request to the host fails.
### decode_message
Converts a Heka protobuf encoded message string into a Lua table. See
[decode_message](analysis.md#decodemessage) for details.
### inject_message
Sends a Heka protocol buffer message into the host. For the Heka message table
arguments `Timestamp`, `Logger`, `Hostname` and `Pid` are restricted header
values. An override configuration option is provided `restricted_headers`; when
true the headers are always set to the configuration values; when false
(default) the headers are set to the values provide in the message table,
if no value is provided it defaults to the appropriate value.
*Arguments*
* msg ([Heka message table](message.md),
[Heka stream reader](#heka-stream-reader-methods),
Heka protobuf string,
or nil (if only updating the checkpoint))
* checkpoint (optional: number, string) - checkpoint to be returned in the
`process_message` call
*Return*
* none - throws an error on invalid input
### create_stream_reader
Creates a Heka stream reader to enable parsing of a framed Heka protobuf stream
in a Lua sandbox. See:
[Example of a Heka protobuf reader](#example-of-a-heka-protobuf-stdin-reader)
*Arguments*
* name (string) - name of the stream reader (used in the log)
*Return*
* hsr (userdata) - Heka stream reader or an error is thrown
#### Heka Stream Reader Methods
##### find_message
Locates a Heka message within the stream.
```lua
local found, consumed, need = hsr:find_message(buf)
```
*Arguments*
* buf (string, userdata (FILE*)) - buffer containing a Heka protobuf stream data
or a userdata file object
* decode (bool default: true) - true if the framed message should be protobuf
decoded
*Return*
* found (bool) - true if a message was found
* consumed (number) - number of bytes consumed so the offset can be tracked for
checkpointing purposes
* need/read (number) - number of bytes needed to complete the message or fill
the underlying buffer or in the case of a file object the number of bytes
added to the buffer
##### decode_message
Converts a Heka protobuf encoded message string into a stream reader
representation. Note: this operation clears the internal stream reader buffer.
*Arguments*
* heka_pb (string) - Heka protobuf binary string
*Return*
* none - throws an error on failure
##### read_message
Provides access to the Heka message data within the reader object. The zeroCopy
flag is not accepted here.
```lua
local ts = hsr:read_message("Timestamp")
```
See [read_message](analysis.md#readmessage) for details.
## Modes of Operation
### Run Once
* Set the `ticker_interval` to zero and return from `process_message` done.
* The `instruction_limit` configuration can be set if desired.
#### Example startup ping
```lua
-- cfg
-- send a simple 'hello' messages every time the host is started
ticker_interval = 0
```
```lua
-- This Source Code Form is subject to the terms of the Mozilla Public
-- License, v. 2.0. If a copy of the MPL was not distributed with this
-- file, You can obtain one at http://mozilla.org/MPL/2.0/.
-- the checkpoint is optional and not being used by this plugin
function process_message()
inject_message({Type = "hello"})
return 0
end
```
### Polling
* Set the `ticker_interval` greater than zero and non fatally (<=0) return from
`process_message`, when the ticker interval expires `process_message` will be
called again.
* The `instruction_limit` configuration can be set if desired.
#### Example heartbeat ping
```lua
-- cfg
ticker_interval = 60
```
```lua
-- This Source Code Form is subject to the terms of the Mozilla Public
-- License, v. 2.0. If a copy of the MPL was not distributed with this
-- file, You can obtain one at http://mozilla.org/MPL/2.0/.
require "io"
local msg = {
Type = "uptime",
Payload = "",
}
function process_message()
local fh = io.popen("uptime")
if fh then
msg.Payload = fh:read("*a")
fh:close()
else
return -1, "popen failed"
end
if msg.Payload then inject_message(msg) end
return 0
end
```
### Continuous
* Don't return from `process_message`.
* The `instruction_limit` configuration **MUST** be set to zero.
#### Example of a Heka protobuf stdin reader
```lua
-- This Source Code Form is subject to the terms of the Mozilla Public
-- License, v. 2.0. If a copy of the MPL was not distributed with this
-- file, You can obtain one at http://mozilla.org/MPL/2.0/.
--[[
Reads a Heka protobuf stream from the stdin file handle
-- .cfg
instruction_limit = 0
--]]
local stdin = require "io".stdin
require "string"
local hsr = create_stream_reader(read_config("Logger"))
function process_message()
local cnt = 0
local found, consumed, read
repeat
repeat
found, consumed, read = hsr:find_message(stdin)
if found then
inject_message(hsr)
cnt = cnt + 1
end
until not found
until read == 0
return 0, string.format("processed %d messages", cnt)
end
```
================================================
FILE: docs/heka/message.md
================================================
# Heka Message Table
## Hash Based Message Fields
```lua
{
Uuid = "data", -- restricted header, auto generated if not a 16 byte raw binary UUID or a 36 character human readable UUID
Logger = "nginx", -- restricted header, defaults to the Logger configuration value
Hostname = "example.com", -- restricted header, defaults to the Hostname configuration value
Timestamp = 1e9, -- restricted header, defaults to the current time
Type = "TEST",
Payload = "Test Payload",
EnvVersion = "0.8",
Pid = 1234, -- restricted header, defaults to the Pid configuration value
Severity = 6,
Fields = {
http_status = 200, -- encoded as a double
request_size = {value=1413, value_type=2, representation="B"} -- encoded as an integer
}
}
```
## Array Based Message Fields
```lua
{
-- Message headers are the same as above
Fields = {
{name="http_status" , value=200}, -- encoded as a double
{name="request_size", value=1413, value_type=2, representation="B"} -- encoded as an integer
}
}
```
================================================
FILE: docs/heka/output.md
================================================
# Output Sandbox Interface
## Recommendations
Since the sandbox does not run in isolation there are some expectations of how
the host infrastructure behaves. The current recommendations are based on the
Hindsight reference implementation.
## Disabled Functionality
- [base library](http://www.lua.org/manual/5.1/manual.html#5.1)
- dofile, load, loadfile, loadstring, newproxy
- [string](http://www.lua.org/manual/5.1/manual.html#5.4)
- dump
- [os](http://www.lua.org/manual/5.1/manual.html#5.8)
- exit, setlocale
## Required Lua Functions (called by the host)
### process_message
Called when the host has a message available for analysis. Usually used in
combination with a [message matcher](/util/message_matcher.md) expression.
Recommenation: specify this as a `message_matcher` configuration option.
*Arguments*
* sequence_id (optional: lightuserdata) - pass in when `async_buffer_size` is
configured
*Return*
* status_code (number) - see the [Modes of Operation](#modes-of-operation) for
a detail explanation of the return codes
* fatal error (greater than zero)
* success (0)
* non fatal failure (-1)
* skip (-2)
* retry (-3)
* batching (-4)
* async output (-5)
* status_message (optional: string) logged when the status code is -1
### timer_event
Called when the host timer expires or on shutdown.
Recommendation: specify this as a `ticker_interval` configuration option.
*Arguments*
* ns (number) - nanosecond timestamp of the function call (it is actually
`time_t * 1e9` to keep the timestamp units consistent so it will only have a
one second resolution)
* shutdown (bool) - true if timer_event is being called due to a shutdown
*Return*
* none
## Available C Functions (called from the plugin)
### read_config
Provides access to the sandbox configuration variables.
*Arguments*
* key (string) - configuration key name
*Return*
* value (string, number, bool, table)
### read_message
Provides access to the Heka message data. See
[read_message](analysis.md#readmessage) for details.
### decode_message
Converts a Heka protobuf encoded message string into a Lua table. See
[decode_message](analysis.md#decodemessage) for details.
### encode_message
Returns a Heka protocol buffer message using the contents of the specified Lua
table. `Timestamp`, `Logger`, `Hostname` and `Pid` are restricted header values.
An override configuration option is provided `restricted_headers`; when true the
headers are always set to the configuration values; when false (default) the
headers are set to the values provided in the message table, if no value is
provided it defaults to the appropriate configuration value.
Note: this operation uses the internal output buffer so it is goverened by the
`output_limit` configuration setting.
*Arguments*
* msg ([Heka message table](message.md))
* framed (bool default: false) A value of true includes the framing header
*Return*
* heka_pb (string) - Heka protobuf binary string, framed as specified
or an error is thrown
### inject_message
Creates a new Heka protocol buffer message, in the input queue, using the
contents of the specified Lua table. The `restricted_headers` configuration
defaults to false (see encode_message above for a full description).
*Arguments*
* msg ([Heka message table](message.md))
*Return*
* none (throws an error if the table does not match the Heka message schema)
### create_message_matcher
Returns a Heka protocol buffer message matcher; used to dynamically filter
messages sent to the output plugin.
*Arguments*
* message_matcher [message matcher](/util/message_matcher.md)
*Return*
* message_matcher (userdata) - or an error is thrown
The message matcher object has one method `eval` that returns true if the
current message matches, false if it does not.
#### Example
See: [heka_tcp_matcher.lua](https://mozilla-services.github.io/lua_sandbox_extensions/socket/sandboxes/heka/output/heka_tcp_matcher.html)
### update_checkpoint
#### Batch Mode
Advances the output checkpoint when in batching mode. The standard use case is
to call it from `timer_event` after successfully flushing a batch on
timeout/shutdown.
*Arguments*
* none
#### Asynchronous Mode
Advances the output checkpoint and optionally reports the number of failures
that occured.
*Arguments*
* sequence_id (lightuserdata) - sequence_id for the message that was just
successfully delivered/acknowledged
* failures (optional: integer) - number of failures that occured in the
asynchronus processing (added to the failure count)
*Return*
* none (throws an error on invalid arg types)
### Modes of Operation
#### Lock Step
* `process_message` operates on the message and returns one of the following
values:
* success (0) - the message was successfully processed and the output
checkpoint is advanced
* failure (-1) - the message was not successfully processed
* the failure count is incremented
* any optional error message is written to the log
* the message is skipped
* the checkpoint is advanced
* skip (-2) - the message was intentionally not processed and the checkpoint
is advanced
* retry (-3) - the message was not successfully processed and the host will
call `process_message` again, with the same message, after a one second
delay
#### Example Payload Output
```lua
-- cfg
message_matcher = "Type == 'inject_payload'"
ticker_interval = 0
--location where the payload is written
output_dir = "/tmp"
```
```lua
-- This Source Code Form is subject to the terms of the Mozilla Public
-- License, v. 2.0. If a copy of the MPL was not distributed with this
-- file, You can obtain one at http://mozilla.org/MPL/2.0/.
require "io"
require "string"
local output_dir = read_config("output_dir") or "/tmp"
function process_message()
local pt = read_message("Fields[payload_type]")
if type(pt) ~= "string" then return -1, "invalid payload_type" end
local pn = read_message("Fields[payload_name]") or ""
if type(pn) ~= "string" then return -1, "invalid payload_name" end
local logger = read_message("Logger") or ""
pn = string.gsub(pn, "%W", "_")
pt = string.gsub(pt, "%W", "_")
logger = string.gsub(logger, "%W", "_")
local fn = string.format("%s/%s.%s.%s", output_dir, logger, pn, pt)
local fh, err = io.open(fn, "w")
if err then return -1, err end
local payload = read_message("Payload") or ""
fh:write(payload)
fh:close()
return 0
end
function timer_event(ns)
-- no op
end
```
#### Batching
* `process_message` batches the message/transformation in memory or on disk and
returns one of the following values:
* batching (-4) - the message was successfully added to the batch
* failure (-1) - the message cannot be batch
* the failure count is incremented
* any optional error message is written to the log
* the message is skipped
* skip (-2) - the message was intentionally not added to the batch
* retry (-3) - the message was not successfully added to the batch and the
host will call `process_message` again, with the same message, after a one
second delay
* success (0) - the batch has been successfully committed and the output
checkpoint is advanced to the most recent message
#### Example Postgres Output
```lua
-- cfg
message_matcher = "Type == 'logfile'"
memory_limit = 0
ticker_interval = 60
buffer_max = 1000
db_config = {
host = "example.com",
port = 5432,
name = "dev",
user = "test",
_password = "testpw",
}
```
```lua
-- This Source Code Form is subject to the terms of the Mozilla Public
-- License, v. 2.0. If a copy of the MPL was not distributed with this
-- file, You can obtain one at http://mozilla.org/MPL/2.0/.
require "os"
require "string"
require "table"
local driver = require "luasql.postgres"
local ticker_interval = read_config("ticker_interval")
local db_config = read_config("db_config") or error("db_config must be set")
local buffer_max = read_config("buffer_max") or 1000
assert(buffer_max > 0, "buffer_max must be greater than zero")
local env = assert(driver.postgres())
local con, err = env:connect(db_config.name, db_config.user, db_config._password, db_config.host, db_config.port)
assert(con, err)
local buffer = {}
local buffer_len = 0
local table_name = "test_table"
local MAX_LENGTH = 65535
local columns = {
-- column name field name field type field length
{"msg_Timestamp" ,"Timestamp" ,"TIMESTAMP" ,nil},
{"payload" ,"Payload" ,"VARCHAR" ,MAX_LENGTH},
{"sourceName" ,"Fields[sourceName]" ,"VARCHAR" ,30},
{"sourceVersion" ,"Fields[sourceVersion]" ,"VARCHAR" ,12},
{"submissionDate" ,"Fields[submissionDate]" ,"DATE" ,nil},
{"sampleId" ,"Fields[sampleId]" ,"SMALLINT" ,nil},
}
local function make_create_table()
local pieces = {"CREATE TABLE IF NOT EXISTS ", table_name, " ("}
for i, c in ipairs(columns) do
table.insert(pieces, c[1])
table.insert(pieces, " ")
table.insert(pieces, c[3])
if c[4] ~= nil then
table.insert(pieces, "(")
table.insert(pieces, c[4])
table.insert(pieces, ")")
end
if c[4] == MAX_LENGTH then
table.insert(pieces, " ENCODE LZO")
end
if i < #columns then
table.insert(pieces, ", ")
end
end
table.insert(pieces, ")")
return table.concat(pieces)
end
assert(con:execute(make_create_table()))
local function bulk_load()
local cnt, err = con:execute(table.concat(buffer))
if not err then
buffer = {}
buffer_len = 0
else
return err
end
end
local function esc_str(v)
if v == nil then return "NULL" end
if type(v) ~= "string" then v = tostring(v) end
if string.len(v) > MAX_LENGTH then
v = "TRUNCATED:" .. string.sub(v, 1, MAX_LENGTH - 10)
end
local escd = con:escape(v)
if not escd then return "NULL" end
return string.format("'%s'", escd)
end
local function esc_num(v)
if v == nil then return "NULL" end
if type(v) ~= "number" then return esc_str(v) end
return tostring(v)
end
local function esc_ts(v)
if v == nil then return "NULL" end
if type(v) ~= "number" then return esc_str(v) end
local seconds = v / 1e9
return table.concat({"(TIMESTAMP 'epoch' + ", seconds, " * INTERVAL '1 seconds')"})
end
local function make_insert(sep)
local pieces = {sep, "("}
for i=1,#columns do
if i > 1 then
table.insert(pieces, ",")
end
local col = columns[i]
if col[3] == "TIMESTAMP" then
table.insert(pieces, esc_ts(read_message(col[2])))
elseif col[3] == "SMALLINT" then
table.insert(pieces, esc_num(read_message(col[2])))
else
table.insert(pieces, esc_str(read_message(col[2])))
end
end
table.insert(pieces, ")")
return table.concat(pieces)
end
local last_load = 0
function process_message()
local sep = ","
if buffer_len == 0 then
buffer_len = buffer_len + 1
buffer[buffer_len] = string.format("INSERT INTO %s VALUES", table_name)
sep = " "
end
buffer_len = buffer_len + 1
buffer[buffer_len] = make_insert(sep)
if buffer_len - 1 >= buffer_max then
local err = bulk_load()
if err then
buffer[buffer_len] = nil
buffer_len = buffer_len - 1
return -3, err
else
last_load = os.time()
return 0
end
end
return -4
end
function timer_event(ns, shutdown)
if buffer_len > 1 and (shutdown or last_load + ticker_interval <= ns / 1e9)then
local err = bulk_load()
if not err then
update_checkpoint()
end
end
end
```
#### Asynchronous
* `async_buffer_size` Recommendation: this configuration variable should be set
and consumed by the host
* `process_message` is called with a sequence_id parameter and asynchronously
sends the message/transformation to the destination and returns one of the
following values:
* asynchronous (-5) - the message was successfully queued
* failure (-1) - the message cannot be queue
* the failure count is incremented
* any optional error message is written to the log
* the message is skipped
* skip (-2) - the message was intentionally not queued
* retry (-3) - the message was not successfully queued and the host will call
`process_message` again, with the same message, after a one second delay
* When an asynchronously sent message is acknowledged
[update_checkpoint](#updatecheckpoint) **MUST** be called to advance the
checkpoint to that specific message
#### Example Kafka Output
[kafka.lua](https://github.com/mozilla-services/lua_sandbox_extensions/blob/main/kafka/sandboxes/heka/output/kafka.lua)
================================================
FILE: docs/index.md
================================================
# Overview
Sandboxes provide a dynamic and isolated execution environment
for data parsing, transformation, and analysis. They allow access to data
without jeopardizing the integrity or performance of the processing
infrastructure. This broadens the audience that the data can be
exposed to and facilitates new uses of the data (i.e. debugging, monitoring,
dynamic provisioning, SLA analysis, intrusion detection, ad-hoc reporting,
etc.)
The Lua sandbox is a library allowing customized control over the Lua execution
environment including functionality like global data preservation/restoration on
shutdown/startup, output collection in textual or binary formats and an array of
parsers for various data types (Nginx, Apache, Syslog, MySQL and many RFC grammars)
These libraries and utilities have been mostly extracted from [Hindsight](https://github.com/mozilla-services/hindsight).
The goal was to decouple the Heka/Hindsight functionality from any particular
infrastructure and make it embeddable into any tool or language.
## Features
- small - memory requirements are as little as 8 KiB for a basic sandbox
- fast - microsecond execution times
- stateful - ability to resume where it left off after a restart/reboot
- isolated - failures are contained and malfunctioning sandboxes are terminated.
Containment is defined in terms of restriction to the operating system,
file system, libraries, memory use, Lua instruction use, and output size.
================================================
FILE: docs/sandbox.md
================================================
# Generic Sandbox Interface
## Configuration
* **input_limit** - the largest input string that is allowed to be processed
(bytes (unsigned), default 65536, 0 for unlimited*). This is not directly used
by the sandbox it is made availble to modules to standardize the configuration.
* **output_limit** - the largest output string an input or analysis plugin can
inject into the host (bytes (unsigned), default 65536, 0 for unlimited*)
* **memory_limit** - the maximum amount of memory a plugin can use before being
terminated (bytes (unsigned), default 8388608, 0 for unlimited*)
* **instruction_limit** - the maximum number of Lua instructions a plugin can
execute in a single API function call (count (unsigned), default 1000000, 0
for unlimited)
* **path** - The path used by require to search for a Lua loader. See
[package loaders](http://www.lua.org/manual/5.1/manual.html#pdf-package.loaders)
for the path syntax. By default no paths are set in the sandbox and
everything has been moved to a sandbox configuration table.
* **cpath** - The path used by require to search for a C loader (same notes as
above)
* **disabled_modules** - Hash specifying which modules should be completely
inaccessible. The existence of the key in the table will disable the module.
```lua
disabled_modules = {io = 1}
```
* **remove_entries** - Hash specifying which functions within a module should be
inaccessible
```lua
remove_entries = {
os = {"getenv", "execute"},
string = {"dump"}
}
```
* **log_level** - syslog severity level, when set to debug (7) the print
function will be wired to the specified logger (default error (3))
* *user defined* any other variable (string, bool, number, table) is passed
through as-is and available via [read_config](#readconfig)
*_0 == SIZE_MAX which in not necessarily the upper limit of the
configuration range UINT_MAX_
## Lua functions exposed to C by the core sandbox
There are no functions exposed by default, see lsb_pcall_setup() and
lsb_pcall_teardown() when defining an API.
## Functions exposed to Lua by the core sandbox
### require
By default only the base library is loaded, additional libraries must be loaded
with require().
*Arguments*
- libraryName (string)
*Return*
- a table - For non user provided libraries the table is also globally
registered with the library name. User provided libraries may implement their
own semantics i.e. the grammar libraries return a table but do not globally
register the table name (see the individual module documentation for the
correct usage).
*Notes*
The following modules have been modified, as described, for use in the sandbox.
- [base library](http://www.lua.org/manual/5.1/manual.html#5.1)
- The require() function has been modified to not expose any of the package
table to the sandbox.
- [math](http://www.lua.org/manual/5.1/manual.html#5.6)
- Added Functions
- erf(x) - Returns the error function value for x.
- erfc(x)- Returns the complementary error function value for x.
- [os](http://www.lua.org/manual/5.1/manual.html#5.8)
- The local timezone is set to UTC in all sandboxes.
### read_config
Provides access to the sandbox configuration variables.
*Arguments*
* key (string) - configuration key name
*Return*
* value (string, number, bool, table)
### output
Receives any number of arguments and appends data to the output buffer, which
cannot exceed the output_limit configuration parameter. See lsb_get_output() to
connect the output to the host application.
*Arguments*
- arg (number, string, bool, nil, userdata implementing output support) - Lua
variable or literal to be appended the output buffer
*Return*
- none
### print
Receives any number of arguments and sends a debug message to the host's logger
function as a tab delimited message. The function clears and then uses the
output buffer so if pending output has been queued and not flushed it will be
lost (the same output_limit restrictions apply). Non-printable characters
are replaced with spaces to preserve the host's log integrity and any embedded
NULs terminate each argument.
*Arguments*
- arg (anything that can be converted to a string with the tostring function)
*Return*
- none
**Note:** To extend the function set exposed to Lua see lsb_add_function()
## Special Lua Global Variables
- **_PRESERVATION_VERSION** (number) This variable is examined during state
restoration; if the previous version does not match the current version the
restoration is aborted and the sandbox starts cleanly. The version should be
incremented any time an incompatible change is made to the global data schema.
When versioning is required, the use of a configuration variable name
`preservation_version` with the following syntax is recommended.
```lua
-- initial (allows the user to bump the version due to a cfg change)
_PRESERVATION_VERSION = read_config("preservation_version") or 0
-- if the plugin code alters the global data schema in an incompatible way this
-- ensures the state is properly cleared when there is a user provided version.
_PRESERVATION_VERSION = (read_config("preservation_version") or 0) + 1
```
## How to interact with the sandbox (creating an API)
The best place to start is with some examples:
### Unit Test API
[Unit Test API](https://mozilla-services.github.io/lua_sandbox/doxygen/test_2sandbox_8h.html)
#### Lua Functions Exposed to C
- int **process** (double)
- exposes a process function that takes a test case number as its argument
and returns and integer result code.
- void **report** (double)
- exposes a report function that takes a test case number as its argument
and returns nothing.
#### C Functions Exposed to Lua
- void **write_output** (optionalArg1, optionalArg2, optionalArgN)
- captures whatever is in the output buffer for use by the host application,
appending any optional arguments (optional arguments have the same
restriction as output).
### Heka Sandbox API
[Heka Sandbox API](https://mozilla-services.github.io/lua_sandbox/doxygen/heka_2sandbox_8h.html)
================================================
FILE: docs/util/message_matcher.md
================================================
# Message Matcher Syntax
The message matcher allows sandboxes to select which messages they want to
consume (see [Heka Message Structure](/heka/message.md))
## Examples
* Type == "test" && Severity == 6
* (Severity == 7 || Payload == "Test Payload") && Type == "test"
* Fields[foo] != "bar"
* Fields[foo][1][0] == "alternate"
* Fields[MyBool] == TRUE
* TRUE
* Fields[created] =~ "^2015"
* Fields[string] =~ "foo.example.com"% -- literal pattern vs "foo%.example%.com"
* Fields[widget] != NIL
* Timestamp >= "2016-05-24T00:00:00Z"
* Timestamp >= 1464048000000000000
## Relational Operators
* == equals
* != not equals
* > greater than
* >= greater than equals
* < less than
* <= less than equals
* =~ Lua pattern match
* !~ Lua negated pattern match
## Logical Operators
* Parentheses are used for grouping expressions
* && and (higher precedence)
* || or
## Boolean
* TRUE
* FALSE
## Constants
* NIL used to test the existence (!=) or non-existence (==) of optional headers or field variables
## Message Variables
* All message variables must be on the left hand side of the relational
comparison
### String
* Uuid - 16 byte raw binary type 4 UUID (useful for partitioning data)
* Type
* Logger
* Payload
* EnvVersion
* Hostname
### Numeric
* Timestamp - in addition to nanoseconds since the UNIX epoch an RFC3339 string is also accepted e.g., "2016-05-24T21:51:00Z"
* Severity
* Pid
### Fields
* Fields[_field_name_] - shorthand for Field[_field_name_][0][0]
* Fields[_field_name_][_field_index_] - shorthand for Field[_field_name_][_field_index_][0]
* Fields[_field_name_][_field_index_][_array_index_] the indices are restricted to 0-255
* If a field type is mis-match for the relational comparison, false will be returned e.g., Fields[foo] == 6 where "foo" is a string
## Quoted String
* Single or double quoted strings are allowed
* The maximum string length is 255 bytes
## Lua Pattern Matching Expression
* Patterns are quoted string values
* An 'escape' pattern modifier of `%` is allowed e.g. `"foo.bar"%` is
treated as a literal instead of a pattern and behaves like the 'plain'
option on string.find(). If there are no pattern match characters in the
string this modifier is set automatically.
* See [Lua Patterns](http://www.lua.org/manual/5.1/manual.html#5.4.1)
* Capture groups are ignored
## Additional Restrictions
* Message matchers are restricted to 128 relational comparisons
* A NUL character '\0' is not allowed in a matcher string
================================================
FILE: gen_gh_pages.lua
================================================
-- This Source Code Form is subject to the terms of the Mozilla Public
-- License, v. 2.0. If a copy of the MPL was not distributed with this
-- file, You can obtain one at http://mozilla.org/MPL/2.0/.
require "os"
require "io"
require "string"
local function output_menu(output_dir, version)
local fh = assert(io.open(string.format("%s/SUMMARY.md", output_dir), "w"))
fh:write(string.format("* [Lua Sandbox Library (%s)](README.md)\n\n", version))
fh:write([[
* [Generic Sandbox](sandbox.md)
* [Heka Sandbox](heka/index.md)
* [Input Interface](heka/input.md)
* [Analysis Interface](heka/analysis.md)
* [Output Interface](heka/output.md)
* [Message Schema](heka/message.md)
* [Message Matcher](util/message_matcher.md)
* [Command Line Tools](cli/index.md)
* [Source Documentation](https://mozilla-services.github.io/lua_sandbox/doxygen/index.html)
* [Sandbox Extensions](https://mozilla-services.github.io/lua_sandbox_extensions)
]])
fh:close()
end
local args = {...}
local function main()
local output_dir = string.format("%s/gb-source", arg[3])
local rv = os.execute(string.format("rsync -rav docs/ %s/", output_dir))
if rv ~= 0 then error"rsync setup" end
local fh = assert(io.open(string.format("%s/book.json", output_dir), "w"))
fh:write([[{"plugins" : ["collapsible-menu", "navigator"]}]])
fh:close()
os.execute(string.format("cd %s;gitbook install", output_dir))
os.execute(string.format("mv %s/index.md %s/README.md", output_dir, output_dir))
output_menu(output_dir, args[1])
os.execute(string.format("gitbook build %s", output_dir))
local rv = os.execute(string.format("rsync -rav %s/_book/ %s/", output_dir, "gh-pages/"))
if rv ~= 0 then error"rsync publish" end
end
main()
================================================
FILE: include/luasandbox/error.h
================================================
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/** Error handling and logging @file */
#ifndef luasandbox_error_h_
#define luasandbox_error_h_
// See Identify your Errors better with char[]
// http://accu.org/index.php/journals/2184
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_cb)(void *context,
const char *component,
int level,
const char *fmt,
...);
typedef struct lsb_logger {
void *context;
lsb_logger_cb cb;
} lsb_logger;
#endif
================================================
FILE: include/luasandbox/heka/sandbox.h
================================================
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/** Heka sandbox implementation @file */
#ifndef luasandbox_heka_sandbox_h_
#define luasandbox_heka_sandbox_h_
#include <stdbool.h>
#include <time.h>
#include "../../luasandbox.h"
#include "../error.h"
#include "../util/heka_message.h"
#ifdef _WIN32
#ifdef luasandboxheka_EXPORTS
#define LSB_HEKA_EXPORT __declspec(dllexport)
#else
#define LSB_HEKA_EXPORT __declspec(dllimport)
#endif
#else
#if __GNUC__ >= 4
#define LSB_HEKA_EXPORT __attribute__ ((visibility ("default")))
#else
#define LSB_HEKA_EXPORT
#endif
#endif
#define LSB_HEKA_MAX_MESSAGE_SIZE "max_message_size"
#define LSB_HEKA_UPDATE_CHECKPOINT "update_checkpoint"
#define LSB_HEKA_THIS_PTR "lsb_heka_this_ptr"
enum lsb_heka_pm_rv {
LSB_HEKA_PM_SENT = 0,
LSB_HEKA_PM_FAIL = -1,
LSB_HEKA_PM_SKIP = -2,
LSB_HEKA_PM_RETRY = -3,
LSB_HEKA_PM_BATCH = -4,
LSB_HEKA_PM_ASYNC = -5
};
enum lsb_heka_im_rv {
LSB_HEKA_IM_SUCCESS = 0,
LSB_HEKA_IM_ERROR = 1, // generic error for backward compatibility
LSB_HEKA_IM_CHECKPOINT = 2,
LSB_HEKA_IM_LIMIT = 3,
};
typedef struct lsb_heka_sandbox lsb_heka_sandbox;
typedef struct lsb_heka_stats {
unsigned long long mem_cur;
unsigned long long mem_max;
unsigned long long ins_max;
unsigned long long out_max;
unsigned long long im_cnt;
unsigned long long im_bytes;
unsigned long long pm_cnt;
unsigned long long pm_failures;
double pm_avg;
double pm_sd;
double te_avg;
double te_sd;
} lsb_heka_stats;
#ifdef __cplusplus
extern "C"
{
#endif
#include "../lauxlib.h"
#include "../lua.h"
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
* a measurable performance benefit but are not always applicable so both
* options are provided to support various types of input plugins. This function
* can be called with a NULL pb pointer by the 'is_running' API or if only a
* checkpoint update is being performed; it should be treated as a no-op and
* used as a synchronization point to collect statistics and communicate
* shutdown status.
*
* @param parent Opaque pointer the host object owning this sandbox
* @param pb Pointer to a Heka protobuf encoded message being injected.
* @param pb_en Length of s
* @param cp_numeric Numeric based checkpoint (can be NAN)
* @param cp_string String based checkpoint (can be NULL)
*
* @return 0 on success
*/
typedef int (*lsb_heka_im_input)(void *parent,
const char *pb,
size_t pb_len,
double cp_numeric,
const char *cp_string);
/**
* inject_message callback function provided by the host.
*
* @param parent Opaque pointer the host object owning this sandbox.
* @param pb Pointer to a Heka protobuf encoded message being injected.
* @param len Length of pb_len
*
* @return 0 on success
*/
typedef int (*lsb_heka_im_analysis)(void *parent,
const char *pb,
size_t pb_len);
/**
* update_checkpoint callback function provided by the host.
*
* @param parent Opaque pointer the host object owning this sandbox.
* @param sequence_id Opaque pointer to the host message sequencing (passed into
* process_message).
*
* @return 0 on success
*/
typedef int (*lsb_heka_update_checkpoint)(void *parent, void *sequence_id);
/**
* Create a sandbox supporting the Heka Input Plugin API
*
* @param parent Opaque pointer the host object owning this sandbox
* @param lua_file Fully qualified path to the Lua source file
* @param state_file Fully qualified filename to the state preservation file
* (NULL if no preservation is required)
* @param lsb_cfg Full configuration string as a Lua table (NULL for lsb
* defaults)
* @param logger Struct for error reporting/debug printing (NULL to disable)
* @param im inject_message callback
* @return lsb_heka_sandbox* On success a pointer to the sandbox otherwise NULL
*/
LSB_HEKA_EXPORT
lsb_heka_sandbox* lsb_heka_create_input(void *parent,
const char *lua_file,
const char *state_file,
const char *lsb_cfg,
lsb_logger *logger,
lsb_heka_im_input im);
/**
* Host access to the input sandbox process_message API. If a numeric
* checkpoint is set the string checkpoint is ignored.
*
* @param hsb Heka input sandbox
* @param cp_numeric NAN if no numeric checkpoint
* @param cp_string NULL if no string checkpoint
* @param profile Take a timing sample on this execution
*
* @return int
* >0 fatal error
* 0 success
* <0 non-fatal error (status message is logged)
*
*/
LSB_HEKA_EXPORT
int lsb_heka_pm_input(lsb_heka_sandbox *hsb,
double cp_numeric,
const char *cp_string,
bool profile);
/**
* Create a sandbox supporting the Heka Analysis Plugin API
*
* @param parent Opaque pointer the host object owning this sandbox
* @param lua_file Fully qualified filename to the Lua source file
* @param state_file Fully qualified filename to the state preservation file
* (NULL if no preservation is required)
* @param lsb_cfg Full configuration string as a Lua table (NULL for lsb
* defaults)
* @param logger Struct for error reporting/debug printing (NULL to disable)
* @param im inject_message callback
* @return lsb_heka_sandbox* On success a pointer to the sandbox otherwise NULL
*/
LSB_HEKA_EXPORT
lsb_heka_sandbox* lsb_heka_create_analysis(void *parent,
const char *lua_file,
const char *state_file,
const char *lsb_cfg,
lsb_logger *logger,
lsb_heka_im_analysis im);
/**
* Host access to the analysis sandbox process_message API
*
* @param hsb Heka analysis sandbox
* @param msg Heka message to process
* @param profile Take a timing sample on this execution
*
* @return int
* >0 fatal error
* 0 success
* <0 non-fatal error (status message is logged)
*
*/
LSB_HEKA_EXPORT
int lsb_heka_pm_analysis(lsb_heka_sandbox *hsb,
lsb_heka_message *msg,
bool profile);
/**
* Create a sandbox supporting the Heka Output Plugin API
*
* @param parent Opaque pointer the host object owning this sandbox
* @param lua_file Fully qualified path to the Lua source file
* @param state_file Fully qualified filename to the state preservation file
* (NULL if no preservation is required)
* @param lsb_cfg Full configuration string as a Lua table (NULL for lsb
* defaults)
* @param logger Struct for error reporting/debug printing (NULL to disable)
* @param ucp checkpoint_updated callback when using batch or async output
*
* @return lsb_heka_sandbox* On success a pointer to the sandbox otherwise NULL
*/
LSB_HEKA_EXPORT
lsb_heka_sandbox* lsb_heka_create_output(void *parent,
const char *lua_file,
const char *state_file,
const char *lsb_cfg,
lsb_logger *logger,
lsb_heka_update_checkpoint ucp);
/**
* Create a sandbox supporting the Heka Output Plugin API with
* inject_message support
*
* @param parent Opaque pointer the host object owning this sandbox
* @param lua_file Fully qualified path to the Lua source file
* @param state_file Fully qualified filename to the state preservation file
* (NULL if no preservation is required)
* @param lsb_cfg Full configuration string as a Lua table (NULL for lsb
* defaults)
* @param logger Struct for error reporting/debug printing (NULL to disable)
* @param ucp checkpoint_updated callback when using batch or async output
* @param im inject_message callback
*
* @return lsb_heka_sandbox* On success a pointer to the sandbox otherwise NULL
*/
LSB_HEKA_EXPORT
lsb_heka_sandbox* lsb_heka_create_output_im(void *parent,
const char *lua_file,
const char *state_file,
const char *lsb_cfg,
lsb_logger *logger,
lsb_heka_update_checkpoint ucp,
lsb_heka_im_analysis im);
/**
* Host access to the output sandbox process_message API
*
* @param hsb Heka output sandbox
* @param msg Heka message to process
* @param sequence_id Opaque pointer to the message sequence id (only used for
* async output plugin otherwise it should be NULL)
* @param profile Take a timing sample on this execution
*
* @return int
* >0 fatal error
* 0 success
* -1 non-fatal_error (status message is logged)
* -2 skip
* -3 retry
* -4 batching
* -5 async output
*
*/
LSB_HEKA_EXPORT
int lsb_heka_pm_output(lsb_heka_sandbox *hsb,
lsb_heka_message *msg,
void *sequence_id,
bool profile);
/**
* Requests a long running input sandbox to stop. This call is not thread safe.
*
* @param hsb Heka sandbox to cleanly stop
*
* @return
*
*/
LSB_HEKA_EXPORT void
lsb_heka_stop_sandbox_clean(lsb_heka_sandbox *hsb);
/**
* Aborts the running sandbox from a different thread of execution. A "shutting
* down" termination message is generated. Used to abort long runnning sandboxes
* such as an input sandbox.
*
* @param hsb Heka sandbox to forcibly stop
*
* @return
*
*/
LSB_HEKA_EXPORT void
lsb_heka_stop_sandbox(lsb_heka_sandbox *hsb);
/**
* Terminates the sandbox as if it had a fatal error (not thread safe).
*
* @param hsb Heka sandbox to terminate
* @param err Reason for termination
*/
LSB_HEKA_EXPORT void
lsb_heka_terminate_sandbox(lsb_heka_sandbox *hsb, const char *err);
/**
* Frees all memory associated with the sandbox; hsb cannont be used after this
* point and the host should set it to NULL.
*
* @param hsb Heka sandbox to free
*
* @return NULL on success, pointer to an error message on failure that MUST BE
* FREED by the caller.
*
*/
LSB_HEKA_EXPORT char*
lsb_heka_destroy_sandbox(lsb_heka_sandbox *hsb);
/**
* Host access to the timer_event API
*
* @param hsb Heka sandbox
* @param t Clock time of the timer_event execution
* @param shutdown Flag indicating the Host is shutting down allowing the
* sandbox to do any desired finialization)
*
* @return int 0 on success
*/
LSB_HEKA_EXPORT
int lsb_heka_timer_event(lsb_heka_sandbox *hsb, time_t t, bool shutdown);
/**
* Return the last error in human readable form.
*
* @param hsb Heka sandbox
*
* @return const char* error message
*/
LSB_HEKA_EXPORT const char* lsb_heka_get_error(lsb_heka_sandbox *hsb);
/**
* Returns the filename of the Lua source.
*
* @param hsb Heka sandbox
*
* @return const char* filename.
*/
LSB_HEKA_EXPORT const char* lsb_heka_get_lua_file(lsb_heka_sandbox *hsb);
/**
* Retrieve the sandbox profiling/monitoring statistics. This call accesses
* internal data and is not thread safe.
*
* @param hsb Heka sandbox
*
* @return lsb_heka_stats A copy of the stats structure
*/
LSB_HEKA_EXPORT lsb_heka_stats lsb_heka_get_stats(lsb_heka_sandbox *hsb);
/**
* Convenience function to test if a sandbox is running.
*
* @param hsb Heka sandbox
*
* @return True if the sandbox has not been terminated
*/
LSB_HEKA_EXPORT bool lsb_heka_is_running(lsb_heka_sandbox *hsb);
/**
* Queries the state of the sandbox.
*
* @param hsb
*
* @return lsb_state
*
*/
LSB_HEKA_EXPORT lsb_state lsb_heka_get_state(lsb_heka_sandbox *hsb);
/**
* Retrieve the currently active sandbox message. This call returns a handle to
* internal data and is not thread safe.
* *
* @param hsb Heka sandbox
*
* @return const lsb_heka_message* NULL if there is no active message
*/
LSB_HEKA_EXPORT const lsb_heka_message*
lsb_heka_get_message(lsb_heka_sandbox *hsb);
/**
* Retrieve the sandbox type.
* *
* @param hsb Heka sandbox
*
* @return char Heka sandbox type identifer
*/
LSB_HEKA_EXPORT char lsb_heka_get_type(lsb_heka_sandbox *hsb);
#ifdef __cplusplus
}
#endif
#endif
================================================
FILE: include/luasandbox/heka/stream_reader.h
================================================
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/** Hindsight Heka stream reader structures @file */
#ifndef luasandbox_heka_stream_reader_h_
#define luasandbox_heka_stream_reader_h_
#include "../util/heka_message.h"
#include "../util/input_buffer.h"
#define LSB_HEKA_STREAM_READER "lsb.heka_stream_reader"
typedef struct heka_stream_reader
{
char *name;
lsb_heka_message msg;
lsb_input_buffer buf;
} heka_stream_reader;
#endif
================================================
FILE: include/luasandbox/lauxlib.h
================================================
/*
** $Id: lauxlib.h,v 1.88.1.1 2007/12/27 13:02:25 roberto Exp $
** Auxiliary functions for building Lua libraries
** See Copyright Notice in lua.h
*/
#ifndef lauxlib_h
#define lauxlib_h
#include <stddef.h>
#include <stdio.h>
#include "lua.h"
#if defined(LUA_COMPAT_GETN)
LUALIB_API int (luaL_getn) (lua_State *L, int t);
LUALIB_API void (luaL_setn) (lua_State *L, int t, int n);
#else
#define luaL_getn(L,i) ((int)lua_objlen(L, i))
#define luaL_setn(L,i,j) ((void)0) /* no op! */
#endif
#if defined(LUA_COMPAT_OPENLIB)
#define luaI_openlib luaL_openlib
#endif
/* extra error code for `luaL_load' */
#define LUA_ERRFILE (LUA_ERRERR+1)
typedef struct luaL_Reg {
const char *name;
lua_CFunction func;
} luaL_Reg;
LUALIB_API void (luaI_openlib) (lua_State *L, const char *libname,
const luaL_Reg *l, int nup);
LUALIB_API void (luaL_register) (lua_State *L, const char *libname,
const luaL_Reg *l);
LUALIB_API int (luaL_getmetafield) (lua_State *L, int obj, const char *e);
LUALIB_API int (luaL_callmeta) (lua_State *L, int obj, const char *e);
LUALIB_API int (luaL_typerror) (lua_State *L, int narg, const char *tname);
LUALIB_API int (luaL_argerror) (lua_State *L, int numarg, const char *extramsg);
LUALIB_API const char *(luaL_checklstring) (lua_State *L, int numArg,
size_t *l);
LUALIB_API const char *(luaL_optlstring) (lua_State *L, int numArg,
const char *def, size_t *l);
LUALIB_API lua_Number (luaL_checknumber) (lua_State *L, int numArg);
LUALIB_API lua_Number (luaL_optnumber) (lua_State *L, int nArg, lua_Number def);
LUALIB_API lua_Integer (luaL_checkinteger) (lua_State *L, int numArg);
LUALIB_API lua_Integer (luaL_optinteger) (lua_State *L, int nArg,
lua_Integer def);
LUALIB_API void (luaL_checkstack) (lua_State *L, int sz, const char *msg);
LUALIB_API void (luaL_checktype) (lua_State *L, int narg, int t);
LUALIB_API void (luaL_checkany) (lua_State *L, int narg);
LUALIB_API int (luaL_newmetatable) (lua_State *L, const char *tname);
LUALIB_API void *(luaL_checkudata) (lua_State *L, int ud, const char *tname);
LUALIB_API void (luaL_where) (lua_State *L, int lvl);
LUALIB_API int (luaL_error) (lua_State *L, const char *fmt, ...);
LUALIB_API int (luaL_checkoption) (lua_State *L, int narg, const char *def,
const char *const lst[]);
LUALIB_API int (luaL_ref) (lua_State *L, int t);
LUALIB_API void (luaL_unref) (lua_State *L, int t, int ref);
LUALIB_API int (luaL_loadfile) (lua_State *L, const char *filename);
LUALIB_API int (luaL_loadbuffer) (lua_State *L, const char *buff, size_t sz,
const char *name);
LUALIB_API int (luaL_loadstring) (lua_State *L, const char *s);
LUALIB_API lua_State *(luaL_newstate) (void);
LUALIB_API const char *(luaL_gsub) (lua_State *L, const char *s, const char *p,
const char *r);
LUALIB_API const char *(luaL_findtable) (lua_State *L, int idx,
const char *fname, int szhint);
/*
** ===============================================================
** some useful macros
** ===============================================================
*/
#define luaL_argcheck(L, cond,numarg,extramsg) \
((void)((cond) || luaL_argerror(L, (numarg), (extramsg))))
#define luaL_checkstring(L,n) (luaL_checklstring(L, (n), NULL))
#define luaL_optstring(L,n,d) (luaL_optlstring(L, (n), (d), NULL))
#define luaL_checkint(L,n) ((int)luaL_checkinteger(L, (n)))
#define luaL_optint(L,n,d) ((int)luaL_optinteger(L, (n), (d)))
#define luaL_checklong(L,n) ((long)luaL_checkinteger(L, (n)))
#define luaL_optlong(L,n,d) ((long)luaL_optinteger(L, (n), (d)))
#define luaL_typename(L,i) lua_typename(L, lua_type(L,(i)))
#define luaL_dofile(L, fn) \
(luaL_loadfile(L, fn) || lua_pcall(L, 0, LUA_MULTRET, 0))
#define luaL_dostring(L, s) \
(luaL_loadstring(L, s) || lua_pcall(L, 0, LUA_MULTRET, 0))
#define luaL_getmetatable(L,n) (lua_getfield(L, LUA_REGISTRYINDEX, (n)))
#define luaL_opt(L,f,n,d) (lua_isnoneornil(L,(n)) ? (d) : f(L,(n)))
/*
** {======================================================
** Generic Buffer manipulation
** =======================================================
*/
typedef struct luaL_Buffer {
char *p; /* current position in buffer */
int lvl; /* number of strings in the stack (level) */
lua_State *L;
char buffer[LUAL_BUFFERSIZE];
} luaL_Buffer;
#define luaL_addchar(B,c) \
((void)((B)->p < ((B)->buffer+LUAL_BUFFERSIZE) || luaL_prepbuffer(B)), \
(*(B)->p++ = (char)(c)))
/* compatibility only */
#define luaL_putchar(B,c) luaL_addchar(B,c)
#define luaL_addsize(B,n) ((B)->p += (n))
LUALIB_API void (luaL_buffinit) (lua_State *L, luaL_Buffer *B);
LUALIB_API char *(luaL_prepbuffer) (luaL_Buffer *B);
LUALIB_API void (luaL_addlstring) (luaL_Buffer *B, const char *s, size_t l);
LUALIB_API void (luaL_addstring) (luaL_Buffer *B, const char *s);
LUALIB_API void (luaL_addvalue) (luaL_Buffer *B);
LUALIB_API void (luaL_pushresult) (luaL_Buffer *B);
/* }====================================================== */
/* compatibility with ref system */
/* pre-defined references */
#define LUA_NOREF (-2)
#define LUA_REFNIL (-1)
#define lua_ref(L,lock) ((lock) ? luaL_ref(L, LUA_REGISTRYINDEX) : \
(lua_pushstring(L, "unlocked references are obsolete"), lua_error(L), 0))
#define lua_unref(L,ref) luaL_unref(L, LUA_REGISTRYINDEX, (ref))
#define lua_getref(L,ref) lua_rawgeti(L, LUA_REGISTRYINDEX, (ref))
#define luaL_reg luaL_Reg
#endif
================================================
FILE: include/luasandbox/lua.h
================================================
/*
** $Id: lua.h,v 1.218.1.7 2012/01/13 20:36:20 roberto Exp $
** Lua - An Extensible Extension Language
** Lua.org, PUC-Rio, Brazil (http://www.lua.org)
** See Copyright Notice at the end of this file
*/
#ifndef lua_h
#define lua_h
#include <stdarg.h>
#include <stddef.h>
#include "luaconf.h"
#define LUA_VERSION "Lua 5.1"
#define LUA_RELEASE "Lua 5.1.5"
#define LUA_VERSION_NUM 501
#define LUA_COPYRIGHT "Copyright (C) 1994-2012 Lua.org, PUC-Rio"
#define LUA_AUTHORS "R. Ierusalimschy, L. H. de Figueiredo & W. Celes"
/* mark for precompiled code (`<esc>Lua') */
#define LUA_SIGNATURE "\033Lua"
/* option for multiple returns in `lua_pcall' and `lua_call' */
#define LUA_MULTRET (-1)
/*
** pseudo-indices
*/
#define LUA_REGISTRYINDEX (-10000)
#define LUA_ENVIRONINDEX (-10001)
#define LUA_GLOBALSINDEX (-10002)
#define lua_upvalueindex(i) (LUA_GLOBALSINDEX-(i))
/* thread status; 0 is OK */
#define LUA_YIELD 1
#define LUA_ERRRUN 2
#define LUA_ERRSYNTAX 3
#define LUA_ERRMEM 4
#define LUA_ERRERR 5
typedef struct lua_State lua_State;
typedef int (*lua_CFunction) (lua_State *L);
/*
** functions that read/write blocks when loading/dumping Lua chunks
*/
typedef const char * (*lua_Reader) (lua_State *L, void *ud, size_t *sz);
typedef int (*lua_Writer) (lua_State *L, const void* p, size_t sz, void* ud);
/*
** prototype for memory-allocation functions
*/
typedef void * (*lua_Alloc) (void *ud, void *ptr, size_t osize, size_t nsize);
/*
** basic types
*/
#define LUA_TNONE (-1)
#define LUA_TNIL 0
#define LUA_TBOOLEAN 1
#define LUA_TLIGHTUSERDATA 2
#define LUA_TNUMBER 3
#define LUA_TSTRING 4
#define LUA_TTABLE 5
#define LUA_TFUNCTION 6
#define LUA_TUSERDATA 7
#define LUA_TTHREAD 8
/*
** table types
*/
#define LUA_TTEMPTY 0
#define LUA_TTARRAY 1
#define LUA_TTHASH 2
#define LUA_TTMIXED 3
/* minimum Lua stack available to a C function */
#define LUA_MINSTACK 20
/*
** generic extra include file
*/
#if defined(LUA_USER_H)
#include LUA_USER_H
#endif
/* type of numbers in Lua */
typedef LUA_NUMBER lua_Number;
/* type for integer functions */
typedef LUA_INTEGER lua_Integer;
/*
** state manipulation
*/
LUA_API lua_State *(lua_newstate) (lua_Alloc f, void *ud);
LUA_API void (lua_close) (lua_State *L);
LUA_API lua_State *(lua_newthread) (lua_State *L);
LUA_API lua_CFunction (lua_atpanic) (lua_State *L, lua_CFunction panicf);
/*
** basic stack manipulation
*/
LUA_API int (lua_gettop) (lua_State *L);
LUA_API void (lua_settop) (lua_State *L, int idx);
LUA_API void (lua_pushvalue) (lua_State *L, int idx);
LUA_API void (lua_remove) (lua_State *L, int idx);
LUA_API void (lua_insert) (lua_State *L, int idx);
LUA_API void (lua_replace) (lua_State *L, int idx);
LUA_API int (lua_checkstack) (lua_State *L, int sz);
LUA_API void (lua_xmove) (lua_State *from, lua_State *to, int n);
/*
** access functions (stack -> C)
*/
LUA_API int (lua_tabletype) (lua_State *L, int idx);
LUA_API int (lua_isnumber) (lua_State *L, int idx);
LUA_API int (lua_isstring) (lua_State *L, int idx);
LUA_API int (lua_iscfunction) (lua_State *L, int idx);
LUA_API int (lua_isuserdata) (lua_State *L, int idx);
LUA_API int (lua_type) (lua_State *L, int idx);
LUA_API const char *(lua_typename) (lua_State *L, int tp);
LUA_API int (lua_equal) (lua_State *L, int idx1, int idx2);
LUA_API int (lua_rawequal) (lua_State *L, int idx1, int idx2);
LUA_API int (lua_lessthan) (lua_State *L, int idx1, int idx2);
LUA_API lua_Number (lua_tonumber) (lua_State *L, int idx);
LUA_API lua_Integer (lua_tointeger) (lua_State *L, int idx);
LUA_API int (lua_toboolean) (lua_State *L, int idx);
LUA_API const char *(lua_tolstring) (lua_State *L, int idx, size_t *len);
LUA_API size_t (lua_objlen) (lua_State *L, int idx);
LUA_API lua_CFunction (lua_tocfunction) (lua_State *L, int idx);
LUA_API void *(lua_touserdata) (lua_State *L, int idx);
LUA_API lua_State *(lua_tothread) (lua_State *L, int idx);
LUA_API const void *(lua_topointer) (lua_State *L, int idx);
/*
** push functions (C -> stack)
*/
LUA_API void (lua_pushnil) (lua_State *L);
LUA_API void (lua_pushnumber) (lua_State *L, lua_Number n);
LUA_API void (lua_pushinteger) (lua_State *L, lua_Integer n);
LUA_API void (lua_pushlstring) (lua_State *L, const char *s, size_t l);
LUA_API void (lua_pushstring) (lua_State *L, const char *s);
LUA_API const char *(lua_pushvfstring) (lua_State *L, const char *fmt,
va_list argp);
LUA_API const char *(lua_pushfstring) (lua_State *L, const char *fmt, ...);
LUA_API void (lua_pushcclosure) (lua_State *L, lua_CFunction fn, int n);
LUA_API void (lua_pushboolean) (lua_State *L, int b);
LUA_API void (lua_pushlightuserdata) (lua_State *L, void *p);
LUA_API int (lua_pushthread) (lua_State *L);
/*
** get functions (Lua -> stack)
*/
LUA_API void (lua_gettable) (lua_State *L, int idx);
LUA_API void (lua_getfield) (lua_State *L, int idx, const char *k);
LUA_API void (lua_rawget) (lua_State *L, int idx);
LUA_API void (lua_rawgeti) (lua_State *L, int idx, int n);
LUA_API void (lua_createtable) (lua_State *L, int narr, int nrec);
LUA_API void *(lua_newuserdata) (lua_State *L, size_t sz);
LUA_API int (lua_getmetatable) (lua_State *L, int objindex);
LUA_API void (lua_getfenv) (lua_State *L, int idx);
/*
** set functions (stack -> Lua)
*/
LUA_API void (lua_settable) (lua_State *L, int idx);
LUA_API void (lua_setfield) (lua_State *L, int idx, const char *k);
LUA_API void (lua_rawset) (lua_State *L, int idx);
LUA_API void (lua_rawseti) (lua_State *L, int idx, int n);
LUA_API int (lua_setmetatable) (lua_State *L, int objindex);
LUA_API int (lua_setfenv) (lua_State *L, int idx);
/*
** `load' and `call' functions (load and run Lua code)
*/
LUA_API void (lua_call) (lua_State *L, int nargs, int nresults);
LUA_API int (lua_pcall) (lua_State *L, int nargs, int nresults, int errfunc);
LUA_API int (lua_cpcall) (lua_State *L, lua_CFunction func, void *ud);
LUA_API int (lua_load) (lua_State *L, lua_Reader reader, void *dt,
const char *chunkname);
LUA_API int (lua_dump) (lua_State *L, lua_Writer writer, void *data);
/*
** coroutine functions
*/
LUA_API int (lua_yield) (lua_State *L, int nresults);
LUA_API int (lua_resume) (lua_State *L, int narg);
LUA_API int (lua_status) (lua_State *L);
/*
** garbage-collection function and options
*/
#define LUA_GCSTOP 0
#define LUA_GCRESTART 1
#define LUA_GCCOLLECT 2
#define LUA_GCCOUNT 3
#define LUA_GCCOUNTB 4
#define LUA_GCSTEP 5
#define LUA_GCSETPAUSE 6
#define LUA_GCSETSTEPMUL 7
LUA_API int (lua_gc) (lua_State *L, int what, int data);
/*
** miscellaneous functions
*/
LUA_API int (lua_error) (lua_State *L);
LUA_API int (lua_next) (lua_State *L, int idx);
LUA_API void (lua_concat) (lua_State *L, int n);
LUA_API lua_Alloc (lua_getallocf) (lua_State *L, void **ud);
LUA_API void lua_setallocf (lua_State *L, lua_Alloc f, void *ud);
/*
** ===============================================================
** some useful macros
** ===============================================================
*/
#define lua_pop(L,n) lua_settop(L, -(n)-1)
#define lua_newtable(L) lua_createtable(L, 0, 0)
#define lua_register(L,n,f) (lua_pushcfunction(L, (f)), lua_setglobal(L, (n)))
#define lua_pushcfunction(L,f) lua_pushcclosure(L, (f), 0)
#define lua_strlen(L,i) lua_objlen(L, (i))
#define lua_isfunction(L,n) (lua_type(L, (n)) == LUA_TFUNCTION)
#define lua_istable(L,n) (lua_type(L, (n)) == LUA_TTABLE)
#define lua_islightuserdata(L,n) (lua_type(L, (n)) == LUA_TLIGHTUSERDATA)
#define lua_isnil(L,n) (lua_type(L, (n)) == LUA_TNIL)
#define lua_isboolean(L,n) (lua_type(L, (n)) == LUA_TBOOLEAN)
#define lua_isthread(L,n) (lua_type(L, (n)) == LUA_TTHREAD)
#define lua_isnone(L,n) (lua_type(L, (n)) == LUA_TNONE)
#define lua_isnoneornil(L, n) (lua_type(L, (n)) <= 0)
#define lua_pushliteral(L, s) \
lua_pushlstring(L, "" s, (sizeof(s)/sizeof(char))-1)
#define lua_setglobal(L,s) lua_setfield(L, LUA_GLOBALSINDEX, (s))
#define lua_getglobal(L,s) lua_getfield(L, LUA_GLOBALSINDEX, (s))
#define lua_tostring(L,i) lua_tolstring(L, (i), NULL)
/*
** compatibility macros and functions
*/
#define lua_open() luaL_newstate()
#define lua_getregistry(L) lua_pushvalue(L, LUA_REGISTRYINDEX)
#define lua_getgccount(L) lua_gc(L, LUA_GCCOUNT, 0)
#define lua_Chunkreader lua_Reader
#define lua_Chunkwriter lua_Writer
/* hack */
LUA_API void lua_setlevel (lua_State *from, lua_State *to);
/*
** {======================================================================
** Debug API
** =======================================================================
*/
/*
** Event codes
*/
#define LUA_HOOKCALL 0
#define LUA_HOOKRET 1
#define LUA_HOOKLINE 2
#define LUA_HOOKCOUNT 3
#define LUA_HOOKTAILRET 4
/*
** Event masks
*/
#define LUA_MASKCALL (1 << LUA_HOOKCALL)
#define LUA_MASKRET (1 << LUA_HOOKRET)
#define LUA_MASKLINE (1 << LUA_HOOKLINE)
#define LUA_MASKCOUNT (1 << LUA_HOOKCOUNT)
typedef struct lua_Debug lua_Debug; /* activation record */
/* Functions to be called by the debuger in specific events */
typedef void (*lua_Hook) (lua_State *L, lua_Debug *ar);
LUA_API int lua_getstack (lua_State *L, int level, lua_Debug *ar);
LUA_API int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar);
LUA_API const char *lua_getlocal (lua_State *L, const lua_Debug *ar, int n);
LUA_API const char *lua_setlocal (lua_State *L, const lua_Debug *ar, int n);
LUA_API const char *lua_getupvalue (lua_State *L, int funcindex, int n);
LUA_API const char *lua_setupvalue (lua_State *L, int funcindex, int n);
LUA_API int lua_sethook (lua_State *L, lua_Hook func, int mask, int count);
LUA_API lua_Hook lua_gethook (lua_State *L);
LUA_API int lua_gethookmask (lua_State *L);
LUA_API int lua_gethookcount (lua_State *L);
LUA_API int lua_gethookcountremaining (lua_State *L);
struct lua_Debug {
int event;
const char *name; /* (n) */
const char *namewhat; /* (n) `global', `local', `field', `method' */
const char *what; /* (S) `Lua', `C', `main', `tail' */
const char *source; /* (S) */
int currentline; /* (l) */
int nups; /* (u) number of upvalues */
int linedefined; /* (S) */
int lastlinedefined; /* (S) */
char short_src[LUA_IDSIZE]; /* (S) */
/* private part */
int i_ci; /* active function */
};
/* }====================================================================== */
/******************************************************************************
* Copyright (C) 1994-2012 Lua.org, PUC-Rio. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
******************************************************************************/
#endif
================================================
FILE: include/luasandbox/luaconf.h
================================================
/*
** $Id: luaconf.h,v 1.82.1.7 2008/02/11 16:25:08 roberto Exp $
** Configuration file for Lua
** See Copyright Notice in lua.h
*/
#ifndef lconfig_h
#define lconfig_h
#include <limits.h>
#include <stddef.h>
/*
** ==================================================================
** Search for "@@" to find all configurable definitions.
** ===================================================================
*/
/*
@@ LUA_ANSI controls the use of non-ansi features.
** CHANGE it (define it) if you want Lua to avoid the use of any
** non-ansi feature or library.
*/
#if defined(__STRICT_ANSI__)
#define LUA_ANSI
#endif
#if !defined(LUA_ANSI) && defined(_WIN32)
#define LUA_WIN
#endif
#if defined(LUA_USE_LINUX)
#define LUA_USE_POSIX
#define LUA_USE_DLOPEN /* needs an extra library: -ldl */
#define LUA_USE_READLINE /* needs some extra libraries */
#endif
#if defined(LUA_USE_MACOSX)
#define LUA_USE_POSIX
#define LUA_DL_DYLD /* does not need extra library */
#endif
/*
@@ LUA_USE_POSIX includes all functionallity listed as X/Open System
@* Interfaces Extension (XSI).
** CHANGE it (define it) if your system is XSI compatible.
*/
#if defined(LUA_USE_POSIX)
#define LUA_USE_MKSTEMP
#define LUA_USE_ISATTY
#define LUA_USE_POPEN
#define LUA_USE_ULONGJMP
#endif
/*
@@ LUA_PATH and LUA_CPATH are the names of the environment variables that
@* Lua check to set its paths.
@@ LUA_INIT is the name of the environment variable that Lua
@* checks for initialization code.
** CHANGE them if you want different names.
*/
#define LUA_PATH "LUA_PATH"
#define LUA_CPATH "LUA_CPATH"
#define LUA_INIT "LUA_INIT"
/*
@@ LUA_PATH_DEFAULT is the default path that Lua uses to look for
@* Lua libraries.
@@ LUA_CPATH_DEFAULT is the default path that Lua uses to look for
@* C libraries.
** CHANGE them if your machine has a non-conventional directory
** hierarchy or if you want to install your libraries in
** non-conventional directories.
*/
#if defined(_WIN32)
/*
** In Windows, any exclamation mark ('!') in the path is replaced by the
** path of the directory of the executable file of the current process.
*/
#define LUA_LDIR "!\\lua\\"
#define LUA_CDIR "!\\"
#define LUA_PATH_DEFAULT \
".\\?.lua;" LUA_LDIR"?.lua;" LUA_LDIR"?\\init.lua;" \
LUA_CDIR"?.lua;" LUA_CDIR"?\\init.lua"
#define LUA_CPATH_DEFAULT \
".\\?.dll;" LUA_CDIR"?.dll;" LUA_CDIR"loadall.dll"
#else
#define LUA_ROOT "/usr/local/"
#define LUA_LDIR LUA_ROOT "share/lua/5.1/"
#define LUA_CDIR LUA_ROOT "lib/lua/5.1/"
#define LUA_PATH_DEFAULT \
"./?.lua;" LUA_LDIR"?.lua;" LUA_LDIR"?/init.lua;" \
LUA_CDIR"?.lua;" LUA_CDIR"?/init.lua"
#define LUA_CPATH_DEFAULT \
"./?.so;" LUA_CDIR"?.so;" LUA_CDIR"loadall.so"
#endif
/*
@@ LUA_DIRSEP is the directory separator (for submodules).
** CHANGE it if your machine does not use "/" as the directory separator
** and is not Windows. (On Windows Lua automatically uses "\".)
*/
#if defined(_WIN32)
#define LUA_DIRSEP "\\"
#else
#define LUA_DIRSEP "/"
#endif
/*
@@ LUA_PATHSEP is the character that separates templates in a path.
@@ LUA_PATH_MARK is the string that marks the substitution points in a
@* template.
@@ LUA_EXECDIR in a Windows path is replaced by the executable's
@* directory.
@@ LUA_IGMARK is a mark to ignore all before it when bulding the
@* luaopen_ function name.
** CHANGE them if for some reason your system cannot use those
** characters. (E.g., if one of those characters is a common character
** in file/directory names.) Probably you do not need to change them.
*/
#define LUA_PATHSEP ";"
#define LUA_PATH_MARK "?"
#define LUA_EXECDIR "!"
#define LUA_IGMARK "-"
/*
@@ LUA_INTEGER is the integral type used by lua_pushinteger/lua_tointeger.
** CHANGE that if ptrdiff_t is not adequate on your machine. (On most
** machines, ptrdiff_t gives a good choice between int or long.)
*/
#define LUA_INTEGER ptrdiff_t
/*
@@ LUA_API is a mark for all core API functions.
@@ LUALIB_API is a mark for all standard library functions.
** CHANGE them if you need to define those functions in some special way.
** For instance, if you want to create one Windows DLL with the core and
** the libraries, you may want to use the following definition (define
** LUA_BUILD_AS_DLL to get it).
*/
#if defined(LUA_BUILD_AS_DLL)
#if defined(LUA_CORE) || defined(LUA_LIB)
#define LUA_API __declspec(dllexport)
#else
#define LUA_API __declspec(dllimport)
#endif
#else
#if __GNUC__ >= 4
#define LUA_API __attribute__ ((visibility ("default")))
#else
#define LUA_API
#endif
#endif
/* more often than not the libs go together with the core */
#define LUALIB_API LUA_API
/*
@@ LUAI_FUNC is a mark for all extern functions that are not to be
@* exported to outside modules.
@@ LUAI_DATA is a mark for all extern (const) variables that are not to
@* be exported to outside modules.
** CHANGE them if you need to mark them in some special way. Elf/gcc
** (versions 3.2 and later) mark them as "hidden" to optimize access
** when Lua is compiled as a shared library.
*/
#if defined(luaall_c)
#define LUAI_FUNC static
#define LUAI_DATA /* empty */
#elif defined(__GNUC__) && ((__GNUC__*100 + __GNUC_MINOR__) >= 302) && \
defined(__ELF__)
#define LUAI_FUNC __attribute__((visibility("hidden"))) extern
#define LUAI_DATA LUAI_FUNC
#else
#define LUAI_FUNC extern
#define LUAI_DATA extern
#endif
/*
@@ LUA_QL describes how error messages quote program elements.
** CHANGE it if you want a different appearance.
*/
#define LUA_QL(x) "'" x "'"
#define LUA_QS LUA_QL("%s")
/*
@@ LUA_IDSIZE gives the maximum size for the description of the source
@* of a function in debug information.
** CHANGE it if you want a different size.
*/
#define LUA_IDSIZE 60
/*
** {==================================================================
** Stand-alone configuration
** ===================================================================
*/
#if defined(lua_c) || defined(luaall_c)
/*
@@ lua_stdin_is_tty detects whether the standard input is a 'tty' (that
@* is, whether we're running lua interactively).
** CHANGE it if you have a better definition for non-POSIX/non-Windows
** systems.
*/
#if defined(LUA_USE_ISATTY)
#include <unistd.h>
#define lua_stdin_is_tty() isatty(0)
#elif defined(LUA_WIN)
#include <io.h>
#include <stdio.h>
#define lua_stdin_is_tty() _isatty(_fileno(stdin))
#else
#define lua_stdin_is_tty() 1 /* assume stdin is a tty */
#endif
/*
@@ LUA_PROMPT is the default prompt used by stand-alone Lua.
@@ LUA_PROMPT2 is the default continuation prompt used by stand-alone Lua.
** CHANGE them if you want different prompts. (You can also change the
** prompts dynamically, assigning to globals _PROMPT/_PROMPT2.)
*/
#define LUA_PROMPT "> "
#define LUA_PROMPT2 ">> "
/*
@@ LUA_PROGNAME is the default name for the stand-alone Lua program.
** CHANGE it if your stand-alone interpreter has a different name and
** your system is not able to detect that name automatically.
*/
#define LUA_PROGNAME "lua"
/*
@@ LUA_MAXINPUT is the maximum length for an input line in the
@* stand-alone interpreter.
** CHANGE it if you need longer lines.
*/
#define LUA_MAXINPUT 512
/*
@@ lua_readline defines how to show a prompt and then read a line from
@* the standard input.
@@ lua_saveline defines how to "save" a read line in a "history".
@@ lua_freeline defines how to free a line read by lua_readline.
** CHANGE them if you want to improve this functionality (e.g., by using
** GNU readline and history facilities).
*/
#if defined(LUA_USE_READLINE)
#include <stdio.h>
#include <readline/readline.h>
#include <readline/history.h>
#define lua_readline(L,b,p) ((void)L, ((b)=readline(p)) != NULL)
#define lua_saveline(L,idx) \
if (lua_strlen(L,idx) > 0) /* non-empty line? */ \
add_history(lua_tostring(L, idx)); /* add it to history */
#define lua_freeline(L,b) ((void)L, free(b))
#else
#define lua_readline(L,b,p) \
((void)L, fputs(p, stdout), fflush(stdout), /* show prompt */ \
fgets(b, LUA_MAXINPUT, stdin) != NULL) /* get line */
#define lua_saveline(L,idx) { (void)L; (void)idx; }
#define lua_freeline(L,b) { (void)L; (void)b; }
#endif
#endif
/* }================================================================== */
/*
@@ LUAI_GCPAUSE defines the default pause between garbage-collector cycles
@* as a percentage.
** CHANGE it if you want the GC to run faster or slower (higher values
** mean larger pauses which mean slower collection.) You can also change
** this value dynamically.
*/
#define LUAI_GCPAUSE 200 /* 200% (wait memory to double before next GC) */
/*
@@ LUAI_GCMUL defines the default speed of garbage collection relative to
@* memory allocation as a percentage.
** CHANGE it if you want to change the granularity of the garbage
** collection. (Higher values mean coarser collections. 0 represents
** infinity, where each step performs a full collection.) You can also
** change this value dynamically.
*/
#define LUAI_GCMUL 200 /* GC runs 'twice the speed' of memory allocation */
/*
@@ LUA_COMPAT_GETN controls compatibility with old getn behavior.
** CHANGE it (define it) if you want exact compatibility with the
** behavior of setn/getn in Lua 5.0.
*/
#undef LUA_COMPAT_GETN
/*
@@ LUA_COMPAT_LOADLIB controls compatibility about global loadlib.
** CHANGE it to undefined as soon as you do not need a global 'loadlib'
** function (the function is still available as 'package.loadlib').
*/
#undef LUA_COMPAT_LOADLIB
/*
@@ LUA_COMPAT_VARARG controls compatibility with old vararg feature.
** CHANGE it to undefined as soon as your programs use only '...' to
** access vararg parameters (instead of the old 'arg' table).
*/
#define LUA_COMPAT_VARARG
/*
@@ LUA_COMPAT_MOD controls compatibility with old math.mod function.
** CHANGE it to undefined as soon as your programs use 'math.fmod' or
** the new '%' operator instead of 'math.mod'.
*/
#define LUA_COMPAT_MOD
/*
@@ LUA_COMPAT_LSTR controls compatibility with old long string nesting
@* facility.
** CHANGE it to 2 if you want the old behaviour, or undefine it to turn
** off the advisory error when nesting [[...]].
*/
#define LUA_COMPAT_LSTR 1
/*
@@ LUA_COMPAT_GFIND controls compatibility with old 'string.gfind' name.
** CHANGE it to undefined as soon as you rename 'string.gfind' to
** 'string.gmatch'.
*/
#define LUA_COMPAT_GFIND
/*
@@ LUA_COMPAT_OPENLIB controls compatibility with old 'luaL_openlib'
@* behavior.
** CHANGE it to undefined as soon as you replace to 'luaL_register'
** your uses of 'luaL_openlib'
*/
#define LUA_COMPAT_OPENLIB
/*
@@ luai_apicheck is the assert macro used by the Lua-C API.
** CHANGE luai_apicheck if you want Lua to perform some checks in the
** parameters it gets from API calls. This may slow down the interpreter
** a bit, but may be quite useful when debugging C code that interfaces
** with Lua. A useful redefinition is to use assert.h.
*/
#if defined(LUA_USE_APICHECK)
#include <assert.h>
#define luai_apicheck(L,o) { (void)L; assert(o); }
#else
#define luai_apicheck(L,o) { (void)L; }
#endif
/*
@@ LUAI_BITSINT defines the number of bits in an int.
** CHANGE here if Lua cannot automatically detect the number of bits of
** your machine. Probably you do not need to change this.
*/
/* avoid overflows in comparison */
#if INT_MAX-20 < 32760
#define LUAI_BITSINT 16
#elif INT_MAX > 2147483640L
/* int has at least 32 bits */
#define LUAI_BITSINT 32
#else
#error "you must define LUA_BITSINT with number of bits in an integer"
#endif
/*
@@ LUAI_UINT32 is an unsigned integer with at least 32 bits.
@@ LUAI_INT32 is an signed integer with at least 32 bits.
@@ LUAI_UMEM is an unsigned integer big enough to count the total
@* memory used by Lua.
@@ LUAI_MEM is a signed integer big enough to count the total memory
@* used by Lua.
** CHANGE here if for some weird reason the default definitions are not
** good enough for your machine. (The definitions in the 'else'
** part always works, but may waste space on machines with 64-bit
** longs.) Probably you do not need to change this.
*/
#if LUAI_BITSINT >= 32
#define LUAI_UINT32 unsigned int
#define LUAI_INT32 int
#define LUAI_MAXINT32 INT_MAX
#define LUAI_UMEM size_t
#define LUAI_MEM ptrdiff_t
#else
/* 16-bit ints */
#define LUAI_UINT32 unsigned long
#define LUAI_INT32 long
#define LUAI_MAXINT32 LONG_MAX
#define LUAI_UMEM unsigned long
#define LUAI_MEM long
#endif
/*
@@ LUAI_MAXCALLS limits the number of nested calls.
** CHANGE it if you need really deep recursive calls. This limit is
** arbitrary; its only purpose is to stop infinite recursion before
** exhausting memory.
*/
#define LUAI_MAXCALLS 20000
/*
@@ LUAI_MAXCSTACK limits the number of Lua stack slots that a C function
@* can use.
** CHANGE it if you need lots of (Lua) stack space for your C
** functions. This limit is arbitrary; its only purpose is to stop C
** functions to consume unlimited stack space. (must be smaller than
** -LUA_REGISTRYINDEX)
*/
#define LUAI_MAXCSTACK 8000
/*
** {==================================================================
** CHANGE (to smaller values) the following definitions if your system
** has a small C stack. (Or you may want to change them to larger
** values if your system has a large C stack and these limits are
** too rigid for you.) Some of these constants control the size of
** stack-allocated arrays used by the compiler or the interpreter, while
** others limit the maximum number of recursive calls that the compiler
** or the interpreter can perform. Values too large may cause a C stack
** overflow for some forms of deep constructs.
** ===================================================================
*/
/*
@@ LUAI_MAXCCALLS is the maximum depth for nested C calls (short) and
@* syntactical nested non-terminals in a program.
*/
#define LUAI_MAXCCALLS 200
/*
@@ LUAI_MAXVARS is the maximum number of local variables per function
@* (must be smaller than 250).
*/
#define LUAI_MAXVARS 200
/*
@@ LUAI_MAXUPVALUES is the maximum number of upvalues per function
@* (must be smaller than 250).
*/
#define LUAI_MAXUPVALUES 60
/*
@@ LUAL_BUFFERSIZE is the buffer size used by the lauxlib buffer system.
*/
#define LUAL_BUFFERSIZE BUFSIZ
/* }================================================================== */
/*
** {==================================================================
@@ LUA_NUMBER is the type of numbers in Lua.
** CHANGE the following definitions only if you want to build Lua
** with a number type different from double. You may also need to
** change lua_number2int & lua_number2integer.
** ===================================================================
*/
#define LUA_NUMBER_DOUBLE
#define LUA_NUMBER double
/*
@@ LUAI_UACNUMBER is the result of an 'usual argument conversion'
@* over a number.
*/
#define LUAI_UACNUMBER double
/*
@@ LUA_NUMBER_SCAN is the format for reading numbers.
@@ LUA_NUMBER_FMT is the format for writing numbers.
@@ lua_number2str converts a number to a string.
@@ LUAI_MAXNUMBER2STR is maximum size of previous conversion.
@@ lua_str2number converts a string to a number.
*/
#define LUA_NUMBER_SCAN "%lf"
#define LUA_NUMBER_FMT "%.14g"
#define lua_number2str(s,n) sprintf((s), LUA_NUMBER_FMT, (n))
#define LUAI_MAXNUMBER2STR 32 /* 16 digits, sign, point, and \0 */
#define lua_str2number(s,p) strtod((s), (p))
/*
@@ The luai_num* macros define the primitive operations over numbers.
*/
#if defined(LUA_CORE)
#include <math.h>
#define luai_numadd(a,b) ((a)+(b))
#define luai_numsub(a,b) ((a)-(b))
#define luai_nummul(a,b) ((a)*(b))
#define luai_numdiv(a,b) ((a)/(b))
#define luai_nummod(a,b) ((a) - floor((a)/(b))*(b))
#define luai_numpow(a,b) (pow(a,b))
#define luai_numunm(a) (-(a))
#define luai_numeq(a,b) ((a)==(b))
#define luai_numlt(a,b) ((a)<(b))
#define luai_numle(a,b) ((a)<=(b))
#define luai_numisnan(a) (!luai_numeq((a), (a)))
#endif
/*
@@ lua_number2int is a macro to convert lua_Number to int.
@@ lua_number2integer is a macro to convert lua_Number to lua_Integer.
** CHANGE them if you know a faster way to convert a lua_Number to
** int (with any rounding method and without throwing errors) in your
** system. In Pentium machines, a naive typecast from double to int
** in C is extremely slow, so any alternative is worth trying.
*/
/* On a Pentium, resort to a trick */
#if defined(LUA_NUMBER_DOUBLE) && !defined(LUA_ANSI) && !defined(__SSE2__) && \
(defined(__i386) || defined (_M_IX86) || defined(__i386__))
/* On a Microsoft compiler, use assembler */
#if defined(_MSC_VER)
#define lua_number2int(i,d) __asm fld d __asm fistp i
#define lua_number2integer(i,n) lua_number2int(i, n)
/* the next trick should work on any Pentium, but sometimes clashes
with a DirectX idiosyncrasy */
#else
union luai_Cast { double l_d; long l_l; };
#define lua_number2int(i,d) \
{ volatile union luai_Cast u; u.l_d = (d) + 6755399441055744.0; (i) = u.l_l; }
#define lua_number2integer(i,n) lua_number2int(i, n)
#endif
/* this option always works, but may be slow */
#else
#define lua_number2int(i,d) ((i)=(int)(d))
#define lua_number2integer(i,d) ((i)=(lua_Integer)(d))
#endif
/* }================================================================== */
/*
@@ LUAI_USER_ALIGNMENT_T is a type that requires maximum alignment.
** CHANGE it if your system requires alignments larger than double. (For
** instance, if your system supports long doubles and they must be
** aligned in 16-byte boundaries, then you should add long double in the
** union.) Probably you do not need to change this.
*/
#define LUAI_USER_ALIGNMENT_T union { double u; void *s; long l; }
/*
@@ LUAI_THROW/LUAI_TRY define how Lua does exception handling.
** CHANGE them if you prefer to use longjmp/setjmp even with C++
** or if want/don't to use _longjmp/_setjmp instead of regular
** longjmp/setjmp. By default, Lua handles errors with exceptions when
** compiling as C++ code, with _longjmp/_setjmp when asked to use them,
** and with longjmp/setjmp otherwise.
*/
#if defined(__cplusplus)
/* C++ exceptions */
#define LUAI_THROW(L,c) throw(c)
#define LUAI_TRY(L,c,a) try { a } catch(...) \
{ if ((c)->status == 0) (c)->status = -1; }
#define luai_jmpbuf int /* dummy variable */
#elif defined(LUA_USE_ULONGJMP)
/* in Unix, try _longjmp/_setjmp (more efficient) */
#define LUAI_THROW(L,c) _longjmp((c)->b, 1)
#define LUAI_TRY(L,c,a) if (_setjmp((c)->b) == 0) { a }
#define luai_jmpbuf jmp_buf
#else
/* default handling with long jumps */
#define LUAI_THROW(L,c) longjmp((c)->b, 1)
#define LUAI_TRY(L,c,a) if (setjmp((c)->b) == 0) { a }
#define luai_jmpbuf jmp_buf
#endif
/*
@@ LUA_MAXCAPTURES is the maximum number of captures that a pattern
@* can do during pattern-matching.
** CHANGE it if you need more captures. This limit is arbitrary.
*/
#define LUA_MAXCAPTURES 32
/*
@@ lua_tmpnam is the function that the OS library uses to create a
@* temporary name.
@@ LUA_TMPNAMBUFSIZE is the maximum size of a name created by lua_tmpnam.
** CHANGE them if you have an alternative to tmpnam (which is considered
** insecure) or if you want the original tmpnam anyway. By default, Lua
** uses tmpnam except when POSIX is available, where it uses mkstemp.
*/
#if defined(loslib_c) || defined(luaall_c)
#if defined(LUA_USE_MKSTEMP)
#include <unistd.h>
#define LUA_TMPNAMBUFSIZE 32
#define lua_tmpnam(b,e) { \
strcpy(b, "/tmp/lua_XXXXXX"); \
e = mkstemp(b); \
if (e != -1) close(e); \
e = (e == -1); }
#else
#define LUA_TMPNAMBUFSIZE L_tmpnam
#define lua_tmpnam(b,e) { e = (tmpnam(b) == NULL); }
#endif
#endif
/*
@@ lua_popen spawns a new process connected to the current one through
@* the file streams.
** CHANGE it if you have a way to implement it in your system.
*/
#if defined(LUA_USE_POPEN)
#define lua_popen(L,c,m) ((void)L, fflush(NULL), popen(c,m))
#define lua_pclose(L,file) ((void)L, (pclose(file) != -1))
#elif defined(LUA_WIN)
#define lua_popen(L,c,m) ((void)L, _popen(c,m))
#define lua_pclose(L,file) ((void)L, (_pclose(file) != -1))
#else
#define lua_popen(L,c,m) ((void)((void)c, m), \
luaL_error(L, LUA_QL("popen") " not supported"), (FILE*)0)
#define lua_pclose(L,file) ((void)((void)L, file), 0)
#endif
/*
@@ LUA_DL_* define which dynamic-library system Lua should use.
** CHANGE here if Lua has problems choosing the appropriate
** dynamic-library system for your platform (either Windows' DLL, Mac's
** dyld, or Unix's dlopen). If your system is some kind of Unix, there
** is a good chance that it has dlopen, so LUA_DL_DLOPEN will work for
** it. To use dlopen you also need to adapt the src/Makefile (probably
** adding -ldl to the linker options), so Lua does not select it
** automatically. (When you change the makefile to add -ldl, you must
** also add -DLUA_USE_DLOPEN.)
** If you do not want any kind of dynamic library, undefine all these
** options.
** By default, _WIN32 gets LUA_DL_DLL and MAC OS X gets LUA_DL_DYLD.
*/
#if defined(LUA_USE_DLOPEN)
#define LUA_DL_DLOPEN
#endif
#if defined(LUA_WIN)
#define LUA_DL_DLL
#endif
/*
@@ LUAI_EXTRASPACE allows you to add user-specific data in a lua_State
@* (the data goes just *before* the lua_State pointer).
** CHANGE (define) this if you really need that. This value must be
** a multiple of the maximum alignment required for your machine.
*/
#define LUAI_EXTRASPACE 0
/*
@@ luai_userstate* allow user-specific actions on threads.
** CHANGE them if you defined LUAI_EXTRASPACE and need to do something
** extra when a thread is created/deleted/resumed/yielded.
*/
#define luai_userstateopen(L) ((void)L)
#define luai_userstateclose(L) ((void)L)
#define luai_userstatethread(L,L1) ((void)L)
#define luai_userstatefree(L) ((void)L)
#define luai_userstateresume(L,n) ((void)L)
#define luai_userstateyield(L,n) ((void)L)
/*
@@ LUA_INTFRMLEN is the length modifier for integer conversions
@* in 'string.format'.
@@ LUA_INTFRM_T is the integer type correspoding to the previous length
@* modifier.
** CHANGE them if your system supports long long or does not support long.
*/
#if defined(LUA_USELONGLONG)
#define LUA_INTFRMLEN "ll"
#define LUA_INTFRM_T long long
#else
#define LUA_INTFRMLEN "l"
#define LUA_INTFRM_T long
#endif
/* =================================================================== */
/*
** Local configuration. You can use this space to add your redefinitions
** without modifying the main part of the file.
*/
#endif
================================================
FILE: include/luasandbox/lualib.h
================================================
/*
** $Id: lualib.h,v 1.36.1.1 2007/12/27 13:02:25 roberto Exp $
** Lua standard libraries
** See Copyright Notice in lua.h
*/
#ifndef lualib_h
#define lualib_h
#include "lua.h"
/* Key to file-handle type */
#define LUA_FILEHANDLE "FILE*"
#define LUA_BASELIBNAME ""
LUALIB_API int (luaopen_base) (lua_State *L);
#define LUA_COLIBNAME "coroutine"
LUALIB_API int (luaopen_coroutine) (lua_State *L);
#define LUA_TABLIBNAME "table"
LUALIB_API int (luaopen_table) (lua_State *L);
#define LUA_IOLIBNAME "io"
LUALIB_API int (luaopen_io) (lua_State *L);
#define LUA_OSLIBNAME "os"
LUALIB_API int (luaopen_os) (lua_State *L);
#define LUA_STRLIBNAME "string"
LUALIB_API int (luaopen_string) (lua_State *L);
#define LUA_MATHLIBNAME "math"
LUALIB_API int (luaopen_math) (lua_State *L);
#define LUA_DBLIBNAME "debug"
LUALIB_API int (luaopen_debug) (lua_State *L);
#define LUA_LOADLIBNAME "package"
LUALIB_API int (luaopen_package) (lua_State *L);
/* open all previous libraries */
LUALIB_API void (luaL_openlibs) (lua_State *L);
#ifndef lua_assert
#define lua_assert(x) ((void)0)
#endif
#endif
================================================
FILE: include/luasandbox/test/mu_test.h
================================================
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/** @brief Unit test macros and global data @file */
#ifndef luasandbox_test_mu_test_h_
#define luasandbox_test_mu_test_h_
#include <stdio.h>
#ifdef _WIN32
#if _MSC_VER < 1900
#define snprintf _snprintf
#endif
#endif
#if defined(_MSC_VER)
#define PRIuSIZE "Iu"
#else
#define PRIuSIZE "zu"
#endif
#define MU_ERR_LEN 1024
#define mu_assert(cond, ...) \
do { \
if (!(cond)) { \
int cnt = snprintf(mu_err, MU_ERR_LEN, "line: %d (%s) ", __LINE__, #cond); \
if (cnt > 0 && cnt < MU_ERR_LEN) { \
cnt = snprintf(mu_err+cnt, MU_ERR_LEN-cnt, __VA_ARGS__); \
if (cnt > 0 && cnt < MU_ERR_LEN) { \
return mu_err; \
} \
} \
mu_err[MU_ERR_LEN - 1] = 0; \
return mu_err; \
} \
} while (0)
#define mu_assert_rv(rv, fn) \
do { \
int result = fn; \
if (rv != result) { \
int cnt = snprintf(mu_err, MU_ERR_LEN, "line: %d %s expected: %d " \
" received: %d", __LINE__, #fn, rv, result); \
if (cnt > 0 && cnt < MU_ERR_LEN) { \
return mu_err; \
} \
mu_err[MU_ERR_LEN - 1] = 0; \
return mu_err; \
} \
} while (0)
#define mu_run_test(test) \
do { \
char *message = test(); \
mu_tests_run++; \
if (message) \
return message; \
} while (0)
int mu_tests_run = 0;
char mu_err[MU_ERR_LEN] = { 0 };
#endif
================================================
FILE: include/luasandbox/test/sandbox.h
================================================
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/** Test interface for the generic lua sandbox @file */
#ifndef luasandbox_test_sandbox_h_
#define luasandbox_test_sandbox_h_
#include <stddef.h>
#include "../../luasandbox.h"
#include "../error.h"
#ifdef _WIN32
#ifdef luasandboxtest_EXPORTS
#define LSB_TEST_EXPORT __declspec(dllexport)
#else
#define LSB_TEST_EXPORT __declspec(dllimport)
#endif
#else
#if __GNUC__ >= 4
#define LSB_TEST_EXPORT __attribute__ ((visibility ("default")))
#else
#define LSB_TEST_EXPORT
#endif
#endif
#ifdef __cplusplus
extern "C"
{
#endif
#include "../lua.h"
/**
* Global variable to store the test output
*
*/
LSB_TEST_EXPORT extern const char *lsb_test_output;
/**
* Global variable storing the length of the current test output string
*
*/
LSB_TEST_EXPORT extern size_t lsb_test_output_len;
/**
* Generaly purpose stderr logger
*
*/
LSB_TEST_EXPORT extern lsb_logger lsb_test_logger;
/**
* Function to emulate processing data
*
* @param lsb Pointer to a lua sandbox
* @param tc Test case number to control how the sandbox state is updated
*
* @return LSB_TEST_EXPORT int Status value returned from the sandbox
*/
LSB_TEST_EXPORT int lsb_test_process(lsb_lua_sandbox *lsb, double tc);
/**
* Function to emulate outputting summary data
*
* @param lsb Pointer to a lua sandbox
* @param tc Test case number to control what data is returned and how the state
* is updated
*
* @return LSB_TEST_EXPORT int 0 on success, 1 on failure
*/
LSB_TEST_EXPORT int lsb_test_report(lsb_lua_sandbox *lsb, double tc);
/**
* Callback for collecting output, places a pointer to the results in the global
* lsb_test_output variable )not thread safe)
*
* @param lua Lua state
*
* @return LSB_TEST_EXPORT int 0 or lua_error
*/
LSB_TEST_EXPORT int lsb_test_write_output(lua_State *lua);
#ifdef __cplusplus
}
#endif
#endif
================================================
FILE: include/luasandbox/util/heka_message.h
================================================
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/** Heka message representation @file */
#ifndef luasandbox_util_heka_message_h_
#define luasandbox_util_heka_message_h_
#include <stdbool.h>
#include <stddef.h>
#include "input_buffer.h"
#include "output_buffer.h"
#include "string.h"
#include "util.h"
#define LSB_UUID_SIZE 16
#define LSB_UUID_STR_SIZE 36
#define LSB_HDR_FRAME_SIZE 3
#define LSB_MIN_HDR_SIZE 14
#define LSB_MAX_HDR_SIZE (255 + LSB_HDR_FRAME_SIZE)
#define LSB_UUID "Uuid"
#define LSB_TIMESTAMP "Timestamp"
#define LSB_TYPE "Type"
#define LSB_LOGGER "Logger"
#define LSB_SEVERITY "Severity"
#define LSB_PAYLOAD "Payload"
#define LSB_ENV_VERSION "EnvVersion"
#define LSB_PID "Pid"
#define LSB_HOSTNAME "Hostname"
#define LSB_FIELDS "Fields"
#define LSB_RAW "raw"
#define LSB_FRAMED "framed"
#define LSB_SIZE "size"
typedef enum {
LSB_PB_UUID = 1,
LSB_PB_TIMESTAMP = 2,
LSB_PB_TYPE = 3,
LSB_PB_LOGGER = 4,
LSB_PB_SEVERITY = 5,
LSB_PB_PAYLOAD = 6,
LSB_PB_ENV_VERSION = 7,
LSB_PB_PID = 8,
LSB_PB_HOSTNAME = 9,
LSB_PB_FIELDS = 10
} lsb_pb_message;
typedef enum {
LSB_PB_NAME = 1,
LSB_PB_VALUE_TYPE = 2,
LSB_PB_REPRESENTATION = 3,
LSB_PB_VALUE_STRING = 4,
LSB_PB_VALUE_BYTES = 5,
LSB_PB_VALUE_INTEGER = 6,
LSB_PB_VALUE_DOUBLE = 7,
LSB_PB_VALUE_BOOL = 8
} lsb_pb_field;
typedef enum {
LSB_PB_STRING = 0,
LSB_PB_BYTES = 1,
LSB_PB_INTEGER = 2,
LSB_PB_DOUBLE = 3,
LSB_PB_BOOL = 4
} lsb_pb_value_types;
typedef struct lsb_heka_field
{
lsb_const_string name;
lsb_const_string representation;
lsb_const_string value;
lsb_pb_value_types value_type;
} lsb_heka_field;
typedef struct lsb_heka_message
{
lsb_const_string raw;
lsb_const_string uuid;
lsb_const_string type;
lsb_const_string logger;
lsb_const_string payload;
lsb_const_string env_version;
lsb_const_string hostname;
lsb_heka_field *fields;
long long timestamp;
int severity;
int pid;
int fields_len;
int fields_size;
} lsb_heka_message;
typedef enum {
LSB_READ_NIL,
LSB_READ_NUMERIC,
LSB_READ_STRING,
LSB_READ_BOOL
} lsb_read_type;
typedef struct {
union
{
lsb_const_string s;
double d;
} u;
lsb_read_type type;
} lsb_read_value;
#ifdef __cplusplus
extern "C"
{
#endif
/**
* Zero the structure and allocate memory for at least 'size' fields
*
* @param m Heka message structure
* @param num_fields Preallocated number of fields (must be >0)
*
* @return lsb_err_value NULL on success error message on failure
*
*/
LSB_UTIL_EXPORT lsb_err_value
lsb_init_heka_message(lsb_heka_message *m, int num_fields);
/**
* Frees the memory allocated for the message fields
*
* @param m Heka message structure
*
*/
LSB_UTIL_EXPORT void lsb_free_heka_message(lsb_heka_message *m);
/**
* Resets the message headers and fields zeroing the allocated memory
*
* @param m Heka message structure
*
*/
LSB_UTIL_EXPORT void lsb_clear_heka_message(lsb_heka_message *m);
/**
* Locates a framed Heka message in an input buffer
*
* @param m Heka message structure
* @param ib Input buffer
* @param decode True if the framed message should be protobuf decoded
* @param discarded_bytes Used to track stream corruption
* @param logger Logger structure (can be set to NULL to disable logging)
*
* @return bool True on success
*/
LSB_UTIL_EXPORT bool lsb_find_heka_message(lsb_heka_message *m,
lsb_input_buffer *ib,
bool decode,
size_t *discarded_bytes,
lsb_logger *logger);
/**
* Decodes an array of bytes into a Heka message. The message structure is
* cleared before decoding.
*
* @param m Heka message structure
* @param buf Protobuf array
* @param len Length of the protobuf array
* @param logger Logger structure (can be set to NULL to disable logging)
*
* @return bool True on success
*
*/
LSB_UTIL_EXPORT bool lsb_decode_heka_message(lsb_heka_message *m,
const char *buf,
size_t len,
lsb_logger *logger);
/**
* Reads a dynamic field from the Heka message
*
* @param m Heka meassage structure
* @param name Field name
* @param fi Field index
* @param ai Array index into the field
* @param val Value structure to be populated by the read
*
* @return bool True on success
*/
LSB_UTIL_EXPORT bool lsb_read_heka_field(const lsb_heka_message *m,
lsb_const_string *name,
int fi,
int ai,
lsb_read_value *val);
/**
* Writes a binary UUID to the output buffer
*
* @param ob Pointer to the output data buffer.
* @param uuid Uuid string to output (can be NULL, binary, human readable UUID)
* @param len Length of UUID (16 or 36 anything else will cause a new UUID to be
* created).
*
* @return lsb_err_value NULL on success error message on failure
*/
LSB_UTIL_EXPORT lsb_err_value
lsb_write_heka_uuid(lsb_output_buffer *ob, const char *uuid, size_t len);
/**
* Writes the Heka framing header to the specified buffer.
*
* @param buf Buffer to write the header to must be at least LSB_MIN_HDR_SIZE
* size.
* @param len Length of the message to encode into the header
*
* @return LSB_UTIL_EXPORT size_t
*/
LSB_UTIL_EXPORT size_t lsb_write_heka_header(char *buf, size_t len);
#ifdef __cplusplus
}
#endif
#endif
================================================
FILE: include/luasandbox/util/heka_message_matcher.h
================================================
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/** Hindsight/Heka message matcher @file */
#ifndef luasandbox_util_heka_message_matcher_h_
#define luasandbox_util_heka_message_matcher_h_
#include <stdbool.h>
#include "heka_message.h"
typedef struct lsb_message_matcher lsb_message_matcher;
#ifdef __cplusplus
extern "C"
{
#endif
/**
* Parses a message matcher expression and returns the matcher
*
* @param exp Expression to parse into a matcher
*
* @return lsb_message_matcher*
*/
LSB_UTIL_EXPORT lsb_message_matcher*
lsb_create_message_matcher(const char *exp);
/**
* Frees all memory associated with a message matcher instance
*
* @param mm Message matcher
*/
LSB_UTIL_EXPORT void lsb_destroy_message_matcher(lsb_message_matcher *mm);
/**
* Evaluates the message matcher against the provided message
*
* @param mm Message matcher
* @param m Heka message
*
* @return bool True if the message is a match
*/
LSB_UTIL_EXPORT bool
lsb_eval_message_matcher(lsb_message_matcher *mm, lsb_heka_message *m);
#ifdef __cplusplus
}
#endif
#endif
================================================
FILE: include/luasandbox/util/input_buffer.h
================================================
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/** Data stream input buffer @file */
#ifndef luasandbox_util_input_buffer_h_
#define luasandbox_util_input_buffer_h_
#include <stdbool.h>
#include <stddef.h>
#include "util.h"
typedef struct lsb_input_buffer
{
char *buf;
size_t size;
size_t maxsize;
size_t readpos;
size_t scanpos;
size_t msglen;
} lsb_input_buffer;
#ifdef __cplusplus
extern "C" {
#endif
/**
* Initialize the provided input buffer
*
* @param b Input buffer
* @param max_message_size The maximum message size the buffer will handle
* before erroring (the internal buffer will contain extra space
* for the header)
*
* @return lsb_err_value NULL on success error message on failure
*/
LSB_UTIL_EXPORT lsb_err_value
lsb_init_input_buffer(lsb_input_buffer *b, size_t max_message_size);
/**
* Frees the memory internally allocated by the buffer and resets the state
*
* @param b Input buffer
*/
LSB_UTIL_EXPORT void lsb_free_input_buffer(lsb_input_buffer *b);
/**
* Expands the input buffer (if necessary) to accomadate the requested number of
* bytes. The expansion happens in power of two increments up to the maxsize.
* The buffer never shrinks in size.
*
* @param b Input buffer
* @param len The length of the data being added to the buffer
*
* @return lsb_err_value NULL on success error message on failure
*/
LSB_UTIL_EXPORT lsb_err_value
lsb_expand_input_buffer(lsb_input_buffer *b, size_t len);
#ifdef __cplusplus
}
#endif
#endif
================================================
FILE: include/luasandbox/util/output_buffer.h
================================================
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/** Data stream output buffer @file */
#ifndef luasandbox_util_output_buffer_h_
#define luasandbox_util_output_buffer_h_
#include <stdbool.h>
#include "util.h"
#define LSB_OUTPUT_SIZE 1024
typedef struct lsb_output_buffer {
char *buf;
size_t maxsize;
size_t size;
size_t pos;
} lsb_output_buffer;
#ifdef __cplusplus
extern "C"
{
#endif
/**
* Initialize the provided input buffer
*
* @param b Output buffer
* @param max_message_size The maximum message size the buffer will handle
* before erroring
*
* @return lsb_err_value NULL on success error message on failure
*/
LSB_UTIL_EXPORT lsb_err_value
lsb_init_output_buffer(lsb_output_buffer *b, size_t max_message_size);
/**
* Frees the memory internally allocated by the buffer and resets the state
*
* @param b Output buffer
*/
LSB_UTIL_EXPORT void lsb_free_output_buffer(lsb_output_buffer *b);
/**
* Resize the output buffer when more space is needed.
*
* @param b Output buffer to resize.
* @param needed Number of additional bytes needed.
*
* @return lsb_err_value NULL on success error message on failure
*/
LSB_UTIL_EXPORT lsb_err_value lsb_expand_output_buffer(lsb_output_buffer *b,
size_t needed);
/**
* Append a character to the output buffer.
*
* @param b Pointer the b buffer.
* @param ch Character to append to the b.
*
* @return lsb_err_value NULL on success error message on failure
*/
LSB_UTIL_EXPORT lsb_err_value lsb_outputc(lsb_output_buffer *b, char ch);
/**
* Append a formatted string to the output buffer.
*
* @param b Pointer the b buffer.
* @param fmt Printf format specifier.
*
* @return lsb_err_value NULL on success error message on failure
*/
LSB_UTIL_EXPORT lsb_err_value
lsb_outputf(lsb_output_buffer *b, const char *fmt, ...);
/**
* Append a fixed string to the output buffer.
*
* @param b Pointer the b buffer.
* @param str String to append to the b.
* @param len Length of the string to append
*
* @return lsb_err_value NULL on success error message on failure
*/
LSB_UTIL_EXPORT lsb_err_value
lsb_outputs(lsb_output_buffer *b, const char *str, size_t len);
/**
* More efficient output of a double to a string. NaN/Inf check and then calls
* lsb_outputfd.
*
* @param b Pointer the output buffer.
* @param d Double value to convert to a string.
*
* @return lsb_err_value NULL on success error message on failure
*/
LSB_UTIL_EXPORT lsb_err_value lsb_outputd(lsb_output_buffer *b, double d);
/**
* More efficient output of a double to a string; no NaN or Inf outputs.
*
* @param b Pointer the output buffer.
* @param d Double value to convert to a string.
*
* @return lsb_err_value NULL on success error message on failure
*/
LSB_UTIL_EXPORT lsb_err_value lsb_outputfd(lsb_output_buffer *b, double d);
#ifdef __cplusplus
}
#endif
#endif
================================================
FILE: include/luasandbox/util/protobuf.h
================================================
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/** Generic protobuf utility functions @file */
#ifndef luasandbox_util_protobuf_h_
#define luasandbox_util_protobuf_h_
#include <stddef.h>
#include <stdbool.h>
#include "output_buffer.h"
#include "util.h"
#define LSB_MAX_VARINT_BYTES 10
typedef enum {
LSB_PB_WT_VARINT = 0,
LSB_PB_WT_FIXED64 = 1,
LSB_PB_WT_LENGTH = 2,
LSB_PB_WT_SGROUP = 3,
LSB_PB_WT_EGROUP = 4,
LSB_PB_WT_FIXED32 = 5
} lsb_pb_wire_types;
#ifdef __cplusplus
extern "C" {
#endif
/**
* Extract the tag and wiretype from a protobuf key
*
* @param p Key
* @param tag Tag Id
* @param wiretype Wiretype Id
*
* @return LSB_EXPORT const char*
*/
LSB_UTIL_EXPORT
const char* lsb_pb_read_key(const char *p, int *tag, int *wiretype);
/**
* Writes a field key (tag id/wire type) to the output buffer.
*
* @param ob Pointer to the output data buffer.
* @param tag Field identifier.
* @param wiretype Field wire type.
*
* @return lsb_err_value NULL on success error message on failure
*/
LSB_UTIL_EXPORT lsb_err_value
lsb_pb_write_key(lsb_output_buffer *ob, unsigned char tag,
unsigned char wiretype);
/**
* Reads the varint into the provided variable
*
* @param p Start of buffer
* @param e End of buffer
* @param vi Varint value
*
* @return const char* Position in the buffer after the varint
*/
LSB_UTIL_EXPORT
const char* lsb_pb_read_varint(const char *p, const char *e, long long *vi);
/**
* Outputs the varint to an existing buffer
*
* @param buf Pointer to buffer with at least LSB_MAX_VARINT_BYTES available,
* @param i Number to be encoded.
*
* @return int Number of bytes written
*/
LSB_UTIL_EXPORT int lsb_pb_output_varint(char *buf, unsigned long long i);
/**
* Writes a varint encoded number to the output buffer.
*
* @param ob Pointer to the output data buffer.
* @param i Number to be encoded.
*
* @return lsb_err_value NULL on success error message on failure
*/
LSB_UTIL_EXPORT lsb_err_value
lsb_pb_write_varint(lsb_output_buffer *ob, unsigned long long i);
/**
* Writes a bool to the output buffer.
*
* @param ob Pointer to the output data buffer.
* @param i Number to be encoded.
*
* @return lsb_err_value NULL on success error message on failure
*/
LSB_UTIL_EXPORT lsb_err_value lsb_pb_write_bool(lsb_output_buffer *ob, int i);
/**
* Writes a double to the output buffer.
*
* @param ob Pointer to the output data buffer.
* @param i Double to be encoded.
*
* @return lsb_err_value NULL on success error message on failure
*/
LSB_UTIL_EXPORT lsb_err_value
lsb_pb_write_double(lsb_output_buffer *ob, double i);
/**
* Writes a string to the output buffer.
*
* @param ob Pointer to the output data buffer.
* @param tag Field identifier.
* @param s String to output.
* @param len Length of s.
*
* @return lsb_err_value NULL on success error message on failure
*/
LSB_UTIL_EXPORT lsb_err_value
lsb_pb_write_string(lsb_output_buffer *ob, char tag, const char *s, size_t len);
/**
* Updates the field length in the output buffer once the size is known, this
* allows for single pass encoding.
*
* @param ob Pointer to the output data buffer.
* @param len_pos Position in the output buffer where the length should be
* written.
*
* @return lsb_err_value NULL on success error message on failure
*/
LSB_UTIL_EXPORT lsb_err_value
lsb_pb_update_field_length(lsb_output_buffer *ob, size_t len_pos);
#ifdef __cplusplus
}
#endif
#endif
================================================
FILE: include/luasandbox/util/running_stats.h
================================================
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/** Calculates the running count, sum, mean, variance, and standard deviation
* @file */
#ifndef lsb_util_running_stats_h_
#define lsb_util_running_stats_h_
#include "util.h"
typedef struct lsb_running_stats
{
double count;
double mean;
double sum;
} lsb_running_stats;
#ifdef __cplusplus
extern "C" {
#endif
/**
* Zeros out the stats counters
*
* @param s Stat structure to zero out
*/
LSB_UTIL_EXPORT void lsb_init_running_stats(lsb_running_stats *s);
/**
* Value to add to the running stats
*
* @param s Stat structure
* @param d Value to add
*/
LSB_UTIL_EXPORT void lsb_update_running_stats(lsb_running_stats *s, double d);
/**
* Return the standard deviation of the stats
*
* @param s Stat structure
*
* @return double Standard deviation of the stats up to this point
*/
LSB_UTIL_EXPORT double lsb_sd_running_stats(lsb_running_stats *s);
#ifdef __cplusplus
}
#endif
#endif
================================================
FILE: include/luasandbox/util/string.h
================================================
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/** Heka message string @file */
#ifndef luasandbox_util_string_h_
#define luasandbox_util_string_h_
#include "util.h"
typedef struct lsb_const_string
{
const char *s;
size_t len;
} lsb_const_string;
#ifdef __cplusplus
extern "C"
{
#endif
/**
* Initializes the struct to zero.
*
* @param s Pointer to the struct
*
*/
LSB_UTIL_EXPORT void lsb_init_const_string(lsb_const_string *s);
/**
* Lua string unescape. The returned string is always NUL terminated, but can
* contain other NULs in its body.
*
* @param d Pointer to the destination array where the content is to be
* unescaped.
* @param s C string to be unescaped
* @param dlen The length of the destination array (must be 1 byte larger than
* the source string (for inclusion of the NUL terminator). After
* successful conversion the final length of the escaped string is
* written back to this value as it may not equal strlen(d).
*
* @return char* A pointer to d or NULL on error.
*/
LSB_UTIL_EXPORT
char* lsb_lua_string_unescape(char *d, const char *s, size_t *dlen);
#ifdef __cplusplus
}
#endif
#endif
================================================
FILE: include/luasandbox/util/string_matcher.h
================================================
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/** C API for the Lua string pattern matcher @file */
#ifndef luasandbox_util_string_matcher_h_
#define luasandbox_util_string_matcher_h_
#include <stdbool.h>
#include <stddef.h>
#include "util.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* Matches a string using a Lua string match pattern
*
* @param s String to match
* @param len Length of the string
* @param p Lua match pattern
* http://www.lua.org/manual/5.1/manual.html#pdf-string.match
*
* @return bool True if the string matches the pattern
*/
LSB_UTIL_EXPORT bool lsb_string_match(const char *s, size_t len, const char *p);
/**
* Searches for a string literal within a string
*
* @param s String to search
* @param ls Length of the string
* @param p Literal match string
* @param lp Length of the match string
*
* @return bool True if the string contains the literal
*/
LSB_UTIL_EXPORT bool lsb_string_find(const char *s, size_t ls, const char *p, size_t lp);
#ifdef __cplusplus
}
#endif
#endif
================================================
FILE: include/luasandbox/util/util.h
================================================
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/** Shared types and structures @file */
#ifndef luasandbox_util_util_h_
#define luasandbox_util_util_h_
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include "../error.h"
#ifdef _WIN32
#ifdef luasandboxutil_EXPORTS
#define LSB_UTIL_EXPORT __declspec(dllexport)
#else
#define LSB_UTIL_EXPORT __declspec(dllimport)
#endif
#else
#if __GNUC__ >= 4
#define LSB_UTIL_EXPORT __attribute__ ((visibility ("default")))
#else
#define LSB_UTIL_EXPORT
#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;
/**
* Hacker's Delight - Henry S. Warren, Jr. page 48
*
* @param x
*
* @return size_t Least power of 2 greater than or equal to x
*/
LSB_UTIL_EXPORT size_t lsb_lp2(unsigned long long x);
/**
* Read a file into a string
*
* @param fn Filename to read
*
* @return char* NULL on failure otherwise a pointer to the file contents (must
* be freed by the caller).
*/
LSB_UTIL_EXPORT char* lsb_read_file(const char *fn);
/**
* Retrieves the highest resolution timer available converted to nanoseconds
*
* @return unsigned long long
*/
LSB_UTIL_EXPORT unsigned long long lsb_get_time();
/**
* Retrieves the highest resolution time since Jan 1, 1970 converted to
* nanoseconds
*
* @return unsigned long long (time_ns)
*/
LSB_UTIL_EXPORT long long lsb_get_timestamp();
/**
* Sets the timezone environment variable for the time conversion functions
*
* @param tz Timezone string (if NULL uses UTC)
*
* @return bool True if the environment variable is successfully set
*/
LSB_UTIL_EXPORT bool lsb_set_tz(const char *tz);
#ifdef __cplusplus
}
#endif
#endif
================================================
FILE: include/luasandbox.h
================================================
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/** Generic Lua sandbox for dynamic data analysis @file */
#ifndef luasandbox_h_
#define luasandbox_h_
#include "luasandbox/error.h"
#ifdef _WIN32
#ifdef luasandbox_EXPORTS
#define LSB_EXPORT __declspec(dllexport)
#else
#define LSB_EXPORT __declspec(dllimport)
#endif
#else
#if __GNUC__ >= 4
#define LSB_EXPORT __attribute__ ((visibility ("default")))
#else
#define LSB_EXPORT
#endif
#endif
#define LSB_ERROR_SIZE 256
#define LSB_SHUTTING_DOWN "shutting down"
#define LSB_CONFIG_TABLE "lsb_config"
#define LSB_THIS_PTR "lsb_this_ptr"
#define LSB_MEMORY_LIMIT "memory_limit"
#define LSB_INSTRUCTION_LIMIT "instruction_limit"
#define LSB_INPUT_LIMIT "input_limit"
#define LSB_OUTPUT_LIMIT "output_limit"
#define LSB_LOG_LEVEL "log_level"
#define LSB_LUA_PATH "path"
#define LSB_LUA_CPATH "cpath"
#define LSB_NIL_ERROR "<nil error message>"
typedef enum {
LSB_UNKNOWN = 0,
LSB_RUNNING = 1,
LSB_TERMINATED = 2,
LSB_STOP = 3
} lsb_state;
typedef enum {
LSB_US_LIMIT = 0,
LSB_US_CURRENT = 1,
LSB_US_MAXIMUM = 2,
LSB_US_MAX
} lsb_usage_stat;
typedef enum {
LSB_UT_MEMORY = 0,
LSB_UT_INSTRUCTION = 1,
LSB_UT_OUTPUT = 2,
LSB_UT_MAX
} lsb_usage_type;
typedef struct lsb_lua_sandbox lsb_lua_sandbox;
#ifdef __cplusplus
extern "C"
{
#endif
#include "luasandbox/lua.h"
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
* string.
* memory_limit = 1024*1024*1
* instruction_limit = 10000
* output_limit = 64*1024
* path = '/modules/?.lua'
* cpath = '/modules/?.so'
* remove_entries = {
* [''] =
* {'collectgarbage','coroutine','dofile','load','loadfile','loadstring',
* 'newproxy','print'},
* os = {'getenv','execute','exit','remove','rename','setlocale','tmpname'}
* }
* disable_modules = {io = 1}
*
*
* @param parent Pointer to associate the owner to this sandbox.
* @param lua_file Filename of the Lua script to run in this sandbox.
* @param cfg Lua structure defining the full sandbox restrictions (may contain
* optional host configuration options, everything is available to
* the sandbox through the read_config API.
* @param logger Struct for error reporting/debug printing (NULL to disable)
* @return lsb_lua_sandbox Sandbox pointer or NULL on failure.
*/
LSB_EXPORT lsb_lua_sandbox*
lsb_create(void *parent, const char *lua_file, const char *cfg,
lsb_logger *logger);
/**
* Initializes the Lua sandbox and loads/runs the Lua script that was specified
* in lua_create_sandbox.
*
* @param lsb Pointer to the sandbox.
* @param state_file Filename where the global data is read. Use a NULL or empty
* string for no data restoration. The global
* _PRESERVATION_VERSION variable will be examined during
* restoration; if the previous version does not match the
* current version the restoration will be aborted and the
* sandbox will start cleanly. _PRESERVATION_VERSION should be
* incremented any time an incompatible change is made to the
* global data schema. If no version is set the check will
* always succeed and a version of zero is assigned.
*
* @return lsb_err_value NULL on success error message on failure
*
*/
LSB_EXPORT lsb_err_value
lsb_init(lsb_lua_sandbox *lsb, const char *state_file);
/**
* Changes the sandbox state to LSB_STOP to allow for a clean exit. This call is
* not thread safe.
*
* @param lsb sandbox to clean stop
*
* @return
*
*/
LSB_EXPORT void lsb_stop_sandbox_clean(lsb_lua_sandbox *lsb);
/**
* Aborts the running sandbox from a different thread of execution. A "shutting
* down" Lua error message is generated.
*
* @param lsb sandbox to abort
*
* @return
*
*/
LSB_EXPORT void lsb_stop_sandbox(lsb_lua_sandbox *lsb);
/**
* Frees the memory associated with the sandbox.
*
* @param lsb Sandbox pointer to discard.
*
* @return NULL on success, pointer to an error message on failure that MUST BE
* FREED by the caller.
*/
LSB_EXPORT char* lsb_destroy(lsb_lua_sandbox *lsb);
/**
* Retrieve the sandbox usage statistics.
*
* @param lsb Pointer to the sandbox.
* @param utype Type of statistic to retrieve i.e. memory.
* @param ustat Type of statistic to retrieve i.e. current.
*
* @return size_t Count or number of bytes depending on the statistic.
*/
LSB_EXPORT size_t lsb_usage(lsb_lua_sandbox *lsb,
lsb_usage_type utype,
lsb_usage_stat ustat);
/**
* Retrieve the current sandbox status.
*
* @param lsb Pointer to the sandbox.
*
* @return lsb_state code
*/
LSB_EXPORT lsb_state lsb_get_state(lsb_lua_sandbox *lsb);
/**
* Return the last error in human readable form.
*
* @param lsb Pointer to the sandbox.
*
* @return const char* error message
*/
LSB_EXPORT const char* lsb_get_error(lsb_lua_sandbox *lsb);
/**
* Sets the last error string.
*
* @param lsb Pointer to the sandbox.
* @param err Error message.
*
* @return const char* error message
*/
LSB_EXPORT void lsb_set_error(lsb_lua_sandbox *lsb, const char *err);
/**
* Access the Lua pointer.
*
* @param lsb Pointer to the sandbox.
*
* @return lua_State* The lua_State pointer.
*/
LSB_EXPORT lua_State* lsb_get_lua(lsb_lua_sandbox *lsb);
/**
* Returns the filename of the Lua source.
*
* @param lsb Pointer to the sandbox.
*
* @return const char* filename.
*/
LSB_EXPORT const char* lsb_get_lua_file(lsb_lua_sandbox *lsb);
/**
* Access the parent pointer stored in the sandbox.
*
* @param lsb Pointer to the sandbox.
*
* @return void* The parent pointer passed to init.
*/
LSB_EXPORT void* lsb_get_parent(lsb_lua_sandbox *lsb);
/**
* Access the logger struct stored in the sandbox. The logger callback is only
* available to modules in debug mode (same as print).
*
* @param lsb Pointer to the sandbox.
*
* @return lsb_logger Pointer to the logger struct
*
*/
LSB_EXPORT const lsb_logger* lsb_get_logger(lsb_lua_sandbox *lsb);
/**
* Create a CFunction for use by the Sandbox. The Lua sandbox pointer is pushed
* to upvalue index 1.
*
* @param lsb Pointer to the sandbox.
* @param func Lua CFunction pointer.
* @param func_name Function name exposed to the Lua sandbox.
*/
LSB_EXPORT void lsb_add_function(lsb_lua_sandbox *lsb,
lua_CFunction func,
const char *func_name);
/**
* Helper function to load the Lua function and set the instruction limits
*
* @param lsb Pointer to the sandbox.
* @param func_name Name of the function to load
*
* @return lsb_err_value NULL on success error message on failure
*/
LSB_EXPORT lsb_err_value
lsb_pcall_setup(lsb_lua_sandbox *lsb, const char *func_name);
/**
* Helper function to update the statistics after the call
*
* @param lsb Pointer to the sandbox.
*/
LSB_EXPORT void lsb_pcall_teardown(lsb_lua_sandbox *lsb);
/**
* Change the sandbox state to LSB_TERMINATED due to a fatal error.
*
* @param lsb Pointer to the sandbox.
* @param err Reason for termination
*/
LSB_EXPORT void lsb_terminate(lsb_lua_sandbox *lsb, const char *err);
#ifdef __cplusplus
}
#endif
#endif
================================================
FILE: include/luasandbox_output.h
================================================
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/** @brief Lua sandbox output generation/retrieval functions @file */
#ifndef luasandbox_output_h_
#define luasandbox_output_h_
#include <stdio.h>
#include "luasandbox.h"
#ifdef __cplusplus
extern "C"
{
#endif
#include "luasandbox/lua.h"
/**
* Add a output function to the environment table. The environment table must be
* on the top of the stack. This function will receive the userdata and
* lsb_output_buffer struct as pointers on the Lua stack.
*
* lsb_output_buffer* output = (output_data*)lua_touserdata(lua, -1);
* ud_object* ud = (ud_object*)lua_touserdata(lua, -2);
*
* @param lua Pointer the Lua state.
* @param fp Function pointer to the outputter.
*
* @return int Zero on success, non-zero on failure.
*/
LSB_EXPORT void lsb_add_output_function(lua_State *lua, lua_CFunction fp);
/**
* Utility function to retrieve a user data output function
*
* @param lua
* @param index
*
* @return lua_CFunction
*/
LSB_EXPORT lua_CFunction lsb_get_output_function(lua_State *lua, int index);
/**
* Add a zero copy function to the environment table. The environment table must
* be on the top of the stack. This function will receive the userdata as a
* pointer on the Lua stack.
*
* ud_object* ud = (ud_object*)lua_touserdata(lua, -1);
*
* @param lua Pointer the Lua state.
* @param fp Function pointer to the zero copy function.
*
* @return int Number of segments (pointer and length for each)
*/
LSB_EXPORT void lsb_add_zero_copy_function(lua_State *lua, lua_CFunction fp);
/**
* Utility function to retrieve a user data zero copy function
*
* @param lua
* @param index
*
* @return lua_CFunction
*/
LSB_EXPORT lua_CFunction lsb_get_zero_copy_function(lua_State *lua, int index);
/**
* Write an array of variables on the Lua stack to the output buffer.
*
* @param lsb Pointer to the sandbox.
* @param start Lua stack index of first variable.
* @param end Lua stack index of the last variable.
* @param append 0 to overwrite the output buffer, 1 to append the output to it
*
*/
LSB_EXPORT void
lsb_output(lsb_lua_sandbox *lsb, int start, int end, int append);
/**
* Write an array of variables on the Lua stack to the output buffer. After
* adding support for coroutines we need an extra variable to specify the
* correct Lua state.
*
* @param lsb Pointer to the sandbox.
* @param lua Pointer the Lua state
* @param start Lua stack index of first variable.
* @param end Lua stack index of the last variable.
* @param append 0 to overwrite the output buffer, 1 to append the output to it
*
*/
LSB_EXPORT void
lsb_output_coroutine(lsb_lua_sandbox *lsb, lua_State *lua, int start,
int end, int append);
/**
* Retrieve the data in the output buffer and reset the buffer. The returned
* output string will remain valid until additional sandbox output is performed.
* The output should be copied if the application needs to hold onto it.
*
* @param lsb Pointer to the sandbox.
* @param len If len is not NULL, it will be set to the length of the string.
*
* @return const char* Pointer to the output buffer.
*/
LSB_EXPORT const char* lsb_get_output(lsb_lua_sandbox *lsb, size_t *len);
#ifdef __cplusplus
}
#endif
#endif
================================================
FILE: include/luasandbox_serialize.h
================================================
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/** Lua sandbox serialization @file */
#ifndef luasandbox_serialize_h_
#define luasandbox_serialize_h_
#include <stdio.h>
#include "luasandbox/util/output_buffer.h"
#include "luasandbox_output.h"
#ifdef __cplusplus
extern "C" {
#endif
#include "luasandbox/lua.h"
/**
* Add a serialization function to the environment table. The environment table
* must be on the top of the stack. This function will receive the userdata,
* fully qualified variable name, and lsb_output_buffer struct as pointers on the
* Lua stack.
*
* lsb_output_buffer* output = (output_data*)lua_touserdata(lua, -1);
* const char *key = (const char*)lua_touserdata(lua, -2);
* ud_object* ud = (ud_object*)lua_touserdata(lua, -3);
*
* @param lua Pointer the Lua state.
* @param fp Function pointer to the serializer.
*
* @return lsb_err_value NULL on success error message on failure
*/
LSB_EXPORT void
lsb_add_serialize_function(lua_State *lua, lua_CFunction fp);
/**
* Serializes a binary data to a Lua string.
*
* @param output Pointer the output buffer.
* @param src Pointer to the binary data.
* @param len Length in bytes of the data to output.
*
* @return lsb_err_value NULL on success error message on failure
*/
LSB_EXPORT lsb_err_value
lsb_serialize_binary(lsb_output_buffer *output, const void *src, size_t len);
/**
* More efficient serialization of a double to a string
*
* @param output Pointer the output buffer.
* @param d Double value to convert to a string.
*
* @return lsb_err_value NULL on success error message on failure
*/
LSB_EXPORT lsb_err_value
lsb_serialize_double(lsb_output_buffer *output, double d);
#ifdef __cplusplus
}
#endif
#endif
================================================
FILE: src/CMakeLists.txt
================================================
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
if(MSVC)
add_definitions(
-DLUA_BUILD_AS_DLL
-D_CRT_SECURE_NO_WARNINGS
)
else()
add_definitions(
-DLUA_USE_POSIX
-DLUA_USE_DLOPEN
-DLUA_USE_STRTODHEX
-DLUA_USE_LONGLONG
-DLUA_USE_GMTIME_R
)
endif()
set(LUA_SRC
lua/lapi.c
lua/lauxlib.c
lua/lbaselib.c
lua/lcode.c
lua/ldblib.c
lua/ldebug.c
lua/ldo.c
lua/ldump.c
lua/lfunc.c
lua/lgc.c
lua/linit.c
lua/liolib.c
lua/llex.c
lua/lmathlib.c
lua/lmem.c
lua/loadlib.c
lua/lobject.c
lua/lopcodes.c
lua/loslib.c
lua/lparser.c
lua/lstate.c
lua/lstring.c
lua/lstrlib.c
lua/ltable.c
lua/ltablib.c
lua/ltm.c
lua/lundump.c
lua/lvm.c
lua/lzio.c
)
set(LUA_SANDBOX_SRC
luasandbox.c
luasandbox_output.c
luasandbox_serialize.c
)
add_library(luasandbox SHARED ${LUA_SANDBOX_SRC} ${LUA_SRC})
set_target_properties(luasandbox PROPERTIES VERSION ${PROJECT_VERSION} SOVERSION 0)
target_link_libraries(luasandbox luasandboxutil ${CMAKE_DL_LIBS})
if(LIBM_LIBRARY)
target_link_libraries(luasandbox ${LIBM_LIBRARY})
endif()
install(TARGETS luasandbox DESTINATION ${CMAKE_INSTALL_LIBDIR})
add_subdirectory(util)
add_subdirectory(heka)
if(NOT WIN32) # todo need to add getopt support for Windows
add_subdirectory(cli)
endif()
add_subdirectory(test)
================================================
FILE: src/cli/CMakeLists.txt
================================================
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
add_executable(lsb_heka_cat lsb_heka_cat)
target_link_libraries(lsb_heka_cat luasandboxutil)
if(LIBM_LIBRARY)
target_link_libraries(lsb_heka_cat ${LIBM_LIBRARY})
endif()
install(TARGETS lsb_heka_cat DESTINATION ${CMAKE_INSTALL_BINDIR})
================================================
FILE: src/cli/lsb_heka_cat.c
================================================
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/** @brief lua_sandbox Heka file stream cat @file */
#include <ctype.h>
#include <limits.h>
#include <math.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include "luasandbox/util/heka_message.h"
#include "luasandbox/util/heka_message_matcher.h"
#include "luasandbox/util/input_buffer.h"
#include "luasandbox/util/protobuf.h"
#include "luasandbox/util/util.h"
typedef void (*output_function)(lsb_heka_message *msg);
static void
log_cb(void *context, const char *component, int level, const char *fmt, ...)
{
(void)context;
(void)component;
(void)level;
va_list args;
va_start(args, fmt);
vfprintf(stderr, fmt, args);
va_end(args);
fwrite("\n", 1, 1, stderr);
}
static lsb_logger logger = { .context = NULL, .cb = log_cb };
// todo this function is duplicated in util/heka_message.c
// we may want to add it to the API if it is generally useful
static const char*
read_string(int wiretype, const char *p, const char *e, lsb_const_string *s)
{
if (wiretype != LSB_PB_WT_LENGTH) {
return NULL;
}
long long vi;
p = lsb_pb_read_varint(p, e, &vi);
if (!p || vi < 0 || vi > e - p) {
return NULL;
}
s->s = p;
s->len = (size_t)vi;
return p + vi;
}
static void output_cs(const char *key, lsb_const_string *cs, bool eol)
{
if (cs->s) {
fprintf(stdout, "%s: %.*s", key, (int)cs->len, cs->s);
} else {
fprintf(stdout, "%s: <nil>", key);
}
if (eol) {
fprintf(stdout, "\n");
}
}
static void output_text(lsb_heka_message *msg)
{
static char tstr[64];
if (!msg->raw.s) return;
fprintf(stdout, ":Uuid: %02hhx%02hhx%02hhx%02hhx-%02hhx%02hhx-%02hhx%02hhx"
"-%02hhx%02hhx-%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx\n",
msg->uuid.s[0], msg->uuid.s[1], msg->uuid.s[2], msg->uuid.s[3],
msg->uuid.s[4], msg->uuid.s[5], msg->uuid.s[6], msg->uuid.s[7],
msg->uuid.s[8], msg->uuid.s[9], msg->uuid.s[10], msg->uuid.s[11],
msg->uuid.s[12], msg->uuid.s[13], msg->uuid.s[14], msg->uuid.s[15]);
fprintf(stdout, ":Timestamp: ");
time_t t = floor(msg->timestamp / 1e9);
double frac = msg->timestamp - t * 1e9;
struct tm *tms = gmtime(&t);
strftime(tstr, sizeof(tstr) - 1, "%Y-%m-%dT%H:%M:%S", tms);
fprintf(stdout, "%s.%09lldZ\n", tstr, (long long)frac);
output_cs(":Type", &msg->type, true);
output_cs(":Logger", &msg->logger, true);
fprintf(stdout, ":Severity: %d\n", msg->severity);
output_cs(":Payload", &msg->payload, true);
output_cs(":EnvVersion", &msg->env_version, true);
if (msg->pid == INT_MIN) {
fprintf(stdout, ":Pid: <nil>\n");
} else {
fprintf(stdout, ":Pid: %d\n", msg->pid);
}
output_cs(":Hostname", &msg->hostname, true);
fprintf(stdout, ":Fields:\n");
for (int i = 0; i < msg->fields_len; ++i) {
fprintf(stdout, " | name: %.*s type: %d ", (int)msg->fields[i].name.len,
msg->fields[i].name.s, msg->fields[i].value_type);
output_cs("representation", &msg->fields[i].representation, false);
fprintf(stdout, " value: ");
const char *p = msg->fields[i].value.s;
const char *e = msg->fields[i].value.s + msg->fields[i].value.len;
switch (msg->fields[i].value_type) {
case LSB_PB_STRING:
{
lsb_const_string cs;
int tag = 0;
int wiretype = 0;
while (p && p < e) {
p = lsb_pb_read_key(p, &tag, &wiretype);
p = read_string(wiretype, p, e, &cs);
if (p) {
fprintf(stdout, "%.*s", (int)cs.len, cs.s);
if (p < e) fprintf(stdout, "|");
}
}
}
break;
case LSB_PB_BYTES:
{
lsb_const_string cs;
int tag = 0;
int wiretype = 0;
while (p && p < e) {
p = lsb_pb_read_key(p, &tag, &wiretype);
p = read_string(wiretype, p, e, &cs);
if (p) {
for (size_t i = 0; i < cs.len; ++i) {
if (isprint(cs.s[i])) {
if (cs.s[i] == '\\') {
fwrite("\\\\", 2, 1, stdout);
} else {
putchar(cs.s[i]);
}
} else {
fprintf(stdout, "\\x%02hhx", (unsigned char)cs.s[i]);
}
}
if (p < e) fprintf(stdout, "|");
}
}
}
break;
case LSB_PB_INTEGER:
{
long long ll = 0;
while (p && p < e) {
p = lsb_pb_read_varint(p, e, &ll);
if (p) {
fprintf(stdout, "%lld", ll);
if (p < e) fprintf(stdout, "|");
}
}
}
break;
case LSB_PB_DOUBLE:
{
double d;
for (int i = 0; p <= (e - sizeof(double)); p += sizeof(double), ++i) {
memcpy(&d, p, sizeof(double));
if (i > 0) fprintf(stdout, "|");
fprintf(stdout, "%.17g", d);
}
}
break;
case LSB_PB_BOOL:
{
long long ll = 0;
while (p && p < e) {
p = lsb_pb_read_varint(p, e, &ll);
if (p) {
fprintf(stdout, "%s", ll == 0 ? "false" : "true");
if (p < e) fprintf(stdout, "|");
}
}
}
break;
}
fprintf(stdout, "\n");
}
fprintf(stdout, "\n");
return;
}
static void output_heka(lsb_heka_message *msg)
{
static char header[LSB_MIN_HDR_SIZE];
size_t hlen = lsb_write_heka_header(header, msg->raw.len);
if (fwrite(header, hlen, 1, stdout) != 1) {
log_cb(NULL, NULL, 0, "error outputting header");
exit(1);
}
if (fwrite(msg->raw.s, msg->raw.len, 1, stdout) != 1) {
log_cb(NULL, NULL, 0, "error outputting message");
exit(1);
}
return;
}
static size_t read_file(FILE *fh, lsb_input_buffer *ib)
{
size_t need;
if (ib->msglen) {
need = ib->msglen + (size_t)ib->buf[ib->scanpos + 1] + LSB_HDR_FRAME_SIZE
- (ib->readpos - ib->scanpos);
} else {
need = ib->scanpos + ib->size - ib->readpos;
}
if (lsb_expand_input_buffer(ib, need)) {
log_cb(NULL, NULL, 0, "buffer reallocation failed");
exit(EXIT_FAILURE);
}
size_t cnt = ib->size - ib->readpos;
size_t nread = fread(ib->buf + ib->readpos,
1,
cnt,
fh);
ib->readpos += nread;
if (cnt != nread) {
clearerr(fh);
}
return nread;
}
static int find_header(const char *cur, int clen, const char *prev, int num)
{
static int cnt = 0;
for (int i = clen - 1; i >= 0; --i) {
if (cur[i] == 0x1e) {
unsigned char hlen;
if (i + 1 < clen) {
hlen = (unsigned char)cur[i + 1];
} else {
hlen = (unsigned char)prev[0];
}
char flag;
int hend = i + 2;
if (hend < clen) {
flag = cur[hend];
} else {
flag = prev[hend - clen];
}
if (flag != 0x08) {
continue;
}
hend += hlen;
if (hend < clen) {
flag = cur[hend];
} else {
flag = prev[hend - clen];
}
if (flag == 0x1f) {
if (++cnt == num) {
return i;
}
}
}
}
return -1;
}
static void move_to_offset(FILE *fh, int num)
{
char buf[2][BUFSIZ];
memset(buf, 0, sizeof(buf));
char *cur = buf[0];
char *prev = buf[1];
char *tmp;
fseek(fh, 0, SEEK_END);
long len = ftell(fh);
if (len < 0) {
log_cb(NULL, NULL, 0, "ftell failed");
}
size_t consume = len > BUFSIZ ? BUFSIZ : len;
size_t pos = len - consume;
while (consume > 0) {
if (fseek(fh, pos, SEEK_SET)) {
log_cb(NULL, NULL, 0, "fseek failed (reading)");
break;
}
if (fread(cur, consume, 1, fh) != 1) {
log_cb(NULL, NULL, 0, "fread failed");
break;
}
int loc = find_header(cur, consume, prev, num);
if (loc >= 0) {
if (fseek(fh, -(consume - loc), SEEK_CUR)) {
log_cb(NULL, NULL, 0, "fseek failed (find position)");
}
return;
}
if (pos >= consume) {
pos -= consume;
} else {
consume = pos;
pos = 0;
}
tmp = cur;
cur = prev;
prev = tmp;
}
fseek(fh, 0, SEEK_SET);
}
int main(int argc, char **argv)
{
bool argerr = false;
bool follow = false;
bool use_stdin = false;
long num
gitextract_30bp_v8t/
├── .gitattributes
├── .gitignore
├── .travis.yml
├── CMakeLists.txt
├── CODE_OF_CONDUCT.md
├── LICENSE.txt
├── README.md
├── build/
│ ├── functions.sh
│ └── run.sh
├── cmake/
│ ├── doxygen.cmake
│ ├── luasandboxConfig.cmake.in
│ └── mozsvc.cmake
├── covfn.txt
├── docs/
│ ├── cli/
│ │ └── index.md
│ ├── heka/
│ │ ├── analysis.md
│ │ ├── index.md
│ │ ├── input.md
│ │ ├── message.md
│ │ └── output.md
│ ├── index.md
│ ├── sandbox.md
│ └── util/
│ └── message_matcher.md
├── gen_gh_pages.lua
├── include/
│ ├── luasandbox/
│ │ ├── error.h
│ │ ├── heka/
│ │ │ ├── sandbox.h
│ │ │ └── stream_reader.h
│ │ ├── lauxlib.h
│ │ ├── lua.h
│ │ ├── luaconf.h
│ │ ├── lualib.h
│ │ ├── test/
│ │ │ ├── mu_test.h
│ │ │ └── sandbox.h
│ │ └── util/
│ │ ├── heka_message.h
│ │ ├── heka_message_matcher.h
│ │ ├── input_buffer.h
│ │ ├── output_buffer.h
│ │ ├── protobuf.h
│ │ ├── running_stats.h
│ │ ├── string.h
│ │ ├── string_matcher.h
│ │ └── util.h
│ ├── luasandbox.h
│ ├── luasandbox_output.h
│ └── luasandbox_serialize.h
└── src/
├── CMakeLists.txt
├── cli/
│ ├── CMakeLists.txt
│ └── lsb_heka_cat.c
├── heka/
│ ├── CMakeLists.txt
│ ├── message.c
│ ├── message_impl.h
│ ├── read_message_zc.c
│ ├── sandbox.c
│ ├── sandbox_impl.h
│ ├── stream_reader.c
│ └── test/
│ ├── CMakeLists.txt
│ ├── lua/
│ │ ├── aim.lua
│ │ ├── analysis.lua
│ │ ├── decode_message.lua
│ │ ├── decode_message_benchmark.lua
│ │ ├── encode_message.lua
│ │ ├── iim.lua
│ │ ├── input.lua
│ │ ├── oim.lua
│ │ ├── output.lua
│ │ ├── pm_no_return.lua
│ │ ├── read_message.lua
│ │ └── read_message_zc.lua
│ ├── test.h.in
│ └── test_heka_sandbox.c
├── lua/
│ ├── lapi.c
│ ├── lapi.h
│ ├── lauxlib.c
│ ├── lbaselib.c
│ ├── lcode.c
│ ├── lcode.h
│ ├── ldblib.c
│ ├── ldebug.c
│ ├── ldebug.h
│ ├── ldo.c
│ ├── ldo.h
│ ├── ldump.c
│ ├── lfunc.c
│ ├── lfunc.h
│ ├── lgc.c
│ ├── lgc.h
│ ├── linit.c
│ ├── liolib.c
│ ├── llex.c
│ ├── llex.h
│ ├── llimits.h
│ ├── lmathlib.c
│ ├── lmem.c
│ ├── lmem.h
│ ├── loadlib.c
│ ├── lobject.c
│ ├── lobject.h
│ ├── lopcodes.c
│ ├── lopcodes.h
│ ├── loslib.c
│ ├── lparser.c
│ ├── lparser.h
│ ├── lstate.c
│ ├── lstate.h
│ ├── lstring.c
│ ├── lstring.h
│ ├── lstrlib.c
│ ├── ltable.c
│ ├── ltable.h
│ ├── ltablib.c
│ ├── ltm.c
│ ├── ltm.h
│ ├── lundump.c
│ ├── lundump.h
│ ├── lvm.c
│ ├── lvm.h
│ ├── lzio.c
│ └── lzio.h
├── luasandbox.c
├── luasandbox_defines.h
├── luasandbox_impl.h
├── luasandbox_output.c
├── luasandbox_serialize.c
├── test/
│ ├── CMakeLists.txt
│ ├── lua/
│ │ ├── bad_module.lua
│ │ ├── counter.lua
│ │ ├── errors.lua
│ │ ├── no_external_modules.lua
│ │ ├── output.lua
│ │ ├── output_errors.lua
│ │ ├── print.lua
│ │ ├── read_config.lua
│ │ ├── restore.lua
│ │ ├── sandbox_config.lua
│ │ ├── serialize.lua
│ │ ├── serialize_failure.lua
│ │ └── simple.lua
│ ├── output/
│ │ └── serialize.lua51.data
│ ├── sandbox.c
│ └── test_generic_sandbox.c
└── util/
├── CMakeLists.txt
├── heka_message.c
├── heka_message_matcher.c
├── heka_message_matcher_impl.h
├── heka_message_matcher_parser.c
├── heka_message_matcher_parser.leg
├── input_buffer.c
├── output_buffer.c
├── protobuf.c
├── running_stats.c
├── string.c
├── string_matcher.c
├── test/
│ ├── CMakeLists.txt
│ ├── test_heka_message.c
│ ├── test_heka_message_matcher.c
│ ├── test_input_buffer.c
│ ├── test_output_buffer.c
│ ├── test_protobuf.c
│ ├── test_running_stats.c
│ ├── test_string.c
│ ├── test_string_matcher.c
│ └── test_util.c
└── util.c
SYMBOL INDEX (1140 symbols across 82 files)
FILE: include/luasandbox.h
type lsb_state (line 42) | typedef enum {
type lsb_usage_stat (line 49) | typedef enum {
type lsb_usage_type (line 57) | typedef enum {
type lsb_lua_sandbox (line 65) | typedef struct lsb_lua_sandbox lsb_lua_sandbox;
FILE: include/luasandbox/error.h
type lsb_logger (line 24) | typedef struct lsb_logger {
FILE: include/luasandbox/heka/sandbox.h
type lsb_heka_pm_rv (line 37) | enum lsb_heka_pm_rv {
type lsb_heka_im_rv (line 46) | enum lsb_heka_im_rv {
type lsb_heka_sandbox (line 53) | typedef struct lsb_heka_sandbox lsb_heka_sandbox;
type lsb_heka_stats (line 55) | typedef struct lsb_heka_stats {
FILE: include/luasandbox/heka/stream_reader.h
type heka_stream_reader (line 17) | typedef struct heka_stream_reader
FILE: include/luasandbox/lauxlib.h
type luaL_Reg (line 35) | typedef struct luaL_Reg {
type luaL_Buffer (line 129) | typedef struct luaL_Buffer {
FILE: include/luasandbox/lua.h
type lua_State (line 50) | typedef struct lua_State lua_State;
type LUA_NUMBER (line 106) | typedef LUA_NUMBER lua_Number;
type LUA_INTEGER (line 110) | typedef LUA_INTEGER lua_Integer;
type lua_Debug (line 334) | typedef struct lua_Debug lua_Debug;
type lua_Debug (line 355) | struct lua_Debug {
FILE: include/luasandbox/util/heka_message.h
type lsb_pb_message (line 40) | typedef enum {
type lsb_pb_field (line 53) | typedef enum {
type lsb_pb_value_types (line 64) | typedef enum {
type lsb_heka_field (line 72) | typedef struct lsb_heka_field
type lsb_heka_message (line 80) | typedef struct lsb_heka_message
type lsb_read_type (line 99) | typedef enum {
type lsb_read_value (line 106) | typedef struct {
FILE: include/luasandbox/util/heka_message_matcher.h
type lsb_message_matcher (line 16) | typedef struct lsb_message_matcher lsb_message_matcher;
FILE: include/luasandbox/util/input_buffer.h
type lsb_input_buffer (line 17) | typedef struct lsb_input_buffer
FILE: include/luasandbox/util/output_buffer.h
type lsb_output_buffer (line 18) | typedef struct lsb_output_buffer {
FILE: include/luasandbox/util/protobuf.h
type lsb_pb_wire_types (line 20) | typedef enum {
FILE: include/luasandbox/util/running_stats.h
type lsb_running_stats (line 15) | typedef struct lsb_running_stats
FILE: include/luasandbox/util/string.h
type lsb_const_string (line 14) | typedef struct lsb_const_string
FILE: src/cli/lsb_heka_cat.c
function log_cb (line 28) | static void
function output_cs (line 63) | static void output_cs(const char *key, lsb_const_string *cs, bool eol)
function output_text (line 76) | static void output_text(lsb_heka_message *msg)
function output_heka (line 196) | static void output_heka(lsb_heka_message *msg)
function read_file (line 212) | static size_t read_file(FILE *fh, lsb_input_buffer *ib)
function find_header (line 239) | static int find_header(const char *cur, int clen, const char *prev, int ...
function move_to_offset (line 281) | static void move_to_offset(FILE *fh, int num)
function main (line 329) | int main(int argc, char **argv)
FILE: src/heka/message.c
function set_missing_headers (line 29) | static void set_missing_headers(lua_State *lua, int idx, lsb_heka_sandbo...
function lsb_err_value (line 262) | static lsb_err_value
function lsb_err_value (line 291) | static lsb_err_value
function lsb_err_value (line 339) | static lsb_err_value
function lsb_err_value (line 386) | static lsb_err_value
function lsb_err_value (line 409) | static lsb_err_value
function lsb_err_value (line 626) | static lsb_err_value
function heka_decode_message (line 702) | int heka_decode_message(lua_State *lua)
function heka_encode_message (line 846) | int heka_encode_message(lua_State *lua)
function lsb_err_value (line 902) | lsb_err_value
function heka_read_message (line 955) | int heka_read_message(lua_State *lua, lsb_heka_message *m)
FILE: src/heka/read_message_zc.c
type read_message_zc (line 23) | typedef struct read_message_zc
function lsb_heka_message (line 32) | static const lsb_heka_message* get_heka_message(lua_State *lua)
function lsb_const_string (line 44) | static lsb_const_string read_message(lua_State *lua, read_message_zc *zc)
function zc_output (line 86) | static int zc_output(lua_State *lua)
function zc_return (line 104) | static int zc_return(lua_State *lua)
function zc_tostring (line 122) | static int zc_tostring(lua_State *lua)
type luaL_reg (line 143) | struct luaL_reg
function heka_create_read_message_zc (line 150) | int heka_create_read_message_zc(lua_State *lua)
FILE: src/heka/sandbox.c
function is_running (line 44) | static int is_running(lua_State *lua)
function read_message (line 62) | static int read_message(lua_State *lua)
function lsb_message_matcher (line 81) | static lsb_message_matcher* mm_check(lua_State *lua)
function mm_gc (line 89) | static int mm_gc(lua_State *lua)
function mm_eval (line 97) | static int mm_eval(lua_State *lua)
function mm_create (line 114) | static int mm_create(lua_State *lua)
function inject_message_input (line 136) | static int inject_message_input(lua_State *lua)
function inject_message_analysis (line 236) | static int inject_message_analysis(lua_State *lua)
function inject_payload (line 270) | static int inject_payload(lua_State *lua)
function update_checkpoint (line 329) | static int update_checkpoint(lua_State *lua)
function set_restrictions (line 362) | static void set_restrictions(lua_State *lua, lsb_heka_sandbox *hsb)
function lsb_heka_sandbox (line 465) | lsb_heka_sandbox* lsb_heka_create_input(void *parent,
function process_message (line 537) | static int process_message(lsb_heka_sandbox *hsb, lsb_heka_message *msg,
function lsb_heka_pm_input (line 623) | int lsb_heka_pm_input(lsb_heka_sandbox *hsb,
function lsb_heka_sandbox (line 657) | lsb_heka_sandbox* lsb_heka_create_analysis(void *parent,
function lsb_heka_pm_analysis (line 729) | int lsb_heka_pm_analysis(lsb_heka_sandbox *hsb,
function pushresult (line 749) | static int pushresult(lua_State *lua, int i, const char *filename)
function zc_write (line 765) | static int zc_write(lua_State *lua, FILE *f, int arg)
function FILE (line 826) | static FILE* getiofile(lua_State *lua, int findex)
function zc_io_write (line 838) | static int zc_io_write(lua_State *lua)
function FILE (line 844) | static FILE* tofile(lua_State *lua)
function zc_f_write (line 852) | static int zc_f_write(lua_State *lua)
function zc_luaopen_io (line 858) | static int zc_luaopen_io(lua_State *lua)
function lsb_heka_sandbox (line 873) | lsb_heka_sandbox* lsb_heka_create_output(void *parent,
function lsb_heka_sandbox (line 885) | lsb_heka_sandbox* lsb_heka_create_output_im(void *parent,
function lsb_heka_stop_sandbox_clean (line 972) | void lsb_heka_stop_sandbox_clean(lsb_heka_sandbox *hsb)
function lsb_heka_stop_sandbox (line 978) | void lsb_heka_stop_sandbox(lsb_heka_sandbox *hsb)
function lsb_heka_terminate_sandbox (line 985) | void lsb_heka_terminate_sandbox(lsb_heka_sandbox *hsb, const char *err)
function lsb_heka_pm_output (line 1003) | int lsb_heka_pm_output(lsb_heka_sandbox *hsb,
function lsb_heka_timer_event (line 1029) | int lsb_heka_timer_event(lsb_heka_sandbox *hsb, time_t t, bool shutdown)
function lsb_heka_stats (line 1082) | lsb_heka_stats lsb_heka_get_stats(lsb_heka_sandbox *hsb)
function lsb_heka_is_running (line 1103) | bool lsb_heka_is_running(lsb_heka_sandbox *hsb)
function lsb_state (line 1111) | lsb_state lsb_heka_get_state(lsb_heka_sandbox *hsb)
function lsb_heka_message (line 1118) | const lsb_heka_message* lsb_heka_get_message(lsb_heka_sandbox *hsb)
function lsb_heka_get_type (line 1125) | char lsb_heka_get_type(lsb_heka_sandbox *hsb)
FILE: src/heka/sandbox_impl.h
type heka_stats (line 17) | struct heka_stats {
type lsb_heka_sandbox (line 29) | struct lsb_heka_sandbox {
FILE: src/heka/stream_reader.c
function heka_stream_reader (line 18) | static heka_stream_reader* check_hsr(lua_State *lua, int args)
function hsr_decode_message (line 27) | static int hsr_decode_message(lua_State *lua)
function hsr_find_message (line 56) | static int hsr_find_message(lua_State *lua)
function hsr_read_message (line 142) | static int hsr_read_message(lua_State *lua)
function hsr_gc (line 154) | static int hsr_gc(lua_State *lua)
type luaL_reg (line 164) | struct luaL_reg
function heka_create_stream_reader (line 174) | int heka_create_stream_reader(lua_State *lua)
FILE: src/heka/test/test_heka_sandbox.c
function dlog (line 29) | void dlog(void *context, const char *component, int level, const char *f...
function iim (line 43) | static int iim(void *parent, const char *pb, size_t pb_len, double cp_nu...
function aim (line 129) | static int aim(void *parent, const char *pb, size_t pb_len)
function aim1 (line 177) | static int aim1(void *parent, const char *pb, size_t pb_len)
function ucp (line 206) | static int ucp(void *parent, void *sequence_id)
function oim (line 226) | static int oim(void *parent, const char *pb, size_t pb_len)
type pm_result (line 481) | struct pm_result {
type pm_result (line 488) | struct pm_result
type pm_result (line 522) | struct pm_result {
type pm_result (line 529) | struct pm_result
function rm_zc (line 736) | static int rm_zc(lua_State *lua)
type timespec (line 850) | struct timespec
function main (line 882) | int main()
FILE: src/lua/lapi.c
function TValue (line 49) | static TValue *index2adr (lua_State *L, int idx) {
function Table (line 79) | static Table *getcurrenv (lua_State *L) {
function luaA_pushobject (line 89) | void luaA_pushobject (lua_State *L, const TValue *o) {
function LUA_API (line 95) | LUA_API int lua_checkstack (lua_State *L, int size) {
function LUA_API (line 110) | LUA_API void lua_xmove (lua_State *from, lua_State *to, int n) {
function LUA_API (line 125) | LUA_API void lua_setlevel (lua_State *from, lua_State *to) {
function LUA_API (line 130) | LUA_API lua_CFunction lua_atpanic (lua_State *L, lua_CFunction panicf) {
function LUA_API (line 140) | LUA_API lua_State *lua_newthread (lua_State *L) {
function LUA_API (line 159) | LUA_API int lua_gettop (lua_State *L) {
function LUA_API (line 164) | LUA_API void lua_settop (lua_State *L, int idx) {
function LUA_API (line 180) | LUA_API void lua_remove (lua_State *L, int idx) {
function LUA_API (line 191) | LUA_API void lua_insert (lua_State *L, int idx) {
function LUA_API (line 203) | LUA_API void lua_replace (lua_State *L, int idx) {
function LUA_API (line 228) | LUA_API void lua_pushvalue (lua_State *L, int idx) {
function LUA_API (line 242) | LUA_API int lua_type (lua_State *L, int idx) {
function LUA_API (line 248) | LUA_API const char *lua_typename (lua_State *L, int t) {
function LUA_API (line 254) | LUA_API int lua_iscfunction (lua_State *L, int idx) {
function LUA_API (line 260) | LUA_API int lua_tabletype (lua_State *L, int idx) {
function LUA_API (line 272) | LUA_API int lua_isnumber (lua_State *L, int idx) {
function LUA_API (line 279) | LUA_API int lua_isstring (lua_State *L, int idx) {
function LUA_API (line 285) | LUA_API int lua_isuserdata (lua_State *L, int idx) {
function LUA_API (line 291) | LUA_API int lua_rawequal (lua_State *L, int index1, int index2) {
function LUA_API (line 299) | LUA_API int lua_equal (lua_State *L, int index1, int index2) {
function LUA_API (line 311) | LUA_API int lua_lessthan (lua_State *L, int index1, int index2) {
function LUA_API (line 325) | LUA_API lua_Number lua_tonumber (lua_State *L, int idx) {
function LUA_API (line 335) | LUA_API lua_Integer lua_tointeger (lua_State *L, int idx) {
function LUA_API (line 349) | LUA_API int lua_toboolean (lua_State *L, int idx) {
function LUA_API (line 355) | LUA_API const char *lua_tolstring (lua_State *L, int idx, size_t *len) {
function LUA_API (line 373) | LUA_API size_t lua_objlen (lua_State *L, int idx) {
function LUA_API (line 391) | LUA_API lua_CFunction lua_tocfunction (lua_State *L, int idx) {
function LUA_API (line 397) | LUA_API void *lua_touserdata (lua_State *L, int idx) {
function LUA_API (line 407) | LUA_API lua_State *lua_tothread (lua_State *L, int idx) {
function LUA_API (line 413) | LUA_API const void *lua_topointer (lua_State *L, int idx) {
function LUA_API (line 433) | LUA_API void lua_pushnil (lua_State *L) {
function LUA_API (line 441) | LUA_API void lua_pushnumber (lua_State *L, lua_Number n) {
function LUA_API (line 449) | LUA_API void lua_pushinteger (lua_State *L, lua_Integer n) {
function LUA_API (line 457) | LUA_API void lua_pushlstring (lua_State *L, const char *s, size_t len) {
function LUA_API (line 466) | LUA_API void lua_pushstring (lua_State *L, const char *s) {
function LUA_API (line 474) | LUA_API const char *lua_pushvfstring (lua_State *L, const char *fmt,
function LUA_API (line 485) | LUA_API const char *lua_pushfstring (lua_State *L, const char *fmt, ...) {
function LUA_API (line 498) | LUA_API void lua_pushcclosure (lua_State *L, lua_CFunction fn, int n) {
function LUA_API (line 515) | LUA_API void lua_pushboolean (lua_State *L, int b) {
function LUA_API (line 523) | LUA_API void lua_pushlightuserdata (lua_State *L, void *p) {
function LUA_API (line 531) | LUA_API int lua_pushthread (lua_State *L) {
function LUA_API (line 546) | LUA_API void lua_gettable (lua_State *L, int idx) {
function LUA_API (line 556) | LUA_API void lua_getfield (lua_State *L, int idx, const char *k) {
function LUA_API (line 569) | LUA_API void lua_rawget (lua_State *L, int idx) {
function LUA_API (line 579) | LUA_API void lua_rawgeti (lua_State *L, int idx, int n) {
function LUA_API (line 590) | LUA_API void lua_createtable (lua_State *L, int narray, int nrec) {
function LUA_API (line 599) | LUA_API int lua_getmetatable (lua_State *L, int objindex) {
function LUA_API (line 628) | LUA_API void lua_getfenv (lua_State *L, int idx) {
function LUA_API (line 657) | LUA_API void lua_settable (lua_State *L, int idx) {
function LUA_API (line 669) | LUA_API void lua_setfield (lua_State *L, int idx, const char *k) {
function LUA_API (line 683) | LUA_API void lua_rawset (lua_State *L, int idx) {
function LUA_API (line 696) | LUA_API void lua_rawseti (lua_State *L, int idx, int n) {
function LUA_API (line 709) | LUA_API int lua_setmetatable (lua_State *L, int objindex) {
function LUA_API (line 746) | LUA_API int lua_setfenv (lua_State *L, int idx) {
function LUA_API (line 788) | LUA_API void lua_call (lua_State *L, int nargs, int nresults) {
type CallS (line 804) | struct CallS { /* data to `f_call' */
function f_call (line 810) | static void f_call (lua_State *L, void *ud) {
function LUA_API (line 817) | LUA_API int lua_pcall (lua_State *L, int nargs, int nresults, int errfun...
type CCallS (line 843) | struct CCallS { /* data to `f_Ccall' */
function f_Ccall (line 849) | static void f_Ccall (lua_State *L, void *ud) {
function LUA_API (line 862) | LUA_API int lua_cpcall (lua_State *L, lua_CFunction func, void *ud) {
function LUA_API (line 874) | LUA_API int lua_load (lua_State *L, lua_Reader reader, void *data,
function LUA_API (line 887) | LUA_API int lua_dump (lua_State *L, lua_Writer writer, void *data) {
function LUA_API (line 902) | LUA_API int lua_status (lua_State *L) {
function LUA_API (line 911) | LUA_API int lua_gc (lua_State *L, int what, int data) {
function LUA_API (line 976) | LUA_API int lua_error (lua_State *L) {
function LUA_API (line 985) | LUA_API int lua_next (lua_State *L, int idx) {
function LUA_API (line 1002) | LUA_API void lua_concat (lua_State *L, int n) {
function LUA_API (line 1019) | LUA_API lua_Alloc lua_getallocf (lua_State *L, void **ud) {
function LUA_API (line 1029) | LUA_API void lua_setallocf (lua_State *L, lua_Alloc f, void *ud) {
function LUA_API (line 1037) | LUA_API void *lua_newuserdata (lua_State *L, size_t size) {
function LUA_API (line 1069) | LUA_API const char *lua_getupvalue (lua_State *L, int funcindex, int n) {
function LUA_API (line 1083) | LUA_API const char *lua_setupvalue (lua_State *L, int funcindex, int n) {
FILE: src/lua/lauxlib.c
function LUALIB_API (line 43) | LUALIB_API int luaL_argerror (lua_State *L, int narg, const char *extram...
function LUALIB_API (line 61) | LUALIB_API int luaL_typerror (lua_State *L, int narg, const char *tname) {
function tag_error (line 68) | static void tag_error (lua_State *L, int narg, int tag) {
function LUALIB_API (line 73) | LUALIB_API void luaL_where (lua_State *L, int level) {
function LUALIB_API (line 86) | LUALIB_API int luaL_error (lua_State *L, const char *fmt, ...) {
function LUALIB_API (line 99) | LUALIB_API int luaL_checkoption (lua_State *L, int narg, const char *def,
function LUALIB_API (line 112) | LUALIB_API int luaL_newmetatable (lua_State *L, const char *tname) {
function LUALIB_API (line 124) | LUALIB_API void *luaL_checkudata (lua_State *L, int ud, const char *tnam...
function LUALIB_API (line 140) | LUALIB_API void luaL_checkstack (lua_State *L, int space, const char *me...
function LUALIB_API (line 146) | LUALIB_API void luaL_checktype (lua_State *L, int narg, int t) {
function LUALIB_API (line 152) | LUALIB_API void luaL_checkany (lua_State *L, int narg) {
function LUALIB_API (line 158) | LUALIB_API const char *luaL_checklstring (lua_State *L, int narg, size_t...
function LUALIB_API (line 165) | LUALIB_API const char *luaL_optlstring (lua_State *L, int narg,
function LUALIB_API (line 176) | LUALIB_API lua_Number luaL_checknumber (lua_State *L, int narg) {
function LUALIB_API (line 184) | LUALIB_API lua_Number luaL_optnumber (lua_State *L, int narg, lua_Number...
function LUALIB_API (line 189) | LUALIB_API lua_Integer luaL_checkinteger (lua_State *L, int narg) {
function LUALIB_API (line 197) | LUALIB_API lua_Integer luaL_optinteger (lua_State *L, int narg,
function LUALIB_API (line 203) | LUALIB_API int luaL_getmetafield (lua_State *L, int obj, const char *eve...
function LUALIB_API (line 219) | LUALIB_API int luaL_callmeta (lua_State *L, int obj, const char *event) {
function LUALIB_API (line 229) | LUALIB_API void (luaL_register) (lua_State *L, const char *libname,
function libsize (line 235) | static int libsize (const luaL_Reg *l) {
function LUALIB_API (line 242) | LUALIB_API void luaI_openlib (lua_State *L, const char *libname,
function checkint (line 280) | static int checkint (lua_State *L, int topop) {
function getsizes (line 287) | static void getsizes (lua_State *L) {
function LUALIB_API (line 302) | LUALIB_API void luaL_setn (lua_State *L, int t, int n) {
function LUALIB_API (line 321) | LUALIB_API int luaL_getn (lua_State *L, int t) {
function LUALIB_API (line 340) | LUALIB_API const char *luaL_gsub (lua_State *L, const char *s, const cha...
function LUALIB_API (line 357) | LUALIB_API const char *luaL_findtable (lua_State *L, int idx,
function emptybuffer (line 398) | static int emptybuffer (luaL_Buffer *B) {
function adjuststack (line 410) | static void adjuststack (luaL_Buffer *B) {
function LUALIB_API (line 429) | LUALIB_API char *luaL_prepbuffer (luaL_Buffer *B) {
function LUALIB_API (line 436) | LUALIB_API void luaL_addlstring (luaL_Buffer *B, const char *s, size_t l) {
function LUALIB_API (line 442) | LUALIB_API void luaL_addstring (luaL_Buffer *B, const char *s) {
function LUALIB_API (line 447) | LUALIB_API void luaL_pushresult (luaL_Buffer *B) {
function LUALIB_API (line 454) | LUALIB_API void luaL_addvalue (luaL_Buffer *B) {
function LUALIB_API (line 472) | LUALIB_API void luaL_buffinit (lua_State *L, luaL_Buffer *B) {
function LUALIB_API (line 481) | LUALIB_API int luaL_ref (lua_State *L, int t) {
function LUALIB_API (line 504) | LUALIB_API void luaL_unref (lua_State *L, int t, int ref) {
type LoadF (line 522) | typedef struct LoadF {
function errfile (line 543) | static int errfile (lua_State *L, const char *what, int fnameindex) {
function LUALIB_API (line 552) | LUALIB_API int luaL_loadfile (lua_State *L, const char *filename) {
type LoadS (line 594) | typedef struct LoadS {
function LUALIB_API (line 610) | LUALIB_API int luaL_loadbuffer (lua_State *L, const char *buff, size_t s...
function LUALIB_API (line 619) | LUALIB_API int (luaL_loadstring) (lua_State *L, const char *s) {
function panic (line 640) | static int panic (lua_State *L) {
function LUALIB_API (line 648) | LUALIB_API lua_State *luaL_newstate (void) {
FILE: src/lua/lbaselib.c
function luaB_print (line 31) | static int luaB_print (lua_State *L) {
function luaB_tonumber (line 53) | static int luaB_tonumber (lua_State *L) {
function luaB_error (line 81) | static int luaB_error (lua_State *L) {
function luaB_getmetatable (line 93) | static int luaB_getmetatable (lua_State *L) {
function luaB_setmetatable (line 104) | static int luaB_setmetatable (lua_State *L) {
function getfunc (line 117) | static void getfunc (lua_State *L, int opt) {
function luaB_getfenv (line 133) | static int luaB_getfenv (lua_State *L) {
function luaB_setfenv (line 143) | static int luaB_setfenv (lua_State *L) {
function luaB_rawequal (line 161) | static int luaB_rawequal (lua_State *L) {
function luaB_rawget (line 169) | static int luaB_rawget (lua_State *L) {
function luaB_rawset (line 177) | static int luaB_rawset (lua_State *L) {
function luaB_gcinfo (line 187) | static int luaB_gcinfo (lua_State *L) {
function luaB_collectgarbage (line 193) | static int luaB_collectgarbage (lua_State *L) {
function luaB_type (line 219) | static int luaB_type (lua_State *L) {
function luaB_next (line 226) | static int luaB_next (lua_State *L) {
function luaB_pairs (line 238) | static int luaB_pairs (lua_State *L) {
function ipairsaux (line 247) | static int ipairsaux (lua_State *L) {
function luaB_ipairs (line 257) | static int luaB_ipairs (lua_State *L) {
function load_aux (line 266) | static int load_aux (lua_State *L, int status) {
function luaB_loadstring (line 277) | static int luaB_loadstring (lua_State *L) {
function luaB_loadfile (line 285) | static int luaB_loadfile (lua_State *L) {
function luaB_load (line 315) | static int luaB_load (lua_State *L) {
function luaB_dofile (line 325) | static int luaB_dofile (lua_State *L) {
function luaB_assert (line 334) | static int luaB_assert (lua_State *L) {
function luaB_unpack (line 342) | static int luaB_unpack (lua_State *L) {
function luaB_select (line 358) | static int luaB_select (lua_State *L) {
function luaB_pcall (line 374) | static int luaB_pcall (lua_State *L) {
function luaB_xpcall (line 384) | static int luaB_xpcall (lua_State *L) {
function luaB_tostring (line 396) | static int luaB_tostring (lua_State *L) {
function luaB_newproxy (line 421) | static int luaB_newproxy (lua_State *L) {
function costatus (line 490) | static int costatus (lua_State *L, lua_State *co) {
function luaB_costatus (line 510) | static int luaB_costatus (lua_State *L) {
function auxresume (line 518) | static int auxresume (lua_State *L, lua_State *co, int narg) {
function luaB_coresume (line 543) | static int luaB_coresume (lua_State *L) {
function luaB_auxwrap (line 561) | static int luaB_auxwrap (lua_State *L) {
function luaB_cocreate (line 576) | static int luaB_cocreate (lua_State *L) {
function luaB_cowrap (line 586) | static int luaB_cowrap (lua_State *L) {
function luaB_yield (line 593) | static int luaB_yield (lua_State *L) {
function luaB_corunning (line 598) | static int luaB_corunning (lua_State *L) {
function auxopen (line 618) | static void auxopen (lua_State *L, const char *name,
function base_open (line 626) | static void base_open (lua_State *L) {
function LUALIB_API (line 648) | LUALIB_API int luaopen_base (lua_State *L) {
function LUALIB_API (line 653) | LUALIB_API int luaopen_coroutine (lua_State *L) {
FILE: src/lua/lcode.c
function isnumeral (line 30) | static int isnumeral(expdesc *e) {
function luaK_nil (line 35) | void luaK_nil (FuncState *fs, int from, int n) {
function luaK_jump (line 59) | int luaK_jump (FuncState *fs) {
function luaK_ret (line 69) | void luaK_ret (FuncState *fs, int first, int nret) {
function condjump (line 74) | static int condjump (FuncState *fs, OpCode op, int A, int B, int C) {
function fixjump (line 80) | static void fixjump (FuncState *fs, int pc, int dest) {
function luaK_getlabel (line 94) | int luaK_getlabel (FuncState *fs) {
function getjump (line 100) | static int getjump (FuncState *fs, int pc) {
function Instruction (line 109) | static Instruction *getjumpcontrol (FuncState *fs, int pc) {
function need_value (line 122) | static int need_value (FuncState *fs, int list) {
function patchtestreg (line 131) | static int patchtestreg (FuncState *fs, int node, int reg) {
function removevalues (line 144) | static void removevalues (FuncState *fs, int list) {
function patchlistaux (line 150) | static void patchlistaux (FuncState *fs, int list, int vtarget, int reg,
function dischargejpc (line 163) | static void dischargejpc (FuncState *fs) {
function luaK_patchlist (line 169) | void luaK_patchlist (FuncState *fs, int list, int target) {
function luaK_patchtohere (line 179) | void luaK_patchtohere (FuncState *fs, int list) {
function luaK_concat (line 185) | void luaK_concat (FuncState *fs, int *l1, int l2) {
function luaK_checkstack (line 199) | void luaK_checkstack (FuncState *fs, int n) {
function luaK_reserveregs (line 209) | void luaK_reserveregs (FuncState *fs, int n) {
function freereg (line 215) | static void freereg (FuncState *fs, int reg) {
function freeexp (line 223) | static void freeexp (FuncState *fs, expdesc *e) {
function addk (line 229) | static int addk (FuncState *fs, TValue *k, TValue *v) {
function luaK_stringK (line 250) | int luaK_stringK (FuncState *fs, TString *s) {
function luaK_numberK (line 257) | int luaK_numberK (FuncState *fs, lua_Number r) {
function boolK (line 264) | static int boolK (FuncState *fs, int b) {
function nilK (line 271) | static int nilK (FuncState *fs) {
function luaK_setreturns (line 280) | void luaK_setreturns (FuncState *fs, expdesc *e, int nresults) {
function luaK_setoneret (line 292) | void luaK_setoneret (FuncState *fs, expdesc *e) {
function luaK_dischargevars (line 304) | void luaK_dischargevars (FuncState *fs, expdesc *e) {
function code_label (line 337) | static int code_label (FuncState *fs, int A, int b, int jump) {
function discharge2reg (line 343) | static void discharge2reg (FuncState *fs, expdesc *e, int reg) {
function discharge2anyreg (line 382) | static void discharge2anyreg (FuncState *fs, expdesc *e) {
function exp2reg (line 390) | static void exp2reg (FuncState *fs, expdesc *e, int reg) {
function luaK_exp2nextreg (line 414) | void luaK_exp2nextreg (FuncState *fs, expdesc *e) {
function luaK_exp2anyreg (line 422) | int luaK_exp2anyreg (FuncState *fs, expdesc *e) {
function luaK_exp2val (line 436) | void luaK_exp2val (FuncState *fs, expdesc *e) {
function luaK_exp2RK (line 444) | int luaK_exp2RK (FuncState *fs, expdesc *e) {
function luaK_storevar (line 472) | void luaK_storevar (FuncState *fs, expdesc *var, expdesc *ex) {
function luaK_self (line 503) | void luaK_self (FuncState *fs, expdesc *e, expdesc *key) {
function invertjump (line 516) | static void invertjump (FuncState *fs, expdesc *e) {
function jumponcond (line 524) | static int jumponcond (FuncState *fs, expdesc *e, int cond) {
function luaK_goiftrue (line 539) | void luaK_goiftrue (FuncState *fs, expdesc *e) {
function luaK_goiffalse (line 563) | static void luaK_goiffalse (FuncState *fs, expdesc *e) {
function codenot (line 586) | static void codenot (FuncState *fs, expdesc *e) {
function luaK_indexed (line 621) | void luaK_indexed (FuncState *fs, expdesc *t, expdesc *k) {
function constfolding (line 627) | static int constfolding (OpCode op, expdesc *e1, expdesc *e2) {
function codearith (line 653) | static void codearith (FuncState *fs, OpCode op, expdesc *e1, expdesc *e...
function codecomp (line 673) | static void codecomp (FuncState *fs, OpCode op, int cond, expdesc *e1,
function luaK_prefix (line 689) | void luaK_prefix (FuncState *fs, UnOpr op, expdesc *e) {
function luaK_infix (line 710) | void luaK_infix (FuncState *fs, BinOpr op, expdesc *v) {
function luaK_posfix (line 737) | void luaK_posfix (FuncState *fs, BinOpr op, expdesc *e1, expdesc *e2) {
function luaK_fixline (line 784) | void luaK_fixline (FuncState *fs, int line) {
function luaK_code (line 789) | static int luaK_code (FuncState *fs, Instruction i, int line) {
function luaK_codeABC (line 804) | int luaK_codeABC (FuncState *fs, OpCode o, int a, int b, int c) {
function luaK_codeABx (line 812) | int luaK_codeABx (FuncState *fs, OpCode o, int a, unsigned int bc) {
function luaK_setlist (line 819) | void luaK_setlist (FuncState *fs, int base, int nelems, int tostore) {
FILE: src/lua/lcode.h
type BinOpr (line 26) | typedef enum BinOpr {
type UnOpr (line 36) | typedef enum UnOpr { OPR_MINUS, OPR_NOT, OPR_LEN, OPR_NOUNOPR } UnOpr;
FILE: src/lua/ldblib.c
function db_getregistry (line 22) | static int db_getregistry (lua_State *L) {
function db_getmetatable (line 28) | static int db_getmetatable (lua_State *L) {
function db_setmetatable (line 37) | static int db_setmetatable (lua_State *L) {
function db_getfenv (line 47) | static int db_getfenv (lua_State *L) {
function db_setfenv (line 54) | static int db_setfenv (lua_State *L) {
function settabss (line 64) | static void settabss (lua_State *L, const char *i, const char *v) {
function settabsi (line 70) | static void settabsi (lua_State *L, const char *i, int v) {
function lua_State (line 76) | static lua_State *getthread (lua_State *L, int *arg) {
function treatstackoption (line 88) | static void treatstackoption (lua_State *L, lua_State *L1, const char *f...
function db_getinfo (line 99) | static int db_getinfo (lua_State *L) {
function db_getlocal (line 144) | static int db_getlocal (lua_State *L) {
function db_setlocal (line 165) | static int db_setlocal (lua_State *L) {
function auxupvalue (line 179) | static int auxupvalue (lua_State *L, int get) {
function db_getupvalue (line 192) | static int db_getupvalue (lua_State *L) {
function db_setupvalue (line 197) | static int db_setupvalue (lua_State *L) {
function hookf (line 207) | static void hookf (lua_State *L, lua_Debug *ar) {
function makemask (line 225) | static int makemask (const char *smask, int count) {
function gethooktable (line 245) | static void gethooktable (lua_State *L) {
function db_sethook (line 258) | static int db_sethook (lua_State *L) {
function db_gethook (line 282) | static int db_gethook (lua_State *L) {
function db_debug (line 302) | static int db_debug (lua_State *L) {
function db_errorfb (line 322) | static int db_errorfb (lua_State *L) {
function LUALIB_API (line 394) | LUALIB_API int luaopen_debug (lua_State *L) {
FILE: src/lua/ldebug.c
function currentpc (line 36) | static int currentpc (lua_State *L, CallInfo *ci) {
function currentline (line 44) | static int currentline (lua_State *L, CallInfo *ci) {
function LUA_API (line 56) | LUA_API int lua_sethook (lua_State *L, lua_Hook func, int mask, int coun...
function LUA_API (line 69) | LUA_API lua_Hook lua_gethook (lua_State *L) {
function LUA_API (line 74) | LUA_API int lua_gethookmask (lua_State *L) {
function LUA_API (line 79) | LUA_API int lua_gethookcount (lua_State *L) {
function LUA_API (line 83) | LUA_API int lua_gethookcountremaining (lua_State *L) {
function LUA_API (line 88) | LUA_API int lua_getstack (lua_State *L, int level, lua_Debug *ar) {
function Proto (line 111) | static Proto *getluaproto (CallInfo *ci) {
function LUA_API (line 131) | LUA_API const char *lua_getlocal (lua_State *L, const lua_Debug *ar, int...
function LUA_API (line 142) | LUA_API const char *lua_setlocal (lua_State *L, const lua_Debug *ar, int...
function funcinfo (line 154) | static void funcinfo (lua_Debug *ar, Closure *cl) {
function info_tailcall (line 171) | static void info_tailcall (lua_Debug *ar) {
function collectvalidlines (line 181) | static void collectvalidlines (lua_State *L, Closure *f) {
function auxgetinfo (line 197) | static int auxgetinfo (lua_State *L, const char *what, lua_Debug *ar,
function LUA_API (line 236) | LUA_API int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar) {
function precheck (line 280) | static int precheck (const Proto *pt) {
function luaG_checkopenop (line 294) | int luaG_checkopenop (Instruction i) {
function checkArgMode (line 308) | static int checkArgMode (const Proto *pt, int r, enum OpArgMask mode) {
function Instruction (line 321) | static Instruction symbexec (const Proto *pt, int lastpc, int reg) {
function luaG_checkcode (line 488) | int luaG_checkcode (const Proto *pt) {
function isinstack (line 563) | static int isinstack (CallInfo *ci, const TValue *o) {
function luaG_typeerror (line 571) | void luaG_typeerror (lua_State *L, const TValue *o, const char *op) {
function luaG_concaterror (line 585) | void luaG_concaterror (lua_State *L, StkId p1, StkId p2) {
function luaG_aritherror (line 592) | void luaG_aritherror (lua_State *L, const TValue *p1, const TValue *p2) {
function luaG_ordererror (line 600) | int luaG_ordererror (lua_State *L, const TValue *p1, const TValue *p2) {
function addinfo (line 611) | static void addinfo (lua_State *L, const char *msg) {
function luaG_errormsg (line 622) | void luaG_errormsg (lua_State *L) {
function luaG_runerror (line 635) | void luaG_runerror (lua_State *L, const char *fmt, ...) {
FILE: src/lua/ldo.c
type lua_longjmp (line 44) | struct lua_longjmp {
function luaD_seterrorobj (line 51) | void luaD_seterrorobj (lua_State *L, int errcode, StkId oldtop) {
function restore_stack_limit (line 71) | static void restore_stack_limit (lua_State *L) {
function resetstack (line 81) | static void resetstack (lua_State *L, int status) {
function luaD_throw (line 94) | void luaD_throw (lua_State *L, int errcode) {
function luaD_rawrunprotected (line 111) | int luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud) {
function correctstack (line 126) | static void correctstack (lua_State *L, TValue *oldstack) {
function luaD_reallocstack (line 141) | void luaD_reallocstack (lua_State *L, int newsize) {
function luaD_reallocCI (line 152) | void luaD_reallocCI (lua_State *L, int newsize) {
function luaD_growstack (line 161) | void luaD_growstack (lua_State *L, int n) {
function CallInfo (line 169) | static CallInfo *growCI (lua_State *L) {
function luaD_callhook (line 181) | void luaD_callhook (lua_State *L, int event, int line) {
function StkId (line 208) | static StkId adjust_varargs (lua_State *L, Proto *p, int actual) {
function StkId (line 244) | static StkId tryfuncTM (lua_State *L, StkId func) {
function luaD_precall (line 265) | int luaD_precall (lua_State *L, StkId func, int nresults) {
function StkId (line 332) | static StkId callrethooks (lua_State *L, StkId firstResult) {
function luaD_poscall (line 343) | int luaD_poscall (lua_State *L, StkId firstResult) {
function luaD_call (line 370) | void luaD_call (lua_State *L, StkId func, int nResults) {
function resume (line 384) | static void resume (lua_State *L, void *ud) {
function resume_error (line 409) | static int resume_error (lua_State *L, const char *msg) {
function LUA_API (line 418) | LUA_API int lua_resume (lua_State *L, int nargs) {
function LUA_API (line 444) | LUA_API int lua_yield (lua_State *L, int nresults) {
function luaD_pcall (line 456) | int luaD_pcall (lua_State *L, Pfunc func, void *u,
type SParser (line 485) | struct SParser { /* data to `f_parser' */
function f_parser (line 491) | static void f_parser (lua_State *L, void *ud) {
function luaD_protectedparser (line 509) | int luaD_protectedparser (lua_State *L, ZIO *z, const char *name) {
FILE: src/lua/ldump.c
type DumpState (line 18) | typedef struct {
function DumpBlock (line 29) | static void DumpBlock(const void* b, size_t size, DumpState* D)
function DumpChar (line 39) | static void DumpChar(int y, DumpState* D)
function DumpInt (line 45) | static void DumpInt(int x, DumpState* D)
function DumpNumber (line 50) | static void DumpNumber(lua_Number x, DumpState* D)
function DumpVector (line 55) | static void DumpVector(const void* b, int n, size_t size, DumpState* D)
function DumpString (line 61) | static void DumpString(const TString* s, DumpState* D)
function DumpConstants (line 80) | static void DumpConstants(const Proto* f, DumpState* D)
function DumpDebug (line 111) | static void DumpDebug(const Proto* f, DumpState* D)
function DumpFunction (line 129) | static void DumpFunction(const Proto* f, const TString* p, DumpState* D)
function DumpHeader (line 143) | static void DumpHeader(DumpState* D)
function luaU_dump (line 153) | int luaU_dump (lua_State* L, const Proto* f, lua_Writer w, void* data, i...
FILE: src/lua/lfunc.c
function Closure (line 23) | Closure *luaF_newCclosure (lua_State *L, int nelems, Table *e) {
function Closure (line 33) | Closure *luaF_newLclosure (lua_State *L, int nelems, Table *e) {
function UpVal (line 44) | UpVal *luaF_newupval (lua_State *L) {
function UpVal (line 53) | UpVal *luaF_findupval (lua_State *L, StkId level) {
function unlinkupval (line 82) | static void unlinkupval (UpVal *uv) {
function luaF_freeupval (line 89) | void luaF_freeupval (lua_State *L, UpVal *uv) {
function luaF_close (line 96) | void luaF_close (lua_State *L, StkId level) {
function Proto (line 115) | Proto *luaF_newproto (lua_State *L) {
function luaF_freeproto (line 141) | void luaF_freeproto (lua_State *L, Proto *f) {
function luaF_freeclosure (line 152) | void luaF_freeclosure (lua_State *L, Closure *c) {
FILE: src/lua/lgc.c
function removeentry (line 62) | static void removeentry (Node *n) {
function reallymarkobject (line 69) | static void reallymarkobject (global_State *g, GCObject *o) {
function marktmu (line 115) | static void marktmu (global_State *g) {
function luaC_separateudata (line 128) | size_t luaC_separateudata (lua_State *L, int all) {
function traversetable (line 158) | static int traversetable (global_State *g, Table *h) {
function traverseproto (line 203) | static void traverseproto (global_State *g, Proto *f) {
function traverseclosure (line 224) | static void traverseclosure (global_State *g, Closure *cl) {
function checkstacksizes (line 241) | static void checkstacksizes (lua_State *L, StkId max) {
function traversestack (line 256) | static void traversestack (global_State *g, lua_State *l) {
function l_mem (line 277) | static l_mem propagatemark (global_State *g) {
function propagateall (line 323) | static size_t propagateall (global_State *g) {
function iscleared (line 337) | static int iscleared (const TValue *o, int iskey) {
function cleartable (line 351) | static void cleartable (GCObject *l) {
function freeobj (line 378) | static void freeobj (lua_State *L, GCObject *o) {
function GCObject (line 407) | static GCObject **sweeplist (lua_State *L, GCObject **p, lu_mem count) {
function checkSizes (line 431) | static void checkSizes (lua_State *L) {
function GCTM (line 445) | static void GCTM (lua_State *L) {
function luaC_callGCTM (line 477) | void luaC_callGCTM (lua_State *L) {
function luaC_freeall (line 483) | void luaC_freeall (lua_State *L) {
function markmt (line 493) | static void markmt (global_State *g) {
function markroot (line 501) | static void markroot (lua_State *L) {
function remarkupvals (line 515) | static void remarkupvals (global_State *g) {
function atomic (line 525) | static void atomic (lua_State *L) {
function l_mem (line 556) | static l_mem singlestep (lua_State *L) {
function luaC_step (line 610) | void luaC_step (lua_State *L) {
function luaC_fullgc (line 635) | void luaC_fullgc (lua_State *L) {
function luaC_barrierf (line 661) | void luaC_barrierf (lua_State *L, GCObject *o, GCObject *v) {
function luaC_barrierback (line 674) | void luaC_barrierback (lua_State *L, Table *t) {
function luaC_link (line 685) | void luaC_link (lua_State *L, GCObject *o, lu_byte tt) {
function luaC_linkupval (line 694) | void luaC_linkupval (lua_State *L, UpVal *uv) {
FILE: src/lua/linit.c
function LUALIB_API (line 30) | LUALIB_API void luaL_openlibs (lua_State *L) {
FILE: src/lua/liolib.c
function pushresult (line 30) | static int pushresult (lua_State *L, int i, const char *filename) {
function fileerror (line 48) | static void fileerror (lua_State *L, int arg, const char *filename) {
function io_type (line 57) | static int io_type (lua_State *L) {
function FILE (line 72) | static FILE *tofile (lua_State *L) {
function FILE (line 86) | static FILE **newfile (lua_State *L) {
function io_noclose (line 98) | static int io_noclose (lua_State *L) {
function io_pclose (line 108) | static int io_pclose (lua_State *L) {
function io_fclose (line 119) | static int io_fclose (lua_State *L) {
function aux_close (line 127) | static int aux_close (lua_State *L) {
function io_close (line 134) | static int io_close (lua_State *L) {
function io_gc (line 142) | static int io_gc (lua_State *L) {
function io_tostring (line 151) | static int io_tostring (lua_State *L) {
function io_open (line 161) | static int io_open (lua_State *L) {
function io_popen (line 174) | static int io_popen (lua_State *L) {
function io_tmpfile (line 183) | static int io_tmpfile (lua_State *L) {
function FILE (line 190) | static FILE *getiofile (lua_State *L, int findex) {
function g_iofile (line 200) | static int g_iofile (lua_State *L, int f, const char *mode) {
function io_input (line 221) | static int io_input (lua_State *L) {
function io_output (line 226) | static int io_output (lua_State *L) {
function aux_lines (line 234) | static void aux_lines (lua_State *L, int idx, int toclose) {
function f_lines (line 241) | static int f_lines (lua_State *L) {
function io_lines (line 248) | static int io_lines (lua_State *L) {
function read_number (line 273) | static int read_number (lua_State *L, FILE *f) {
function test_eof (line 286) | static int test_eof (lua_State *L, FILE *f) {
function read_line (line 294) | static int read_line (lua_State *L, FILE *f) {
function read_chars (line 316) | static int read_chars (lua_State *L, FILE *f, size_t n) {
function g_read (line 334) | static int g_read (lua_State *L, FILE *f, int first) {
function io_read (line 381) | static int io_read (lua_State *L) {
function f_read (line 386) | static int f_read (lua_State *L) {
function io_readline (line 391) | static int io_readline (lua_State *L) {
function g_write (line 413) | static int g_write (lua_State *L, FILE *f, int arg) {
function io_write (line 432) | static int io_write (lua_State *L) {
function f_write (line 437) | static int f_write (lua_State *L) {
function f_seek (line 442) | static int f_seek (lua_State *L) {
function f_setvbuf (line 458) | static int f_setvbuf (lua_State *L) {
function io_flush (line 470) | static int io_flush (lua_State *L) {
function f_flush (line 475) | static int f_flush (lua_State *L) {
function createmeta (line 510) | static void createmeta (lua_State *L) {
function createstdfile (line 518) | static void createstdfile (lua_State *L, FILE *f, int k, const char *fna...
function newfenv (line 530) | static void newfenv (lua_State *L, lua_CFunction cls) {
function LUALIB_API (line 537) | LUALIB_API int luaopen_io (lua_State *L) {
FILE: src/lua/llex.c
function save (line 51) | static void save (LexState *ls, int c) {
function luaX_init (line 64) | void luaX_init (lua_State *L) {
function luaX_lexerror (line 102) | void luaX_lexerror (LexState *ls, const char *msg, int token) {
function luaX_syntaxerror (line 112) | void luaX_syntaxerror (LexState *ls, const char *msg) {
function TString (line 117) | TString *luaX_newstring (LexState *ls, const char *str, size_t l) {
function inclinenumber (line 129) | static void inclinenumber (LexState *ls) {
function luaX_setinput (line 140) | void luaX_setinput (lua_State *L, LexState *ls, ZIO *z, TString *source) {
function check_next (line 163) | static int check_next (LexState *ls, const char *set) {
function buffreplace (line 171) | static void buffreplace (LexState *ls, char from, char to) {
function trydecpoint (line 179) | static void trydecpoint (LexState *ls, SemInfo *seminfo) {
function read_numeral (line 194) | static void read_numeral (LexState *ls, SemInfo *seminfo) {
function skip_sep (line 210) | static int skip_sep (LexState *ls) {
function read_long_string (line 223) | static void read_long_string (LexState *ls, SemInfo *seminfo, int sep) {
function read_string (line 278) | static void read_string (LexState *ls, int del, SemInfo *seminfo) {
function llex (line 334) | static int llex (LexState *ls, SemInfo *seminfo) {
function luaX_next (line 449) | void luaX_next (LexState *ls) {
function luaX_lookahead (line 460) | void luaX_lookahead (LexState *ls) {
FILE: src/lua/llex.h
type RESERVED (line 24) | enum RESERVED {
type SemInfo (line 43) | typedef union {
type Token (line 49) | typedef struct Token {
type LexState (line 55) | typedef struct LexState {
FILE: src/lua/llimits.h
type LUAI_UINT32 (line 18) | typedef LUAI_UINT32 lu_int32;
type LUAI_UMEM (line 20) | typedef LUAI_UMEM lu_mem;
type LUAI_MEM (line 22) | typedef LUAI_MEM l_mem;
type lu_byte (line 27) | typedef unsigned char lu_byte;
type LUAI_USER_ALIGNMENT_T (line 47) | typedef LUAI_USER_ALIGNMENT_T L_Umaxalign;
type LUAI_UACNUMBER (line 51) | typedef LUAI_UACNUMBER l_uacNumber;
type lu_int32 (line 88) | typedef lu_int32 Instruction;
FILE: src/lua/lmathlib.c
function math_abs (line 26) | static int math_abs (lua_State *L) {
function math_sin (line 31) | static int math_sin (lua_State *L) {
function math_sinh (line 36) | static int math_sinh (lua_State *L) {
function math_cos (line 41) | static int math_cos (lua_State *L) {
function math_cosh (line 46) | static int math_cosh (lua_State *L) {
function math_tan (line 51) | static int math_tan (lua_State *L) {
function math_tanh (line 56) | static int math_tanh (lua_State *L) {
function math_asin (line 61) | static int math_asin (lua_State *L) {
function math_acos (line 66) | static int math_acos (lua_State *L) {
function math_atan (line 71) | static int math_atan (lua_State *L) {
function math_atan2 (line 76) | static int math_atan2 (lua_State *L) {
function math_ceil (line 81) | static int math_ceil (lua_State *L) {
function math_floor (line 86) | static int math_floor (lua_State *L) {
function math_fmod (line 91) | static int math_fmod (lua_State *L) {
function math_modf (line 96) | static int math_modf (lua_State *L) {
function math_sqrt (line 104) | static int math_sqrt (lua_State *L) {
function math_pow (line 109) | static int math_pow (lua_State *L) {
function math_log (line 114) | static int math_log (lua_State *L) {
function math_log10 (line 119) | static int math_log10 (lua_State *L) {
function math_exp (line 124) | static int math_exp (lua_State *L) {
function math_deg (line 129) | static int math_deg (lua_State *L) {
function math_rad (line 134) | static int math_rad (lua_State *L) {
function math_frexp (line 139) | static int math_frexp (lua_State *L) {
function math_ldexp (line 146) | static int math_ldexp (lua_State *L) {
function math_min (line 153) | static int math_min (lua_State *L) {
function math_max (line 167) | static int math_max (lua_State *L) {
function math_random (line 181) | static int math_random (lua_State *L) {
function math_randomseed (line 209) | static int math_randomseed (lua_State *L) {
function math_erf (line 215) | static int math_erf (lua_State *L) {
function math_erfc (line 221) | static int math_erfc (lua_State *L) {
function LUALIB_API (line 265) | LUALIB_API int luaopen_math (lua_State *L) {
FILE: src/lua/loadlib.c
function ll_unloadlib (line 64) | static void ll_unloadlib (void *lib) {
function lua_CFunction (line 76) | static lua_CFunction ll_sym (lua_State *L, void *lib, const char *sym) {
function pusherror (line 96) | static void pusherror (lua_State *L) {
function ll_unloadlib (line 106) | static void ll_unloadlib (void *lib) {
function lua_CFunction (line 118) | static lua_CFunction ll_sym (lua_State *L, void *lib, const char *sym) {
function pusherror (line 143) | static void pusherror (lua_State *L) {
function ll_unloadlib (line 170) | static void ll_unloadlib (void *lib) {
function lua_CFunction (line 196) | static lua_CFunction ll_sym (lua_State *L, void *lib, const char *sym) {
function ll_unloadlib (line 223) | static void ll_unloadlib (void *lib) {
function lua_CFunction (line 235) | static lua_CFunction ll_sym (lua_State *L, void *lib, const char *sym) {
function gctm (line 270) | static int gctm (lua_State *L) {
function ll_loadfunc (line 278) | static int ll_loadfunc (lua_State *L, const char *path, const char *sym) {
function readable (line 300) | static int readable (const char *filename) {
function loaderror (line 355) | static void loaderror (lua_State *L, const char *filename) {
function loader_Lua (line 361) | static int loader_Lua (lua_State *L) {
function loader_C (line 383) | static int loader_C (lua_State *L) {
function loader_Croot (line 395) | static int loader_Croot (lua_State *L) {
function loader_preload (line 416) | static int loader_preload (lua_State *L) {
function add_empty_metatable (line 427) | static void add_empty_metatable(lua_State* L)
function remove_entries (line 438) | static void remove_entries(lua_State* L, const char* name)
function is_disabled (line 470) | static int is_disabled(lua_State* L, const char* name)
function ll_require (line 496) | static int ll_require (lua_State *L) {
function setfenv (line 557) | static void setfenv (lua_State *L) {
function dooptions (line 569) | static void dooptions (lua_State *L, int n) {
function modinit (line 579) | static void modinit (lua_State *L, const char *modname) {
function ll_module (line 594) | static int ll_module (lua_State *L) {
function ll_seeall (line 622) | static int ll_seeall (lua_State *L) {
function LUALIB_API (line 656) | LUALIB_API int luaopen_package (lua_State *L) {
FILE: src/lua/lobject.c
function luaO_int2fb (line 35) | int luaO_int2fb (unsigned int x) {
function luaO_fb2int (line 47) | int luaO_fb2int (int x) {
function luaO_log2 (line 54) | int luaO_log2 (unsigned int x) {
function luaO_rawequalObj (line 72) | int luaO_rawequalObj (const TValue *t1, const TValue *t2) {
function luaO_str2d (line 90) | int luaO_str2d (const char *s, lua_Number *result) {
function pushstr (line 104) | static void pushstr (lua_State *L, const char *str) {
function luaO_chunkid (line 182) | void luaO_chunkid (char *out, const char *source, size_t bufflen) {
FILE: src/lua/lobject.h
type GCObject (line 36) | typedef union GCObject GCObject;
type GCheader (line 49) | typedef struct GCheader {
type Value (line 59) | typedef union {
type TValue (line 73) | typedef struct lua_TValue {
type TValue (line 193) | typedef TValue *StkId;
type TString (line 199) | typedef union TString {
type Udata (line 215) | typedef union Udata {
type Proto (line 231) | typedef struct Proto {
type LocVar (line 262) | typedef struct LocVar {
type UpVal (line 274) | typedef struct UpVal {
type CClosure (line 295) | typedef struct CClosure {
type LClosure (line 302) | typedef struct LClosure {
type Closure (line 309) | typedef union Closure {
type TKey (line 323) | typedef union TKey {
type Node (line 332) | typedef struct Node {
type Table (line 338) | typedef struct Table {
FILE: src/lua/lopcodes.h
type OpMode (line 31) | enum OpMode {iABC, iABx, iAsBx}
type OpCode (line 150) | typedef enum {
type OpArgMask (line 245) | enum OpArgMask {
FILE: src/lua/loslib.c
function os_pushresult (line 23) | static int os_pushresult (lua_State *L, int i, const char *filename) {
function os_execute (line 93) | static int os_execute (lua_State *L) {
function os_remove (line 99) | static int os_remove (lua_State *L) {
function os_rename (line 105) | static int os_rename (lua_State *L) {
function os_tmpname (line 112) | static int os_tmpname (lua_State *L) {
function os_getenv (line 123) | static int os_getenv (lua_State *L) {
function os_clock (line 129) | static int os_clock (lua_State *L) {
function setfield (line 143) | static void setfield (lua_State *L, const char *key, int value) {
function setboolfield (line 148) | static void setboolfield (lua_State *L, const char *key, int value) {
function getboolfield (line 155) | static int getboolfield (lua_State *L, const char *key) {
function getfield (line 164) | static int getfield (lua_State *L, const char *key, int d) {
function os_date (line 203) | static int os_date (lua_State *L) {
function os_time (line 249) | static int os_time (lua_State *L) {
function os_difftime (line 274) | static int os_difftime (lua_State *L) {
function os_setlocale (line 283) | static int os_setlocale (lua_State *L) {
function os_exit (line 295) | static int os_exit (lua_State *L) {
function LUALIB_API (line 318) | LUALIB_API int luaopen_os (lua_State *L) {
FILE: src/lua/lparser.c
type BlockCnt (line 40) | typedef struct BlockCnt {
function anchor_token (line 57) | static void anchor_token (LexState *ls) {
function error_expected (line 65) | static void error_expected (LexState *ls, int token) {
function errorlimit (line 71) | static void errorlimit (FuncState *fs, int limit, const char *what) {
function testnext (line 80) | static int testnext (LexState *ls, int c) {
function check (line 89) | static void check (LexState *ls, int c) {
function checknext (line 94) | static void checknext (LexState *ls, int c) {
function check_match (line 104) | static void check_match (LexState *ls, int what, int who, int where) {
function TString (line 117) | static TString *str_checkname (LexState *ls) {
function init_exp (line 126) | static void init_exp (expdesc *e, expkind k, int i) {
function codestring (line 133) | static void codestring (LexState *ls, expdesc *e, TString *s) {
function checkname (line 138) | static void checkname(LexState *ls, expdesc *e) {
function registerlocalvar (line 143) | static int registerlocalvar (LexState *ls, TString *varname) {
function new_localvar (line 160) | static void new_localvar (LexState *ls, TString *name, int n) {
function adjustlocalvars (line 167) | static void adjustlocalvars (LexState *ls, int nvars) {
function removevars (line 176) | static void removevars (LexState *ls, int tolevel) {
function indexupvalue (line 183) | static int indexupvalue (FuncState *fs, TString *name, expdesc *v) {
function searchvar (line 207) | static int searchvar (FuncState *fs, TString *n) {
function markupval (line 217) | static void markupval (FuncState *fs, int level) {
function singlevaraux (line 224) | static int singlevaraux (FuncState *fs, TString *n, expdesc *var, int ba...
function singlevar (line 248) | static void singlevar (LexState *ls, expdesc *var) {
function adjust_assign (line 256) | static void adjust_assign (LexState *ls, int nvars, int nexps, expdesc *...
function enterlevel (line 276) | static void enterlevel (LexState *ls) {
function enterblock (line 285) | static void enterblock (FuncState *fs, BlockCnt *bl, lu_byte isbreakable) {
function leaveblock (line 296) | static void leaveblock (FuncState *fs) {
function pushclosure (line 310) | static void pushclosure (LexState *ls, FuncState *func, expdesc *v) {
function open_func (line 328) | static void open_func (LexState *ls, FuncState *fs) {
function close_func (line 356) | static void close_func (LexState *ls) {
function Proto (line 383) | Proto *luaY_parser (lua_State *L, ZIO *z, Mbuffer *buff, const char *nam...
function field (line 407) | static void field (LexState *ls, expdesc *v) {
function yindex (line 418) | static void yindex (LexState *ls, expdesc *v) {
type ConsControl (line 434) | struct ConsControl {
function recfield (line 443) | static void recfield (LexState *ls, struct ConsControl *cc) {
function closelistfield (line 464) | static void closelistfield (FuncState *fs, struct ConsControl *cc) {
function lastlistfield (line 475) | static void lastlistfield (FuncState *fs, struct ConsControl *cc) {
function listfield (line 490) | static void listfield (LexState *ls, struct ConsControl *cc) {
function constructor (line 498) | static void constructor (LexState *ls, expdesc *t) {
function parlist (line 543) | static void parlist (LexState *ls) {
function body (line 576) | static void body (LexState *ls, expdesc *e, int needself, int line) {
function explist1 (line 596) | static int explist1 (LexState *ls, expdesc *v) {
function funcargs (line 609) | static void funcargs (LexState *ls, expdesc *f) {
function prefixexp (line 667) | static void prefixexp (LexState *ls, expdesc *v) {
function primaryexp (line 690) | static void primaryexp (LexState *ls, expdesc *v) {
function simpleexp (line 727) | static void simpleexp (LexState *ls, expdesc *v) {
function UnOpr (line 778) | static UnOpr getunopr (int op) {
function BinOpr (line 788) | static BinOpr getbinopr (int op) {
function BinOpr (line 828) | static BinOpr subexpr (LexState *ls, expdesc *v, unsigned int limit) {
function expr (line 856) | static void expr (LexState *ls, expdesc *v) {
function block_follow (line 871) | static int block_follow (int token) {
function block (line 881) | static void block (LexState *ls) {
type LHS_assign (line 896) | struct LHS_assign {
function check_conflict (line 908) | static void check_conflict (LexState *ls, struct LHS_assign *lh, expdesc...
function assignment (line 931) | static void assignment (LexState *ls, struct LHS_assign *lh, int nvars) {
function cond (line 965) | static int cond (LexState *ls) {
function breakstat (line 975) | static void breakstat (LexState *ls) {
function whilestat (line 991) | static void whilestat (LexState *ls, int line) {
function repeatstat (line 1010) | static void repeatstat (LexState *ls, int line) {
function exp1 (line 1036) | static int exp1 (LexState *ls) {
function forbody (line 1046) | static void forbody (LexState *ls, int base, int line, int nvars, int is...
function fornum (line 1067) | static void fornum (LexState *ls, TString *varname, int line) {
function forlist (line 1089) | static void forlist (LexState *ls, TString *indexname) {
function forstat (line 1112) | static void forstat (LexState *ls, int line) {
FILE: src/lua/lparser.h
type expkind (line 19) | typedef enum {
type expdesc (line 37) | typedef struct expdesc {
type upvaldesc (line 48) | typedef struct upvaldesc {
type BlockCnt (line 54) | struct BlockCnt
type FuncState (line 58) | typedef struct FuncState {
FILE: src/lua/lstate.c
type LG (line 35) | typedef struct LG {
function stack_init (line 42) | static void stack_init (lua_State *L1, lua_State *L) {
function freestack (line 61) | static void freestack (lua_State *L, lua_State *L1) {
function f_luaopen (line 70) | static void f_luaopen (lua_State *L, void *ud) {
function preinit_state (line 84) | static void preinit_state (lua_State *L, global_State *g) {
function close_state (line 105) | static void close_state (lua_State *L) {
function lua_State (line 119) | lua_State *luaE_newthread (lua_State *L) {
function luaE_freethread (line 134) | void luaE_freethread (lua_State *L, lua_State *L1) {
function LUA_API (line 143) | LUA_API lua_State *lua_newstate (lua_Alloc f, void *ud) {
function callallgcTM (line 193) | static void callallgcTM (lua_State *L, void *ud) {
function LUA_API (line 199) | LUA_API void lua_close (lua_State *L) {
FILE: src/lua/lstate.h
type lua_longjmp (line 18) | struct lua_longjmp
type stringtable (line 38) | typedef struct stringtable {
type CallInfo (line 48) | typedef struct CallInfo {
type global_State (line 68) | typedef struct global_State {
type lua_State (line 100) | struct lua_State {
type Table (line 141) | struct Table
type Proto (line 142) | struct Proto
type UpVal (line 143) | struct UpVal
type lua_State (line 144) | struct lua_State
FILE: src/lua/lstring.c
function luaS_resize (line 22) | void luaS_resize (lua_State *L, int newsize) {
function TString (line 50) | static TString *newlstr (lua_State *L, const char *str, size_t l,
function TString (line 75) | TString *luaS_newlstr (lua_State *L, const char *str, size_t l) {
function Udata (line 96) | Udata *luaS_newudata (lua_State *L, size_t s, Table *e) {
FILE: src/lua/lstrlib.c
function str_len (line 28) | static int str_len (lua_State *L) {
function posrelat (line 36) | static ptrdiff_t posrelat (ptrdiff_t pos, size_t len) {
function str_sub (line 43) | static int str_sub (lua_State *L) {
function str_reverse (line 57) | static int str_reverse (lua_State *L) {
function str_lower (line 68) | static int str_lower (lua_State *L) {
function str_upper (line 81) | static int str_upper (lua_State *L) {
function str_rep (line 93) | static int str_rep (lua_State *L) {
function str_byte (line 106) | static int str_byte (lua_State *L) {
function str_char (line 125) | static int str_char (lua_State *L) {
function writer (line 140) | static int writer (lua_State *L, const void* b, size_t size, void* B) {
function str_dump (line 147) | static int str_dump (lua_State *L) {
type MatchState (line 170) | typedef struct MatchState {
function check_capture (line 186) | static int check_capture (MatchState *ms, int l) {
function capture_to_close (line 194) | static int capture_to_close (MatchState *ms) {
function match_class (line 226) | static int match_class (int c, int cl) {
function matchbracketclass (line 245) | static int matchbracketclass (int c, const char *p, const char *ec) {
function singlematch (line 268) | static int singlematch (int c, const char *p, const char *ep) {
function push_onecapture (line 466) | static void push_onecapture (MatchState *ms, int i, const char *s,
function push_captures (line 485) | static int push_captures (MatchState *ms, const char *s, const char *e) {
function str_find_aux (line 495) | static int str_find_aux (lua_State *L, int find) {
function str_find (line 538) | static int str_find (lua_State *L) {
function str_match (line 543) | static int str_match (lua_State *L) {
function gmatch_aux (line 548) | static int gmatch_aux (lua_State *L) {
function gmatch (line 574) | static int gmatch (lua_State *L) {
function gfind_nodef (line 584) | static int gfind_nodef (lua_State *L) {
function add_s (line 590) | static void add_s (MatchState *ms, luaL_Buffer *b, const char *s,
function add_value (line 612) | static void add_value (MatchState *ms, luaL_Buffer *b, const char *s,
function str_gsub (line 644) | static int str_gsub (lua_State *L) {
function addquoted (line 696) | static void addquoted (lua_State *L, luaL_Buffer *b, int arg) {
function addintlen (line 747) | static void addintlen (char *form) {
function str_format (line 756) | static int str_format (lua_State *L) {
function createmetatable (line 847) | static void createmetatable (lua_State *L) {
function LUALIB_API (line 862) | LUALIB_API int luaopen_string (lua_State *L) {
FILE: src/lua/ltable.c
function Node (line 84) | static Node *hashnum (const Table *t, lua_Number n) {
function Node (line 100) | static Node *mainposition (const Table *t, const TValue *key) {
function arrayindex (line 120) | static int arrayindex (const TValue *key) {
function findindex (line 137) | static int findindex (lua_State *L, Table *t, StkId key) {
function luaH_next (line 162) | int luaH_next (lua_State *L, Table *t, StkId key) {
function computesizes (line 189) | static int computesizes (int nums[], int *narray) {
function countint (line 211) | static int countint (const TValue *key, int *nums) {
function numusearray (line 222) | static int numusearray (const Table *t, int *nums) {
function numusehash (line 247) | static int numusehash (const Table *t, int *nums, int *pnasize) {
function setarrayvector (line 263) | static void setarrayvector (lua_State *L, Table *t, int size) {
function setnodevector (line 272) | static void setnodevector (lua_State *L, Table *t, int size) {
function resize (line 297) | static void resize (lua_State *L, Table *t, int nasize, int nhsize) {
function luaH_resizearray (line 327) | void luaH_resizearray (lua_State *L, Table *t, int nasize) {
function rehash (line 333) | static void rehash (lua_State *L, Table *t, const TValue *ek) {
function Table (line 358) | Table *luaH_new (lua_State *L, int narray, int nhash) {
function luaH_free (line 374) | void luaH_free (lua_State *L, Table *t) {
function Node (line 382) | static Node *getfreepos (Table *t) {
function TValue (line 399) | static TValue *newkey (lua_State *L, Table *t, const TValue *key) {
function TValue (line 435) | const TValue *luaH_getnum (Table *t, int key) {
function TValue (line 455) | const TValue *luaH_getstr (Table *t, TString *key) {
function TValue (line 469) | const TValue *luaH_get (Table *t, const TValue *key) {
function TValue (line 495) | TValue *luaH_set (lua_State *L, Table *t, const TValue *key) {
function TValue (line 509) | TValue *luaH_setnum (lua_State *L, Table *t, int key) {
function TValue (line 521) | TValue *luaH_setstr (lua_State *L, Table *t, TString *key) {
function unbound_search (line 533) | static int unbound_search (Table *t, unsigned int j) {
function luaH_getn (line 561) | int luaH_getn (Table *t) {
function luaH_type (line 580) | int luaH_type (Table *t) {
function Node (line 590) | Node *luaH_mainposition (const Table *t, const TValue *key) {
function luaH_isdummy (line 594) | int luaH_isdummy (Node *n) { return n == dummynode; }
FILE: src/lua/ltablib.c
function foreachi (line 22) | static int foreachi (lua_State *L) {
function foreach (line 39) | static int foreach (lua_State *L) {
function maxn (line 56) | static int maxn (lua_State *L) {
function getn (line 72) | static int getn (lua_State *L) {
function setn (line 78) | static int setn (lua_State *L) {
function tinsert (line 90) | static int tinsert (lua_State *L) {
function tremove (line 118) | static int tremove (lua_State *L) {
function addfield (line 135) | static void addfield (lua_State *L, luaL_Buffer *b, int i) {
function tconcat (line 144) | static int tconcat (lua_State *L) {
function set2 (line 173) | static void set2 (lua_State *L, int i, int j) {
function sort_comp (line 178) | static int sort_comp (lua_State *L, int a, int b) {
function auxsort (line 193) | static void auxsort (lua_State *L, int l, int u) {
function sort (line 256) | static int sort (lua_State *L) {
function LUALIB_API (line 283) | LUALIB_API int luaopen_table (lua_State *L) {
FILE: src/lua/ltm.c
function luaT_init (line 30) | void luaT_init (lua_State *L) {
function TValue (line 50) | const TValue *luaT_gettm (Table *events, TMS event, TString *ename) {
function TValue (line 61) | const TValue *luaT_gettmbyobj (lua_State *L, const TValue *o, TMS event) {
FILE: src/lua/ltm.h
type TMS (line 18) | typedef enum {
FILE: src/lua/lundump.c
type LoadState (line 23) | typedef struct {
function error (line 36) | static void error(LoadState* S, const char* why)
function LoadBlock (line 48) | static void LoadBlock(LoadState* S, void* b, size_t size)
function LoadChar (line 54) | static int LoadChar(LoadState* S)
function LoadInt (line 61) | static int LoadInt(LoadState* S)
function lua_Number (line 69) | static lua_Number LoadNumber(LoadState* S)
function TString (line 76) | static TString* LoadString(LoadState* S)
function LoadCode (line 90) | static void LoadCode(LoadState* S, Proto* f)
function LoadConstants (line 100) | static void LoadConstants(LoadState* S, Proto* f)
function LoadDebug (line 137) | static void LoadDebug(LoadState* S, Proto* f)
function Proto (line 161) | static Proto* LoadFunction(LoadState* S, TString* p)
function LoadHeader (line 183) | static void LoadHeader(LoadState* S)
function Proto (line 195) | Proto* luaU_undump (lua_State* L, ZIO* Z, Mbuffer* buff, const char* name)
function luaU_header (line 214) | void luaU_header (char* h)
FILE: src/lua/lvm.c
function TValue (line 35) | const TValue *luaV_tonumber (const TValue *obj, TValue *n) {
function luaV_tostring (line 47) | int luaV_tostring (lua_State *L, StkId obj) {
function traceexec (line 60) | static void traceexec (lua_State *L, const Instruction *pc) {
function callTMres (line 80) | static void callTMres (lua_State *L, StkId res, const TValue *f,
function callTM (line 96) | static void callTM (lua_State *L, const TValue *f, const TValue *p1,
function luaV_gettable (line 108) | void luaV_gettable (lua_State *L, const TValue *t, TValue *key, StkId va...
function luaV_settable (line 134) | void luaV_settable (lua_State *L, const TValue *t, TValue *key, StkId va...
function call_binTM (line 165) | static int call_binTM (lua_State *L, const TValue *p1, const TValue *p2,
function TValue (line 176) | static const TValue *get_compTM (lua_State *L, Table *mt1, Table *mt2,
function call_orderTM (line 190) | static int call_orderTM (lua_State *L, const TValue *p1, const TValue *p2,
function l_strcmp (line 203) | static int l_strcmp (const TString *ls, const TString *rs) {
function luaV_lessthan (line 225) | int luaV_lessthan (lua_State *L, const TValue *l, const TValue *r) {
function lessequal (line 239) | static int lessequal (lua_State *L, const TValue *l, const TValue *r) {
function luaV_equalval (line 255) | int luaV_equalval (lua_State *L, const TValue *t1, const TValue *t2) {
function luaV_concat (line 282) | void luaV_concat (lua_State *L, int total, int last) {
function Arith (line 317) | static void Arith (lua_State *L, StkId ra, const TValue *rb,
function luaV_execute (line 377) | void luaV_execute (lua_State *L, int nexeccalls) {
FILE: src/lua/lzio.c
function luaZ_fill (line 21) | int luaZ_fill (ZIO *z) {
function luaZ_lookahead (line 35) | int luaZ_lookahead (ZIO *z) {
function luaZ_init (line 48) | void luaZ_init (lua_State *L, ZIO *z, lua_Reader reader, void *data) {
function luaZ_read (line 58) | size_t luaZ_read (ZIO *z, void *b, size_t n) {
FILE: src/lua/lzio.h
type ZIO (line 18) | typedef struct Zio ZIO;
type Mbuffer (line 24) | typedef struct Mbuffer {
type Zio (line 56) | struct Zio {
FILE: src/luasandbox.c
function libsize (line 45) | static int libsize(const luaL_Reg *l)
function preload_modules (line 52) | static void preload_modules(lua_State *lua)
function instruction_usage (line 108) | static size_t instruction_usage(lsb_lua_sandbox *lsb)
function instruction_manager (line 114) | static void instruction_manager(lua_State *lua, lua_Debug *ar)
function output (line 122) | static int output(lua_State *lua)
function output_print (line 138) | static int output_print(lua_State *lua)
function read_config (line 196) | static int read_config(lua_State *lua)
function unprotected_panic (line 210) | static int unprotected_panic(lua_State *lua)
function get_size (line 218) | static size_t get_size(lua_State *lua, int idx, const char *item)
function check_string (line 227) | static int check_string(lua_State *L, int idx, const char *name,
function check_unsigned (line 249) | static int check_unsigned(lua_State *L, int idx, const char *name, unsig...
function check_size (line 274) | static int check_size(lua_State *L, int idx, const char *name, size_t val)
function lua_State (line 299) | static lua_State* load_sandbox_config(const char *cfg, lsb_logger *logger)
function copy_table (line 347) | static void copy_table(lua_State *sb, lua_State *cfg, lsb_logger *logger)
function set_random_seed (line 420) | static void set_random_seed()
function lsb_lua_sandbox (line 448) | lsb_lua_sandbox* lsb_create(void *parent,
function lsb_err_value (line 548) | lsb_err_value lsb_init(lsb_lua_sandbox *lsb, const char *state_file)
function stop_hook (line 633) | static void stop_hook(lua_State *lua, lua_Debug *ar)
function lsb_stop_sandbox_clean (line 641) | void lsb_stop_sandbox_clean(lsb_lua_sandbox *lsb)
function lsb_stop_sandbox (line 650) | void lsb_stop_sandbox(lsb_lua_sandbox *lsb)
function lsb_usage (line 691) | size_t lsb_usage(lsb_lua_sandbox *lsb, lsb_usage_type utype,
function lsb_set_error (line 707) | void lsb_set_error(lsb_lua_sandbox *lsb, const char *err)
function lua_State (line 720) | lua_State* lsb_get_lua(lsb_lua_sandbox *lsb)
function lsb_logger (line 738) | const lsb_logger* lsb_get_logger(lsb_lua_sandbox *lsb)
function lsb_state (line 744) | lsb_state lsb_get_state(lsb_lua_sandbox *lsb)
function lsb_add_function (line 750) | void lsb_add_function(lsb_lua_sandbox *lsb, lua_CFunction func,
function lsb_err_value (line 761) | lsb_err_value lsb_pcall_setup(lsb_lua_sandbox *lsb, const char *func_name)
function lsb_pcall_teardown (line 785) | void lsb_pcall_teardown(lsb_lua_sandbox *lsb)
function lsb_terminate (line 799) | void lsb_terminate(lsb_lua_sandbox *lsb, const char *err)
FILE: src/luasandbox_impl.h
type lsb_lua_sandbox (line 16) | struct lsb_lua_sandbox {
FILE: src/luasandbox_output.c
function lsb_add_output_function (line 24) | void lsb_add_output_function(lua_State *lua, lua_CFunction fp)
function lua_CFunction (line 32) | lua_CFunction lsb_get_output_function(lua_State *lua, int index)
function lsb_add_zero_copy_function (line 44) | void lsb_add_zero_copy_function(lua_State *lua, lua_CFunction fp)
function lua_CFunction (line 52) | lua_CFunction lsb_get_zero_copy_function(lua_State *lua, int index)
function lsb_output (line 64) | void lsb_output(lsb_lua_sandbox *lsb, int start, int end, int append)
function lsb_output_coroutine (line 70) | void lsb_output_coroutine(lsb_lua_sandbox *lsb, lua_State *lua, int start,
FILE: src/luasandbox_serialize.c
type table_ref (line 25) | typedef struct
type table_ref_array (line 31) | typedef struct
type serialization_data (line 38) | typedef struct
function lua_CFunction (line 94) | static lua_CFunction get_serialize_function(lua_State *lua, int index)
function ignore_value_type (line 115) | static int
function table_ref (line 151) | static table_ref* find_table_ref(table_ref_array *tra, const void *ptr)
function table_ref (line 171) | static table_ref*
function get_preservation_version (line 197) | static int get_preservation_version(lua_State *lua)
function lsb_err_value (line 215) | static lsb_err_value
function lsb_err_value (line 230) | static lsb_err_value
function lsb_err_value (line 288) | static lsb_err_value
function lsb_err_value (line 374) | lsb_err_value preserve_global_data(lsb_lua_sandbox *lsb)
function file_exists (line 483) | static int file_exists(const char *fn)
function lsb_err_value (line 494) | lsb_err_value restore_global_data(lsb_lua_sandbox *lsb)
function lsb_add_serialize_function (line 529) | void lsb_add_serialize_function(lua_State *lua, lua_CFunction fp)
function lsb_err_value (line 537) | lsb_err_value lsb_serialize_binary(lsb_output_buffer *ob, const void *sr...
function lsb_err_value (line 564) | lsb_err_value lsb_serialize_double(lsb_output_buffer *ob, double d)
FILE: src/test/sandbox.c
function logger (line 24) | static void logger(void *context,
function lsb_test_write_output (line 42) | int lsb_test_write_output(lua_State *lua)
function lsb_test_process (line 56) | int lsb_test_process(lsb_lua_sandbox *lsb, double tc)
function lsb_test_report (line 118) | int lsb_test_report(lsb_lua_sandbox *lsb, double tc)
FILE: src/test/test_generic_sandbox.c
type test_ud (line 36) | typedef struct test_ud {
function ud_new (line 41) | static int ud_new(lua_State *lua)
function ud_serialize (line 58) | static int ud_serialize(lua_State *lua)
function ud_output (line 69) | static int ud_output(lua_State *lua)
type luaL_reg (line 78) | struct luaL_reg
function luaopen_ud (line 84) | static int luaopen_ud(lua_State *lua)
function add_ud_module (line 96) | static void add_ud_module(lsb_lua_sandbox *sb)
function file_exists (line 123) | int file_exists(const char *fn)
function print (line 135) | void print(void *context, const char *component, int level, const char *...
function main (line 927) | int main()
FILE: src/util/heka_message.c
function decode_header (line 20) | static size_t decode_header(char *buf,
function read_string_value (line 66) | static bool
function read_integer_value (line 87) | static bool
function read_double_value (line 106) | static bool
function lsb_decode_heka_message (line 212) | bool lsb_decode_heka_message(lsb_heka_message *m,
function lsb_find_heka_message (line 337) | bool lsb_find_heka_message(lsb_heka_message *m,
function lsb_err_value (line 435) | lsb_err_value lsb_init_heka_message(lsb_heka_message *m, int num_fields)
function lsb_clear_heka_message (line 449) | void lsb_clear_heka_message(lsb_heka_message *m)
function lsb_free_heka_message (line 470) | void lsb_free_heka_message(lsb_heka_message *m)
function lsb_read_heka_field (line 481) | bool lsb_read_heka_field(const lsb_heka_message *m,
function lsb_err_value (line 525) | lsb_err_value
function lsb_write_heka_header (line 581) | size_t lsb_write_heka_header(char *buf, size_t len)
FILE: src/util/heka_message_matcher.c
function string_test (line 22) | static bool string_test(match_node *mn, lsb_const_string *val)
function numeric_test (line 71) | static bool numeric_test(match_node *mn, double val)
function eval_node (line 95) | static bool eval_node(match_node *mn, lsb_heka_message *m)
function lsb_destroy_message_matcher (line 192) | void lsb_destroy_message_matcher(lsb_message_matcher *mm)
function lsb_eval_message_matcher (line 200) | bool lsb_eval_message_matcher(lsb_message_matcher *mm, lsb_heka_message *m)
FILE: src/util/heka_message_matcher_impl.h
type match_operation (line 15) | typedef enum {
type match_type (line 32) | typedef enum {
type match_pattern_mod (line 41) | typedef enum {
type indices (line 47) | struct indices {
type match_node (line 53) | typedef struct match_node {
type lsb_message_matcher (line 69) | struct lsb_message_matcher {
FILE: src/util/heka_message_matcher_parser.c
type match_node_tmp (line 34) | typedef struct match_node_tmp {
type match_node_array (line 52) | typedef struct match_node_array {
type input_string (line 59) | typedef struct input_string {
type context (line 66) | typedef struct context {
function init_match_node (line 98) | static void init_match_node(match_node_tmp *mn)
function move_match_node (line 104) | static void move_match_node(match_node_tmp *dest, match_node_tmp *src)
function realloc_mna (line 111) | static void realloc_mna(match_node_array *mna)
function push_output (line 125) | static void push_output(context *ctx, match_node_tmp *mn)
function push_op (line 134) | static void push_op(context *ctx, match_operation op)
function pop_to_paren (line 154) | static void pop_to_paren(context *ctx)
function pop_all_ops (line 164) | static void pop_all_ops(context *ctx)
function update_date (line 174) | static void update_date(context *ctx, int year, int mon, int day)
function update_time (line 183) | static void update_time(context *ctx, int hour, int minute, int sec)
function update_offset (line 191) | static void update_offset(context *ctx, char sign, int hour, int minute)
function set_field (line 197) | static void set_field(context *ctx, char *name)
function set_timestamp (line 210) | static void set_timestamp(context *ctx)
function set_numeric_value (line 222) | static void set_numeric_value(context *ctx, char *s)
function set_string_value (line 229) | static void set_string_value(context *ctx, char *s)
function set_match_mod (line 252) | static void set_match_mod(context *ctx)
function check_string_len (line 261) | static bool check_string_len(char *s)
function cond_cnt (line 274) | static int cond_cnt(context *ctx)
type yycontext (line 334) | typedef struct _yycontext yycontext;
type yythunk (line 336) | typedef struct _yythunk { int begin, end; yyaction action; struct _yy...
type _yycontext (line 338) | struct _yycontext {
function yyrefill (line 390) | YY_LOCAL(int) yyrefill(yycontext *yy)
function yymatchDot (line 408) | YY_LOCAL(int) yymatchDot(yycontext *yy)
function yymatchChar (line 415) | YY_LOCAL(int) yymatchChar(yycontext *yy, int c)
function yymatchString (line 428) | YY_LOCAL(int) yymatchString(yycontext *yy, const char *s)
function yymatchClass (line 445) | YY_LOCAL(int) yymatchClass(yycontext *yy, unsigned char *bits)
function yyDo (line 460) | YY_LOCAL(void) yyDo(yycontext *yy, yyaction action, int begin, int end)
function yyText (line 473) | YY_LOCAL(int) yyText(yycontext *yy, int begin, int end)
function yyDone (line 491) | YY_LOCAL(void) yyDone(yycontext *yy)
function yyCommit (line 504) | YY_LOCAL(void) yyCommit(yycontext *yy)
function yyAccept (line 515) | YY_LOCAL(int) yyAccept(yycontext *yy, int tp0)
function yyPush (line 530) | YY_LOCAL(void) yyPush(yycontext *yy, char *text, int count)
function yyPop (line 543) | YY_LOCAL(void) yyPop(yycontext *yy, char *text, int count) { yy->__val...
function yySet (line 544) | YY_LOCAL(void) yySet(yycontext *yy, char *text, int count) { yy->__val...
function yy_1_nil (line 607) | YY_ACTION(void) yy_1_nil(yycontext *yy, char *yytext, int yyleng)
function yy_1_second_frac (line 621) | YY_ACTION(void) yy_1_second_frac(yycontext *yy, char *yytext, int yyleng)
function yy_1_second (line 635) | YY_ACTION(void) yy_1_second(yycontext *yy, char *yytext, int yyleng)
function yy_1_minute (line 649) | YY_ACTION(void) yy_1_minute(yycontext *yy, char *yytext, int yyleng)
function yy_1_hour (line 663) | YY_ACTION(void) yy_1_hour(yycontext *yy, char *yytext, int yyleng)
function yy_2_timeoffset (line 677) | YY_ACTION(void) yy_2_timeoffset(yycontext *yy, char *yytext, int yyleng)
function yy_1_timeoffset (line 695) | YY_ACTION(void) yy_1_timeoffset(yycontext *yy, char *yytext, int yyleng)
function yy_1_partialtime (line 713) | YY_ACTION(void) yy_1_partialtime(yycontext *yy, char *yytext, int yyleng)
function yy_1_day (line 733) | YY_ACTION(void) yy_1_day(yycontext *yy, char *yytext, int yyleng)
function yy_1_month (line 747) | YY_ACTION(void) yy_1_month(yycontext *yy, char *yytext, int yyleng)
function yy_1_year (line 761) | YY_ACTION(void) yy_1_year(yycontext *yy, char *yytext, int yyleng)
function yy_1_fulldate (line 775) | YY_ACTION(void) yy_1_fulldate(yycontext *yy, char *yytext, int yyleng)
function yy_1_timestamp (line 795) | YY_ACTION(void) yy_1_timestamp(yycontext *yy, char *yytext, int yyleng)
function yy_1_index (line 809) | YY_ACTION(void) yy_1_index(yycontext *yy, char *yytext, int yyleng)
function yy_3_fields (line 823) | YY_ACTION(void) yy_3_fields(yycontext *yy, char *yytext, int yyleng)
function yy_2_fields (line 841) | YY_ACTION(void) yy_2_fields(yycontext *yy, char *yytext, int yyleng)
function yy_1_fields (line 859) | YY_ACTION(void) yy_1_fields(yycontext *yy, char *yytext, int yyleng)
function yy_1_numeric_value (line 877) | YY_ACTION(void) yy_1_numeric_value(yycontext *yy, char *yytext, int yyleng)
function yy_1_pid (line 891) | YY_ACTION(void) yy_1_pid(yycontext *yy, char *yytext, int yyleng)
function yy_1_severity (line 905) | YY_ACTION(void) yy_1_severity(yycontext *yy, char *yytext, int yyleng)
function yy_1_string_match_mod (line 919) | YY_ACTION(void) yy_1_string_match_mod(yycontext *yy, char *yytext, int y...
function yy_1_string_match (line 933) | YY_ACTION(void) yy_1_string_match(yycontext *yy, char *yytext, int yyleng)
function yy_1_string_value (line 947) | YY_ACTION(void) yy_1_string_value(yycontext *yy, char *yytext, int yyleng)
function yy_5_string_headers (line 961) | YY_ACTION(void) yy_5_string_headers(yycontext *yy, char *yytext, int yyl...
function yy_4_string_headers (line 975) | YY_ACTION(void) yy_4_string_headers(yycontext *yy, char *yytext, int yyl...
function yy_3_string_headers (line 989) | YY_ACTION(void) yy_3_string_headers(yycontext *yy, char *yytext, int yyl...
function yy_2_string_headers (line 1003) | YY_ACTION(void) yy_2_string_headers(yycontext *yy, char *yytext, int yyl...
function yy_1_string_headers (line 1017) | YY_ACTION(void) yy_1_string_headers(yycontext *yy, char *yytext, int yyl...
function yy_1_uuid (line 1031) | YY_ACTION(void) yy_1_uuid(yycontext *yy, char *yytext, int yyleng)
function yy_1_close (line 1045) | YY_ACTION(void) yy_1_close(yycontext *yy, char *yytext, int yyleng)
function yy_1_open (line 1059) | YY_ACTION(void) yy_1_open(yycontext *yy, char *yytext, int yyleng)
function yy_1_or (line 1073) | YY_ACTION(void) yy_1_or(yycontext *yy, char *yytext, int yyleng)
function yy_1_and (line 1087) | YY_ACTION(void) yy_1_and(yycontext *yy, char *yytext, int yyleng)
function yy_2_boolean (line 1101) | YY_ACTION(void) yy_2_boolean(yycontext *yy, char *yytext, int yyleng)
function yy_1_boolean (line 1115) | YY_ACTION(void) yy_1_boolean(yycontext *yy, char *yytext, int yyleng)
function yy_2_boolean_test (line 1129) | YY_ACTION(void) yy_2_boolean_test(yycontext *yy, char *yytext, int yyleng)
function yy_1_boolean_test (line 1143) | YY_ACTION(void) yy_1_boolean_test(yycontext *yy, char *yytext, int yyleng)
function yy_1_op_lt (line 1157) | YY_ACTION(void) yy_1_op_lt(yycontext *yy, char *yytext, int yyleng)
function yy_1_op_lte (line 1171) | YY_ACTION(void) yy_1_op_lte(yycontext *yy, char *yytext, int yyleng)
function yy_1_op_gt (line 1185) | YY_ACTION(void) yy_1_op_gt(yycontext *yy, char *yytext, int yyleng)
function yy_1_op_gte (line 1199) | YY_ACTION(void) yy_1_op_gte(yycontext *yy, char *yytext, int yyleng)
function yy_1_op_sne (line 1213) | YY_ACTION(void) yy_1_op_sne(yycontext *yy, char *yytext, int yyleng)
function yy_1_op_seq (line 1227) | YY_ACTION(void) yy_1_op_seq(yycontext *yy, char *yytext, int yyleng)
function yy_1_op_ne (line 1241) | YY_ACTION(void) yy_1_op_ne(yycontext *yy, char *yytext, int yyleng)
function yy_1_op_eq (line 1255) | YY_ACTION(void) yy_1_op_eq(yycontext *yy, char *yytext, int yyleng)
function yy_1_test (line 1269) | YY_ACTION(void) yy_1_test(yycontext *yy, char *yytext, int yyleng)
function yy_1_match (line 1283) | YY_ACTION(void) yy_1_match(yycontext *yy, char *yytext, int yyleng)
function yy_second_frac (line 1298) | YY_RULE(int) yy_second_frac(yycontext *yy)
function yy_second (line 1319) | YY_RULE(int) yy_second(yycontext *yy)
function yy_minute (line 1356) | YY_RULE(int) yy_minute(yycontext *yy)
function yy_hour (line 1377) | YY_RULE(int) yy_hour(yycontext *yy)
function yy_timeoffset (line 1414) | YY_RULE(int) yy_timeoffset(yycontext *yy)
function yy_partialtime (line 1439) | YY_RULE(int) yy_partialtime(yycontext *yy)
function yy_fulltime (line 1452) | YY_RULE(int) yy_fulltime(yycontext *yy)
function yy_day (line 1461) | YY_RULE(int) yy_day(yycontext *yy)
function yy_month (line 1511) | YY_RULE(int) yy_month(yycontext *yy)
function yy_year (line 1548) | YY_RULE(int) yy_year(yycontext *yy)
function yy_fulldate (line 1569) | YY_RULE(int) yy_fulldate(yycontext *yy)
function yy_rfc3339 (line 1578) | YY_RULE(int) yy_rfc3339(yycontext *yy)
function yy_ts_quoted (line 1587) | YY_RULE(int) yy_ts_quoted(yycontext *yy)
function yy_zero_to_255 (line 1600) | YY_RULE(int) yy_zero_to_255(yycontext *yy)
function yy_index (line 1615) | YY_RULE(int) yy_index(yycontext *yy)
function yy_fields (line 1636) | YY_RULE(int) yy_fields(yycontext *yy)
function yy_exponent (line 1669) | YY_RULE(int) yy_exponent(yycontext *yy)
function yy_decimal (line 1686) | YY_RULE(int) yy_decimal(yycontext *yy)
function yy_number (line 1699) | YY_RULE(int) yy_number(yycontext *yy)
function yy_sign (line 1716) | YY_RULE(int) yy_sign(yycontext *yy)
function yy_numeric_value (line 1725) | YY_RULE(int) yy_numeric_value(yycontext *yy)
function yy_string_match_mod (line 1758) | YY_RULE(int) yy_string_match_mod(yycontext *yy)
function yy_nil (line 1767) | YY_RULE(int) yy_nil(yycontext *yy)
function yy_string_match (line 1776) | YY_RULE(int) yy_string_match(yycontext *yy)
function yy_string_value (line 1793) | YY_RULE(int) yy_string_value(yycontext *yy)
function yy_string_headers (line 1858) | YY_RULE(int) yy_string_headers(yycontext *yy)
function yy_boolean (line 1874) | YY_RULE(int) yy_boolean(yycontext *yy)
function yy_false (line 1887) | YY_RULE(int) yy_false(yycontext *yy)
function yy_true (line 1896) | YY_RULE(int) yy_true(yycontext *yy)
function yy_relational (line 1905) | YY_RULE(int) yy_relational(yycontext *yy)
function yy_op_lt (line 1922) | YY_RULE(int) yy_op_lt(yycontext *yy)
function yy_op_lte (line 1931) | YY_RULE(int) yy_op_lte(yycontext *yy)
function yy_op_gt (line 1940) | YY_RULE(int) yy_op_gt(yycontext *yy)
function yy_op_gte (line 1949) | YY_RULE(int) yy_op_gte(yycontext *yy)
function yy_op_sne (line 1958) | YY_RULE(int) yy_op_sne(yycontext *yy)
function yy_op_seq (line 1967) | YY_RULE(int) yy_op_seq(yycontext *yy)
function yy_op_ne (line 1976) | YY_RULE(int) yy_op_ne(yycontext *yy)
function yy_op_eq (line 1985) | YY_RULE(int) yy_op_eq(yycontext *yy)
function yy_boolean_test (line 1994) | YY_RULE(int) yy_boolean_test(yycontext *yy)
function yy_field_test (line 2007) | YY_RULE(int) yy_field_test(yycontext *yy)
function yy_pid (line 2033) | YY_RULE(int) yy_pid(yycontext *yy)
function yy_severity (line 2050) | YY_RULE(int) yy_severity(yycontext *yy)
function yy_optional_string_headers (line 2059) | YY_RULE(int) yy_optional_string_headers(yycontext *yy)
function yy_timestamp (line 2077) | YY_RULE(int) yy_timestamp(yycontext *yy)
function yy_uuid (line 2090) | YY_RULE(int) yy_uuid(yycontext *yy)
function yy_close (line 2103) | YY_RULE(int) yy_close(yycontext *yy)
function yy_open (line 2112) | YY_RULE(int) yy_open(yycontext *yy)
function yy_test (line 2121) | YY_RULE(int) yy_test(yycontext *yy)
function yy_and (line 2139) | YY_RULE(int) yy_and(yycontext *yy)
function yy_expr (line 2154) | YY_RULE(int) yy_expr(yycontext *yy)
function yy_or (line 2167) | YY_RULE(int) yy_or(yycontext *yy)
function yy_anded (line 2182) | YY_RULE(int) yy_anded(yycontext *yy)
function yy_eol (line 2195) | YY_RULE(int) yy_eol(yycontext *yy)
function yy_ored (line 2207) | YY_RULE(int) yy_ored(yycontext *yy)
function yy_sp (line 2220) | YY_RULE(int) yy_sp(yycontext *yy)
function yy_match (line 2230) | YY_RULE(int) yy_match(yycontext *yy)
function YYPARSEFROM (line 2244) | YY_PARSE(int) YYPARSEFROM(YY_CTX_PARAM_ yyrule yystart)
function YYPARSE (line 2269) | YY_PARSE(int) YYPARSE(YY_CTX_PARAM)
function YYRELEASE (line 2274) | YY_PARSE(yycontext *) YYRELEASE(yycontext *yyctx)
function match_node (line 2291) | static match_node* copy_node(unsigned char parent, match_node *mn,
function match_node (line 2346) | static match_node* inorder_traverse(unsigned char parent, match_node **o...
function get_matcher_bytes (line 2366) | static size_t get_matcher_bytes(match_node_tmp nodes[], size_t size)
function make_tree (line 2399) | static void make_tree(match_node_tmp nodes[], size_t size)
function lsb_message_matcher (line 2417) | static lsb_message_matcher* make_matcher(match_node_tmp nodes[], size_t ...
function lsb_message_matcher (line 2450) | lsb_message_matcher* lsb_create_message_matcher(const char *exp)
FILE: src/util/input_buffer.c
function lsb_err_value (line 19) | lsb_err_value
function lsb_free_input_buffer (line 36) | void lsb_free_input_buffer(lsb_input_buffer *b)
function lsb_err_value (line 49) | lsb_err_value lsb_expand_input_buffer(lsb_input_buffer *b, size_t len)
FILE: src/util/output_buffer.c
function lsb_err_value (line 26) | lsb_err_value
function lsb_free_output_buffer (line 42) | void lsb_free_output_buffer(lsb_output_buffer *b)
function lsb_err_value (line 52) | lsb_err_value lsb_expand_output_buffer(lsb_output_buffer *b, size_t needed)
function lsb_err_value (line 78) | lsb_err_value lsb_outputc(lsb_output_buffer *b, char ch)
function lsb_err_value (line 92) | lsb_err_value lsb_outputf(lsb_output_buffer *b, const char *fmt, ...)
function lsb_err_value (line 146) | lsb_err_value lsb_outputs(lsb_output_buffer *b, const char *str, size_t ...
function lsb_err_value (line 161) | lsb_err_value lsb_outputd(lsb_output_buffer *b, double d)
function lsb_err_value (line 178) | lsb_err_value lsb_outputfd(lsb_output_buffer *b, double d)
FILE: src/util/protobuf.c
function lsb_err_value (line 25) | lsb_err_value lsb_pb_write_key(lsb_output_buffer *ob, unsigned char tag,
function lsb_pb_output_varint (line 56) | int lsb_pb_output_varint(char *buf, unsigned long long i)
function lsb_err_value (line 75) | lsb_err_value lsb_pb_write_varint(lsb_output_buffer *ob, unsigned long l...
function lsb_err_value (line 85) | lsb_err_value lsb_pb_write_bool(lsb_output_buffer *ob, int i)
function lsb_err_value (line 99) | lsb_err_value lsb_pb_write_double(lsb_output_buffer *ob, double i)
function lsb_err_value (line 113) | lsb_err_value
function lsb_err_value (line 127) | lsb_err_value lsb_pb_update_field_length(lsb_output_buffer *ob, size_t l...
FILE: src/util/running_stats.c
function lsb_init_running_stats (line 13) | void lsb_init_running_stats(lsb_running_stats *s)
function lsb_update_running_stats (line 21) | void lsb_update_running_stats(lsb_running_stats *s, double d)
function lsb_sd_running_stats (line 37) | double lsb_sd_running_stats(lsb_running_stats *s)
FILE: src/util/string.c
function lsb_init_const_string (line 15) | void lsb_init_const_string(lsb_const_string *s)
FILE: src/util/string_matcher.c
type MatchState (line 35) | typedef struct MatchState {
function match_class (line 66) | static int match_class(int c, int cl)
function matchbracketclass (line 97) | static int matchbracketclass(int c, const char *p, const char *ec)
function singlematch (line 117) | static int singlematch(int c, const char *p, const char *ep)
function lsb_string_match (line 282) | bool lsb_string_match(const char *s, size_t len, const char *p)
function lsb_string_find (line 300) | bool lsb_string_find(const char *s, size_t ls, const char *p, size_t lp)
FILE: src/util/test/test_heka_message.c
type log_message (line 26) | struct log_message {
type log_message (line 32) | struct log_message
function log_cb (line 34) | void log_cb(void *context, const char *component, int severity, const ch...
type decode_failure (line 108) | struct decode_failure {
type decode_failure (line 113) | struct decode_failure
type decode_failure (line 145) | struct decode_failure
type find_message (line 158) | struct find_message {
type find_message (line 166) | struct find_message
type find_message (line 190) | struct find_message
function main (line 398) | int main()
FILE: src/util/test/test_heka_message_matcher.c
function main (line 457) | int main()
FILE: src/util/test/test_input_buffer.c
function main (line 149) | int main()
FILE: src/util/test/test_output_buffer.c
function main (line 270) | int main()
FILE: src/util/test/test_protobuf.c
type test_data (line 60) | struct test_data {
type test_data (line 65) | struct test_data
function main (line 246) | int main()
FILE: src/util/test/test_running_stats.c
function main (line 80) | int main()
FILE: src/util/test/test_string.c
type testcase (line 20) | typedef struct {
function main (line 100) | int main()
FILE: src/util/test/test_string_matcher.c
function main (line 182) | int main()
FILE: src/util/test/test_util.c
function main (line 124) | int main()
FILE: src/util/util.c
function lsb_lp2 (line 35) | size_t lsb_lp2(unsigned long long x)
function lsb_get_time (line 75) | unsigned long long lsb_get_time()
function lsb_get_timestamp (line 114) | long long lsb_get_timestamp()
function lsb_set_tz (line 143) | bool lsb_set_tz(const char *tz)
Condensed preview — 162 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (1,110K chars).
[
{
"path": ".gitattributes",
"chars": 19,
"preview": "*.data text eol=lf\n"
},
{
"path": ".gitignore",
"chars": 59,
"preview": "*.preserve\nrelease/\nsrc/test/modules/\nTesting\n*~\ngh-pages/\n"
},
{
"path": ".travis.yml",
"chars": 427,
"preview": "language: generic\nsudo: required\nservices:\n - docker\n\nenv:\n matrix:\n - DOCKER_IMAGE=centos:7 CMAKE_URL=auto\n "
},
{
"path": "CMakeLists.txt",
"chars": 2343,
"preview": "# This Source Code Form is subject to the terms of the Mozilla Public\n# License, v. 2.0. If a copy of the MPL was not di"
},
{
"path": "CODE_OF_CONDUCT.md",
"chars": 691,
"preview": "# Community Participation Guidelines\n\nThis repository is governed by Mozilla's code of conduct and etiquette guidelines."
},
{
"path": "LICENSE.txt",
"chars": 199,
"preview": "# This Source Code Form is subject to the terms of the Mozilla Public\n# License, v. 2.0. If a copy of the MPL was not di"
},
{
"path": "README.md",
"chars": 3177,
"preview": "# Lua Sandbox Library\n\n## Overview\n\nSandboxes provide a dynamic and isolated execution environment\nfor data parsing, tra"
},
{
"path": "build/functions.sh",
"chars": 6180,
"preview": "#!/bin/sh\n\n# This Source Code Form is subject to the terms of the Mozilla Public\n# License, v. 2.0. If a copy of the MPL"
},
{
"path": "build/run.sh",
"chars": 389,
"preview": "#!/bin/sh\n\n# This Source Code Form is subject to the terms of the Mozilla Public\n# License, v. 2.0. If a copy of the MPL"
},
{
"path": "cmake/doxygen.cmake",
"chars": 1972,
"preview": "# This Source Code Form is subject to the terms of the Mozilla Public\n# License, v. 2.0. If a copy of the MPL was not di"
},
{
"path": "cmake/luasandboxConfig.cmake.in",
"chars": 665,
"preview": "set(LUASANDBOX_VERSION x.y.z)\n\n@PACKAGE_INIT@\n\nset_and_check(LUASANDBOX_INCLUDE_DIR \"@PACKAGE_CMAKE_INSTALL_INCLUDEDIR@\""
},
{
"path": "cmake/mozsvc.cmake",
"chars": 2233,
"preview": "# This Source Code Form is subject to the terms of the Mozilla Public\n# License, v. 2.0. If a copy of the MPL was not di"
},
{
"path": "covfn.txt",
"chars": 25438,
"preview": "Function Source "
},
{
"path": "docs/cli/index.md",
"chars": 825,
"preview": "# Command Line Interface Tools\n\n## lsb_heka_cat\n\nA command-line utility for counting, viewing, filtering, and extracting"
},
{
"path": "docs/heka/analysis.md",
"chars": 6737,
"preview": "# Analysis Sandbox Interface\n\n## Recommendations\nSince the sandbox does not run in isolation there are some expectations"
},
{
"path": "docs/heka/index.md",
"chars": 2233,
"preview": "# Heka Sandbox Interface\n\n## Overview\n\nThis document describes the 1.0 release of the Heka sandbox API built on the\n[Gen"
},
{
"path": "docs/heka/input.md",
"chars": 6439,
"preview": "# Input Sandbox Interface\n\n## Recommendations\nSince the sandbox does not run in isolation there are some expectations of"
},
{
"path": "docs/heka/message.md",
"chars": 1172,
"preview": "# Heka Message Table\n\n## Hash Based Message Fields\n\n```lua\n{\nUuid = \"data\", -- restricted header, a"
},
{
"path": "docs/heka/output.md",
"chars": 13060,
"preview": "# Output Sandbox Interface\n\n## Recommendations\nSince the sandbox does not run in isolation there are some expectations o"
},
{
"path": "docs/index.md",
"chars": 1461,
"preview": "# Overview\n\nSandboxes provide a dynamic and isolated execution environment\nfor data parsing, transformation, and analysi"
},
{
"path": "docs/sandbox.md",
"chars": 6126,
"preview": "# Generic Sandbox Interface\n\n## Configuration\n\n* **input_limit** - the largest input string that is allowed to be proces"
},
{
"path": "docs/util/message_matcher.md",
"chars": 2511,
"preview": "# Message Matcher Syntax\n\nThe message matcher allows sandboxes to select which messages they want to\nconsume (see [Heka "
},
{
"path": "gen_gh_pages.lua",
"chars": 1771,
"preview": "-- This Source Code Form is subject to the terms of the Mozilla Public\n-- License, v. 2.0. If a copy of the MPL was not "
},
{
"path": "include/luasandbox/error.h",
"chars": 943,
"preview": "/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n/* vim: set ts=2 et sw=2 tw=80: */\n/* This"
},
{
"path": "include/luasandbox/heka/sandbox.h",
"chars": 13129,
"preview": "/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n/* vim: set ts=2 et sw=2 tw=80: */\n/* This"
},
{
"path": "include/luasandbox/heka/stream_reader.h",
"chars": 722,
"preview": "/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n/* vim: set ts=2 et sw=2 tw=80: */\n/* This"
},
{
"path": "include/luasandbox/lauxlib.h",
"chars": 5777,
"preview": "/*\n** $Id: lauxlib.h,v 1.88.1.1 2007/12/27 13:02:25 roberto Exp $\n** Auxiliary functions for building Lua libraries\n** S"
},
{
"path": "include/luasandbox/lua.h",
"chars": 11964,
"preview": "/*\n** $Id: lua.h,v 1.218.1.7 2012/01/13 20:36:20 roberto Exp $\n** Lua - An Extensible Extension Language\n** Lua.org, PUC"
},
{
"path": "include/luasandbox/luaconf.h",
"chars": 22484,
"preview": "/*\n** $Id: luaconf.h,v 1.82.1.7 2008/02/11 16:25:08 roberto Exp $\n** Configuration file for Lua\n** See Copyright Notice "
},
{
"path": "include/luasandbox/lualib.h",
"chars": 1107,
"preview": "/*\n** $Id: lualib.h,v 1.36.1.1 2007/12/27 13:02:25 roberto Exp $\n** Lua standard libraries\n** See Copyright Notice in lu"
},
{
"path": "include/luasandbox/test/mu_test.h",
"chars": 3258,
"preview": "/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n/* vim: set ts=2 et sw=2 tw=80: */\n/* This"
},
{
"path": "include/luasandbox/test/sandbox.h",
"chars": 2153,
"preview": "/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n/* vim: set ts=2 et sw=2 tw=80: */\n/* This"
},
{
"path": "include/luasandbox/util/heka_message.h",
"chars": 6145,
"preview": "/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n/* vim: set ts=2 et sw=2 tw=80: */\n/* This"
},
{
"path": "include/luasandbox/util/heka_message_matcher.h",
"chars": 1334,
"preview": "/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n/* vim: set ts=2 et sw=2 tw=80: */\n/* This"
},
{
"path": "include/luasandbox/util/input_buffer.h",
"chars": 1805,
"preview": "/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n/* vim: set ts=2 et sw=2 tw=80: */\n/* This"
},
{
"path": "include/luasandbox/util/output_buffer.h",
"chars": 3217,
"preview": "/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n/* vim: set ts=2 et sw=2 tw=80: */\n/* This"
},
{
"path": "include/luasandbox/util/protobuf.h",
"chars": 3752,
"preview": "/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n/* vim: set ts=2 et sw=2 tw=80: */\n/* This"
},
{
"path": "include/luasandbox/util/running_stats.h",
"chars": 1229,
"preview": "/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n/* vim: set ts=2 et sw=2 tw=80: */\n/* This"
},
{
"path": "include/luasandbox/util/string.h",
"chars": 1462,
"preview": "/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n/* vim: set ts=2 et sw=2 tw=80: */\n/* This"
},
{
"path": "include/luasandbox/util/string_matcher.h",
"chars": 1311,
"preview": "/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n/* vim: set ts=2 et sw=2 tw=80: */\n/* This"
},
{
"path": "include/luasandbox/util/util.h",
"chars": 2134,
"preview": "/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n/* vim: set ts=2 et sw=2 tw=80: */\n/* This"
},
{
"path": "include/luasandbox.h",
"chars": 7852,
"preview": "/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n/* vim: set ts=2 et sw=2 tw=80: */\n/* This"
},
{
"path": "include/luasandbox_output.h",
"chars": 3534,
"preview": "/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n/* vim: set ts=2 et sw=2 tw=80: */\n/* This"
},
{
"path": "include/luasandbox_serialize.h",
"chars": 1992,
"preview": "/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n/* vim: set ts=2 et sw=2 tw=80: */\n/* This"
},
{
"path": "src/CMakeLists.txt",
"chars": 1390,
"preview": "# This Source Code Form is subject to the terms of the Mozilla Public\n# License, v. 2.0. If a copy of the MPL was not di"
},
{
"path": "src/cli/CMakeLists.txt",
"chars": 440,
"preview": "# This Source Code Form is subject to the terms of the Mozilla Public\n# License, v. 2.0. If a copy of the MPL was not di"
},
{
"path": "src/cli/lsb_heka_cat.c",
"chars": 11582,
"preview": "/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n/* vim: set ts=2 et sw=2 tw=80: */\n/* This"
},
{
"path": "src/heka/CMakeLists.txt",
"chars": 843,
"preview": "# This Source Code Form is subject to the terms of the Mozilla Public\n# License, v. 2.0. If a copy of the MPL was not di"
},
{
"path": "src/heka/message.c",
"chars": 30511,
"preview": "/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n/* vim: set ts=2 et sw=2 tw=80: */\n/* This"
},
{
"path": "src/heka/message_impl.h",
"chars": 2014,
"preview": "/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n/* vim: set ts=2 et sw=2 tw=80: */\n/* This"
},
{
"path": "src/heka/read_message_zc.c",
"chars": 5857,
"preview": "/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n/* vim: set ts=2 et sw=2 tw=80: */\n/* This"
},
{
"path": "src/heka/sandbox.c",
"chars": 31042,
"preview": "/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n/* vim: set ts=2 et sw=2 tw=80: */\n/* This"
},
{
"path": "src/heka/sandbox_impl.h",
"chars": 1476,
"preview": "/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n/* vim: set ts=2 et sw=2 tw=80: */\n/* This"
},
{
"path": "src/heka/stream_reader.c",
"chars": 6397,
"preview": "/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n/* vim: set ts=2 et sw=2 tw=80: */\n/* This"
},
{
"path": "src/heka/test/CMakeLists.txt",
"chars": 897,
"preview": "# This Source Code Form is subject to the terms of the Mozilla Public\n# License, v. 2.0. If a copy of the MPL was not di"
},
{
"path": "src/heka/test/lua/aim.lua",
"chars": 2651,
"preview": "-- This Source Code Form is subject to the terms of the Mozilla Public\n-- License, v. 2.0. If a copy of the MPL was not "
},
{
"path": "src/heka/test/lua/analysis.lua",
"chars": 868,
"preview": "-- This Source Code Form is subject to the terms of the Mozilla Public\n-- License, v. 2.0. If a copy of the MPL was not "
},
{
"path": "src/heka/test/lua/decode_message.lua",
"chars": 10016,
"preview": "-- This Source Code Form is subject to the terms of the Mozilla Public\n-- License, v. 2.0. If a copy of the MPL was not "
},
{
"path": "src/heka/test/lua/decode_message_benchmark.lua",
"chars": 941,
"preview": "-- This Source Code Form is subject to the terms of the Mozilla Public\n-- License, v. 2.0. If a copy of the MPL was not "
},
{
"path": "src/heka/test/lua/encode_message.lua",
"chars": 6119,
"preview": "-- This Source Code Form is subject to the terms of the Mozilla Public\n-- License, v. 2.0. If a copy of the MPL was not "
},
{
"path": "src/heka/test/lua/iim.lua",
"chars": 7155,
"preview": "-- This Source Code Form is subject to the terms of the Mozilla Public\n-- License, v. 2.0. If a copy of the MPL was not "
},
{
"path": "src/heka/test/lua/input.lua",
"chars": 1402,
"preview": "-- This Source Code Form is subject to the terms of the Mozilla Public\n-- License, v. 2.0. If a copy of the MPL was not "
},
{
"path": "src/heka/test/lua/oim.lua",
"chars": 887,
"preview": "-- This Source Code Form is subject to the terms of the Mozilla Public\n-- License, v. 2.0. If a copy of the MPL was not "
},
{
"path": "src/heka/test/lua/output.lua",
"chars": 1715,
"preview": "-- This Source Code Form is subject to the terms of the Mozilla Public\n-- License, v. 2.0. If a copy of the MPL was not "
},
{
"path": "src/heka/test/lua/pm_no_return.lua",
"chars": 235,
"preview": "-- This Source Code Form is subject to the terms of the Mozilla Public\n-- License, v. 2.0. If a copy of the MPL was not "
},
{
"path": "src/heka/test/lua/read_message.lua",
"chars": 2228,
"preview": "-- This Source Code Form is subject to the terms of the Mozilla Public\n-- License, v. 2.0. If a copy of the MPL was not "
},
{
"path": "src/heka/test/lua/read_message_zc.lua",
"chars": 2963,
"preview": "-- This Source Code Form is subject to the terms of the Mozilla Public\n-- License, v. 2.0. If a copy of the MPL was not "
},
{
"path": "src/heka/test/test.h.in",
"chars": 855,
"preview": "/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n/* vim: set ts=2 et sw=2 tw=80: */\n/* This"
},
{
"path": "src/heka/test/test_heka_sandbox.c",
"chars": 33446,
"preview": "/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n/* vim: set ts=2 et sw=2 tw=80: */\n/* This"
},
{
"path": "src/lua/lapi.c",
"chars": 22914,
"preview": "/*\n** $Id: lapi.c,v 2.55.1.5 2008/07/04 18:41:18 roberto Exp $\n** Lua API\n** See Copyright Notice in lua.h\n*/\n\n\n#include"
},
{
"path": "src/lua/lapi.h",
"chars": 262,
"preview": "/*\n** $Id: lapi.h,v 2.2.1.1 2007/12/27 13:02:25 roberto Exp $\n** Auxiliary functions from Lua API\n** See Copyright Notic"
},
{
"path": "src/lua/lauxlib.c",
"chars": 17420,
"preview": "/*\n** $Id: lauxlib.c,v 1.159.1.3 2008/01/21 13:20:51 roberto Exp $\n** Auxiliary functions for building Lua libraries\n** "
},
{
"path": "src/lua/lbaselib.c",
"chars": 17113,
"preview": "/*\n** $Id: lbaselib.c,v 1.191.1.6 2008/02/14 16:46:22 roberto Exp $\n** Basic library\n** See Copyright Notice in lua.h\n*/"
},
{
"path": "src/lua/lcode.c",
"chars": 21170,
"preview": "/*\n** $Id: lcode.c,v 2.25.1.5 2011/01/31 14:53:16 roberto Exp $\n** Code generator for Lua\n** See Copyright Notice in lua"
},
{
"path": "src/lua/lcode.h",
"chars": 2750,
"preview": "/*\n** $Id: lcode.h,v 1.48.1.1 2007/12/27 13:02:25 roberto Exp $\n** Code generator for Lua\n** See Copyright Notice in lua"
},
{
"path": "src/lua/ldblib.c",
"chars": 10092,
"preview": "/*\n** $Id: ldblib.c,v 1.104.1.4 2009/08/04 18:50:18 roberto Exp $\n** Interface from Lua to its debug API\n** See Copyrigh"
},
{
"path": "src/lua/ldebug.c",
"chars": 16919,
"preview": "/*\n** $Id: ldebug.c,v 2.29.1.6 2008/05/08 16:56:26 roberto Exp $\n** Debug Interface\n** See Copyright Notice in lua.h\n*/\n"
},
{
"path": "src/lua/ldebug.h",
"chars": 1061,
"preview": "/*\n** $Id: ldebug.h,v 2.3.1.1 2007/12/27 13:02:25 roberto Exp $\n** Auxiliary functions from Debug Interface module\n** Se"
},
{
"path": "src/lua/ldo.c",
"chars": 14907,
"preview": "/*\n** $Id: ldo.c,v 2.38.1.4 2012/01/18 02:27:10 roberto Exp $\n** Stack and Call structure of Lua\n** See Copyright Notice"
},
{
"path": "src/lua/ldo.h",
"chars": 1897,
"preview": "/*\n** $Id: ldo.h,v 2.7.1.1 2007/12/27 13:02:25 roberto Exp $\n** Stack and Call structure of Lua\n** See Copyright Notice "
},
{
"path": "src/lua/ldump.c",
"chars": 3114,
"preview": "/*\n** $Id: ldump.c,v 2.8.1.1 2007/12/27 13:02:25 roberto Exp $\n** save precompiled Lua chunks\n** See Copyright Notice in"
},
{
"path": "src/lua/lfunc.c",
"chars": 4618,
"preview": "/*\n** $Id: lfunc.c,v 2.12.1.2 2007/12/28 14:58:43 roberto Exp $\n** Auxiliary functions to manipulate prototypes and clos"
},
{
"path": "src/lua/lfunc.h",
"chars": 1125,
"preview": "/*\n** $Id: lfunc.h,v 2.4.1.1 2007/12/27 13:02:25 roberto Exp $\n** Auxiliary functions to manipulate prototypes and closu"
},
{
"path": "src/lua/lgc.c",
"chars": 20061,
"preview": "/*\n** $Id: lgc.c,v 2.38.1.2 2011/03/18 18:05:38 roberto Exp $\n** Garbage Collector\n** See Copyright Notice in lua.h\n*/\n\n"
},
{
"path": "src/lua/lgc.h",
"chars": 3159,
"preview": "/*\n** $Id: lgc.h,v 2.15.1.1 2007/12/27 13:02:25 roberto Exp $\n** Garbage Collector\n** See Copyright Notice in lua.h\n*/\n\n"
},
{
"path": "src/lua/linit.c",
"chars": 765,
"preview": "/*\n** $Id: linit.c,v 1.14.1.1 2007/12/27 13:02:25 roberto Exp $\n** Initialization of libraries for lua.c\n** See Copyrigh"
},
{
"path": "src/lua/liolib.c",
"chars": 13466,
"preview": "/*\n** $Id: liolib.c,v 2.73.1.4 2010/05/14 15:33:51 roberto Exp $\n** Standard I/O (and system) library\n** See Copyright N"
},
{
"path": "src/lua/llex.c",
"chars": 12586,
"preview": "/*\n** $Id: llex.c,v 2.20.1.2 2009/11/23 14:58:22 roberto Exp $\n** Lexical Analyzer\n** See Copyright Notice in lua.h\n*/\n\n"
},
{
"path": "src/lua/llex.h",
"chars": 2177,
"preview": "/*\n** $Id: llex.h,v 1.58.1.1 2007/12/27 13:02:25 roberto Exp $\n** Lexical Analyzer\n** See Copyright Notice in lua.h\n*/\n\n"
},
{
"path": "src/lua/llimits.h",
"chars": 2349,
"preview": "/*\n** $Id: llimits.h,v 1.69.1.1 2007/12/27 13:02:25 roberto Exp $\n** Limits, basic types, and some other `installation-d"
},
{
"path": "src/lua/lmathlib.c",
"chars": 6087,
"preview": "/*\n** $Id: lmathlib.c,v 1.67.1.1 2007/12/27 13:02:25 roberto Exp $\n** Standard mathematical library\n** See Copyright Not"
},
{
"path": "src/lua/lmem.c",
"chars": 2172,
"preview": "/*\n** $Id: lmem.c,v 1.70.1.1 2007/12/27 13:02:25 roberto Exp $\n** Interface to Memory Manager\n** See Copyright Notice in"
},
{
"path": "src/lua/lmem.h",
"chars": 1494,
"preview": "/*\n** $Id: lmem.h,v 1.31.1.1 2007/12/27 13:02:25 roberto Exp $\n** Interface to Memory Manager\n** See Copyright Notice in"
},
{
"path": "src/lua/loadlib.c",
"chars": 18901,
"preview": "/*\n** $Id: loadlib.c,v 1.52.1.4 2009/09/09 13:17:16 roberto Exp $\n** Dynamic library loader for Lua\n** See Copyright Not"
},
{
"path": "src/lua/lobject.c",
"chars": 5498,
"preview": "/*\n** $Id: lobject.c,v 2.22.1.1 2007/12/27 13:02:25 roberto Exp $\n** Some generic functions over Lua objects\n** See Copy"
},
{
"path": "src/lua/lobject.h",
"chars": 8502,
"preview": "/*\n** $Id: lobject.h,v 2.20.1.2 2008/08/06 13:29:48 roberto Exp $\n** Type definitions for Lua objects\n** See Copyright N"
},
{
"path": "src/lua/lopcodes.c",
"chars": 2884,
"preview": "/*\n** $Id: lopcodes.c,v 1.37.1.1 2007/12/27 13:02:25 roberto Exp $\n** See Copyright Notice in lua.h\n*/\n\n\n#define lopcode"
},
{
"path": "src/lua/lopcodes.h",
"chars": 8086,
"preview": "/*\n** $Id: lopcodes.h,v 1.125.1.1 2007/12/27 13:02:25 roberto Exp $\n** Opcodes for Lua virtual machine\n** See Copyright "
},
{
"path": "src/lua/loslib.c",
"chars": 8008,
"preview": "/*\n** $Id: loslib.c,v 1.19.1.3 2008/01/18 16:38:18 roberto Exp $\n** Standard Operating System library\n** See Copyright N"
},
{
"path": "src/lua/lparser.c",
"chars": 36696,
"preview": "/*\n** $Id: lparser.c,v 2.42.1.4 2011/10/21 19:31:42 roberto Exp $\n** Lua Parser\n** See Copyright Notice in lua.h\n*/\n\n\n#i"
},
{
"path": "src/lua/lparser.h",
"chars": 2261,
"preview": "/*\n** $Id: lparser.h,v 1.57.1.1 2007/12/27 13:02:25 roberto Exp $\n** Lua Parser\n** See Copyright Notice in lua.h\n*/\n\n#if"
},
{
"path": "src/lua/lstate.c",
"chars": 5674,
"preview": "/*\n** $Id: lstate.c,v 2.36.1.2 2008/01/03 15:20:39 roberto Exp $\n** Global State\n** See Copyright Notice in lua.h\n*/\n\n\n#"
},
{
"path": "src/lua/lstate.h",
"chars": 5011,
"preview": "/*\n** $Id: lstate.h,v 2.24.1.2 2008/01/03 15:20:39 roberto Exp $\n** Global State\n** See Copyright Notice in lua.h\n*/\n\n#i"
},
{
"path": "src/lua/lstring.c",
"chars": 3110,
"preview": "/*\n** $Id: lstring.c,v 2.8.1.1 2007/12/27 13:02:25 roberto Exp $\n** String table (keeps all strings handled by Lua)\n** S"
},
{
"path": "src/lua/lstring.h",
"chars": 814,
"preview": "/*\n** $Id: lstring.h,v 1.43.1.1 2007/12/27 13:02:25 roberto Exp $\n** String table (keep all strings handled by Lua)\n** S"
},
{
"path": "src/lua/lstrlib.c",
"chars": 23561,
"preview": "/*\n** $Id: lstrlib.c,v 1.132.1.5 2010/05/14 15:34:19 roberto Exp $\n** Standard library for string operations and pattern"
},
{
"path": "src/lua/ltable.c",
"chars": 16478,
"preview": "/*\n** $Id: ltable.c,v 2.32.1.2 2007/12/28 15:32:23 roberto Exp $\n** Lua tables (hash)\n** See Copyright Notice in lua.h\n*"
},
{
"path": "src/lua/ltable.h",
"chars": 1220,
"preview": "/*\n** $Id: ltable.h,v 2.10.1.1 2007/12/27 13:02:25 roberto Exp $\n** Lua tables (hash)\n** See Copyright Notice in lua.h\n*"
},
{
"path": "src/lua/ltablib.c",
"chars": 7341,
"preview": "/*\n** $Id: ltablib.c,v 1.38.1.3 2008/02/14 16:46:58 roberto Exp $\n** Library for Table Manipulation\n** See Copyright Not"
},
{
"path": "src/lua/ltm.c",
"chars": 1650,
"preview": "/*\n** $Id: ltm.c,v 2.8.1.1 2007/12/27 13:02:25 roberto Exp $\n** Tag methods\n** See Copyright Notice in lua.h\n*/\n\n\n#inclu"
},
{
"path": "src/lua/ltm.h",
"chars": 1018,
"preview": "/*\n** $Id: ltm.h,v 2.6.1.1 2007/12/27 13:02:25 roberto Exp $\n** Tag methods\n** See Copyright Notice in lua.h\n*/\n\n#ifndef"
},
{
"path": "src/lua/lundump.c",
"chars": 4629,
"preview": "/*\n** $Id: lundump.c,v 2.7.1.4 2008/04/04 19:51:41 roberto Exp $\n** load precompiled Lua chunks\n** See Copyright Notice "
},
{
"path": "src/lua/lundump.h",
"chars": 890,
"preview": "/*\n** $Id: lundump.h,v 1.37.1.1 2007/12/27 13:02:25 roberto Exp $\n** load precompiled Lua chunks\n** See Copyright Notice"
},
{
"path": "src/lua/lvm.c",
"chars": 23242,
"preview": "/*\n** $Id: lvm.c,v 2.63.1.5 2011/08/17 20:43:11 roberto Exp $\n** Lua virtual machine\n** See Copyright Notice in lua.h\n*/"
},
{
"path": "src/lua/lvm.h",
"chars": 1159,
"preview": "/*\n** $Id: lvm.h,v 2.5.1.1 2007/12/27 13:02:25 roberto Exp $\n** Lua virtual machine\n** See Copyright Notice in lua.h\n*/\n"
},
{
"path": "src/lua/lzio.c",
"chars": 1628,
"preview": "/*\n** $Id: lzio.c,v 1.31.1.1 2007/12/27 13:02:25 roberto Exp $\n** a generic input stream interface\n** See Copyright Noti"
},
{
"path": "src/lua/lzio.h",
"chars": 1556,
"preview": "/*\n** $Id: lzio.h,v 1.21.1.1 2007/12/27 13:02:25 roberto Exp $\n** Buffered streams\n** See Copyright Notice in lua.h\n*/\n\n"
},
{
"path": "src/luasandbox.c",
"chars": 20615,
"preview": "/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n/* vim: set ts=2 et sw=2 tw=80: */\n/* This"
},
{
"path": "src/luasandbox_defines.h",
"chars": 656,
"preview": "/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n/* vim: set ts=2 et sw=2 tw=80: */\n/* This"
},
{
"path": "src/luasandbox_impl.h",
"chars": 1300,
"preview": "/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n/* vim: set ts=2 et sw=2 tw=80: */\n/* This"
},
{
"path": "src/luasandbox_output.c",
"chars": 3833,
"preview": "/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n/* vim: set ts=2 et sw=2 tw=80: */\n/* This"
},
{
"path": "src/luasandbox_serialize.c",
"chars": 16768,
"preview": "/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n/* vim: set ts=2 et sw=2 tw=80: */\n/* This"
},
{
"path": "src/test/CMakeLists.txt",
"chars": 1194,
"preview": "# This Source Code Form is subject to the terms of the Mozilla Public\n# License, v. 2.0. If a copy of the MPL was not di"
},
{
"path": "src/test/lua/bad_module.lua",
"chars": 20,
"preview": "return 1 + nilvalue\n"
},
{
"path": "src/test/lua/counter.lua",
"chars": 274,
"preview": "-- This Source Code Form is subject to the terms of the Mozilla Public\n-- License, v. 2.0. If a copy of the MPL was not "
},
{
"path": "src/test/lua/errors.lua",
"chars": 1397,
"preview": "-- This Source Code Form is subject to the terms of the Mozilla Public\n-- License, v. 2.0. If a copy of the MPL was not "
},
{
"path": "src/test/lua/no_external_modules.lua",
"chars": 76,
"preview": "require \"foo\"\n\nfunction process(tc)\n return 0\nend\n\nfunction report()\nend\n"
},
{
"path": "src/test/lua/output.lua",
"chars": 467,
"preview": "-- This Source Code Form is subject to the terms of the Mozilla Public\n-- License, v. 2.0. If a copy of the MPL was not "
},
{
"path": "src/test/lua/output_errors.lua",
"chars": 701,
"preview": "-- This Source Code Form is subject to the terms of the Mozilla Public\n-- License, v. 2.0. If a copy of the MPL was not "
},
{
"path": "src/test/lua/print.lua",
"chars": 571,
"preview": "-- This Source Code Form is subject to the terms of the Mozilla Public\n-- License, v. 2.0. If a copy of the MPL was not "
},
{
"path": "src/test/lua/read_config.lua",
"chars": 565,
"preview": "assert(type(read_config) == \"function\")\nassert(read_config(\"memory_limit\") == 65765)\nassert(read_config(\"instruction_lim"
},
{
"path": "src/test/lua/restore.lua",
"chars": 383,
"preview": "-- This Source Code Form is subject to the terms of the Mozilla Public\n-- License, v. 2.0. If a copy of the MPL was not "
},
{
"path": "src/test/lua/sandbox_config.lua",
"chars": 2572,
"preview": "local ok, err = pcall(require, \"io\")\nassert(not ok, \"the io module is disabled\")\nassert(err == \"module 'io' disabled\", e"
},
{
"path": "src/test/lua/serialize.lua",
"chars": 1709,
"preview": "-- This Source Code Form is subject to the terms of the Mozilla Public\n-- License, v. 2.0. If a copy of the MPL was not "
},
{
"path": "src/test/lua/serialize_failure.lua",
"chars": 246,
"preview": "-- This Source Code Form is subject to the terms of the Mozilla Public\n-- License, v. 2.0. If a copy of the MPL was not "
},
{
"path": "src/test/lua/simple.lua",
"chars": 170,
"preview": "gint = 1\n\nfunction process(tc)\n if tc == 1 then\n return 0, \"ok\"\n elseif tc == 2 then\n return 0, tru"
},
{
"path": "src/test/output/serialize.lua51.data",
"chars": 4316,
"preview": "if _PRESERVATION_VERSION and _PRESERVATION_VERSION ~= 0 then return end\n_G[\"ninf\"] = -1/0\n_G[\"empty_object1\"] = {}\nif _G"
},
{
"path": "src/test/sandbox.c",
"chars": 3815,
"preview": "/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n/* vim: set ts=2 et sw=2 tw=80: */\n/* This"
},
{
"path": "src/test/test_generic_sandbox.c",
"chars": 29276,
"preview": "/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n/* vim: set ts=2 et sw=2 tw=80: */\n/* This"
},
{
"path": "src/util/CMakeLists.txt",
"chars": 834,
"preview": "# This Source Code Form is subject to the terms of the Mozilla Public\n# License, v. 2.0. If a copy of the MPL was not di"
},
{
"path": "src/util/heka_message.c",
"chars": 15330,
"preview": "/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n/* vim: set ts=2 et sw=2 tw=80: */\n/* This"
},
{
"path": "src/util/heka_message_matcher.c",
"chars": 6110,
"preview": "/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n/* vim: set ts=2 et sw=2 tw=80: */\n/* This"
},
{
"path": "src/util/heka_message_matcher_impl.h",
"chars": 1319,
"preview": "/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n/* vim: set ts=2 et sw=2 tw=80: */\n/* This"
},
{
"path": "src/util/heka_message_matcher_parser.c",
"chars": 85621,
"preview": "/* A recursive-descent parser generated by peg 0.1.18 */\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#de"
},
{
"path": "src/util/heka_message_matcher_parser.leg",
"chars": 15429,
"preview": "%{\n/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n/* vim: set ts=2 et sw=2 tw=80: */\n/* T"
},
{
"path": "src/util/input_buffer.c",
"chars": 2013,
"preview": "/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n/* vim: set ts=2 et sw=2 tw=80: */\n/* This"
},
{
"path": "src/util/output_buffer.c",
"chars": 5328,
"preview": "/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n/* vim: set ts=2 et sw=2 tw=80: */\n/* This"
},
{
"path": "src/util/protobuf.c",
"chars": 3463,
"preview": "/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n/* vim: set ts=2 et sw=2 tw=80: */\n/* This"
},
{
"path": "src/util/running_stats.c",
"chars": 984,
"preview": "/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n/* vim: set ts=2 et sw=2 tw=80: */\n/* This"
},
{
"path": "src/util/string.c",
"chars": 1756,
"preview": "/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n/* vim: set ts=2 et sw=2 tw=80: */\n/* This"
},
{
"path": "src/util/string_matcher.c",
"chars": 8419,
"preview": "/*\n** Modified Lua lstrlib.c for the Lua sandbox message matcher pattern-matching\n*\n* Copyright (C) 1994-2012 Lua.org, P"
},
{
"path": "src/util/test/CMakeLists.txt",
"chars": 2557,
"preview": "# This Source Code Form is subject to the terms of the Mozilla Public\n# License, v. 2.0. If a copy of the MPL was not di"
},
{
"path": "src/util/test/test_heka_message.c",
"chars": 16548,
"preview": "/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n/* vim: set ts=2 et sw=2 tw=80: */\n/* This"
},
{
"path": "src/util/test/test_heka_message_matcher.c",
"chars": 18776,
"preview": "/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n/* vim: set ts=2 et sw=2 tw=80: */\n/* This"
},
{
"path": "src/util/test/test_input_buffer.c",
"chars": 4417,
"preview": "/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n/* vim: set ts=2 et sw=2 tw=80: */\n/* This"
},
{
"path": "src/util/test/test_output_buffer.c",
"chars": 8182,
"preview": "/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n/* vim: set ts=2 et sw=2 tw=80: */\n/* This"
},
{
"path": "src/util/test/test_protobuf.c",
"chars": 7591,
"preview": "/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n/* vim: set ts=2 et sw=2 tw=80: */\n/* This"
},
{
"path": "src/util/test/test_running_stats.c",
"chars": 2284,
"preview": "/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n/* vim: set ts=2 et sw=2 tw=80: */\n/* This"
},
{
"path": "src/util/test/test_string.c",
"chars": 2871,
"preview": "/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n/* vim: set ts=2 et sw=2 tw=80: */\n/* This"
},
{
"path": "src/util/test/test_string_matcher.c",
"chars": 4495,
"preview": "/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n/* vim: set ts=2 et sw=2 tw=80: */\n/* This"
},
{
"path": "src/util/test/test_util.c",
"chars": 3084,
"preview": "/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n/* vim: set ts=2 et sw=2 tw=80: */\n/* This"
},
{
"path": "src/util/util.c",
"chars": 3821,
"preview": "/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n/* vim: set ts=2 et sw=2 tw=80: */\n/* This"
}
]
About this extraction
This page contains the full source code of the mozilla-services/lua_sandbox GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 162 files (1.0 MB), approximately 332.2k tokens, and a symbol index with 1140 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.