vfs: check userland buffers before reading them.
[haiku.git] / src / apps / debugger / user_interface / cli / CommandLineUserInterface.h
blobc6d68acfe0c471ce57f863805056b716c9086372
1 /*
2 * Copyright 2011-2016, Rene Gollent, rene@gollent.com.
3 * Copyright 2012, Ingo Weinhold, ingo_weinhold@gmx.de.
4 * Distributed under the terms of the MIT License.
5 */
6 #ifndef COMMAND_LINE_USER_INTERFACE_H
7 #define COMMAND_LINE_USER_INTERFACE_H
10 #include <ObjectList.h>
11 #include <String.h>
13 #include "CliContext.h"
14 #include "UserInterface.h"
17 class CliCommand;
20 class CommandLineUserInterface : public UserInterface {
21 public:
22 CommandLineUserInterface();
23 virtual ~CommandLineUserInterface();
25 virtual const char* ID() const;
27 virtual status_t Init(Team* team,
28 UserInterfaceListener* listener);
29 virtual void Show();
30 virtual void Terminate();
31 // shut down the UI *now* -- no more user
32 // feedback
34 virtual UserInterface* Clone() const;
36 virtual bool IsInteractive() const;
38 virtual status_t LoadSettings(const TeamUiSettings* settings);
39 virtual status_t SaveSettings(TeamUiSettings*& settings) const;
41 virtual void NotifyUser(const char* title,
42 const char* message,
43 user_notification_type type);
44 virtual void NotifyBackgroundWorkStatus(
45 const char* message);
46 virtual int32 SynchronouslyAskUser(const char* title,
47 const char* message, const char* choice1,
48 const char* choice2, const char* choice3);
49 virtual status_t SynchronouslyAskUserForFile(entry_ref* _ref);
51 void Run();
52 // Called by the main thread, when
53 // everything has been set up. Enters the
54 // input loop.
56 private:
57 struct CommandEntry;
58 typedef BObjectList<CommandEntry> CommandList;
60 struct HelpCommand;
62 // GCC 2 support
63 friend struct HelpCommand;
65 private:
66 static status_t _InputLoopEntry(void* data);
67 status_t _InputLoop();
69 status_t _RegisterCommands();
70 bool _RegisterCommand(const BString& name,
71 CliCommand* command);
72 void _ExecuteCommand(int argc,
73 const char* const* argv);
74 CommandEntry* _FindCommand(const char* commandName);
75 void _PrintHelp(const char* commandName);
76 static int _CompareCommandEntries(
77 const CommandEntry* command1,
78 const CommandEntry* command2);
80 private:
81 CliContext fContext;
82 CommandList fCommands;
83 sem_id fShowSemaphore;
84 bool fShown;
85 volatile bool fTerminating;
89 #endif // COMMAND_LINE_USER_INTERFACE_H