@@ -55,20 +55,11 @@ PHPAPI const char php_sig_webp[4] = {'W', 'E', 'B', 'P'};
55
55
/* REMEMBER TO ADD MIME-TYPE TO FUNCTION php_image_type_to_mime_type */
56
56
/* PCX must check first 64bytes and byte 0=0x0a and byte2 < 0x06 */
57
57
58
- /* return info as a struct, to make expansion easier */
59
-
60
- struct gfxinfo {
61
- unsigned int width ;
62
- unsigned int height ;
63
- unsigned int bits ;
64
- unsigned int channels ;
65
- };
66
-
67
58
/* {{{ php_handle_gif
68
59
* routine to handle GIF files. If only everything were that easy... ;} */
69
- static struct gfxinfo * php_handle_gif (php_stream * stream )
60
+ static struct php_gfxinfo * php_handle_gif (php_stream * stream )
70
61
{
71
- struct gfxinfo * result = NULL ;
62
+ struct php_gfxinfo * result = NULL ;
72
63
unsigned char dim [5 ];
73
64
74
65
if (php_stream_seek (stream , 3 , SEEK_CUR ))
@@ -77,7 +68,7 @@ static struct gfxinfo *php_handle_gif (php_stream * stream)
77
68
if (php_stream_read (stream , (char * )dim , sizeof (dim )) != sizeof (dim ))
78
69
return NULL ;
79
70
80
- result = (struct gfxinfo * ) ecalloc (1 , sizeof (struct gfxinfo ));
71
+ result = (struct php_gfxinfo * ) ecalloc (1 , sizeof (struct php_gfxinfo ));
81
72
result -> width = (unsigned int )dim [0 ] | (((unsigned int )dim [1 ])<<8 );
82
73
result -> height = (unsigned int )dim [2 ] | (((unsigned int )dim [3 ])<<8 );
83
74
result -> bits = dim [4 ]& 0x80 ? ((((unsigned int )dim [4 ])& 0x07 ) + 1 ) : 0 ;
@@ -88,9 +79,9 @@ static struct gfxinfo *php_handle_gif (php_stream * stream)
88
79
/* }}} */
89
80
90
81
/* {{{ php_handle_psd */
91
- static struct gfxinfo * php_handle_psd (php_stream * stream )
82
+ static struct php_gfxinfo * php_handle_psd (php_stream * stream )
92
83
{
93
- struct gfxinfo * result = NULL ;
84
+ struct php_gfxinfo * result = NULL ;
94
85
unsigned char dim [8 ];
95
86
96
87
if (php_stream_seek (stream , 11 , SEEK_CUR ))
@@ -99,7 +90,7 @@ static struct gfxinfo *php_handle_psd (php_stream * stream)
99
90
if (php_stream_read (stream , (char * )dim , sizeof (dim )) != sizeof (dim ))
100
91
return NULL ;
101
92
102
- result = (struct gfxinfo * ) ecalloc (1 , sizeof (struct gfxinfo ));
93
+ result = (struct php_gfxinfo * ) ecalloc (1 , sizeof (struct php_gfxinfo ));
103
94
result -> height = (((unsigned int )dim [0 ]) << 24 ) + (((unsigned int )dim [1 ]) << 16 ) + (((unsigned int )dim [2 ]) << 8 ) + ((unsigned int )dim [3 ]);
104
95
result -> width = (((unsigned int )dim [4 ]) << 24 ) + (((unsigned int )dim [5 ]) << 16 ) + (((unsigned int )dim [6 ]) << 8 ) + ((unsigned int )dim [7 ]);
105
96
@@ -108,9 +99,9 @@ static struct gfxinfo *php_handle_psd (php_stream * stream)
108
99
/* }}} */
109
100
110
101
/* {{{ php_handle_bmp */
111
- static struct gfxinfo * php_handle_bmp (php_stream * stream )
102
+ static struct php_gfxinfo * php_handle_bmp (php_stream * stream )
112
103
{
113
- struct gfxinfo * result = NULL ;
104
+ struct php_gfxinfo * result = NULL ;
114
105
unsigned char dim [16 ];
115
106
int size ;
116
107
@@ -122,12 +113,12 @@ static struct gfxinfo *php_handle_bmp (php_stream * stream)
122
113
123
114
size = (((unsigned int )dim [ 3 ]) << 24 ) + (((unsigned int )dim [ 2 ]) << 16 ) + (((unsigned int )dim [ 1 ]) << 8 ) + ((unsigned int ) dim [ 0 ]);
124
115
if (size == 12 ) {
125
- result = (struct gfxinfo * ) ecalloc (1 , sizeof (struct gfxinfo ));
116
+ result = (struct php_gfxinfo * ) ecalloc (1 , sizeof (struct php_gfxinfo ));
126
117
result -> width = (((unsigned int )dim [ 5 ]) << 8 ) + ((unsigned int ) dim [ 4 ]);
127
118
result -> height = (((unsigned int )dim [ 7 ]) << 8 ) + ((unsigned int ) dim [ 6 ]);
128
119
result -> bits = ((unsigned int )dim [11 ]);
129
120
} else if (size > 12 && (size <= 64 || size == 108 || size == 124 )) {
130
- result = (struct gfxinfo * ) ecalloc (1 , sizeof (struct gfxinfo ));
121
+ result = (struct php_gfxinfo * ) ecalloc (1 , sizeof (struct php_gfxinfo ));
131
122
result -> width = (((unsigned int )dim [ 7 ]) << 24 ) + (((unsigned int )dim [ 6 ]) << 16 ) + (((unsigned int )dim [ 5 ]) << 8 ) + ((unsigned int ) dim [ 4 ]);
132
123
result -> height = (((unsigned int )dim [11 ]) << 24 ) + (((unsigned int )dim [10 ]) << 16 ) + (((unsigned int )dim [ 9 ]) << 8 ) + ((unsigned int ) dim [ 8 ]);
133
124
result -> height = abs ((int32_t )result -> height );
@@ -158,9 +149,9 @@ static unsigned long int php_swf_get_bits (unsigned char* buffer, unsigned int p
158
149
159
150
#if defined(HAVE_ZLIB ) && !defined(COMPILE_DL_ZLIB )
160
151
/* {{{ php_handle_swc */
161
- static struct gfxinfo * php_handle_swc (php_stream * stream )
152
+ static struct php_gfxinfo * php_handle_swc (php_stream * stream )
162
153
{
163
- struct gfxinfo * result = NULL ;
154
+ struct php_gfxinfo * result = NULL ;
164
155
165
156
long bits ;
166
157
unsigned char a [64 ];
@@ -222,7 +213,7 @@ static struct gfxinfo *php_handle_swc(php_stream * stream)
222
213
}
223
214
224
215
if (!status ) {
225
- result = (struct gfxinfo * ) ecalloc (1 , sizeof (struct gfxinfo ));
216
+ result = (struct php_gfxinfo * ) ecalloc (1 , sizeof (struct php_gfxinfo ));
226
217
bits = php_swf_get_bits (b , 0 , 5 );
227
218
result -> width = (php_swf_get_bits (b , 5 + bits , bits ) -
228
219
php_swf_get_bits (b , 5 , bits )) / 20 ;
@@ -239,9 +230,9 @@ static struct gfxinfo *php_handle_swc(php_stream * stream)
239
230
#endif
240
231
241
232
/* {{{ php_handle_swf */
242
- static struct gfxinfo * php_handle_swf (php_stream * stream )
233
+ static struct php_gfxinfo * php_handle_swf (php_stream * stream )
243
234
{
244
- struct gfxinfo * result = NULL ;
235
+ struct php_gfxinfo * result = NULL ;
245
236
long bits ;
246
237
unsigned char a [32 ];
247
238
@@ -251,7 +242,7 @@ static struct gfxinfo *php_handle_swf (php_stream * stream)
251
242
if (php_stream_read (stream , (char * )a , sizeof (a )) != sizeof (a ))
252
243
return NULL ;
253
244
254
- result = (struct gfxinfo * ) ecalloc (1 , sizeof (struct gfxinfo ));
245
+ result = (struct php_gfxinfo * ) ecalloc (1 , sizeof (struct php_gfxinfo ));
255
246
bits = php_swf_get_bits (a , 0 , 5 );
256
247
result -> width = (php_swf_get_bits (a , 5 + bits , bits ) -
257
248
php_swf_get_bits (a , 5 , bits )) / 20 ;
@@ -265,9 +256,9 @@ static struct gfxinfo *php_handle_swf (php_stream * stream)
265
256
266
257
/* {{{ php_handle_png
267
258
* routine to handle PNG files */
268
- static struct gfxinfo * php_handle_png (php_stream * stream )
259
+ static struct php_gfxinfo * php_handle_png (php_stream * stream )
269
260
{
270
- struct gfxinfo * result = NULL ;
261
+ struct php_gfxinfo * result = NULL ;
271
262
unsigned char dim [9 ];
272
263
/* Width: 4 bytes
273
264
* Height: 4 bytes
@@ -284,7 +275,7 @@ static struct gfxinfo *php_handle_png (php_stream * stream)
284
275
if ((php_stream_read (stream , (char * )dim , sizeof (dim ))) < sizeof (dim ))
285
276
return NULL ;
286
277
287
- result = (struct gfxinfo * ) ecalloc (1 , sizeof (struct gfxinfo ));
278
+ result = (struct php_gfxinfo * ) ecalloc (1 , sizeof (struct php_gfxinfo ));
288
279
result -> width = (((unsigned int )dim [0 ]) << 24 ) + (((unsigned int )dim [1 ]) << 16 ) + (((unsigned int )dim [2 ]) << 8 ) + ((unsigned int )dim [3 ]);
289
280
result -> height = (((unsigned int )dim [4 ]) << 24 ) + (((unsigned int )dim [5 ]) << 16 ) + (((unsigned int )dim [6 ]) << 8 ) + ((unsigned int )dim [7 ]);
290
281
result -> bits = (unsigned int )dim [8 ];
@@ -443,9 +434,9 @@ static int php_read_APP(php_stream * stream, unsigned int marker, zval *info)
443
434
444
435
/* {{{ php_handle_jpeg
445
436
main loop to parse JPEG structure */
446
- static struct gfxinfo * php_handle_jpeg (php_stream * stream , zval * info )
437
+ static struct php_gfxinfo * php_handle_jpeg (php_stream * stream , zval * info )
447
438
{
448
- struct gfxinfo * result = NULL ;
439
+ struct php_gfxinfo * result = NULL ;
449
440
unsigned int marker = M_PSEUDO ;
450
441
unsigned short length , ff_read = 1 ;
451
442
@@ -468,7 +459,7 @@ static struct gfxinfo *php_handle_jpeg (php_stream * stream, zval *info)
468
459
case M_SOF15 :
469
460
if (result == NULL ) {
470
461
/* handle SOFn block */
471
- result = (struct gfxinfo * ) ecalloc (1 , sizeof (struct gfxinfo ));
462
+ result = (struct php_gfxinfo * ) ecalloc (1 , sizeof (struct php_gfxinfo ));
472
463
length = php_read2 (stream );
473
464
result -> bits = php_stream_getc (stream );
474
465
result -> height = php_read2 (stream );
@@ -571,9 +562,9 @@ static unsigned int php_read4(php_stream * stream)
571
562
572
563
/* {{{ php_handle_jpc
573
564
Main loop to parse JPEG2000 raw codestream structure */
574
- static struct gfxinfo * php_handle_jpc (php_stream * stream )
565
+ static struct php_gfxinfo * php_handle_jpc (php_stream * stream )
575
566
{
576
- struct gfxinfo * result = NULL ;
567
+ struct php_gfxinfo * result = NULL ;
577
568
int highest_bit_depth , bit_depth ;
578
569
unsigned char first_marker_id ;
579
570
unsigned int i ;
@@ -594,7 +585,7 @@ static struct gfxinfo *php_handle_jpc(php_stream * stream)
594
585
return NULL ;
595
586
}
596
587
597
- result = (struct gfxinfo * )ecalloc (1 , sizeof (struct gfxinfo ));
588
+ result = (struct php_gfxinfo * )ecalloc (1 , sizeof (struct php_gfxinfo ));
598
589
599
590
php_read2 (stream ); /* Lsiz */
600
591
php_read2 (stream ); /* Rsiz */
@@ -642,9 +633,9 @@ static struct gfxinfo *php_handle_jpc(php_stream * stream)
642
633
643
634
/* {{{ php_handle_jp2
644
635
main loop to parse JPEG 2000 JP2 wrapper format structure */
645
- static struct gfxinfo * php_handle_jp2 (php_stream * stream )
636
+ static struct php_gfxinfo * php_handle_jp2 (php_stream * stream )
646
637
{
647
- struct gfxinfo * result = NULL ;
638
+ struct php_gfxinfo * result = NULL ;
648
639
unsigned int box_length ;
649
640
unsigned int box_type ;
650
641
char jp2c_box_id [] = {(char )0x6a , (char )0x70 , (char )0x32 , (char )0x63 };
@@ -768,9 +759,9 @@ static unsigned php_ifd_get32u(void *Long, int motorola_intel)
768
759
769
760
/* {{{ php_handle_tiff
770
761
main loop to parse TIFF structure */
771
- static struct gfxinfo * php_handle_tiff (php_stream * stream , zval * info , int motorola_intel )
762
+ static struct php_gfxinfo * php_handle_tiff (php_stream * stream , zval * info , int motorola_intel )
772
763
{
773
- struct gfxinfo * result = NULL ;
764
+ struct php_gfxinfo * result = NULL ;
774
765
int i , num_entries ;
775
766
unsigned char * dir_entry ;
776
767
size_t ifd_size , dir_size , entry_value , width = 0 , height = 0 , ifd_addr ;
@@ -836,7 +827,7 @@ static struct gfxinfo *php_handle_tiff (php_stream * stream, zval *info, int mot
836
827
efree (ifd_data );
837
828
if ( width && height ) {
838
829
/* not the same when in for-loop */
839
- result = (struct gfxinfo * ) ecalloc (1 , sizeof (struct gfxinfo ));
830
+ result = (struct php_gfxinfo * ) ecalloc (1 , sizeof (struct php_gfxinfo ));
840
831
result -> height = height ;
841
832
result -> width = width ;
842
833
result -> bits = 0 ;
@@ -848,9 +839,9 @@ static struct gfxinfo *php_handle_tiff (php_stream * stream, zval *info, int mot
848
839
/* }}} */
849
840
850
841
/* {{{ php_handle_psd */
851
- static struct gfxinfo * php_handle_iff (php_stream * stream )
842
+ static struct php_gfxinfo * php_handle_iff (php_stream * stream )
852
843
{
853
- struct gfxinfo * result ;
844
+ struct php_gfxinfo * result ;
854
845
unsigned char a [10 ];
855
846
int chunkId ;
856
847
int size ;
@@ -884,7 +875,7 @@ static struct gfxinfo *php_handle_iff(php_stream * stream)
884
875
height = php_ifd_get16s (a + 2 , 1 );
885
876
bits = a [8 ] & 0xff ;
886
877
if (width > 0 && height > 0 && bits > 0 && bits < 33 ) {
887
- result = (struct gfxinfo * ) ecalloc (1 , sizeof (struct gfxinfo ));
878
+ result = (struct php_gfxinfo * ) ecalloc (1 , sizeof (struct php_gfxinfo ));
888
879
result -> width = width ;
889
880
result -> height = height ;
890
881
result -> bits = bits ;
@@ -909,7 +900,7 @@ static struct gfxinfo *php_handle_iff(php_stream * stream)
909
900
* int Number of columns
910
901
* int Number of rows
911
902
*/
912
- static int php_get_wbmp (php_stream * stream , struct gfxinfo * * result , int check )
903
+ static int php_get_wbmp (php_stream * stream , struct php_gfxinfo * * result , int check )
913
904
{
914
905
int i , width = 0 , height = 0 ;
915
906
@@ -970,9 +961,9 @@ static int php_get_wbmp(php_stream *stream, struct gfxinfo **result, int check)
970
961
/* }}} */
971
962
972
963
/* {{{ php_handle_wbmp */
973
- static struct gfxinfo * php_handle_wbmp (php_stream * stream )
964
+ static struct php_gfxinfo * php_handle_wbmp (php_stream * stream )
974
965
{
975
- struct gfxinfo * result = (struct gfxinfo * ) ecalloc (1 , sizeof (struct gfxinfo ));
966
+ struct php_gfxinfo * result = (struct php_gfxinfo * ) ecalloc (1 , sizeof (struct php_gfxinfo ));
976
967
977
968
if (!php_get_wbmp (stream , & result , 0 )) {
978
969
efree (result );
@@ -984,7 +975,7 @@ static struct gfxinfo *php_handle_wbmp(php_stream * stream)
984
975
/* }}} */
985
976
986
977
/* {{{ php_get_xbm */
987
- static int php_get_xbm (php_stream * stream , struct gfxinfo * * result )
978
+ static int php_get_xbm (php_stream * stream , struct php_gfxinfo * * result )
988
979
{
989
980
char * fline ;
990
981
char * iname ;
@@ -1031,7 +1022,7 @@ static int php_get_xbm(php_stream *stream, struct gfxinfo **result)
1031
1022
1032
1023
if (width && height ) {
1033
1024
if (result ) {
1034
- * result = (struct gfxinfo * ) ecalloc (1 , sizeof (struct gfxinfo ));
1025
+ * result = (struct php_gfxinfo * ) ecalloc (1 , sizeof (struct php_gfxinfo ));
1035
1026
(* result )-> width = width ;
1036
1027
(* result )-> height = height ;
1037
1028
}
@@ -1043,18 +1034,18 @@ static int php_get_xbm(php_stream *stream, struct gfxinfo **result)
1043
1034
/* }}} */
1044
1035
1045
1036
/* {{{ php_handle_xbm */
1046
- static struct gfxinfo * php_handle_xbm (php_stream * stream )
1037
+ static struct php_gfxinfo * php_handle_xbm (php_stream * stream )
1047
1038
{
1048
- struct gfxinfo * result ;
1039
+ struct php_gfxinfo * result ;
1049
1040
php_get_xbm (stream , & result );
1050
1041
return result ;
1051
1042
}
1052
1043
/* }}} */
1053
1044
1054
1045
/* {{{ php_handle_ico */
1055
- static struct gfxinfo * php_handle_ico (php_stream * stream )
1046
+ static struct php_gfxinfo * php_handle_ico (php_stream * stream )
1056
1047
{
1057
- struct gfxinfo * result = NULL ;
1048
+ struct php_gfxinfo * result = NULL ;
1058
1049
unsigned char dim [16 ];
1059
1050
int num_icons = 0 ;
1060
1051
@@ -1066,7 +1057,7 @@ static struct gfxinfo *php_handle_ico(php_stream * stream)
1066
1057
if (num_icons < 1 || num_icons > 255 )
1067
1058
return NULL ;
1068
1059
1069
- result = (struct gfxinfo * ) ecalloc (1 , sizeof (struct gfxinfo ));
1060
+ result = (struct php_gfxinfo * ) ecalloc (1 , sizeof (struct php_gfxinfo ));
1070
1061
1071
1062
while (num_icons > 0 )
1072
1063
{
@@ -1093,9 +1084,9 @@ static struct gfxinfo *php_handle_ico(php_stream * stream)
1093
1084
/* }}} */
1094
1085
1095
1086
/* {{{ php_handle_webp */
1096
- static struct gfxinfo * php_handle_webp (php_stream * stream )
1087
+ static struct php_gfxinfo * php_handle_webp (php_stream * stream )
1097
1088
{
1098
- struct gfxinfo * result = NULL ;
1089
+ struct php_gfxinfo * result = NULL ;
1099
1090
const char sig [3 ] = {'V' , 'P' , '8' };
1100
1091
unsigned char buf [18 ];
1101
1092
char format ;
@@ -1116,7 +1107,7 @@ static struct gfxinfo *php_handle_webp(php_stream * stream)
1116
1107
return NULL ;
1117
1108
}
1118
1109
1119
- result = (struct gfxinfo * ) ecalloc (1 , sizeof (struct gfxinfo ));
1110
+ result = (struct php_gfxinfo * ) ecalloc (1 , sizeof (struct php_gfxinfo ));
1120
1111
1121
1112
switch (format ) {
1122
1113
case ' ' :
@@ -1178,14 +1169,14 @@ static void php_avif_stream_skip(void* stream, size_t num_bytes) {
1178
1169
* declared as invalid. Around 450 bytes are usually enough.
1179
1170
* Transforms such as mirror and rotation are not applied on width and height.
1180
1171
*/
1181
- static struct gfxinfo * php_handle_avif (php_stream * stream ) {
1182
- struct gfxinfo * result = NULL ;
1172
+ static struct php_gfxinfo * php_handle_avif (php_stream * stream ) {
1173
+ struct php_gfxinfo * result = NULL ;
1183
1174
AvifInfoFeatures features ;
1184
1175
struct php_avif_stream avif_stream ;
1185
1176
avif_stream .stream = stream ;
1186
1177
1187
1178
if (AvifInfoGetFeaturesStream (& avif_stream , php_avif_stream_read , php_avif_stream_skip , & features ) == kAvifInfoOk ) {
1188
- result = (struct gfxinfo * )ecalloc (1 , sizeof (struct gfxinfo ));
1179
+ result = (struct php_gfxinfo * )ecalloc (1 , sizeof (struct php_gfxinfo ));
1189
1180
result -> width = features .width ;
1190
1181
result -> height = features .height ;
1191
1182
result -> bits = features .bit_depth ;
@@ -1443,7 +1434,7 @@ PHPAPI int php_getimagetype(php_stream *stream, const char *input, char *filetyp
1443
1434
static void php_getimagesize_from_stream (php_stream * stream , char * input , zval * info , INTERNAL_FUNCTION_PARAMETERS ) /* {{{ */
1444
1435
{
1445
1436
int itype = 0 ;
1446
- struct gfxinfo * result = NULL ;
1437
+ struct php_gfxinfo * result = NULL ;
1447
1438
1448
1439
if (!stream ) {
1449
1440
RETURN_FALSE ;
0 commit comments