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 17using BPrivate::Libroot::GetCurrentLocaleBackend; 18using BPrivate::Libroot::LocaleBackend; 19using BPrivate::Libroot::LocaleBackendData; 20#endif 21 22 23extern "C" struct lconv* 24localeconv(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 37extern "C" struct lconv* 38localeconv_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