|
Packit |
a38265 |
/*
|
|
Packit |
a38265 |
Copyright (C) 2008 Annodex Association
|
|
Packit |
a38265 |
|
|
Packit |
a38265 |
Redistribution and use in source and binary forms, with or without
|
|
Packit |
a38265 |
modification, are permitted provided that the following conditions
|
|
Packit |
a38265 |
are met:
|
|
Packit |
a38265 |
|
|
Packit |
a38265 |
- Redistributions of source code must retain the above copyright
|
|
Packit |
a38265 |
notice, this list of conditions and the following disclaimer.
|
|
Packit |
a38265 |
|
|
Packit |
a38265 |
- Redistributions in binary form must reproduce the above copyright
|
|
Packit |
a38265 |
notice, this list of conditions and the following disclaimer in the
|
|
Packit |
a38265 |
documentation and/or other materials provided with the distribution.
|
|
Packit |
a38265 |
|
|
Packit |
a38265 |
- Neither the name of the Annodex Association nor the names of its
|
|
Packit |
a38265 |
contributors may be used to endorse or promote products derived from
|
|
Packit |
a38265 |
this software without specific prior written permission.
|
|
Packit |
a38265 |
|
|
Packit |
a38265 |
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
Packit |
a38265 |
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
Packit |
a38265 |
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
|
Packit |
a38265 |
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ORGANISATION OR
|
|
Packit |
a38265 |
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
Packit |
a38265 |
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
Packit |
a38265 |
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
Packit |
a38265 |
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
Packit |
a38265 |
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
Packit |
a38265 |
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
Packit |
a38265 |
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
Packit |
a38265 |
*/
|
|
Packit |
a38265 |
|
|
Packit |
a38265 |
#include "config.h"
|
|
Packit |
a38265 |
|
|
Packit |
a38265 |
#include <stdio.h>
|
|
Packit |
a38265 |
#include <stdlib.h>
|
|
Packit |
a38265 |
#include <string.h>
|
|
Packit |
a38265 |
#include <unistd.h>
|
|
Packit |
a38265 |
|
|
Packit |
a38265 |
/* #define DEBUG */
|
|
Packit |
a38265 |
|
|
Packit |
a38265 |
#define TOOLNAME_LEN 32
|
|
Packit |
a38265 |
|
|
Packit |
a38265 |
int
|
|
Packit |
a38265 |
usage (char * progname)
|
|
Packit |
a38265 |
{
|
|
Packit |
a38265 |
printf ("Usage: oggz <subcommand> [options] filename ...\n\n");
|
|
Packit |
a38265 |
|
|
Packit |
a38265 |
printf ("oggz is a commandline tool for manipulating Ogg files. It supports\n"
|
|
Packit |
a38265 |
"multiplexed files conformant with RFC3533. Oggz can parse headers for\n"
|
|
Packit |
a38265 |
"CELT, CMML, FLAC, Kate, PCM, Speex, Theora and Vorbis, and can read and write\n"
|
|
Packit |
a38265 |
"Ogg Skeleton logical bitstreams.\n");
|
|
Packit |
a38265 |
|
|
Packit |
a38265 |
printf ("\nCommands:\n");
|
|
Packit |
a38265 |
printf (" help Display help for a specific subcommand (eg. \"oggz help chop\")\n");
|
|
Packit |
a38265 |
|
|
Packit |
a38265 |
printf ("\nReporting:\n");
|
|
Packit |
a38265 |
printf (" codecs Display the list of codecs found in one or more files and\n"
|
|
Packit |
a38265 |
" their bitstreams.\n");
|
|
Packit |
a38265 |
printf (" diff Hexdump the packets of two Ogg files and output differences.\n");
|
|
Packit |
a38265 |
printf (" dump Hexdump packets of an Ogg file, or revert an Ogg file from\n"
|
|
Packit |
a38265 |
" such a hexdump.\n");
|
|
Packit |
a38265 |
printf (" info Display information about one or more Ogg files and their\n"
|
|
Packit |
a38265 |
" bitstreams.\n");
|
|
Packit |
a38265 |
printf (" scan Scan an Ogg file and output characteristic landmarks.\n");
|
|
Packit |
a38265 |
printf (" validate Validate the Ogg framing of one or more files.\n");
|
|
Packit |
a38265 |
|
|
Packit |
a38265 |
|
|
Packit |
a38265 |
printf ("\nExtraction:\n");
|
|
Packit |
a38265 |
printf (" rip Extract one or more logical bitstreams from an Ogg file.\n");
|
|
Packit |
a38265 |
|
|
Packit |
a38265 |
printf ("\nEditing:\n");
|
|
Packit |
a38265 |
printf (" chop Extract the part of an Ogg file between given start and/or\n"
|
|
Packit |
a38265 |
" end times.\n");
|
|
Packit |
a38265 |
printf (" comment List or edit comments in an Ogg file.\n");
|
|
Packit |
a38265 |
printf (" merge Merge Ogg files together, interleaving pages in order of\n"
|
|
Packit |
a38265 |
" presentation time.\n");
|
|
Packit |
a38265 |
printf (" sort Sort the pages of an Ogg file in order of presentation time.\n");
|
|
Packit |
a38265 |
|
|
Packit |
a38265 |
printf ("\nMiscellaneous:\n");
|
|
Packit |
a38265 |
printf (" known-codecs List codecs known by this version of oggz\n");
|
|
Packit |
a38265 |
|
|
Packit |
a38265 |
printf ("\n");
|
|
Packit |
a38265 |
printf ("Please report bugs to <ogg-dev@xiph.org>\n");
|
|
Packit |
a38265 |
|
|
Packit |
a38265 |
return 0;
|
|
Packit |
a38265 |
}
|
|
Packit |
a38265 |
|
|
Packit |
a38265 |
int
|
|
Packit |
a38265 |
main (int argc, char ** argv)
|
|
Packit |
a38265 |
{
|
|
Packit |
a38265 |
char * progname = argv[0];
|
|
Packit |
a38265 |
char toolname[TOOLNAME_LEN];
|
|
Packit |
a38265 |
int ret;
|
|
Packit |
a38265 |
|
|
Packit |
a38265 |
if (argc < 2) {
|
|
Packit |
a38265 |
usage (progname);
|
|
Packit |
a38265 |
} else {
|
|
Packit |
a38265 |
if (!strncmp (argv[1], "-v", 2) || !strncmp(argv[1], "version", 7) || !strncmp(argv[1], "--version", 9)) {
|
|
Packit |
a38265 |
printf ("oggz version " VERSION "\n");
|
|
Packit |
a38265 |
} else if (!strncmp(argv[1], "-h", 2) || !strncmp (argv[1], "help", 4) || !strncmp(argv[1], "--help", 6)) {
|
|
Packit |
a38265 |
if (argc == 2) {
|
|
Packit |
a38265 |
usage (progname);
|
|
Packit |
a38265 |
} else {
|
|
Packit |
a38265 |
sprintf (toolname, "oggz-%s", argv[2]);
|
|
Packit |
a38265 |
|
|
Packit |
a38265 |
/* Try running "man toolname" */
|
|
Packit |
a38265 |
argv[1] = "man";
|
|
Packit |
a38265 |
argv[2] = toolname;
|
|
Packit |
a38265 |
ret = execvp ("man", &argv[1]);
|
|
Packit |
a38265 |
|
|
Packit |
a38265 |
/* If that fails (ie. "man" is not installed), try running "toolname --help" */
|
|
Packit |
a38265 |
argv[1] = toolname;
|
|
Packit |
a38265 |
argv[2] = "--help";
|
|
Packit |
a38265 |
ret = execvp (toolname, &argv[1]);
|
|
Packit |
a38265 |
|
|
Packit |
a38265 |
if (ret == -1) {
|
|
Packit |
a38265 |
perror (toolname);
|
|
Packit |
a38265 |
}
|
|
Packit |
a38265 |
}
|
|
Packit |
a38265 |
} else {
|
|
Packit |
a38265 |
sprintf (toolname, "oggz-%s", argv[1]);
|
|
Packit |
a38265 |
argv[1] = toolname;
|
|
Packit |
a38265 |
ret = execvp (toolname, &argv[1]);
|
|
Packit |
a38265 |
|
|
Packit |
a38265 |
if (ret == -1) {
|
|
Packit |
a38265 |
perror (toolname);
|
|
Packit |
a38265 |
}
|
|
Packit |
a38265 |
}
|
|
Packit |
a38265 |
}
|
|
Packit |
a38265 |
|
|
Packit |
a38265 |
exit (0);
|
|
Packit |
a38265 |
}
|