[prev in list] [next in list] [prev in thread] [next in thread]
List: graphicsmagick-commit
Subject: [GM-commit] GraphicsMagick: Blob refers to stdio, bzip2, and gzip file handl...
From: GraphicsMagick Commits <graphicsmagick-commit () lists ! sourceforge ! net>
Date: 2012-06-16 19:34:21
Message-ID: hg.3355f77e6df4.1339875261.-1602079902 () blade ! simplesystems ! org
[Download RAW message or body]
changeset 3355f77e6df4 in /hg/GraphicsMagick
details: http://hg.GraphicsMagick.org/hg/GraphicsMagick?cmd=changeset;node=3355f77e6df4
summary: Blob refers to stdio, bzip2, and gzip file handles using their own type.
diffstat:
ChangeLog | 4 +
magick/blob.c | 172 ++++++++++++++++++++++++++++++----------------------
www/Changelog.html | 3 +
3 files changed, 105 insertions(+), 74 deletions(-)
diffs (truncated from 584 to 300 lines):
diff -r 251738d41582 -r 3355f77e6df4 ChangeLog
--- a/ChangeLog Sat Jun 16 11:20:38 2012 -0500
+++ b/ChangeLog Sat Jun 16 14:34:16 2012 -0500
@@ -1,5 +1,9 @@
2012-06-16 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
+ * magick/blob.c (MagickFileHandle): Refer to stdio, bzip2, and
+ gzip file handles using their own type. Eliminates warnings
+ observed when compiling with zlib 1.2.7.
+
* tiff: Updated libtiff to 4.0.2 release.
* png: Updated libpng to 1.5.11 release.
diff -r 251738d41582 -r 3355f77e6df4 magick/blob.c
--- a/magick/blob.c Sat Jun 16 11:20:38 2012 -0500
+++ b/magick/blob.c Sat Jun 16 14:34:16 2012 -0500
@@ -86,6 +86,18 @@
/*
Typedef declarations.
*/
+
+typedef union _MagickFileHandle
+{
+ FILE *std; /* stdio handle */
+#if defined(HasBZLIB)
+ BZFILE *bz; /* bzip handle */
+#endif
+#if defined(HasZLIB)
+ gzFile gz; /* zlib handle */
+#endif
+} MagickFileHandle;
+
struct _BlobInfo
{
size_t
@@ -109,8 +121,8 @@
StreamType
type; /* Classification for how BLOB I/O is implemented. */
- FILE
- *file; /* File handle for I/O (if any) */
+ MagickFileHandle
+ handle; /* Handle for I/O (if any) */
BlobMode
mode; /* Blob open mode */
@@ -269,7 +281,7 @@
{
if ((image->blob->offset+length) >= image->blob->extent)
{
- if ((image->blob->mapped) && (image->blob->file != (FILE *) NULL))
+ if ((image->blob->mapped) && (image->blob->handle.std != (FILE *) NULL))
{
/* Memory mapped file */
int
@@ -283,7 +295,7 @@
*data;
image->blob->data=0;
- filedes=fileno(image->blob->file);
+ filedes=fileno(image->blob->handle.std);
quantum=image->blob->quantum;
quantum<<=1;
extent=image->blob->extent;
@@ -368,7 +380,13 @@
blob_info->quantum=DefaultBlobQuantum;
blob_info->offset=0;
blob_info->type=BlobStream;
- blob_info->file=(FILE *) NULL;
+ blob_info->handle.std=(FILE *) NULL;
+#if defined(HasBZLIB)
+ blob_info->handle.bz=(BZFILE *) NULL;
+#endif
+#if defined(HasZLIB)
+ blob_info->handle.gz=(gzFile) NULL;
+#endif
blob_info->data=(unsigned char *) blob;
}
@@ -443,13 +461,13 @@
if ((FileStream == image->blob->type) ||
((BlobStream == image->blob->type) &&
- (image->blob->mapped) && (image->blob->file != (FILE *) NULL)))
+ (image->blob->mapped) && (image->blob->handle.std != (FILE *) NULL)))
{
#if defined(HAVE_POSIX_FALLOCATE)
int
err_status;
- if ((err_status=posix_fallocate(fileno(image->blob->file),
+ if ((err_status=posix_fallocate(fileno(image->blob->handle.std),
0UL, size)) != 0)
{
ThrowException(&image->exception,BlobError,UnableToWriteBlob,strerror(err_status));
@@ -484,7 +502,7 @@
#endif
if (BlobStream == image->blob->type)
{
- if ((image->blob->mapped) && (image->blob->file != (FILE *) NULL))
+ if ((image->blob->mapped) && (image->blob->handle.std != (FILE *) NULL))
{
/*
Memory mapped file I/O
@@ -499,7 +517,7 @@
*data;
image->blob->data=0;
- filedes=fileno(image->blob->file);
+ filedes=fileno(image->blob->handle.std);
extent=size;
/*
@@ -866,7 +884,7 @@
clone_info->status=blob_info->status;
clone_info->temporary=blob_info->temporary;
clone_info->type=blob_info->type;
- clone_info->file=blob_info->file;
+ clone_info->handle=blob_info->handle;
clone_info->data=blob_info->data;
clone_info->reference_count=1;
return(clone_info);
@@ -929,20 +947,20 @@
case StandardStream:
case PipeStream:
{
- status=ferror(image->blob->file);
+ status=ferror(image->blob->handle.std);
break;
}
case ZipStream:
{
#if defined(HasZLIB)
- (void) gzerror(image->blob->file,&status);
+ (void) gzerror(image->blob->handle.gz,&status);
#endif
break;
}
case BZipStream:
{
#if defined(HasBZLIB)
- (void) BZ2_bzerror(image->blob->file,&status);
+ (void) BZ2_bzerror(image->blob->handle.bz,&status);
#endif
break;
}
@@ -966,44 +984,44 @@
{
if (image->blob->fsync)
{
- (void) fflush(image->blob->file);
- (void) fsync(fileno(image->blob->file));
+ (void) fflush(image->blob->handle.std);
+ (void) fsync(fileno(image->blob->handle.std));
}
- status=fclose(image->blob->file);
+ status=fclose(image->blob->handle.std);
break;
}
case PipeStream:
{
#if defined(HAVE_PCLOSE)
- status=pclose(image->blob->file);
+ status=pclose(image->blob->handle.std);
#endif /* defined(HAVE_PCLOSE) */
break;
}
case ZipStream:
{
#if defined(HasZLIB)
- status=gzclose(image->blob->file);
+ status=gzclose(image->blob->handle.gz);
#endif
break;
}
case BZipStream:
{
#if defined(HasBZLIB)
- BZ2_bzclose(image->blob->file);
+ BZ2_bzclose(image->blob->handle.bz);
#endif
break;
}
case BlobStream:
{
- if (image->blob->file != (FILE *) NULL)
+ if (image->blob->handle.std != (FILE *) NULL)
{
/*
Truncate memory-mapped output file to size.
*/
- (void) MagickFtruncate(fileno(image->blob->file),image->blob->length);
+ (void) MagickFtruncate(fileno(image->blob->handle.std),image->blob->length);
if (image->blob->fsync)
- (void) fsync(fileno(image->blob->file));
- status=fclose(image->blob->file);
+ (void) fsync(fileno(image->blob->handle.std));
+ status=fclose(image->blob->handle.std);
}
break;
}
@@ -1162,7 +1180,13 @@
blob_info->eof=MagickFalse;
blob_info->exempt=MagickFalse;
blob_info->type=UndefinedStream;
- blob_info->file=(FILE *) NULL;
+ blob_info->handle.std=(FILE *) NULL;
+#if defined(HasBZLIB)
+ blob_info->handle.bz=(BZFILE *) NULL;
+#endif
+#if defined(HasZLIB)
+ blob_info->handle.gz=(gzFile) NULL;
+#endif
blob_info->data=(unsigned char *) NULL;
}
@@ -1207,7 +1231,7 @@
case StandardStream:
case PipeStream:
{
- image->blob->eof=feof(image->blob->file);
+ image->blob->eof=feof(image->blob->handle.std);
break;
}
case ZipStream:
@@ -1221,7 +1245,7 @@
int
status;
- (void) BZ2_bzerror(image->blob->file,&status);
+ (void) BZ2_bzerror(image->blob->handle.bz,&status);
image->blob->eof=status == BZ_UNEXPECTED_EOF;
#endif
break;
@@ -1369,7 +1393,7 @@
{
assert(image != (const Image *) NULL);
assert(image->blob != (const BlobInfo *) NULL);
- return (image->blob->file);
+ return (image->blob->handle.std);
}
/*
@@ -1487,7 +1511,7 @@
break;
case FileStream:
{
- offset=(MagickFstat(fileno(image->blob->file),&attributes) < 0 ? 0 :
+ offset=(MagickFstat(fileno(image->blob->handle.std),&attributes) < 0 ? 0 :
attributes.st_size);
break;
}
@@ -2508,7 +2532,7 @@
*/
if (*type == 'r')
{
- image->blob->file=stdin;
+ image->blob->handle.std=stdin;
if (image->logging)
(void) LogMagickEvent(BlobEvent,GetMagickModule(),
" using stdin as StandardStream blob 0x%p",
@@ -2516,7 +2540,7 @@
}
else
{
- image->blob->file=stdout;
+ image->blob->handle.std=stdout;
if (image->logging)
(void) LogMagickEvent(BlobEvent,GetMagickModule(),
" using stdout as StandardStream blob 0x%p",
@@ -2545,11 +2569,11 @@
#endif
(void) strlcpy(mode_string,type,sizeof(mode_string));
mode_string[1]='\0';
- image->blob->file=(FILE *) NULL;
+ image->blob->handle.std=(FILE *) NULL;
if (MagickConfirmAccess(FileExecuteConfirmAccessMode,filename+1,
exception) != MagickFail)
- image->blob->file=(FILE *) popen(filename+1,mode_string);
- if (image->blob->file != (FILE *) NULL)
+ image->blob->handle.std=(FILE *) popen(filename+1,mode_string);
+ if (image->blob->handle.std != (FILE *) NULL)
{
image->blob->type=PipeStream;
if (image->logging)
@@ -2578,12 +2602,12 @@
((strlen(filename) > 5) &&
(LocaleCompare(filename+strlen(filename)-5,".svgz") == 0)))
{
- image->blob->file=(FILE *) NULL;
+ image->blob->handle.gz=(gzFile) NULL;
if (MagickConfirmAccess((type[0] == 'r' ? FileReadConfirmAccessMode :
FileWriteConfirmAccessMode),filename,
exception) != MagickFail)
- image->blob->file=(FILE *) gzopen(filename,type);
- if (image->blob->file != (FILE *) NULL)
+ image->blob->handle.gz=gzopen(filename,type);
+ if (image->blob->handle.gz != (gzFile) NULL)
{
image->blob->type=ZipStream;
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Graphicsmagick-commit mailing list
Graphicsmagick-commit@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/graphicsmagick-commit
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic