-/* -*- mode: C; c-file-style: "gnu" -*- */
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
/* dbus-address.c Server address parser.
*
* Copyright (C) 2003 CodeFactory AB
*
* 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
*
*/
(b) == '_' || \
(b) == '/' || \
(b) == '\\' || \
+ (b) == '*' || \
(b) == '.')
/**
}
/**
- * Returns the method string of an address entry.
+ * Returns the method string of an address entry. For example, given
+ * the address entry "tcp:host=example.com" it would return the string
+ * "tcp"
*
* @param entry the entry.
* @returns a string describing the method. This string
}
/**
- * Returns a value from a key of an entry.
+ * Returns a value from a key of an entry. For example,
+ * given the address "tcp:host=example.com,port=8073" if you asked
+ * for the key "host" you would get the value "example.com"
*
+ * The returned value is already unescaped.
+ *
* @param entry the entry.
* @param key the key.
* @returns the key value. This string must not be freed.
* method:key=value,key=value;method:key=value
*
* See the D-Bus specification for complete docs on the format.
+ *
+ * When connecting to an address, the first address entries
+ * in the semicolon-separated list should be tried first.
*
* @param address the address.
* @param entry return location to an array of entries.
entries = NULL;
pos = 0;
len = _dbus_string_get_length (&str);
+
+ if (len == 0)
+ {
+ dbus_set_error (error, DBUS_ERROR_BAD_ADDRESS,
+ "Empty address '%s'", address);
+ goto error;
+ }
while (pos < len)
{
/**
* Unescapes the given string as a value in a key=value pair
- * for a D-Bus address.
+ * for a D-Bus address. Note that dbus_address_entry_get_value()
+ * returns an already-unescaped value.
*
* @param value the escaped value
* @param error error to set if the unescaping fails
"%",
"$",
" ",
- "*"
};
dbus_bool_t
_dbus_address_test (void)
{
DBusAddressEntry **entries;
- int len;
- DBusError error;
+ int len;
+ DBusError error = DBUS_ERROR_INIT;
int i;
- dbus_error_init (&error);
-
i = 0;
while (i < _DBUS_N_ELEMENTS (escape_tests))
{
dbus_address_entries_free (entries);
/* Different possible errors */
+ if (dbus_parse_address ("", &entries, &len, &error))
+ _dbus_assert_not_reached ("Parsed incorrect address.");
+ else
+ dbus_error_free (&error);
+
if (dbus_parse_address ("foo", &entries, &len, &error))
_dbus_assert_not_reached ("Parsed incorrect address.");
else