Freeciv-3.1: /fast/freeciv/nightly/S3_1/server/scripting/tolua_fcdb_gen.c Source File

Freeciv-3.1

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 */
18TOLUA_API int tolua_fcdb_open (lua_State* tolua_S);
19LUALIB_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_fcdb_option */
92 static int tolua_fcdb_fcdb_option00(lua_State* tolua_S)
93{
94#ifndef TOLUA_RELEASE
95 tolua_Error tolua_err;
96 if (
97 !tolua_isstring(tolua_S,1,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 const char* name = ((const char*) tolua_tostring(tolua_S,1,0));
106 {
107 const char* tolua_ret = (const char*) api_fcdb_option(L,name);
108 tolua_pushstring(tolua_S,(const char*)tolua_ret);
109 }
110 }
111 return 1;
112#ifndef TOLUA_RELEASE
113 tolua_lerror:
114 tolua_error(tolua_S,"#ferror in function 'option'.",&tolua_err);
115 return 0;
116#endif
117}
118
119/* Open lib function */
120LUALIB_API int luaopen_fcdb (lua_State* tolua_S)
121{
122 tolua_open(tolua_S);
123 tolua_reg_types(tolua_S);
124 tolua_module(tolua_S,NULL,0);
125 tolua_beginmodule(tolua_S,NULL);
126 tolua_module(tolua_S,"auth",0);
127 tolua_beginmodule(tolua_S,"auth");
128 tolua_function(tolua_S,"get_username",tolua_fcdb_auth_get_username00);
129 tolua_function(tolua_S,"get_ipaddr",tolua_fcdb_auth_get_ipaddr00);
130 tolua_endmodule(tolua_S);
131 tolua_module(tolua_S,"fcdb",0);
132 tolua_beginmodule(tolua_S,"fcdb");
133 tolua_function(tolua_S,"option",tolua_fcdb_fcdb_option00);
134 tolua_endmodule(tolua_S);
135
136 { /* begin embedded lua code */
137 static unsigned char B[] = {
138 10,102, 99,100, 98, 91, 34,112, 97,114, 97,109, 34, 93, 32,
139 61, 32,123, 10, 72, 79, 83, 84, 32, 61, 32, 34, 35,100,101,
140 112,114,101, 99, 97,116,101,100, 46,104,111,115,116, 34, 44,
141 10, 85, 83, 69, 82, 32, 61, 32, 34, 35,100,101,112,114,101,
142 99, 97,116,101,100, 46,117,115,101,114, 34, 44, 10, 80, 79,
143 82, 84, 32, 61, 32, 34, 35,100,101,112,114,101, 99, 97,116,
144 101,100, 46,112,111,114,116, 34, 44, 10, 80, 65, 83, 83, 87,
145 79, 82, 68, 32, 61, 32, 34, 35,100,101,112,114,101, 99, 97,
146 116,101,100, 46,112, 97,115,115,119,111,114,100, 34, 44, 10,
147 68, 65, 84, 65, 66, 65, 83, 69, 32, 61, 32, 34, 35,100,101,
148 112,114,101, 99, 97,116,101,100, 46,100, 97,116, 97, 98, 97,
149 115,101, 34, 44, 10, 84, 65, 66, 76, 69, 95, 85, 83, 69, 82,
150 32, 61, 32, 34, 35,100,101,112,114,101, 99, 97,116,101,100,
151 46,116, 97, 98,108,101, 95,117,115,101,114, 34, 44, 10, 84,
152 65, 66, 76, 69, 95, 76, 79, 71, 32, 61, 32, 34, 35,100,101,
153 112,114,101, 99, 97,116,101,100, 46,116, 97, 98,108,101, 95,
154 108,111,103, 34, 44, 10, 66, 65, 67, 75, 69, 78, 68, 32, 61,
155 32, 34, 35,100,101,112,114,101, 99, 97,116,101,100, 46, 98,
156 97, 99,107,101,110,100, 34, 10,125,32
157 };
158 if (luaL_loadbuffer(tolua_S,(char*)B,sizeof(B),"tolua: embedded Lua code") == LUA_OK)
159 lua_pcall(tolua_S,0,LUA_MULTRET,0);
160 } /* end of embedded lua code */
161
162 tolua_endmodule(tolua_S);
163 return 1;
164}
165/* Open tolua function */
166TOLUA_API int tolua_fcdb_open (lua_State* tolua_S)
167{
168 lua_pushcfunction(tolua_S, luaopen_fcdb);
169 lua_pushstring(tolua_S, "fcdb");
170 lua_call(tolua_S, 1, 0);
171 return 1;
172}
api_auth_get_username
const char * api_auth_get_username(lua_State *L, Connection *pconn)
Definition api_fcdb_auth.c:38
api_auth_get_ipaddr
const char * api_auth_get_ipaddr(lua_State *L, Connection *pconn)
Definition api_fcdb_auth.c:50
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
name
const char * name
Definition inputfile.c:127
luascript_types.h
script_fcdb.h
connection
Definition connection.h:141
luaopen_fcdb
LUALIB_API int luaopen_fcdb(lua_State *tolua_S)
Definition tolua_fcdb_gen.c:120
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:166
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:92
tolua_bnd_takeownership
int tolua_bnd_takeownership(lua_State *L)
tolua_fcdb_auth_get_ipaddr00
static int tolua_fcdb_auth_get_ipaddr00(lua_State *tolua_S)
Definition tolua_fcdb_gen.c:64