WvStreams
|
00001 /* -*- mode: C; c-file-style: "gnu" -*- */ 00002 /* dbus-marshal-validate.h Validation routines for marshaled data 00003 * 00004 * Copyright (C) 2005 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00021 * 00022 */ 00023 00024 #ifndef DBUS_MARSHAL_VALIDATE_H 00025 #define DBUS_MARSHAL_VALIDATE_H 00026 00027 #include "config.h" 00028 00029 #ifndef PACKAGE 00030 #error "config.h not included here" 00031 #endif 00032 00036 typedef enum 00037 { 00038 DBUS_VALIDATION_MODE_WE_TRUST_THIS_DATA_ABSOLUTELY, 00039 DBUS_VALIDATION_MODE_DATA_IS_UNTRUSTED 00040 } DBusValidationMode; 00041 00049 typedef enum 00050 { 00051 #define _DBUS_NEGATIVE_VALIDITY_COUNT 4 00052 DBUS_VALIDITY_UNKNOWN_OOM_ERROR = -4, 00053 DBUS_INVALID_FOR_UNKNOWN_REASON = -3, 00054 DBUS_VALID_BUT_INCOMPLETE = -2, 00055 DBUS_VALIDITY_UNKNOWN = -1, 00056 DBUS_VALID = 0, 00057 DBUS_INVALID_UNKNOWN_TYPECODE = 1, 00058 DBUS_INVALID_MISSING_ARRAY_ELEMENT_TYPE = 2, 00059 DBUS_INVALID_SIGNATURE_TOO_LONG = 3, /* this one is impossible right now since 00060 * you can't put a too-long value in a byte 00061 */ 00062 DBUS_INVALID_EXCEEDED_MAXIMUM_ARRAY_RECURSION = 4, 00063 DBUS_INVALID_EXCEEDED_MAXIMUM_STRUCT_RECURSION = 5, 00064 DBUS_INVALID_STRUCT_ENDED_BUT_NOT_STARTED = 6, 00065 DBUS_INVALID_STRUCT_STARTED_BUT_NOT_ENDED = 7, 00066 DBUS_INVALID_STRUCT_HAS_NO_FIELDS = 8, 00067 DBUS_INVALID_ALIGNMENT_PADDING_NOT_NUL = 9, 00068 DBUS_INVALID_BOOLEAN_NOT_ZERO_OR_ONE = 10, 00069 DBUS_INVALID_NOT_ENOUGH_DATA = 11, 00070 DBUS_INVALID_TOO_MUCH_DATA = 12, 00071 DBUS_INVALID_BAD_BYTE_ORDER = 13, 00072 DBUS_INVALID_BAD_PROTOCOL_VERSION = 14, 00073 DBUS_INVALID_BAD_MESSAGE_TYPE = 15, 00074 DBUS_INVALID_BAD_SERIAL = 16, 00075 DBUS_INVALID_INSANE_FIELDS_ARRAY_LENGTH = 17, 00076 DBUS_INVALID_INSANE_BODY_LENGTH = 18, 00077 DBUS_INVALID_MESSAGE_TOO_LONG = 19, 00078 DBUS_INVALID_HEADER_FIELD_CODE = 20, 00079 DBUS_INVALID_HEADER_FIELD_HAS_WRONG_TYPE = 21, 00080 DBUS_INVALID_USES_LOCAL_INTERFACE = 22, 00081 DBUS_INVALID_USES_LOCAL_PATH = 23, 00082 DBUS_INVALID_HEADER_FIELD_APPEARS_TWICE = 24, 00083 DBUS_INVALID_BAD_DESTINATION = 25, 00084 DBUS_INVALID_BAD_INTERFACE = 26, 00085 DBUS_INVALID_BAD_MEMBER = 27, 00086 DBUS_INVALID_BAD_ERROR_NAME = 28, 00087 DBUS_INVALID_BAD_SENDER = 29, 00088 DBUS_INVALID_MISSING_PATH = 30, 00089 DBUS_INVALID_MISSING_INTERFACE = 31, 00090 DBUS_INVALID_MISSING_MEMBER = 32, 00091 DBUS_INVALID_MISSING_ERROR_NAME = 33, 00092 DBUS_INVALID_MISSING_REPLY_SERIAL = 34, 00093 DBUS_INVALID_LENGTH_OUT_OF_BOUNDS = 35, 00094 DBUS_INVALID_ARRAY_LENGTH_EXCEEDS_MAXIMUM = 36, 00095 DBUS_INVALID_BAD_PATH = 37, 00096 DBUS_INVALID_SIGNATURE_LENGTH_OUT_OF_BOUNDS = 38, 00097 DBUS_INVALID_BAD_UTF8_IN_STRING = 39, 00098 DBUS_INVALID_ARRAY_LENGTH_INCORRECT = 40, 00099 DBUS_INVALID_VARIANT_SIGNATURE_LENGTH_OUT_OF_BOUNDS = 41, 00100 DBUS_INVALID_VARIANT_SIGNATURE_BAD = 42, 00101 DBUS_INVALID_VARIANT_SIGNATURE_EMPTY = 43, 00102 DBUS_INVALID_VARIANT_SIGNATURE_SPECIFIES_MULTIPLE_VALUES = 44, 00103 DBUS_INVALID_VARIANT_SIGNATURE_MISSING_NUL = 45, 00104 DBUS_INVALID_STRING_MISSING_NUL = 46, 00105 DBUS_INVALID_SIGNATURE_MISSING_NUL = 47, 00106 DBUS_INVALID_EXCEEDED_MAXIMUM_DICT_ENTRY_RECURSION = 48, 00107 DBUS_INVALID_DICT_ENTRY_ENDED_BUT_NOT_STARTED = 49, 00108 DBUS_INVALID_DICT_ENTRY_STARTED_BUT_NOT_ENDED = 50, 00109 DBUS_INVALID_DICT_ENTRY_HAS_NO_FIELDS = 51, 00110 DBUS_INVALID_DICT_ENTRY_HAS_ONLY_ONE_FIELD = 52, 00111 DBUS_INVALID_DICT_ENTRY_HAS_TOO_MANY_FIELDS = 53, 00112 DBUS_INVALID_DICT_ENTRY_NOT_INSIDE_ARRAY = 54, 00113 DBUS_INVALID_DICT_KEY_MUST_BE_BASIC_TYPE = 55, 00114 DBUS_VALIDITY_LAST 00115 } DBusValidity; 00116 00117 DBusValidity _dbus_validate_signature_with_reason (const DBusString *type_str, 00118 int type_pos, 00119 int len); 00120 DBusValidity _dbus_validate_body_with_reason (const DBusString *expected_signature, 00121 int expected_signature_start, 00122 int byte_order, 00123 int *bytes_remaining, 00124 const DBusString *value_str, 00125 int value_pos, 00126 int len); 00127 00128 dbus_bool_t _dbus_validate_path (const DBusString *str, 00129 int start, 00130 int len); 00131 dbus_bool_t _dbus_validate_interface (const DBusString *str, 00132 int start, 00133 int len); 00134 dbus_bool_t _dbus_validate_member (const DBusString *str, 00135 int start, 00136 int len); 00137 dbus_bool_t _dbus_validate_error_name (const DBusString *str, 00138 int start, 00139 int len); 00140 dbus_bool_t _dbus_validate_bus_name (const DBusString *str, 00141 int start, 00142 int len); 00143 dbus_bool_t _dbus_validate_signature (const DBusString *str, 00144 int start, 00145 int len); 00146 00147 #ifdef DBUS_DISABLE_CHECKS 00148 00149 /* Be sure they don't exist, since we don't want to use them outside of checks 00150 * and so we want the compile failure. 00151 */ 00152 #define DECLARE_DBUS_NAME_CHECK(what) 00153 #define DEFINE_DBUS_NAME_CHECK(what) 00154 00155 #else /* !DBUS_DISABLE_CHECKS */ 00156 00160 #define DECLARE_DBUS_NAME_CHECK(what) \ 00161 dbus_bool_t _dbus_check_is_valid_##what (const char *name) 00162 00165 #define DEFINE_DBUS_NAME_CHECK(what) \ 00166 dbus_bool_t \ 00167 _dbus_check_is_valid_##what (const char *name) \ 00168 { \ 00169 DBusString str; \ 00170 \ 00171 if (name == NULL) \ 00172 return FALSE; \ 00173 \ 00174 _dbus_string_init_const (&str, name); \ 00175 return _dbus_validate_##what (&str, 0, \ 00176 _dbus_string_get_length (&str)); \ 00177 } 00178 #endif /* !DBUS_DISABLE_CHECKS */ 00179 00180 DECLARE_DBUS_NAME_CHECK(path); 00181 DECLARE_DBUS_NAME_CHECK(interface); 00182 DECLARE_DBUS_NAME_CHECK(member); 00183 DECLARE_DBUS_NAME_CHECK(error_name); 00184 DECLARE_DBUS_NAME_CHECK(bus_name); 00185 DECLARE_DBUS_NAME_CHECK(signature); 00186 00187 #endif /* DBUS_MARSHAL_VALIDATE_H */