vfs: check userland buffers before reading them.
[haiku.git] / src / tools / fs_shell / fssh.h
blobfc1389192276b2e1f74499237d4a1f1f2f5509b4
1 /*
2 * Copyright 2007, Ingo Weinhold, bonefish@cs.tu-berlin.de.
3 * Distributed under the terms of the MIT License.
4 */
5 #ifndef _FSSH_FSSH_H
6 #define _FSSH_FSSH_H
9 #include "compatibility.h"
11 #include <map>
12 #include <string>
14 #include "fssh_defs.h"
17 typedef fssh_status_t command_function(int argc, const char* const* argv);
20 namespace FSShell {
23 enum {
24 COMMAND_RESULT_EXIT = 1,
28 // Command
29 class Command {
30 public:
31 Command(const char* name,
32 const char* description);
33 Command(command_function* function,
34 const char* name, const char* description);
35 virtual ~Command();
37 const char* Name() const;
38 const char* Description() const;
40 virtual fssh_status_t Do(int argc, const char* const* argv);
42 private:
43 std::string fName;
44 std::string fDescription;
45 command_function* fFunction;
49 // CommandManager
50 class CommandManager {
51 private:
52 CommandManager();
54 public:
55 static CommandManager* Default();
57 void AddCommand(Command* command);
58 void AddCommand(command_function* function,
59 const char* name, const char* description);
60 void AddCommands(command_function* function,
61 const char* name, const char* description,
62 ...);
63 Command* FindCommand(const char* name) const;
64 void ListCommands() const;
66 private:
67 typedef std::map<std::string, Command*> CommandMap;
69 CommandMap fCommands;
71 static CommandManager* sManager;
75 extern void register_additional_commands(void);
78 } // namespace FSShell
81 #endif // _FSSH_FSSH_H