mirror of
https://github.com/openharmony/developtools_syscap_codec.git
synced 2026-08-26 17:56:33 -04:00
@@ -40,6 +40,7 @@ typedef struct RequiredProductCompatibilityIDHead {
|
||||
|
||||
void FreeContextBuffer(char *contextBuffer);
|
||||
int32_t GetFileContext(const char *inputFile, char **contextBufPtr, uint32_t *bufferLen);
|
||||
int32_t CheckFileAndGetFileContext(const char *inputFile, char **contextBufPtr, uint32_t *bufferLen);
|
||||
int32_t ConvertedContextSaveAsFile(char *outDirPath, const char *filename, char *convertedBuffer, size_t contextBufLen);
|
||||
int32_t CheckRpcidFormat(const char *inputFile, char **buffer, uint32_t *len);
|
||||
cJSON *CreateWholeSyscapJsonObj(void);
|
||||
|
||||
@@ -92,6 +92,19 @@ int32_t GetFileContext(const char *inputFile, char **contextBufPtr, uint32_t *bu
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t CheckFileAndGetFileContext(const char *inputFile, char **contextBufPtr, uint32_t *bufferLen)
|
||||
{
|
||||
if (inputFile == NULL) {
|
||||
PRINT_ERR("input file is NULL.\n");
|
||||
return -1;
|
||||
}
|
||||
uint32_t ret = GetFileContext(inputFile, contextBufPtr, bufferLen);
|
||||
if (ret != 0) {
|
||||
PRINT_ERR("GetFileContext failed, input file : %s\n", inputFile);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int32_t ConvertedContextSaveAsFile(char *outDirPath, const char *filename, char *convertedBuffer, size_t contextBufLen)
|
||||
{
|
||||
int32_t ret;
|
||||
|
||||
+3
-21
@@ -250,15 +250,9 @@ int32_t CreatePCID(char *inputFile, char *outDirPath)
|
||||
uint32_t contextBufLen;
|
||||
char *contextBuffer = NULL;
|
||||
|
||||
if (inputFile == NULL) {
|
||||
PRINT_ERR("inputFile is null.\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
cJSON *allOsSyscapObj = CreateWholeSyscapJsonObj();
|
||||
int32_t ret = GetFileContext(inputFile, &contextBuffer, (uint32_t *)&contextBufLen);
|
||||
int32_t ret = CheckFileAndGetFileContext(inputFile, &contextBuffer, (uint32_t *)&contextBufLen);
|
||||
if (ret != 0) {
|
||||
PRINT_ERR("GetFileContext failed, input file : %s\n", inputFile);
|
||||
return FreeAfterCreatePCID(NULL, allOsSyscapObj, contextBuffer, 0, -1);
|
||||
}
|
||||
|
||||
@@ -486,15 +480,9 @@ int32_t DecodePCID(char *inputFile, char *outDirPath)
|
||||
freePcidJsonInfo.jsonRootObj = NULL;
|
||||
freePcidJsonInfo.sysCapObj = NULL;
|
||||
freePcidJsonInfo.flag = 0;
|
||||
|
||||
if (inputFile == NULL) {
|
||||
PRINT_ERR("inputFile is null.\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = GetFileContext(inputFile, &freePcidJsonInfo.contextBuffer, (uint32_t *)&contextBufLen);
|
||||
ret = CheckFileAndGetFileContext(inputFile, &freePcidJsonInfo.contextBuffer, (uint32_t *)&contextBufLen);
|
||||
if (ret != 0) {
|
||||
PRINT_ERR("GetFileContext failed, input file : %s\n", inputFile);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -887,14 +875,8 @@ int32_t EncodePcidscToString(char *inputFile, char *outDirPath)
|
||||
freePcidInfo.outDirPathFinal = outDirPath;
|
||||
PCIDMain *pcidMain = NULL;
|
||||
|
||||
if (inputFile == NULL) {
|
||||
PRINT_ERR("inputFile is null.\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = GetFileContext(inputFile, &freePcidInfo.contextBuffer, (uint32_t *)&bufferLen);
|
||||
ret = CheckFileAndGetFileContext(inputFile, &freePcidInfo.contextBuffer, (uint32_t *)&bufferLen);
|
||||
if (ret != 0) {
|
||||
PRINT_ERR("Get pcid file failed, pcid file path: %s\n", inputFile);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
+1
-7
@@ -150,13 +150,7 @@ int32_t RPCIDEncode(char *inputFile, char *outputPath)
|
||||
gJsonObjectSysCap.cjsonObjectRoot = NULL;
|
||||
gJsonObjectSysCap.sysCapPtr = NULL;
|
||||
|
||||
if (inputFile == NULL) {
|
||||
PRINT_ERR("inputFile is null.\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (GetFileContext(inputFile, &contextBuffer, &bufferLen) != 0) {
|
||||
PRINT_ERR("GetFileContext failed, input file : %s\n", inputFile);
|
||||
if (CheckFileAndGetFileContext(inputFile, &contextBuffer, &bufferLen) != 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user