Commit 816a940a authored by colinw's avatar colinw

Fixed some problems whereby the tools were crashing if no filename was passed

in on the command line



git-svn-id: http://svn.annodex.net/liboggz/trunk@451 8158c8cd-e7e1-0310-9fa4-c5954c97daef
parent db5c02b0
......@@ -77,7 +77,7 @@ dump_char_line (unsigned char * buf, long n)
int i;
fprintf (outfile, " ");
for (i = 0; i < n; i++) {
if (isgraph(buf[i])) fprintf (outfile, "%c", buf[i]);
else if (isspace(buf[i])) fprintf (outfile, " ");
......@@ -259,7 +259,7 @@ revert_file (char * infilename)
if (current_serialno != -1) {
int ret;
#ifdef DEBUG
#ifdef DEBUG
printf ("feeding packet (%010ld) %ld bytes\n",
current_serialno, op.bytes);
#endif
......@@ -271,7 +271,7 @@ revert_file (char * infilename)
fwrite (buf, 1, 1024, outfile);
}
}
/* Start new packet */
bos = 0; eos = 0;
if (sscanf (&line[line_offset], " *** %[b]%[o]%[s]%n", &c, &c, &c,
......@@ -327,7 +327,7 @@ revert_file (char * infilename)
op.packet = packet;
}
}
packet[op.bytes-1] = (unsigned char) val;
line_offset += consumed;
......@@ -355,7 +355,8 @@ main (int argc, char ** argv)
progname = argv[0];
if (argc < 2) {
printf ("usage: %s filename\n", progname);
usage (progname);
return (1);
}
table = oggz_table_new();
......@@ -387,14 +388,14 @@ main (int argc, char ** argv)
if (i == ':') {
usage (progname);
oggz_table_delete(table);
exit (1);
return (1);
}
switch (i) {
case 'h': /* help */
usage (progname);
oggz_table_delete(table);
exit (0);
return (0);
break;
case 'b': /* binary */
dump_bits = 1;
......@@ -433,7 +434,7 @@ main (int argc, char ** argv)
if (optind >= argc) {
usage (progname);
oggz_table_delete(table);
exit (1);
return (1);
}
infilename = argv[optind++];
......@@ -446,7 +447,7 @@ main (int argc, char ** argv)
fprintf (stderr, "%s: unable to open output file %s\n",
progname, outfilename);
oggz_table_delete(table);
exit (1);
return (1);
}
}
......@@ -454,7 +455,7 @@ main (int argc, char ** argv)
if (dump_bits) {
fprintf (stderr, "%s: Revert of binary dump not supported\n", progname);
oggz_table_delete(table);
exit (1);
return (1);
}
revert_file (infilename);
......@@ -476,7 +477,7 @@ main (int argc, char ** argv)
progname, infilename, strerror (errno));
}
oggz_table_delete(table);
exit (1);
return (1);
}
if (dump_all_serialnos) {
......@@ -490,9 +491,10 @@ main (int argc, char ** argv)
}
while ((n = oggz_read (oggz, 1024)) > 0);
oggz_close (oggz);
}
oggz_table_delete(table);
exit (0);
return (0);
}
......@@ -159,12 +159,12 @@ read_packet (OGGZ * oggz, ogg_packet * op, long serialno, void * user_data)
vorbis_info_init (&vi);
vorbis_comment_init (&vc);
if ((ret = vorbis_synthesis_headerin (&vi, &vc, op)) == 0) {
if (vi.rate != 0) {
printf ("Got vorbis info: version %d\tchannels %d\trate %ld\n",
vi.version, vi.channels, vi.rate);
init_stream (serialno, vi.rate, 1, 0);
}
}
......@@ -172,14 +172,14 @@ read_packet (OGGZ * oggz, ogg_packet * op, long serialno, void * user_data)
} else if (!strncmp ((char *)&op->packet[0], "Speex ", 8)) {
#ifdef HAVE_SPEEX
SpeexHeader * header;
header = speex_packet_to_header ((char *)op->packet, op->bytes);
if (header) {
init_stream (serialno, header->rate, 1, 0);
printf ("Got speex samplerate %d\n", header->rate);
free (header);
}
#endif
......@@ -215,7 +215,8 @@ main (int argc, char ** argv)
long n;
if (argc < 2) {
printf ("usage: %s filename\n", argv[0]);
printf ("Usage: %s filename\n", argv[0]);
return (1);
}
granule_rate = 1000000;
......@@ -227,7 +228,7 @@ main (int argc, char ** argv)
if ((oggz = oggz_open ((char *)argv[1], OGGZ_READ)) == NULL) {
printf ("unable to open file %s\n", argv[1]);
exit (1);
return (1);
}
oggz_set_metric (oggz, -1, gp_metric, NULL);
......@@ -245,5 +246,5 @@ main (int argc, char ** argv)
oggz_close (oggz);
exit (0);
return (0);
}
......@@ -73,13 +73,13 @@ main (int argc, char ** argv)
long n;
if (argc < 2) {
printf ("usage: %s filename\n", argv[0]);
printf ("Usage: %s filename\n", argv[0]);
return (1);
}
if ((oggz = oggz_open ((char *)argv[1], OGGZ_READ)) == NULL) {
printf ("unable to open file %s\n", argv[1]);
exit (1);
return (1);
}
oggz_set_read_callback (oggz, -1, read_packet, NULL);
......@@ -87,5 +87,5 @@ main (int argc, char ** argv)
oggz_close (oggz);
exit (0);
return (0);
}
......@@ -117,7 +117,7 @@ omdata_delete (OMData * omdata)
}
oggz_table_delete (omdata->inputs);
free (omdata);
free (omdata);
}
static int
......@@ -140,7 +140,7 @@ omdata_add_input (OMData * omdata, FILE * infile)
ominput_delete (input);
return -1;
}
return 0;
}
......@@ -213,6 +213,12 @@ main (int argc, char * argv[])
int i;
progname = argv[0];
if (argc < 2) {
usage (progname);
return (1);
}
omdata = omdata_new();
while (1) {
......@@ -233,14 +239,14 @@ main (int argc, char * argv[])
if (i == ':') {
usage (progname);
omdata_delete (omdata);
exit (1);
return (1);
}
switch (i) {
case 'h': /* help */
usage (progname);
omdata_delete (omdata);
exit (0);
return (0);
break;
case 'o': /* output */
outfilename = optarg;
......@@ -254,7 +260,7 @@ main (int argc, char * argv[])
if (optind >= argc) {
usage (progname);
omdata_delete (omdata);
exit (1);
return (1);
}
while (optind < argc) {
......@@ -276,7 +282,7 @@ main (int argc, char * argv[])
fprintf (stderr, "%s: unable to open output file %s\n",
progname, outfilename);
omdata_delete (omdata);
exit (1);
return (1);
}
}
......@@ -284,5 +290,5 @@ main (int argc, char * argv[])
omdata_delete (omdata);
exit (0);
return (0);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment