Line data Source code
1 :
2 : /*
3 : * Copyright (C) Yichun Zhang (agentzh)
4 : */
5 :
6 :
7 : #ifndef DDEBUG
8 : #define DDEBUG 0
9 : #endif
10 : #include "ddebug.h"
11 :
12 :
13 : #include "ngx_http_lua_config.h"
14 : #include "api/ngx_http_lua_api.h"
15 :
16 :
17 : static int ngx_http_lua_config_prefix(lua_State *L);
18 : static int ngx_http_lua_config_configure(lua_State *L);
19 :
20 :
21 : void
22 18 : ngx_http_lua_inject_config_api(lua_State *L)
23 : {
24 : /* ngx.config */
25 :
26 18 : lua_createtable(L, 0, 6 /* nrec */); /* .config */
27 :
28 : #if (NGX_DEBUG)
29 18 : lua_pushboolean(L, 1);
30 : #else
31 : lua_pushboolean(L, 0);
32 : #endif
33 18 : lua_setfield(L, -2, "debug");
34 :
35 18 : lua_pushcfunction(L, ngx_http_lua_config_prefix);
36 18 : lua_setfield(L, -2, "prefix");
37 :
38 18 : lua_pushinteger(L, nginx_version);
39 18 : lua_setfield(L, -2, "nginx_version");
40 :
41 18 : lua_pushinteger(L, ngx_http_lua_version);
42 18 : lua_setfield(L, -2, "ngx_lua_version");
43 :
44 18 : lua_pushcfunction(L, ngx_http_lua_config_configure);
45 18 : lua_setfield(L, -2, "nginx_configure");
46 :
47 18 : lua_pushliteral(L, "http");
48 18 : lua_setfield(L, -2, "subsystem");
49 :
50 18 : lua_setfield(L, -2, "config");
51 18 : }
52 :
53 :
54 : static int
55 0 : ngx_http_lua_config_prefix(lua_State *L)
56 : {
57 0 : lua_pushlstring(L, (char *) ngx_cycle->prefix.data,
58 0 : ngx_cycle->prefix.len);
59 0 : return 1;
60 : }
61 :
62 :
63 : static int
64 0 : ngx_http_lua_config_configure(lua_State *L)
65 : {
66 0 : lua_pushliteral(L, NGX_CONFIGURE);
67 0 : return 1;
68 : }
69 :
70 : /* vi:set ft=c ts=4 sw=4 et fdm=marker: */
|