ArduinoLibs
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
LoginShell.h
1 /*
2  * Copyright (C) 2016 Southern Storm Software, Pty Ltd.
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a
5  * copy of this software and associated documentation files (the "Software"),
6  * to deal in the Software without restriction, including without limitation
7  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8  * and/or sell copies of the Software, and to permit persons to whom the
9  * Software is furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice shall be included
12  * in all copies or substantial portions of the Software.
13  *
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20  * DEALINGS IN THE SOFTWARE.
21  */
22 
23 #ifndef LOGIN_SHELL_h
24 #define LOGIN_SHELL_h
25 
26 #include "Shell.h"
27 
28 typedef int (*ShellPasswordCheckFunc)(const char *username, const char *password);
29 
30 class LoginShell : public Shell
31 {
32 public:
33  LoginShell();
34  virtual ~LoginShell();
35 
36  const char *machineName() const { return machName; }
37  void setMachineName(const char *machineName) { machName = machineName; }
38 
39  ShellPasswordCheckFunc passwordCheckFunction() const { return checkFunc; }
40  void setPasswordCheckFunction(ShellPasswordCheckFunc function) { checkFunc = function; }
41 
42 protected:
43  virtual void beginSession();
44  virtual void printPrompt();
45  virtual void execute();
46 
47 private:
48  const char *machName;
49  ShellPasswordCheckFunc checkFunc;
50 };
51 
52 #endif
void setMachineName(const char *machineName)
Sets the name of the machine to display in the login prompt.
Definition: LoginShell.h:37
const char * machineName() const
Gets the name of the machine to display in the login prompt.
Definition: LoginShell.h:36
void setPasswordCheckFunction(ShellPasswordCheckFunc function)
Sets the password checking function.
Definition: LoginShell.h:40
LoginShell()
Constructs a new login shell.
Definition: LoginShell.cpp:67
virtual void printPrompt()
Prints the current prompt string.
Definition: Shell.cpp:1007
ShellPasswordCheckFunc
Password checking function for login shells.
ShellPasswordCheckFunc passwordCheckFunction() const
Gets the current password checking function, or NULL if the function has not been set yet...
Definition: LoginShell.h:39
virtual void beginSession()
Begins a login session.
Definition: Shell.cpp:958
virtual void execute()
Executes the command in the buffer.
Definition: Shell.cpp:1057
Command-line shell access via a login shell.
Definition: LoginShell.h:30
virtual ~LoginShell()
Destroys this login shell.
Definition: LoginShell.cpp:76
Command-line shell access.
Definition: Shell.h:62