[xiph-commits] r3628 - liboggz/trunk/src/tools

conrad at svn.annodex.net conrad at svn.annodex.net
Tue Jul 8 08:37:48 PDT 2008


Author: conrad
Date: 2008-07-08 08:37:47 -0700 (Tue, 08 Jul 2008)
New Revision: 3628

Added:
   liboggz/trunk/src/tools/oggz.c
Modified:
   liboggz/trunk/src/tools/Makefile.am
Log:
add a wrapper "oggz" tool, so that commands like the following work:
  $ oggz dump file.ogv  -- runs "oggz-dump file.ogv"
  $ oggz help info      -- runs "man oggz-info", or "oggz-info --help" on win32
  $ oggz                -- prints a list of common oggz-tools

(so you can use a space instead of a hyphen, like with git)


Modified: liboggz/trunk/src/tools/Makefile.am
===================================================================
--- liboggz/trunk/src/tools/Makefile.am	2008-07-07 12:26:34 UTC (rev 3627)
+++ liboggz/trunk/src/tools/Makefile.am	2008-07-08 15:37:47 UTC (rev 3628)
@@ -13,6 +13,8 @@
 OGGZDIR = ../liboggz
 OGGZ_LIBS = $(OGGZDIR)/liboggz.la @OGG_LIBS@
 
+oggz_any_programs = oggz
+
 if OGGZ_CONFIG_READ
 oggz_read_programs = oggz-dump oggz-info oggz-scan
 oggz_read_noinst_programs =
@@ -27,9 +29,12 @@
 noinst_HEADERS = oggz_tools.h skeleton.h
 
 # Programs to build
-bin_PROGRAMS = $(oggz_read_programs) $(oggz_rw_programs)
+bin_PROGRAMS = $(oggz_any_programs) $(oggz_read_programs) $(oggz_rw_programs)
 noinst_PROGRAMS = $(oggz_read_noinst_programs) $(oggz_rw_noinst_programs)
 
+oggz_SOURCES = oggz.c
+oggz_LDADD =
+
 oggz_info_SOURCES = oggz-info.c oggz_tools.c skeleton.c
 oggz_info_LDADD = $(OGGZ_LIBS) -lm
 

Added: liboggz/trunk/src/tools/oggz.c
===================================================================
--- liboggz/trunk/src/tools/oggz.c	                        (rev 0)
+++ liboggz/trunk/src/tools/oggz.c	2008-07-08 15:37:47 UTC (rev 3628)
@@ -0,0 +1,111 @@
+/*
+   Copyright (C) 2008 Annodex Association
+
+   Redistribution and use in source and binary forms, with or without
+   modification, are permitted provided that the following conditions
+   are met:
+
+   - Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+
+   - Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+
+   - Neither the name of the Annodex Association nor the names of its
+   contributors may be used to endorse or promote products derived from
+   this software without specific prior written permission.
+
+   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+   ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+   PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE ORGANISATION OR
+   CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+   EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+   PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+   PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+   LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+   NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+   SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#include "config.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+/* #define DEBUG */
+
+#define TOOLNAME_LEN 16
+
+int
+usage (char * progname)
+{
+  printf ("Usage: oggz [--help] COMMAND [ARGS]\n\n");
+
+  printf ("The most commonly used oggz commands are:\n\n");
+
+  printf ("  chop          Extract the part of an Ogg file between given start\n"
+          "                and/or end times.\n");
+
+  printf ("  comment       List or edit comments in an Ogg file.\n");
+
+  printf ("  diff          Hexdump the packets of two Ogg files and output\n"
+          "                differences.\n");
+
+  printf ("  dump          Hexdump packets of an Ogg file, or revert an Ogg file\n"
+          "                from such a hexdump.\n");
+
+  printf ("  info          Display information about one or more Ogg files and\n"
+          "                their bitstreams.\n");
+
+  printf ("  merge         Merge Ogg files together, interleaving pages in order\n"
+          "                of presentation time.\n");
+
+  printf ("  rip           Extract one or more logical bitstreams from an Ogg file.\n");
+
+  printf ("  scan          Scan an Ogg file and output characteristic landmarks.\n");
+
+  printf ("  sort          Sort the pages of an Ogg file in order of presentation\n"
+          "                time.\n");
+
+  printf ("  validate      Validate the Ogg framing of one or more files.\n");
+
+  return 0;
+}
+
+int
+main (int argc, char ** argv)
+{
+  char * progname = argv[0];
+  char toolname[TOOLNAME_LEN];
+
+  if (argc < 2) {
+     usage (progname);
+  } else {
+    if (!strncmp (argv[1], "help", 4) || !strncmp(argv[1], "--help", 6)) {
+      if (argc == 2) {
+        usage (progname);
+      } else {
+        sprintf (toolname, "oggz-%s", argv[2]);
+#ifdef _WIN32
+        argv[1] = toolname;
+        argv[2] = "--help";
+        execvp (toolname, &argv[1]);
+#else
+        argv[1] = "man";
+        argv[2] = toolname;
+        execvp ("man", &argv[1]);
+#endif
+      }
+    } else {
+      sprintf (toolname, "oggz-%s", argv[1]);
+      argv[1] = toolname;
+      execvp (toolname, &argv[1]);
+    }
+  }
+
+  exit (0);
+}



More information about the commits mailing list