gstfunnel: avoid access of freed pad
[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 <stdlib.h>
27
28 #include <gst/gst.h>
29 #include "gst/gst-i18n-app.h"
30
31 /*
32  * This is a kind of hacky way to make all the tools use the same version code.
33  * If anyone knows a less hacky way to get this done, feel free to implement it.
34  * 
35  * It also includes all the files that all the tools require.
36  */
37
38 static gboolean __gst_tools_version = FALSE;
39
40 #define GST_TOOLS_GOPTION_VERSION \
41     { "version", 0, 0, G_OPTION_ARG_NONE, &__gst_tools_version, \
42       N_("Print version information and exit"), NULL }
43
44 static void
45 gst_tools_print_version (const gchar * tool)
46 {
47   if (__gst_tools_version) {
48     gchar *version_str;
49
50     version_str = gst_version_string ();
51     g_print ("%s version %u.%u.%u\n", g_get_prgname (),
52         GST_VERSION_MAJOR, GST_VERSION_MINOR, GST_VERSION_MICRO);
53     g_print ("%s\n", version_str);
54     g_print ("%s\n", GST_PACKAGE_ORIGIN);
55     g_free (version_str);
56     exit (0);
57   }
58 }
59
60 static void
61 gst_tools_set_prgname (const gchar * tool)
62 {
63   gchar *s;
64
65   s = g_strdup_printf ("%s-%u.%u", tool, GST_VERSION_MAJOR, GST_VERSION_MINOR);
66   g_set_prgname (s);
67   g_free (s);
68 }
69
70 #endif /* __GST_TOOLS_H__ */