1 /* 2 * Copyright (c) 2023-2023 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 CONTEXT_TOOL_H 17 #define CONTEXT_TOOL_H 18 19 #include <stdint.h> 20 #include <stdio.h> 21 22 #include "cJSON.h" 23 24 #define PRINT_ERR(...) \ 25 do { \ 26 printf("ERROR: [%s: %d] -> ", __FILE__, __LINE__); \ 27 printf(__VA_ARGS__); \ 28 } while (0) 29 30 #ifdef __cplusplus 31 #if __cplusplus 32 extern "C" { 33 #endif /* __cplusplus */ 34 #endif /* __cplusplus */ 35 36 typedef struct RequiredProductCompatibilityIDHead { 37 uint16_t apiVersion : 15; 38 uint16_t apiVersionType : 1; 39 } RPCIDHead; 40 41 void FreeContextBuffer(char *contextBuffer); 42 int32_t GetFileContext(const char *inputFile, char **contextBufPtr, uint32_t *bufferLen); 43 int32_t CheckFileAndGetFileContext(const char *inputFile, char **contextBufPtr, uint32_t *bufferLen); 44 int32_t ConvertedContextSaveAsFile(char *outDirPath, const char *filename, char *convertedBuffer, size_t contextBufLen); 45 int32_t CheckRpcidFormat(const char *inputFile, char **buffer, uint32_t *len); 46 cJSON *CreateWholeSyscapJsonObj(void); 47 48 #ifdef __cplusplus 49 #if __cplusplus 50 } 51 #endif /* __cplusplus */ 52 #endif /* __cplusplus */ 53 54 #endif /* SYSCAP_TOOL_H */