コード例 #1
0
ファイル: mu-runtime.c プロジェクト: Chris00/mu
gboolean
mu_runtime_init (const char* muhome_arg, const char *name)
{
	gchar *muhome;

	g_return_val_if_fail (!_initialized, FALSE);
	g_return_val_if_fail (name, FALSE);

	setlocale (LC_ALL, "");

#ifndef GLIB_VERSION_2_36
	g_type_init ();
#endif /*GLIB_VERSION_2_36*/

	if (muhome_arg)
		muhome = g_strdup (muhome_arg);
	else
		muhome = mu_util_guess_mu_homedir ();

	if (!mu_util_create_dir_maybe (muhome, 0700, TRUE)) {
		g_printerr ("mu: invalid mu homedir specified;"
			    " use --muhome=<dir>\n");
		runtime_free ();
		return FALSE;
	}

	_data = g_new0 (MuRuntimeData, 1);
	_data->_str[MU_RUNTIME_PATH_MUHOME] = muhome;

	init_paths (muhome, _data);
	_data->_name = g_strdup (name);

	if (!init_log (muhome, name, MU_LOG_OPTIONS_BACKUP)) {
		runtime_free ();
		g_free (muhome);
		return FALSE;
	}

	return _initialized = TRUE;
}
コード例 #2
0
ファイル: mu-config.c プロジェクト: DarwinAwardWinner/mu
static void
set_group_mu_defaults (void)
{
	gchar *exp;

	if (!MU_CONFIG.muhome)
		MU_CONFIG.muhome = mu_util_guess_mu_homedir();

	exp = mu_util_dir_expand(MU_CONFIG.muhome);
	if (exp) {
		g_free(MU_CONFIG.muhome);
		MU_CONFIG.muhome = exp;
	}

	/* check for the MU_NOCOLOR env var; but in any case don't
	 * use colors unless we're writing to a tty */
	if (g_getenv (MU_NOCOLOR) != NULL)
		MU_CONFIG.nocolor = TRUE;

	if (!isatty(fileno(stdout)))
		MU_CONFIG.nocolor = TRUE;
}