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 SOFTBUS_HIDUMPER_H 17 #define SOFTBUS_HIDUMPER_H 18 19 #include <stdint.h> 20 #include "common_list.h" 21 22 #ifdef __cplusplus 23 #if __cplusplus 24 extern "C" { 25 #endif 26 #endif 27 28 #define SOFTBUS_MODULE_NAME_LEN 32 29 #define SOFTBUS_MODULE_HELP_LEN 128 30 #define SOFTBUS_DUMP_VAR_NAME_LEN 32 31 #define SOFTBUS_DUMP_EXIST 1 32 #define SOFTBUS_DUMP_NOT_EXIST 0 33 34 typedef int32_t (*SoftBusVarDumpCb)(int fd); 35 36 typedef struct { 37 ListNode node; 38 char varName[SOFTBUS_MODULE_NAME_LEN]; 39 SoftBusVarDumpCb dumpCallback; 40 } SoftBusDumpVarNode; 41 42 typedef int32_t (*DumpHandlerFunc)(int fd, int32_t argc, const char **argv); 43 44 typedef struct { 45 ListNode node; 46 char moduleName[SOFTBUS_MODULE_NAME_LEN]; 47 char helpInfo[SOFTBUS_MODULE_HELP_LEN]; 48 DumpHandlerFunc dumpHandler; 49 } HandlerNode; 50 51 void SoftBusDumpShowHelp(int fd); 52 void SoftBusDumpErrInfo(int fd, const char *argv); 53 void SoftBusDumpSubModuleHelp(int fd, char *moduleName, ListNode *varList); 54 int32_t SoftBusAddDumpVarToList(const char *dumpVar, SoftBusVarDumpCb cb, ListNode *subModoleVarList); 55 void SoftBusReleaseDumpVar(ListNode *varList); 56 int32_t SoftBusRegHiDumperHandler(char *moduleName, char *helpInfo, DumpHandlerFunc handler); 57 int32_t SoftBusDumpDispatch(int fd, int32_t argc, const char **argv); 58 int32_t SoftBusHiDumperModuleInit(void); 59 void SoftBusHiDumperModuleDeInit(void); 60 61 #ifdef __cplusplus 62 #if __cplusplus 63 } 64 #endif /* __cplusplus */ 65 #endif /* __cplusplus */ 66 #endif /* SOFTBUS_HIDUMPER_H */ 67