#include <sys/types.h>
#include <sys/stat.h>
#include <errno.h>
-#ifdef _MSC_VER
-# include <direct.h>
-# include <io.h>
-# ifndef S_ISDIR
-# define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
-# endif
-#else
-# include <unistd.h>
-#endif
#include "xkbcommon/xkbcommon.h"
#include "utils.h"
#include "context.h"
+
/**
* Append one directory to the context's include path.
*/
}
darray_append(ctx->includes, tmp);
- log_dbg(ctx, "Include path added: %s\n", tmp);
+ log_dbg(ctx, XKB_LOG_MESSAGE_NO_ID, "Include path added: %s\n", tmp);
return 1;
err:
darray_append(ctx->failed_includes, tmp);
- log_dbg(ctx, "Include path failed: %s (%s)\n", tmp, strerror(err));
+ log_dbg(ctx, XKB_LOG_MESSAGE_NO_ID,
+ "Include path failed: %s (%s)\n", tmp, strerror(err));
return 0;
}
const char *
xkb_context_include_path_get_extra_path(struct xkb_context *ctx)
{
- const char *extra = secure_getenv("XKB_CONFIG_EXTRA_PATH");
+ const char *extra = xkb_context_getenv(ctx, "XKB_CONFIG_EXTRA_PATH");
return extra ? extra : DFLT_XKB_CONFIG_EXTRA_PATH;
}
const char *
xkb_context_include_path_get_system_path(struct xkb_context *ctx)
{
- const char *root = secure_getenv("XKB_CONFIG_ROOT");
+ const char *root = xkb_context_getenv(ctx, "XKB_CONFIG_ROOT");
return root ? root : DFLT_XKB_CONFIG_ROOT;
}
char *user_path;
int ret = 0;
- home = secure_getenv("HOME");
+ home = xkb_context_getenv(ctx, "HOME");
- xdg = secure_getenv("XDG_CONFIG_HOME");
+ xdg = xkb_context_getenv(ctx, "XDG_CONFIG_HOME");
if (xdg != NULL) {
user_path = asprintf_safe("%s/xkb", xdg);
if (user_path) {
if (!ctx || --ctx->refcnt > 0)
return;
+ free(ctx->x11_atom_cache);
xkb_context_include_path_clear(ctx);
atom_table_free(ctx->atom_table);
free(ctx);
ctx->log_fn = default_log_fn;
ctx->log_level = XKB_LOG_LEVEL_ERROR;
ctx->log_verbosity = 0;
+ ctx->use_environment_names = !(flags & XKB_CONTEXT_NO_ENVIRONMENT_NAMES);
+ ctx->use_secure_getenv = !(flags & XKB_CONTEXT_NO_SECURE_GETENV);
/* Environment overwrites defaults. */
- env = secure_getenv("XKB_LOG_LEVEL");
+ env = xkb_context_getenv(ctx, "XKB_LOG_LEVEL");
if (env)
xkb_context_set_log_level(ctx, log_level(env));
- env = secure_getenv("XKB_LOG_VERBOSITY");
+ env = xkb_context_getenv(ctx, "XKB_LOG_VERBOSITY");
if (env)
xkb_context_set_log_verbosity(ctx, log_verbosity(env));
if (!(flags & XKB_CONTEXT_NO_DEFAULT_INCLUDES) &&
!xkb_context_include_path_append_default(ctx)) {
- log_err(ctx, "failed to add default include path %s\n",
+ log_err(ctx, XKB_LOG_MESSAGE_NO_ID,
+ "failed to add default include path %s\n",
DFLT_XKB_CONFIG_ROOT);
xkb_context_unref(ctx);
return NULL;
}
- ctx->use_environment_names = !(flags & XKB_CONTEXT_NO_ENVIRONMENT_NAMES);
-
ctx->atom_table = atom_table_new();
if (!ctx->atom_table) {
xkb_context_unref(ctx);
return NULL;
}
+ ctx->x11_atom_cache = NULL;
+
return ctx;
}