/**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "mod_lua.h"
#include "http_log.h"
#include "apr_uuid.h"
#include "lua_config.h"
#include "apr_file_info.h"
#include "mod_auth.h"
#ifndef AP_LUA_MODULE_EXT
#if defined(NETWARE)
#else
#endif
#endif
#if APR_HAS_THREADS
#endif
extern apr_global_mutex_t *lua_ivm_mutex;
{
/* global IVM mutex */
pool);
if (rv != APR_SUCCESS) {
"mod_lua: Failed to reopen mutex lua-ivm-shm in child");
}
/* Server pool mutex */
#if APR_HAS_THREADS
#endif
}
/* forward dec'l from this file */
#if 0
const char *msg)
{
int i;
int top = lua_gettop(L);
for (i = 1; i <= top; i++) {
int t = lua_type(L, i);
switch (t) {
case LUA_TSTRING:{
"%d: '%s'", i, lua_tostring(L, i));
break;
}
case LUA_TUSERDATA:{
break;
}
case LUA_TLIGHTUSERDATA:{
i);
break;
}
case LUA_TNIL:{
break;
}
case LUA_TNONE:{
break;
}
case LUA_TBOOLEAN:{
"%d: %s", i, lua_toboolean(L,
i) ? "true" :
"false");
break;
}
case LUA_TNUMBER:{
"%d: %g", i, lua_tonumber(L, i));
break;
}
case LUA_TTABLE:{
break;
}
case LUA_TTHREAD:{
break;
}
case LUA_TFUNCTION:{
break;
}
default:{
"%d: unknown: [%s]", i, lua_typename(L, i));
break;
}
}
}
}
#endif
/* BEGIN modules*/
/* BEGIN apache lmodule */
{
lua_getglobal(L, "package");
lua_newtable(L);
lua_setglobal(L, "apache2");
lua_getglobal(L, "apache2");
makeintegerfield(L, OK);
makeintegerfield(L, DECLINED);
makeintegerfield(L, DONE);
/*
makeintegerfield(L, HTTP_CONTINUE);
makeintegerfield(L, HTTP_SWITCHING_PROTOCOLS);
makeintegerfield(L, HTTP_PROCESSING);
makeintegerfield(L, HTTP_OK);
makeintegerfield(L, HTTP_CREATED);
makeintegerfield(L, HTTP_ACCEPTED);
makeintegerfield(L, HTTP_NON_AUTHORITATIVE);
makeintegerfield(L, HTTP_NO_CONTENT);
makeintegerfield(L, HTTP_RESET_CONTENT);
makeintegerfield(L, HTTP_PARTIAL_CONTENT);
makeintegerfield(L, HTTP_MULTI_STATUS);
makeintegerfield(L, HTTP_ALREADY_REPORTED);
makeintegerfield(L, HTTP_IM_USED);
makeintegerfield(L, HTTP_MULTIPLE_CHOICES);
makeintegerfield(L, HTTP_MOVED_PERMANENTLY);
makeintegerfield(L, HTTP_MOVED_TEMPORARILY);
makeintegerfield(L, HTTP_SEE_OTHER);
makeintegerfield(L, HTTP_NOT_MODIFIED);
makeintegerfield(L, HTTP_USE_PROXY);
makeintegerfield(L, HTTP_TEMPORARY_REDIRECT);
makeintegerfield(L, HTTP_PERMANENT_REDIRECT);
makeintegerfield(L, HTTP_BAD_REQUEST);
makeintegerfield(L, HTTP_UNAUTHORIZED);
makeintegerfield(L, HTTP_PAYMENT_REQUIRED);
makeintegerfield(L, HTTP_FORBIDDEN);
makeintegerfield(L, HTTP_NOT_FOUND);
makeintegerfield(L, HTTP_METHOD_NOT_ALLOWED);
makeintegerfield(L, HTTP_NOT_ACCEPTABLE);
makeintegerfield(L, HTTP_PROXY_AUTHENTICATION_REQUIRED);
makeintegerfield(L, HTTP_REQUEST_TIME_OUT);
makeintegerfield(L, HTTP_CONFLICT);
makeintegerfield(L, HTTP_GONE);
makeintegerfield(L, HTTP_LENGTH_REQUIRED);
makeintegerfield(L, HTTP_PRECONDITION_FAILED);
makeintegerfield(L, HTTP_REQUEST_ENTITY_TOO_LARGE);
makeintegerfield(L, HTTP_REQUEST_URI_TOO_LARGE);
makeintegerfield(L, HTTP_UNSUPPORTED_MEDIA_TYPE);
makeintegerfield(L, HTTP_RANGE_NOT_SATISFIABLE);
makeintegerfield(L, HTTP_EXPECTATION_FAILED);
makeintegerfield(L, HTTP_UNPROCESSABLE_ENTITY);
makeintegerfield(L, HTTP_LOCKED);
makeintegerfield(L, HTTP_FAILED_DEPENDENCY);
makeintegerfield(L, HTTP_UPGRADE_REQUIRED);
makeintegerfield(L, HTTP_PRECONDITION_REQUIRED);
makeintegerfield(L, HTTP_TOO_MANY_REQUESTS);
makeintegerfield(L, HTTP_REQUEST_HEADER_FIELDS_TOO_LARGE);
makeintegerfield(L, HTTP_INTERNAL_SERVER_ERROR);
makeintegerfield(L, HTTP_NOT_IMPLEMENTED);
makeintegerfield(L, HTTP_BAD_GATEWAY);
makeintegerfield(L, HTTP_SERVICE_UNAVAILABLE);
makeintegerfield(L, HTTP_GATEWAY_TIME_OUT);
makeintegerfield(L, HTTP_VERSION_NOT_SUPPORTED);
makeintegerfield(L, HTTP_VARIANT_ALSO_VARIES);
makeintegerfield(L, HTTP_INSUFFICIENT_STORAGE);
makeintegerfield(L, HTTP_LOOP_DETECTED);
makeintegerfield(L, HTTP_NOT_EXTENDED);
makeintegerfield(L, HTTP_NETWORK_AUTHENTICATION_REQUIRED);
*/
}
/* END apache2 lmodule */
/* END library functions */
/* callback for cleaning up a lua vm when pool is closed */
{
AP_DEBUG_ASSERT(l != NULL);
return APR_SUCCESS;
}
{
}
return APR_SUCCESS;
}
/*
munge_path(L,
"path",
"?.lua",
"./?.lua",
lifecycle_pool,
spec->package_paths,
spec->file);
*/
/**
* field -> "path" or "cpath"
* sub_pat -> "?.lua"
* rep_pat -> "./?.lua"
* pool -> lifecycle pool for allocations
* paths -> things to add
* file -> ???
*/
const char *field,
const char *sub_pat,
const char *rep_pat,
const char *file)
{
const char *current;
const char *parent_dir;
const char *pattern;
const char *modified;
char *part;
lua_getglobal(L, "package");
lua_pop(L, 2);
NULL);
lua_pushstring(L, part);
}
#ifdef AP_ENABLE_LUAJIT
lua_getglobal(L, "require");
lua_pushliteral(L, "jit.");
lua_pushvalue(L, -3);
lua_concat(L, 2);
"Failed to init LuaJIT: %s", msg);
return 1;
}
return 0;
}
#endif
{
lua_State* L;
L = luaL_newstate();
#ifdef AP_ENABLE_LUAJIT
luaopen_jit(L);
#endif
luaL_openlibs(L);
if (spec->package_paths) {
munge_path(L,
"path", "?.lua", "./?.lua",
}
if (spec->package_cpaths) {
munge_path(L,
}
}
lua_pcall(L, 0, LUA_MULTRET, 0);
}
else {
int rc;
if (rc != 0) {
: lua_tostring(L, 0));
return APR_EBADF;
}
lua_tostring(L, -1));
return APR_EBADF;
}
}
#ifdef AP_ENABLE_LUAJIT
#endif
*vm = L;
return APR_SUCCESS;
}
{
return copied_spec;
}
{
lua_State* L;
if (L != NULL) {
spec->L = L;
return APR_SUCCESS;
}
}
return APR_EGENERAL;
}
/**
* Function used to create a lua_State instance bound into the web
* server in the appropriate scope.
*/
{
int tryCache = 0;
char *hash;
#if APR_HAS_THREADS
#endif
L = sspec->L;
}
}
}
if (L == NULL) {
if (
L = sspec->L;
}
else {
return NULL;
}
}
}
#if APR_HAS_THREADS
#endif
}
else {
lifecycle_pool) != APR_SUCCESS) {
L = NULL;
}
}
if (L == NULL) {
/* not available, so create */
AP_DEBUG_ASSERT(L != NULL);
}
}
tryCache = 1;
}
else {
char* mkey;
if (cache_info == NULL) {
}
}
/* On first visit, modified will be zero, but that's fine - The file is
loaded in the vm_construct function.
*/
|| cache_info->modified == 0) {
tryCache = 1;
}
}
if (cache_info->runs == 0)
tryCache = 1;
}
cache_info->runs++;
}
int rc;
if (rc != 0) {
: lua_tostring(L, 0));
return 0;
}
lua_pcall(L, 0, LUA_MULTRET, 0);
}
return L;
}