diff options
author | Maarten Bosmans <mkbosmans@gmail.com> | 2012-04-09 21:33:52 +0200 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2012-04-10 12:09:02 +0100 |
commit | b74e8ebd50da443537a031132ebc86728f79e5f5 (patch) | |
tree | da4a5166d7a77cbd4e20ca76f66ee0546828a7ad /boilerplate/cairo-boilerplate-win32-printing.c | |
parent | 0bb3e0769a49f639ae86a9577394fc51709441f5 (diff) | |
download | cairo-b74e8ebd50da443537a031132ebc86728f79e5f5.tar.gz |
Add _cairo_win32_print_gdi_error to boilerplate code
This function is not exported in libcairo, so can't be used from the
library.
Diffstat (limited to 'boilerplate/cairo-boilerplate-win32-printing.c')
-rw-r--r-- | boilerplate/cairo-boilerplate-win32-printing.c | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/boilerplate/cairo-boilerplate-win32-printing.c b/boilerplate/cairo-boilerplate-win32-printing.c index 6fc61159b..625d52c53 100644 --- a/boilerplate/cairo-boilerplate-win32-printing.c +++ b/boilerplate/cairo-boilerplate-win32-printing.c @@ -59,8 +59,34 @@ # define FEATURESETTING_PSLEVEL 0x0002 #endif -cairo_status_t -_cairo_win32_print_gdi_error (const char *context); +static cairo_status_t +_cairo_win32_print_gdi_error (const char *context) +{ + void *lpMsgBuf; + DWORD last_error = GetLastError (); + + if (!FormatMessageW (FORMAT_MESSAGE_ALLOCATE_BUFFER | + FORMAT_MESSAGE_FROM_SYSTEM, + NULL, + last_error, + MAKELANGID (LANG_NEUTRAL, SUBLANG_DEFAULT), + (LPWSTR) &lpMsgBuf, + 0, NULL)) { + fprintf (stderr, "%s: Unknown GDI error", context); + } else { + fprintf (stderr, "%s: %S", context, (wchar_t *)lpMsgBuf); + + LocalFree (lpMsgBuf); + } + + fflush (stderr); + + /* We should switch off of last_status, but we'd either return + * CAIRO_STATUS_NO_MEMORY or CAIRO_STATUS_UNKNOWN_ERROR and there + * is no CAIRO_STATUS_UNKNOWN_ERROR. + */ + return CAIRO_STATUS_NO_MEMORY; +} static cairo_user_data_key_t win32_closure_key; |