This source file includes following definitions.
- ArcMethod
- BitsMethod
- LineMethod
- OvalMethod
- PolyMethod
- RectMethod
- RegionMethod
- RRectMethod
- StandardPixmap
- TextMethod
- BottleneckTest
- closedir
- Exit
- FilenameToFSSpec
- HGetVInfo
- MACIsMagickConflict
- MACErrorHandler
- MACFatalErrorHandler
- MacGSExecuteCommand
- MacGSLaunchApplicationCore
- MacGSLaunchApplication
- MacGSLaunchApplicationToFront
- MacGSQuitApplication
- MacGSSetWorkingFolder
- MACSetErrorHook
- MACSetEventHook
- MACSystemCommand
- MACWarningHandler
- opendir
- ProcessPendingEvents
- readdir
- MagickMax
- ReadPICTImage
- SearchForFile
- seekdir
- MagickMin
- SetApplicationType
- telldir
#if defined(macintosh)
#define _X_H
#define _WIDGET_H
#include <AppleEvents.h>
#include <AERegistry.h>
#include <AEObjects.h>
#include <AEPackObject.h>
#include <Processes.h>
#include <QuickDraw.h>
#include <QDOffscreen.h>
#include <Palettes.h>
#include <ImageCompression.h>
#include <PictUtils.h>
#include <Files.h>
#include <Gestalt.h>
#include <TextUtils.h>
#define ColorInfo KolorInfo
#include "magick/studio.h"
#include "magick/blob.h"
#include "magick/client.h"
#include "magick/exception.h"
#include "magick/exception-private.h"
#include "magick/image-private.h"
#include "magick/list.h"
#include "magick/magick.h"
#include "magick/monitor.h"
#include "magick/monitor-private.h"
#include "magick/pixel-accessor.h"
#include "magick/quantum.h"
#include "magick/string_.h"
#include "magick/utility.h"
#include "magick/mac.h"
ImageDescriptionHandle
image_description = nil;
static Boolean
SearchForFile(OSType,OSType,FSSpec *,short);
static pascal void
ArcMethod(GrafVerb,Rect *,short,short),
BitsMethod(BitMap *,Rect *,Rect *,short,RgnHandle),
FilenameToFSSpec(const char *filename,FSSpec *fsspec),
LineMethod(Point),
OvalMethod(GrafVerb,Rect *),
PolyMethod(GrafVerb,PolyHandle),
RRectMethod(GrafVerb,Rect *,short,short),
RectMethod(GrafVerb,Rect *),
RegionMethod(GrafVerb,RgnHandle),
StandardPixmap(PixMapPtr,Rect *,MatrixRecordPtr,short,RgnHandle,PixMapPtr,
Rect *,short),
TextMethod(short,Ptr,Point,Point);
#if defined(DISABLE_SIOUX)
static MACEventHookPtr
event_hook = nil;
static MACErrorHookPtr
exception.hook = nil;
#endif
static pascal void ArcMethod(GrafVerb verb,Rect *r,short startAngle,
short arcAngle)
{
#pragma unused (verb,r,startAngle,arcAngle)
}
static pascal void BitsMethod(BitMap *bitPtr,Rect *source_rectangle,
Rect *dstRect,short mode,RgnHandle maskRgn)
{
#pragma unused (bitPtr,source_rectangle,dstRect,mode,maskRgn)
}
static pascal void LineMethod(Point newPt)
{
#pragma unused (newPt)
}
static pascal void OvalMethod(GrafVerb verb,Rect *r)
{
#pragma unused (verb,r)
}
static pascal void PolyMethod(GrafVerb verb,PolyHandle poly)
{
#pragma unused (verb,poly)
}
static pascal void RectMethod(GrafVerb verb,Rect *r)
{
#pragma unused (verb,r)
}
static pascal void RegionMethod(GrafVerb verb,RgnHandle rgn)
{
#pragma unused (verb,rgn)
}
static pascal void RRectMethod(GrafVerb verb,Rect *r,short ovalWidth,
short ovalHeight)
{
#pragma unused (verb,r,ovalWidth,ovalHeight)
}
static pascal void StandardPixmap(PixMapPtr source,Rect *source_rectangle,
MatrixRecordPtr matrix,short mode,RgnHandle mask,PixMapPtr matte,
Rect *matte_rectangle,short flags)
{
#pragma unused (source_rectangle,matrix,mode,mask,matte,matte_rectangle,flags)
Ptr
data;
ssize_t
size;
GetCompressedPixMapInfo(source,&image_description,&data,&size,nil,nil);
}
static pascal void TextMethod(short byteCount,Ptr textBuf,Point numer,
Point denom)
{
#pragma unused (byteCount,textBuf,numer,denom)
}
#if !defined(DISABLE_QUICKTIME)
static short BottleneckTest(PicHandle picture,CodecType *codec,int *depth,
short *colormap_id)
{
CQDProcs
bottlenecks;
int
status;
Rect
rectangle;
ssize_t
version;
status=Gestalt(gestaltQuickTime,&version);
if (status != noErr)
{
ParamText("\pQuickTime not installed. Please install, then try again.",
"\p","\p","\p");
Alert(128,nil);
return(-1);
}
SetStdCProcs(&bottlenecks);
bottlenecks.textProc=NewQDTextUPP(&TextMethod);
bottlenecks.lineProc=NewQDLineUPP(&LineMethod);
bottlenecks.rectProc=NewQDRectUPP(&RectMethod);
bottlenecks.rRectProc=NewQDRRectUPP(&RRectMethod);
bottlenecks.ovalProc=NewQDOvalUPP(&OvalMethod);
bottlenecks.arcProc=NewQDArcUPP(&ArcMethod);
bottlenecks.polyProc=NewQDPolyUPP(&PolyMethod);
bottlenecks.rgnProc=NewQDRgnUPP(&RegionMethod);
bottlenecks.bitsProc=NewQDBitsUPP(&BitsMethod);
bottlenecks.newProc1=(UniversalProcPtr) NewStdPixUPP(&StandardPixmap);
(*(qd.thePort)).grafProcs=(QDProcs *) &bottlenecks;
DrawPicture(picture,&((**picture).picFrame));
PaintRect(&rectangle);
(*(qd.thePort)).grafProcs=0L;
*codec='unkn';
*depth=0;
*colormap_id=(-1);
if (image_description != nil)
{
*codec=(**image_description).cType;
*depth=(**image_description).depth;
*colormap_id=(**image_description).clutID;
}
DisposeQDTextUPP(bottlenecks.textProc);
DisposeQDLineUPP(bottlenecks.lineProc);
DisposeQDRectUPP(bottlenecks.rectProc);
DisposeQDRRectUPP(bottlenecks.rRectProc);
DisposeQDOvalUPP(bottlenecks.ovalProc);
DisposeQDArcUPP(bottlenecks.arcProc);
DisposeQDPolyUPP(bottlenecks.polyProc);
DisposeQDRgnUPP(bottlenecks.rgnProc);
DisposeQDBitsUPP(bottlenecks.bitsProc);
DisposeStdPixUPP(bottlenecks.newProc1);
return(0);
}
#endif
#if !defined(_MAGICKCORE_POSIX_SUPPORT_VERSION)
MagickExport void closedir(DIR *entry)
{
if (image->debug != MagickFalse)
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
assert(entry != (DIR *) NULL);
RelinquishMagickMemory(entry);
}
#endif
MagickExport int Exit(int status)
{
#if !defined(DISABLE_SIOUX)
(void) FormatLocaleFile(stdout,"Select File->Quit to exit.\n");
#endif
exit(status);
return(0);
}
MagickExport void pascal FilenameToFSSpec(const char *filename,FSSpec *fsspec)
{
Str255
name;
assert(filename != (char *) NULL);
c2pstrcpy(name,filename);
FSMakeFSSpec(0,0,name,fsspec);
}
static OSErr HGetVInfo(short volume_index,StringPtr volume_name,short *volume,
size_t *free_bytes,size_t *total_bytes)
{
HParamBlockRec
pb;
OSErr
result;
size_t
blocksize;
unsigned short
allocation_blocks,
free_blocks;
pb.volumeParam.ioVRefNum=0;
pb.volumeParam.ioNamePtr=volume_name;
pb.volumeParam.ioVolIndex=volume_index;
result=PBHGetVInfoSync(&pb);
if (result != noErr)
return(result);
*volume=pb.volumeParam.ioVRefNum;
blocksize=(size_t) pb.volumeParam.ioVAlBlkSiz;
allocation_blocks=(unsigned short) pb.volumeParam.ioVNmAlBlks;
free_blocks=(unsigned short) pb.volumeParam.ioVFrBlk;
*free_bytes=free_blocks*blocksize;
*total_bytes=allocation_blocks*blocksize;
return(result);
}
MagickExport MagickBooleanType MACIsMagickConflict(const char *magick)
{
size_t
free_bytes,
number_bytes;
OSErr
status;
short
volume;
Str255
volume_name;
assert(magick != (char *) NULL);
if (image->debug != MagickFalse)
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",magick);
(void) CopyMagickString((char *) volume_name,magick,MaxTextExtent);
c2pstr((char *) volume_name);
if (volume_name[volume_name[0]] != ':')
volume_name[++volume_name[0]]=':';
status=HGetVInfo(-1,volume_name,&volume,&free_bytes,&number_bytes);
return(status != 0 ? MagickFalse : MagickTrue);
}
MagickExport void MACErrorHandler(const ExceptionType error,const char *reason,
const char *description)
{
char
buffer[3*MaxTextExtent];
if (reason == (char *) NULL)
return;
if (description == (char *) NULL)
(void) FormatLocaleString(buffer,MaxTextExtent,"%s: %s.\n",GetClientName(),
reason);
else
(void) FormatLocaleString(buffer,MaxTextExtent,"%s: %s (%s).\n",
GetClientName(),reason,description);
#if defined(DISABLE_SIOUX)
if(exception.hook != (MACErrorHookPtr) NULL)
exception.hook(error,buffer);
else
{
MagickCoreTerminus();
exit(error);
}
#else
puts(buffer);
MagickCoreTerminus();
exit(error);
#endif
}
#if defined(DISABLE_SIOUX)
static void MACFatalErrorHandler(const ExceptionType severity,
const char *reason,const char *description)
{
char
buffer[3*MaxTextExtent];
if (reason == (char *) NULL)
return;
if (description == (char *) NULL)
(void) FormatLocaleString(buffer,MaxTextExtent,"%s: %s.\n",GetClientName(),
reason);
else
(void) FormatLocaleString(buffer,MaxTextExtent,"%s: %s (%s).\n",
GetClientName(),reason,description);
if(exception.hook != (MACErrorHookPtr) NULL)
exception.hook(severity, buffer);
else
{
MagickCoreTerminus();
exit(severity);
}
}
#endif
static OSErr MacGSExecuteCommand(const char *command,ssize_t length)
{
AEAddressDesc
event_descriptor;
AEDesc
reply = {typeNull, NULL};
AppleEvent
event = {typeNull, NULL};
DescType
descriptor_type;
int
error;
OSType
id = 'gsVR';
Size
actualSize;
(void) AECreateDesc(typeApplSignature,&id,sizeof(id),&event_descriptor);
(void) AECreateAppleEvent(id,'exec',&event_descriptor,-1,kAnyTransactionID,
&event);
(void) AEPutParamPtr(&event,keyDirectObject,typeChar,command,length);
(void) AESend(&event,&reply,kAEWaitReply+kAENeverInteract,kAENormalPriority,
kNoTimeOut,NULL,NULL);
(void) AEGetParamPtr(&reply,keyDirectObject,typeInteger,&descriptor_type,
&error,sizeof(error),&actualSize);
(void) AEDisposeDesc(&event_descriptor);
(void) AEDisposeDesc(&event);
if (reply.descriptorType != NULL)
AEDisposeDesc(&reply);
return((OSErr) error);
}
static OSErr MacGSLaunchApplicationCore(ssize_t flags)
{
FSSpec
file_info;
LaunchParamBlockRec
launch_info;
OSErr
error;
if (!SearchForFile('gsVR','APPL',&file_info,1))
return(-43);
launch_info.launchBlockID=extendedBlock;
launch_info.launchEPBLength=extendedBlockLen;
launch_info.launchFileFlags=0;
launch_info.launchControlFlags=launchContinue+launchNoFileFlags+flags;
launch_info.launchAppSpec=(&file_info);
launch_info.launchAppParameters=nil;
error=LaunchApplication(&launch_info);
return(error);
}
static OSErr MacGSLaunchApplication(void)
{
return(MacGSLaunchApplicationCore(launchDontSwitch));
}
static OSErr MacGSLaunchApplicationToFront(void)
{
return(MacGSLaunchApplicationCore(0));
}
static void MacGSQuitApplication(void)
{
AEAddressDesc
event_descriptor;
AEDesc
reply = {typeNull, NULL};
AppleEvent
event = {typeNull, NULL};
OSType
id = 'GPLT';
(void) AECreateDesc(typeApplSignature,&id,sizeof(id),&event_descriptor);
(void) AECreateAppleEvent(typeAppleEvent,kAEQuitApplication,
&event_descriptor,-1,kAnyTransactionID,&event);
(void) AESend(&event,&reply,kAENoReply,kAENormalPriority,kNoTimeOut,NULL,
NULL);
(void) AEDisposeDesc(&event_descriptor);
(void) AEDisposeDesc(&event);
if (reply.descriptorType != NULL)
AEDisposeDesc(&reply);
}
static OSErr MacGSSetWorkingFolder(char *directory)
{
AEDesc
application_descriptor,
event_descriptor,
object,
path_descriptor,
type_descriptor,
reply;
AppleEvent
event;
DescType
folder_type = 'wfdr';
OSErr
error;
OSType
id = 'GPLT';
AECreateDesc(typeNull,NULL,0,&application_descriptor);
AECreateDesc(typeChar,directory,strlen(directory),&path_descriptor);
(void) AECreateDesc(typeType,&folder_type,sizeof(DescType),&type_descriptor);
CreateObjSpecifier(cProperty,&application_descriptor,formPropertyID,
&type_descriptor,0,&object);
(void) AECreateDesc(typeApplSignature,&id,sizeof(id),&event_descriptor);
(void) AECreateAppleEvent(kAECoreSuite,kAESetData,&event_descriptor,-1,
kAnyTransactionID,&event);
(void) AEPutParamDesc(&event,keyDirectObject,&object);
(void) AEPutParamDesc(&event,keyAEData,&path_descriptor);
error=AESend(&event,&reply,kAENoReply+kAENeverInteract,kAENormalPriority,
kNoTimeOut,NULL,NULL);
(void) AEDisposeDesc(&event);
(void) AEDisposeDesc(&event_descriptor);
(void) AEDisposeDesc(&object);
(void) AEDisposeDesc(&type_descriptor);
(void) AEDisposeDesc(&path_descriptor);
(void) AEDisposeDesc(&application_descriptor);
return(error);
}
MagickExport void MACSetErrorHook(MACErrorHookPtr hook)
{
exception.hook=hook;
}
MagickExport void MACSetEventHook(MACEventHookPtr hook)
{
event_hook=hook;
}
MagickExport int MACSystemCommand(const char * command)
{
if (MacGSLaunchApplicationToFront())
return(-1);
return(MacGSExecuteCommand(command,strlen(command)));
}
MagickExport void MACWarningHandler(const ExceptionType warning,
const char *reason,const char *description)
{
char
buffer[1664];
if (reason == (char *) NULL)
return;
if (description == (char *) NULL)
(void) FormatLocaleString(buffer,MaxTextExtent,"%s: %s.\n",GetClientName(),
reason);
else
(void) FormatLocaleString(buffer,MaxTextExtent,"%s: %s (%s).\n",
GetClientName(),reason,description);
#if defined(DISABLE_SIOUX)
if(exception.hook != (MACErrorHookPtr) NULL)
exception.hook(warning, buffer);
#else
(void)warning;
puts(buffer);
#endif
}
#if !defined(_MAGICKCORE_POSIX_SUPPORT_VERSION)
MagickExport DIR *opendir(const char *path)
{
Str255 pathname;
CInfoPBRec
search_info;
DIR
*entry;
int
error;
search_info.hFileInfo.ioNamePtr=0;
if ((path != (char *) NULL) || (*path != '\0'))
if ((path[0] != '.') || (path[1] != '\0'))
{
c2pstrcpy(pathname,path);
search_info.hFileInfo.ioNamePtr=pathname;
}
search_info.hFileInfo.ioCompletion=0;
search_info.hFileInfo.ioVRefNum=0;
search_info.hFileInfo.ioFDirIndex=0;
search_info.hFileInfo.ioDirID=0;
error=PBGetCatInfoSync(&search_info);
if (error != noErr)
{
errno=error;
return((DIR *) NULL);
}
entry=(DIR *) AcquireMagickMemory(sizeof(DIR));
if (entry == (DIR *) NULL)
return((DIR *) NULL);
entry->d_VRefNum=search_info.hFileInfo.ioVRefNum;
entry->d_DirID=search_info.hFileInfo.ioDirID;
entry->d_index=1;
return(entry);
}
#endif
MagickExport void ProcessPendingEvents(const char *text)
{
#if defined(DISABLE_SIOUX)
if (event_hook != (MACEventHookPtr) NULL)
event_hook(text);
#else
static const char
*mark = (char *) NULL;
EventRecord
event;
while (WaitNextEvent(everyEvent,&event,0L,nil))
SIOUXHandleOneEvent(&event);
if (isatty(STDIN_FILENO) && (text != mark))
{
(void) puts(text);
mark=text;
}
#endif
}
#if !defined(_MAGICKCORE_POSIX_SUPPORT_VERSION)
MagickExport struct dirent *readdir(DIR *entry)
{
CInfoPBRec
search_info;
int
error;
static struct dirent
dir_entry;
static unsigned char
pathname[MaxTextExtent];
if (entry == (DIR *) NULL)
return((struct dirent *) NULL);
search_info.hFileInfo.ioCompletion=0;
search_info.hFileInfo.ioNamePtr=pathname;
search_info.hFileInfo.ioVRefNum=0;
search_info.hFileInfo.ioFDirIndex=entry->d_index;
search_info.hFileInfo.ioDirID=entry->d_DirID;
error=PBGetCatInfoSync(&search_info);
if (error != noErr)
{
errno=error;
return((struct dirent *) NULL);
}
entry->d_index++;
p2cstrcpy(dir_entry.d_name,search_info.hFileInfo.ioNamePtr);
dir_entry.d_namlen=strlen(dir_entry.d_name);
return(&dir_entry);
}
#endif
static inline size_t MagickMax(const size_t x,const size_t y)
{
if (x > y)
return(x);
return(y);
}
MagickExport Image *ReadPICTImage(const ImageInfo *image_info,
ExceptionInfo *exception)
{
#define PICTHeaderSize 512
CodecType
codec;
GDHandle
device;
GWorldPtr
graphic_world,
port;
Image
*image;
int
depth,
status;
MagickBooleanType
proceed,
status;
PicHandle
picture_handle;
PictInfo
picture_info;
QDErr
theErr = noErr;
Rect
rectangle;
RGBColor
Pixel;
short
colormap_id;
ssize_t
y;
image=AcquireImage(image_info);
status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
if (status == MagickFalse)
return(NULL);
picture_handle=(PicHandle) NewHandle(MagickMax(GetBlobSize(image)-
PICTHeaderSize,PICTHeaderSize));
if (picture_handle == nil)
ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
HLock((Handle) picture_handle);
(void) ReadBlob(image,PICTHeaderSize,*(unsigned char **) picture_handle);
status=ReadBlob(image,GetBlobSize(image)-PICTHeaderSize,*(unsigned char **)
picture_handle);
if (status == MagickFalse)
{
DisposeHandle((Handle) picture_handle);
ThrowReaderException(CorruptImageError,"UnableToReadImageData");
}
GetGWorld(&port,&device);
theErr=NewGWorld(&graphic_world,0,&(**picture_handle).picFrame,nil,nil,
useTempMem | keepLocal);
if ((theErr != noErr) && (graphic_world == nil))
{
DisposeHandle((Handle) picture_handle);
ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
}
HUnlock((Handle) picture_handle);
SetGWorld(graphic_world,nil);
theErr=GetPictInfo(picture_handle,&picture_info,0,1,systemMethod,0);
if (theErr != noErr)
{
DisposeGWorld(graphic_world);
DisposeHandle((Handle) picture_handle);
ThrowReaderException(CorruptImageError,"UnableToReadImageData");
}
#if defined(DISABLE_QUICKTIME)
codec='unkn';
colormap_id=(-1);
depth=picture_info.depth;
#else
BottleneckTest(picture_handle,&codec,&depth,&colormap_id);
#endif
switch (codec)
{
case 'rpza':
case 'jpeg':
case 'rle ':
case 'raw ':
case 'smc ':
{
if (depth > 200)
{
depth-=32;
picture_info.theColorTable=GetCTable(colormap_id);
}
break;
}
default:
{
depth=picture_info.depth;
if (depth <= 8)
(void) GetPictInfo(picture_handle,&picture_info,returnColorTable,
(short) (1 << picture_info.depth),systemMethod,0);
break;
}
}
image->x_resolution=(picture_info.hRes) >> 16;
image->y_resolution=(picture_info.vRes) >> 16;
image->units=PixelsPerInchResolution;
image->columns=picture_info.sourceRect.right-picture_info.sourceRect.left;
image->rows=picture_info.sourceRect.bottom-picture_info.sourceRect.top;
if ((depth <= 8) && ((*(picture_info.theColorTable))->ctSize != 0))
{
size_t
number_colors;
number_colors=(*(picture_info.theColorTable))->ctSize;
if (!AcquireImageColormap(image,number_colors))
{
if (picture_info.theColorTable != nil)
DisposeHandle((Handle) picture_info.theColorTable);
DisposeGWorld(graphic_world);
DisposeHandle((Handle) picture_handle);
ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
}
for (x=0; x < image->colors; x++)
{
image->colormap[x].red=
(*(picture_info.theColorTable))->ctTable[x].rgb.red;
image->colormap[x].green=
(*(picture_info.theColorTable))->ctTable[x].rgb.green;
image->colormap[x].blue=
(*(picture_info.theColorTable))->ctTable[x].rgb.blue;
}
}
SetRect(&rectangle,0,0,image->columns,image->rows);
(void) UpdateGWorld(&graphic_world,depth,&rectangle,
picture_info.theColorTable,nil,0);
LockPixels(GetGWorldPixMap(graphic_world));
EraseRect(&rectangle);
DrawPicture(picture_handle,&rectangle);
if ((depth <= 8) && (colormap_id == -1))
{
DisposeHandle((Handle) picture_info.theColorTable);
picture_info.theColorTable=nil;
}
DisposeHandle((Handle) picture_handle);
for (y=0; y < image->rows; y++)
{
register IndexPacket
*restrict indexes;
register ssize_t
x;
register PixelPacket
*restrict q;
q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
if (q == (PixelPacket *) NULL)
break;
indexes=GetAuthenticIndexQueue(image);
for (x=0; x < image->columns; x++)
{
GetCPixel(x,y,&Pixel);
SetPixelRed(q,ScaleCharToQuantum(Pixel.red & 0xff));
SetPixelGreen(q,ScaleCharToQuantum(Pixel.green & 0xff));
SetPixelBlue(q,ScaleCharToQuantum(Pixel.blue & 0xff));
if (image->storage_class == PseudoClass)
SetPixelIndex(indexes+x,Color2Index(&Pixel));
q++;
}
if (SyncAuthenticPixels(image,exception) == MagickFalse)
break;
proceed=SetImageProgress(image,LoadImageTag,y,image->rows);
if (proceed == MagickFalse)
break;
}
UnlockPixels(GetGWorldPixMap(graphic_world));
SetGWorld(port,device);
if (picture_info.theColorTable != nil)
DisposeHandle((Handle) picture_info.theColorTable);
DisposeGWorld(graphic_world);
(void) CloseBlob(image);
return(image);
}
static Boolean SearchForFile(OSType creator_type,OSType file_type,FSSpec *file,
short count)
{
char
*buffer;
CInfoPBRec
search1_info,
search2_info;
FSSpec
application;
HParamBlockRec
parameter_info;
OSErr
error;
ProcessInfoRec
application_info;
ProcessSerialNumber
serial_number;
ssize_t
buffer_size = 16384;
serial_number.lowLongOfPSN=kCurrentProcess;
serial_number.highLongOfPSN=0;
application_info.processInfoLength=sizeof(ProcessInfoRec);
application_info.processName=NULL;
application_info.processAppSpec=(&application);
GetProcessInformation(&serial_number,&application_info);
buffer=NewPtr(buffer_size);
if (buffer == (char *) NULL)
return(false);
parameter_info.csParam.ioCompletion=NULL;
parameter_info.csParam.ioNamePtr=NULL;
parameter_info.csParam.ioVRefNum=application.vRefNum;
parameter_info.csParam.ioMatchPtr=file;
parameter_info.csParam.ioReqMatchCount=count;
parameter_info.csParam.ioSearchBits=fsSBFlFndrInfo;
parameter_info.csParam.ioSearchInfo1=&search1_info;
parameter_info.csParam.ioSearchInfo2=&search2_info;
parameter_info.csParam.ioSearchTime=0;
parameter_info.csParam.ioCatPosition.initialize=0;
parameter_info.csParam.ioOptBuffer=buffer;
parameter_info.csParam.ioOptBufSize=buffer_size;
search1_info.hFileInfo.ioNamePtr=NULL;
search1_info.hFileInfo.ioFlFndrInfo.fdType=file_type;
search1_info.hFileInfo.ioFlFndrInfo.fdCreator=creator_type;
search1_info.hFileInfo.ioFlAttrib=0;
search1_info.hFileInfo.ioFlParID=0;
search2_info=search1_info;
search2_info.hFileInfo.ioFlAttrib=0x10;
search2_info.hFileInfo.ioFlFndrInfo.fdCreator=creator_type;
search2_info.hFileInfo.ioFlFndrInfo.fdType=(-1);
search2_info.hFileInfo.ioFlFndrInfo.fdFlags=0;
search2_info.hFileInfo.ioFlFndrInfo.fdLocation.h=0;
search2_info.hFileInfo.ioFlFndrInfo.fdLocation.v=0;
search2_info.hFileInfo.ioFlFndrInfo.fdFldr=0;
search2_info.hFileInfo.ioFlParID=0;
error=PBCatSearchSync((CSParamPtr) ¶meter_info);
DisposePtr(buffer);
if (parameter_info.csParam.ioReqMatchCount ==
parameter_info.csParam.ioActMatchCount)
error=eofErr;
if (parameter_info.csParam.ioActMatchCount == 0)
error=0;
return(error == eofErr);
}
#if !defined(_MAGICKCORE_POSIX_SUPPORT_VERSION)
MagickExport void seekdir(DIR *entry,ssize_t position)
{
assert(entry != (DIR *) NULL);
entry->d_index=position;
}
#endif
static inline size_t MagickMin(const size_t x,const size_t y)
{
if (x < y)
return(x);
return(y);
}
MagickExport void SetApplicationType(const char *filename,const char *magick,
OSType application)
{
FSSpec
file_specification;
OSType
filetype;
Str255
name;
assert(filename != (char *) NULL);
if (image->debug != MagickFalse)
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",filename);
assert(magick != (const char *) NULL);
filetype=' ';
(void) CopyMagickString((char *) &filetype,magick,MagickMin(strlen(magick),
4));
if (LocaleCompare(magick,"JPG") == 0)
(void) CopyMagickString((char *) &filetype,"JPEG",MaxTextExtent);
c2pstrcpy(name,filename);
FSMakeFSSpec(0,0,name,&file_specification);
FSpCreate(&file_specification,application,filetype,smSystemScript);
}
#if !defined(_MAGICKCORE_POSIX_SUPPORT_VERSION)
MagickExport ssize_t telldir(DIR *entry)
{
return(entry->d_index);
}
#endif
#endif