[xiph-commits] r3501 - liboggz/trunk/src/tools/oggz-chop
conrad at svn.annodex.net
conrad at svn.annodex.net
Thu Feb 28 00:09:05 PST 2008
Author: conrad
Date: 2008-02-28 00:09:04 -0800 (Thu, 28 Feb 2008)
New Revision: 3501
Added:
liboggz/trunk/src/tools/oggz-chop/cmd.c
liboggz/trunk/src/tools/oggz-chop/cmd.h
liboggz/trunk/src/tools/oggz-chop/main.c
liboggz/trunk/src/tools/oggz-chop/oggz-chop.h
Modified:
liboggz/trunk/src/tools/oggz-chop/Makefile.am
liboggz/trunk/src/tools/oggz-chop/oggz-chop.c
Log:
split oggz-chop commandline functions out into oggz-chop/cmd.h
Modified: liboggz/trunk/src/tools/oggz-chop/Makefile.am
===================================================================
--- liboggz/trunk/src/tools/oggz-chop/Makefile.am 2008-02-27 23:32:26 UTC (rev 3500)
+++ liboggz/trunk/src/tools/oggz-chop/Makefile.am 2008-02-28 08:09:04 UTC (rev 3501)
@@ -1,6 +1,6 @@
## Process this file with automake to produce Makefile.in
-INCLUDES = -I$(top_srcdir)/include @OGG_CFLAGS@
+INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/include @OGG_CFLAGS@
OGGZDIR = ../../liboggz
OGGZ_LIBS = $(OGGZDIR)/liboggz.la @OGG_LIBS@
@@ -14,6 +14,16 @@
# Programs to build
bin_PROGRAMS = $(oggz_rw_programs)
+noinst_PROGRAMS = httpdate_test
-oggz_chop_SOURCES = oggz-chop.c ../oggz_tools.c
+TESTS_ENVIRONMENT = $(VALGRIND_ENVIRONMENT)
+
+TESTS = httpdate_test
+
+noinst_HEADERS = alloc_snprintf.h cgi.h cmd.h header.h httpdate.h memory.h oggz-chop.h tests.h
+
+oggz_chop_SOURCES = oggz-chop.c ../oggz_tools.c cmd.c main.c
oggz_chop_LDADD = $(OGGZ_LIBS)
+
+httpdate_test_SOURCES = httpdate.c httpdate_test.c
+
Added: liboggz/trunk/src/tools/oggz-chop/cmd.c
===================================================================
--- liboggz/trunk/src/tools/oggz-chop/cmd.c (rev 0)
+++ liboggz/trunk/src/tools/oggz-chop/cmd.c 2008-02-28 08:09:04 UTC (rev 3501)
@@ -0,0 +1,118 @@
+#include "config.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <getopt.h>
+
+#include "oggz-chop.h"
+
+static char * progname;
+
+static void
+usage (char * progname)
+{
+ printf ("Usage: %s [options] filename\n", progname);
+ printf ("Chop an Ogg file.\n");
+ printf ("\nOutput options\n");
+ printf (" -o filename, --output filename\n");
+ printf (" Specify output filename\n");
+ printf (" -s start_time, --start start_time\n");
+ printf (" Specify start time\n");
+ printf (" -e end_time, --end end_time\n");
+ printf (" Specify end time\n");
+ printf ("\nMiscellaneous options\n");
+ printf (" -h, --help Display this help and exit\n");
+ printf (" -v, --version Output version information and exit\n");
+ printf ("\n");
+ printf ("Please report bugs to <ogg-dev at xiph.org>\n");
+}
+
+int
+cmd_main (int argc, char * argv[])
+{
+ int show_version = 0;
+ int show_help = 0;
+ double start = 0.0, end = -1.0;
+ char * infilename = NULL, * outfilename = NULL;
+ int i;
+
+ progname = argv[0];
+
+ if (argc < 2) {
+ usage (progname);
+ return (1);
+ }
+
+ while (1) {
+ char * optstring = "s:e:o:hv";
+
+#ifdef HAVE_GETOPT_LONG
+ static struct option long_options[] = {
+ {"start", required_argument, 0, 's'},
+ {"end", required_argument, 0, 'e'},
+ {"output", required_argument, 0, 'o'},
+ {"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);
+#endif
+ if (i == -1) break;
+ if (i == ':') {
+ usage (progname);
+ goto exit_err;
+ }
+
+ switch (i) {
+ case 's': /* start */
+ start = atof (optarg);
+ break;
+ case 'e': /* end */
+ end = atof (optarg);
+ break;
+ case 'h': /* help */
+ show_help = 1;
+ break;
+ case 'v': /* version */
+ show_version = 1;
+ break;
+ case 'o': /* output */
+ outfilename = optarg;
+ break;
+ default:
+ break;
+ }
+ }
+
+ if (show_version) {
+ printf ("%s version " VERSION "\n", progname);
+ }
+
+ if (show_help) {
+ usage (progname);
+ }
+
+ if (show_version || show_help) {
+ goto exit_ok;
+ }
+
+ if (optind >= argc) {
+ usage (progname);
+ goto exit_err;
+ }
+
+ infilename = argv[optind++];
+
+ return chop (infilename, outfilename, start, end);
+
+exit_ok:
+ return 0;
+
+exit_err:
+ return 1;
+}
Added: liboggz/trunk/src/tools/oggz-chop/cmd.h
===================================================================
--- liboggz/trunk/src/tools/oggz-chop/cmd.h (rev 0)
+++ liboggz/trunk/src/tools/oggz-chop/cmd.h 2008-02-28 08:09:04 UTC (rev 3501)
@@ -0,0 +1,6 @@
+#ifndef __CMD_H__
+#define __CMD_H__
+
+int cmd_main (int argc, char * argv[]);
+
+#endif /* __CMD_H__ */
Added: liboggz/trunk/src/tools/oggz-chop/main.c
===================================================================
--- liboggz/trunk/src/tools/oggz-chop/main.c (rev 0)
+++ liboggz/trunk/src/tools/oggz-chop/main.c 2008-02-28 08:09:04 UTC (rev 3501)
@@ -0,0 +1,28 @@
+#include "config.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "oggz-chop.h"
+/*#include "cgi.h"*/
+#include "cmd.h"
+
+int
+main (int argc, char * argv[])
+{
+ int err = 0;
+
+#if 0
+ if (cgi_test ()) {
+ err = cgi_main (¶ms);
+ } else {
+ err = cmd_main (¶ms, argc, argv);
+ }
+#else
+ err = cmd_main (argc, argv);
+#endif
+
+ if (err) return 1;
+ else return 0;
+}
Modified: liboggz/trunk/src/tools/oggz-chop/oggz-chop.c
===================================================================
--- liboggz/trunk/src/tools/oggz-chop/oggz-chop.c 2008-02-27 23:32:26 UTC (rev 3500)
+++ liboggz/trunk/src/tools/oggz-chop/oggz-chop.c 2008-02-28 08:09:04 UTC (rev 3501)
@@ -1,4 +1,3 @@
-
/*
Copyright (C) 2008 Annodex Association
@@ -37,57 +36,10 @@
#include <getopt.h>
#include <errno.h>
-
#include <oggz/oggz.h>
-static char * progname;
+#include "oggz-chop.h"
-static void
-usage (char * progname)
-{
- printf ("Usage: %s [options] filename\n", progname);
- printf ("Chop an Ogg file.\n");
- printf ("\nOutput options\n");
- printf (" -o filename, --output filename\n");
- printf (" Specify output filename\n");
- printf (" -s start_time, --start start_time\n");
- printf (" Specify start time\n");
- printf (" -e end_time, --end end_time\n");
- printf (" Specify end time\n");
- printf ("\nMiscellaneous options\n");
- printf (" -h, --help Display this help and exit\n");
- printf (" -v, --version Output version information and exit\n");
- printf ("\n");
- printf ("Please report bugs to <ogg-dev at xiph.org>\n");
-}
-
-/************************************************************
- * OCState
- */
-
-typedef struct _OCState {
- OggzTable * tracks;
- FILE * outfile;
- double start;
- double end;
-} OCState;
-
-/************************************************************
- * OCTrackState
- */
-
-typedef struct _OCTrackState {
- OggzTable * page_accum;
-
- int headers_remaining;
-
- long start_granule;
-
- /* Greatest previously inferred keyframe value */
- ogg_int64_t prev_keyframe;
-
-} OCTrackState;
-
static OCTrackState *
track_state_new (void)
{
@@ -325,7 +277,7 @@
return OGGZ_CONTINUE;
}
-static int
+int
chop (char * infilename, char * outfilename, double start, double end)
{
OCState state;
@@ -344,8 +296,8 @@
} else {
state.outfile = fopen (outfilename, "wb");
if (state.outfile == NULL) {
- fprintf (stderr, "%s: unable to open output file %s\n",
- progname, outfilename);
+ fprintf (stderr, "oggz-chop: unable to open output file %s\n",
+ outfilename);
return -1;
}
}
@@ -363,91 +315,3 @@
return 0;
}
-
-int
-main (int argc, char * argv[])
-{
- int show_version = 0;
- int show_help = 0;
- double start = 0.0, end = -1.0;
- char * infilename = NULL, * outfilename = NULL;
- int i;
-
- progname = argv[0];
-
- if (argc < 2) {
- usage (progname);
- return (1);
- }
-
- while (1) {
- char * optstring = "s:e:o:hv";
-
-#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);
-#endif
- if (i == -1) break;
- if (i == ':') {
- usage (progname);
- goto exit_err;
- }
-
- switch (i) {
- case 's': /* start */
- start = atof (optarg);
- break;
- case 'e': /* end */
- end = atof (optarg);
- break;
- case 'h': /* help */
- show_help = 1;
- break;
- case 'v': /* version */
- show_version = 1;
- break;
- case 'o': /* output */
- outfilename = optarg;
- break;
- default:
- break;
- }
- }
-
- if (show_version) {
- printf ("%s version " VERSION "\n", progname);
- }
-
- if (show_help) {
- usage (progname);
- }
-
- if (show_version || show_help) {
- goto exit_ok;
- }
-
- if (optind >= argc) {
- usage (progname);
- goto exit_err;
- }
-
- infilename = argv[optind++];
-
- return chop (infilename, outfilename, start, end);
-
-exit_ok:
- return 0;
-
-exit_err:
- return 1;
-}
Added: liboggz/trunk/src/tools/oggz-chop/oggz-chop.h
===================================================================
--- liboggz/trunk/src/tools/oggz-chop/oggz-chop.h (rev 0)
+++ liboggz/trunk/src/tools/oggz-chop/oggz-chop.h 2008-02-28 08:09:04 UTC (rev 3501)
@@ -0,0 +1,66 @@
+/*
+ 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 ASSOCIATION 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.
+*/
+
+#ifndef __OGGZ_CHOP_H__
+#define __OGGZ_CHOP_H__
+
+#include <oggz/oggz.h>
+
+/************************************************************
+ * OCState
+ */
+
+typedef struct _OCState {
+ OggzTable * tracks;
+ FILE * outfile;
+ double start;
+ double end;
+} OCState;
+
+/************************************************************
+ * OCTrackState
+ */
+
+typedef struct _OCTrackState {
+ OggzTable * page_accum;
+
+ int headers_remaining;
+
+ long start_granule;
+
+ /* Greatest previously inferred keyframe value */
+ ogg_int64_t prev_keyframe;
+
+} OCTrackState;
+
+int chop (char * infilename, char * outfilename, double start, double end);
+
+#endif /* __OGGZ_CHOP_H__ */
More information about the commits
mailing list