2 (c) 2004: Jelmer Vernooij <jelmer@samba.org>
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 #include "dlinklist.h"
34 #define COND_PRINTF(desc,field) if(field) printf("%s: %s\n", desc, field);
36 void write_praudio_info(struct ptb_hdr *hdr)
38 printf("Audio Type: ");
39 switch(hdr->class_info.song.release_info.pr_audio.type)
41 case AUDIO_TYPE_SINGLE: printf("Single\n"); break;
42 case AUDIO_TYPE_EP: printf("EP\n"); break;
43 case AUDIO_TYPE_ALBUM: printf("Album\n"); break;
44 case AUDIO_TYPE_DOUBLE_ALBUM: printf("Double Album\n"); break;
45 case AUDIO_TYPE_TRIPLE_ALBUM: printf("Triple Album\n"); break;
46 case AUDIO_TYPE_BOXSET: printf("Boxset\n"); break;
48 COND_PRINTF("Album Title", hdr->class_info.song.release_info.pr_audio.album_title);
49 printf("Year: %d\n", hdr->class_info.song.release_info.pr_audio.year);
50 printf("Live recording? %s\n", hdr->class_info.song.release_info.pr_audio.is_live_recording?"Yes":"No");
53 void write_prvideo_info(struct ptb_hdr *hdr)
55 COND_PRINTF("Video Title", hdr->class_info.song.release_info.pr_video.video_title);
56 printf("Year: %d\n", hdr->class_info.song.release_info.pr_video.year);
57 printf("Live recording? %s\n", hdr->class_info.song.release_info.pr_video.is_live_recording?"Yes":"No");
60 void write_bootleg_info(struct ptb_hdr *hdr)
62 COND_PRINTF("Bootleg Title", hdr->class_info.song.release_info.bootleg.title);
63 printf("Date: %d-%d-%d\n",
64 hdr->class_info.song.release_info.bootleg.day,
65 hdr->class_info.song.release_info.bootleg.month,
66 hdr->class_info.song.release_info.bootleg.year);
69 void write_song_info(struct ptb_hdr *hdr)
71 COND_PRINTF("Title", hdr->class_info.song.title);
72 COND_PRINTF("Artist", hdr->class_info.song.artist);
73 COND_PRINTF("Words By", hdr->class_info.song.words_by);
74 COND_PRINTF("Music By", hdr->class_info.song.music_by);
75 COND_PRINTF("Arranged By", hdr->class_info.song.arranged_by);
76 COND_PRINTF("Guitar Transcribed By", hdr->class_info.song.guitar_transcribed_by);
77 COND_PRINTF("Bass Transcribed By", hdr->class_info.song.bass_transcribed_by);
78 if(hdr->class_info.song.lyrics)
79 printf("Lyrics\n----------\n%s\n\n", hdr->class_info.song.lyrics);
80 COND_PRINTF("Copyright", hdr->class_info.song.copyright);
82 printf("Release type: ");
83 switch(hdr->class_info.song.release_type) {
84 case RELEASE_TYPE_PR_AUDIO:
85 printf("Public Release (Audio)\n");
86 write_praudio_info(hdr);
88 case RELEASE_TYPE_PR_VIDEO:
89 printf("Public Release (Video)\n");
90 write_prvideo_info(hdr);
92 case RELEASE_TYPE_BOOTLEG:
94 write_bootleg_info(hdr);
96 case RELEASE_TYPE_UNRELEASED:
97 printf("Unreleased\n");
102 void write_lesson_info(struct ptb_hdr *hdr)
104 COND_PRINTF("Title", hdr->class_info.lesson.title);
105 COND_PRINTF("Artist", hdr->class_info.lesson.artist);
106 printf("Style: %d\n", hdr->class_info.lesson.style);
108 switch(hdr->class_info.lesson.level) {
109 case LEVEL_BEGINNER: printf("Beginner"); break;
110 case LEVEL_INTERMEDIATE: printf("Intermediate"); break;
111 case LEVEL_ADVANCED: printf("Advanced"); break;
113 COND_PRINTF("Author", hdr->class_info.lesson.author);
114 COND_PRINTF("Copyright", hdr->class_info.lesson.copyright);
117 int main(int argc, const char **argv)
124 struct poptOption options[] = {
126 {"debug", 'd', POPT_ARG_NONE, &debugging, 0, "Turn on debugging output" },
127 {"version", 'v', POPT_ARG_NONE, &version, 'v', "Show version information" },
131 pc = poptGetContext(argv[0], argc, argv, options, 0);
132 poptSetOtherOptionHelp(pc, "file.ptb");
133 while((c = poptGetNextOpt(pc)) >= 0) {
136 printf("ptbinfo Version "PACKAGE_VERSION"\n");
137 printf("(C) 2004 Jelmer Vernooij <jelmer@samba.org>\n");
143 ptb_set_debug(debugging);
144 ptb_set_asserts_fatal(0);
146 if(!poptPeekArg(pc)) {
147 poptPrintUsage(pc, stderr, 0);
150 ret = ptb_read_file(poptGetArg(pc));
153 perror("Read error: ");
157 printf("File type: ");
158 switch(ret->hdr.classification) {
159 case CLASSIFICATION_SONG:
161 write_song_info(&ret->hdr);
163 case CLASSIFICATION_LESSON:
165 write_lesson_info(&ret->hdr);
172 DLIST_LEN(ret->instrument[0].sections, tmp1, struct ptb_section *);
173 DLIST_LEN(ret->instrument[1].sections, tmp2, struct ptb_section *);
174 printf("Number of sections: \tRegular: %d Bass: %d\n", tmp1, tmp2);
176 DLIST_LEN(ret->instrument[0].guitars, tmp1, struct ptb_guitar *);
177 DLIST_LEN(ret->instrument[1].guitars, tmp2, struct ptb_guitar *);
179 printf("Number of guitars: \tRegular: %d Bass: %d\n", tmp1, tmp2);