Embedded TCP/IP stack  4.7.0
fnet_shell.h
1 /**************************************************************************
2 *
3 * Copyright 2008-2018 by Andrey Butok. FNET Community.
4 *
5 ***************************************************************************
6 *
7 * Licensed under the Apache License, Version 2.0 (the "License"); you may
8 * not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
15 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 *
19 ***************************************************************************
20 *
21 * FNET Shell service API.
22 *
23 ***************************************************************************/
24 #ifndef _FNET_SHELL_H_
25 
26 #define _FNET_SHELL_H_
27 
103 /**************************************************************************/
108 #define FNET_SHELL_QUOTE_SYMBOL '\''
109 
110 /**************************************************************************/
127 #define FNET_SHELL_ESCAPE_SYMBOL '\\'
128 
129 /**************************************************************************/
135 #define FNET_SHELL_COMMAND_SPLITTER ';'
136 
137 /**************************************************************************/
141 typedef enum
142 {
150 
151 /**************************************************************************/
155 typedef void *fnet_shell_desc_t;
156 
157 /**************************************************************************/
173 
174 /**************************************************************************/
187 typedef struct
188 {
189  const fnet_char_t *name;
209 
210 /**************************************************************************/
218 typedef struct
219 {
224  void (*shell_init)( fnet_shell_desc_t shell_desc );
227 } fnet_shell_t;
228 
229 
230 /**************************************************************************/
233 typedef struct
234 {
249 
250 #if defined(__cplusplus)
251 extern "C" {
252 #endif
253 
254 /***************************************************************************/
279 
280 /***************************************************************************/
297 
298 /***************************************************************************/
338 
339 
340 /***************************************************************************/
362 
363 /***************************************************************************/
380 
381 /***************************************************************************/
410 fnet_return_t fnet_shell_block( fnet_shell_desc_t desc, void (*on_ctrlc)(fnet_shell_desc_t shl_desc, void *cookie), void *cookie);
411 
412 /***************************************************************************/
430 
431 /***************************************************************************/
482 
483 /***************************************************************************/
536 
537 /***************************************************************************/
552 void fnet_shell_putchar(fnet_shell_desc_t desc, fnet_char_t character);
553 
554 /***************************************************************************/
572 fnet_int32_t fnet_shell_getchar(fnet_shell_desc_t desc);
573 
574 /***************************************************************************/
595 
596 /***************************************************************************/
612 
613 /***************************************************************************/
632 
633 #if defined(__cplusplus)
634 }
635 #endif
636 
639 #endif
The Shell service is accepting user commnads.
Definition: fnet_shell.h:145
void fnet_shell_help(fnet_shell_desc_t desc)
Prints the command-shell help message.
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:241
Stream control structure.
Definition: fnet_serial.h:100
Shell main control structure.
Definition: fnet_shell.h:218
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:189
fnet_char_t * cmd_line_buffer
Command-line buffer.
Definition: fnet_shell.h:236
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:196
The Shell service is blocked and ignores user commnads.
Definition: fnet_shell.h:147
const fnet_shell_command_t * 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:220
The Shell service finished command execution.
Definition: fnet_shell.h:148
fnet_return_t
General return codes, used by most of API functions.
Definition: fnet_stdlib.h:89
fnet_index_t min_args
Minimum number of arguments the command accepts.
Definition: fnet_shell.h:190
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.
const fnet_shell_command_t * fnet_shell_get_command_by_name(fnet_shell_desc_t desc, const fnet_char_t *name)
Looks for a shell command by its name.
unsigned long fnet_size_t
Unsigned integer type representing the size in bytes.
Definition: fnet_stdlib.h:55
void fnet_shell_unblock(fnet_shell_desc_t desc)
Unblocks the shell to accept user commands.
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:237
The Shell service is executing user commnads.
Definition: fnet_shell.h:146
The Shell service is not initialized.
Definition: fnet_shell.h:144
fnet_index_t max_args
Maximum number of arguments the command accepts.
Definition: fnet_shell.h:191
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:192
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...
fnet_serial_stream_t stream
Serial stream assigned to the shell.
Definition: fnet_shell.h:240
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:172
fnet_int32_t fnet_shell_getchar(fnet_shell_desc_t desc)
Reads character from the shell stream.
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:194
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:80
fnet_shell_state_t
Shell states. Used mainly for debugging purposes.
Definition: fnet_shell.h:141
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.
fnet_char_t * prompt_str
Shell prompt (null-terminated string).
Definition: fnet_shell.h:223
void * fnet_shell_desc_t
Shell service descriptor.
Definition: fnet_shell.h:155
The Shell service is not initialized.
Definition: fnet_shell.h:143
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:70
const fnet_shell_t * shell
Shell control structure.
Definition: fnet_shell.h:235
char fnet_char_t
Type representing the charecter.
Definition: fnet_stdlib.h:75
Shell command control structure.
Definition: fnet_shell.h:187
Input parameters for fnet_shell_init().
Definition: fnet_shell.h:233
fnet_return_t fnet_shell_switch(fnet_shell_desc_t desc, const fnet_shell_t *switch_shell)
Switch to other command line set.
fnet_shell_desc_t fnet_shell_init(fnet_shell_params_t *params)
Initializes the Shell service.

© 2005-2020 by Andrej Butok. http://fnet.sourceforge.net