1/* 2 * Copyright 2005, Ingo Weinhold <bonefish@cs.tu-berlin.de>. 3 * Copyright 2010, Oliver Tappe, zooey@hirschkaefer.de. 4 * All rights reserved. Distributed under the terms of the MIT license. 5 */ 6 7#include <errno.h> 8#include <string.h> 9 10#include <errno_private.h> 11#include "LocaleBackend.h" 12 13 14using BPrivate::Libroot::GetCurrentLocaleBackend; 15using BPrivate::Libroot::LocaleBackend; 16using BPrivate::Libroot::LocaleBackendData; 17 18 19extern "C" size_t 20strxfrm(char *out, const char *in, size_t size) 21{ 22 LocaleBackend* backend = GetCurrentLocaleBackend(); 23 24 if (backend != NULL) { 25 size_t outSize = 0; 26 status_t status = backend->Strxfrm(out, in, size, outSize); 27 28 if (status != B_OK) 29 __set_errno(EINVAL); 30 31 return outSize; 32 } 33 34 return strlcpy(out, in, size); 35} 36 37 38extern "C" size_t 39strxfrm_l(char *out, const char *in, size_t size, locale_t l) 40{ 41 LocaleBackendData* locale = (LocaleBackendData*)l; 42 LocaleBackend* backend = locale->backend; 43 44 if (backend != NULL) { 45 size_t outSize = 0; 46 status_t status = backend->Strxfrm(out, in, size, outSize); 47 48 if (status != B_OK) 49 __set_errno(EINVAL); 50 51 return outSize; 52 } 53 54 return strlcpy(out, in, size); 55} 56