When no command match is found internally, the TELNETs_CmdHandlerExt()
callback function is automatically called. This function needs to be implemented in the user application, and has the following prototype:
Code Block |
---|
CPU_INT16S TELNETs_CmdHandlerExt (CPU_CHAR *pcmd_line, |
...
void *pcwd,
CPU_BOOLEAN *psession_active, |
...
...
...
...
where pcmd_line
is the received complete line; pcwd
, a pointer to the current working directory; and psession_active
, a pointer to a variable indicating whether or not the telnet session is active. As for the pout_fnct
parameter, it is a pointer to a function whose purpose is to provide a way for a command to transmit data to the telnet client, with the help of the pout_opt
parameter.
...
The pseudocode for TELNETs_CmdProcessCmdHandlerExt()
is shown in section Listing 3-3 “Pseudocode following listing.
Code Block |
---|
language | cpp |
---|
title | Listing - Pseudocode for TELNETs_CmdHandlerExt() |
---|
|
...
.
...
|
CPU_INT16S TELNETs_CmdHandlerExt ( |
...
CPU_CHAR *pcmd_line,
void *pcwd,
CPU_BOOLEAN *psession_active,
void *pout_opt,
TELNETs_SESSION *psession,
TELNET_OUT_FNCT *pout_fnct,
TELNETs_ERR *perr)
{
Parse the command line (pcmd_line). (1)
Search corresponding command. (2)
Execute command. (3)
Transmit error message if needed. (4)
} |
Panel |
---|
|
- The command line received by the telnet server and passed in parameter has to be parsed in order to extract the command name, as well as its eventual arguments.
|
...
- Once the command name has been read from the command line,
TELNETs_
|
...
CmdHandlerExt() has to locate the corresponding function. The storage and search mechanism taking place here is implementation specific.
|
...
- Finally, the function corresponding to the one passed in the command line is invoked, and output to the telnet client is possibly transmitted.
|
...
- If an error occurred while processing (i.e., searching for) the command, the function simply returns with the error variable set accordingly. However, if the error occurred inside the function, it is that function responsibility to transmit an appropriate message to the telnet client.
|