Up to [cvs.NetBSD.org] / src / common / lib / libprop
Request diff between arbitrary revisions
Keyword substitution: kv
Default branch: MAIN
proplib: Nix trailing whitespace.
Fix a paste-o that caused prop_data_create_copy() to be intolerant of creating empty data objects. Fixes t_ifconfig::ifconfig_description unit test.
Improvements to the problib(3) API: ==> Provide a much more complete set of setters and getters for different value types in the prop_array_util(3) and prop_dictionary_util(3) functions. ==> Overhaul the prop_data(3), prop_number(3), and prop_string(3) APIs to be easier to use and less awkwardly named, Deprecate the old awkward names, and produce link-time warnings when they are referenced. ==> Deprecate mutable prop_data(3) and prop_string(3) objects. The old APIs that support them still exist, but will now produce link-time warnings when used. ==> When the new prop_string(3) API is used, strings are internally de-duplicated as a memory footprint optimization. ==> Provide a rich set of bounds-checked gettter functions in and a corresponding set of convenience setters in the prop_number(3) API. ==> Add a new prop_bool_value(3) function that is equivalent to prop_bool_true(3), but aligned with the new "value" routines in prop_data(3), prop_string(3), and prop_number(3).
Ooops, restore accidently removed files from merge mishap
Sync with HEAD
Sync with HEAD
Fix building libprop as a host tool library on platforms that don't have the Matt Thomas rbtree: - Include rb.c in libnbcompat, and provide a nbcompat sys/rbtree.h header. - Make sure libprop's source file include prop_object_impl.h before anything else, and pull in nbtool_config.h from there. Tested by simulating such a host system by renaming the host's <sys/rbtree.h> out of the way (which reproduced the build failure) and verifying that the host-tool installboot contained the rb_* functions in its own .text segment.
Pull up following revision(s) (requested by cyber in ticket #316): common/lib/libprop/prop_data.c: revision 1.14 Properly handle empty data nodes (such as generated by Apple's plist editor). They are in the form of <data></data>, whereas the original code path only checked for empty being <data/>. This causes an assert to be triggered when trying to access the node's content. Patch reviewed by thorpej.
Properly handle empty data nodes (such as generated by Apple's plist editor). They are in the form of <data></data>, whereas the original code path only checked for empty being <data/>. This causes an assert to be triggered when trying to access the node's content. Patch reviewed by thorpej.
Pull up following revision(s) (requested by tsutsui in ticket #1224): common/lib/libc/gen/bswap64.c: revision 1.2 common/lib/libprop/prop_data.c: revision 1.10 common/lib/libc/inet/inet_addr.c: revision 1.2 common/lib/libc/hash/rmd160/rmd160.c: revision 1.4 common/lib/libc/gen/bswap32.c: revision 1.2 common/lib/libc/gen/bswap16.c: revision 1.2 common/lib/libc/arch/alpha/gen/byte_swap_4.S: revision 1.3 common/lib/libc/arch/sh3/string/memset.S: revision 1.2 common/lib/libc/arch/alpha/gen/byte_swap_2.S: revision 1.3 common/lib/libc/md/md5c.c: revision 1.3 common/lib/libc/hash/sha1/sha1.c: revision 1.3 common/lib/libc/md/md4c.c: revision 1.3 sys/sys/rmd160.h: revision 1.2 sys/sys/sha2.h: revision 1.2 For all files under src/common, as well as related man pages under src/lib/libc, or related headers under src/sys/sys: change u_intNN_t to uintNN_t.
Sync with wrstuden-revivesa-base-2.
Fix an issue introduced with the prop_stack change: It's not a good idea to return a 3-value enum from a function declared to return bool. This broke the recurse case for prop_object_equals(). Instead, declare the object type equals routine to return a _prop_object_equals_rv_t. Give the same treatment to the object type free routines: declare them to return a _prop_object_free_rv_t, and consistently check those return values againt the enum type. Tidy up some whitespace while we're here.
Sync w/ -current. 34 merge conflicts to follow.
sync with head.
In prop_data_create_data(blob, len), if len == 0, allocate no memory for blob, and leave pd_mutable set to NULL. In this way, avoid tripping over the assertion in prop_data_data_nocopy().
Remove clause 3 and 4 from TNF licenses
sync with HEAD
For all files under src/common, as well as related man pages under src/lib/libc, or related headers under src/sys/sys: change u_intNN_t to uintNN_t.
sync with HEAD
Catch up on netbsd-4 as of a few days ago.
Pull up following revision(s) (requested by joerg in ticket #904): sbin/veriexecctl/veriexecctl.c: revision 1.29 (via patch) common/lib/libprop/prop_string.c: revision 1.9 (via patch) distrib/sets/lists/comp/mi: revision 1.1063 (via patch) common/lib/libprop/prop_kern.c: revision 1.8 (via patch) common/include/prop/prop_string.h: revision 1.2 (via patch) common/include/prop/prop_ingest.h: revision 1.2 (via patch) usr.sbin/btdevctl/btdevctl.c: revision 1.5 (via patch) common/lib/libprop/prop_object_impl.h: revision 1.14 (via patch) common/lib/libprop/prop_rb.c: revision 1.7 (via patch) common/include/prop/prop_array.h: revision 1.5 (via patch) common/lib/libprop/prop_stack.h: revision 1.1 (via patch) common/lib/libprop/prop_object_impl.h: revision 1.16 (via patch) common/lib/libprop/prop_number.3: revision 1.7 (via patch) common/lib/libprop/prop_stack.h: revision 1.2 (via patch) common/lib/libprop/prop_stack.c: revision 1.1 (via patch) common/lib/libprop/prop_object_impl.h: revision 1.17 (via patch) common/lib/libprop/prop_dictionary_util.c: revision 1.2 (via patch) common/lib/libprop/prop_dictionary_util.3: revision 1.2 (via patch) common/lib/libprop/prop_dictionary.c: revision 1.18 (via patch) common/lib/libprop/prop_stack.c: revision 1.2 (via patch) common/lib/libprop/prop_object_impl.h: revision 1.18 (via patch) common/lib/libprop/prop_dictionary.c: revision 1.19 (via patch) common/include/prop/prop_bool.h: revision 1.3 (via patch) common/include/prop/prop_dictionary.h: revision 1.7 (via patch) common/include/prop/prop_data.h: revision 1.2 (via patch) sys/sys/dkio.h: revision 1.14 (via patch) usr.sbin/btdevctl/sdp.c: revision 1.4 (via patch) common/include/prop/Makefile: revision 1.3 (via patch) common/include/prop/prop_number.h: revision 1.5 (via patch) common/lib/libprop/prop_object.c: revision 1.14 (via patch) common/lib/libprop/prop_object.c: revision 1.15 (via patch) common/lib/libprop/prop_object.c: revision 1.16 (via patch) common/lib/libprop/prop_bool.3: revision 1.3 (via patch) common/lib/libprop/prop_data.3: revision 1.4 (via patch) common/lib/libprop/prop_object.3: revision 1.6 (via patch) common/lib/libprop/prop_data.c: revision 1.7 (via patch) common/lib/libprop/prop_data.c: revision 1.8 (via patch) common/lib/libprop/prop_data.c: revision 1.9 (via patch) common/lib/libprop/prop_dictionary.c: revision 1.20 (via patch) usr.sbin/btdevctl/print.c: revision 1.9 (via patch) sbin/veriexecctl/veriexecctl_parse.y: revision 1.22 (via patch) common/lib/libprop/prop_number.c: revision 1.12 (via patch) common/include/prop/proplib.h: revision 1.5 (via patch) common/lib/libprop/prop_number.c: revision 1.13 (via patch) common/lib/libprop/prop_number.c: revision 1.14 (via patch) common/include/prop/prop_object.h: revision 1.5 (via patch) common/lib/libprop/prop_array.3: revision 1.5 (via patch) common/include/prop/prop_object.h: revision 1.6 (via patch) common/lib/libprop/prop_string.3: revision 1.4 (via patch) common/lib/libprop/prop_bool.c: revision 1.10 (via patch) common/lib/libprop/Makefile.inc: revision 1.6 (via patch) common/lib/libprop/prop_ingest.c: revision 1.2 (via patch) common/lib/libprop/prop_bool.c: revision 1.11 (via patch) common/lib/libprop/prop_array.c: revision 1.10 (via patch) common/lib/libprop/prop_ingest.3: revision 1.3 (via patch) common/lib/libprop/prop_bool.c: revision 1.12 (via patch) common/lib/libprop/prop_array.c: revision 1.11 (via patch) common/lib/libprop/prop_string.c: revision 1.7 (via patch) common/lib/libprop/prop_dictionary.3: revision 1.8 (via patch) common/lib/libprop/prop_array.c: revision 1.9 (via patch) usr.sbin/btdevctl/db.c: revision 1.4 (via patch) common/lib/libprop/prop_string.c: revision 1.8 (via patch) common/include/prop/plistref.h: revision 1.1 (via patch) Consider '\r' to be white space. Discussed with and also kept as local change by freza. With this change, DOS style line endings work. boolean_t -> bool TRUE -> true FALSE -> false libprop is currently using a recursive parser. While this is fine for userland, deeply nested arrays and dictionaries can easily overflow the kernel stack and thereby force a panic. Fix the internalizer and prop_object_release to use a separate call stack and alter the dictionary and array handling to not recurse on the C stack. The default stack has an inline depth of 16 elements, which should keep the overhead reasonable. This issue was found by Pavel Cahyna and Jachym Holecek. Additionally add a limit for prop_object_copyin_ioctl to prevent user programs from temporary allocating unbound amount of kernel memory. Allow malloc to fail so that tight loops of userland processes can't force panics by exhausting the kernel map. Tested with the sample exploit of Jachym, his test suite and reviewed by himself (initial patch), Christos Zoulas and Jason Thorpe. struct plistref does not reference other proplib data types, so split it in its own header file to be included by dkio.h. Fixes breakage due to pollution from proplib.h in programs which include ioctl.h. Tested and OK by dogcow@. Attempt at fixing build failures after proplib was converted to bool: FALSE -> false, TRUE -> true, boolean_t -> bool, int -> bool when appropriate, include stdbool.h . proplib.h no longer provides boolean_t, so it is necessary to change to bool. From Tom Spindler (dogcow@). Avoid using unbound amount of stack frames in prop_object_equal by using a dynamic stack as well. Reorder arguments for the internalizer as the iteration is always present and should go before possibly NULL arguments. Reviewed by mjf@ and adrianp@
Avoid using unbound amount of stack frames in prop_object_equal by using a dynamic stack as well. Reorder arguments for the internalizer as the iteration is always present and should go before possibly NULL arguments. Reviewed by mjf@ and adrianp@
libprop is currently using a recursive parser. While this is fine for userland, deeply nested arrays and dictionaries can easily overflow the kernel stack and thereby force a panic. Fix the internalizer and prop_object_release to use a separate call stack and alter the dictionary and array handling to not recurse on the C stack. The default stack has an inline depth of 16 elements, which should keep the overhead reasonable. This issue was found by Pavel Cahyna and Jachym Holecek. Additionally add a limit for prop_object_copyin_ioctl to prevent user programs from temporary allocating unbound amount of kernel memory. Allow malloc to fail so that tight loops of userland processes can't force panics by exhausting the kernel map. Tested with the sample exploit of Jachym, his test suite and reviewed by himself (initial patch), Christos Zoulas and Jason Thorpe.
boolean_t -> bool TRUE -> true FALSE -> false
Fix white space skipping before closing tag when padding characters are present. Okayed by thorpej.
Add casts to apease lint.
file prop_data.c was added on branch newlock2 on 2006-10-18 14:41:09 +0000
Add casts to apease lint.
Pull up following revision(s) (requested by thorpej in ticket #51): common/lib/libprop/prop_dictionary.c: revision 1.11 common/lib/libprop/prop_number.c: revision 1.5 common/lib/libprop/prop_bool.c: revision 1.5 common/lib/libprop/prop_data.c: revision 1.4 common/lib/libprop/prop_string.c: revision 1.4 common/lib/libprop/prop_array.c: revision 1.6 Also guard object accessors against NULL (like we do foreign object types) so that apps can use this construct safely: obj = prop_dictionary_get(dict, "value"); if (! prop_number_equals_integer(obj, 5)) { ... } Suggested by Iain Hibbert.
Pull up following revision(s) (requested by thorpej in ticket #43): common/include/prop/prop_ingest.h: revision 1.1 common/lib/libprop/prop_number.c: revision 1.4 common/include/prop/prop_array.h: revision 1.3 common/lib/libprop/prop_object_impl.h: revision 1.4 common/include/prop/prop_dictionary.h: revision 1.4 distrib/sets/lists/comp/mi: revision 1.911 common/include/prop/Makefile: revision 1.2 common/lib/libprop/prop_bool.c: revision 1.4 distrib/sets/lists/base/shl.mi: revision 1.365 common/lib/libprop/prop_data.c: revision 1.3 lib/libprop/shlib_version: revision 1.4 lib/libprop/Makefile: revision 1.6 common/lib/libprop/prop_object.c: revision 1.4 common/lib/libprop/prop_object.3: revision 1.4 common/include/prop/proplib.h: revision 1.3 common/lib/libprop/Makefile.inc: revision 1.3 common/include/prop/prop_object.h: revision 1.4 common/lib/libprop/prop_array.c: revision 1.4 common/lib/libprop/prop_array.3: revision 1.4 common/lib/libprop/prop_string.c: revision 1.3 common/lib/libprop/prop_dictionary.3: revision 1.4 common/lib/libprop/prop_ingest.c: revision 1.1 common/lib/libprop/prop_ingest.3: revision 1.1 common/lib/libprop/prop_dictionary.c: revision 1.9 Several changes to proplib: - Arrays can now be externalized and internalized in the same way dictionaries can. - Add new "externalize to file" and "internalize from file" functions to make reading a property list from a file and writing a property list to a file more convenient. - Many assertions in the object implementations are gone. Instead, calling an accessor for one object type with a different object type as an argument will return a suitable "invalid" value. - prop_object_type() now returns a new PROP_TYPE_UNKNOWN value if called with a NULL object. - Externalized property lists now contain a reference to the Apple XML plist DTD. - Add a new prop_ingest(3) facility, which provides a convenient way to translate a dictionary into an arbitrary binary representation.
Also guard object accessors against NULL (like we do foreign object types) so that apps can use this construct safely: obj = prop_dictionary_get(dict, "value"); if (! prop_number_equals_integer(obj, 5)) { ... } Suggested by Iain Hibbert.
Several changes to proplib: - Arrays can now be externalized and internalized in the same way dictionaries can. - Add new "externalize to file" and "internalize from file" functions to make reading a property list from a file and writing a property list to a file more convenient. - Many assertions in the object implementations are gone. Instead, calling an accessor for one object type with a different object type as an argument will return a suitable "invalid" value. - prop_object_type() now returns a new PROP_TYPE_UNKNOWN value if called with a NULL object. - Externalized property lists now contain a reference to the Apple XML plist DTD. - Add a new prop_ingest(3) facility, which provides a convenient way to translate a dictionary into an arbitrary binary representation.
- Add prop_array_equals(), prop_dictionary_equals(), and prop_dictionary_keysym_equals(), and prop_object_equals() functions. - Use realloc() where it makes sense. There will be more changes in this area. - Add a _prop_object_type structure that is used internally to keep information about the object types. Decreases the footprint of the objects slightly by replacing several pointers with just one.
Initial commit of proplib, a library for manipulating property lists and converting to/from an XML external representation (based on Apple XML property lists). Works in the kernel and user space.