|
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 |
|
|
Packit |
a38265 |
#include "oggz/oggz.h"
|
|
Packit |
a38265 |
|
|
Packit |
a38265 |
/* #define DEBUG */
|
|
Packit |
a38265 |
|
|
Packit |
a38265 |
typedef int (*qsort_func) (const void * p1, const void * p2);
|
|
Packit |
a38265 |
|
|
Packit |
a38265 |
int
|
|
Packit |
a38265 |
usage (char * progname)
|
|
Packit |
a38265 |
{
|
|
Packit |
a38265 |
printf ("Usage: oggz-known-codecs [options]\n\n");
|
|
Packit |
a38265 |
|
|
Packit |
a38265 |
printf ("List codecs known by this version of oggz\n");
|
|
Packit |
a38265 |
|
|
Packit |
a38265 |
printf ("\nMiscellaneous options\n");
|
|
Packit |
a38265 |
printf (" -h, --help Display this help and exit\n");
|
|
Packit |
a38265 |
printf (" -v, --version Output version information and exit\n");
|
|
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 |
static int
|
|
Packit |
a38265 |
cmpstringp (char * const * p1, char * const * p2)
|
|
Packit |
a38265 |
{
|
|
Packit |
a38265 |
/* The actual arguments to this function are "pointers to
|
|
Packit |
a38265 |
pointers to char", but strcmp(3) arguments are "pointers
|
|
Packit |
a38265 |
to char", hence the function cast plus dereference */
|
|
Packit |
a38265 |
|
|
Packit |
a38265 |
if (!(*p1)) return -1;
|
|
Packit |
a38265 |
if (!(*p2)) return 1;
|
|
Packit |
a38265 |
|
|
Packit |
a38265 |
return strcmp (*p1, *p2);
|
|
Packit |
a38265 |
}
|
|
Packit |
a38265 |
|
|
Packit |
a38265 |
int
|
|
Packit |
a38265 |
main (int argc, char ** argv)
|
|
Packit |
a38265 |
{
|
|
Packit |
a38265 |
OggzStreamContent content;
|
|
Packit |
a38265 |
const char * content_types[OGGZ_CONTENT_UNKNOWN];
|
|
Packit |
a38265 |
|
|
Packit |
a38265 |
char * progname = argv[0];
|
|
Packit |
a38265 |
|
|
Packit |
a38265 |
if (argc == 2) {
|
|
Packit |
a38265 |
if (!strncmp (argv[1], "-?", 2)) {
|
|
Packit |
a38265 |
printf ("-v --version -h --help\n");
|
|
Packit |
a38265 |
exit (0);
|
|
Packit |
a38265 |
} else if (!strncmp (argv[1], "-v", 2) || !strncmp (argv[1], "--version", 9)) {
|
|
Packit |
a38265 |
printf ("%s version " VERSION "\n", progname);
|
|
Packit |
a38265 |
exit (0);
|
|
Packit |
a38265 |
} else if (!strncmp (argv[1], "-h", 2) || !strncmp (argv[1], "--help", 6)) {
|
|
Packit |
a38265 |
usage (progname);
|
|
Packit |
a38265 |
exit (0);
|
|
Packit |
a38265 |
} else {
|
|
Packit |
a38265 |
usage (progname);
|
|
Packit |
a38265 |
exit (1);
|
|
Packit |
a38265 |
}
|
|
Packit |
a38265 |
} else if (argc > 2) {
|
|
Packit |
a38265 |
usage (progname);
|
|
Packit |
a38265 |
exit (1);
|
|
Packit |
a38265 |
}
|
|
Packit |
a38265 |
|
|
Packit |
a38265 |
/* Collect the content type names, filtering out deprecated and
|
|
Packit |
a38265 |
duplicates ones */
|
|
Packit |
a38265 |
for (content = 0; content < OGGZ_CONTENT_UNKNOWN; content++) {
|
|
Packit |
a38265 |
switch (content) {
|
|
Packit |
a38265 |
case OGGZ_CONTENT_FLAC0:
|
|
Packit |
a38265 |
case OGGZ_CONTENT_ANXDATA:
|
|
Packit |
a38265 |
content_types[content] = NULL;
|
|
Packit |
a38265 |
break;
|
|
Packit |
a38265 |
default:
|
|
Packit |
a38265 |
content_types[content] = oggz_content_type (content);
|
|
Packit |
a38265 |
break;
|
|
Packit |
a38265 |
}
|
|
Packit |
a38265 |
}
|
|
Packit |
a38265 |
|
|
Packit |
a38265 |
/* Sort them */
|
|
Packit |
a38265 |
qsort (content_types, OGGZ_CONTENT_UNKNOWN, sizeof (char *),
|
|
Packit |
a38265 |
(qsort_func) cmpstringp);
|
|
Packit |
a38265 |
|
|
Packit |
a38265 |
/* Print them */
|
|
Packit |
a38265 |
for (content = 0; content < OGGZ_CONTENT_UNKNOWN; content++) {
|
|
Packit |
a38265 |
if (content_types[content])
|
|
Packit |
a38265 |
puts (content_types[content]);
|
|
Packit |
a38265 |
}
|
|
Packit |
a38265 |
|
|
Packit |
a38265 |
exit (0);
|
|
Packit |
a38265 |
}
|