Update
[gdb.git] / gdb / mi / mi-cmd-target.c
blob8ca4defbd2e9f1012c52b9f6cc2277b5640cb6c8
1 /* MI Command Set - target commands.
2 Copyright (C) 2007, 2008 Free Software Foundation, Inc.
4 This file is part of GDB.
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
11 This program 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
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>. */
19 #include "defs.h"
20 #include "mi-cmds.h"
21 #include "mi-getopt.h"
22 #include "remote.h"
24 /* Get a file from the target. */
26 enum mi_cmd_result
27 mi_cmd_target_file_get (char *command, char **argv, int argc)
29 int optind = 0;
30 char *optarg;
31 const char *remote_file, *local_file;
32 static struct mi_opt opts[] =
34 { 0, 0, 0 }
36 static const char *prefix = "mi_cmd_target_file_get";
38 if (mi_getopt (prefix, argc, argv, opts, &optind, &optarg) != -1
39 || optind != argc - 2)
40 error (_("mi_cmd_target_file_get: Usage: REMOTE_FILE LOCAL_FILE"));
42 remote_file = argv[optind];
43 local_file = argv[optind + 1];
45 remote_file_get (remote_file, local_file, 0);
47 return MI_CMD_DONE;
50 /* Send a file to the target. */
52 enum mi_cmd_result
53 mi_cmd_target_file_put (char *command, char **argv, int argc)
55 int optind = 0;
56 char *optarg;
57 const char *remote_file, *local_file;
58 static struct mi_opt opts[] =
60 { 0, 0, 0 }
62 static const char *prefix = "mi_cmd_target_file_put";
64 if (mi_getopt (prefix, argc, argv, opts, &optind, &optarg) != -1
65 || optind != argc - 2)
66 error (_("mi_cmd_target_file_put: Usage: LOCAL_FILE REMOTE_FILE"));
68 local_file = argv[optind];
69 remote_file = argv[optind + 1];
71 remote_file_put (local_file, remote_file, 0);
73 return MI_CMD_DONE;
76 /* Delete a file on the target. */
78 enum mi_cmd_result
79 mi_cmd_target_file_delete (char *command, char **argv, int argc)
81 int optind = 0;
82 char *optarg;
83 const char *remote_file, *local_file;
84 static struct mi_opt opts[] =
86 { 0, 0, 0 }
88 static const char *prefix = "mi_cmd_target_file_delete";
90 if (mi_getopt (prefix, argc, argv, opts, &optind, &optarg) != -1
91 || optind != argc - 1)
92 error (_("mi_cmd_target_file_delete: Usage: REMOTE_FILE"));
94 remote_file = argv[optind];
96 remote_file_delete (remote_file, 0);
98 return MI_CMD_DONE;