#ifndef __SHELL_H__
#define __SHELL_H__

#include "types.h"
#include "continuation.h"
#include "usart.h"

class Shell : public Continuation
{
	public:
		Shell() : _aUart(*new USART_1) {}
		~Shell() {}
		virtual bool Run(bool unUsed);

	private:
		char*	allocLine(void);
		void	deallocLine(char* line);
		void	unknown(char* str);
		void	pinheadQuote(char* str);
		void	timeAtDepth(char* str);
		void	holdThisDepth(char* str);
		void	startAfter(char* str);
		void	inform(char* str);
		void	version(char* str);
		void	help(char* str);
		void	parse(char* str);
		void	inttostr(char* str, uint32_t i);
		void 	shellStart(void);
		void 	shellInput(char* command);
		void 	shellPrompt(const char* prompt);
		void	shellOutput(const char* str1, const char* str2);
		void	sendLine(char* line);
		void	getChar(uint8_t c);

		enum {
			LineLength		= 80,
			NumberOfLines	= 50
		};

		USART_1&					_aUart;

		char*						_lines[NumberOfLines];
		char 						_buf[LineLength];
		char 						_line[LineLength];
		char 						_bufptr;
		uint32_t 					_numSent;

		typedef void (Shell::*ShellMemberFunction) (char* str);
		struct command {
		  const char*	 		commandString;
		  ShellMemberFunction	commandFunction;
		};
};

#endif // __TELNETD_H__
