From 3aa5f6a3a663a5f2694ec6fc8cdf9744b616e15e Mon Sep 17 00:00:00 2001 From: Nikias Bassen Date: Sun, 16 Apr 2023 16:06:11 +0200 Subject: Add new output-only formats and Define constants for the different plist formats This commit introduces constants for the different plist formats, and adds 3 new human-readable output-only formats: - PLIST_FORMAT_PRINT: the default human-readable format - PLIST_FORMAT_LIMD: "libimobiledevice" format (used in ideviceinfo) - PLIST_FORMAT_PLUTIL: plutil-style format Also, a new set of write functions has been added: - plist_write_to_string - plist_write_to_stream - plist_write_to_file Plus a simple "dump" function: - plist_print See documentation for details. --- tools/plistutil.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'tools') diff --git a/tools/plistutil.c b/tools/plistutil.c index 4b83df3..e339b8b 100644 --- a/tools/plistutil.c +++ b/tools/plistutil.c @@ -115,13 +115,13 @@ static options_t *parse_arguments(int argc, char *argv[]) return NULL; } if (!strncmp(argv[i+1], "bin", 3)) { - options->out_fmt = 1; + options->out_fmt = PLIST_FORMAT_BINARY; } else if (!strncmp(argv[i+1], "xml", 3)) { - options->out_fmt = 2; + options->out_fmt = PLIST_FORMAT_XML; } else if (!strncmp(argv[i+1], "json", 4)) { - options->out_fmt = 3; + options->out_fmt = PLIST_FORMAT_JSON; } else if (!strncmp(argv[i+1], "openstep", 8) || !strncmp(argv[i+1], "ostep", 5)) { - options->out_fmt = 4; + options->out_fmt = PLIST_FORMAT_OSTEP; } else { fprintf(stderr, "ERROR: Unsupported output format\n"); free(options); @@ -289,13 +289,13 @@ int main(int argc, char *argv[]) if (options->flags & OPT_SORT) { plist_sort(root_node); } - if (options->out_fmt == 1) { + if (options->out_fmt == PLIST_FORMAT_BINARY) { output_res = plist_to_bin(root_node, &plist_out, &size); - } else if (options->out_fmt == 2) { + } else if (options->out_fmt == PLIST_FORMAT_XML) { output_res = plist_to_xml(root_node, &plist_out, &size); - } else if (options->out_fmt == 3) { + } else if (options->out_fmt == PLIST_FORMAT_JSON) { output_res = plist_to_json(root_node, &plist_out, &size, !(options->flags & OPT_COMPACT)); - } else if (options->out_fmt == 4) { + } else if (options->out_fmt == PLIST_FORMAT_OSTEP) { output_res = plist_to_openstep(root_node, &plist_out, &size, !(options->flags & OPT_COMPACT)); } } -- cgit v1.1-32-gdbae