Add scripting API control over unit 'stay'
[freeciv.git] / server / scripting / api_fcdb_auth.c
blobf891f7f46a466861e6f4c51900b69d789a51cc29
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.
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 *****************************************************************************/
14 #ifdef HAVE_CONFIG_H
15 #include <fc_config.h>
16 #endif
18 /* utility */
19 #include "log.h"
21 /* common */
22 #include "connection.h"
24 /* common/scriptcore */
25 #include "luascript.h"
27 /* server */
28 #include "auth.h"
30 /* server/scripting */
31 #include "script_fcdb.h"
33 #include "api_fcdb_auth.h"
35 /*****************************************************************************
36 Get the username.
37 *****************************************************************************/
38 const char *api_auth_get_username(lua_State *L, Connection *pconn)
40 LUASCRIPT_CHECK_STATE(L, NULL);
41 LUASCRIPT_CHECK_SELF(L, pconn, NULL);
42 fc_assert_ret_val(conn_is_valid(pconn), NULL);
44 return auth_get_username(pconn);
47 /*****************************************************************************
48 Get the ip address.
49 *****************************************************************************/
50 const char *api_auth_get_ipaddr(lua_State *L, Connection *pconn)
52 LUASCRIPT_CHECK_STATE(L, NULL);
53 LUASCRIPT_CHECK_SELF(L, pconn, NULL);
54 fc_assert_ret_val(conn_is_valid(pconn), NULL);
56 return auth_get_ipaddr(pconn);
59 /*****************************************************************************
60 Set the password.
61 *****************************************************************************/
62 bool api_auth_set_password(lua_State *L, Connection *pconn,
63 const char *password)
65 LUASCRIPT_CHECK_STATE(L, NULL);
66 LUASCRIPT_CHECK_SELF(L, pconn, FALSE);
67 fc_assert_ret_val(conn_is_valid(pconn), FALSE);
69 return auth_set_password(pconn, password);
72 /*****************************************************************************
73 Get the password
74 *****************************************************************************/
75 const char *api_auth_get_password(lua_State *L, Connection *pconn)
77 LUASCRIPT_CHECK_STATE(L, NULL);
78 LUASCRIPT_CHECK_SELF(L, pconn, NULL);
79 fc_assert_ret_val(conn_is_valid(pconn), NULL);
81 return auth_get_password(pconn);