Backport to stable: --version option
Aleksander Morgado
aleksander at aleksander.es
Thu Apr 23 00:54:35 PDT 2015
On Thu, Apr 23, 2015 at 1:07 AM, poma <pomidorabelisima at gmail.com> wrote:
>
> $ ModemManager --version
>
> ** (ModemManager:3842): WARNING **: Unknown option --version
>
> Backport to stable "core: add --version option to the ModemManager daemon"
> See http://cgit.freedesktop.org/ModemManager/ModemManager/commit/?id=c4e7fdf
>
Thanks, pushed to mm-1-4.
> ---
> src/main.c | 4 ----
> src/mm-context.c | 19 +++++++++++++++++++
> src/mm-context.h | 5 +++++
> 3 files changed, 24 insertions(+), 4 deletions(-)
>
> diff --git a/src/main.c b/src/main.c
> index f44a2c6..a5ff664 100644
> --- a/src/main.c
> +++ b/src/main.c
> @@ -30,10 +30,6 @@
> #include "mm-log.h"
> #include "mm-context.h"
>
> -#if !defined(MM_DIST_VERSION)
> -# define MM_DIST_VERSION VERSION
> -#endif
> -
> /* Maximum time to wait for all modems to get disabled and removed */
> #define MAX_SHUTDOWN_TIME_SECS 20
>
> diff --git a/src/mm-context.c b/src/mm-context.c
> index c02a4cf..4f88851 100644
> --- a/src/mm-context.c
> +++ b/src/mm-context.c
> @@ -20,6 +20,7 @@
> /*****************************************************************************/
> /* Application context */
>
> +static gboolean version_flag;
> static gboolean debug;
> static const gchar *log_level;
> static const gchar *log_file;
> @@ -27,6 +28,7 @@ static gboolean show_ts;
> static gboolean rel_ts;
>
> static const GOptionEntry entries[] = {
> + { "version", 'V', 0, G_OPTION_ARG_NONE, &version_flag, "Print version", NULL },
> { "debug", 0, 0, G_OPTION_ARG_NONE, &debug, "Run with extended debugging capabilities", NULL },
> { "log-level", 0, 0, G_OPTION_ARG_STRING, &log_level, "Log level: one of [ERR, WARN, INFO, DEBUG]", "INFO" },
> { "log-file", 0, 0, G_OPTION_ARG_STRING, &log_file, "Path to log file", NULL },
> @@ -121,6 +123,19 @@ mm_context_get_test_plugin_dir (void)
>
> /*****************************************************************************/
>
> +static void
> +print_version (void)
> +{
> + g_print ("\n"
> + "ModemManager " MM_DIST_VERSION "\n"
> + "Copyright (2008 - 2014) The ModemManager authors\n"
> + "License GPLv2+: GNU GPL version 2 or later <http://gnu.org/licenses/gpl-2.0.html>\n"
> + "This is free software: you are free to change and redistribute it.\n"
> + "There is NO WARRANTY, to the extent permitted by law.\n"
> + "\n");
> + exit (EXIT_SUCCESS);
> +}
> +
> void
> mm_context_init (gint argc,
> gchar **argv)
> @@ -147,4 +162,8 @@ mm_context_init (gint argc,
> if (!show_ts && !rel_ts)
> show_ts = TRUE;
> }
> +
> + /* If just version requested, print and exit */
> + if (version_flag)
> + print_version ();
> }
> diff --git a/src/mm-context.h b/src/mm-context.h
> index 727cbd7..6627a60 100644
> --- a/src/mm-context.h
> +++ b/src/mm-context.h
> @@ -16,8 +16,13 @@
> #ifndef MM_CONTEXT_H
> #define MM_CONTEXT_H
>
> +#include <config.h>
> #include <glib.h>
>
> +#if !defined(MM_DIST_VERSION)
> +# define MM_DIST_VERSION VERSION
> +#endif
> +
> void mm_context_init (gint argc,
> gchar **argv);
>
> --
> 2.1.0
>
> _______________________________________________
> ModemManager-devel mailing list
> ModemManager-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/modemmanager-devel
--
Aleksander
https://aleksander.es
More information about the ModemManager-devel
mailing list