mod_lua.c revision fb57141433a12af705da56421319212ea6cbdab3
10705fbc225dcf590c9ba24a4f04de221358060arbowen * Licensed to the Apache Software Foundation (ASF) under one or more
10705fbc225dcf590c9ba24a4f04de221358060arbowen * contributor license agreements. See the NOTICE file distributed with
d3e250aab242db84d14060985b5db675a731d548nd * this work for additional information regarding copyright ownership.
10705fbc225dcf590c9ba24a4f04de221358060arbowen * The ASF licenses this file to You under the Apache License, Version 2.0
10705fbc225dcf590c9ba24a4f04de221358060arbowen * (the "License"); you may not use this file except in compliance with
10705fbc225dcf590c9ba24a4f04de221358060arbowen * the License. You may obtain a copy of the License at
10705fbc225dcf590c9ba24a4f04de221358060arbowen * Unless required by applicable law or agreed to in writing, software
10705fbc225dcf590c9ba24a4f04de221358060arbowen * distributed under the License is distributed on an "AS IS" BASIS,
#include "mod_lua.h"
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include "lua_apr.h"
#include "lua_config.h"
#include "apr_optional.h"
#include "mod_ssl.h"
#include "mod_auth.h"
#ifdef APR_HAS_THREADS
#include "apr_thread_proc.h"
const char *name;
const char *file_name;
const char *function_name;
const char *lua_response;
ap_lua_init(L, p);
ap_lua_load_request_lmodule(L, p);
return OK;
switch (scope) {
case AP_LUA_SCOPE_ONCE:
case AP_LUA_SCOPE_UNSET:
case AP_LUA_SCOPE_REQUEST:
case AP_LUA_SCOPE_CONN:
#if APR_HAS_THREADS
case AP_LUA_SCOPE_THREAD:
ap_assert(0);
request_rec *r,
const char *filename,
const char *bytecode,
const char *function,
const char *what)
if (filename) {
char *file;
case AP_LUA_SCOPE_ONCE:
case AP_LUA_SCOPE_UNSET:
case AP_LUA_SCOPE_REQUEST:
case AP_LUA_SCOPE_CONN:
#if APR_HAS_THREADS
case AP_LUA_SCOPE_THREAD:
ap_assert(0);
return spec;
static const char* ap_lua_interpolate_string(apr_pool_t* pool, const char* string, const char** values)
char *stringBetween;
const char* ret;
int srclen,x,y;
for (x=0; x < srclen; x++) {
return string;
return ret;
return DECLINED;
if (!r->header_only) {
lua_State *L;
&lua_module);
return HTTP_INTERNAL_SERVER_ERROR;
return HTTP_INTERNAL_SERVER_ERROR;
ap_lua_run_lua_request(L, r);
report_lua_error(L, r);
return OK;
int rc;
lua_State *L;
&lua_module);
&lua_module);
if (hook_specs) {
return HTTP_INTERNAL_SERVER_ERROR;
return HTTP_INTERNAL_SERVER_ERROR;
ap_lua_run_lua_request(L, r);
ap_lua_run_lua_request(L, r);
t = lua_gettop(L);
lua_settop(L, t);
report_lua_error(L, r);
return HTTP_INTERNAL_SERVER_ERROR;
return rc;
return DECLINED;
int rc, n = 0;
lua_State *L;
&lua_module);
&lua_module);
return HTTP_INTERNAL_SERVER_ERROR;
filename);
return HTTP_INTERNAL_SERVER_ERROR;
ap_lua_run_lua_request(L, r);
ap_lua_run_lua_request(L, r);
t = lua_gettop(L);
lua_settop(L, t);
report_lua_error(L, r);
return HTTP_INTERNAL_SERVER_ERROR;
return rc;
return DECLINED;
apr_size_t i = 0;
while (i < bufsiz) {
char ch;
typedef struct cr_ctx
const char *endstr;
} cr_ctx;
static const char *lf =
return lf;
apr_size_t i = 0;
*plen = 0;
return NULL;
typedef struct hack_section_baton
const char *name;
int apr_hook_when;
const char *arg)
if (!hook_specs) {
sizeof(ap_lua_mapped_handler_spec *));
return NULL;
void *mconfig,
const char *line)
if (line[0]) {
const char *word;
char *tmp;
int rv;
if (function) {
/* This lua State is used only to compile the input strings -> bytecode, so we don't need anything extra. */
if (rv != 0) {
return errstr;
luaL_Buffer b;
luaL_pushresult(&b);
if (!*current) {
return NULL;
void *_cfg,
const char *file,
const char *function,
int apr_hook_when)
if (!hook_specs) {
sizeof(ap_lua_mapped_handler_spec *));
return NULL;
void *_cfg,
const char *file,
const char *function)
return NULL;
if (lookup) {
return DECLINED;
const char *file,
const char *function,
const char *when)
if (err) {
return err;
if (when) {
const char *line)
line);
const char *file,
const char *function)
const char *line)
const char *file,
const char *function)
const char *line)
line);
const char *file,
const char *function,
const char *when)
if (when) {
const char *line)
line);
const char *file,
const char *function)
const char *line)
line);
const char *file,
const char *function,
const char *when)
if (when) {
const char *line)
line);
const char *file,
const char *function,
const char *when)
if (when) {
const char *line)
line);
const char *file,
const char *function)
if (err) {
return err;
if (err) {
return err;
function);
const char *line)
line);
const char *arg,
char *fixed_filename;
arg,
return NULL;
const char *arg)
void *_cfg,
const char *arg)
void *_cfg,
const char *arg)
arg);
return NULL;
void *_cfg,
const char *arg)
arg);
return NULL;
void *_cfg,
const char *scope,
const char *min,
const char *max)
#if !APR_HAS_THREADS
scope);
#if APR_HAS_THREADS
,scope);
return NULL;
const char *root)
&lua_module);
return NULL;
AP_LUA_DECLARE(const char *) ap_lua_ssl_val(apr_pool_t *p, server_rec *s, conn_rec *c, request_rec *r, const char *var)
if (lua_ssl_val) {
return NULL;
const void **parsed_require_line)
const char *provider_name;
const char *arg;
return NULL;
const void *parsed_require_line)
lua_State *L;
&lua_module);
&lua_module);
int result;
int nargs = 0;
if (L == NULL) {
return AUTHZ_GENERAL_ERROR;
return AUTHZ_GENERAL_ERROR;
ap_lua_run_lua_request(L, r);
return AUTHZ_GENERAL_ERROR;
return AUTHZ_GENERAL_ERROR;
return AUTHZ_GENERAL_ERROR;
switch (result) {
case AUTHZ_DENIED:
case AUTHZ_GRANTED:
case AUTHZ_NEUTRAL:
case AUTHZ_GENERAL_ERROR:
case AUTHZ_DENIED_NO_USER:
return result;
return AUTHZ_GENERAL_ERROR;
const char *function)
if (err)
return err;
return NULL;
"Add a directory to lua's package.cpath"),
NULL,
NULL,
NULL,
NULL,
{NULL}
return cfg;
return OK;
return cfg;
ap_lua_push_request(L, r);
return OK;
return OK;
const void *key,
const void *overlay_val,
const void *base_val,
const void *data)
a->codecache = (overrides->codecache== AP_LUA_CACHE_UNSET) ? base->codecache : overrides->codecache;
/* http_request.h hooks */