summaryrefslogtreecommitdiff
path: root/dbus/dbus-string-util.c
Commit message (Collapse)AuthorAgeFilesLines
* Add SPDX license marker for the AFL-2.1 OR GPL-2.0-or-later licenseRalf Habacker2023-01-041-0/+2
| | | | | | | | | The full license texts are not added because they were already added in a previous commit. Signed-off-by: Ralf Habacker <ralf.habacker@freenet.de> see #394
* test: Move string tests (most of dbus-string-util.c) hereSimon McVittie2019-01-211-845/+8
| | | | Signed-off-by: Simon McVittie <smcv@collabora.com>
* embedded tests: Conform to the same API for all testsSimon McVittie2018-12-171-1/+1
| | | | | | | | | This will make it possible to unify the wrapper code that runs them. I'm using a plain C string rather than a DBusString to make it more straightforward to carve out tests into their own executables. Signed-off-by: Simon McVittie <smcv@collabora.com>
* trivial: Remove trailing whitespace from copyright noticesSimon McVittie2018-12-171-3/+3
| | | | | | | | | | | | | | We don't usually mass-remove trailing whitespace from the actual source code because it would complicate cherry-picking bug fixes to older branches, but that reasoning doesn't really apply to the comments containing copyright and licensing notices. Removing trailing whitespace makes it much easier to move code around: we have a commit hook that rejects commits containing trailing whitespace, but that commit hook counts moving a file as a delete + add pair, so it objects to moving code that contains trailing whitespace. Signed-off-by: Simon McVittie <smcv@collabora.com>
* DBusString: Add _DBUS_STRING_INIT_INVALID and allow "freeing" itSimon McVittie2017-11-241-1/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This means we can finally use patterns like this: DBusString buffer = _DBUS_STRING_INIT_INVALID; dbus_bool_t ret = FALSE; ... some long setup ... if (!_dbus_string_init (&buffer)) goto out; ... some long operation ... ret = TRUE; out: ... free things ... _dbus_string_free (&buffer); ... free more things ... return ret; without having to have a separate boolean to track whether buffer has been initialized. One observable difference is that if s is a "const" (borrowed pointer) string, _dbus_string_free (&s) now sets it to be invalid. Previously, it would have kept its (borrowed pointer) contents, which seems like a violation of least-astonishment. Signed-off-by: Simon McVittie <smcv@collabora.com> Reviewed-by: Philip Withnall <withnall@endlessm.com> Bug: https://bugs.freedesktop.org/show_bug.cgi?id=89104
* DBusString: Reverse the sense of ->invalidSimon McVittie2017-11-241-1/+1
| | | | | | | | | | It's easier to implement a stack-allocated string that is valid to free (but for no other purpose) if we consider all-bits-zero to be invalid. Signed-off-by: Simon McVittie <smcv@collabora.com> Reviewed-by: Philip Withnall <withnall@endlessm.com> Bug: https://bugs.freedesktop.org/show_bug.cgi?id=89104
* Prefer to use _dbus_test_fatal() for assertion failures in testsSimon McVittie2017-11-151-141/+140
| | | | | | | | | | | | This is a little more self-documenting - it justifies why it's acceptable to fail hard on out-of-memory conditions. _dbus_test_fatal() isn't compiled unless we are compiling embedded tests, so compiling with embedded tests disabled provides reasonable confidence that we aren't using _dbus_test_fatal() inappropriately. Reviewed-by: Philip Withnall <withnall@endlessm.com> Signed-off-by: Simon McVittie <smcv@collabora.com> Bug: https://bugs.freedesktop.org/show_bug.cgi?id=103601
* Embedded tests: Emit TAP diagnostics instead of printfSimon McVittie2017-11-151-4/+6
| | | | | | Reviewed-by: Philip Withnall <withnall@endlessm.com> Signed-off-by: Simon McVittie <smcv@collabora.com> Bug: https://bugs.freedesktop.org/show_bug.cgi?id=103601
* tests: Assert that _DBUS_STRING_DEFINE_STATIC looks as expectedSimon McVittie2017-11-071-0/+12
| | | | | | Signed-off-by: Simon McVittie <smcv@collabora.com> Reviewed-by: Philip Withnall <withnall@endlessm.com> Bug: https://bugs.freedesktop.org/show_bug.cgi?id=89104
* Remove trailing newlines from _dbus_assert_not_reachedSimon McVittie2016-08-121-2/+2
| | | | | | | | This was never necessary: _dbus_assert_not_reached() always added one. Signed-off-by: Simon McVittie <smcv@debian.org> Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de> Bug: https://bugs.freedesktop.org/show_bug.cgi?id=97009
* Fix several -Wpointer-sign warnings in test_hex_roundtrip() and related types.Ralf Habacker2015-11-231-6/+6
| | | | | Bug: https://bugs.freedesktop.org/show_bug.cgi?id=93069 Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
* tests to embedded tests: replaced in libdbusChengwei Yang2013-06-281-2/+2
| | | | | | Signed-off-by: Chengwei Yang <chengwei.yang@intel.com> Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk> Bug: https://bugs.freedesktop.org/show_bug.cgi?id=66291
* _dbus_string_append_double, _dbus_string_parse_double: removeSimon McVittie2012-02-131-17/+0
| | | | | | | | They're unused, except by their own regression tests. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=39759 Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk> Reviewed-by: Lennart Poettering <lennart@poettering.net>
* _dbus_string_append_unichar, _dbus_string_get_unichar: removeSimon McVittie2012-02-131-17/+0
| | | | | | | | | These are unused (except by their regression test!) and not visible to external callers. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=39759 Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk> Reviewed-by: Lennart Poettering <lennart@poettering.net>
* Remove maximum length field from DBusStringSimon McVittie2011-06-221-55/+0
| | | | | | | | | | | | The source code says it's "a historical artifact from a feature that turned out to be dumb". Respond accordingly! This reduces sizeof (DBusString) by 20% on ILP32 architectures, which can't hurt. (No reduction on LP64 architectures that align pointers naturally, unfortunately.) Bug: https://bugs.freedesktop.org/show_bug.cgi?id=38570 Reviewed-by: Will Thompson <will.thompson@collabora.co.uk>
* Improved dbus_string_replace_len()Roberto Guido2011-02-181-2/+86
| | | | | | Reviewed-by: Havoc Pennington <hp@pobox.com> Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk> Bug: https://bugs.freedesktop.org/show_bug.cgi?id=21261
* Consistently include <config.h> in all C source files and never in header files.Marcus Brinkmann2010-03-191-0/+1
|
* _dbus_string_toupper_ascii(): new function, reviewed by Colin Walters.Ralf Habacker2010-02-281-0/+32
|
* _dbus_string_tolower_ascii(): new function, reviewed by Colin Walters.Ralf Habacker2010-02-281-1/+33
|
* Bug 21161 - Update the FSF addressTobias Mueller2009-07-101-1/+1
| | | | | | No comment. Signed-off-by: Colin Walters <walters@verbum.org>
* Add new function _dbus_string_split_on_byteRay Strode2008-07-111-0/+25
| | | | | It allows you to turn a string like KEY=VALUE into two strings key and value.
* Add support for compacting DBusStrings to release wasted memory.Ryan Lortie2007-09-201-0/+56
| | | | | | | | | | | | | | | | | 2007-09-19 Ryan Lortie <desrt@desrt.ca> * dbus/dbus-string.[ch] (compact, _dbus_string_compact, _dbus_string_lock): new compact function to free up allocated memory that is no longer used. * dbus/dbus-message.c (load_message): call _dbus_string_compact on the message loader buffer. * dbus/dbus-transport-socket.c (do_reading, do_writing): call _dbus_string_compact on the incoming/outgoing "encoded" buffers. * dbus/dbus-string-util.c (_dbus_string_test): add a few tests for string compacting.
* 2007-07-13 Havoc Pennington <hp@redhat.com>Havoc Pennington2007-07-141-1/+1
| | | | * Add indent-tabs-mode: nil to all file headers.
* 2007-06-09 Havoc Pennington <hp@redhat.com>Havoc Pennington2007-06-101-31/+81
| | | | | | | | | | | | | | | | | * dbus/dbus-string.c (_dbus_string_pop_line): fix this not to think an empty line is the end of the file. Also, fix some whitespace. * dbus/dbus-string-util.c: add more tests for _dbus_string_pop_line() revealing that it thinks an empty line is the end of the file, which broke dbus-auth-script.c so it didn't really run the scripts * dbus/dbus-auth.c: add ANONYMOUS mechanism * dbus/dbus-auth-script.c (_dbus_auth_script_run): fix to detect an empty/no-op auth script; add commands to check that we have or don't have the expected credentials
* * dbus/dbus-string.[ch] (_dbus_string_find_eol): new function.Ralf Habacker2006-12-121-0/+38
| | | | | | * dbus/dbus-string-util.c (_dbus_string_test): added testcases for _dbus_string_find_eol(). Approved by: Havoc Pennington.
* 2006-09-30 Havoc Pennington <hp@redhat.com>Havoc Pennington2006-10-011-37/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * configure.in (LT_CURRENT, LT_AGE): increment current and age to reflect addition of interfaces. * doc/dbus-specification.xml: describe a new org.freedesktop.DBus.Peer.GetMachineId method * dbus/dbus-string.c (_dbus_string_skip_white_reverse): new function (_dbus_string_skip_white, _dbus_string_skip_blank): use new DBUS_IS_ASCII_BLANK, DBUS_IS_ASCII_WHITE macros and fix assertion at end of skip_white (_dbus_string_chop_white): new function * bus/connection.c (bus_connections_setup_connection): call dbus_connection_set_route_peer_messages. * dbus/dbus-connection.c (_dbus_connection_peer_filter_unlocked_no_update): modify to support a GetMachineId method. Also, support a new flag to let the bus pass peer methods through to apps on the bus, which can be set with dbus_connection_set_route_peer_messages. Finally, handle and return an error for anything unknown on the Peer interface, which will allow us to extend the Peer interface in the future without fear that we're now intercepting something apps were wanting to see. * tools/dbus-uuidgen.c: a thin wrapper around the functions in dbus/dbus-uuidgen.c * dbus/dbus-uuidgen.c: implement the bulk of the dbus-uuidgen binary here, since most of the code is already in libdbus * dbus/dbus-sysdeps.c (_dbus_read_local_machine_uuid): read the uuid from the system config file * dbus/dbus-internals.c (_dbus_generate_uuid, _dbus_uuid_encode) (_dbus_read_uuid_file_without_creating) (_dbus_create_uuid_file_exclusively, _dbus_read_uuid_file): new uuid-related functions, partly factored out from dbus-server.c * dbus/dbus-sysdeps.c (_dbus_error_from_errno): convert EEXIST to DBUS_ERROR_FILE_EXISTS instead of EEXIST * dbus/dbus-protocol.h (DBUS_ERROR_FILE_EXISTS): add file exists error * tools/dbus-cleanup-sockets.1: explain what the point of this thing is a bit more * autogen.sh (run_configure): add --config-cache to default configure args * dbus/dbus-internals.h (_DBUS_ASSERT_ERROR_IS_SET): disable the error set/clear assertions when DBUS_DISABLE_CHECKS is defined * tools/dbus-launch.c (main): if xdisplay hasn't been opened, don't try to save address, fixes crash in make check
* 2005-02-25 Havoc Pennington <hp@redhat.com>Havoc Pennington2005-02-251-24/+0
| | | | | | | | | | | | | | | | | | | | | | | | * doc/dbus-specification.xml: document the GUID thing * dbus/dbus-server.c (_dbus_server_init_base): initialize a globally unique ID for the server, and put a "guid=hexencoded" field in the address * dbus/dbus-bus.c: fix missing #include of dbus-threads-internal.h * dbus/dbus-message.c: ditto * dbus/dbus-dataslot.c: ditto * dbus/dbus-list.c: ditto * dbus/dbus-internals.h: wait, just include dbus-threads-internal.h here * dbus/dbus-string.c (_dbus_string_copy_to_buffer): move back for use in main library * dbus/dbus-sysdeps.c (_dbus_generate_random_bytes_buffer): new function
* 2005-02-05 Havoc Pennington <hp@redhat.com>Havoc Pennington2005-02-061-0/+43
| | | | | | | | | | | | | | | | | * dbus/dbus-message-factory.c (generate_special): more test cases, increasing coverage * dbus/dbus-marshal-validate.c (validate_body_helper): return the reason why a signature was invalid * dbus/dbus-marshal-header.c (load_and_validate_field): fix to skip the length of the string before we look at it in validation * dbus/dbus-string-util.c (_dbus_string_test): add tests for equal_substring * dbus/dbus-message.c (_dbus_message_loader_new): default max_message_length to DBUS_MAXIMUM_MESSAGE_LENGTH
* 2005-01-16 Havoc Pennington <hp@redhat.com>Havoc Pennington2005-01-171-0/+727
This is about it on what can be disabled/deleted from libdbus easily, back below 150K anyhow. Deeper cuts are more work than just turning the code off as I've done here. * dbus/dbus-marshal-basic.c (_dbus_pack_int32): we don't need the signed int convenience funcs * dbus/dbus-internals.c (_dbus_verbose_real): omit when not in verbose mode * dbus/dbus-string-util.c, dbus/dbus-string.c: more breaking things out of libdbus * dbus/dbus-sysdeps.c, dbus/dbus-sysdeps-util.c: same * dbus/dbus-hash.c: purge the TWO_STRINGS crap (well, make it tests-enabled-only, though it should probably be deleted) * dbus/dbus-message-util.c: same stuff * dbus/dbus-auth-util.c: same stuff