Created
August 31, 2016 14:03
-
-
Save tryone144/07fd60857e6d837872f21209179d909f to your computer and use it in GitHub Desktop.
Print error message for specific X11 error code.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* xlib_err | |
* print error message for specific error code | |
* | |
* (c) 2016 Bernd Busse | |
**/ | |
#include <stdlib.h> | |
#include <stdio.h> | |
#include <errno.h> | |
#include <X11/Xlib.h> | |
int main(int argc, char* argv[]) { | |
if (argc != 2) { | |
fprintf(stderr, "usage: %s CODE\n", argv[0]); | |
return EXIT_FAILURE; | |
} | |
Display* dpy = XOpenDisplay(NULL); | |
if (dpy == NULL) { | |
fprintf(stderr, "Error: cannot connect to X\n"); | |
return EXIT_FAILURE; | |
} | |
int code = atoi(argv[1]); | |
char buf[256] = { 0 }; | |
XGetErrorText(dpy, code, buf, 256); | |
printf("Error Code: %d\n", code); | |
printf(" => %s\n", buf); | |
return EXIT_SUCCESS; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment