summaryrefslogtreecommitdiffstats
path: root/dbus/dbus-address.c
diff options
context:
space:
mode:
authorHavoc Pennington <hp@redhat.com>2006-09-16 19:24:08 +0000
committerHavoc Pennington <hp@redhat.com>2006-09-16 19:24:08 +0000
commitfe4715b656237b89767b5dc0cba4c107541b6e0d (patch)
tree8defca3126803c37043110e7edb81dfa5476fceb /dbus/dbus-address.c
parente001455a0300cc1df17684a028049c8c33e4f575 (diff)
2006-09-16 Havoc Pennington <hp@redhat.com>
* dbus/dbus-transport.c (_dbus_transport_open): modify to delegate to _dbus_transport_open_platform_specific, _dbus_transport_open_socket, and _dbus_transport_open_debug_pipe * dbus/dbus-transport-protected.h: add _dbus_transport_open_platform_specific
Diffstat (limited to 'dbus/dbus-address.c')
-rw-r--r--dbus/dbus-address.c133
1 files changed, 75 insertions, 58 deletions
diff --git a/dbus/dbus-address.c b/dbus/dbus-address.c
index 7dc33e3e..c6354f14 100644
--- a/dbus/dbus-address.c
+++ b/dbus/dbus-address.c
@@ -48,6 +48,81 @@ struct DBusAddressEntry
DBusList *values; /**< List of values */
};
+
+void
+_dbus_set_bad_address (DBusError *error,
+ const char *address_problem_type,
+ const char *address_problem_field,
+ const char *address_problem_other)
+{
+ if (address_problem_type != NULL)
+ dbus_set_error (error, DBUS_ERROR_BAD_ADDRESS,
+ "Server address of type %s was missing argument %s",
+ address_problem_type, address_problem_field);
+ else
+ dbus_set_error (error, DBUS_ERROR_BAD_ADDRESS,
+ "Could not parse server address: %s",
+ address_problem_other);
+}
+
+#define _DBUS_ADDRESS_OPTIONALLY_ESCAPED_BYTE(b) \
+ (((b) >= 'a' && (b) <= 'z') || \
+ ((b) >= 'A' && (b) <= 'Z') || \
+ ((b) >= '0' && (b) <= '9') || \
+ (b) == '-' || \
+ (b) == '_' || \
+ (b) == '/' || \
+ (b) == '\\' || \
+ (b) == '.')
+
+/**
+ * Appends an escaped version of one string to another string,
+ * using the D-Bus address escaping mechanism
+ *
+ * @param escaped the string to append to
+ * @param unescaped the string to escape
+ * @returns #FALSE if no memory
+ */
+dbus_bool_t
+_dbus_address_append_escaped (DBusString *escaped,
+ const DBusString *unescaped)
+{
+ const char *p;
+ const char *end;
+ dbus_bool_t ret;
+ int orig_len;
+
+ ret = FALSE;
+
+ orig_len = _dbus_string_get_length (escaped);
+ p = _dbus_string_get_const_data (unescaped);
+ end = p + _dbus_string_get_length (unescaped);
+ while (p != end)
+ {
+ if (_DBUS_ADDRESS_OPTIONALLY_ESCAPED_BYTE (*p))
+ {
+ if (!_dbus_string_append_byte (escaped, *p))
+ goto out;
+ }
+ else
+ {
+ if (!_dbus_string_append_byte (escaped, '%'))
+ goto out;
+ if (!_dbus_string_append_byte_as_hex (escaped, *p))
+ goto out;
+ }
+
+ ++p;
+ }
+
+ ret = TRUE;
+
+ out:
+ if (!ret)
+ _dbus_string_set_length (escaped, orig_len);
+ return ret;
+}
+
/** @} */ /* End of internals */
static void
@@ -165,64 +240,6 @@ dbus_address_entry_get_value (DBusAddressEntry *entry,
return NULL;
}
-#define _DBUS_ADDRESS_OPTIONALLY_ESCAPED_BYTE(b) \
- (((b) >= 'a' && (b) <= 'z') || \
- ((b) >= 'A' && (b) <= 'Z') || \
- ((b) >= '0' && (b) <= '9') || \
- (b) == '-' || \
- (b) == '_' || \
- (b) == '/' || \
- (b) == '\\' || \
- (b) == '.')
-
-/**
- * Appends an escaped version of one string to another string,
- * using the D-Bus address escaping mechanism
- *
- * @param escaped the string to append to
- * @param unescaped the string to escape
- * @returns #FALSE if no memory
- */
-dbus_bool_t
-_dbus_address_append_escaped (DBusString *escaped,
- const DBusString *unescaped)
-{
- const char *p;
- const char *end;
- dbus_bool_t ret;
- int orig_len;
-
- ret = FALSE;
-
- orig_len = _dbus_string_get_length (escaped);
- p = _dbus_string_get_const_data (unescaped);
- end = p + _dbus_string_get_length (unescaped);
- while (p != end)
- {
- if (_DBUS_ADDRESS_OPTIONALLY_ESCAPED_BYTE (*p))
- {
- if (!_dbus_string_append_byte (escaped, *p))
- goto out;
- }
- else
- {
- if (!_dbus_string_append_byte (escaped, '%'))
- goto out;
- if (!_dbus_string_append_byte_as_hex (escaped, *p))
- goto out;
- }
-
- ++p;
- }
-
- ret = TRUE;
-
- out:
- if (!ret)
- _dbus_string_set_length (escaped, orig_len);
- return ret;
-}
-
static dbus_bool_t
append_unescaped_value (DBusString *unescaped,
const DBusString *escaped,