[client,x11] add helper util x11_error_to_string

The helper function x11_error_to_string stringifies a X11 error return
code.
This commit is contained in:
akallabeth 2024-09-16 09:21:28 +02:00
parent f67e641cce
commit 2b1abcd550
No known key found for this signature in database
GPG Key ID: A49454A3FC909FD5
2 changed files with 12 additions and 0 deletions

View File

@ -226,3 +226,13 @@ fail:
pclose(keyScript);
return rc;
}
const char* x11_error_to_string(xfContext* xfc, int error, char* buffer, size_t size)
{
WINPR_ASSERT(xfc);
WINPR_ASSERT(size <= INT32_MAX);
const int rc = XGetErrorText(xfc->display, error, buffer, (int)size);
if (rc)
WLog_WARN(TAG, "XGetErrorText returned %d", rc);
return buffer;
}

View File

@ -25,6 +25,8 @@
#include <X11/Xlib.h>
#include "xfreerdp.h"
const char* x11_error_to_string(xfContext* xfc, int error, char* buffer, size_t size);
#define X_GET_ATOM_VAR_NAME(x) #x
#define Safe_XGetAtomName(log, display, atom) \
Safe_XGetAtomNameEx((log), (display), (atom), X_GET_ATOM_VAR_NAME(atom))