summaryrefslogtreecommitdiffstats
path: root/dbus/dbus-string.c
diff options
context:
space:
mode:
authorHavoc Pennington <hp@redhat.com>2003-01-26 21:16:06 +0000
committerHavoc Pennington <hp@redhat.com>2003-01-26 21:16:06 +0000
commit2f440457d5fe45afb732820da64a147157e2e82d (patch)
tree82ed5d30be63cbbf9cdd9e993d789700c049d1bb /dbus/dbus-string.c
parent1d2478ae4f2da8869eab94ca455a1329230c179e (diff)
2003-01-26 Havoc Pennington <hp@pobox.com>
* dbus/dbus-message-builder.c: implement, completely untested. * test/data/*: add data to be used in testing. ".message" files are our simple loadable text format. ".message-raw" will be binary dumps of messages. * dbus/dbus-string.c (_dbus_string_starts_with_c_str): new
Diffstat (limited to 'dbus/dbus-string.c')
-rw-r--r--dbus/dbus-string.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/dbus/dbus-string.c b/dbus/dbus-string.c
index 0e9a94d2..ac84cda8 100644
--- a/dbus/dbus-string.c
+++ b/dbus/dbus-string.c
@@ -1369,6 +1369,41 @@ _dbus_string_equal_c_str (const DBusString *a,
return TRUE;
}
+/**
+ * Checks whether a string starts with the given C string.
+ *
+ * @param a the string
+ * @param c_str the C string
+ * @returns #TRUE if string starts with it
+ */
+dbus_bool_t
+_dbus_string_starts_with_c_str (const DBusString *a,
+ const char *c_str)
+{
+ const unsigned char *ap;
+ const unsigned char *bp;
+ const unsigned char *a_end;
+ const DBusRealString *real_a = (const DBusRealString*) a;
+ DBUS_GENERIC_STRING_PREAMBLE (real_a);
+
+ ap = real_a->str;
+ bp = (const unsigned char*) c_str;
+ a_end = real_a->str + real_a->len;
+ while (ap != a_end && *bp)
+ {
+ if (*ap != *bp)
+ return FALSE;
+
+ ++ap;
+ ++bp;
+ }
+
+ if (*bp == '\0')
+ return TRUE;
+ else
+ return FALSE;
+}
+
static const signed char base64_table[] = {
/* 0 */ 'A',
/* 1 */ 'B',