added concrete implementations of putc(), getc(), getchar() and gets()
[tangerine.git] / workbench / locale / languages / piglatin.c
blob62d62d2910ba1efe1746684ef76f5e7c1798f6df
1 /*
2 Copyright © 1995-2007, 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 LANGVER 41 /* Version number of language */
31 #define LANGREV 1 /* Revision number of language */
32 #define LANGTAG "\0$VER: piglatin.language 41.1 (20.2.1997)"
34 AROS_LD1(STRPTR, getlangstring,
35 AROS_LHA(ULONG, id, D0),
36 struct LocaleBase *, LocaleBase, 9, language);
38 /* ----------------------------------------------------------------------- */
40 /* Bit masks for locale .language functions. Only implement GetString() */
41 #define LF_GetLangStr (1L << 3)
43 /* Arrays for Pig Latin character type/conversion */
44 extern const STRPTR __pig_strings[];
46 /* -------------------------------------------------------------------------
47 Library definition, you should not need to change any of this.
48 ------------------------------------------------------------------------- */
50 struct Language
52 struct Library library;
53 struct ExecBase *sysbase;
54 BPTR seglist;
57 extern const UBYTE name[];
58 extern const UBYTE version[];
59 extern const APTR inittabl[4];
60 extern void *const functable[];
61 extern struct Language *AROS_SLIB_ENTRY(init,language)();
62 AROS_LD1(struct Language *, open,
63 AROS_LHA(ULONG, version, D0),
64 struct Language *, language, 1, language);
65 AROS_LD0(BPTR, close, struct Language *, language, 2, language);
66 AROS_LD0(BPTR, expunge, struct Language *, language, 3, language);
67 AROS_LD0I(int, null, struct Language *, language, 4, language);
68 AROS_LD0(ULONG, mask, struct Language *, language, 5, language);
69 extern const char end;
71 int entry(void)
73 return -1;
76 const struct Resident languageTag =
78 RTC_MATCHWORD,
79 (struct Resident *)&languageTag,
80 (APTR)&end,
81 RTF_AUTOINIT,
82 LANGVER,
83 NT_LIBRARY,
84 -120,
85 (STRPTR)name,
86 (STRPTR)&version[7],
87 (ULONG *)inittabl
90 const UBYTE name[]=LANGSTR ".language";
91 const UBYTE version[]=LANGTAG;
93 const ULONG datatable = 0;
95 const APTR inittabl[4] =
97 (APTR)sizeof(struct Language),
98 (APTR)functable,
99 (APTR)&datatable,
100 &AROS_SLIB_ENTRY(init,language)
103 struct ExecBase *mySysBase;
105 AROS_UFH3(struct Language *, AROS_SLIB_ENTRY(init,language),
106 AROS_UFHA(struct Language *, language, D0),
107 AROS_UFHA(BPTR, segList, A0),
108 AROS_UFHA(struct ExecBase *, SysBase, A6)
111 AROS_USERFUNC_INIT
114 You could just as easily do this bit as the InitResident()
115 datatable, however this works just as well.
117 language->library.lib_Node.ln_Type = NT_LIBRARY;
118 language->library.lib_Node.ln_Pri = -120;
119 language->library.lib_Node.ln_Name = (char *)name;
120 language->library.lib_Flags = LIBF_SUMUSED | LIBF_CHANGED;
121 language->library.lib_Version = LANGVER;
122 language->library.lib_Revision = LANGREV;
123 language->library.lib_IdString = (APTR)&version[7];
125 language->seglist = segList;
126 language->sysbase = SysBase;
127 mySysBase = SysBase;
130 Although it is unlikely, you would return NULL if you for some
131 unknown reason couldn't open.
133 bug("GetLangStr: Loaded at address %p\n", &AROS_SLIB_ENTRY(getlangstring,language));
134 return language;
136 AROS_USERFUNC_EXIT
139 #define SysBase language->sysbase
141 AROS_LH1(struct Language *, open,
142 AROS_LHA(ULONG, version, D0),
143 struct Language *, language, 1, language)
145 AROS_LIBFUNC_INIT
146 language->library.lib_OpenCnt++;
147 language->library.lib_Flags &= ~LIBF_DELEXP;
149 /* Again return NULL if you could not open */
150 return language;
152 AROS_LIBFUNC_EXIT
155 AROS_LH0(BPTR, close, struct Language *, language, 2, language)
157 AROS_LIBFUNC_INIT
159 if(! --language->library.lib_OpenCnt)
161 /* Delayed expunge pending? */
162 if(language->library.lib_Flags & LIBF_DELEXP)
164 /* Yes, expunge the library */
165 return AROS_LC0(BPTR, expunge, struct Language *, language, 3, language);
168 return NULL;
169 AROS_LIBFUNC_EXIT
172 AROS_LH0(BPTR, expunge, struct Language *, language, 3, language)
174 AROS_LIBFUNC_INIT
176 BPTR ret;
177 if(language->library.lib_OpenCnt)
179 /* Can't expunge, we are still open */
180 language->library.lib_Flags |= LIBF_DELEXP;
181 return 0;
184 Remove(&language->library.lib_Node);
185 ret = language->seglist;
187 FreeMem((UBYTE *)language - language->library.lib_NegSize,
188 language->library.lib_PosSize + language->library.lib_NegSize);
190 return ret;
192 AROS_LIBFUNC_EXIT
195 AROS_LH0I(int, null, struct Language *, language, 4, language)
197 AROS_LIBFUNC_INIT
199 return 0;
201 AROS_LIBFUNC_EXIT
204 /* ------------------------------------------------------------------------
205 Language specific functions
206 ------------------------------------------------------------------------ */
208 #undef SysBase
209 #define SysBase mySysBase
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),
256 &AROS_SLIB_ENTRY(close,language),
257 &AROS_SLIB_ENTRY(expunge,language),
258 &AROS_SLIB_ENTRY(null,language),
259 &AROS_SLIB_ENTRY(mask,language),
261 /* Note, shorter function table, as only getlangstring is used */
263 /* 0 - 3 */
264 &AROS_SLIB_ENTRY(null, language),
265 &AROS_SLIB_ENTRY(null, language),
266 &AROS_SLIB_ENTRY(null, language),
267 &AROS_SLIB_ENTRY(getlangstring, language),
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"
323 /* This is the end of ROMtag marker. */
324 const char end=0;