Freeciv-3.2: /fast/freeciv/nightly/S3_2/server/scripting/tolua_fcdb_gen.c Source File

Freeciv-3.2

Loading...
Searching...
No Matches
tolua_fcdb_gen.c
Go to the documentation of this file.
1/*
2** Lua binding: fcdb
3*/
4
5#include "tolua.h"
6
7#ifndef __cplusplus
8#include <stdlib.h>
9#endif
10#ifdef __cplusplus
11 extern "C" int tolua_bnd_takeownership (lua_State* L); // from tolua_map.c
12#else
13 int tolua_bnd_takeownership (lua_State* L); /* from tolua_map.c */
14#endif
15#include <string.h>
16
17/* Exported function */
18 TOLUA_API int tolua_fcdb_open (lua_State* tolua_S);
19 LUALIB_API int luaopen_fcdb (lua_State* tolua_S);
20
21#ifdef HAVE_CONFIG_H
22#include <fc_config.h>
23#endif
24#include "luascript_types.h"
25#include "api_fcdb_auth.h"
26#include "api_fcdb_base.h"
27#include "script_fcdb.h"
28
29/* function to register type */
30 static void tolua_reg_types (lua_State* tolua_S)
31{
32 tolua_usertype(tolua_S,"Connection");
33}
34
35/* function: api_auth_get_username */
36 static int tolua_fcdb_auth_get_username00(lua_State* tolua_S)
37{
38#ifndef TOLUA_RELEASE
39 tolua_Error tolua_err;
40 if (
41 !tolua_isusertype(tolua_S,1,"Connection",0,&tolua_err) ||
42 !tolua_isnoobj(tolua_S,2,&tolua_err)
43 )
44 goto tolua_lerror;
45 else
46#endif
47 {
48 lua_State* L = tolua_S;
49 Connection* pconn = ((Connection*) tolua_tousertype(tolua_S,1,0));
50 {
51 const char* tolua_ret = (const char*) api_auth_get_username(L,pconn);
52 tolua_pushstring(tolua_S,(const char*)tolua_ret);
53 }
54 }
55 return 1;
56#ifndef TOLUA_RELEASE
57 tolua_lerror:
58 tolua_error(tolua_S,"#ferror in function 'get_username'.",&tolua_err);
59 return 0;
60#endif
61}
62
63/* function: api_auth_get_ipaddr */
64 static int tolua_fcdb_auth_get_ipaddr00(lua_State* tolua_S)
65{
66#ifndef TOLUA_RELEASE
67 tolua_Error tolua_err;
68 if (
69 !tolua_isusertype(tolua_S,1,"Connection",0,&tolua_err) ||
70 !tolua_isnoobj(tolua_S,2,&tolua_err)
71 )
72 goto tolua_lerror;
73 else
74#endif
75 {
76 lua_State* L = tolua_S;
77 Connection* pconn = ((Connection*) tolua_tousertype(tolua_S,1,0));
78 {
79 const char* tolua_ret = (const char*) api_auth_get_ipaddr(L,pconn);
80 tolua_pushstring(tolua_S,(const char*)tolua_ret);
81 }
82 }
83 return 1;
84#ifndef TOLUA_RELEASE
85 tolua_lerror:
86 tolua_error(tolua_S,"#ferror in function 'get_ipaddr'.",&tolua_err);
87 return 0;
88#endif
89}
90
91/* function: api_auth_get_cmdlevel */
92 static int tolua_fcdb_auth_get_cmdlevel00(lua_State* tolua_S)
93{
94#ifndef TOLUA_RELEASE
95 tolua_Error tolua_err;
96 if (
97 !tolua_isusertype(tolua_S,1,"Connection",0,&tolua_err) ||
98 !tolua_isnoobj(tolua_S,2,&tolua_err)
99 )
100 goto tolua_lerror;
101 else
102#endif
103 {
104 lua_State* L = tolua_S;
105 Connection* pconn = ((Connection*) tolua_tousertype(tolua_S,1,0));
106 {
107 int tolua_ret = (int) api_auth_get_cmdlevel(L,pconn);
108 tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
109 }
110 }
111 return 1;
112#ifndef TOLUA_RELEASE
113 tolua_lerror:
114 tolua_error(tolua_S,"#ferror in function 'get_cmdlevel'.",&tolua_err);
115 return 0;
116#endif
117}
118
119/* function: api_auth_set_cmdlevel */
120 static int tolua_fcdb_auth_set_cmdlevel00(lua_State* tolua_S)
121{
122#ifndef TOLUA_RELEASE
123 tolua_Error tolua_err;
124 if (
125 !tolua_isusertype(tolua_S,1,"Connection",0,&tolua_err) ||
126 !tolua_isnumber(tolua_S,2,0,&tolua_err) ||
127 !tolua_isnoobj(tolua_S,3,&tolua_err)
128 )
129 goto tolua_lerror;
130 else
131#endif
132 {
133 lua_State* L = tolua_S;
134 Connection* pconn = ((Connection*) tolua_tousertype(tolua_S,1,0));
135 int level = ((int) tolua_tonumber(tolua_S,2,0));
136 {
137 api_auth_set_cmdlevel(L,pconn,level);
138 }
139 }
140 return 0;
141#ifndef TOLUA_RELEASE
142 tolua_lerror:
143 tolua_error(tolua_S,"#ferror in function 'set_cmdlevel'.",&tolua_err);
144 return 0;
145#endif
146}
147
148/* function: api_fcdb_option */
149 static int tolua_fcdb_fcdb_option00(lua_State* tolua_S)
150{
151#ifndef TOLUA_RELEASE
152 tolua_Error tolua_err;
153 if (
154 !tolua_isstring(tolua_S,1,0,&tolua_err) ||
155 !tolua_isnoobj(tolua_S,2,&tolua_err)
156 )
157 goto tolua_lerror;
158 else
159#endif
160 {
161 lua_State* L = tolua_S;
162 const char* name = ((const char*) tolua_tostring(tolua_S,1,0));
163 {
164 const char* tolua_ret = (const char*) api_fcdb_option(L,name);
165 tolua_pushstring(tolua_S,(const char*)tolua_ret);
166 }
167 }
168 return 1;
169#ifndef TOLUA_RELEASE
170 tolua_lerror:
171 tolua_error(tolua_S,"#ferror in function 'option'.",&tolua_err);
172 return 0;
173#endif
174}
175
176/* Open lib function */
177 LUALIB_API int luaopen_fcdb (lua_State* tolua_S)
178{
179 tolua_open(tolua_S);
180 tolua_reg_types(tolua_S);
181 tolua_module(tolua_S,NULL,0);
182 tolua_beginmodule(tolua_S,NULL);
183 tolua_module(tolua_S,"auth",0);
184 tolua_beginmodule(tolua_S,"auth");
185 tolua_function(tolua_S,"get_username",tolua_fcdb_auth_get_username00);
186 tolua_function(tolua_S,"get_ipaddr",tolua_fcdb_auth_get_ipaddr00);
187 tolua_function(tolua_S,"get_cmdlevel",tolua_fcdb_auth_get_cmdlevel00);
188 tolua_function(tolua_S,"set_cmdlevel",tolua_fcdb_auth_set_cmdlevel00);
189 tolua_endmodule(tolua_S);
190 tolua_module(tolua_S,"fcdb",0);
191 tolua_beginmodule(tolua_S,"fcdb");
192 tolua_function(tolua_S,"option",tolua_fcdb_fcdb_option00);
193 tolua_endmodule(tolua_S);
194
195 { /* begin embedded lua code */
196 static unsigned char B[] = {
197 10,102, 99,100, 98, 91, 34,112, 97,114, 97,109, 34, 93, 32,
198 61, 32,123, 10, 72, 79, 83, 84, 32, 61, 32, 34, 35,100,101,
199 112,114,101, 99, 97,116,101,100, 46,104,111,115,116, 34, 44,
200 10, 85, 83, 69, 82, 32, 61, 32, 34, 35,100,101,112,114,101,
201 99, 97,116,101,100, 46,117,115,101,114, 34, 44, 10, 80, 79,
202 82, 84, 32, 61, 32, 34, 35,100,101,112,114,101, 99, 97,116,
203 101,100, 46,112,111,114,116, 34, 44, 10, 80, 65, 83, 83, 87,
204 79, 82, 68, 32, 61, 32, 34, 35,100,101,112,114,101, 99, 97,
205 116,101,100, 46,112, 97,115,115,119,111,114,100, 34, 44, 10,
206 68, 65, 84, 65, 66, 65, 83, 69, 32, 61, 32, 34, 35,100,101,
207 112,114,101, 99, 97,116,101,100, 46,100, 97,116, 97, 98, 97,
208 115,101, 34, 44, 10, 84, 65, 66, 76, 69, 95, 85, 83, 69, 82,
209 32, 61, 32, 34, 35,100,101,112,114,101, 99, 97,116,101,100,
210 46,116, 97, 98,108,101, 95,117,115,101,114, 34, 44, 10, 84,
211 65, 66, 76, 69, 95, 76, 79, 71, 32, 61, 32, 34, 35,100,101,
212 112,114,101, 99, 97,116,101,100, 46,116, 97, 98,108,101, 95,
213 108,111,103, 34, 44, 10, 66, 65, 67, 75, 69, 78, 68, 32, 61,
214 32, 34, 35,100,101,112,114,101, 99, 97,116,101,100, 46, 98,
215 97, 99,107,101,110,100, 34, 10,125,32
216 };
217 if (luaL_loadbuffer(tolua_S,(char*)B,sizeof(B),"tolua: embedded Lua code") == LUA_OK)
218 lua_pcall(tolua_S,0,LUA_MULTRET,0);
219 } /* end of embedded lua code */
220
221 tolua_endmodule(tolua_S);
222 return 1;
223}
224/* Open tolua function */
225 TOLUA_API int tolua_fcdb_open (lua_State* tolua_S)
226{
227 lua_pushcfunction(tolua_S, luaopen_fcdb);
228 lua_pushstring(tolua_S, "fcdb");
229 lua_call(tolua_S, 1, 0);
230 return 1;
231}
api_auth_get_username
const char * api_auth_get_username(lua_State *L, Connection *pconn)
Definition api_fcdb_auth.c:39
api_auth_set_cmdlevel
void api_auth_set_cmdlevel(lua_State *L, Connection *pconn, int level)
Definition api_fcdb_auth.c:75
api_auth_get_cmdlevel
int api_auth_get_cmdlevel(lua_State *L, Connection *pconn)
Definition api_fcdb_auth.c:63
api_auth_get_ipaddr
const char * api_auth_get_ipaddr(lua_State *L, Connection *pconn)
Definition api_fcdb_auth.c:51
api_fcdb_auth.h
api_fcdb_option
const char * api_fcdb_option(lua_State *L, const char *type)
Definition api_fcdb_base.c:34
api_fcdb_base.h
incite_cost
char * incite_cost
Definition comments.c:74
name
const char * name
Definition inputfile.c:127
luascript_types.h
script_fcdb.h
level
struct setting_list * level[OLEVELS_NUM]
Definition settings.c:190
connection
Definition connection.h:136
tolua_fcdb_auth_get_cmdlevel00
static int tolua_fcdb_auth_get_cmdlevel00(lua_State *tolua_S)
Definition tolua_fcdb_gen.c:92
luaopen_fcdb
LUALIB_API int luaopen_fcdb(lua_State *tolua_S)
Definition tolua_fcdb_gen.c:177
tolua_fcdb_auth_get_username00
static int tolua_fcdb_auth_get_username00(lua_State *tolua_S)
Definition tolua_fcdb_gen.c:36
tolua_fcdb_open
TOLUA_API int tolua_fcdb_open(lua_State *tolua_S)
Definition tolua_fcdb_gen.c:225
tolua_reg_types
static void tolua_reg_types(lua_State *tolua_S)
Definition tolua_fcdb_gen.c:30
tolua_fcdb_fcdb_option00
static int tolua_fcdb_fcdb_option00(lua_State *tolua_S)
Definition tolua_fcdb_gen.c:149
tolua_bnd_takeownership
int tolua_bnd_takeownership(lua_State *L)
tolua_fcdb_auth_set_cmdlevel00
static int tolua_fcdb_auth_set_cmdlevel00(lua_State *tolua_S)
Definition tolua_fcdb_gen.c:120
tolua_fcdb_auth_get_ipaddr00
static int tolua_fcdb_auth_get_ipaddr00(lua_State *tolua_S)
Definition tolua_fcdb_gen.c:64