1 /* 2 * Copyright (c) 2020-2021 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 #ifndef STARTUP_INIT_CMD_EXECUTOR_H 16 #define STARTUP_INIT_CMD_EXECUTOR_H 17 #include <stdlib.h> 18 #include <string.h> 19 20 #include "list.h" 21 22 #ifdef __cplusplus 23 #if __cplusplus 24 extern "C" { 25 #endif 26 #endif 27 28 typedef struct { 29 ListNode cmdExecutor; 30 int cmdId; 31 unsigned char careContext; 32 char *name; 33 } PluginCmd; 34 35 typedef int (*CmdExecutor)(int id, const char *name, int argc, const char **argv); 36 typedef struct { 37 ListNode node; 38 int id; 39 CmdExecutor execCmd; 40 } PluginCmdExecutor; 41 42 void PluginExecCmdByName(const char *name, const char *cmdContent); 43 // only exec in current context 44 int PluginExecCmd(const char *name, int argc, const char **argv); 45 46 int AddCmdExecutor(const char *cmdName, CmdExecutor execCmd); 47 48 int AddRebootCmdExecutor(const char *cmd, CmdExecutor executor); 49 50 #ifdef __cplusplus 51 #if __cplusplus 52 } 53 #endif 54 #endif 55 #endif 56