1 | /* |
---|
2 | * MMOVE Shell Command Implmentation |
---|
3 | * |
---|
4 | * Author: Fernando RUIZ CASAS |
---|
5 | * Work: fernando.ruiz@ctv.es |
---|
6 | * Home: correo@fernando-ruiz.com |
---|
7 | * |
---|
8 | * The license and distribution terms for this file may be |
---|
9 | * found in the file LICENSE in this distribution or at |
---|
10 | * http://www.rtems.com/license/LICENSE. |
---|
11 | * |
---|
12 | * $Id$ |
---|
13 | */ |
---|
14 | |
---|
15 | #ifdef HAVE_CONFIG_H |
---|
16 | #include "config.h" |
---|
17 | #endif |
---|
18 | |
---|
19 | #include <ctype.h> |
---|
20 | #include <stdio.h> |
---|
21 | #include <string.h> |
---|
22 | |
---|
23 | #include <rtems.h> |
---|
24 | #include <rtems/shell.h> |
---|
25 | #include <rtems/stringto.h> |
---|
26 | #include "internal.h" |
---|
27 | |
---|
28 | static int rtems_shell_main_mmove( |
---|
29 | int argc, |
---|
30 | char *argv[] |
---|
31 | ) |
---|
32 | { |
---|
33 | unsigned long tmp; |
---|
34 | void *src; |
---|
35 | void *dst; |
---|
36 | size_t length; |
---|
37 | |
---|
38 | if ( argc < 4 ) { |
---|
39 | fprintf(stderr,"%s: too few arguments\n", argv[0]); |
---|
40 | return -1; |
---|
41 | } |
---|
42 | |
---|
43 | /* |
---|
44 | * Convert arguments into numbers |
---|
45 | */ |
---|
46 | if ( rtems_string_to_pointer(argv[1], &dst, NULL) ) { |
---|
47 | printf( "Destination argument (%s) is not a number\n", argv[1] ); |
---|
48 | return -1; |
---|
49 | } |
---|
50 | |
---|
51 | if ( rtems_string_to_pointer(argv[2], &src, NULL) ) { |
---|
52 | printf( "Source argument (%s) is not a number\n", argv[2] ); |
---|
53 | return -1; |
---|
54 | } |
---|
55 | |
---|
56 | if ( rtems_string_to_unsigned_long(argv[3], &tmp, NULL, 0) ) { |
---|
57 | printf( "Length argument (%s) is not a number\n", argv[3] ); |
---|
58 | return -1; |
---|
59 | } |
---|
60 | length = (size_t) tmp; |
---|
61 | |
---|
62 | /* |
---|
63 | * Now copy the memory. |
---|
64 | */ |
---|
65 | memcpy(dst, src, length); |
---|
66 | |
---|
67 | return 0; |
---|
68 | } |
---|
69 | |
---|
70 | rtems_shell_cmd_t rtems_shell_MMOVE_Command = { |
---|
71 | "mmove", /* name */ |
---|
72 | "mmove dst src length", /* usage */ |
---|
73 | "mem", /* topic */ |
---|
74 | rtems_shell_main_mmove, /* command */ |
---|
75 | NULL, /* alias */ |
---|
76 | NULL /* next */ |
---|
77 | }; |
---|