1*600f14f4SXin Li /* metaflac - Command-line FLAC metadata editor
2*600f14f4SXin Li * Copyright (C) 2001-2009 Josh Coalson
3*600f14f4SXin Li * Copyright (C) 2011-2023 Xiph.Org Foundation
4*600f14f4SXin Li *
5*600f14f4SXin Li * This program is free software; you can redistribute it and/or
6*600f14f4SXin Li * modify it under the terms of the GNU General Public License
7*600f14f4SXin Li * as published by the Free Software Foundation; either version 2
8*600f14f4SXin Li * of the License, or (at your option) any later version.
9*600f14f4SXin Li *
10*600f14f4SXin Li * This program is distributed in the hope that it will be useful,
11*600f14f4SXin Li * but WITHOUT ANY WARRANTY; without even the implied warranty of
12*600f14f4SXin Li * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13*600f14f4SXin Li * GNU General Public License for more details.
14*600f14f4SXin Li *
15*600f14f4SXin Li * You should have received a copy of the GNU General Public License along
16*600f14f4SXin Li * with this program; if not, write to the Free Software Foundation, Inc.,
17*600f14f4SXin Li * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18*600f14f4SXin Li */
19*600f14f4SXin Li
20*600f14f4SXin Li #ifdef HAVE_CONFIG_H
21*600f14f4SXin Li # include <config.h>
22*600f14f4SXin Li #endif
23*600f14f4SXin Li
24*600f14f4SXin Li #include "operations.h"
25*600f14f4SXin Li #include "options.h"
26*600f14f4SXin Li #include <locale.h>
27*600f14f4SXin Li #include <stdlib.h>
28*600f14f4SXin Li #include <string.h>
29*600f14f4SXin Li #include "share/compat.h"
30*600f14f4SXin Li
31*600f14f4SXin Li #ifndef FUZZ_TOOL_METAFLAC
main(int argc,char * argv[])32*600f14f4SXin Li int main(int argc, char *argv[])
33*600f14f4SXin Li #else
34*600f14f4SXin Li static int main_to_fuzz(int argc, char *argv[])
35*600f14f4SXin Li #endif
36*600f14f4SXin Li {
37*600f14f4SXin Li CommandLineOptions options;
38*600f14f4SXin Li int ret = 0;
39*600f14f4SXin Li
40*600f14f4SXin Li #ifdef __EMX__
41*600f14f4SXin Li _response(&argc, &argv);
42*600f14f4SXin Li _wildcard(&argc, &argv);
43*600f14f4SXin Li #endif
44*600f14f4SXin Li #ifdef _WIN32
45*600f14f4SXin Li if (get_utf8_argv(&argc, &argv) != 0) {
46*600f14f4SXin Li fputs("ERROR: failed to convert command line parameters to UTF-8\n", stderr);
47*600f14f4SXin Li return 1;
48*600f14f4SXin Li }
49*600f14f4SXin Li #endif
50*600f14f4SXin Li
51*600f14f4SXin Li #ifdef _WIN32
52*600f14f4SXin Li {
53*600f14f4SXin Li const char *var;
54*600f14f4SXin Li var = getenv("LC_ALL");
55*600f14f4SXin Li if (!var)
56*600f14f4SXin Li var = getenv("LC_NUMERIC");
57*600f14f4SXin Li if (!var)
58*600f14f4SXin Li var = getenv("LANG");
59*600f14f4SXin Li if (!var || strcmp(var, "C") != 0)
60*600f14f4SXin Li setlocale(LC_ALL, "");
61*600f14f4SXin Li }
62*600f14f4SXin Li #else
63*600f14f4SXin Li setlocale(LC_ALL, "");
64*600f14f4SXin Li #endif
65*600f14f4SXin Li init_options(&options);
66*600f14f4SXin Li
67*600f14f4SXin Li if ((ret = parse_options(argc, argv, &options)) == 0)
68*600f14f4SXin Li ret = !do_operations(&options);
69*600f14f4SXin Li else
70*600f14f4SXin Li ret = 1;
71*600f14f4SXin Li
72*600f14f4SXin Li free_options(&options);
73*600f14f4SXin Li
74*600f14f4SXin Li return ret;
75*600f14f4SXin Li }
76