diff options
| author | 2023-02-07 11:43:04 +0100 | |
|---|---|---|
| committer | 2023-02-07 11:43:04 +0100 | |
| commit | fe1b22723868b038c4d0b84d9582edcdd888af97 (patch) | |
| tree | 7db408f97a23c3283eebf1e02caec03bfab9c614 | |
| parent | 6390abcd1c94f4c29291c81322726d6946fd345f (diff) | |
| download | libplist-fe1b22723868b038c4d0b84d9582edcdd888af97.tar.gz libplist-fe1b22723868b038c4d0b84d9582edcdd888af97.tar.bz2 | |
Add function to interface to allow enabling/disabling error/debug output for the format parses
This makes the `-d` option work in plistutil that wasn't doing anything
| -rw-r--r-- | include/plist/plist.h | 7 | ||||
| -rw-r--r-- | src/bplist.c | 5 | ||||
| -rw-r--r-- | src/jplist.c | 5 | ||||
| -rw-r--r-- | src/oplist.c | 5 | ||||
| -rw-r--r-- | src/plist.c | 13 | ||||
| -rw-r--r-- | src/xplist.c | 5 | ||||
| -rw-r--r-- | tools/plistutil.c | 5 |
7 files changed, 45 insertions, 0 deletions
diff --git a/include/plist/plist.h b/include/plist/plist.h index 0a21499..f955d5e 100644 --- a/include/plist/plist.h +++ b/include/plist/plist.h | |||
| @@ -1094,6 +1094,13 @@ extern "C" | |||
| 1094 | */ | 1094 | */ |
| 1095 | void plist_mem_free(void* ptr); | 1095 | void plist_mem_free(void* ptr); |
| 1096 | 1096 | ||
| 1097 | /** | ||
| 1098 | * Set debug level for the format parsers. | ||
| 1099 | * | ||
| 1100 | * @param debug Debug level. Currently, only 0 (off) and 1 (enabled) are supported. | ||
| 1101 | */ | ||
| 1102 | void plist_set_debug(int debug); | ||
| 1103 | |||
| 1097 | /*@}*/ | 1104 | /*@}*/ |
| 1098 | 1105 | ||
| 1099 | #ifdef __cplusplus | 1106 | #ifdef __cplusplus |
diff --git a/src/bplist.c b/src/bplist.c index ff0b399..72040cc 100644 --- a/src/bplist.c +++ b/src/bplist.c | |||
| @@ -227,6 +227,11 @@ void plist_bin_deinit(void) | |||
| 227 | /* deinit binary plist stuff */ | 227 | /* deinit binary plist stuff */ |
| 228 | } | 228 | } |
| 229 | 229 | ||
| 230 | void plist_bin_set_debug(int debug) | ||
| 231 | { | ||
| 232 | plist_bin_debug = debug; | ||
| 233 | } | ||
| 234 | |||
| 230 | static plist_t parse_bin_node_at_index(struct bplist_data *bplist, uint32_t node_index); | 235 | static plist_t parse_bin_node_at_index(struct bplist_data *bplist, uint32_t node_index); |
| 231 | 236 | ||
| 232 | static plist_t parse_int_node(const char **bnode, uint8_t size) | 237 | static plist_t parse_int_node(const char **bnode, uint8_t size) |
diff --git a/src/jplist.c b/src/jplist.c index 99a8877..8ed7398 100644 --- a/src/jplist.c +++ b/src/jplist.c | |||
| @@ -64,6 +64,11 @@ void plist_json_deinit(void) | |||
| 64 | /* deinit JSON stuff */ | 64 | /* deinit JSON stuff */ |
| 65 | } | 65 | } |
| 66 | 66 | ||
| 67 | void plist_json_set_debug(int debug) | ||
| 68 | { | ||
| 69 | plist_json_debug = debug; | ||
| 70 | } | ||
| 71 | |||
| 67 | #ifndef HAVE_STRNDUP | 72 | #ifndef HAVE_STRNDUP |
| 68 | static char* strndup(const char* str, size_t len) | 73 | static char* strndup(const char* str, size_t len) |
| 69 | { | 74 | { |
diff --git a/src/oplist.c b/src/oplist.c index 287d5a2..1781962 100644 --- a/src/oplist.c +++ b/src/oplist.c | |||
| @@ -63,6 +63,11 @@ void plist_ostep_deinit(void) | |||
| 63 | /* deinit OpenStep plist stuff */ | 63 | /* deinit OpenStep plist stuff */ |
| 64 | } | 64 | } |
| 65 | 65 | ||
| 66 | void plist_ostep_set_debug(int debug) | ||
| 67 | { | ||
| 68 | plist_ostep_debug = debug; | ||
| 69 | } | ||
| 70 | |||
| 66 | #ifndef HAVE_STRNDUP | 71 | #ifndef HAVE_STRNDUP |
| 67 | static char* strndup(const char* str, size_t len) | 72 | static char* strndup(const char* str, size_t len) |
| 68 | { | 73 | { |
diff --git a/src/plist.c b/src/plist.c index 689fc79..8d57416 100644 --- a/src/plist.c +++ b/src/plist.c | |||
| @@ -1497,6 +1497,19 @@ PLIST_API int plist_data_val_contains(plist_t datanode, const uint8_t* cmpval, s | |||
| 1497 | return (memmem(data->buff, data->length, cmpval, n) != NULL); | 1497 | return (memmem(data->buff, data->length, cmpval, n) != NULL); |
| 1498 | } | 1498 | } |
| 1499 | 1499 | ||
| 1500 | extern void plist_xml_set_debug(int debug); | ||
| 1501 | extern void plist_bin_set_debug(int debug); | ||
| 1502 | extern void plist_json_set_debug(int debug); | ||
| 1503 | extern void plist_ostep_set_debug(int debug); | ||
| 1504 | |||
| 1505 | PLIST_API void plist_set_debug(int debug) | ||
| 1506 | { | ||
| 1507 | plist_xml_set_debug(debug); | ||
| 1508 | plist_bin_set_debug(debug); | ||
| 1509 | plist_json_set_debug(debug); | ||
| 1510 | plist_ostep_set_debug(debug); | ||
| 1511 | } | ||
| 1512 | |||
| 1500 | PLIST_API void plist_sort(plist_t plist) | 1513 | PLIST_API void plist_sort(plist_t plist) |
| 1501 | { | 1514 | { |
| 1502 | if (!plist) { | 1515 | if (!plist) { |
diff --git a/src/xplist.c b/src/xplist.c index 1abc46d..bd506fb 100644 --- a/src/xplist.c +++ b/src/xplist.c | |||
| @@ -102,6 +102,11 @@ void plist_xml_deinit(void) | |||
| 102 | /* deinit XML stuff */ | 102 | /* deinit XML stuff */ |
| 103 | } | 103 | } |
| 104 | 104 | ||
| 105 | void plist_xml_set_debug(int debug) | ||
| 106 | { | ||
| 107 | plist_xml_debug = debug; | ||
| 108 | } | ||
| 109 | |||
| 105 | static size_t dtostr(char *buf, size_t bufsize, double realval) | 110 | static size_t dtostr(char *buf, size_t bufsize, double realval) |
| 106 | { | 111 | { |
| 107 | size_t len = 0; | 112 | size_t len = 0; |
diff --git a/tools/plistutil.c b/tools/plistutil.c index 1c199fe..4b83df3 100644 --- a/tools/plistutil.c +++ b/tools/plistutil.c | |||
| @@ -184,6 +184,11 @@ int main(int argc, char *argv[]) | |||
| 184 | return 0; | 184 | return 0; |
| 185 | } | 185 | } |
| 186 | 186 | ||
| 187 | if (options->flags & OPT_DEBUG) | ||
| 188 | { | ||
| 189 | plist_set_debug(1); | ||
| 190 | } | ||
| 191 | |||
| 187 | if (!options->in_file || !strcmp(options->in_file, "-")) | 192 | if (!options->in_file || !strcmp(options->in_file, "-")) |
| 188 | { | 193 | { |
| 189 | read_size = 0; | 194 | read_size = 0; |
