summaryrefslogtreecommitdiffstats
path: root/dbus/dbus-sysdeps.c
diff options
context:
space:
mode:
authorHavoc Pennington <hp@redhat.com>2005-01-17 01:20:02 +0000
committerHavoc Pennington <hp@redhat.com>2005-01-17 01:20:02 +0000
commit4c1a2a760b67b4600db3e5b9c2ad0056b5cf32b6 (patch)
tree391cea651b377e1ff09f5a45ee4e8dbdd25dc1ef /dbus/dbus-sysdeps.c
parentaad6fa897f85486386b030847151cb09943c97c0 (diff)
2005-01-16 Havoc Pennington <hp@redhat.com>
* dbus/dbus-userdb-util.c: split out part of dbus-userdb.c * dbus/dbus-sysdeps.c (_dbus_uid_from_string): move here to pave way for stripping down dbus-userdb.c stuff included in libdbus. Rename _dbus_parse_uid for consistency.
Diffstat (limited to 'dbus/dbus-sysdeps.c')
-rw-r--r--dbus/dbus-sysdeps.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/dbus/dbus-sysdeps.c b/dbus/dbus-sysdeps.c
index 5547d6c6..049c63ab 100644
--- a/dbus/dbus-sysdeps.c
+++ b/dbus/dbus-sysdeps.c
@@ -3014,4 +3014,47 @@ _dbus_print_backtrace (void)
}
#endif /* asserts or tests enabled */
+
+/**
+ * Gets a UID from a UID string.
+ *
+ * @param uid_str the UID in string form
+ * @param uid UID to fill in
+ * @returns #TRUE if successfully filled in UID
+ */
+dbus_bool_t
+_dbus_parse_uid (const DBusString *uid_str,
+ dbus_uid_t *uid)
+{
+ int end;
+ long val;
+
+ if (_dbus_string_get_length (uid_str) == 0)
+ {
+ _dbus_verbose ("UID string was zero length\n");
+ return FALSE;
+ }
+
+ val = -1;
+ end = 0;
+ if (!_dbus_string_parse_int (uid_str, 0, &val,
+ &end))
+ {
+ _dbus_verbose ("could not parse string as a UID\n");
+ return FALSE;
+ }
+
+ if (end != _dbus_string_get_length (uid_str))
+ {
+ _dbus_verbose ("string contained trailing stuff after UID\n");
+ return FALSE;
+ }
+
+ *uid = val;
+
+ return TRUE;
+}
+
/** @} end of sysdeps */
+
+/* tests in dbus-sysdeps-util.c */