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