mirror of
https://github.com/openharmony/developtools_syscap_codec.git
synced 2026-08-26 17:56:33 -04:00
Merge branch 'master' of gitee.com:openharmony/developtools_syscap_codec
# Conflicts: # include/codec_config/syscap_define.h
This commit is contained in:
@@ -29,6 +29,7 @@ sources_platform_common = [
|
||||
"./src/create_pcid.c",
|
||||
"./src/endian_internal.c",
|
||||
"./src/context_tool.c",
|
||||
"./src/common_method.c",
|
||||
]
|
||||
|
||||
ohos_executable("syscap_tool_bin") {
|
||||
@@ -97,6 +98,7 @@ if (defined(ohos_lite)) {
|
||||
"./src/context_tool.c",
|
||||
"./src/endian_internal.c",
|
||||
"./src/syscap_tool.c",
|
||||
"./src/common_method.c",
|
||||
]
|
||||
|
||||
deps += [
|
||||
@@ -122,6 +124,7 @@ if (defined(ohos_lite)) {
|
||||
"./src/context_tool.c",
|
||||
"./src/endian_internal.c",
|
||||
"./src/syscap_tool.c",
|
||||
"./src/common_method.c",
|
||||
]
|
||||
external_deps = [
|
||||
"bounds_checking_function:libsec_static",
|
||||
|
||||
@@ -354,6 +354,9 @@ typedef enum SystemCapabilityNum {
|
||||
ABILITY_APPEXTENSION_PHOTOEDITOREXTENSION,
|
||||
HIVIEWDFX_HICOLLIE,
|
||||
BUNDLEMANAGER_APPDOMAINVERIFY,
|
||||
COMMUNICATION_NETMANAGER_BLUETOOTH,
|
||||
NOTIFICATION_NOTIFICATIONSETTINGS,
|
||||
MULTIMEDIA_VIDEOPROCESSINGENGINE,
|
||||
SECURITY_CRYPTOFRAMEWORK_KEY,
|
||||
SECURITY_CRYPTOFRAMEWORK_KEY_SYMKEY,
|
||||
SECURITY_CRYPTOFRAMEWORK_KEY_ASYMKEY,
|
||||
@@ -364,7 +367,6 @@ typedef enum SystemCapabilityNum {
|
||||
SECURITY_CRYPTOFRAMEWORK_MAC,
|
||||
SECURITY_CRYPTOFRAMEWORK_KDF,
|
||||
SECURITY_CRYPTOFRAMEWORK_RAND,
|
||||
MULTIMEDIA_VIDEOPROCESSINGENGINE,
|
||||
// Add before here
|
||||
SYSCAP_BASIC_END = 500,
|
||||
} SyscapNum;
|
||||
@@ -702,6 +704,9 @@ const static SyscapWithNum g_arraySyscap[] = {
|
||||
{"SystemCapability.Customization.CustomConfig", CUSTOMIZATION_CUSTOMCONFIG},
|
||||
{"SystemCapability.Ability.AppExtension.PhotoEditorExtension", ABILITY_APPEXTENSION_PHOTOEDITOREXTENSION},
|
||||
{"SystemCapability.BundleManager.AppDomainVerify", BUNDLEMANAGER_APPDOMAINVERIFY},
|
||||
{"SystemCapability.Communication.NetManager.Bluetooth", COMMUNICATION_NETMANAGER_BLUETOOTH},
|
||||
{"SystemCapability.Notification.NotificationSettings", NOTIFICATION_NOTIFICATIONSETTINGS},
|
||||
{"SystemCapability.Multimedia.VideoProcessingEngine", MULTIMEDIA_VIDEOPROCESSINGENGINE},
|
||||
{"SystemCapability.Security.CryptoFramework.Key", SECURITY_CRYPTOFRAMEWORK_KEY},
|
||||
{"SystemCapability.Security.CryptoFramework.Key.SymKey", SECURITY_CRYPTOFRAMEWORK_KEY_SYMKEY},
|
||||
{"SystemCapability.Security.CryptoFramework.Key.AsymKey", SECURITY_CRYPTOFRAMEWORK_KEY_ASYMKEY},
|
||||
@@ -712,7 +717,6 @@ const static SyscapWithNum g_arraySyscap[] = {
|
||||
{"SystemCapability.Security.CryptoFramework.Mac", SECURITY_CRYPTOFRAMEWORK_MAC},
|
||||
{"SystemCapability.Security.CryptoFramework.Kdf", SECURITY_CRYPTOFRAMEWORK_KDF},
|
||||
{"SystemCapability.Security.CryptoFramework.Rand", SECURITY_CRYPTOFRAMEWORK_RAND},
|
||||
{"SystemCapability.Multimedia.VideoProcessingEngine", MULTIMEDIA_VIDEOPROCESSINGENGINE},
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#include "endian_internal.h"
|
||||
#include "syscap_interface.h"
|
||||
#include "context_tool.h"
|
||||
#include "common_method.h"
|
||||
|
||||
#ifdef SYSCAP_DEFINE_EXTERN_ENABLE
|
||||
#include "syscap_define_custom.h"
|
||||
@@ -292,6 +293,10 @@ static int32_t ParseRpcidToJson(char *input, uint32_t inputLen, cJSON *rpcidJson
|
||||
char *sysCapBegin = input + sizeof(RPCIDHead) + sizeof(uint32_t);
|
||||
RPCIDHead *rpcidHeader = (RPCIDHead *)input;
|
||||
cJSON *sysCapJson = cJSON_CreateArray();
|
||||
if (sysCapJson == NULL) {
|
||||
PRINT_ERR("Get sysCapJson failed, sysCapJson is empty.\n");
|
||||
ret = -1;
|
||||
}
|
||||
for (i = 0; i < sysCapCount; i++) {
|
||||
char *temp = sysCapBegin + i * SINGLE_FEAT_LEN;
|
||||
if (strlen(temp) >= SINGLE_FEAT_LEN) {
|
||||
@@ -443,7 +448,7 @@ static char *FreeAfterDecodeRpcidToString(struct FreeAfterDecodeRpcidInfo freeAf
|
||||
{
|
||||
switch (type) {
|
||||
case FREE_MALLOC_PRISYSCAP_AFTER_DECODE_RPCID:
|
||||
free(freeAfterDecodeRpcidInfo.priSyscap);
|
||||
SafeFree(freeAfterDecodeRpcidInfo.priSyscap);
|
||||
free(freeAfterDecodeRpcidInfo.osSysCapIndex);
|
||||
cJSON_Delete(freeAfterDecodeRpcidInfo.sysCapDefine);
|
||||
cJSON_Delete(freeAfterDecodeRpcidInfo.rpcidRoot);
|
||||
@@ -495,6 +500,11 @@ char *DecodeRpcidToStringFormat(const char *inputFile)
|
||||
|
||||
// parse rpcid to json
|
||||
freeAfterDecodeRpcidInfo.rpcidRoot = cJSON_CreateObject();
|
||||
if (freeAfterDecodeRpcidInfo.rpcidRoot == NULL) {
|
||||
PRINT_ERR("Failed to create cJSON object for rpcidRoot\n");
|
||||
return FreeAfterDecodeRpcidToString(freeAfterDecodeRpcidInfo, FREE_CONTEXT_OUT_AFTER_DECODE_RPCID, outBuffer);
|
||||
}
|
||||
|
||||
if (ParseRpcidToJson(freeAfterDecodeRpcidInfo.contextBuffer, bufferLen, freeAfterDecodeRpcidInfo.rpcidRoot)) {
|
||||
PRINT_ERR("Prase rpcid to json failed. Input file: %s\n", inputFile);
|
||||
return FreeAfterDecodeRpcidToString(freeAfterDecodeRpcidInfo, FREE_RPCID_ROOT_AFTER_DECODE_RPCID, outBuffer);
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
#define PCID_MAIN_BYTES 128
|
||||
#define PCID_MAIN_INTS 32
|
||||
|
||||
#define E_EORROR (-1)
|
||||
#define E_ERROR (-1)
|
||||
#define E_OK 0
|
||||
#define E_APIVERSION 1
|
||||
#define E_SYSCAP 2
|
||||
@@ -54,7 +54,7 @@ char *DecodeRpcidToStringFormat(const char *inputFile);
|
||||
* rpcidString, input string format rpcid.
|
||||
* result, output comparison results.
|
||||
* retval:
|
||||
* E_EORROR, compare failed.
|
||||
* E_ERROR, compare failed.
|
||||
* E_OK, compare successful and meet the requirements.
|
||||
* E_APIVERSION, compare successful but api version too low.
|
||||
* E_SYSCAP, compare successful but missing some syscaps.
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Copyright (c) 2024-2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "common_method.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
void SafeFree(char *pointer)
|
||||
{
|
||||
if ((pointer) != NULL) {
|
||||
free(pointer);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
* Copyright (c) 2024-2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef COMMON_METHOD_H
|
||||
#define COMMON_METHOD_H
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
void SafeFree(char *pointer);
|
||||
|
||||
#endif
|
||||
+4
-2
@@ -155,23 +155,25 @@ int32_t CheckRpcidFormat(const char *inputFile, char **buffer, uint32_t *len)
|
||||
}
|
||||
if (bufferLen < (2 * sizeof(uint32_t))) { // 2, header of rpcid.sc
|
||||
PRINT_ERR("Parse file failed(format is invalid), input file : %s\n", inputFile);
|
||||
free(contextBuffer);
|
||||
FreeContextBuffer(contextBuffer);
|
||||
return -1;
|
||||
}
|
||||
rpcidHeader = (RPCIDHead *)contextBuffer;
|
||||
if (rpcidHeader->apiVersionType != 1) {
|
||||
PRINT_ERR("Parse file failed(apiVersionType != 1), input file : %s\n", inputFile);
|
||||
free(contextBuffer);
|
||||
FreeContextBuffer(contextBuffer);
|
||||
return -1;
|
||||
}
|
||||
sysCaptype = NtohsInter(*(uint16_t *)(rpcidHeader + 1));
|
||||
if (sysCaptype != 2) { // 2, app syscap type
|
||||
PRINT_ERR("Parse file failed(sysCaptype != 2), input file : %s\n", inputFile);
|
||||
FreeContextBuffer(contextBuffer);
|
||||
return -1;
|
||||
}
|
||||
sysCapLength = NtohsInter(*(uint16_t *)((char *)(rpcidHeader + 1) + sizeof(uint16_t)));
|
||||
if (bufferLen < sizeof(RPCIDHead) + sizeof(uint32_t) + sysCapLength) {
|
||||
PRINT_ERR("Parse file failed(SysCap length exceeded), input file : %s\n", inputFile);
|
||||
FreeContextBuffer(contextBuffer);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
+29
-29
@@ -25,6 +25,7 @@
|
||||
#include "endian_internal.h"
|
||||
#include "create_pcid.h"
|
||||
#include "context_tool.h"
|
||||
#include "common_method.h"
|
||||
|
||||
#ifdef SYSCAP_DEFINE_EXTERN_ENABLE
|
||||
#include "syscap_define_custom.h"
|
||||
@@ -58,7 +59,6 @@ struct FreeEncodePcidInfo {
|
||||
char *outDirPathFinal;
|
||||
};
|
||||
|
||||
|
||||
struct FreeDecodePcidJsonInfo {
|
||||
char *strJson;
|
||||
char *contextBuffer;
|
||||
@@ -271,6 +271,7 @@ int32_t CreatePCID(char *inputFile, char *outDirPath)
|
||||
|
||||
cJSON *jsonOsSyscapObj = cJSON_GetObjectItem(jsonSyscapObj, "os");
|
||||
cJSON *jsonPriSyscapObj = cJSON_GetObjectItem(jsonSyscapObj, "private");
|
||||
|
||||
ret = GetOsAndPriSyscapSize(jsonOsSyscapObj, jsonPriSyscapObj, &osCapSize, &privateCapSize);
|
||||
if (ret != 0) {
|
||||
return PreFreeAfterCreatePCID(NULL, allOsSyscapObj, jsonRootObj, contextBuffer, 0);
|
||||
@@ -358,7 +359,7 @@ static int32_t GetPriSyscapResult(cJSON *capVectorPtr, int32_t ret)
|
||||
return ret;
|
||||
}
|
||||
|
||||
int32_t GetPriSyscap(PCIDMain *pcidMain, cJSON *sysCapObject, size_t contextBufLen)
|
||||
static int32_t GetPriSyscap(PCIDMain *pcidMain, cJSON *sysCapObject, int32_t contextBufLen)
|
||||
{
|
||||
cJSON *capVectorPtr = cJSON_CreateArray();
|
||||
if (capVectorPtr == NULL) {
|
||||
@@ -366,12 +367,7 @@ int32_t GetPriSyscap(PCIDMain *pcidMain, cJSON *sysCapObject, size_t contextBufL
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (contextBufLen > UINT32_MAX) {
|
||||
PRINT_ERR("the data privateSyscapLen is out of scope.");
|
||||
return GetPriSyscapResult(capVectorPtr, -1);
|
||||
}
|
||||
|
||||
int32_t privateSyscapLen = (int32_t)(contextBufLen - sizeof(PCIDMain) - 1);
|
||||
int32_t privateSyscapLen = contextBufLen - sizeof(PCIDMain) - 1;
|
||||
if (privateSyscapLen < 0 || privateSyscapLen > INT32_MAX) {
|
||||
PRINT_ERR("parse private syscap failed.");
|
||||
return GetPriSyscapResult(capVectorPtr, -1);
|
||||
@@ -452,9 +448,8 @@ static int32_t FreeAfterDecodePCID(struct FreeDecodePcidJsonInfo freePcidJsonInf
|
||||
{
|
||||
switch (type) {
|
||||
case FREE_DECODE_PCID_CONVERT_OUT:
|
||||
free(freePcidJsonInfo.strJson);
|
||||
cJSON_free(freePcidJsonInfo.strJson);
|
||||
cJSON_Delete(freePcidJsonInfo.jsonRootObj);
|
||||
cJSON_Delete(freePcidJsonInfo.sysCapObj);
|
||||
FreeContextBuffer(freePcidJsonInfo.contextBuffer);
|
||||
break;
|
||||
case FREE_DECODE_PCID_ROOT_OUT:
|
||||
@@ -467,6 +462,9 @@ static int32_t FreeAfterDecodePCID(struct FreeDecodePcidJsonInfo freePcidJsonInf
|
||||
FreeContextBuffer(freePcidJsonInfo.contextBuffer);
|
||||
break;
|
||||
case FREE_DECODE_PCID_CONTEXT_OUT:
|
||||
cJSON_Delete(freePcidJsonInfo.sysCapObj);
|
||||
FreeContextBuffer(freePcidJsonInfo.contextBuffer);
|
||||
break;
|
||||
default:
|
||||
FreeContextBuffer(freePcidJsonInfo.contextBuffer);
|
||||
}
|
||||
@@ -526,15 +524,14 @@ int32_t DecodePCID(char *inputFile, char *outDirPath)
|
||||
return FreeAfterDecodePCID(freePcidJsonInfo, FREE_DECODE_PCID_ROOT_OUT, ret);
|
||||
}
|
||||
|
||||
freePcidJsonInfo.sysCapObj = NULL; // avoid being released repeatedly.
|
||||
freePcidJsonInfo.strJson = cJSON_Print(freePcidJsonInfo.jsonRootObj);
|
||||
|
||||
char *strJson = cJSON_Print(freePcidJsonInfo.jsonRootObj);
|
||||
const char outputFileName[] = "pcid.json";
|
||||
ret = ConvertedContextSaveAsFile(outDirPath, outputFileName, strJson, strlen(strJson));
|
||||
ret = ConvertedContextSaveAsFile(outDirPath, outputFileName, freePcidJsonInfo.strJson,
|
||||
strlen(freePcidJsonInfo.strJson));
|
||||
if (ret != 0) {
|
||||
PRINT_ERR("ConvertedContextSaveAsFile failed, outDirPath:%s, filename:%s\n", outDirPath, outputFileName);
|
||||
}
|
||||
free(strJson);
|
||||
return FreeAfterDecodePCID(freePcidJsonInfo, FREE_DECODE_PCID_CONVERT_OUT, ret);
|
||||
}
|
||||
|
||||
@@ -665,7 +662,6 @@ static int32_t AddPriSyscapToJsonObj(char *priSyscapString, uint32_t priSyscapSt
|
||||
cJSON *sysCapArray = cJSON_CreateArray();
|
||||
if (sysCapArray == NULL) {
|
||||
PRINT_ERR("Create cJSON array failed.\n");
|
||||
free(sysCapArray);
|
||||
return -1;
|
||||
}
|
||||
if (priSyscapStringLen == 0) {
|
||||
@@ -701,7 +697,6 @@ static int32_t GetSyscapStr(char *input, char const *priSyscapStr, uint32_t* osS
|
||||
uint32_t fileContextLen;
|
||||
if (GetFileContext(input, &ctx, (uint32_t *)&fileContextLen) != 0) {
|
||||
PRINT_ERR("GetFileContext failed, input file : %s\n", input);
|
||||
free(ctx);
|
||||
return -1;
|
||||
}
|
||||
if (ParseStringSyscap(ctx, osSyscap, OS_SYSCAP_NUM, pcidHeader, PCID_HEADER) != 0) {
|
||||
@@ -719,6 +714,7 @@ int32_t DecodeStringPCIDToJson(char *input, char *outDirPath)
|
||||
uint32_t osSyscap[OS_SYSCAP_NUM] = {0};
|
||||
uint32_t pcidHeader[PCID_HEADER];
|
||||
char *priSyscapStr = NULL;
|
||||
char *jsonBuffer = NULL;
|
||||
ret = GetSyscapStr(input, priSyscapStr, osSyscap, pcidHeader);
|
||||
if (ret == -1) {
|
||||
return ret;
|
||||
@@ -727,40 +723,44 @@ int32_t DecodeStringPCIDToJson(char *input, char *outDirPath)
|
||||
// add to json object
|
||||
cJSON *sysCapObj = cJSON_CreateObject();
|
||||
cJSON *rootObj = cJSON_CreateObject();
|
||||
if (sysCapObj == NULL || rootObj == NULL) {
|
||||
PRINT_ERR("Failed to create cJSON objects.\n");
|
||||
goto FAILED;
|
||||
}
|
||||
|
||||
if (!cJSON_AddItemToObject(rootObj, "syscap", sysCapObj)) {
|
||||
PRINT_ERR("Add syscap to json failed.\n");
|
||||
goto ADD_JSON_FAILED;
|
||||
goto FAILED;
|
||||
}
|
||||
if (AddHeaderToJsonObj(pcidHeader, PCID_HEADER, rootObj) != 0) {
|
||||
PRINT_ERR("Add header to json object failed.\n");
|
||||
goto ADD_JSON_FAILED;
|
||||
goto FAILED;
|
||||
}
|
||||
if (AddOsSyscapToJsonObj(osSyscap, OS_SYSCAP_NUM, sysCapObj) != 0) {
|
||||
PRINT_ERR("Add os syscap json object failed.\n");
|
||||
goto ADD_JSON_FAILED;
|
||||
goto FAILED;
|
||||
}
|
||||
|
||||
if (AddPriSyscapToJsonObj(priSyscapStr, (uint32_t)strlen(priSyscapStr), sysCapObj) != 0) {
|
||||
if (AddPriSyscapToJsonObj(priSyscapStr, (uint32_t) strlen(priSyscapStr), sysCapObj) != 0) {
|
||||
PRINT_ERR("Add private syscap json object failed.\n");
|
||||
goto ADD_JSON_FAILED;
|
||||
goto FAILED;
|
||||
}
|
||||
// save as json file
|
||||
char *jsonBuffer = cJSON_Print(rootObj);
|
||||
jsonBuffer = cJSON_Print(rootObj);
|
||||
if (jsonBuffer == NULL) {
|
||||
PRINT_ERR("json buffer is null.\n");
|
||||
goto ADD_JSON_FAILED;
|
||||
goto FAILED;
|
||||
}
|
||||
const char outputFileName[] = "pcid.json";
|
||||
if (ConvertedContextSaveAsFile(outDirPath, outputFileName,
|
||||
jsonBuffer, strlen(jsonBuffer)) != 0) {
|
||||
if (ConvertedContextSaveAsFile(outDirPath, outputFileName, jsonBuffer, strlen(jsonBuffer)) != 0) {
|
||||
PRINT_ERR("Save as json file failed.\n");
|
||||
goto SAVE_FAILED;
|
||||
goto FAILED;
|
||||
}
|
||||
ret = 0;
|
||||
|
||||
SAVE_FAILED:
|
||||
free(jsonBuffer);
|
||||
ADD_JSON_FAILED:
|
||||
FAILED:
|
||||
cJSON_free(jsonBuffer);
|
||||
SafeFree(priSyscapStr);
|
||||
cJSON_Delete(sysCapObj);
|
||||
cJSON_Delete(rootObj);
|
||||
return ret;
|
||||
|
||||
+24
-8
@@ -27,6 +27,7 @@
|
||||
#include "create_pcid.h"
|
||||
#include "syscap_tool.h"
|
||||
#include "context_tool.h"
|
||||
#include "common_method.h"
|
||||
|
||||
#ifdef SYSCAP_DEFINE_EXTERN_ENABLE
|
||||
#include "syscap_define_custom.h"
|
||||
@@ -71,6 +72,14 @@ struct FreeAfterEncodeRpcidscInfo {
|
||||
int16_t flag;
|
||||
};
|
||||
|
||||
static void FreePointerMemory(char *pcidContent, char *rpcidContent, char *pcidPriSyscap, char *rpcidPriSyscap)
|
||||
{
|
||||
SafeFree(pcidContent);
|
||||
SafeFree(rpcidPriSyscap);
|
||||
SafeFree(rpcidContent);
|
||||
SafeFree(pcidPriSyscap);
|
||||
}
|
||||
|
||||
static int32_t FillOsCapLength(char *convertedBuffer, char *contextBuffer, struct JsonObjectSysCap gJsonObjectSysCap,
|
||||
uint32_t sysCapSize, int32_t ret)
|
||||
{
|
||||
@@ -204,6 +213,11 @@ static int32_t ParseRpcidToJson(char *input, uint32_t inputLen, cJSON *rpcidJson
|
||||
char *sysCapBegin = input + sizeof(RPCIDHead) + sizeof(uint32_t);
|
||||
RPCIDHead *rpcidHeader = (RPCIDHead *)input;
|
||||
cJSON *sysCapJson = cJSON_CreateArray();
|
||||
if (sysCapJson == NULL) {
|
||||
PRINT_ERR("Failed to create sysCapJson array\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (i = 0; i < sysCapCount; i++) {
|
||||
char *temp = sysCapBegin + i * SINGLE_FEAT_LEN;
|
||||
if (strlen(temp) >= SINGLE_FEAT_LEN || strlen(temp) == 0) {
|
||||
@@ -263,14 +277,18 @@ int32_t RPCIDDecode(char *inputFile, char *outputPath)
|
||||
|
||||
// save to json file
|
||||
convertedBuffer = cJSON_Print(rpcidRoot);
|
||||
if (convertedBuffer == NULL) {
|
||||
PRINT_ERR("cJSON_Print failed to create JSON string\n");
|
||||
goto FREE_RPCID_ROOT;
|
||||
}
|
||||
|
||||
ret = ConvertedContextSaveAsFile(outputPath, "rpcid.json", convertedBuffer, strlen(convertedBuffer));
|
||||
if (ret != 0) {
|
||||
PRINT_ERR("ConvertedContextSaveAsFile failed, outputPath:%s, filename:rpcid.json\n", outputPath);
|
||||
free(convertedBuffer);
|
||||
cJSON_free(convertedBuffer);
|
||||
goto FREE_RPCID_ROOT;
|
||||
}
|
||||
free(convertedBuffer);
|
||||
|
||||
cJSON_free(convertedBuffer);
|
||||
FREE_RPCID_ROOT:
|
||||
cJSON_Delete(rpcidRoot);
|
||||
FREE_CONTEXT_OUT:
|
||||
@@ -705,10 +723,7 @@ int32_t ComparePcidWithRpcidString(char *pcidFile, char *rpcidFile, uint32_t typ
|
||||
&rpcidPriSyscap, &rpcidPriSyscapLen);
|
||||
if (ret != 0) {
|
||||
PRINT_ERR("Separate syscap from string failed. ret = %d\n", ret);
|
||||
free(pcidContent);
|
||||
free(rpcidContent);
|
||||
free(pcidPriSyscap);
|
||||
free(rpcidPriSyscap);
|
||||
FreePointerMemory(pcidContent, rpcidContent, pcidPriSyscap, rpcidPriSyscap);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -720,5 +735,6 @@ int32_t ComparePcidWithRpcidString(char *pcidFile, char *rpcidFile, uint32_t typ
|
||||
} else {
|
||||
printf("Fail! The pcid does not meet the rpcid\n");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,6 +41,7 @@ if (defined(ohos_lite)) {
|
||||
"../../../src/create_pcid.c",
|
||||
"../../../src/endian_internal.c",
|
||||
"../../../src/syscap_tool.c",
|
||||
"../../../src/common_method.c",
|
||||
"syscap_codec_test.cpp",
|
||||
]
|
||||
|
||||
@@ -82,6 +83,7 @@ if (defined(ohos_lite)) {
|
||||
"../../../src/create_pcid.c",
|
||||
"../../../src/endian_internal.c",
|
||||
"../../../src/syscap_tool.c",
|
||||
"../../../src/common_method.c",
|
||||
"syscap_codec_test.cpp",
|
||||
]
|
||||
|
||||
|
||||
@@ -208,7 +208,7 @@ def _check_path_prefix(paths):
|
||||
|
||||
def traversal_files(subsystem_path, _files):
|
||||
for item in os.scandir(subsystem_path):
|
||||
if is_symlik(item.path):
|
||||
if is_symlink(item.path):
|
||||
continue
|
||||
elif item.is_file() and item.name == 'ohos.build':
|
||||
_files.append(item.path)
|
||||
@@ -230,7 +230,7 @@ def get_file_type(file_path):
|
||||
return 'unknown'
|
||||
|
||||
|
||||
def is_symlik(file_path):
|
||||
def is_symlink(file_path):
|
||||
file_type = get_file_type(file_path)
|
||||
if file_type == 'symlink':
|
||||
link_target = os.readlink(file_path)
|
||||
|
||||
Reference in New Issue
Block a user