• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef BSHELL_UTILS_
17 #define BSHELL_UTILS_
18 #include <memory.h>
19 #include <stdint.h>
20 #include <stdio.h>
21 
22 #include "init_log.h"
23 #include "securec.h"
24 
25 #define BSH_LABEL "SHELL"
26 #ifndef BSH_DOMAIN
27 #define BSH_DOMAIN (BASE_DOMAIN + 5)
28 #endif
29 
30 #define BSH_LOGI(fmt, ...) STARTUP_LOGI(BSH_DOMAIN, BSH_LABEL, fmt, ##__VA_ARGS__)
31 #define BSH_LOGE(fmt, ...) STARTUP_LOGE(BSH_DOMAIN, BSH_LABEL, fmt, ##__VA_ARGS__)
32 #define BSH_LOGV(fmt, ...) STARTUP_LOGV(BSH_DOMAIN, BSH_LABEL, fmt, ##__VA_ARGS__)
33 
34 #define BSH_CHECK(ret, exper, ...) \
35     if (!(ret)) { \
36         BSH_LOGE(__VA_ARGS__); \
37         exper; \
38     }
39 #define BSH_ONLY_CHECK(ret, exper, ...) \
40     if (!(ret)) { \
41         exper; \
42     }
43 #endif