MagickCore 7.0.10
locale.c
Go to the documentation of this file.
1/*
2%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3% %
4% %
5% %
6% L OOO CCCC AAA L EEEEE %
7% L O O C A A L E %
8% L O O C AAAAA L EEE %
9% L O O C A A L E %
10% LLLLL OOO CCCC A A LLLLL EEEEE %
11% %
12% %
13% WizardsToolkit Locale Methods %
14% %
15% Software Design %
16% Cristy %
17% July 2003 %
18% %
19% %
20% Copyright @ 1999 ImageMagick Studio LLC, a non-profit organization %
21% dedicated to making software imaging solutions freely available. %
22% %
23% You may not use this file except in compliance with the License. You may %
24% obtain a copy of the License at %
25% %
26% https://imagemagick.org/script/license.php %
27% %
28% Unless required by applicable law or agreed to in writing, software %
29% distributed under the License is distributed on an "AS IS" BASIS, %
30% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. %
31% See the License for the specific language governing permissions and %
32% limitations under the License. %
33% %
34%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
35%
36%
37*/
38
39/*
40 Include declarations.
41*/
42#include "wizard/studio.h"
43#include "wizard/blob.h"
44#include "wizard/client.h"
45#include "wizard/configure.h"
46#include "wizard/exception.h"
48#include "wizard/hashmap.h"
49#include "wizard/locale_.h"
50#include "wizard/log.h"
51#include "wizard/memory_.h"
52#include "wizard/nt-base.h"
53#include "wizard/semaphore.h"
54#include "wizard/splay-tree.h"
55#include "wizard/string_.h"
56#include "wizard/token.h"
57#include "wizard/utility.h"
59#include "wizard/xml-tree.h"
61
62/*
63 Define declarations.
64*/
65#if defined(WIZARDSTOOLKIT_HAVE_NEWLOCALE) || defined(WIZARDSTOOLKIT_WINDOWS_SUPPORT)
66# define WIZARDSTOOLKIT_LOCALE_SUPPORT
67#endif
68#define LocaleFilename "locale.xml"
69#define MaxRecursionDepth 200
70
71/*
72 Static declarations.
73*/
74static const char
76 "<?xml version=\"1.0\"?>"
77 "<localemap>"
78 " <locale name=\"C\">"
79 " <Exception>"
80 " <Message name=\"\">"
81 " </Message>"
82 " </Exception>"
83 " </locale>"
84 "</localemap>";
85
86static SemaphoreInfo
88
89static SplayTreeInfo
91
92#if defined(WIZARDSTOOLKIT_LOCALE_SUPPORT)
93static volatile locale_t
94 c_locale = (locale_t) NULL;
95#endif
96
97/*
98 Forward declarations.
99*/
102 LoadLocaleCache(SplayTreeInfo *,const char *,const char *,const char *,
103 const size_t,ExceptionInfo *);
104
105#if defined(WIZARDSTOOLKIT_LOCALE_SUPPORT)
106/*
107%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
108% %
109% %
110% %
111+ A c q u i r e C L o c a l e %
112% %
113% %
114% %
115%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
116%
117% AcquireCLocale() allocates the C locale object, or (locale_t) 0 with
118% errno set if it cannot be acquired.
119%
120% The format of the AcquireCLocale method is:
121%
122% locale_t AcquireCLocale(void)
123%
124*/
125static locale_t AcquireCLocale(void)
126{
127#if defined(WIZARDSTOOLKIT_HAVE_NEWLOCALE)
128 if (c_locale == (locale_t) NULL)
129 c_locale=newlocale(LC_ALL_MASK,"C",(locale_t) 0);
130#elif defined(WIZARDSTOOLKIT_WINDOWS_SUPPORT) && !defined(__MINGW32__)
131 if (c_locale == (locale_t) NULL)
132 c_locale=_create_locale(LC_ALL,"C");
133#endif
134 return(c_locale);
135}
136#endif
137
138/*
139%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
140% %
141% %
142% %
143% A c q u i r e L o c a l e S p l a y T r e e %
144% %
145% %
146% %
147%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
148%
149% AcquireLocaleSplayTree() caches one or more locale configurations which
150% provides a mapping between locale attributes and a locale tag.
151%
152% The format of the AcquireLocaleSplayTree method is:
153%
154% SplayTreeInfo *AcquireLocaleSplayTree(const char *filename,
155% ExceptionInfo *exception)
156%
157% A description of each parameter follows:
158%
159% o filename: the font file tag.
160%
161% o locale: the actual locale.
162%
163% o exception: return any errors or warnings in this structure.
164%
165*/
166
167static void *DestroyLocaleNode(void *locale_info)
168{
170 *p;
171
172 p=(LocaleInfo *) locale_info;
173 if (p->path != (char *) NULL)
174 p->path=DestroyString(p->path);
175 if (p->tag != (char *) NULL)
176 p->tag=DestroyString(p->tag);
177 if (p->message != (char *) NULL)
179 return(RelinquishWizardMemory(p));
180}
181
182static SplayTreeInfo *AcquireLocaleSplayTree(const char *filename,
183 const char *locale,ExceptionInfo *exception)
184{
186 status;
187
190
191 locale_cache=NewSplayTree(CompareSplayTreeString,(void *(*)(void *)) NULL,
193 if (locale_cache == (SplayTreeInfo *) NULL)
194 ThrowFatalException(ResourceFatalError,"memory allocation failed `%s'");
195 status=WizardTrue;
196#if !defined(WIZARDSTOOLKIT_ZERO_CONFIGURATION_SUPPORT)
197 {
198 const StringInfo
199 *option;
200
202 *options;
203
204 options=GetLocaleOptions(filename,exception);
205 option=(const StringInfo *) GetNextValueInLinkedList(options);
206 while (option != (const StringInfo *) NULL)
207 {
208 status&=LoadLocaleCache(locale_cache,(const char *)
209 GetStringInfoDatum(option),GetStringInfoPath(option),locale,0,
210 exception);
211 option=(const StringInfo *) GetNextValueInLinkedList(options);
212 }
213 options=DestroyLocaleOptions(options);
215 {
216 options=GetLocaleOptions("english.xml",exception);
217 option=(const StringInfo *) GetNextValueInLinkedList(options);
218 while (option != (const StringInfo *) NULL)
219 {
220 status&=LoadLocaleCache(locale_cache,(const char *)
221 GetStringInfoDatum(option),GetStringInfoPath(option),locale,0,
222 exception);
223 option=(const StringInfo *) GetNextValueInLinkedList(options);
224 }
225 options=DestroyLocaleOptions(options);
226 }
227 }
228#endif
230 status&=LoadLocaleCache(locale_cache,LocaleMap,"built-in",locale,0,
231 exception);
232 return(locale_cache);
233}
234
235#if defined(WIZARDSTOOLKIT_LOCALE_SUPPORT)
236/*
237%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
238% %
239% %
240% %
241+ D e s t r o y C L o c a l e %
242% %
243% %
244% %
245%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
246%
247% DestroyCLocale() releases the resources allocated for a locale object
248% returned by a call to the AcquireCLocale() method.
249%
250% The format of the DestroyCLocale method is:
251%
252% void DestroyCLocale(void)
253%
254*/
255static void DestroyCLocale(void)
256{
257 if (c_locale != (locale_t) NULL)
258 freelocale(c_locale);
259 c_locale=(locale_t) NULL;
260}
261#endif
262
263/*
264%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
265% %
266% %
267% %
268% D e s t r o y L o c a l e O p t i o n s %
269% %
270% %
271% %
272%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
273%
274% DestroyLocaleOptions() releases memory associated with an locale
275% messages.
276%
277% The format of the DestroyProfiles method is:
278%
279% LinkedListInfo *DestroyLocaleOptions(Image *image)
280%
281% A description of each parameter follows:
282%
283% o image: the image.
284%
285*/
286
287static void *DestroyOptions(void *message)
288{
289 return(DestroyStringInfo((StringInfo *) message));
290}
291
293{
294 assert(messages != (LinkedListInfo *) NULL);
296 return(DestroyLinkedList(messages,DestroyOptions));
297}
298
299/*
300%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
301% %
302% %
303% %
304+ F o r m a t L o c a l e F i l e %
305% %
306% %
307% %
308%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
309%
310% FormatLocaleFile() prints formatted output of a variable argument list to a
311% file in the "C" locale.
312%
313% The format of the FormatLocaleFile method is:
314%
315% ssize_t FormatLocaleFile(FILE *file,const char *format,...)
316%
317% A description of each parameter follows.
318%
319% o file: the file.
320%
321% o format: A file describing the format to use to write the remaining
322% arguments.
323%
324*/
325
326WizardExport ssize_t FormatLocaleFileList(FILE *file,const char *format,
327 va_list operands)
328{
329 ssize_t
330 n;
331
332#if defined(WIZARDSTOOLKIT_LOCALE_SUPPORT) && defined(WIZARDSTOOLKIT_HAVE_VFPRINTF_L)
333 {
334 locale_t
335 locale;
336
337 locale=AcquireCLocale();
338 if (locale == (locale_t) NULL)
339 n=(ssize_t) vfprintf(file,format,operands);
340 else
341#if defined(WIZARDSTOOLKIT_WINDOWS_SUPPORT)
342 n=(ssize_t) vfprintf_l(file,format,locale,operands);
343#else
344 n=(ssize_t) vfprintf_l(file,locale,format,operands);
345#endif
346 }
347#else
348#if defined(WIZARDSTOOLKIT_LOCALE_SUPPORT) && defined(WIZARDSTOOLKIT_HAVE_USELOCALE)
349 {
350 locale_t
351 locale,
352 previous_locale;
353
354 locale=AcquireCLocale();
355 if (locale == (locale_t) NULL)
356 n=(ssize_t) vfprintf(file,format,operands);
357 else
358 {
359 previous_locale=uselocale(locale);
360 n=(ssize_t) vfprintf(file,format,operands);
361 uselocale(previous_locale);
362 }
363 }
364#else
365 n=(ssize_t) vfprintf(file,format,operands);
366#endif
367#endif
368 return(n);
369}
370
371WizardExport ssize_t FormatLocaleFile(FILE *file,const char *format,...)
372{
373 ssize_t
374 n;
375
376 va_list
377 operands;
378
379 va_start(operands,format);
380 n=FormatLocaleFileList(file,format,operands);
381 va_end(operands);
382 return(n);
383}
384
385/*
386%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
387% %
388% %
389% %
390+ F o r m a t L o c a l e S t r i n g %
391% %
392% %
393% %
394%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
395%
396% FormatLocaleString() prints formatted output of a variable argument list to
397% a string buffer in the "C" locale.
398%
399% The format of the FormatLocaleString method is:
400%
401% ssize_t FormatLocaleString(char *string,const size_t length,
402% const char *format,...)
403%
404% A description of each parameter follows.
405%
406% o string: FormatLocaleString() returns the formatted string in this
407% character buffer.
408%
409% o length: the maximum length of the string.
410%
411% o format: A string describing the format to use to write the remaining
412% arguments.
413%
414*/
415
416WizardExport ssize_t FormatLocaleStringList(char *string,const size_t length,
417 const char *format,va_list operands)
418{
419 ssize_t
420 n;
421
422#if defined(WIZARDSTOOLKIT_LOCALE_SUPPORT) && defined(WIZARDSTOOLKIT_HAVE_VSNPRINTF_L)
423 {
424 locale_t
425 locale;
426
427 locale=AcquireCLocale();
428 if (locale == (locale_t) NULL)
429 n=(ssize_t) vsnprintf(string,length,format,operands);
430 else
431#if defined(WIZARDSTOOLKIT_WINDOWS_SUPPORT)
432 n=(ssize_t) vsnprintf_l(string,length,format,locale,operands);
433#else
434 n=(ssize_t) vsnprintf_l(string,length,locale,format,operands);
435#endif
436 }
437#elif defined(WIZARDSTOOLKIT_HAVE_VSNPRINTF)
438#if defined(WIZARDSTOOLKIT_LOCALE_SUPPORT) && defined(WIZARDSTOOLKIT_HAVE_USELOCALE)
439 {
440 locale_t
441 locale,
442 previous_locale;
443
444 locale=AcquireCLocale();
445 if (locale == (locale_t) NULL)
446 n=(ssize_t) vsnprintf(string,length,format,operands);
447 else
448 {
449 previous_locale=uselocale(locale);
450 n=(ssize_t) vsnprintf(string,length,format,operands);
451 uselocale(previous_locale);
452 }
453 }
454#else
455 n=(ssize_t) vsnprintf(string,length,format,operands);
456#endif
457#else
458 n=(ssize_t) vsprintf(string,format,operands);
459#endif
460 if (n < 0)
461 string[length-1]='\0';
462 return(n);
463}
464
465WizardExport ssize_t FormatLocaleString(char *string,const size_t length,
466 const char *format,...)
467{
468 ssize_t
469 n;
470
471 va_list
472 operands;
473
474 va_start(operands,format);
475 n=FormatLocaleStringList(string,length,format,operands);
476 va_end(operands);
477 return(n);
478}
479
480/*
481%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
482% %
483% %
484% %
485+ G e t L o c a l e I n f o _ %
486% %
487% %
488% %
489%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
490%
491% GetLocaleInfo_() searches the locale list for the specified tag and if
492% found returns attributes for that element.
493%
494% The format of the GetLocaleInfo method is:
495%
496% const LocaleInfo *GetLocaleInfo_(const char *tag,
497% ExceptionInfo *exception)
498%
499% A description of each parameter follows:
500%
501% o tag: the locale tag.
502%
503% o exception: return any errors or warnings in this structure.
504%
505*/
507 ExceptionInfo *exception)
508{
509 const LocaleInfo
510 *locale_info;
511
512 assert(exception != (ExceptionInfo *) NULL);
513 if (IsLocaleTreeInstantiated(exception) == WizardFalse)
514 return((const LocaleInfo *) NULL);
516 if ((tag == (const char *) NULL) || (LocaleCompare(tag,"*") == 0))
517 {
519 locale_info=(const LocaleInfo *) GetNextValueInSplayTree(locale_cache);
521 return(locale_info);
522 }
523 locale_info=(const LocaleInfo *) GetValueFromSplayTree(locale_cache,tag);
525 return(locale_info);
526}
527
528/*
529%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
530% %
531% %
532% %
533% G e t L o c a l e I n f o L i s t %
534% %
535% %
536% %
537%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
538%
539% GetLocaleInfoList() returns any locale messages that match the
540% specified pattern.
541%
542% The format of the GetLocaleInfoList function is:
543%
544% const LocaleInfo **GetLocaleInfoList(const char *pattern,
545% size_t *number_messages,ExceptionInfo *exception)
546%
547% A description of each parameter follows:
548%
549% o pattern: Specifies a pointer to a text string containing a pattern.
550%
551% o number_messages: This integer returns the number of locale messages in
552% the list.
553%
554% o exception: return any errors or warnings in this structure.
555%
556*/
557
558#if defined(__cplusplus) || defined(c_plusplus)
559extern "C" {
560#endif
561
562static int LocaleInfoCompare(const void *x,const void *y)
563{
564 const LocaleInfo
565 **p,
566 **q;
567
568 p=(const LocaleInfo **) x,
569 q=(const LocaleInfo **) y;
570 if (LocaleCompare((*p)->path,(*q)->path) == 0)
571 return(LocaleCompare((*p)->tag,(*q)->tag));
572 return(LocaleCompare((*p)->path,(*q)->path));
573}
574
575#if defined(__cplusplus) || defined(c_plusplus)
576}
577#endif
578
579WizardExport const LocaleInfo **GetLocaleInfoList(const char *pattern,
580 size_t *number_messages,ExceptionInfo *exception)
581{
582 const LocaleInfo
583 **messages;
584
585 const LocaleInfo
586 *p;
587
588 ssize_t
589 i;
590
591 /*
592 Allocate locale list.
593 */
594 assert(pattern != (char *) NULL);
595 (void) LogWizardEvent(TraceEvent,GetWizardModule(),"%s",pattern);
596 assert(number_messages != (size_t *) NULL);
597 *number_messages=0;
598 p=GetLocaleInfo_("*",exception);
599 if (p == (const LocaleInfo *) NULL)
600 return((const LocaleInfo **) NULL);
601 messages=(const LocaleInfo **) AcquireQuantumMemory((size_t)
602 GetNumberOfNodesInSplayTree(locale_cache)+1UL,sizeof(*messages));
603 if (messages == (const LocaleInfo **) NULL)
604 return((const LocaleInfo **) NULL);
605 /*
606 Generate locale list.
607 */
611 for (i=0; p != (const LocaleInfo *) NULL; )
612 {
613 if ((p->stealth == WizardFalse) &&
614 (GlobExpression(p->tag,pattern,WizardTrue) != WizardFalse))
615 messages[i++]=p;
617 }
619 qsort((void *) messages,(size_t) i,sizeof(*messages),LocaleInfoCompare);
620 messages[i]=(LocaleInfo *) NULL;
621 *number_messages=(size_t) i;
622 return(messages);
623}
624
625/*
626%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
627% %
628% %
629% %
630% G e t L o c a l e L i s t %
631% %
632% %
633% %
634%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
635%
636% GetLocaleList() returns any locale messages that match the specified
637% pattern.
638%
639% The format of the GetLocaleList function is:
640%
641% char **GetLocaleList(const char *pattern,size_t *number_messages,
642% Exceptioninfo *exception)
643%
644% A description of each parameter follows:
645%
646% o pattern: Specifies a pointer to a text string containing a pattern.
647%
648% o number_messages: This integer returns the number of messages in the
649% list.
650%
651% o exception: return any errors or warnings in this structure.
652%
653*/
654
655#if defined(__cplusplus) || defined(c_plusplus)
656extern "C" {
657#endif
658
659static int LocaleTagCompare(const void *x,const void *y)
660{
661 char
662 **p,
663 **q;
664
665 p=(char **) x;
666 q=(char **) y;
667 return(LocaleCompare(*p,*q));
668}
669
670#if defined(__cplusplus) || defined(c_plusplus)
671}
672#endif
673
674WizardExport char **GetLocaleList(const char *pattern,
675 size_t *number_messages,ExceptionInfo *exception)
676{
677 char
678 **messages;
679
680 const LocaleInfo
681 *p;
682
683 ssize_t
684 i;
685
686 /*
687 Allocate locale list.
688 */
689 assert(pattern != (char *) NULL);
690 (void) LogWizardEvent(TraceEvent,GetWizardModule(),"%s",pattern);
691 assert(number_messages != (size_t *) NULL);
692 *number_messages=0;
693 p=GetLocaleInfo_("*",exception);
694 if (p == (const LocaleInfo *) NULL)
695 return((char **) NULL);
696 messages=(char **) AcquireQuantumMemory((size_t)
697 GetNumberOfNodesInSplayTree(locale_cache)+1UL,sizeof(*messages));
698 if (messages == (char **) NULL)
699 return((char **) NULL);
702 for (i=0; p != (const LocaleInfo *) NULL; )
703 {
704 if ((p->stealth == WizardFalse) &&
705 (GlobExpression(p->tag,pattern,WizardTrue) != WizardFalse))
706 messages[i++]=ConstantString(p->tag);
708 }
710 qsort((void *) messages,(size_t) i,sizeof(*messages),LocaleTagCompare);
711 messages[i]=(char *) NULL;
712 *number_messages=(size_t) i;
713 return(messages);
714}
715
716/*
717%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
718% %
719% %
720% %
721% G e t L o c a l e M e s s a g e %
722% %
723% %
724% %
725%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
726%
727% GetLocaleMessage() returns a message in the current locale that matches the
728% supplied tag.
729%
730% The format of the GetLocaleMessage method is:
731%
732% const char *GetLocaleMessage(const char *tag)
733%
734% A description of each parameter follows:
735%
736% o tag: Return a message that matches this tag in the current locale.
737%
738*/
739WizardExport const char *GetLocaleMessage(const char *tag)
740{
741 char
742 name[WizardLocaleExtent];
743
744 const LocaleInfo
745 *locale_info;
746
748 *exception;
749
750 if ((tag == (const char *) NULL) || (*tag == '\0'))
751 return(tag);
752 exception=AcquireExceptionInfo();
753 (void) FormatLocaleString(name,WizardLocaleExtent,"%s/",tag);
754 locale_info=GetLocaleInfo_(name,exception);
755 exception=DestroyExceptionInfo(exception);
756 if (locale_info != (const LocaleInfo *) NULL)
757 return(locale_info->message);
758 return(tag);
759}
760
761/*
762%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
763% %
764% %
765% %
766% G e t L o c a l e O p t i o n s %
767% %
768% %
769% %
770%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
771%
772% GetLocaleOptions() returns any Wizard configuration messages associated
773% with the specified filename.
774%
775% The format of the GetLocaleOptions method is:
776%
777% LinkedListInfo *GetLocaleOptions(const char *filename,
778% ExceptionInfo *exception)
779%
780% A description of each parameter follows:
781%
782% o filename: the locale file tag.
783%
784% o exception: return any errors or warnings in this structure.
785%
786*/
788 ExceptionInfo *exception)
789{
790 char
791 path[WizardPathExtent];
792
793 const char
794 *element;
795
797 *messages,
798 *paths;
799
801 *xml;
802
803 assert(filename != (const char *) NULL);
804 (void) LogWizardEvent(TraceEvent,GetWizardModule(),"%s",filename);
805 assert(exception != (ExceptionInfo *) NULL);
806 (void) CopyWizardString(path,filename,WizardPathExtent);
807 /*
808 Load XML from configuration files to linked-list.
809 */
810 messages=NewLinkedList(0);
811 paths=GetConfigurePaths(filename,exception);
812 if (paths != (LinkedListInfo *) NULL)
813 {
815 element=(const char *) GetNextValueInLinkedList(paths);
816 while (element != (const char *) NULL)
817 {
818 (void) FormatLocaleString(path,WizardPathExtent,"%s%s",element,
819 filename);
821 "Searching for locale file: \"%s\"",path);
823 if (xml != (StringInfo *) NULL)
824 (void) AppendValueToLinkedList(messages,xml);
825 element=(const char *) GetNextValueInLinkedList(paths);
826 }
828 }
829#if defined(WIZARDSTOOLKIT_WINDOWS_SUPPORT)
830 {
831 char
832 *blob;
833
834 blob=(char *) NTResourceToBlob(filename);
835 if (blob != (char *) NULL)
836 {
837 xml=AcquireStringInfo(0);
838 SetStringInfoLength(xml,strlen(blob)+1);
839 SetStringInfoDatum(xml,(unsigned char *) blob);
840 blob=(char *) RelinquishMagickMemory(blob);
841 SetStringInfoPath(xml,filename);
842 (void) AppendValueToLinkedList(messages,xml);
843 }
844 }
845#endif
846 ResetLinkedListIterator(messages);
847 return(messages);
848}
849
850/*
851%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
852% %
853% %
854% %
855% G e t L o c a l e V a l u e %
856% %
857% %
858% %
859%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
860%
861% GetLocaleValue() returns the message associated with the locale info.
862%
863% The format of the GetLocaleValue method is:
864%
865% const char *GetLocaleValue(const LocaleInfo *locale_info)
866%
867% A description of each parameter follows:
868%
869% o locale_info: The locale info.
870%
871*/
872WizardExport const char *GetLocaleValue(const LocaleInfo *locale_info)
873{
875 assert(locale_info != (LocaleInfo *) NULL);
876 assert(locale_info->signature == WizardSignature);
877 return(locale_info->message);
878}
879
880/*
881%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
882% %
883% %
884% %
885+ I s L o c a l e T r e e I n s t a n t i a t e d %
886% %
887% %
888% %
889%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
890%
891% IsLocaleTreeInstantiated() determines if the locale tree is instantiated.
892% If not, it instantiates the tree and returns it.
893%
894% The format of the IsLocaleInstantiated method is:
895%
896% WizardBooleanType IsLocaleTreeInstantiated(ExceptionInfo *exception)
897%
898% A description of each parameter follows.
899%
900% o exception: return any errors or warnings in this structure.
901%
902*/
904{
905 if (locale_cache == (SplayTreeInfo *) NULL)
906 {
907 if (locale_semaphore == (SemaphoreInfo *) NULL)
910 if (locale_cache == (SplayTreeInfo *) NULL)
911 {
912 char
913 *locale;
914
915 const char
916 *p;
917
918 locale=(char *) NULL;
919 p=setlocale(LC_CTYPE,(const char *) NULL);
920 if (p != (const char *) NULL)
921 locale=ConstantString(p);
922 if (locale == (char *) NULL)
923 locale=GetEnvironmentValue("LC_ALL");
924 if (locale == (char *) NULL)
925 locale=GetEnvironmentValue("LC_MESSAGES");
926 if (locale == (char *) NULL)
927 locale=GetEnvironmentValue("LC_CTYPE");
928 if (locale == (char *) NULL)
929 locale=GetEnvironmentValue("LANG");
930 if (locale == (char *) NULL)
931 locale=ConstantString("C");
933 locale=DestroyString(locale);
934 }
936 }
937 return(locale_cache != (SplayTreeInfo *) NULL ? WizardTrue : WizardFalse);
938}
939
940/*
941%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
942% %
943% %
944% %
945+ I n t e r p r e t L o c a l e V a l u e %
946% %
947% %
948% %
949%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
950%
951% InterpretLocaleValue() interprets the string as a floating point number in
952% the "C" locale and returns its value as a double. If sentinal is not a null
953% pointer, the method also sets the value pointed by sentinal to point to the
954% first character after the number.
955%
956% The format of the InterpretLocaleValue method is:
957%
958% double InterpretLocaleValue(const char *value,char **sentinal)
959%
960% A description of each parameter follows:
961%
962% o value: the string value.
963%
964% o sentinal: if sentinal is not NULL, a pointer to the character after the
965% last character used in the conversion is stored in the location
966% referenced by sentinal.
967%
968*/
969WizardExport double InterpretLocaleValue(const char *string,char **sentinal)
970{
971 char
972 *q;
973
974 double
975 value;
976
977 if ((*string == '0') && ((string[1] | 0x20)=='x'))
978 value=(double) strtoul(string,&q,16);
979 else
980 {
981#if defined(WIZARDSTOOLKIT_LOCALE_SUPPORT) && defined(WIZARDSTOOLKIT_HAVE_STRTOD_L)
982 locale_t
983 locale;
984
985 locale=AcquireCLocale();
986 if (locale == (locale_t) NULL)
987 value=strtod(string,&q);
988 else
989 value=strtod_l(string,&q,locale);
990#else
991 value=strtod(string,&q);
992#endif
993 }
994 if (sentinal != (char **) NULL)
995 *sentinal=q;
996 return(value);
997}
998
999/*
1000%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1001% %
1002% %
1003% %
1004% L i s t L o c a l e I n f o %
1005% %
1006% %
1007% %
1008%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1009%
1010% ListLocaleInfo() lists the locale info to a file.
1011%
1012% The format of the ListLocaleInfo method is:
1013%
1014% WizardBooleanType ListLocaleInfo(FILE *file,ExceptionInfo *exception)
1015%
1016% A description of each parameter follows.
1017%
1018% o file: An pointer to a FILE.
1019%
1020% o exception: return any errors or warnings in this structure.
1021%
1022*/
1024 ExceptionInfo *exception)
1025{
1026 const char
1027 *path;
1028
1029 const LocaleInfo
1030 **locale_info;
1031
1032 ssize_t
1033 i;
1034
1035 size_t
1036 number_messages;
1037
1038 if (file == (const FILE *) NULL)
1039 file=stdout;
1040 number_messages=0;
1041 locale_info=GetLocaleInfoList("*",&number_messages,exception);
1042 if (locale_info == (const LocaleInfo **) NULL)
1043 return(WizardFalse);
1044 path=(const char *) NULL;
1045 for (i=0; i < (ssize_t) number_messages; i++)
1046 {
1047 if (locale_info[i]->stealth != WizardFalse)
1048 continue;
1049 if ((path == (const char *) NULL) ||
1050 (LocaleCompare(path,locale_info[i]->path) != 0))
1051 {
1052 if (locale_info[i]->path != (char *) NULL)
1053 (void) FormatLocaleFile(file,"\nPath: %s\n\n",locale_info[i]->path);
1054 (void) FormatLocaleFile(file,"Tag/Message\n");
1055 (void) FormatLocaleFile(file,
1056 "-------------------------------------------------"
1057 "------------------------------\n");
1058 }
1059 path=locale_info[i]->path;
1060 (void) FormatLocaleFile(file,"%s\n",locale_info[i]->tag);
1061 if (locale_info[i]->message != (char *) NULL)
1062 (void) FormatLocaleFile(file," %s",locale_info[i]->message);
1063 (void) FormatLocaleFile(file,"\n");
1064 }
1065 (void) fflush(file);
1066 locale_info=(const LocaleInfo **)
1067 RelinquishWizardMemory((void *) locale_info);
1068 return(WizardTrue);
1069}
1070
1071/*
1072%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1073% %
1074% %
1075% %
1076+ L o a d L o c a l e L i s t %
1077% %
1078% %
1079% %
1080%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1081%
1082% LoadLocaleCache() loads the locale configurations which provides a mapping
1083% between locale attributes and a locale name.
1084%
1085% The format of the LoadLocaleCache method is:
1086%
1087% WizardBooleanType LoadLocaleCache(SplayTreeInfo *locale_cache,
1088% const char *xml,const char *filename,const size_t depth,
1089% ExceptionInfo *exception)
1090%
1091% A description of each parameter follows:
1092%
1093% o xml: The locale list in XML format.
1094%
1095% o filename: The locale list filename.
1096%
1097% o depth: depth of <include /> statements.
1098%
1099% o exception: return any errors or warnings in this structure.
1100%
1101*/
1102
1103static void ChopLocaleComponents(char *path,const size_t components)
1104{
1105 char
1106 *p;
1107
1108 ssize_t
1109 count;
1110
1111 if (*path == '\0')
1112 return;
1113 p=path+strlen(path)-1;
1114 if (*p == '/')
1115 *p='\0';
1116 for (count=0; (count < (ssize_t) components) && (p > path); p--)
1117 if (*p == '/')
1118 {
1119 *p='\0';
1120 count++;
1121 }
1122 if (count < (ssize_t) components)
1123 *path='\0';
1124}
1125
1127 const ExceptionType wizard_unused(severity),
1128 const char *reason,const char *description)
1129{
1130 wizard_unreferenced(severity);
1131
1132 if (reason == (char *) NULL)
1133 return;
1134 (void) FormatLocaleFile(stderr,"%s: %s",GetClientName(),reason);
1135 if (description != (char *) NULL)
1136 (void) FormatLocaleFile(stderr," (%s)",description);
1137 (void) FormatLocaleFile(stderr,".\n");
1138 (void) fflush(stderr);
1139 exit(1);
1140}
1141
1143 const char *xml,const char *filename,const char *locale,const size_t depth,
1144 ExceptionInfo *exception)
1145{
1146 char
1147 keyword[WizardLocaleExtent],
1148 message[WizardLocaleExtent],
1149 tag[WizardLocaleExtent],
1150 *token;
1151
1152 const char
1153 *q;
1154
1156 fatal_handler;
1157
1159 *locale_info;
1160
1161 char
1162 *p;
1163
1164 size_t
1165 extent;
1166
1168 status;
1169
1170 /*
1171 Read the locale configure file.
1172 */
1174 "Loading locale configure file \"%s\" ...",filename);
1175 if (xml == (const char *) NULL)
1176 return(WizardFalse);
1177 status=WizardTrue;
1178 locale_info=(LocaleInfo *) NULL;
1179 *tag='\0';
1180 *message='\0';
1181 *keyword='\0';
1183 token=AcquireString(xml);
1184 extent=strlen(token)+WizardPathExtent;
1185 for (q=(char *) xml; *q != '\0'; )
1186 {
1187 /*
1188 Interpret XML.
1189 */
1190 GetNextToken(q,&q,extent,token);
1191 if (*token == '\0')
1192 break;
1193 (void) CopyWizardString(keyword,token,WizardLocaleExtent);
1194 if (LocaleNCompare(keyword,"<!DOCTYPE",9) == 0)
1195 {
1196 /*
1197 Doctype element.
1198 */
1199 while ((LocaleNCompare(q,"]>",2) != 0) && (*q != '\0'))
1200 {
1201 GetNextToken(q,&q,extent,token);
1202 while (isspace((int) ((unsigned char) *q)) != 0)
1203 q++;
1204 }
1205 continue;
1206 }
1207 if (LocaleNCompare(keyword,"<!--",4) == 0)
1208 {
1209 /*
1210 Comment element.
1211 */
1212 while ((LocaleNCompare(q,"->",2) != 0) && (*q != '\0'))
1213 {
1214 GetNextToken(q,&q,extent,token);
1215 while (isspace((int) ((unsigned char) *q)) != 0)
1216 q++;
1217 }
1218 continue;
1219 }
1220 if (LocaleCompare(keyword,"<include") == 0)
1221 {
1222 /*
1223 Include element.
1224 */
1225 while (((*token != '/') && (*(token+1) != '>')) && (*q != '\0'))
1226 {
1227 (void) CopyWizardString(keyword,token,WizardLocaleExtent);
1228 GetNextToken(q,&q,extent,token);
1229 if (*token != '=')
1230 continue;
1231 GetNextToken(q,&q,extent,token);
1232 if (LocaleCompare(keyword,"locale") == 0)
1233 {
1234 if (LocaleCompare(locale,token) != 0)
1235 break;
1236 continue;
1237 }
1238 if (LocaleCompare(keyword,"file") == 0)
1239 {
1240 if (depth > 200)
1241 (void) ThrowWizardException(exception,GetWizardModule(),
1242 ConfigureError,"include element nested too deeply: `%s'",
1243 token);
1244 else
1245 {
1246 char
1247 path[WizardPathExtent],
1248 *xml;
1249
1250 *path='\0';
1251 GetPathComponent(filename,HeadPath,path);
1252 if (*path != '\0')
1255 if (*token == *DirectorySeparator)
1256 (void) CopyWizardString(path,token,WizardPathExtent);
1257 else
1258 (void) ConcatenateWizardString(path,token,WizardPathExtent);
1259 xml=FileToXML(path,~0UL);
1260 if (xml != (char *) NULL)
1261 {
1262 status&=LoadLocaleCache(locale_cache,xml,path,locale,
1263 depth+1,exception);
1264 xml=(char *) RelinquishWizardMemory(xml);
1265 }
1266 }
1267 }
1268 }
1269 continue;
1270 }
1271 if (LocaleCompare(keyword,"<locale") == 0)
1272 {
1273 /*
1274 Locale element.
1275 */
1276 while ((*token != '>') && (*q != '\0'))
1277 {
1278 (void) CopyWizardString(keyword,token,WizardLocaleExtent);
1279 GetNextToken(q,&q,extent,token);
1280 if (*token != '=')
1281 continue;
1282 GetNextToken(q,&q,extent,token);
1283 }
1284 continue;
1285 }
1286 if (LocaleCompare(keyword,"</locale>") == 0)
1287 {
1288 ChopLocaleComponents(tag,1);
1290 continue;
1291 }
1292 if (LocaleCompare(keyword,"<localemap>") == 0)
1293 continue;
1294 if (LocaleCompare(keyword,"</localemap>") == 0)
1295 continue;
1296 if (LocaleCompare(keyword,"<message") == 0)
1297 {
1298 /*
1299 Message element.
1300 */
1301 while ((*token != '>') && (*q != '\0'))
1302 {
1303 (void) CopyWizardString(keyword,token,WizardLocaleExtent);
1304 GetNextToken(q,&q,extent,token);
1305 if (*token != '=')
1306 continue;
1307 GetNextToken(q,&q,extent,token);
1308 if (LocaleCompare(keyword,"name") == 0)
1309 {
1312 }
1313 }
1314 for (p=(char *) q; (*q != '<') && (*q != '\0'); q++) ;
1315 while (isspace((int) ((unsigned char) *p)) != 0)
1316 p++;
1317 q--;
1318 while ((isspace((int) ((unsigned char) *q)) != 0) && (q > p))
1319 q--;
1320 (void) CopyWizardString(message,p,WizardMin(q-p+2,WizardLocaleExtent));
1321 locale_info=(LocaleInfo *) AcquireWizardMemory(sizeof(*locale_info));
1322 if (locale_info == (LocaleInfo *) NULL)
1324 "memory allocation failed `%s'");
1325 (void) memset(locale_info,0,sizeof(*locale_info));
1326 locale_info->path=ConstantString(filename);
1327 locale_info->tag=ConstantString(tag);
1328 locale_info->message=ConstantString(message);
1329 locale_info->signature=WizardSignature;
1330 status=AddValueToSplayTree(locale_cache,locale_info->tag,locale_info);
1331 if (status == WizardFalse)
1333 "memory allocation failed `%s'");
1334 (void) ConcatenateWizardString(tag,message,WizardLocaleExtent);
1336 q++;
1337 continue;
1338 }
1339 if (LocaleCompare(keyword,"</message>") == 0)
1340 {
1341 ChopLocaleComponents(tag,2);
1343 continue;
1344 }
1345 if (*keyword == '<')
1346 {
1347 /*
1348 Subpath element.
1349 */
1350 if (*(keyword+1) == '?')
1351 continue;
1352 if (*(keyword+1) == '/')
1353 {
1354 ChopLocaleComponents(tag,1);
1355 if (*tag != '\0')
1357 continue;
1358 }
1359 token[strlen(token)-1]='\0';
1360 (void) CopyWizardString(token,token+1,WizardLocaleExtent);
1363 continue;
1364 }
1365 GetNextToken(q,(const char **) NULL,extent,token);
1366 if (*token != '=')
1367 continue;
1368 }
1369 token=(char *) RelinquishWizardMemory(token);
1370 (void) SetFatalErrorHandler(fatal_handler);
1371 return(status != 0 ? WizardTrue : WizardFalse);
1372}
1373
1374/*
1375%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1376% %
1377% %
1378% %
1379+ L o c a l e C o m p o n e n t G e n e s i s %
1380% %
1381% %
1382% %
1383%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1384%
1385% LocaleComponentGenesis() instantiates the locale component.
1386%
1387% The format of the LocaleComponentGenesis method is:
1388%
1389% WizardBooleanType LocaleComponentGenesis(void)
1390%
1391*/
1393{
1394 if (locale_semaphore == (SemaphoreInfo *) NULL)
1396#if defined(WIZARDSTOOLKIT_LOCALE_SUPPORT)
1397 (void) AcquireCLocale();
1398#endif
1399 return(WizardTrue);
1400}
1401
1402/*
1403%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1404% %
1405% %
1406% %
1407+ L o c a l e C o m p o n e n t T e r m i n u s %
1408% %
1409% %
1410% %
1411%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1412%
1413% LocaleComponentTerminus() destroys the locale component.
1414%
1415% The format of the LocaleComponentTerminus method is:
1416%
1417% LocaleComponentTerminus(void)
1418%
1419*/
1421{
1422 if (locale_semaphore == (SemaphoreInfo *) NULL)
1425 if (locale_cache != (SplayTreeInfo *) NULL)
1427#if defined(WIZARDSTOOLKIT_LOCALE_SUPPORT)
1428 DestroyCLocale();
1429#endif
1432}
WizardExport const char * GetClientName(void)
Definition client.c:64
WizardExport LinkedListInfo * GetConfigurePaths(const char *filename, ExceptionInfo *exception)
Definition configure.c:675
#define ThrowFatalException(severity, tag)
WizardExport ExceptionInfo * AcquireExceptionInfo(void)
Definition exception.c:125
WizardExport ExceptionInfo * DestroyExceptionInfo(ExceptionInfo *exception)
Definition exception.c:399
WizardExport WizardBooleanType ThrowWizardException(ExceptionInfo *exception, const char *module, const char *function, const size_t line, const ExceptionType severity, const char *format,...)
Definition exception.c:1029
WizardExport FatalErrorHandler SetFatalErrorHandler(FatalErrorHandler handler)
Definition exception.c:846
ExceptionType
Definition exception.h:60
@ ResourceFatalError
Definition exception.h:121
@ ConfigureError
Definition exception.h:88
void(* FatalErrorHandler)(const ExceptionType, const char *, const char *)
Definition exception.h:131
WizardExport void ResetLinkedListIterator(LinkedListInfo *list_info)
Definition hashmap.c:1919
WizardExport WizardBooleanType AppendValueToLinkedList(LinkedListInfo *list_info, const void *value)
Definition hashmap.c:149
WizardExport LinkedListInfo * NewLinkedList(const size_t capacity)
Definition hashmap.c:1362
WizardExport void * GetNextValueInLinkedList(LinkedListInfo *list_info)
Definition hashmap.c:605
WizardExport LinkedListInfo * DestroyLinkedList(LinkedListInfo *list_info, void *(*relinquish_value)(void *))
Definition hashmap.c:397
static WizardBooleanType LoadLocaleCache(SplayTreeInfo *, const char *, const char *, const char *, const size_t, ExceptionInfo *)
Definition locale.c:1142
static WizardBooleanType IsLocaleTreeInstantiated(ExceptionInfo *)
Definition locale.c:903
WizardExport char ** GetLocaleList(const char *pattern, size_t *number_messages, ExceptionInfo *exception)
Definition locale.c:674
static void * DestroyLocaleNode(void *locale_info)
Definition locale.c:167
static void * DestroyOptions(void *message)
Definition locale.c:287
static SplayTreeInfo * AcquireLocaleSplayTree(const char *filename, const char *locale, ExceptionInfo *exception)
Definition locale.c:182
WizardExport ssize_t FormatLocaleFile(FILE *file, const char *format,...)
Definition locale.c:371
static void ChopLocaleComponents(char *path, const size_t components)
Definition locale.c:1103
WizardExport ssize_t FormatLocaleStringList(char *string, const size_t length, const char *format, va_list operands)
Definition locale.c:416
WizardExport const LocaleInfo * GetLocaleInfo_(const char *tag, ExceptionInfo *exception)
Definition locale.c:506
static void LocaleFatalErrorHandler(const ExceptionType wizard_unused(severity), const char *reason, const char *description)
Definition locale.c:1126
WizardExport ssize_t FormatLocaleFileList(FILE *file, const char *format, va_list operands)
Definition locale.c:326
WizardExport LinkedListInfo * DestroyLocaleOptions(LinkedListInfo *messages)
Definition locale.c:292
static int LocaleTagCompare(const void *x, const void *y)
Definition locale.c:659
static SplayTreeInfo * locale_cache
Definition locale.c:90
WizardExport double InterpretLocaleValue(const char *string, char **sentinal)
Definition locale.c:969
WizardExport ssize_t FormatLocaleString(char *string, const size_t length, const char *format,...)
Definition locale.c:465
WizardExport const char * GetLocaleMessage(const char *tag)
Definition locale.c:739
static int LocaleInfoCompare(const void *x, const void *y)
Definition locale.c:562
WizardExport WizardBooleanType ListLocaleInfo(FILE *file, ExceptionInfo *exception)
Definition locale.c:1023
WizardExport WizardBooleanType LocaleComponentGenesis(void)
Definition locale.c:1392
WizardExport const char * GetLocaleValue(const LocaleInfo *locale_info)
Definition locale.c:872
WizardExport const LocaleInfo ** GetLocaleInfoList(const char *pattern, size_t *number_messages, ExceptionInfo *exception)
Definition locale.c:579
WizardExport void LocaleComponentTerminus(void)
Definition locale.c:1420
#define LocaleFilename
Definition locale.c:68
static SemaphoreInfo * locale_semaphore
Definition locale.c:87
WizardExport LinkedListInfo * GetLocaleOptions(const char *filename, ExceptionInfo *exception)
Definition locale.c:787
static const char * LocaleMap
Definition locale.c:75
#define WizardLocaleExtent
Definition locale_.h:28
WizardBooleanType LogWizardEvent(const LogEventType type, const char *module, const char *function, const size_t line, const char *format,...)
Definition log.c:1390
@ LocaleEvent
Definition log.h:47
@ TraceEvent
Definition log.h:39
@ ConfigureEvent
Definition log.h:44
#define GetWizardModule()
Definition log.h:30
WizardExport void * AcquireWizardMemory(const size_t size)
Definition memory.c:586
WizardExport void * AcquireQuantumMemory(const size_t count, const size_t quantum)
Definition memory.c:657
WizardExport void * RelinquishWizardMemory(void *memory)
Definition memory.c:1039
#define WizardExport
#define wizard_unreferenced(x)
#define WizardPathExtent
#define WizardSignature
#define wizard_unused(x)
WizardExport void RelinquishSemaphoreInfo(SemaphoreInfo **semaphore_info)
Definition semaphore.c:338
WizardExport SemaphoreInfo * AcquireSemaphoreInfo(void)
Definition semaphore.c:156
WizardExport void LockSemaphoreInfo(SemaphoreInfo *semaphore_info)
Definition semaphore.c:282
WizardExport void UnlockSemaphoreInfo(SemaphoreInfo *semaphore_info)
Definition semaphore.c:437
WizardExport void ActivateSemaphoreInfo(SemaphoreInfo **semaphore_info)
Definition semaphore.c:247
WizardExport const void * GetValueFromSplayTree(SplayTreeInfo *splay_tree, const void *key)
Definition splay-tree.c:874
WizardExport const void * GetNextValueInSplayTree(SplayTreeInfo *splay_tree)
Definition splay-tree.c:819
WizardExport void ResetSplayTreeIterator(SplayTreeInfo *splay_tree)
WizardExport int CompareSplayTreeString(const void *target, const void *source)
Definition splay-tree.c:410
WizardExport size_t GetNumberOfNodesInSplayTree(const SplayTreeInfo *splay_tree)
Definition splay-tree.c:929
WizardExport SplayTreeInfo * DestroySplayTree(SplayTreeInfo *splay_tree)
Definition splay-tree.c:678
WizardExport WizardBooleanType AddValueToSplayTree(SplayTreeInfo *splay_tree, const void *key, const void *value)
Definition splay-tree.c:152
WizardExport SplayTreeInfo * NewSplayTree(int(*compare)(const void *, const void *), void *(*relinquish_key)(void *), void *(*relinquish_value)(void *))
WizardExport void SetStringInfoLength(StringInfo *string_info, const size_t length)
Definition string.c:1865
WizardExport int LocaleNCompare(const char *p, const char *q, const size_t length)
Definition string.c:1608
WizardExport char * DestroyString(char *string)
Definition string.c:830
WizardExport int LocaleCompare(const char *p, const char *q)
Definition string.c:1510
WizardExport void SetStringInfoPath(StringInfo *string_info, const char *path)
Definition string.c:1907
WizardExport char * ConstantString(const char *source)
Definition string.c:655
WizardExport size_t ConcatenateWizardString(char *destination, const char *source, const size_t length)
Definition string.c:478
WizardExport StringInfo * AcquireStringInfo(const size_t length)
Definition string.c:179
WizardExport StringInfo * ConfigureFileToStringInfo(const char *filename)
Definition string.c:546
WizardExport char * AcquireString(const char *source)
Definition string.c:133
WizardExport void SetStringInfoDatum(StringInfo *string_info, const unsigned char *source)
Definition string.c:1832
WizardExport unsigned char * GetStringInfoDatum(const StringInfo *string_info)
Definition string.c:1251
WizardExport char * GetEnvironmentValue(const char *name)
Definition string.c:1177
WizardExport size_t CopyWizardString(char *destination, const char *source, const size_t length)
Definition string.c:762
WizardExport const char * GetStringInfoPath(const StringInfo *string_info)
Definition string.c:1309
WizardExport StringInfo * DestroyStringInfo(StringInfo *string_info)
Definition string.c:857
char * tag
Definition locale_.h:35
size_t signature
Definition locale_.h:46
char * message
Definition locale_.h:36
WizardBooleanType stealth
Definition locale_.h:39
char * path
Definition locale_.h:34
#define DirectorySeparator
Definition studio.h:239
WizardExport WizardBooleanType GlobExpression(const char *expression, const char *pattern, const WizardBooleanType case_insensitive)
Definition token.c:259
WizardExport void GetNextToken(const char *start, const char **end, const size_t extent, char *token)
Definition token.c:103
#define WizardMin(x, y)
WizardExport void GetPathComponent(const char *path, PathType type, char *component)
Definition utility.c:415
@ HeadPath
Definition utility.h:30
WizardBooleanType
Definition wizard-type.h:26
@ WizardTrue
Definition wizard-type.h:28
@ WizardFalse
Definition wizard-type.h:27
unsigned int WizardStatusType
Definition wizard-type.h:42
WizardPrivate char * FileToXML(const char *, const size_t)
Definition xml-tree.c:633