xref: /haiku/src/system/libroot/posix/locale/localeconv.cpp (revision 17889a8c70dbb3d59c1412f6431968753c767bab)
1 /*
2  * Copyright 2002-2010 Haiku Inc. All rights reserved.
3  * Distributed under the terms of the MIT License.
4  *
5  * Author:
6  * 		Daniel Reinhold, danielre@users.sf.net
7  * 		Oliver Tappe, zooey@hirschkaefer.de
8  */
9 
10 
11 #include <PosixLocaleConv.h>
12 
13 #ifndef _KERNEL_MODE
14 #include <locale.h>
15 #include "LocaleBackend.h"
16 
17 using BPrivate::Libroot::GetCurrentLocaleBackend;
18 using BPrivate::Libroot::LocaleBackend;
19 using BPrivate::Libroot::LocaleBackendData;
20 #endif
21 
22 
23 extern "C" struct lconv*
24 localeconv(void)
25 {
26 #ifndef _KERNEL_MODE
27 	LocaleBackend* backend = GetCurrentLocaleBackend();
28 	if (backend != NULL)
29 		return const_cast<lconv*>(backend->LocaleConv());
30 #endif
31 
32 	return &BPrivate::Libroot::gPosixLocaleConv;
33 }
34 
35 
36 #ifndef _KERNEL_MODE
37 extern "C" struct lconv*
38 localeconv_l(locale_t l)
39 {
40 	LocaleBackendData* locale = (LocaleBackendData*)l;
41 	LocaleBackend* backend = locale->backend;
42 
43 	if (backend != NULL)
44 		return const_cast<lconv*>(backend->LocaleConv());
45 
46 	return &BPrivate::Libroot::gPosixLocaleConv;
47 }
48 #endif