vfs: check userland buffers before reading them.
[haiku.git] / src / apps / terminal / Shell.h
blobdf14406e82dab2c4f4e1e6548436317d16a169d9
1 /*
2 * Copyright 2007 Haiku, Inc.
3 * Copyright (c) 2003-4 Kian Duffy <myob@users.sourceforge.net>
4 * Copyright (c) 2004 Daniel Furrer <assimil8or@users.sourceforge.net>
5 * Parts Copyright (C) 1998,99 Kazuho Okui and Takashi Murai.
6 * Distributed under the terms of the MIT License.
7 * Authors:
8 * Stefano Ceccherini <stefano.ceccherini@gmail.com>
9 * Kian Duffy <myob@users.sourceforge.net>
10 * Kazuho Okui
11 * Takashi Murai
13 #ifndef _SHELL_H
14 #define _SHELL_H
17 #include "ShellInfo.h"
20 class ActiveProcessInfo;
21 class ShellParameters;
22 // TODO: Maybe merge TermParse and Shell classes ?
23 class TerminalBuffer;
24 class TermParse;
27 class Shell {
28 public:
29 Shell();
30 virtual ~Shell();
32 status_t Open(int row, int col,
33 const ShellParameters& parameters);
34 void Close();
36 const char* TTYName() const;
38 ssize_t Read(void* buffer, size_t numBytes) const;
39 ssize_t Write(const void* buffer, size_t numBytes);
41 status_t UpdateWindowSize(int row, int columns);
43 status_t GetAttr(struct termios& attr) const;
44 status_t SetAttr(const struct termios& attr);
46 int FD() const;
47 pid_t ProcessID() const
48 { return fShellInfo.ProcessID(); }
49 const ShellInfo& Info() const
50 { return fShellInfo; }
52 int Encoding() const
53 { return fShellInfo.Encoding(); }
54 void SetEncoding(int encoding)
55 { fShellInfo.SetEncoding(encoding); }
57 bool HasActiveProcesses() const;
58 bool GetActiveProcessInfo(
59 ActiveProcessInfo& _info) const;
61 virtual status_t AttachBuffer(TerminalBuffer* buffer);
62 virtual void DetachBuffer();
64 private:
65 status_t _Spawn(int row, int col,
66 const ShellParameters& parameters);
68 private:
69 ShellInfo fShellInfo;
70 int fFd;
71 pid_t fProcessID;
72 TermParse* fTermParse;
73 bool fAttached;
77 #endif // _SHELL_H