GadgetSeed  0.9.6
shell.h
[詳解]
1 /** @file
2  @brief コマンドシェル
3 
4  @date 2007.03.16
5  @date 2002.03.24
6  @author Takashi SHUDO
7 */
8 
9 #ifndef SHELL_H
10 #define SHELL_H
11 
12 #include "sysconfig.h"
13 #include "str.h"
14 #include "lineedit.h"
15 #include "history.h"
16 #include "console.h"
17 
18 #ifndef GSC_SHELL_MAX_COM_ARGV
19 #define GSC_SHELL_MAX_COM_ARGV 10 // $gsc shellコマンド最大引数の数
20 #endif
21 
23  uchar ext[4]; ///< 拡張子文字列
24  int (* operation)(uchar *fname, uchar *arg); /// ファイル実行関数
25 }; ///< ファイル種別に対するコマンド実行定義
26 
27 // comList.attr 実行後のリターンのみ入力時の動作
28 #define CMDATTR_CONT 0x0001 // 同じコマンドを実行
29 #define CMDATTR_ARGLESS 0x0002 // 引数は省略
30 
31 #define CMDATTR_CTAL (CMDATTR_CONT|CMDATTR_ARGLESS)
32 
34  uchar name[12]; ///< コマンド名文字列
35  void (*init)(void); ///< コマンド初期化関数
36  int (*command)(int argc, uchar *argv[]); ///< コマンド実行関数
37  unsigned short attr; ///< コマンド属性
38  char *usage_str; ///< 使用法文字列
39  char *manual_str; ///< マニュアル文字列
40  const struct st_shell_command * const * sublist; ///< サブコマンド配列
41 }; ///< シェルコマンド構造体
42 
43 struct st_shell {
44  struct st_lineedit comLine; ///< コマンドライン
45  uchar lastCom[GSC_SHELL_MAX_LINE_COLUMS+1]; ///< 最後に実行したコマンド
46  struct st_history his; ///< コマンドヒストリ
47  const uchar *prompt; ///< コマンドプロンプト文字列
48  int argc; ///< コマンド引数数
49  uchar *argv[GSC_SHELL_MAX_COM_ARGV]; ///< コマンド引数文字列
50  struct st_shell_command * const * shell_coms; ///< 各シェルコマンド配列
51 }; ///< シェルデータ構造体
52 
53 extern void init_shell(struct st_shell *shell, struct st_shell_command * const *coms, const uchar *prompt);
54 extern void print_prompt(struct st_shell *shell);
55 extern void dispose_shell_line(struct st_shell *shell);
56 extern int exec_shell_command(struct st_shell *shell, uchar *str);
57 extern void print_command_usage(const struct st_shell_command *command);
58 extern int task_shell(struct st_shell *shell, uchar ch);
59 extern void startup_shell(void);
60 extern int add_shell_command(struct st_shell_command *command);
61 
62 #ifdef GSC_COMP_ENABLE_SHELL
63 extern int exec_command(uchar *str);
64 extern int escaped_str(uchar *dstr, uchar *sstr);
65 extern void set_file_operation(const struct st_file_operation * const fileop[]);
66 extern int do_file_operation(uchar *str, uchar *arg);
67 #endif
68 
69 #endif // SHELL_H
unsigned char uchar
GadgetSeedの文字(列)は unsigned char 型となる
Definition: str.h:13
シェルコマンド構造体
Definition: shell.h:33
int argc
コマンド引数数
Definition: shell.h:48
struct st_shell_command *const * shell_coms
各シェルコマンド配列
Definition: shell.h:50
ラインエディタ
Definition: lineedit.h:30
シェルデータ構造体
Definition: shell.h:43
ラインエディタ
const uchar * prompt
コマンドプロンプト文字列
Definition: shell.h:47
文字列処理
コマンドヒストリ
Definition: history.h:18
int(* command)(int argc, uchar *argv[])
コマンド実行関数
Definition: shell.h:36
void init_shell(struct st_shell *shell, struct st_shell_command *const *coms, const uchar *prompt)
シェルを初期化する
Definition: shell.c:39
void dispose_shell_line(struct st_shell *shell)
編集中のコマンドラインを破棄する
Definition: shell.c:67
int escaped_str(uchar *dstr, uchar *sstr)
文字列をshellで処理可能なようにエスケープシーケンスを追加する
Definition: shell.c:506
ファイル種別に対するコマンド実行定義
Definition: shell.h:22
int exec_shell_command(struct st_shell *shell, uchar *str)
str文字列のコマンドを実行する
Definition: shell.c:218
unsigned short attr
コマンド属性
Definition: shell.h:37
コマンドヒストリ
uchar ext[4]
拡張子文字列
Definition: shell.h:23
int task_shell(struct st_shell *shell, uchar ch)
文字列編集タスク
Definition: shell.c:457
const struct st_shell_command *const * sublist
サブコマンド配列
Definition: shell.h:40
コンソールI/O
void print_prompt(struct st_shell *shell)
プロンプトを表示する
Definition: shell.c:57
char * usage_str
使用法文字列
Definition: shell.h:38
#define GSC_SHELL_MAX_LINE_COLUMS
$gsc shellコマンドラインの最大文字数
Definition: lineedit.h:16
char * manual_str
マニュアル文字列
Definition: shell.h:39