gstreamer/tools/tools.h
Tim-Philipp Müller ca320242f3 tools: call g_set_prgname() before doing the option parsing
g_setprgname is implicitly called by g_option_context_new() with a check
to see if it's been set already, so set it before g_option_context_new()

Move version printing back until after the options have been parsed,
otherwise it won't work, since it evaluates a flag set by the
option parser.
2010-02-16 11:33:19 +00:00

70 lines
2 KiB
C

/* GStreamer
* Copyright (C) 2005 Benjamin Otte <otte@gnome.org>
*
* tools.h: header for common stuff of all GStreamer tools
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __GST_TOOLS_H__
#define __GST_TOOLS_H__
#include <stdlib.h>
#include <gst/gst.h>
#include "gst/gst-i18n-app.h"
/*
* This is a kind of hacky way to make all the tools use the same version code.
* If anyone knows a less hacky way to get this done, feel free to implement it.
*
* It also includes all the files that all the tools require.
*/
static gboolean __gst_tools_version = FALSE;
#define GST_TOOLS_GOPTION_VERSION \
{ "version", 0, 0, G_OPTION_ARG_NONE, &__gst_tools_version, \
N_("Print version information and exit"), NULL }
static void
gst_tools_print_version (const gchar * tool)
{
if (__gst_tools_version) {
gchar *version_str;
version_str = gst_version_string ();
g_print ("%s version %u.%u.%u\n", g_get_prgname (),
GST_VERSION_MAJOR, GST_VERSION_MINOR, GST_VERSION_MICRO);
g_print ("%s\n", version_str);
g_print ("%s\n", GST_PACKAGE_ORIGIN);
g_free (version_str);
exit (0);
}
}
static void
gst_tools_set_prgname (const gchar * tool)
{
gchar *s;
s = g_strdup_printf ("%s-%u.%u", tool, GST_VERSION_MAJOR, GST_VERSION_MINOR);
g_set_prgname (s);
g_free (s);
}
#endif /* __GST_TOOLS_H__ */