X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dbus%2Fdbus-string-private.h;h=2e6de900fdc95e7278abe18b163cb13079cd26d9;hb=04c58b9e5fbdf3acc7565f989e5fcd11f0c23c57;hp=d26aabe1d7193f74df00349516934a6724b45e32;hpb=3ed9db546e1143bc9aa2d83a6f423fdd81227352;p=platform%2Fupstream%2Fdbus.git diff --git a/dbus/dbus-string-private.h b/dbus/dbus-string-private.h index d26aabe..2e6de90 100644 --- a/dbus/dbus-string-private.h +++ b/dbus/dbus-string-private.h @@ -1,5 +1,5 @@ -/* -*- mode: C; c-file-style: "gnu" -*- */ -/* dbus-string-private.h String utility class (internal to D-BUS implementation) +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */ +/* dbus-string-private.h String utility class (internal to D-Bus implementation) * * Copyright (C) 2002, 2003 Red Hat, Inc. * @@ -17,15 +17,14 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * */ #ifndef DBUS_STRING_PRIVATE_H #define DBUS_STRING_PRIVATE_H -#include - +#include #include #include @@ -46,13 +45,13 @@ typedef struct unsigned char *str; /**< String data, plus nul termination */ int len; /**< Length without nul */ int allocated; /**< Allocated size of data */ - int max_length; /**< Max length of this string, without nul byte */ unsigned int constant : 1; /**< String data is not owned by DBusString */ unsigned int locked : 1; /**< DBusString has been locked and can't be changed */ unsigned int invalid : 1; /**< DBusString is invalid (e.g. already freed) */ unsigned int align_offset : 3; /**< str - align_offset is the actual malloc block */ } DBusRealString; +_DBUS_STATIC_ASSERT (sizeof (DBusRealString) == sizeof (DBusString)); /** * @defgroup DBusStringInternals DBusString implementation details @@ -65,17 +64,25 @@ typedef struct */ /** - * This is the maximum max length (and thus also the maximum length) - * of a DBusString + * The maximum length of a DBusString */ -#define _DBUS_STRING_MAX_MAX_LENGTH (_DBUS_INT32_MAX - _DBUS_STRING_ALLOCATION_PADDING) +#define _DBUS_STRING_MAX_LENGTH (_DBUS_INT32_MAX - _DBUS_STRING_ALLOCATION_PADDING) /** * Checks a bunch of assertions about a string object * * @param real the DBusRealString */ -#define DBUS_GENERIC_STRING_PREAMBLE(real) _dbus_assert ((real) != NULL); _dbus_assert (!(real)->invalid); _dbus_assert ((real)->len >= 0); _dbus_assert ((real)->allocated >= 0); _dbus_assert ((real)->max_length >= 0); _dbus_assert ((real)->len <= ((real)->allocated - _DBUS_STRING_ALLOCATION_PADDING)); _dbus_assert ((real)->len <= (real)->max_length) +#define DBUS_GENERIC_STRING_PREAMBLE(real) \ + do { \ + (void) real; /* might be unused unless asserting */ \ + _dbus_assert ((real) != NULL); \ + _dbus_assert (!(real)->invalid); \ + _dbus_assert ((real)->len >= 0); \ + _dbus_assert ((real)->allocated >= 0); \ + _dbus_assert ((real)->len <= ((real)->allocated - _DBUS_STRING_ALLOCATION_PADDING)); \ + _dbus_assert ((real)->len <= _DBUS_STRING_MAX_LENGTH); \ + } while (0) /** * Checks assertions about a string object that needs to be @@ -107,6 +114,18 @@ typedef struct #define DBUS_CONST_STRING_PREAMBLE(str) const DBusRealString *real = (DBusRealString*) str; \ DBUS_GENERIC_STRING_PREAMBLE (real) +/** + * Checks for ASCII blank byte + * @param c the byte + */ +#define DBUS_IS_ASCII_BLANK(c) ((c) == ' ' || (c) == '\t') + +/** + * Checks for ASCII whitespace byte + * @param c the byte + */ +#define DBUS_IS_ASCII_WHITE(c) ((c) == ' ' || (c) == '\t' || (c) == '\n' || (c) == '\r') + /** @} */ DBUS_END_DECLS