tools/: Add back --version command line option (#340460).
[platform/upstream/gstreamer.git] / tools / tools.h
1 /* GStreamer
2  * Copyright (C) 2005 Benjamin Otte <otte@gnome.org>
3  *
4  * tools.h: header for common stuff of all GStreamer tools
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Library General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Library General Public License for more details.
15  *
16  * You should have received a copy of the GNU Library General Public
17  * License along with this library; if not, write to the
18  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19  * Boston, MA 02111-1307, USA.
20  */
21
22
23 #ifndef __GST_TOOLS_H__
24 #define __GST_TOOLS_H__
25
26 #include "gst/gst-i18n-app.h"
27
28 /*
29  * This is a kind of hacky way to make all the tools use the same version code.
30  * If anyone knows a less hacky way to get this done, feel free to implement it.
31  * 
32  * It also includes all the files that all the tools require.
33  */
34
35 static gboolean __gst_tools_version = FALSE;
36
37 #define GST_TOOLS_GOPTION_VERSION \
38     { "version", 0, 0, G_OPTION_ARG_NONE, &__gst_tools_version, \
39       N_("Print version information and exit"), NULL }
40
41 static void
42 gst_tools_print_version (const gchar * tool)
43 {
44   gchar *s;
45
46   s = g_strdup_printf ("%s-%u.%u", tool, GST_VERSION_MAJOR, GST_VERSION_MINOR);
47   g_set_prgname (s);
48   g_free (s);
49
50   if (__gst_tools_version) {
51     gchar *version_str;
52
53     version_str = gst_version_string ();
54     g_print ("%s version %u.%u.%u\n", g_get_prgname (),
55         GST_VERSION_MAJOR, GST_VERSION_MINOR, GST_VERSION_MICRO);
56     g_print ("%s\n", version_str);
57     g_print ("%s\n", GST_PACKAGE_ORIGIN);
58     g_free (version_str);
59     exit (0);
60   }
61 }
62
63 #endif /* __GST_TOOLS_H__ */