Logo Search packages:      
Sourcecode: dbus version File versions

dbus_bool_t dbus_message_append_args_valist ( DBusMessage message,
int  first_arg_type,
va_list  var_args 
)

This function takes a va_list for use by language bindings. It's otherwise the same as dbus_message_append_args().

Todo:
: Shouldn't this function clean up the changes to the message on failures? (Yes)
See also:
dbus_message_append_args.
Parameters:
message the message
first_arg_type type of first argument
var_args value of first argument, then list of type/value pairs
Returns:
TRUE on success

Definition at line 4256 of file dbus-message.c.

References _dbus_string_get_length(), _dbus_warn(), body, dbus_message_append_iter_init(), dbus_message_iter_append_boolean(), dbus_message_iter_append_byte(), dbus_message_iter_append_custom(), dbus_message_iter_append_double(), dbus_message_iter_append_int32(), dbus_message_iter_append_nil(), dbus_message_iter_append_object_path(), dbus_message_iter_append_object_path_array(), dbus_message_iter_append_string(), dbus_message_iter_append_string_array(), dbus_message_iter_append_uint32(), FALSE, NULL, and TRUE.

Referenced by dbus_g_proxy_begin_call(), dbus_g_proxy_call_no_reply(), and dbus_message_append_args().

{
  int type, old_len;
  DBusMessageIter iter;

  _dbus_return_val_if_fail (message != NULL, FALSE);
  
  old_len = _dbus_string_get_length (&message->body);
  
  type = first_arg_type;

  dbus_message_append_iter_init (message, &iter);
  
  while (type != DBUS_TYPE_INVALID)
    {
      switch (type)
      {
      case DBUS_TYPE_NIL:
        if (!dbus_message_iter_append_nil (&iter))
          goto errorout;
        break;
      case DBUS_TYPE_BYTE:
        /* Read an int from varargs, because the original unsigned
         * char has been promoted to int. */
        if (!dbus_message_iter_append_byte (&iter, va_arg (var_args, int)))
          goto errorout;
        break;
      case DBUS_TYPE_BOOLEAN:
        if (!dbus_message_iter_append_boolean (&iter, va_arg (var_args, dbus_bool_t)))
          goto errorout;
        break;
      case DBUS_TYPE_INT32:
          /* FIXME this is probably wrong, because an int passed in probably gets
           * converted to plain "int" not necessarily 32-bit.
           */
        if (!dbus_message_iter_append_int32 (&iter, va_arg (var_args, dbus_int32_t)))
          goto errorout;
        break;
      case DBUS_TYPE_UINT32:
          /* FIXME this is probably wrong, because an int passed in probably gets
           * converted to plain "int" not necessarily 32-bit.
           */
        if (!dbus_message_iter_append_uint32 (&iter, va_arg (var_args, dbus_uint32_t)))
          goto errorout;          
        break;
#ifdef DBUS_HAVE_INT64
        case DBUS_TYPE_INT64:
        if (!dbus_message_iter_append_int64 (&iter, va_arg (var_args, dbus_int64_t)))
          goto errorout;
        break;
      case DBUS_TYPE_UINT64:
        if (!dbus_message_iter_append_uint64 (&iter, va_arg (var_args, dbus_uint64_t)))
          goto errorout;          
        break;
#endif /* DBUS_HAVE_INT64 */
      case DBUS_TYPE_DOUBLE:
        if (!dbus_message_iter_append_double (&iter, va_arg (var_args, double)))
          goto errorout;
        break;
      case DBUS_TYPE_STRING:
        if (!dbus_message_iter_append_string (&iter, va_arg (var_args, const char *)))
          goto errorout;
        break;
        case DBUS_TYPE_OBJECT_PATH:
        if (!dbus_message_iter_append_object_path (&iter, va_arg (var_args, const char*)))
          goto errorout;
          break;
      case DBUS_TYPE_CUSTOM:
        {
          const char *name;
          unsigned char *data;
          int len;
 
          name = va_arg (var_args, const char *);
          data = va_arg (var_args, unsigned char *);
          len = va_arg (var_args, int);

          if (!dbus_message_iter_append_custom (&iter, name, data, len))
            goto errorout;
          break;
        }
      case DBUS_TYPE_ARRAY:
        {
          void *data;
          int len, type;
 
          type = va_arg (var_args, int);
          data = va_arg (var_args, void *);
          len = va_arg (var_args, int);

          switch (type)
            {
            case DBUS_TYPE_BYTE:
            case DBUS_TYPE_BOOLEAN:
            case DBUS_TYPE_INT32:
            case DBUS_TYPE_UINT32:
#ifdef DBUS_HAVE_INT64
              case DBUS_TYPE_INT64:
            case DBUS_TYPE_UINT64:
#endif /* DBUS_HAVE_INT64 */
            case DBUS_TYPE_DOUBLE:
            if (!_dbus_message_iter_append_basic_array (&iter, type, data, len))
              goto errorout;
            break;
            case DBUS_TYPE_STRING:
            if (!dbus_message_iter_append_string_array (&iter, (const char **)data, len))
              goto errorout;
            break;
            case DBUS_TYPE_OBJECT_PATH:
            if (!dbus_message_iter_append_object_path_array (&iter, (const char **)data, len))
              goto errorout;
            break;
            case DBUS_TYPE_NIL:
            case DBUS_TYPE_ARRAY:
            case DBUS_TYPE_CUSTOM:
            case DBUS_TYPE_DICT:
            _dbus_warn ("dbus_message_append_args_valist doesn't support recursive arrays\n");
            goto errorout;
            default:
            _dbus_warn ("Unknown field type %d\n", type);
            goto errorout;
            }
        }
        break;
        
      case DBUS_TYPE_DICT:
        _dbus_warn ("dbus_message_append_args_valist doesn't support dicts\n");
        goto errorout;
      default:
        _dbus_warn ("Unknown field type %d\n", type);
        goto errorout;
      }

      type = va_arg (var_args, int);
    }

  return TRUE;

 errorout:
  return FALSE;
}


Generated by  Doxygen 1.6.0   Back to index