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 #ifndef HISYSEVENT_INTERFACES_NATIVE_INNERKITS_HISYSEVENT_INCLUDE_HISYSEVENT_C_H 16 #define HISYSEVENT_INTERFACES_NATIVE_INNERKITS_HISYSEVENT_INCLUDE_HISYSEVENT_C_H 17 18 #include <stdbool.h> 19 #include <stddef.h> 20 #include <stdint.h> 21 22 #ifdef __cplusplus 23 extern "C" { 24 #endif 25 26 #define MAX_LENGTH_OF_PARAM_NAME 49 27 28 /** 29 * @brief Define the type of the param. 30 */ 31 enum HiSysEventParamType { 32 HISYSEVENT_INVALID = 0, 33 HISYSEVENT_BOOL = 1, 34 HISYSEVENT_INT8 = 2, 35 HISYSEVENT_UINT8 = 3, 36 HISYSEVENT_INT16 = 4, 37 HISYSEVENT_UINT16 = 5, 38 HISYSEVENT_INT32 = 6, 39 HISYSEVENT_UINT32 = 7, 40 HISYSEVENT_INT64 = 8, 41 HISYSEVENT_UINT64 = 9, 42 HISYSEVENT_FLOAT = 10, 43 HISYSEVENT_DOUBLE = 11, 44 HISYSEVENT_STRING = 12, 45 HISYSEVENT_BOOL_ARRAY = 13, 46 HISYSEVENT_INT8_ARRAY = 14, 47 HISYSEVENT_UINT8_ARRAY = 15, 48 HISYSEVENT_INT16_ARRAY = 16, 49 HISYSEVENT_UINT16_ARRAY = 17, 50 HISYSEVENT_INT32_ARRAY = 18, 51 HISYSEVENT_UINT32_ARRAY = 19, 52 HISYSEVENT_INT64_ARRAY = 20, 53 HISYSEVENT_UINT64_ARRAY = 21, 54 HISYSEVENT_FLOAT_ARRAY = 22, 55 HISYSEVENT_DOUBLE_ARRAY = 23, 56 HISYSEVENT_STRING_ARRAY = 24 57 }; 58 typedef enum HiSysEventParamType HiSysEventParamType; 59 60 /** 61 * @brief Define the value of the param. 62 */ 63 union HiSysEventParamValue { 64 bool b; 65 int8_t i8; 66 uint8_t ui8; 67 int16_t i16; 68 uint16_t ui16; 69 int32_t i32; 70 uint32_t ui32; 71 int64_t i64; 72 uint64_t ui64; 73 float f; 74 double d; 75 char *s; 76 void *array; 77 }; 78 typedef union HiSysEventParamValue HiSysEventParamValue; 79 80 /** 81 * @brief Define param struct. 82 */ 83 struct HiSysEventParam { 84 char name[MAX_LENGTH_OF_PARAM_NAME]; 85 HiSysEventParamType t; 86 HiSysEventParamValue v; 87 size_t arraySize; 88 }; 89 typedef struct HiSysEventParam HiSysEventParam; 90 91 /** 92 * @brief Event type. 93 */ 94 enum HiSysEventEventType { 95 HISYSEVENT_FAULT = 1, 96 HISYSEVENT_STATISTIC = 2, 97 HISYSEVENT_SECURITY = 3, 98 HISYSEVENT_BEHAVIOR = 4 99 }; 100 typedef enum HiSysEventEventType HiSysEventEventType; 101 102 /** 103 * @brief Write system event. 104 * @param domain event domain. 105 * @param name event name. 106 * @param type event type. 107 * @param params event params. 108 * @param size the size of param list. 109 * @return 0 means success, less than 0 means failure, greater than 0 means invalid params. 110 */ 111 #define OH_HiSysEvent_Write(domain, name, type, params, size) \ 112 HiSysEvent_Write(__FUNCTION__, __LINE__, domain, name, type, params, size) 113 114 int HiSysEvent_Write(const char* func, int64_t line, const char* domain, const char* name, 115 HiSysEventEventType type, const HiSysEventParam params[], size_t size); 116 117 #ifdef __cplusplus 118 } 119 #endif 120 #endif // HISYSEVENT_INTERFACES_NATIVE_INNERKITS_HISYSEVENT_INCLUDE_HISYSEVENT_C_H