[xiph-commits] r3674 - in liboggz/trunk/src/tools: . oggz-chop
conrad at svn.annodex.net
conrad at svn.annodex.net
Sat Aug 2 20:10:25 PDT 2008
Author: conrad
Date: 2008-08-02 20:10:24 -0700 (Sat, 02 Aug 2008)
New Revision: 3674
Modified:
liboggz/trunk/src/tools/oggz-basetime.c
liboggz/trunk/src/tools/oggz-chop/cmd.c
liboggz/trunk/src/tools/oggz-comment.c
liboggz/trunk/src/tools/oggz-diff.in
liboggz/trunk/src/tools/oggz-dump.c
liboggz/trunk/src/tools/oggz-info.c
liboggz/trunk/src/tools/oggz-known-codecs.c
liboggz/trunk/src/tools/oggz-merge.c
liboggz/trunk/src/tools/oggz-rip.c
liboggz/trunk/src/tools/oggz-scan.c
liboggz/trunk/src/tools/oggz-sort.c
liboggz/trunk/src/tools/oggz-validate.c
liboggz/trunk/src/tools/oggz_tools.c
liboggz/trunk/src/tools/oggz_tools.h
Log:
add -? option to all tools, which simply prints out all possible
options, and nothing else (for shell completion).
Modified: liboggz/trunk/src/tools/oggz-basetime.c
===================================================================
--- liboggz/trunk/src/tools/oggz-basetime.c 2008-08-01 09:47:05 UTC (rev 3673)
+++ liboggz/trunk/src/tools/oggz-basetime.c 2008-08-03 03:10:24 UTC (rev 3674)
@@ -251,6 +251,11 @@
return (1);
}
+ if (!strncmp (argv[1], "-?", 2)) {
+ printf ("-h --help\n");
+ exit (0);
+ }
+
if (!strcmp (argv[1], "-h") || !strcmp (argv[1], "--help")) {
usage (progname);
return (0);
Modified: liboggz/trunk/src/tools/oggz-chop/cmd.c
===================================================================
--- liboggz/trunk/src/tools/oggz-chop/cmd.c 2008-08-01 09:47:05 UTC (rev 3673)
+++ liboggz/trunk/src/tools/oggz-chop/cmd.c 2008-08-03 03:10:24 UTC (rev 3674)
@@ -38,6 +38,20 @@
int show_help = 0;
int i;
+ char * optstring = "s:e:o:khv";
+
+#ifdef HAVE_GETOPT_LONG
+ static struct option long_options[] = {
+ {"start", required_argument, 0, 's'},
+ {"end", required_argument, 0, 'e'},
+ {"output", required_argument, 0, 'o'},
+ {"no-skeleton", no_argument, 0, 'k'},
+ {"help", no_argument, 0, 'h'},
+ {"version", no_argument, 0, 'v'},
+ {0,0,0,0}
+ };
+#endif
+
progname = argv[0];
if (argc < 2) {
@@ -45,24 +59,21 @@
return (1);
}
+ if (!strncmp (argv[1], "-?", 2)) {
+#ifdef HAVE_GETOPT_LONG
+ ot_print_options (long_options, optstring);
+#else
+ ot_print_short_options (optstring);
+#endif
+ exit (0);
+ }
+
memset (state, 0, sizeof(*state));
state->end = -1.0;
state->do_skeleton = 1;
while (1) {
- char * optstring = "s:e:o:khv";
-
#ifdef HAVE_GETOPT_LONG
- static struct option long_options[] = {
- {"start", required_argument, 0, 's'},
- {"end", required_argument, 0, 'e'},
- {"output", required_argument, 0, 'o'},
- {"no-skeleton", no_argument, 0, 'k'},
- {"help", no_argument, 0, 'h'},
- {"version", no_argument, 0, 'v'},
- {0,0,0,0}
- };
-
i = getopt_long(argc, argv, optstring, long_options, NULL);
#else
i = getopt (argc, argv, optstring);
Modified: liboggz/trunk/src/tools/oggz-comment.c
===================================================================
--- liboggz/trunk/src/tools/oggz-comment.c 2008-08-01 09:47:05 UTC (rev 3673)
+++ liboggz/trunk/src/tools/oggz-comment.c 2008-08-03 03:10:24 UTC (rev 3674)
@@ -386,10 +386,35 @@
long n;
int i = 1;
+ char * optstring = "lo:dac:s:hv";
+
+#ifdef HAVE_GETOPT_LONG
+ static struct option long_options[] = {
+ {"list", no_argument, 0, 'l'},
+ {"output", required_argument, 0, 'o'},
+ {"delete", no_argument, 0, 'd'},
+ {"all", no_argument, 0, 'a'},
+ {"content-type", required_argument, 0, 'c'},
+ {"serialno", required_argument, 0, 's'},
+ {"help", no_argument, 0, 'h'},
+ {"version", no_argument, 0, 'v'},
+ {0,0,0,0}
+ };
+#endif
+
ot_init ();
progname = argv[0];
+ if (argc == 2 && !strncmp (argv[1], "-?", 2)) {
+#ifdef HAVE_GETOPT_LONG
+ ot_print_options (long_options, optstring);
+#else
+ ot_print_short_options (optstring);
+#endif
+ exit (0);
+ }
+
if (argc < 3) {
usage (progname);
return (1);
@@ -398,21 +423,7 @@
ocdata = ocdata_new ();
while (1) {
- char * optstring = "lo:dac:s:hv";
-
#ifdef HAVE_GETOPT_LONG
- static struct option long_options[] = {
- {"list", no_argument, 0, 'l'},
- {"output", required_argument, 0, 'o'},
- {"delete", no_argument, 0, 'd'},
- {"all", no_argument, 0, 'a'},
- {"content-type", required_argument, 0, 'c'},
- {"serialno", required_argument, 0, 's'},
- {"help", no_argument, 0, 'h'},
- {"version", no_argument, 0, 'v'},
- {0,0,0,0}
- };
-
i = getopt_long(argc, argv, optstring, long_options, NULL);
#else
i = getopt (argc, argv, optstring);
Modified: liboggz/trunk/src/tools/oggz-diff.in
===================================================================
--- liboggz/trunk/src/tools/oggz-diff.in 2008-08-01 09:47:05 UTC (rev 3673)
+++ liboggz/trunk/src/tools/oggz-diff.in 2008-08-03 03:10:24 UTC (rev 3674)
@@ -59,13 +59,26 @@
GETOPTEST=`getopt --version`
case $GETOPTEST in
getopt*) # GNU getopt
- TEMP=`getopt -l verbose -l version -l brief -l context:: -l unified:: -l ed -l normal -l rcs -l side-by-side -l paginate -l binary -l hexadecimal -l serialno: -l content-type: -l hide-offset -l hide-serialno -l hide-granulepos -l hide-packetno -l help -- +qC:uU:eylbxs:c:OSGPhv "$@"`
+ GETOPTARGS="-l verbose -l version -l brief -l context:: -l unified:: -l ed -l normal -l rcs -l side-by-side -l paginate -l binary -l hexadecimal -l serialno: -l content-type: -l hide-offset -l hide-serialno -l hide-granulepos -l hide-packetno -l help -- +qC:uU:eylbxs:c:OSGPhv"
+ QARGS="--verbose --version --brief --context --unified --ed --normal --rcs --side-by-side --paginate --binary --hexadecimal --serialno --content-type --hide-offset --hide-serialno --hide-granulepos --hide-packetno --help -q -C -u -U -e -y -l -b -x -s -c -O -S -G -P -h -v"
;;
*) # POSIX getopt ?
- TEMP=`getopt qC:uU:eylbxs:c:OSGPhv "$@"`
+ GETOPTARGS="qC:uU:eylbxs:c:OSGPhv"
+ QARGS="-q -C -u -U -e -y -l -b -x -s -c -O -S -G -P -h -v"
;;
esac
+# First check for -? option
+if test "X$1" = "X-?"; then
+ echo $QARGS
+ exit 0
+fi
+
+echo $GETOPTARGS
+
+TEMP=`getopt $GETOPTARGS "$@"`
+echo $TEMP
+
if test "$?" != "0"; then
usage
fi
Modified: liboggz/trunk/src/tools/oggz-dump.c
===================================================================
--- liboggz/trunk/src/tools/oggz-dump.c 2008-08-01 09:47:05 UTC (rev 3673)
+++ liboggz/trunk/src/tools/oggz-dump.c 2008-08-03 03:10:24 UTC (rev 3674)
@@ -505,6 +505,27 @@
int filter_serialnos = 0;
int filter_content_types = 0;
+ char * optstring = "hvbxnro:s:c:OSGP";
+
+#ifdef HAVE_GETOPT_LONG
+ static struct option long_options[] = {
+ {"help", no_argument, 0, 'h'},
+ {"version", no_argument, 0, 'v'},
+ {"binary", no_argument, 0, 'b'},
+ {"hexadecimal", no_argument, 0, 'x'},
+ {"new", no_argument, 0, 'n'},
+ {"revert", no_argument, 0, 'r'},
+ {"output", required_argument, 0, 'o'},
+ {"serialno", required_argument, 0, 's'},
+ {"content-type", required_argument, 0, 'c'},
+ {"hide-offset", no_argument, 0, 'O'},
+ {"hide-serialno", no_argument, 0, 'S'},
+ {"hide-granulepos", no_argument, 0, 'G'},
+ {"hide-packetno", no_argument, 0, 'P'},
+ {0,0,0,0}
+ };
+#endif
+
ot_init ();
progname = argv[0];
@@ -514,31 +535,21 @@
return (1);
}
+ if (!strncmp (argv[1], "-?", 2)) {
+#ifdef HAVE_GETOPT_LONG
+ ot_print_options (long_options, optstring);
+#else
+ ot_print_short_options (optstring);
+#endif
+ exit (0);
+ }
+
oddata = oddata_new ();
oddata->read_packet = read_packet;
while (1) {
- char * optstring = "hvbxnro:s:c:OSGP";
-
#ifdef HAVE_GETOPT_LONG
- static struct option long_options[] = {
- {"help", no_argument, 0, 'h'},
- {"version", no_argument, 0, 'v'},
- {"binary", no_argument, 0, 'b'},
- {"hexadecimal", no_argument, 0, 'x'},
- {"new", no_argument, 0, 'n'},
- {"revert", no_argument, 0, 'r'},
- {"output", required_argument, 0, 'o'},
- {"serialno", required_argument, 0, 's'},
- {"content-type", required_argument, 0, 'c'},
- {"hide-offset", no_argument, 0, 'O'},
- {"hide-serialno", no_argument, 0, 'S'},
- {"hide-granulepos", no_argument, 0, 'G'},
- {"hide-packetno", no_argument, 0, 'P'},
- {0,0,0,0}
- };
-
i = getopt_long(argc, argv, optstring, long_options, NULL);
#else
i = getopt (argc, argv, optstring);
Modified: liboggz/trunk/src/tools/oggz-info.c
===================================================================
--- liboggz/trunk/src/tools/oggz-info.c 2008-08-01 09:47:05 UTC (rev 3673)
+++ liboggz/trunk/src/tools/oggz-info.c 2008-08-03 03:10:24 UTC (rev 3674)
@@ -516,6 +516,22 @@
OGGZ * oggz;
OI_Info info;
+ char * optstring = "hvlbgpka";
+
+#ifdef HAVE_GETOPT_LONG
+ static struct option long_options[] = {
+ {"help", no_argument, 0, 'h'},
+ {"version", no_argument, 0, 'v'},
+ {"length", no_argument, 0, 'l'},
+ {"bitrate", no_argument, 0, 'b'},
+ {"page-stats", no_argument, 0, 'g'},
+ {"packet-stats", no_argument, 0, 'p'},
+ {"skeleton", no_argument, 0, 'k'},
+ {"all", no_argument, 0, 'a'},
+ {NULL,0,0,0}
+ };
+#endif
+
progname = argv[0];
if (argc < 2) {
@@ -523,22 +539,17 @@
return (1);
}
+ if (!strncmp (argv[1], "-?", 2)) {
+#ifdef HAVE_GETOPT_LONG
+ ot_print_options (long_options, optstring);
+#else
+ ot_print_short_options (optstring);
+#endif
+ exit (0);
+ }
+
while (1) {
- char * optstring = "hvlbgpka";
-
#ifdef HAVE_GETOPT_LONG
- static struct option long_options[] = {
- {"help", no_argument, 0, 'h'},
- {"version", no_argument, 0, 'v'},
- {"length", no_argument, 0, 'l'},
- {"bitrate", no_argument, 0, 'b'},
- {"page-stats", no_argument, 0, 'g'},
- {"packet-stats", no_argument, 0, 'p'},
- {"skeleton", no_argument, 0, 'k'},
- {"all", no_argument, 0, 'a'},
- {0,0,0,0}
- };
-
i = getopt_long (argc, argv, optstring, long_options, NULL);
#else
i = getopt (argc, argv, optstring);
Modified: liboggz/trunk/src/tools/oggz-known-codecs.c
===================================================================
--- liboggz/trunk/src/tools/oggz-known-codecs.c 2008-08-01 09:47:05 UTC (rev 3673)
+++ liboggz/trunk/src/tools/oggz-known-codecs.c 2008-08-03 03:10:24 UTC (rev 3674)
@@ -78,7 +78,10 @@
char * progname = argv[0];
if (argc == 2) {
- if (!strncmp (argv[1], "-v", 2) || !strncmp (argv[1], "--version", 9)) {
+ if (!strncmp (argv[1], "-?", 2)) {
+ printf ("-v --version -h --help\n");
+ exit (0);
+ } else if (!strncmp (argv[1], "-v", 2) || !strncmp (argv[1], "--version", 9)) {
printf ("%s version " VERSION "\n", progname);
exit (0);
} else if (!strncmp (argv[1], "-h", 2) || !strncmp (argv[1], "--help", 6)) {
Modified: liboggz/trunk/src/tools/oggz-merge.c
===================================================================
--- liboggz/trunk/src/tools/oggz-merge.c 2008-08-01 09:47:05 UTC (rev 3673)
+++ liboggz/trunk/src/tools/oggz-merge.c 2008-08-03 03:10:24 UTC (rev 3674)
@@ -331,6 +331,18 @@
OMData * omdata;
int i;
+ char * optstring = "hvVo:";
+
+#ifdef HAVE_GETOPT_LONG
+ static struct option long_options[] = {
+ {"help", no_argument, 0, 'h'},
+ {"version", no_argument, 0, 'v'},
+ {"verbose", no_argument, 0, 'V'},
+ {"output", required_argument, 0, 'o'},
+ {0,0,0,0}
+ };
+#endif
+
ot_init ();
progname = argv[0];
@@ -340,20 +352,19 @@
return (1);
}
+ if (!strncmp (argv[1], "-?", 2)) {
+#ifdef HAVE_GETOPT_LONG
+ ot_print_options (long_options, optstring);
+#else
+ ot_print_short_options (optstring);
+#endif
+ exit (0);
+ }
+
omdata = omdata_new();
while (1) {
- char * optstring = "hvVo:";
-
#ifdef HAVE_GETOPT_LONG
- static struct option long_options[] = {
- {"help", no_argument, 0, 'h'},
- {"version", no_argument, 0, 'v'},
- {"verbose", no_argument, 0, 'V'},
- {"output", required_argument, 0, 'o'},
- {0,0,0,0}
- };
-
i = getopt_long (argc, argv, optstring, long_options, NULL);
#else
i = getopt (argc, argv, optstring);
Modified: liboggz/trunk/src/tools/oggz-rip.c
===================================================================
--- liboggz/trunk/src/tools/oggz-rip.c 2008-08-01 09:47:05 UTC (rev 3673)
+++ liboggz/trunk/src/tools/oggz-rip.c 2008-08-03 03:10:24 UTC (rev 3674)
@@ -306,6 +306,21 @@
long l;
int i, n;
+ char * optstring = "hvVo:s:i:c:";
+
+#ifdef HAVE_GETOPT_LONG
+ static struct option long_options[] = {
+ {"help", no_argument, 0, 'h'},
+ {"version", no_argument, 0, 'v'},
+ {"output", required_argument, 0, 'o'},
+ {"verbose", no_argument, 0, 'V'},
+ {"serialno", required_argument, 0, 's'},
+ {"stream-index", required_argument, 0, 'i'},
+ {"content-type", required_argument, 0, 'c'},
+ {0,0,0,0}
+ };
+#endif
+
ot_init();
progname = argv[0];
@@ -315,23 +330,19 @@
return (1);
}
+ if (!strncmp (argv[1], "-?", 2)) {
+#ifdef HAVE_GETOPT_LONG
+ ot_print_options (long_options, optstring);
+#else
+ ot_print_short_options (optstring);
+#endif
+ exit (0);
+ }
+
ordata = ordata_new ();
while (1) {
- char * optstring = "hvVo:s:i:c:";
-
#ifdef HAVE_GETOPT_LONG
- static struct option long_options[] = {
- {"help", no_argument, 0, 'h'},
- {"version", no_argument, 0, 'v'},
- {"output", required_argument, 0, 'o'},
- {"verbose", no_argument, 0, 'V'},
- {"serialno", required_argument, 0, 's'},
- {"stream-index", required_argument, 0, 'i'},
- {"content-type", required_argument, 0, 'c'},
- {0,0,0,0}
- };
-
i = getopt_long (argc, argv, optstring, long_options, NULL);
#else
i = getopt (argc, argv, optstring);
Modified: liboggz/trunk/src/tools/oggz-scan.c
===================================================================
--- liboggz/trunk/src/tools/oggz-scan.c 2008-08-01 09:47:05 UTC (rev 3673)
+++ liboggz/trunk/src/tools/oggz-scan.c 2008-08-03 03:10:24 UTC (rev 3674)
@@ -207,6 +207,19 @@
char * infilename = NULL, * outfilename = NULL;
int i;
+ char * optstring = "f:khvo:";
+
+#ifdef HAVE_GETOPT_LONG
+ static struct option long_options[] = {
+ {"output", required_argument, 0, 'o'},
+ {"format", required_argument, 0, 'f'},
+ {"keyframe", no_argument, 0, 'k'},
+ {"help", no_argument, 0, 'h'},
+ {"version", no_argument, 0, 'v'},
+ {0,0,0,0}
+ };
+#endif
+
progname = argv[0];
if (argc < 2) {
@@ -214,19 +227,17 @@
return (1);
}
+ if (!strncmp (argv[1], "-?", 2)) {
+#ifdef HAVE_GETOPT_LONG
+ ot_print_options (long_options, optstring);
+#else
+ ot_print_short_options (optstring);
+#endif
+ exit (0);
+ }
+
while (1) {
- char * optstring = "f:khvo:";
-
#ifdef HAVE_GETOPT_LONG
- static struct option long_options[] = {
- {"output", required_argument, 0, 'o'},
- {"format", required_argument, 0, 'f'},
- {"keyframe", no_argument, 0, 'k'},
- {"help", no_argument, 0, 'h'},
- {"version", no_argument, 0, 'v'},
- {0,0,0,0}
- };
-
i = getopt_long(argc, argv, optstring, long_options, NULL);
#else
i = getopt (argc, argv, optstring);
Modified: liboggz/trunk/src/tools/oggz-sort.c
===================================================================
--- liboggz/trunk/src/tools/oggz-sort.c 2008-08-01 09:47:05 UTC (rev 3673)
+++ liboggz/trunk/src/tools/oggz-sort.c 2008-08-03 03:10:24 UTC (rev 3674)
@@ -336,6 +336,18 @@
OSData * osdata;
int i;
+ char * optstring = "hvVo:";
+
+#ifdef HAVE_GETOPT_LONG
+ static struct option long_options[] = {
+ {"help", no_argument, 0, 'h'},
+ {"version", no_argument, 0, 'v'},
+ {"verbose", no_argument, 0, 'V'},
+ {"output", required_argument, 0, 'o'},
+ {0,0,0,0}
+ };
+#endif
+
ot_init ();
progname = argv[0];
@@ -345,20 +357,19 @@
return (1);
}
+ if (!strncmp (argv[1], "-?", 2)) {
+#ifdef HAVE_GETOPT_LONG
+ ot_print_options (long_options, optstring);
+#else
+ ot_print_short_options (optstring);
+#endif
+ exit (0);
+ }
+
osdata = osdata_new();
while (1) {
- char * optstring = "hvVo:";
-
#ifdef HAVE_GETOPT_LONG
- static struct option long_options[] = {
- {"help", no_argument, 0, 'h'},
- {"version", no_argument, 0, 'v'},
- {"verbose", no_argument, 0, 'V'},
- {"output", required_argument, 0, 'o'},
- {0,0,0,0}
- };
-
i = getopt_long (argc, argv, optstring, long_options, NULL);
#else
i = getopt (argc, argv, optstring);
Modified: liboggz/trunk/src/tools/oggz-validate.c
===================================================================
--- liboggz/trunk/src/tools/oggz-validate.c 2008-08-01 09:47:05 UTC (rev 3673)
+++ liboggz/trunk/src/tools/oggz-validate.c 2008-08-03 03:10:24 UTC (rev 3674)
@@ -419,6 +419,21 @@
char * filename;
int i = 1;
+ char * optstring = "M:psPhvE";
+
+#ifdef HAVE_GETOPT_LONG
+ static struct option long_options[] = {
+ {"max-errors", required_argument, 0, 'M'},
+ {"prefix", no_argument, 0, 'p'},
+ {"suffix", no_argument, 0, 's'},
+ {"partial", no_argument, 0, 'P'},
+ {"help", no_argument, 0, 'h'},
+ {"help-errors", no_argument, 0, 'E'},
+ {"version", no_argument, 0, 'v'},
+ {0,0,0,0}
+ };
+#endif
+
ot_init();
progname = argv[0];
@@ -428,21 +443,17 @@
return (1);
}
+ if (!strncmp (argv[1], "-?", 2)) {
+#ifdef HAVE_GETOPT_LONG
+ ot_print_options (long_options, optstring);
+#else
+ ot_print_short_options (optstring);
+#endif
+ exit (0);
+ }
+
while (1) {
- char * optstring = "M:psPhvE";
-
#ifdef HAVE_GETOPT_LONG
- static struct option long_options[] = {
- {"max-errors", required_argument, 0, 'M'},
- {"prefix", no_argument, 0, 'p'},
- {"suffix", no_argument, 0, 's'},
- {"partial", no_argument, 0, 'P'},
- {"help", no_argument, 0, 'h'},
- {"help-errors", no_argument, 0, 'E'},
- {"version", no_argument, 0, 'v'},
- {0,0,0,0}
- };
-
i = getopt_long(argc, argv, optstring, long_options, NULL);
#else
i = getopt (argc, argv, optstring);
Modified: liboggz/trunk/src/tools/oggz_tools.c
===================================================================
--- liboggz/trunk/src/tools/oggz_tools.c 2008-08-01 09:47:05 UTC (rev 3673)
+++ liboggz/trunk/src/tools/oggz_tools.c 2008-08-03 03:10:24 UTC (rev 3674)
@@ -35,6 +35,8 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <getopt.h>
+
#include <oggz/oggz.h>
#include "dirac.h"
@@ -468,3 +470,28 @@
_setmode( _fileno( stdout ), _O_BINARY );
#endif
}
+
+void
+ot_print_short_options (char * optstring)
+{
+ char *c;
+
+ for (c=optstring; *c; c++) {
+ if (*c != ':') printf ("-%c ", *c);
+ }
+
+ printf ("\n");
+}
+
+#ifdef HAVE_GETOPT_LONG
+void
+ot_print_options (struct option long_options[], char * optstring)
+{
+ int i;
+ for (i=0; long_options[i].name != NULL; i++) {
+ printf ("--%s ", long_options[i].name);
+ }
+
+ ot_print_short_options (optstring);
+}
+#endif
Modified: liboggz/trunk/src/tools/oggz_tools.h
===================================================================
--- liboggz/trunk/src/tools/oggz_tools.h 2008-08-01 09:47:05 UTC (rev 3673)
+++ liboggz/trunk/src/tools/oggz_tools.h 2008-08-03 03:10:24 UTC (rev 3674)
@@ -34,6 +34,7 @@
#define __OGGZ_TOOLS_H__
#include "config.h"
+#include <getopt.h>
const char *
ot_page_identify (OGGZ *oggz, const ogg_page * og, char ** info);
@@ -61,4 +62,12 @@
*/
void ot_init (void);
+/*
+ * Print options. Must use these in response to -? for each command,
+ * for bash completion.
+ */
+void ot_print_short_options (char * optstring);
+
+void ot_print_options (struct option long_options[], char * optstring);
+
#endif /* __OGGZ_TOOLS_H__ */
More information about the commits
mailing list