cvs: php4 /ext/printer printer.c
| From: | Frank M. Kromann | Date: | Fri, 27 Oct 2000 20:54:23 +0000 |
| Subject: | cvs: php4 /ext/printer printer.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-2320@lists.php.net to get a copy of this message | ||
fmk Fri Oct 27 13:54:23 2000 EDT
Modified files:
/php4/ext/printer printer.c
Log:
Fixing problems in function caused by wrong use of function.
Index: php4/ext/printer/printer.c
diff -u php4/ext/printer/printer.c:1.4 php4/ext/printer/printer.c:1.5
--- php4/ext/printer/printer.c:1.4 Fri Oct 27 13:28:00 2000
+++ php4/ext/printer/printer.c Fri Oct 27 13:54:23 2000
@@ -17,14 +17,13 @@
+----------------------------------------------------------------------+
*/
-/* $Id: printer.c,v 1.4 2000/10/27 20:28:00 fmk Exp $ */
+/* $Id: printer.c,v 1.5 2000/10/27 20:54:23 fmk Exp $ */
#include "php.h"
#include "php_ini.h"
#include "ext/standard/php_string.h"
#include "ext/standard/info.h"
#include "ext/standard/php_math.h"
-#include <math.h>
#include "php_printer.h"
@@ -54,6 +53,7 @@
static void destroy_ressources(zend_rsrc_list_entry *resource);
int _print_enumvalue(char * EnumStr);
+
function_entry printer_functions[] = {
PHP_FE(printer_open, NULL)
PHP_FE(printer_close, NULL)
@@ -108,7 +108,7 @@
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.4
2000/10/27 20:28:00 fmk Exp $");
+ 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();
}
@@ -264,7 +264,7 @@
Return an array of printers attached to the server */
PHP_FUNCTION(printer_list)
{
- zval *Printer, *Printer_ptr, *arg1, *arg2, *arg3;
+ zval *Printer, *Printer_ptr, **arg1, **arg2, **arg3;
char InfoBuffer[8192];
LPTSTR Name;
PRINTER_INFO_1 *P1;
@@ -277,20 +277,20 @@
argc = ARG_COUNT(ht);
- if (argc < 1 || argc > 3 || getParameters(ht, argc, &arg1, &arg2, &arg3) ==
FAILURE) {
+ if (argc < 1 || argc > 3 || zend_get_parameters_ex(ht, argc, &arg1, &arg2,
&arg3) == FAILURE) {
WRONG_PARAM_COUNT;
}
- convert_to_string(arg1);
- EnumVal = _print_enumvalue(arg1->value.str.val);
+ convert_to_string_ex(arg1);
+ EnumVal = _print_enumvalue((*arg1)->value.str.val);
if (argc > 1) {
- convert_to_string(arg2);
- Name = arg2->value.str.val;
+ convert_to_string_ex(arg2);
+ Name = (*arg2)->value.str.val;
if (strlen(Name) == 0)
Name = NULL;
}
if (argc > 2) {
- convert_to_long(arg3);
- Level = (int)arg3->value.lval;
+ convert_to_long_ex(arg3);
+ Level = (int)(*arg3)->value.lval;
if (!LevvelsAllowed[Level]) {
RETURN_FALSE;
}
@@ -976,24 +976,23 @@
return printer->pPrinterName;
}
+#define hex2dec(a) (a>='A')?a-'A'+10:a-'0'
+
/* convert a hexadecimal number to the rgb colorref */
COLORREF hex_to_rgb(char* hex)
{
int r = 0,g = 0,b = 0, len;
- char tmp[3];
len = strlen(hex);
+ php_strtoupper(hex, len);
if (len >= 2) {
- strncpy(tmp, hex, 2);
- r = _php_math_basetolong(tmp, 16);
+ r = hex2dec(hex[0])*16 + hex2dec(hex[1]);
}
if (len >= 4) {
- strncpy(tmp, hex+2, 2);
- g = _php_math_basetolong(tmp, 16);
+ g = hex2dec(hex[2])*16 + hex2dec(hex[3]);
}
if (len == 6) {
- strncpy(tmp, hex+4, 2);
- b = _php_math_basetolong(tmp, 16);
+ b = hex2dec(hex[4])*16 + hex2dec(hex[5]);
}
return RGB(r,g,b);