Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Startup Init Lite
提交
8fc7ef33
S
Startup Init Lite
项目概览
OpenHarmony
/
Startup Init Lite
大约 1 年 前同步成功
通知
3
Star
37
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
Startup Init Lite
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
8fc7ef33
编写于
6月 02, 2022
作者:
M
Mupceet
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
shell 优化
Signed-off-by:
N
Mupceet
<
laiguizhong@huawei.com
>
上级
645ad4cf
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
8 addition
and
29 deletion
+8
-29
services/begetctl/main.c
services/begetctl/main.c
+1
-10
services/begetctl/shell/shell.h
services/begetctl/shell/shell.h
+1
-2
services/begetctl/shell/shell_bas.c
services/begetctl/shell/shell_bas.c
+5
-6
services/begetctl/shell/shell_bas.h
services/begetctl/shell/shell_bas.h
+0
-1
services/begetctl/shell/shell_main.c
services/begetctl/shell/shell_main.c
+1
-10
未找到文件。
services/begetctl/main.c
浏览文件 @
8fc7ef33
...
...
@@ -22,19 +22,10 @@
#include "init_param.h"
static
BShellHandle
g_handle
=
NULL
;
static
int32_t
ShellOuput
(
const
char
*
data
,
int32_t
len
)
{
for
(
int32_t
i
=
0
;
i
<
len
;
i
++
)
{
putchar
(
*
(
data
+
i
));
}
(
void
)
fflush
(
stdout
);
return
len
;
}
BShellHandle
GetShellHandle
(
void
)
{
if
(
g_handle
==
NULL
)
{
BShellInfo
info
=
{
PARAM_SHELL_DEFAULT_PROMPT
,
NULL
,
ShellOuput
};
BShellInfo
info
=
{
PARAM_SHELL_DEFAULT_PROMPT
,
NULL
};
BShellEnvInit
(
&
g_handle
,
&
info
);
}
return
g_handle
;
...
...
services/begetctl/shell/shell.h
浏览文件 @
8fc7ef33
...
...
@@ -87,10 +87,9 @@ typedef struct BShellParam_ {
typedef
struct
BShellInfo_
{
char
*
prompt
;
BShellInput_
input
;
BShellOutput_
output
;
}
BShellInfo
;
int
BShellEnvInit
(
BShellHandle
*
handle
,
BShellInfo
*
info
);
int
BShellEnvInit
(
BShellHandle
*
handle
,
const
BShellInfo
*
info
);
int
BShellEnvStart
(
BShellHandle
handle
);
void
BShellEnvDestory
(
BShellHandle
handle
);
...
...
services/begetctl/shell/shell_bas.c
浏览文件 @
8fc7ef33
...
...
@@ -95,12 +95,12 @@ static int32_t BShellCmdExit(BShellHandle handle, int32_t argc, char *argv[])
int32_t
BShellEnvOutput
(
BShellHandle
handle
,
char
*
fmt
,
...)
{
BSH_CHECK
(
handle
!=
NULL
,
return
BSH_INVALID_PARAM
,
"Invalid shell env"
);
va_list
list
;
va_list
list
;
va_start
(
list
,
fmt
);
vfprintf
(
stdout
,
fmt
,
list
);
int
len
=
vfprintf
(
stdout
,
fmt
,
list
);
va_end
(
list
);
(
void
)
fflush
(
stdout
);
return
0
;
return
len
;
}
int32_t
BShellEnvOutputString
(
BShellHandle
handle
,
const
char
*
string
)
...
...
@@ -108,7 +108,7 @@ int32_t BShellEnvOutputString(BShellHandle handle, const char *string)
BSH_CHECK
(
handle
!=
NULL
,
return
BSH_INVALID_PARAM
,
"Invalid shell env"
);
printf
(
"%s"
,
string
);
(
void
)
fflush
(
stdout
);
return
0
;
return
strlen
(
string
)
;
}
int32_t
BShellEnvOutputPrompt
(
BShellHandle
handle
,
const
char
*
prompt
)
...
...
@@ -402,7 +402,7 @@ void BShellEnvLoop(BShellHandle handle)
}
}
int32_t
BShellEnvInit
(
BShellHandle
*
handle
,
BShellInfo
*
info
)
int32_t
BShellEnvInit
(
BShellHandle
*
handle
,
const
BShellInfo
*
info
)
{
BSH_CHECK
(
handle
!=
NULL
,
return
BSH_INVALID_PARAM
,
"Invalid shell env"
);
BSH_CHECK
(
info
!=
NULL
&&
info
->
prompt
!=
NULL
,
return
BSH_INVALID_PARAM
,
"Invalid cmd name"
);
...
...
@@ -413,7 +413,6 @@ int32_t BShellEnvInit(BShellHandle *handle, BShellInfo *info)
shell
->
cursor
=
0
;
shell
->
shellState
=
BSH_IN_NORMAL
;
shell
->
input
=
info
->
input
;
shell
->
output
=
info
->
output
;
shell
->
prompt
=
strdup
(
info
->
prompt
);
shell
->
command
=
NULL
;
shell
->
param
=
NULL
;
...
...
services/begetctl/shell/shell_bas.h
浏览文件 @
8fc7ef33
...
...
@@ -91,7 +91,6 @@ typedef struct BShellEnv_ {
BShellKey
*
keyHandle
;
BShellStatus
status
;
BShellInput_
input
;
BShellOutput_
output
;
char
data
[
BSH_COMMAND_MAX_LENGTH
];
}
BShellEnv
;
...
...
services/begetctl/shell/shell_main.c
浏览文件 @
8fc7ef33
...
...
@@ -30,15 +30,6 @@ static void signalHandler(int signal)
exit
(
0
);
}
static
int32_t
ShellOuput
(
const
char
*
data
,
int32_t
len
)
{
for
(
int32_t
i
=
0
;
i
<
len
;
i
++
)
{
putchar
(
*
(
data
+
i
));
}
(
void
)
fflush
(
stdout
);
return
len
;
}
static
int32_t
ShellInput
(
char
*
data
,
int32_t
len
)
{
for
(
int32_t
i
=
0
;
i
<
len
;
i
++
)
{
...
...
@@ -50,7 +41,7 @@ static int32_t ShellInput(char *data, int32_t len)
BShellHandle
GetShellHandle
(
void
)
{
if
(
g_handle
==
NULL
)
{
BShellInfo
info
=
{
PARAM_SHELL_DEFAULT_PROMPT
,
ShellInput
,
ShellOuput
};
BShellInfo
info
=
{
PARAM_SHELL_DEFAULT_PROMPT
,
ShellInput
};
BShellEnvInit
(
&
g_handle
,
&
info
);
}
return
g_handle
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录