- Tabs to spaces.
[AROS.git] / workbench / libs / locale / locale_init.c
blobba55a8bf2591516800fd19d5824872b0f97e3a1e
1 /*
2 Copyright © 1995-2011, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Initialisation for the locale.library.
6 Lang: english
7 */
9 #define AROS_ALMOST_COMPATIBLE
10 #include <exec/types.h>
11 #include <exec/lists.h>
12 #include <exec/memory.h>
13 #include <exec/resident.h>
14 #include <aros/symbolsets.h>
15 #include <exec/semaphores.h>
17 #include <proto/exec.h>
19 #include "locale_intern.h"
20 #include LC_LIBDEFS_FILE
22 /* This global variable is needed for LocRawDoFmt */
24 struct LocaleBase *globallocalebase = NULL;
26 /* Avoid using nasty #defines if we can :-) */
27 AROS_MAKE_ALIAS(globallocalebase, LocaleBase);
29 static int Init(LIBBASETYPEPTR LIBBASE)
31 struct IntLocale *def;
33 /* A few internal functions need to access a global LocaleBase pointer,
34 because they're used to patch dos.library functions, and thus don't
35 directly get a LocaleBase pointer. Someday, with TLS, this will go away. */
36 globallocalebase = (struct LocaleBase *)LIBBASE;
38 /* Do whatever static initialisation you need here */
39 InitSemaphore(&((struct IntLocaleBase *)LIBBASE)->lb_LocaleLock);
40 InitSemaphore(&((struct IntLocaleBase *)LIBBASE)->lb_CatalogLock);
42 NEWLIST(&((struct IntLocaleBase *)LIBBASE)->lb_CatalogList);
44 IntLB(LIBBASE)->lb_DefaultLocale = def =
45 AllocMem(sizeof(struct IntLocale), MEMF_CLEAR | MEMF_ANY);
46 if (def != NULL)
48 /* Copy the defaults to our new structure */
49 CopyMem(&defLocale, def, sizeof(struct Locale));
51 /* Set lb_CurrentLocale *BEFORE* SetLocaleLanguage */
52 IntLB(LIBBASE)->lb_CurrentLocale = def;
54 /* Setup the languages - will not fail here. */
55 SetLocaleLanguage(def, (struct LocaleBase *)LIBBASE);
57 def->il_Count = 0;
58 InstallPatches();
60 return TRUE;
63 return FALSE;
67 ADD2INITLIB(Init, 0);