[xiph-cvs] cvs commit: ogg-tools/oggsplit common.c common.h oggsplit.1 Makefile.am configure.in oggsplit.c output.c stream.c system.h xmalloc.c

Ralph Giles giles at xiph.org
Thu Aug 7 01:45:39 PDT 2003



giles       03/08/07 04:45:39

  Modified:    oggsplit Makefile.am configure.in oggsplit.c output.c
                        stream.c
  Added:       oggsplit common.c common.h oggsplit.1
  Removed:     oggsplit system.h xmalloc.c
  Log:
  Update from Philip Jägenstedt:
  
  I removed the autoproject-supplied system.h and xmalloc.c, and made my own x*alloc
  functions and put them in common.*.
  
  I don't know if this will the tool build on OS X, but at least there's
  less code/macros that can go wrong now.

Revision  Changes    Path
1.2       +1 -1      ogg-tools/oggsplit/Makefile.am

Index: Makefile.am
===================================================================
RCS file: /usr/local/cvsroot/ogg-tools/oggsplit/Makefile.am,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Makefile.am	6 Aug 2003 11:08:11 -0000	1.1
+++ Makefile.am	7 Aug 2003 08:45:39 -0000	1.2
@@ -5,7 +5,7 @@
 bin_PROGRAMS=oggsplit
 
 oggsplit_SOURCES=oggsplit.c stream.c stream.h output.c output.h \
-	xmalloc.c system.h getopt.c getopt1.c getopt.h
+	common.c common.h getopt.c getopt1.c getopt.h
 oggsplit_CFLAGS=$(OGG_CFLAGS)
 oggsplit_LDADD=$(OGG_LIBS)
 

<p><p>1.2       +3 -3      ogg-tools/oggsplit/configure.in

Index: configure.in
===================================================================
RCS file: /usr/local/cvsroot/ogg-tools/oggsplit/configure.in,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- configure.in	6 Aug 2003 11:08:11 -0000	1.1
+++ configure.in	7 Aug 2003 08:45:39 -0000	1.2
@@ -12,12 +12,12 @@
 AC_PROG_INSTALL
 AC_PROG_CC
 
+dnl Checks for Ogg libraries and headers.
+XIPH_PATH_OGG()
+
 dnl Checks for libraries.
 
 dnl Checks for header files.
 AC_HEADER_STDC
 
-dnl Checks for Ogg libraries and header files.
-XIPH_PATH_OGG()
-
 AC_OUTPUT(Makefile)

<p><p>1.2       +22 -16    ogg-tools/oggsplit/oggsplit.c

Index: oggsplit.c
===================================================================
RCS file: /usr/local/cvsroot/ogg-tools/oggsplit/oggsplit.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- oggsplit.c	6 Aug 2003 11:08:11 -0000	1.1
+++ oggsplit.c	7 Aug 2003 08:45:39 -0000	1.2
@@ -19,18 +19,16 @@
 */
 
 #include <stdio.h>
-#include <sys/types.h>
 #include <getopt.h>
-#include "system.h"
+#include <errno.h>
+#include <sys/types.h>
+#include <dirent.h>
 
 #include <ogg/ogg.h>
 
 #include "stream.h"
 #include "output.h"
-
-char *xmalloc();
-char *xrealloc();
-char *xstrdup();
+#include "common.h"
 
 #define CHUNK_SIZE 4096
 
@@ -247,7 +245,9 @@
 
 int main(int argc, char **argv)
 {
-  int c;
+  DIR *test;
+  int c, outdir_len;
+
   while((c=getopt_long(argc,argv,optstring,options,NULL))!=EOF){
     switch(c){
     case 'c':
@@ -257,16 +257,22 @@
       unchain=0;
       break;
     case 'o':
-      {
-	int outdir_len;
-	if(outdir!=NULL)free(outdir);
-	outdir_len=strlen(optarg)+2;
+      if((test=opendir(optarg))==NULL){
+	fprintf(stderr, "ERROR: Cannot use output directory `%s': %s\n",
+		optarg, strerror(errno));
+	exit(1);
+      }
+      closedir(test);
+
+      outdir_len=strlen(optarg)+2;
+      if(outdir==NULL)
         outdir=xmalloc(outdir_len);
-	strcpy(outdir, optarg);
-	if(outdir[outdir_len-3]!='/'){
-	  outdir[outdir_len-2]='/';
-	  outdir[outdir_len-1]='\0';
-	}
+      else
+	outdir=xrealloc(outdir, outdir_len);
+      strcpy(outdir, optarg);
+      if(outdir[outdir_len-3]!='/'){
+	outdir[outdir_len-2]='/';
+	outdir[outdir_len-1]='\0';
       }
       break;
     case 'V':

<p><p>1.2       +5 -9      ogg-tools/oggsplit/output.c

Index: output.c
===================================================================
RCS file: /usr/local/cvsroot/ogg-tools/oggsplit/output.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- output.c	6 Aug 2003 11:08:11 -0000	1.1
+++ output.c	7 Aug 2003 08:45:39 -0000	1.2
@@ -19,14 +19,10 @@
 */
 
 #include <stdio.h>
-#include <sys/types.h>
-#include "system.h"
+#include <errno.h>
 
 #include "output.h"
-
-char *xmalloc();
-char *xrealloc();
-char *xstrdup();
+#include "common.h"
 
 int output_ctrl_init(output_ctrl_t *oc,
                      char *dirname, char *filename)
@@ -36,7 +32,7 @@
    * address of the output_t objects musn't change (they are referenced
    * directly in the stream objects).
    */
-  oc->outputs=(output_t **)xmalloc(sizeof(output_t *)*8);
+  oc->outputs=xmalloc(sizeof(output_t *)*8);
 
   oc->dirname=xstrdup(dirname);
 
@@ -78,11 +74,11 @@
 
   if(oc->outputs_used==oc->outputs_size){
     /* allocate room for 8 more (output_t *):s */
-    oc->outputs=(output_t **)xrealloc(oc->outputs, sizeof(output_t *)*(oc->outputs_size+8));
+    oc->outputs=xrealloc(oc->outputs, sizeof(output_t *)*(oc->outputs_size+8));
     oc->outputs_size+=8;
   }
 
-  op=(output_t *)xmalloc(sizeof(output_t));
+  op=xmalloc(sizeof(output_t));
 
   fnlen=strlen(oc->dirname)+strlen(oc->basename)+16;
   op->filename=xmalloc(fnlen);

<p><p>1.2       +3 -8      ogg-tools/oggsplit/stream.c

Index: stream.c
===================================================================
RCS file: /usr/local/cvsroot/ogg-tools/oggsplit/stream.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- stream.c	6 Aug 2003 11:08:11 -0000	1.1
+++ stream.c	7 Aug 2003 08:45:39 -0000	1.2
@@ -19,14 +19,9 @@
 */
 
 #include <stdio.h>
-#include <sys/types.h>
-#include "system.h"
 
 #include "stream.h"
-
-char *xmalloc();
-char *xrealloc();
-char *xstrdup();
+#include "common.h"
 
 const char *magic_vorbis = "\x01vorbis";
 const char *magic_theora = "\x80theora";
@@ -36,7 +31,7 @@
 int stream_ctrl_init(stream_ctrl_t *sc)
 {
   /* begin with 2 stream_t:s */
-  sc->streams=(stream_t *)xmalloc(sizeof(stream_t)*2);
+  sc->streams=xmalloc(sizeof(stream_t)*2);
 
   sc->streams_size=2;
   sc->streams_used=0;
@@ -55,7 +50,7 @@
 
   if(sc->streams_used==sc->streams_size){
     /* we need more streams, alloc 2 more */
-    sc->streams=(stream_t *)xrealloc(sc->streams,sizeof(stream_t)*(sc->streams_size+2));
+    sc->streams=xrealloc(sc->streams,sizeof(stream_t)*(sc->streams_size+2));
     sc->streams_size+=2;
   }
 

<p><p>1.1                  ogg-tools/oggsplit/common.c

Index: common.c
===================================================================
/* 
 * oggsplit - splits multiplexed Ogg files into separate files
 *
 * Copyright (C) 2003 Philip Jägenstedt
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2, or (at your option)
 * any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software Foundation,
 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  
*/

#include <stdlib.h>
#include <stdio.h>
#include <string.h>

#include "common.h"

void *xmalloc(size_t size)
{
  void *p;
  p=malloc(size);
  if(p==NULL){
    fprintf(stderr, "ERROR: Memory exhausted.\n");
    exit(1);
  }
  return p;
}

void *xrealloc(void *p, size_t size)
{
  p=realloc(p, size);
  if(p==NULL){
    fprintf(stderr, "ERROR: Memory exhausted.\n");
    exit(1);
  }
  return p;
}

char *xstrdup(const char *src)
{
  char *dest;
  dest=xmalloc(strlen(src)+1);
  strcpy(dest, src);
  return dest;
}

<p><p>1.1                  ogg-tools/oggsplit/common.h

Index: common.h
===================================================================
/* 
 * oggsplit - splits multiplexed Ogg files into separate files
 *
 * Copyright (C) 2003 Philip Jägenstedt
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2, or (at your option)
 * any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software Foundation,
 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  
*/

#ifndef _XMALLOC_H
#define _XMALLOC_H

void *xmalloc(size_t size);
void *xrealloc(void *p, size_t size);
char *xstrdup(const char *source);

#endif /* _XMALLOC_H */

<p><p>1.1                  ogg-tools/oggsplit/oggsplit.1

Index: oggsplit.1
===================================================================
.\"                              hey, Emacs:   -*- nroff -*-
.\" oggsplit is free software; you can redistribute it and/or modify
.\" it under the terms of the GNU General Public License as published by
.\" the Free Software Foundation; either version 2 of the License, or
.\" (at your option) any later version.
.\"
.\" This program is distributed in the hope that it will be useful,
.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
.\" GNU General Public License for more details.
.\"
.\" You should have received a copy of the GNU General Public License
.\" along with this program; see the file COPYING.  If not, write to
.\" the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
.\"
.TH oggsplit 1 "August 4, 2003"
.\" Please update the above date whenever this man page is modified.

.SH NAME
oggsplit \- splits multiplexed Ogg files
.SH SYNOPSIS
.B oggsplit
[
.B -cgVh
]
[
.B -o
.I <directory>
]
.I input_files \fR...

.SH DESCRIPTION
\fBoggsplit\fP splits multiplexed Ogg files into separate files. Both grouped
and chained logical streams are are supported.
.PP
Grouping (concurrent multiplexing) is when two streams run alongside in the
file, as is the case in a theora+vorbis Ogg file. Chaining (sequential
multiplexing) is when complete physical bitstreams are strung one after the
other. Such a file is created by simply joining two complete files with
\fBcat(1)\fP or a similar tool.
.PP
By default \fBoggsplit\fP extracts all streams, chained as well as grouped.
Since \fBoggsplit\fP does not care about about stream formats and thus works
with any type of stream. For the same reason, it cannot split the file at an
arbitrary point. For such functionality, use a specialized tool like
\fBvcut(1)\fP.

.SH OPTIONS
\fBoggsplit\fP accepts the following options:
.TP
.B \-c, \-\-unchain
Only split chained streams.
.TP
.B \-g, \-\-ungroup
Only split grouped streams. This  will cause only the first link to be
processed, and the names of the output files will be slightly simpler.
.TP
.BI "-o, --outdir " "<directory>"
Create all output files in the specified directory.
.TP
.B \-V, \-\-version
Show oggsplit version.
.TP
.B \-h, \-\-help
Show summary of options.

.SH AUTHOR
Philip Jägenstedt <philipj at telia.com>.

<p><p>--- >8 ----
List archives:  http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'cvs-request at xiph.org'
containing only the word 'unsubscribe' in the body.  No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.



More information about the commits mailing list