lua_request.c revision 5ec23983db597859169a29da98b5c536e882f47d
/**
* 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 <lua.h>
#include <apr_pools.h>
#include "mod_lua.h"
#include "util_script.h"
#include "lua_apr.h"
#include "scoreboard.h"
#include "lua_dbd.h"
#include "util_md5.h"
#define POST_MAX_VARS 500
#ifndef MODLUA_MAX_REG_MATCH
#define MODLUA_MAX_REG_MATCH 25
#endif
typedef char *(*req_field_string_f) (request_rec * r);
typedef int (*req_field_int_f) (request_rec * r);
{
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:{
i);
break;
}
case LUA_TLIGHTUSERDATA:{
"%d: lightuserdata", 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:{
"%d: <table>", i);
break;
}
case LUA_TFUNCTION:{
"%d: <function>", i);
break;
}
default:{
"%d: unknown: -[%s]-", i, lua_typename(L, i));
break;
}
}
}
}
/**
* Verify that the thing at index is a request_rec wrapping
* userdata thingamajig and return it if it is. if it is not
* lua will enter its error handling routine.
*/
{
request_rec *r;
return r;
}
/* ------------------ request methods -------------------- */
/* helper callback for req_parseargs */
static int req_aprtable2luatable_cb(void *l, const char *key,
const char *value)
{
int t;
/* rstack_dump(L, RRR, "start of cb"); */
/* L is [table<s,t>, table<s,s>] */
/* build complex */
/* rstack_dump(L, RRR, "after getfield"); */
t = lua_type(L, -1);
switch (t) {
case LUA_TNIL:
case LUA_TNONE:{
lua_newtable(L); /* [array, table<s,t>, table<s,s>] */
break;
}
case LUA_TTABLE:{
/* [array, table<s,t>, table<s,s>] */
break;
}
}
/* L is [table<s,t>, table<s,s>] */
/* build simple */
}
else {
lua_pop(L, 1);
}
return 1;
}
/*
=======================================================================================================================
lua_read_body(request_rec *r, const char **rbuf, apr_off_t *size): Reads any additional form data sent in POST/PUT
requests. Used for multipart POST data.
=======================================================================================================================
*/
{
return (rc);
}
if (ap_should_client_block(r)) {
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
char argsbuffer[HUGE_STRING_LEN];
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
}
else {
}
}
}
return (rc);
}
/*
* =======================================================================================================================
* and writes to a file.
* =======================================================================================================================
*/
{
return rc;
if (ap_should_client_block(r)) {
char argsbuffer[HUGE_STRING_LEN];
rpos = 0;
while ((len_read =
sizeof(argsbuffer))) > 0) {
else
&written);
return APR_ENOSPC;
}
}
return rc;
}
/* r:parseargs() returning a lua table */
static int req_parseargs(lua_State *L)
{
lua_newtable(L);
lua_newtable(L); /* [table, table] */
ap_args_to_table(r, &form_table);
return 2; /* [table<string, string>, table<string, array<string>>] */
}
/* r:parsebody(): Parses regular (url-enocded) or multipart POST data and returns two tables*/
static int req_parsebody(lua_State *L)
{
int res;
char *multipart;
const char *contentType;
lua_newtable(L);
lua_newtable(L); /* [table, table] */
if (contentType != NULL && (sscanf(contentType, "multipart/form-data; boundary=%250c", multipart) == 1)) {
const char *data;
int i;
return 2;
}
i = 0;
for
(
) {
i++;
if (i == POST_MAX_VARS) break;
if (!crlf) break;
"Content-Disposition: form-data; name=\"%255[^\"]\"; filename=\"%255[^\"]\"",
}
}
}
else {
char *buffer;
}
}
}
return 2; /* [table<string, string>, table<string, array<string>>] */
}
/*
* lua_ap_requestbody; r:requestbody([filename]) - Reads or stores the request
* body
*/
static int lua_ap_requestbody(lua_State *L)
{
const char *filename;
request_rec *r;
r = ap_lua_check_request_rec(L, 1);
if (r) {
lua_pushnil(L);
lua_pushliteral(L, "Request body was larger than the permitted size.");
return 2;
}
return (0);
if (!filename) {
const char *data;
return (0);
return (2);
} else {
APR_FPROT_OS_DEFAULT, r->pool);
lua_settop(L, 0);
if (rc == APR_SUCCESS) {
lua_pushboolean(L, 0);
return 1;
}
return (1);
} else
lua_pushboolean(L, 0);
return (1);
}
}
return (0);
}
/* wrap ap_rputs as r:puts(String) */
{
int argc = lua_gettop(L);
int i;
for (i = 2; i <= argc; i++) {
ap_rputs(luaL_checkstring(L, i), r);
}
return 0;
}
/* wrap ap_rwrite as r:write(String) */
{
size_t n;
int rv;
lua_pushinteger(L, rv);
return 1;
}
/* r:addoutputfilter(name|function) */
static int req_add_output_filter(lua_State *L)
{
name);
return 0;
}
/* wrap ap_construct_url as r:construct_url(String) */
static int req_construct_url(lua_State *L)
{
return 1;
}
/* wrap ap_escape_html r:escape_html(String) */
static int req_escape_html(lua_State *L)
{
const char *s = luaL_checkstring(L, 2);
return 1;
}
/* wrap optional ssl_var_lookup as r:ssl_var_lookup(String) */
static int req_ssl_var_lookup(lua_State *L)
{
const char *s = luaL_checkstring(L, 2);
(char *)s);
lua_pushstring(L, res);
return 1;
}
/* BEGIN dispatch mathods for request_rec fields */
/* not really a field, but we treat it like one */
static const char *req_document_root(request_rec *r)
{
return ap_document_root(r);
}
static const char *req_context_prefix(request_rec *r)
{
return ap_context_prefix(r);
}
static const char *req_context_document_root(request_rec *r)
{
return ap_context_document_root(r);
}
static char *req_uri_field(request_rec *r)
{
return r->uri;
}
static const char *req_method_field(request_rec *r)
{
return r->method;
}
static const char *req_handler_field(request_rec *r)
{
return r->handler;
}
static const char *req_proxyreq_field(request_rec *r)
{
switch (r->proxyreq) {
case PROXYREQ_NONE: return "PROXYREQ_NONE";
case PROXYREQ_PROXY: return "PROXYREQ_PROXY";
case PROXYREQ_REVERSE: return "PROXYREQ_REVERSE";
case PROXYREQ_RESPONSE: return "PROXYREQ_RESPONSE";
default: return NULL;
}
}
static const char *req_hostname_field(request_rec *r)
{
return r->hostname;
}
static const char *req_args_field(request_rec *r)
{
return r->args;
}
static const char *req_path_info_field(request_rec *r)
{
return r->path_info;
}
static const char *req_canonical_filename_field(request_rec *r)
{
return r->canonical_filename;
}
static const char *req_filename_field(request_rec *r)
{
return r->filename;
}
static const char *req_user_field(request_rec *r)
{
return r->user;
}
static const char *req_unparsed_uri_field(request_rec *r)
{
return r->unparsed_uri;
}
static const char *req_ap_auth_type_field(request_rec *r)
{
return r->ap_auth_type;
}
static const char *req_content_encoding_field(request_rec *r)
{
return r->content_encoding;
}
static const char *req_content_type_field(request_rec *r)
{
return r->content_type;
}
static const char *req_range_field(request_rec *r)
{
return r->range;
}
static const char *req_protocol_field(request_rec *r)
{
return r->protocol;
}
static const char *req_the_request_field(request_rec *r)
{
return r->the_request;
}
static const char *req_log_id_field(request_rec *r)
{
return r->log_id;
}
static const char *req_useragent_ip_field(request_rec *r)
{
return r->useragent_ip;
}
static int req_remaining_field(request_rec *r)
{
return r->remaining;
}
static int req_status_field(request_rec *r)
{
return r->status;
}
static int req_assbackwards_field(request_rec *r)
{
return r->assbackwards;
}
{
return r->headers_in;
}
{
return r->headers_out;
}
{
return r->err_headers_out;
}
{
return r->subprocess_env;
}
{
return r->notes;
}
static int req_ssl_is_https_field(request_rec *r)
{
return ap_lua_ssl_is_https(r->connection);
}
static int lua_ap_rflush (lua_State *L) {
int returnValue;
request_rec *r;
r = ap_lua_check_request_rec(L, 1);
returnValue = ap_rflush(r);
lua_pushboolean(L, (returnValue == 0));
return 1;
}
static const char* lua_ap_options(request_rec* r)
{
int opts;
opts = ap_allow_options(r);
return apr_psprintf(r->pool, "%s %s %s %s %s %s", (opts&OPT_INDEXES) ? "Indexes" : "", (opts&OPT_INCLUDES) ? "Includes" : "", (opts&OPT_SYM_LINKS) ? "FollowSymLinks" : "", (opts&OPT_EXECCGI) ? "ExecCGI" : "", (opts&OPT_MULTI) ? "MultiViews" : "", (opts&OPT_ALL) == OPT_ALL ? "All" : "" );
}
static const char* lua_ap_allowoverrides(request_rec* r)
{
int opts;
opts = ap_allow_overrides(r);
return apr_psprintf(r->pool, "%s %s %s %s %s %s", (opts&OR_NONE) ? "None" : "", (opts&OR_LIMIT) ? "Limit" : "", (opts&OR_OPTIONS) ? "Options" : "", (opts&OR_FILEINFO) ? "FileInfo" : "", (opts&OR_AUTHCFG) ? "AuthCfg" : "", (opts&OR_INDEXES) ? "Indexes" : "" );
}
static int lua_ap_started(request_rec* r)
{
}
static const char* lua_ap_basic_auth_pw(request_rec* r)
{
ap_get_basic_auth_pw(r, &pw);
}
static int lua_ap_limit_req_body(request_rec* r)
{
return (int) ap_get_limit_req_body(r);
}
static int lua_ap_is_initial_req(request_rec *r)
{
return ap_is_initial_req(r);
}
static int lua_ap_some_auth_required(request_rec *r)
{
return ap_some_auth_required(r);
}
static int lua_ap_sendfile(lua_State *L)
{
const char *filename;
request_rec *r;
r = ap_lua_check_request_rec(L, 1);
lua_pushboolean(L, 0);
}
else {
r->pool);
if (rc == APR_SUCCESS) {
lua_pushinteger(L, sent);
}
else {
lua_pushboolean(L, 0);
}
}
return (1);
}
/*
* lua_apr_b64encode; r:encode_base64(string) - encodes a string to Base64
* format
*/
static int lua_apr_b64encode(lua_State *L)
{
const char *plain;
char *encoded;
request_rec *r;
r = ap_lua_check_request_rec(L, 1);
if (encoded_len) {
return 1;
}
return 0;
}
/*
* lua_apr_b64decode; r:decode_base64(string) - decodes a Base64 string
*/
static int lua_apr_b64decode(lua_State *L)
{
const char *encoded;
char *plain;
request_rec *r;
r = ap_lua_check_request_rec(L, 1);
if (decoded_len) {
return 1;
}
return 0;
}
/*
* lua_ap_unescape; r:unescape(string) - Unescapes an URL-encoded string
*/
static int lua_ap_unescape(lua_State *L)
{
const char *escaped;
char *plain;
size_t x,
y;
request_rec *r;
r = ap_lua_check_request_rec(L, 1);
y = ap_unescape_urlencoded(plain);
if (!y) {
lua_pushstring(L, plain);
return 1;
}
return 0;
}
/*
* lua_ap_escape; r:escape(string) - URL-escapes a string
*/
static int lua_ap_escape(lua_State *L)
{
const char *plain;
char *escaped;
size_t x;
request_rec *r;
r = ap_lua_check_request_rec(L, 1);
lua_pushstring(L, escaped);
return 1;
}
/*
* lua_apr_md5; r:md5(string) - Calculates an MD5 digest of a string
*/
static int lua_apr_md5(lua_State *L)
{
const char *buffer;
char *result;
request_rec *r;
r = ap_lua_check_request_rec(L, 1);
lua_pushstring(L, result);
return 1;
}
/*
* lua_apr_sha1; r:sha1(string) - Calculates the SHA1 digest of a string
*/
static int lua_apr_sha1(lua_State *L)
{
unsigned char digest[APR_SHA1_DIGESTSIZE];
const char *buffer;
char *result;
request_rec *r;
r = ap_lua_check_request_rec(L, 1);
lua_pushstring(L, result);
return 1;
}
/*
* lua_ap_mpm_query; r:mpm_query(info) - Queries for MPM info
*/
static int lua_ap_mpm_query(lua_State *L)
{
int x,
y;
x = lua_tonumber(L, 1);
ap_mpm_query(x, &y);
lua_pushnumber(L, y);
return 1;
}
/*
* lua_ap_expr; r:expr(string) - Evaluates an expr statement.
*/
static int lua_ap_expr(lua_State *L)
{
request_rec *r;
int x = 0;
const char *expr,
*err;
r = ap_lua_check_request_rec(L, 1);
res.line_number = 0;
if (!err) {
lua_pushboolean(L, x);
if (x < 0) {
lua_pushstring(L, err);
return 2;
}
return 1;
} else {
lua_pushboolean(L, 0);
lua_pushstring(L, err);
return 2;
}
lua_pushboolean(L, 0);
return 1;
}
/*
* lua_ap_regex; r:regex(string, pattern [, flags])
* - Evaluates a regex and returns captures if matched
*/
static int lua_ap_regex(lua_State *L)
{
request_rec *r;
int i,
rv,
const char *pattern,
*source;
char *err;
r = ap_lua_check_request_rec(L, 1);
if (rv) {
lua_pushboolean(L, 0);
lua_pushstring(L, err);
return 2;
}
lua_pushboolean(L, 0);
"regcomp found %d matches; only %d allowed.",
lua_pushstring(L, err);
return 2;
}
if (rv == AP_REG_NOMATCH) {
lua_pushboolean(L, 0);
return 1;
}
lua_newtable(L);
lua_pushinteger(L, i);
else
lua_pushnil(L);
lua_settable(L, -3);
}
return 1;
}
/*
* lua_ap_scoreboard_process; r:scoreboard_process(a) - returns scoreboard info
*/
static int lua_ap_scoreboard_process(lua_State *L)
{
int i;
i = lua_tonumber(L, 2);
if (ps_record) {
lua_newtable(L);
lua_pushstring(L, "connections");
lua_settable(L, -3);
lua_pushstring(L, "keepalive");
lua_settable(L, -3);
lua_pushstring(L, "lingering_close");
lua_settable(L, -3);
lua_pushstring(L, "pid");
lua_settable(L, -3);
lua_pushstring(L, "suspended");
lua_settable(L, -3);
lua_pushstring(L, "write_completion");
lua_settable(L, -3);
lua_pushstring(L, "not_accepting");
lua_settable(L, -3);
lua_pushstring(L, "quiescing");
lua_settable(L, -3);
return 1;
}
return 0;
}
/*
* lua_ap_scoreboard_worker; r:scoreboard_worker(proc, thread) - Returns thread
* info
*/
static int lua_ap_scoreboard_worker(lua_State *L)
{
int i,
j;
i = lua_tonumber(L, 2);
j = lua_tonumber(L, 3);
if (ws_record) {
lua_newtable(L);
lua_pushstring(L, "access_count");
lua_settable(L, -3);
lua_pushstring(L, "bytes_served");
lua_settable(L, -3);
lua_pushstring(L, "client");
lua_settable(L, -3);
lua_pushstring(L, "conn_bytes");
lua_settable(L, -3);
lua_pushstring(L, "conn_count");
lua_settable(L, -3);
lua_pushstring(L, "generation");
lua_settable(L, -3);
lua_pushstring(L, "last_used");
lua_settable(L, -3);
lua_pushstring(L, "pid");
lua_settable(L, -3);
lua_pushstring(L, "request");
lua_settable(L, -3);
lua_pushstring(L, "start_time");
lua_settable(L, -3);
lua_pushstring(L, "status");
lua_settable(L, -3);
lua_pushstring(L, "stop_time");
lua_settable(L, -3);
lua_pushstring(L, "tid");
lua_settable(L, -3);
lua_pushstring(L, "vhost");
lua_settable(L, -3);
#ifdef HAVE_TIMES
lua_pushstring(L, "stimes");
lua_settable(L, -3);
lua_pushstring(L, "utimes");
lua_settable(L, -3);
#endif
return 1;
}
return 0;
}
/*
* lua_ap_restarted; r:started() - Returns the timestamp of last server
* (re)start
*/
static int lua_ap_restarted(lua_State *L)
{
return 1;
}
/*
* lua_ap_clock; r:clock() - Returns timestamp with microsecond precision
*/
static int lua_ap_clock(lua_State *L)
{
now = apr_time_now();
lua_pushnumber(L, now);
return 1;
}
/*
* lua_ap_add_input_filter; r:add_input_filter(name) - Adds an input filter to
* the chain
*/
static int lua_ap_add_input_filter(lua_State *L)
{
request_rec *r;
const char *filterName;
r = ap_lua_check_request_rec(L, 1);
if (filter) {
lua_pushboolean(L, 1);
} else
lua_pushboolean(L, 0);
return 1;
}
/*
* lua_ap_module_info; r:module_info(mod_name) - Returns information about a
* loaded module
*/
static int lua_ap_module_info(lua_State *L)
{
const char *moduleName;
if (mod) {
const command_rec *cmd;
lua_newtable(L);
lua_pushstring(L, "commands");
lua_newtable(L);
lua_settable(L, -3);
}
lua_settable(L, -3);
return 1;
}
return 0;
}
/*
* lua_ap_runtime_dir_relative: r:runtime_dir_relative(file): Returns the
* filename as relative to the runtime dir
*/
static int lua_ap_runtime_dir_relative(lua_State *L)
{
request_rec *r;
const char *file;
r = ap_lua_check_request_rec(L, 1);
return 1;
}
/*
* lua_ap_set_document_root; r:set_document_root(path) - sets the current doc
* root for the request
*/
static int lua_ap_set_document_root(lua_State *L)
{
request_rec *r;
const char *root;
r = ap_lua_check_request_rec(L, 1);
ap_set_document_root(r, root);
return 0;
}
/*
* lua_ap_stat; r:stat(filename) - Runs stat on a file and returns the file
* info as a table
*/
static int lua_ap_stat(lua_State *L)
{
request_rec *r;
const char *filename;
r = ap_lua_check_request_rec(L, 1);
lua_newtable(L);
lua_pushstring(L, "mtime");
lua_settable(L, -3);
lua_pushstring(L, "atime");
lua_settable(L, -3);
lua_pushstring(L, "ctime");
lua_settable(L, -3);
lua_pushstring(L, "size");
lua_settable(L, -3);
lua_pushstring(L, "filetype");
lua_settable(L, -3);
return 1;
}
else {
return 0;
}
}
/*
* lua_ap_loaded_modules; r:loaded_modules() - Returns a list of loaded modules
*/
static int lua_ap_loaded_modules(lua_State *L)
{
int i;
lua_newtable(L);
lua_pushinteger(L, i + 1);
lua_settable(L, -3);
}
return 1;
}
/*
* lua_ap_server_info; r:server_info() - Returns server info, such as the
* executable filename, server root, mpm etc
*/
static int lua_ap_server_info(lua_State *L)
{
lua_newtable(L);
lua_pushstring(L, "server_executable");
lua_settable(L, -3);
lua_pushstring(L, "server_root");
lua_settable(L, -3);
lua_pushstring(L, "scoreboard_fname");
lua_settable(L, -3);
lua_pushstring(L, "server_mpm");
lua_pushstring(L, ap_show_mpm());
lua_settable(L, -3);
return 1;
}
/*
* === Auto-scraped functions ===
*/
/**
* ap_set_context_info: Set context_prefix and context_document_root.
* @param r The request
* @param prefix the URI prefix, without trailing slash
* @param document_root the corresponding directory on disk, without trailing
* slash
* @note If one of prefix of document_root is NULL, the corrsponding
* property will not be changed.
*/
static int lua_ap_set_context_info(lua_State *L)
{
request_rec *r;
const char *prefix;
const char *document_root;
r = ap_lua_check_request_rec(L, 1);
return 0;
}
/**
* ap_os_escape_path (apr_pool_t *p, const char *path, int partial)
* convert an OS path to a URL in an OS dependant way.
* @param p The pool to allocate from
* @param path The path to convert
* @param partial if set, assume that the path will be appended to something
* with a '/' in it (and thus does not prefix "./")
* @return The converted URL
*/
static int lua_ap_os_escape_path(lua_State *L)
{
char *returnValue;
request_rec *r;
const char *path;
int partial = 0;
r = ap_lua_check_request_rec(L, 1);
if (lua_isboolean(L, 3))
return 1;
}
/**
* ap_escape_logitem (apr_pool_t *p, const char *str)
* Escape a string for logging
* @param p The pool to allocate from
* @param str The string to escape
* @return The escaped string
*/
static int lua_ap_escape_logitem(lua_State *L)
{
char *returnValue;
request_rec *r;
const char *str;
r = ap_lua_check_request_rec(L, 1);
return 1;
}
/**
* ap_strcmp_match (const char *str, const char *expected)
* Determine if a string matches a patterm containing the wildcards '?' or '*'
* @param str The string to check
* @param expected The pattern to match against
* @param ignoreCase Whether to ignore case when matching
* @return 1 if the two strings match, 0 otherwise
*/
static int lua_ap_strcmp_match(lua_State *L)
{
int returnValue;
const char *str;
const char *expected;
int ignoreCase = 0;
if (lua_isboolean(L, 3))
if (!ignoreCase)
else
lua_pushboolean(L, (!returnValue));
return 1;
}
/**
* ap_set_keepalive (request_rec *r)
* Set the keepalive status for this request
* @param r The current request
* @return 1 if keepalive can be set, 0 otherwise
*/
static int lua_ap_set_keepalive(lua_State *L)
{
int returnValue;
request_rec *r;
r = ap_lua_check_request_rec(L, 1);
returnValue = ap_set_keepalive(r);
return 1;
}
/**
* ap_make_etag (request_rec *r, int force_weak)
* Construct an entity tag from the resource information. If it's a real
* file, build in some of the file characteristics.
* @param r The current request
* @param force_weak Force the entity tag to be weak - it could be modified
* again in as short an interval.
* @return The entity tag
*/
static int lua_ap_make_etag(lua_State *L)
{
char *returnValue;
request_rec *r;
int force_weak;
r = ap_lua_check_request_rec(L, 1);
return 1;
}
/**
* ap_send_interim_response (request_rec *r, int send_headers)
* Send an interim (HTTP 1xx) response immediately.
* @param r The request
* @param send_headers Whether to send&clear headers in r->headers_out
*/
static int lua_ap_send_interim_response(lua_State *L)
{
request_rec *r;
int send_headers = 0;
r = ap_lua_check_request_rec(L, 1);
if (lua_isboolean(L, 2))
return 0;
}
/**
* ap_custom_response (request_rec *r, int status, const char *string)
* Install a custom response handler for a given status
* @param r The current request
* @param status The status for which the custom response should be used
* @param string The custom response. This can be a static string, a file
* or a URL
*/
static int lua_ap_custom_response(lua_State *L)
{
request_rec *r;
int status;
const char *string;
r = ap_lua_check_request_rec(L, 1);
return 0;
}
/**
* ap_exists_config_define (const char *name)
* Check for a definition from the server command line
* @param name The define to check for
* @return 1 if defined, 0 otherwise
*/
static int lua_ap_exists_config_define(lua_State *L)
{
int returnValue;
const char *name;
return 1;
}
static int lua_ap_get_server_name_for_url(lua_State *L)
{
const char *servername;
request_rec *r;
r = ap_lua_check_request_rec(L, 1);
lua_pushstring(L, servername);
return 1;
}
/**
* ap_state_query (int query_code) item starts a new field */
static int lua_ap_state_query(lua_State *L)
{
int returnValue;
int query_code;
return 1;
}
static int lua_ap_sleep(lua_State *L)
{
int msec;
return 0;
}
/* END dispatch methods for request_rec fields */
static int req_dispatch(lua_State *L)
{
lua_pop(L, 2);
lua_pop(L, 1);
if (rft) {
case APL_REQ_FUNTYPE_TABLE:{
"request_rec->dispatching %s -> apr table",
name);
ap_lua_push_apr_table(L, rs);
return 1;
}
case APL_REQ_FUNTYPE_LUACFUN:{
"request_rec->dispatching %s -> lua_CFunction",
name);
lua_pushcfunction(L, func);
return 1;
}
case APL_REQ_FUNTYPE_STRING:{
char *rs;
"request_rec->dispatching %s -> string", name);
lua_pushstring(L, rs);
return 1;
}
case APL_REQ_FUNTYPE_INT:{
int rs;
"request_rec->dispatching %s -> int", name);
lua_pushnumber(L, rs);
return 1;
}
case APL_REQ_FUNTYPE_BOOLEAN:{
int rs;
"request_rec->dispatching %s -> boolean", name);
lua_pushboolean(L, rs);
return 1;
}
}
}
return 0;
}
/* helper function for the logging functions below */
{
const char *msg;
r, "%s", msg);
return 0;
}
/* r:debug(String) and friends which use apache logging */
{
return req_log_at(L, APLOG_EMERG);
}
{
return req_log_at(L, APLOG_ALERT);
}
{
return req_log_at(L, APLOG_CRIT);
}
{
return req_log_at(L, APLOG_ERR);
}
{
return req_log_at(L, APLOG_WARNING);
}
static int req_notice(lua_State *L)
{
return req_log_at(L, APLOG_NOTICE);
}
{
return req_log_at(L, APLOG_INFO);
}
{
return req_log_at(L, APLOG_DEBUG);
}
static int lua_ivm_get(lua_State *L) {
if (object) {
return 1;
}
else {
return 0;
}
}
static int lua_ivm_set(lua_State *L) {
luaL_checkany(L, 3);
/* This will require MaxConnectionsPerChild to be > 0, since it's
* essentially leaking memory as values are being overridden */
}
return 0;
}
{ \
}
/* handle r.status = 201 */
static int req_newindex(lua_State *L)
{
const char *key;
/* request_rec* r = lua_touserdata(L, lua_upvalueindex(1)); */
/* const char* key = luaL_checkstring(L, -2); */
return 0;
}
return 0;
}
return 0;
}
return 0;
}
return 0;
}
return 0;
}
return 0;
}
return 0;
}
apr_psprintf(r->pool,
"Property [%s] may not be set on a request_rec",
key));
lua_error(L);
return 0;
}
static const struct luaL_Reg request_methods[] = {
{"__index", req_dispatch},
{"__newindex", req_newindex},
/* {"__newindex", req_set_field}, */
};
static const struct luaL_Reg connection_methods[] = {
};
static const char* lua_ap_auth_name(request_rec* r)
{
const char *name;
name = ap_auth_name(r);
}
static const char* lua_ap_get_server_name(request_rec* r)
{
const char *name;
name = ap_get_server_name(r);
}
static const struct luaL_Reg server_methods[] = {
};
{
return rft;
}
{
p));
APL_REQ_FUNTYPE_STRING, p));
lua_pushvalue(L, -1);
lua_pop(L, 2);
lua_pushvalue(L, -1);
lua_pop(L, 2);
lua_pushvalue(L, -1);
lua_pop(L, 2);
}
{
lua_boxpointer(L, c);
luaL_getmetatable(L, "Apache2.Connection");
lua_setmetatable(L, -2);
luaL_getmetatable(L, "Apache2.Connection");
ap_lua_push_apr_table(L, c->notes);
lua_pushstring(L, c->client_ip);
lua_pop(L, 1);
}
{
lua_boxpointer(L, s);
luaL_getmetatable(L, "Apache2.Server");
lua_setmetatable(L, -2);
luaL_getmetatable(L, "Apache2.Server");
lua_pushstring(L, s->server_hostname);
lua_pop(L, 1);
}
{
lua_boxpointer(L, r);
luaL_getmetatable(L, "Apache2.Request");
lua_setmetatable(L, -2);
}