#ifndef MAGICK_BYTE_BUFFER_PRIVATE_H
#define MAGICK_BYTE_BUFFER_PRIVATE_H
-typedef struct _ByteBuffer
+typedef struct _MagickByteBuffer
{
Image
*image;
unsigned char
data[8192];
-} ByteBuffer;
+} MagickByteBuffer;
-static int ReadByteBuffer(ByteBuffer *buffer)
+static inline int ReadMagickByteBuffer(MagickByteBuffer *buffer)
{
if ((buffer->offset == buffer->count) && (buffer->offset > 0))
{
return(buffer->data[buffer->offset++]);
}
-static char *GetByteBufferDatum(ByteBuffer *buffer)
+static inline char *GetMagickByteBufferDatum(MagickByteBuffer *buffer)
{
ssize_t
i;
- i=1; /* Skip first to avoid reload of buffer; */
+ i=1; /* Skip first to avoid reload of buffer */
while (buffer->offset < buffer->count)
buffer->data[i++]=buffer->data[buffer->offset++];
buffer->count=ReadBlob(buffer->image,sizeof(buffer->data)-i,buffer->data+i);
return((char *) buffer->data+1);
}
-static inline void CheckRemainingByteBuffer(ByteBuffer *buffer,size_t length)
+static void CheckMagickByteBuffer(MagickByteBuffer *buffer,
+ const size_t length)
{
if ((buffer->offset+length) > (ssize_t) sizeof(buffer->data))
- (void) GetByteBufferDatum(buffer);
+ (void) GetMagickByteBufferDatum(buffer);
}
-static inline void SkipByteBuffer(ByteBuffer *buffer,size_t length)
-{
- CheckRemainingByteBuffer(buffer,length);
- if ((buffer->offset+length) < buffer->count)
- buffer->offset+=length;
-}
-
-static MagickBooleanType CompareByteBuffer(const char *p,ByteBuffer *buffer,
- const size_t length)
+static MagickBooleanType CompareMagickByteBuffer(MagickByteBuffer *buffer,
+ const char *p,const size_t length)
{
const char
*q;
- CheckRemainingByteBuffer(buffer,length);
+ CheckMagickByteBuffer(buffer,length);
q=(const char *) buffer->data+buffer->offset;
if (LocaleNCompare(p,q,length) != 0)
return(MagickFalse);
return(MagickTrue);
}
-#endif
\ No newline at end of file
+static inline void SkipMagickByteBuffer(MagickByteBuffer *buffer,
+ const size_t length)
+{
+ CheckMagickByteBuffer(buffer,length);
+ if ((buffer->offset+length) < buffer->count)
+ buffer->offset+=length;
+}
+
+#endif
#include "MagickCore/transform.h"
#include "MagickCore/utility.h"
#include "MagickCore/module.h"
-#include "byte-buffer-private.h"
+#include "bytebuffer-private.h"
#include "ghostscript-private.h"
\f
/*
int
c;
- ByteBuffer
+ MagickByteBuffer
buffer;
register char
spotcolor=0;
(void) memset(&buffer,0,sizeof(buffer));
buffer.image=image;
- for (c=ReadByteBuffer(&buffer); c != EOF; c=ReadByteBuffer(&buffer))
+ for (c=ReadMagickByteBuffer(&buffer); c != EOF; c=ReadMagickByteBuffer(&buffer))
{
switch(c)
{
if (*version == '\0')
{
i=0;
- for (c=ReadByteBuffer(&buffer); c != EOF; c=ReadByteBuffer(&buffer))
+ for (c=ReadMagickByteBuffer(&buffer); c != EOF; c=ReadMagickByteBuffer(&buffer))
{
if ((c == '\r') || (c == '\n') || ((i+1) == MagickPathExtent))
break;
default:
continue;
}
- if (CompareByteBuffer(PDFRotate,&buffer,strlen(PDFRotate)) != MagickFalse)
+ if (CompareMagickByteBuffer(&buffer,PDFRotate,strlen(PDFRotate)) != MagickFalse)
{
- p=GetByteBufferDatum(&buffer);
+ p=GetMagickByteBufferDatum(&buffer);
(void) sscanf(p,PDFRotate" %lf",&pdf_info->angle);
}
if (pdf_info->cmyk == MagickFalse)
{
- if ((CompareByteBuffer(DefaultCMYK,&buffer,strlen(DefaultCMYK)) != MagickFalse) ||
- (CompareByteBuffer(DeviceCMYK,&buffer,strlen(DeviceCMYK)) != MagickFalse) ||
- (CompareByteBuffer(CMYKProcessColor,&buffer,strlen(CMYKProcessColor)) != MagickFalse))
+ if ((CompareMagickByteBuffer(&buffer,DefaultCMYK,strlen(DefaultCMYK)) != MagickFalse) ||
+ (CompareMagickByteBuffer(&buffer,DeviceCMYK,strlen(DeviceCMYK)) != MagickFalse) ||
+ (CompareMagickByteBuffer(&buffer,CMYKProcessColor,strlen(CMYKProcessColor)) != MagickFalse))
{
pdf_info->cmyk=MagickTrue;
continue;
}
}
- if (CompareByteBuffer(SpotColor,&buffer,strlen(SpotColor)) != MagickFalse)
+ if (CompareMagickByteBuffer(&buffer,SpotColor,strlen(SpotColor)) != MagickFalse)
{
char
name[MagickPathExtent],
(void) FormatLocaleString(property,MagickPathExtent,
"pdf:SpotColor-%.20g",(double) spotcolor++);
i=0;
- SkipByteBuffer(&buffer,strlen(SpotColor)+1);
- for (c=ReadByteBuffer(&buffer); c != EOF; c=ReadByteBuffer(&buffer))
+ SkipMagickByteBuffer(&buffer,strlen(SpotColor)+1);
+ for (c=ReadMagickByteBuffer(&buffer); c != EOF; c=ReadMagickByteBuffer(&buffer))
{
if ((isspace(c) != 0) || (c == '/') || ((i+1) == MagickPathExtent))
break;
count=0;
if (pdf_info->cropbox != MagickFalse)
{
- if (CompareByteBuffer(CropBox,&buffer,strlen(CropBox)) != MagickFalse)
+ if (CompareMagickByteBuffer(&buffer,CropBox,strlen(CropBox)) != MagickFalse)
{
/*
Note region defined by crop box.
*/
- p=GetByteBufferDatum(&buffer);
+ p=GetMagickByteBufferDatum(&buffer);
count=(ssize_t) sscanf(p,"CropBox [%lf %lf %lf %lf",&bounds.x1,
&bounds.y1,&bounds.x2,&bounds.y2);
if (count != 4)
else
if (pdf_info->trimbox != MagickFalse)
{
- if (CompareByteBuffer(TrimBox,&buffer,strlen(TrimBox)) != MagickFalse)
+ if (CompareMagickByteBuffer(&buffer,TrimBox,strlen(TrimBox)) != MagickFalse)
{
/*
Note region defined by trim box.
*/
- p=GetByteBufferDatum(&buffer);
+ p=GetMagickByteBufferDatum(&buffer);
count=(ssize_t) sscanf(p,"TrimBox [%lf %lf %lf %lf",&bounds.x1,
&bounds.y1,&bounds.x2,&bounds.y2);
if (count != 4)
}
}
else
- if (CompareByteBuffer(MediaBox,&buffer,strlen(MediaBox)) != MagickFalse)
+ if (CompareMagickByteBuffer(&buffer,MediaBox,strlen(MediaBox)) != MagickFalse)
{
/*
Note region defined by media box.
*/
- p=GetByteBufferDatum(&buffer);
+ p=GetMagickByteBufferDatum(&buffer);
count=(ssize_t) sscanf(p,"MediaBox [%lf %lf %lf %lf",&bounds.x1,
&bounds.y1,&bounds.x2,&bounds.y2);
if (count != 4)
#include "MagickCore/token.h"
#include "MagickCore/transform.h"
#include "MagickCore/utility.h"
-#include "byte-buffer-private.h"
+#include "bytebuffer-private.h"
#include "ghostscript-private.h"
\f
/*
%
*/
-static inline int ProfileInteger(ByteBuffer *buffer,short int *hex_digits)
+static inline int ProfileInteger(MagickByteBuffer *buffer,short int *hex_digits)
{
int
c,
value=0;
for (i=0; i < 2; )
{
- c=ReadByteBuffer(buffer);
+ c=ReadMagickByteBuffer(buffer);
if ((c == EOF) || ((c == '%') && (l == '%')))
{
value=(-1);
#define ICCProfile "BeginICCProfile:"
#define PhotoshopProfile "BeginPhotoshop:"
- ByteBuffer
+ MagickByteBuffer
buffer;
int
skip=MagickFalse;
(void) memset(&buffer,0,sizeof(buffer));
buffer.image=image;
- for (c=ReadByteBuffer(&buffer); c != EOF; c=ReadByteBuffer(&buffer))
+ for (c=ReadMagickByteBuffer(&buffer); c != EOF; c=ReadMagickByteBuffer(&buffer))
{
switch(c)
{
/*
Skip %%BeginDocument thru %%EndDocument.
*/
- if (CompareByteBuffer(BeginDocument,&buffer,strlen(BeginDocument)) != MagickFalse)
+ if (CompareMagickByteBuffer(&buffer,BeginDocument,strlen(BeginDocument)) != MagickFalse)
skip=MagickTrue;
- if (CompareByteBuffer(EndDocument,&buffer,strlen(EndDocument)) != MagickFalse)
+ if (CompareMagickByteBuffer(&buffer,EndDocument,strlen(EndDocument)) != MagickFalse)
skip=MagickFalse;
if (skip != MagickFalse)
continue;
- if (CompareByteBuffer(PostscriptLevel,&buffer,strlen(PostscriptLevel)) != MagickFalse)
+ if (CompareMagickByteBuffer(&buffer,PostscriptLevel,strlen(PostscriptLevel)) != MagickFalse)
{
- p=GetByteBufferDatum(&buffer)+4;
+ p=GetMagickByteBufferDatum(&buffer)+4;
(void) SetImageProperty(image,"ps:Level",p,exception);
}
- if (CompareByteBuffer(ImageData,&buffer,strlen(ImageData)) != MagickFalse)
+ if (CompareMagickByteBuffer(&buffer,ImageData,strlen(ImageData)) != MagickFalse)
{
- p=GetByteBufferDatum(&buffer);
+ p=GetMagickByteBufferDatum(&buffer);
(void) sscanf(p,ImageData " %lu %lu",&ps_info->columns,&ps_info->rows);
}
/*
Is this a CMYK document?
*/
length=strlen(DocumentProcessColors);
- if (CompareByteBuffer(DocumentProcessColors,&buffer,length) != MagickFalse)
+ if (CompareMagickByteBuffer(&buffer,DocumentProcessColors,length) != MagickFalse)
{
- p=GetByteBufferDatum(&buffer);
+ p=GetMagickByteBufferDatum(&buffer);
if ((GlobExpression(p,"*Cyan*",MagickTrue) != MagickFalse) ||
(GlobExpression(p,"*Magenta*",MagickTrue) != MagickFalse) ||
(GlobExpression(p,"*Yellow*",MagickTrue) != MagickFalse))
ps_info->cmyk=MagickTrue;
}
- if (CompareByteBuffer(CMYKCustomColor,&buffer,strlen(CMYKCustomColor)) != MagickFalse)
+ if (CompareMagickByteBuffer(&buffer,CMYKCustomColor,strlen(CMYKCustomColor)) != MagickFalse)
ps_info->cmyk=MagickTrue;
- if (CompareByteBuffer(CMYKProcessColor,&buffer,strlen(CMYKProcessColor)) != MagickFalse)
+ if (CompareMagickByteBuffer(&buffer,CMYKProcessColor,strlen(CMYKProcessColor)) != MagickFalse)
ps_info->cmyk=MagickTrue;
length=strlen(DocumentCustomColors);
- if ((CompareByteBuffer(DocumentCustomColors,&buffer,length) != MagickFalse) ||
- (CompareByteBuffer(CMYKCustomColor,&buffer,strlen(CMYKCustomColor)) != MagickFalse) ||
- (CompareByteBuffer(SpotColor,&buffer,strlen(SpotColor)) != MagickFalse))
+ if ((CompareMagickByteBuffer(&buffer,DocumentCustomColors,length) != MagickFalse) ||
+ (CompareMagickByteBuffer(&buffer,CMYKCustomColor,strlen(CMYKCustomColor)) != MagickFalse) ||
+ (CompareMagickByteBuffer(&buffer,SpotColor,strlen(SpotColor)) != MagickFalse))
{
char
name[MagickPathExtent],
(void) FormatLocaleString(property,MagickPathExtent,
"pdf:SpotColor-%.20g",(double) spotcolor++);
i=0;
- for (c=ReadByteBuffer(&buffer); c != EOF; c=ReadByteBuffer(&buffer))
+ for (c=ReadMagickByteBuffer(&buffer); c != EOF; c=ReadMagickByteBuffer(&buffer))
{
if ((isspace(c) != 0) || ((i+1) == MagickPathExtent))
break;
continue;
}
if ((ps_info->icc_profile == (StringInfo *) NULL) &&
- (CompareByteBuffer(ICCProfile,&buffer,strlen(ICCProfile)) != MagickFalse))
+ (CompareMagickByteBuffer(&buffer,ICCProfile,strlen(ICCProfile)) != MagickFalse))
{
unsigned char
*datum;
continue;
}
if ((ps_info->photoshop_profile == (StringInfo *) NULL) &&
- (CompareByteBuffer(PhotoshopProfile,&buffer,strlen(PhotoshopProfile)) != MagickFalse))
+ (CompareMagickByteBuffer(&buffer,PhotoshopProfile,strlen(PhotoshopProfile)) != MagickFalse))
{
unsigned char
*q;
/*
Read Photoshop profile.
*/
- p=GetByteBufferDatum(&buffer);
+ p=GetMagickByteBufferDatum(&buffer);
count=(ssize_t) sscanf(p,PhotoshopProfile " %lu",&extent);
if (count != 1)
continue;
*/
count=0;
i=0;
- if (CompareByteBuffer(BoundingBox,&buffer,strlen(BoundingBox)) != MagickFalse)
+ if (CompareMagickByteBuffer(&buffer,BoundingBox,strlen(BoundingBox)) != MagickFalse)
{
- p=GetByteBufferDatum(&buffer);
+ p=GetMagickByteBufferDatum(&buffer);
count=(ssize_t) sscanf(p,BoundingBox " %lf %lf %lf %lf",
&bounds.x1,&bounds.y1,&bounds.x2,&bounds.y2);
i=2;
}
- if (CompareByteBuffer(DocumentMedia,&buffer,strlen(DocumentMedia)) != MagickFalse)
+ if (CompareMagickByteBuffer(&buffer,DocumentMedia,strlen(DocumentMedia)) != MagickFalse)
{
- p=GetByteBufferDatum(&buffer);
+ p=GetMagickByteBufferDatum(&buffer);
count=(ssize_t) sscanf(p,DocumentMedia " %lf %lf %lf %lf",
&bounds.x1,&bounds.y1,&bounds.x2,&bounds.y2);
i=1;
}
- if (CompareByteBuffer(HiResBoundingBox,&buffer,strlen(HiResBoundingBox)) != MagickFalse)
+ if (CompareMagickByteBuffer(&buffer,HiResBoundingBox,strlen(HiResBoundingBox)) != MagickFalse)
{
- p=GetByteBufferDatum(&buffer);
+ p=GetMagickByteBufferDatum(&buffer);
count=(ssize_t) sscanf(p,HiResBoundingBox " %lf %lf %lf %lf",
&bounds.x1,&bounds.y1,&bounds.x2,&bounds.y2);
i=3;
}
- if (CompareByteBuffer(PageBoundingBox,&buffer,strlen(PageBoundingBox)) != MagickFalse)
+ if (CompareMagickByteBuffer(&buffer,PageBoundingBox,strlen(PageBoundingBox)) != MagickFalse)
{
- p=GetByteBufferDatum(&buffer);
+ p=GetMagickByteBufferDatum(&buffer);
count=(ssize_t) sscanf(p,PageBoundingBox " %lf %lf %lf %lf",
&bounds.x1,&bounds.y1,&bounds.x2,&bounds.y2);
i=1;
}
- if (CompareByteBuffer(PageMedia,&buffer,strlen(PageMedia)) == 0)
+ if (CompareMagickByteBuffer(&buffer,PageMedia,strlen(PageMedia)) == 0)
{
- p=GetByteBufferDatum(&buffer);
+ p=GetMagickByteBufferDatum(&buffer);
count=(ssize_t) sscanf(p,PageMedia " %lf %lf %lf %lf",
&bounds.x1,&bounds.y1,&bounds.x2,&bounds.y2);
i=1;
count=write(file,translate_geometry,(unsigned int)
strlen(translate_geometry));
}
+ (void) count;
file=close(file)-1;
/*
Render Postscript with the Ghostscript delegate.