cvs: pecl /printer printer.c

From: Date: Tue, 02 Dec 2003 23:57:51 +0000
Subject: cvs: pecl /printer printer.c
Groups: php.pecl.cvs 
Request: Send a blank email to pecl-cvs+get-548@lists.php.net to get a copy of this message
fmk Tue Dec 2 18:57:51 2003 EDT Modified files: /pecl/printer printer.c Log: More memory issues. Added an option that will allow printing to file Index: pecl/printer/printer.c diff -u pecl/printer/printer.c:1.25 pecl/printer/printer.c:1.26 --- pecl/printer/printer.c:1.25 Tue Dec 2 18:02:56 2003 +++ pecl/printer/printer.c Tue Dec 2 18:57:51 2003 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: printer.c,v 1.25 2003/12/02 23:02:56 fmk Exp $ */ +/* $Id: printer.c,v 1.26 2003/12/02 23:57:51 fmk Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -111,7 +111,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.25 2003/12/02 23:02:56 fmk Exp $"); + php_info_print_table_row(2, "RCS Version", "$Id: printer.c,v 1.26 2003/12/02 23:57:51 fmk Exp $"); php_info_print_table_end(); DISPLAY_INI_ENTRIES(); } @@ -146,6 +146,7 @@ #define TEXT_ALIGN 12 #define DEVICENAME 13 #define DRIVER_VERSION 14 +#define OUTPUT_FILE 15 #define BRUSH_SOLID -1 #define BRUSH_CUSTOM -2 @@ -176,6 +177,7 @@ REGP_CONSTANT("PRINTER_TITLE", TITLE); REGP_CONSTANT("PRINTER_DEVICENAME", DEVICENAME); REGP_CONSTANT("PRINTER_DRIVERVERSION", DRIVER_VERSION); + REGP_CONSTANT("PRINTER_OUTPUT_FILE", OUTPUT_FILE); REGP_CONSTANT("PRINTER_RESOLUTION_Y", YRESOLUTION); REGP_CONSTANT("PRINTER_RESOLUTION_X", XRESOLUTION); REGP_CONSTANT("PRINTER_SCALE", SCALE); @@ -278,7 +280,7 @@ resource->device = emalloc(DocumentProperties(NULL, NULL, resource->name, NULL, NULL, 0)); DocumentProperties(NULL, resource->handle, resource->name, resource->device, NULL, DM_OUT_BUFFER); - resource->info.lpszDocName = "PHP generated Document"; + resource->info.lpszDocName = estrdup("PHP generated Document"); resource->info.lpszOutput = NULL; resource->info.lpszDatatype = estrdup("TEXT"); resource->info.fwType = 0; @@ -330,10 +332,10 @@ convert_to_string_ex(arg2); docinfo.pDocName = (LPTSTR)resource->info.lpszDocName; + docinfo.pOutputFile = (LPTSTR)resource->info.lpszOutput; docinfo.pDatatype = (LPTSTR)resource->info.lpszDatatype; - docinfo.pOutputFile = NULL; - sd = StartDocPrinter(resource->handle, 1, (LPSTR)&docinfo); + sd = StartDocPrinter(resource->handle, 1, (LPBYTE)&docinfo); sp = StartPagePrinter(resource->handle); if( sd && sp ) { @@ -497,7 +499,19 @@ case TITLE: convert_to_string_ex(arg3); - resource->info.lpszDocName = Z_STRVAL_PP(arg3); + if (resource->info.lpszDocName) { + efree((char *)resource->info.lpszDocName); + } + resource->info.lpszDocName = estrdup(Z_STRVAL_PP(arg3)); + resource->info.cbSize = sizeof(resource->info); + break; + + case OUTPUT_FILE: + convert_to_string_ex(arg3); + if (resource->info.lpszOutput) { + efree((char *)resource->info.lpszOutput); + } + resource->info.lpszOutput = estrdup(Z_STRVAL_PP(arg3)); resource->info.cbSize = sizeof(resource->info); break; @@ -586,6 +600,14 @@ case TITLE: RETURN_STRING((char*)resource->info.lpszDocName,1); + case OUTPUT_FILE: + if (resource->info.lpszOutput) { + RETURN_STRING((char*)resource->info.lpszOutput,1); + } + else { + RETURN_NULL(); + } + case ORIENTATION: RETURN_LONG(resource->device->dmOrientation); @@ -695,7 +717,10 @@ if(argc == 2) { convert_to_string_ex(parameter[1]); - resource->info.lpszDocName = Z_STRVAL_PP(parameter[1]); + if (resource->info.lpszDocName) { + efree((char *)resource->info.lpszDocName); + } + resource->info.lpszDocName = estrdup(Z_STRVAL_PP(parameter[1])); resource->info.cbSize = sizeof(resource->info); } @@ -1325,6 +1350,12 @@ printer *p = (printer*)resource->ptr; ClosePrinter(p->handle); + if (p->info.lpszDocName) { + efree((char *)p->info.lpszDocName); + } + if (p->info.lpszOutput) { + efree((char *)p->info.lpszOutput); + } if (p->info.lpszDatatype) { efree((char *)p->info.lpszDatatype); }

« previous php.pecl.cvs (#548) next »