summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDarren Salt <linux@youmustbejoking.demon.co.uk>2008-04-06 19:32:21 +0100
committerDarren Salt <linux@youmustbejoking.demon.co.uk>2008-04-06 19:32:21 +0100
commitb1c711f131520ce268b6403bb7e61595300c5b81 (patch)
tree2fe2dc17094214259e33027fcc5aacdcadd5c0e2
parent1397c2baedd7a1f4a203c4a1ce14d8a46ba5d523 (diff)
downloadxine-lib-b1c711f131520ce268b6403bb7e61595300c5b81.tar.gz
xine-lib-b1c711f131520ce268b6403bb7e61595300c5b81.tar.bz2
Add a tool to list MIME types & filetype extns known to xine-lib plugins.
This is expected to see most use in updating MIME type lists in front ends' desktop files.
-rw-r--r--.hgignore3
-rw-r--r--ChangeLog2
-rw-r--r--configure.ac5
-rw-r--r--debian/libxine1.install1
-rw-r--r--doc/man/en/Makefile.am12
-rw-r--r--doc/man/en/xine-config.16
-rw-r--r--doc/man/en/xine-list.1.in40
-rw-r--r--m4/getopt_long.m434
-rw-r--r--misc/Makefile.am4
-rw-r--r--misc/libxine.pc.in3
-rw-r--r--misc/xine-config.in7
-rw-r--r--misc/xine-list.c159
12 files changed, 271 insertions, 5 deletions
diff --git a/.hgignore b/.hgignore
index 18e56d5d4..d310df4af 100644
--- a/.hgignore
+++ b/.hgignore
@@ -4,6 +4,7 @@ syntax: glob
*.lo
*.la
+*.o
.libs/*
.deps/*
Makefile
@@ -45,6 +46,7 @@ doc/faq/faq.html
doc/faq/faq.txt
doc/hackersguide/*.png
doc/hackersguide/hackersguide.html
+doc/man/*/xine-list-*.1
include/xine.h
@@ -54,6 +56,7 @@ misc/libxine.pc
misc/relchk.sh
misc/xine-config
misc/xine-lib.spec
+misc/xine-list-*
po/POTFILES
po/*.gmo
diff --git a/ChangeLog b/ChangeLog
index 75c0b254e..fe676b129 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,8 @@ xine-lib (1.1.12) 2008-??-??
* Fixed and improved the PulseAudio driver.
* Fixed a regression in 1.1.11.1 which broke Quicktime container handling.
* And another, this time in the Matroska demuxer.
+ * Added a tool to assist with generating front ends' desktop files. It
+ lists MIME types & filename extensions known to the installed xine-lib.
xine-lib (1.1.11.1) 2008-03-30
* Security fixes:
diff --git a/configure.ac b/configure.ac
index be32b1cf5..9acb49427 100644
--- a/configure.ac
+++ b/configure.ac
@@ -19,6 +19,8 @@ XINE_MINOR=1
XINE_SUB=11
dnl XINE_PATCH should be left empty or set to ".1" or ".2" or something similar
XINE_PATCH=.1
+dnl Release series number (usually $XINE_MAJOR.$XINE_MINOR)
+XINE_SERIES=1.1
dnl if test $XINE_SUB -eq 0 ; then
dnl XINE_SUBPART="";
@@ -66,6 +68,7 @@ AC_SUBST(XINE_MAJOR)
AC_SUBST(XINE_MINOR)
AC_SUBST(XINE_SUB)
AC_SUBST(XINE_PATCH)
+AC_SUBST(XINE_SERIES)
AC_SUBST(XINE_IFACE_AGE)
AC_SUBST(XINE_BIN_AGE)
@@ -254,6 +257,8 @@ AC_CHECK_DECL(sysi86,[
#include <sys/sysi86.h>
])
+AC_GETOPT_LONG
+
dnl ---------------------------------------------
dnl Windows ports checks
dnl ---------------------------------------------
diff --git a/debian/libxine1.install b/debian/libxine1.install
index b4037aa21..7fd9ade02 100644
--- a/debian/libxine1.install
+++ b/debian/libxine1.install
@@ -1,3 +1,4 @@
+usr/bin/xine-list*
usr/lib/libxine*.so.*
usr/lib/xine/plugins/*/post/*.so
usr/lib/xine/plugins/*/*.so
diff --git a/doc/man/en/Makefile.am b/doc/man/en/Makefile.am
index ee0296033..8cdf212a6 100644
--- a/doc/man/en/Makefile.am
+++ b/doc/man/en/Makefile.am
@@ -1,5 +1,13 @@
include $(top_srcdir)/misc/Makefile.common
-man_MANS = xine-config.1 xine.5
+STATICMANS = xine-config.1 xine.5
+DYNAMICMANS = xine-list-@XINE_SERIES@.1
-EXTRA_DIST = $(man_MANS)
+man_MANS = $(STATICMANS) $(DYNAMICMANS)
+
+BUILT_SOURCES = $(DYNAMICMANS)
+DISTCLEANFILES = $(DYNAMICMANS)
+EXTRA_DIST = $(STATICMANS) $(suffix .in,$(DYNAMICMANS))
+
+xine-list-@XINE_SERIES@.1: xine-list.1.in
+ (echo '.ds xl xine\-list\-@XINE_MAJOR@.@XINE_MINOR@'; cat $<) >$@
diff --git a/doc/man/en/xine-config.1 b/doc/man/en/xine-config.1
index d8c778475..207dc2dea 100644
--- a/doc/man/en/xine-config.1
+++ b/doc/man/en/xine-config.1
@@ -36,6 +36,8 @@ Print the linker flags that are necessary to link \fIlibxine\fP to a program.
Print the compiler flags (for C and Objective C, respectively) that are
necessary to compile a program that uses \fIlibxine\fP.
.TP 8
+.B \-\-bindir
+.TQ 8
.B \-\-plugindir
.TQ 8
.B \-\-datadir
@@ -43,8 +45,8 @@ necessary to compile a program that uses \fIlibxine\fP.
.B \-\-scriptdir
.TQ 8
.B \-\-localedir
-Print the directory where, respectively, \fIlibxine\fP plugins, data files,
-scripts and locale data are stored/expected.
+Print the directory where, respectively, \fIlibxine\fP binaries, plugins,
+data files, scripts and locale data are stored/expected.
.TP 8
.B \-\-prefix=PREFIX
If specified, use PREFIX instead of the installation prefix that \fIxine-lib\fP
diff --git a/doc/man/en/xine-list.1.in b/doc/man/en/xine-list.1.in
new file mode 100644
index 000000000..e159852c8
--- /dev/null
+++ b/doc/man/en/xine-list.1.in
@@ -0,0 +1,40 @@
+.TH XINE 1 2001-08-28 "The xine project"
+.SH NAME
+\*(xl - get supported filetype information from xine-lib
+.SH SYNOPSIS
+.B \*(xl
+[\fPoptions...\fI]
+.SH DESCRIPTION
+.PP
+\fI\*(xl\fP is a tool that is used to list the MIME type and filename
+extension information known and supported by the installed \fIxine-lib\fP.
+It is of use in filling in MIME information in front ends' desktop files.
+.
+.SH OPTIONS
+.l
+\fIxine\-list\fP accepts the following options:
+.TP 8
+.B \-m
+.B \-\-mime\-types
+List the MIME types known to \fIxine-lib\fP. (This is the default action.)
+.TP 8
+.B \-e
+.B \-\-extensions
+List the file types (filename extensions) known to \fIxine-lib\fP.
+.TP 8
+.B \-a
+.B \-\-all
+List the MIME types known to \fIxine-lib\fP, along with their filename
+extensions and descriptions.
+.TP 8
+.B \-p
+.B \-\-pretty\-print
+Add line feeds; print each item on a line of its own.
+.SH COPYRIGHT
+Copyright \(co 2008 the xine project.
+
+Permission to use, copy, modify, and distribute this software and its
+documentation for any purpose and without fee is hereby granted, provided
+that the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
diff --git a/m4/getopt_long.m4 b/m4/getopt_long.m4
new file mode 100644
index 000000000..39f41ffc2
--- /dev/null
+++ b/m4/getopt_long.m4
@@ -0,0 +1,34 @@
+dnl ---------------------------------------------
+dnl Check for GNU getopt_long()
+dnl ---------------------------------------------
+
+AC_DEFUN([AC_GETOPT_LONG], [
+ AC_MSG_CHECKING(for GNU getopt_long)
+ AC_RUN_IFELSE([AC_LANG_SOURCE([[
+#include <stdio.h>
+#include <stdlib.h>
+#include <getopt.h>
+
+static struct option long_options[] = {
+ {"help" , no_argument, 0, 1 },
+ {"version" , no_argument, 0, 2 },
+ {0 , no_argument, 0, 0 }
+};
+
+int main (int argc, char **argv) {
+ int option_index = 0;
+ int c;
+ opterr = 0;
+ while ((c = getopt_long (argc, argv, "?hv",
+ long_options, &option_index)) != EOF)
+ ;
+ return 0;
+}
+ ]])],
+ [AC_MSG_RESULT(yes);
+ ac_getopt_long=yes;
+ AC_DEFINE(HAVE_GETOPT_LONG,,[Define this if you have GNU getopt_long() implemented])],
+ [AC_MSG_RESULT(no); ac_getopt_long=no],
+ [AC_MSG_RESULT(no); ac_getopt_long=no])
+ AM_CONDITIONAL(HAVE_GETOPT_LONG, test x"$ac_getopt_long" = "xyes")
+])
diff --git a/misc/Makefile.am b/misc/Makefile.am
index ef61b325d..1ab4097c5 100644
--- a/misc/Makefile.am
+++ b/misc/Makefile.am
@@ -16,9 +16,13 @@ EXTRA_DIST = build_rpms.sh \
Makefile.common
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)
+
xine-fontconv: xine-fontconv.c
$(CC) -W -Wall -g -o xine-fontconv xine-fontconv.c -lz `freetype-config --cflags` `freetype-config --libs`
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 297b8c88b..735631f8b 100644
--- a/misc/xine-config.in
+++ b/misc/xine-config.in
@@ -22,10 +22,12 @@ Options:
[--libs]
[--acflags]
[--cflags]
+ [--bindir]
[--plugindir]
[--datadir]
[--scriptdir]
[--localedir]
+ [--xine-list]
[--objcflags]
EOF
exit $1
@@ -57,9 +59,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;
+}