forked from Imagelibrary/rtems
* libnetworking/rtems/tftp.h: Provide a decl to the TFTP file system opts table. * libnetworking/rtems/ftpfs.h: Provide a decl to the FTP file system opts table. * libmisc/Makefile.am: Add the mount command and supporting files. * libmisc/preinstall.am: Rebuilt. * libmisc/shell/cat_file.c, libmisc/shell/cmds.c, libmisc/shell/main_alias.c, libmisc/shell/main_cat.c, libmisc/shell/main_cd.c, libmisc/shell/main_chdir.c, libmisc/shell/main_chmod.c, libmisc/shell/main_chroot.c, libmisc/shell/main_cpuuse.c, libmisc/shell/main_date.c, libmisc/shell/main_dir.c, libmisc/shell/main_exit.c, libmisc/shell/main_help.c, libmisc/shell/main_id.c, libmisc/shell/main_logoff.c, libmisc/shell/main_ls.c, libmisc/shell/main_mallocdump.c, libmisc/shell/main_mdump.c, libmisc/shell/main_medit.c, libmisc/shell/main_mfill.c, libmisc/shell/main_mkdir.c, libmisc/shell/main_mmove.c, libmisc/shell/main_mwdump.c, libmisc/shell/main_pwd.c, libmisc/shell/main_rm.c, libmisc/shell/main_rmdir.c, libmisc/shell/main_stackuse.c, libmisc/shell/main_tty.c, libmisc/shell/main_umask.c, libmisc/shell/main_whoami.c, libmisc/shell/shell.c, libmisc/shell/shell_cmdset.c, libmisc/shell/shell_makeargs.c, libmisc/shell/str2int.c, libmisc/shell/write_file.c: Move all shell_* types, variables and functions to rtems_shell_* to avoid namespace clashes with applications. The is an RTEMS shell after all. * libmisc/shell/shell.h, libmisc/shell/internal.h, libmisc/shell/shellconfig.h: Move all shell_* types, variables and functions to rtems_shell_* to avoid namespace clashes with applications. Add the mount command supporting types. * libmisc/shell/main_mount.c, libmisc/shell/main_mount_ftp.c, libmisc/shell/main_mount_msdos.c, libmisc/shell/main_mount_nfs.c, libmisc/shell/main_mount_tftp.c: New.
96 lines
1.6 KiB
C
96 lines
1.6 KiB
C
/*
|
|
* Author: Fernando RUIZ CASAS
|
|
* Work: fernando.ruiz@ctv.es
|
|
* Home: correo@fernando-ruiz.com
|
|
*
|
|
* The license and distribution terms for this file may be
|
|
* found in the file LICENSE in this distribution or at
|
|
* http://www.rtems.com/license/LICENSE.
|
|
*
|
|
* $Id$
|
|
*/
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
#include "config.h"
|
|
#endif
|
|
|
|
|
|
#include <rtems/shell.h>
|
|
#include "internal.h"
|
|
|
|
/*
|
|
* str to int "0xaffe" "0b010010" "0123" "192939"
|
|
*/
|
|
int rtems_shell_str2int(char * s) {
|
|
int sign=1;
|
|
int base=10;
|
|
int value=0;
|
|
int digit;
|
|
|
|
if (!s) return 0;
|
|
if (*s) {
|
|
if (*s=='-') {
|
|
sign=-1;
|
|
s++;
|
|
if (!*s) return 0;
|
|
}
|
|
if (*s=='0') {
|
|
s++;
|
|
switch(*s) {
|
|
case 'x':
|
|
case 'X':
|
|
s++;
|
|
base=16;
|
|
break;
|
|
case 'b':
|
|
case 'B':
|
|
s++;
|
|
base=2;
|
|
break;
|
|
default:
|
|
base=8;
|
|
break;
|
|
}
|
|
}
|
|
while (*s) {
|
|
switch(*s) {
|
|
case '0':
|
|
case '1':
|
|
case '2':
|
|
case '3':
|
|
case '4':
|
|
case '5':
|
|
case '6':
|
|
case '7':
|
|
case '8':
|
|
case '9':
|
|
digit=*s-'0';
|
|
break;
|
|
case 'A':
|
|
case 'B':
|
|
case 'C':
|
|
case 'D':
|
|
case 'E':
|
|
case 'F':
|
|
digit=*s-'A'+10;
|
|
break;
|
|
case 'a':
|
|
case 'b':
|
|
case 'c':
|
|
case 'd':
|
|
case 'e':
|
|
case 'f':
|
|
digit=*s-'a'+10;
|
|
break;
|
|
default:
|
|
return value*sign;
|
|
}
|
|
if (digit>base)
|
|
return value*sign;
|
|
value=value*base+digit;
|
|
s++;
|
|
}
|
|
}
|
|
return value*sign;
|
|
}
|