D-Bus 1.6.12
|
00001 /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */ 00002 /* dbus-string-private.h String utility class (internal to D-Bus implementation) 00003 * 00004 * Copyright (C) 2002, 2003 Red Hat, Inc. 00005 * 00006 * Licensed under the Academic Free License version 2.1 00007 * 00008 * This program is free software; you can redistribute it and/or modify 00009 * it under the terms of the GNU General Public License as published by 00010 * the Free Software Foundation; either version 2 of the License, or 00011 * (at your option) any later version. 00012 * 00013 * This program is distributed in the hope that it will be useful, 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 * GNU General Public License for more details. 00017 * 00018 * You should have received a copy of the GNU General Public License 00019 * along with this program; if not, write to the Free Software 00020 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00021 * 00022 */ 00023 00024 #ifndef DBUS_STRING_PRIVATE_H 00025 #define DBUS_STRING_PRIVATE_H 00026 00027 #include <dbus/dbus-internals.h> 00028 #include <dbus/dbus-memory.h> 00029 #include <dbus/dbus-types.h> 00030 00031 #ifndef DBUS_CAN_USE_DBUS_STRING_PRIVATE 00032 #error "Don't go including dbus-string-private.h for no good reason" 00033 #endif 00034 00035 DBUS_BEGIN_DECLS 00036 00043 typedef struct 00044 { 00045 unsigned char *str; 00046 int len; 00047 int allocated; 00048 unsigned int constant : 1; 00049 unsigned int locked : 1; 00050 unsigned int invalid : 1; 00051 unsigned int align_offset : 3; 00052 } DBusRealString; 00053 00054 _DBUS_STATIC_ASSERT (sizeof (DBusRealString) == sizeof (DBusString)); 00055 00069 #define _DBUS_STRING_MAX_LENGTH (_DBUS_INT32_MAX - _DBUS_STRING_ALLOCATION_PADDING) 00070 00076 #define DBUS_GENERIC_STRING_PREAMBLE(real) \ 00077 do { \ 00078 (void) real; /* might be unused unless asserting */ \ 00079 _dbus_assert ((real) != NULL); \ 00080 _dbus_assert (!(real)->invalid); \ 00081 _dbus_assert ((real)->len >= 0); \ 00082 _dbus_assert ((real)->allocated >= 0); \ 00083 _dbus_assert ((real)->len <= ((real)->allocated - _DBUS_STRING_ALLOCATION_PADDING)); \ 00084 _dbus_assert ((real)->len <= _DBUS_STRING_MAX_LENGTH); \ 00085 } while (0) 00086 00093 #define DBUS_STRING_PREAMBLE(str) DBusRealString *real = (DBusRealString*) str; \ 00094 DBUS_GENERIC_STRING_PREAMBLE (real); \ 00095 _dbus_assert (!(real)->constant); \ 00096 _dbus_assert (!(real)->locked) 00097 00105 #define DBUS_LOCKED_STRING_PREAMBLE(str) DBusRealString *real = (DBusRealString*) str; \ 00106 DBUS_GENERIC_STRING_PREAMBLE (real); \ 00107 _dbus_assert (!(real)->constant) 00108 00114 #define DBUS_CONST_STRING_PREAMBLE(str) const DBusRealString *real = (DBusRealString*) str; \ 00115 DBUS_GENERIC_STRING_PREAMBLE (real) 00116 00121 #define DBUS_IS_ASCII_BLANK(c) ((c) == ' ' || (c) == '\t') 00122 00127 #define DBUS_IS_ASCII_WHITE(c) ((c) == ' ' || (c) == '\t' || (c) == '\n' || (c) == '\r') 00128 00131 DBUS_END_DECLS 00132 00133 #endif /* DBUS_STRING_PRIVATE_H */