45 Commits

Author SHA1 Message Date
Nikias Bassen 9dfcfe8dc2 Fix fread() unused return values by actually handling errors 2026-04-10 12:21:17 +02:00
Nikias Bassen c8b36a80ba Add OpenStep coercion support for non-OpenStep plist types
- Use PLIST_OPT_COERCE option to coerce PLIST_BOOLEAN, PLIST_DATE, PLIST_UID, and PLIST_NULL to OpenStep-compatible types (1 or 0, ISO 8601 strings, integers, and 'NULL' string)
- Add plist_to_openstep_with_options() function to allow passing coercion option (and others)
- Update plist_write_to_string() and plist_write_to_stream() accordingly
2026-03-22 19:16:51 +01:00
Calil Khalil 3edac28498 Add JSON coercion support for non-JSON plist types
- Add PLIST_OPT_COERCE option to coerce PLIST_DATE, PLIST_DATA, and PLIST_UID to JSON-compatible types (ISO 8601 strings, Base64 strings, and integers)
- Add plist_to_json_with_options() function to allow passing coercion options (and others)
- Update plist_write_to_string() and plist_write_to_stream() to support coercion option
- Add --coerce flag to plistutil for JSON output
- Create plist2json symlink that automatically enables coercion when invoked
2026-03-20 17:12:47 +01:00
Nikias Bassen 3bdee70a9c plistutil: Read STDIN in chunks instead of 1 byte at a time 2026-02-20 05:17:32 +01:00
Nikias Bassen e3d5bbdf1f plistutil: Add a --nodepath option to allow selecting a specific node 2026-02-20 03:38:36 +01:00
Nikias Bassen 30132a9e2c plistutil: Use getopt for solid option parsing 2026-02-20 02:32:19 +01:00
Nikias Bassen 57664f6394 plistutil: Make sure to check for memory allocation failure
Addresses #302.

Credit to @ylwango613.
2026-01-23 16:35:54 +01:00
Nikias Bassen 001a59eef3 plistutil: Use proper error description for new error codes 2026-01-17 16:35:19 +01:00
Nikias Bassen 438f01bad1 plistutil: (partially) Fix processing extremely large files
Thanks to @ylwango613 for reporting.
2025-10-29 16:50:38 +01:00
Nikias Bassen e3ca6af2c5 configure: Allow building the library without tool(s) 2024-12-03 02:28:15 +01:00
Duncan Ogilvie 6eff9eb548 Use listplist_version function instead of PACKAGE_VERSION in plistutil 2024-11-28 16:47:57 +01:00
Duncan Ogilvie b611aa62b8 Fix compilation on MSVC 2024-11-28 15:39:51 +01:00
Nikias Bassen 4af7c9accb plistutil: Add -p command line switch to print plist in human-readable format 2023-04-21 13:48:29 +02:00
Nikias Bassen ce9ce43efd Add plist_read_from_file() to interface, update plist_from_memory()
plist_read_from_file() is a convenience function that will open a
given file, checks its size, allocates a buffer large enough to
hold the full contents, and reads from file to fill the buffer.
Then, it calls plist_from_memory() to convert the data to plist
format.
A (breaking) change had to be made so that plist_from_memory() will
also return the parsed format in its 4th argument (if non-NULL).
2023-04-19 17:49:07 +02:00
Nikias Bassen 3aa5f6a3a6 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.
2023-04-16 16:06:11 +02:00
Nikias Bassen fe1b227238 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
2023-02-07 11:43:04 +01:00
Nikias Bassen 6390abcd1c plistutil: Add command line switch to allow sorting of the output plist 2023-02-06 18:57:40 +01:00
Nikias Bassen 60d291941f Add support for OpenStep plist format 2023-01-08 05:29:22 +01:00
Nikias Bassen 6fcecd0226 plistutil: Make sure the input buffer is 0-terminated in all code paths 2022-01-31 03:32:57 +01:00
Nikias Bassen 0a5f1cc10b plistutil: Check return values from plist API to print proper error messages
and return a meaningful exit code.
2021-12-23 14:14:24 +01:00
Nikias Bassen 429cbc660a Add support for JSON format 2021-12-23 03:09:07 +01:00
Nikias Bassen 501f8c86eb plistutil: Fix stdin input buffer reallocation 2021-02-06 03:25:37 +01:00
Rosen Penev af9b59e6a1 Replace malloc + memset with calloc where appropriate
calloc is faster for big allocations. It's also simpler.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2021-01-25 16:20:57 +01:00
Rosen Penev 85ede33a22 Improve code readability by using explicit != 0 compare when using strncmp
[clang-tidy] Found with bugprone-suspicious-string-compare

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2020-11-24 01:15:12 +01:00
Nikias Bassen eff97404bd Add API version to library and pkgconfig file for proper linking 2020-06-14 23:18:39 +02:00
Martin Szulecki c14849987d Unfold automake variables into multiple lines for maintainability 2020-06-09 18:19:07 +02:00
Nikias Bassen 07edc82d87 plistutil: Update copyright header 2020-06-05 17:08:46 +02:00
Nikias Bassen d417d386f8 plistutil: Add new "--version" option to output version information 2020-06-05 17:07:14 +02:00
Nikias Bassen e64fbba33a plistutil: Fix option parsing 2020-06-05 17:06:39 +02:00
Martin Szulecki d237e7125a Unify plistutil usage output with other tools and add project URLs 2020-06-04 02:30:40 +02:00
Martin Szulecki 4a33d60335 Add config.h include to plistutil.c 2020-06-04 02:29:27 +02:00
Martin Szulecki ff4fc77a81 Replace tabs with correct space indentation in plistutil.c 2020-06-04 02:28:07 +02:00
Nikias Bassen 517a4f93b7 plistutil: Improve usage text alignment 2020-05-24 16:48:42 +02:00
Jaywalker 56d6e1212a plistutil: Added ability to specify output format 2020-05-24 07:54:46 -05:00
Jaywalker d975256447 plistutil: Added ability for files to be read from stdin 2020-05-24 07:54:09 -05:00
Nikias Bassen eb92931938 plistutil: Print error message when opening input/output file fails and plug memory leaks on error 2017-02-07 02:17:55 +01:00
Nikias Bassen b32194d96e plistutil: Use plist_is_binary() to check for binary plist data 2017-01-18 15:46:27 +01:00
Nikias Bassen 7391a50635 plistutil: Prevent OOB heap buffer read by checking input size
As pointed out in #87 plistutil would do a memcmp with a heap buffer
without checking the size. If the size is less than 8 it would read
beyond the bounds of this heap buffer. This commit prevents that.
2017-01-18 15:44:51 +01:00
Nikias Bassen 2731ec0c47 plistutil: Plug some memory leaks 2015-01-29 00:29:31 +01:00
Nikias Bassen 6693241784 plistutil: Use static buffer for stat() 2015-01-29 00:26:59 +01:00
Martin Szulecki 8ed89366e4 plistutil: Improve error message for a human if input file reading failed 2015-01-23 15:01:17 +01:00
Martin Szulecki 7f28d8f757 plistutil: Cleanup code style a bit and remove obsolete extra header 2015-01-23 15:00:25 +01:00
Martin Szulecki f4caa6a751 Update and correct some copyright header comments 2015-01-23 14:58:16 +01:00
Martin Szulecki 6dcc8c48bb Replace some LDADD references to use $(top_builddir) for distcheck 2014-02-13 18:56:35 +01:00
Nikias Bassen a798afc8b5 change build system to autotools 2013-12-13 00:44:17 +01:00