int
main (int    argc,
      char **argv)
{
	int      retval;

	gboolean  get = FALSE;
	gboolean  monitor = FALSE;
	char     *tz_set = NULL;

	GError         *error;
	GOptionContext *context;
        GOptionEntry options[] = {
                { "get", 'g', 0, G_OPTION_ARG_NONE, &get, "Get the current timezone", NULL },
                { "set", 's', 0, G_OPTION_ARG_STRING, &tz_set, "Set the timezone to TIMEZONE", "TIMEZONE" },
                { "monitor", 'm', 0, G_OPTION_ARG_NONE, &monitor, "Monitor timezone changes", NULL },
                { NULL, 0, 0, 0, NULL, NULL, NULL }
        };

	retval = 0;

#if !GLIB_CHECK_VERSION (2, 36, 0)
	g_type_init ();
#endif

	context = g_option_context_new ("");
	g_option_context_add_main_entries (context, options, NULL);

	error = NULL;
	if (!g_option_context_parse (context, &argc, &argv, &error)) {
		g_printerr ("%s\n", error->message);
		g_error_free (error);
		g_option_context_free (context);

		return 1;
	}

	g_option_context_free (context);

	if (get || (!tz_set && !monitor))
		timezone_print ();
	else if (tz_set)
		retval = timezone_set (tz_set);
	else if (monitor)
		timezone_monitor ();
	else
		g_assert_not_reached ();

        return retval;
}
int
main (int    argc,
      char **argv)
{
	int      retval;

	gboolean  monitor = FALSE;

	GError         *error;
	GOptionContext *context;
        GOptionEntry options[] = {
                { "monitor", 'm', 0, G_OPTION_ARG_NONE, &monitor, "Monitor timezone changes", NULL },
                { NULL, 0, 0, 0, NULL, NULL, NULL }
        };

	retval = 0;

	context = g_option_context_new ("");
	g_option_context_add_main_entries (context, options, NULL);

	error = NULL;
	if (!g_option_context_parse (context, &argc, &argv, &error)) {
		g_printerr ("%s\n", error->message);
		g_error_free (error);
		g_option_context_free (context);

		return 1;
	}

	g_option_context_free (context);

	timezone_print ();
	if (monitor)
		timezone_monitor ();

        return retval;
}