grub2: bring back build of aros-side grub2 tools
[AROS.git] / workbench / libs / locale / patches.c
blobad86fa610894a57618bf66be4083fe6a3a885b63
1 /*
2 Copyright © 1995-2011, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 /**************************************************************************/
8 #include "locale_intern.h"
10 #include <exec/execbase.h>
11 #include <aros/libcall.h>
13 #include <proto/exec.h>
14 #include <proto/dos.h>
15 #include <proto/utility.h>
16 #include <proto/locale.h>
18 /**************************************************************************/
20 #define LIB_EXEC 1
21 #define LIB_UTILITY 2
22 #define LIB_DOS 3
23 #define LIB_LOCALE 4
25 /**************************************************************************/
27 AROS_LD4(APTR, LocRawDoFmt,
28 AROS_LDA(CONST_STRPTR, FormatString, A0),
29 AROS_LDA(APTR, DataStream, A1),
30 AROS_LDA(VOID_FUNC, PutChProc, A2),
31 AROS_LDA(APTR, PutChData, A3), struct ExecBase *, SysBase, 31, Locale);
32 AROS_LD4(APTR, LocVNewRawDoFmt,
33 AROS_LDA(CONST_STRPTR, FormatString, A0),
34 AROS_LDA(VOID_FUNC, PutChProc, A2),
35 AROS_LDA(APTR, PutChData, A3),
36 AROS_LDA(va_list, DataStream, A1),
37 struct ExecBase *, SysBase, 39, Locale);
38 AROS_LD3(LONG, LocStrnicmp,
39 AROS_LDA(CONST_STRPTR, string1, A0),
40 AROS_LDA(CONST_STRPTR, string2, A1),
41 AROS_LDA(LONG, length, D0),
42 struct UtilityBase *, UtilityBase, 32, Locale);
43 AROS_LD2(LONG, LocStricmp,
44 AROS_LDA(CONST_STRPTR, string1, A0),
45 AROS_LDA(CONST_STRPTR, string2, A1),
46 struct UtilityBase *, UtilityBase, 33, Locale);
47 AROS_LD1(ULONG, LocToLower,
48 AROS_LDA(ULONG, character, D0),
49 struct UtilityBase *, UtilityBase, 34, Locale);
50 AROS_LD1(ULONG, LocToUpper,
51 AROS_LDA(ULONG, character, D0),
52 struct UtilityBase *, UtilityBase, 35, Locale);
53 AROS_LD1(LONG, LocDateToStr,
54 AROS_LDA(struct DateTime *, datetime, D1),
55 struct DosLibrary *, DOSBase, 36, Locale);
56 AROS_LD1(LONG, LocStrToDate,
57 AROS_LDA(struct DateTime *, datetime, D1),
58 struct DosLibrary *, DOSBase, 37, Locale);
59 AROS_LD1(CONST_STRPTR, LocDosGetLocalizedString,
60 AROS_LDA(LONG, stringNum, D1),
61 struct DosLibrary *, DOSBase, 38, Locale);
63 /**************************************************************************/
65 static struct patchinfo
67 WORD library;
68 WORD whichfunc;
69 APTR whichpatchfunc;
70 } pi[] =
72 {LIB_EXEC, 87, AROS_SLIB_ENTRY(LocRawDoFmt, Locale, 31)},
73 {LIB_UTILITY, 28, AROS_SLIB_ENTRY(LocStrnicmp, Locale, 32)},
74 {LIB_UTILITY, 27, AROS_SLIB_ENTRY(LocStricmp, Locale, 33)},
75 {LIB_UTILITY, 30, AROS_SLIB_ENTRY(LocToLower, Locale, 34)},
76 {LIB_UTILITY, 29, AROS_SLIB_ENTRY(LocToUpper, Locale, 35)},
77 {LIB_DOS, 124, AROS_SLIB_ENTRY(LocDateToStr, Locale, 36)},
78 {LIB_DOS, 125, AROS_SLIB_ENTRY(LocStrToDate, Locale, 37)},
79 {LIB_DOS, 163, AROS_SLIB_ENTRY(LocDosGetLocalizedString, Locale, 38)},
80 {LIB_EXEC, 137, AROS_SLIB_ENTRY(LocVNewRawDoFmt, Locale, 39)},
81 {0}
84 /**************************************************************************/
86 static struct Library *GetLib(WORD which)
88 struct Library *lib = NULL;
90 switch (which)
92 case LIB_EXEC:
93 lib = (struct Library *)SysBase;
94 break;
96 case LIB_DOS:
97 lib = (struct Library *)DOSBase;
98 break;
100 case LIB_UTILITY:
101 lib = (struct Library *)UtilityBase;
102 break;
104 case LIB_LOCALE:
105 lib = (struct Library *)LocaleBase;
106 break;
109 return lib;
112 /**************************************************************************/
114 void InstallPatches(void)
116 WORD i;
118 #ifdef __MORPHOS__
119 static const struct TagItem PatchTags[] = {
120 {SETFUNCTAG_MACHINE, MACHINE_PPC},
121 {SETFUNCTAG_TYPE, SETFUNCTYPE_NORMAL},
122 {SETFUNCTAG_IDNAME, (ULONG) "locale.library Language Patch"},
123 {SETFUNCTAG_DELETE, TRUE},
124 {TAG_DONE}
126 #endif
128 Forbid();
129 for (i = 0; pi[i].library; i++)
131 #ifdef __MORPHOS__
132 NewSetFunction(GetLib(pi[i].library), pi[i].whichpatchfunc,
133 -pi[i].whichfunc * LIB_VECTSIZE, PatchTags);
134 #else
135 SetFunction(GetLib(pi[i].library),
136 -pi[i].whichfunc * LIB_VECTSIZE, pi[i].whichpatchfunc);
137 #endif
139 Permit();
140 LocaleBase->lb_SysPatches = TRUE;
143 /**************************************************************************/