API: add _context prefix to log-related functions This is to follow the general scheme set by all of the other API functions. Since no one is using these functions yet, we don't (actually better not) add the old names to xkbcommon-compat.h. Signed-off-by: Ran Benita <ran234@gmail.com>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362
diff --git a/src/context.c b/src/context.c
index 6710fe2..b3e2f23 100644
--- a/src/context.c
+++ b/src/context.c
@@ -296,11 +296,11 @@ xkb_context_new(enum xkb_context_flags flags)
/* Environment overwrites defaults. */
env = getenv("XKB_LOG");
if (env)
- xkb_set_log_level(ctx, log_level(env));
+ xkb_context_set_log_level(ctx, log_level(env));
env = getenv("XKB_VERBOSITY");
if (env)
- xkb_set_log_verbosity(ctx, log_verbosity(env));
+ xkb_context_set_log_verbosity(ctx, log_verbosity(env));
if (!(flags & XKB_CONTEXT_NO_DEFAULT_INCLUDES) &&
!xkb_context_include_path_append_default(ctx)) {
@@ -361,40 +361,40 @@ xkb_log(struct xkb_context *ctx, enum xkb_log_level level,
}
XKB_EXPORT void
-xkb_set_log_fn(struct xkb_context *ctx,
- void (*log_fn)(struct xkb_context *ctx,
- enum xkb_log_level level,
- const char *fmt, va_list args))
+xkb_context_set_log_fn(struct xkb_context *ctx,
+ void (*log_fn)(struct xkb_context *ctx,
+ enum xkb_log_level level,
+ const char *fmt, va_list args))
{
ctx->log_fn = (log_fn ? log_fn : default_log_fn);
}
XKB_EXPORT enum xkb_log_level
-xkb_get_log_level(struct xkb_context *ctx)
+xkb_context_get_log_level(struct xkb_context *ctx)
{
return ctx->log_level;
}
XKB_EXPORT void
-xkb_set_log_level(struct xkb_context *ctx, enum xkb_log_level level)
+xkb_context_set_log_level(struct xkb_context *ctx, enum xkb_log_level level)
{
ctx->log_level = level;
}
XKB_EXPORT int
-xkb_get_log_verbosity(struct xkb_context *ctx)
+xkb_context_get_log_verbosity(struct xkb_context *ctx)
{
return ctx->log_verbosity;
}
XKB_EXPORT void
-xkb_set_log_verbosity(struct xkb_context *ctx, int verbosity)
+xkb_context_set_log_verbosity(struct xkb_context *ctx, int verbosity)
{
ctx->log_verbosity = verbosity;
}
XKB_EXPORT void *
-xkb_get_user_data(struct xkb_context *ctx)
+xkb_context_get_user_data(struct xkb_context *ctx)
{
if (ctx)
return ctx->user_data;
@@ -402,7 +402,7 @@ xkb_get_user_data(struct xkb_context *ctx)
}
XKB_EXPORT void
-xkb_set_user_data(struct xkb_context *ctx, void *user_data)
+xkb_context_set_user_data(struct xkb_context *ctx, void *user_data)
{
ctx->user_data = user_data;
}
diff --git a/src/context.h b/src/context.h
index 1a87815..fb3150a 100644
--- a/src/context.h
+++ b/src/context.h
@@ -68,12 +68,12 @@ xkb_log(struct xkb_context *ctx, enum xkb_log_level level,
const char *fmt, ...);
#define xkb_log_cond_level(ctx, level, ...) do { \
- if (xkb_get_log_level(ctx) >= (level)) \
+ if (xkb_context_get_log_level(ctx) >= (level)) \
xkb_log((ctx), (level), __VA_ARGS__); \
} while (0)
#define xkb_log_cond_verbosity(ctx, level, vrb, ...) do { \
- if (xkb_get_log_verbosity(ctx) >= (vrb)) \
+ if (xkb_context_get_log_verbosity(ctx) >= (vrb)) \
xkb_log_cond_level((ctx), (level), __VA_ARGS__); \
} while (0)
diff --git a/src/xkbcomp/compat.c b/src/xkbcomp/compat.c
index 963c938..06cb0a6 100644
--- a/src/xkbcomp/compat.c
+++ b/src/xkbcomp/compat.c
@@ -311,7 +311,7 @@ AddInterp(CompatInfo *info, SymInterpInfo *new)
old = FindMatchingInterp(info, new);
if (old) {
- int verbosity = xkb_get_log_verbosity(info->keymap->ctx);
+ int verbosity = xkb_context_get_log_verbosity(info->keymap->ctx);
bool report = ((old->file_id == new->file_id && verbosity > 0) ||
verbosity > 9);
@@ -425,7 +425,7 @@ AddIndicatorMap(CompatInfo *info, LEDInfo *new)
LEDInfo *old;
enum led_field collide;
struct xkb_context *ctx = info->keymap->ctx;
- int verbosity = xkb_get_log_verbosity(ctx);
+ int verbosity = xkb_context_get_log_verbosity(ctx);
darray_foreach(old, info->leds) {
bool report;
diff --git a/src/xkbcomp/keycodes.c b/src/xkbcomp/keycodes.c
index cfd8bd9..2c5af55 100644
--- a/src/xkbcomp/keycodes.c
+++ b/src/xkbcomp/keycodes.c
@@ -177,7 +177,7 @@ AddIndicatorName(KeyNamesInfo *info, enum merge_mode merge,
xkb_led_index_t old_idx;
IndicatorNameInfo *old;
bool replace, report;
- int verbosity = xkb_get_log_verbosity(info->ctx);
+ int verbosity = xkb_context_get_log_verbosity(info->ctx);
replace = (merge == MERGE_REPLACE) || (merge == MERGE_OVERRIDE);
@@ -279,7 +279,7 @@ AddKeyName(KeyNamesInfo *info, xkb_keycode_t kc, unsigned long name,
{
KeyNameInfo *namei;
xkb_keycode_t old;
- int verbosity = xkb_get_log_verbosity(info->ctx);
+ int verbosity = xkb_context_get_log_verbosity(info->ctx);
if (kc >= darray_size(info->key_names))
darray_resize0(info->key_names, kc + 1);
@@ -483,7 +483,7 @@ HandleKeycodeDef(KeyNamesInfo *info, KeycodeDef *stmt, enum merge_mode merge)
static void
HandleAliasCollision(KeyNamesInfo *info, AliasInfo *old, AliasInfo *new)
{
- int verbosity = xkb_get_log_verbosity(info->ctx);
+ int verbosity = xkb_context_get_log_verbosity(info->ctx);
bool report = ((new->file_id == old->file_id && verbosity > 0) ||
verbosity > 9);
diff --git a/src/xkbcomp/symbols.c b/src/xkbcomp/symbols.c
index 793804a..f92f8a6 100644
--- a/src/xkbcomp/symbols.c
+++ b/src/xkbcomp/symbols.c
@@ -399,7 +399,7 @@ MergeKeys(SymbolsInfo *info, KeyInfo *into, KeyInfo *from)
xkb_layout_index_t groups_in_both;
enum key_field collide = 0;
bool clobber, report;
- int verbosity = xkb_get_log_verbosity(info->keymap->ctx);
+ int verbosity = xkb_context_get_log_verbosity(info->keymap->ctx);
if (from->merge == MERGE_REPLACE) {
ClearKeyInfo(into);
@@ -1669,7 +1669,7 @@ CopySymbolsToKeymap(struct xkb_keymap *keymap, SymbolsInfo *info)
if (!CopySymbolsDef(info, keyi))
info->errorCount++;
- if (xkb_get_log_verbosity(keymap->ctx) > 3) {
+ if (xkb_context_get_log_verbosity(keymap->ctx) > 3) {
xkb_foreach_key(key, keymap) {
if (key->name[0] == '\0')
continue;
diff --git a/src/xkbcomp/types.c b/src/xkbcomp/types.c
index 12f477f..ada9a1f 100644
--- a/src/xkbcomp/types.c
+++ b/src/xkbcomp/types.c
@@ -252,7 +252,7 @@ static bool
AddKeyType(KeyTypesInfo *info, KeyTypeInfo *new)
{
KeyTypeInfo *old;
- int verbosity = xkb_get_log_verbosity(info->keymap->ctx);
+ int verbosity = xkb_context_get_log_verbosity(info->keymap->ctx);
old = FindMatchingKeyType(info, new->name);
if (old) {
diff --git a/test/log.c b/test/log.c
index cf59045..ac32867 100644
--- a/test/log.c
+++ b/test/log.c
@@ -51,7 +51,7 @@ log_fn(struct xkb_context *ctx, enum xkb_log_level level,
{
char *s;
int size;
- darray_char *ls = xkb_get_user_data(ctx);
+ darray_char *ls = xkb_context_get_user_data(ctx);
assert(ls);
size = vasprintf(&s, fmt, args);
@@ -78,8 +78,8 @@ main(void)
assert(ctx);
darray_init(log_string);
- xkb_set_user_data(ctx, &log_string);
- xkb_set_log_fn(ctx, log_fn);
+ xkb_context_set_user_data(ctx, &log_string);
+ xkb_context_set_log_fn(ctx, log_fn);
log_warn(ctx, "first warning: %d\n", 87);
log_info(ctx, "first info\n");
@@ -87,15 +87,15 @@ main(void)
log_err(ctx, "first error: %lu\n", 115415UL);
log_vrb(ctx, 5, "first verbose 5\n");
- xkb_set_log_level(ctx, XKB_LOG_LEVEL_DEBUG);
+ xkb_context_set_log_level(ctx, XKB_LOG_LEVEL_DEBUG);
log_warn(ctx, "second warning: %d\n", 87);
log_dbg(ctx, "second debug: %s %s\n", "hello", "world");
log_info(ctx, "second info\n");
log_err(ctx, "second error: %lu\n", 115415UL);
log_vrb(ctx, 6, "second verbose 6\n");
- xkb_set_log_verbosity(ctx, 0);
- xkb_set_log_level(ctx, XKB_LOG_LEVEL_CRITICAL);
+ xkb_context_set_log_verbosity(ctx, 0);
+ xkb_context_set_log_level(ctx, XKB_LOG_LEVEL_CRITICAL);
log_warn(ctx, "third warning: %d\n", 87);
log_dbg(ctx, "third debug: %s %s\n", "hello", "world");
log_info(ctx, "third info\n");
diff --git a/test/rules-file.c b/test/rules-file.c
index b2091de..b3b3b6c 100644
--- a/test/rules-file.c
+++ b/test/rules-file.c
@@ -92,16 +92,16 @@ static void
benchmark(struct xkb_context *ctx)
{
struct timespec start, stop, elapsed;
- enum xkb_log_level old_level = xkb_get_log_level(ctx);
- int old_verb = xkb_get_log_verbosity(ctx);
+ enum xkb_log_level old_level = xkb_context_get_log_level(ctx);
+ int old_verb = xkb_context_get_log_verbosity(ctx);
int i;
struct xkb_rule_names rmlvo = {
"evdev", "pc105", "us,il", ",", "ctrl:nocaps,grp:menu_toggle",
};
struct xkb_component_names kccgst;
- xkb_set_log_level(ctx, XKB_LOG_LEVEL_CRITICAL);
- xkb_set_log_verbosity(ctx, 0);
+ xkb_context_set_log_level(ctx, XKB_LOG_LEVEL_CRITICAL);
+ xkb_context_set_log_verbosity(ctx, 0);
clock_gettime(CLOCK_MONOTONIC, &start);
for (i = 0; i < BENCHMARK_ITERATIONS; i++) {
@@ -113,8 +113,8 @@ benchmark(struct xkb_context *ctx)
}
clock_gettime(CLOCK_MONOTONIC, &stop);
- xkb_set_log_level(ctx, old_level);
- xkb_set_log_verbosity(ctx, old_verb);
+ xkb_context_set_log_level(ctx, old_level);
+ xkb_context_set_log_verbosity(ctx, old_verb);
elapsed.tv_sec = stop.tv_sec - start.tv_sec;
elapsed.tv_nsec = stop.tv_nsec - start.tv_nsec;
diff --git a/test/rulescomp.c b/test/rulescomp.c
index e30f539..7318f75 100644
--- a/test/rulescomp.c
+++ b/test/rulescomp.c
@@ -65,20 +65,20 @@ static void
benchmark(struct xkb_context *context)
{
struct timespec start, stop, elapsed;
- enum xkb_log_level old_level = xkb_get_log_level(context);
- int old_verb = xkb_get_log_verbosity(context);
+ enum xkb_log_level old_level = xkb_context_get_log_level(context);
+ int old_verb = xkb_context_get_log_verbosity(context);
int i;
- xkb_set_log_level(context, XKB_LOG_LEVEL_CRITICAL);
- xkb_set_log_verbosity(context, 0);
+ xkb_context_set_log_level(context, XKB_LOG_LEVEL_CRITICAL);
+ xkb_context_set_log_verbosity(context, 0);
clock_gettime(CLOCK_MONOTONIC, &start);
for (i = 0; i < BENCHMARK_ITERATIONS; i++)
assert(test_rmlvo_silent(context, "evdev", "evdev", "us", "", ""));
clock_gettime(CLOCK_MONOTONIC, &stop);
- xkb_set_log_level(context, old_level);
- xkb_set_log_verbosity(context, old_verb);
+ xkb_context_set_log_level(context, old_level);
+ xkb_context_set_log_verbosity(context, old_verb);
elapsed.tv_sec = stop.tv_sec - start.tv_sec;
elapsed.tv_nsec = stop.tv_nsec - start.tv_nsec;
diff --git a/xkbcommon/xkbcommon.h b/xkbcommon/xkbcommon.h
index 995771f..43c5220 100644
--- a/xkbcommon/xkbcommon.h
+++ b/xkbcommon/xkbcommon.h
@@ -279,10 +279,10 @@ enum xkb_log_level {
* Passing NULL restores the default function, which logs to stderr.
**/
void
-xkb_set_log_fn(struct xkb_context *context,
- void (*log_fn)(struct xkb_context *context,
- enum xkb_log_level level,
- const char *format, va_list args));
+xkb_context_set_log_fn(struct xkb_context *context,
+ void (*log_fn)(struct xkb_context *context,
+ enum xkb_log_level level,
+ const char *format, va_list args));
/**
* Sets the current logging level. The value controls which messages
* are logged. The default level is XKB_LOG_LEVEL_ERROR.
@@ -291,13 +291,14 @@ xkb_set_log_fn(struct xkb_context *context,
* and may be specified as a level number or name.
*/
void
-xkb_set_log_level(struct xkb_context *context, enum xkb_log_level level);
+xkb_context_set_log_level(struct xkb_context *context,
+ enum xkb_log_level level);
/**
* Returns the current logging level.
*/
enum xkb_log_level
-xkb_get_log_level(struct xkb_context *context);
+xkb_context_get_log_level(struct xkb_context *context);
/**
* Sets the current logging verbosity, a value from 0 to 10.
@@ -312,13 +313,13 @@ xkb_get_log_level(struct xkb_context *context);
* or lower.
*/
void
-xkb_set_log_verbosity(struct xkb_context *ctx, int verbosity);
+xkb_context_set_log_verbosity(struct xkb_context *ctx, int verbosity);
/**
* Returns the current logging verbosity.
*/
int
-xkb_get_log_verbosity(struct xkb_context *ctx);
+xkb_context_get_log_verbosity(struct xkb_context *ctx);
/**
* Retrieves stored data pointer from the context. This might be useful
@@ -327,13 +328,13 @@ xkb_get_log_verbosity(struct xkb_context *ctx);
* If context is NULL, returns NULL.
**/
void *
-xkb_get_user_data(struct xkb_context *context);
+xkb_context_get_user_data(struct xkb_context *context);
/**
* Store custom user data in the context.
*/
void
-xkb_set_user_data(struct xkb_context *context, void *user_data);
+xkb_context_set_user_data(struct xkb_context *context, void *user_data);
/** @} */