-
Notifications
You must be signed in to change notification settings - Fork 2
/
setlocale.c
80 lines (54 loc) · 1.9 KB
/
setlocale.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/*++
toro C Library
https://github.com/KilianKegel/toro-C-Library#toro-c-library-formerly-known-as-torito-c-library
Copyright (c) 2017-2024, Kilian Kegel. All rights reserved.
SPDX-License-Identifier: GNU General Public License v3.0
Module Name:
setlocale.c
Abstract:
Implementation of the Standard C function.
Sets or retrieves the run-time locale.
NOTE: minimized functionality
only LC_ALL and "C" accepted as parameters
Author:
Kilian Kegel
--*/
#include <CdeServices.h>
#include <string.h>
#include <locale.h>
extern struct _CDE_LCONV_LANGUAGE* _locales[];
/** setlocale()
*
Synopsis
#include <locale.h>
char *setlocale(int category, const char *locale);
Description
Sets or retrieves the run-time locale.
NOTE: minimized functionality
only LC_ALL and "C" accepted as parameters
https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/setlocale-wsetlocale?view=msvc-160&viewFallbackFrom=vs-2019
Paramters
https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/setlocale-wsetlocale?view=msvc-160#parameters
Returns
https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/setlocale-wsetlocale?view=msvc-160#return-value
**/
char* setlocale(int nCat, char const* szLocale) {
CDE_APP_IF* pCdeAppIf = __cdeGetAppIf();
char* pszRet = NULL;
struct _CDE_LCONV_LANGUAGE** ppLocales = &_locales[-1];
do {
if (nCat != LC_ALL)
break;
if (NULL == szLocale)
break;
while ((*++ppLocales)->szLanguageCountry != NULL) {
if (0 == strcmp((*ppLocales)->szLanguageCountry, szLocale))
{
memcpy(&pCdeAppIf->ActiveLocale,ppLocales,sizeof(struct _CDE_LCONV_LANGUAGE));
pszRet = (*ppLocales)->szLanguageCountry;
break;
}
}
} while (0);
return pszRet;
}