本文整理汇总了C++中AddValueToSplayTree函数的典型用法代码示例。如果您正苦于以下问题:C++ AddValueToSplayTree函数的具体用法?C++ AddValueToSplayTree怎么用?C++ AddValueToSplayTree使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了AddValueToSplayTree函数的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: assert
//.........这里部分代码省略.........
if (*p++ == '"')
{
if (active != MagickFalse)
*q++='\n';
active=active != MagickFalse ? MagickFalse : MagickTrue;
}
if (active != MagickFalse)
*q++=(*p);
}
*q='\0';
/*
Initialize image structure.
*/
xpm_colors=NewSplayTree(CompareXPMColor,RelinquishMagickMemory,
(void *(*)(void *)) NULL);
if (AcquireImageColormap(image,image->colors) == MagickFalse)
{
xpm_buffer=DestroyString(xpm_buffer);
ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
}
/*
Read image colormap.
*/
image->depth=1;
next=NextXPMLine(xpm_buffer);
for (j=0; (j < (ssize_t) image->colors) && (next != (char *) NULL); j++)
{
MagickPixelPacket
pixel;
p=next;
next=NextXPMLine(p);
(void) CopyXPMColor(key,p,MagickMin((size_t) width,MaxTextExtent-1));
status=AddValueToSplayTree(xpm_colors,ConstantString(key),(void *) j);
/*
Parse color.
*/
(void) CopyMagickString(target,"gray",MaxTextExtent);
q=ParseXPMColor(p+width,MagickTrue);
if (q != (char *) NULL)
{
while ((isspace((int) ((unsigned char) *q)) == 0) && (*q != '\0'))
q++;
if ((next-q) < 0)
break;
if (next != (char *) NULL)
(void) CopyXPMColor(target,q,MagickMin((size_t) (next-q),
MaxTextExtent-1));
else
(void) CopyMagickString(target,q,MaxTextExtent);
q=ParseXPMColor(target,MagickFalse);
if (q != (char *) NULL)
*q='\0';
}
StripString(target);
grey=strstr(target,"grey");
if (grey != (char *) NULL)
grey[2]='a';
if (LocaleCompare(target,"none") == 0)
{
image->storage_class=DirectClass;
image->matte=MagickTrue;
}
status=QueryColorCompliance(target,XPMCompliance,&image->colormap[j],
exception);
if (status == MagickFalse)
示例2: LoadCoderCache
//.........这里部分代码省略.........
if (depth > 200)
(void) ThrowMagickException(exception,GetMagickModule(),
ConfigureError,"IncludeNodeNestedTooDeeply","`%s'",token);
else
{
char
path[MagickPathExtent],
*file_xml;
GetPathComponent(filename,HeadPath,path);
if (*path != '\0')
(void) ConcatenateMagickString(path,DirectorySeparator,
MagickPathExtent);
if (*token == *DirectorySeparator)
(void) CopyMagickString(path,token,MagickPathExtent);
else
(void) ConcatenateMagickString(path,token,MagickPathExtent);
file_xml=FileToXML(path,~0UL);
if (file_xml != (char *) NULL)
{
status&=LoadCoderCache(coder_cache,file_xml,path,depth+1,
exception);
file_xml=DestroyString(file_xml);
}
}
}
}
continue;
}
if (LocaleCompare(keyword,"<coder") == 0)
{
/*
Coder element.
*/
coder_info=(CoderInfo *) AcquireMagickMemory(sizeof(*coder_info));
if (coder_info == (CoderInfo *) NULL)
ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
(void) ResetMagickMemory(coder_info,0,sizeof(*coder_info));
coder_info->path=ConstantString(filename);
coder_info->exempt=MagickFalse;
coder_info->signature=MagickCoreSignature;
continue;
}
if (coder_info == (CoderInfo *) NULL)
continue;
if (LocaleCompare(keyword,"/>") == 0)
{
status=AddValueToSplayTree(coder_cache,ConstantString(
coder_info->magick),coder_info);
if (status == MagickFalse)
(void) ThrowMagickException(exception,GetMagickModule(),
ResourceLimitError,"MemoryAllocationFailed","`%s'",
coder_info->magick);
coder_info=(CoderInfo *) NULL;
continue;
}
GetMagickToken(q,(const char **) NULL,token);
if (*token != '=')
continue;
GetMagickToken(q,&q,token);
GetMagickToken(q,&q,token);
switch (*keyword)
{
case 'M':
case 'm':
{
if (LocaleCompare((char *) keyword,"magick") == 0)
{
coder_info->magick=ConstantString(token);
break;
}
break;
}
case 'N':
case 'n':
{
if (LocaleCompare((char *) keyword,"name") == 0)
{
coder_info->name=ConstantString(token);
break;
}
break;
}
case 'S':
case 's':
{
if (LocaleCompare((char *) keyword,"stealth") == 0)
{
coder_info->stealth=IsStringTrue(token);
break;
}
break;
}
default:
break;
}
}
token=(char *) RelinquishMagickMemory(token);
return(status != 0 ? MagickTrue : MagickFalse);
}
示例3: SetImageRegistry
MagickExport MagickBooleanType SetImageRegistry(const RegistryType type,
const char *key,const void *value,ExceptionInfo *exception)
{
MagickBooleanType
status;
RegistryInfo
*registry_info;
void
*clone_value;
if (IsEventLogging() != MagickFalse)
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",key);
clone_value=(void *) NULL;
switch (type)
{
case StringRegistryType:
default:
{
const char
*string;
string=(const char *) value;
clone_value=(void *) ConstantString(string);
break;
}
case ImageRegistryType:
{
const Image
*image;
image=(const Image *) value;
if (image->signature != MagickSignature)
{
(void) ThrowMagickException(exception,GetMagickModule(),RegistryError,
"UnableToSetRegistry","%s",key);
return(MagickFalse);
}
clone_value=(void *) CloneImageList(image,exception);
break;
}
case ImageInfoRegistryType:
{
const ImageInfo
*image_info;
image_info=(const ImageInfo *) value;
if (image_info->signature != MagickSignature)
{
(void) ThrowMagickException(exception,GetMagickModule(),RegistryError,
"UnableToSetRegistry","%s",key);
return(MagickFalse);
}
clone_value=(void *) CloneImageInfo(image_info);
break;
}
}
if (clone_value == (void *) NULL)
return(MagickFalse);
registry_info=(RegistryInfo *) AcquireMagickMemory(sizeof(*registry_info));
if (registry_info == (RegistryInfo *) NULL)
ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
(void) ResetMagickMemory(registry_info,0,sizeof(*registry_info));
registry_info->type=type;
registry_info->value=clone_value;
registry_info->signature=MagickSignature;
if ((registry == (SplayTreeInfo *) NULL) &&
(instantiate_registry == MagickFalse))
{
if (registry_semaphore == (SemaphoreInfo *) NULL)
AcquireSemaphoreInfo(®istry_semaphore);
LockSemaphoreInfo(registry_semaphore);
if ((registry == (SplayTreeInfo *) NULL) &&
(instantiate_registry == MagickFalse))
{
registry=NewSplayTree(CompareSplayTreeString,RelinquishMagickMemory,
DestroyRegistryNode);
instantiate_registry=MagickTrue;
}
UnlockSemaphoreInfo(registry_semaphore);
}
status=AddValueToSplayTree(registry,ConstantString(key),registry_info);
return(status);
}
示例4: LoadTypeList
//.........这里部分代码省略.........
(void) CopyMagickString(path,token,MaxTextExtent);
else
(void) ConcatenateMagickString(path,token,MaxTextExtent);
sans_exception=AcquireExceptionInfo();
xml=FileToString(path,~0UL,sans_exception);
sans_exception=DestroyExceptionInfo(sans_exception);
if (xml != (char *) NULL)
{
status=LoadTypeList(xml,path,depth+1,exception);
xml=(char *) RelinquishMagickMemory(xml);
}
}
}
}
continue;
}
if (LocaleCompare(keyword,"<type") == 0)
{
/*
Type element.
*/
type_info=(TypeInfo *) AcquireMagickMemory(sizeof(*type_info));
if (type_info == (TypeInfo *) NULL)
ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
(void) ResetMagickMemory(type_info,0,sizeof(*type_info));
type_info->path=ConstantString(filename);
type_info->signature=MagickSignature;
continue;
}
if (type_info == (TypeInfo *) NULL)
continue;
if (LocaleCompare(keyword,"/>") == 0)
{
status=AddValueToSplayTree(type_list,type_info->name,type_info);
if (status == MagickFalse)
(void) ThrowMagickException(exception,GetMagickModule(),
ResourceLimitError,"MemoryAllocationFailed","`%s'",type_info->name);
type_info=(TypeInfo *) NULL;
}
GetMagickToken(q,(const char **) NULL,token);
if (*token != '=')
continue;
GetMagickToken(q,&q,token);
GetMagickToken(q,&q,token);
switch (*keyword)
{
case 'E':
case 'e':
{
if (LocaleCompare((char *) keyword,"encoding") == 0)
{
type_info->encoding=ConstantString(token);
break;
}
break;
}
case 'F':
case 'f':
{
if (LocaleCompare((char *) keyword,"face") == 0)
{
type_info->face=StringToUnsignedLong(token);
break;
}
if (LocaleCompare((char *) keyword,"family") == 0)
{
示例5: ThrowFatalException
static SplayTreeInfo *AcquireCoderCache(const char *filename,
ExceptionInfo *exception)
{
const StringInfo
*option;
LinkedListInfo
*options;
MagickStatusType
status;
register ssize_t
i;
SplayTreeInfo
*coder_cache;
/*
Load external coder map.
*/
coder_cache=NewSplayTree(CompareSplayTreeString,RelinquishMagickMemory,
DestroyCoderNode);
if (coder_cache == (SplayTreeInfo *) NULL)
ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
status=MagickTrue;
options=GetConfigureOptions(filename,exception);
option=(const StringInfo *) GetNextValueInLinkedList(options);
while (option != (const StringInfo *) NULL)
{
status&=LoadCoderCache(coder_cache,(const char *)
GetStringInfoDatum(option),GetStringInfoPath(option),0,exception);
option=(const StringInfo *) GetNextValueInLinkedList(options);
}
options=DestroyConfigureOptions(options);
/*
Load built-in coder map.
*/
for (i=0; i < (ssize_t) (sizeof(CoderMap)/sizeof(*CoderMap)); i++)
{
CoderInfo
*coder_info;
register const CoderMapInfo
*p;
p=CoderMap+i;
coder_info=(CoderInfo *) AcquireMagickMemory(sizeof(*coder_info));
if (coder_info == (CoderInfo *) NULL)
{
(void) ThrowMagickException(exception,GetMagickModule(),
ResourceLimitError,"MemoryAllocationFailed","`%s'",p->name);
continue;
}
(void) ResetMagickMemory(coder_info,0,sizeof(*coder_info));
coder_info->path=(char *) "[built-in]";
coder_info->magick=(char *) p->magick;
coder_info->name=(char *) p->name;
coder_info->exempt=MagickTrue;
coder_info->signature=MagickCoreSignature;
status&=AddValueToSplayTree(coder_cache,ConstantString(coder_info->magick),
coder_info);
if (status == MagickFalse)
(void) ThrowMagickException(exception,GetMagickModule(),
ResourceLimitError,"MemoryAllocationFailed","`%s'",coder_info->name);
}
return(coder_cache);
}
示例6: NTAcquireTypeCache
//.........这里部分代码省略.........
(LocaleCompare(token,"UltraLight") == 0) )
{
type_info->weight=200;
}
else if (LocaleCompare(token,"Light") == 0)
{
type_info->weight=300;
}
else if ( (LocaleCompare(token,"Normal") == 0) ||
(LocaleCompare(token,"Regular") == 0) )
{
type_info->weight=400;
}
else if (LocaleCompare(token,"Medium") == 0)
{
type_info->weight=500;
}
else if ( (LocaleCompare(token,"SemiBold") == 0) ||
(LocaleCompare(token,"DemiBold") == 0) )
{
type_info->weight=600;
}
else if ( (LocaleCompare(token,"ExtraBold") == 0) ||
(LocaleCompare(token,"UltraBold") == 0) )
{
type_info->weight=800;
}
else if ( (LocaleCompare(token,"Heavy") == 0) ||
(LocaleCompare(token,"Black") == 0) )
{
type_info->weight=900;
}
else if (LocaleCompare(token,"Condensed") == 0)
{
type_info->stretch = CondensedStretch;
}
else if (LocaleCompare(token,"Expanded") == 0)
{
type_info->stretch = ExpandedStretch;
}
else if (LocaleCompare(token,"ExtraCondensed") == 0)
{
type_info->stretch = ExtraCondensedStretch;
}
else if (LocaleCompare(token,"ExtraExpanded") == 0)
{
type_info->stretch = ExtraExpandedStretch;
}
else if (LocaleCompare(token,"SemiCondensed") == 0)
{
type_info->stretch = SemiCondensedStretch;
}
else if (LocaleCompare(token,"SemiExpanded") == 0)
{
type_info->stretch = SemiExpandedStretch;
}
else if (LocaleCompare(token,"UltraCondensed") == 0)
{
type_info->stretch = UltraCondensedStretch;
}
else if (LocaleCompare(token,"UltraExpanded") == 0)
{
type_info->stretch = UltraExpandedStretch;
}
else
{
family_extent=q;
}
}
(void) CopyMagickString(buffer,value_name,family_extent-value_name+1);
StripString(buffer);
type_info->family=ConstantString(buffer);
list_entries++;
status=AddValueToSplayTree(type_cache,ConstantString(type_info->name),
type_info);
if (status == MagickFalse)
(void) ThrowMagickException(exception,GetMagickModule(),
ResourceLimitError,"MemoryAllocationFailed","`%s'",type_info->name);
}
}
RegCloseKey(reg_key);
return(MagickTrue);
}
示例7: LoadFontConfigFonts
//.........这里部分代码省略.........
FcPatternDestroy(pattern);
}
FcObjectSetDestroy(object_set);
}
if (font_set == (FcFontSet *) NULL)
{
FcConfigDestroy(font_config);
return(MagickFalse);
}
for (i=0; i < (ssize_t) font_set->nfont; i++)
{
status=FcPatternGetString(font_set->fonts[i],FC_FAMILY,0,&family);
if (status != FcResultMatch)
continue;
status=FcPatternGetString(font_set->fonts[i],FC_FILE,0,&file);
if (status != FcResultMatch)
continue;
*extension='\0';
GetPathComponent((const char *) file,ExtensionPath,extension);
if ((*extension != '\0') && (LocaleCompare(extension,"gz") == 0))
continue;
type_info=(TypeInfo *) AcquireMagickMemory(sizeof(*type_info));
if (type_info == (TypeInfo *) NULL)
continue;
(void) ResetMagickMemory(type_info,0,sizeof(*type_info));
type_info->path=ConstantString("System Fonts");
type_info->signature=MagickSignature;
(void) CopyMagickString(name,"Unknown",MaxTextExtent);
status=FcPatternGetString(font_set->fonts[i],FC_FULLNAME,0,&fullname);
if ((status == FcResultMatch) && (fullname != (FcChar8 *) NULL))
(void) CopyMagickString(name,(const char *) fullname,MaxTextExtent);
else
{
if (family != (FcChar8 *) NULL)
(void) CopyMagickString(name,(const char *) family,MaxTextExtent);
status=FcPatternGetString(font_set->fonts[i],FC_STYLE,0,&style);
if ((status == FcResultMatch) && (style != (FcChar8 *) NULL) &&
(LocaleCompare((const char *) style,"Regular") != 0))
{
(void) ConcatenateMagickString(name," ",MaxTextExtent);
(void) ConcatenateMagickString(name,(const char *) style,
MaxTextExtent);
}
}
type_info->name=ConstantString(name);
(void) SubstituteString(&type_info->name," ","-");
type_info->family=ConstantString((const char *) family);
status=FcPatternGetInteger(font_set->fonts[i],FC_SLANT,0,&slant);
type_info->style=NormalStyle;
if (slant == FC_SLANT_ITALIC)
type_info->style=ItalicStyle;
if (slant == FC_SLANT_OBLIQUE)
type_info->style=ObliqueStyle;
status=FcPatternGetInteger(font_set->fonts[i],FC_WIDTH,0,&width);
type_info->stretch=NormalStretch;
if (width >= FC_WIDTH_ULTRACONDENSED)
type_info->stretch=UltraCondensedStretch;
if (width >= FC_WIDTH_EXTRACONDENSED)
type_info->stretch=ExtraCondensedStretch;
if (width >= FC_WIDTH_CONDENSED)
type_info->stretch=CondensedStretch;
if (width >= FC_WIDTH_SEMICONDENSED)
type_info->stretch=SemiCondensedStretch;
if (width >= FC_WIDTH_NORMAL)
type_info->stretch=NormalStretch;
if (width >= FC_WIDTH_SEMIEXPANDED)
type_info->stretch=SemiExpandedStretch;
if (width >= FC_WIDTH_EXPANDED)
type_info->stretch=ExpandedStretch;
if (width >= FC_WIDTH_EXTRAEXPANDED)
type_info->stretch=ExtraExpandedStretch;
if (width >= FC_WIDTH_ULTRAEXPANDED)
type_info->stretch=UltraExpandedStretch;
type_info->weight=400;
status=FcPatternGetInteger(font_set->fonts[i],FC_WEIGHT,0,&weight);
if (weight >= FC_WEIGHT_THIN)
type_info->weight=100;
if (weight >= FC_WEIGHT_EXTRALIGHT)
type_info->weight=200;
if (weight >= FC_WEIGHT_LIGHT)
type_info->weight=300;
if (weight >= FC_WEIGHT_NORMAL)
type_info->weight=400;
if (weight >= FC_WEIGHT_MEDIUM)
type_info->weight=500;
if (weight >= FC_WEIGHT_DEMIBOLD)
type_info->weight=600;
if (weight >= FC_WEIGHT_BOLD)
type_info->weight=700;
if (weight >= FC_WEIGHT_EXTRABOLD)
type_info->weight=800;
if (weight >= FC_WEIGHT_BLACK)
type_info->weight=900;
type_info->glyphs=ConstantString((const char *) file);
(void) AddValueToSplayTree(type_list,type_info->name,type_info);
}
FcFontSetDestroy(font_set);
FcConfigDestroy(font_config);
return(MagickTrue);
}
示例8: AcquireUniqueFileResource
MagickExport int AcquireUniqueFileResource(char *path)
{
#if !defined(O_NOFOLLOW)
#define O_NOFOLLOW 0
#endif
#if !defined(TMP_MAX)
# define TMP_MAX 238328
#endif
int
c,
file;
register char
*p;
register ssize_t
i;
static const char
portable_filename[65] =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_-";
StringInfo
*key;
unsigned char
*datum;
assert(path != (char *) NULL);
(void) LogMagickEvent(ResourceEvent,GetMagickModule(),"...");
if (random_info == (RandomInfo *) NULL)
{
LockSemaphoreInfo(resource_semaphore);
if (random_info == (RandomInfo *) NULL)
random_info=AcquireRandomInfo();
UnlockSemaphoreInfo(resource_semaphore);
}
file=(-1);
for (i=0; i < (ssize_t) TMP_MAX; i++)
{
/*
Get temporary pathname.
*/
(void) GetPathTemplate(path);
key=GetRandomKey(random_info,6);
p=path+strlen(path)-12;
datum=GetStringInfoDatum(key);
for (i=0; i < (ssize_t) GetStringInfoLength(key); i++)
{
c=(int) (datum[i] & 0x3f);
*p++=portable_filename[c];
}
key=DestroyStringInfo(key);
#if defined(MAGICKCORE_HAVE_MKSTEMP)
file=mkstemp(path);
if (file != -1)
{
#if defined(MAGICKCORE_HAVE_FCHMOD)
(void) fchmod(file,0600);
#endif
#if defined(__OS2__)
setmode(file,O_BINARY);
#endif
break;
}
#endif
key=GetRandomKey(random_info,12);
p=path+strlen(path)-12;
datum=GetStringInfoDatum(key);
for (i=0; i < (ssize_t) GetStringInfoLength(key); i++)
{
c=(int) (datum[i] & 0x3f);
*p++=portable_filename[c];
}
key=DestroyStringInfo(key);
file=open_utf8(path,O_RDWR | O_CREAT | O_EXCL | O_BINARY | O_NOFOLLOW,
S_MODE);
if ((file >= 0) || (errno != EEXIST))
break;
}
(void) LogMagickEvent(ResourceEvent,GetMagickModule(),"%s",path);
if (file == -1)
return(file);
if (resource_semaphore == (SemaphoreInfo *) NULL)
ActivateSemaphoreInfo(&resource_semaphore);
LockSemaphoreInfo(resource_semaphore);
if (temporary_resources == (SplayTreeInfo *) NULL)
temporary_resources=NewSplayTree(CompareSplayTreeString,
DestroyTemporaryResources,(void *(*)(void *)) NULL);
UnlockSemaphoreInfo(resource_semaphore);
(void) AddValueToSplayTree(temporary_resources,ConstantString(path),
(const void *) NULL);
return(file);
}
示例9: ReadDNGImage
//.........这里部分代码省略.........
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
image_info->filename);
assert(exception != (ExceptionInfo *) NULL);
assert(exception->signature == MagickSignature);
image=AcquireImage(image_info);
status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
if (status == MagickFalse)
{
image=DestroyImageList(image);
return((Image *) NULL);
}
(void) CloseBlob(image);
(void) DestroyImageList(image);
/*
Convert DNG to PPM with delegate.
*/
image=AcquireImage(image_info);
read_info=CloneImageInfo(image_info);
(void) InvokeDelegate(read_info,image,"dng:decode",(char *) NULL,exception);
image=DestroyImage(image);
(void) FormatMagickString(read_info->filename,MaxTextExtent,"%s.png",
read_info->unique);
sans_exception=AcquireExceptionInfo();
image=ReadImage(read_info,sans_exception);
sans_exception=DestroyExceptionInfo(sans_exception);
if (image == (Image *) NULL)
{
(void) FormatMagickString(read_info->filename,MaxTextExtent,"%s.ppm",
read_info->unique);
image=ReadImage(read_info,exception);
}
(void) RelinquishUniqueFileResource(read_info->filename);
if (image != (Image *) NULL)
{
char
filename[MaxTextExtent],
*xml;
ExceptionInfo
*sans;
(void) CopyMagickString(image->magick,read_info->magick,MaxTextExtent);
(void) FormatMagickString(filename,MaxTextExtent,"%s.ufraw",
read_info->unique);
sans=AcquireExceptionInfo();
xml=FileToString(filename,MaxTextExtent,sans);
(void) RelinquishUniqueFileResource(filename);
if (xml != (char *) NULL)
{
XMLTreeInfo
*ufraw;
/*
Inject
*/
ufraw=NewXMLTree(xml,sans);
if (ufraw != (XMLTreeInfo *) NULL)
{
char
*content,
property[MaxTextExtent];
const char
*tag;
XMLTreeInfo
*next;
if (image->properties == (void *) NULL)
((Image *) image)->properties=NewSplayTree(
CompareSplayTreeString,RelinquishMagickMemory,
RelinquishMagickMemory);
next=GetXMLTreeChild(ufraw,(const char *) NULL);
while (next != (XMLTreeInfo *) NULL)
{
tag=GetXMLTreeTag(next);
if (tag == (char *) NULL)
tag="unknown";
(void) FormatMagickString(property,MaxTextExtent,"dng:%s",tag);
content=ConstantString(GetXMLTreeContent(next));
StripString(content);
if ((LocaleCompare(tag,"log") != 0) &&
(LocaleCompare(tag,"InputFilename") != 0) &&
(LocaleCompare(tag,"OutputFilename") != 0) &&
(LocaleCompare(tag,"OutputType") != 0) &&
(strlen(content) != 0))
(void) AddValueToSplayTree((SplayTreeInfo *)
((Image *) image)->properties,ConstantString(property),
content);
next=GetXMLTreeSibling(next);
}
ufraw=DestroyXMLTree(ufraw);
}
xml=DestroyString(xml);
}
sans=DestroyExceptionInfo(sans);
}
read_info=DestroyImageInfo(read_info);
return(image);
}
示例10: AcquireUniqueFileResource
MagickExport int AcquireUniqueFileResource(char *path)
{
#if !defined(O_NOFOLLOW)
#define O_NOFOLLOW 0
#endif
#if !defined(TMP_MAX)
# define TMP_MAX 238328
#endif
char
*resource;
int
c,
file;
register char
*p;
register long
i;
static const char
portable_filename[65] =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_-";
StringInfo
*key;
unsigned char
*datum;
assert(path != (char *) NULL);
(void) LogMagickEvent(ResourceEvent,GetMagickModule(),"%s",path);
if (random_info == (RandomInfo *) NULL)
random_info=AcquireRandomInfo();
file=(-1);
for (i=0; i < TMP_MAX; i++)
{
/*
Get temporary pathname.
*/
(void) GetPathTemplate(path);
#if defined(MAGICKCORE_HAVE_MKSTEMP)
file=mkstemp(path);
if (file != -1)
break;
#endif
key=GetRandomKey(random_info,8);
p=path+strlen(path)-8;
datum=GetStringInfoDatum(key);
for (i=0; i < 8; i++)
{
c=(int) (datum[i] & 0x3f);
*p++=portable_filename[c];
}
key=DestroyStringInfo(key);
file=open(path,O_RDWR | O_CREAT | O_EXCL | O_BINARY | O_NOFOLLOW,S_MODE);
if ((file > 0) || (errno != EEXIST))
break;
}
(void) LogMagickEvent(ResourceEvent,GetMagickModule(),"%s",path);
if (file == -1)
return(file);
AcquireSemaphoreInfo(&resource_semaphore);
if (temporary_resources == (SplayTreeInfo *) NULL)
temporary_resources=NewSplayTree(CompareSplayTreeString,
RelinquishMagickMemory,DestroyTemporaryResources);
RelinquishSemaphoreInfo(resource_semaphore);
resource=ConstantString(path);
(void) AddValueToSplayTree(temporary_resources,resource,resource);
return(file);
}
示例11: LoadLocaleList
//.........这里部分代码省略.........
/*
Locale element.
*/
while ((*token != '>') && (*q != '\0'))
{
(void) CopyMagickString(keyword,token,MaxTextExtent);
GetMagickToken(q,&q,token);
if (*token != '=')
continue;
GetMagickToken(q,&q,token);
}
continue;
}
if (LocaleCompare(keyword,"</locale>") == 0)
{
ChopLocaleComponents(tag,1);
(void) ConcatenateMagickString(tag,"/",MaxTextExtent);
continue;
}
if (LocaleCompare(keyword,"<localemap>") == 0)
continue;
if (LocaleCompare(keyword,"</localemap>") == 0)
continue;
if (LocaleCompare(keyword,"<message") == 0)
{
/*
Message element.
*/
while ((*token != '>') && (*q != '\0'))
{
(void) CopyMagickString(keyword,token,MaxTextExtent);
GetMagickToken(q,&q,token);
if (*token != '=')
continue;
GetMagickToken(q,&q,token);
if (LocaleCompare(keyword,"name") == 0)
{
(void) ConcatenateMagickString(tag,token,MaxTextExtent);
(void) ConcatenateMagickString(tag,"/",MaxTextExtent);
}
}
for (p=(char *) q; (*q != '<') && (*q != '\0'); q++) ;
while (isspace((int) ((unsigned char) *p)) != 0)
p++;
q--;
while ((isspace((int) ((unsigned char) *q)) != 0) && (q > p))
q--;
(void) CopyMagickString(message,p,(size_t) (q-p+2));
locale_info=(LocaleInfo *) AcquireMagickMemory(sizeof(*locale_info));
if (locale_info == (LocaleInfo *) NULL)
ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
(void) ResetMagickMemory(locale_info,0,sizeof(*locale_info));
locale_info->path=ConstantString(filename);
locale_info->tag=ConstantString(tag);
locale_info->message=ConstantString(message);
locale_info->signature=MagickSignature;
status=AddValueToSplayTree(locale_list,locale_info->tag,locale_info);
if (status == MagickFalse)
(void) ThrowMagickException(exception,GetMagickModule(),
ResourceLimitError,"MemoryAllocationFailed","`%s'",
locale_info->tag);
(void) ConcatenateMagickString(tag,message,MaxTextExtent);
(void) ConcatenateMagickString(tag,"\n",MaxTextExtent);
q++;
continue;
}
if (LocaleCompare(keyword,"</message>") == 0)
{
ChopLocaleComponents(tag,2);
(void) ConcatenateMagickString(tag,"/",MaxTextExtent);
continue;
}
if (*keyword == '<')
{
/*
Subpath element.
*/
if (*(keyword+1) == '?')
continue;
if (*(keyword+1) == '/')
{
ChopLocaleComponents(tag,1);
if (*tag != '\0')
(void) ConcatenateMagickString(tag,"/",MaxTextExtent);
continue;
}
token[strlen(token)-1]='\0';
(void) CopyMagickString(token,token+1,MaxTextExtent);
(void) ConcatenateMagickString(tag,token,MaxTextExtent);
(void) ConcatenateMagickString(tag,"/",MaxTextExtent);
continue;
}
GetMagickToken(q,(const char **) NULL,token);
if (*token != '=')
continue;
}
token=(char *) RelinquishMagickMemory(token);
(void) SetFatalErrorHandler(fatal_handler);
return(status);
}
示例12: AcquireUniqueFileResource
MagickExport int AcquireUniqueFileResource(char *path)
{
#if !defined(O_NOFOLLOW)
#define O_NOFOLLOW 0
#endif
#if !defined(TMP_MAX)
# define TMP_MAX 238328
#endif
char
*resource;
int
c,
file;
register char
*p;
register long
i;
unsigned char
key[8];
assert(path != (char *) NULL);
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
file=(-1);
for (i=0; i < TMP_MAX; i++)
{
/*
Get temporary pathname.
*/
(void) GetPathTemplate(path);
#if defined(HAVE_MKSTEMP)
file=mkstemp(path);
if (file != -1)
break;
#endif
GetRandomKey(key,8);
p=path+strlen(path)-8;
for (i=0; i < 8; i++)
{
c=(int) (key[i] & 0x1f);
*p++=(char) (c > 9 ? c+(int) 'a'-10 : c+(int) '0');
}
file=open(path,O_RDWR | O_CREAT | O_EXCL | O_BINARY | O_NOFOLLOW,S_MODE);
if ((file > 0) || (errno != EEXIST))
break;
}
(void) LogMagickEvent(ResourceEvent,GetMagickModule(),"%s",path);
if (file == -1)
return(file);
(void) AcquireMagickResource(FileResource,1);
if (temporary_resources == (SplayTreeInfo *) NULL)
temporary_resources=NewSplayTree(CompareSplayTreeString,
RelinquishMagickMemory,DestroyTemporaryResources);
resource=ConstantString(AcquireString(path));
(void) AddValueToSplayTree(temporary_resources,resource,resource);
return(file);
}
示例13: LoadTypeList
//.........这里部分代码省略.........
status=LoadTypeList(xml,path,depth+1,exception);
xml=DestroyString(xml);
}
}
}
include=GetNextXMLTreeTag(include);
}
*font_path='\0';
#if defined(__WINDOWS__)
if (NTGhostscriptFonts(font_path,MaxTextExtent-2))
(void) ConcatenateMagickString(font_path,DirectorySeparator,MaxTextExtent);
#endif
type=GetXMLTreeChild(type_map,"type");
while (type != (XMLTreeInfo *) NULL)
{
/*
Process type element.
*/
type_info=(TypeInfo *) AcquireMagickMemory(sizeof(*type_info));
if (type_info == (TypeInfo *) NULL)
ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
(void) ResetMagickMemory(type_info,0,sizeof(*type_info));
type_info->path=ConstantString(filename);
type_info->signature=MagickSignature;
attribute=GetXMLTreeAttribute(type,"encoding");
if (attribute != (const char *) NULL)
type_info->encoding=ConstantString(attribute);
attribute=GetXMLTreeAttribute(type,"face");
if (attribute != (const char *) NULL)
type_info->face=(unsigned long) atol(attribute);
attribute=GetXMLTreeAttribute(type,"family");
if (attribute != (const char *) NULL)
type_info->family=ConstantString(attribute);
attribute=GetXMLTreeAttribute(type,"format");
if (attribute != (const char *) NULL)
type_info->format=ConstantString(attribute);
attribute=GetXMLTreeAttribute(type,"foundry");
if (attribute != (const char *) NULL)
type_info->foundry=ConstantString(attribute);
attribute=GetXMLTreeAttribute(type,"fullname");
if (attribute != (const char *) NULL)
type_info->description=ConstantString(attribute);
attribute=GetXMLTreeAttribute(type,"glyphs");
if (attribute != (const char *) NULL)
{
char
*path;
path=ConstantString(attribute);
#if defined(__WINDOWS__)
if (strchr(path,'@') != (char *) NULL)
(void) SubstituteString(&path,"@[email protected]",font_path);
#endif
type_info->glyphs=path;
}
attribute=GetXMLTreeAttribute(type,"metrics");
if (attribute != (const char *) NULL)
{
char
*path;
path=ConstantString(attribute);
#if defined(__WINDOWS__)
if (strchr(path,'@') != (char *) NULL)
(void) SubstituteString(&path,"@[email protected]",font_path);
#endif
type_info->metrics=path;
}
attribute=GetXMLTreeAttribute(type,"name");
if (attribute != (const char *) NULL)
type_info->name=ConstantString(attribute);
attribute=GetXMLTreeAttribute(type,"stealth");
if (attribute != (const char *) NULL)
type_info->stealth=IsMagickTrue(attribute);
attribute=GetXMLTreeAttribute(type,"stretch");
if (attribute != (const char *) NULL)
type_info->stretch=(StretchType) ParseMagickOption(MagickStretchOptions,
MagickFalse,attribute);
attribute=GetXMLTreeAttribute(type,"style");
if (attribute != (const char *) NULL)
type_info->style=(StyleType) ParseMagickOption(MagickStyleOptions,
MagickFalse,attribute);
attribute=GetXMLTreeAttribute(type,"weight");
if (attribute != (const char *) NULL)
{
type_info->weight=(unsigned long) atol(attribute);
if (LocaleCompare(attribute,"bold") == 0)
type_info->weight=700;
if (LocaleCompare(attribute,"normal") == 0)
type_info->weight=400;
}
status=AddValueToSplayTree(type_list,type_info->name,type_info);
if (status == MagickFalse)
(void) ThrowMagickException(exception,GetMagickModule(),
ResourceLimitError,"MemoryAllocationFailed","`%s'",filename);
type=GetNextXMLTreeTag(type);
}
type_map=DestroyXMLTree(type_map);
return(status);
}
示例14: LoadCoderLists
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% %
% %
% L o a d C o d e r L i s t s %
% %
% %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% LoadCoderLists() loads one or more coder configuration file which
% provides a mapping between coder attributes and a coder name.
%
% The format of the LoadCoderLists coder is:
%
% MagickBooleanType LoadCoderLists(const char *filename,
% ExceptionInfo *exception)
%
% A description of each parameter follows:
%
% o filename: the font file name.
%
% o exception: return any errors or warnings in this structure.
%
*/
static MagickBooleanType LoadCoderLists(const char *filename,
ExceptionInfo *exception)
{
const StringInfo
*option;
LinkedListInfo
*options;
MagickStatusType
status;
register long
i;
/*
Load built-in coder map.
*/
status=MagickFalse;
if (coder_list == (SplayTreeInfo *) NULL)
{
coder_list=NewSplayTree(CompareSplayTreeString,RelinquishMagickMemory,
DestroyCoderNode);
if (coder_list == (SplayTreeInfo *) NULL)
{
ThrowFileException(exception,ResourceLimitError,
"MemoryAllocationFailed",filename);
return(MagickFalse);
}
}
for (i=0; i < (long) (sizeof(CoderMap)/sizeof(*CoderMap)); i++)
{
CoderInfo
*coder_info;
register const CoderMapInfo
*p;
p=CoderMap+i;
coder_info=(CoderInfo *) AcquireAlignedMemory(1,sizeof(*coder_info));
if (coder_info == (CoderInfo *) NULL)
{
(void) ThrowMagickException(exception,GetMagickModule(),
ResourceLimitError,"MemoryAllocationFailed","`%s'",coder_info->name);
continue;
}
(void) ResetMagickMemory(coder_info,0,sizeof(*coder_info));
coder_info->path=(char *) "[built-in]";
coder_info->magick=(char *) p->magick;
coder_info->name=(char *) p->name;
coder_info->exempt=MagickTrue;
coder_info->signature=MagickSignature;
status=AddValueToSplayTree(coder_list,ConstantString(coder_info->magick),
coder_info);
if (status == MagickFalse)
(void) ThrowMagickException(exception,GetMagickModule(),
ResourceLimitError,"MemoryAllocationFailed","`%s'",coder_info->name);
}
/*
Load external coder map.
*/
options=GetConfigureOptions(filename,exception);
option=(const StringInfo *) GetNextValueInLinkedList(options);
while (option != (const StringInfo *) NULL)
{
status|=LoadCoderList((const char *) GetStringInfoDatum(option),
GetStringInfoPath(option),0,exception);
option=(const StringInfo *) GetNextValueInLinkedList(options);
}
options=DestroyConfigureOptions(options);
return(status != 0 ? MagickTrue : MagickFalse);
}