!93 字符串形式的 pcid 与 rpcid 比较功能支持直接输入字符串。

Merge pull request !93 from chenyude/syscap_tool
This commit is contained in:
openharmony_ci
2022-07-19 02:51:18 +00:00
committed by Gitee
3 changed files with 26 additions and 13 deletions
+4 -1
View File
@@ -18,6 +18,9 @@
#include "stdint.h"
#define TYPE_FILE (0U)
#define TYPE_STRING (1U)
#ifdef __cplusplus
#if __cplusplus
extern "C" {
@@ -35,7 +38,7 @@ int32_t RPCIDDecode(char *inputFile, char *outputPath);
/* in: inputFile, out: outputPath/rpcid.json */
int32_t EncodeRpcidscToString(char *inputFile, char *outDirPath);
/* in: pcidFile, rpcidFile */
int32_t ComparePcidWithRpcidString(char *pcidFile, char *rpcidFile);
int32_t ComparePcidWithRpcidString(char *pcidFile, char *rpcidFile, uint32_t type);
int32_t SeparateSyscapFromString(const char *inputString, uint32_t *osArray, uint32_t osArraySize,
char **priSyscap, uint32_t *priSyscapLen);
+6 -3
View File
@@ -29,7 +29,7 @@
printf("ERROR: [%s: %d] -> ", __FILE__, __LINE__); \
printf(__VA_ARGS__); \
} while (0)
#define SYSCAP_VERSION "1.0.1"
#define SYSCAP_VERSION "1.1.1"
#define OUTPUT_VERSION_LEN 200
#define ENCODE 0
#define DECODE 1
@@ -130,7 +130,9 @@ int main(int argc, char **argv)
case 0x115: // 0x115, -Pesi inputfile
ret = EncodePcidscToString(inputfile, outputpath); break;
case 0x60: // 0x60, -C PCID.txt RPCID.txt
ret = ComparePcidWithRpcidString(pcidfile, rpcidfile); break;
ret = ComparePcidWithRpcidString(pcidfile, rpcidfile, TYPE_FILE); break;
case 0x64: // 0x64, -sC "pcidstring" "rpcidstring"
ret = ComparePcidWithRpcidString(pcidfile, rpcidfile, TYPE_STRING); break;
case 0x111: // 0x111, -Pei inputfile
ret = CreatePCID(inputfile, outputpath); break;
case 0x112: // 0x112, -Pdi inputfile
@@ -168,7 +170,8 @@ void PrintHelp(void)
printf("-h, --help\t: how to use\n");
printf("-R, --RPCID\t: encode or decode RPCID\n");
printf("-P, --PCID\t: encode or decode PCID\n");
printf("-C, --compare\t: compare pcid with rpcid string format.\n");
printf("-C, --compare\t: compare pcid with rpcid string format.\n\t"
"-s, --string : input string.\n");
printf("-e, --encode\t: encode to sc format.\n\t-s, --string : encode to string format.\n");
printf("-d, --decode\t: decode to json format.\n\t-s, --string : decode string format.\n");
printf("-i filepath, --input filepath\t: input file\n");
+16 -9
View File
@@ -647,7 +647,7 @@ SKIP_PRI_SYSCAP:
return 0;
}
int32_t ComparePcidWithRpcidString(char *pcidFile, char *rpcidFile)
int32_t ComparePcidWithRpcidString(char *pcidFile, char *rpcidFile, uint32_t type)
{
int32_t ret;
int32_t versionFlag = 0;
@@ -663,14 +663,21 @@ int32_t ComparePcidWithRpcidString(char *pcidFile, char *rpcidFile)
uint32_t pcidOsAarry[PCID_OUT_BUFFER] = {0};
uint32_t rpcidOsAarry[PCID_OUT_BUFFER] = {0};
if (GetFileContext(pcidFile, &pcidContent, &pcidContentLen)) {
PRINT_ERR("Get pcid file context failed, input file : %s\n", pcidFile);
return -1;
}
if (GetFileContext(rpcidFile, &rpcidContent, &rpcidContentLen)) {
PRINT_ERR("Get rpcid file context failed, input file : %s\n", rpcidFile);
free(pcidContent);
if (type == TYPE_FILE) {
if (GetFileContext(pcidFile, &pcidContent, &pcidContentLen)) {
PRINT_ERR("Get pcid file context failed, input file : %s\n", pcidFile);
return -1;
}
if (GetFileContext(rpcidFile, &rpcidContent, &rpcidContentLen)) {
PRINT_ERR("Get rpcid file context failed, input file : %s\n", rpcidFile);
free(pcidContent);
return -1;
}
} else if (type == TYPE_STRING) {
pcidContent = pcidFile;
rpcidContent = rpcidFile;
} else {
PRINT_ERR("Input file type error, type=%d\n", type);
return -1;
}