2 Copyright © 1995-2014, The AROS Development Team. All rights reserved.
5 Desc: common code for language description files
8 #include <exec/types.h>
9 #include <aros/system.h>
10 #include <exec/resident.h>
11 #include <exec/libraries.h>
12 #include <libraries/locale.h>
14 #include <proto/exec.h>
15 #include <aros/libcall.h>
16 #include <aros/asmcall.h>
18 #include <aros/debug.h>
20 AROS_LD1(STRPTR, getlangstring,
21 AROS_LHA(ULONG, id, D0),
22 struct LocaleBase *, LocaleBase, 9, language);
24 /* ----------------------------------------------------------------------- */
26 /* Arrays for character type/conversion */
27 extern const STRPTR ___strings[];
29 /* -------------------------------------------------------------------------
30 Library definition, you should not need to change any of this.
31 ------------------------------------------------------------------------- */
35 struct Library library;
36 struct ExecBase *sysbase;
40 extern const UBYTE name[];
41 extern const UBYTE version[];
42 extern const APTR inittabl[4];
43 extern void *const functable[];
44 extern struct Language *AROS_SLIB_ENTRY(init,language,0)();
45 AROS_LD1(struct Language *, open,
46 AROS_LHA(ULONG, version, D0),
47 struct Language *, language, 1, language);
48 AROS_LD0(BPTR, close, struct Language *, language, 2, language);
49 AROS_LD0(BPTR, expunge, struct Language *, language, 3, language);
50 AROS_LD0I(int, null, struct Language *, language, 0, language);
51 AROS_LD0(ULONG, mask, struct Language *, language, 5, language);
52 extern const char end;
59 const struct Resident languageTag =
62 (struct Resident *)&languageTag,
73 const UBYTE name[]=LANGSTR ".language";
74 const UBYTE nativelang[]=NLANGTAG; /* N.B - MUST come before $VER: */
75 const UBYTE version[]=LANGTAG;
77 const ULONG datatable = 0;
79 const APTR inittabl[4] =
81 (APTR)sizeof(struct Language),
84 &AROS_SLIB_ENTRY(init,language,0)
87 struct ExecBase *SysBase;
89 AROS_UFH3(struct Language *, AROS_SLIB_ENTRY(init,language,0),
90 AROS_UFHA(struct Language *, language, D0),
91 AROS_UFHA(BPTR, segList, A0),
92 AROS_UFHA(struct ExecBase *, _SysBase, A6)
98 You could just as easily do this bit as the InitResident()
99 datatable, however this works just as well.
101 language->library.lib_Node.ln_Type = NT_LIBRARY;
102 language->library.lib_Node.ln_Pri = -120;
103 language->library.lib_Node.ln_Name = (char *)name;
104 language->library.lib_Flags = LIBF_SUMUSED | LIBF_CHANGED;
105 language->library.lib_Version = LANGVER;
106 language->library.lib_Revision = LANGREV;
107 language->library.lib_IdString = (APTR)&version[7];
109 language->seglist = segList;
110 language->sysbase = _SysBase;
114 Although it is unlikely, you would return NULL if you for some
115 unknown reason couldn't open.
117 D(bug("GetLangStr: Loaded at address %p\n", &AROS_SLIB_ENTRY(getlangstring,language,9)));
124 AROS_LH1(struct Language *, open,
125 AROS_LHA(ULONG, version, D0),
126 struct Language *, language, 1, language)
129 language->library.lib_OpenCnt++;
130 language->library.lib_Flags &= ~LIBF_DELEXP;
132 /* Again return NULL if you could not open */
138 AROS_LH0(BPTR, close, struct Language *, language, 2, language)
142 if(! --language->library.lib_OpenCnt)
144 /* Delayed expunge pending? */
145 if(language->library.lib_Flags & LIBF_DELEXP)
147 /* Yes, expunge the library */
148 return AROS_LC0(BPTR, expunge, struct Language *, language, 3, language);
155 AROS_LH0(BPTR, expunge, struct Language *, language, 3, language)
160 if(language->library.lib_OpenCnt)
162 /* Can't expunge, we are still open */
163 language->library.lib_Flags |= LIBF_DELEXP;
167 Remove(&language->library.lib_Node);
168 ret = language->seglist;
170 FreeMem((UBYTE *)language - language->library.lib_NegSize,
171 language->library.lib_PosSize + language->library.lib_NegSize);
178 AROS_LH0I(int, null, struct Language *, language, 0, language)