summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorUli Schlachter <psychon@znc.in>2015-04-04 16:44:19 +0200
committerUli Schlachter <psychon@znc.in>2015-04-04 16:45:47 +0200
commit862579778af55817d24e7cd421d34febd95791c1 (patch)
tree9727904826771f6deee04d4a5e5e4ad4c534a94d /src
parentfb56799357b01dec7cfe37d33f95cb02962814e9 (diff)
Also return the extension name for events and errors
Signed-off-by: Uli Schlachter <psychon@znc.in>
Diffstat (limited to 'src')
-rw-r--r--src/xcb_errors.c18
-rw-r--r--src/xcb_errors.h10
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
}