/**
* Append one directory to the context's include path.
*/
-_X_EXPORT int
+XKB_EXPORT int
xkb_context_include_path_append(struct xkb_context *ctx, const char *path)
{
struct stat stat_buf;
/**
* Append the default include directories to the context.
*/
-_X_EXPORT int
+XKB_EXPORT int
xkb_context_include_path_append_default(struct xkb_context *ctx)
{
const char *home;
/**
* Remove all entries in the context's include path.
*/
-_X_EXPORT void
+XKB_EXPORT void
xkb_context_include_path_clear(struct xkb_context *ctx)
{
char **path;
/**
* xkb_context_include_path_clear() + xkb_context_include_path_append_default()
*/
-_X_EXPORT int
+XKB_EXPORT int
xkb_context_include_path_reset_defaults(struct xkb_context *ctx)
{
xkb_context_include_path_clear(ctx);
/**
* Returns the number of entries in the context's include path.
*/
-_X_EXPORT unsigned int
+XKB_EXPORT unsigned int
xkb_context_num_include_paths(struct xkb_context *ctx)
{
return darray_size(ctx->includes);
* Returns the given entry in the context's include path, or NULL if an
* invalid index is passed.
*/
-_X_EXPORT const char *
+XKB_EXPORT const char *
xkb_context_include_path_get(struct xkb_context *ctx, unsigned int idx)
{
if (idx >= xkb_context_num_include_paths(ctx))
/**
* Take a new reference on the context.
*/
-_X_EXPORT struct xkb_context *
+XKB_EXPORT struct xkb_context *
xkb_context_ref(struct xkb_context *ctx)
{
ctx->refcnt++;
* Drop an existing reference on the context, and free it if the refcnt is
* now 0.
*/
-_X_EXPORT void
+XKB_EXPORT void
xkb_context_unref(struct xkb_context *ctx)
{
if (--ctx->refcnt > 0)
/**
* Create a new context.
*/
-_X_EXPORT struct xkb_context *
+XKB_EXPORT struct xkb_context *
xkb_context_new(enum xkb_context_flags flags)
{
struct xkb_context *ctx = calloc(1, sizeof(*ctx));
return true;
}
-_X_EXPORT char *
+XKB_EXPORT char *
xkb_map_get_as_string(struct xkb_keymap *keymap)
{
char *ret = NULL;
{ 0xffbd, 0x003d }, /* KP_Equal = EQUAL SIGN */
};
-_X_EXPORT uint32_t
+XKB_EXPORT uint32_t
xkb_keysym_to_utf32(xkb_keysym_t keysym)
{
int min = 0;
return length + 1;
}
-_X_EXPORT int
+XKB_EXPORT int
xkb_keysym_to_utf8(xkb_keysym_t keysym, char *buffer, size_t size)
{
uint32_t codepoint;
#include "xkb-priv.h"
#include "ks_tables.h"
-_X_EXPORT void
+XKB_EXPORT void
xkb_keysym_get_name(xkb_keysym_t ks, char *buffer, size_t size)
{
int i, n, h, idx;
snprintf(buffer, size, "0x%08x", ks);
}
-_X_EXPORT xkb_keysym_t
+XKB_EXPORT xkb_keysym_t
xkb_keysym_from_name(const char *s)
{
int i, n, h, c, idx;
/**
* Returns the total number of modifiers active in the keymap.
*/
-_X_EXPORT xkb_mod_index_t
+XKB_EXPORT xkb_mod_index_t
xkb_map_num_mods(struct xkb_keymap *keymap)
{
xkb_mod_index_t i;
/**
* Return the name for a given modifier.
*/
-_X_EXPORT const char *
+XKB_EXPORT const char *
xkb_map_mod_get_name(struct xkb_keymap *keymap, xkb_mod_index_t idx)
{
if (idx >= xkb_map_num_mods(keymap))
/**
* Returns the index for a named modifier.
*/
-_X_EXPORT xkb_mod_index_t
+XKB_EXPORT xkb_mod_index_t
xkb_map_mod_get_index(struct xkb_keymap *keymap, const char *name)
{
xkb_mod_index_t i;
/**
* Return the total number of active groups in the keymap.
*/
-_X_EXPORT xkb_group_index_t
+XKB_EXPORT xkb_group_index_t
xkb_map_num_groups(struct xkb_keymap *keymap)
{
xkb_group_index_t ret = 0;
/**
* Returns the name for a given group.
*/
-_X_EXPORT const char *
+XKB_EXPORT const char *
xkb_map_group_get_name(struct xkb_keymap *keymap, xkb_group_index_t idx)
{
if (idx >= xkb_map_num_groups(keymap))
/**
* Returns the index for a named group.
*/
-_X_EXPORT xkb_group_index_t
+XKB_EXPORT xkb_group_index_t
xkb_map_group_get_index(struct xkb_keymap *keymap, const char *name)
{
xkb_group_index_t num_groups = xkb_map_num_groups(keymap);
/**
* Returns the number of groups active for a particular key.
*/
-_X_EXPORT xkb_group_index_t
+XKB_EXPORT xkb_group_index_t
xkb_key_num_groups(struct xkb_keymap *keymap, xkb_keycode_t kc)
{
if (XkbKeycodeInRange(keymap, kc))
/**
* Return the total number of active LEDs in the keymap.
*/
-_X_EXPORT xkb_led_index_t
+XKB_EXPORT xkb_led_index_t
xkb_map_num_leds(struct xkb_keymap *keymap)
{
xkb_led_index_t ret = 0;
/**
* Returns the name for a given group.
*/
-_X_EXPORT const char *
+XKB_EXPORT const char *
xkb_map_led_get_name(struct xkb_keymap *keymap, xkb_led_index_t idx)
{
if (idx >= xkb_map_num_leds(keymap))
/**
* Returns the index for a named group.
*/
-_X_EXPORT xkb_group_index_t
+XKB_EXPORT xkb_group_index_t
xkb_map_led_get_index(struct xkb_keymap *keymap, const char *name)
{
xkb_led_index_t num_leds = xkb_map_num_leds(keymap);
* Provides the symbols to use for the given key and state. Returns the
* number of symbols pointed to in syms_out.
*/
-_X_EXPORT int
+XKB_EXPORT int
xkb_key_get_syms(struct xkb_state *state, xkb_keycode_t kc,
const xkb_keysym_t **syms_out)
{
/**
* Simple boolean specifying whether or not the key should repeat.
*/
-_X_EXPORT int
+XKB_EXPORT int
xkb_key_repeats(struct xkb_keymap *keymap, xkb_keycode_t kc)
{
if (!XkbKeycodeInRange(keymap, kc))
return;
}
-_X_EXPORT struct xkb_state *
+XKB_EXPORT struct xkb_state *
xkb_state_new(struct xkb_keymap *keymap)
{
struct xkb_state *ret;
return ret;
}
-_X_EXPORT struct xkb_state *
+XKB_EXPORT struct xkb_state *
xkb_state_ref(struct xkb_state *state)
{
state->refcnt++;
return state;
}
-_X_EXPORT void
+XKB_EXPORT void
xkb_state_unref(struct xkb_state *state)
{
state->refcnt--;
free(state);
}
-_X_EXPORT struct xkb_keymap *
+XKB_EXPORT struct xkb_keymap *
xkb_state_get_map(struct xkb_state *state)
{
return state->keymap;
* Given a particular key event, updates the state structure to reflect the
* new modifiers.
*/
-_X_EXPORT void
+XKB_EXPORT void
xkb_state_update_key(struct xkb_state *state, xkb_keycode_t kc,
enum xkb_key_direction direction)
{
* lossy, and should only be used to update a slave state mirroring the
* master, e.g. in a client/server window system.
*/
-_X_EXPORT void
+XKB_EXPORT void
xkb_state_update_mask(struct xkb_state *state,
xkb_mod_mask_t base_mods,
xkb_mod_mask_t latched_mods,
* Serialises the requested modifier state into an xkb_mod_mask_t, with all
* the same disclaimers as in xkb_state_update_mask.
*/
-_X_EXPORT xkb_mod_mask_t
+XKB_EXPORT xkb_mod_mask_t
xkb_state_serialize_mods(struct xkb_state *state,
enum xkb_state_component type)
{
* Serialises the requested group state, with all the same disclaimers as
* in xkb_state_update_mask.
*/
-_X_EXPORT xkb_group_index_t
+XKB_EXPORT xkb_group_index_t
xkb_state_serialize_group(struct xkb_state *state,
enum xkb_state_component type)
{
* Returns 1 if the given modifier is active with the specified type(s), 0 if
* not, or -1 if the modifier is invalid.
*/
-_X_EXPORT int
+XKB_EXPORT int
xkb_state_mod_index_is_active(struct xkb_state *state,
xkb_mod_index_t idx,
enum xkb_state_component type)
* Returns 1 if the modifiers are active with the specified type(s), 0 if
* not, or -1 if any of the modifiers are invalid.
*/
-_X_EXPORT int
+XKB_EXPORT int
xkb_state_mod_indices_are_active(struct xkb_state *state,
enum xkb_state_component type,
enum xkb_state_match match,
* Returns 1 if the given modifier is active with the specified type(s), 0 if
* not, or -1 if the modifier is invalid.
*/
-_X_EXPORT int
+XKB_EXPORT int
xkb_state_mod_name_is_active(struct xkb_state *state, const char *name,
enum xkb_state_component type)
{
* Returns 1 if the modifiers are active with the specified type(s), 0 if
* not, or -1 if any of the modifiers are invalid.
*/
-_X_EXPORT int
+XKB_EXPORT int
xkb_state_mod_names_are_active(struct xkb_state *state,
enum xkb_state_component type,
enum xkb_state_match match,
* Returns 1 if the given group is active with the specified type(s), 0 if
* not, or -1 if the group is invalid.
*/
-_X_EXPORT int
+XKB_EXPORT int
xkb_state_group_index_is_active(struct xkb_state *state,
xkb_group_index_t idx,
enum xkb_state_component type)
* Returns 1 if the given modifier is active with the specified type(s), 0 if
* not, or -1 if the modifier is invalid.
*/
-_X_EXPORT int
+XKB_EXPORT int
xkb_state_group_name_is_active(struct xkb_state *state, const char *name,
enum xkb_state_component type)
{
/**
* Returns 1 if the given LED is active, 0 if not, or -1 if the LED is invalid.
*/
-_X_EXPORT int
+XKB_EXPORT int
xkb_state_led_index_is_active(struct xkb_state *state, xkb_led_index_t idx)
{
if (idx >= xkb_map_num_leds(state->keymap))
/**
* Returns 1 if the given LED is active, 0 if not, or -1 if the LED is invalid.
*/
-_X_EXPORT int
+XKB_EXPORT int
xkb_state_led_name_is_active(struct xkb_state *state, const char *name)
{
xkb_led_index_t idx = xkb_map_led_get_index(state->keymap, name);
#include <stdio.h>
#include <stdlib.h>
-#include <X11/Xfuncproto.h>
-
/*
* We sometimes malloc strings and then expose them as const char*'s. This
* macro is used when we free these strings in order to avoid -Wcast-qual
#define uStringText(s) ((s) == NULL ? "<NullString>" : (s))
#define uStrCasePrefix(s1, s2) (strncasecmp((s1), (s2), strlen(s1)) == 0)
-/***====================================================================***/
+/* Compiler Attributes */
+
+#if defined(__GNUC__) && (__GNUC__ >= 4) && !defined(__CYGWIN__)
+# define XKB_EXPORT __attribute__((visibility("default")))
+#elif defined(__SUNPRO_C) && (__SUNPRO_C >= 0x550)
+# define XKB_EXPORT __global
+#else /* not gcc >= 4 and not Sun Studio >= 8 */
+# define XKB_EXPORT
+#endif
+
+#if defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 203)
+# define ATTR_PRINTF(x,y) __attribute__((__format__(__printf__, x, y)))
+#else /* not gcc >= 2.3 */
+# define ATTR_PRINTF(x,y)
+#endif
+
+#if (defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 205)) \
+ || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590))
+# define ATTR_NORETURN __attribute__((__noreturn__))
+#else
+# define ATTR_NORETURN
+#endif /* GNUC */
extern bool
uSetErrorFile(char *name);
#define INFO uInformation
-extern _X_ATTRIBUTE_PRINTF(1, 2) void
+ATTR_PRINTF(1, 2) void
uInformation(const char *s, ...);
#define ACTION uAction
-extern _X_ATTRIBUTE_PRINTF(1, 2) void
+ATTR_PRINTF(1, 2) void
uAction(const char *s, ...);
#define WARN uWarning
-extern _X_ATTRIBUTE_PRINTF(1, 2) void
+ATTR_PRINTF(1, 2) void
uWarning(const char *s, ...);
#define ERROR uError
-extern _X_ATTRIBUTE_PRINTF(1, 2) void
+ATTR_PRINTF(1, 2) void
uError(const char *s, ...);
#define FATAL uFatalError
-extern _X_ATTRIBUTE_PRINTF(1, 2) _X_NORETURN void
+ATTR_PRINTF(1, 2) ATTR_NORETURN void
uFatalError(const char *s, ...);
/* WSGO stands for "Weird Stuff Going On" (wtf???) */
#define WSGO uInternalError
-extern _X_ATTRIBUTE_PRINTF(1, 2) void
+ATTR_PRINTF(1, 2) void
uInternalError(const char *s, ...);
#endif /* UTILS_H */
return keymap;
}
-_X_EXPORT struct xkb_keymap *
+XKB_EXPORT struct xkb_keymap *
xkb_map_new_from_names(struct xkb_context *ctx,
const struct xkb_rule_names *rmlvo,
enum xkb_map_compile_flags flags)
return keymap;
}
-_X_EXPORT struct xkb_keymap *
+XKB_EXPORT struct xkb_keymap *
xkb_map_new_from_string(struct xkb_context *ctx,
const char *string,
enum xkb_keymap_format format,
return keymap;
}
-_X_EXPORT struct xkb_keymap *
+XKB_EXPORT struct xkb_keymap *
xkb_map_new_from_file(struct xkb_context *ctx,
FILE *file,
enum xkb_keymap_format format,
return keymap;
}
-_X_EXPORT struct xkb_keymap *
+XKB_EXPORT struct xkb_keymap *
xkb_map_ref(struct xkb_keymap *keymap)
{
keymap->refcnt++;
return keymap;
}
-_X_EXPORT void
+XKB_EXPORT void
xkb_map_unref(struct xkb_keymap *keymap)
{
if (!keymap || --keymap->refcnt > 0)