+extern int optind;
+
+int
+main (int argc, char **argv)
+{
+ unsigned int arg_cnt = 0;
+
+ bool bold = false;
+
+ const struct color *colors[2] = {
+ NULL, /* foreground */
+ NULL, /* background */
+ };
+
+ const char *file = NULL;
+
+ program_name = argv[0];
+ atexit (cleanup);
+
+ setvbuf (stdout, NULL, _IOLBF, 0);
+
+#if DEBUG
+ log = open_file (DEBUG_FILE, "w");
+#endif
+
+ process_opts (argc, argv);
+
+ arg_cnt = argc - optind;
+
+ if (clean || clean_all)
+ {
+ if (clean && clean_all)
+ vfprintf_fail (formats[FMT_GENERIC], "--clean and --clean-all switch are mutually exclusive");
+ if (arg_cnt > 1)
+ {
+ const char *format = "%s %s";
+ const char *message = "switch cannot be used with more than one file";
+ if (clean)
+ vfprintf_fail (format, "--clean", message);
+ else if (clean_all)
+ vfprintf_fail (format, "--clean-all", message);
+ }
+ }
+ else
+ {
+ if (arg_cnt == 0 || arg_cnt > 2)
+ {
+ vfprintf_diag ("%u arguments provided, expected 1-2 arguments or clean option", arg_cnt);
+ print_hint ();
+ exit (EXIT_FAILURE);
+ }
+ }
+
+ if (clean || clean_all)
+ process_file_arg (argv[optind], &file, &stream);
+ else
+ process_args (arg_cnt, &argv[optind], &bold, colors, &file, &stream);
+ read_print_stream (bold, colors, file, stream);
+
+ RELEASE_VAR (exclude);
+
+ exit (EXIT_SUCCESS);
+}
+