3 <<getlocalename_l>>---create or modify a locale object
13 locale_t getlocalename_l(int <[category]>, locale_t <[locobj]>);
15 locale_t _getlocalename_l_r(void *<[reent]>, int <[category]>,
19 The <<getlocalename_l>> function shall return the locale name for the
20 given locale category of the locale object locobj, or of the global
21 locale if locobj is the special locale object LC_GLOBAL_LOCALE.
23 The category argument specifies the locale category to be queried. If
24 the value is LC_ALL or is not a supported locale category value (see
25 <<setlocale>>), <<getlocalename_l>> shall fail.
27 The behavior is undefined if the locobj argument is neither the special
28 locale object LC_GLOBAL_LOCALE nor a valid locale object handle.
31 Upon successful completion, <<getlocalename_l>> shall return a pointer
32 to a string containing the locale name; otherwise, a null pointer shall
35 If locobj is LC_GLOBAL_LOCALE, the returned string pointer might be
36 invalidated or the string content might be overwritten by a subsequent
37 call in the same thread to <<getlocalename_l>> with LC_GLOBAL_LOCALE;
38 the returned string pointer might also be invalidated if the calling
39 thread is terminated. Otherwise, the returned string pointer and content
40 shall remain valid until the locale object locobj is used in a call to
41 <<freelocale>> or as the base argument in a successful call to
44 No errors are defined.
47 <<getlocalename_l>> is POSIX-1.2008 since Base Specification Issue 8
51 #include "setlocale.h"
54 _getlocalename_l_r (struct _reent
*ptr
, int category
, struct __locale_t
*locobj
)
56 if (category
<= LC_ALL
|| category
> LC_MESSAGES
)
61 if (locobj
== LC_GLOBAL_LOCALE
)
63 /* getlocalename_l is supposed to return the value in a
64 thread-safe manner. This requires to copy over the
65 category string into thread-local storage. */
66 strcpy (_REENT_GETLOCALENAME_L_BUF (ptr
),
67 __get_global_locale ()->categories
[category
]);
69 return locobj
->categories
[category
];
74 getlocalename_l (int category
, struct __locale_t
*locobj
)
76 return _getlocalename_l_r (_REENT
, category
, locobj
);