cvs: php4(PHP_4_2_0) /ext/exif exif.c

From: Date: Tue, 03 Sep 2002 07:39:11 +0000
Subject: cvs: php4(PHP_4_2_0) /ext/exif exif.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-13797@lists.php.net to get a copy of this message
derick Tue Sep 3 03:39:11 2002 EDT Modified files: (Branch: PHP_4_2_0) /php4/ext/exif exif.c Log: - Fix #ifdefs

Index: php4/ext/exif/exif.c diff -u php4/ext/exif/exif.c:1.52.2.10 php4/ext/exif/exif.c:1.52.2.11 --- php4/ext/exif/exif.c:1.52.2.10 Thu Aug 29 04:35:47 2002 +++ php4/ext/exif/exif.c Tue Sep 3 03:39:10 2002 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: exif.c,v 1.52.2.10 2002/08/29 08:35:47 helly Exp $ */ +/* $Id: exif.c,v 1.52.2.11 2002/09/03 07:39:10 derick Exp $ */ /* ToDos * @@ -73,8 +73,8 @@ typedef unsigned char uchar; #ifndef TRUE - #define TRUE 1 - #define FALSE 0 +#define TRUE 1 +#define FALSE 0 #endif #define EXIT_FAILURE 1 @@ -937,9 +937,9 @@ for(i=0; i<image_info->info_list[section_index].count; i++) { info_value = &image_info->info_list[section_index].list[i]; - #ifdef EXIF_DEBUG +#ifdef EXIF_DEBUG /* php_error(E_NOTICE,"adding info #%d: '%s:%s'", i, exif_get_sectionname(section_index), info_value->name);*/ - #endif +#endif if ( !(name = info_value->name)) { sprintf(uname,"%d", unknown++); name = uname; @@ -1399,9 +1399,9 @@ } ImageInfo->sections_found |= FOUND_ANY_TAG; - #ifdef EXIF_DEBUG +#ifdef EXIF_DEBUG php_error(E_NOTICE,"process tag(x%04x=%s,@x%04X+x%04X(=%d)): %s", tag, exif_get_tagname(tag,tagname), value_ptr-offset_base, byte_count, byte_count, format==TAG_FMT_STRING?(value_ptr?value_ptr:"<no data>"):exif_get_tagformat(format)); - #endif +#endif if (section_index==SECTION_THUMBNAIL) { switch(tag) { case TAG_STRIP_OFFSETS: @@ -1565,9 +1565,9 @@ int NumDirEntries; int NextDirOffset; - #ifdef EXIF_DEBUG +#ifdef EXIF_DEBUG php_error(E_NOTICE,"exif_process_IFD_in_JPEG(x%04X(=%d))", IFDlength, IFDlength); - #endif +#endif ImageInfo->sections_found |= FOUND_IFD0; @@ -1593,9 +1593,9 @@ return; } /* That is the IFD for the first thumbnail */ - #ifdef EXIF_DEBUG +#ifdef EXIF_DEBUG php_error(E_NOTICE,"expect next IFD to be thumbnail"); - #endif +#endif exif_process_IFD_in_JPEG(ImageInfo, OffsetBase + NextDirOffset, OffsetBase, IFDlength, SECTION_THUMBNAIL); } } @@ -1626,9 +1626,9 @@ /* First directory starts at offset 8. Offsets starts at 0. */ exif_process_IFD_in_JPEG(ImageInfo, CharBuf+8, CharBuf, length/*-14*/, SECTION_IFD0); - #ifdef EXIF_DEBUG +#ifdef EXIF_DEBUG php_error(E_NOTICE,"exif_process_TIFF_in_JPEG, done"); - #endif +#endif /* Compute the CCD width, in milimeters. */ if (ImageInfo->FocalplaneXRes != 0) { @@ -1650,9 +1650,9 @@ return; } exif_process_TIFF_in_JPEG(ImageInfo,CharBuf+8,length-8); - #ifdef EXIF_DEBUG +#ifdef EXIF_DEBUG php_error(E_NOTICE,"process Exif done"); - #endif +#endif } /* }}} */ @@ -1670,9 +1670,9 @@ exif_add_image_info( ImageInfo, SECTION_APP12, "Info", TAG_NONE, TAG_FMT_STRING, l2, buffer+2+l1+1); } } - #ifdef EXIF_DEBUG +#ifdef EXIF_DEBUG php_error(E_NOTICE,"process section APP12 with l1=%d, l2=%d done", l1, l2); - #endif +#endif } /* }}} */ @@ -1687,22 +1687,22 @@ int marker = 0; int ll, lh, got; uchar *Data; - #ifdef EXIF_DEBUG +#ifdef EXIF_DEBUG size_t fpos; - #endif +#endif - #ifdef EXIF_DEBUG +#ifdef EXIF_DEBUG fpos = ftell(infile); php_error(E_NOTICE,"search section %d at 0x%04X", ImageInfo->sections_count, fpos); - #endif +#endif for (a=0;a<7;a++) { marker = fgetc(infile); if (marker != 0xff) break; } - #ifdef EXIF_DEBUG +#ifdef EXIF_DEBUG fpos = ftell(infile); - #endif +#endif if (marker == 0xff) { /* 0xff is legal padding, but if we get that many, something's wrong. */ php_error(E_WARNING, "too many padding bytes!"); @@ -1737,9 +1737,9 @@ return FALSE; } - #ifdef EXIF_DEBUG +#ifdef EXIF_DEBUG php_error(E_NOTICE,"process section(x%02X=%s) @ x%04X + x%04X(=%d)", marker, exif_get_markername(marker), fpos, itemlen, itemlen); - #endif +#endif switch(marker) { case M_SOS: /* stop before hitting compressed data */ /* If reading entire image is requested, read the rest of the data. */ @@ -1793,9 +1793,9 @@ break; case M_FPIX: /*ImageInfo->sections_found |= FOUND_FPIX;*/ - #ifdef EXIF_DEBUG +#ifdef EXIF_DEBUG php_error(E_NOTICE,"Found Flash Pix Extension Data"); - #endif +#endif /*exif_process_TIFF_in_JPEG(ImageInfo,(char *)Data,itemlen);*/ break; case M_APP12: @@ -1823,9 +1823,9 @@ break; } } - #ifdef EXIF_DEBUG +#ifdef EXIF_DEBUG php_error(E_NOTICE,"exif_scan_JPEG_header, done"); - #endif +#endif return TRUE; } /* }}} */ @@ -1838,9 +1838,9 @@ unsigned char *dir_entry; size_t ifd_size, dir_size, entry_offset, next_offset, entry_length, entry_value; int entry_tag , entry_type; - #ifdef EXIF_DEBUG +#ifdef EXIF_DEBUG char tagname[64]; - #endif +#endif sn = ImageInfo->sections_count++; if ( ImageInfo->FileSize >= dir_offset+2) { @@ -1850,17 +1850,17 @@ fread(ImageInfo->sections[sn].Data, 1, 2, infile); num_entries = php_ifd_get16u(ImageInfo->sections[sn].Data, ImageInfo->motorola_intel); dir_size = 2/*num dir entries*/ +12/*length of entry*/*num_entries +4/* offset to next ifd (points to thumbnail or NULL)*/; - #ifdef EXIF_DEBUG +#ifdef EXIF_DEBUG php_error(E_NOTICE,"Read from TIFF: filesize(x%04X), IFD dir(x%04X + x%04X), IFD entries(%d)", ImageInfo->FileSize, dir_offset, dir_size, num_entries); - #endif +#endif if ( ImageInfo->FileSize >= dir_offset+dir_size) { ImageInfo->sections[sn].Size = dir_size; ImageInfo->sections[sn].Data = erealloc(ImageInfo->sections[sn].Data,ImageInfo->sections[sn].Size); fread(ImageInfo->sections[sn].Data+2, 1, dir_size-2, infile); next_offset = php_ifd_get32u(ImageInfo->sections[sn].Data + dir_size - 4, ImageInfo->motorola_intel); - #ifdef EXIF_DEBUG +#ifdef EXIF_DEBUG php_error(E_NOTICE,"Read from TIFF done, next offset x%04X", next_offset); - #endif +#endif /* now we have the directory we can look how long it should be */ ifd_size = dir_size; for(i=0;i<num_entries;i++) { @@ -1930,13 +1930,13 @@ php_error(E_ERROR,"Error in TIFF: filesize(x%04X) less than size of IFD(x%04X + x%04X)", ImageInfo->FileSize, dir_offset, ifd_size); return FALSE; } - #ifdef EXIF_DEBUG +#ifdef EXIF_DEBUG php_error(E_NOTICE,"Read from TIFF: filesize(x%04X), IFD(x%04X + x%04X)", ImageInfo->FileSize, dir_offset, ifd_size); - #endif +#endif fread(ImageInfo->sections[sn].Data+dir_size, 1, ifd_size-dir_size, infile); - #ifdef EXIF_DEBUG +#ifdef EXIF_DEBUG php_error(E_NOTICE,"Read from TIFF, done"); - #endif +#endif } /* now process the tags */ for(i=0;i<num_entries;i++) { @@ -1964,13 +1964,13 @@ break; } entry_offset = php_ifd_get32u(dir_entry+8, ImageInfo->motorola_intel); - #ifdef EXIF_DEBUG +#ifdef EXIF_DEBUG php_error(E_NOTICE,"Found other IFD: %s at x%04X", exif_get_tagname(entry_tag,tagname), entry_offset); - #endif +#endif exif_process_IFD_in_TIFF(ImageInfo,infile,entry_offset,sub_section_index); - #ifdef EXIF_DEBUG +#ifdef EXIF_DEBUG php_error(E_NOTICE,"TIFF subsection %s done", exif_get_sectionname(sub_section_index)); - #endif +#endif } else { exif_process_IFD_TAG(ImageInfo,dir_entry,ImageInfo->sections[sn].Data-dir_offset,ifd_size,section_index,0); } @@ -1978,13 +1978,13 @@ if (next_offset && section_index != SECTION_THUMBNAIL) { /* this should be a thumbnail IFD */ /* the thumbnail itself is stored at Tag=StripOffsets */ - #ifdef EXIF_DEBUG +#ifdef EXIF_DEBUG php_error(E_NOTICE,"Read next IFD (THUMBNAIL) at x%04X", next_offset); - #endif +#endif exif_process_IFD_in_TIFF(ImageInfo,infile,next_offset,SECTION_THUMBNAIL); - #ifdef EXIF_DEBUG +#ifdef EXIF_DEBUG php_error(E_NOTICE,"Read THUMBNAIL @0x%04X + 0x%04X", ImageInfo->ThumbnailOffset, ImageInfo->ThumbnailSize); - #endif +#endif if (ImageInfo->ThumbnailOffset && ImageInfo->ThumbnailSize) { ImageInfo->Thumbnail = emalloc(ImageInfo->ThumbnailSize); if (!ImageInfo->Thumbnail) { @@ -1994,9 +1994,9 @@ fread(ImageInfo->Thumbnail, 1, ImageInfo->ThumbnailSize, infile); } } - #ifdef EXIF_DEBUG +#ifdef EXIF_DEBUG php_error(E_NOTICE,"Read next IFD (THUMBNAIL) done"); - #endif +#endif } return TRUE; } else { @@ -2034,9 +2034,9 @@ { ImageInfo->FileType = IMAGE_FILETYPE_TIFF_II; ImageInfo->motorola_intel = 0; - #ifdef EXIF_DEBUG +#ifdef EXIF_DEBUG php_error(E_NOTICE,"File(%s) has TIFF/II format", ImageInfo->FileName); - #endif +#endif ImageInfo->sections_found |= FOUND_IFD0; return exif_process_IFD_in_TIFF(ImageInfo,infile,php_ifd_get32u(file_header+4,ImageInfo->motorola_intel),SECTION_IFD0); } @@ -2045,9 +2045,9 @@ { ImageInfo->FileType = IMAGE_FILETYPE_TIFF_MM; ImageInfo->motorola_intel = 1; - #ifdef EXIF_DEBUG +#ifdef EXIF_DEBUG php_error(E_NOTICE,"File(%s) has TIFF/MM format", ImageInfo->FileName); - #endif +#endif ImageInfo->sections_found |= FOUND_IFD0; return exif_process_IFD_in_TIFF(ImageInfo,infile,php_ifd_get32u(file_header+4,ImageInfo->motorola_intel),SECTION_IFD0); } @@ -2179,11 +2179,11 @@ } efree(sections_str); /* now see what we need */ - #ifdef EXIF_DEBUG +#ifdef EXIF_DEBUG sections_str = exif_get_sectionlist(sections_needed); php_error(E_NOTICE,"Sections needed: %s", sections_str[0] ? sections_str : "None"); efree(sections_str); - #endif +#endif } if(ac >= 3) { convert_to_long_ex(p_sub_arrays); @@ -2204,9 +2204,9 @@ sections_str = exif_get_sectionlist(ImageInfo.sections_found); - #ifdef EXIF_DEBUG +#ifdef EXIF_DEBUG php_error(E_NOTICE,"Sections found: %s", sections_str[0] ? sections_str : "None"); - #endif +#endif ImageInfo.sections_found |= FOUND_COMPUTED;/* do not inform about in debug*/ @@ -2217,9 +2217,9 @@ RETURN_FALSE; } - #ifdef EXIF_DEBUG +#ifdef EXIF_DEBUG php_error(E_NOTICE,"Returning information"); - #endif +#endif /*************************************************************************************************/ /* generic created information must use motorola/intel organisation from the executing processor */ @@ -2286,9 +2286,9 @@ } efree(sections_str); - #ifdef EXIF_DEBUG +#ifdef EXIF_DEBUG php_error(E_NOTICE,"adding image infos"); - #endif +#endif add_assoc_image_info( return_value, sub_arrays, &ImageInfo, SECTION_FILE); add_assoc_image_info( return_value, 1, &ImageInfo, SECTION_COMPUTED); @@ -2302,15 +2302,15 @@ add_assoc_image_info( return_value, sub_arrays, &ImageInfo, SECTION_FPIX); add_assoc_image_info( return_value, sub_arrays, &ImageInfo, SECTION_APP12); - #ifdef EXIF_DEBUG +#ifdef EXIF_DEBUG php_error(E_NOTICE,"Discarding info"); - #endif +#endif php_exif_discard_imageinfo(&ImageInfo); - #ifdef EXIF_DEBUG +#ifdef EXIF_DEBUG php_error(E_NOTICE,"read_exif_data done"); - #endif +#endif } /* }}} */ @@ -2342,21 +2342,21 @@ RETURN_FALSE; } - #ifdef EXIF_DEBUG +#ifdef EXIF_DEBUG php_error(E_NOTICE,"Returning thumbnail(%d)", ImageInfo.ThumbnailSize); - #endif +#endif RETVAL_STRINGL(ImageInfo.Thumbnail, ImageInfo.ThumbnailSize, 1); - #ifdef EXIF_DEBUG +#ifdef EXIF_DEBUG php_error(E_NOTICE,"Discarding info"); - #endif +#endif php_exif_discard_imageinfo(&ImageInfo); - #ifdef EXIF_DEBUG +#ifdef EXIF_DEBUG php_error(E_NOTICE,"exif_thumbnail done"); - #endif +#endif } /* }}} */
« previous php.cvs (#13797) next »