diff options
author | Darren Salt <linux@youmustbejoking.demon.co.uk> | 2008-04-06 19:41:43 +0100 |
---|---|---|
committer | Darren Salt <linux@youmustbejoking.demon.co.uk> | 2008-04-06 19:41:43 +0100 |
commit | 40a1c7da2f5cfb6ed7210cbea192acd1b0231c41 (patch) | |
tree | 7ee720d1b7e6692ad26e277e5fa08f928642a533 /misc | |
parent | 039b044abf0830eebf90e54d575a179a4ac0f0e1 (diff) | |
parent | b1c711f131520ce268b6403bb7e61595300c5b81 (diff) | |
download | xine-lib-40a1c7da2f5cfb6ed7210cbea192acd1b0231c41.tar.gz xine-lib-40a1c7da2f5cfb6ed7210cbea192acd1b0231c41.tar.bz2 |
Merge from 1.1; adapt xine-list for 1.2.
--HG--
rename : debian/libxine1.install => debian/libxine2.install
rename : src/demuxers/demux_ogg.c => src/combined/xine_ogg_demuxer.c
Diffstat (limited to 'misc')
-rw-r--r-- | misc/Makefile.am | 4 | ||||
-rw-r--r-- | misc/libxine.pc.in | 3 | ||||
-rw-r--r-- | misc/xine-config.in | 7 | ||||
-rw-r--r-- | misc/xine-list.c | 159 |
4 files changed, 172 insertions, 1 deletions
diff --git a/misc/Makefile.am b/misc/Makefile.am index cd013b752..783f269f7 100644 --- a/misc/Makefile.am +++ b/misc/Makefile.am @@ -13,9 +13,13 @@ EXTRA_DIST = build_rpms.sh \ fonts/cetus.ttf bin_SCRIPTS = xine-config +bin_PROGRAMS = xine-list-@XINE_SERIES@ pkgconfig_DATA=libxine.pc +xine_list_@XINE_SERIES@_SOURCES = xine-list.c +xine_list_@XINE_SERIES@_LDADD = $(XINE_LIB) + fontdir = $(pkgdatadir)/fonts dist_font_DATA = \ fonts/cetus-16.xinefont.gz \ diff --git a/misc/libxine.pc.in b/misc/libxine.pc.in index a6565bad0..754acc5ca 100644 --- a/misc/libxine.pc.in +++ b/misc/libxine.pc.in @@ -1,5 +1,6 @@ prefix=@prefix@ exec_prefix=@exec_prefix@ +bindir=@bindir@ libdir=@libdir@ includedir=@includedir@ @@ -15,6 +16,8 @@ scriptdir=@XINE_SCRIPTPATH@ localedir=@XINE_LOCALEDIR@ objcflags=@OBJCFLAGS@ +xine_list=${bindir}/xine-list-@XINE_SERIES@ + Name: libxine Description: The xine engine library Version: @XINE_MAJOR@.@XINE_MINOR@.@XINE_SUB@@XINE_PATCH@ diff --git a/misc/xine-config.in b/misc/xine-config.in index 1492d739b..e1192cf46 100644 --- a/misc/xine-config.in +++ b/misc/xine-config.in @@ -23,10 +23,12 @@ Options: [--libs] [--acflags] [--cflags] + [--bindir] [--plugindir] [--datadir] [--scriptdir] [--localedir] + [--xine-list] [--objcflags] EOF exit $1 @@ -58,9 +60,12 @@ while test $# -gt 0; do --cflags|--libs) args="$args${args+ }$1" ;; - --prefix|--acflags|--plugindir|--datadir|--scriptdir|--localedir|--objcflags) + --prefix|--acflags|--bindir|--plugindir|--datadir|--scriptdir|--localedir|--objcflags) args="$args${args+ }--variable=${1#--}" ;; + --xine-list) + args="$args${args+ }--variable=xine_list" + ;; --exec-prefix) args="$args${args+ }--variable=exec_prefix" ;; diff --git a/misc/xine-list.c b/misc/xine-list.c new file mode 100644 index 000000000..ec7b7f694 --- /dev/null +++ b/misc/xine-list.c @@ -0,0 +1,159 @@ +/* + * Copyright (C) 2008 the xine-project + * + * 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 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; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 + * USA + */ + +#include <xine.h> + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <getopt.h> + +#define XINE_LIST_VERSION_N(x,y) #x"."#y +#define XINE_LIST_VERSION XINE_LIST_VERSION_N(XINE_MAJOR_VERSION,XINE_MINOR_VERSION) + +int main (int argc, char *argv[]) +{ + int optstate = 0; + int which = 'm'; + int lf = 0; + + for (;;) + { +#define OPTS "hvaemp" +#ifdef HAVE_GETOPT_LONG + static const struct option longopts[] = { + { "help", no_argument, NULL, 'h' }, + { "version", no_argument, NULL, 'v' }, + { "mime-types", no_argument, NULL, 'm' }, + { "extensions", no_argument, NULL, 'e' }, + { "all", no_argument, NULL, 'a' }, + { NULL } + }; + int index = 0; + int opt = getopt_long (argc, argv, OPTS, longopts, &index); +#else + int opt = getopt(argc, argv, OPTS); +#endif + if (opt == -1) + break; + + switch (opt) + { + case 'h': + optstate |= 1; + break; + case 'v': + optstate |= 4; + break; + case 'a': + case 'e': + case 'm': + which = opt; + break; + case 'p': + lf = 1; + break; + default: + optstate |= 2; + break; + } + } + + if (optstate & 1) + printf ("\ +xine-list-"XINE_LIST_VERSION" %s\n\ +using xine-lib %s\n\ +usage: %s [options]\n\ +options:\n\ + -h, --help this help text\n\ + -m, --mime-types list just the supported MIME types\n\ + -e, --extensions list just the recognised filename extensions\n\ + -a, --all list everything\n\ + -p, --pretty-print add line feeds\n\ +\n", XINE_VERSION, xine_get_version_string (), argv[0]); + else if (optstate & 4) + printf ("\ +xine-list %s\n\ +using xine-lib %s\n\ +(c) 2008 the xine project team\n\ +This is free software; see the source for copying conditions. There is NO\n\ +warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE,\n\ +to the extent permitted by law.\n", + XINE_VERSION, xine_get_version_string ()); + + if (optstate & 2) + { + fputs ("xine-list: invalid option (try -h or --help)\n", stderr); + return 1; + } + + if (optstate) + return 0; + + xine_t *xine = xine_new (); + xine_init (xine); + + char *text = NULL; + char *sep, *sep2; + switch (which) + { + case 'a': + case 'm': + text = xine_get_mime_types (xine); + if (!text || !*text) + goto read_fail; + sep = sep2 = text - 1; + for (;;) + { + text = sep + 1; + sep = strchr (text, ';') ? : text + strlen (text); + sep2 = which == 'a' ? sep : strchr (text, ':') ? : sep; + if (!*sep) + break; + if (printf ("%.*s;", (int)(sep2 - text), text) < 0 || (lf && puts ("") < 0)) + goto write_fail; + } + break; + + case 'e': + text = xine_get_file_extensions (xine); + if (!text || !*text) + goto read_fail; + sep = text - 1; + do + { + text = sep + 1; + sep = strchr (text, ' ') ? : text + strlen (text); + if (sep[-1] != '/' && + printf ("%.*s%s", (int)(sep - text), text, lf ? "\n" : *sep ? " " : "") < 0) + goto write_fail; + } while (*sep); + break; + } + + return 0; + + read_fail: + fputs ("xine-list: failed to read types info\n", stderr); + return 1; + + write_fail: + perror ("xine-list"); + return 1; +} |