Apache2
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
lua_vmprep.h
Go to the documentation of this file.
1 
18 #include "lua.h"
19 #include "lauxlib.h"
20 #include "lualib.h"
21 
22 #include "httpd.h"
23 
24 #include "apr_thread_rwlock.h"
25 #include "apr_strings.h"
26 #include "apr_tables.h"
27 #include "apr_hash.h"
28 #include "apr_buckets.h"
29 #include "apr_file_info.h"
30 #include "apr_time.h"
31 #include "apr_pools.h"
32 #include "apr_reslist.h"
33 
34 
35 #ifndef VMPREP_H
36 #define VMPREP_H
37 
38 #define AP_LUA_SCOPE_UNSET 0
39 #define AP_LUA_SCOPE_ONCE 1
40 #define AP_LUA_SCOPE_REQUEST 2
41 #define AP_LUA_SCOPE_CONN 3
42 #define AP_LUA_SCOPE_THREAD 4
43 #define AP_LUA_SCOPE_SERVER 5
44 
45 #define AP_LUA_CACHE_UNSET 0
46 #define AP_LUA_CACHE_NEVER 1
47 #define AP_LUA_CACHE_STAT 2
48 #define AP_LUA_CACHE_FOREVER 3
49 
50 #define AP_LUA_FILTER_INPUT 1
51 #define AP_LUA_FILTER_OUTPUT 2
52 
53 typedef void (*ap_lua_state_open_callback) (lua_State *L, apr_pool_t *p,
54  void *ctx);
58 typedef struct
59 {
60  /* NEED TO ADD ADDITIONAL PACKAGE PATHS AS PART OF SPEC INSTEAD OF DIR CONFIG */
63 
64  /* name of base file to load in the vm */
65  const char *file;
66 
67  /* APL_SCOPE_ONCE | APL_SCOPE_REQUEST | APL_SCOPE_CONN | APL_SCOPE_THREAD | APL_SCOPE_SERVER */
68  int scope;
69  unsigned int vm_min;
70  unsigned int vm_max;
71 
73  void* cb_arg;
74 
75  /* pool to use for lifecycle if APL_SCOPE_ONCE is set, otherwise unused */
77 
78  /* Pre-compiled Lua Byte code to load directly. If bytecode_len is >0,
79  * the file part of this structure is ignored for loading purposes, but
80  * it is used for error messages.
81  */
82  const char *bytecode;
84 
85  int codecache;
87 
88 typedef struct
89 {
90  const char *function_name;
91  const char *file_name;
92  int scope;
94  const char *bytecode;
96  int codecache;
98 
99 typedef struct
100 {
101  const char *function_name;
102  const char *file_name;
103  const char* filter_name;
104  int direction; /* AP_LUA_FILTER_INPUT | AP_LUA_FILTER_OUTPUT */
106 
107 typedef struct {
111 } ap_lua_finfo;
112 
113 typedef struct {
114  lua_State* L;
117 
121 void ap_lua_load_apache2_lmodule(lua_State *L);
122 
123 /*
124  * alternate means of getting lua_State (preferred eventually)
125  * Obtain a lua_State which has loaded file and is associated with lifecycle_pool
126  * If one exists, will return extant one, otherwise will create, attach, and return
127  * This does no locking around the lua_State, so if the pool is shared between
128  * threads, locking is up the client.
129  *
130  * @lifecycle_pool -> pool whose lifeycle controls the lua_State
131  * @file file to be opened, also used as a key for uniquing lua_States
132  * @cb callback for vm initialization called *before* the file is opened
133  * @ctx a baton passed to cb
134  */
135 lua_State *ap_lua_get_lua_state(apr_pool_t *lifecycle_pool,
136  ap_lua_vm_spec *spec, request_rec* r);
137 
138 #if APR_HAS_THREADS || defined(DOXYGEN)
139 /*
140  * Initialize mod_lua mutex.
141  * @pool pool for mutex
142  * @s server_rec for logging
143  */
145 #endif
146 
147 #endif
size_t apr_size_t
Definition: apr.h:375
Definition: lua_vmprep.h:99
APR Reader/Writer Lock Routines.
int scope
Definition: lua_vmprep.h:68
void(* ap_lua_state_open_callback)(lua_State *L, apr_pool_t *p, void *ctx)
Definition: lua_vmprep.h:53
Definition: apr_tables.h:62
const char * bytecode
Definition: lua_vmprep.h:82
unsigned int vm_max
Definition: lua_vmprep.h:70
APR File Information.
apr_bucket_brigade request_rec apr_pool_t * pool
Definition: mod_dav.h:552
Definition: lua_vmprep.h:113
ap_lua_state_open_callback cb
Definition: lua_vmprep.h:72
const char * file_name
Definition: lua_vmprep.h:91
int scope
Definition: lua_vmprep.h:92
APR Hash Tables.
int codecache
Definition: lua_vmprep.h:96
apr_pool_t * pool
Definition: lua_vmprep.h:76
void * cb_arg
Definition: lua_vmprep.h:73
void ap_lua_init_mutex(apr_pool_t *pool, server_rec *s)
lua_State * L
Definition: lua_vmprep.h:114
const char * function_name
Definition: lua_vmprep.h:90
int direction
Definition: lua_vmprep.h:104
APR-UTIL Resource List Routines.
apr_array_header_t * package_paths
Definition: lua_vmprep.h:61
const char * file_name
Definition: lua_vmprep.h:102
const char * filter_name
Definition: lua_vmprep.h:103
apr_int64_t apr_time_t
Definition: apr_time.h:45
APR memory allocation.
HTTP Daemon routines.
A structure to store information for each virtual server.
Definition: httpd.h:1310
Definition: lua_vmprep.h:107
APR Table library.
Definition: lua_vmprep.h:88
Definition: ap_regex.h:107
APR-UTIL Buckets/Bucket Brigades.
const char * function_name
Definition: lua_vmprep.h:101
const char * file
Definition: lua_vmprep.h:65
apr_pool_t * p
void ap_lua_load_apache2_lmodule(lua_State *L)
lua_State * ap_lua_get_lua_state(apr_pool_t *lifecycle_pool, ap_lua_vm_spec *spec, request_rec *r)
apr_size_t bytecode_len
Definition: lua_vmprep.h:95
Definition: lua_vmprep.h:58
A structure that represents the current request.
Definition: httpd.h:810
APR Strings library.
struct apr_pool_t apr_pool_t
Definition: apr_pools.h:60
typedef void(APR_THREAD_FUNC *PFN_HSE_IO_COMPLETION)(EXTENSION_CONTROL_BLOCK *ecb
apr_time_t modified
Definition: lua_vmprep.h:109
request_rec * r
Definition: mod_dav.h:515
APR Time Library.
unsigned int vm_min
Definition: lua_vmprep.h:69
ap_lua_finfo * finfo
Definition: lua_vmprep.h:115
int codecache
Definition: lua_vmprep.h:85
apr_size_t runs
Definition: lua_vmprep.h:108
apr_size_t bytecode_len
Definition: lua_vmprep.h:83
apr_array_header_t * package_cpaths
Definition: lua_vmprep.h:62
ap_regex_t * uri_pattern
Definition: lua_vmprep.h:93
off_t apr_off_t
Definition: apr.h:377
const char * bytecode
Definition: lua_vmprep.h:94
apr_off_t size
Definition: lua_vmprep.h:110