cvs: php4 /ext/printer php_printer.h printer.c

From: Date: Mon, 06 Nov 2000 13:58:13 +0000
Subject: cvs: php4 /ext/printer php_printer.h printer.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-2501@lists.php.net to get a copy of this message
dbeu Mon Nov 6 05:58:13 2000 EDT Modified files: /php4/ext/printer php_printer.h printer.c Log: only beautifying

Index: php4/ext/printer/php_printer.h diff -u php4/ext/printer/php_printer.h:1.3 php4/ext/printer/php_printer.h:1.4 --- php4/ext/printer/php_printer.h:1.3 Fri Oct 27 13:53:50 2000 +++ php4/ext/printer/php_printer.h Mon Nov 6 05:58:12 2000 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_printer.h,v 1.3 2000/10/27 20:53:50 fmk Exp $ */ +/* $Id: php_printer.h,v 1.4 2000/11/06 13:58:12 dbeu Exp $ */ #ifndef PHP_PRINTER_H #define PHP_PRINTER_H @@ -61,11 +61,11 @@ typedef struct { - HANDLE handle; - LPTSTR name; + HANDLE handle; + LPTSTR name; LPDEVMODE device; - LPVOID data; - DOC_INFO_1 info1; + LPVOID data; + DOC_INFO_1 info1; DOCINFO info; HDC dc; } printer; @@ -83,9 +83,8 @@ } font_struct; - typedef struct { - int printer_id; + int printer_id; int pen_id; int font_id; int brush_id; Index: php4/ext/printer/printer.c diff -u php4/ext/printer/printer.c:1.5 php4/ext/printer/printer.c:1.6 --- php4/ext/printer/printer.c:1.5 Fri Oct 27 13:54:23 2000 +++ php4/ext/printer/printer.c Mon Nov 6 05:58:12 2000 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: printer.c,v 1.5 2000/10/27 20:54:23 fmk Exp $ */ +/* $Id: printer.c,v 1.6 2000/11/06 13:58:12 dbeu Exp $ */ #include "php.h" #include "php_ini.h" @@ -33,12 +33,8 @@ php_printer_globals printer_globals; #endif -static int printer_id; -static int brush_id; -static int pen_id; -static int font_id; +static int printer_id, brush_id, pen_id, font_id; - #ifdef PHP_WIN32 /* windows headers */ #include <windows.h> @@ -55,45 +51,45 @@ function_entry printer_functions[] = { - PHP_FE(printer_open, NULL) - PHP_FE(printer_close, NULL) - PHP_FE(printer_write, NULL) - PHP_FE(printer_name, NULL) - PHP_FE(printer_list, NULL) - PHP_FE(printer_set_option, NULL) - PHP_FE(printer_get_option, NULL) - PHP_FE(printer_create_dc, NULL) - PHP_FE(printer_delete_dc, NULL) - PHP_FE(printer_start_doc, NULL) - PHP_FE(printer_end_doc, NULL) - PHP_FE(printer_start_page, NULL) - PHP_FE(printer_end_page, NULL) - PHP_FE(printer_create_pen, NULL) - PHP_FE(printer_delete_pen, NULL) - PHP_FE(printer_select_pen, NULL) - PHP_FE(printer_create_brush, NULL) - PHP_FE(printer_delete_brush, NULL) - PHP_FE(printer_select_brush, NULL) - PHP_FE(printer_logical_fontheight, NULL) - PHP_FE(printer_draw_roundrect, NULL) - PHP_FE(printer_draw_rectangle, NULL) - PHP_FE(printer_draw_text, NULL) - PHP_FE(printer_draw_elipse, NULL) - PHP_FE(printer_create_font, NULL) - PHP_FE(printer_delete_font, NULL) - PHP_FE(printer_select_font, NULL) - {NULL, NULL, NULL} + PHP_FE(printer_open, NULL) + PHP_FE(printer_close, NULL) + PHP_FE(printer_write, NULL) + PHP_FE(printer_name, NULL) + PHP_FE(printer_list, NULL) + PHP_FE(printer_set_option, NULL) + PHP_FE(printer_get_option, NULL) + PHP_FE(printer_create_dc, NULL) + PHP_FE(printer_delete_dc, NULL) + PHP_FE(printer_start_doc, NULL) + PHP_FE(printer_end_doc, NULL) + PHP_FE(printer_start_page, NULL) + PHP_FE(printer_end_page, NULL) + PHP_FE(printer_create_pen, NULL) + PHP_FE(printer_delete_pen, NULL) + PHP_FE(printer_select_pen, NULL) + PHP_FE(printer_create_brush, NULL) + PHP_FE(printer_delete_brush, NULL) + PHP_FE(printer_select_brush, NULL) + PHP_FE(printer_logical_fontheight, NULL) + PHP_FE(printer_draw_roundrect, NULL) + PHP_FE(printer_draw_rectangle, NULL) + PHP_FE(printer_draw_text, NULL) + PHP_FE(printer_draw_elipse, NULL) + PHP_FE(printer_create_font, NULL) + PHP_FE(printer_delete_font, NULL) + PHP_FE(printer_select_font, NULL) + {NULL, NULL, NULL} }; zend_module_entry printer_module_entry = { - "printer", - printer_functions, - PHP_MINIT(printer), - NULL, - NULL, - NULL, - PHP_MINFO(printer), - STANDARD_MODULE_PROPERTIES + "printer", + printer_functions, + PHP_MINIT(printer), + NULL, + NULL, + NULL, + PHP_MINFO(printer), + STANDARD_MODULE_PROPERTIES }; #ifdef COMPILE_DL_PRINTER @@ -103,22 +99,20 @@ PHP_MINFO_FUNCTION(printer) { - char* printer = get_default_printer(); - - php_info_print_table_start(); - php_info_print_table_row(2, "Printer Support" , "enabled"); - php_info_print_table_row(2, "Default printing device", get_default_printer()); - php_info_print_table_row(2, "RCS Version" , "$Id: printer.c,v 1.5 2000/10/27 20:54:23 fmk Exp $"); - php_info_print_table_end(); + php_info_print_table_start(); + php_info_print_table_row(2, "Printer Support", "enabled"); + php_info_print_table_row(2, "Default printing device", get_default_printer()); + php_info_print_table_row(2, "RCS Version", "$Id: printer.c,v 1.6 2000/11/06 13:58:12 dbeu Exp $"); + php_info_print_table_end(); } PHP_MINIT_FUNCTION(printer) { - printer_id = zend_register_list_destructors_ex(destroy_ressources, NULL, "printer", module_number); - pen_id = zend_register_list_destructors_ex(destroy_ressources, NULL, "printer pen", module_number); - font_id = zend_register_list_destructors_ex(destroy_ressources, NULL, "printer font", module_number); - brush_id = zend_register_list_destructors_ex(destroy_ressources, NULL, "printer brush", module_number); - return SUCCESS; + printer_id = zend_register_list_destructors_ex(destroy_ressources, NULL, "printer", module_number); + pen_id = zend_register_list_destructors_ex(destroy_ressources, NULL, "printer pen", module_number); + font_id = zend_register_list_destructors_ex(destroy_ressources, NULL, "printer font", module_number); + brush_id = zend_register_list_destructors_ex(destroy_ressources, NULL, "printer brush", module_number); + return SUCCESS; } @@ -126,44 +120,41 @@ Return a handle or false if connection failed */ PHP_FUNCTION(printer_open) { - pval **arg1; - printer *resource; - - PRINTERLS_FETCH(); + pval **arg1; + printer *resource; - resource = (printer *)emalloc(sizeof(printer)); + PRINTERLS_FETCH(); + resource = (printer *)emalloc(sizeof(printer)); /* use the given printer */ if( zend_get_parameters_ex(1, &arg1) != FAILURE ) { - convert_to_string_ex(arg1); - resource->name = estrdup((*arg1)->value.str.val); + convert_to_string_ex(arg1); + resource->name = (*arg1)->value.str.val; } /* use detected default */ else { - resource->name = get_default_printer(); + resource->name = get_default_printer(); } - - if( OpenPrinter(resource->name, &resource->handle, NULL) != 0 ) { - resource->device = emalloc(DocumentProperties(NULL, NULL, resource->name, NULL, NULL, 0)); - DocumentProperties(NULL, resource->handle, resource->name, resource->device, NULL, DM_OUT_BUFFER); - /* set DOCINFO defaults */ - resource->info.lpszDocName = "PHP generated Document"; - resource->info.lpszOutput = NULL; - resource->info.lpszDatatype = "TEXT"; - resource->info.fwType = 0; - resource->info.cbSize = sizeof(resource->info); - - resource->dc = CreateDC(NULL, resource->name, NULL, resource->device); - - ZEND_REGISTER_RESOURCE(return_value, resource, PRINTERG(printer_id)); - } - else { - php_error(E_WARNING,"couldn't connect to the printer [%s]", resource->name); - RETURN_FALSE; - } + if( OpenPrinter(resource->name, &resource->handle, NULL) != 0 ) { + resource->device = emalloc(DocumentProperties(NULL, NULL, resource->name, NULL, NULL, 0)); + DocumentProperties(NULL, resource->handle, resource->name, resource->device, NULL, DM_OUT_BUFFER); + + /* set DOCINFO defaults */ + resource->info.lpszDocName = "PHP generated Document"; + resource->info.lpszOutput = NULL; + resource->info.lpszDatatype = "TEXT"; + resource->info.fwType = 0; + resource->info.cbSize = sizeof(resource->info); + resource->dc = CreateDC(NULL, resource->name, NULL, resource->device); + ZEND_REGISTER_RESOURCE(return_value, resource, PRINTERG(printer_id)); + } + else { + php_error(E_WARNING,"couldn't connect to the printer [%s]", resource->name); + RETURN_FALSE; + } } /* }}} */ @@ -172,25 +163,24 @@ Close the printer connection */ PHP_FUNCTION(printer_close) { - pval **arg1; - printer *resource; - - PRINTERLS_FETCH(); + pval **arg1; + printer *resource; - if ( zend_get_parameters_ex(1, &arg1) == FAILURE ) { - WRONG_PARAM_COUNT; - } + PRINTERLS_FETCH(); + if ( zend_get_parameters_ex(1, &arg1) == FAILURE ) { + WRONG_PARAM_COUNT; + } - ZEND_FETCH_RESOURCE(resource, printer *, arg1, -1, "Printer Handle", PRINTERG(printer_id)); + ZEND_FETCH_RESOURCE(resource, printer *, arg1, -1, "Printer Handle", PRINTERG(printer_id)); - if( ClosePrinter(resource->handle) != 0 ) { - RETURN_TRUE; - } - else { - php_error(E_WARNING,"the printer connection to [%s] couldn't be closed", resource->name); - RETURN_FALSE; - } + if( ClosePrinter(resource->handle) != 0 ) { + RETURN_TRUE; + } + else { + php_error(E_WARNING,"the printer connection to [%s] couldn't be closed", resource->name); + RETURN_FALSE; + } } /* }}} */ @@ -199,42 +189,39 @@ Write directly to the printer */ PHP_FUNCTION(printer_write) { - pval **arg1, **arg2; - printer *resource; - LPDWORD recieved = NULL; - int sd, sp = 0; - - PRINTERLS_FETCH(); + pval **arg1, **arg2; + printer *resource; + LPDWORD recieved = NULL; + int sd, sp = 0; - if ( zend_get_parameters_ex(2, &arg1, &arg2) == FAILURE ) { - WRONG_PARAM_COUNT; - } + PRINTERLS_FETCH(); + if ( zend_get_parameters_ex(2, &arg1, &arg2) == FAILURE ) { + WRONG_PARAM_COUNT; + } - ZEND_FETCH_RESOURCE(resource, printer *, arg1, -1, "Printer Handle", PRINTERG(printer_id)); - convert_to_string_ex(arg2); - resource->data = estrdup((*arg2)->value.str.val); + ZEND_FETCH_RESOURCE(resource, printer *, arg1, -1, "Printer Handle", PRINTERG(printer_id)); + convert_to_string_ex(arg2); + resource->data = estrdup((*arg2)->value.str.val); /* reflect DOCINFO to DOC_INFO_1 */ resource->info1.pDocName = estrdup(resource->info.lpszDocName); resource->info1.pDatatype = estrdup(resource->info.lpszDatatype); - /* check availability */ - sd = StartDocPrinter(resource->handle, 1, (LPSTR)&resource->info1); - sp = StartPagePrinter(resource->handle); - - if( sd != 0 || !sp ) { - WritePrinter(resource->handle, resource->data, strlen(resource->data), (unsigned long*)&recieved); - EndPagePrinter(resource->handle); - EndDocPrinter(resource->handle); - - RETURN_TRUE; - } - else { - php_error(E_WARNING,"couldn't allocate the printerjob" ); - RETURN_FALSE; - } + sd = StartDocPrinter(resource->handle, 1, (LPSTR)&resource->info1); + sp = StartPagePrinter(resource->handle); + + if( sd != 0 || !sp ) { + WritePrinter(resource->handle, resource->data, strlen(resource->data), (unsigned long*)&recieved); + EndPagePrinter(resource->handle); + EndDocPrinter(resource->handle); + RETURN_TRUE; + } + else { + php_error(E_WARNING,"couldn't allocate the printerjob" ); + RETURN_FALSE; + } } /* }}} */ @@ -243,19 +230,17 @@ Return the printer name */ PHP_FUNCTION(printer_name) { - pval **arg1; - printer *resource; + pval **arg1; + printer *resource; - PRINTERLS_FETCH(); + PRINTERLS_FETCH(); - if ( zend_get_parameters_ex(1, &arg1) == FAILURE ) { - WRONG_PARAM_COUNT; - } + if ( zend_get_parameters_ex(1, &arg1) == FAILURE ) { + WRONG_PARAM_COUNT; + } - ZEND_FETCH_RESOURCE(resource, printer *, arg1, -1, "Printer Handle", PRINTERG(printer_id)); - - RETURN_STRING(resource->name,1); + RETURN_STRING(resource->name,1); } /* }}} */ @@ -277,7 +262,7 @@ argc = ARG_COUNT(ht); - if (argc < 1 || argc > 3 || zend_get_parameters_ex(ht, argc, &arg1, &arg2, &arg3) == FAILURE) { + if(zend_get_parameters_ex(ht, argc, &arg1, &arg2, &arg3) == FAILURE) { WRONG_PARAM_COUNT; } convert_to_string_ex(arg1); @@ -373,62 +358,62 @@ pval **arg1, **arg2, **arg3; printer *resource; - PRINTERLS_FETCH(); + PRINTERLS_FETCH(); - if ( zend_get_parameters_ex(3, &arg1, &arg2, &arg3) == FAILURE ) { - WRONG_PARAM_COUNT; - } + if( zend_get_parameters_ex(3, &arg1, &arg2, &arg3) == FAILURE ) { + WRONG_PARAM_COUNT; + } ZEND_FETCH_RESOURCE(resource, printer *, arg1, -1, "Printer Handle", PRINTERG(printer_id)); convert_to_string_ex(arg2); if(!strcmp((*arg2)->value.str.val,"copies")) { - convert_to_long_ex(arg3); - resource->device->dmCopies = (short)(*arg3)->value.lval; + convert_to_long_ex(arg3); + resource->device->dmCopies = (short)(*arg3)->value.lval; } else if(!strcmp((*arg2)->value.str.val,"mode")) { - convert_to_string_ex(arg3); - resource->info.lpszDatatype = estrdup((*arg3)->value.str.val); + convert_to_string_ex(arg3); + resource->info.lpszDatatype = estrdup((*arg3)->value.str.val); } else if(!strcmp((*arg2)->value.str.val,"title")) { - convert_to_string_ex(arg3); - resource->info.lpszDocName = estrdup((*arg3)->value.str.val); + convert_to_string_ex(arg3); + resource->info.lpszDocName = estrdup((*arg3)->value.str.val); } else if(!strcmp((*arg2)->value.str.val,"orientation")) { - convert_to_long_ex(arg3); - resource->device->dmOrientation = (short)(*arg3)->value.lval; + convert_to_long_ex(arg3); + resource->device->dmOrientation = (short)(*arg3)->value.lval; } else if(!strcmp((*arg2)->value.str.val,"resolution")) { - convert_to_long_ex(arg3); - resource->device->dmYResolution = (short)(*arg3)->value.lval; + convert_to_long_ex(arg3); + resource->device->dmYResolution = (short)(*arg3)->value.lval; } else if(!strcmp((*arg2)->value.str.val,"papersize")) { - convert_to_long_ex(arg3); - resource->device->dmPaperSize = (short)(*arg3)->value.lval; + convert_to_long_ex(arg3); + resource->device->dmPaperSize = (short)(*arg3)->value.lval; } else if(!strcmp((*arg2)->value.str.val,"paperlength")) { - convert_to_long_ex(arg3); - resource->device->dmPaperLength = (*arg3)->value.lval * 254; + convert_to_long_ex(arg3); + resource->device->dmPaperLength = (*arg3)->value.lval * 254; } else if(!strcmp((*arg2)->value.str.val,"paperwidth")) { - convert_to_long_ex(arg3); - resource->device->dmPaperWidth = (*arg3)->value.lval * 254; + convert_to_long_ex(arg3); + resource->device->dmPaperWidth = (*arg3)->value.lval * 254; } else if(!strcmp((*arg2)->value.str.val,"scale")) { - convert_to_long_ex(arg3); - resource->device->dmScale = (short)(*arg3)->value.lval; + convert_to_long_ex(arg3); + resource->device->dmScale = (short)(*arg3)->value.lval; } else if(!strcmp((*arg2)->value.str.val,"bgcolor")) { - convert_to_string_ex(arg3); - SetBkColor(resource->dc, hex_to_rgb((*arg3)->value.str.val)); + convert_to_string_ex(arg3); + SetBkColor(resource->dc, hex_to_rgb((*arg3)->value.str.val)); } else if(!strcmp((*arg2)->value.str.val,"textalign")) { - convert_to_long_ex(arg3); - SetTextAlign(resource->dc, (*arg3)->value.lval); + convert_to_long_ex(arg3); + SetTextAlign(resource->dc, (*arg3)->value.lval); } else { - php_error(E_WARNING,"unknown option passed to printer_set_option()"); - RETURN_FALSE; + php_error(E_WARNING,"unknown option passed to printer_set_option()"); + RETURN_FALSE; }; RETURN_TRUE; @@ -443,51 +428,51 @@ pval **arg1, **arg2; printer *resource; - PRINTERLS_FETCH(); + PRINTERLS_FETCH(); - if ( zend_get_parameters_ex(2, &arg1, &arg2) == FAILURE ) { - WRONG_PARAM_COUNT; - } + if( zend_get_parameters_ex(2, &arg1, &arg2) == FAILURE ) { + WRONG_PARAM_COUNT; + } ZEND_FETCH_RESOURCE(resource, printer *, arg1, -1, "Printer Handle", PRINTERG(printer_id)); convert_to_string_ex(arg2); if(!strcmp((*arg2)->value.str.val,"copies")) { - RETURN_LONG(resource->device->dmCopies); + RETURN_LONG(resource->device->dmCopies); } else if(!strcmp((*arg2)->value.str.val,"mode")) { - RETURN_STRING((char*)resource->info.lpszDatatype,1); + RETURN_STRING((char*)resource->info.lpszDatatype,1); } else if(!strcmp((*arg2)->value.str.val,"title")) { - RETURN_STRING((char*)resource->info.lpszDocName,1); + RETURN_STRING((char*)resource->info.lpszDocName,1); } else if(!strcmp((*arg2)->value.str.val,"orientation")) { - RETURN_LONG(resource->device->dmOrientation); + RETURN_LONG(resource->device->dmOrientation); } else if(!strcmp((*arg2)->value.str.val,"resolution")) { - RETURN_LONG(resource->device->dmYResolution); + RETURN_LONG(resource->device->dmYResolution); } else if(!strcmp((*arg2)->value.str.val,"papersize")) { - RETURN_LONG(resource->device->dmPaperSize); + RETURN_LONG(resource->device->dmPaperSize); } else if(!strcmp((*arg2)->value.str.val,"paperlength")) { - RETURN_LONG(resource->device->dmPaperLength / 245); + RETURN_LONG(resource->device->dmPaperLength / 245); } else if(!strcmp((*arg2)->value.str.val,"paperwidth")){ - RETURN_LONG(resource->device->dmPaperWidth / 245); + RETURN_LONG(resource->device->dmPaperWidth / 245); } else if(!strcmp((*arg2)->value.str.val,"driverversion")) { - RETURN_LONG(resource->device->dmDriverVersion); + RETURN_LONG(resource->device->dmDriverVersion); } else if(!strcmp((*arg2)->value.str.val,"specversion")) { - RETURN_LONG(resource->device->dmSpecVersion); + RETURN_LONG(resource->device->dmSpecVersion); } else if(!strcmp((*arg2)->value.str.val,"scale")) { - RETURN_LONG(resource->device->dmScale); + RETURN_LONG(resource->device->dmScale); } else { - php_error(E_WARNING,"unknown option passed to printer_get_option()"); - RETURN_FALSE; + php_error(E_WARNING,"unknown option passed to printer_get_option()"); + RETURN_FALSE; } } /* }}} */ @@ -500,11 +485,11 @@ pval **arg1; printer *resource; - PRINTERLS_FETCH(); + PRINTERLS_FETCH(); - if ( zend_get_parameters_ex(1, &arg1) == FAILURE ) { - WRONG_PARAM_COUNT; - } + if( zend_get_parameters_ex(1, &arg1) == FAILURE ) { + WRONG_PARAM_COUNT; + } ZEND_FETCH_RESOURCE(resource, printer *, arg1, -1, "Printer Handle", PRINTERG(printer_id)); @@ -525,11 +510,11 @@ pval **arg1; printer *resource; - PRINTERLS_FETCH(); + PRINTERLS_FETCH(); - if ( zend_get_parameters_ex(1, &arg1) == FAILURE ) { - WRONG_PARAM_COUNT; - } + if( zend_get_parameters_ex(1, &arg1) == FAILURE ) { + WRONG_PARAM_COUNT; + } ZEND_FETCH_RESOURCE(resource, printer *, arg1, -1, "Printer Handle", PRINTERG(printer_id)); @@ -552,11 +537,11 @@ pval **arg1; printer *resource; - PRINTERLS_FETCH(); + PRINTERLS_FETCH(); - if ( zend_get_parameters_ex(1, &arg1) == FAILURE ) { - WRONG_PARAM_COUNT; - } + if( zend_get_parameters_ex(1, &arg1) == FAILURE ) { + WRONG_PARAM_COUNT; + } ZEND_FETCH_RESOURCE(resource, printer *, arg1, -1, "Printer Handle", PRINTERG(printer_id)); @@ -577,11 +562,11 @@ pval **arg1; printer *resource; - PRINTERLS_FETCH(); + PRINTERLS_FETCH(); - if ( zend_get_parameters_ex(1, &arg1) == FAILURE ) { - WRONG_PARAM_COUNT; - } + if( zend_get_parameters_ex(1, &arg1) == FAILURE ) { + WRONG_PARAM_COUNT; + } ZEND_FETCH_RESOURCE(resource, printer *, arg1, -1, "Printer Handle", PRINTERG(printer_id)); @@ -604,9 +589,9 @@ PRINTERLS_FETCH(); - if ( zend_get_parameters_ex(1, &arg1) == FAILURE ) { - WRONG_PARAM_COUNT; - } + if( zend_get_parameters_ex(1, &arg1) == FAILURE ) { + WRONG_PARAM_COUNT; + } ZEND_FETCH_RESOURCE(resource, printer *, arg1, -1, "Printer Handle", PRINTERG(printer_id)); @@ -629,9 +614,9 @@ PRINTERLS_FETCH(); - if ( zend_get_parameters_ex(1, &arg1) == FAILURE ) { - WRONG_PARAM_COUNT; - } + if( zend_get_parameters_ex(1, &arg1) == FAILURE ) { + WRONG_PARAM_COUNT; + } ZEND_FETCH_RESOURCE(resource, printer *, arg1, -1, "Printer Handle", PRINTERG(printer_id)); @@ -654,9 +639,9 @@ PRINTERLS_FETCH(); - if ( zend_get_parameters_ex(3, &arg1, &arg2, &arg3) == FAILURE ) { - WRONG_PARAM_COUNT; - } + if( zend_get_parameters_ex(3, &arg1, &arg2, &arg3) == FAILURE ) { + WRONG_PARAM_COUNT; + } convert_to_string_ex(arg1); convert_to_string_ex(arg3); @@ -664,7 +649,7 @@ pen->pointer = CreatePen(get_pen_style((*arg1)->value.str.val), (*arg2)->value.lval, hex_to_rgb((*arg3)->value.str.val)); - ZEND_REGISTER_RESOURCE(return_value, pen, PRINTERG(pen_id)); + ZEND_REGISTER_RESOURCE(return_value, pen, PRINTERG(pen_id)); } /* }}} */ @@ -678,13 +663,13 @@ PRINTERLS_FETCH(); - if ( zend_get_parameters_ex(1, &arg1) == FAILURE ) { - WRONG_PARAM_COUNT; - } + if( zend_get_parameters_ex(1, &arg1) == FAILURE ) { + WRONG_PARAM_COUNT; + } ZEND_FETCH_RESOURCE(pen, pen_struct *, arg1, -1, "Pen Handle", PRINTERG(pen_id)); - DeleteObject(pen->pointer); + DeleteObject(pen->pointer); } /* }}} */ @@ -699,8 +684,8 @@ PRINTERLS_FETCH(); - if ( zend_get_parameters_ex(2, &arg1, &arg2) == FAILURE ) { - WRONG_PARAM_COUNT; + if( zend_get_parameters_ex(2, &arg1, &arg2) == FAILURE ) { + WRONG_PARAM_COUNT; } ZEND_FETCH_RESOURCE(resource, printer *, arg1, -1, "Printer Handle", PRINTERG(printer_id)); @@ -720,19 +705,21 @@ PRINTERLS_FETCH(); - if ( zend_get_parameters_ex(2, &arg1, &arg2) == FAILURE ) { - WRONG_PARAM_COUNT; + if( zend_get_parameters_ex(2, &arg1, &arg2) == FAILURE ) { + WRONG_PARAM_COUNT; } convert_to_string_ex(arg1); convert_to_string_ex(arg2); - if(!strcmp((*arg1)->value.str.val,"solid")) + if(!strcmp((*arg1)->value.str.val,"solid")) { brush->pointer = CreateSolidBrush(hex_to_rgb((*arg2)->value.str.val)); - else + } + else { brush->pointer = CreateHatchBrush(hex_to_rgb((*arg2)->value.str.val), get_hatch_style((*arg1)->value.str.val)); + } - ZEND_REGISTER_RESOURCE(return_value, brush, PRINTERG(brush_id)); + ZEND_REGISTER_RESOURCE(return_value, brush, PRINTERG(brush_id)); } /* }}} */ @@ -746,8 +733,8 @@ PRINTERLS_FETCH(); - if ( zend_get_parameters_ex(1, &arg1) == FAILURE ) { - WRONG_PARAM_COUNT; + if( zend_get_parameters_ex(1, &arg1) == FAILURE ) { + WRONG_PARAM_COUNT; } ZEND_FETCH_RESOURCE(brush, brush_struct *, arg1, -1, "Brush Handle", PRINTERG(brush_id)); @@ -767,8 +754,8 @@ PRINTERLS_FETCH(); - if ( zend_get_parameters_ex(2, &arg1, &arg2) == FAILURE ) { - WRONG_PARAM_COUNT; + if( zend_get_parameters_ex(2, &arg1, &arg2) == FAILURE ) { + WRONG_PARAM_COUNT; } ZEND_FETCH_RESOURCE(resource, printer *, arg1, -1, "Printer Handle", PRINTERG(printer_id)); @@ -788,8 +775,8 @@ PRINTERLS_FETCH(); - if ( zend_get_parameters_ex(2, &arg1, &arg2) == FAILURE ) { - WRONG_PARAM_COUNT; + if( zend_get_parameters_ex(2, &arg1, &arg2) == FAILURE ) { + WRONG_PARAM_COUNT; } ZEND_FETCH_RESOURCE(resource, printer *, arg1, -1, "Printer Handle", PRINTERG(printer_id)); @@ -809,9 +796,9 @@ printer *resource; PRINTERLS_FETCH(); - - if ( zend_get_parameters_ex(7, &arg1, &arg2, &arg3, &arg4, &arg5, &arg6, &arg7) == FAILURE ) { - WRONG_PARAM_COUNT; + + if( zend_get_parameters_ex(7, &arg1, &arg2, &arg3, &arg4, &arg5, &arg6, &arg7) == FAILURE ) { + WRONG_PARAM_COUNT; } ZEND_FETCH_RESOURCE(resource, printer *, arg1, -1, "Printer Handle", PRINTERG(printer_id)); @@ -823,13 +810,7 @@ convert_to_long_ex(arg6); convert_to_long_ex(arg7); - RoundRect(resource->dc, - (*arg2)->value.lval, - (*arg3)->value.lval, - (*arg4)->value.lval, - (*arg5)->value.lval, - (*arg6)->value.lval, - (*arg7)->value.lval); + RoundRect(resource->dc, (*arg2)->value.lval, (*arg3)->value.lval, (*arg4)->value.lval, (*arg5)->value.lval, (*arg6)->value.lval, (*arg7)->value.lval); } /* }}} */ @@ -843,8 +824,8 @@ PRINTERLS_FETCH(); - if ( zend_get_parameters_ex(5, &arg1, &arg2, &arg3, &arg4, &arg5) == FAILURE ) { - WRONG_PARAM_COUNT; + if( zend_get_parameters_ex(5, &arg1, &arg2, &arg3, &arg4, &arg5) == FAILURE ) { + WRONG_PARAM_COUNT; } ZEND_FETCH_RESOURCE(resource, printer *, arg1, -1, "Printer Handle", PRINTERG(printer_id)); @@ -854,11 +835,7 @@ convert_to_long_ex(arg4); convert_to_long_ex(arg5); - Rectangle(resource->dc, - (*arg2)->value.lval, - (*arg3)->value.lval, - (*arg4)->value.lval, - (*arg5)->value.lval); + Rectangle(resource->dc, (*arg2)->value.lval, (*arg3)->value.lval, (*arg4)->value.lval, (*arg5)->value.lval); } /* }}} */ @@ -872,8 +849,8 @@ PRINTERLS_FETCH(); - if ( zend_get_parameters_ex(5, &arg1, &arg2, &arg3, &arg4, &arg5) == FAILURE ) { - WRONG_PARAM_COUNT; + if( zend_get_parameters_ex(5, &arg1, &arg2, &arg3, &arg4, &arg5) == FAILURE ) { + WRONG_PARAM_COUNT; } ZEND_FETCH_RESOURCE(resource, printer *, arg1, -1, "Printer Handle", PRINTERG(printer_id)); @@ -883,11 +860,7 @@ convert_to_long_ex(arg4); convert_to_long_ex(arg5); - Ellipse(resource->dc, - (*arg2)->value.lval, - (*arg3)->value.lval, - (*arg4)->value.lval, - (*arg5)->value.lval); + Ellipse(resource->dc, (*arg2)->value.lval, (*arg3)->value.lval, (*arg4)->value.lval, (*arg5)->value.lval); } /* }}} */ @@ -901,8 +874,8 @@ PRINTERLS_FETCH(); - if ( zend_get_parameters_ex(4, &arg1, &arg2, &arg3, &arg4) == FAILURE ) { - WRONG_PARAM_COUNT; + if( zend_get_parameters_ex(4, &arg1, &arg2, &arg3, &arg4) == FAILURE ) { + WRONG_PARAM_COUNT; } ZEND_FETCH_RESOURCE(resource, printer *, arg1, -1, "Printer Handle", PRINTERG(printer_id)); @@ -933,8 +906,8 @@ PRINTERLS_FETCH(); - if ( zend_get_parameters_ex(1, &arg1) == FAILURE ) { - WRONG_PARAM_COUNT; + if( zend_get_parameters_ex(1, &arg1) == FAILURE ) { + WRONG_PARAM_COUNT; } ZEND_FETCH_RESOURCE(font, font_struct *, arg1, -1, "Font Handle", PRINTERG(font_id)); @@ -954,8 +927,8 @@ PRINTERLS_FETCH(); - if ( zend_get_parameters_ex(2, &arg1, &arg2) == FAILURE ) { - WRONG_PARAM_COUNT; + if( zend_get_parameters_ex(2, &arg1, &arg2) == FAILURE ) { + WRONG_PARAM_COUNT; } ZEND_FETCH_RESOURCE(resource, printer *, arg1, -1, "Printer Handle", PRINTERG(printer_id)); @@ -965,13 +938,13 @@ } /* }}} */ + /* get the default printer */ char *get_default_printer(void) { PRINTER_INFO_2 *printer; DWORD need = sizeof(printer), received; - printer = emalloc(need); EnumPrinters(PRINTER_ENUM_DEFAULT, NULL, 2, (LPBYTE)printer, need, &need, &received); return printer->pPrinterName; } @@ -1016,13 +989,12 @@ int get_hatch_style(char *hatch) { int HS = HS_BDIAGONAL; - if(!strcmp(hatch,"bdiagonal")) HS = HS_BDIAGONAL; - else if(!strcmp(hatch,"cross")) HS = HS_CROSS; - else if(!strcmp(hatch,"diagcross")) HS = HS_DIAGCROSS; - else if(!strcmp(hatch,"fdiagonal")) HS = HS_FDIAGONAL; - else if(!strcmp(hatch,"horizontal")) HS = HS_HORIZONTAL; - else if(!strcmp(hatch,"vertical")) HS = HS_VERTICAL; - + if(!strcmp(hatch, "bdiagonal")) HS = HS_BDIAGONAL; + else if(!strcmp(hatch, "cross")) HS = HS_CROSS; + else if(!strcmp(hatch, "diagcross")) HS = HS_DIAGCROSS; + else if(!strcmp(hatch, "fdiagonal")) HS = HS_FDIAGONAL; + else if(!strcmp(hatch, "horizontal")) HS = HS_HORIZONTAL; + else if(!strcmp(hatch, "vertical")) HS = HS_VERTICAL; return HS; } @@ -1030,16 +1002,14 @@ int _print_enumvalue(char * EnumStr) { int EV = PRINTER_ENUM_LOCAL; - php_strtoupper(EnumStr, strlen(EnumStr)); - if (!strcmp(EnumStr, "PRINTER_ENUM_LOCAL")) EV = PRINTER_ENUM_LOCAL; - if (!strcmp(EnumStr, "PRINTER_ENUM_NAME")) EV = PRINTER_ENUM_NAME; - if (!strcmp(EnumStr, "PRINTER_ENUM_SHARED")) EV = PRINTER_ENUM_SHARED; - if (!strcmp(EnumStr, "PRINTER_ENUM_DEFAULT")) EV = PRINTER_ENUM_DEFAULT; - if (!strcmp(EnumStr, "PRINTER_ENUM_CONNECTIONS")) EV = PRINTER_ENUM_CONNECTIONS; - if (!strcmp(EnumStr, "PRINTER_ENUM_NETWORK")) EV = PRINTER_ENUM_NETWORK; - if (!strcmp(EnumStr, "PRINTER_ENUM_REMOTE")) EV = PRINTER_ENUM_REMOTE; - + if(!strcmp(EnumStr, "PRINTER_ENUM_LOCAL")) EV = PRINTER_ENUM_LOCAL; + if(!strcmp(EnumStr, "PRINTER_ENUM_NAME")) EV = PRINTER_ENUM_NAME; + if(!strcmp(EnumStr, "PRINTER_ENUM_SHARED")) EV = PRINTER_ENUM_SHARED; + if(!strcmp(EnumStr, "PRINTER_ENUM_DEFAULT")) EV = PRINTER_ENUM_DEFAULT; + if(!strcmp(EnumStr, "PRINTER_ENUM_CONNECTIONS")) EV = PRINTER_ENUM_CONNECTIONS; + if(!strcmp(EnumStr, "PRINTER_ENUM_NETWORK")) EV = PRINTER_ENUM_NETWORK; + if(!strcmp(EnumStr, "PRINTER_ENUM_REMOTE")) EV = PRINTER_ENUM_REMOTE; return EV; } @@ -1047,7 +1017,7 @@ /* resource deallocation */ static void destroy_ressources(zend_rsrc_list_entry *resource) { - efree(resource); + efree(resource); } #endif
« previous php.cvs (#2501) next »