source: rtems/cpukit/libmisc/shell/main_medit.c @ 0893220

4.104.115
Last change on this file since 0893220 was 48751ab, checked in by Joel Sherrill <joel.sherrill@…>, on 07/23/09 at 14:32:34

2009-07-23 Joel Sherrill <joel.sherrill@…>

  • libmisc/Makefile.am, libmisc/shell/main_chmod.c, libmisc/shell/main_mdump.c, libmisc/shell/main_medit.c, libmisc/shell/main_mfill.c, libmisc/shell/main_mmove.c, libmisc/shell/main_msdosfmt.c, libmisc/shell/main_mwdump.c, libmisc/shell/main_sleep.c, libmisc/shell/main_umask.c, libmisc/shell/shell_script.c, libmisc/stringto/stringto.h, libmisc/stringto/stringto_template.h: Convert return type from bool to rtems_status_code and add rtems_string_to_pointer. Perform associated clean up and changes for return type change.
  • libmisc/stringto/stringtopointer.c: New file.
  • Property mode set to 100644
File size: 1.7 KB
Line 
1/*
2 *  MEDIT 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
28extern int rtems_shell_main_mdump(int, char *);
29
30int rtems_shell_main_medit(
31  int   argc,
32  char *argv[]
33)
34{
35  unsigned char *pb;
36  void          *tmpp;
37  int            n;
38  int            i;
39
40  if ( argc < 3 ) {
41    fprintf(stderr,"%s: too few arguments\n", argv[0]);
42    return -1;
43  }
44
45  /*
46   *  Convert arguments into numbers
47   */
48  if ( rtems_string_to_pointer(argv[1], &tmpp, NULL) ) {
49    printf( "Address argument (%s) is not a number\n", argv[1] );
50    return -1;
51  }
52  pb = tmpp;
53
54  /*
55   * Now edit the memory
56   */
57  n = 0;
58  for (i=2 ; i<=argc ; i++) {
59    unsigned char tmpc;
60
61    if ( rtems_string_to_unsigned_char(argv[i], &tmpc, NULL, 0) ) {
62      printf( "Value (%s) is not a number\n", argv[i] );
63      continue;
64    }
65
66    pb[n++] = tmpc;
67  }
68
69  return 0;
70}
71
72rtems_shell_cmd_t rtems_shell_MEDIT_Command = {
73  "medit",                                      /* name */
74  "medit address value1 [value2 ...]",          /* usage */
75  "mem",                                        /* topic */
76  rtems_shell_main_medit,                       /* command */
77  NULL,                                         /* alias */
78  NULL                                          /* next */
79};
Note: See TracBrowser for help on using the repository browser.