locale-setup.c revision 5430f7f2bc7330f3088b894166bf3524a067e3d8
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
/***
This file is part of systemd.
Copyright 2010 Lennart Poettering
under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
systemd is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
#include <string.h>
#include <stdlib.h>
#include <errno.h>
#include "locale-setup.h"
#include "util.h"
#include "macro.h"
#include "virt.h"
enum {
/* We don't list LC_ALL here on purpose. People should be
* using LANG instead. */
};
static const char * const variable_names[_VARIABLE_MAX] = {
[VARIABLE_LANG] = "LANG",
[VARIABLE_LANGUAGE] = "LANGUAGE",
[VARIABLE_LC_CTYPE] = "LC_CTYPE",
[VARIABLE_LC_NUMERIC] = "LC_NUMERIC",
[VARIABLE_LC_TIME] = "LC_TIME",
[VARIABLE_LC_COLLATE] = "LC_COLLATE",
[VARIABLE_LC_MONETARY] = "LC_MONETARY",
[VARIABLE_LC_MESSAGES] = "LC_MESSAGES",
[VARIABLE_LC_PAPER] = "LC_PAPER",
[VARIABLE_LC_NAME] = "LC_NAME",
[VARIABLE_LC_ADDRESS] = "LC_ADDRESS",
[VARIABLE_LC_TELEPHONE] = "LC_TELEPHONE",
[VARIABLE_LC_MEASUREMENT] = "LC_MEASUREMENT",
[VARIABLE_LC_IDENTIFICATION] = "LC_IDENTIFICATION"
};
int locale_setup(void) {
char *variables[_VARIABLE_MAX];
int r = 0, i;
if (detect_container(NULL) <= 0)
#if defined(TARGET_FEDORA) || defined(TARGET_MEEGO)
#endif
NULL)) < 0) {
if (r != -ENOENT)
}
/* Hmm, nothing set on the kernel cmd line? Then let's
* try /etc/locale.conf */
if (r <= 0 &&
NULL)) < 0) {
if (r != -ENOENT)
}
if (r <= 0 &&
NULL)) < 0) {
if (r != -ENOENT)
}
#elif defined(TARGET_SUSE)
if (r <= 0 &&
NULL)) < 0) {
if (r != -ENOENT)
}
if (r <= 0 &&
NULL)) < 0) {
if (r != -ENOENT)
}
#elif defined(TARGET_ARCH)
if (r <= 0 &&
NULL)) < 0) {
if (r != -ENOENT)
}
#elif defined(TARGET_GENTOO)
* These files are later compiled by env-update into shell
* export commands at /etc/profile.env, with variables being
*/
if (r <= 0 &&
NULL)) < 0) {
if (r != -ENOENT)
}
if (r <= 0 &&
NULL)) < 0) {
if (r != -ENOENT)
}
#endif
if (!variables[VARIABLE_LANG]) {
r = -ENOMEM;
goto finish;
}
}
for (i = 0; i < _VARIABLE_MAX; i++) {
if (variables[i]) {
r = -errno;
goto finish;
}
} else
unsetenv(variable_names[i]);
}
r = 0;
for (i = 0; i < _VARIABLE_MAX; i++)
return r;
}