Freeciv-3.3: /fast/freeciv/nightly/main/server/scripting/api_fcdb_auth.c Source File

Freeciv-3.3

Loading...
Searching...
No Matches
api_fcdb_auth.c
Go to the documentation of this file.
1/*****************************************************************************
2 Freeciv - Copyright (C) 2005 - The Freeciv Project
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2, or (at your option)
6 any later version.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12*****************************************************************************/
13
14#ifdef HAVE_CONFIG_H
15#include <fc_config.h>
16#endif
17
18/* utility */
19#include "log.h"
20
21/* common */
22#include "connection.h"
23
24/* common/scriptcore */
25#include "luascript.h"
26
27/* server */
28#include "auth.h"
29#include "connecthand.h"
30
31/* server/scripting */
32#include "script_fcdb.h"
33
34#include "api_fcdb_auth.h"
35
36/**********************************************************************/
39 const char *api_auth_get_username(lua_State *L, Connection *pconn)
40{
41 LUASCRIPT_CHECK_STATE(L, NULL);
42 LUASCRIPT_CHECK_SELF(L, pconn, NULL);
43 fc_assert_ret_val(conn_is_valid(pconn), NULL);
44
45 return auth_get_username(pconn);
46}
47
48/**********************************************************************/
51 const char *api_auth_get_ipaddr(lua_State *L, Connection *pconn)
52{
53 LUASCRIPT_CHECK_STATE(L, NULL);
54 LUASCRIPT_CHECK_SELF(L, pconn, NULL);
55 fc_assert_ret_val(conn_is_valid(pconn), NULL);
56
57 return auth_get_ipaddr(pconn);
58}
59
60/**********************************************************************/
63 int api_auth_get_cmdlevel(lua_State *L, Connection *pconn)
64{
65 LUASCRIPT_CHECK_STATE(L, -1);
66 LUASCRIPT_CHECK_SELF(L, pconn, -1);
67 fc_assert_ret_val(conn_is_valid(pconn), -1);
68
69 return conn_get_access(pconn);
70}
71
72/**********************************************************************/
75 void api_auth_set_cmdlevel(lua_State *L, Connection *pconn, int level)
76{
77 LUASCRIPT_CHECK_STATE(L);
78 LUASCRIPT_CHECK_SELF(L, pconn);
79 fc_assert_ret(conn_is_valid(pconn));
80
81 conn_set_access(pconn, level, TRUE);
82}
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
auth_get_username
const char * auth_get_username(struct connection *pconn)
Definition auth.c:348
auth_get_ipaddr
const char * auth_get_ipaddr(struct connection *pconn)
Definition auth.c:358
auth.h
incite_cost
char * incite_cost
Definition comments.c:74
conn_set_access
void conn_set_access(struct connection *pconn, enum cmdlevel new_level, bool granted)
Definition connecthand.c:72
connecthand.h
conn_get_access
enum cmdlevel conn_get_access(const struct connection *pconn)
Definition connection.c:775
conn_is_valid
bool conn_is_valid(const struct connection *pconn)
Definition connection.c:934
connection.h
log.h
fc_assert_ret
#define fc_assert_ret(condition)
Definition log.h:191
fc_assert_ret_val
#define fc_assert_ret_val(condition, val)
Definition log.h:194
luascript.h
LUASCRIPT_CHECK_STATE
#define LUASCRIPT_CHECK_STATE(L,...)
Definition luascript.h:117
LUASCRIPT_CHECK_SELF
#define LUASCRIPT_CHECK_SELF(L, value,...)
Definition luascript.h:146
script_fcdb.h
level
struct setting_list * level[OLEVELS_NUM]
Definition settings.c:190
connection
Definition connection.h:136
TRUE
#define TRUE
Definition support.h:46