From b6d80895594816fcb9f3a7f69a513f985db89272 Mon Sep 17 00:00:00 2001 From: Sergey Poznyakoff Date: Fri, 8 Jul 2011 13:13:17 +0300 Subject: Implement the --info option. * NEWS: Update. * configure.ac: Version 1.2.90 * doc/idest.texi: Document the --info option. * libid3tag/file.c (id3_file_struct_ntags) (id3_file_struct_iterate): New functions. * libid3tag/file.h (id3_file_struct_ntags) (id3_file_struct_iterate): New protos. (id3_file_struct_iterator_t): New data type. * src/cmdline.opt: New option --info. * src/idest.h (info_id3): New proto. (del_id3v2): Remove. * src/idop.c (info_id3): New function. * src/main.c (id3_mode): Add info_id3. --- libid3tag/file.c | 27 +++++++++++++++++++++++++++ libid3tag/file.h | 11 +++++++++++ 2 files changed, 38 insertions(+) (limited to 'libid3tag') diff --git a/libid3tag/file.c b/libid3tag/file.c index 1feb504..7c483ef 100644 --- a/libid3tag/file.c +++ b/libid3tag/file.c @@ -885,3 +885,30 @@ id3_file_update(struct id3_file *file) return result; } + +unsigned int +id3_file_struct_ntags(struct id3_file *file) +{ + assert(file); + return file->ntags; +} + +int +id3_file_struct_iterate(struct id3_file *file, + id3_file_struct_iterator_t fun, + void *data) +{ + int i; + int rc = 0; + + assert(file); + + for (i = 0; i < file->ntags; i++) { + struct filetag *tag = file->tags + i; + + rc = fun(tag->tag, tag->location, tag->length, data); + if (rc) + break; + } + return 0; +} diff --git a/libid3tag/file.h b/libid3tag/file.h index c948b84..304b654 100644 --- a/libid3tag/file.h +++ b/libid3tag/file.h @@ -22,4 +22,15 @@ #ifndef LIBID3TAG_FILE_H # define LIBID3TAG_FILE_H +unsigned int id3_file_struct_ntags(struct id3_file *file); + +typedef int (*id3_file_struct_iterator_t)(struct id3_tag *tag, + unsigned long location, + id3_length_t length, + void *data); +int id3_file_struct_iterate(struct id3_file *file, + id3_file_struct_iterator_t fun, + void *data); + + #endif -- cgit v1.2.1