1/* 2 * Copyright 2011, Oliver Tappe, zooey@hirschkaefer.de. 3 * All rights reserved. Distributed under the terms of the MIT license. 4 */ 5 6#include <errno.h> 7 8#include <errno_private.h> 9#include <LocaleBackend.h> 10#include <wchar_private.h> 11 12 13using BPrivate::Libroot::GetCurrentLocaleBackend; 14using BPrivate::Libroot::LocaleBackend; 15using BPrivate::Libroot::LocaleBackendData; 16 17 18extern "C" size_t 19__wcsxfrm(wchar_t* dest, const wchar_t* src, size_t destSize) 20{ 21 LocaleBackend* backend = GetCurrentLocaleBackend(); 22 23 if (backend != NULL) { 24 size_t outSize = 0; 25 status_t status = backend->Wcsxfrm(dest, src, destSize, outSize); 26 27 if (status != B_OK) 28 __set_errno(EINVAL); 29 30 return outSize; 31 } 32 33 return wcslcpy(dest, src, destSize); 34} 35 36 37B_DEFINE_WEAK_ALIAS(__wcsxfrm, wcsxfrm); 38 39 40extern "C" size_t 41__wcsxfrm_l(wchar_t* dest, const wchar_t* src, size_t destSize, locale_t l) 42{ 43 LocaleBackendData* locale = (LocaleBackendData*)l; 44 LocaleBackend* backend = locale->backend; 45 46 if (backend != NULL) { 47 size_t outSize = 0; 48 status_t status = backend->Wcsxfrm(dest, src, destSize, outSize); 49 50 if (status != B_OK) 51 __set_errno(EINVAL); 52 53 return outSize; 54 } 55 56 return wcslcpy(dest, src, destSize); 57} 58 59 60B_DEFINE_WEAK_ALIAS(__wcsxfrm_l, wcsxfrm_l); 61