Blame src/metaflac/main.c

Packit 8f7830
/* metaflac - Command-line FLAC metadata editor
Packit 8f7830
 * Copyright (C) 2001-2009  Josh Coalson
Packit 8f7830
 * Copyright (C) 2011-2016  Xiph.Org Foundation
Packit 8f7830
 *
Packit 8f7830
 * This program is free software; you can redistribute it and/or
Packit 8f7830
 * modify it under the terms of the GNU General Public License
Packit 8f7830
 * as published by the Free Software Foundation; either version 2
Packit 8f7830
 * of the License, or (at your option) any later version.
Packit 8f7830
 *
Packit 8f7830
 * This program is distributed in the hope that it will be useful,
Packit 8f7830
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 8f7830
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit 8f7830
 * GNU General Public License for more details.
Packit 8f7830
 *
Packit 8f7830
 * You should have received a copy of the GNU General Public License along
Packit 8f7830
 * with this program; if not, write to the Free Software Foundation, Inc.,
Packit 8f7830
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Packit 8f7830
 */
Packit 8f7830
Packit 8f7830
#ifdef HAVE_CONFIG_H
Packit 8f7830
#  include <config.h>
Packit 8f7830
#endif
Packit 8f7830
Packit 8f7830
#include "operations.h"
Packit 8f7830
#include "options.h"
Packit 8f7830
#include <locale.h>
Packit 8f7830
#include <stdlib.h>
Packit 8f7830
#include <string.h>
Packit 8f7830
#include "share/compat.h"
Packit 8f7830
Packit 8f7830
int main(int argc, char *argv[])
Packit 8f7830
{
Packit 8f7830
	CommandLineOptions options;
Packit 8f7830
	int ret = 0;
Packit 8f7830
Packit 8f7830
#ifdef __EMX__
Packit 8f7830
	_response(&argc, &argv);
Packit 8f7830
	_wildcard(&argc, &argv);
Packit 8f7830
#endif
Packit 8f7830
#ifdef _WIN32
Packit 8f7830
	if (get_utf8_argv(&argc, &argv) != 0) {
Packit 8f7830
		fputs("ERROR: failed to convert command line parameters to UTF-8\n", stderr);
Packit 8f7830
		return 1;
Packit 8f7830
	}
Packit 8f7830
#endif
Packit 8f7830
Packit 8f7830
#ifdef _WIN32
Packit 8f7830
	{
Packit 8f7830
		const char *var;
Packit 8f7830
		var = getenv("LC_ALL");
Packit 8f7830
		if (!var)
Packit 8f7830
			var = getenv("LC_NUMERIC");
Packit 8f7830
		if (!var)
Packit 8f7830
			var = getenv("LANG");
Packit 8f7830
		if (!var || strcmp(var, "C") != 0)
Packit 8f7830
			setlocale(LC_ALL, "");
Packit 8f7830
	}
Packit 8f7830
#else
Packit 8f7830
	setlocale(LC_ALL, "");
Packit 8f7830
#endif
Packit 8f7830
	init_options(&options);
Packit 8f7830
Packit 8f7830
	if ((ret = parse_options(argc, argv, &options)) == 0)
Packit 8f7830
		ret = !do_operations(&options);
Packit 8f7830
	else
Packit 8f7830
		ret = 1;
Packit 8f7830
Packit 8f7830
	free_options(&options);
Packit 8f7830
Packit 8f7830
	return ret;
Packit 8f7830
}