Changeset View
Changeset View
Standalone View
Standalone View
lib/libc/nls/msgcat.c
Show First 20 Lines • Show All 52 Lines • ▼ Show 20 Lines | |||||
#include <pthread.h> | #include <pthread.h> | ||||
#include <stdio.h> | #include <stdio.h> | ||||
#include <stdlib.h> | #include <stdlib.h> | ||||
#include <string.h> | #include <string.h> | ||||
#include <unistd.h> | #include <unistd.h> | ||||
#include "un-namespace.h" | #include "un-namespace.h" | ||||
#include "../locale/xlocale_private.h" | #include "../locale/xlocale_private.h" | ||||
#include "libc_private.h" | |||||
#define _DEFAULT_NLS_PATH "/usr/share/nls/%L/%N.cat:/usr/share/nls/%N/%L:" \ | #define _DEFAULT_NLS_PATH "/usr/share/nls/%L/%N.cat:/usr/share/nls/%N/%L:" \ | ||||
_PATH_LOCALBASE "/share/nls/%L/%N.cat:" \ | _PATH_LOCALBASE "/share/nls/%L/%N.cat:" \ | ||||
_PATH_LOCALBASE "/share/nls/%N/%L" | _PATH_LOCALBASE "/share/nls/%N/%L" | ||||
#define RLOCK(fail) { int ret; \ | #define RLOCK(fail) { int ret; \ | ||||
if (__isthreaded && \ | if (__isthreaded && \ | ||||
((ret = _pthread_rwlock_rdlock(&rwlock)) != 0)) { \ | ((ret = _pthread_rwlock_rdlock(&rwlock)) != 0)) { \ | ||||
▲ Show 20 Lines • Show All 48 Lines • ▼ Show 20 Lines | |||||
}; | }; | ||||
SLIST_HEAD(listhead, catentry) cache = | SLIST_HEAD(listhead, catentry) cache = | ||||
SLIST_HEAD_INITIALIZER(cache); | SLIST_HEAD_INITIALIZER(cache); | ||||
nl_catd | nl_catd | ||||
catopen(const char *name, int type) | catopen(const char *name, int type) | ||||
{ | { | ||||
return (__catopen_l(name, type, __get_locale())); | |||||
} | |||||
nl_catd | |||||
__catopen_l(const char *name, int type, locale_t locale) | |||||
{ | |||||
struct stat sbuf; | struct stat sbuf; | ||||
struct catentry *np; | struct catentry *np; | ||||
char *base, *cptr, *cptr1, *nlspath, *pathP, *pcode; | char *base, *cptr, *cptr1, *nlspath, *pathP, *pcode; | ||||
char *plang, *pter; | char *plang, *pter; | ||||
int saverr, spcleft; | int saverr, spcleft; | ||||
const char *lang, *tmpptr; | const char *lang, *tmpptr; | ||||
char path[PATH_MAX]; | char path[PATH_MAX]; | ||||
/* sanity checking */ | /* sanity checking */ | ||||
if (name == NULL || *name == '\0') | if (name == NULL || *name == '\0') | ||||
NLRETERR(EINVAL); | NLRETERR(EINVAL); | ||||
if (strchr(name, '/') != NULL) | if (strchr(name, '/') != NULL) | ||||
/* have a pathname */ | /* have a pathname */ | ||||
lang = NULL; | lang = NULL; | ||||
else { | else { | ||||
if (type == NL_CAT_LOCALE) | if (type == NL_CAT_LOCALE) | ||||
lang = querylocale(LC_MESSAGES_MASK, __get_locale()); | lang = querylocale(LC_MESSAGES_MASK, locale); | ||||
else | else | ||||
lang = getenv("LANG"); | lang = getenv("LANG"); | ||||
if (lang == NULL || *lang == '\0' || strlen(lang) > ENCODING_LEN || | if (lang == NULL || *lang == '\0' || strlen(lang) > ENCODING_LEN || | ||||
(lang[0] == '.' && | (lang[0] == '.' && | ||||
(lang[1] == '\0' || (lang[1] == '.' && lang[2] == '\0'))) || | (lang[1] == '\0' || (lang[1] == '.' && lang[2] == '\0'))) || | ||||
strchr(lang, '/') != NULL) | strchr(lang, '/') != NULL) | ||||
lang = "C"; | lang = "C"; | ||||
▲ Show 20 Lines • Show All 327 Lines • Show Last 20 Lines |