mirror of
https://github.com/openharmony/developtools_syscap_codec.git
synced 2026-08-27 02:11:19 -04:00
@@ -323,8 +323,8 @@ FREE_SYSCAP_OUT:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int32_t TransStringFormatAndSaveSyscap(struct FreeAfterDecodeRpcidInfo freeAfterDecodeRpcidInfo, cJSON *sysCapArray,
|
||||
const char *inputFile)
|
||||
static int32_t TransStringFormatAndSaveSyscap(struct FreeAfterDecodeRpcidInfo freeAfterDecodeRpcidInfo,
|
||||
cJSON *sysCapArray, const char *inputFile)
|
||||
{
|
||||
// trans to string format
|
||||
freeAfterDecodeRpcidInfo.sysCapDefine = CreateWholeSyscapJsonObj();
|
||||
@@ -339,7 +339,8 @@ static int32_t TransStringFormatAndSaveSyscap(struct FreeAfterDecodeRpcidInfo fr
|
||||
return -1;
|
||||
}
|
||||
// malloc for save os syscap index
|
||||
freeAfterDecodeRpcidInfo.osSysCapIndex = (uint16_t *)malloc(sizeof(uint16_t) * freeAfterDecodeRpcidInfo.sysCapArraySize);
|
||||
freeAfterDecodeRpcidInfo.osSysCapIndex = (uint16_t *)malloc(sizeof(uint16_t)
|
||||
* freeAfterDecodeRpcidInfo.sysCapArraySize);
|
||||
if (freeAfterDecodeRpcidInfo.osSysCapIndex == NULL) {
|
||||
PRINT_ERR("malloc failed.\n");
|
||||
return -1;
|
||||
@@ -398,7 +399,8 @@ static void PrintResultToOutBuffer(struct FreeAfterDecodeRpcidInfo freeAfterDeco
|
||||
}
|
||||
|
||||
static void PartSysCapAndOutBuffer(struct FreeAfterDecodeRpcidInfo freeAfterDecodeRpcidInfo, char *outBuffer,
|
||||
char *priSyscapArray, cJSON *sysCapArray) {
|
||||
char *priSyscapArray, cJSON *sysCapArray)
|
||||
{
|
||||
uint32_t i;
|
||||
int32_t ret = 0;
|
||||
uint16_t indexOs = 0;
|
||||
@@ -428,7 +430,8 @@ static void PartSysCapAndOutBuffer(struct FreeAfterDecodeRpcidInfo freeAfterDeco
|
||||
}
|
||||
|
||||
static char *FreeAfterDecodeRpcidToString(struct FreeAfterDecodeRpcidInfo freeAfterDecodeRpcidInfo, int32_t type,
|
||||
char *outBuffer) {
|
||||
char *outBuffer)
|
||||
{
|
||||
switch (type) {
|
||||
case FREE_MALLOC_PRISYSCAP_AFTER_DECODE_RPCID:
|
||||
free(freeAfterDecodeRpcidInfo.priSyscap);
|
||||
@@ -497,8 +500,9 @@ char *DecodeRpcidToStringFormat(const char *inputFile)
|
||||
return FreeAfterDecodeRpcidToString(freeAfterDecodeRpcidInfo, FREE_MALLOC_PRISYSCAP_AFTER_DECODE_RPCID, outBuffer);
|
||||
}
|
||||
|
||||
static int32_t CopySyscopToRet(struct PcidPriSyscapInfo pcidPriSyscapInfo, const size_t allSyscapNum, char *tempSyscap,
|
||||
uint32_t i, uint8_t k) {
|
||||
static int32_t CopySyscopToRet(struct PcidPriSyscapInfo pcidPriSyscapInfo, const size_t allSyscapNum,
|
||||
char *tempSyscap, uint32_t i, uint8_t k)
|
||||
{
|
||||
uint32_t pos = (i - 2) * INT_BIT + k;
|
||||
uint32_t t;
|
||||
for (t = 0; t < allSyscapNum; t++) {
|
||||
@@ -506,15 +510,16 @@ static int32_t CopySyscopToRet(struct PcidPriSyscapInfo pcidPriSyscapInfo, const
|
||||
break;
|
||||
}
|
||||
}
|
||||
pcidPriSyscapInfo.ret = strcpy_s(tempSyscap, sizeof(char) * SINGLE_SYSCAP_LEN, g_arraySyscap[t].str); // 2, header of pcid & rpcid
|
||||
pcidPriSyscapInfo.ret = strcpy_s(tempSyscap, sizeof(char) * SINGLE_SYSCAP_LEN, g_arraySyscap[t].str);
|
||||
// 2, header of pcid & rpcid
|
||||
if (pcidPriSyscapInfo.ret != EOK) {
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int32_t CheckPcidEachBit(struct PcidPriSyscapInfo pcidPriSyscapInfo, CompareError *result, const size_t allSyscapNum,
|
||||
uint32_t i, uint32_t blockBits)
|
||||
static int32_t CheckPcidEachBit(struct PcidPriSyscapInfo pcidPriSyscapInfo, CompareError *result,
|
||||
const size_t allSyscapNum, uint32_t i, uint32_t blockBits)
|
||||
{
|
||||
int32_t flag = 0;
|
||||
for (uint8_t k = 0; k < INT_BIT; k++) {
|
||||
@@ -531,14 +536,15 @@ static int32_t CheckPcidEachBit(struct PcidPriSyscapInfo pcidPriSyscapInfo, Comp
|
||||
FreeCompareError(result);
|
||||
return -1;
|
||||
}
|
||||
result->syscap[pcidPriSyscapInfo.ossyscapFlag++] = tempSyscap;
|
||||
result->syscap[pcidPriSyscapInfo.ossyscapFlag++] = tempSyscap;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int32_t ComparePcidWithOsSyscap(struct PcidPriSyscapInfo pcidPriSyscapInfo, uint32_t pcidOsAarry[PCID_OUT_BUFFER],
|
||||
uint32_t rpcidOsAarry[PCID_OUT_BUFFER], CompareError *result, const size_t allSyscapNum)
|
||||
static int32_t ComparePcidWithOsSyscap(struct PcidPriSyscapInfo pcidPriSyscapInfo,
|
||||
uint32_t pcidOsAarry[PCID_OUT_BUFFER], uint32_t rpcidOsAarry[PCID_OUT_BUFFER], CompareError *result,
|
||||
const size_t allSyscapNum)
|
||||
{
|
||||
uint32_t i;
|
||||
int32_t ret = 0;
|
||||
|
||||
@@ -54,7 +54,7 @@ struct SystemCapabilityAsyncContext {
|
||||
};
|
||||
|
||||
static char* CalculateAllStringLength(char *priOutput, char osCapArray[PCID_MAIN_U32][U32_TO_STR_MAX_LEN],
|
||||
char (*priCapArray)[SINGLE_SYSCAP_LEN], char *allSyscapBuffer)
|
||||
char (*priCapArray)[SINGLE_SYSCAP_LEN], char *allSyscapBuffer)
|
||||
{
|
||||
bool retBool;
|
||||
errno_t err = EOK;
|
||||
@@ -112,7 +112,7 @@ static char* CalculateAllStringLength(char *priOutput, char osCapArray[PCID_MAIN
|
||||
}
|
||||
|
||||
static char* FreeAfterGetSysCap(char *priOutput, char (*priCapArray)[SINGLE_SYSCAP_LEN], char *allSyscapBuffer,
|
||||
int32_t type)
|
||||
int32_t type)
|
||||
{
|
||||
if (type == FREE_PRICAP_ARRAY_AFTER_GET_SYS_CAP) {
|
||||
free(priCapArray);
|
||||
|
||||
+4
-4
@@ -87,7 +87,6 @@ static int32_t FillOsCapLength(char *convertedBuffer, char *contextBuffer, struc
|
||||
headPtr->apiVersion = HtonsInter((uint16_t)apiVerItem->valueint);
|
||||
headPtr->apiVersionType = 1;
|
||||
|
||||
|
||||
fillTmpPtr = convertedBuffer + sizeof(RPCIDHead);
|
||||
*(uint16_t *)fillTmpPtr = HtonsInter(2); // 2, SysCap Type, 2: request Cap
|
||||
fillTmpPtr += sizeof(uint16_t);
|
||||
@@ -330,8 +329,8 @@ static int32_t PrintOutputToFile(struct FreeAfterEncodeRpcidscInfo freeAfterEnco
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int32_t OutputSetMemAndPrintToFile(struct FreeAfterEncodeRpcidscInfo freeAfterEncodeRpcidscInfo,
|
||||
int32_t sysCapArraySize, cJSON *sysCapArray, char *outDirPath)
|
||||
static int32_t OutputSetMemAndPrintToFile(struct FreeAfterEncodeRpcidscInfo freeAfterEncodeRpcidscInfo,
|
||||
int32_t sysCapArraySize, cJSON *sysCapArray, char *outDirPath)
|
||||
{
|
||||
char *priSyscap = NULL;
|
||||
cJSON *cJsonTemp = NULL;
|
||||
@@ -373,7 +372,8 @@ static int32_t OutputSetMemAndPrintToFile(struct FreeAfterEncodeRpcidscInfo free
|
||||
outUint[0] = *(uint32_t *)freeAfterEncodeRpcidscInfo.contextBuffer;
|
||||
outUint[1] = *(uint32_t *)(freeAfterEncodeRpcidscInfo.contextBuffer + sizeof(uint32_t));
|
||||
uint8_t *osOutUint = (uint8_t *)(outUint + 2);
|
||||
if (SetOsSysCapBitMap(osOutUint, 120, freeAfterEncodeRpcidscInfo.osSysCapIndex, indexOs) != 0) { // 120, len of osOutUint
|
||||
// 120, len of osOutUint
|
||||
if (SetOsSysCapBitMap(osOutUint, 120, freeAfterEncodeRpcidscInfo.osSysCapIndex, indexOs) != 0) {
|
||||
PRINT_ERR("Set os syscap bit map failed.\n");
|
||||
freeAfterEncodeRpcidscInfo.flag = 1;
|
||||
return ret;
|
||||
|
||||
Reference in New Issue
Block a user