locale.library: use system default locale if locale argument is NULL.
[AROS.git] / workbench / libs / locale / strconvert.c
blobb4ef253c50a18e0a0137087fd19732408824fa96
1 /*
2 Copyright © 1995-2011, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: StrConvert - Stub for the Locale StrConvert function.
6 Lang: english
7 */
8 #include <exec/types.h>
9 #include <proto/exec.h>
10 #include "locale_intern.h"
11 #include <aros/asmcall.h>
13 #define DEBUG_STRCONVERT(x) ;
15 /*****************************************************************************
17 NAME */
18 #include <proto/locale.h>
20 AROS_LH5(ULONG, StrConvert,
22 /* SYNOPSIS */
23 AROS_LHA(const struct Locale *, locale, A0),
24 AROS_LHA(CONST_STRPTR , string, A1),
25 AROS_LHA(APTR , buffer, A2),
26 AROS_LHA(ULONG , bufferSize, D0),
27 AROS_LHA(ULONG , type, D1),
29 /* LOCATION */
30 struct LocaleBase *, LocaleBase, 29, Locale)
32 /* FUNCTION
33 This function will transform the string given and place the
34 result in the supplied buffers, copying at most bufferSize
35 bytes.
37 The transformation is such that if the C strcmp() function
38 was called on two strings transformed by this function then
39 the result will be the same as calling the Locale StrnCmp()
40 function on the two strings.
42 INPUTS
43 locale - the Locale to use for the transformation or
44 NULL for the system default locale.
45 string - the string to be transformed
46 buffer - the destination for the transformed string.
47 This buffer may need to be larger than the
48 untransformed string.
49 bufferSize - the maximum number of bytes to place in
50 buffer.
51 type - how to transform the string. See the
52 StrnCmp() function for possible values.
54 RESULT
55 Length of the number of BYTES placed in the buffer by
56 the transformation process minus 1 (for NULL termination).
58 NOTES
60 EXAMPLE
62 BUGS
64 SEE ALSO
65 StrnCmp()
67 INTERNALS
69 *****************************************************************************/
71 AROS_LIBFUNC_INIT
73 LONG result;
74 struct Locale *def_locale = NULL;
76 if (locale == NULL)
78 locale = OpenLocale(NULL);
79 def_locale = (struct Locale *)locale;
82 DEBUG_STRCONVERT(dprintf
83 ("StrConvert: locale 0x%lx <%s> buffer 0x%lx size %ld type 0x%lx\n",
84 locale, string, buffer, bufferSize, type));
86 DEBUG_STRCONVERT(dprintf("StrConvert: Function 0x%lx\n",
87 IntL(locale)->il_LanguageFunctions[15]));
89 #ifdef AROS_CALL4
90 result = AROS_CALL4(ULONG, IntL(locale)->il_LanguageFunctions[15],
91 AROS_LCA(CONST_STRPTR, string, A1),
92 AROS_LCA(APTR, buffer, A2),
93 AROS_LCA(ULONG, bufferSize, D0),
94 AROS_LCA(ULONG, type, D1), struct LocaleBase *, LocaleBase);
95 #else
96 result = AROS_UFC4(ULONG, IntL(locale)->il_LanguageFunctions[15],
97 AROS_UFCA(CONST_STRPTR, string, A1),
98 AROS_UFCA(APTR, buffer, A2),
99 AROS_UFCA(ULONG, bufferSize, D0), AROS_UFCA(ULONG, type, D1));
100 #endif
102 DEBUG_STRCONVERT(dprintf("StrConvert: retval %lu\n", result));
104 CloseLocale(def_locale);
106 return result;
108 AROS_LIBFUNC_EXIT