Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Published by Scroll Versions from this space and version 1.05.00

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,

...


								  void 				*pout_opt,

...


								  TELNET_OUT_FNCT

...

 	 pout_fnct,

...


								  TELNETs_ERR 		*perr);

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 for TELNETs_CmdHandlerExt()”.

Listing 3-3 Pseudocode for TELNETs_CmdHandlerExt()

L3-3(1) following listing.

  1. 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.

...

  1. Once the command name has been read from the command line, TELNETs_

...

  1. CmdHandlerExt() has to locate the corresponding function. The storage and search mechanism taking place here is implementation specific.

...

  1. Finally, the function corresponding to the one passed in the command line is invoked, and output to the telnet client is possibly transmitted.

...

  1. 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.