shell.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2009-2013 Freie Universit├Ąt Berlin
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser
5  * General Public License v2.1. See the file LICENSE in the top level
6  * directory for more details.
7  */
8 
20 #ifndef SHELL_H
21 #define SHELL_H
22 
23 #include <stdint.h>
24 
25 #include "kernel_defines.h"
26 
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30 
34 #define SHELL_DEFAULT_BUFSIZE (128)
35 
53 typedef int (*shell_command_handler_t)(int argc, char **argv);
54 
60 typedef struct shell_command_t {
61  const char *name;
62  const char *desc;
65 
73 void shell_run_once(const shell_command_t *commands, char *line_buf, int len);
74 
82 static inline void shell_run_forever(const shell_command_t *commands,
83  char *line_buf, int len)
84 {
85  while (1) {
86  shell_run_once(commands, line_buf, len);
87  }
88 }
89 
97 static inline void shell_run(const shell_command_t *commands,
98  char *line_buf, int len)
99 {
100  shell_run_forever(commands, line_buf, len);
101 }
102 
103 #ifdef __cplusplus
104 }
105 #endif
106 
107 #endif /* SHELL_H */
108 
void shell_run_once(const shell_command_t *commands, char *line_buf, int len)
Start a shell and exit once EOF is reached.
int(* shell_command_handler_t)(int argc, char **argv)
Protype of a shell callback handler.
Definition: shell.h:53
const char * name
Name of the function.
Definition: shell.h:61
static void shell_run(const shell_command_t *commands, char *line_buf, int len)
Back-porting alias for shell_run_forever.
Definition: shell.h:97
A single command in the list of the supported commands.
Definition: shell.h:60
static void shell_run_forever(const shell_command_t *commands, char *line_buf, int len)
Start a shell and restart it if it exits.
Definition: shell.h:82
const char * desc
Description to print in the "help" command.
Definition: shell.h:62
Common macros and compiler attributes/pragmas configuration.
shell_command_handler_t handler
The callback function.
Definition: shell.h:63
struct shell_command_t shell_command_t
A single command in the list of the supported commands.