Update graphics/pecl-imlib2 to version 0.1.00_6
[dports.git] / graphics / pecl-imlib2 / files / patch-imlib2.c
1 --- imlib2.c    2004-01-01 18:57:55.000000000 -0500
2 +++ imlib2.c    2015-04-09 12:48:55.000000000 -0400
3 @@ -26,6 +26,7 @@
4  
5  #include "php.h"
6  #include "php_ini.h"
7 +#include "ext/standard/head.h"
8  #include "ext/standard/info.h"
9  #include "php_imlib2.h"
10  #include <Imlib2.h>
11 @@ -47,8 +48,12 @@
12  static int le_imlib2_img;
13  static int le_imlib2_poly;
14  
15 +ZEND_BEGIN_ARG_INFO(second_arg_force_ref, 0)
16 +       ZEND_ARG_PASS_INFO(0)
17 +       ZEND_ARG_PASS_INFO(1)
18 +       ZEND_END_ARG_INFO();
19  
20 -function_entry imlib2_functions[] = {
21 +zend_function_entry imlib2_functions[] = {
22         PHP_FE(imlib2_image_modify_gamma,NULL)
23         PHP_FE(imlib2_image_modify_contrast,NULL)
24         PHP_FE(imlib2_image_modify_brightness,NULL)
25 @@ -271,8 +276,8 @@
26     *four = Z_LVAL_PP(zfour);
27  }
28  
29 -static int _php_handle_cliprect_array(zval **dbox, char *func_name,
30 -                                      int *x, int *y, int *w, int *h)
31 +static int _php_handle_cliprect_array(zval **dbox, const char *func_name,
32 +                                      int *x, int *y, int *w, int *h TSRMLS_DC)
33  {
34     zval **element, ***box_coords;
35     int i,arrcount;
36 @@ -382,7 +387,7 @@
37  }
38  
39  
40 -static void _php_imlib2_draw_something(INTERNAL_FUNCTION_PARAMETERS, void (*func)(), char *func_name)
41 +static void _php_imlib2_draw_something(INTERNAL_FUNCTION_PARAMETERS, void (*func)(), const char *func_name)
42  {
43     zval **img, **d1, **d2, **d3, **d4, **dr, **dg, **db, **da, **dbox;
44     int x,y,w,h,r,g,b,a,cx,cy,cw,ch,argc;
45 @@ -407,7 +412,7 @@
46  
47     if (argc > 9)
48     {
49 -      if (!_php_handle_cliprect_array(dbox, func_name, &cx,&cy,&cw,&ch))
50 +      if (!_php_handle_cliprect_array(dbox, func_name, &cx,&cy,&cw,&ch TSRMLS_CC))
51           RETURN_FALSE;
52        imlib_context_set_cliprect(cx,cy,cw,ch);
53     }
54 @@ -643,8 +648,8 @@
55         zval **img, **gamma;
56         Imlib_Image im;
57         Imlib_Color_Modifier cm;
58 -       IMLIB2_LS_FETCH();
59         double ng;
60 +       IMLIB2_LS_FETCH();
61  
62         if (ZEND_NUM_ARGS() != 2 | zend_get_parameters_ex(2, &img, &gamma) == FAILURE) {
63                 WRONG_PARAM_COUNT;
64 @@ -654,7 +659,7 @@
65  
66         ng = Z_DVAL_PP(gamma);
67  
68 -       if(cm = imlib_create_color_modifier()){
69 +       if ((cm = imlib_create_color_modifier())) {
70                 imlib_context_set_color_modifier(cm);
71                 imlib_context_set_image(im);
72                 imlib_modify_color_modifier_gamma(ng);
73 @@ -675,8 +680,8 @@
74         zval **img, **contrast;
75         Imlib_Image im;
76         Imlib_Color_Modifier cm;
77 -       IMLIB2_LS_FETCH();
78         double nc;
79 +       IMLIB2_LS_FETCH();
80  
81         if (ZEND_NUM_ARGS() != 2 | zend_get_parameters_ex(2, &img, &contrast) == FAILURE) {
82                 WRONG_PARAM_COUNT;
83 @@ -686,7 +691,7 @@
84  
85         nc = Z_DVAL_PP(contrast);
86  
87 -       if(cm = imlib_create_color_modifier()){
88 +       if ((cm = imlib_create_color_modifier())) {
89                 imlib_context_set_color_modifier(cm);
90                 imlib_context_set_image(im);
91                 imlib_modify_color_modifier_contrast(nc);
92 @@ -707,8 +712,8 @@
93         zval **img, **bv;
94         Imlib_Image im;
95         Imlib_Color_Modifier cm;
96 -       IMLIB2_LS_FETCH();
97         double nbv;
98 +       IMLIB2_LS_FETCH();
99  
100         if (ZEND_NUM_ARGS() != 2 | zend_get_parameters_ex(2, &img, &bv) == FAILURE) {
101                 WRONG_PARAM_COUNT;
102 @@ -718,7 +723,7 @@
103  
104         nbv = Z_DVAL_PP(bv);
105  
106 -       if(cm = imlib_create_color_modifier()){
107 +       if ((cm = imlib_create_color_modifier())) {
108                 imlib_context_set_color_modifier(cm);
109                 imlib_context_set_image(im);
110                 imlib_modify_color_modifier_brightness(nbv);
111 @@ -760,9 +765,9 @@
112  {
113         zval **img, **angle;
114         double rot_angle, rads, pi;
115 -       pi = 3.141592653;
116         Imlib_Image src_img, dst_img;
117         IMLIB2_LS_FETCH();
118 +       pi = 3.141592653;
119  
120         if((ZEND_NUM_ARGS() != 2) || zend_get_parameters_ex(2, &img, &angle) == FAILURE) {
121                 WRONG_PARAM_COUNT;
122 @@ -806,7 +811,7 @@
123     tmpfile = estrdup("/tmp/phpimlib.XXXXXX");
124  
125     if ((fd = mkstemp(tmpfile)) < 0) {
126 -      php_error(E_WARNING, "%s: unable to open temporary file", get_active_function_name());
127 +      php_error(E_WARNING, "%s: unable to open temporary file", get_active_function_name(TSRMLS_C));
128        efree(tmpfile);
129        RETURN_FALSE;
130     }
131 @@ -814,7 +819,7 @@
132     /* TODO: notify in case of errors? */
133     retval = fchmod(fd, S_IRUSR|S_IWUSR);
134     if (retval != 0) {
135 -      php_error(E_WARNING, "%s: could not change permissions on temporary file", get_active_function_name());
136 +      php_error(E_WARNING, "%s: could not change permissions on temporary file", get_active_function_name(TSRMLS_C));
137        close(fd);
138        efree(tmpfile);
139        RETURN_FALSE;
140 @@ -851,7 +856,7 @@
141     /* fseek or something, then read the file and dump it out. */
142     lseek(fd, 0, SEEK_SET);
143  
144 -   output = php_header();
145 +   output = php_header(TSRMLS_C);
146     if (output) {
147        char buf[4096];
148  
149 @@ -861,7 +866,7 @@
150        ap_bsetflag(php3_rqst->connection->client, B_EBCDIC2ASCII, 0);
151  #endif
152        while ((retval = read(fd, buf, sizeof(buf))) > 0) {
153 -         php_write(buf, retval);
154 +         php_write(buf, retval TSRMLS_CC);
155        }
156     }
157  
158 @@ -1254,7 +1259,7 @@
159  
160     if (argc > 7)
161     {
162 -      if (!_php_handle_cliprect_array(dbox, "imlib_image_draw_polygon", &cx, &cy, &cw, &ch))
163 +      if (!_php_handle_cliprect_array(dbox, "imlib_image_draw_polygon", &cx, &cy, &cw, &ch TSRMLS_CC))
164           RETURN_FALSE;
165        imlib_context_set_cliprect(cx,cy,cw,ch);
166     }
167 @@ -1303,7 +1308,7 @@
168  
169     if (argc > 7)
170     {
171 -      if (!_php_handle_cliprect_array(fbox, "imlib_image_fill_color_range_rectangle", &cx,&cy,&cw,&ch))
172 +      if (!_php_handle_cliprect_array(fbox, "imlib_image_fill_color_range_rectangle", &cx,&cy,&cw,&ch TSRMLS_CC))
173           RETURN_FALSE;
174        imlib_context_set_cliprect(cx,cy,cw,ch);
175     }
176 @@ -1350,7 +1355,7 @@
177  
178     if (argc > 6)
179     {
180 -      if (!_php_handle_cliprect_array(dbox, "imlib_image_fill_polygon", &cx, &cy, &cw, &ch))
181 +      if (!_php_handle_cliprect_array(dbox, "imlib_image_fill_polygon", &cx, &cy, &cw, &ch TSRMLS_CC))
182           RETURN_FALSE;
183        imlib_context_set_cliprect(cx,cy,cw,ch);
184     }