summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2023-02-07 11:43:04 +0100
committerGravatar Nikias Bassen2023-02-07 11:43:04 +0100
commitfe1b22723868b038c4d0b84d9582edcdd888af97 (patch)
tree7db408f97a23c3283eebf1e02caec03bfab9c614
parent6390abcd1c94f4c29291c81322726d6946fd345f (diff)
downloadlibplist-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.h7
-rw-r--r--src/bplist.c5
-rw-r--r--src/jplist.c5
-rw-r--r--src/oplist.c5
-rw-r--r--src/plist.c13
-rw-r--r--src/xplist.c5
-rw-r--r--tools/plistutil.c5
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"
*/
void plist_mem_free(void* ptr);
+ /**
+ * Set debug level for the format parsers.
+ *
+ * @param debug Debug level. Currently, only 0 (off) and 1 (enabled) are supported.
+ */
+ void plist_set_debug(int debug);
+
/*@}*/
#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)
/* deinit binary plist stuff */
}
+void plist_bin_set_debug(int debug)
+{
+ plist_bin_debug = debug;
+}
+
static plist_t parse_bin_node_at_index(struct bplist_data *bplist, uint32_t node_index);
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)
/* deinit JSON stuff */
}
+void plist_json_set_debug(int debug)
+{
+ plist_json_debug = debug;
+}
+
#ifndef HAVE_STRNDUP
static char* strndup(const char* str, size_t len)
{
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)
/* deinit OpenStep plist stuff */
}
+void plist_ostep_set_debug(int debug)
+{
+ plist_ostep_debug = debug;
+}
+
#ifndef HAVE_STRNDUP
static char* strndup(const char* str, size_t len)
{
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
return (memmem(data->buff, data->length, cmpval, n) != NULL);
}
+extern void plist_xml_set_debug(int debug);
+extern void plist_bin_set_debug(int debug);
+extern void plist_json_set_debug(int debug);
+extern void plist_ostep_set_debug(int debug);
+
+PLIST_API void plist_set_debug(int debug)
+{
+ plist_xml_set_debug(debug);
+ plist_bin_set_debug(debug);
+ plist_json_set_debug(debug);
+ plist_ostep_set_debug(debug);
+}
+
PLIST_API void plist_sort(plist_t plist)
{
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)
/* deinit XML stuff */
}
+void plist_xml_set_debug(int debug)
+{
+ plist_xml_debug = debug;
+}
+
static size_t dtostr(char *buf, size_t bufsize, double realval)
{
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[])
return 0;
}
+ if (options->flags & OPT_DEBUG)
+ {
+ plist_set_debug(1);
+ }
+
if (!options->in_file || !strcmp(options->in_file, "-"))
{
read_size = 0;