cvs: pecl /printer php_printer.h printer.c

From: Date: Thu, 04 Dec 2003 22:14:23 +0000
Subject: cvs: pecl /printer php_printer.h printer.c
Groups: php.pecl.cvs 
Request: Send a blank email to pecl-cvs+get-555@lists.php.net to get a copy of this message
fmk Thu Dec 4 17:14:23 2003 EDT Modified files: /pecl/printer php_printer.h printer.c Log: Apply zend-global macros. Fix alocation problem for default printer. # The extension would cause php to crash on shutdown Index: pecl/printer/php_printer.h diff -u pecl/printer/php_printer.h:1.13 pecl/printer/php_printer.h:1.14 --- pecl/printer/php_printer.h:1.13 Thu Dec 4 00:17:09 2003 +++ pecl/printer/php_printer.h Thu Dec 4 17:14:22 2003 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_printer.h,v 1.13 2003/12/04 05:17:09 fmk Exp $ */ +/* $Id: php_printer.h,v 1.14 2003/12/04 22:14:22 fmk Exp $ */ #ifndef PHP_PRINTER_H #define PHP_PRINTER_H @@ -71,9 +71,9 @@ HDC dc; } printer; -typedef struct { +ZEND_BEGIN_MODULE_GLOBALS(printer) char *default_printer; -} zend_printer_globals; +ZEND_END_MODULE_GLOBALS(printer) #ifdef ZTS #define PRINTERG(v) TSRMG(printer_globals_id, zend_printer_globals *, v) Index: pecl/printer/printer.c diff -u pecl/printer/printer.c:1.26 pecl/printer/printer.c:1.27 --- pecl/printer/printer.c:1.26 Tue Dec 2 18:57:51 2003 +++ pecl/printer/printer.c Thu Dec 4 17:14:22 2003 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: printer.c,v 1.26 2003/12/02 23:57:51 fmk Exp $ */ +/* $Id: printer.c,v 1.27 2003/12/04 22:14:22 fmk Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -33,12 +33,6 @@ #include "php_printer.h" -#ifdef ZTS -int printer_globals_id; -#else -zend_printer_globals printer_globals; -#endif - static int le_printer, le_brush, le_pen, le_font; #ifdef PHP_WIN32 @@ -100,6 +94,8 @@ STANDARD_MODULE_PROPERTIES }; +ZEND_DECLARE_MODULE_GLOBALS(printer) + #ifdef COMPILE_DL_PRINTER ZEND_GET_MODULE(printer) #endif @@ -111,24 +107,24 @@ 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.26 2003/12/02 23:57:51 fmk Exp $"); + 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_end(); DISPLAY_INI_ENTRIES(); } static PHP_INI_MH(OnUpdatePrinter) { - if(new_value != "") { - if(PRINTERG(default_printer)) { - efree(PRINTERG(default_printer)); + if (new_value != NULL && new_value_length > 0) { + if (PRINTERG(default_printer)) { + pefree(PRINTERG(default_printer), 1); } - PRINTERG(default_printer) = estrdup(new_value); + PRINTERG(default_printer) = pestrdup(new_value, 1); } return SUCCESS; } PHP_INI_BEGIN() - STD_PHP_INI_ENTRY("printer.default_printer", "", PHP_INI_ALL, OnUpdatePrinter, default_printer, zend_printer_globals, printer_globals) + PHP_INI_ENTRY("printer.default_printer", "", PHP_INI_ALL, OnUpdatePrinter) PHP_INI_END() #define COPIES 0 @@ -152,13 +148,13 @@ #define REGP_CONSTANT(a,b) REGISTER_LONG_CONSTANT(a, b, CONST_CS | CONST_PERSISTENT); -static void php_printer_init(zend_printer_globals *printer_globals) { +static void php_printer_init(zend_printer_globals *printer_globals TSRMLS_DC) { printer_globals->default_printer = get_default_printer(); } -static void php_printer_shutdown(zend_printer_globals *printer_globals) { - if(printer_globals->default_printer) { - efree(printer_globals->default_printer); +static void php_printer_shutdown(zend_printer_globals *printer_globals TSRMLS_DC) { + if (printer_globals->default_printer) { + pefree(printer_globals->default_printer, 1); } } @@ -381,7 +377,7 @@ } case 2: convert_to_string_ex(arg2); - Name = estrdup(Z_STRVAL_PP(arg2)); + Name = Z_STRVAL_PP(arg2); Level = 1; break; case 1: @@ -459,10 +455,6 @@ zend_hash_index_update(Z_ARRVAL_P(return_value), i, (void *) &Printer, sizeof(zval *), (void **) &Printer_ptr); } - - if(Name != NULL) { - efree(Name); - } } /* }}} */ @@ -1280,14 +1272,14 @@ if(GetVersion() < 0x80000000){ GetProfileString("windows", "device", ",,,", buffer, 250); php_strtok_r(buffer, ",", &strtok_buf); - printer_name = estrdup(buffer); + printer_name = pestrdup(buffer, 1); } else { EnumPrinters(PRINTER_ENUM_DEFAULT, NULL, 2, NULL, 0, &need, &received); if(need > 0) { printer = (PRINTER_INFO_2 *)emalloc(need+1); EnumPrinters(PRINTER_ENUM_DEFAULT, NULL, 2, (LPBYTE)printer, need, &need, &received); - printer_name = estrdup(printer->pPrinterName); + printer_name = pestrdup(printer->pPrinterName, 1); efree(printer); } } @@ -1296,7 +1288,6 @@ } - int hex2dec(char hex){ switch(hex) { case 'F': case 'f': @@ -1320,6 +1311,7 @@ return (int)hex; } } + /* convert a hexadecimal number to the rgb colorref */ COLORREF hex_to_rgb(char* hex) {

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