xref: /haiku/src/system/libroot/posix/string/strxfrm.cpp (revision a3f665982e2e078ba42e7bf941bd5f3dd8989c55)
1*a3f66598SOliver Tappe /*
2*a3f66598SOliver Tappe  * Copyright 2005, Ingo Weinhold <bonefish@cs.tu-berlin.de>.
3*a3f66598SOliver Tappe  * Copyright 2010, Oliver Tappe, zooey@hirschkaefer.de.
4*a3f66598SOliver Tappe  * All rights reserved. Distributed under the terms of the MIT license.
5*a3f66598SOliver Tappe  */
6*a3f66598SOliver Tappe 
7*a3f66598SOliver Tappe #define B_USE_POSITIVE_POSIX_ERRORS
8*a3f66598SOliver Tappe #include <errno.h>
9*a3f66598SOliver Tappe #include <string.h>
10*a3f66598SOliver Tappe 
11*a3f66598SOliver Tappe #include "LocaleBackend.h"
12*a3f66598SOliver Tappe 
13*a3f66598SOliver Tappe 
14*a3f66598SOliver Tappe using BPrivate::gLocaleBackend;
15*a3f66598SOliver Tappe 
16*a3f66598SOliver Tappe 
17*a3f66598SOliver Tappe extern "C" size_t
18*a3f66598SOliver Tappe strxfrm(char *out, const char *in, size_t size)
19*a3f66598SOliver Tappe {
20*a3f66598SOliver Tappe 	if (gLocaleBackend != NULL) {
21*a3f66598SOliver Tappe 		size_t outSize = 0;
22*a3f66598SOliver Tappe 		status_t status =  gLocaleBackend->Strxfrm(out, in, size, outSize);
23*a3f66598SOliver Tappe 
24*a3f66598SOliver Tappe 		if (status != B_OK)
25*a3f66598SOliver Tappe 			errno = EINVAL;
26*a3f66598SOliver Tappe 
27*a3f66598SOliver Tappe 		return outSize;
28*a3f66598SOliver Tappe 	}
29*a3f66598SOliver Tappe 
30*a3f66598SOliver Tappe 	return strlcpy(out, in, size);
31*a3f66598SOliver Tappe }
32