View | Details | Raw Unified
Collapse All | Expand All

(-) cuetools-1.3-OFFICIAL/doc/cuebreakpoints.1 (-34 / +82 lines)
 Lines 1-46    Link Here 
.TH cuetools 1
.TH cuebreakpoints 1 2005-08-23 "Cuetools 1.3"
.
.SH NAME
.SH NAME
cuebreakpoints
cuebreakpoints \- report track breakpoints from a CUE or TOC file
.
.SH DESCRIPTION
cuebreakpoints \- print the breakpoints from a cue or toc file
.
.SH SYNOPSIS
.SH SYNOPSIS
.B cuebreakpoints
.B cuebreakpoints
[option...] [file...]
[ {
.
.B \-i
.I format
|
.BR \-\-input\-format =\fIformat\fP
} {
.B \-\-append\-gaps
|
.B \-\-prepend\-gaps
|
.B \-\-split\-gaps
} ]
[
.I file
\&... ]
.br
.B cuebreakpoints \-\-help
.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 availabe: 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
.SH OPTIONS
.TP
.TP
.B \-h, \--help
.BR \-h ", " \-\-help
print usage information
displays a usage message and exits.
.
.TP
.TP
.B \-i, \--input-format cue|toc
.BR \-i " \fIformat\fP, " \-\-input\-format=\fIformat\fP
set format of file(s)
sets the expected format of the input file(s) to
.
.IR format ,
which must be either
.B cue
or
.BR toc .
.TP
.TP
.B \--append-gaps
.B \-\-append\-gaps
append pregaps to previous track (default)
appends pregaps to the end of the previous track.
.
This is the default.
.TP
.TP
.B \--prepend-gaps
.B \-\-prepend\-gaps
prefix pregaps to track
prefixes pregaps to the beginning of each subsequent track.
.
.TP
.TP
.B \--split-gaps
.B \-\-split\-gaps
split at beginning and end of pregaps
separates pregaps from both the preceding and succeeding tracks.
.
.SH NOTES
The breakpoints are in a format usable by shnsplit (part of the shntool package).
.PP
.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 split mode.
If more than one of
.PP
.BR \-\-append\-gaps ,
If no files are specified, stdin is used.  If a filename is specified and the format is not specified, the format will be set based on a ".cue" or ".toc" suffix.
.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
.SH AUTHOR
Svend Sorensen
Cuetools was written by Svend Sorensen.
.
Branden Robinson contributed fixes and enhancements to the utilities and
documentation.
.SH "SEE ALSO"
.SH "SEE ALSO"
cueconvert(1),
.BR cueconvert (1),
cueprint(1)
.BR cueprint (1)
(-) cuetools-1.3-OFFICIAL/doc/cueconvert.1 (-25 / +70 lines)
 Lines 1-34    Link Here 
.TH cuetools 1
.TH cueconvert 1 2005-08-23 "Cuetools 1.3"
.
.SH NAME
.SH NAME
cueconvert
cueconvert \- convert files between CUE and TOC formats
.
.SH DESCRIPTION
cueconvert \- convert between the cue and toc formats
.
.SH SYNOPSIS
.SH SYNOPSIS
.B cueconvert
.B cueconvert
[option...] [infile [outfile]]
[
.
.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 \-\-help
.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 filenamess 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
.SH OPTIONS
.TP
.TP
.B \-h, \--help
.BR \-h ", " \-\-help
print usage information
displays a usage message and exits.
.
.TP
.TP
.B \-i, \--input-format cue|toc
.BR \-i " \fIformat\fP, " \-\-input\-format=\fIformat\fP
set format of input file
sets the expected format of the input file to
.
.IR format .
.TP
.TP
.B \-o, \--output-format cue|toc
.BR \-o " \fIformat\fP, " \-\-output\-format=\fIformat\fP
set format of output file
sets the format of the generated output file to
.
.IR format .
.SH NOTES
.PP
If infile or outfile is not specified, stdin and stdout are used, respectively.  If a filename is specified and the format is not specified, the format will be set based on a ".cue" or ".toc" suffix.  If the output file format is not specified, and it cannot be determined from the suffix, it will be set to the opposite of the input format.
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
.SH AUTHOR
Svend Sorensen
Cuetools was written by Svend Sorensen.
.
Branden Robinson contributed fixes and enhancements to the utilities and
documentation.
.SH "SEE ALSO"
.SH "SEE ALSO"
cuebreakpoints(1),
.BR cuebreakpoints (1),
cueprint(1)
.BR cueprint (1)
(-) cuetools-1.3-OFFICIAL/doc/cueprint.1 (-183 / +170 lines)
 Lines 1-198    Link Here 
.TH cuetools 1
.TH cueprint 1 2005-08-23 "Cuetools 1.3"
.
.SH NAME
.SH NAME
cueprint
cueprint \- report disc and track infomation from a CUE or TOC file
.
.SH DESCRIPTION
cueprint \- print disc and track infomation for a cue or toc file
.
.SH SYNOPSIS
.SH SYNOPSIS
.B cueprint
.B cueprint
[option...] [file...]
[ {
.
.B \-i
.SH OPTIONS
.I format
.TP
|
.B \-h, \--help
.BR \-\-input\-format =\fIformat\fP
print usage information
} {
.
.B \-n
.TP
.I number
.B \-i, \--input-format cue|toc
|
set format of file(s)
.BR \-\-track\-number =\fInumber\fP
.
} {
.TP
.B \-d
.B \-n, \--track-number <number>
.I template
only print track information for single track.  The default is to print information for all tracks.
|
.
.BR \-\-disc\-template =\fItemplate\fP
.TP
} {
.B \-d, \--disc-template <template>
.B \-t
set disc template (see TEMPLATE EXPANSION)
.I template
.
|
.TP
.BR \-\-track\-template =\fItemplate\fP
.B \-t, \--track-template <template>
} ]
set track template (see TEMPLATE EXPANSION)
[
.
.I file
.SH TEMPLATE EXPANSION
\&... ]
All characters in the template are reproduced in the output except for conversions, which begin with `%'.
.br
.PP
.B cueprint \-\-help
A conversion has the form `%[flags][width][.precision]<conversion\-char>'.
.SH DESCRIPTION
.PP
.B cueprint
There may be zero or more of the following flags:
reports disc and track information from CUE and TOC files, which are
.
typically created by compact disc ripping software.
.TP
.B \-
left justification
.
.TP
.B +
place sign before numbers
.
.TP
.B ` '
(space) place a space before a positive number
.
.TP
.B 0
pad with zeros
.
.TP
.B #
(unused)
.
.PP
width is the minimum field width.  precision is the maximum width for strings.
.PP
Disc template expansion characters are valid for both the disc and track templates.
.PP
.PP
.B Disc Conversion Specifiers
By default,
.
.B cueprint
.TP
reports a default set of disc information, and a default set of information
.B A
for each track on the disc.
album arranger
With options, the report can be restricted to a specific track, and the
.
presentation of the disc and track information can be extensively
.TP
customized using
.B C
.BR printf (3)-style
album composer
format strings (referred to here as \(oqtemplates\(cq to avoid confusion
.
with the concept of file format).
.TP
All characters in a template are reproduced as-is in the output except for
.B G
conversions (which begin with
album genre
.RB \(oq % \(cq)
.
and escapes (which begin with
.TP
.RB \(oq \e \(cq).
.B M
album message
.
.TP
.B N
number of tracks
.
.TP
.B P
album performer
.
.TP
.B S
album songwriter
.
.TP
.B T
album title
.
.TP
.B U
album UPC/EAN
.
.PP
.PP
.B Track Conversion Specifiers
If no filenames are specified,
.
.B cueprint
.TP
reads from standard input, and an input format option
.B a
.I must
track arranger
be specified.
.
If one or more filenames is provided, but the input format option is not
.TP
specified, the input format will be guessed based on each file's suffix
.B c
(e.g.,
track composer
.I .cue
.
or
.TP
.IR .toc ).
.B g
This heuristic is case-insensitive.
track genre
.SS Conversions
.
A conversion has the form
.TP
.RB \(oq % [ \fIflags\fP ][ \fIwidth\fP ][ .\fIprecision\fP ] \fItype\fP \(cq.
.B i
.PP
track ISRC
.I flags
.
may be zero or more of the following:
.TP
.TS
.B m
nokeep;
track message
l	l.
.
Character	Meaning
.TP
_
.B n
\-	left-justify expansion
track number
\(oq \(cq (space)	place a blank space before a positive number
.
0	pad numbers with zeroes
.TP
.TE
.B p
.\"#	(unused)
track perfomer
.PP
.
.I width
.TP
is the minimum field width.
.B t
.I precision
track title
is the maximum width for strings.
.
.I type
.TP
is a single character which specifies the conversion type \(em apart from
.B u
.BR % ,
track ISRC (CD-TEXT)
it is the only mandatory part of the conversion.
.
.PP
.PP
The available conversion types are presented in the table below; disc
Any other character is expanded to that character.  For example, a % expands to a literal `%'.
conversion types are presented in the left half of the table, and track
.
conversion types in the right half.
.SH ESCAPES
Disc template expansion characters are valid for both disc and track
The following single-character escapes are recognized:
templates.
.
.TS
.TP
nokeep;
.B \ea
l	l	l	l.
alert (bell)
Character	Conversion	Character	Conversion
.
_
.TP
A	album arranger	a	track arranger
.B \eb
C	album composer	c	track composer
backspace
G	album genre	g	track genre
.
		i	track ISRC
.TP
M	album message	m	track message
.B \ef
N	number of tracks	n	track number
formfeed
P	album performer	p	track performer
.
S	album songwriter
.TP
T	album title	t	track title
.B \en
U	album UPC/EAN	u	track ISRC (CD-TEXT)
newline
.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
.TP
.B \er
.BR \-d " \fItemplate\fP, " \-\-disc\-template=\fItemplate\fP
carriage return
set disc template (see TEMPLATE EXPANSION)
.
.TP
.TP
.B \et
.BR \-h ", " \-\-help
horizontal tab
displays a usage message and exits.
.
.TP
.TP
.B \ev
.BR \-i " \fIformat\fP, " \-\-input\-format=\fIformat\fP
vertial tab
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
.TP
.B \e0
.BR \-t " \fItemplate\fP, " \-\-track\-template=\fItemplate\fP
NULL
set track template (see TEMPLATE EXPANSION)
.
.SH "EXIT STATUS"
.SH NOTES
.B cueprint
If no files are specified, stdin is used.  If a filename is specified and the format is not specified, the format will be set based on a ".cue" or ".toc" suffix.
exits with status zero if it successfully reports information from each
.
input file, and nonzero if there were problems.
.SH EXAMPLES
.SH EXAMPLES
To display disc and track information (using the default template for both), run:
To display disc and track information (using the default template for
both):
.PP
.PP
% cueprint album.cue
.RB "% " "cueprint album.cue"
.PP
.PP
To print the number of tracks in a cue file, run:
To print the number of tracks in a CUE file:
.PP
.PP
% cueprint -d '%N\en' album.cue
.RB "% " "cueprint -d \(aq%N\en\(aq album.cue"
.
.SH AUTHOR
.SH AUTHOR
Svend Sorensen
Cuetools was written by Svend Sorensen.
.
Branden Robinson contributed fixes and enhancements to the utilities and
documentation.
.SH "SEE ALSO"
.SH "SEE ALSO"
cueconvert(1),
.BR cuebreakpoints (1),
cuebreakpoints(1)
.BR cueconvert (1),
.BR printf(3)
(-) split-gaps (-24 / +57 lines)
 Lines 3-20    Link Here 
 *
 *
 * Copyright (C) 2004 Svend Sorensen
 * Copyright (C) 2004 Svend Sorensen
 * For license terms, see the file COPYING in this distribution.
 * For license terms, see the file COPYING in this distribution.
 *
 * Modified 2005-08-23 by Branden Robinson.
 */
 */
#include <stdio.h>
#include <getopt.h>	/* getopt_long() */
#include <stdlib.h>
#include <stdio.h>	/* fprintf(), printf(), snprintf(), stderr */
#include <string.h>
#include <stdlib.h>	/* exit() */
#include <getopt.h>
#include <string.h>	/* strcasecmp() */
#include "cuefile.h"
#include "cuefile.h"
#include "time.h"
#include "time.h"
char *progname;
char *progname;
/* pregap correction modes
/*
 * pregap correction modes:
 * APPEND - append pregap to previous track (except for first track)
 * APPEND - append pregap to previous track (except for first track)
 * PREPEND - prefix pregap to current track
 * PREPEND - prefix pregap to current track
 * SPLIT - print breakpoints for beginning and end of pregap
 * SPLIT - print breakpoints for beginning and end of pregap
 Lines 23-44    Link Here 
void usage (int status)
void usage (int status)
{
{
	char synopsis[1024];
	/* TODO: We could use asprintf() if we know we're using GNU libc. */
	snprintf(synopsis, 1023, "usage: %s [option ...] [file ...]\n",
		 progname);
	if (0 == status) {
	if (0 == status) {
		fprintf(stdout, "%s: usage: cuebreakpoints [option...] [file...]\n", progname);
		printf("%s", synopsis);
		fputs("\
		printf("Report track breakpoints from a CUE or TOC file.\n"
\n\
		       "\n"
OPTIONS\n\
		       "Options:\n"
", stdout);
		       "-h, --help\t\t\t\tdisplay this message and exit\n"
		       "-i {cue|toc}, --input-format={cue|toc}\tset format of"
		       " input file(s)\n"
		       "--append-gaps\t\t\t\tappend pregaps to previous track\n"
		       "--prepend-gaps\t\t\t\tprefix pregaps to track\n"
		       "--split-gaps\t\t\t\tsplit at beginning and end of"
		       " pregaps\n"
		       "\n"
		       "The default handling of gaps is as if --append-gaps"
		       " were specified.\n"
		       "\n"
		       "See the %s(1) manual page for more information.\n",
		       progname);
	} else {
	} else {
		fprintf(stderr, "run `%s --help' for usage\n", progname);
		fprintf(stderr, "%sRun \"%s --help\" for more information.\n",
			synopsis, progname);
	}
	}
	exit (status);
	exit(status);
}
}
void print_m_ss_ff (long frame)
void print_m_ss_ff (long frame)
 Lines 46-52    Link Here 
	int m, s, f;
	int m, s, f;
	time_frame_to_msf(frame, &m, &s, &f);
	time_frame_to_msf(frame, &m, &s, &f);
	printf ("%d:%02d.%02d\n", m, s, f);
	printf("%d:%02d.%02d\n", m, s, f);
}
}
void print_breakpoint (long b)
void print_breakpoint (long b)
 Lines 64-70    Link Here 
	for (i = 1; i <= cd_get_ntrack(cd); i++) {
	for (i = 1; i <= cd_get_ntrack(cd); i++) {
		track = cd_get_track(cd, i);
		track = cd_get_track(cd, i);
		/* when breakpoint is at:
		/*
		 * when breakpoint is at:
		 * index 0: gap is prepended to track
		 * index 0: gap is prepended to track
		 * index 1: gap is appended to previous track
		 * index 1: gap is appended to previous track
		 */
		 */
 Lines 92-98    Link Here 
	Cd *cd = NULL;
	Cd *cd = NULL;
	if (NULL == (cd = cf_parse(name, &format))) {
	if (NULL == (cd = cf_parse(name, &format))) {
		fprintf(stderr, "%s: input file error\n", name);
		fprintf(stderr, "%s: error: unable to parse input file"
			" \"%s\"\n", progname, name);
		return -1;
		return -1;
	}
	}
 Lines 105-113    Link Here 
{
{
	int format = UNKNOWN;
	int format = UNKNOWN;
	int gaps = APPEND;
	int gaps = APPEND;
	int ret = 0;		/* return value of breaks() */
	/* option variables */
	/* option variables */
	char c;
	int c;
	/* getopt_long() variables */
	/* getopt_long() variables */
	extern char *optarg;
	extern char *optarg;
	extern int optind;
	extern int optind;
 Lines 121-127    Link Here 
		{NULL, 0, NULL, 0}
		{NULL, 0, NULL, 0}
	};
	};
	progname = *argv;
	progname = argv[0];
	while (-1 != (c = getopt_long(argc, argv, "hi:", longopts, NULL))) {
	while (-1 != (c = getopt_long(argc, argv, "hi:", longopts, NULL))) {
		switch (c) {
		switch (c) {
 Lines 129-142    Link Here 
			usage(0);
			usage(0);
			break;
			break;
		case 'i':
		case 'i':
			if (0 == strcmp("cue", optarg)) {
			if (0 == strcasecmp("cue", optarg)) {
				format = CUE;
				format = CUE;
			} else if (0 == strcmp("toc", optarg)) {
			} else if (0 == strcasecmp("toc", optarg)) {
				format = TOC;
				format = TOC;
			} else {
			} else {
				fprintf(stderr, "%s: illegal format `%s'\n", progname, optarg);
				fprintf(stderr, "%s: error: unknown input file"
					" format \"%s\"\n", progname, optarg);
				usage(1);
				usage(1);
			}
			}
			break;
			break;
		case 'a':
		case 'a':
			gaps = APPEND;
			gaps = APPEND;
 Lines 152-163    Link Here 
		}
		}
	}
	}
	/* What we do depends on the number of operands. */
	if (optind == argc) {
	if (optind == argc) {
		breaks("-", format, gaps);
		/* No operands: report breakpoints of stdin. */
		ret = breaks("-", format, gaps);
	} else {
	} else {
		for (; optind < argc; optind++)
		/* Report track breakpoints for each operand. */
			breaks(argv[optind], format, gaps);
		for (; optind < argc; optind++) {
			ret = breaks(argv[optind], format, gaps);
			/* Bail out if breaks() returns nonzero. */
			if (!ret)
				break;
		}
	}
	}
	return 0;
	return ret;
}
}
(-) cuetools-1.3-OFFICIAL/src/tools/cueconvert.c (-25 / +52 lines)
 Lines 3-34    Link Here 
 *
 *
 * Copyright (C) 2004 Svend Sorensen
 * Copyright (C) 2004 Svend Sorensen
 * For license terms, see the file COPYING in this distribution.
 * For license terms, see the file COPYING in this distribution.
 *
 * Modified 2005-08-23 by Branden Robinson.
 */
 */
#include <stdio.h>
#include <getopt.h>	/* getopt_long() */
#include <stdlib.h>
#include <stdio.h>	/* fprintf(), printf(), snprintf(), stderr */
#include <string.h>
#include <stdlib.h>	/* exit() */
#include <getopt.h>
#include <string.h>	/* strcasecmp() */
#include "cuefile.h"
#include "cuefile.h"
char *progname;
char *progname;
void usage (int status)
void usage (int status)
{
{
	char synopsis[1024];
	/* TODO: We could use asprintf() if we know we're using GNU libc. */
	snprintf(synopsis, 1023, "usage: %s [option ...] [infile [outfile]]\n",
		 progname);
	if (0 == status) {
	if (0 == status) {
		fprintf(stdout, "%s: usage: cueconvert [option...] [infile [outfile]]\n", progname);
		printf("%s", synopsis);
		fputs("\
		printf("Convert files between CUE and TOC formats.\n"
\n\
		       "\n"
OPTIONS\n\
		       "Options:\n"
", stdout);
		       "-h, --help\t\t\t\tdisplay this message and exit\n"
		       "-i {cue|toc}, --input-format={cue|toc}\tset format of"
		       " input file\n"
		       "-o {cue|toc}, --output-format={cue|toc}\tset format of"
		       " output file\n"
		       "\n"
		       "See the %s(1) manual page for more information.\n",
		       progname);
	} else {
	} else {
		fprintf(stderr, "run `%s --help' for usage\n", progname);
		fprintf(stderr, "%sRun \"%s --help\" for more information.\n",
				synopsis, progname);
	}
	}
	exit (status);
	exit(status);
}
}
int convert (char *iname, int iformat, char *oname, int oformat)
int convert (char *iname, int iformat, char *oname, int oformat)
 Lines 36-42    Link Here 
	Cd *cd = NULL;
	Cd *cd = NULL;
	if (NULL == (cd = cf_parse(iname, &iformat))) {
	if (NULL == (cd = cf_parse(iname, &iformat))) {
		fprintf(stderr, "input file error\n");
		fprintf(stderr, "%s: error: unable to parse input file\n",
			progname);
		return -1;
		return -1;
	}
	}
 Lines 62-70    Link Here 
{
{
	int iformat = UNKNOWN;
	int iformat = UNKNOWN;
	int oformat = UNKNOWN;
	int oformat = UNKNOWN;
	/* option variables */
	int ret = 0;		/* return value of convert() */
	char c;
	/* getopt_long() variables */
	/* getopt_long() variables */
	int c;
	extern char *optarg;
	extern char *optarg;
	extern int optind;
	extern int optind;
 Lines 75-81    Link Here 
		{NULL, 0, NULL, 0}
		{NULL, 0, NULL, 0}
	};
	};
	progname = *argv;
	progname = argv[0];
	while (-1 != (c = getopt_long(argc, argv, "hi:o:", longopts, NULL))) {
	while (-1 != (c = getopt_long(argc, argv, "hi:o:", longopts, NULL))) {
		switch (c) {
		switch (c) {
 Lines 83-106    Link Here 
			usage(0);
			usage(0);
			break;
			break;
		case 'i':
		case 'i':
			if (0 == strcmp("cue", optarg)) {
			if (0 == strcasecmp("cue", optarg)) {
				iformat = CUE;
				iformat = CUE;
			} else if (0 == strcmp("toc", optarg)) {
			} else if (0 == strcasecmp("toc", optarg)) {
				iformat = TOC;
				iformat = TOC;
			} else {
			} else {
				fprintf(stderr, "%s: illegal format `%s'\n", progname, optarg);
				fprintf(stderr, "%s: unknown input file format"
					" \"%s\"\n", progname, optarg);
				usage(1);
				usage(1);
			}
			}
			break;
			break;
		case 'o':
		case 'o':
			if (0 == strcmp("cue", optarg)) {
			if (0 == strcasecmp("cue", optarg)) {
				oformat = CUE;
				oformat = CUE;
			} else if (0 == strcmp("toc", optarg)) {
			} else if (0 == strcasecmp("toc", optarg)) {
				oformat = TOC;
				oformat = TOC;
			} else {
			} else {
				fprintf(stderr, "%s: illegal format `%s'\n", progname, optarg);
				fprintf(stderr, "%s: unknown output file format"
					" \"%s\"\n", progname, optarg);
				usage(1);
				usage(1);
			}
			}
			break;
			break;
		default:
		default:
			usage(1);
			usage(1);
 Lines 106-120    Link Here 
		}
		}
	}
	}
	/* What we do depends on the number of operands. */
	if (optind == argc) {
	if (optind == argc) {
		convert("-", iformat, "-", oformat);
		/* No operands: convert stdin to stdout. */
		ret = convert("-", iformat, "-", oformat);
	} else if (optind == argc - 1) {
	} else if (optind == argc - 1) {
		convert(argv[optind], iformat, "-", oformat);
		/* One operand: convert operand file to stdout. */
		ret = convert(argv[optind], iformat, "-", oformat);
	} else if (optind == argc - 2) {
	} else if (optind == argc - 2) {
		convert(argv[optind], iformat, argv[optind + 1], oformat);
		/* Two operands: convert input file to output file. */
		ret = convert(argv[optind], iformat, argv[optind + 1], oformat);
	} else {
	} else {
		usage(1);
		usage(1);
	}
	}
	return 0;
	if (0 != ret) {
		fprintf(stderr, "%s: conversion failed\n", progname);
	}
	return ret;
}
}
(-) cuetools-1.3-OFFICIAL/src/tools/cueprint.c (-60 / +74 lines)
 Lines 3-15    Link Here 
 *
 *
 * Copyright (C) 2004 Svend Sorensen
 * Copyright (C) 2004 Svend Sorensen
 * For license terms, see the file COPYING in this distribution.
 * For license terms, see the file COPYING in this distribution.
 *
 * Modified 2005-08-23 by Branden Robinson.
 */
 */
#include <stdio.h>
#include <ctype.h>	/* isdigit() */
#include <stdlib.h>		/* exit() */
#include <getopt.h>	/* getopt_long() */
#include <string.h>		/* strcmp() */
#include <stdio.h>	/* fprintf(), printf(), snprintf(), stderr */
#include <getopt.h>
#include <stdlib.h>	/* exit() */
#include <ctype.h>		/* isdigit() */
#include <string.h>	/* strcasecmp() */
#include "cuefile.h"
#include "cuefile.h"
/* default templates */
/* default templates */
 Lines 57-108    Link Here 
void usage (int status)
void usage (int status)
{
{
	char synopsis[1024];
	/* TODO: We could use asprintf() if we know we're using GNU libc. */
	snprintf(synopsis, 1023, "usage: %s [option ...] [file ...]\n",
		 progname);
	if (0 == status) {
	if (0 == status) {
		fprintf(stdout, "%s: usage: cueprint [option...] [file...]\n", progname);
		printf("%s", synopsis);
		fputs("\
		printf("Report disc and track information from a CUE or TOC"
\n\
		       " file.\n"
OPTIONS\n\
		       "\n"
\n\
		       "Options:\n"
Template Expansion\n\
		       "-d TEMPLATE, --disc-template=TEMPLATE\tset disc"
Disc:\n\
		       " template\n"
%A - album arranger\n\
		       "-h, --help\t\t\t\tdisplay this message and exit\n"
%C - album composer\n\
		       "-i {cue|toc}, --input-format={cue|toc}\tset format of"
%G - album genre\n\
		       " input file(s)\n"
%M - album message\n\
		       "-n N, --track-number=N\t\t\treport information for"
%N - number of tracks\n\
		       " track N only\n"
%P - album performer\n\
		       "-t TEMPLATE, --track-template=TEMPLATE\tset track"
%S - album songwriter\n\
		       " template\n"
%T - album title\n\
		       "\n"
%U - album UPC/EAN\n\
		       "TEMPLATE is a printf(3)-style format string.\n"
Track:\n\
		       "\n"
%a - track arranger\n\
		       "Default disc template: %s\n"
%c - track composer\n\
		       "Default track template: %s\n"
%g - track genre\n\
		       "See the %s(1) manual page for more information.\n",
%i - track ISRC\n\
		       D_TEMPLATE, T_TEMPLATE, progname);
%m - track message\n\
%n - track number\n\
%p - track perfomer\n\
%t - track title\n\
%u - track ISRC (CD-TEXT)\n\
\n\
Any other %<character> is expanded to that character.  For example, to get a\n\
'%', use %%.\n\
\n\
", stdout);
		fprintf(stdout, "default disc template is:\n%s\n", D_TEMPLATE);
		fprintf(stdout, "default track template is:\n%s\n", T_TEMPLATE);
	} else {
	} else {
		fprintf(stderr, "run `%s --help' for usage\n", progname);
		fprintf(stderr, "%sRun \"%s --help\" for more information.\n",
			synopsis, progname);
	}
	}
	exit (status);
	exit(status);
}
}
/* TODO: Shouldn't we be using vprintf() to help us out with this stuff? */
void disc_field (char *conv, int length, Cd *cd, Value *value)
void disc_field (char *conv, int length, Cd *cd, Value *value)
{
{
	char *c;	/* pointer to conversion character */
	char *c;	/* pointer to conversion character */
 Lines 230-237    Link Here 
}
}
/* print a % conversion specification
/*
 * %[flag(s)][width][.precision]<conversion-char>
 * Print a conversion specification.
 * [flag(s)][width][.precision]<conversion-char>
 */
 */
void print_conv (char *start, int length, Cd *cd, int trackno)
void print_conv (char *start, int length, Cd *cd, int trackno)
{
{
 Lines 240-246    Link Here 
	char *c;	/* pointer to conversion-char */
	char *c;	/* pointer to conversion-char */
	/* TODO: use strndup? */
	/* TODO: use strndup? */
	conv = malloc ((unsigned) (length + 1));
	conv = malloc((unsigned) (length + 1));
	strncpy(conv, start, length);
	strncpy(conv, start, length);
	conv[length] = '\0';
	conv[length] = '\0';
 Lines 303-309    Link Here 
				conv_length++;
				conv_length++;
				c++;
				c++;
			}
			}
			
			/* precision */
			/* precision */
			/* '*' not recognized */
			/* '*' not recognized */
			if ('.' == *c) {
			if ('.' == *c) {
 Lines 329-335    Link Here 
	}
	}
}
}
int info (char *name, int format, int trackno, char *d_template, char *t_template)
int info (char *name, int format, int trackno, char *d_template,
	  char *t_template)
{
{
	Cd *cd = NULL;
	Cd *cd = NULL;
	int ntrack;
	int ntrack;
 Lines 359-366    Link Here 
	return 0;
	return 0;
}
}
/* translate escape sequences in a string
/*
 * string is overwritten and terminated
 * Translate escape sequences in a string.
 * The string is overwritten and terminated.
 * TODO: this does not handle octal and hexidecimal escapes
 * TODO: this does not handle octal and hexidecimal escapes
 *       except for \0
 *       except for \0
 */
 */
 Lines 420-430    Link Here 
int main (int argc, char **argv)
int main (int argc, char **argv)
{
{
	int format = UNKNOWN;
	int format = UNKNOWN;
	int trackno = -1;		/* track number (-1 = unspecified, 0 = disc info) */
	int trackno = -1;		/* track number (-1 = unspecified,
							  0 = disc info) */
	char *d_template = NULL;	/* disc template */
	char *d_template = NULL;	/* disc template */
	char *t_template = NULL;	/* track template */
	char *t_template = NULL;	/* track template */
	int ret = 0;			/* return value of info() */
	/* getopt_long() variables */
	/* getopt_long() variables */
	char c;
	int c;
	extern char *optarg;
	extern char *optarg;
	extern int optind;
	extern int optind;
 Lines 437-458    Link Here 
		{NULL, 0, NULL, 0}
		{NULL, 0, NULL, 0}
	};
	};
	progname = *argv;
	progname = argv[0];
	while (-1 != (c = getopt_long(argc, argv, "hi:n:d:t:", longopts, NULL))) {
	while (-1 != (c = getopt_long(argc, argv, "hi:n:d:t:", longopts, NULL)))
	{
		switch (c) {
		switch (c) {
		case 'h':
		case 'h':
			usage(0);
			usage(0);
			break;
			break;
		case 'i':
		case 'i':
			if (0 == strcmp("cue", optarg)) {
			if (0 == strcasecmp("cue", optarg)) {
				format = CUE;
				format = CUE;
			} else if (0 == strcmp("toc", optarg)) {
			} else if (0 == strcasecmp("toc", optarg)) {
				format = TOC;
				format = TOC;
			} else {
			} else {
				fprintf(stderr, "%s: illegal format `%s'\n", progname, optarg);
				fprintf(stderr, "%s: error: unknown input file"
					" format \"%s\"\n", progname, optarg);
				usage(1);
				usage(1);
			}
			}
			break;
			break;
		case 'n':
		case 'n':
			trackno = atoi(optarg);
			trackno = atoi(optarg);
 Lines 468-474    Link Here 
		}
		}
	}
	}
	/* if no disc or track template is set, use the defaults for both */
	/* If no disc or track template is set, use the defaults for both. */
	/* TODO: alternative to strdup to get variable strings? */
	/* TODO: alternative to strdup to get variable strings? */
	if (NULL == d_template && NULL == t_template) {
	if (NULL == d_template && NULL == t_template) {
		d_template = strdup(D_TEMPLATE);
		d_template = strdup(D_TEMPLATE);
 Lines 481-496    Link Here 
			t_template = strdup("");
			t_template = strdup("");
	}
	}
	/* translate escape sequences */
	/* Translate escape sequences. */
	translate_escapes(d_template);
	translate_escapes(d_template);
	translate_escapes(t_template);
	translate_escapes(t_template);
	/* What we do depends on the number of operands. */
	if (optind == argc) {
	if (optind == argc) {
		info("-", format, trackno, d_template, t_template);
		/* No operands: report information about stdin. */
		ret = info("-", format, trackno, d_template, t_template);
	} else {
	} else {
		for (; optind < argc; optind++)
		/* Report information for each operand. */
			info(argv[optind], format, trackno, d_template, t_template);
		for (; optind < argc; optind++) {
			ret = info(argv[optind], format, trackno, d_template,
				   t_template);
			/* Bail out if info() returns nonzero. */
			if (!ret)
				break;
		}
	}
	}
	return 0;
	return ret;
}
}