Ejemplo n.º 1
0
static int context_read_data(Context *c) {
        int r, q, p;

        r = locale_read_data(c);
        q = vconsole_read_data(c);
        p = x11_read_data(c);

        return r < 0 ? r : q < 0 ? q : p;
}
Ejemplo n.º 2
0
static int property_get_locale(
                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;
        _cleanup_strv_free_ char **l = NULL;
        int p, q, r;

        r = locale_read_data(c, reply);
        if (r < 0)
                return r;

        l = new0(char*, _VARIABLE_LC_MAX+1);
        if (!l)
                return -ENOMEM;

        for (p = 0, q = 0; p < _VARIABLE_LC_MAX; p++) {
                char *t;
                const char *name;

                name = locale_variable_to_string(p);
                assert(name);

                if (isempty(c->locale[p]))
                        continue;

                if (asprintf(&t, "%s=%s", name, c->locale[p]) < 0)
                        return -ENOMEM;

                l[q++] = t;
        }

        return sd_bus_message_append_strv(reply, l);
}