xref: /haiku/src/system/libroot/posix/string/strxfrm.cpp (revision cbe0a0c436162d78cc3f92a305b64918c839d079)
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 
14 using BPrivate::Libroot::gLocaleBackend;
15 
16 
17 extern "C" size_t
18 strxfrm(char *out, const char *in, size_t size)
19 {
20 	if (gLocaleBackend != NULL) {
21 		size_t outSize = 0;
22 		status_t status =  gLocaleBackend->Strxfrm(out, in, size, outSize);
23 
24 		if (status != B_OK)
25 			__set_errno(EINVAL);
26 
27 		return outSize;
28 	}
29 
30 	return strlcpy(out, in, size);
31 }
32