/* metaflac - Command-line FLAC metadata editor
- * Copyright (C) 2001 Josh Coalson
+ * Copyright (C) 2001,2002,2003,2004,2005,2006,2007,2008,2009 Josh Coalson
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* 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 this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-#include <assert.h>
-#include <ctype.h>
-#include <stdarg.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include "FLAC/all.h"
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif
-static int usage(const char *message, ...);
+#include "operations.h"
+#include "options.h"
+#include <locale.h>
+#include <stdlib.h>
int main(int argc, char *argv[])
{
- bool verbose, list_mode;
-
- if(argc <= 1)
- return usage(0);
-
- /* get the options */
- for(i = 1; i < argc; i++) {
- if(argv[i][0] != '-' || argv[i][1] == 0)
- break;
- if(0 == strcmp(argv[i], "-l"))
- list_mode = true;
- else if(0 == strcmp(argv[i], "-v"))
- verbose = true;
- else if(0 == strcmp(argv[i], "-v-"))
- verbose = false;
- else {
- return usage("ERROR: invalid option '%s'\n", argv[i]);
- }
- }
- if(i + (list_mode? 1:2) != argc)
- return usage("ERROR: invalid arguments (more/less than %d filename%s?)\n", (list_mode? 1:2), (list_mode? "":"s"));
-
- return 0;
-}
-
-int usage(const char *message, ...)
-{
- va_list args;
+ CommandLineOptions options;
+ int ret = 0;
- if(message) {
- va_start(args, message);
+#ifdef __EMX__
+ _response(&argc, &argv);
+ _wildcard(&argc, &argv);
+#endif
- (void) vfprintf(stderr, message, args);
+ setlocale(LC_ALL, "");
+ init_options(&options);
- va_end(args);
+ if ((ret = parse_options(argc, argv, &options)) == 0)
+ ret = !do_operations(&options);
+ else
+ ret = 1;
- }
- printf("==============================================================================\n");
- printf("metaflac - Command-line FLAC metadata editor version %s\n", FLAC__VERSION_STRING);
- printf("Copyright (C) 2001 Josh Coalson\n");
- printf("\n");
- printf("This program is free software; you can redistribute it and/or\n");
- printf("modify it under the terms of the GNU General Public License\n");
- printf("as published by the Free Software Foundation; either version 2\n");
- printf("of the License, or (at your option) any later version.\n");
- printf("\n");
- printf("This program is distributed in the hope that it will be useful,\n");
- printf("but WITHOUT ANY WARRANTY; without even the implied warranty of\n");
- printf("MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n");
- printf("GNU General Public License for more details.\n");
- printf("\n");
- printf("You should have received a copy of the GNU General Public License\n");
- printf("along with this program; if not, write to the Free Software\n");
- printf("Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.\n");
- printf("==============================================================================\n");
- printf("Usage:\n");
- printf(" metaflac [options] infile [outfile]\n");
- printf("\n");
- printf("options:\n");
- printf(" -l : list metadata blocks\n");
- printf(" -v : verbose\n");
- printf(" -v- can all be used to turn off a particular option\n");
+ free_options(&options);
- return 1;
+ return ret;
}