1 /*
2 * madplay - MPEG audio decoder and player
3 * Copyright (C) 2000-2004 Robert Leslie
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 *
19 * $Id: tagger.c,v 1.6 2004/01/23 09:41:32 rob Exp $
20 */
21
22 # ifdef HAVE_CONFIG_H
23 # include "config.h"
24 # endif
25
26 # include "global.h"
27
28 # include <stdio.h>
29 # include <id3tag.h>
30
31 # include "tagger.h"
32
tagger_init(struct tagger * tagger)33 void tagger_init(struct tagger *tagger)
34 {
35 tagger->mode = TAGGER_MODE_DISPLAY;
36 }
37
tagger_finish(struct tagger * tagger)38 void tagger_finish(struct tagger *tagger)
39 {
40 }
41
42 static
tag_one(struct tagger * tagger,char const * path)43 int tag_one(struct tagger *tagger, char const *path)
44 {
45 struct id3_file *file;
46
47 file = id3_file_open(path, tagger->mode == TAGGER_MODE_MODIFY ?
48 ID3_FILE_MODE_READWRITE : ID3_FILE_MODE_READONLY);
49 if (file == 0) {
50 perror(path);
51 return -1;
52 }
53
54 /* ... */
55
56 if (id3_file_close(file) == -1) {
57 perror(path);
58 return -1;
59 }
60
61 return 0;
62 }
63
tagger_run(struct tagger * tagger,int argc,char const * argv[])64 int tagger_run(struct tagger *tagger, int argc, char const *argv[])
65 {
66 int i, result = 0;
67
68 for (i = 0; i < argc; ++i) {
69 if (tag_one(tagger, argv[i]) == -1)
70 result = -1;
71 }
72
73 return result;
74 }
75