Ejemplo n.º 1
0
int main(int argc, const char** argv) {
    const char* pname = argv[0];

    if (argc >= 2 && is_help(argv[1])) {
        return usage(pname, EXIT_SUCCESS);
    } else if (argc >= 3 && is_help(argv[2])) {
        return usage(pname, EXIT_SUCCESS);
    } else if (argc <= 2) {
        error("Not enough arguments");
        return usage(pname, EXIT_FAILURE);
    }

    const char* fname = argv[1];
    const char* action = argv[2];

    int sub_argc = argc - 3;
    const char** sub_argv = argv + 3;

    if (strncmp(action, "buy", 4) == 0) {
        return buy(pname, fname, sub_argc, sub_argv);
    } else if (strncmp(action, "sell", 5) == 0) {
        return sell(pname, fname, sub_argc, sub_argv);
    } else if (strncmp(action, "inventory", 10) == 0) {
        return inventory(pname, fname, sub_argc, sub_argv);
    } else if (strncmp(action, "state", 6) == 0) {
        return inventory(pname, fname, sub_argc, sub_argv);
    } else if (strncmp(action, "history", 8) == 0) {
        return history(pname, fname, sub_argc, sub_argv);
    } else {
        error("Unknown action %s", action);
        return usage(argv[0], EXIT_FAILURE);
    }
}
Ejemplo n.º 2
0
int			is_keypause(char *options, t_tetris *game, char **argv, int *i)
{
  if (options[0] == '\0')
    is_help(options, game, argv, i);
  if (!my_strncmp(game->keys->keyquit, options, 0)
      && !my_strncmp(game->keys->keypause, options, 0)
      && !my_strncmp(game->keys->keyquit, options, 0)
      && !my_strncmp(game->keys->keyleft, options, 0)
      && !my_strncmp(game->keys->keydrop, options, 0)
      && !my_strncmp(game->keys->keyturn, options, 0))
    game->keys->keypause = options;
  else
    is_help(options, game, argv, i);
  return (0);
}
Ejemplo n.º 3
0
int			is_level(char *options, t_tetris *game, char **argv, int *i)
{
  int			level;

  level = my_getnbr(options);
  if (level <= 0)
    is_help(options, game, argv, i);
  game->scene->level = level;
  return (0);
}
Ejemplo n.º 4
0
void Parser::parse( const char *str, int len, bool end )
{
    const char *p = str;
    const char *pos = p;
    const char *s = 0;//数据开始位置
    const char *e = 0;//数据结束位置
    while( len > 0 )
    {
        if( *p == '<' )
        {
            pos = p;
            if( s )
               e = p;//记下数据结束位置
        }
        else if( *p=='>' )
        {
            std::string tag( pos + 1, p - pos - 1 );
			reArrange(tag);

            if( is_version( tag ) )
                ;//std::cout << tag << "\n";
			else if(is_help(tag))
				;
            else if( is_end( tag ) )
            {
                if( s && e )
                {
                    std::string data( s + 1, e -s - 1 );
                    on_data( data );
                    s = e = 0;
                }
                on_end( tag );
            }
            else if( is_element( tag ) )
            {
                parse_property( tag );
                on_end( tag );
            }
            else
            {
				
                parse_property( tag );
                s = p;//记下数据开位置
            }
        }
        p++;
        len--;
    }
}
Ejemplo n.º 5
0
int			is_mapsize(char *options, t_tetris *game, char **argv, int *i)
{
  int			rows;
  int			colums;
  int			x;

  x = 0;
  rows = my_getnbr(options);
  while (options[x++] != ',');
  colums = my_getnbr(&options[x]);
  if (rows <= 0 || colums <= 0)
    is_help(options, game, argv, i);
  game->scene->rows = rows;
  game->scene->colums = colums;
  return (0);
}
Ejemplo n.º 6
0
int
main (int argc, char *argv[])
{
    bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
    bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
    textdomain (GETTEXT_PACKAGE);

    int status = EXIT_SUCCESS;

    g_type_init ();

    GPasteClient *client = g_paste_client_new ();
    GError *error = NULL;
    const gchar *arg1, *arg2;

    if (!client)
    {
        if (argc == 2 && is_help (argv[1]))
        {
            show_help (argv[0]);
            return EXIT_SUCCESS;
        }

        failure_exit ();
    }

    if (!isatty (fileno (stdin)))
    {
        /* We are being piped */
        GString *data = g_string_new ("");
        gchar c;

        while ((c = fgetc (stdin)) != EOF)
            data = g_string_append_c (data, c);

        data->str[data->len - 1] = '\0';

        g_paste_client_add (client, data->str, &error);

        g_string_free (data, TRUE);
    }
    else
    {
        switch (argc)
        {
        case 1:
            show_history (client, FALSE, FALSE, &error);
            break;
        case 2:
            arg1 = argv[1];
            if (is_help (arg1))
            {
                show_help (argv[0]);
            }
            else if (g_strcmp0 (arg1, "start") == 0 ||
                     g_strcmp0 (arg1, "d") == 0 ||
                     g_strcmp0 (arg1, "daemon") == 0)
            {
                g_paste_client_track (client, TRUE, &error);
            }
            else if (g_strcmp0 (arg1, "stop") == 0 ||
                     g_strcmp0 (arg1, "q") == 0 ||
                     g_strcmp0 (arg1, "quit") == 0)
            {
                g_paste_client_track (client, FALSE, &error);
            }
            else if (g_strcmp0 (arg1, "e") == 0 ||
                     g_strcmp0 (arg1, "empty") == 0)
            {
                g_paste_client_empty (client, &error);
            }
            else if (g_strcmp0 (arg1, "v") == 0 ||
                     g_strcmp0 (arg1, "version") == 0 ||
                     g_strcmp0 (arg1, "-v") == 0 ||
                     g_strcmp0 (arg1, "--version") == 0)
            {
                printf ("%s\n", PACKAGE_STRING);
            }
#ifdef ENABLE_APPLET
            else if (g_strcmp0 (arg1, "applet") == 0)
            {
                g_spawn_command_line_async (PKGLIBEXECDIR "/gpaste-applet", &error);
                if (error)
                {
                    fprintf (stderr, _("Couldn't spawn gpaste-applet.\n"));
                    g_clear_error (&error);
                    status = EXIT_FAILURE;
                }
            }
#endif
            else if (g_strcmp0 (arg1, "s") == 0 ||
                     g_strcmp0 (arg1, "settings") == 0 ||
                     g_strcmp0 (arg1, "p") == 0 ||
                     g_strcmp0 (arg1, "preferences") == 0)
            {
                execl (PKGLIBEXECDIR "/gpaste-settings", "GPaste-Settings", NULL);
            }
            else if (g_strcmp0 (arg1, "dr") == 0 ||
                     g_strcmp0 (arg1, "daemon-reexec") == 0)
            {
                g_paste_client_reexecute (client, &error);
                if (error && error->code == G_DBUS_ERROR_NO_REPLY)
                {
                    printf (_("Successfully reexecuted the daemon\n"));
                }
            }
            else if (g_strcmp0 (arg1, "h") == 0 ||
                     g_strcmp0 (arg1, "history") == 0)
            {
                show_history (client, FALSE, FALSE, &error);
            }
            else if (g_strcmp0 (arg1, "rh") == 0 ||
                     g_strcmp0 (arg1, "raw-history") == 0)
            {
                show_history (client, TRUE, FALSE, &error);
            }
            else if (g_strcmp0 (arg1, "zh") == 0 ||
                     g_strcmp0 (arg1, "zero-history") == 0)
            {
                show_history (client, FALSE, TRUE, &error);
            }
            else if (g_strcmp0 (arg1, "lh") == 0 ||
                     g_strcmp0 (arg1, "list-histories") == 0)
            {
                gchar **histories = g_paste_client_list_histories (client, &error);
                if (!error)
                {
                    for (gchar **h = histories; *h; ++h)
                        printf ("%s\n", *h);
                    g_strfreev (histories);
                }
            }
            else
            {
                show_help (argv[0]);
                status = EXIT_FAILURE;
            }
            break;
        case 3:
            arg1 = argv[1];
            arg2 = argv[2];
            if (g_strcmp0 (arg1, "bh") == 0||
                g_strcmp0 (arg1, "backup-history") == 0)
            {
                g_paste_client_backup_history (client, arg2, &error);
            }
            else if (g_strcmp0 (arg1, "sh") == 0 ||
                     g_strcmp0 (arg1, "switch-history") == 0)
            {
                g_paste_client_switch_history (client, arg2, &error);
            }
            else if (g_strcmp0 (arg1, "dh") == 0 ||
                     g_strcmp0 (arg1, "delete-history") == 0)
            {
                g_paste_client_delete_history (client, arg2, &error);
            }
            else if (g_strcmp0 (arg1, "a") == 0 ||
                     g_strcmp0 (arg1, "add") == 0)
            {
                g_paste_client_add (client, arg2, &error);
            }
            else if (g_strcmp0 (arg1, "g") == 0||
                     g_strcmp0 (arg1, "get") == 0)
            {
                printf ("%s", g_paste_client_get_element (client, g_ascii_strtoull (arg2, NULL, 0), &error));
            }
            else if (g_strcmp0 (arg1, "s") == 0 ||
                     g_strcmp0 (arg1, "set") == 0 ||
                     g_strcmp0 (arg1, "select") == 0)
            {
                g_paste_client_select (client, g_ascii_strtoull (arg2, NULL, 0), &error);
            }
            else if (g_strcmp0 (arg1, "d") == 0 ||
                     g_strcmp0 (arg1, "delete") == 0)
            {
                g_paste_client_delete (client, g_ascii_strtoull (arg2, NULL, 0), &error);
            }
            else if (g_strcmp0 (arg1, "f") == 0 ||
                     g_strcmp0 (arg1, "file") == 0)
            {
               gchar *content = NULL;

               if (g_file_get_contents (arg2,
                                        &content,
                                        NULL, /* length */
                                        &error))
               {
                   g_paste_client_add (client, content, &error);
                   g_free (content);
               }
               else
               {
                   fprintf (stderr, _("Could not read file: %s\n"), arg2);
                   g_clear_error (&error);
                   status = EXIT_FAILURE;
               }
            }
            else
            {
                show_help (argv[0]);
                status = EXIT_FAILURE;
            }
            break;
        default:
            show_help (argv[0]);
            status = EXIT_FAILURE;
            break;
        }
    }

    if (error)
    {
        g_error_free (error);
        failure_exit ();
    }

    g_object_unref (client);

    return status;
}
Ejemplo n.º 7
0
Archivo: lxcfs.c Proyecto: Blub/lxcfs
int main(int argc, char *argv[])
{
	int ret = -1, pidfd;
	char *pidfile = NULL, *v = NULL;
	size_t pidfile_len;
	/*
	 * what we pass to fuse_main is:
	 * argv[0] -s -f -o allow_other,directio argv[1] NULL
	 */
	int nargs = 5, cnt = 0;
	char *newargv[6];

	/* accomodate older init scripts */
	swallow_arg(&argc, argv, "-s");
	swallow_arg(&argc, argv, "-f");
	if (swallow_option(&argc, argv, "-o", &v)) {
		if (strcmp(v, "allow_other") != 0) {
			fprintf(stderr, "Warning: unexpected fuse option %s\n", v);
			exit(1);
		}
		free(v);
		v = NULL;
	}
	if (swallow_option(&argc, argv, "-p", &v))
		pidfile = v;

	if (argc == 2  && strcmp(argv[1], "--version") == 0) {
		fprintf(stderr, "%s\n", VERSION);
		exit(0);
	}
	if (argc != 2 || is_help(argv[1]))
		usage(argv[0]);

	do_reload();
	signal(SIGUSR1, reload_handler);

	newargv[cnt++] = argv[0];
	newargv[cnt++] = "-f";
	newargv[cnt++] = "-o";
	newargv[cnt++] = "allow_other,direct_io,entry_timeout=0.5,attr_timeout=0.5";
	newargv[cnt++] = argv[1];
	newargv[cnt++] = NULL;

	if (!cgfs_setup_controllers())
		goto out;

	if (!pidfile) {
		pidfile_len = strlen(RUNTIME_PATH) + strlen("/lxcfs.pid") + 1;
		pidfile = alloca(pidfile_len);
		snprintf(pidfile, pidfile_len, "%s/lxcfs.pid", RUNTIME_PATH);
	}
	if ((pidfd = set_pidfile(pidfile)) < 0)
		goto out;

	ret = fuse_main(nargs, newargv, &lxcfs_ops, NULL);

	dlclose(dlopen_handle);
	unlink(pidfile);
	close(pidfd);

out:
	return ret;
}
Ejemplo n.º 8
0
gint
main (gint argc, gchar *argv[])
{
    G_PASTE_INIT_GETTEXT ();

    if (argc > 1)
    {
        if (is_help (argv[1]))
        {
            show_help (argv[0]);
            return EXIT_SUCCESS;
        }
        else if (is_version (argv[1]))
        {
            show_version ();
            return EXIT_SUCCESS;
        }
    }

    int status = EXIT_SUCCESS;

    G_PASTE_CLEANUP_ERROR_FREE GError *error = NULL;
    G_PASTE_CLEANUP_UNREF GPasteClient *client = g_paste_client_new_sync (&error);

    if (!client)
        failure_exit (error);

    if (!isatty (fileno (stdin)) && argc == 1)
    {
        /* We are being piped */
        G_PASTE_CLEANUP_STRING_FREE GString *data = g_string_new ("");
        gchar c;

        while ((c = fgetc (stdin)) != EOF)
            data = g_string_append_c (data, c);

        data->str[data->len - 1] = '\0';

        g_paste_client_add_sync (client, data->str, &error);
    }
    else
    {
        const gchar *arg1, *arg2, *arg3;
        switch (argc)
        {
        case 1:
            show_history (client, FALSE, FALSE, &error);
            break;
        case 2:
            arg1 = argv[1];
            if (!g_strcmp0 (arg1, "about"))
                g_paste_client_about_sync (client, &error);
            else if (!g_strcmp0 (arg1, "dr") ||
                     !g_strcmp0 (arg1, "daemon-reexec"))
            {
                g_paste_client_reexecute_sync (client, &error);
                if (error && error->code == G_DBUS_ERROR_NO_REPLY)
                {
                    printf (_("Successfully reexecuted the daemon\n"));
                    return EXIT_SUCCESS;
                }
            }
            else if (!g_strcmp0 (arg1, "dv") ||
                     !g_strcmp0 (arg1, "daemon-version"))
            {
                G_PASTE_CLEANUP_FREE gchar *v = g_paste_client_get_version (client);
                printf ("%s\n", v);
            }
            else if (!g_strcmp0 (arg1, "e") ||
                     !g_strcmp0 (arg1, "empty"))
            {
                g_paste_client_empty_sync (client, &error);
            }
            else if (!g_strcmp0 (arg1, "h") ||
                     !g_strcmp0 (arg1, "history"))
            {
                show_history (client, FALSE, FALSE, &error);
            }
            else if (!g_strcmp0 (arg1, "hs") ||
                     !g_strcmp0 (arg1, "history-size"))
            {
                guint32 size = g_paste_client_get_history_size_sync (client, &error);
                if (!error)
                    printf ("%u\n", size);
            }
            else if (!g_strcmp0 (arg1, "lh") ||
                     !g_strcmp0 (arg1, "list-histories"))
            {
                G_PASTE_CLEANUP_STRFREEV GStrv histories = g_paste_client_list_histories_sync (client, &error);
                if (!error)
                {
                    for (GStrv h = histories; *h; ++h)
                        printf ("%s\n", *h);
                }
            }
            else if (!g_strcmp0 (arg1, "rh") ||
                     !g_strcmp0 (arg1, "raw-history"))
            {
                show_history (client, TRUE, FALSE, &error);
            }
            else if (!g_strcmp0 (arg1, "s")        ||
                     !g_strcmp0 (arg1, "settings") ||
                     !g_strcmp0 (arg1, "p")        ||
                     !g_strcmp0 (arg1, "preferences"))
            {
                status = spawn ("Settings", &error);
            }
            else if (!g_strcmp0 (arg1, "start") ||
                     !g_strcmp0 (arg1, "d")     ||
                     !g_strcmp0 (arg1, "daemon"))
            {
                g_paste_client_track_sync (client, TRUE, &error);
            }
            else if (!g_strcmp0 (arg1, "stop") ||
                     !g_strcmp0 (arg1, "q")    ||
                     !g_strcmp0 (arg1, "quit"))
            {
                g_paste_client_track_sync (client, FALSE, &error);
            }
            else if (!g_strcmp0 (arg1, "zh") ||
                     !g_strcmp0 (arg1, "zero-history"))
            {
                show_history (client, FALSE, TRUE, &error);
            }
#if G_PASTE_CONFIG_ENABLE_APPLET
            else if (!g_strcmp0 (arg1, "applet"))
            {
                status = spawn ("Applet", &error);
            }
#endif
#if G_PASTE_CONFIG_ENABLE_UNITY
            else if (!g_strcmp0 (arg1, "app-indicator"))
            {
                status = spawn ("AppIndicator", &error);
            }
#endif
            else
            {
                show_help (argv[0]);
                status = EXIT_FAILURE;
            }
            break;
        case 3:
            arg1 = argv[1];
            arg2 = argv[2];
            if (!g_strcmp0 (arg1, "a") ||
                !g_strcmp0 (arg1, "add"))
            {
                g_paste_client_add_sync (client, arg2, &error);
            }
            else if (!g_strcmp0 (arg1, "bh") ||
                     !g_strcmp0 (arg1, "backup-history"))
            {
                g_paste_client_backup_history_sync (client, arg2, &error);
            }
            else if (!g_strcmp0 (arg1, "d")      ||
                     !g_strcmp0 (arg1, "del")    ||
                     !g_strcmp0 (arg1, "delete") ||
                     !g_strcmp0 (arg1, "rm")     ||
                     !g_strcmp0 (arg1, "remove"))
            {
                g_paste_client_delete_sync (client, _strtoull (arg2), &error);
            }
            else if (!g_strcmp0 (arg1, "dp") ||
                     !g_strcmp0 (arg1, "delete-password"))
            {
                g_paste_client_delete_password_sync (client, arg2, &error);
            }
            else if (!g_strcmp0 (arg1, "dh") ||
                     !g_strcmp0 (arg1, "delete-history"))
            {
                g_paste_client_delete_history_sync (client, arg2, &error);
            }
            else if (!g_strcmp0 (arg1, "f") ||
                     !g_strcmp0 (arg1, "file"))
            {
                g_paste_client_add_file_sync (client, arg2, &error);
            }
            else if (!g_strcmp0 (arg1, "g") ||
                     !g_strcmp0 (arg1, "get"))
            {
                printf ("%s", g_paste_client_get_element_sync (client, _strtoull (arg2), &error));
            }
            else if (!g_strcmp0 (arg1, "gr") ||
                     !g_strcmp0 (arg1, "get-raw"))
            {
                printf ("%s", g_paste_client_get_raw_element_sync (client, _strtoull (arg2), &error));
            }
            else if (!g_strcmp0 (arg1, "s")   ||
                     !g_strcmp0 (arg1, "set") ||
                     !g_strcmp0 (arg1, "select"))
            {
                g_paste_client_select_sync (client, _strtoull (arg2), &error);
            }
            else if (!g_strcmp0 (arg1, "sh") ||
                     !g_strcmp0 (arg1, "switch-history"))
            {
                g_paste_client_switch_history_sync (client, arg2, &error);
            }
            else
            {
                show_help (argv[0]);
                status = EXIT_FAILURE;
            }
            break;
        case 4:
            arg1 = argv[1];
            arg2 = argv[2];
            arg3 = argv[3];
            if (!g_strcmp0 (arg1, "ap") ||
                !g_strcmp0 (arg1, "add-password"))
            {
                g_paste_client_add_password_sync (client, arg2, arg3, &error);
            }
            else if (!g_strcmp0 (arg1, "rp") ||
                     !g_strcmp0 (arg1, "rename-password"))
            {
                g_paste_client_rename_password_sync (client, arg2, arg3, &error);
            }
            else if (!g_strcmp0 (arg1, "sp")   ||
                     !g_strcmp0 (arg1, "set-password"))
            {
                g_paste_client_set_password_sync (client, _strtoull (arg2), arg3, &error);
            }
            else
            {
                show_help (argv[0]);
                status = EXIT_FAILURE;
            }
            break;
        default:
            show_help (argv[0]);
            status = EXIT_FAILURE;
            break;
        }
    }

    if (error)
        failure_exit (error);

    return status;
}
Ejemplo n.º 9
0
gint
main (gint argc, gchar *argv[])
{
    G_PASTE_INIT_GETTEXT ();

    if (argc > 1)
    {
        if (is_help (argv[1]))
        {
            show_help (argv[0]);
            return EXIT_SUCCESS;
        }
        else if (is_version (argv[1]))
        {
            show_version ();
            return EXIT_SUCCESS;
        }
    }

    int status = EXIT_SUCCESS;

    G_PASTE_CLEANUP_ERROR_FREE GError *error = NULL;
    G_PASTE_CLEANUP_UNREF GPasteClient *client = g_paste_client_new_sync (&error);

    if (!client)
        failure_exit (error);

    if (!isatty (fileno (stdin)))
    {
        /* We are being piped */
        G_PASTE_CLEANUP_STRING_FREE GString *data = g_string_new ("");
        gchar c;

        while ((c = fgetc (stdin)) != EOF)
            data = g_string_append_c (data, c);

        data->str[data->len - 1] = '\0';

        g_paste_client_add_sync (client, data->str, &error);
    }
    else
    {
        const gchar *arg1, *arg2;
        switch (argc)
        {
        case 1:
            show_history (client, FALSE, FALSE, &error);
            break;
        case 2:
            arg1 = argv[1];
            if (!g_strcmp0 (arg1, "start") ||
                !g_strcmp0 (arg1, "d") ||
                !g_strcmp0 (arg1, "daemon"))
            {
                g_paste_client_track_sync (client, TRUE, &error);
            }
            else if (!g_strcmp0 (arg1, "stop") ||
                     !g_strcmp0 (arg1, "q") ||
                     !g_strcmp0 (arg1, "quit"))
            {
                g_paste_client_track_sync (client, FALSE, &error);
            }
            else if (!g_strcmp0 (arg1, "e") ||
                     !g_strcmp0 (arg1, "empty"))
            {
                g_paste_client_empty_sync (client, &error);
            }
#if G_PASTE_CONFIG_ENABLE_APPLET
            else if (!g_strcmp0 (arg1, "applet"))
            {
                g_spawn_command_line_async (PKGLIBEXECDIR "/gpaste-applet", &error);
                if (error)
                {
                    g_critical ("%s: %s", _("Couldn't spawn gpaste-applet.\n"), error->message);
                    g_clear_error (&error);
                    status = EXIT_FAILURE;
                }
            }
#endif
            else if (!g_strcmp0 (arg1, "s") ||
                     !g_strcmp0 (arg1, "settings") ||
                     !g_strcmp0 (arg1, "p") ||
                     !g_strcmp0 (arg1, "preferences"))
            {
                execl (PKGLIBEXECDIR "/gpaste-settings", "GPaste-Settings", NULL);
            }
            else if (!g_strcmp0 (arg1, "dr") ||
                     !g_strcmp0 (arg1, "daemon-reexec"))
            {
                g_paste_client_reexecute_sync (client, &error);
                if (error && error->code == G_DBUS_ERROR_NO_REPLY)
                {
                    printf (_("Successfully reexecuted the daemon\n"));
                    return EXIT_SUCCESS;
                }
            }
            else if (!g_strcmp0 (arg1, "h") ||
                     !g_strcmp0 (arg1, "history"))
            {
                show_history (client, FALSE, FALSE, &error);
            }
            else if (!g_strcmp0 (arg1, "hs") ||
                     !g_strcmp0 (arg1, "history-size"))
            {
                guint32 size = g_paste_client_get_history_size_sync (client, &error);
                if (!error)
                    printf ("%u\n", size);
            }
            else if (!g_strcmp0 (arg1, "rh") ||
                     !g_strcmp0 (arg1, "raw-history"))
            {
                show_history (client, TRUE, FALSE, &error);
            }
            else if (!g_strcmp0 (arg1, "zh") ||
                     !g_strcmp0 (arg1, "zero-history"))
            {
                show_history (client, FALSE, TRUE, &error);
            }
            else if (!g_strcmp0 (arg1, "lh") ||
                     !g_strcmp0 (arg1, "list-histories"))
            {
                G_PASTE_CLEANUP_STRFREEV GStrv histories = g_paste_client_list_histories_sync (client, &error);
                if (!error)
                {
                    for (GStrv h = histories; *h; ++h)
                        printf ("%s\n", *h);
                }
            }
            else if (!g_strcmp0 (argv[1], "about"))
            {
                g_paste_client_about_sync (client, &error);
            }
            else
            {
                show_help (argv[0]);
                status = EXIT_FAILURE;
            }
            break;
        case 3:
            arg1 = argv[1];
            arg2 = argv[2];
            if (!g_strcmp0 (arg1, "bh")||
                !g_strcmp0 (arg1, "backup-history"))
            {
                g_paste_client_backup_history_sync (client, arg2, &error);
            }
            else if (!g_strcmp0 (arg1, "sh") ||
                     !g_strcmp0 (arg1, "switch-history"))
            {
                g_paste_client_switch_history_sync (client, arg2, &error);
            }
            else if (!g_strcmp0 (arg1, "dh") ||
                     !g_strcmp0 (arg1, "delete-history"))
            {
                g_paste_client_delete_history_sync (client, arg2, &error);
            }
            else if (!g_strcmp0 (arg1, "a") ||
                     !g_strcmp0 (arg1, "add"))
            {
                g_paste_client_add_sync (client, arg2, &error);
            }
            else if (!g_strcmp0 (arg1, "g")||
                     !g_strcmp0 (arg1, "get"))
            {
                printf ("%s", g_paste_client_get_element_sync (client, g_ascii_strtoull (arg2, NULL, 0), &error));
            }
            else if (!g_strcmp0 (arg1, "s") ||
                     !g_strcmp0 (arg1, "set") ||
                     !g_strcmp0 (arg1, "select"))
            {
                g_paste_client_select_sync (client, g_ascii_strtoull (arg2, NULL, 0), &error);
            }
            else if (!g_strcmp0 (arg1, "d") ||
                     !g_strcmp0 (arg1, "delete"))
            {
                g_paste_client_delete_sync (client, g_ascii_strtoull (arg2, NULL, 0), &error);
            }
            else if (!g_strcmp0 (arg1, "f") ||
                     !g_strcmp0 (arg1, "file"))
            {
                g_paste_client_add_file_sync (client, arg2, &error);
            }
            else
            {
                show_help (argv[0]);
                status = EXIT_FAILURE;
            }
            break;
        default:
            show_help (argv[0]);
            status = EXIT_FAILURE;
            break;
        }
    }

    if (error)
        failure_exit (error);

    return status;
}