vaseboot/VasEBoot-core/osdep/aros/config.c

95 lines
2.3 KiB
C

/*
* VasEBoot -- GRand Unified Bootloader
* Copyright (C) 1999,2000,2001,2002,2003,2004,2006,2007,2008,2009,2010,2011,2012,2013 Free Software Foundation, Inc.
*
* VasEBoot is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* VasEBoot 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with VasEBoot. If not, see <http://www.gnu.org/licenses/>.
*/
#include <config.h>
#include <config-util.h>
#include <VasEBoot/emu/hostdisk.h>
#include <VasEBoot/emu/exec.h>
#include <VasEBoot/emu/config.h>
#include <VasEBoot/util/install.h>
#include <VasEBoot/util/misc.h>
#include <string.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <errno.h>
#include <stdlib.h>
const char *
VasEBoot_util_get_config_filename (void)
{
static char *value = NULL;
if (!value)
value = VasEBoot_util_path_concat (3, VasEBoot_SYSCONFDIR,
"default", "VasEBoot");
return value;
}
const char *
VasEBoot_util_get_pkgdatadir (void)
{
const char *ret = getenv ("pkgdatadir");
if (ret)
return ret;
return VasEBoot_DATADIR "/" PACKAGE;
}
const char *
VasEBoot_util_get_pkglibdir (void)
{
return VasEBoot_LIBDIR "/" PACKAGE;
}
const char *
VasEBoot_util_get_localedir (void)
{
return LOCALEDIR;
}
void
VasEBoot_util_load_config (struct VasEBoot_util_config *cfg)
{
const char *cfgfile;
FILE *f = NULL;
const char *v;
memset (cfg, 0, sizeof (*cfg));
v = getenv ("VasEBoot_ENABLE_CRYPTODISK");
if (v && v[0] == 'y' && v[1] == '\0')
cfg->is_cryptodisk_enabled = 1;
v = getenv ("VasEBoot_DISTRIBUTOR");
if (v)
cfg->VasEBoot_distributor = xstrdup (v);
cfgfile = VasEBoot_util_get_config_filename ();
if (!VasEBoot_util_is_regular (cfgfile))
return;
f = VasEBoot_util_fopen (cfgfile, "r");
if (f)
{
VasEBoot_util_parse_config (f, cfg, 0);
fclose (f);
}
else
VasEBoot_util_warn (_("cannot open configuration file `%s': %s"),
cfgfile, strerror (errno));
}