Pārlūkot izejas kodu

Added long options to all tools.

Tools exit if format is not "cue" or "toc".
master
Svend Sorensen pirms 19 gadiem
vecāks
revīzija
4aa5950850
6 mainītis faili ar 73 papildinājumiem un 42 dzēšanām
  1. +3
    -3
      man/cuebreakpoints.man
  2. +4
    -4
      man/cueconvert.man
  3. +7
    -7
      man/cueprint.man
  4. +16
    -8
      tools/cuebreakpoints.c
  5. +21
    -9
      tools/cueconvert.c
  6. +22
    -11
      tools/cueprint.c

+ 3
- 3
man/cuebreakpoints.man Parādīt failu

@@ -8,15 +8,15 @@ cuebreakpoints \- print the breakpoints from a cue or toc file
.
.SH SYNOPSIS
.B cuebreakpoints
[\-h] [\-i cue|toc] [file...]
[option...] [file...]
.
.SH OPTIONS
.TP
.B \-h
.B \-h, \--help
print usage information
.
.TP
.B \-i cue|toc
.B \-i, \--input-format cue|toc
set format of file(s)
.
.SH NOTES


+ 4
- 4
man/cueconvert.man Parādīt failu

@@ -8,19 +8,19 @@ cueconvert \- convert between the cue and toc formats
.
.SH SYNOPSIS
.B cueconvert
[\-h] [\-i cue|toc] [\-o cue|toc] [infile [outfile]]
[option...] [infile [outfile]]
.
.SH OPTIONS
.TP
.B \-h
.B \-h, \--help
print usage information
.
.TP
.B \-i cue|toc
.B \-i, \--input-format cue|toc
set format of input file
.
.TP
.B \-o cue|toc
.B \-o, \--output-format cue|toc
set format of output file
.
.SH NOTES


+ 7
- 7
man/cueprint.man Parādīt failu

@@ -8,27 +8,27 @@ cueprint \- print disc and track infomation for a cue or toc file
.
.SH SYNOPSIS
.B cueprint
[\-h] [\-i cue|toc] [-n <tracknumber>] [\-d <template>] [\-t <template>] [file...]
[option...] [file...]
.
.SH OPTIONS
.TP
.B \-h
.B \-h, \--help
print usage information
.
.TP
.B \-i cue|toc
.B \-i, \--input-format cue|toc
set format of file(s)
.
.TP
.B \-n <tracknumber>
only print track information for track tracknumber. The default is to print information for all tracks.
.B \-n, \--track-number <number>
only print track information for single track. The default is to print information for all tracks.
.
.TP
.B \-d <template>
.B \-d, \--disc-template <template>
set disc template (see TEMPLATE EXPANSION)
.
.TP
.B \-t <template>
.B \-t, \--track-template <template>
set track template (see TEMPLATE EXPANSION)
.
.SH TEMPLATE EXPANSION


+ 16
- 8
tools/cuebreakpoints.c Parādīt failu

@@ -8,7 +8,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <getopt.h>
#include "cuefile.h"
#include "time.h"

@@ -17,16 +17,15 @@ char *progname;
void usage (int status)
{
if (0 == status) {
fprintf(stdout, "%s: usage: cuebreakpoints [-h] [-i cue|toc] [file...]\n", progname);
fprintf(stdout, "%s: usage: cuebreakpoints [option...] [file...]\n", progname);
fputs("\
\n\
OPTIONS\n\
-h print usage\n\
-i cue|toc set format of file(s)\n\
-h, --help print usage\n\
-i, --input-format cue|toc set format of file(s)\n\
", stdout);
} else {
fprintf(stderr, "%s: syntax error\n", progname);
fprintf(stderr, "run `%s -h' for usage\n", progname);
fprintf(stderr, "run `%s --help' for usage\n", progname);
}

exit (status);
@@ -75,13 +74,19 @@ int main (int argc, char **argv)

/* option variables */
char c;
/* getopt() variables */
/* getopt_long() variables */
extern char *optarg;
extern int optind;

static struct option longopts[] = {
{"help", no_argument, NULL, 'h'},
{"input-format", required_argument, NULL, 'i'},
{NULL, 0, NULL, 0}
};

progname = *argv;

while (-1 != (c = getopt(argc, argv, "hi:"))) {
while (-1 != (c = getopt_long(argc, argv, "hi:", longopts, NULL))) {
switch (c) {
case 'h':
usage(0);
@@ -91,6 +96,9 @@ int main (int argc, char **argv)
format = CUE;
else if (0 == strcmp("toc", optarg))
format = TOC;
else
fprintf(stderr, "%s: illegal format `%s'\n", progname, optarg);
usage(1);
break;
default:
usage(1);


+ 21
- 9
tools/cueconvert.c Parādīt failu

@@ -8,7 +8,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <getopt.h>
#include "cuefile.h"

char *progname;
@@ -16,17 +16,16 @@ char *progname;
void usage (int status)
{
if (0 == status) {
fprintf(stdout, "%s: usage: cueconvert [-h] [-i cue|toc] [-o cue|toc] [infile [outfile]]\n", progname);
fprintf(stdout, "%s: usage: cueconvert [option...] [infile [outfile]]\n", progname);
fputs("\
\n\
OPTIONS\n\
-h print usage\n\
-i cue|toc set format of input file\n\
-o cue|toc set format of output file\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\
", stdout);
} else {
fprintf(stderr, "%s: syntax error\n", progname);
fprintf(stderr, "run `%s -h' for usage\n", progname);
fprintf(stderr, "run `%s --help' for usage\n", progname);
}

exit (status);
@@ -65,13 +64,20 @@ int main (int argc, char **argv)
int oformat = UNKNOWN;
/* option variables */
char c;
/* getopt() variables */
/* 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'},
{NULL, 0, NULL, 0}
};

progname = *argv;

while (-1 != (c = getopt(argc, argv, "hi:o:"))) {
while (-1 != (c = getopt_long(argc, argv, "hi:o:", longopts, NULL))) {
switch (c) {
case 'h':
usage(0);
@@ -81,12 +87,18 @@ int main (int argc, char **argv)
iformat = CUE;
else if (0 == strcmp("toc", optarg))
iformat = TOC;
else
fprintf(stderr, "%s: illegal 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: illegal format `%s'\n", progname, optarg);
usage(1);
break;
default:
usage(1);


+ 22
- 11
tools/cueprint.c Parādīt failu

@@ -8,7 +8,7 @@
#include <stdio.h>
#include <stdlib.h> /* exit() */
#include <string.h> /* strcmp() */
#include <unistd.h> /* getopt() */
#include <getopt.h>
#include <ctype.h> /* isdigit() */
#include "cuefile.h"

@@ -58,15 +58,15 @@ char *progname;
void usage (int status)
{
if (0 == status) {
fprintf(stdout, "%s: usage: cueprint [-h] [-i cue|toc] [-n <tracknumer>] [-d <template>] [-t <template>] [file...]\n", progname);
fprintf(stdout, "%s: usage: cueprint [option...] [file...]\n", progname);
fputs("\
\n\
OPTIONS\n\
-h print usage\n\
-i cue|toc set format of file(s)\n\
-n <tracknumber> only print track information for track tracknumer\n\
-d <template> set disc template (see TEMPLATE EXPANSION)\n\
-t <template> set track template (see TEMPLATE EXPANSION)\n\
-h, --help print usage\n\
-i, --input-format cue|toc set format of file(s)\n\
-n, --track-number <number> only print track information for single track\n\
-d, --disc-template <template> set disc template (see TEMPLATE EXPANSION)\n\
-t, --track-template <template> set track template (see TEMPLATE EXPANSION)\n\
\n\
Template Expansion\n\
Disc:\n\
@@ -97,8 +97,7 @@ Any other %<character> is expanded to that character. For example, to get a\n\
fprintf(stdout, "default disc template is:\n%s\n", D_TEMPLATE);
fprintf(stdout, "default track template is:\n%s\n", T_TEMPLATE);
} else {
fprintf(stderr, "%s: syntax error\n", progname);
fprintf(stderr, "run `%s -h' for usage\n", progname);
fprintf(stderr, "run `%s --help' for usage\n", progname);
}

exit (status);
@@ -424,14 +423,23 @@ int main (int argc, char **argv)
int trackno = -1; /* track number (-1 = unspecified, 0 = disc info) */
char *d_template = NULL; /* disc template */
char *t_template = NULL; /* track template */
/* getopt () variables */
/* getopt_long() variables */
char c;
extern char *optarg;
extern int optind;

static struct option longopts[] = {
{"help", no_argument, NULL, 'h'},
{"input-format", required_argument, NULL, 'i'},
{"track-number", required_argument, NULL, 'n'},
{"disc-template", required_argument, NULL, 'd'},
{"track-template", required_argument, NULL, 't'},
{NULL, 0, NULL, 0}
};

progname = *argv;

while (-1 != (c = getopt(argc, argv, "hi:n:d:t:"))) {
while (-1 != (c = getopt_long(argc, argv, "hi:n:d:t:", longopts, NULL))) {
switch (c) {
case 'h':
usage(0);
@@ -441,6 +449,9 @@ int main (int argc, char **argv)
format = CUE;
else if (0 == strcmp("toc", optarg))
format = TOC;
else
fprintf(stderr, "%s: illegal format `%s'\n", progname, optarg);
usage(1);
break;
case 'n':
trackno = atoi(optarg);


Notiek ielāde…
Atcelt
Saglabāt