pax_global_header00006660000000000000000000000064124367622240014522gustar00rootroot0000000000000052 comment=365e379483ea180bcfa272d89a2524da55b1d600 cuetools-1.4.1/000077500000000000000000000000001243676222400133625ustar00rootroot00000000000000cuetools-1.4.1/.gitignore000066400000000000000000000011451243676222400153530ustar00rootroot00000000000000*_parse.c *_parse.h *_scan.c /ar-lib /config.h /config.h.in /config.log /config.status /src/lib/.deps/ /src/tools/.deps/ /src/tools/cuebreakpoints /src/tools/cueconvert /src/tools/cueprint /ylwrap Makefile # Object files *.o *.ko *.obj *.elf # Precompiled Headers *.gch *.pch # Libraries *.lib *.a *.la *.lo # Shared objects (inc. Windows DLLs) *.dll *.so *.so.* *.dylib # Executables *.exe *.out *.app *.i*86 *.x86_64 *.hex # http://www.gnu.org/software/automake Makefile.in # http://www.gnu.org/software/autoconf /autom4te.cache /aclocal.m4 /compile /configure /depcomp /install-sh /missing /stamp-h1 cuetools-1.4.1/.travis.yml000066400000000000000000000001061243676222400154700ustar00rootroot00000000000000language: c install: autoreconf --install script: ./configure && make cuetools-1.4.1/AUTHORS000066400000000000000000000000421243676222400144260ustar00rootroot00000000000000Svend Sorensen cuetools-1.4.1/COPYING000066400000000000000000000431101243676222400144140ustar00rootroot00000000000000 GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. cuetools-1.4.1/ChangeLog000066400000000000000000000000001243676222400151220ustar00rootroot00000000000000cuetools-1.4.1/Makefile.am000066400000000000000000000001271243676222400154160ustar00rootroot00000000000000# Makefile.am - process with automake to produce Makefile.in SUBDIRS = doc src extras cuetools-1.4.1/NEWS000066400000000000000000000040571243676222400140670ustar00rootroot00000000000000Version 1.4.0 * See git history for changes. Changes since 1.3 * Applied most of Branden Robinson's Debian patch (cuetools_1.3-2.diff.gz). This included many fixes and enhancements to tools and manual pages. cuebreakpoints and cueconvert will exit if they fail on any of the input files. cuebreakpoints, cueconvert, and cuetools will exit with a nonzero return value if there was a failure on an input file. * Added version option to all tools. * Single quoted string support has been removed. This was broken, and I am not sure of any software that supports single quoted strings in cue or toc files. Changes since 1.2 * Build system has been rewritten using automake/autoconf. * Added append, prepend, and split pregap modes to cuebreakpoints. * Fixed possible compilation error with Bison. * All tools accept long options. * Programs exit if --input-format or --output-format is an illegal value. Changes since 1.1 * cuebreakpoints was not printing the last track breakpoint. This has been fixed. * cueprint now prints a zero-length string for undefined values. Flags, width, and precision are applied to conversion characters which have no conversion. * Added a tagging script, cuetag.sh, which uses cueprint, vorbiscomment, and mp3info to tag Ogg Vorbis and MP3 files. This needs more testing and documentation. * Added a track selection flag to cueprint. Changes since 1.0 * File formats documentation has been readded and updated (docs/formats.txt). * ``CDTEXTFILE`` is now a recognized (but ignored) keyword. * If only a disc or track template is specified on the command line, then only the disc or track information is printed, respectively. * cueprint now supports flags and width and precision values for template expansion (like the printf command). Changes since 0.6 * cuetools-1.x is a significant code rewrite of 0.x. The cue/toc parsing code has been reimplemented in lex/yacc. * cuerename has been replaced by the more general utility cueprint. * Usage syntax of the utilities has changed. See the respective man pages. cuetools-1.4.1/README.md000066400000000000000000000013371243676222400146450ustar00rootroot00000000000000# cuetools [![Build Status](https://travis-ci.org/svend/cuetools.svg?branch=master)](https://travis-ci.org/svend/cuetools) cue and toc file parsers and utilities https://github.com/svend/cuetools Copyright (C) 2004, 2005, 2006, 2007, 2013 Svend Sorensen cuetools is a set of utilities for working with Cue Sheet (cue) and Table of Contents (toc) files. It includes: - `cueconvert` convert between the cue and toc formats - `cuebreakpoints` print the breakpoints from a cue or toc file - `cueprint` print disc and track infomation for a cue or toc file Directory layout: - `doc/` documentation (including man pages) - `src/` all source files - `src/lib/` scanning, parsing, and printing library - `src/tools/` cue and toc tools cuetools-1.4.1/TODO000066400000000000000000000004761243676222400140610ustar00rootroot00000000000000* (cue/toc) Line numbers in error messages are off sometimes. * (cue/toc) Single quoted strings are not supported. * (toc) Binary CD-TEXT data is parsed, but not saved. * (toc) Only a single data file is supported. * (cue) track_mode does not match cdrtools and CDRWIN docs. * (cue) Add support for CDTEXTFILE format. cuetools-1.4.1/configure.ac000066400000000000000000000005251243676222400156520ustar00rootroot00000000000000AC_INIT([cuetools], [1.4.0], [svend@ciffer.net]) AM_INIT_AUTOMAKE([-Wall -Werror foreign]) AC_PROG_CC AC_PROG_INSTALL AC_PROG_RANLIB AM_PROG_LEX m4_ifdef([AM_PROG_AR], [AM_PROG_AR]) AC_PROG_YACC AC_CONFIG_HEADERS([config.h]) AC_CONFIG_FILES([Makefile doc/Makefile src/Makefile src/lib/Makefile src/tools/Makefile extras/Makefile]) AC_OUTPUT cuetools-1.4.1/doc/000077500000000000000000000000001243676222400141275ustar00rootroot00000000000000cuetools-1.4.1/doc/Makefile.am000066400000000000000000000002271243676222400161640ustar00rootroot00000000000000# Makefile.am - process with automake to produce Makefile.in man_MANS = cuebreakpoints.1 cueconvert.1 cueprint.1 EXTRA_DIST = $(man_MANS) formats.txt cuetools-1.4.1/doc/cuebreakpoints.1000066400000000000000000000046721243676222400172400ustar00rootroot00000000000000.TH "cuebreakpoints" "1" .SH NAME cuebreakpoints \- report track breakpoints from a CUE or TOC file .SH SYNOPSIS .B cuebreakpoints [ { .B \-i .I format | .BR \-\-input\-format =\fIformat\fP } { .B \-\-append\-gaps | .B \-\-prepend\-gaps | .B \-\-split\-gaps } ] [ .I file \&... ] .br .B cuebreakpoints \-h | \-\-help .br .B cuebreakpoints \-V | \-\-version .SH DESCRIPTION .B cuebreakpoints reports the track breakpoints found in CUE and TOC files, which are typically created by compact disc ripping software. The breakpoints are in a format usable by .B shnsplit (part of the shntool package). .PP Three approaches to track pregaps are available: append (to previous track), prepend (to succeeding track), and split (from both preceding and succeeding tracks). The split approach can result in up to twice as many breakpoints being reported as there are tracks on the disc. .PP The first track's pregap cannot be appended to the previous track, so it is prefixed to the track in both append and prepend modes. If you want the track without it, use the .B \-\-split\-gaps option. .PP If no filenames are specified, .B cuebreakpoints reads from standard input, and an input format option .I must be specified. If one or more filenames is provided, but the input format option is not specified, the input format will be guessed based on each file's suffix (e.g., .I .cue or .IR .toc ). This heuristic is case-insensitive. .SH OPTIONS .TP .BR \-h ", " \-\-help displays a usage message and exits. .TP .BR \-i " \fIformat\fP, " \-\-input\-format=\fIformat\fP sets the expected format of the input file(s) to .IR format , which must be either .B cue or .BR toc . .TP .B \-\-append\-gaps appends pregaps to the end of the previous track. This is the default. .TP .B \-\-prepend\-gaps prefixes pregaps to the beginning of each subsequent track. .TP .B \-\-split\-gaps separates pregaps from both the preceding and succeeding tracks. .TP .B \-V, \-\-version displays version information and exits. .PP If more than one of .BR \-\-append\-gaps , .BR \-\-prepend\-gaps , and .B \-\-split\-gaps are specified, all except the last encountered are ignored. .SH "EXIT STATUS" .B cuebreakpoints exits with status zero if it successfully generates a report for each input file, and nonzero if there were problems. .SH AUTHOR Cuetools was written by Svend Sorensen. Branden Robinson contributed fixes and enhancements to the utilities and documentation. .SH "SEE ALSO" .BR cueconvert (1), .BR cueprint (1) cuetools-1.4.1/doc/cueconvert.1000066400000000000000000000034471243676222400163760ustar00rootroot00000000000000.TH "cueconvert" "1" .SH NAME cueconvert \- convert files between CUE and TOC formats .SH SYNOPSIS .B cueconvert [ .B \-i .I format | .BR \-\-input\-format =\fIformat\fP ] [ .B \-o .I format | .BR \-\-output\-format =\fIformat\fP ] [ .I infile [ .I outfile ] ] .br .B cueconvert \-h | \-\-help .br .B cueconvert \-V | \-\-version .SH DESCRIPTION .B cueconvert coverts files between the CUE and TOC formats, each of which are commonly used by compact disc ripping software to denote track breakpoints and other data. .PP The operands are optional; if .I infile is not specified, .B cueconvert reads from standard input, and if .I outfile is not specified, it writes to standard output. .PP If no filenames are specified, standard input is used, and an input format option .I must be specified. The complementary format is used for output. .PP If filenames are provided, but format options are not specified, the input and output formats will be guessed based on each filename's suffix (e.g., .I .cue or .IR .toc ). This heuristic is case-insensitive. .SH OPTIONS .TP .BR \-h ", " \-\-help displays a usage message and exits. .TP .BR \-i " \fIformat\fP, " \-\-input\-format=\fIformat\fP sets the expected format of the input file to .IR format . .TP .BR \-o " \fIformat\fP, " \-\-output\-format=\fIformat\fP sets the format of the generated output file to .IR format . .TP .B \-V ", " \-\-version displays version information and exits. .PP The option argument .I format must be either .B cue or .BR toc . .SH "EXIT STATUS" .B cueconvert exits with status zero if it successfully coverts the input file, and nonzero if there were problems. .SH AUTHOR Cuetools was written by Svend Sorensen. Branden Robinson contributed fixes and enhancements to the utilities and documentation. .SH "SEE ALSO" .BR cuebreakpoints(1), .BR cueprint(1) cuetools-1.4.1/doc/cueprint.1000066400000000000000000000111121243676222400160360ustar00rootroot00000000000000.TH "cueprint" "1" .SH NAME cueprint \- report disc and track information from a CUE or TOC file .SH SYNOPSIS .B cueprint [ { .B \-i .I format | .BR \-\-input\-format =\fIformat\fP } { .B \-n .I number | .BR \-\-track\-number =\fInumber\fP } { .B \-d .I template | .BR \-\-disc\-template =\fItemplate\fP } { .B \-t .I template | .BR \-\-track\-template =\fItemplate\fP } ] [ .I file \&... ] .br .B cueprint \-h | \-\-help .br .B cueprint \-V | \-\-version .SH DESCRIPTION .B cueprint reports disc and track information from CUE and TOC files, which are typically created by compact disc ripping software. .PP By default, .B cueprint reports a default set of disc information, and a default set of information for each track on the disc. With options, the report can be restricted to a specific track, and the presentation of the disc and track information can be extensively customized using .BR printf (3)-style format strings (referred to here as \(oqtemplates\(cq to avoid confusion with the concept of file format). All characters in a template are reproduced as-is in the output except for conversions (which begin with .RB \(oq % \(cq) and escapes (which begin with .RB \(oq \e \(cq). .PP If no filenames are specified, .B cueprint reads from standard input, and an input format option .I must be specified. If one or more filenames is provided, but the input format option is not specified, the input format will be guessed based on each file's suffix (e.g., .I .cue or .IR .toc ). This heuristic is case-insensitive. .SS Conversions A conversion has the form .RB \(oq % [ \fIflags\fP ][ \fIwidth\fP ][ .\fIprecision\fP ] \fItype\fP \(cq. .PP .I flags may be zero or more of the following: .TS nokeep; l l. Character Meaning _ \- left-justify expansion + place sign before numbers \(oq \(cq (space) place a blank space before a positive number 0 pad numbers with zeroes .TE .\"# (unused) .PP .I width is the minimum field width. .I precision is the maximum width for strings. .I type is a single character which specifies the conversion type \(em apart from .BR % , it is the only mandatory part of the conversion. .PP The available conversion types are presented in the table below; disc conversion types are presented in the left half of the table, and track conversion types in the right half. Disc template expansion characters are valid for both disc and track templates. .TS nokeep; l l l l. Character Conversion Character Conversion _ A album arranger a track arranger C album composer c track composer G album genre g track genre i track ISRC M album message m track message N number of tracks n track number P album performer p track performer S album songwriter T album title t track title U album UPC/EAN u track ISRC (CD-TEXT) .TE .PP Any other character used as a conversion type expands to itself. This is how a literal percent sign is placed in the template; i.e., .RB \(oq %% \(cq expands to .RB \(oq % \(cq. .SS Escapes The recognized escapes are all single characters, and listed in the table below. .TS nokeep; l l. Escape Sequence Expansion _ \ea alert (bell) \eb backspace \ef formfeed \en newline \er carriage return \et horizontal tab \ev vertical tab \e0 null .TE .PP Any other character used after the .RB \(oq \e \(cq in an escape sequence expands to itself. This is how a literal escape character is placed in the template; i.e., .RB \(oq \e\e \(cq expands to .RB \(oq \e \(cq. .SH OPTIONS .TP .BR \-d " \fItemplate\fP, " \-\-disc\-template=\fItemplate\fP set disc template (see .B Conversions ) .TP .BR \-h ", " \-\-help displays a usage message and exits. .TP .BR \-i " \fIformat\fP, " \-\-input\-format=\fIformat\fP sets the expected format of the input file(s) to .IR format , which must be either .B cue or .BR toc . .TP .BR \-n " \fInumber\fP, " \-\-track\-number=\fInumber\fP only print track information for a single track. The default is to print information for all tracks. .TP .BR \-t " \fItemplate\fP, " \-\-track\-template=\fItemplate\fP set track template (see .B Conversions ) .TP .B \-V ", " \-\-version displays version information and exits. .SH "EXIT STATUS" .B cueprint exits with status zero if it successfully reports information from each input file, and nonzero if there were problems. .SH EXAMPLES To display disc and track information (using the default template for both): .PP .RB "% " "cueprint album.cue" .PP To print the number of tracks in a CUE file: .PP .RB "% " "cueprint -d \(aq%N\en\(aq album.cue" .SH AUTHOR Cuetools was written by Svend Sorensen. Branden Robinson contributed fixes and enhancements to the utilities and documentation. .SH "SEE ALSO" .BR cuebreakpoints (1), .BR cueconvert (1), .BR printf(3) cuetools-1.4.1/doc/cuetag.1000066400000000000000000000010101243676222400154510ustar00rootroot00000000000000.TH "CUETAG" "1" .SH "NAME" cuetag \- tag files based on cue/toc file information .SH "SYNOPSIS" .PP cuetag [file]... .SH "DESCRIPTION" This manual page documents briefly the \fBcuetag\fR shell script. .SH "AUTHOR" This manual page was written by Patrick Matth\[:a]i for cuetools. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU General Public License, Version 2 or any later version published by the Free Software Foundation. cuetools-1.4.1/doc/formats.txt000066400000000000000000000246331243676222400163530ustar00rootroot00000000000000=========================================================== Description of the Cue Sheet/Table of Contents File Formats =========================================================== :Author: Svend Sorensen :Contact: svend@ciffer.net :Date: $LastChangedDate$ .. contents:: The Cue Sheet (cue) and Table of Contents (toc) file formats both describe the layout of a CD. Notes ===== A cue or toc file has an (optional) global section, followed by any number of track sections. Lines (with a few exceptions for the toc format) begin with a keyword, which may be followed by whitespace separated fields. Some keywords are only allowed in the global section or a track section. Format Notation --------------- A string may be enclosed in single or double quotation marks. If the string contains whitespace, it must be enclosed in quotation marks. ```` a required field ``[field]`` an optional field ``...`` preceding field may be repeated any number of times Cue Sheet Format ================ The standard file suffix for a cue file is ``.cue``. Keywords -------- CATALOG ~~~~~~~ :Description: Sets the media catalog number of the CD. :Section(s): global :Format: ``CATALOG `` ``catalog_number`` an integer consisting of exactly 13 digits. CDTEXTFILE ~~~~~~~~~~ :Description: Sets an external file for CD-TEXT data. :Section(s): global :Format: ``CDTEXTFILE `` ``filename`` a string. The CD-TEXT file contains encoded CD-TEXT data. The standard extension for CD-TEXT files is ``.cdt``. *TODO: describe CD-TEXT file format* FILE ~~~~ :Description: Sets a new input file. :Section(s): track :Format: ``FILE [file_format]`` ``filename`` a string. ``file_format`` one of: ``BINARY``, ``MOTOROLA``, ``AIFF``, ``WAVE``, or ``MP3`` [#]_. ``FILE`` line precedes the beginning of the track section. .. [#] ``file_fomat`` differs between software packages. The cdrtools_ ``cue.c`` file also has ``file_format`` entries for ``AU`` and ``OGG``. FLAGS ~~~~~ :Description: Sets track flags. :Section(s): track :Format: ``FLAGS [flag]...`` ``flag`` one of: ``PRE``, ``DCP``, ``4CH``, or ``SCMS``. INDEX ~~~~~ :Description: Sets a track index. :Section(s): track :Format: ``INDEX `` ``index_number`` an integer in the range 0-99. ``index`` time in MSF format. Having an ``INDEX 00`` and an ``INDEX 01`` defines a pregap using data from the ``FILE``. ISRC ~~~~ :Description: Sets track ISRC number. :Section(s): track :Format: ``ISRC `` ``ISRC_number`` a string with the format CCOOOOYYSSSSS. POSTGAP ~~~~~~~ :Description: Sets track postgap. :Section(s): track :Format: ``POSTGAP `` ``postgap`` time in MSF format. Postgap is filled with generated silence. PREGAP ~~~~~~ :Description: Sets track pregap. :Section(s): track :Format: ``PREGAP `` ``pregap`` time in MSF format. The pregap is filled with generated silence. REM ~~~ :Description: Begins a comment line. :Section(s): any :Format: ``REM [comments]`` TRACK ~~~~~ :Description: Starts a new track. :Section(s): track :Format: ``TRACK `` ``track_number`` a positive integer in the range 1-99. ``track_mode`` one of: ``AUDIO``, ``CDG``, ``MODE1/2048``, ``MODE1/2352``, ``MODE2/2336``, ``MODE2/2352``, ``CDI/2336``, or ``CDI/2352``. (CD-TEXT keywords) ~~~~~~~~~~~~~~~~~~ :Description: Sets CD-TEXT data. :Section(s): any :Format: `` `` ``CDTEXT_keyword`` one of: (see `CD-TEXT`_ section for a list of keywords). ``CDTEXT_field`` a string. The cue format does not have native support for binary CD-TEXT. Table of Contents File Format ============================= The standard file suffix for a toc file is ``.toc``. Certain keywords begin a block, which must be enclosed between ``{`` and ``}`` brackets. Comments -------- Comments begin with ``//`` and may be placed anywhere except inside quoted strings. A comment beginning with ``//`` is stripped from each line. Keywords -------- AUDIOFILE ~~~~~~~~~ :Description: Add file to current track. :Section(s): track :Format: ``AUDIOFILE "" [length]`` ``filename`` a string. ``start`` time in MSF format. ``length`` time in MSF format. CATALOG ~~~~~~~ :Description: Sets the media catalog number of the CD. :Section(s): global :Format: ``CATALOG ""`` ``catalog_number`` an integer consisting of exactly 13 digits. CD_DA ~~~~~ :Description: Sets the CD format to audio. :Section(s): global :Format: ``CD_DA`` CD_ROM ~~~~~~ :Description: Sets the CD format to data. :Section(s): global :Format: ``CD_ROM`` CD_ROM_XA ~~~~~~~~~ :Description: Sets the CD format to mixed. :Section(s): global :Format: ``CD_ROM_XA`` CD_TEXT ~~~~~~~ :Section(s): any :Format: ``CD_TEXT {}`` Begins a CD-TEXT block. COPY ~~~~ :Description: Sets the copy permitted flag. :Section(s): track :Format: ``COPY`` DATAFILE ~~~~~~~~ :Description: Add data from file to current track. :Section(s): track :Format: ``DATAFILE "" [length]`` ``filename`` a string. ``length`` time in MSF format. ISRC ~~~~ :Description: Sets track ISRC number. :Section(s): track :Format: ``ISRC ""`` ``ISRC_number`` a string with the format CCOOOOYYSSSSS. FIFO ~~~~ :Description: Add data from FIFO to current track. :Section(s): track :Format: ``FIFO "" "`` ``length`` time in MSF format. FILE ~~~~ :Description: Add data from file to current track. :Section(s): track :Format: ``FILE "" [length]`` ``filename`` a string. ``start`` time in MSF format. ``length`` time in MSF format. FOUR_CHANNEL_AUDIO ~~~~~~~~~~~~~~~~~~ :Description: Sets the four channel audio flag. :Section(s): track :Format: ``FOUR_CHANNEL_AUDIO`` INDEX ~~~~~ :Description: Sets a track index. :Section(s): track :Format: ``INDEX `` ``index_number`` a non-negative integer. ``index_time`` time in MSF format. LANGUAGE ~~~~~~~~ :Description: Begins a language block. :Section(s): track :Subsection(s): CD-TEXT block :Format: ``LANGUAGE language_number { cd_text }`` ``language_number`` an integer in the range 0-255. ``cd_text`` a series of CD-TEXT keyword lines. LANGUAGE_MAP ~~~~~~~~~~~~ :Description: Begins a language map block. :Section(s): global :Subsection(s): CD-TEXT block :Format: ``LANGUAGE_MAP { language_map... }`` ``language_map`` is a mapping of an integer in the range 0-255 to a country code. *TODO: add description of mapping format* NO ~~ :Description: Negates (clears) track flags. :Section(s): track :Format: ``NO `` ``flag`` one of: ``COPY`` or ``PRE_EMPHASIS``. PREGAP ~~~~~~ :Description: Sets track pregap. :Section(s): track :Format: ``PREGAP `` ``pregap`` time in MSF format. SILENCE ~~~~~~~ :Description: Add zero (silent) audio data to current track. :Section(s): track :Format: ``SILENCE `` ``length`` time in MSF format. START ~~~~~ :Description: Sets the length of the pregap. :Section(s): track :Format: ``START `` ``start`` time in MSF format. TRACK ~~~~~ :Description: Starts a new track. :Section(s): track :Format: ``TRACK [sub_channel_mode]`` ``track_mode`` one of: ``AUDIO``, ``MODE1``, ``MODE1_RAW``, ``MODE2``, ``MODE2_FORM1``, ``MODE2_FORM2``, ``MODE2_FORM_MIX``, ``MODE2_RAW`` ``sub_channel_mode`` one of: ``RW``, ``RW_RAW`` TWO_CHANNEL_AUDIO ~~~~~~~~~~~~~~~~~ :Description: Sets the two channel audio flag. :Section(s): track :Format: ``TWO_CHANNEL_AUDIO`` ZERO ~~~~ :Description: Add zero data to current track. :Section(s): track :Format: ``ZERO `` ``length`` time in MSF format. (CD-TEXT keywords) ~~~~~~~~~~~~~~~~~~ :Description: Sets CD-TEXT data. :Section(s): any :Subsection(s): language block :Format1: `` ""`` ``CDTEXT_keyword`` one of: (see `CD-TEXT`_ section for a list of keywords). ``CDTEXT_field`` a string. :Format2: `` { CDTEXT_binary_data }`` ``CDTEXT_binary_data`` comma separated list of integers in the range 0-255. Format1 is for character data and Format2 is for binary data. See `CD-TEXT`_ section for a list of CD-TEXT keywords. CD-TEXT ======= MMC-3_ specifies 16 CD-TEXT types. Three are reserved and have no corresponding keywords. One is shared; the keyword depends on whether it is for the disc (``UPC_EAN``) or a track (``ISRC``). CD-TEXT entries are either character or binary data. All descriptions taken from MMC-3_. Keywords -------- ARRANGER ~~~~~~~~ :Description: Name(s) of the arranger(s) :Section: any :Format: character COMPOSER ~~~~~~~~ :Description: Name(s) of the composer(s) :Section: any :Format: character DISC_ID ~~~~~~~ :Description: Disc Identification information :Section: any :Format: binary GENRE ~~~~~ :Description: Genre Identification and Genre information :Section: any :Format: binary Genre codes are in the Enhanced CD Specification or cdrtools_ ``cdtext.h`` file. ISRC ~~~~~ :Description: ISRC Code of each track :Section: track :Format: character MESSAGE ~~~~~~~ :Description: Message from the content provider and/or artist :Section: any :Format: character PERFORMER ~~~~~~~~~ :Description: Name(s) of the performer(s) :Section: any :Format: character SONGWRITER ~~~~~~~~~~ :Description: Name(s) of the songwriter(s) :Section: any :Format: character TITLE ~~~~~ :Description: Title of album name or Track Titles :Section: any :Format: character TOC_INFO ~~~~~~~~~ :Description: Table of Content information :Section: any :Format: binary TOC_INFO2 ~~~~~~~~~ :Description: Second Table of Content information :Section: any :Format: binary UPC_EAN ~~~~~~~ :Description: UPC/EAN code of the album :Section: disc :Format: character SIZE_INFO ~~~~~~~~~ :Description: Size information of the Block :Section: any :Format: binary Definitions =========== frame 1/75 of a second. International Standard Recording Code (ISRC) A 12 character identification code for sound recordings. See `ISRC intro`_ for details. Media Catalog Number (MCN) A 13 digit UPC/EAN code for the disc. MSF format a representation of time in the form ``m:s:f``. ``m`` is minutes, ``s`` is seconds, and ``f`` is frames. Fields may be zero padded. .. _MMC-3: ftp://ftp.t10.org/t10/drafts/mmc3/ .. _cdrtools: http://www.fokus.gmd.de/research/cc/glone/employees/joerg.schilling/private/cdrecord.html .. _ISRC intro: http://www.ifpi.org/site-content/online/isrc_intro.html cuetools-1.4.1/extras/000077500000000000000000000000001243676222400146705ustar00rootroot00000000000000cuetools-1.4.1/extras/Makefile.am000066400000000000000000000001441243676222400167230ustar00rootroot00000000000000# Makefile.am - process with automake to produce Makefile.in EXTRA_DIST = cueconvert.cgi index.txt cuetools-1.4.1/extras/cueconvert.cgi000066400000000000000000000047261243676222400175420ustar00rootroot00000000000000#!/usr/bin/env python # cueconvert.cgi - use HTML form to drive cueconvert import os import cgi # error reporting #import cgitb; cgitb.enable() # cueconvert path CUECONVERT = "./cueconvert" def print_form(iformat, oformat, text, errors): # input format radio buttons # one "" and one "checked" iformat_cue = "" iformat_toc = "" # output format radio buttons oformat_cue = "" oformat_toc = "" if iformat == "cue": iformat_cue = "checked" else: iformat_toc = "checked" if oformat == "cue": oformat_cue = "checked" else: oformat_toc = "checked" # print HTML form print "Content-type: text/html" print print """ cueconvert

cueconvert

Cue Sheet/TOC File

Input Format cue toc

Output Format cue toc

%s

cueconvert is part of the cuetools project.

""" % (cgi.escape(text), iformat_cue, iformat_toc, oformat_cue, oformat_toc, cgi.escape(errors)) def convert(iformat, oformat, text): """convert - convert a cue or toc file returns converted text, and any error messages""" command = CUECONVERT # append flags to command if iformat == "cue": command += " -i cue" elif iformat == "toc": command += " -i toc" if oformat == "cue": command += " -o cue" elif oformat == "toc": command += " -o toc" ifile, ofile, efile = os.popen3(command) ifile.write(text) ifile.close() text = ofile.read() errors = efile.read() ofile.close() efile.close() return text, errors def main(): iformat = "cue" # input format oformat = "toc" # output format text = "" # input file content errors = "" # cueconvert error messages form = cgi.FieldStorage() if form: iformat = form.getfirst("iformat") oformat = form.getfirst("oformat") text = form.getfirst("text", "") text, errors = convert(iformat, oformat, text) # switch input and output formats for next pass iformat, oformat = oformat, iformat print_form(iformat, oformat, text, errors) if __name__ == '__main__': main() cuetools-1.4.1/extras/index.txt000066400000000000000000000041211243676222400165360ustar00rootroot00000000000000======== cuetools ======== :Author: Svend Sorensen :Contact: svend@ciffer.net cuetools is a set of utilites for working with Cue Sheet (cue) and Table of Contents (toc) files. .. contents:: Documentation ============= cuetools Docs ------------- README.txt_ Program Notes CHANGES.txt_ Change Summary BUGS.txt_ Program Bugs/TODO COPYING_ License Information formats.txt_ Description of the Cue Sheet/Table of Contents File Formats Man Pages --------- cuebreakpoints.man_ cuebreakpoints(1) manual page cueconvert.man_ cueconvert(1) manual page cueprint.man_ cueprint(1) manual page .. _README.txt: README.html .. _CHANGES.txt: CHANGES.html .. _BUGS.txt: BUGS.html .. _COPYING: COPYING .. _formats.txt: formats.html .. _cuebreakpoints.man: man/cuebreakpoints.html .. _cueconvert.man: man/cueconvert.html .. _cueprint.man: man/cueprint.html Resources ========= Project Links ------------- * cuetools `project page`_ [1]_ * cuetools `downloads`_ [1]_ * cuetools `Subversion repository`_ (browse_) [1]_ * cueconvert `web interface`_ .. _project page: http://developer.berlios.de/projects/cuetools/ .. _downloads: http://developer.berlios.de/project/showfiles.php?group_id=2130 .. _Subversion repository: http://developer.berlios.de/svn/?group_id=2130 .. _browse: http://svn.berlios.de/viewcvs/cuetools .. _web interface: http://sorensen.freeshell.org/cuetools/cueconvert.cgi Mailing Lists [1]_ ------------------ cuetools-announce_ news and announcements (cuetools-announce@lists.berlios.de) cuetools-users_ general discussion (cuetools-users@lists.berlios.de) .. _cuetools-users: https://lists.berlios.de/pipermail/cuetools-users .. _cuetools-announce: https://lists.berlios.de/pipermail/cuetools-announce Other Links ----------- * Cdrdao_ * cdrdao(1) man page - description of toc file format * shntool_ .. _Cdrdao: http://cdrdao.sourceforge.net .. _shntool: http://www.etree.org/shnutils/shntool/ .. [1] Hosted by |BerliOS| .. |BerliOS| image:: http://developer.berlios.de/bslogo.php?group_id=2130 :alt: BerliOS Developer Logo :target: http://developer.berlios.de :height: 32 :width: 124 cuetools-1.4.1/src/000077500000000000000000000000001243676222400141515ustar00rootroot00000000000000cuetools-1.4.1/src/Makefile.am000066400000000000000000000001221243676222400162000ustar00rootroot00000000000000# Makefile.am - process with automake to produce Makefile.in SUBDIRS = lib tools cuetools-1.4.1/src/lib/000077500000000000000000000000001243676222400147175ustar00rootroot00000000000000cuetools-1.4.1/src/lib/Makefile.am000066400000000000000000000010251243676222400167510ustar00rootroot00000000000000# Makefile.am - process with automake to produce Makefile.in BUILT_SOURCES = cue_parse.h toc_parse.h EXTRA_DIST = $(BUILT_SOURCES) AM_YFLAGS = -d AM_LFLAGS = -olex.yy.c noinst_LIBRARIES = libcuefile.a libcuefile_a_headers = cd.h cdtext.h cuefile.h cue.h time.h toc.h \ cue_parse_prefix.h toc_parse_prefix.h libcuefile_a_SOURCES = cd.c cdtext.c time.c cuefile.c cue_print.c toc_print.c \ cue_parse.y cue_scan.l toc_parse.y toc_scan.l \ $(libcuefile_a_headers) cuetools-1.4.1/src/lib/cd.c000066400000000000000000000136631243676222400154620ustar00rootroot00000000000000/* * cd.c -- cd functions * * Copyright (C) 2004, 2005, 2006, 2007, 2013 Svend Sorensen * For license terms, see the file COPYING in this distribution. */ #include #include #include #include "cd.h" typedef struct Data Data; struct Data { int type; /* DataType */ char *name; /* data source name */ long start; /* start time for data */ long length; /* length of data */ }; struct Track { Data zero_pre; /* pre-gap generated with zero data */ Data file; /* track data file */ Data zero_post; /* post-gap generated with zero data */ int mode; /* track mode */ int sub_mode; /* sub-channel mode */ int flags; /* flags */ char *isrc; /* IRSC Code (5.22.4) 12 bytes */ Cdtext *cdtext; /* CD-TEXT */ int nindex; /* number of indexes */ long index[MAXINDEX]; /* indexes (in frames) (5.29.2.5) * relative to start of track * index[0] should always be zero */ }; struct Cd { int mode; /* disc mode */ char *catalog; /* Media Catalog Number (5.22.3) */ Cdtext *cdtext; /* CD-TEXT */ int ntrack; /* number of tracks in album */ Track *track[MAXTRACK]; /* array of tracks */ }; Cd *cd_init() { Cd *cd = NULL; cd = malloc(sizeof(Cd)); if(NULL == cd) { fprintf(stderr, "unable to create cd\n"); } else { cd->mode = MODE_CD_DA; cd->catalog = NULL; cd->cdtext = cdtext_init(); cd->ntrack = 0; } return cd; } Track *track_init() { Track *track = NULL; track = malloc(sizeof(Track)); if (NULL == track) { fprintf(stderr, "unable to create track\n"); } else { track->zero_pre.type = DATA_ZERO; track->zero_pre.name = NULL; track->zero_pre.start = 0; track->zero_pre.length = 0; track->file.type = DATA_AUDIO; track->file.name = NULL; track->file.start = 0; track->file.length = 0; track->zero_post.type = DATA_ZERO; track->zero_post.name = NULL; track->zero_post.start = 0; track->zero_post.length = 0; track->mode = MODE_AUDIO; track->sub_mode = SUB_MODE_RW; track->flags = FLAG_NONE; track->isrc = NULL; track->cdtext = cdtext_init(); track->nindex = 0; } return track; } /* * cd structure functions */ void cd_set_mode(Cd *cd, int mode) { cd->mode = mode; } int cd_get_mode(Cd *cd) { return cd->mode; } void cd_set_catalog(Cd *cd, char *catalog) { if (cd->catalog) { free(cd->catalog); } cd->catalog = strdup(catalog); } char *cd_get_catalog(Cd *cd) { return cd->catalog; } Cdtext *cd_get_cdtext(Cd *cd) { return cd->cdtext; } Track *cd_add_track(Cd *cd) { if (MAXTRACK > cd->ntrack) { cd->ntrack++; } else { fprintf(stderr, "too many tracks\n"); } /* this will reinit last track if there were too many */ cd->track[cd->ntrack - 1] = track_init(); return cd->track[cd->ntrack - 1]; } int cd_get_ntrack(Cd *cd) { return cd->ntrack; } Track *cd_get_track(Cd *cd, int i) { if (0 < i && i <= cd->ntrack) { return cd->track[i - 1]; } return NULL; } /* * track structure functions */ void track_set_filename(Track *track, char *filename) { if (track->file.name) { free(track->file.name); } track->file.name = strdup(filename); } char *track_get_filename(Track *track) { return track->file.name; } void track_set_start(Track *track, long start) { track->file.start = start; } long track_get_start(Track *track) { return track->file.start; } void track_set_length(Track *track, long length) { track->file.length = length; } long track_get_length(Track *track) { return track->file.length; } void track_set_mode(Track *track, int mode) { track->mode = mode; } int track_get_mode(Track *track) { return track->mode; } void track_set_sub_mode(Track *track, int sub_mode) { track->sub_mode = sub_mode; } int track_get_sub_mode(Track *track) { return track->sub_mode; } void track_set_flag(Track *track, int flag) { track->flags |= flag; } void track_clear_flag(Track *track, int flag) { track->flags &= ~flag; } int track_is_set_flag(Track *track, int flag) { return track->flags & flag; } void track_set_zero_pre(Track *track, long length) { track->zero_pre.length = length; } long track_get_zero_pre(Track *track) { return track->zero_pre.length; } void track_set_zero_post(Track *track, long length) { track->zero_post.length = length; } long track_get_zero_post(Track *track) { return track->zero_post.length; } void track_set_isrc(Track *track, char *isrc) { if (track->isrc) { free(track->isrc); } track->isrc = strdup(isrc); } char *track_get_isrc(Track *track) { return track->isrc; } Cdtext *track_get_cdtext(Track *track) { return track->cdtext; } void track_add_index(Track *track, long index) { if (MAXINDEX > track->nindex) { track->nindex++; } else { fprintf(stderr, "too many indexes\n"); } /* this will overwrite last index if there were too many */ track->index[track->nindex - 1] = index; } int track_get_nindex(Track *track) { return track->nindex; } long track_get_index(Track *track, int i) { if (0 <= i && i < track->nindex) { return track->index[i]; } return -1; } /* * dump cd information */ void cd_track_dump(Track *track) { int i; printf("zero_pre: %ld\n", track->zero_pre.length); printf("filename: %s\n", track->file.name); printf("start: %ld\n", track->file.start); printf("length: %ld\n", track->file.length); printf("zero_post: %ld\n", track->zero_post.length); printf("mode: %d\n", track->mode); printf("sub_mode: %d\n", track->sub_mode); printf("flags: 0x%x\n", track->flags); printf("isrc: %s\n", track->isrc); printf("indexes: %d\n", track->nindex); for (i = 0; i < track->nindex; ++i) { printf("index %d: %ld\n", i, track->index[i]); } if (NULL != track->cdtext) { printf("cdtext:\n"); cdtext_dump(track->cdtext, 1); } } void cd_dump(Cd *cd) { int i; printf("Disc Info\n"); printf("mode: %d\n", cd->mode); printf("catalog: %s\n", cd->catalog); if (NULL != cd->cdtext) { printf("cdtext:\n"); cdtext_dump(cd->cdtext, 0); } for (i = 0; i < cd->ntrack; ++i) { printf("Track %d Info\n", i + 1); cd_track_dump(cd->track[i]); } } cuetools-1.4.1/src/lib/cd.h000066400000000000000000000072171243676222400154650ustar00rootroot00000000000000/* * cd.h -- cd structure * * Copyright (C) 2004, 2005, 2006, 2007, 2013 Svend Sorensen * For license terms, see the file COPYING in this distribution. */ /* references: MMC-3 draft revsion - 10g */ #ifndef CD_H #define CD_H #include "cdtext.h" #define MAXTRACK 99 /* Red Book track limit */ #define MAXINDEX 99 /* Red Book index limit */ /* * disc modes * DATA FORM OF MAIN DATA (5.29.2.8) */ enum DiscMode { MODE_CD_DA, /* CD-DA */ MODE_CD_ROM, /* CD-ROM mode 1 */ MODE_CD_ROM_XA /* CD-ROM XA and CD-I */ }; /* * track modes * 5.29.2.8 DATA FORM OF MAIN DATA * Table 350 - Data Block Type Codes */ enum TrackMode { MODE_AUDIO, /* 2352 byte block length */ MODE_MODE1, /* 2048 byte block length */ MODE_MODE1_RAW, /* 2352 byte block length */ MODE_MODE2, /* 2336 byte block length */ MODE_MODE2_FORM1, /* 2048 byte block length */ MODE_MODE2_FORM2, /* 2324 byte block length */ MODE_MODE2_FORM_MIX, /* 2332 byte block length */ MODE_MODE2_RAW /* 2352 byte block length */ }; /* * sub-channel mode * 5.29.2.13 Data Form of Sub-channel * NOTE: not sure if this applies to cue files */ enum TrackSubMode { SUB_MODE_RW, /* RAW Data */ SUB_MODE_RW_RAW /* PACK DATA (written R-W */ }; /* * track flags * Q Sub-channel Control Field (4.2.3.3, 5.29.2.2) */ enum TrackFlag { FLAG_NONE = 0x00, /* no flags set */ FLAG_PRE_EMPHASIS = 0x01, /* audio recorded with pre-emphasis */ FLAG_COPY_PERMITTED = 0x02, /* digital copy permitted */ FLAG_DATA = 0x04, /* data track */ FLAG_FOUR_CHANNEL = 0x08, /* 4 audio channels */ FLAG_SCMS = 0x10, /* SCMS (not Q Sub-ch.) (5.29.2.7) */ FLAG_ANY = 0xff /* any flags set */ }; enum DataType { DATA_AUDIO, DATA_DATA, DATA_FIFO, DATA_ZERO }; /* ADTs */ typedef struct Cd Cd; typedef struct Track Track; /* return pointer to CD structure */ Cd *cd_init(); /* dump all info from CD structure * in human readable format (for debugging) */ void cd_dump(Cd *cd); /* * Cd functions */ void cd_set_mode(Cd *cd, int mode); int cd_get_mode(Cd *cd); void cd_set_catalog(Cd *cd, char *catalog); char *cd_get_catalog(Cd *cd); /* * return pointer to cd's Cdtext */ Cdtext *cd_get_cdtext(Cd *cd); /* * add a new track to cd, increment number of tracks * and return pointer to new track */ Track *cd_add_track(Cd *cd); /* * return number of tracks in cd */ int cd_get_ntrack(Cd *cd); Track *cd_get_track(Cd *cd, int i); /* * Track functions */ /* filename of data file */ void track_set_filename(Track *track, char *filename); char *track_get_filename(Track *track); /* track start is starting position in data file */ void track_set_start(Track *track, long start); long track_get_start(Track *track); /* track length is length of data file to use */ void track_set_length(Track *track, long length); long track_get_length(Track *track); /* see enum TrackMode */ void track_set_mode(Track *track, int mode); int track_get_mode(Track *track); /* see enum TrackSubMode */ void track_set_sub_mode(Track *track, int sub_mode); int track_get_sub_mode(Track *track); /* see enum TrackFlag */ void track_set_flag(Track *track, int flag); void track_clear_flag(Track *track, int flag); int track_is_set_flag(Track *track, int flag); /* zero data pregap */ void track_set_zero_pre(Track *track, long length); long track_get_zero_pre(Track *track); /* zero data postgap */ void track_set_zero_post(Track *track, long length); long track_get_zero_post(Track *track); void track_set_isrc(Track *track, char *isrc); char *track_get_isrc(Track *track); Cdtext *track_get_cdtext(Track *track); void track_add_index(Track *track, long index); int track_get_nindex(Track *track); long track_get_index(Track *track, int i); #endif cuetools-1.4.1/src/lib/cdtext.c000066400000000000000000000064721243676222400163670ustar00rootroot00000000000000/* * cdtext.c -- CD-TEXT data structure and functions * * Copyright (C) 2004, 2005, 2006, 2007, 2013 Svend Sorensen * For license terms, see the file COPYING in this distribution. */ #include #include #include #include "cdtext.h" struct Cdtext { int pti; int format; char *value; }; Cdtext *cdtext_init() { Cdtext *new_cdtext = NULL; Cdtext cdtext[] = { {PTI_TITLE, FORMAT_CHAR, NULL}, {PTI_PERFORMER, FORMAT_CHAR, NULL}, {PTI_SONGWRITER, FORMAT_CHAR, NULL}, {PTI_COMPOSER, FORMAT_CHAR, NULL}, {PTI_ARRANGER, FORMAT_CHAR, NULL}, {PTI_MESSAGE, FORMAT_CHAR, NULL}, {PTI_DISC_ID, FORMAT_BINARY, NULL}, {PTI_GENRE, FORMAT_BINARY, NULL}, {PTI_TOC_INFO1, FORMAT_BINARY, NULL}, {PTI_TOC_INFO2, FORMAT_BINARY, NULL}, {PTI_RESERVED1, FORMAT_CHAR, NULL}, {PTI_RESERVED2, FORMAT_CHAR, NULL}, {PTI_RESERVED3, FORMAT_CHAR, NULL}, {PTI_RESERVED4, FORMAT_CHAR, NULL}, {PTI_UPC_ISRC, FORMAT_CHAR, NULL}, {PTI_SIZE_INFO, FORMAT_BINARY, NULL}, {PTI_END, FORMAT_CHAR, NULL} }; new_cdtext = (Cdtext *) calloc (sizeof (cdtext) / sizeof (Cdtext), sizeof (Cdtext)); if (NULL == new_cdtext) { fprintf (stderr, "problem allocating memory\n"); } else { memcpy (new_cdtext, cdtext, sizeof(cdtext)); } return new_cdtext; } void cdtext_delete(Cdtext *cdtext) { int i; if (NULL != cdtext) { for (i = 0; PTI_END != cdtext[i].pti; i++) { free (cdtext[i].value); } free (cdtext); } } /* return 0 if there is no cdtext, returns non-zero otherwise */ int cdtext_is_empty(Cdtext *cdtext) { for (; PTI_END != cdtext->pti; cdtext++) { if (NULL != cdtext->value) { return -1; } } return 0; } /* sets cdtext's pti entry to field */ void cdtext_set(int pti, char *value, Cdtext *cdtext) { if (NULL != value) { /* don't pass NULL to strdup */ for (; PTI_END != cdtext->pti; cdtext++) { if (pti == cdtext->pti) { free (cdtext->value); cdtext->value = strdup (value); } } } } /* returns value for pti, NULL if pti is not found */ char *cdtext_get(int pti, Cdtext *cdtext) { for (; PTI_END != cdtext->pti; cdtext++) { if (pti == cdtext->pti) { return cdtext->value; } } return NULL; } const char *cdtext_get_key(int pti, int istrack) { char *key = NULL; switch (pti) { case PTI_TITLE: key = "TITLE"; break; case PTI_PERFORMER: key = "PERFORMER"; break; case PTI_SONGWRITER: key = "SONGWRITER"; break; case PTI_COMPOSER: key = "COMPOSER"; break; case PTI_ARRANGER: key = "ARRANGER"; break; case PTI_MESSAGE: key = "MESSAGE"; break; case PTI_DISC_ID: key = "DISC_ID"; break; case PTI_GENRE: key = "GENRE"; break; case PTI_TOC_INFO1: key = "TOC_INFO1"; break; case PTI_TOC_INFO2: key = "TOC_INFO1"; break; case PTI_RESERVED1: /* reserved */ break; case PTI_RESERVED2: /* reserved */ break; case PTI_RESERVED3: /* reserved */ break; case PTI_RESERVED4: /* reserved */ break; case PTI_UPC_ISRC: if (0 == istrack) key = "UPC_EAN"; else key = "ISRC"; break; case PTI_SIZE_INFO: key = "SIZE_INFO"; break; } return key; } void cdtext_dump(Cdtext *cdtext, int istrack) { int pti; char *value = NULL; for (pti = 0; PTI_END != pti; pti++) { if (NULL != (value = cdtext_get(pti, cdtext))) { printf("%s: ", cdtext_get_key(pti, istrack)); printf("%s\n", value); } } } cuetools-1.4.1/src/lib/cdtext.h000066400000000000000000000041651243676222400163710ustar00rootroot00000000000000/* * cdtext.h -- CD-TEXT declarations * * Copyright (C) 2004, 2005, 2006, 2007, 2013 Svend Sorensen * For license terms, see the file COPYING in this distribution. */ /* references: MMC-3 draft revsion - 10g */ #ifndef CDTEXT_H #define CDTEXT_H #include /* cdtext pack type indicators */ enum Pti { PTI_TITLE, /* title of album or track titles */ PTI_PERFORMER, /* name(s) of the performer(s) */ PTI_SONGWRITER, /* name(s) of the songwriter(s) */ PTI_COMPOSER, /* name(s) of the composer(s) */ PTI_ARRANGER, /* name(s) of the arranger(s) */ PTI_MESSAGE, /* message(s) from the content provider and/or artist */ PTI_DISC_ID, /* (binary) disc identification information */ PTI_GENRE, /* (binary) genre identification and genre information */ PTI_TOC_INFO1, /* (binary) table of contents information */ PTI_TOC_INFO2, /* (binary) second table of contents information */ PTI_RESERVED1, /* reserved */ PTI_RESERVED2, /* reserved */ PTI_RESERVED3, /* reserved */ PTI_RESERVED4, /* reserved for content provider only */ PTI_UPC_ISRC, /* UPC/EAN code of the album and ISRC code of each track */ PTI_SIZE_INFO, /* (binary) size information of the block */ PTI_END /* terminating PTI (for stepping through PTIs) */ }; enum PtiFormat { FORMAT_CHAR, /* single or double byte character string */ FORMAT_BINARY /* binary data */ }; typedef struct Cdtext Cdtext; /* return a pointer to a new Cdtext */ Cdtext *cdtext_init(); /* release a Cdtext */ void cdtext_delete(Cdtext *cdtext); /* returns non-zero if there are no CD-TEXT fields set, zero otherwise */ int cdtext_is_empty(Cdtext *cdtext); /* set CD-TEXT field to value for PTI pti */ void cdtext_set(int pti, char *value, Cdtext *cdtext); /* returns pointer to CD-TEXT value for PTI pti */ char *cdtext_get(int pti, Cdtext *cdtext); /* * returns appropriate string for PTI pti * if istrack is zero, UPC/EAN string will be returned for PTI_UPC_ISRC * othwise ISRC string will be returned */ const char *cdtext_get_key(int pti, int istrack); /* * dump all cdtext info * in human readable format (for debugging) */ void cdtext_dump(Cdtext *cdtext, int istrack); #endif cuetools-1.4.1/src/lib/cue.h000066400000000000000000000003521243676222400156440ustar00rootroot00000000000000/* * cue.h -- cue function declarations * * Copyright (C) 2004, 2005, 2006, 2007, 2013 Svend Sorensen * For license terms, see the file COPYING in this distribution. */ Cd *cue_parse(FILE *fp); void cue_print(FILE *fp, Cd *cd); cuetools-1.4.1/src/lib/cue_parse.y000066400000000000000000000110041243676222400170530ustar00rootroot00000000000000%{ /* * cue_parse.y -- parser for cue files * * Copyright (C) 2004, 2005, 2006, 2007, 2013 Svend Sorensen * For license terms, see the file COPYING in this distribution. */ #include #include #include #include "cd.h" #include "time.h" #include "cue_parse_prefix.h" #define YYDEBUG 1 extern int yylex(); void yyerror (char *s); static Cd *cd = NULL; static Track *track = NULL; static Track *prev_track = NULL; static Cdtext *cdtext = NULL; static char *prev_filename = NULL; /* last file in or before last track */ static char *cur_filename = NULL; /* last file in the last track */ static char *new_filename = NULL; /* last file in this track */ %} %start cuefile %union { long ival; char *sval; } %token NUMBER %token STRING /* global (header) */ %token CATALOG %token CDTEXTFILE %token FFILE %token BINARY %token MOTOROLA %token AIFF %token WAVE %token MP3 /* track */ %token TRACK %token AUDIO %token MODE1_2048 %token MODE1_2352 %token MODE2_2336 %token MODE2_2048 %token MODE2_2342 %token MODE2_2332 %token MODE2_2352 /* ISRC is with CD_TEXT */ %token TRACK_ISRC %token FLAGS %token PRE %token DCP %token FOUR_CH %token SCMS %token PREGAP %token INDEX %token POSTGAP /* CD-TEXT */ %token TITLE %token PERFORMER %token SONGWRITER %token COMPOSER %token ARRANGER %token MESSAGE %token DISC_ID %token GENRE %token TOC_INFO1 %token TOC_INFO2 %token UPC_EAN %token ISRC %token SIZE_INFO %type track_mode %type track_flag %type time %type cdtext_item %% cuefile : new_cd global_statements track_list ; new_cd : /* empty */ { cd = cd_init(); cdtext = cd_get_cdtext(cd); } ; global_statements : /* empty */ | global_statements global_statement ; global_statement : CATALOG STRING '\n' { cd_set_catalog(cd, $2); } | CDTEXTFILE STRING '\n' { /* ignored */ } | cdtext | track_data | error '\n' ; track_data : FFILE STRING file_format '\n' { if (NULL != new_filename) { yyerror("too many files specified\n"); free(new_filename); } new_filename = strdup($2); } ; track_list : track | track_list track ; track : new_track track_def track_statements ; file_format : BINARY | MOTOROLA | AIFF | WAVE | MP3 ; new_track : /*empty */ { /* save previous track, to later set length */ prev_track = track; track = cd_add_track(cd); cdtext = track_get_cdtext(track); cur_filename = new_filename; if (NULL != cur_filename) { prev_filename = cur_filename; } if (NULL == prev_filename) { yyerror("no file specified for track"); } else { track_set_filename(track, prev_filename); } new_filename = NULL; } ; track_def : TRACK NUMBER track_mode '\n' { track_set_mode(track, $3); } ; track_mode : AUDIO | MODE1_2048 | MODE1_2352 | MODE2_2336 | MODE2_2048 | MODE2_2342 | MODE2_2332 | MODE2_2352 ; track_statements : track_statement | track_statements track_statement ; track_statement : cdtext | FLAGS track_flags '\n' | TRACK_ISRC STRING '\n' { track_set_isrc(track, $2); } | PREGAP time '\n' { track_set_zero_pre(track, $2); } | INDEX NUMBER time '\n' { int i = track_get_nindex(track); long prev_length; if (0 == i) { /* first index */ track_set_start(track, $3); if (NULL != prev_track && NULL == cur_filename) { /* track shares file with previous track */ prev_length = $3 - track_get_start(prev_track); track_set_length(prev_track, prev_length); } } for (; i <= $2; i++) { track_add_index(track, \ track_get_zero_pre(track) + $3 \ - track_get_start(track)); } } | POSTGAP time '\n' { track_set_zero_post(track, $2); } | track_data | error '\n' ; track_flags : /* empty */ | track_flags track_flag { track_set_flag(track, $2); } ; track_flag : PRE | DCP | FOUR_CH | SCMS ; cdtext : cdtext_item STRING '\n' { cdtext_set ($1, $2, cdtext); } ; cdtext_item : TITLE | PERFORMER | SONGWRITER | COMPOSER | ARRANGER | MESSAGE | DISC_ID | GENRE | TOC_INFO1 | TOC_INFO2 | UPC_EAN | ISRC | SIZE_INFO ; time : NUMBER | NUMBER ':' NUMBER ':' NUMBER { $$ = time_msf_to_frame($1, $3, $5); } ; %% /* lexer interface */ extern int cue_lineno; extern int yydebug; extern FILE *cue_yyin; void yyerror (char *s) { fprintf(stderr, "%d: %s\n", cue_lineno, s); } Cd *cue_parse (FILE *fp) { cue_yyin = fp; yydebug = 0; if (0 == yyparse()) { return cd; } return NULL; } cuetools-1.4.1/src/lib/cue_parse_prefix.h000066400000000000000000000026211243676222400204140ustar00rootroot00000000000000/* * cue_parse_prefix.h -- yacc symbol redefinitions (for cue parser) * * * Copyright (C) 2004, 2005, 2006, 2007, 2013 Svend Sorensen * For license terms, see the file COPYING in this distribution. */ /* Remap normal yacc names so we can have multiple parsers * see http://www.gnu.org/software/automake/manual/html_node/Yacc-and-Lex.html */ #define yymaxdepth cue_yymaxdepth #define yyparse cue_yyparse #define yylex cue_yylex #define yyerror cue_yyerror #define yylval cue_yylval #define yychar cue_yychar #define yydebug cue_yydebug #define yypact cue_yypact #define yyr1 cue_yyr1 #define yyr2 cue_yyr2 #define yydef cue_yydef #define yychk cue_yychk #define yypgo cue_yypgo #define yyact cue_yyact #define yyexca cue_yyexca #define yyerrflag cue_yyerrflag #define yynerrs cue_yynerrs #define yyps cue_yyps #define yypv cue_yypv #define yys cue_yys #define yy_yys cue_yy_yys #define yystate cue_yystate #define yytmp cue_yytmp #define yyv cue_yyv #define yy_yyv cue_yy_yyv #define yyval cue_yyval #define yylloc cue_yylloc #define yyreds cue_yyreds #define yytoks cue_yytoks #define yylhs cue_yylhs #define yylen cue_yylen #define yydefred cue_yydefred #define yydgoto cue_yydgoto #define yysinde cue_yysindex #define yyrindex cue_yyrindex #define yygindex cue_yygindex #define yytable cue_yytable #define yycheck cue_yycheck #define yyname cue_yyname #define yyrule cue_yyrule cuetools-1.4.1/src/lib/cue_print.c000066400000000000000000000071611243676222400170600ustar00rootroot00000000000000/* * cue_print.y -- print cue file * * Copyright (C) 2004, 2005, 2006, 2007, 2013 Svend Sorensen * For license terms, see the file COPYING in this distribution. */ #include #include #include "cd.h" #include "time.h" void cue_print_track (FILE *fp, Track *track, int trackno); void cue_print_cdtext (Cdtext *cdtext, FILE *fp, int istrack); void cue_print_index (long i, FILE *fp); char *filename = ""; /* last track datafile */ long prev_length = 0; /* last track length */ /* prints cd in cue format */ void cue_print (FILE *fp, Cd *cd) { Cdtext *cdtext = cd_get_cdtext(cd); int i; /* track */ Track *track = NULL; /* print global information */ if (NULL != cd_get_catalog(cd)) { fprintf(fp, "CATALOG %s\n", cd_get_catalog(cd)); } cue_print_cdtext(cdtext, fp, 0); /* print track information */ for (i = 1; i <= cd_get_ntrack(cd); i++) { track = cd_get_track(cd, i); fprintf(fp, "\n"); cue_print_track(fp, track, i); } } void cue_print_track (FILE *fp, Track *track, int trackno) { Cdtext *cdtext = track_get_cdtext(track); int i; /* index */ if (NULL != track_get_filename(track)) { /* * always print filename for track 1, afterwards only * print filename if it differs from the previous track */ if (0 != strcmp(track_get_filename(track), filename)) { filename = track_get_filename(track); fprintf(fp, "FILE \"%s\" ", filename); /* NOTE: what to do with other formats (MP3, etc)? */ if (MODE_AUDIO == track_get_mode(track)) { fprintf(fp, "WAVE\n"); } else { fprintf(fp, "BINARY\n"); } } } fprintf(fp, "TRACK %02d ", trackno); switch (track_get_mode(track)) { case MODE_AUDIO: fprintf(fp, "AUDIO\n"); break; case MODE_MODE1: fprintf(fp, "MODE1/2048\n"); break; case MODE_MODE1_RAW: fprintf(fp, "MODE1/2352\n"); break; case MODE_MODE2: fprintf(fp, "MODE2/2048\n"); break; case MODE_MODE2_FORM1: fprintf(fp, "MODE2/2336\n"); break; case MODE_MODE2_FORM2: fprintf(fp, "MODE2/2324\n"); break; case MODE_MODE2_FORM_MIX: fprintf(fp, "MODE2/2336\n"); break; case MODE_MODE2_RAW: fprintf(fp, "MODE2/2352\n"); break; } cue_print_cdtext(cdtext, fp, 1); if (0 != track_is_set_flag(track, FLAG_ANY)) { fprintf(fp, "FLAGS"); if (0 != track_is_set_flag(track, FLAG_PRE_EMPHASIS)) { fprintf(fp, " PRE"); } if (0 != track_is_set_flag(track, FLAG_COPY_PERMITTED)) { fprintf(fp, " DCP"); } if (0 != track_is_set_flag(track, FLAG_FOUR_CHANNEL)) { fprintf(fp, " 4CH"); } if (0 != track_is_set_flag(track, FLAG_SCMS)) { fprintf(fp, " SCMS"); } fprintf(fp, "\n"); } if (NULL != track_get_isrc(track)) { fprintf(fp, "ISRC %s\n", track_get_isrc(track)); } if (0 != track_get_zero_pre(track)) { fprintf (fp, "PREGAP %s\n", time_frame_to_mmssff(track_get_zero_pre(track))); } /* don't print index 0 if index 1 = 0 */ if (track_get_index(track, 1) == 0) { i = 1; } else { i = 0; } for (; i < track_get_nindex(track); i++) { fprintf(fp, "INDEX %02d ", i); cue_print_index( \ track_get_index(track, i) \ + track_get_start(track) \ - track_get_zero_pre(track) , fp); } if (0 != track_get_zero_post(track)) { fprintf (fp, "POSTGAP %s\n", time_frame_to_mmssff(track_get_zero_post(track))); } prev_length = track_get_length(track); } void cue_print_cdtext (Cdtext *cdtext, FILE *fp, int istrack) { int pti; char *value = NULL; for (pti = 0; PTI_END != pti; pti++) { if (NULL != (value = cdtext_get(pti, cdtext))) { fprintf(fp, "%s", cdtext_get_key(pti, istrack)); fprintf(fp, " \"%s\"\n", value); } } } void cue_print_index (long i, FILE *fp) { fprintf (fp, "%s\n", time_frame_to_mmssff(i)); } cuetools-1.4.1/src/lib/cue_scan.l000066400000000000000000000057311243676222400166620ustar00rootroot00000000000000%{ /* * cue_scan.l -- lexer for cue files * * Copyright (C) 2004, 2005, 2006, 2007, 2013 Svend Sorensen * For license terms, see the file COPYING in this distribution. */ #include #include #include "cd.h" #include "cue_parse_prefix.h" #include "cue_parse.h" int cue_lineno = 1; %} ws [ \t\r] nonws [^ \t\r\n] %option noyywrap %option prefix="cue_yy" %s NAME %% \"([^\"]|\\\")*\" { yylval.sval = strdup(yytext + 1); yylval.sval[strlen(yylval.sval) - 1] = '\0'; BEGIN(INITIAL); return STRING; } {nonws}+ { yylval.sval = strdup(yytext); BEGIN(INITIAL); return STRING; } CATALOG { BEGIN(NAME); return CATALOG; } CDTEXTFILE { BEGIN(NAME); return CDTEXTFILE; } FILE { BEGIN(NAME); return FFILE; } BINARY { return BINARY; } MOTOROLA { return MOTOROLA; } AIFF { return AIFF; } WAVE { return WAVE; } MP3 { return MP3; } TRACK { return TRACK; } AUDIO { yylval.ival = MODE_AUDIO; return AUDIO; } MODE1\/2048 { yylval.ival = MODE_MODE1; return MODE1_2048; } MODE1\/2352 { yylval.ival = MODE_MODE1_RAW; return MODE1_2352; } MODE2\/2336 { yylval.ival = MODE_MODE2; return MODE2_2336; } MODE2\/2048 { yylval.ival = MODE_MODE2_FORM1; return MODE2_2048; } MODE2\/2342 { yylval.ival = MODE_MODE2_FORM2; return MODE2_2342; } MODE2\/2332 { yylval.ival = MODE_MODE2_FORM_MIX; return MODE2_2332; } MODE2\/2352 { yylval.ival = MODE_MODE2_RAW; return MODE2_2352; } FLAGS { return FLAGS; } PRE { yylval.ival = FLAG_PRE_EMPHASIS; return PRE; } DCP { yylval.ival = FLAG_COPY_PERMITTED; return DCP; } 4CH { yylval.ival = FLAG_FOUR_CHANNEL; return FOUR_CH; } SCMS { yylval.ival = FLAG_SCMS; return SCMS; } PREGAP { return PREGAP; } INDEX { return INDEX; } POSTGAP { return POSTGAP; } TITLE { BEGIN(NAME); yylval.ival = PTI_TITLE; return TITLE; } PERFORMER { BEGIN(NAME); yylval.ival = PTI_PERFORMER; return PERFORMER; } SONGWRITER { BEGIN(NAME); yylval.ival = PTI_SONGWRITER; return SONGWRITER; } COMPOSER { BEGIN(NAME); yylval.ival = PTI_COMPOSER; return COMPOSER; } ARRANGER { BEGIN(NAME); yylval.ival = PTI_ARRANGER; return ARRANGER; } MESSAGE { BEGIN(NAME); yylval.ival = PTI_MESSAGE; return MESSAGE; } DISC_ID { BEGIN(NAME); yylval.ival = PTI_DISC_ID; return DISC_ID; } GENRE { BEGIN(NAME); yylval.ival = PTI_GENRE; return GENRE; } TOC_INFO1 { BEGIN(NAME); yylval.ival = PTI_TOC_INFO1; return TOC_INFO1; } TOC_INFO2 { BEGIN(NAME); yylval.ival = PTI_TOC_INFO2; return TOC_INFO2; } UPC_EAN { BEGIN(NAME); yylval.ival = PTI_UPC_ISRC; return UPC_EAN; } ISRC/{ws}+\" { BEGIN(NAME); yylval.ival = PTI_UPC_ISRC; return ISRC; } SIZE_INFO { BEGIN(NAME); yylval.ival = PTI_SIZE_INFO; return SIZE_INFO; } ISRC { BEGIN(NAME); return TRACK_ISRC; } ^{ws}*REM.*\n { cue_lineno++; /* ignore comments */ } {ws}+ { /* ignore whitespace */ } [[:digit:]]+ { yylval.ival = atoi(yytext); return NUMBER; } : { return yytext[0]; } ^{ws}*\n { cue_lineno++; /* blank line */ } \n { cue_lineno++; return '\n'; } . { fprintf(stderr, "bad character '%c'\n", yytext[0]); } %% cuetools-1.4.1/src/lib/cuefile.c000066400000000000000000000031341243676222400165000ustar00rootroot00000000000000/* * cuefile.c -- cue/toc functions * * Copyright (C) 2004, 2005, 2006, 2007, 2013 Svend Sorensen * For license terms, see the file COPYING in this distribution. */ #include #include #include "cuefile.h" #include "cue.h" #include "toc.h" Cd *cf_parse(char *name, int *format) { FILE *fp = NULL; Cd *cd = NULL; if (UNKNOWN == *format) { if (UNKNOWN == (*format = cf_format_from_suffix(name))) { fprintf(stderr, "%s: unknown file suffix\n", name); return NULL; } } if (0 == strcmp("-", name)) { fp = stdin; } else if (NULL == (fp = fopen(name, "r"))) { fprintf(stderr, "%s: error opening file\n", name); return NULL; } switch (*format) { case CUE: cd = cue_parse(fp); break; case TOC: cd = toc_parse(fp); break; } if(stdin != fp) { fclose(fp); } return cd; } int cf_print(char *name, int *format, Cd *cd) { FILE *fp = NULL; if (UNKNOWN == *format) { if (UNKNOWN == (*format = cf_format_from_suffix(name))) { fprintf(stderr, "%s: unknown file suffix\n", name); return -1; } } if (0 == strcmp("-", name)) { fp = stdout; } else if (NULL == (fp = fopen(name, "w"))) { fprintf(stderr, "%s: error opening file\n", name); return -1; } switch (*format) { case CUE: cue_print(fp, cd); break; case TOC: toc_print(fp, cd); break; } if(stdout != fp) { fclose(fp); } return 0; } int cf_format_from_suffix(char *name) { char *suffix; if (0 != (suffix = strrchr(name, '.'))) { if (0 == strcasecmp(".cue", suffix)) { return CUE; } else if (0 == strcasecmp(".toc", suffix)) { return TOC; } } return UNKNOWN; } cuetools-1.4.1/src/lib/cuefile.h000066400000000000000000000006021243676222400165020ustar00rootroot00000000000000/* * cuefile.h -- cue/toc public declarations * * Copyright (C) 2004, 2005, 2006, 2007, 2013 Svend Sorensen * For license terms, see the file COPYING in this distribution. */ #include "cd.h" enum Format {CUE, TOC, UNKNOWN}; typedef struct Cue Cue; Cd *cf_parse(char *fname, int *format); int cf_print(char *fname, int *format, Cd *cue); int cf_format_from_suffix(char *fname); cuetools-1.4.1/src/lib/time.c000066400000000000000000000017361243676222400160300ustar00rootroot00000000000000/* * time.c -- time functions * * Copyright (C) 2004, 2005, 2006, 2007, 2013 Svend Sorensen * For license terms, see the file COPYING in this distribution. */ #include #include long time_msf_to_frame(int m, int s, int f) { return (m * 60 + s) * 75 + f; } void msf_frame_to_msf(long frame, int *m, int *s, int *f) { *f = frame % 75; /* 0 <= frames <= 74 */ frame /= 75; *s = frame % 60; /* 0 <= seconds <= 59 */ frame /= 60; *m = frame; /* 0 <= minutes */ } void time_frame_to_msf(long frame, int *m, int *s, int *f) { *f = frame % 75; /* 0 <= frames <= 74 */ frame /= 75; *s = frame % 60; /* 0 <= seconds <= 59 */ frame /= 60; *m = frame; /* 0 <= minutes */ } /* print frame in mm:ss:ff format */ char *time_frame_to_mmssff(long f) { static char msf[10]; int minutes, seconds, frames; msf_frame_to_msf(f, &minutes, &seconds, &frames); sprintf(msf, "%02d:%02d:%02d", minutes, seconds, frames); return msf; } cuetools-1.4.1/src/lib/time.h000066400000000000000000000006051243676222400160270ustar00rootroot00000000000000/* * time.h -- time declarations * * Copyright (C) 2004, 2005, 2006, 2007, 2013 Svend Sorensen * For license terms, see the file COPYING in this distribution. */ #ifndef TIME_H #define TIME_H long time_msf_to_frame(int m, int s, int f); long time_mmssff_to_frame(char *mmssff); void time_frame_to_msf(long frame, int *m, int *s, int *f); char *time_frame_to_mmssff(long f); #endif cuetools-1.4.1/src/lib/toc.h000066400000000000000000000003521243676222400156550ustar00rootroot00000000000000/* * toc.h -- toc function declarations * * Copyright (C) 2004, 2005, 2006, 2007, 2013 Svend Sorensen * For license terms, see the file COPYING in this distribution. */ Cd *toc_parse(FILE *fp); void toc_print(FILE *fp, Cd *cd); cuetools-1.4.1/src/lib/toc_parse.y000066400000000000000000000125011243676222400170670ustar00rootroot00000000000000%{ /* * toc_parse.y -- parser for toc files * * Copyright (C) 2004, 2005, 2006, 2007, 2013 Svend Sorensen * For license terms, see the file COPYING in this distribution. */ #include #include #include #include "cd.h" #include "time.h" #include "toc_parse_prefix.h" #define YYDEBUG 1 extern int yylex(); void yyerror (char *s); static Cd *cd = NULL; static Track *track = NULL; static Cdtext *cdtext = NULL; %} %start tocfile %union { long ival; char *sval; } %token NUMBER %token STRING /* global (header) */ %token CATALOG %token CD_DA %token CD_ROM %token CD_ROM_XA /* track */ %token TRACK %token AUDIO %token MODE1 %token MODE1_RAW %token MODE2 %token MODE2_FORM1 %token MODE2_FORM2 %token MODE2_FORM_MIX %token MODE2_RAW %token RW %token RW_RAW %token NO %token COPY %token PRE_EMPHASIS %token TWO_CHANNEL_AUDIO %token FOUR_CHANNEL_AUDIO %token ISRC %token SILENCE %token ZERO %token AUDIOFILE %token DATAFILE %token FIFO %token START %token PREGAP %token INDEX /* CD-TEXT */ %token CD_TEXT %token LANGUAGE_MAP %token LANGUAGE %token TITLE %token PERFORMER %token SONGWRITER %token COMPOSER %token ARRANGER %token MESSAGE %token DISC_ID %token GENRE %token TOC_INFO1 %token TOC_INFO2 %token UPC_EAN %token ISRC %token SIZE_INFO %type disc_mode %type track_modes %type track_mode %type track_sub_mode %type track_set_flag %type track_clear_flag %type time %type cdtext_item %% tocfile : new_cd global_statements track_list ; new_cd : /* empty */ { cd = cd_init(); cdtext = cd_get_cdtext(cd); } ; global_statements : /* empty */ | global_statements global_statement ; global_statement : CATALOG STRING '\n' { cd_set_catalog(cd, $2); } | disc_mode '\n' { cd_set_mode(cd, $1); } | CD_TEXT '{' opt_nl language_map cdtext_langs '}' '\n' | error '\n' ; disc_mode : CD_DA | CD_ROM | CD_ROM_XA ; track_list : track | track_list track ; track : new_track track_def track_statements { while (2 > track_get_nindex(track)) { track_add_index(track, 0); } } ; new_track : /* empty */ { track = cd_add_track(cd); cdtext = track_get_cdtext(track); /* add 0 index */ track_add_index(track, 0); } ; track_def : TRACK track_modes '\n' { track_set_mode(track, $2); } ; track_modes : track_mode | track_mode track_sub_mode { track_set_sub_mode(track, $2); } ; track_mode : AUDIO | MODE1 | MODE1_RAW | MODE2 | MODE2_FORM1 | MODE2_FORM2 | MODE2_FORM_MIX | MODE2_RAW ; track_sub_mode : RW | RW_RAW ; track_statements : track_statement | track_statements track_statement ; track_statement : track_flags | ISRC STRING '\n' { track_set_isrc(track, $2); } | CD_TEXT '{' opt_nl cdtext_langs '}' '\n' | track_data | track_pregap | track_index | error '\n' ; track_flags : track_set_flag { track_set_flag(track, $1); } | track_clear_flag { track_clear_flag(track, $1); } ; track_set_flag : COPY '\n' | PRE_EMPHASIS '\n' | FOUR_CHANNEL_AUDIO '\n' ; track_clear_flag : NO PRE_EMPHASIS '\n' { $$ = $2; } | NO COPY '\n' { $$ = $2; } | TWO_CHANNEL_AUDIO '\n' ; track_data : zero_data time '\n' { if (NULL == track_get_filename(track)) { track_set_zero_pre(track, $2); } else { track_set_zero_post(track, $2); } } | AUDIOFILE STRING time '\n' { track_set_filename(track, $2); track_set_start(track, $3); } | AUDIOFILE STRING time time '\n' { track_set_filename(track, $2); track_set_start(track, $3); track_set_length(track, $4); } | DATAFILE STRING '\n' { track_set_filename(track, $2); } | DATAFILE STRING time '\n' { track_set_filename(track, $2); track_set_start(track, $3); } | FIFO STRING time '\n' { track_set_filename(track, $2); track_set_start(track, $3); } ; zero_data : SILENCE | ZERO ; track_pregap : START '\n' | START time '\n' { track_add_index(track, $2); } | PREGAP time '\n' { track_set_zero_pre(track, $2); track_add_index(track, $2); } ; track_index : INDEX time '\n' { track_add_index(track, $2); } ; language_map : LANGUAGE_MAP '{' opt_nl languages '}' '\n' ; languages : language | languages language ; language : NUMBER ':' NUMBER opt_nl { /* not implemented */ } ; cdtext_langs : cdtext_lang | cdtext_langs cdtext_lang ; cdtext_lang : LANGUAGE NUMBER '{' opt_nl cdtext_defs '}' '\n' ; cdtext_defs : /* empty */ | cdtext_defs cdtext_def ; cdtext_def : cdtext_item STRING '\n' { cdtext_set ($1, $2, cdtext); } | cdtext_item '{' bytes '}' '\n' { yyerror("binary CD-TEXT data not supported\n"); } ; cdtext_item : TITLE | PERFORMER | SONGWRITER | COMPOSER | ARRANGER | MESSAGE | DISC_ID | GENRE | TOC_INFO1 | TOC_INFO2 | UPC_EAN | ISRC | SIZE_INFO ; bytes : /* empty */ | bytes ',' NUMBER ; time : NUMBER | NUMBER ':' NUMBER ':' NUMBER { $$ = time_msf_to_frame($1, $3, $5); } ; opt_nl : /* empty */ | '\n' ; %% /* lexer interface */ extern int toc_lineno; extern int yydebug; extern FILE *toc_yyin; void yyerror (char *s) { fprintf(stderr, "%d: %s\n", toc_lineno, s); } Cd *toc_parse (FILE *fp) { toc_yyin = fp; yydebug = 0; if (0 == yyparse()) { return cd; } return NULL; } cuetools-1.4.1/src/lib/toc_parse_prefix.h000066400000000000000000000026151243676222400204300ustar00rootroot00000000000000/* * toc_parse_prefix.h -- yacc symbol redefinitions (for toc parser) * * Copyright (C) 2004, 2005, 2006, 2007, 2013 Svend Sorensen * For license terms, see the file COPYING in this distribution. */ /* Remap normal yacc names so we can have multiple parsers * see http://www.gnu.org/software/automake/manual/html_node/Yacc-and-Lex.html */ #define yymaxdepth toc_yymaxdepth #define yyparse toc_yyparse #define yylex toc_yylex #define yyerror toc_yyerror #define yylval toc_yylval #define yychar toc_ychar #define yydebug toc_yydebug #define yypact toc_yypact #define yyr1 toc_yyr1 #define yyr2 toc_yyr2 #define yydef toc_yydef #define yychk toc_yychk #define yypgo toc_yypgo #define yyact toc_yyact #define yyexca toc_yyexca #define yyerrflag toc_yyerrflag #define yynerrs toc_yynerrs #define yyps toc_yyps #define yypv toc_yypv #define yys toc_yys #define yy_yys toc_yy_yys #define yystate toc_yystate #define yytmp toc_yytmp #define yyv toc_yyv #define yy_yyv toc_yy_yyv #define yyval toc_yyval #define yylloc toc_yylloc #define yyreds toc_yyreds #define yytoks toc_yytoks #define yylhs toc_yylhs #define yylen toc_yylen #define yydefred toc_yydefred #define yydgoto toc_yydgoto #define yysinde toc_yysindex #define yyrindex toc_yyrindex #define yygindex toc_yygindex #define yytable toc_yytable #define yycheck toc_yycheck #define yyname toc_yyname #define yyrule toc_yyrule cuetools-1.4.1/src/lib/toc_print.c000066400000000000000000000067751243676222400171030ustar00rootroot00000000000000/* * toc_print.c -- print toc file * * Copyright (C) 2004, 2005, 2006, 2007, 2013 Svend Sorensen * For license terms, see the file COPYING in this distribution. */ #include #include #include "cd.h" #include "time.h" void toc_print_track (FILE *fp, Track *track); void toc_print_cdtext (Cdtext *cdtext, FILE *fp, int istrack); void toc_print (FILE *fp, Cd *cd) { Cdtext *cdtext = cd_get_cdtext(cd); int i; /* track */ Track *track; switch(cd_get_mode(cd)) { case MODE_CD_DA: fprintf(fp, "CD_DA\n"); break; case MODE_CD_ROM: fprintf(fp, "CD_ROM\n"); break; case MODE_CD_ROM_XA: fprintf(fp, "CD_ROM_XA\n"); break; } if (NULL != cd_get_catalog(cd)) { fprintf(fp, "CATALOG \"%s\"\n", cd_get_catalog(cd)); } if(0 != cdtext_is_empty(cdtext)) { fprintf(fp, "CD_TEXT {\n"); fprintf(fp, "\tLANGUAGE_MAP { 0:9 }\n"); fprintf(fp, "\tLANGUAGE 0 {\n"); toc_print_cdtext(cdtext, fp, 0); fprintf(fp, "\t}\n"); fprintf(fp, "}\n"); } for (i = 1; i <= cd_get_ntrack(cd); i++) { track = cd_get_track(cd, i); fprintf(fp, "\n"); toc_print_track(fp, track); } } void toc_print_track (FILE *fp, Track *track) { Cdtext *cdtext = track_get_cdtext(track); int i; /* index */ fprintf(fp, "TRACK "); switch (track_get_mode(track)) { case MODE_AUDIO: fprintf(fp, "AUDIO"); break; case MODE_MODE1: fprintf(fp, "MODE1"); break; case MODE_MODE1_RAW: fprintf(fp, "MODE1_RAW"); break; case MODE_MODE2: fprintf(fp, "MODE2"); break; case MODE_MODE2_FORM1: fprintf(fp, "MODE2_FORM1"); break; case MODE_MODE2_FORM2: fprintf(fp, "MODE2_FORM2"); break; case MODE_MODE2_FORM_MIX: fprintf(fp, "MODE2_FORM_MIX"); break; } fprintf(fp, "\n"); if (0 != track_is_set_flag(track, FLAG_PRE_EMPHASIS)) { fprintf(fp, "PRE_EMPHASIS\n"); } if (0 != track_is_set_flag(track, FLAG_COPY_PERMITTED)) { fprintf(fp, "COPY\n"); } if (0 != track_is_set_flag(track, FLAG_FOUR_CHANNEL)) { fprintf(fp, "FOUR_CHANNEL_AUDIO\n"); } if (NULL != track_get_isrc(track)) { fprintf(fp, "ISRC \"%s\"\n", track_get_isrc(track)); } if (0 != cdtext_is_empty(cdtext)) { fprintf(fp, "CD_TEXT {\n"); fprintf(fp, "\tLANGUAGE 0 {\n"); toc_print_cdtext(cdtext, fp, 1); fprintf(fp, "\t}\n"); fprintf(fp, "}\n"); } if (0 != track_get_zero_pre(track)) { fprintf(fp, "ZERO "); fprintf(fp, "%s", time_frame_to_mmssff(track_get_zero_pre(track))); fprintf(fp, "\n"); } fprintf(fp, "FILE "); fprintf(fp, "\"%s\" ", track_get_filename(track)); if (0 == track_get_start(track)) { fprintf(fp, "0"); } else { fprintf(fp, "%s", time_frame_to_mmssff(track_get_start(track))); } if (0 != track_get_length(track)) { fprintf(fp, " %s", time_frame_to_mmssff(track_get_length(track))); } fprintf(fp, "\n"); if (0 != track_get_zero_post(track)) { fprintf(fp, "ZERO "); fprintf(fp, "%s", time_frame_to_mmssff(track_get_zero_post(track))); fprintf(fp, "\n"); } if (track_get_index(track, 1) != 0) { fprintf(fp, "START "); fprintf(fp, "%s\n", time_frame_to_mmssff(track_get_index(track, 1))); } for (i = 2; i < track_get_nindex(track); i++) { fprintf(fp, "INDEX "); fprintf(fp, "%s\n", time_frame_to_mmssff( \ track_get_index(track, i) - track_get_index(track, 0) \ )); } } void toc_print_cdtext (Cdtext *cdtext, FILE *fp, int istrack) { int pti; char *value = NULL; for (pti = 0; PTI_END != pti; pti++) { if (NULL != (value = cdtext_get(pti, cdtext))) { fprintf(fp, "\t\t"); fprintf(fp, "%s", cdtext_get_key(pti, istrack)); fprintf(fp, " \"%s\"\n", value); } } } cuetools-1.4.1/src/lib/toc_scan.l000066400000000000000000000065231243676222400166730ustar00rootroot00000000000000%{ /* * toc_scan.l -- lexer for toc files * * Copyright (C) 2004, 2005, 2006, 2007, 2013 Svend Sorensen * For license terms, see the file COPYING in this distribution. */ #include #include #include "cd.h" #include "toc_parse_prefix.h" #include "toc_parse.h" int toc_lineno = 1; %} ws [ \t\r] nonws [^ \t\r\n] %option noyywrap %option prefix="toc_yy" %s NAME %% \"([^\"]|\\\")*\" { yylval.sval = strdup(yytext + 1); yylval.sval[strlen(yylval.sval) - 1] = '\0'; BEGIN(INITIAL); return STRING; } {nonws}+ { yylval.sval = strdup(yytext); BEGIN(INITIAL); return STRING; } CATALOG { BEGIN(NAME); return CATALOG; } CD_DA { yylval.ival = MODE_CD_DA; return CD_DA; } CD_ROM { yylval.ival = MODE_CD_ROM; return CD_ROM; } CD_ROM_XA { yylval.ival = MODE_CD_ROM_XA; return CD_ROM_XA; } TRACK { return TRACK; } AUDIO { yylval.ival = MODE_AUDIO; return AUDIO; } MODE1 { yylval.ival = MODE_MODE1; return MODE1; } MODE1_RAW { yylval.ival = MODE_MODE1_RAW; return MODE1_RAW; } MODE2 { yylval.ival = MODE_MODE2; return MODE2; } MODE2_FORM1 { yylval.ival = MODE_MODE2_FORM1; return MODE2_FORM1; } MODE2_FORM2 { yylval.ival = MODE_MODE2_FORM2; return MODE2_FORM2; } MODE2_FORM_MIX { yylval.ival = MODE_MODE2_FORM_MIX; return MODE2_FORM_MIX; } MODE2_RAW { yylval.ival = MODE_MODE2_RAW; return MODE2_RAW; } RW { yylval.ival = SUB_MODE_RW; return RW; } RW_RAW { yylval.ival = SUB_MODE_RW_RAW; return RW_RAW; } NO { return NO; } COPY { yylval.ival = FLAG_COPY_PERMITTED; return COPY; } PRE_EMPHASIS { yylval.ival = FLAG_PRE_EMPHASIS; return PRE_EMPHASIS; } FOUR_CHANNEL_AUDIO { yylval.ival = FLAG_FOUR_CHANNEL; return FOUR_CHANNEL_AUDIO; } TWO_CHANNEL_AUDIO { yylval.ival = FLAG_FOUR_CHANNEL; return TWO_CHANNEL_AUDIO; } /* ISRC is with CD-TEXT items */ SILENCE { return SILENCE; } ZERO { return ZERO; } (AUDIO)?FILE { BEGIN(NAME); return AUDIOFILE; } DATAFILE { BEGIN(NAME); return DATAFILE; } FIFO { BEGIN(NAME); return FIFO; } START { return START; } PREGAP { return PREGAP; } INDEX { return INDEX; } CD_TEXT { return CD_TEXT; } LANGUAGE_MAP { return LANGUAGE_MAP; } LANGUAGE { return LANGUAGE; } TITLE { BEGIN(NAME); yylval.ival = PTI_TITLE; return TITLE; } PERFORMER { BEGIN(NAME); yylval.ival = PTI_PERFORMER; return PERFORMER; } SONGWRITER { BEGIN(NAME); yylval.ival = PTI_SONGWRITER; return SONGWRITER; } COMPOSER { BEGIN(NAME); yylval.ival = PTI_COMPOSER; return COMPOSER; } ARRANGER { BEGIN(NAME); yylval.ival = PTI_ARRANGER; return ARRANGER; } MESSAGE { BEGIN(NAME); yylval.ival = PTI_MESSAGE; return MESSAGE; } DISC_ID { BEGIN(NAME); yylval.ival = PTI_DISC_ID; return DISC_ID; } GENRE { BEGIN(NAME); yylval.ival = PTI_GENRE; return GENRE; } TOC_INFO1 { BEGIN(NAME); yylval.ival = PTI_TOC_INFO1; return TOC_INFO1; } TOC_INFO2 { BEGIN(NAME); yylval.ival = PTI_TOC_INFO2; return TOC_INFO2; } UPC_EAN { BEGIN(NAME); yylval.ival = PTI_UPC_ISRC; return UPC_EAN; } ISRC { BEGIN(NAME); yylval.ival = PTI_UPC_ISRC; return ISRC; } SIZE_INFO { BEGIN(NAME); yylval.ival = PTI_SIZE_INFO; return SIZE_INFO; } "//".*\n { toc_lineno++; /* ignore comments */ } {ws}+ { /* ignore whitespace */ } [[:digit:]]+ { yylval.ival = atoi(yytext); return NUMBER; } :|,|\{|\} { return yytext[0]; } ^{ws}*\n { toc_lineno++; /* blank line */ } \n { toc_lineno++; return '\n'; } . { fprintf(stderr, "bad character '%c'\n", yytext[0]); } %% cuetools-1.4.1/src/tools/000077500000000000000000000000001243676222400153115ustar00rootroot00000000000000cuetools-1.4.1/src/tools/Makefile.am000066400000000000000000000003051243676222400173430ustar00rootroot00000000000000# Makefile.am - process with automake to produce Makefile.in bin_PROGRAMS = cuebreakpoints cueconvert cueprint bin_SCRIPTS = cuetag.sh LDADD = ../lib/libcuefile.a AM_CPPFLAGS = -I$(srcdir)/../lib cuetools-1.4.1/src/tools/cuebreakpoints.c000066400000000000000000000104571243676222400205020ustar00rootroot00000000000000/* * cuebreakpoints.c -- print track break points * * Copyright (C) 2004, 2005, 2006, 2007, 2013 Svend Sorensen * For license terms, see the file COPYING in this distribution. */ #include /* getopt_long() */ #include /* fprintf(), printf(), snprintf(), stderr */ #include /* exit() */ #include /* strcasecmp() */ #include "cuefile.h" #include "time.h" #if HAVE_CONFIG_H #include "config.h" #else /* not HAVE_CONFIG_H */ #define PACKAGE_STRING "cuebreakpoints" #endif /* HAVE_CONFIG_H */ char *progname; /* * pregap correction modes: * APPEND - append pregap to previous track (except for first track) * PREPEND - prefix pregap to current track * SPLIT - print breakpoints for beginning and end of pregap */ enum GapMode {APPEND, PREPEND, SPLIT}; /* Print usage information and exit */ void usage(int status) { if (0 == status) { printf("Usage: %s [option...] [file...]\n", progname); printf("Report track breakpoints from a CUE or TOC file.\n" "\n" "OPTIONS\n" "-h, --help print usage\n" "-i, --input-format cue|toc set format of file(s)\n" "--append-gaps append pregaps to previous track (default)\n" "--prepend-gaps prefix pregaps to track\n" "--split-gaps split at beginning and end of pregaps\n" "-V, --version print version information\n"); } else { fprintf(stderr, "Try `%s --help' for more information.\n", progname); } exit (status); } /* Print version information and exit */ void version() { printf("%s\n", PACKAGE_STRING); exit(0); } void print_m_ss_ff(long frame) { int m, s, f; time_frame_to_msf(frame, &m, &s, &f); printf ("%d:%02d.%02d\n", m, s, f); } void print_breakpoint(long b) { /* Do not print zero breakpoints. */ if (0 != b) { print_m_ss_ff(b); } } void print_breaks(Cd *cd, int gaps) { int i; long b; long pg; Track *track; for (i = 1; i <= cd_get_ntrack(cd); i++) { track = cd_get_track(cd, i); /* * When breakpoint is at: * index 0: gap is prepended to track * index 1: gap is appended to previous track */ b = track_get_start(track); pg = track_get_index(track, 1) - track_get_zero_pre(track); if (gaps == PREPEND || gaps == SPLIT) { print_breakpoint(b); /* * There is no previous track to append the first track's * pregap to. */ } else if (gaps == APPEND && 1 < i) { print_breakpoint(b + pg); } /* If pregap exists, print breakpoints (in split mode). */ if (gaps == SPLIT && 0 < pg) { print_breakpoint(b + pg); } } } int breaks(char *name, int format, int gaps) { Cd *cd = NULL; if (NULL == (cd = cf_parse(name, &format))) { fprintf(stderr, "%s: error: unable to parse input file" " `%s'\n", progname, name); return -1; } print_breaks(cd, gaps); return 0; } int main(int argc, char *argv[]) { int format = UNKNOWN; int gaps = APPEND; int ret = 0; /* return value of breaks() */ /* option variables */ int c; /* getopt_long() variables */ extern char *optarg; extern int optind; static struct option longopts[] = { {"help", no_argument, NULL, 'h'}, {"input-format", required_argument, NULL, 'i'}, {"append-gaps", no_argument, NULL, 'a'}, {"prepend-gaps", no_argument, NULL, 'p'}, {"split-gaps", no_argument, NULL, 's'}, {"version", no_argument, NULL, 'V'}, {NULL, 0, NULL, 0} }; progname = argv[0]; while (-1 != (c = getopt_long(argc, argv, "hi:V", longopts, NULL))) { switch (c) { case 'h': usage(0); break; case 'i': if (0 == strcmp("cue", optarg)) { format = CUE; } else if (0 == strcmp("toc", optarg)) { format = TOC; } else { fprintf(stderr, "%s: error: unknown input file" " format `%s'\n", progname, optarg); usage(1); } break; case 'a': gaps = APPEND; break; case 'p': gaps = PREPEND; break; case 's': gaps = SPLIT; break; case 'V': version(); break; default: usage(1); break; } } /* What we do depends on the number of operands. */ if (optind == argc) { /* No operands: report breakpoints of stdin. */ ret = breaks("-", format, gaps); } else { /* Report track breakpoints for each operand. */ for (; optind < argc; optind++) { ret = breaks(argv[optind], format, gaps); /* Exit if breaks() returns nonzero. */ if (!ret) { break; } } } return ret; } cuetools-1.4.1/src/tools/cueconvert.c000066400000000000000000000067331243676222400176430ustar00rootroot00000000000000/* * cueconvert.c -- convert between cue/toc formats * * Copyright (C) 2004, 2005, 2006, 2007, 2013 Svend Sorensen * For license terms, see the file COPYING in this distribution. */ #include /* getopt_long() */ #include /* fprintf(), printf(), snprintf(), stderr */ #include /* exit() */ #include /* strcasecmp() */ #include "cuefile.h" #if HAVE_CONFIG_H #include "config.h" #else /* not HAVE_CONFIG_H */ #define PACKAGE_STRING "cueconvert" #endif /* HAVE_CONFIG_H */ char *progname; /* Print usage information and exit */ void usage(int status) { if (0 == status) { printf("Usage: %s [option...] [infile [outfile]]\n", progname); printf("Convert file between the CUE and TOC formats.\n" "\n" "OPTIONS\n" "-h, --help print usage\n" "-i, --input-format cue|toc set format of input file\n" "-o, --output-format cue|toc set format of output file\n" "-V, --version print version information\n"); } else { fprintf(stderr, "Try `%s --help' for more information.\n", progname); } exit (status); } /* Print version information and exit */ void version() { printf("%s\n", PACKAGE_STRING); exit(0); } int convert(char *iname, int iformat, char *oname, int oformat) { Cd *cd = NULL; if (NULL == (cd = cf_parse(iname, &iformat))) { fprintf(stderr, "%s: error: unable to parse input file" " `%s'\n", progname, iname); return -1; } if (UNKNOWN == oformat) { /* first use file suffix */ if (UNKNOWN == (oformat = cf_format_from_suffix(oname))) { /* then use opposite of input format */ switch(iformat) { case CUE: oformat = TOC; break; case TOC: oformat = CUE; break; } } } return cf_print(oname, &oformat, cd); } int main(int argc, char *argv[]) { int iformat = UNKNOWN; int oformat = UNKNOWN; int ret = 0; /* return value of convert() */ /* option variables */ int c; /* getopt_long() variables */ extern char *optarg; extern int optind; static struct option longopts[] = { {"help", no_argument, NULL, 'h'}, {"input-format", required_argument, NULL, 'i'}, {"output-format", required_argument, NULL, 'o'}, {"version", no_argument, NULL, 'V'}, {NULL, 0, NULL, 0} }; progname = argv[0]; while (-1 != (c = getopt_long(argc, argv, "hi:o:V", longopts, NULL))) { switch (c) { case 'h': usage(0); break; case 'i': if (0 == strcmp("cue", optarg)) { iformat = CUE; } else if (0 == strcmp("toc", optarg)) { iformat = TOC; } else { fprintf(stderr, "%s: error: unknown input file" " format `%s'\n", progname, optarg); usage(1); } break; case 'o': if (0 == strcmp("cue", optarg)) { oformat = CUE; } else if (0 == strcmp("toc", optarg)) { oformat = TOC; } else { fprintf(stderr, "%s: error: unknown output file" " format `%s'\n", progname, optarg); usage(1); } break; case 'V': version(); break; default: usage(1); break; } } /* What we do depends on the number of operands. */ if (optind == argc) { /* No operands: report breakpoints of stdin. */ ret = convert("-", iformat, "-", oformat); } else if (optind == argc - 1) { /* One operand: convert operand file to stdout. */ ret = convert(argv[optind], iformat, "-", oformat); } else if (optind == argc - 2) { /* Two operands: convert input file to output file. */ ret = convert(argv[optind], iformat, argv[optind + 1], oformat); } else { usage(1); } return ret; } cuetools-1.4.1/src/tools/cueprint.c000066400000000000000000000241221243676222400173070ustar00rootroot00000000000000/* * cueprint.c -- print cd information based on a template * * Copyright (C) 2004, 2005, 2006, 2007, 2013 Svend Sorensen * For license terms, see the file COPYING in this distribution. */ #include /* isdigit() */ #include /* getopt_long() */ #include /* fprintf(), printf(), snprintf(), stderr */ #include /* exit() */ #include /* strcasecmp() */ #include "cuefile.h" #if HAVE_CONFIG_H #include "config.h" #else /* not HAVE_CONFIG_H */ #define PACKAGE_STRING "cueprint" #endif /* HAVE_CONFIG_H */ /* default templates */ #define D_TEMPLATE "\ Disc Information\n\ arranger: %A\n\ composer: %C\n\ genre: %G\n\ message: %M\n\ no. of tracks: %N\n\ performer: %P\n\ songwriter: %S\n\ title: %T\n\ UPC/EAN: %U\n\ " #define T_TEMPLATE "\ \n\ Track %n Information\n\ arranger: %a\n\ composer: %c\n\ genre: %g\n\ ISRC: %i\n\ message: %m\n\ track number: %n\n\ perfomer: %p\n\ title: %t\n\ ISRC (CD-TEXT): %u\n\ " /* default string to print for unset (NULL) values */ #define VALUE_UNSET "" /* * *_get_* functions can return an int or a char * */ typedef union { int ival; char *sval; char cval; } Value; char *progname; /* Print usage information and exit */ void usage(int status) { if (0 == status) { printf("Usage: %s [option...] [file...]\n", progname); printf("Report disc and track information from a CUE or TOC file.\n" "\n" "OPTIONS\n" "-h, --help print usage\n" "-i, --input-format cue|toc set format of file(s)\n" "-n, --track-number only print track information for single track\n" "-d, --disc-template