@@ -55,20 +55,11 @@ PHPAPI const char php_sig_webp[4] = {'W', 'E', 'B', 'P'};
5555/* REMEMBER TO ADD MIME-TYPE TO FUNCTION php_image_type_to_mime_type */
5656/* PCX must check first 64bytes and byte 0=0x0a and byte2 < 0x06 */
5757
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-
6758/* {{{ php_handle_gif
6859 * 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 )
7061{
71- struct gfxinfo * result = NULL ;
62+ struct php_gfxinfo * result = NULL ;
7263 unsigned char dim [5 ];
7364
7465 if (php_stream_seek (stream , 3 , SEEK_CUR ))
@@ -77,7 +68,7 @@ static struct gfxinfo *php_handle_gif (php_stream * stream)
7768 if (php_stream_read (stream , (char * )dim , sizeof (dim )) != sizeof (dim ))
7869 return NULL ;
7970
80- result = (struct gfxinfo * ) ecalloc (1 , sizeof (struct gfxinfo ));
71+ result = (struct php_gfxinfo * ) ecalloc (1 , sizeof (struct php_gfxinfo ));
8172 result -> width = (unsigned int )dim [0 ] | (((unsigned int )dim [1 ])<<8 );
8273 result -> height = (unsigned int )dim [2 ] | (((unsigned int )dim [3 ])<<8 );
8374 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)
8879/* }}} */
8980
9081/* {{{ php_handle_psd */
91- static struct gfxinfo * php_handle_psd (php_stream * stream )
82+ static struct php_gfxinfo * php_handle_psd (php_stream * stream )
9283{
93- struct gfxinfo * result = NULL ;
84+ struct php_gfxinfo * result = NULL ;
9485 unsigned char dim [8 ];
9586
9687 if (php_stream_seek (stream , 11 , SEEK_CUR ))
@@ -99,7 +90,7 @@ static struct gfxinfo *php_handle_psd (php_stream * stream)
9990 if (php_stream_read (stream , (char * )dim , sizeof (dim )) != sizeof (dim ))
10091 return NULL ;
10192
102- result = (struct gfxinfo * ) ecalloc (1 , sizeof (struct gfxinfo ));
93+ result = (struct php_gfxinfo * ) ecalloc (1 , sizeof (struct php_gfxinfo ));
10394 result -> height = (((unsigned int )dim [0 ]) << 24 ) + (((unsigned int )dim [1 ]) << 16 ) + (((unsigned int )dim [2 ]) << 8 ) + ((unsigned int )dim [3 ]);
10495 result -> width = (((unsigned int )dim [4 ]) << 24 ) + (((unsigned int )dim [5 ]) << 16 ) + (((unsigned int )dim [6 ]) << 8 ) + ((unsigned int )dim [7 ]);
10596
@@ -108,9 +99,9 @@ static struct gfxinfo *php_handle_psd (php_stream * stream)
10899/* }}} */
109100
110101/* {{{ php_handle_bmp */
111- static struct gfxinfo * php_handle_bmp (php_stream * stream )
102+ static struct php_gfxinfo * php_handle_bmp (php_stream * stream )
112103{
113- struct gfxinfo * result = NULL ;
104+ struct php_gfxinfo * result = NULL ;
114105 unsigned char dim [16 ];
115106 int size ;
116107
@@ -122,12 +113,12 @@ static struct gfxinfo *php_handle_bmp (php_stream * stream)
122113
123114 size = (((unsigned int )dim [ 3 ]) << 24 ) + (((unsigned int )dim [ 2 ]) << 16 ) + (((unsigned int )dim [ 1 ]) << 8 ) + ((unsigned int ) dim [ 0 ]);
124115 if (size == 12 ) {
125- result = (struct gfxinfo * ) ecalloc (1 , sizeof (struct gfxinfo ));
116+ result = (struct php_gfxinfo * ) ecalloc (1 , sizeof (struct php_gfxinfo ));
126117 result -> width = (((unsigned int )dim [ 5 ]) << 8 ) + ((unsigned int ) dim [ 4 ]);
127118 result -> height = (((unsigned int )dim [ 7 ]) << 8 ) + ((unsigned int ) dim [ 6 ]);
128119 result -> bits = ((unsigned int )dim [11 ]);
129120 } 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 ));
131122 result -> width = (((unsigned int )dim [ 7 ]) << 24 ) + (((unsigned int )dim [ 6 ]) << 16 ) + (((unsigned int )dim [ 5 ]) << 8 ) + ((unsigned int ) dim [ 4 ]);
132123 result -> height = (((unsigned int )dim [11 ]) << 24 ) + (((unsigned int )dim [10 ]) << 16 ) + (((unsigned int )dim [ 9 ]) << 8 ) + ((unsigned int ) dim [ 8 ]);
133124 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
158149
159150#if defined(HAVE_ZLIB ) && !defined(COMPILE_DL_ZLIB )
160151/* {{{ php_handle_swc */
161- static struct gfxinfo * php_handle_swc (php_stream * stream )
152+ static struct php_gfxinfo * php_handle_swc (php_stream * stream )
162153{
163- struct gfxinfo * result = NULL ;
154+ struct php_gfxinfo * result = NULL ;
164155
165156 long bits ;
166157 unsigned char a [64 ];
@@ -227,7 +218,7 @@ static struct gfxinfo *php_handle_swc(php_stream * stream)
227218 }
228219
229220 if (!status ) {
230- result = (struct gfxinfo * ) ecalloc (1 , sizeof (struct gfxinfo ));
221+ result = (struct php_gfxinfo * ) ecalloc (1 , sizeof (struct php_gfxinfo ));
231222 bits = php_swf_get_bits (b , 0 , 5 );
232223 result -> width = (php_swf_get_bits (b , 5 + bits , bits ) -
233224 php_swf_get_bits (b , 5 , bits )) / 20 ;
@@ -244,9 +235,9 @@ static struct gfxinfo *php_handle_swc(php_stream * stream)
244235#endif
245236
246237/* {{{ php_handle_swf */
247- static struct gfxinfo * php_handle_swf (php_stream * stream )
238+ static struct php_gfxinfo * php_handle_swf (php_stream * stream )
248239{
249- struct gfxinfo * result = NULL ;
240+ struct php_gfxinfo * result = NULL ;
250241 long bits ;
251242 unsigned char a [32 ];
252243
@@ -256,7 +247,7 @@ static struct gfxinfo *php_handle_swf (php_stream * stream)
256247 if (php_stream_read (stream , (char * )a , sizeof (a )) != sizeof (a ))
257248 return NULL ;
258249
259- result = (struct gfxinfo * ) ecalloc (1 , sizeof (struct gfxinfo ));
250+ result = (struct php_gfxinfo * ) ecalloc (1 , sizeof (struct php_gfxinfo ));
260251 bits = php_swf_get_bits (a , 0 , 5 );
261252 result -> width = (php_swf_get_bits (a , 5 + bits , bits ) -
262253 php_swf_get_bits (a , 5 , bits )) / 20 ;
@@ -270,9 +261,9 @@ static struct gfxinfo *php_handle_swf (php_stream * stream)
270261
271262/* {{{ php_handle_png
272263 * routine to handle PNG files */
273- static struct gfxinfo * php_handle_png (php_stream * stream )
264+ static struct php_gfxinfo * php_handle_png (php_stream * stream )
274265{
275- struct gfxinfo * result = NULL ;
266+ struct php_gfxinfo * result = NULL ;
276267 unsigned char dim [9 ];
277268/* Width: 4 bytes
278269 * Height: 4 bytes
@@ -289,7 +280,7 @@ static struct gfxinfo *php_handle_png (php_stream * stream)
289280 if ((php_stream_read (stream , (char * )dim , sizeof (dim ))) < sizeof (dim ))
290281 return NULL ;
291282
292- result = (struct gfxinfo * ) ecalloc (1 , sizeof (struct gfxinfo ));
283+ result = (struct php_gfxinfo * ) ecalloc (1 , sizeof (struct php_gfxinfo ));
293284 result -> width = (((unsigned int )dim [0 ]) << 24 ) + (((unsigned int )dim [1 ]) << 16 ) + (((unsigned int )dim [2 ]) << 8 ) + ((unsigned int )dim [3 ]);
294285 result -> height = (((unsigned int )dim [4 ]) << 24 ) + (((unsigned int )dim [5 ]) << 16 ) + (((unsigned int )dim [6 ]) << 8 ) + ((unsigned int )dim [7 ]);
295286 result -> bits = (unsigned int )dim [8 ];
@@ -448,9 +439,9 @@ static int php_read_APP(php_stream * stream, unsigned int marker, zval *info)
448439
449440/* {{{ php_handle_jpeg
450441 main loop to parse JPEG structure */
451- static struct gfxinfo * php_handle_jpeg (php_stream * stream , zval * info )
442+ static struct php_gfxinfo * php_handle_jpeg (php_stream * stream , zval * info )
452443{
453- struct gfxinfo * result = NULL ;
444+ struct php_gfxinfo * result = NULL ;
454445 unsigned int marker = M_PSEUDO ;
455446 unsigned short length , ff_read = 1 ;
456447
@@ -473,7 +464,7 @@ static struct gfxinfo *php_handle_jpeg (php_stream * stream, zval *info)
473464 case M_SOF15 :
474465 if (result == NULL ) {
475466 /* handle SOFn block */
476- result = (struct gfxinfo * ) ecalloc (1 , sizeof (struct gfxinfo ));
467+ result = (struct php_gfxinfo * ) ecalloc (1 , sizeof (struct php_gfxinfo ));
477468 length = php_read2 (stream );
478469 result -> bits = php_stream_getc (stream );
479470 result -> height = php_read2 (stream );
@@ -576,9 +567,9 @@ static unsigned int php_read4(php_stream * stream)
576567
577568/* {{{ php_handle_jpc
578569 Main loop to parse JPEG2000 raw codestream structure */
579- static struct gfxinfo * php_handle_jpc (php_stream * stream )
570+ static struct php_gfxinfo * php_handle_jpc (php_stream * stream )
580571{
581- struct gfxinfo * result = NULL ;
572+ struct php_gfxinfo * result = NULL ;
582573 int highest_bit_depth , bit_depth ;
583574 unsigned char first_marker_id ;
584575 unsigned int i ;
@@ -599,7 +590,7 @@ static struct gfxinfo *php_handle_jpc(php_stream * stream)
599590 return NULL ;
600591 }
601592
602- result = (struct gfxinfo * )ecalloc (1 , sizeof (struct gfxinfo ));
593+ result = (struct php_gfxinfo * )ecalloc (1 , sizeof (struct php_gfxinfo ));
603594
604595 php_read2 (stream ); /* Lsiz */
605596 php_read2 (stream ); /* Rsiz */
@@ -647,9 +638,9 @@ static struct gfxinfo *php_handle_jpc(php_stream * stream)
647638
648639/* {{{ php_handle_jp2
649640 main loop to parse JPEG 2000 JP2 wrapper format structure */
650- static struct gfxinfo * php_handle_jp2 (php_stream * stream )
641+ static struct php_gfxinfo * php_handle_jp2 (php_stream * stream )
651642{
652- struct gfxinfo * result = NULL ;
643+ struct php_gfxinfo * result = NULL ;
653644 unsigned int box_length ;
654645 unsigned int box_type ;
655646 char jp2c_box_id [] = {(char )0x6a , (char )0x70 , (char )0x32 , (char )0x63 };
@@ -773,9 +764,9 @@ static unsigned php_ifd_get32u(void *Long, int motorola_intel)
773764
774765/* {{{ php_handle_tiff
775766 main loop to parse TIFF structure */
776- static struct gfxinfo * php_handle_tiff (php_stream * stream , zval * info , int motorola_intel )
767+ static struct php_gfxinfo * php_handle_tiff (php_stream * stream , zval * info , int motorola_intel )
777768{
778- struct gfxinfo * result = NULL ;
769+ struct php_gfxinfo * result = NULL ;
779770 int i , num_entries ;
780771 unsigned char * dir_entry ;
781772 size_t ifd_size , dir_size , entry_value , width = 0 , height = 0 , ifd_addr ;
@@ -841,7 +832,7 @@ static struct gfxinfo *php_handle_tiff (php_stream * stream, zval *info, int mot
841832 efree (ifd_data );
842833 if ( width && height ) {
843834 /* not the same when in for-loop */
844- result = (struct gfxinfo * ) ecalloc (1 , sizeof (struct gfxinfo ));
835+ result = (struct php_gfxinfo * ) ecalloc (1 , sizeof (struct php_gfxinfo ));
845836 result -> height = height ;
846837 result -> width = width ;
847838 result -> bits = 0 ;
@@ -853,9 +844,9 @@ static struct gfxinfo *php_handle_tiff (php_stream * stream, zval *info, int mot
853844/* }}} */
854845
855846/* {{{ php_handle_psd */
856- static struct gfxinfo * php_handle_iff (php_stream * stream )
847+ static struct php_gfxinfo * php_handle_iff (php_stream * stream )
857848{
858- struct gfxinfo * result ;
849+ struct php_gfxinfo * result ;
859850 unsigned char a [10 ];
860851 int chunkId ;
861852 int size ;
@@ -889,7 +880,7 @@ static struct gfxinfo *php_handle_iff(php_stream * stream)
889880 height = php_ifd_get16s (a + 2 , 1 );
890881 bits = a [8 ] & 0xff ;
891882 if (width > 0 && height > 0 && bits > 0 && bits < 33 ) {
892- result = (struct gfxinfo * ) ecalloc (1 , sizeof (struct gfxinfo ));
883+ result = (struct php_gfxinfo * ) ecalloc (1 , sizeof (struct php_gfxinfo ));
893884 result -> width = width ;
894885 result -> height = height ;
895886 result -> bits = bits ;
@@ -914,7 +905,7 @@ static struct gfxinfo *php_handle_iff(php_stream * stream)
914905 * int Number of columns
915906 * int Number of rows
916907 */
917- static int php_get_wbmp (php_stream * stream , struct gfxinfo * * result , int check )
908+ static int php_get_wbmp (php_stream * stream , struct php_gfxinfo * * result , int check )
918909{
919910 int i , width = 0 , height = 0 ;
920911
@@ -975,9 +966,9 @@ static int php_get_wbmp(php_stream *stream, struct gfxinfo **result, int check)
975966/* }}} */
976967
977968/* {{{ php_handle_wbmp */
978- static struct gfxinfo * php_handle_wbmp (php_stream * stream )
969+ static struct php_gfxinfo * php_handle_wbmp (php_stream * stream )
979970{
980- struct gfxinfo * result = (struct gfxinfo * ) ecalloc (1 , sizeof (struct gfxinfo ));
971+ struct php_gfxinfo * result = (struct php_gfxinfo * ) ecalloc (1 , sizeof (struct php_gfxinfo ));
981972
982973 if (!php_get_wbmp (stream , & result , 0 )) {
983974 efree (result );
@@ -989,7 +980,7 @@ static struct gfxinfo *php_handle_wbmp(php_stream * stream)
989980/* }}} */
990981
991982/* {{{ php_get_xbm */
992- static int php_get_xbm (php_stream * stream , struct gfxinfo * * result )
983+ static int php_get_xbm (php_stream * stream , struct php_gfxinfo * * result )
993984{
994985 char * fline ;
995986 char * iname ;
@@ -1036,7 +1027,7 @@ static int php_get_xbm(php_stream *stream, struct gfxinfo **result)
10361027
10371028 if (width && height ) {
10381029 if (result ) {
1039- * result = (struct gfxinfo * ) ecalloc (1 , sizeof (struct gfxinfo ));
1030+ * result = (struct php_gfxinfo * ) ecalloc (1 , sizeof (struct php_gfxinfo ));
10401031 (* result )-> width = width ;
10411032 (* result )-> height = height ;
10421033 }
@@ -1048,18 +1039,18 @@ static int php_get_xbm(php_stream *stream, struct gfxinfo **result)
10481039/* }}} */
10491040
10501041/* {{{ php_handle_xbm */
1051- static struct gfxinfo * php_handle_xbm (php_stream * stream )
1042+ static struct php_gfxinfo * php_handle_xbm (php_stream * stream )
10521043{
1053- struct gfxinfo * result ;
1044+ struct php_gfxinfo * result ;
10541045 php_get_xbm (stream , & result );
10551046 return result ;
10561047}
10571048/* }}} */
10581049
10591050/* {{{ php_handle_ico */
1060- static struct gfxinfo * php_handle_ico (php_stream * stream )
1051+ static struct php_gfxinfo * php_handle_ico (php_stream * stream )
10611052{
1062- struct gfxinfo * result = NULL ;
1053+ struct php_gfxinfo * result = NULL ;
10631054 unsigned char dim [16 ];
10641055 int num_icons = 0 ;
10651056
@@ -1071,7 +1062,7 @@ static struct gfxinfo *php_handle_ico(php_stream * stream)
10711062 if (num_icons < 1 || num_icons > 255 )
10721063 return NULL ;
10731064
1074- result = (struct gfxinfo * ) ecalloc (1 , sizeof (struct gfxinfo ));
1065+ result = (struct php_gfxinfo * ) ecalloc (1 , sizeof (struct php_gfxinfo ));
10751066
10761067 while (num_icons > 0 )
10771068 {
@@ -1098,9 +1089,9 @@ static struct gfxinfo *php_handle_ico(php_stream * stream)
10981089/* }}} */
10991090
11001091/* {{{ php_handle_webp */
1101- static struct gfxinfo * php_handle_webp (php_stream * stream )
1092+ static struct php_gfxinfo * php_handle_webp (php_stream * stream )
11021093{
1103- struct gfxinfo * result = NULL ;
1094+ struct php_gfxinfo * result = NULL ;
11041095 const char sig [3 ] = {'V' , 'P' , '8' };
11051096 unsigned char buf [18 ];
11061097 char format ;
@@ -1121,7 +1112,7 @@ static struct gfxinfo *php_handle_webp(php_stream * stream)
11211112 return NULL ;
11221113 }
11231114
1124- result = (struct gfxinfo * ) ecalloc (1 , sizeof (struct gfxinfo ));
1115+ result = (struct php_gfxinfo * ) ecalloc (1 , sizeof (struct php_gfxinfo ));
11251116
11261117 switch (format ) {
11271118 case ' ' :
@@ -1183,14 +1174,14 @@ static void php_avif_stream_skip(void* stream, size_t num_bytes) {
11831174 * declared as invalid. Around 450 bytes are usually enough.
11841175 * Transforms such as mirror and rotation are not applied on width and height.
11851176 */
1186- static struct gfxinfo * php_handle_avif (php_stream * stream ) {
1187- struct gfxinfo * result = NULL ;
1177+ static struct php_gfxinfo * php_handle_avif (php_stream * stream ) {
1178+ struct php_gfxinfo * result = NULL ;
11881179 AvifInfoFeatures features ;
11891180 struct php_avif_stream avif_stream ;
11901181 avif_stream .stream = stream ;
11911182
11921183 if (AvifInfoGetFeaturesStream (& avif_stream , php_avif_stream_read , php_avif_stream_skip , & features ) == kAvifInfoOk ) {
1193- result = (struct gfxinfo * )ecalloc (1 , sizeof (struct gfxinfo ));
1184+ result = (struct php_gfxinfo * )ecalloc (1 , sizeof (struct php_gfxinfo ));
11941185 result -> width = features .width ;
11951186 result -> height = features .height ;
11961187 result -> bits = features .bit_depth ;
@@ -1448,7 +1439,7 @@ PHPAPI int php_getimagetype(php_stream *stream, const char *input, char *filetyp
14481439static void php_getimagesize_from_stream (php_stream * stream , char * input , zval * info , INTERNAL_FUNCTION_PARAMETERS ) /* {{{ */
14491440{
14501441 int itype = 0 ;
1451- struct gfxinfo * result = NULL ;
1442+ struct php_gfxinfo * result = NULL ;
14521443
14531444 if (!stream ) {
14541445 RETURN_FALSE ;
0 commit comments