1bae44755Sopenharmony_ci/* 2bae44755Sopenharmony_ci * Copyright (c) 2023-2023 Huawei Device Co., Ltd. 3bae44755Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 4bae44755Sopenharmony_ci * you may not use this file except in compliance with the License. 5bae44755Sopenharmony_ci * You may obtain a copy of the License at 6bae44755Sopenharmony_ci * 7bae44755Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 8bae44755Sopenharmony_ci * 9bae44755Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 10bae44755Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 11bae44755Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12bae44755Sopenharmony_ci * See the License for the specific language governing permissions and 13bae44755Sopenharmony_ci * limitations under the License. 14bae44755Sopenharmony_ci */ 15bae44755Sopenharmony_ci 16bae44755Sopenharmony_ci#ifndef CONTEXT_TOOL_H 17bae44755Sopenharmony_ci#define CONTEXT_TOOL_H 18bae44755Sopenharmony_ci 19bae44755Sopenharmony_ci#include <stdint.h> 20bae44755Sopenharmony_ci#include <stdio.h> 21bae44755Sopenharmony_ci 22bae44755Sopenharmony_ci#include "cJSON.h" 23bae44755Sopenharmony_ci 24bae44755Sopenharmony_ci#define PRINT_ERR(...) \ 25bae44755Sopenharmony_ci do { \ 26bae44755Sopenharmony_ci printf("ERROR: [%s: %d] -> ", __FILE__, __LINE__); \ 27bae44755Sopenharmony_ci printf(__VA_ARGS__); \ 28bae44755Sopenharmony_ci } while (0) 29bae44755Sopenharmony_ci 30bae44755Sopenharmony_ci#ifdef __cplusplus 31bae44755Sopenharmony_ci#if __cplusplus 32bae44755Sopenharmony_ciextern "C" { 33bae44755Sopenharmony_ci#endif /* __cplusplus */ 34bae44755Sopenharmony_ci#endif /* __cplusplus */ 35bae44755Sopenharmony_ci 36bae44755Sopenharmony_citypedef struct RequiredProductCompatibilityIDHead { 37bae44755Sopenharmony_ci uint16_t apiVersion : 15; 38bae44755Sopenharmony_ci uint16_t apiVersionType : 1; 39bae44755Sopenharmony_ci} RPCIDHead; 40bae44755Sopenharmony_ci 41bae44755Sopenharmony_civoid FreeContextBuffer(char *contextBuffer); 42bae44755Sopenharmony_ciint32_t GetFileContext(const char *inputFile, char **contextBufPtr, uint32_t *bufferLen); 43bae44755Sopenharmony_ciint32_t CheckFileAndGetFileContext(const char *inputFile, char **contextBufPtr, uint32_t *bufferLen); 44bae44755Sopenharmony_ciint32_t ConvertedContextSaveAsFile(char *outDirPath, const char *filename, char *convertedBuffer, size_t contextBufLen); 45bae44755Sopenharmony_ciint32_t CheckRpcidFormat(const char *inputFile, char **buffer, uint32_t *len); 46bae44755Sopenharmony_cicJSON *CreateWholeSyscapJsonObj(void); 47bae44755Sopenharmony_ci 48bae44755Sopenharmony_ci#ifdef __cplusplus 49bae44755Sopenharmony_ci#if __cplusplus 50bae44755Sopenharmony_ci} 51bae44755Sopenharmony_ci#endif /* __cplusplus */ 52bae44755Sopenharmony_ci#endif /* __cplusplus */ 53bae44755Sopenharmony_ci 54bae44755Sopenharmony_ci#endif /* SYSCAP_TOOL_H */