Natural Tiny Shell (NT-Shell) library is a tiny shell library for a small embedded system. The interface is really simple. You should only know ntshell_execute in ntshell.h. So you can port it to any embedded system easily. Please enjoy your small embedded system with it. :)

Dependents:   NaturalTinyShell_TestProgram

Embed: (wiki syntax)

« Back to documentation index

ntshell.c File Reference

ntshell.c File Reference

小規模組み込みシステム向けのシェルシステムの実装。 More...

Go to the source code of this file.

Functions

static void actfunc_history_prev (vtparse_t *parser, vtparse_action_t action, unsigned char ch)
 テキストヒストリで1つ後ろを辿る。
static void actfunc_history_next (vtparse_t *parser, vtparse_action_t action, unsigned char ch)
 テキストヒストリで1つ前を辿る。
static void actfunc_cursor_left (vtparse_t *parser, vtparse_action_t action, unsigned char ch)
 カーソルを左へ移動させる。
static void actfunc_cursor_right (vtparse_t *parser, vtparse_action_t action, unsigned char ch)
 カーソルを右へ移動させる。
static void actfunc_enter (vtparse_t *parser, vtparse_action_t action, unsigned char ch)
 エンターキーの処理を実行する。
static void actfunc_cancel (vtparse_t *parser, vtparse_action_t action, unsigned char ch)
 キャンセルキーの処理を実行する。
static void actfunc_insert (vtparse_t *parser, vtparse_action_t action, unsigned char ch)
 挿入処理を実行する。
static void actfunc_backspace (vtparse_t *parser, vtparse_action_t action, unsigned char ch)
 バックスペース処理を実行する。
static void actfunc_suggest (vtparse_t *parser, vtparse_action_t action, unsigned char ch)
 入力補完処理を実行する。
void parser_callback (vtparse_t *parser, vtparse_action_t action, unsigned char ch)
 パーサーに対するコールバック関数。
void ntshell_version (int *major, int *minor, int *release)
 Natural Tiny Shellのバージョンを返す。
void ntshell_execute (ntshell_t *p, int(*func_read)(char *buf, int cnt), int(*func_write)(const char *buf, int cnt), int(*func_cb)(const char *text))
 Natural Tiny Shellを実行する。

Variables

static const ntshell_action_table_t action_table []
 アクションに対する処理関数テーブル。

Detailed Description

小規模組み込みシステム向けのシェルシステムの実装。

Author:
Shinichiro Nakamura

Definition in file ntshell.c.


Function Documentation

static void actfunc_backspace ( vtparse_t *  parser,
vtparse_action_t  action,
unsigned char  ch 
) [static]

バックスペース処理を実行する。

Parameters:
parserパーサー。
actionアクション。
ch入力文字。

Definition at line 275 of file ntshell.c.

static void actfunc_cancel ( vtparse_t *  parser,
vtparse_action_t  action,
unsigned char  ch 
) [static]

キャンセルキーの処理を実行する。

一般的なOSのCTRL+C処理はシグナルを発行し、受信したプロセスが 中断処理を実行する。 ここでのキャンセルは見た目を再現したもので、 入力中の文字列を破棄してカーソルを新しい入力に備えて復帰させるものだ。

Parameters:
parserパーサー。
actionアクション。
ch入力文字。

Definition at line 223 of file ntshell.c.

static void actfunc_cursor_left ( vtparse_t *  parser,
vtparse_action_t  action,
unsigned char  ch 
) [static]

カーソルを左へ移動させる。

Parameters:
parserパーサー。
actionアクション。
ch入力文字。

Definition at line 166 of file ntshell.c.

static void actfunc_cursor_right ( vtparse_t *  parser,
vtparse_action_t  action,
unsigned char  ch 
) [static]

カーソルを右へ移動させる。

Parameters:
parserパーサー。
actionアクション。
ch入力文字。

Definition at line 182 of file ntshell.c.

static void actfunc_enter ( vtparse_t *  parser,
vtparse_action_t  action,
unsigned char  ch 
) [static]

エンターキーの処理を実行する。

Parameters:
parserパーサー。
actionアクション。
ch入力文字。

Definition at line 198 of file ntshell.c.

static void actfunc_history_next ( vtparse_t *  parser,
vtparse_action_t  action,
unsigned char  ch 
) [static]

テキストヒストリで1つ前を辿る。

Parameters:
parserパーサー。
actionアクション。
ch入力文字。

Definition at line 142 of file ntshell.c.

static void actfunc_history_prev ( vtparse_t *  parser,
vtparse_action_t  action,
unsigned char  ch 
) [static]

テキストヒストリで1つ後ろを辿る。

Parameters:
parserパーサー。
actionアクション。
ch入力文字。

Definition at line 118 of file ntshell.c.

static void actfunc_insert ( vtparse_t *  parser,
vtparse_action_t  action,
unsigned char  ch 
) [static]

挿入処理を実行する。

Parameters:
parserパーサー。
actionアクション。
ch入力文字。

Definition at line 239 of file ntshell.c.

static void actfunc_suggest ( vtparse_t *  parser,
vtparse_action_t  action,
unsigned char  ch 
) [static]

入力補完処理を実行する。

Parameters:
parserパーサー。
actionアクション。
ch入力文字。

Definition at line 306 of file ntshell.c.

void ntshell_execute ( ntshell_t *  p,
int(*)(char *buf, int cnt)  func_read,
int(*)(const char *buf, int cnt)  func_write,
int(*)(const char *text)  func_cb 
)

Natural Tiny Shellを実行する。

この関数は実行を返さない。

Parameters:
parserVT100パーサー。
editorテキストエディタ。
historyテキストヒストリ。
func_readシリアルリード関数。
func_writeシリアルライト関数。
func_cbコールバック関数。

Definition at line 510 of file ntshell.c.

void ntshell_version ( int *  major,
int *  minor,
int *  release 
)

Natural Tiny Shellのバージョンを返す。

返すバージョンはリリースバージョンである。

Parameters:
majorメージャーバージョン。
minorマイナーバージョン。
releaseリリースバージョン。

Definition at line 492 of file ntshell.c.

void parser_callback ( vtparse_t *  parser,
vtparse_action_t  action,
unsigned char  ch 
)

パーサーに対するコールバック関数。

vtparseモジュールのコールバック関数に従った実装である。

Parameters:
parserパーサー。
actionアクション。
chキャラクタ。

Definition at line 456 of file ntshell.c.


Variable Documentation

const ntshell_action_table_t action_table[] [static]
Initial value:
 {
    {VTPARSE_ACTION_EXECUTE, 0x01, actfunc_cursor_head},
    {VTPARSE_ACTION_EXECUTE, 0x02, actfunc_cursor_left},
    {VTPARSE_ACTION_EXECUTE, 0x03, actfunc_cancel},
    {VTPARSE_ACTION_EXECUTE, 0x05, actfunc_cursor_tail},
    {VTPARSE_ACTION_EXECUTE, 0x06, actfunc_cursor_right},
    {VTPARSE_ACTION_EXECUTE, 0x08, actfunc_backspace},
    {VTPARSE_ACTION_EXECUTE, 0x09, actfunc_suggest},
    {VTPARSE_ACTION_EXECUTE, 0x0d, actfunc_enter},
    {VTPARSE_ACTION_EXECUTE, 0x0e, actfunc_history_next},
    {VTPARSE_ACTION_EXECUTE, 0x10, actfunc_history_prev},
    {VTPARSE_ACTION_CSI_DISPATCH, 0x41, actfunc_history_prev},
    {VTPARSE_ACTION_CSI_DISPATCH, 0x42, actfunc_history_next},
    {VTPARSE_ACTION_CSI_DISPATCH, 0x43, actfunc_cursor_right},
    {VTPARSE_ACTION_CSI_DISPATCH, 0x44, actfunc_cursor_left},
    {VTPARSE_ACTION_PRINT, 0x7f, actfunc_backspace},
}

アクションに対する処理関数テーブル。

やってくるコードは仮想端末側の処理に依存する。 よって様々なプラットフォームの様々な仮想端末で試すと良い。

Platform

Tools

Windows

Hyper Terminal, Poderossa, TeraTerm

Linux

minicom, screen, kermit

Definition at line 430 of file ntshell.c.