OLD | NEW |
1 /* MI Command Set - target commands. | 1 /* MI Command Set - target commands. |
2 Copyright (C) 2007-2012 Free Software Foundation, Inc. | 2 Copyright (C) 2007-2012 Free Software Foundation, Inc. |
3 | 3 |
4 This file is part of GDB. | 4 This file is part of GDB. |
5 | 5 |
6 This program is free software; you can redistribute it and/or modify | 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 | 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 | 8 the Free Software Foundation; either version 3 of the License, or |
9 (at your option) any later version. | 9 (at your option) any later version. |
10 | 10 |
11 This program is distributed in the hope that it will be useful, | 11 This program is distributed in the hope that it will be useful, |
12 but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 GNU General Public License for more details. | 14 GNU General Public License for more details. |
15 | 15 |
16 You should have received a copy of the GNU General Public License | 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/>. */ | 17 along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
18 | 18 |
19 #include "defs.h" | 19 #include "defs.h" |
20 #include "mi-cmds.h" | 20 #include "mi-cmds.h" |
21 #include "mi-getopt.h" | 21 #include "mi-getopt.h" |
22 #include "remote.h" | 22 #include "remote.h" |
23 | 23 |
24 /* Get a file from the target. */ | 24 /* Get a file from the target. */ |
25 | 25 |
26 void | 26 void |
27 mi_cmd_target_file_get (char *command, char **argv, int argc) | 27 mi_cmd_target_file_get (char *command, char **argv, int argc) |
28 { | 28 { |
29 int optind = 0; | 29 int oind = 0; |
30 char *optarg; | 30 char *oarg; |
31 const char *remote_file, *local_file; | 31 const char *remote_file, *local_file; |
32 static const struct mi_opt opts[] = | 32 static const struct mi_opt opts[] = |
33 { | 33 { |
34 { 0, 0, 0 } | 34 { 0, 0, 0 } |
35 }; | 35 }; |
36 static const char prefix[] = "-target-file-get"; | 36 static const char prefix[] = "-target-file-get"; |
37 | 37 |
38 if (mi_getopt (prefix, argc, argv, opts, &optind, &optarg) != -1 | 38 if (mi_getopt (prefix, argc, argv, opts, &oind, &oarg) != -1 |
39 || optind != argc - 2) | 39 || oind != argc - 2) |
40 error (_("-target-file-get: Usage: REMOTE_FILE LOCAL_FILE")); | 40 error (_("-target-file-get: Usage: REMOTE_FILE LOCAL_FILE")); |
41 | 41 |
42 remote_file = argv[optind]; | 42 remote_file = argv[oind]; |
43 local_file = argv[optind + 1]; | 43 local_file = argv[oind + 1]; |
44 | 44 |
45 remote_file_get (remote_file, local_file, 0); | 45 remote_file_get (remote_file, local_file, 0); |
46 } | 46 } |
47 | 47 |
48 /* Send a file to the target. */ | 48 /* Send a file to the target. */ |
49 | 49 |
50 void | 50 void |
51 mi_cmd_target_file_put (char *command, char **argv, int argc) | 51 mi_cmd_target_file_put (char *command, char **argv, int argc) |
52 { | 52 { |
53 int optind = 0; | 53 int oind = 0; |
54 char *optarg; | 54 char *oarg; |
55 const char *remote_file, *local_file; | 55 const char *remote_file, *local_file; |
56 static const struct mi_opt opts[] = | 56 static const struct mi_opt opts[] = |
57 { | 57 { |
58 { 0, 0, 0 } | 58 { 0, 0, 0 } |
59 }; | 59 }; |
60 static const char prefix[] = "-target-file-put"; | 60 static const char prefix[] = "-target-file-put"; |
61 | 61 |
62 if (mi_getopt (prefix, argc, argv, opts, &optind, &optarg) != -1 | 62 if (mi_getopt (prefix, argc, argv, opts, &oind, &oarg) != -1 |
63 || optind != argc - 2) | 63 || oind != argc - 2) |
64 error (_("-target-file-put: Usage: LOCAL_FILE REMOTE_FILE")); | 64 error (_("-target-file-put: Usage: LOCAL_FILE REMOTE_FILE")); |
65 | 65 |
66 local_file = argv[optind]; | 66 local_file = argv[oind]; |
67 remote_file = argv[optind + 1]; | 67 remote_file = argv[oind + 1]; |
68 | 68 |
69 remote_file_put (local_file, remote_file, 0); | 69 remote_file_put (local_file, remote_file, 0); |
70 } | 70 } |
71 | 71 |
72 /* Delete a file on the target. */ | 72 /* Delete a file on the target. */ |
73 | 73 |
74 void | 74 void |
75 mi_cmd_target_file_delete (char *command, char **argv, int argc) | 75 mi_cmd_target_file_delete (char *command, char **argv, int argc) |
76 { | 76 { |
77 int optind = 0; | 77 int oind = 0; |
78 char *optarg; | 78 char *oarg; |
79 const char *remote_file; | 79 const char *remote_file; |
80 static const struct mi_opt opts[] = | 80 static const struct mi_opt opts[] = |
81 { | 81 { |
82 { 0, 0, 0 } | 82 { 0, 0, 0 } |
83 }; | 83 }; |
84 static const char prefix[] = "-target-file-delete"; | 84 static const char prefix[] = "-target-file-delete"; |
85 | 85 |
86 if (mi_getopt (prefix, argc, argv, opts, &optind, &optarg) != -1 | 86 if (mi_getopt (prefix, argc, argv, opts, &oind, &oarg) != -1 |
87 || optind != argc - 1) | 87 || oind != argc - 1) |
88 error (_("-target-file-delete: Usage: REMOTE_FILE")); | 88 error (_("-target-file-delete: Usage: REMOTE_FILE")); |
89 | 89 |
90 remote_file = argv[optind]; | 90 remote_file = argv[oind]; |
91 | 91 |
92 remote_file_delete (remote_file, 0); | 92 remote_file_delete (remote_file, 0); |
93 } | 93 } |
94 | 94 |
OLD | NEW |