Powered by Pair ImageMagick logo
Image Magick
Main Page | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | File List | Namespace Members | Data Fields | Globals | Related Pages

ImageMagick-6.1.1/magick/blob.c File Reference

#include "magick/studio.h"
#include "magick/blob.h"
#include "magick/blob_private.h"
#include "magick/cache.h"
#include "magick/client.h"
#include "magick/constitute.h"
#include "magick/delegate.h"
#include "magick/error.h"
#include "magick/error_private.h"
#include "magick/image_private.h"
#include "magick/list.h"
#include "magick/log.h"
#include "magick/magick.h"
#include "magick/memory_.h"
#include "magick/resource_.h"
#include "magick/semaphore.h"
#include "magick/string_.h"
#include "magick/utility.h"

Include dependency graph for blob.c:

Include dependency graph

Go to the source code of this file.

Data Structures

struct  _BlobInfo

Defines

#define DefaultBlobQuantum   0x3c005UL
#define MAP_FAILED   ((void *) -1)
#define MinBlobExtent   65541UL
#define MS_SYNC   0x04

Enumerations

enum  StreamType {
  UndefinedStream, FileStream, StandardStream, PipeStream,
  ZipStream, BZipStream, FifoStream, BlobStream
}

Functions

MagickExport void AttachBlob (BlobInfo *blob_info, const void *blob, const size_t length)
MagickExport MagickBooleanType BlobToFile (char *filename, const void *blob, const size_t length, ExceptionInfo *exception)
MagickExport ImageBlobToImage (const ImageInfo *image_info, const void *blob, const size_t length, ExceptionInfo *exception)
MagickExport BlobInfoCloneBlobInfo (const BlobInfo *blob_info)
MagickExport void CloseBlob (Image *image)
MagickExport void DestroyBlob (Image *image)
MagickExport unsigned char * DetachBlob (BlobInfo *blob_info)
MagickExport int EOFBlob (const Image *image)
MagickExport unsigned char * FileToBlob (const char *filename, size_t *length, ExceptionInfo *exception)
MagickExport MagickBooleanType GetBlobError (const Image *image)
MagickExport FILE * GetBlobFileHandle (const Image *image)
MagickExport void GetBlobInfo (BlobInfo *blob_info)
MagickExport MagickSizeType GetBlobSize (const Image *image)
MagickExport unsigned char * GetBlobStreamData (const Image *image)
MagickExport StreamHandler GetBlobStreamHandler (const Image *image)
MagickExport unsigned char * ImageToBlob (const ImageInfo *image_info, Image *image, size_t *length, ExceptionInfo *exception)
MagickExport MagickBooleanType ImageToFile (Image *image, char *filename, ExceptionInfo *exception)
MagickExport MagickBooleanType IsBlobExempt (const Image *image)
MagickExport MagickBooleanType IsBlobSeekable (const Image *image)
MagickExport MagickBooleanType IsBlobTemporary (const Image *image)
MagickExport unsigned char * MapBlob (int file, const MapMode mode, const MagickOffsetType offset, const size_t length)
MagickExport void MSBOrderLong (unsigned char *buffer, const size_t length)
MagickExport void MSBOrderShort (unsigned char *p, const size_t length)
MagickExport MagickBooleanType OpenBlob (const ImageInfo *image_info, Image *image, const BlobMode mode, ExceptionInfo *exception)
MagickBooleanType PingStream (const Image *magick_unused(image), const void *magick_unused(pixels), const size_t magick_unused(columns))
MagickExport ImagePingBlob (const ImageInfo *image_info, const void *blob, const size_t length, ExceptionInfo *exception)
ssize_t ReadInlineBlob (Image *image, const size_t length, unsigned char *data)
MagickExport ssize_t ReadBlob (Image *image, const size_t length, unsigned char *data)
MagickExport int ReadBlobByte (Image *image)
MagickExport unsigned long ReadBlobLSBLong (Image *image)
MagickExport unsigned short ReadBlobLSBShort (Image *image)
MagickExport unsigned long ReadBlobMSBLong (Image *image)
MagickExport unsigned short ReadBlobMSBShort (Image *image)
MagickExport char * ReadBlobString (Image *image, char *string)
MagickExport BlobInfoReferenceBlob (BlobInfo *blob)
MagickExport MagickOffsetType SeekBlob (Image *image, const MagickOffsetType offset, const int whence)
MagickExport void SetBlobExempt (Image *image, const MagickBooleanType exempt)
MagickExport int SyncBlob (Image *image)
MagickExport MagickOffsetType TellBlob (const Image *image)
MagickExport MagickBooleanType UnmapBlob (void *map, const size_t length)
ssize_t WriteInlineBlob (Image *image, const size_t length, const unsigned char *data)
MagickExport ssize_t WriteBlob (Image *image, const size_t length, const unsigned char *data)
MagickExport ssize_t WriteBlobByte (Image *image, const unsigned char value)
MagickExport ssize_t WriteBlobLSBLong (Image *image, const unsigned long value)
MagickExport ssize_t WriteBlobLSBShort (Image *image, const unsigned short value)
MagickExport ssize_t WriteBlobMSBLong (Image *image, const unsigned long value)
MagickExport ssize_t WriteBlobMSBShort (Image *image, const unsigned short value)
MagickExport ssize_t WriteBlobString (Image *image, const char *string)


Define Documentation

#define DefaultBlobQuantum   0x3c005UL
 

Definition at line 74 of file blob.c.

Referenced by AttachBlob(), GetBlobInfo(), ImageToBlob(), and OpenBlob().

#define MAP_FAILED   ((void *) -1)
 

Definition at line 79 of file blob.c.

Referenced by MapBlob().

#define MinBlobExtent   65541UL
 

Definition at line 81 of file blob.c.

Referenced by OpenBlob().

#define MS_SYNC   0x04
 

Definition at line 83 of file blob.c.

Referenced by SyncBlob().


Enumeration Type Documentation

enum StreamType
 

Enumeration values:
UndefinedStream 
FileStream 
StandardStream 
PipeStream 
ZipStream 
BZipStream 
FifoStream 
BlobStream 

Definition at line 89 of file blob.c.

00090 { 00091 UndefinedStream, 00092 FileStream, 00093 StandardStream, 00094 PipeStream, 00095 ZipStream, 00096 BZipStream, 00097 FifoStream, 00098 BlobStream 00099 } StreamType;


Function Documentation

MagickExport void AttachBlob BlobInfo blob_info,
const void *  blob,
const size_t  length
 

Definition at line 176 of file blob.c.

References assert, BlobStream, _BlobInfo::data, _BlobInfo::debug, DefaultBlobQuantum, _BlobInfo::extent, _BlobInfo::file, GetMagickModule, _BlobInfo::length, LogMagickEvent(), MagickExport, MagickFalse, _BlobInfo::offset, _BlobInfo::quantum, TraceEvent, and _BlobInfo::type.

00178 { 00179 assert(blob_info != (BlobInfo *) NULL); 00180 if (blob_info->debug != MagickFalse) 00181 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"..."); 00182 blob_info->length=length; 00183 blob_info->extent=length; 00184 blob_info->quantum=DefaultBlobQuantum; 00185 blob_info->offset=0; 00186 blob_info->type=BlobStream; 00187 blob_info->file=(FILE *) NULL; 00188 blob_info->data=(unsigned char *) blob; 00189 }

Here is the call graph for this function:

MagickExport MagickBooleanType BlobToFile char *  filename,
const void *  blob,
const size_t  length,
ExceptionInfo exception
 

Definition at line 222 of file blob.c.

References AcquireUniqueFileResource(), assert, BlobError, GetMagickModule, LogMagickEvent(), MagickBooleanType, MagickExport, MagickFalse, MagickMaxBufferSize, MagickTrue, Min, O_BINARY, S_MODE, ssize_t, ThrowFileException, and TraceEvent.

00224 { 00225 int 00226 file; 00227 00228 register size_t 00229 i; 00230 00231 ssize_t 00232 count; 00233 00234 assert(filename != (const char *) NULL); 00235 (void) LogMagickEvent(TraceEvent,GetMagickModule(),filename); 00236 assert(blob != (const void *) NULL); 00237 if (*filename == '\0') 00238 file=AcquireUniqueFileResource(filename); 00239 else 00240 file=open(filename,O_RDWR | O_CREAT | O_EXCL | O_BINARY,S_MODE); 00241 if (file == -1) 00242 { 00243 ThrowFileException(exception,BlobError,"UnableToWriteBlob",filename); 00244 return(MagickFalse); 00245 } 00246 for (i=0; i < length; i+=count) 00247 { 00248 count=write(file,(char *) blob+i,Min(length-i,(size_t) 00249 MagickMaxBufferSize)); 00250 if (count <= 0) 00251 { 00252 count=0; 00253 if (errno != EINTR) 00254 break; 00255 } 00256 } 00257 (void) close(file); 00258 if (i < length) 00259 { 00260 ThrowFileException(exception,BlobError,"UnableToWriteBlob",filename); 00261 return(MagickFalse); 00262 } 00263 return(MagickTrue); 00264 }

Here is the call graph for this function:

MagickExport Image* BlobToImage const ImageInfo image_info,
const void *  blob,
const size_t  length,
ExceptionInfo exception
 

Definition at line 298 of file blob.c.

References assert, _Image::blob, _ImageInfo::blob, BlobError, BlobToFile(), CloneImageInfo(), CopyMagickString(), _ImageInfo::debug, DestroyImageInfo(), DetachBlob(), _ImageInfo::filename, GetMagickBlobSupport(), GetMagickInfo(), GetMagickModule, _ImageInfo::length, LogMagickEvent(), _ImageInfo::magick, MagickBooleanType, MagickExport, MagickFalse, MagickSignature, MaxTextExtent, ReadImage(), RelinquishUniqueFileResource(), SetExceptionInfo(), SetImageInfo(), _ImageInfo::signature, ThrowMagickException(), TraceEvent, and UndefinedException.

00300 { 00301 const MagickInfo 00302 *magick_info; 00303 00304 Image 00305 *image; 00306 00307 ImageInfo 00308 *blob_info; 00309 00310 MagickBooleanType 00311 status; 00312 00313 assert(image_info != (ImageInfo *) NULL); 00314 assert(image_info->signature == MagickSignature); 00315 if (image_info->debug != MagickFalse) 00316 (void) LogMagickEvent(TraceEvent,GetMagickModule(),image_info->filename); 00317 assert(exception != (ExceptionInfo *) NULL); 00318 (void) SetExceptionInfo(exception,UndefinedException); 00319 if ((blob == (const void *) NULL) || (length == 0)) 00320 { 00321 (void) ThrowMagickException(exception,GetMagickModule(),BlobError, 00322 "ZeroLengthBlobNotPermitted",image_info->filename); 00323 return((Image *) NULL); 00324 } 00325 blob_info=CloneImageInfo(image_info); 00326 blob_info->blob=(void *) blob; 00327 blob_info->length=length; 00328 if (*blob_info->magick == '\0') 00329 (void) SetImageInfo(blob_info,MagickFalse,exception); 00330 magick_info=GetMagickInfo(blob_info->magick,exception); 00331 if (magick_info == (const MagickInfo *) NULL) 00332 { 00333 blob_info=DestroyImageInfo(blob_info); 00334 return((Image *) NULL); 00335 } 00336 if (GetMagickBlobSupport(magick_info) != MagickFalse) 00337 { 00338 /* 00339 Native blob support for this image format. 00340 */ 00341 (void) CopyMagickString(blob_info->filename,image_info->filename, 00342 MaxTextExtent); 00343 (void) CopyMagickString(blob_info->magick,image_info->magick, 00344 MaxTextExtent); 00345 image=ReadImage(blob_info,exception); 00346 if (image != (Image *) NULL) 00347 (void) DetachBlob(image->blob); 00348 blob_info=DestroyImageInfo(blob_info); 00349 return(image); 00350 } 00351 /* 00352 Write blob to a temporary file on disk. 00353 */ 00354 blob_info->blob=(void *) NULL; 00355 blob_info->length=0; 00356 *blob_info->filename='\0'; 00357 status=BlobToFile(blob_info->filename,blob,length,exception); 00358 if (status == MagickFalse) 00359 { 00360 (void) RelinquishUniqueFileResource(blob_info->filename); 00361 blob_info=DestroyImageInfo(blob_info); 00362 return((Image *) NULL); 00363 } 00364 image=ReadImage(blob_info,exception); 00365 (void) RelinquishUniqueFileResource(blob_info->filename); 00366 blob_info=DestroyImageInfo(blob_info); 00367 return(image); 00368 }

Here is the call graph for this function:

MagickExport BlobInfo* CloneBlobInfo const BlobInfo blob_info  ) 
 

Definition at line 394 of file blob.c.

References AcquireMagickMemory(), _BlobInfo::data, _BlobInfo::eof, _BlobInfo::exempt, _BlobInfo::extent, _BlobInfo::file, GetBlobInfo(), IsEventLogging(), _BlobInfo::length, MagickExport, _BlobInfo::mapped, _BlobInfo::offset, _BlobInfo::quantum, ResourceLimitFatalError, _BlobInfo::size, _BlobInfo::status, _BlobInfo::stream, _BlobInfo::temporary, ThrowMagickFatalException, and _BlobInfo::type.

00395 { 00396 BlobInfo 00397 *clone_info; 00398 00399 clone_info=(BlobInfo *) AcquireMagickMemory(sizeof(*clone_info)); 00400 if (clone_info == (BlobInfo *) NULL) 00401 ThrowMagickFatalException(ResourceLimitFatalError,"MemoryAllocationFailed", 00402 strerror(errno)); 00403 GetBlobInfo(clone_info); 00404 if (blob_info == (BlobInfo *) NULL) 00405 return(clone_info); 00406 clone_info->length=blob_info->length; 00407 clone_info->extent=blob_info->extent; 00408 clone_info->quantum=blob_info->quantum; 00409 clone_info->mapped=blob_info->mapped; 00410 clone_info->eof=blob_info->eof; 00411 clone_info->offset=blob_info->offset; 00412 clone_info->size=blob_info->size; 00413 clone_info->exempt=blob_info->exempt; 00414 clone_info->status=blob_info->status; 00415 clone_info->temporary=blob_info->temporary; 00416 clone_info->type=blob_info->type; 00417 clone_info->file=blob_info->file; 00418 clone_info->stream=blob_info->stream; 00419 clone_info->data=blob_info->data; 00420 clone_info->debug=IsEventLogging(); 00421 clone_info->reference_count=1; 00422 clone_info->semaphore=(SemaphoreInfo *) NULL; 00423 return(clone_info); 00424 }

Here is the call graph for this function:

MagickExport void CloseBlob Image image  ) 
 

Definition at line 449 of file blob.c.

References assert, _Image::blob, BlobStream, BZipStream, _Image::debug, DetachBlob(), _BlobInfo::eof, _BlobInfo::exempt, FifoStream, _BlobInfo::file, _Image::filename, FileStream, GetBlobSize(), GetMagickModule, LogMagickEvent(), MagickBooleanType, MagickExport, MagickFalse, MagickSignature, pclose, PipeStream, _Image::signature, _BlobInfo::size, StandardStream, _BlobInfo::status, SyncBlob(), _Image::taint, TraceEvent, _BlobInfo::type, UndefinedStream, and ZipStream.

00450 { 00451 int 00452 status; 00453 00454 /* 00455 Close image file. 00456 */ 00457 assert(image != (Image *) NULL); 00458 assert(image->signature == MagickSignature); 00459 if (image->debug != MagickFalse) 00460 (void) LogMagickEvent(TraceEvent,GetMagickModule(),image->filename); 00461 assert(image->blob != (BlobInfo *) NULL); 00462 if (image->blob->type == UndefinedStream) 00463 return; 00464 image->taint=MagickFalse; 00465 image->blob->size=GetBlobSize(image); 00466 image->blob->eof=MagickFalse; 00467 if (image->blob->exempt != MagickFalse) 00468 return; 00469 status=0; 00470 (void) SyncBlob(image); 00471 switch (image->blob->type) 00472 { 00473 case UndefinedStream: 00474 break; 00475 case FileStream: 00476 case StandardStream: 00477 case PipeStream: 00478 { 00479 status=ferror(image->blob->file); 00480 break; 00481 } 00482 case ZipStream: 00483 { 00484 #if defined(HasZLIB) 00485 (void) gzerror(image->blob->file,&status); 00486 #endif 00487 break; 00488 } 00489 case BZipStream: 00490 { 00491 #if defined(HasBZLIB) 00492 (void) BZ2_bzerror((BZFILE *) image->blob->file,&status); 00493 #endif 00494 break; 00495 } 00496 case FifoStream: 00497 case BlobStream: 00498 break; 00499 } 00500 image->blob->status=(MagickBooleanType) (status < 0); 00501 switch (image->blob->type) 00502 { 00503 case UndefinedStream: 00504 break; 00505 case FileStream: 00506 case StandardStream: 00507 { 00508 status=fclose(image->blob->file); 00509 break; 00510 } 00511 case PipeStream: 00512 { 00513 #if defined(HAVE_POPEN) 00514 status=pclose(image->blob->file); 00515 #endif 00516 break; 00517 } 00518 case ZipStream: 00519 { 00520 #if defined(HasZLIB) 00521 status=gzclose(image->blob->file); 00522 #endif 00523 break; 00524 } 00525 case BZipStream: 00526 { 00527 #if defined(HasBZLIB) 00528 BZ2_bzclose((BZFILE *) image->blob->file); 00529 #endif 00530 break; 00531 } 00532 case FifoStream: 00533 case BlobStream: 00534 break; 00535 } 00536 (void) DetachBlob(image->blob); 00537 image->blob->status=(MagickBooleanType) (status < 0); 00538 }

Here is the call graph for this function:

MagickExport void DestroyBlob Image image  ) 
 

Definition at line 563 of file blob.c.

References AcquireSemaphoreInfo(), assert, _Image::blob, CloseBlob(), _BlobInfo::data, _Image::debug, DestroySemaphoreInfo(), _Image::filename, GetMagickModule, _BlobInfo::length, LogMagickEvent(), MagickExport, MagickFalse, MagickSignature, _BlobInfo::mapped, _BlobInfo::reference_count, RelinquishMagickMemory(), RelinquishSemaphoreInfo(), _BlobInfo::semaphore, _Image::signature, TraceEvent, and UnmapBlob().

00564 { 00565 assert(image != (Image *) NULL); 00566 assert(image->signature == MagickSignature); 00567 if (image->debug != MagickFalse) 00568 (void) LogMagickEvent(TraceEvent,GetMagickModule(),image->filename); 00569 image->blob->semaphore=AcquireSemaphoreInfo(image->blob->semaphore); 00570 image->blob->reference_count--; 00571 if (image->blob->reference_count > 0) 00572 { 00573 RelinquishSemaphoreInfo(image->blob->semaphore); 00574 return; 00575 } 00576 CloseBlob(image); 00577 if (image->blob->mapped != MagickFalse) 00578 (void) UnmapBlob(image->blob->data,image->blob->length); 00579 RelinquishSemaphoreInfo(image->blob->semaphore); 00580 image->blob->semaphore=DestroySemaphoreInfo(image->blob->semaphore); 00581 image->blob=(BlobInfo *) RelinquishMagickMemory(image->blob); 00582 }

Here is the call graph for this function:

MagickExport unsigned char* DetachBlob BlobInfo blob_info  ) 
 

Definition at line 607 of file blob.c.

References assert, _BlobInfo::data, _BlobInfo::debug, _BlobInfo::eof, _BlobInfo::exempt, _BlobInfo::file, GetMagickModule, _BlobInfo::length, LogMagickEvent(), MagickExport, MagickFalse, _BlobInfo::mapped, _BlobInfo::offset, _BlobInfo::stream, StreamHandler, TraceEvent, _BlobInfo::type, UndefinedStream, and UnmapBlob().

00608 { 00609 unsigned char 00610 *data; 00611 00612 assert(blob_info != (BlobInfo *) NULL); 00613 if (blob_info->debug != MagickFalse) 00614 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"..."); 00615 if (blob_info->mapped != MagickFalse) 00616 (void) UnmapBlob(blob_info->data,blob_info->length); 00617 blob_info->mapped=MagickFalse; 00618 blob_info->length=0; 00619 blob_info->offset=0; 00620 blob_info->eof=MagickFalse; 00621 blob_info->exempt=MagickFalse; 00622 blob_info->type=UndefinedStream; 00623 blob_info->file=(FILE *) NULL; 00624 data=blob_info->data; 00625 blob_info->data=(unsigned char *) NULL; 00626 blob_info->stream=(StreamHandler) NULL; 00627 return(data); 00628 }

Here is the call graph for this function:

MagickExport int EOFBlob const Image image  ) 
 

Definition at line 654 of file blob.c.

References assert, _Image::blob, BlobStream, BZipStream, _Image::debug, _BlobInfo::eof, FifoStream, _BlobInfo::file, FileStream, GetMagickModule, LogMagickEvent(), MagickBooleanType, MagickExport, MagickFalse, MagickSignature, PipeStream, _Image::signature, StandardStream, TraceEvent, _BlobInfo::type, UndefinedStream, and ZipStream.

00655 { 00656 assert(image != (Image *) NULL); 00657 assert(image->signature == MagickSignature); 00658 if (image->debug != MagickFalse) 00659 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"..."); 00660 assert(image->blob != (BlobInfo *) NULL); 00661 assert(image->blob->type != UndefinedStream); 00662 switch (image->blob->type) 00663 { 00664 case UndefinedStream: 00665 break; 00666 case FileStream: 00667 case StandardStream: 00668 case PipeStream: 00669 { 00670 image->blob->eof=(MagickBooleanType) (feof(image->blob->file) != 0); 00671 break; 00672 } 00673 case ZipStream: 00674 { 00675 image->blob->eof=MagickFalse; 00676 break; 00677 } 00678 case BZipStream: 00679 { 00680 #if defined(HasBZLIB) 00681 int 00682 status; 00683 00684 status=0; 00685 (void) BZ2_bzerror((BZFILE *) image->blob->file,&status); 00686 image->blob->eof=(MagickBooleanType) (status == BZ_UNEXPECTED_EOF); 00687 #endif 00688 break; 00689 } 00690 case FifoStream: 00691 { 00692 image->blob->eof=MagickFalse; 00693 break; 00694 } 00695 case BlobStream: 00696 break; 00697 } 00698 return((int) image->blob->eof); 00699 }

Here is the call graph for this function:

MagickExport unsigned char* FileToBlob const char *  filename,
size_t *  length,
ExceptionInfo exception
 

Definition at line 734 of file blob.c.

References AcquireMagickMemory(), assert, BlobError, CopyMagickMemory(), GetMagickModule, LogMagickEvent(), MagickExport, MagickMaxBufferSize, MagickOffsetType, MagickSeek, MapBlob(), MaxTextExtent, Min, O_BINARY, ReadMode, RelinquishMagickMemory(), ResourceLimitError, SetExceptionInfo(), ssize_t, ThrowMagickException(), TraceEvent, UndefinedException, and UnmapBlob().

00736 { 00737 int 00738 file; 00739 00740 MagickOffsetType 00741 offset; 00742 00743 unsigned char 00744 *blob; 00745 00746 void 00747 *map; 00748 00749 assert(filename != (const char *) NULL); 00750 (void) LogMagickEvent(TraceEvent,GetMagickModule(),filename); 00751 assert(exception != (ExceptionInfo *) NULL); 00752 (void) SetExceptionInfo(exception,UndefinedException); 00753 file=open(filename,O_RDONLY | O_BINARY); 00754 if (file == -1) 00755 { 00756 (void) ThrowMagickException(exception,GetMagickModule(),BlobError, 00757 "UnableToOpenFile",filename,strerror(errno)); 00758 return((unsigned char *) NULL); 00759 } 00760 offset=(MagickOffsetType) MagickSeek(file,0,SEEK_END); 00761 if ((offset < 0) || (offset != (MagickOffsetType) ((ssize_t) offset))) 00762 { 00763 (void) close(file); 00764 (void) ThrowMagickException(exception,GetMagickModule(),BlobError, 00765 "UnableToCreateBlob",filename,strerror(errno)); 00766 return((unsigned char *) NULL); 00767 } 00768 *length=(size_t) offset; 00769 blob=(unsigned char *) 00770 AcquireMagickMemory((*length+MaxTextExtent)*sizeof(*blob)); 00771 if (blob == (unsigned char *) NULL) 00772 { 00773 (void) close(file); 00774 (void) ThrowMagickException(exception,GetMagickModule(), 00775 ResourceLimitError,"MemoryAllocationFailed",filename); 00776 return((unsigned char *) NULL); 00777 } 00778 map=MapBlob(file,ReadMode,0,*length); 00779 if (map != (unsigned char *) NULL) 00780 { 00781 (void) CopyMagickMemory(blob,map,*length); 00782 (void) UnmapBlob(map,*length); 00783 } 00784 else 00785 { 00786 register size_t 00787 i; 00788 00789 ssize_t 00790 count; 00791 00792 (void) MagickSeek(file,0,SEEK_SET); 00793 for (i=0; i < *length; i+=count) 00794 { 00795 count=read(file,blob+i,Min(*length-i,(size_t) MagickMaxBufferSize)); 00796 if (count <= 0) 00797 { 00798 count=0; 00799 if (errno != EINTR) 00800 break; 00801 } 00802 } 00803 if (i < *length) 00804 { 00805 (void) close(file); 00806 blob=(unsigned char *) RelinquishMagickMemory(blob); 00807 (void) ThrowMagickException(exception,GetMagickModule(),BlobError, 00808 "UnableToReadBlob",filename,strerror(errno)); 00809 return((unsigned char *) NULL); 00810 } 00811 } 00812 blob[*length]='\0'; 00813 (void) close(file); 00814 return(blob); 00815 }

Here is the call graph for this function:

MagickExport MagickBooleanType GetBlobError const Image image  ) 
 

Definition at line 841 of file blob.c.

References assert, _Image::blob, _Image::debug, _Image::filename, GetMagickModule, LogMagickEvent(), MagickBooleanType, MagickExport, MagickFalse, MagickSignature, _Image::signature, _BlobInfo::status, and TraceEvent.

00842 { 00843 assert(image != (const Image *) NULL); 00844 assert(image->signature == MagickSignature); 00845 if (image->debug != MagickFalse) 00846 (void) LogMagickEvent(TraceEvent,GetMagickModule(),image->filename); 00847 return(image->blob->status); 00848 }

Here is the call graph for this function:

MagickExport FILE* GetBlobFileHandle const Image image  ) 
 

Definition at line 873 of file blob.c.

References assert, _Image::blob, _BlobInfo::file, MagickExport, MagickSignature, and _Image::signature.

00874 { 00875 assert(image != (const Image *) NULL); 00876 assert(image->signature == MagickSignature); 00877 return(image->blob->file); 00878 }

MagickExport void GetBlobInfo BlobInfo blob_info  ) 
 

Definition at line 903 of file blob.c.

References assert, DefaultBlobQuantum, IsEventLogging(), MagickExport, MagickSignature, ResetMagickMemory(), and UndefinedStream.

00904 { 00905 assert(blob_info != (BlobInfo *) NULL); 00906 (void) ResetMagickMemory(blob_info,0,sizeof(*blob_info)); 00907 blob_info->type=UndefinedStream; 00908 blob_info->quantum=DefaultBlobQuantum; 00909 blob_info->debug=IsEventLogging(); 00910 blob_info->reference_count=1; 00911 blob_info->signature=MagickSignature; 00912 }

Here is the call graph for this function:

MagickExport MagickSizeType GetBlobSize const Image image  ) 
 

Definition at line 941 of file blob.c.

References assert, _Image::blob, BlobStream, BZipStream, _Image::debug, FifoStream, _BlobInfo::file, _Image::filename, FileStream, GetMagickModule, _BlobInfo::length, LogMagickEvent(), MagickExport, MagickFalse, MagickSignature, MagickSizeType, PipeStream, _Image::signature, _BlobInfo::size, StandardStream, TraceEvent, _BlobInfo::type, UndefinedStream, and ZipStream.

Referenced by CloseBlob(), DescribeImage(), GetImageInfoAttribute(), jpeg_embed(), MagickGetImageSize(), OpenBlob(), PreviewImage(), ReadARTImage(), ReadAVIImage(), ReadAVSImage(), ReadBMPImage(), ReadCMYKImage(), ReadDCMImage(), ReadFITSImage(), ReadGRAYImage(), ReadICONImage(), ReadMETAImage(), ReadMIFFImage(), ReadMPCImage(), ReadMTVImage(), ReadPCXImage(), ReadPIXImage(), ReadPNMImage(), ReadPWPImage(), ReadRAWImage(), ReadRGBImage(), ReadRLEImage(), ReadSFWImage(), ReadSGIImage(), ReadSUNImage(), ReadTEXTImage(), ReadTGAImage(), ReadTIMImage(), ReadVIFFImage(), ReadYCBCRImage(), ReadYUVImage(), SizeBlob(), TranslateText(), WritePALMImage(), and XS().

00942 { 00943 MagickSizeType 00944 length; 00945 00946 struct stat 00947 attributes; 00948 00949 assert(image != (Image *) NULL); 00950 assert(image->signature == MagickSignature); 00951 if (image->debug != MagickFalse) 00952 (void) LogMagickEvent(TraceEvent,GetMagickModule(),image->filename); 00953 assert(image->blob != (BlobInfo *) NULL); 00954 length=0; 00955 switch (image->blob->type) 00956 { 00957 case UndefinedStream: 00958 { 00959 length=image->blob->size; 00960 break; 00961 } 00962 case FileStream: 00963 { 00964 length=(MagickSizeType) (fstat(fileno(image->blob->file), 00965 &attributes) < 0 ? 0 : attributes.st_size); 00966 break; 00967 } 00968 case StandardStream: 00969 case PipeStream: 00970 break; 00971 case ZipStream: 00972 { 00973 #if defined(HasZLIB) 00974 length=(MagickSizeType) (stat(image->filename,&attributes) < 0 ? 0 : 00975 attributes.st_size); 00976 #endif 00977 break; 00978 } 00979 case BZipStream: 00980 { 00981 #if defined(HasBZLIB) 00982 length=(MagickSizeType) (stat(image->filename,&attributes) < 0 ? 0 : 00983 attributes.st_size); 00984 #endif 00985 break; 00986 } 00987 case FifoStream: 00988 break; 00989 case BlobStream: 00990 { 00991 length=(MagickSizeType) image->blob->length; 00992 break; 00993 } 00994 } 00995 return(length); 00996 }

Here is the call graph for this function:

MagickExport unsigned char* GetBlobStreamData const Image image  ) 
 

Definition at line 1021 of file blob.c.

References assert, _Image::blob, _BlobInfo::data, MagickExport, MagickSignature, and _Image::signature.

01022 { 01023 assert(image != (const Image *) NULL); 01024 assert(image->signature == MagickSignature); 01025 return(image->blob->data); 01026 }

MagickExport StreamHandler GetBlobStreamHandler const Image image  ) 
 

Definition at line 1051 of file blob.c.

References assert, _Image::blob, _Image::debug, _Image::filename, GetMagickModule, LogMagickEvent(), MagickExport, MagickFalse, MagickSignature, _Image::signature, _BlobInfo::stream, StreamHandler, and TraceEvent.

Referenced by SetPixelStream(), and SyncPixelStream().

01052 { 01053 assert(image != (const Image *) NULL); 01054 assert(image->signature == MagickSignature); 01055 if (image->debug != MagickFalse) 01056 (void) LogMagickEvent(TraceEvent,GetMagickModule(),image->filename); 01057 return(image->blob->stream); 01058 }

Here is the call graph for this function:

MagickExport unsigned char* ImageToBlob const ImageInfo image_info,
Image image,
size_t *  length,
ExceptionInfo exception
 

Definition at line 1093 of file blob.c.

01095 { 01096 const MagickInfo 01097 *magick_info; 01098 01099 ImageInfo 01100 *blob_info; 01101 01102 MagickBooleanType 01103 status; 01104 01105 unsigned char 01106 *blob; 01107 01108 assert(image_info != (const ImageInfo *) NULL); 01109 assert(image_info->signature == MagickSignature); 01110 if (image_info->debug != MagickFalse) 01111 (void) LogMagickEvent(TraceEvent,GetMagickModule(),image_info->