mirror of
https://github.com/Proxmark/proxmark3.git
synced 2025-08-19 21:03:23 -07:00
jsonloadstr
This commit is contained in:
parent
2b73f4f973
commit
94feba0d60
2 changed files with 18 additions and 0 deletions
|
@ -264,6 +264,23 @@ bool HexToBuffer(const char *errormsg, const char *hexvalue, uint8_t * buffer, s
|
|||
return true;
|
||||
}
|
||||
|
||||
int JsonLoadStr(json_t *root, char *path, char *value) {
|
||||
if (!value)
|
||||
return 1;
|
||||
|
||||
json_t *jelm = json_path_get((const json_t *)root, path);
|
||||
if (!jelm || !json_is_string(jelm))
|
||||
return 2;
|
||||
|
||||
const char * strval = json_string_value(jelm);
|
||||
if (!strval)
|
||||
return 1;
|
||||
|
||||
memcpy(value, strval, strlen(strval));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int JsonLoadBufAsHex(json_t *elm, char *path, uint8_t *data, size_t maxbufferlen, size_t *datalen) {
|
||||
if (datalen)
|
||||
*datalen = 0;
|
||||
|
|
|
@ -33,6 +33,7 @@ extern int JsonSaveTLVTreeElm(json_t *elm, char *path, struct tlvdb *tlvdbelm, b
|
|||
|
||||
extern int JsonSaveTLVTree(json_t *root, json_t *elm, char *path, struct tlvdb *tlvdbelm);
|
||||
|
||||
extern int JsonLoadStr(json_t *root, char *path, char *value);
|
||||
extern int JsonLoadBufAsHex(json_t *elm, char *path, uint8_t *data, size_t maxbufferlen, size_t *datalen);
|
||||
|
||||
extern bool ParamLoadFromJson(struct tlvdb *tlv);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue