diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/xcb_errors.c | 18 | ||||
-rw-r--r-- | src/xcb_errors.h | 10 |
2 files changed, 22 insertions, 6 deletions
diff --git a/src/xcb_errors.c b/src/xcb_errors.c index c6f87d4..0c6c742 100644 --- a/src/xcb_errors.c +++ b/src/xcb_errors.c @@ -147,7 +147,7 @@ const char *xcb_errors_get_name_for_minor_code(xcb_errors_context_t *ctx, } const char *xcb_errors_get_name_for_event(xcb_errors_context_t *ctx, - uint8_t event_code) + uint8_t event_code, const char **extension) { struct extension_info_t *best = NULL; struct extension_info_t *next = ctx->extensions; @@ -167,15 +167,20 @@ const char *xcb_errors_get_name_for_event(xcb_errors_context_t *ctx, best = current; } - if (best == NULL || best->first_event == 0) + if (best == NULL || best->first_event == 0) { /* Nothing found */ + if (extension) + *extension = NULL; return get_strings_entry(xproto_info.strings_events, event_code); + } + if (extension) + *extension = best->name; return get_strings_entry(best->static_info.strings_events, event_code - best->first_event); } const char *xcb_errors_get_name_for_error(xcb_errors_context_t *ctx, - uint8_t error_code) + uint8_t error_code, const char **extension) { struct extension_info_t *best = NULL; struct extension_info_t *next = ctx->extensions; @@ -195,9 +200,14 @@ const char *xcb_errors_get_name_for_error(xcb_errors_context_t *ctx, best = current; } - if (best == NULL || best->first_error == 0) + if (best == NULL || best->first_error == 0) { /* Nothing found */ + if (extension) + *extension = NULL; return get_strings_entry(xproto_info.strings_errors, error_code); + } + if (extension) + *extension = best->name; return get_strings_entry(best->static_info.strings_errors, error_code - best->first_error); } diff --git a/src/xcb_errors.h b/src/xcb_errors.h index a9c8d0d..177b04c 100644 --- a/src/xcb_errors.h +++ b/src/xcb_errors.h @@ -90,24 +90,30 @@ const char *xcb_errors_get_name_for_minor_code(xcb_errors_context_t *ctx, * * @param ctx An errors context, created with @ref xcb_errors_context_new () * @param event_code The response_type of an event. + * @param extension Will be set to the name of the extension that generated this + * event or NULL for unknown errors or core X11 errors. This argument may be + * NULL. * @return A string allocated in static storage that contains a name for this * major code. This will never return NULL, but other functions in this library * may. */ const char *xcb_errors_get_name_for_event(xcb_errors_context_t *ctx, - uint8_t event_code); + uint8_t event_code, const char **extension); /** * Get the name corresponding to some error. * * @param ctx An errors context, created with @ref xcb_errors_context_new () * @param error_code The error_code of an error reply. + * @param extension Will be set to the name of the extension that generated this + * event or NULL for unknown errors or core X11 errors. This argument may be + * NULL. * @return A string allocated in static storage that contains a name for this * major code. This will never return NULL, but other functions in this library * may. */ const char *xcb_errors_get_name_for_error(xcb_errors_context_t *ctx, - uint8_t error_code); + uint8_t error_code, const char **extension); #ifdef __cplusplus } |