151 Commits

Author SHA1 Message Date
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 a7e82b8465 plist: make array and dict iterators opaque
Introduce private iterator structs for plist_array_iter and
plist_dict_iter, and fix *_next_item() to properly advance
iterator state and handle malformed containers safely.
2026-02-12 02:10:19 +01:00
Nikias Bassen e45099fb21 Prevent deep nesting of plist structures in all input/output formats
Thanks to @unbengable12 for reporting. Addresses #288, #289, #290, #291, and #292.
2026-01-17 16:04:00 +01:00
Nikias Bassen 5b3ae4c132 Add circular reference detection to all format writers
Thanks to @LkkkLxy for pointing out the issue.
2026-01-14 02:50:40 +01:00
Nikias Bassen cb76e4da84 Add plist_new_unix_date, plist_get_unix_date_val, plist_set_unix_date_val functions
These functions work with int64_t values representing a UNIX timestamp instead
of using the 'MAC epoch'. They should be used instead of plist_new_date,
plist_get_date_val, and plist_set_date_val, which are now marked deprecated
and might be removed in a future version of libplist.
2025-05-13 18:34:32 +02:00
guyingzhao d031e94d7a C++: Data: Add const char* constructor 2025-04-06 12:38:45 +02:00
guyingzhao 1aae1e5b7d C++: Add f/Front() and b/Back() to Array to access first/last element 2025-04-06 12:37:05 +02:00
guyingzhao 464382e6f8 C++: Dictionary: Update template definition for better readability 2025-04-06 12:27:40 +02:00
guyingzhao e6f3c6c621 C++: Array: Add const Node& variants to Append, Insert 2025-04-06 12:18:23 +02:00
Nikias Bassen ed8a73301b C++: Add = operator to String class 2025-04-06 11:48:14 +02:00
guyingzhao 31f1a810e5 C++: Add const char* constructor to String class 2025-04-06 11:44:13 +02:00
Nikias Bassen 8e310421ad C++: Add new Structure::FromMemory() 2025-04-06 11:36:18 +02:00
guyingzhao d40f03e409 C++: Add more convenience functions to the interface 2025-03-01 23:42:06 +01:00
guyingzhao 02be84957d C++: Fix String::GetValue memory leaking and suport assignment of const char* 2025-03-01 23:17:04 +01:00
Nikias Bassen 1327c87bf9 Revert "Change API around #PLIST_DATA to use uint8_t instead of char arrays"
This reverts commit a91f5740d1.
2024-05-13 19:38:22 +02:00
Nikias Bassen f8be42eaef Add PLIST_DICT convenience functions for different queries/operations 2024-04-18 10:18:17 +02:00
Nikias Bassen a91f5740d1 Change API around #PLIST_DATA to use uint8_t instead of char arrays
This makes it more obvious that it is arbitrary data and not necessarily
a string value.
2024-04-14 18:19:14 +02:00
Nikias Bassen 86c3ef2de8 docs: Use README.md to generate mainpage with doxygen
Actually we are using a slightly modified one that removes the
`Table of Contents` section and replaces it with the doxygen-compatible
`[TOC]` to auto-generate a TOC that has working links.
2024-02-21 01:01:00 +01:00
Nikias Bassen 082b69db5d Add a libplist_version() function to the interface 2024-02-05 11:47:06 +01:00
Nikias Bassen 3daee6097c Fix PLIST_API definitions 2024-01-29 10:45:41 +01:00
Nikias Bassen d772fd74d2 Add an explicit PLIST_FORMAT_NONE value 2023-05-20 17:32:34 +02:00
Nikias Bassen ff0010080b Windows: Use winsock2.h instead of sys/time.h when using MSVC 2023-05-13 20:23:19 +02:00
Nikias Bassen 91c0aa8fa8 Move PLIST_API to the headers 2023-05-13 19:53:26 +02:00
Nikias Bassen 954b3e44b7 Update doxygen config and document undocumented macros 2023-05-05 02:43:40 +02:00
Nikias Bassen 61f01b1b06 Add a PLIST_OPT_NONE value to plist_write_options_t 2023-04-24 13:35:56 +02:00
Nikias Bassen 7b94db8122 Remove unnecessary const to silence compiler warning 2023-04-21 15:44:20 +02:00
Nikias Bassen 8aeda7886c C++: Remove deprecated Insert() 2023-04-21 12:56:53 +02:00
Nikias Bassen 12c45a21b4 C++: Add dictionary and array size method
Thanks @Cryptiiiic for the contribution.
2023-04-21 12:16:55 +02:00
Nikias Bassen 3fdb111269 Remove deprecated plist_dict_insert_item() 2023-04-19 17:52:23 +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 bfc97788f0 Fix build without --enable-debug 2023-02-07 12:47:10 +01: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 706771e357 Add new plist_sort() function 2023-02-03 16:48:34 +01:00
Daniel c2f396a537 Add lowercase begin/end iterator functions
... for Dictionary and Array
2023-02-03 00:26:19 +01:00
Daniel cbb43d790d Add PList::Array iterator member functions
... returning both iterators and const_iterators:
* PList::Array::Begin()
* PList::Array::End()
2023-02-03 00:26:19 +01:00
Nikias Bassen d886885b0e Rename PLIST_UINT to PLIST_INT and add plist_new_int() and plist_get_int_val()
This properly supports getting and setting signed or unsigned integer values.
Also, a new helper function plist_int_val_is_negative() was added to determine if
a given #PLIST_INT node has a negative value or not.

The old type PLIST_UINT is defined as a macro with the value of PLIST_INT for
backwards compatibility.

This commit also adds int vs. uint support to the C++ interface, and the python
bindings in a hopefully useful way.
2023-01-16 04:25:52 +01:00
Nikias Bassen 60d291941f Add support for OpenStep plist format 2023-01-08 05:29:22 +01:00
Nikias Bassen 25e80940c5 docs: Fix parameter and type names for doxygen 2022-02-07 11:57:38 +01:00
Nikias Bassen 429cbc660a Add support for JSON format 2021-12-23 03:09:07 +01:00
Nikias Bassen 70f4a422e0 Add a return value to plist_to_* and plist_from_* functions
This way it can be easier determined why an import/export operation failed
instead of just having a NULL result.
2021-12-22 03:17:26 +01:00
Nikias Bassen 810e1a5936 Add support for PLIST_NULL type 2021-12-19 16:13:07 +01:00
Nikias Bassen c31beaaec1 Add new plist_mem_free() function
Thanks to @azerg for bringing this to my attention.

Instead of having multiple (internally identical) plist_*_free() functions,
this commit introduces a single plist_mem_free() that can be used to free
the memory allocated by plist_to_xml(), plist_to_bin(), plist_get_key_val(),
plist_get_string_val(), and plist_get_data_val().
Note: This commit REMOVES plist_to_bin_free() and plist_to_xml_free().
2021-12-19 02:43:36 +01:00
Rosen Penev 8c7e258e80 [clang-tidy] cpp: Turn reference operators to const
Found with cppcoreguidelines-c-copy-assignment-signature

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2021-06-22 01:18:28 +02:00
Martin Szulecki c14849987d Unfold automake variables into multiple lines for maintainability 2020-06-09 18:19:07 +02:00
Rosen Penev 68dc3f5642 c++: Fix inconsistent declarations
Signed-off-by: Rosen Penev <rosenp@gmail.com>
2020-06-03 19:58:18 +02:00
Nikias Bassen 303924413f Add plist_*_val_compare, plist_*_val_contains, etc. for the respective node types
... except container node types like PLIST_ARRAY or PLIST_DICT.
2020-05-11 04:32:22 +02:00
Nikias Bassen 49cbc8df76 Add plist_get_data_ptr() and plist_get_string_ptr() to the interface 2019-11-07 04:54:45 +01:00
Nikias Bassen 4d4586903b Add plist_to_bin_free() and plist_to_xml_free() functions that free memory allocated by plist_to_bin()/plist_to_xml() 2019-11-07 02:59:05 +01:00