- Tabs to spaces.
[AROS.git] / workbench / libs / locale / locrawdofmt.c
blob22949c9a5cf8e7ee183d4f5c8b50df021d469d0d
1 /*
2 Copyright © 1995-2011, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Locale_RawDoFmt - locale.library's private replacement
6 of exec.library/RawDoFmt function. IPrefs will install
7 the patch.
9 Lang: english
12 #include <exec/rawfmt.h>
13 #include <exec/types.h>
14 #include <proto/exec.h>
15 #include <proto/locale.h>
16 #include "locale_intern.h"
17 #include <aros/asmcall.h>
18 #include <stdarg.h>
21 AROS_UFH3(VOID, LocRawDoFmtFormatStringFunc,
22 AROS_UFHA(struct Hook *, hook, A0),
23 AROS_UFHA(struct Locale *, locale, A2),
24 AROS_UFHA(char, fill, A1))
26 AROS_USERFUNC_INIT
28 #ifdef __mc68000__
29 register char *pdata asm("a3") = hook->h_Data;
30 #else
31 char *pdata = hook->h_Data;
32 #endif
34 switch ((IPTR) hook->h_SubEntry)
36 case (IPTR) RAWFMTFUNC_STRING:
37 /* Standard Array Function */
38 *pdata++ = fill;
39 break;
40 case (IPTR) RAWFMTFUNC_SERIAL:
41 /* Standard Serial Function */
42 RawPutChar(fill);
43 break;
44 case (IPTR) RAWFMTFUNC_COUNT:
45 /* Standard Count Function */
46 (*((ULONG *) pdata))++;
47 break;
48 default:
49 AROS_UFC3(void, hook->h_SubEntry,
50 AROS_UFCA(char, fill, D0),
51 AROS_UFCA(APTR, pdata, A3),
52 AROS_UFCA(struct ExecBase *, SysBase, A6));
54 hook->h_Data = pdata;
56 AROS_USERFUNC_EXIT
59 AROS_UFH3(VOID, LocRawDoFmtFormatStringFunc_SysV,
60 AROS_UFHA(struct Hook *, hook, A0),
61 AROS_UFHA(struct Locale *, locale, A2), AROS_UFHA(char, fill, A1))
63 AROS_USERFUNC_INIT
65 APTR(*proc) (APTR, UBYTE) = (APTR) hook->h_SubEntry;
66 char *pdata = hook->h_Data;
68 switch ((IPTR) hook->h_SubEntry)
70 case (IPTR) RAWFMTFUNC_STRING:
71 /* Standard Array Function */
72 *pdata++ = fill;
73 break;
75 case (IPTR) RAWFMTFUNC_SERIAL:
76 /* Standard Serial Function */
77 RawPutChar(fill);
78 break;
80 case (IPTR) RAWFMTFUNC_COUNT:
81 /* Standard Count Function */
82 (*((ULONG *) pdata))++;
83 break;
85 default:
86 pdata = proc(pdata, fill);
88 hook->h_Data = pdata;
90 AROS_USERFUNC_EXIT
93 #undef LocaleBase
95 /*****************************************************************************
97 NAME */
98 #include <proto/locale.h>
100 AROS_PLH4(APTR, LocRawDoFmt,
102 /* SYNOPSIS */
103 AROS_LHA(CONST_STRPTR, FormatString, A0),
104 AROS_LHA(APTR , DataStream, A1),
105 AROS_LHA(VOID_FUNC , PutChProc, A2),
106 AROS_LHA(APTR , PutChData, A3),
108 /* LOCATION */
109 struct ExecBase *, SysBase, 31, Locale)
111 /* FUNCTION
112 See exec.library/RawDoFmt
114 INPUTS
115 See exec.library/RawDoFmt
117 RESULT
119 NOTES
120 This function is not called by apps directly. Instead dos.library/DosGet-
121 LocalizedString is patched to use this function. This means, that the
122 LocaleBase parameter above actually points to SysBase, so we make use of
123 the global LocaleBase variable. This function is marked as private,
124 thus the headers generator won't mind the different basename in the header.
126 EXAMPLE
128 BUGS
130 SEE ALSO
131 RawDoFmt(), FormatString().
133 INTERNALS
135 *****************************************************************************/
137 AROS_LIBFUNC_INIT
139 struct Hook hook;
140 APTR retval;
142 hook.h_Entry = (HOOKFUNC) AROS_ASMSYMNAME(LocRawDoFmtFormatStringFunc);
143 hook.h_SubEntry = (HOOKFUNC) PutChProc;
144 hook.h_Data = PutChData;
146 //kprintf("LocRawDoFmt: FormatString = \"%s\"\n", FormatString);
148 REPLACEMENT_LOCK;
150 retval = FormatString(&(IntLB(LocaleBase)->lb_CurrentLocale->il_Locale),
151 (STRPTR) FormatString, DataStream, &hook);
153 REPLACEMENT_UNLOCK;
155 //kprintf("LocRawDoFmt: FormatString: returning %x\n", retval);
157 return retval;
159 AROS_LIBFUNC_EXIT
163 /*****************************************************************************
165 NAME */
166 #include <proto/locale.h>
168 AROS_PLH4(APTR, LocVNewRawDoFmt,
170 /* SYNOPSIS */
171 AROS_LHA(CONST_STRPTR, FormatString, A0),
172 AROS_LHA(VOID_FUNC , PutChProc, A2),
173 AROS_LHA(APTR , PutChData, A3),
174 AROS_LHA(va_list , DataStream, A1),
176 /* LOCATION */
177 struct ExecBase *, SysBase, 39, Locale)
179 /* FUNCTION
180 See exec.library/VNewRawDoFmt
182 INPUTS
183 See exec.library/VNewRawDoFmt
185 RESULT
187 NOTES
188 This function is not called by apps directly. Instead exec.library/VNewRawDoFmt
189 is patched to use this function. This means, that the library base parameter above
190 actually points to SysBase, so we make use of the global LocaleBase variable.
191 This function is marked as private, thus the headers generator won't mind the
192 different basename in the header.
194 EXAMPLE
196 BUGS
198 SEE ALSO
199 RawDoFmt(), FormatString().
201 INTERNALS
203 *****************************************************************************/
206 AROS_LIBFUNC_INIT
208 struct Hook hook;
210 hook.h_Entry =
211 (HOOKFUNC) AROS_ASMSYMNAME(LocRawDoFmtFormatStringFunc_SysV);
212 hook.h_SubEntry = (HOOKFUNC) PutChProc;
213 hook.h_Data = PutChData;
215 REPLACEMENT_LOCK;
217 InternalFormatString(&(IntLB(LocaleBase)->lb_CurrentLocale->il_Locale),
218 (STRPTR) FormatString, NULL, &hook, DataStream);
220 REPLACEMENT_UNLOCK;
222 return hook.h_Data;
224 AROS_LIBFUNC_EXIT