Ejemplo n.º 1
0
/**
 * Append the default include directories to the context.
 */
XKB_EXPORT int
xkb_context_include_path_append_default(struct xkb_context *ctx)
{
    const char *home;
    char *user_path;
    int err;
    int ret = 0;

    ret |= xkb_context_include_path_append(ctx, DFLT_XKB_CONFIG_ROOT);

    home = getenv("HOME");
    if (!home)
        return ret;
    err = asprintf(&user_path, "%s/.xkb", home);
    if (err <= 0)
        return ret;
    ret |= xkb_context_include_path_append(ctx, user_path);
    free(user_path);

    return ret;
}
int
main(void)
{
    struct xkb_context *context = test_get_context(0);

    assert(context);

    assert(xkb_context_num_include_paths(context) == 1);
    assert(!xkb_context_include_path_append(context, "¡NONSENSE!"));
    assert(xkb_context_num_include_paths(context) == 1);

    xkb_context_unref(context);

    return 0;
}