2 Copyright © 1995-2011, The AROS Development Team. All rights reserved.
5 Desc: Locale_RawDoFmt - locale.library's private replacement
6 of exec.library/RawDoFmt function. IPrefs will install
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>
21 #include <clib/alib_protos.h>
23 AROS_UFH3(VOID
, LocRawDoFmtFormatStringFunc
,
24 AROS_UFHA(struct Hook
*, hook
, A0
),
25 AROS_UFHA(struct Locale
*, locale
, A2
),
26 AROS_UFHA(char, fill
, A1
))
31 register char *pdata
asm("a3") = hook
->h_Data
;
33 char *pdata
= hook
->h_Data
;
36 switch ((IPTR
) hook
->h_SubEntry
)
38 case (IPTR
) RAWFMTFUNC_STRING
:
39 /* Standard Array Function */
42 case (IPTR
) RAWFMTFUNC_SERIAL
:
43 /* Standard Serial Function */
46 case (IPTR
) RAWFMTFUNC_COUNT
:
47 /* Standard Count Function */
48 (*((ULONG
*) pdata
))++;
51 AROS_UFC3NR(void, hook
->h_SubEntry
,
52 AROS_UFCA(char, fill
, D0
),
53 AROS_UFCA(APTR
, pdata
, A3
),
54 AROS_UFCA(struct ExecBase
*, SysBase
, A6
));
61 AROS_UFH3(VOID
, LocRawDoFmtFormatStringFunc_SysV
,
62 AROS_UFHA(struct Hook
*, hook
, A0
),
63 AROS_UFHA(struct Locale
*, locale
, A2
), AROS_UFHA(char, fill
, A1
))
67 APTR(*proc
) (APTR
, UBYTE
) = (APTR
) hook
->h_SubEntry
;
68 char *pdata
= hook
->h_Data
;
70 switch ((IPTR
) hook
->h_SubEntry
)
72 case (IPTR
) RAWFMTFUNC_STRING
:
73 /* Standard Array Function */
77 case (IPTR
) RAWFMTFUNC_SERIAL
:
78 /* Standard Serial Function */
82 case (IPTR
) RAWFMTFUNC_COUNT
:
83 /* Standard Count Function */
84 (*((ULONG
*) pdata
))++;
88 pdata
= proc(pdata
, fill
);
97 /*****************************************************************************
100 #include <proto/locale.h>
102 AROS_PLH4(APTR
, LocRawDoFmt
,
105 AROS_LHA(CONST_STRPTR
, FormatString
, A0
),
106 AROS_LHA(RAWARG
, DataStream
, A1
),
107 AROS_LHA(VOID_FUNC
, PutChProc
, A2
),
108 AROS_LHA(APTR
, PutChData
, A3
),
111 struct ExecBase
*, SysBase
, 31, Locale
)
114 See exec.library/RawDoFmt
117 See exec.library/RawDoFmt
122 This function is not called by apps directly. Instead dos.library/DosGet-
123 LocalizedString is patched to use this function. This means, that the
124 LocaleBase parameter above actually points to SysBase, so we make use of
125 the global LocaleBase variable. This function is marked as private,
126 thus the headers generator won't mind the different basename in the header.
133 RawDoFmt(), FormatString().
137 *****************************************************************************/
144 hook
.h_Entry
= (HOOKFUNC
) AROS_ASMSYMNAME(LocRawDoFmtFormatStringFunc
);
145 hook
.h_SubEntry
= (HOOKFUNC
) PutChProc
;
146 hook
.h_Data
= PutChData
;
148 //kprintf("LocRawDoFmt: FormatString = \"%s\"\n", FormatString);
152 retval
= FormatString(&(IntLB(LocaleBase
)->lb_CurrentLocale
->il_Locale
),
153 (STRPTR
) FormatString
, DataStream
, &hook
);
157 //kprintf("LocRawDoFmt: FormatString: returning %x\n", retval);
165 /*****************************************************************************
168 #include <proto/locale.h>
170 AROS_PLH4(APTR
, LocVNewRawDoFmt
,
173 AROS_LHA(CONST_STRPTR
, FormatString
, A0
),
174 AROS_LHA(VOID_FUNC
, PutChProc
, A2
),
175 AROS_LHA(APTR
, PutChData
, A3
),
176 AROS_LHA(va_list , DataStream
, A1
),
179 struct ExecBase
*, SysBase
, 39, Locale
)
182 See exec.library/VNewRawDoFmt
185 See exec.library/VNewRawDoFmt
190 This function is not called by apps directly. Instead exec.library/VNewRawDoFmt
191 is patched to use this function. This means, that the library base parameter above
192 actually points to SysBase, so we make use of the global LocaleBase variable.
193 This function is marked as private, thus the headers generator won't mind the
194 different basename in the header.
201 RawDoFmt(), FormatString().
205 *****************************************************************************/
213 ULONG iSize
= 0, dSize
= 0;
214 #if defined(__arm__) || defined(__x86_64__)
215 va_list nullarg
= {};
220 /* Scan to determine the location of the positional arguments */
221 GetDataStreamFromFormat(FormatString
, nullarg
, NULL
, NULL
,
223 iStream
= alloca(iSize
);
225 /* Scan to determine the size of the repacked datastream */
226 GetDataStreamFromFormat(FormatString
, nullarg
, NULL
, &dSize
,
228 dStream
= alloca(dSize
);
230 /* Repack the va_list into the datastream */
231 GetDataStreamFromFormat(FormatString
, DataStream
, dStream
, &dSize
,
235 (HOOKFUNC
) AROS_ASMSYMNAME(LocRawDoFmtFormatStringFunc_SysV
);
236 hook
.h_SubEntry
= (HOOKFUNC
) PutChProc
;
237 hook
.h_Data
= PutChData
;
241 InternalFormatString(&(IntLB(LocaleBase
)->lb_CurrentLocale
->il_Locale
),
242 (STRPTR
) FormatString
, dStream
, iStream
, &hook
);