-
Notifications
You must be signed in to change notification settings - Fork 0
/
id3v1read.c
45 lines (37 loc) · 1000 Bytes
/
id3v1read.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include <stdio.h>
#include <stdlib.h>
#include <libgen.h> /* basename() */
#include "id3v1.h"
static void usage(char *argv[]);
int main(int argc, char *argv[])
{
int n;
struct id3v1tag tag;
FILE *mp3;
if (argc < 2)
usage(argv);
for (n=1; n < argc; ++n)
{
if ((mp3=fopen(argv[n], "r")) == NULL) {
fprintf(stderr, "cannot open \"%s\", skipping.\n", argv[n]);
continue;
}
if (get_id3v1_tag(mp3, &tag) == NOTAG) {
fprintf(stderr, "cannot read tag data of \"%s\", skipping.\n", argv[n]);
fclose(mp3);
continue;
} else {
printf("FILE\t%s\n", argv[n]);
print_id3v1_tag(&tag);
printf("\n");
fclose(mp3);
}
}
return 0;
}
static void usage(char *argv[])
{
fprintf(stderr, "usage: %s <file> [file2 ...]\n", basename(argv[0]));
fprintf(stderr, "read id3v1.x mp3 tag info.\n");
exit(EXIT_FAILURE);
}