#ifndef _aplmt_networking_uip_apps_telnetd_shell_shellapi_h_ #define _aplmt_networking_uip_apps_telnetd_shell_shellapi_h_ /*---------------------------------------------------------------------------- ** SUMMARY: Command Shell Interface for uIP Telnet deamon ** ** DESCRIPTION: ** This file provides the infrastructure for a simple Command ** shell that interfaces with the uIP telnet deamon. ** ** USAGE NOTES: ** ------------ ** o Each shell command is identified by a single printable ASCII character. ** The first non-whitespace character in the line is assumed to be the ** the command character. ** o The command character (and trailing non-whitespace characters) and ** the intervening whitespace before the first command argument are ** stripped off prior to calling the shell command function. ** o The shell command function (_func) typically returns non-zero (true). If ** it returns zero (false), then the shell engine will automatically close ** the telnet connection. ** o The command table is typically created/populated by the top-level "creator" ** object. ** o The very last entry in the command table must be a 0/NULL pointer. ** o The second to last entry in the command table is assumed to be the ** default command handler, i.e. the command that is called if there ** is no matching command found. ** ** CONFIGURATION ** ------------- ** COMPILE: none. ** ** PLATFORM: none. ** ** APPLICATION: OPTION_APLMTUIP_TELNET_SHELL_PROMPT ** ** NOTES: ** 1. For efficency/optimization some methods are 'inlined'. The inlining ** is done by using the preprocessor/macros. The application should ** treat all methods as function calls and not rely on the fact they may ** be currently defined as macros. ----------------------------------------------------------------------------*/ #include "aplcfg.h" /* For: Application configuration */ #include "apl/types/types.h" /* For: basic types */ #include "aplmt/networking/uip/apps/telnetd/telnetdapi.h" #ifdef __cplusplus extern "C" { #endif /*-------------- CONSTANTS -------------------------------------------------*/ /** String that is used as the shell prompt */ #ifndef OPTION_APLMTUIP_TELNET_SHELL_PROMPT #define OPTION_APLMTUIP_TELNET_SHELL_PROMPT "> " #endif /*-------------- TYPES -----------------------------------------------------*/ /** Individual Command Structure */ struct AplmtUIPTelnetShellCmd_t { AplBool (* _func)(struct AplmtUIPTelnetdState_t*, char, char*); /* Command Function */ char* _helpstring; /* Help string */ char _cmd; /* Single character command (case sensitive) */ }; /** Command table entry */ typedef struct AplmtUIPTelnetShellCmd_t* AplmtUIPTelnetShellCmdEntry_t; /** Reference to the populate command table */ extern AplmtUIPTelnetShellCmdEntry_t aplmtUIPTelnetShellCommands[]; /*-------------- PUBLIC/PUBLISHED API --------------------------------------*/ /** This method is a callback into the application. It is called when a telnet connection has been established. At a minimum it should output the shell banner/intro. The prompt string will automaticaly be generated by the shell engine. */ void AplmtUIP_cbTelnetShellConnected( struct AplmtUIPTelnetdState_t* s ); /** This method is a callback into the application. It is called when a telnet connection is closed. */ void AplmtUIP_cbTelnetShellClosed( struct AplmtUIPTelnetdState_t* s ); #ifdef __cplusplus } #endif #endif /* _aplmt_networking_uip_apps_telnetd_shell_shellapi_h_ */