1 | /** |
---|
2 | * @file rtems/shell.h |
---|
3 | * |
---|
4 | * Instantatiate a new terminal shell. |
---|
5 | */ |
---|
6 | |
---|
7 | /* |
---|
8 | * Author: |
---|
9 | * |
---|
10 | * WORK: fernando.ruiz@ctv.es |
---|
11 | * HOME: correo@fernando-ruiz.com |
---|
12 | * |
---|
13 | * Thanks at: |
---|
14 | * Chris John |
---|
15 | * |
---|
16 | * $Id$ |
---|
17 | */ |
---|
18 | |
---|
19 | #ifndef __SHELL_H__ |
---|
20 | #define __SHELL_H__ |
---|
21 | |
---|
22 | #include <rtems.h> |
---|
23 | #include <stdio.h> |
---|
24 | #include <termios.h> |
---|
25 | |
---|
26 | #ifdef __cplusplus |
---|
27 | extern "C" { |
---|
28 | #endif |
---|
29 | |
---|
30 | typedef int (*shell_command_t)(int argc,char * argv[]); |
---|
31 | |
---|
32 | struct shell_cmd_tt ; |
---|
33 | typedef struct shell_cmd_tt shell_cmd_t; |
---|
34 | |
---|
35 | struct shell_cmd_tt { |
---|
36 | char * name; |
---|
37 | char * usage; |
---|
38 | char * topic; |
---|
39 | shell_command_t command; |
---|
40 | shell_cmd_t * alias; |
---|
41 | shell_cmd_t * next; |
---|
42 | }; |
---|
43 | |
---|
44 | uint32_t new_rtems_name(char * rtems_name); |
---|
45 | shell_cmd_t * shell_lookup_cmd(char * cmd); |
---|
46 | shell_cmd_t * shell_add_cmd(char * cmd, |
---|
47 | char * topic, |
---|
48 | char * usage, |
---|
49 | shell_command_t command); |
---|
50 | shell_cmd_t * shell_alias_cmd(char * cmd, char * alias); |
---|
51 | |
---|
52 | int shell_make_args(char * cmd, |
---|
53 | int * pargc, |
---|
54 | char * argv[]); |
---|
55 | |
---|
56 | typedef struct { |
---|
57 | rtems_name magic; /* 'S','E','N','V': Shell Environment */ |
---|
58 | char * devname; |
---|
59 | char * taskname; |
---|
60 | tcflag_t tcflag; |
---|
61 | /* user extensions */ |
---|
62 | int exit_shell; /* logout */ |
---|
63 | int forever ; /* repeat login */ |
---|
64 | int errorlevel; |
---|
65 | int mdump_adr; |
---|
66 | } shell_env_t; |
---|
67 | |
---|
68 | int shell_scanline(char * line,int size,FILE * in,FILE * out) ; |
---|
69 | void cat_file(FILE * out,char *name); |
---|
70 | void write_file(char *name,char * content); |
---|
71 | |
---|
72 | rtems_status_code shell_init(char * task_name , |
---|
73 | uint32_t task_stacksize,/*0 default*/ |
---|
74 | rtems_task_priority task_priority , |
---|
75 | char * devname , |
---|
76 | tcflag_t tcflag , |
---|
77 | int forever ); |
---|
78 | |
---|
79 | extern shell_env_t global_shell_env, |
---|
80 | * current_shell_env; |
---|
81 | /*--------*/ |
---|
82 | /* cmds.c */ |
---|
83 | /*--------*/ |
---|
84 | int str2int(char * s); |
---|
85 | void register_cmds(void); |
---|
86 | |
---|
87 | #ifdef __cplusplus |
---|
88 | } |
---|
89 | #endif |
---|
90 | |
---|
91 | #endif |
---|