Embedded TCP/IP stack: fnet_shell.h Source File

FNET

fnet_shell.h
1 /**************************************************************************
2 *
3 * Copyright 2011-2017 by Andrey Butok. FNET Community.
4 * Copyright 2008-2010 by Andrey Butok. Freescale Semiconductor, Inc.
5 *
6 ***************************************************************************
7 *
8 * Licensed under the Apache License, Version 2.0 (the "License"); you may
9 * not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
11 *
12 * http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
16 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 *
20 ***************************************************************************
21 *
22 * FNET Shell service API.
23 *
24 ***************************************************************************/
25 #ifndef _FNET_SHELL_H_
26 
27 #define _FNET_SHELL_H_
28 
104 /**************************************************************************/
109 #define FNET_SHELL_QUOTE_SYMBOL '\''
110 
111 /**************************************************************************/
128 #define FNET_SHELL_ESCAPE_SYMBOL '\\'
129 
130 /**************************************************************************/
136 #define FNET_SHELL_COMMAND_SPLITTER ';'
137 
138 /**************************************************************************/
142 typedef enum
143 {
151 
152 /**************************************************************************/
156 typedef void *fnet_shell_desc_t;
157 
158 /**************************************************************************/
174 
175 struct fnet_shell_command;
176 /**************************************************************************/
190 {
191  const fnet_char_t *name;
210 };
211 
212 /**************************************************************************/
221 {
228  void (*shell_init)( fnet_shell_desc_t shell_desc );
232 };
233 
234 
235 /**************************************************************************/
239 {
240  const struct fnet_shell *shell;
253 };
254 
255 #if defined(__cplusplus)
256 extern "C" {
257 #endif
258 
259 /***************************************************************************/
284 
285 /***************************************************************************/
302 
303 /***************************************************************************/
343 
344 
345 /***************************************************************************/
367 
368 /***************************************************************************/
385 
386 /***************************************************************************/
415 fnet_return_t fnet_shell_block( fnet_shell_desc_t desc, void (*on_ctrlc)(fnet_shell_desc_t shl_desc, void *cookie), void *cookie);
416 
417 /***************************************************************************/
435 
436 /***************************************************************************/
487 
488 /***************************************************************************/
541 
542 /***************************************************************************/
557 void fnet_shell_putchar(fnet_shell_desc_t desc, fnet_char_t character);
558 
559 /***************************************************************************/
577 fnet_int32_t fnet_shell_getchar(fnet_shell_desc_t desc);
578 
579 /***************************************************************************/
599 fnet_return_t fnet_shell_switch( fnet_shell_desc_t desc, const struct fnet_shell *switch_shell);
600 
601 /***************************************************************************/
617 
618 #if defined(__cplusplus)
619 }
620 #endif
621 
624 #endif
fnet_bool_t echo
Enable/disable terminal echo flag. When set to FNET_TRUE the echo is enabled, characters received by ...
Definition: fnet_shell.h:246
The Shell service is accepting user commnads.
Definition: fnet_shell.h:146
void fnet_shell_help(fnet_shell_desc_t desc)
Prints the command-shell help message.
Stream control structure.
Definition: fnet_serial.h:101
fnet_shell_desc_t fnet_shell_init(struct fnet_shell_params *params)
Initializes the Shell service.
fnet_return_t fnet_shell_script(fnet_shell_desc_t desc, fnet_char_t *script)
Executes the command line script.
const fnet_char_t * name
Command name (null-terminated string).
Definition: fnet_shell.h:191
fnet_serial_stream_t stream
Serial stream assigned to the shell.
Definition: fnet_shell.h:245
The Shell service is blocked and ignores user commnads.
Definition: fnet_shell.h:148
Shell main control structure.
Definition: fnet_shell.h:220
The Shell service finished command execution.
Definition: fnet_shell.h:149
fnet_return_t
General return codes, used by most of API functions.
Definition: fnet_stdlib.h:90
fnet_return_t fnet_shell_block(fnet_shell_desc_t desc, void(*on_ctrlc)(fnet_shell_desc_t shl_desc, void *cookie), void *cookie)
Blocks the shell to ignore user commands.
void fnet_shell_script_stop(fnet_shell_desc_t desc)
Stops execution of the shell command line.
fnet_char_t * description
Brief description of the command (null-terminated string). This field is used by the fnet_shell_help...
Definition: fnet_shell.h:196
fnet_index_t min_args
Minimum number of arguments the command accepts.
Definition: fnet_shell.h:192
unsigned long fnet_size_t
Unsigned integer type representing the size in bytes.
Definition: fnet_stdlib.h:56
Input parameters for fnet_shell_init().
Definition: fnet_shell.h:238
fnet_index_t max_args
Maximum number of arguments the command accepts.
Definition: fnet_shell.h:193
void fnet_shell_unblock(fnet_shell_desc_t desc)
Unblocks the shell to accept user commands.
The Shell service is executing user commnads.
Definition: fnet_shell.h:147
The Shell service is not initialized.
Definition: fnet_shell.h:145
fnet_char_t * cmd_line_buffer
Command-line buffer.
Definition: fnet_shell.h:241
fnet_char_t * syntax
Syntax of the command (null-terminated string). This field is used by the fnet_shell_help() function...
Definition: fnet_shell.h:198
fnet_size_t cmd_line_buffer_size
Size of the command-line buffer. It defines the maximum length of the entered input-command line...
Definition: fnet_shell.h:242
fnet_size_t fnet_shell_println(fnet_shell_desc_t desc, const fnet_char_t *format,...)
Prints formatted text to the shell stream and terminates the printed text by the line separator strin...
void(* fnet_shell_cmd_function_t)(fnet_shell_desc_t desc, fnet_index_t argc, fnet_char_t **argv)
Command callback function prototype.
Definition: fnet_shell.h:173
fnet_return_t fnet_shell_switch(fnet_shell_desc_t desc, const struct fnet_shell *switch_shell)
Switch to other command line set.
fnet_int32_t fnet_shell_getchar(fnet_shell_desc_t desc)
Reads character from the shell stream.
fnet_size_t fnet_shell_printf(fnet_shell_desc_t desc, const fnet_char_t *format,...)
Prints formatted text to the shell stream.
fnet_bool_t
Boolean type.
Definition: fnet_stdlib.h:81
fnet_shell_state_t
Shell states. Used mainly for debugging purposes.
Definition: fnet_shell.h:142
void fnet_shell_putchar(fnet_shell_desc_t desc, fnet_char_t character)
Writes character to the shell stream.
fnet_bool_t fnet_shell_is_ctrlc(fnet_shell_desc_t desc)
Detects if the [Ctrl]+[c] is received.
Shell command control structure.
Definition: fnet_shell.h:189
fnet_char_t * prompt_str
Shell prompt (null-terminated string).
Definition: fnet_shell.h:226
fnet_shell_cmd_function_t cmd_ptr
Pointer to the actual command function defined by the fnet_shell_cmd_function_t type.
Definition: fnet_shell.h:194
void * fnet_shell_desc_t
Shell service descriptor.
Definition: fnet_shell.h:156
The Shell service is not initialized.
Definition: fnet_shell.h:144
void fnet_shell_release(fnet_shell_desc_t desc)
Releases the Shell service.
unsigned int fnet_index_t
Unsigned integer type representing the index.
Definition: fnet_stdlib.h:71
char fnet_char_t
Type representing the charecter.
Definition: fnet_stdlib.h:76
const struct fnet_shell * shell
Shell control structure.
Definition: fnet_shell.h:240
const struct fnet_shell_command * cmd_table
The pointer to the command table. The last table element must have all fields set to zero as the end...
Definition: fnet_shell.h:222

© 2005-2018 by Andrey Butok. http://fnet.sourceforge.net