@@ -59,20 +59,11 @@ PHPAPI const char php_sig_heix[4] = {'h', 'e', 'i', 'x'};
59
59
/* REMEMBER TO ADD MIME-TYPE TO FUNCTION php_image_type_to_mime_type */
60
60
/* PCX must check first 64bytes and byte 0=0x0a and byte2 < 0x06 */
61
61
62
- /* return info as a struct, to make expansion easier */
63
-
64
- struct gfxinfo {
65
- unsigned int width ;
66
- unsigned int height ;
67
- unsigned int bits ;
68
- unsigned int channels ;
69
- };
70
-
71
62
/* {{{ php_handle_gif
72
63
* routine to handle GIF files. If only everything were that easy... ;} */
73
- static struct gfxinfo * php_handle_gif (php_stream * stream )
64
+ static struct php_gfxinfo * php_handle_gif (php_stream * stream )
74
65
{
75
- struct gfxinfo * result = NULL ;
66
+ struct php_gfxinfo * result = NULL ;
76
67
unsigned char dim [5 ];
77
68
78
69
if (php_stream_seek (stream , 3 , SEEK_CUR ))
@@ -81,7 +72,7 @@ static struct gfxinfo *php_handle_gif (php_stream * stream)
81
72
if (php_stream_read (stream , (char * )dim , sizeof (dim )) != sizeof (dim ))
82
73
return NULL ;
83
74
84
- result = (struct gfxinfo * ) ecalloc (1 , sizeof (struct gfxinfo ));
75
+ result = (struct php_gfxinfo * ) ecalloc (1 , sizeof (struct php_gfxinfo ));
85
76
result -> width = (unsigned int )dim [0 ] | (((unsigned int )dim [1 ])<<8 );
86
77
result -> height = (unsigned int )dim [2 ] | (((unsigned int )dim [3 ])<<8 );
87
78
result -> bits = dim [4 ]& 0x80 ? ((((unsigned int )dim [4 ])& 0x07 ) + 1 ) : 0 ;
@@ -92,9 +83,9 @@ static struct gfxinfo *php_handle_gif (php_stream * stream)
92
83
/* }}} */
93
84
94
85
/* {{{ php_handle_psd */
95
- static struct gfxinfo * php_handle_psd (php_stream * stream )
86
+ static struct php_gfxinfo * php_handle_psd (php_stream * stream )
96
87
{
97
- struct gfxinfo * result = NULL ;
88
+ struct php_gfxinfo * result = NULL ;
98
89
unsigned char dim [8 ];
99
90
100
91
if (php_stream_seek (stream , 11 , SEEK_CUR ))
@@ -103,7 +94,7 @@ static struct gfxinfo *php_handle_psd (php_stream * stream)
103
94
if (php_stream_read (stream , (char * )dim , sizeof (dim )) != sizeof (dim ))
104
95
return NULL ;
105
96
106
- result = (struct gfxinfo * ) ecalloc (1 , sizeof (struct gfxinfo ));
97
+ result = (struct php_gfxinfo * ) ecalloc (1 , sizeof (struct php_gfxinfo ));
107
98
result -> height = (((unsigned int )dim [0 ]) << 24 ) + (((unsigned int )dim [1 ]) << 16 ) + (((unsigned int )dim [2 ]) << 8 ) + ((unsigned int )dim [3 ]);
108
99
result -> width = (((unsigned int )dim [4 ]) << 24 ) + (((unsigned int )dim [5 ]) << 16 ) + (((unsigned int )dim [6 ]) << 8 ) + ((unsigned int )dim [7 ]);
109
100
@@ -112,9 +103,9 @@ static struct gfxinfo *php_handle_psd (php_stream * stream)
112
103
/* }}} */
113
104
114
105
/* {{{ php_handle_bmp */
115
- static struct gfxinfo * php_handle_bmp (php_stream * stream )
106
+ static struct php_gfxinfo * php_handle_bmp (php_stream * stream )
116
107
{
117
- struct gfxinfo * result = NULL ;
108
+ struct php_gfxinfo * result = NULL ;
118
109
unsigned char dim [16 ];
119
110
int size ;
120
111
@@ -126,12 +117,12 @@ static struct gfxinfo *php_handle_bmp (php_stream * stream)
126
117
127
118
size = (((unsigned int )dim [ 3 ]) << 24 ) + (((unsigned int )dim [ 2 ]) << 16 ) + (((unsigned int )dim [ 1 ]) << 8 ) + ((unsigned int ) dim [ 0 ]);
128
119
if (size == 12 ) {
129
- result = (struct gfxinfo * ) ecalloc (1 , sizeof (struct gfxinfo ));
120
+ result = (struct php_gfxinfo * ) ecalloc (1 , sizeof (struct php_gfxinfo ));
130
121
result -> width = (((unsigned int )dim [ 5 ]) << 8 ) + ((unsigned int ) dim [ 4 ]);
131
122
result -> height = (((unsigned int )dim [ 7 ]) << 8 ) + ((unsigned int ) dim [ 6 ]);
132
123
result -> bits = ((unsigned int )dim [11 ]);
133
124
} else if (size > 12 && (size <= 64 || size == 108 || size == 124 )) {
134
- result = (struct gfxinfo * ) ecalloc (1 , sizeof (struct gfxinfo ));
125
+ result = (struct php_gfxinfo * ) ecalloc (1 , sizeof (struct php_gfxinfo ));
135
126
result -> width = (((unsigned int )dim [ 7 ]) << 24 ) + (((unsigned int )dim [ 6 ]) << 16 ) + (((unsigned int )dim [ 5 ]) << 8 ) + ((unsigned int ) dim [ 4 ]);
136
127
result -> height = (((unsigned int )dim [11 ]) << 24 ) + (((unsigned int )dim [10 ]) << 16 ) + (((unsigned int )dim [ 9 ]) << 8 ) + ((unsigned int ) dim [ 8 ]);
137
128
result -> height = abs ((int32_t )result -> height );
@@ -162,9 +153,9 @@ static unsigned long int php_swf_get_bits (unsigned char* buffer, unsigned int p
162
153
163
154
#if defined(HAVE_ZLIB ) && !defined(COMPILE_DL_ZLIB )
164
155
/* {{{ php_handle_swc */
165
- static struct gfxinfo * php_handle_swc (php_stream * stream )
156
+ static struct php_gfxinfo * php_handle_swc (php_stream * stream )
166
157
{
167
- struct gfxinfo * result = NULL ;
158
+ struct php_gfxinfo * result = NULL ;
168
159
169
160
long bits ;
170
161
unsigned char a [64 ];
@@ -231,7 +222,7 @@ static struct gfxinfo *php_handle_swc(php_stream * stream)
231
222
}
232
223
233
224
if (!status ) {
234
- result = (struct gfxinfo * ) ecalloc (1 , sizeof (struct gfxinfo ));
225
+ result = (struct php_gfxinfo * ) ecalloc (1 , sizeof (struct php_gfxinfo ));
235
226
bits = php_swf_get_bits (b , 0 , 5 );
236
227
result -> width = (php_swf_get_bits (b , 5 + bits , bits ) -
237
228
php_swf_get_bits (b , 5 , bits )) / 20 ;
@@ -248,9 +239,9 @@ static struct gfxinfo *php_handle_swc(php_stream * stream)
248
239
#endif
249
240
250
241
/* {{{ php_handle_swf */
251
- static struct gfxinfo * php_handle_swf (php_stream * stream )
242
+ static struct php_gfxinfo * php_handle_swf (php_stream * stream )
252
243
{
253
- struct gfxinfo * result = NULL ;
244
+ struct php_gfxinfo * result = NULL ;
254
245
long bits ;
255
246
unsigned char a [32 ];
256
247
@@ -260,7 +251,7 @@ static struct gfxinfo *php_handle_swf (php_stream * stream)
260
251
if (php_stream_read (stream , (char * )a , sizeof (a )) != sizeof (a ))
261
252
return NULL ;
262
253
263
- result = (struct gfxinfo * ) ecalloc (1 , sizeof (struct gfxinfo ));
254
+ result = (struct php_gfxinfo * ) ecalloc (1 , sizeof (struct php_gfxinfo ));
264
255
bits = php_swf_get_bits (a , 0 , 5 );
265
256
result -> width = (php_swf_get_bits (a , 5 + bits , bits ) -
266
257
php_swf_get_bits (a , 5 , bits )) / 20 ;
@@ -274,9 +265,9 @@ static struct gfxinfo *php_handle_swf (php_stream * stream)
274
265
275
266
/* {{{ php_handle_png
276
267
* routine to handle PNG files */
277
- static struct gfxinfo * php_handle_png (php_stream * stream )
268
+ static struct php_gfxinfo * php_handle_png (php_stream * stream )
278
269
{
279
- struct gfxinfo * result = NULL ;
270
+ struct php_gfxinfo * result = NULL ;
280
271
unsigned char dim [9 ];
281
272
/* Width: 4 bytes
282
273
* Height: 4 bytes
@@ -293,7 +284,7 @@ static struct gfxinfo *php_handle_png (php_stream * stream)
293
284
if ((php_stream_read (stream , (char * )dim , sizeof (dim ))) < sizeof (dim ))
294
285
return NULL ;
295
286
296
- result = (struct gfxinfo * ) ecalloc (1 , sizeof (struct gfxinfo ));
287
+ result = (struct php_gfxinfo * ) ecalloc (1 , sizeof (struct php_gfxinfo ));
297
288
result -> width = (((unsigned int )dim [0 ]) << 24 ) + (((unsigned int )dim [1 ]) << 16 ) + (((unsigned int )dim [2 ]) << 8 ) + ((unsigned int )dim [3 ]);
298
289
result -> height = (((unsigned int )dim [4 ]) << 24 ) + (((unsigned int )dim [5 ]) << 16 ) + (((unsigned int )dim [6 ]) << 8 ) + ((unsigned int )dim [7 ]);
299
290
result -> bits = (unsigned int )dim [8 ];
@@ -452,9 +443,9 @@ static int php_read_APP(php_stream * stream, unsigned int marker, zval *info)
452
443
453
444
/* {{{ php_handle_jpeg
454
445
main loop to parse JPEG structure */
455
- static struct gfxinfo * php_handle_jpeg (php_stream * stream , zval * info )
446
+ static struct php_gfxinfo * php_handle_jpeg (php_stream * stream , zval * info )
456
447
{
457
- struct gfxinfo * result = NULL ;
448
+ struct php_gfxinfo * result = NULL ;
458
449
unsigned int marker = M_PSEUDO ;
459
450
unsigned short length , ff_read = 1 ;
460
451
@@ -477,7 +468,7 @@ static struct gfxinfo *php_handle_jpeg (php_stream * stream, zval *info)
477
468
case M_SOF15 :
478
469
if (result == NULL ) {
479
470
/* handle SOFn block */
480
- result = (struct gfxinfo * ) ecalloc (1 , sizeof (struct gfxinfo ));
471
+ result = (struct php_gfxinfo * ) ecalloc (1 , sizeof (struct php_gfxinfo ));
481
472
length = php_read2 (stream );
482
473
result -> bits = php_stream_getc (stream );
483
474
result -> height = php_read2 (stream );
@@ -580,9 +571,9 @@ static unsigned int php_read4(php_stream * stream)
580
571
581
572
/* {{{ php_handle_jpc
582
573
Main loop to parse JPEG2000 raw codestream structure */
583
- static struct gfxinfo * php_handle_jpc (php_stream * stream )
574
+ static struct php_gfxinfo * php_handle_jpc (php_stream * stream )
584
575
{
585
- struct gfxinfo * result = NULL ;
576
+ struct php_gfxinfo * result = NULL ;
586
577
int highest_bit_depth , bit_depth ;
587
578
unsigned char first_marker_id ;
588
579
unsigned int i ;
@@ -603,7 +594,7 @@ static struct gfxinfo *php_handle_jpc(php_stream * stream)
603
594
return NULL ;
604
595
}
605
596
606
- result = (struct gfxinfo * )ecalloc (1 , sizeof (struct gfxinfo ));
597
+ result = (struct php_gfxinfo * )ecalloc (1 , sizeof (struct php_gfxinfo ));
607
598
608
599
php_read2 (stream ); /* Lsiz */
609
600
php_read2 (stream ); /* Rsiz */
@@ -651,9 +642,9 @@ static struct gfxinfo *php_handle_jpc(php_stream * stream)
651
642
652
643
/* {{{ php_handle_jp2
653
644
main loop to parse JPEG 2000 JP2 wrapper format structure */
654
- static struct gfxinfo * php_handle_jp2 (php_stream * stream )
645
+ static struct php_gfxinfo * php_handle_jp2 (php_stream * stream )
655
646
{
656
- struct gfxinfo * result = NULL ;
647
+ struct php_gfxinfo * result = NULL ;
657
648
unsigned int box_length ;
658
649
unsigned int box_type ;
659
650
char jp2c_box_id [] = {(char )0x6a , (char )0x70 , (char )0x32 , (char )0x63 };
@@ -777,9 +768,9 @@ static unsigned php_ifd_get32u(void *Long, int motorola_intel)
777
768
778
769
/* {{{ php_handle_tiff
779
770
main loop to parse TIFF structure */
780
- static struct gfxinfo * php_handle_tiff (php_stream * stream , zval * info , int motorola_intel )
771
+ static struct php_gfxinfo * php_handle_tiff (php_stream * stream , zval * info , int motorola_intel )
781
772
{
782
- struct gfxinfo * result = NULL ;
773
+ struct php_gfxinfo * result = NULL ;
783
774
int i , num_entries ;
784
775
unsigned char * dir_entry ;
785
776
size_t ifd_size , dir_size , entry_value , width = 0 , height = 0 , ifd_addr ;
@@ -845,7 +836,7 @@ static struct gfxinfo *php_handle_tiff (php_stream * stream, zval *info, int mot
845
836
efree (ifd_data );
846
837
if ( width && height ) {
847
838
/* not the same when in for-loop */
848
- result = (struct gfxinfo * ) ecalloc (1 , sizeof (struct gfxinfo ));
839
+ result = (struct php_gfxinfo * ) ecalloc (1 , sizeof (struct php_gfxinfo ));
849
840
result -> height = height ;
850
841
result -> width = width ;
851
842
result -> bits = 0 ;
@@ -857,9 +848,9 @@ static struct gfxinfo *php_handle_tiff (php_stream * stream, zval *info, int mot
857
848
/* }}} */
858
849
859
850
/* {{{ php_handle_psd */
860
- static struct gfxinfo * php_handle_iff (php_stream * stream )
851
+ static struct php_gfxinfo * php_handle_iff (php_stream * stream )
861
852
{
862
- struct gfxinfo * result ;
853
+ struct php_gfxinfo * result ;
863
854
unsigned char a [10 ];
864
855
int chunkId ;
865
856
int size ;
@@ -893,7 +884,7 @@ static struct gfxinfo *php_handle_iff(php_stream * stream)
893
884
height = php_ifd_get16s (a + 2 , 1 );
894
885
bits = a [8 ] & 0xff ;
895
886
if (width > 0 && height > 0 && bits > 0 && bits < 33 ) {
896
- result = (struct gfxinfo * ) ecalloc (1 , sizeof (struct gfxinfo ));
887
+ result = (struct php_gfxinfo * ) ecalloc (1 , sizeof (struct php_gfxinfo ));
897
888
result -> width = width ;
898
889
result -> height = height ;
899
890
result -> bits = bits ;
@@ -918,7 +909,7 @@ static struct gfxinfo *php_handle_iff(php_stream * stream)
918
909
* int Number of columns
919
910
* int Number of rows
920
911
*/
921
- static int php_get_wbmp (php_stream * stream , struct gfxinfo * * result , int check )
912
+ static int php_get_wbmp (php_stream * stream , struct php_gfxinfo * * result , int check )
922
913
{
923
914
int i , width = 0 , height = 0 ;
924
915
@@ -979,9 +970,9 @@ static int php_get_wbmp(php_stream *stream, struct gfxinfo **result, int check)
979
970
/* }}} */
980
971
981
972
/* {{{ php_handle_wbmp */
982
- static struct gfxinfo * php_handle_wbmp (php_stream * stream )
973
+ static struct php_gfxinfo * php_handle_wbmp (php_stream * stream )
983
974
{
984
- struct gfxinfo * result = (struct gfxinfo * ) ecalloc (1 , sizeof (struct gfxinfo ));
975
+ struct php_gfxinfo * result = (struct php_gfxinfo * ) ecalloc (1 , sizeof (struct php_gfxinfo ));
985
976
986
977
if (!php_get_wbmp (stream , & result , 0 )) {
987
978
efree (result );
@@ -993,7 +984,7 @@ static struct gfxinfo *php_handle_wbmp(php_stream * stream)
993
984
/* }}} */
994
985
995
986
/* {{{ php_get_xbm */
996
- static int php_get_xbm (php_stream * stream , struct gfxinfo * * result )
987
+ static int php_get_xbm (php_stream * stream , struct php_gfxinfo * * result )
997
988
{
998
989
char * fline ;
999
990
char * iname ;
@@ -1040,7 +1031,7 @@ static int php_get_xbm(php_stream *stream, struct gfxinfo **result)
1040
1031
1041
1032
if (width && height ) {
1042
1033
if (result ) {
1043
- * result = (struct gfxinfo * ) ecalloc (1 , sizeof (struct gfxinfo ));
1034
+ * result = (struct php_gfxinfo * ) ecalloc (1 , sizeof (struct php_gfxinfo ));
1044
1035
(* result )-> width = width ;
1045
1036
(* result )-> height = height ;
1046
1037
}
@@ -1052,18 +1043,18 @@ static int php_get_xbm(php_stream *stream, struct gfxinfo **result)
1052
1043
/* }}} */
1053
1044
1054
1045
/* {{{ php_handle_xbm */
1055
- static struct gfxinfo * php_handle_xbm (php_stream * stream )
1046
+ static struct php_gfxinfo * php_handle_xbm (php_stream * stream )
1056
1047
{
1057
- struct gfxinfo * result ;
1048
+ struct php_gfxinfo * result ;
1058
1049
php_get_xbm (stream , & result );
1059
1050
return result ;
1060
1051
}
1061
1052
/* }}} */
1062
1053
1063
1054
/* {{{ php_handle_ico */
1064
- static struct gfxinfo * php_handle_ico (php_stream * stream )
1055
+ static struct php_gfxinfo * php_handle_ico (php_stream * stream )
1065
1056
{
1066
- struct gfxinfo * result = NULL ;
1057
+ struct php_gfxinfo * result = NULL ;
1067
1058
unsigned char dim [16 ];
1068
1059
int num_icons = 0 ;
1069
1060
@@ -1075,7 +1066,7 @@ static struct gfxinfo *php_handle_ico(php_stream * stream)
1075
1066
if (num_icons < 1 || num_icons > 255 )
1076
1067
return NULL ;
1077
1068
1078
- result = (struct gfxinfo * ) ecalloc (1 , sizeof (struct gfxinfo ));
1069
+ result = (struct php_gfxinfo * ) ecalloc (1 , sizeof (struct php_gfxinfo ));
1079
1070
1080
1071
while (num_icons > 0 )
1081
1072
{
@@ -1102,9 +1093,9 @@ static struct gfxinfo *php_handle_ico(php_stream * stream)
1102
1093
/* }}} */
1103
1094
1104
1095
/* {{{ php_handle_webp */
1105
- static struct gfxinfo * php_handle_webp (php_stream * stream )
1096
+ static struct php_gfxinfo * php_handle_webp (php_stream * stream )
1106
1097
{
1107
- struct gfxinfo * result = NULL ;
1098
+ struct php_gfxinfo * result = NULL ;
1108
1099
const char sig [3 ] = {'V' , 'P' , '8' };
1109
1100
unsigned char buf [18 ];
1110
1101
char format ;
@@ -1125,7 +1116,7 @@ static struct gfxinfo *php_handle_webp(php_stream * stream)
1125
1116
return NULL ;
1126
1117
}
1127
1118
1128
- result = (struct gfxinfo * ) ecalloc (1 , sizeof (struct gfxinfo ));
1119
+ result = (struct php_gfxinfo * ) ecalloc (1 , sizeof (struct php_gfxinfo ));
1129
1120
1130
1121
switch (format ) {
1131
1122
case ' ' :
@@ -1187,14 +1178,14 @@ static void php_avif_stream_skip(void* stream, size_t num_bytes) {
1187
1178
* declared as invalid. Around 450 bytes are usually enough.
1188
1179
* Transforms such as mirror and rotation are not applied on width and height.
1189
1180
*/
1190
- static struct gfxinfo * php_handle_avif (php_stream * stream ) {
1191
- struct gfxinfo * result = NULL ;
1181
+ static struct php_gfxinfo * php_handle_avif (php_stream * stream ) {
1182
+ struct php_gfxinfo * result = NULL ;
1192
1183
AvifInfoFeatures features ;
1193
1184
struct php_avif_stream avif_stream ;
1194
1185
avif_stream .stream = stream ;
1195
1186
1196
1187
if (AvifInfoGetFeaturesStream (& avif_stream , php_avif_stream_read , php_avif_stream_skip , & features ) == kAvifInfoOk ) {
1197
- result = (struct gfxinfo * )ecalloc (1 , sizeof (struct gfxinfo ));
1188
+ result = (struct php_gfxinfo * )ecalloc (1 , sizeof (struct php_gfxinfo ));
1198
1189
result -> width = features .width ;
1199
1190
result -> height = features .height ;
1200
1191
result -> bits = features .bit_depth ;
@@ -1463,7 +1454,7 @@ PHPAPI int php_getimagetype(php_stream *stream, const char *input, char *filetyp
1463
1454
static void php_getimagesize_from_stream (php_stream * stream , char * input , zval * info , INTERNAL_FUNCTION_PARAMETERS ) /* {{{ */
1464
1455
{
1465
1456
int itype = 0 ;
1466
- struct gfxinfo * result = NULL ;
1457
+ struct php_gfxinfo * result = NULL ;
1467
1458
1468
1459
if (!stream ) {
1469
1460
RETURN_FALSE ;
0 commit comments