Locale/Languages: restore backwards compatible native language names
[AROS.git] / workbench / locale / languages / piglatin.c
blob06d109ee12d983a7bbfbd9766b8bd53d5fff9ab8
1 /*
2 Copyright © 1995-2013, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: piglatin.language description file.
6 Lang: english
7 */
9 /*
10 This is a rather silly language, but it is more of an example than
11 then english language file, as this one actually does something...
13 In fact you may even wish to copy this one instead of copying
14 english_language.c and english_data.c
17 #include <exec/types.h>
18 #include <aros/system.h>
19 #include <exec/resident.h>
20 #include <exec/libraries.h>
21 #include <libraries/locale.h>
23 #include <proto/exec.h>
24 #include <aros/libcall.h>
25 #include <aros/asmcall.h>
27 #include <aros/debug.h>
29 #define LANGSTR "piglatin" /* String version of above */
30 #define NLANGSTR "pig-latin" /* Native version of LANGSTR */
31 #define LANGVER 41 /* Version number of language */
32 #define LANGREV 3 /* Revision number of language */
33 #define LANGTAG "\0$VER: " LANGSTR ".language 41.3 (30.09.2014)"
34 #define NLANGTAG "$NLANG:" NLANGSTR
36 AROS_LD1(STRPTR, getlangstring,
37 AROS_LHA(ULONG, id, D0),
38 struct LocaleBase *, LocaleBase, 9, language);
40 /* ----------------------------------------------------------------------- */
42 /* Bit masks for locale .language functions. Only implement GetString() */
43 #define LF_GetLangStr (1L << 3)
45 /* Arrays for Pig Latin character type/conversion */
46 extern const STRPTR __pig_strings[];
48 /* -------------------------------------------------------------------------
49 Library definition, you should not need to change any of this.
50 ------------------------------------------------------------------------- */
52 struct Language
54 struct Library library;
55 struct ExecBase *sysbase;
56 BPTR seglist;
59 extern const UBYTE name[];
60 extern const UBYTE version[];
61 extern const APTR inittabl[4];
62 extern void *const functable[];
63 extern struct Language *AROS_SLIB_ENTRY(init,language,0)();
64 AROS_LD1(struct Language *, open,
65 AROS_LHA(ULONG, version, D0),
66 struct Language *, language, 1, language);
67 AROS_LD0(BPTR, close, struct Language *, language, 2, language);
68 AROS_LD0(BPTR, expunge, struct Language *, language, 3, language);
69 AROS_LD0I(int, null, struct Language *, language, 0, language);
70 AROS_LD0(ULONG, mask, struct Language *, language, 5, language);
71 extern const char end;
73 int entry(void)
75 return -1;
78 const struct Resident languageTag =
80 RTC_MATCHWORD,
81 (struct Resident *)&languageTag,
82 (APTR)&end,
83 RTF_AUTOINIT,
84 LANGVER,
85 NT_LIBRARY,
86 -120,
87 (STRPTR)name,
88 (STRPTR)&version[7],
89 (ULONG *)inittabl
92 const UBYTE name[]=LANGSTR ".language";
93 const UBYTE nativelang[]=NLANGTAG; /* N.B - MUST come before $VER: */
94 const UBYTE version[]=LANGTAG;
96 const ULONG datatable = 0;
98 const APTR inittabl[4] =
100 (APTR)sizeof(struct Language),
101 (APTR)functable,
102 (APTR)&datatable,
103 &AROS_SLIB_ENTRY(init,language,0)
106 struct ExecBase *SysBase;
108 AROS_UFH3(struct Language *, AROS_SLIB_ENTRY(init,language,0),
109 AROS_UFHA(struct Language *, language, D0),
110 AROS_UFHA(BPTR, segList, A0),
111 AROS_UFHA(struct ExecBase *, _SysBase, A6)
114 AROS_USERFUNC_INIT
117 You could just as easily do this bit as the InitResident()
118 datatable, however this works just as well.
120 language->library.lib_Node.ln_Type = NT_LIBRARY;
121 language->library.lib_Node.ln_Pri = -120;
122 language->library.lib_Node.ln_Name = (char *)name;
123 language->library.lib_Flags = LIBF_SUMUSED | LIBF_CHANGED;
124 language->library.lib_Version = LANGVER;
125 language->library.lib_Revision = LANGREV;
126 language->library.lib_IdString = (APTR)&version[7];
128 language->seglist = segList;
129 language->sysbase = _SysBase;
130 SysBase = _SysBase;
133 Although it is unlikely, you would return NULL if you for some
134 unknown reason couldn't open.
136 bug("GetLangStr: Loaded at address %p\n", &AROS_SLIB_ENTRY(getlangstring,language,9));
137 return language;
139 AROS_USERFUNC_EXIT
143 AROS_LH1(struct Language *, open,
144 AROS_LHA(ULONG, version, D0),
145 struct Language *, language, 1, language)
147 AROS_LIBFUNC_INIT
148 language->library.lib_OpenCnt++;
149 language->library.lib_Flags &= ~LIBF_DELEXP;
151 /* Again return NULL if you could not open */
152 return language;
154 AROS_LIBFUNC_EXIT
157 AROS_LH0(BPTR, close, struct Language *, language, 2, language)
159 AROS_LIBFUNC_INIT
161 if(! --language->library.lib_OpenCnt)
163 /* Delayed expunge pending? */
164 if(language->library.lib_Flags & LIBF_DELEXP)
166 /* Yes, expunge the library */
167 return AROS_LC0(BPTR, expunge, struct Language *, language, 3, language);
170 return BNULL;
171 AROS_LIBFUNC_EXIT
174 AROS_LH0(BPTR, expunge, struct Language *, language, 3, language)
176 AROS_LIBFUNC_INIT
178 BPTR ret;
179 if(language->library.lib_OpenCnt)
181 /* Can't expunge, we are still open */
182 language->library.lib_Flags |= LIBF_DELEXP;
183 return 0;
186 Remove(&language->library.lib_Node);
187 ret = language->seglist;
189 FreeMem((UBYTE *)language - language->library.lib_NegSize,
190 language->library.lib_PosSize + language->library.lib_NegSize);
192 return ret;
194 AROS_LIBFUNC_EXIT
197 AROS_LH0I(int, null, struct Language *, language, 0, language)
199 AROS_LIBFUNC_INIT
201 return 0;
203 AROS_LIBFUNC_EXIT
206 /* ------------------------------------------------------------------------
207 Language specific functions
208 ------------------------------------------------------------------------ */
211 /* ULONG LanguageMask():
212 This function is to inform locale.library what functions it should
213 use from this library. This is done by returning a bitmask containing
214 1's for functions to use, and 0's for functions to ignore.
216 Unused bits MUST be 0 for future compatibility.
218 AROS_LH0(ULONG, mask, struct Language *, language, 5, language)
220 AROS_LIBFUNC_INIT
222 return ( LF_GetLangStr );
224 AROS_LIBFUNC_EXIT
227 /* STRPTR GetLangString(ULONG num): Language function 3
228 This function is called by GetLocaleStr() and should return
229 the string matching the string id passed in as num.
231 AROS_LH1(STRPTR, getlangstring,
232 AROS_LHA(ULONG, id, D0),
233 struct LocaleBase *, LocaleBase, 9, language)
235 AROS_LIBFUNC_INIT
237 //kprintf("\nWe have got to getlangstring\n");
239 if(id < MAXSTRMSG)
240 return __pig_strings[id];
241 else
242 return NULL;
244 AROS_LIBFUNC_EXIT
247 /* -----------------------------------------------------------------------
248 Library function table - you will need to alter this
249 I have this right here at the end of the library so that I do not
250 have to have prototypes for the functions. Although you could do that.
251 ----------------------------------------------------------------------- */
253 void *const functable[] =
255 &AROS_SLIB_ENTRY(open,language,1),
256 &AROS_SLIB_ENTRY(close,language,2),
257 &AROS_SLIB_ENTRY(expunge,language,3),
258 &AROS_SLIB_ENTRY(null,language,0),
259 &AROS_SLIB_ENTRY(mask,language,5),
261 /* Note, shorter function table, as only getlangstring is used */
263 /* 0 - 3 */
264 &AROS_SLIB_ENTRY(null, language, 0),
265 &AROS_SLIB_ENTRY(null, language, 0),
266 &AROS_SLIB_ENTRY(null, language, 0),
267 &AROS_SLIB_ENTRY(getlangstring, language, 9),
268 (void *)-1
272 Note how only the required data structures are kept...
274 This is the list of strings. It is an array of pointers to strings,
275 although how it is laid out is implementation dependant.
277 const STRPTR __pig_strings[] =
279 /* A blank string */
282 /* The days of the week. Starts with the first day of the week.
283 In English this would be Sunday, this depends upon the settings
284 of Locale->CalendarType.
286 "Undaysay", "Ondaymay", "Uesdaytay", "Ednesdayway",
287 "Hursdaytay", "Ridayfay", "Aturdaysay",
289 /* Abbreviated days of the week */
290 "Unsay", "Onmay", "Uetay", "Edway", "Hutay", "Rifay", "Atsay",
292 /* Months of the year */
293 "Anuaryjay", "Ebruaryfay", "Archmay",
294 "Aprilway", "Aymay", "Unejay",
295 "Ulyjay", "Augustway", "Eptembersay",
296 "Octoberway", "Ovembernay", "Ecemberday",
298 /* Abbreviated months of the year */
299 "Anjay", "Ebfay", "Armay", "Aprway", "Aymay", "Unjay",
300 "Uljay", "Augway", "Epsay", "Octway", "Ovnay", "Ecday",
302 "Yesay", /* Yes, affirmative response */
303 "Onay", /* No/negative response */
305 /* AM/PM strings AM 0000 -> 1159, PM 1200 -> 2359 */
306 "am", "pm",
308 /* Soft and hard hyphens */
309 "-", "-",
311 /* Open and close quotes */
312 "\"", "\"",
314 /* Days: But not actual day names
315 Yesterday - the day before the current
316 Today - the current day
317 Tomorrow - the next day
318 Future.
320 "Esterdayyay", "Odaytay", "Omorrowtay", "Uturefay",
322 /* Native language name */
323 NLANGSTR
326 /* This is the end of ROMtag marker. */
327 const char end=0;