fix __AROS_SETVECADDR invocations.
[AROS.git] / workbench / locale / languages / lang_openclose.inc
bloba98fe88c40b022afed5047ab2a8b74cd57ab65a2
1 /*
2     Copyright © 1995-2014, The AROS Development Team. All rights reserved.
3     $Id$
5     Desc: common code for language description files
6 */
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  ------------------------------------------------------------------------- */
33 struct Language
35     struct Library library;
36     struct ExecBase *sysbase;
37     BPTR seglist;
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;
54 int entry(void)
56     return -1;
59 const struct Resident languageTag =
61     RTC_MATCHWORD,
62     (struct Resident *)&languageTag,
63     (APTR)&end,
64     RTF_AUTOINIT,
65     LANGVER,
66     NT_LIBRARY,
67     -120,
68     (STRPTR)name,
69     (STRPTR)&version[7],
70     (ULONG *)inittabl
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),
82     (APTR)functable,
83     (APTR)&datatable,
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)
95     AROS_USERFUNC_INIT
97     /*
98         You could just as easily do this bit as the InitResident()
99         datatable, however this works just as well.
100     */
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;
111     SysBase = _SysBase;
113     /*
114         Although it is unlikely, you would return NULL if you for some
115         unknown reason couldn't open.
116     */
117     D(bug("GetLangStr: Loaded at address %p\n", &AROS_SLIB_ENTRY(getlangstring,language,9)));
118     return language;
120     AROS_USERFUNC_EXIT
124 AROS_LH1(struct Language *, open,
125     AROS_LHA(ULONG, version, D0),
126     struct Language *, language, 1, language)
128     AROS_LIBFUNC_INIT
129     language->library.lib_OpenCnt++;
130     language->library.lib_Flags &= ~LIBF_DELEXP;
132     /* Again return NULL if you could not open */
133     return language;
135     AROS_LIBFUNC_EXIT
138 AROS_LH0(BPTR, close, struct Language *, language, 2, language)
140     AROS_LIBFUNC_INIT
142     if(! --language->library.lib_OpenCnt)
143     {
144         /* Delayed expunge pending? */
145         if(language->library.lib_Flags & LIBF_DELEXP)
146         {
147             /* Yes, expunge the library */
148             return AROS_LC0(BPTR, expunge, struct Language *, language, 3, language);
149         }
150     }
151     return BNULL;
152     AROS_LIBFUNC_EXIT
155 AROS_LH0(BPTR, expunge, struct Language *, language, 3, language)
157     AROS_LIBFUNC_INIT
159     BPTR ret;
160     if(language->library.lib_OpenCnt)
161     {
162         /* Can't expunge, we are still open */
163         language->library.lib_Flags |= LIBF_DELEXP;
164         return 0;
165     }
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);
173     return ret;
175     AROS_LIBFUNC_EXIT
178 AROS_LH0I(int, null, struct Language *, language, 0, language)
180     AROS_LIBFUNC_INIT
182     return 0;
184     AROS_LIBFUNC_EXIT