root/liboggz/trunk/src/tools/oggz.c

Revision 3833, 4.6 kB (checked in by conrad, 3 weeks ago)

oggz: increase temp buffer for toolname, to fit "oggz-known-codecs"

Line 
1 /*
2    Copyright (C) 2008 Annodex Association
3
4    Redistribution and use in source and binary forms, with or without
5    modification, are permitted provided that the following conditions
6    are met:
7
8    - Redistributions of source code must retain the above copyright
9    notice, this list of conditions and the following disclaimer.
10
11    - Redistributions in binary form must reproduce the above copyright
12    notice, this list of conditions and the following disclaimer in the
13    documentation and/or other materials provided with the distribution.
14
15    - Neither the name of the Annodex Association nor the names of its
16    contributors may be used to endorse or promote products derived from
17    this software without specific prior written permission.
18
19    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20    ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21    LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
22    PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE ORGANISATION OR
23    CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24    EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25    PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26    PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27    LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28    NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29    SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31
32 #include "config.h"
33
34 #include <stdio.h>
35 #include <stdlib.h>
36 #include <string.h>
37 #include <unistd.h>
38
39 /* #define DEBUG */
40
41 #define TOOLNAME_LEN 32
42
43 int
44 usage (char * progname)
45 {
46   printf ("Usage: oggz <subcommand> [options] filename ...\n\n");
47
48   printf ("oggz is a commandline tool for manipulating Ogg files. It supports\n"
49           "multiplexed files conformant with RFC3533. Oggz can parse headers for\n"
50           "CELT, CMML, FLAC, Kate, PCM, Speex, Theora and Vorbis, and can read and write\n"
51           "Ogg Skeleton logical bitstreams.\n");
52
53   printf ("\nCommands:\n");
54   printf ("  help          Display help for a specific subcommand (eg. \"oggz help chop\")\n");
55
56   printf ("\nReporting:\n");
57   printf ("  diff          Hexdump the packets of two Ogg files and output differences.\n");
58   printf ("  dump          Hexdump packets of an Ogg file, or revert an Ogg file from\n"
59           "                such a hexdump.\n");
60
61   printf ("  info          Display information about one or more Ogg files and their\n"
62           "                bitstreams.\n");
63
64   printf ("  scan          Scan an Ogg file and output characteristic landmarks.\n");
65
66   printf ("  validate      Validate the Ogg framing of one or more files.\n");
67
68
69   printf ("\nExtraction:\n");
70   printf ("  rip           Extract one or more logical bitstreams from an Ogg file.\n");
71
72   printf ("\nEditing:\n");
73   printf ("  chop          Extract the part of an Ogg file between given start and/or\n"
74           "                end times.\n");
75   printf ("  comment       List or edit comments in an Ogg file.\n");
76   printf ("  merge         Merge Ogg files together, interleaving pages in order of\n"
77           "                presentation time.\n");
78   printf ("  sort          Sort the pages of an Ogg file in order of presentation time.\n");
79
80   printf ("\nMiscellaneous:\n");
81   printf ("  known-codecs  List codecs known by this version of oggz\n");
82
83   printf ("\n");
84   printf ("Please report bugs to <ogg-dev@xiph.org>\n");
85
86   return 0;
87 }
88
89 int
90 main (int argc, char ** argv)
91 {
92   char * progname = argv[0];
93   char toolname[TOOLNAME_LEN];
94   int ret;
95
96   if (argc < 2) {
97      usage (progname);
98   } else {
99     if (!strncmp (argv[1], "-v", 2) || !strncmp(argv[1], "version", 7) || !strncmp(argv[1], "--version", 9)) {
100       printf ("oggz version " VERSION "\n");
101     } else if (!strncmp(argv[1], "-h", 2) || !strncmp (argv[1], "help", 4) || !strncmp(argv[1], "--help", 6)) {
102       if (argc == 2) {
103         usage (progname);
104       } else {
105         sprintf (toolname, "oggz-%s", argv[2]);
106
107         /* Try running "man toolname" */
108         argv[1] = "man";
109         argv[2] = toolname;
110         ret = execvp ("man", &argv[1]);
111
112         /* If that fails (ie. "man" is not installed), try running "toolname --help" */
113         argv[1] = toolname;
114         argv[2] = "--help";
115         ret = execvp (toolname, &argv[1]);
116
117         if (ret == -1) {
118           perror (toolname);
119         }
120       }
121     } else {
122       sprintf (toolname, "oggz-%s", argv[1]);
123       argv[1] = toolname;
124       ret = execvp (toolname, &argv[1]);
125
126       if (ret == -1) {
127         perror (toolname);
128       }
129     }
130   }
131
132   exit (0);
133 }
Note: See TracBrowser for help on using the browser.