Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- struct id3tag {
- char *title[31];
- char *interpret[31];
- char *album[31];
- char *year[5];
- char *comment[31];
- int *genre[1];
- } tag;
- int print_id3(char *filename) {
- FILE *file;
- char tag_mark[3] = {"TAG"};
- int bool, i;
- file = fopen(filename, "r");
- if (file == NULL) {
- return 1;
- }
- // Dateizeiger auf die Position 128 bytes vor Dateiende setzen
- int status_fseek = fseek(file, -128, SEEK_END);
- if (status_fseek != 0) {
- (void) fclose(file);
- return 3;
- }
- // die ersten 3 Byte auslesen
- char tag_read[3];
- (void) fread((void *) &tag_read, 1, 3, file);
- if (ferror(file) != 0) {
- (void) fclose(file);
- return 3;
- }
- // wenn die ersten drei Byte TAG heißen, dann ist ein id3tag geschrieben
- for (i = 0; i < 3; i++) {
- bool = (tag_mark[i] == tag_read[i]) ? 1 : 0;
- }
- if (bool == 1) {
- (void) fread((void *) &tag.title, 1, sizeof(((struct id3tag *) 0)->title) / 8 - 1, file);
- tag.title[30] = "\0";
- (void) fread((void *) &tag.interpret, 1, sizeof(((struct id3tag *) 0)->interpret) / 8 - 1, file);
- tag.interpret[30] = "\0";
- (void) fread((void *) &tag.album, 1, sizeof(((struct id3tag *) 0)->album) / 8 - 1, file);
- tag.album[30] = "\0";
- (void) fread((void *) &tag.comment, 1, sizeof(((struct id3tag *) 0)->comment) / 8 - 1, file);
- tag.comment[30] = "\0";
- (void) fread((void *) &tag.year, 1, sizeof(((struct id3tag *) 0)->year) / 8 - 1, file);
- tag.year[4] = "\0";
- (void) fread((void *) &tag.genre, 1, sizeof(((struct id3tag *) 0)->genre) / 8 - 1, file);
- (void) fclose(file);
- return 0;
- } else {
- (void) fclose(file);
- return 2;
- }
Advertisement
Add Comment
Please, Sign In to add comment