cvs: pecl /printer printer.c
| From: | Frank M. Kromann | Date: | Mon, 22 Dec 2003 23:00:32 +0000 |
| Subject: | cvs: pecl /printer printer.c | ||
| Groups: | php.pecl.cvs | ||
| Request: | Send a blank email to pecl-cvs+get-607@lists.php.net to get a copy of this message | ||
fmk Mon Dec 22 18:00:32 2003 EDT
Modified files:
/pecl/printer printer.c
Log:
Memory cleanup and new error messages (thanks to Paul Kippes <kippesp@yahoo.com>)
Index: pecl/printer/printer.c
diff -u pecl/printer/printer.c:1.27 pecl/printer/printer.c:1.28
--- pecl/printer/printer.c:1.27 Thu Dec 4 17:14:22 2003
+++ pecl/printer/printer.c Mon Dec 22 18:00:32 2003
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: printer.c,v 1.27 2003/12/04 22:14:22 fmk Exp $ */
+/* $Id: printer.c,v 1.28 2003/12/22 23:00:32 fmk Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -107,7 +107,7 @@
php_info_print_table_row(2, "Printer Support", "enabled");
php_info_print_table_row(2, "Default printing device", PRINTERG(default_printer) ?
PRINTERG(default_printer) : "<b>not detected</b>");
php_info_print_table_row(2, "Module state", "working");
- php_info_print_table_row(2, "RCS Version", "$Id: printer.c,v 1.27 2003/12/04
22:14:22 fmk Exp $");
+ php_info_print_table_row(2, "RCS Version", "$Id: printer.c,v 1.28 2003/12/22
23:00:32 fmk Exp $");
php_info_print_table_end();
DISPLAY_INI_ENTRIES();
}
@@ -1220,25 +1220,46 @@
virtual_filepath(Z_STRVAL_PP(arg2), &path TSRMLS_CC);
- bmp = LoadImage(0, path, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
+ if ((bmp = LoadImage(0, path, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE)) == NULL) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to load bitmap %s",
Z_STRVAL_PP(arg2));
+ RETURN_FALSE;
+ }
+
SelectObject(resource->dc, bmp);
+ if (!(GetDeviceCaps(resource->dc, RASTERCAPS) & RC_BITBLT))
+ {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Printer does not support bitmaps");
+ DeleteObject(bmp);
+ RETURN_FALSE;
+ }
if((dummy = CreateCompatibleDC(NULL)) == NULL) {
+ DeleteObject(bmp);
RETURN_FALSE;
}
if(SelectObject(dummy, bmp) == NULL) {
DeleteDC(dummy);
+ DeleteObject(bmp);
RETURN_FALSE;
}
if (GetObject(bmp, sizeof(BITMAP), &bmp_property) == 0) {
DeleteDC(dummy);
+ DeleteObject(bmp);
RETURN_FALSE;
}
- BitBlt(resource->dc, Z_LVAL_PP(arg3), Z_LVAL_PP(arg4), bmp_property.bmWidth,
bmp_property.bmHeight, dummy, 0, 0, SRCCOPY);
+ if (!BitBlt(resource->dc, Z_LVAL_PP(arg3), Z_LVAL_PP(arg4), bmp_property.bmWidth,
bmp_property.bmHeight, dummy, 0, 0, SRCCOPY))
+ {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Printer failed to accept bitmap");
+
+ DeleteDC(dummy);
+ DeleteObject(bmp);
+ RETURN_FALSE;
+ }
+
DeleteDC(dummy);
DeleteObject(bmp);
RETURN_TRUE;