| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
#ifdef HAVE_CONFIG_H |
| 20 |
# include <gsm_config.h> |
| 21 |
#endif |
| 22 |
|
| 23 |
#include <ctype.h> |
| 24 |
#include <errno.h> |
| 25 |
#include <stdio.h> |
| 26 |
#include <sys/types.h> |
| 27 |
|
| 28 |
#if defined STDC_HEADERS || defined _LIBC |
| 29 |
# include <stdlib.h> |
| 30 |
#else |
| 31 |
# ifdef HAVE_MALLOC_H |
| 32 |
# include <malloc.h> |
| 33 |
# else |
| 34 |
void free (); |
| 35 |
# endif |
| 36 |
#endif |
| 37 |
|
| 38 |
#if defined HAVE_STRING_H || defined _LIBC |
| 39 |
# include <string.h> |
| 40 |
#else |
| 41 |
# include <strings.h> |
| 42 |
# ifndef memcpy |
| 43 |
# define memcpy(Dst, Src, Num) bcopy (Src, Dst, Num) |
| 44 |
# endif |
| 45 |
#endif |
| 46 |
#if !HAVE_STRCHR && !defined _LIBC |
| 47 |
# ifndef strchr |
| 48 |
# define strchr index |
| 49 |
# endif |
| 50 |
#endif |
| 51 |
|
| 52 |
#if defined HAVE_UNISTD_H || defined _LIBC |
| 53 |
# include <unistd.h> |
| 54 |
#endif |
| 55 |
|
| 56 |
#include "gettext.h" |
| 57 |
#include "gettextP.h" |
| 58 |
#ifdef _LIBC |
| 59 |
# include <libintl.h> |
| 60 |
#else |
| 61 |
# include "libgettext.h" |
| 62 |
#endif |
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
static struct loaded_l10nfile *_nl_loaded_domains; |
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
struct loaded_l10nfile * |
| 73 |
internal_function |
| 74 |
_nl_find_domain (dirname, locale, domainname) |
| 75 |
const char *dirname; |
| 76 |
char *locale; |
| 77 |
const char *domainname; |
| 78 |
{ |
| 79 |
struct loaded_l10nfile *retval; |
| 80 |
const char *language; |
| 81 |
const char *modifier; |
| 82 |
const char *territory; |
| 83 |
const char *codeset; |
| 84 |
const char *normalized_codeset; |
| 85 |
const char *special; |
| 86 |
const char *sponsor; |
| 87 |
const char *revision; |
| 88 |
const char *alias_value; |
| 89 |
int mask; |
| 90 |
|
| 91 |
|
| 92 |
|
| 93 |
|
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
|
| 98 |
|
| 99 |
|
| 100 |
|
| 101 |
|
| 102 |
|
| 103 |
|
| 104 |
|
| 105 |
|
| 106 |
|
| 107 |
|
| 108 |
|
| 109 |
|
| 110 |
|
| 111 |
|
| 112 |
|
| 113 |
|
| 114 |
retval = _nl_make_l10nflist (&_nl_loaded_domains, dirname, |
| 115 |
strlen (dirname) + 1, 0, locale, NULL, NULL, |
| 116 |
NULL, NULL, NULL, NULL, NULL, domainname, 0); |
| 117 |
if (retval != NULL) |
| 118 |
{ |
| 119 |
|
| 120 |
int cnt; |
| 121 |
|
| 122 |
if (retval->decided == 0) |
| 123 |
_nl_load_domain (retval); |
| 124 |
|
| 125 |
if (retval->data != NULL) |
| 126 |
return retval; |
| 127 |
|
| 128 |
for (cnt = 0; retval->successor[cnt] != NULL; ++cnt) |
| 129 |
{ |
| 130 |
if (retval->successor[cnt]->decided == 0) |
| 131 |
_nl_load_domain (retval->successor[cnt]); |
| 132 |
|
| 133 |
if (retval->successor[cnt]->data != NULL) |
| 134 |
break; |
| 135 |
} |
| 136 |
return cnt >= 0 ? retval : NULL; |
| 137 |
|
| 138 |
} |
| 139 |
|
| 140 |
|
| 141 |
|
| 142 |
|
| 143 |
alias_value = _nl_expand_alias (locale); |
| 144 |
if (alias_value != NULL) |
| 145 |
{ |
| 146 |
#if defined _LIBC || defined HAVE_STRDUP |
| 147 |
locale = strdup (alias_value); |
| 148 |
if (locale == NULL) |
| 149 |
return NULL; |
| 150 |
#else |
| 151 |
size_t len = strlen (alias_value) + 1; |
| 152 |
locale = (char *) malloc (len); |
| 153 |
if (locale == NULL) |
| 154 |
return NULL; |
| 155 |
|
| 156 |
memcpy (locale, alias_value, len); |
| 157 |
#endif |
| 158 |
} |
| 159 |
|
| 160 |
|
| 161 |
|
| 162 |
|
| 163 |
mask = _nl_explode_name (locale, &language, &modifier, &territory, |
| 164 |
&codeset, &normalized_codeset, &special, |
| 165 |
&sponsor, &revision); |
| 166 |
|
| 167 |
|
| 168 |
|
| 169 |
retval = _nl_make_l10nflist (&_nl_loaded_domains, dirname, |
| 170 |
strlen (dirname) + 1, mask, language, territory, |
| 171 |
codeset, normalized_codeset, modifier, special, |
| 172 |
sponsor, revision, domainname, 1); |
| 173 |
if (retval == NULL) |
| 174 |
|
| 175 |
return NULL; |
| 176 |
|
| 177 |
if (retval->decided == 0) |
| 178 |
_nl_load_domain (retval); |
| 179 |
if (retval->data == NULL) |
| 180 |
{ |
| 181 |
int cnt; |
| 182 |
for (cnt = 0; retval->successor[cnt] != NULL; ++cnt) |
| 183 |
{ |
| 184 |
if (retval->successor[cnt]->decided == 0) |
| 185 |
_nl_load_domain (retval->successor[cnt]); |
| 186 |
if (retval->successor[cnt]->data != NULL) |
| 187 |
break; |
| 188 |
} |
| 189 |
} |
| 190 |
|
| 191 |
|
| 192 |
if (alias_value != NULL) |
| 193 |
free (locale); |
| 194 |
|
| 195 |
return retval; |
| 196 |
} |
| 197 |
|
| 198 |
|
| 199 |
#ifdef _LIBC |
| 200 |
static void __attribute__ ((unused)) |
| 201 |
free_mem (void) |
| 202 |
{ |
| 203 |
struct loaded_l10nfile *runp = _nl_loaded_domains; |
| 204 |
|
| 205 |
while (runp != NULL) |
| 206 |
{ |
| 207 |
struct loaded_l10nfile *here = runp; |
| 208 |
if (runp->data != NULL) |
| 209 |
_nl_unload_domain ((struct loaded_domain *) runp->data); |
| 210 |
runp = runp->next; |
| 211 |
free (here); |
| 212 |
} |
| 213 |
} |
| 214 |
|
| 215 |
text_set_element (__libc_subfreeres, free_mem); |
| 216 |
#endif |