• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ sd_bus_message_append函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中sd_bus_message_append函数的典型用法代码示例。如果您正苦于以下问题:C++ sd_bus_message_append函数的具体用法?C++ sd_bus_message_append怎么用?C++ sd_bus_message_append使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了sd_bus_message_append函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: property_get_what

static int property_get_what(
                sd_bus *bus,
                const char *path,
                const char *interface,
                const char *property,
                sd_bus_message *reply,
                void *userdata,
                sd_bus_error *error) {

        Mount *m = userdata;
        const char *d;

        assert(bus);
        assert(reply);
        assert(m);

        if (m->from_proc_self_mountinfo && m->parameters_proc_self_mountinfo.what)
                d = m->parameters_proc_self_mountinfo.what;
        else if (m->from_fragment && m->parameters_fragment.what)
                d = m->parameters_fragment.what;
        else
                d = "";

        return sd_bus_message_append(reply, "s", d);
}
开发者ID:MOBO-OSS,项目名称:systemd-relative,代码行数:25,代码来源:dbus-mount.c


示例2: transient_kill_set_properties

static int transient_kill_set_properties(sd_bus_message *m) {
    assert(m);

    if (arg_send_sighup)
        return sd_bus_message_append(m, "(sv)", "SendSIGHUP", "b", arg_send_sighup);
    else
        return 0;
}
开发者ID:pszewczyk,项目名称:systemd,代码行数:8,代码来源:run.c


示例3: get_group_property

static int get_group_property(sd_bus *bus, const char *path,
		const char *interface, const char *property, sd_bus_message *reply,
		void *userdata, sd_bus_error *error) {

	struct dmmp_path_group *group = userdata;

	if (strcmp(property, GROUP_ID) == 0)
		return sd_bus_message_append(reply, "u", dmmp_path_group_id_get(group));

	if (strcmp(property, GROUP_PRIORITY) == 0)
		return sd_bus_message_append(reply, "u", dmmp_path_group_priority_get(group));

	if (strcmp(property, GROUP_STATUS) == 0)
		return sd_bus_message_append(reply, "s", dmmp_path_group_status_str(
				dmmp_path_group_status_get(group)));

	// TODO deal with error
	return -1;
}
开发者ID:trgill,项目名称:plugind,代码行数:19,代码来源:multipath_dbus.c


示例4: client_chart

static void client_chart(const char *address) {
        _cleanup_bus_message_unref_ sd_bus_message *x = NULL;
        size_t csize;
        sd_bus *b;
        int r;

        r = sd_bus_new(&b);
        assert_se(r >= 0);

        r = sd_bus_set_address(b, address);
        assert_se(r >= 0);

        r = sd_bus_start(b);
        assert_se(r >= 0);

        assert_se(sd_bus_call_method(b, ":1.1", "/", "benchmark.server", "Ping", NULL, NULL, NULL) >= 0);

        printf("SIZE\tCOPY\tMEMFD\n");

        for (csize = 1; csize <= MAX_SIZE; csize *= 2) {
                usec_t t;
                unsigned n_copying, n_memfd;

                printf("%zu\t", csize);

                b->use_memfd = 0;

                t = now(CLOCK_MONOTONIC);
                for (n_copying = 0;; n_copying++) {
                        transaction(b, csize);
                        if (now(CLOCK_MONOTONIC) >= t + arg_loop_usec)
                                break;
                }

                printf("%u\t", (unsigned) ((n_copying * USEC_PER_SEC) / arg_loop_usec));

                b->use_memfd = -1;

                t = now(CLOCK_MONOTONIC);
                for (n_memfd = 0;; n_memfd++) {
                        transaction(b, csize);
                        if (now(CLOCK_MONOTONIC) >= t + arg_loop_usec)
                                break;
                }

                printf("%u\n", (unsigned) ((n_memfd * USEC_PER_SEC) / arg_loop_usec));
        }

        b->use_memfd = 1;
        assert_se(sd_bus_message_new_method_call(b, ":1.1", "/", "benchmark.server", "Exit", &x) >= 0);
        assert_se(sd_bus_message_append(x, "t", csize) >= 0);
        assert_se(sd_bus_send(b, x, NULL) >= 0);

        sd_bus_unref(b);
}
开发者ID:prodigeni,项目名称:systemd,代码行数:55,代码来源:test-bus-kernel-benchmark.c


示例5: get_handler

static int get_handler(sd_bus *bus, const char *path, const char *interface, const char *property, sd_bus_message *reply, void *userdata, sd_bus_error *error) {
        struct context *c = userdata;
        int r;

        log_info("property get for %s called, returning \"%s\".", property, c->something);

        r = sd_bus_message_append(reply, "s", c->something);
        assert_se(r >= 0);

        return 1;
}
开发者ID:rhvgoyal,项目名称:systemd,代码行数:11,代码来源:test-bus-objects.c


示例6: sd_bus_message_new_signal

static struct ipmi_rs *ipmi_dbus_sendrecv(struct ipmi_intf *intf,
		struct ipmi_rq *req)
{
	sd_bus_message *msg;
	int rc;

	(void)intf;

	rsp.ccode = 0xff;

	rc = sd_bus_message_new_signal(bus, &msg, object_path,
			interface, "ReceivedMessage");
	if (rc < 0) {
		lprintf(LOG_ERR, "%s: failed to create message: %s\n",
				__func__, strerror(-rc));
		goto out;
	}

	rc = sd_bus_message_append(msg, "yyyy",
			++seq,
			req->msg.netfn,
			req->msg.lun,
			req->msg.cmd);
	if (rc < 0) {
		lprintf(LOG_ERR, "%s: failed to init bytes\n", __func__);
		goto out_free;
	}

	rc = sd_bus_message_append_array(msg, 'y', req->msg.data,
			req->msg.data_len);
	if (rc < 0) {
		lprintf(LOG_ERR, "%s: failed to init body\n", __func__);
		goto out_free;
	}

	rc = sd_bus_send(bus, msg, NULL);
	if (rc < 0) {
		lprintf(LOG_ERR, "%s: failed to send dbus message\n",
				__func__);
		goto out_free;
	}

	for (reply_received = false; !reply_received;) {
		rc = sd_bus_wait(bus, -1);
		sd_bus_process(bus, NULL);
	}

out_free:
	sd_bus_message_unref(msg);
out:
	return &rsp;
}
开发者ID:openbmc,项目名称:ipmitool,代码行数:52,代码来源:dbus.c


示例7: transient_unit_set_properties

static int transient_unit_set_properties(sd_bus_message *m, char **properties) {
        char **i;
        int r;

        r = sd_bus_message_append(m, "(sv)", "Description", "s", arg_description);
        if (r < 0)
                return r;

        STRV_FOREACH(i, properties) {
                r = bus_append_unit_property_assignment(m, *i);
                if (r < 0)
                        return r;
        }
开发者ID:NetworkManager,项目名称:systemd,代码行数:13,代码来源:run.c


示例8: bus_property_get_tristate

int bus_property_get_tristate(
                sd_bus *bus,
                const char *path,
                const char *interface,
                const char *property,
                sd_bus_message *reply,
                void *userdata,
                sd_bus_error *error) {

        int *tristate = userdata;

        return sd_bus_message_append(reply, "b", *tristate > 0);
}
开发者ID:chuanchang,项目名称:systemd,代码行数:13,代码来源:bus-util.c


示例9: transient_unit_set_properties

static int transient_unit_set_properties(sd_bus_message *m, char **properties) {
    int r;

    r = sd_bus_message_append(m, "(sv)", "Description", "s", arg_description);
    if (r < 0)
        return r;

    r = bus_append_unit_property_assignment_many(m, properties);
    if (r < 0)
        return r;

    return 0;
}
开发者ID:pszewczyk,项目名称:systemd,代码行数:13,代码来源:run.c


示例10: sd_bus_set_property

_public_ int sd_bus_set_property(
                sd_bus *bus,
                const char *destination,
                const char *path,
                const char *interface,
                const char *member,
                sd_bus_error *error,
                const char *type, ...) {

        _cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL;
        va_list ap;
        int r;

        bus_assert_return(bus, -EINVAL, error);
        bus_assert_return(isempty(interface) || interface_name_is_valid(interface), -EINVAL, error);
        bus_assert_return(member_name_is_valid(member), -EINVAL, error);
        bus_assert_return(signature_is_single(type, false), -EINVAL, error);
        bus_assert_return(!bus_pid_changed(bus), -ECHILD, error);

        if (!BUS_IS_OPEN(bus->state)) {
                r = -ENOTCONN;
                goto fail;
        }

        r = sd_bus_message_new_method_call(bus, &m, destination, path, "org.freedesktop.DBus.Properties", "Set");
        if (r < 0)
                goto fail;

        r = sd_bus_message_append(m, "ss", strempty(interface), member);
        if (r < 0)
                goto fail;

        r = sd_bus_message_open_container(m, 'v', type);
        if (r < 0)
                goto fail;

        va_start(ap, type);
        r = sd_bus_message_appendv(m, type, ap);
        va_end(ap);
        if (r < 0)
                goto fail;

        r = sd_bus_message_close_container(m);
        if (r < 0)
                goto fail;

        return sd_bus_call(bus, m, 0, error, NULL);

fail:
        return sd_bus_error_set_errno(error, r);
}
开发者ID:dankor,项目名称:systemd,代码行数:51,代码来源:bus-convenience.c


示例11: transient_timer_set_properties

static int transient_timer_set_properties(sd_bus_message *m) {
    int r;

    assert(m);

    r = transient_unit_set_properties(m, arg_timer_property);
    if (r < 0)
        return r;

    /* Automatically clean up our transient timers */
    r = sd_bus_message_append(m, "(sv)", "RemainAfterElapse", "b", false);
    if (r < 0)
        return r;

    if (arg_on_active) {
        r = sd_bus_message_append(m, "(sv)", "OnActiveSec", "t", arg_on_active);
        if (r < 0)
            return r;
    }

    if (arg_on_boot) {
        r = sd_bus_message_append(m, "(sv)", "OnBootSec", "t", arg_on_boot);
        if (r < 0)
            return r;
    }

    if (arg_on_startup) {
        r = sd_bus_message_append(m, "(sv)", "OnStartupSec", "t", arg_on_startup);
        if (r < 0)
            return r;
    }

    if (arg_on_unit_active) {
        r = sd_bus_message_append(m, "(sv)", "OnUnitActiveSec", "t", arg_on_unit_active);
        if (r < 0)
            return r;
    }

    if (arg_on_unit_inactive) {
        r = sd_bus_message_append(m, "(sv)", "OnUnitInactiveSec", "t", arg_on_unit_inactive);
        if (r < 0)
            return r;
    }

    if (arg_on_calendar) {
        r = sd_bus_message_append(m, "(sv)", "OnCalendar", "s", arg_on_calendar);
        if (r < 0)
            return r;
    }

    return 0;
}
开发者ID:pszewczyk,项目名称:systemd,代码行数:52,代码来源:run.c


示例12: value_handler

static int value_handler(sd_bus *bus, const char *path, const char *interface, const char *property, sd_bus_message *reply, void *userdata, sd_bus_error *error) {
        _cleanup_free_ char *s = NULL;
        const char *x;
        int r;

        assert_se(asprintf(&s, "object %p, path %s", userdata, path) >= 0);
        r = sd_bus_message_append(reply, "s", s);
        assert_se(r >= 0);

        assert_se(x = startswith(path, "/value/"));

        assert_se(PTR_TO_UINT(userdata) == 30);

        return 1;
}
开发者ID:rhvgoyal,项目名称:systemd,代码行数:15,代码来源:test-bus-objects.c


示例13: cc_Calculator_split_async

int cc_Calculator_split_async(
    struct cc_client_Calculator *instance, double value,
    cc_Calculator_split_reply_t callback)
{
    int result = 0;
    struct cc_instance *i;
    sd_bus_message *message = NULL;

    CC_LOG_DEBUG("invoked cc_Calculator_split_async()\n");
    assert(instance);
    assert(callback);
    i = instance->instance;
    assert(i && i->backend && i->backend->bus);
    assert(i->service && i->path && i->interface);

    if (instance->split_reply_slot) {
        CC_LOG_ERROR("unable to call method with already pending reply\n");
        return -EBUSY;
    }
    assert(!instance->split_reply_callback);

    result = sd_bus_message_new_method_call(
        i->backend->bus, &message, i->service, i->path, i->interface, "split");
    if (result < 0) {
        CC_LOG_ERROR("unable to create message: %s\n", strerror(-result));
        goto fail;
    }
    result = sd_bus_message_append(message, "d", value);
    if (result < 0) {
        CC_LOG_ERROR("unable to append message method arguments: %s\n", strerror(-result));
        goto fail;
    }

    result = sd_bus_call_async(
        i->backend->bus, &instance->split_reply_slot, message,
        &cc_Calculator_split_reply_thunk, instance, CC_DBUS_ASYNC_CALL_TIMEOUT_USEC);
    if (result < 0) {
        CC_LOG_ERROR("unable to issue method call: %s\n", strerror(-result));
        goto fail;
    }
    instance->split_reply_callback = callback;

fail:
    message = sd_bus_message_unref(message);

    return result;
}
开发者ID:GENIVI,项目名称:capic-poc,代码行数:47,代码来源:client-Calculator.c


示例14: append_controller_property

static int append_controller_property(sd_bus *bus, sd_bus_message *m) {
        const char *unique;
        int r;

        assert(bus);
        assert(m);

        r = sd_bus_get_unique_name(bus, &unique);
        if (r < 0)
                return log_error_errno(r, "Failed to get unique name: %m");

        r = sd_bus_message_append(m, "(sv)", "Controller", "s", unique);
        if (r < 0)
                return bus_log_create_error(r);

        return 0;
}
开发者ID:Werkov,项目名称:systemd,代码行数:17,代码来源:nspawn-register.c


示例15: main

int main(int argc, char *argv[]) {
    struct bus_match_node root = {
        .type = BUS_MATCH_ROOT,
    };

    _cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL;
    _cleanup_(sd_bus_flush_close_unrefp) sd_bus *bus = NULL;
    enum bus_match_node_type i;
    sd_bus_slot slots[19];
    int r;

    r = sd_bus_open_system(&bus);
    if (r < 0)
        return EXIT_TEST_SKIP;

    assert_se(match_add(slots, &root, "arg2='wal\\'do',sender='foo',type='signal',interface='bar.x',", 1) >= 0);
    assert_se(match_add(slots, &root, "arg2='wal\\'do2',sender='foo',type='signal',interface='bar.x',", 2) >= 0);
    assert_se(match_add(slots, &root, "arg3='test',sender='foo',type='signal',interface='bar.x',", 3) >= 0);
    assert_se(match_add(slots, &root, "arg3='test',sender='foo',type='method_call',interface='bar.x',", 4) >= 0);
    assert_se(match_add(slots, &root, "", 5) >= 0);
    assert_se(match_add(slots, &root, "interface='quux.x'", 6) >= 0);
    assert_se(match_add(slots, &root, "interface='bar.x'", 7) >= 0);
    assert_se(match_add(slots, &root, "member='waldo',path='/foo/bar'", 8) >= 0);
    assert_se(match_add(slots, &root, "path='/foo/bar'", 9) >= 0);
    assert_se(match_add(slots, &root, "path_namespace='/foo'", 10) >= 0);
    assert_se(match_add(slots, &root, "path_namespace='/foo/quux'", 11) >= 0);
    assert_se(match_add(slots, &root, "arg1='two'", 12) >= 0);
    assert_se(match_add(slots, &root, "member='waldo',arg2path='/prefix/'", 13) >= 0);
    assert_se(match_add(slots, &root, "member=waldo,path='/foo/bar',arg3namespace='prefix'", 14) >= 0);
    assert_se(match_add(slots, &root, "arg4has='pi'", 15) >= 0);
    assert_se(match_add(slots, &root, "arg4has='pa'", 16) >= 0);
    assert_se(match_add(slots, &root, "arg4has='po'", 17) >= 0);
    assert_se(match_add(slots, &root, "arg4='pi'", 18) >= 0);

    bus_match_dump(&root, 0);

    assert_se(sd_bus_message_new_signal(bus, &m, "/foo/bar", "bar.x", "waldo") >= 0);
    assert_se(sd_bus_message_append(m, "ssssas", "one", "two", "/prefix/three", "prefix.four", 3, "pi", "pa", "po") >= 0);
    assert_se(bus_message_seal(m, 1, 0) >= 0);

    zero(mask);
    assert_se(bus_match_run(NULL, &root, m) == 0);
    assert_se(mask_contains((unsigned[]) {
        9, 8, 7, 5, 10, 12, 13, 14, 15, 16, 17
    }, 11));
开发者ID:arthur-c,项目名称:systemd,代码行数:45,代码来源:test-bus-match.c


示例16: bus_property_get_tristate

int bus_property_get_tristate(
                sd_bus *bus,
                const char *path,
                const char *interface,
                const char *property,
                sd_bus_message *reply,
                sd_bus_error *error,
                void *userdata) {

        int *tristate = userdata;
        int r;

        r = sd_bus_message_append(reply, "b", *tristate > 0);
        if (r < 0)
                return r;

        return 1;
}
开发者ID:shazj99,项目名称:systemd,代码行数:18,代码来源:bus-util.c


示例17: transient_cgroup_set_properties

static int transient_cgroup_set_properties(sd_bus_message *m) {
    int r;
    assert(m);

    if (!isempty(arg_slice)) {
        _cleanup_free_ char *slice;

        r = unit_name_mangle_with_suffix(arg_slice, UNIT_NAME_NOGLOB, ".slice", &slice);
        if (r < 0)
            return r;

        r = sd_bus_message_append(m, "(sv)", "Slice", "s", slice);
        if (r < 0)
            return r;
    }

    return 0;
}
开发者ID:pszewczyk,项目名称:systemd,代码行数:18,代码来源:run.c


示例18: property_get_chassis

static int property_get_chassis(
    sd_bus *bus,
    const char *path,
    const char *interface,
    const char *property,
    sd_bus_message *reply,
    void *userdata,
    sd_bus_error *error) {

    Context *c = userdata;
    const char *name;

    if (isempty(c->data[PROP_CHASSIS]))
        name = fallback_chassis();
    else
        name = c->data[PROP_CHASSIS];

    return sd_bus_message_append(reply, "s", name);
}
开发者ID:NetworkManager,项目名称:systemd,代码行数:19,代码来源:hostnamed.c


示例19: create_property_set

static sd_bus_message *
create_property_set(sd_bus *bus, const char *service, const char *path,
    const char *interface, const char *member)
{
    sd_bus_message *m;
    int r;

    r = sd_bus_message_new_method_call(bus, &m, service, path,
        "org.freedesktop.DBus.Properties", "Set");
    SOL_INT_CHECK(r, < 0, NULL);

    r = sd_bus_message_append(m, "ss", interface, member);
    SOL_INT_CHECK_GOTO(r, < 0, error_append);

    return m;

error_append:
    sd_bus_message_unref(m);
    return NULL;
}
开发者ID:cabelitos,项目名称:soletta,代码行数:20,代码来源:sol-bluetooth-impl-bluez.c


示例20: property_get_options

static int property_get_options(
                sd_bus *bus,
                const char *path,
                const char *interface,
                const char *property,
                sd_bus_message *reply,
                void *userdata,
                sd_bus_error *error) {

        Swap *s = SWAP(userdata);
        const char *options = NULL;

        assert(bus);
        assert(reply);
        assert(s);

        if (s->from_fragment)
                options = s->parameters_fragment.options;

        return sd_bus_message_append(reply, "s", options);
}
开发者ID:arthur-c,项目名称:systemd,代码行数:21,代码来源:dbus-swap.c



注:本文中的sd_bus_message_append函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ sd_bus_message_enter_container函数代码示例发布时间:2022-05-30
下一篇:
C++ sd_bus_error_setf函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap