From: cristy Date: Wed, 21 Oct 2009 17:58:01 +0000 (+0000) Subject: (no commit message) X-Git-Tag: 7.0.1-0~10483 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=54a531d335ea060a99bead94dcdf45f18496fa83;p=imagemagick --- diff --git a/magick/coder.c b/magick/coder.c index 25c3b4010..6b065855d 100644 --- a/magick/coder.c +++ b/magick/coder.c @@ -64,7 +64,7 @@ #define MagickCoderFilename "coder.xml" /* - Static declarations. + Typedef declarations. */ typedef struct _CoderMapInfo { @@ -72,7 +72,10 @@ typedef struct _CoderMapInfo *magick, *name; } CoderMapInfo; - + +/* + Static declarations. +*/ static const CoderMapInfo CoderMap[] = { @@ -213,8 +216,7 @@ static const CoderMapInfo { "XTRNSTREAM", "XTRN" }, { "XV", "VIFF" }, { "Y", "RAW" }, - { "YCbCrA", "YCbCr" }, - { (const char *) NULL, (const char *) NULL } + { "YCbCrA", "YCbCr" } }; static SemaphoreInfo @@ -878,8 +880,8 @@ static MagickBooleanType LoadCoderLists(const char *filename, MagickStatusType status; - register const CoderMapInfo - *p; + register long + i; /* Load built-in coder map. @@ -896,11 +898,15 @@ static MagickBooleanType LoadCoderLists(const char *filename, return(MagickFalse); } } - for (p=CoderMap; p->magick != (const char *) NULL; p++) + for (i=0; i < (long) (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) { diff --git a/magick/color.c b/magick/color.c index 7235e2517..46476c729 100644 --- a/magick/color.c +++ b/magick/color.c @@ -72,7 +72,7 @@ #define ColorFilename "colors.xml" /* - Static declarations. + Typedef declarations. */ typedef struct _ColorMapInfo { @@ -88,7 +88,10 @@ typedef struct _ColorMapInfo const long compliance; } ColorMapInfo; - + +/* + Static declarations. +*/ static const ColorMapInfo ColorMap[] = { @@ -771,8 +774,7 @@ static const ColorMapInfo { "yellow2", 238, 238, 0, 1, X11Compliance }, { "yellow3", 205, 205, 0, 1, X11Compliance }, { "yellow4", 139, 139, 0, 1, X11Compliance }, - { "YellowGreen", 154, 205, 50, 1, SVGCompliance | X11Compliance | XPMCompliance }, - { (const char *) NULL, 0, 0, 0, 0, UndefinedCompliance } + { "YellowGreen", 154, 205, 50, 1, SVGCompliance | X11Compliance | XPMCompliance } }; /* @@ -2143,8 +2145,8 @@ static MagickBooleanType LoadColorLists(const char *filename, MagickStatusType status; - register const ColorMapInfo - *p; + register long + i; /* Load built-in color map. @@ -2161,11 +2163,15 @@ static MagickBooleanType LoadColorLists(const char *filename, } } scale=(MagickRealType) ScaleCharToQuantum(1); - for (p=ColorMap; p->name != (const char *) NULL; p++) + for (i=0; i < (long) (sizeof(ColorMap)/sizeof(*ColorMap)); i++) { ColorInfo *color_info; + register const ColorMapInfo + *p; + + p=ColorMap+i; color_info=(ColorInfo *) AcquireMagickMemory(sizeof(*color_info)); if (color_info == (ColorInfo *) NULL) { diff --git a/magick/configure.c b/magick/configure.c index c58951dee..2d762b4d9 100644 --- a/magick/configure.c +++ b/magick/configure.c @@ -59,15 +59,23 @@ */ #define ConfigureFilename "configure.xml" +/* + Typedef declarations. +*/ +typedef struct _ConfigureMapInfo +{ + const char + *name, + *value; +} ConfigureMapInfo; + /* Static declarations. */ -static const char - *ConfigureMap = (char *) - "" - "" - " " - ""; +static const ConfigureMapInfo + ConfigureMap[] = + { + }; static LinkedListInfo *configure_list = (LinkedListInfo *) NULL; @@ -110,12 +118,15 @@ static void *DestroyConfigureElement(void *configure_info) *p; p=(ConfigureInfo *) configure_info; - if (p->path != (char *) NULL) - p->path=DestroyString(p->path); - if (p->name != (char *) NULL) - p->name=DestroyString(p->name); - if (p->value != (char *) NULL) - p->value=DestroyString(p->value); + if (p->exempt == MagickFalse) + { + if (p->value != (char *) NULL) + p->value=DestroyString(p->value); + if (p->name != (char *) NULL) + p->name=DestroyString(p->name); + if (p->path != (char *) NULL) + p->path=DestroyString(p->path); + } p=(ConfigureInfo *) RelinquishMagickMemory(p); return((void *) NULL); } @@ -1014,10 +1025,7 @@ static MagickBooleanType LoadConfigureList(const char *xml,const char *filename, } status=MagickTrue; configure_info=(ConfigureInfo *) NULL; - if (xml == (char *) NULL) - token=AcquireString(ConfigureMap); - else - token=AcquireString((char *) xml); + token=AcquireString((char *) xml); for (q=(char *) xml; *q != '\0'; ) { /* @@ -1098,6 +1106,7 @@ static MagickBooleanType LoadConfigureList(const char *xml,const char *filename, ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed"); (void) ResetMagickMemory(configure_info,0,sizeof(*configure_info)); configure_info->path=ConstantString(filename); + configure_info->exempt=MagickFalse; configure_info->signature=MagickSignature; continue; } @@ -1189,9 +1198,6 @@ static MagickBooleanType LoadConfigureList(const char *xml,const char *filename, static MagickBooleanType LoadConfigureLists(const char *filename, ExceptionInfo *exception) { -#if defined(MAGICKCORE_EMBEDDABLE_SUPPORT) - return(LoadConfigureList(ConfigureMap,"built-in",0,exception)); -#else const StringInfo *option; @@ -1201,7 +1207,56 @@ static MagickBooleanType LoadConfigureLists(const char *filename, MagickStatusType status; + register long + i; + + /* + Load built-in configure map. + */ status=MagickFalse; + if (configure_list == (LinkedListInfo *) NULL) + { + configure_list=NewLinkedList(0); + if (configure_list == (LinkedListInfo *) NULL) + { + ThrowFileException(exception,ResourceLimitError, + "MemoryAllocationFailed",filename); + return(MagickFalse); + } + } + for (i=0; i < (long) (sizeof(ConfigureMap)/sizeof(*ConfigureMap)); i++) + { + ConfigureInfo + *configure_info; + + register const ConfigureMapInfo + *p; + + p=ConfigureMap+i; + configure_info=(ConfigureInfo *) AcquireMagickMemory( + sizeof(*configure_info)); + if (configure_info == (ConfigureInfo *) NULL) + { + (void) ThrowMagickException(exception,GetMagickModule(), + ResourceLimitError,"MemoryAllocationFailed","`%s'", + configure_info->name); + continue; + } + (void) ResetMagickMemory(configure_info,0,sizeof(*configure_info)); + configure_info->path=(char *) "[built-in]"; + configure_info->name=(char *) p->name; + configure_info->value=(char *) p->value; + configure_info->exempt=MagickTrue; + configure_info->signature=MagickSignature; + status=AppendValueToLinkedList(configure_list,configure_info); + if (status == MagickFalse) + (void) ThrowMagickException(exception,GetMagickModule(), + ResourceLimitError,"MemoryAllocationFailed","`%s'", + configure_info->name); + } + /* + Load external configure map. + */ options=GetConfigureOptions(filename,exception); option=(const StringInfo *) GetNextValueInLinkedList(options); while (option != (const StringInfo *) NULL) @@ -1211,9 +1266,5 @@ static MagickBooleanType LoadConfigureLists(const char *filename, option=(const StringInfo *) GetNextValueInLinkedList(options); } options=DestroyConfigureOptions(options); - if ((configure_list == (LinkedListInfo *) NULL) || - (IsLinkedListEmpty(configure_list) != MagickFalse)) - status|=LoadConfigureList(ConfigureMap,"built-in",0,exception); return(status != 0 ? MagickTrue : MagickFalse); -#endif } diff --git a/magick/configure.h b/magick/configure.h index 0be05da78..058a39eba 100644 --- a/magick/configure.h +++ b/magick/configure.h @@ -32,6 +32,7 @@ typedef struct _ConfigureInfo *value; MagickBooleanType + exempt, stealth; struct _ConfigureInfo diff --git a/magick/magic.c b/magick/magic.c index d5bd5f32b..0c6b5a646 100644 --- a/magick/magic.c +++ b/magick/magic.c @@ -57,9 +57,10 @@ Define declarations. */ #define MagicFilename "magic.xml" +#define MagickString(magic) (const unsigned char *) (magic), sizeof(magic)-1 /* - Static declarations. + Typedef declarations. */ typedef struct _MagicMapInfo { @@ -75,9 +76,10 @@ typedef struct _MagicMapInfo const size_t length; } MagicMapInfo; - -#define MagickString(magic) (const unsigned char *) (magic), sizeof(magic)-1 - + +/* + Static declarations. +*/ static const MagicMapInfo MagicMap[] = { @@ -188,8 +190,7 @@ static const MagicMapInfo { "XEF", 0, MagickString("FOVb") }, { "XPM", 1, MagickString("* XPM *") }, { "XWD", 4, MagickString("\007\000\000") }, - { "XWD", 5, MagickString("\000\000\007") }, - { (const char *) NULL, 0, MagickString((const char *) NULL) } + { "XWD", 5, MagickString("\000\000\007") } }; static LinkedListInfo @@ -1000,8 +1001,8 @@ static MagickBooleanType LoadMagicLists(const char *filename, MagickStatusType status; - register const MagicMapInfo - *p; + register long + i; /* Load built-in magic map. @@ -1017,11 +1018,15 @@ static MagickBooleanType LoadMagicLists(const char *filename, return(MagickFalse); } } - for (p=MagicMap; p->name != (const char *) NULL; p++) + for (i=0; i < (long) (sizeof(MagicMap)/sizeof(*MagicMap)); i++) { MagicInfo *magic_info; + register const MagicMapInfo + *p; + + p=MagicMap+i; magic_info=(MagicInfo *) AcquireMagickMemory(sizeof(*magic_info)); if (magic_info == (MagicInfo *) NULL) { diff --git a/magick/policy.c b/magick/policy.c index d5cc002f8..650afa362 100644 --- a/magick/policy.c +++ b/magick/policy.c @@ -62,22 +62,12 @@ #define PolicyFilename "policy.xml" /* - Declare policy map. -*/ -static const char - *PolicyMap = (const char *) - "" - "" - ""; - -/* - Domaindef declarations. + Typedef declarations. */ struct _PolicyInfo { char - *path, - *name; + *path; PolicyDomain domain; @@ -86,10 +76,12 @@ struct _PolicyInfo rights; char + *name, *pattern, *value; MagickBooleanType + exempt, stealth, debug; @@ -99,10 +91,29 @@ struct _PolicyInfo unsigned long signature; }; + +typedef struct _PolicyMapInfo +{ + const PolicyDomain + domain; + + const PolicyRights + rights; + + const char + *name, + *pattern, + *value; +} PolicyMapInfo; /* Static declarations. */ +static const PolicyMapInfo + PolicyMap[] = + { + }; + static LinkedListInfo *policy_list = (LinkedListInfo *) NULL; @@ -144,14 +155,17 @@ static void *DestroyPolicyElement(void *policy_info) *p; p=(PolicyInfo *) policy_info; - if (p->value != (char *) NULL) - p->value=DestroyString(p->value); - if (p->pattern != (char *) NULL) - p->pattern=DestroyString(p->pattern); - if (p->name != (char *) NULL) - p->name=DestroyString(p->name); - if (p->path != (char *) NULL) - p->path=DestroyString(p->path); + if (p->exempt == MagickFalse) + { + if (p->value != (char *) NULL) + p->value=DestroyString(p->value); + if (p->pattern != (char *) NULL) + p->pattern=DestroyString(p->pattern); + if (p->name != (char *) NULL) + p->name=DestroyString(p->name); + if (p->path != (char *) NULL) + p->path=DestroyString(p->path); + } p=(PolicyInfo *) RelinquishMagickMemory(p); return((void *) NULL); } @@ -811,6 +825,7 @@ static MagickBooleanType LoadPolicyList(const char *xml,const char *filename, ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed"); (void) ResetMagickMemory(policy_info,0,sizeof(*policy_info)); policy_info->path=ConstantString(filename); + policy_info->exempt=MagickFalse; policy_info->signature=MagickSignature; continue; } @@ -931,9 +946,6 @@ static MagickBooleanType LoadPolicyList(const char *xml,const char *filename, static MagickBooleanType LoadPolicyLists(const char *filename, ExceptionInfo *exception) { -#if defined(MAGICKCORE_EMBEDDABLE_SUPPORT) - return(LoadPolicyList(PolicyMap,"built-in",0,exception)); -#else const StringInfo *option; @@ -943,7 +955,56 @@ static MagickBooleanType LoadPolicyLists(const char *filename, MagickStatusType status; + register long + i; + + /* + Load built-in policy map. + */ status=MagickFalse; + if (policy_list == (LinkedListInfo *) NULL) + { + policy_list=NewLinkedList(0); + if (policy_list == (LinkedListInfo *) NULL) + { + ThrowFileException(exception,ResourceLimitError, + "MemoryAllocationFailed",filename); + return(MagickFalse); + } + } + for (i=0; i < (long) (sizeof(PolicyMap)/sizeof(*PolicyMap)); i++) + { + PolicyInfo + *policy_info; + + register const PolicyMapInfo + *p; + + p=PolicyMap+i; + policy_info=(PolicyInfo *) AcquireMagickMemory(sizeof(*policy_info)); + if (policy_info == (PolicyInfo *) NULL) + { + (void) ThrowMagickException(exception,GetMagickModule(), + ResourceLimitError,"MemoryAllocationFailed","`%s'",policy_info->name); + continue; + } + (void) ResetMagickMemory(policy_info,0,sizeof(*policy_info)); + policy_info->path=(char *) "[built-in]"; + policy_info->domain=p->domain; + policy_info->rights=p->rights; + policy_info->name=(char *) p->name; + policy_info->pattern=(char *) p->pattern; + policy_info->value=(char *) p->value; + policy_info->exempt=MagickTrue; + policy_info->signature=MagickSignature; + status=AppendValueToLinkedList(policy_list,policy_info); + if (status == MagickFalse) + (void) ThrowMagickException(exception,GetMagickModule(), + ResourceLimitError,"MemoryAllocationFailed","`%s'",policy_info->name); + } + /* + Load external policy map. + */ options=GetConfigureOptions(filename,exception); option=(const StringInfo *) GetNextValueInLinkedList(options); while (option != (const StringInfo *) NULL) @@ -953,9 +1014,5 @@ static MagickBooleanType LoadPolicyLists(const char *filename, option=(const StringInfo *) GetNextValueInLinkedList(options); } options=DestroyConfigureOptions(options); - if ((policy_list == (LinkedListInfo *) NULL) || - (IsLinkedListEmpty(policy_list) != MagickFalse)) - status|=LoadPolicyList(PolicyMap,"built-in",0,exception); return(status != 0 ? MagickTrue : MagickFalse); -#endif } diff --git a/magick/version.h b/magick/version.h index 2156d650a..6fd3cda51 100644 --- a/magick/version.h +++ b/magick/version.h @@ -77,6 +77,7 @@ extern MagickExport char extern MagickExport const char *GetMagickCopyright(void), + *GetMagickFeatures(void), *GetMagickPackageName(void), *GetMagickQuantumDepth(unsigned long *), *GetMagickQuantumRange(unsigned long *),