summaryrefslogtreecommitdiffstats
path: root/dbus/dbus-message-builder.c
diff options
context:
space:
mode:
authorHavoc Pennington <hp@redhat.com>2003-02-13 00:08:18 +0000
committerHavoc Pennington <hp@redhat.com>2003-02-13 00:08:18 +0000
commit3791dcca16cb46b0ff7305beff75d1aa2645940c (patch)
tree2c758acd5d023a51baaad74fa539910123cdcd84 /dbus/dbus-message-builder.c
parent63e779e41ca09007af789fff90011860dc69f937 (diff)
2003-02-10 Havoc Pennington <hp@pobox.com>
* dbus/dbus-auth-script.c, dbus/dbus-auth-script.h: sync initial cut at test framework for DBusAuth from laptop. Doesn't quite work yet but it compiles and I need to get it off the 266mhz laptop. ;-) * dbus/dbus-server-debug.c (_dbus_server_debug_accept_transport): fix a memleak in error case
Diffstat (limited to 'dbus/dbus-message-builder.c')
-rw-r--r--dbus/dbus-message-builder.c96
1 files changed, 15 insertions, 81 deletions
diff --git a/dbus/dbus-message-builder.c b/dbus/dbus-message-builder.c
index 47313337..58c4430c 100644
--- a/dbus/dbus-message-builder.c
+++ b/dbus/dbus-message-builder.c
@@ -40,72 +40,6 @@
* @{
*/
-static dbus_bool_t
-pop_line (DBusString *source,
- DBusString *dest)
-{
- int eol;
- dbus_bool_t have_newline;
-
- _dbus_string_set_length (dest, 0);
-
- eol = 0;
- if (_dbus_string_find (source, 0, "\n", &eol))
- {
- have_newline = TRUE;
- eol += 1; /* include newline */
- }
- else
- {
- eol = _dbus_string_get_length (source);
- have_newline = FALSE;
- }
-
- if (eol == 0)
- return FALSE; /* eof */
-
- if (!_dbus_string_move_len (source, 0, eol,
- dest, 0))
- {
- _dbus_warn ("failed to pop line\n");
- return FALSE;
- }
-
- /* dump the newline */
- if (have_newline)
- {
- _dbus_assert (_dbus_string_get_length (dest) > 0);
- _dbus_string_set_length (dest,
- _dbus_string_get_length (dest) - 1);
- }
-
- return TRUE;
-}
-
-static void
-strip_command_name (DBusString *str)
-{
- int i;
-
- i = 0;
- if (_dbus_string_find_blank (str, 0, &i))
- _dbus_string_skip_blank (str, i, &i);
-
- _dbus_string_delete (str, 0, i);
-}
-
-static void
-strip_leading_space (DBusString *str)
-{
- int i;
-
- i = 0;
- _dbus_string_skip_blank (str, 0, &i);
-
- if (i > 0)
- _dbus_string_delete (str, 0, i);
-}
-
typedef struct
{
DBusString name;
@@ -394,7 +328,7 @@ _dbus_message_data_load (DBusString *dest,
const char *s;
_dbus_string_get_const_data (filename, &s);
_dbus_warn ("Getting contents of %s failed: %s\n",
- s, dbus_result_to_string (result));
+ s, dbus_result_to_string (result));
goto out;
}
@@ -409,14 +343,14 @@ _dbus_message_data_load (DBusString *dest,
unalign = FALSE;
line_no = 0;
next_iteration:
- while (pop_line (&file, &line))
+ while (_dbus_string_pop_line (&file, &line))
{
dbus_bool_t just_set_unalign;
just_set_unalign = FALSE;
line_no += 1;
- strip_leading_space (&line);
+ _dbus_string_delete_leading_blanks (&line);
if (_dbus_string_get_length (&line) == 0)
{
@@ -494,7 +428,7 @@ _dbus_message_data_load (DBusString *dest,
{
long val;
- strip_command_name (&line);
+ _dbus_string_delete_first_word (&line);
if (!_dbus_string_parse_int (&line, 0, &val, NULL))
{
@@ -525,7 +459,7 @@ _dbus_message_data_load (DBusString *dest,
* command, we segfault.
*/
- strip_command_name (&line);
+ _dbus_string_delete_first_word (&line);
if (!_dbus_string_parse_int (&line, 0, &val, NULL))
{
@@ -547,7 +481,7 @@ _dbus_message_data_load (DBusString *dest,
{
unsigned char the_byte;
- strip_command_name (&line);
+ _dbus_string_delete_first_word (&line);
if (_dbus_string_equal_c_str (&line, "'\\''"))
the_byte = '\'';
@@ -578,7 +512,7 @@ _dbus_message_data_load (DBusString *dest,
else if (_dbus_string_starts_with_c_str (&line,
"START_LENGTH"))
{
- strip_command_name (&line);
+ _dbus_string_delete_first_word (&line);
if (!save_start (length_hash, &line,
_dbus_string_get_length (dest)))
@@ -590,7 +524,7 @@ _dbus_message_data_load (DBusString *dest,
else if (_dbus_string_starts_with_c_str (&line,
"END_LENGTH"))
{
- strip_command_name (&line);
+ _dbus_string_delete_first_word (&line);
if (!save_length (length_hash, &line,
_dbus_string_get_length (dest)))
@@ -604,7 +538,7 @@ _dbus_message_data_load (DBusString *dest,
{
SAVE_FOR_UNALIGN (dest, 4);
- strip_command_name (&line);
+ _dbus_string_delete_first_word (&line);
if (!append_saved_length (dest, length_hash,
&line,
@@ -620,7 +554,7 @@ _dbus_message_data_load (DBusString *dest,
else if (_dbus_string_starts_with_c_str (&line,
"FIELD_NAME"))
{
- strip_command_name (&line);
+ _dbus_string_delete_first_word (&line);
if (_dbus_string_get_length (&line) != 4)
{
@@ -645,7 +579,7 @@ _dbus_message_data_load (DBusString *dest,
{
int code;
- strip_command_name (&line);
+ _dbus_string_delete_first_word (&line);
if (_dbus_string_starts_with_c_str (&line, "INVALID"))
code = DBUS_TYPE_INVALID;
@@ -689,7 +623,7 @@ _dbus_message_data_load (DBusString *dest,
SAVE_FOR_UNALIGN (dest, 4);
long val;
- strip_command_name (&line);
+ _dbus_string_delete_first_word (&line);
if (!_dbus_string_parse_int (&line, 0, &val, NULL))
{
@@ -712,7 +646,7 @@ _dbus_message_data_load (DBusString *dest,
SAVE_FOR_UNALIGN (dest, 4);
long val;
- strip_command_name (&line);
+ _dbus_string_delete_first_word (&line);
/* FIXME should have _dbus_string_parse_uint32 */
if (!_dbus_string_parse_int (&line, 0, &val, NULL))
@@ -733,7 +667,7 @@ _dbus_message_data_load (DBusString *dest,
SAVE_FOR_UNALIGN (dest, 8);
double val;
- strip_command_name (&line);
+ _dbus_string_delete_first_word (&line);
if (!_dbus_string_parse_double (&line, 0, &val, NULL))
goto parse_failed;
@@ -754,7 +688,7 @@ _dbus_message_data_load (DBusString *dest,
int size_offset;
int old_len;
- strip_command_name (&line);
+ _dbus_string_delete_first_word (&line);
size_offset = _dbus_string_get_length (dest);
size_offset = _DBUS_ALIGN_VALUE (size_offset, 4);