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)
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 *****************************************************************************/
15 #include <fc_config.h>
22 #include "connection.h"
24 /* common/scriptcore */
25 #include "luascript.h"
30 /* server/scripting */
31 #include "script_fcdb.h"
33 #include "api_fcdb_auth.h"
35 /*****************************************************************************
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 /*****************************************************************************
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 /*****************************************************************************
61 *****************************************************************************/
62 bool api_auth_set_password(lua_State
*L
, Connection
*pconn
,
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 /*****************************************************************************
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
);