mirror of
https://github.com/openharmony/developtools_syscap_codec.git
synced 2026-08-27 02:11:19 -04:00
feat: syscap compare function support input string directly.
Signed-off-by: yudechen <chenyude@huawei.com> Change-Id: Id80a3439972a17aadcbcaa3e216f6774d04e1ef4
This commit is contained in:
@@ -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
@@ -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
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user