diff options
| author | 2023-04-16 16:06:11 +0200 | |
|---|---|---|
| committer | 2023-04-16 16:06:11 +0200 | |
| commit | 3aa5f6a3a663a5f2694ec6fc8cdf9744b616e15e (patch) | |
| tree | 9b071b9f041f80ab36a240b226af642cc0c19031 /tools/plistutil.c | |
| parent | bfc97788f081584ced9cd35d85b69b3fec6b907c (diff) | |
| download | libplist-3aa5f6a3a663a5f2694ec6fc8cdf9744b616e15e.tar.gz libplist-3aa5f6a3a663a5f2694ec6fc8cdf9744b616e15e.tar.bz2 | |
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.
Diffstat (limited to 'tools/plistutil.c')
| -rw-r--r-- | tools/plistutil.c | 16 |
1 files changed, 8 insertions, 8 deletions
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[]) | |||
| 115 | return NULL; | 115 | return NULL; |
| 116 | } | 116 | } |
| 117 | if (!strncmp(argv[i+1], "bin", 3)) { | 117 | if (!strncmp(argv[i+1], "bin", 3)) { |
| 118 | options->out_fmt = 1; | 118 | options->out_fmt = PLIST_FORMAT_BINARY; |
| 119 | } else if (!strncmp(argv[i+1], "xml", 3)) { | 119 | } else if (!strncmp(argv[i+1], "xml", 3)) { |
| 120 | options->out_fmt = 2; | 120 | options->out_fmt = PLIST_FORMAT_XML; |
| 121 | } else if (!strncmp(argv[i+1], "json", 4)) { | 121 | } else if (!strncmp(argv[i+1], "json", 4)) { |
| 122 | options->out_fmt = 3; | 122 | options->out_fmt = PLIST_FORMAT_JSON; |
| 123 | } else if (!strncmp(argv[i+1], "openstep", 8) || !strncmp(argv[i+1], "ostep", 5)) { | 123 | } else if (!strncmp(argv[i+1], "openstep", 8) || !strncmp(argv[i+1], "ostep", 5)) { |
| 124 | options->out_fmt = 4; | 124 | options->out_fmt = PLIST_FORMAT_OSTEP; |
| 125 | } else { | 125 | } else { |
| 126 | fprintf(stderr, "ERROR: Unsupported output format\n"); | 126 | fprintf(stderr, "ERROR: Unsupported output format\n"); |
| 127 | free(options); | 127 | free(options); |
| @@ -289,13 +289,13 @@ int main(int argc, char *argv[]) | |||
| 289 | if (options->flags & OPT_SORT) { | 289 | if (options->flags & OPT_SORT) { |
| 290 | plist_sort(root_node); | 290 | plist_sort(root_node); |
| 291 | } | 291 | } |
| 292 | if (options->out_fmt == 1) { | 292 | if (options->out_fmt == PLIST_FORMAT_BINARY) { |
| 293 | output_res = plist_to_bin(root_node, &plist_out, &size); | 293 | output_res = plist_to_bin(root_node, &plist_out, &size); |
| 294 | } else if (options->out_fmt == 2) { | 294 | } else if (options->out_fmt == PLIST_FORMAT_XML) { |
| 295 | output_res = plist_to_xml(root_node, &plist_out, &size); | 295 | output_res = plist_to_xml(root_node, &plist_out, &size); |
| 296 | } else if (options->out_fmt == 3) { | 296 | } else if (options->out_fmt == PLIST_FORMAT_JSON) { |
| 297 | output_res = plist_to_json(root_node, &plist_out, &size, !(options->flags & OPT_COMPACT)); | 297 | output_res = plist_to_json(root_node, &plist_out, &size, !(options->flags & OPT_COMPACT)); |
| 298 | } else if (options->out_fmt == 4) { | 298 | } else if (options->out_fmt == PLIST_FORMAT_OSTEP) { |
| 299 | output_res = plist_to_openstep(root_node, &plist_out, &size, !(options->flags & OPT_COMPACT)); | 299 | output_res = plist_to_openstep(root_node, &plist_out, &size, !(options->flags & OPT_COMPACT)); |
| 300 | } | 300 | } |
| 301 | } | 301 | } |
