src/modules/systemd/dbus.c
/*
 * dbus_get_property_string fills the given buffer with the value of the given
 * object property.
 */
dbus_get_property_string fills the given buffer with the value of the given
object property.
dbus_get_property_string fills the given buffer with the value of the given object property .
int dbus_get_property_string(
  char          *s,
  const size_t  n,
  const char    *service,
  const char    *path,
  const char    *interface,
  const char    *property
) {
  DBusMessageIter *iter = NULL;
  char            *value = NULL;
  int             type = 0;
  iter = dbus_get_property(
                      service,
                      path,
                      interface,
                      property);
  if (NULL == iter){
    zbx_free(iter);
    return FAIL;
  }
  type = dbus_message_iter_get_arg_type(iter);
  switch (type) {
  case DBUS_TYPE_STRING:
    dbus_message_iter_get_basic(iter, &value);
    zbx_strlcpy(s, value, n);
    zbx_free(iter);
    return SUCCEED;
  case DBUS_TYPE_BOOLEAN:
    dbus_message_iter_get_basic(iter, &value);
    zbx_strlcpy(s, yes_no(value), n);
    zbx_free(iter);
    return SUCCEED;
  }
  zbx_free(iter);
  return FAIL;
}
int dbus_get_property_string ( char * s , const size_t n , const char * service , const char * path , const char * interface , const char * property ) { DBusMessageIter * iter = NULL ; char * value = NULL ; int type = 0 ; iter = dbus_get_property ( service , path , interface , property ) ; if ( NULL == iter ) { zbx_free ( iter ) ; return FAIL ; } type = dbus_message_iter_get_arg_type ( iter ) ; switch ( type ) { case DBUS_TYPE_STRING : dbus_message_iter_get_basic ( iter , & value ) ; zbx_strlcpy ( s , value , n ) ; zbx_free ( iter ) ; return SUCCEED ; case DBUS_TYPE_BOOLEAN : dbus_message_iter_get_basic ( iter , & value ) ; zbx_strlcpy ( s , yes_no ( value ) , n ) ; zbx_free ( iter ) ; return SUCCEED ; } zbx_free ( iter ) ; return FAIL ; }
dbus_get_property_string fills the given buffer with the value of the given
 object property.
dbus_get_property_string fills the given buffer with the value of the given object property .