Merge remote-tracking branch 'speedprog/banByIp'
[oweals/minetest.git] / src / servercommand.h
1 /*
2 Part of Minetest-c55
3 Copyright (C) 2010-11 celeron55, Perttu Ahola <celeron55@gmail.com>
4 Copyright (C) 2011 Ciaran Gultnieks <ciaran@ciarang.com>
5
6 Permission to use, copy, modify, and distribute this software for any
7 purpose with or without fee is hereby granted, provided that the above
8 copyright notice and this permission notice appear in all copies.
9
10 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 */
18
19 #ifndef SERVERCOMMAND_HEADER
20 #define SERVERCOMMAND_HEADER
21
22 #include <vector>
23 #include <sstream>
24 #include "common_irrlicht.h"
25 #include "player.h"
26 #include "server.h"
27
28 struct ServerCommandContext
29 {
30
31         std::vector<std::wstring> parms;
32         std::wstring paramstring;
33         Server* server;
34         ServerEnvironment *env;
35         Player* player;
36         // Effective privs for the player, which may be different to their
37         // stored ones - e.g. if they are named in the config as an admin.
38         u64 privs;
39         u32 flags;
40
41         ServerCommandContext(
42                 std::vector<std::wstring> parms,
43                 std::wstring paramstring,
44                 Server* server,
45                 ServerEnvironment *env,
46                 Player* player,
47                 u64 privs)
48                 : parms(parms), paramstring(paramstring),
49                 server(server), env(env), player(player), privs(privs)
50         {
51         }
52
53 };
54
55 // Process a command sent from a client. The environment and connection
56 // should be locked when this is called.
57 // Returns a response message, to be dealt with according to the flags set
58 // in the context.
59 std::wstring processServerCommand(ServerCommandContext *ctx);
60
61 #endif
62
63