69 #if defined(MAGICKCORE_HAVE_NEWLOCALE) || defined(MAGICKCORE_WINDOWS_SUPPORT) 70 # define MAGICKCORE_LOCALE_SUPPORT 72 #define LocaleFilename "locale.xml" 79 "<?xml version=\"1.0\"?>" 81 " <locale name=\"C\">" 83 " <Message name=\"\">" 95 #if defined(MAGICKCORE_LOCALE_SUPPORT) 96 static volatile locale_t
97 c_locale = (locale_t) NULL;
108 #if defined(MAGICKCORE_LOCALE_SUPPORT) 128 static locale_t AcquireCLocale(
void)
130 #if defined(MAGICKCORE_HAVE_NEWLOCALE) 131 if (c_locale == (locale_t) NULL)
132 c_locale=newlocale(LC_ALL_MASK,
"C",(locale_t) 0);
133 #elif defined(MAGICKCORE_WINDOWS_SUPPORT) && !defined(__MINGW32__) 134 if (c_locale == (locale_t) NULL)
135 c_locale=_create_locale(LC_ALL,
"C");
176 if (p->
path != (
char *) NULL)
178 if (p->
tag != (
char *) NULL)
180 if (p->
message != (
char *) NULL)
197 #if !defined(MAGICKCORE_ZERO_CONFIGURATION_SUPPORT) 236 #if defined(MAGICKCORE_LOCALE_SUPPORT) 256 static void DestroyCLocale(
void)
258 #if defined(MAGICKCORE_HAVE_NEWLOCALE) 259 if (c_locale != (locale_t) NULL)
260 freelocale(c_locale);
261 #elif defined(MAGICKCORE_WINDOWS_SUPPORT) && !defined(__MINGW32__) 262 if (c_locale != (locale_t) NULL)
263 _free_locale(c_locale);
265 c_locale=(locale_t) NULL;
338 #if defined(MAGICKCORE_LOCALE_SUPPORT) && defined(MAGICKCORE_HAVE_VFPRINTF_L) 343 locale=AcquireCLocale();
344 if (locale == (locale_t) NULL)
345 n=(ssize_t) vfprintf(file,format,operands);
347 #if defined(MAGICKCORE_WINDOWS_SUPPORT) 348 n=(ssize_t) vfprintf_l(file,format,locale,operands);
350 n=(ssize_t) vfprintf_l(file,locale,format,operands);
354 #if defined(MAGICKCORE_LOCALE_SUPPORT) && defined(MAGICKCORE_HAVE_USELOCALE) 360 locale=AcquireCLocale();
361 if (locale == (locale_t) NULL)
362 n=(ssize_t) vfprintf(file,format,operands);
365 previous_locale=uselocale(locale);
366 n=(ssize_t) vfprintf(file,format,operands);
367 uselocale(previous_locale);
371 n=(ssize_t) vfprintf(file,format,operands);
386 va_start(operands,format);
424 const size_t length,
const char *
magick_restrict format,va_list operands)
429 #if defined(MAGICKCORE_LOCALE_SUPPORT) && defined(MAGICKCORE_HAVE_VSNPRINTF_L) 434 locale=AcquireCLocale();
435 if (locale == (locale_t) NULL)
436 n=(ssize_t) vsnprintf(
string,length,format,operands);
438 #if defined(MAGICKCORE_WINDOWS_SUPPORT) 439 n=(ssize_t) vsnprintf_l(
string,length,format,locale,operands);
441 n=(ssize_t) vsnprintf_l(
string,length,locale,format,operands);
444 #elif defined(MAGICKCORE_HAVE_VSNPRINTF) 445 #if defined(MAGICKCORE_LOCALE_SUPPORT) && defined(MAGICKCORE_HAVE_USELOCALE) 451 locale=AcquireCLocale();
452 if (locale == (locale_t) NULL)
453 n=(ssize_t) vsnprintf(
string,length,format,operands);
456 previous_locale=uselocale(locale);
457 n=(ssize_t) vsnprintf(
string,length,format,operands);
458 uselocale(previous_locale);
462 n=(ssize_t) vsnprintf(
string,length,format,operands);
465 n=(ssize_t) vsprintf(
string,format,operands);
468 string[length-1]=
'\0';
481 va_start(operands,format);
523 if ((tag == (
const char *) NULL) || (
LocaleCompare(tag,
"*") == 0))
565 #if defined(__cplusplus) || defined(c_plusplus) 582 #if defined(__cplusplus) || defined(c_plusplus) 601 assert(pattern != (
char *) NULL);
603 assert(number_messages != (
size_t *) NULL);
628 *number_messages=(size_t) i;
662 #if defined(__cplusplus) || defined(c_plusplus) 677 #if defined(__cplusplus) || defined(c_plusplus) 696 assert(pattern != (
char *) NULL);
698 assert(number_messages != (
size_t *) NULL);
702 return((
char **) NULL);
705 if (messages == (
char **) NULL)
706 return((
char **) NULL);
718 messages[i]=(
char *) NULL;
719 *number_messages=(size_t) i;
757 if ((tag == (
const char *) NULL) || (*tag ==
'\0'))
810 assert(filename != (
const char *) NULL);
823 while (element != (
const char *) NULL)
828 "Searching for locale file: \"%s\"",path);
836 #if defined(MAGICKCORE_WINDOWS_SUPPORT) 841 blob=(
char *) NTResourceToBlob(filename);
842 if (blob != (
char *) NULL)
925 locale=(
char *) NULL;
926 p=setlocale(LC_CTYPE,(
const char *) NULL);
927 if (p != (
const char *) NULL)
929 if (locale == (
char *) NULL)
931 if (locale == (
char *) NULL)
933 if (locale == (
char *) NULL)
935 if (locale == (
char *) NULL)
937 if (locale == (
char *) NULL)
985 if ((*
string ==
'0') && ((
string[1] | 0x20)==
'x'))
986 value=(double) strtoul(
string,&q,16);
989 #if defined(MAGICKCORE_LOCALE_SUPPORT) && defined(MAGICKCORE_HAVE_STRTOD_L) 993 locale=AcquireCLocale();
994 if (locale == (locale_t) NULL)
995 value=strtod(
string,&q);
997 value=strtod_l(
string,&q,locale);
999 value=strtod(
string,&q);
1002 if (sentinal != (
char **) NULL)
1046 if (file == (
const FILE *) NULL)
1050 if (locale_info == (
const LocaleInfo **) NULL)
1052 path=(
const char *) NULL;
1053 for (i=0; i < (ssize_t) number_messages; i++)
1057 if ((path == (
const char *) NULL) ||
1060 if (locale_info[i]->path != (
char *) NULL)
1064 "-------------------------------------------------" 1065 "------------------------------\n");
1067 path=locale_info[i]->
path;
1069 if (locale_info[i]->message != (
char *) NULL)
1073 (void) fflush(file);
1120 p=path+strlen(path)-1;
1123 for (count=0; (count < (ssize_t) components) && (p > path); p--)
1129 if (count < (ssize_t) components)
1135 const char *reason,
const char *description)
1139 if (reason == (
char *) NULL)
1142 if (description != (
char *) NULL)
1145 (void) fflush(stderr);
1150 const char *filename,
const char *locale,
const size_t depth,
ExceptionInfo *exception)
1180 "Loading locale configure file \"%s\" ...",filename);
1181 if (xml == (
const char *) NULL)
1191 for (q=(
char *) xml; *q !=
'\0'; )
1208 while (isspace((
int) ((
unsigned char) *q)) != 0)
1221 while (isspace((
int) ((
unsigned char) *q)) != 0)
1231 while (((*token !=
'/') && (*(token+1) !=
'>')) && (*q !=
'\0'))
1265 if (file_xml != (
char *) NULL)
1281 while ((*token !=
'>') && (*q !=
'\0'))
1306 while ((*token !=
'>') && (*q !=
'\0'))
1319 for (p=(
char *) q; (*q !=
'<') && (*q !=
'\0'); q++) ;
1320 while (isspace((
int) ((
unsigned char) *p)) != 0)
1323 while ((isspace((
int) ((
unsigned char) *q)) != 0) && (q > p))
1328 (void) memset(locale_info,0,
sizeof(*locale_info));
1349 if (*keyword ==
'<')
1354 if (*(keyword+1) ==
'?')
1356 if (*(keyword+1) ==
'/')
1363 token[strlen(token)-1]=
'\0';
1410 if ((p == (
char *) NULL) && (q == (
char *) NULL))
1412 if (p == (
char *) NULL)
1414 if (q == (
char *) NULL)
1416 #if defined(MAGICKCORE_HAVE_STRCASECMP) 1417 return(strcasecmp(p,q));
1426 c=(int) *((
unsigned char *) p);
1427 d=(int) *((
unsigned char *) q);
1466 assert(
string != (
char *) NULL);
1467 for (q=
string; *q !=
'\0'; q++)
1468 *q=(
char) tolower((
int) *q);
1510 if ((p == (
char *) NULL) && (q == (
char *) NULL))
1512 if (p == (
char *) NULL)
1514 if (q == (
char *) NULL)
1516 #if defined(MAGICKCORE_HAVE_STRNCASECMP) 1517 return(strncasecmp(p,q,length));
1527 for (i=length; i != 0; i--)
1529 c=(int) *((
unsigned char *) p);
1530 d=(int) *((
unsigned char *) q);
1571 assert(
string != (
char *) NULL);
1572 for (q=
string; *q !=
'\0'; q++)
1573 *q=(
char) toupper((
int) *q);
1626 #if defined(MAGICKCORE_LOCALE_SUPPORT)
static void * DestroyLocaleNode(void *locale_info)
#define MagickMaxRecursionDepth
MagickExport MagickBooleanType AddValueToSplayTree(SplayTreeInfo *splay_tree, const void *key, const void *value)
static void ChopLocaleComponents(char *path, const size_t components)
static const unsigned char AsciiMap[]
MagickPrivate ssize_t FormatLocaleStringList(char *magick_restrict string, const size_t length, const char *magick_restrict format, va_list operands)
MagickExport void SetStringInfoPath(StringInfo *string_info, const char *path)
MagickExport void UnlockSemaphoreInfo(SemaphoreInfo *semaphore_info)
MagickExport void ResetLinkedListIterator(LinkedListInfo *list_info)
MagickPrivate void LocaleComponentTerminus(void)
MagickExport LinkedListInfo * DestroyLinkedList(LinkedListInfo *list_info, void *(*relinquish_value)(void *))
MagickExport size_t ConcatenateMagickString(char *destination, const char *source, const size_t length)
MagickExport SemaphoreInfo * AcquireSemaphoreInfo(void)
static const char * LocaleMap
static void * DestroyOptions(void *message)
MagickExport ExceptionInfo * AcquireExceptionInfo(void)
static SplayTreeInfo * AcquireLocaleSplayTree(const char *filename, const char *locale, ExceptionInfo *exception)
MagickExport MagickBooleanType AppendValueToLinkedList(LinkedListInfo *list_info, const void *value)
MagickExport ssize_t FormatLocaleString(char *magick_restrict string, const size_t length, const char *magick_restrict format,...)
MagickExport LinkedListInfo * GetLocaleOptions(const char *filename, ExceptionInfo *exception)
static void * AcquireCriticalMemory(const size_t size)
static int LocaleTagCompare(const void *x, const void *y)
MagickExport void * GetNextValueInLinkedList(LinkedListInfo *list_info)
MagickExport const void * GetNextValueInSplayTree(SplayTreeInfo *splay_tree)
#define MagickCoreSignature
void(* FatalErrorHandler)(const ExceptionType, const char *, const char *)
MagickExport void LockSemaphoreInfo(SemaphoreInfo *semaphore_info)
MagickExport unsigned char * GetStringInfoDatum(const StringInfo *string_info)
MagickPrivate ssize_t FormatLocaleFileList(FILE *file, const char *magick_restrict format, va_list operands)
MagickExport void GetPathComponent(const char *path, PathType type, char *component)
MagickExport ssize_t FormatLocaleFile(FILE *file, const char *magick_restrict format,...)
#define DirectorySeparator
unsigned int MagickStatusType
MagickExport char * AcquireString(const char *source)
MagickExport void LocaleLower(char *string)
MagickExport StringInfo * DestroyStringInfo(StringInfo *string_info)
MagickExport void * AcquireQuantumMemory(const size_t count, const size_t quantum)
MagickExport int LocaleNCompare(const char *p, const char *q, const size_t length)
static MagickBooleanType LoadLocaleCache(SplayTreeInfo *, const char *, const char *, const char *, const size_t, ExceptionInfo *)
MagickExport SplayTreeInfo * DestroySplayTree(SplayTreeInfo *splay_tree)
MagickExport MagickBooleanType GlobExpression(const char *expression, const char *pattern, const MagickBooleanType case_insensitive)
MagickExport SplayTreeInfo * NewSplayTree(int(*compare)(const void *, const void *), void *(*relinquish_key)(void *), void *(*relinquish_value)(void *))
MagickExport MagickBooleanType ThrowMagickException(ExceptionInfo *exception, const char *module, const char *function, const size_t line, const ExceptionType severity, const char *tag, const char *format,...)
MagickExport MagickBooleanType LogMagickEvent(const LogEventType type, const char *module, const char *function, const size_t line, const char *format,...)
MagickExport MagickBooleanType ListLocaleInfo(FILE *file, ExceptionInfo *exception)
MagickExport char ** GetLocaleList(const char *pattern, size_t *number_messages, ExceptionInfo *exception)
#define MagickLocaleExtent
MagickExport FatalErrorHandler SetFatalErrorHandler(FatalErrorHandler handler)
static SemaphoreInfo * locale_semaphore
static int LocaleInfoCompare(const void *x, const void *y)
MagickExport char * GetEnvironmentValue(const char *name)
MagickExport StringInfo * ConfigureFileToStringInfo(const char *filename)
MagickExport LinkedListInfo * NewLinkedList(const size_t capacity)
static void LocaleFatalErrorHandler(const ExceptionType magick_unused(severity), const char *reason, const char *description)
static SplayTreeInfo * locale_cache
MagickExport size_t CopyMagickString(char *destination, const char *source, const size_t length)
MagickExport const void * GetValueFromSplayTree(SplayTreeInfo *splay_tree, const void *key)
MagickExport const char * GetClientName(void)
MagickExport StringInfo * AcquireStringInfo(const size_t length)
MagickExport int LocaleCompare(const char *p, const char *q)
MagickExport LinkedListInfo * DestroyLocaleOptions(LinkedListInfo *messages)
#define GetMagickModule()
MagickExport int CompareSplayTreeString(const void *target, const void *source)
MagickExport const char * GetStringInfoPath(const StringInfo *string_info)
MagickExport void GetNextToken(const char *start, const char **end, const size_t extent, char *token)
MagickExport const char * GetLocaleMessage(const char *tag)
MagickPrivate MagickBooleanType LocaleComponentGenesis(void)
MagickExport void SetStringInfoLength(StringInfo *string_info, const size_t length)
MagickExport char * DestroyString(char *string)
MagickExport void ActivateSemaphoreInfo(SemaphoreInfo **semaphore_info)
MagickExport const LocaleInfo * GetLocaleInfo_(const char *tag, ExceptionInfo *exception)
MagickExport void ResetSplayTreeIterator(SplayTreeInfo *splay_tree)
MagickExport void * RelinquishMagickMemory(void *memory)
#define magick_unreferenced(x)
MagickExport size_t GetNumberOfNodesInSplayTree(const SplayTreeInfo *splay_tree)
static MagickBooleanType IsLocaleTreeInstantiated(ExceptionInfo *)
MagickExport const char * GetLocaleValue(const LocaleInfo *locale_info)
MagickPrivate char * FileToXML(const char *, const size_t)
MagickBooleanType stealth
MagickExport const LocaleInfo ** GetLocaleInfoList(const char *pattern, size_t *number_messages, ExceptionInfo *exception)
MagickExport void RelinquishSemaphoreInfo(SemaphoreInfo **semaphore_info)
MagickExport void LocaleUpper(char *string)
MagickExport char * ConstantString(const char *source)
MagickExport void SetStringInfoDatum(StringInfo *string_info, const unsigned char *source)
MagickExport ExceptionInfo * DestroyExceptionInfo(ExceptionInfo *exception)
MagickExport double InterpretLocaleValue(const char *magick_restrict string, char **magick_restrict sentinal)