Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:24:19

0001 /**
0002  * @file
0003  * 
0004  * @brief MMOVE Shell Command Implmentation
0005  */
0006 
0007 /*
0008  * Copyright (c) 2001 Fernando Ruiz Casas <fruizcasas@gmail.com>
0009  *
0010  *  The license and distribution terms for this file may be
0011  *  found in the file LICENSE in this distribution or at
0012  *  http://www.rtems.org/license/LICENSE.
0013  */
0014 
0015 #ifdef HAVE_CONFIG_H
0016 #include "config.h"
0017 #endif
0018 
0019 #include <ctype.h>
0020 #include <stdio.h>
0021 #include <string.h>
0022 
0023 #include <rtems.h>
0024 #include <rtems/shell.h>
0025 #include <rtems/stringto.h>
0026 #include "internal.h"
0027 
0028 static int rtems_shell_main_mmove(
0029   int   argc,
0030   char *argv[]
0031 )
0032 {
0033   unsigned long  tmp;
0034   void          *src;
0035   void          *dst;
0036   size_t         length;
0037 
0038   if ( argc < 4 ) {
0039     fprintf(stderr,"%s: too few arguments\n", argv[0]);
0040     return -1;
0041    }
0042 
0043   /*
0044    *  Convert arguments into numbers
0045    */
0046   if ( rtems_string_to_pointer(argv[1], &dst, NULL) ) {
0047     printf( "Destination argument (%s) is not a number\n", argv[1] );
0048     return -1;
0049   }
0050 
0051   if ( rtems_string_to_pointer(argv[2], &src, NULL) ) {
0052     printf( "Source argument (%s) is not a number\n", argv[2] );
0053     return -1;
0054   }
0055 
0056   if ( rtems_string_to_unsigned_long(argv[3], &tmp, NULL, 0) ) {
0057     printf( "Length argument (%s) is not a number\n", argv[3] );
0058     return -1;
0059   }
0060   length = (size_t) tmp;
0061 
0062   /*
0063    *  Now copy the memory.
0064    */
0065   memmove(dst, src, length);
0066 
0067  return 0;
0068 }
0069 
0070 rtems_shell_cmd_t rtems_shell_MMOVE_Command = {
0071   "mmove",                                      /* name */
0072   "mmove dst src length",                       /* usage */
0073   "mem",                                        /* topic */
0074   rtems_shell_main_mmove,                       /* command */
0075   NULL,                                         /* alias */
0076   NULL                                          /* next */
0077 };