strerror() is big; don't use it unless requested
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@717 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
parent
34974400b3
commit
cbc6fcce57
@ -50,8 +50,20 @@
|
||||
* Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* This is the maximum number of arguments that will be accepted for a command */
|
||||
|
||||
#define NSH_MAX_ARGUMENTS 6
|
||||
|
||||
/* strerror() produces much nicer output but is, however, quite large and
|
||||
* will only be used if CONFIG_NSH_STRERROR is defined.
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_NSH_STRERROR
|
||||
# define NSH_ERRNO strerror(errno)
|
||||
#else
|
||||
# define NSH_ERRNO errno
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
@ -1,7 +1,7 @@
|
||||
/****************************************************************************
|
||||
* nsh_envcmds.c
|
||||
*
|
||||
* Copyright (C) 2007 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@ -14,7 +14,7 @@
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name Gregory Nutt nor the names of its contributors may be
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
@ -118,7 +118,7 @@ void cmd_set(FAR void *handle, int argc, char **argv)
|
||||
{
|
||||
if (setenv(argv[1], argv[2], TRUE) < 0)
|
||||
{
|
||||
nsh_output(handle, g_fmtcmdfailed, argv[0], "setenv", strerror(errno));
|
||||
nsh_output(handle, g_fmtcmdfailed, argv[0], "setenv", NSH_ERRNO);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@ -132,7 +132,7 @@ void cmd_unset(FAR void *handle, int argc, char **argv)
|
||||
{
|
||||
if (unsetenv(argv[1]) < 0)
|
||||
{
|
||||
nsh_output(handle, g_fmtcmdfailed, argv[0], "unsetenv", strerror(errno));
|
||||
nsh_output(handle, g_fmtcmdfailed, argv[0], "unsetenv", NSH_ERRNO);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -229,7 +229,7 @@ static int ls_handler(FAR void *handle, const char *dirpath, struct dirent *entr
|
||||
free(fullpath);
|
||||
if (ret != 0)
|
||||
{
|
||||
nsh_output(handle, g_fmtcmdfailed, "ls", "stat", strerror(errno));
|
||||
nsh_output(handle, g_fmtcmdfailed, "ls", "stat", NSH_ERRNO);
|
||||
return OK;
|
||||
}
|
||||
|
||||
@ -371,7 +371,7 @@ void cmd_cat(FAR void *handle, int argc, char **argv)
|
||||
int fd = open(argv[1], O_RDONLY);
|
||||
if (fd < 0)
|
||||
{
|
||||
nsh_output(handle, g_fmtcmdfailed, argv[0], "open", strerror(errno));
|
||||
nsh_output(handle, g_fmtcmdfailed, argv[0], "open", NSH_ERRNO);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -389,7 +389,7 @@ void cmd_cat(FAR void *handle, int argc, char **argv)
|
||||
|
||||
if (errno != EINTR)
|
||||
{
|
||||
nsh_output(handle, g_fmtcmdfailed, argv[0], "read", strerror(errno));
|
||||
nsh_output(handle, g_fmtcmdfailed, argv[0], "read", NSH_ERRNO);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -409,7 +409,7 @@ void cmd_cat(FAR void *handle, int argc, char **argv)
|
||||
|
||||
if (errno != EINTR)
|
||||
{
|
||||
nsh_output(handle, g_fmtcmdfailed, argv[0], "write", strerror(errno));
|
||||
nsh_output(handle, g_fmtcmdfailed, argv[0], "write", NSH_ERRNO);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -452,7 +452,7 @@ void cmd_cp(FAR void *handle, int argc, char **argv)
|
||||
rdfd = open(argv[1], O_RDONLY);
|
||||
if (rdfd < 0)
|
||||
{
|
||||
nsh_output(handle, g_fmtcmdfailed, argv[0], "open", strerror(errno));
|
||||
nsh_output(handle, g_fmtcmdfailed, argv[0], "open", NSH_ERRNO);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -494,7 +494,7 @@ void cmd_cp(FAR void *handle, int argc, char **argv)
|
||||
wrfd = open(wrpath, oflags, 0666);
|
||||
if (wrfd < 0)
|
||||
{
|
||||
nsh_output(handle, g_fmtcmdfailed, argv[0], "open", strerror(errno));
|
||||
nsh_output(handle, g_fmtcmdfailed, argv[0], "open", NSH_ERRNO);
|
||||
goto out_with_fullpath;
|
||||
}
|
||||
|
||||
@ -518,7 +518,7 @@ void cmd_cp(FAR void *handle, int argc, char **argv)
|
||||
{
|
||||
/* Read error */
|
||||
|
||||
nsh_output(handle, g_fmtcmdfailed, argv[0], "read", strerror(errno));
|
||||
nsh_output(handle, g_fmtcmdfailed, argv[0], "read", NSH_ERRNO);
|
||||
goto out_with_wrfd;
|
||||
}
|
||||
}
|
||||
@ -535,7 +535,7 @@ void cmd_cp(FAR void *handle, int argc, char **argv)
|
||||
{
|
||||
/* Read error */
|
||||
|
||||
nsh_output(handle, g_fmtcmdfailed, argv[0], "write", strerror(errno));
|
||||
nsh_output(handle, g_fmtcmdfailed, argv[0], "write", NSH_ERRNO);
|
||||
goto out_with_wrfd;
|
||||
}
|
||||
}
|
||||
@ -628,7 +628,7 @@ void cmd_mkdir(FAR void *handle, int argc, char **argv)
|
||||
int result = mkdir(argv[1], 0777);
|
||||
if ( result < 0)
|
||||
{
|
||||
nsh_output(handle, g_fmtcmdfailed, argv[0], "mkdir", strerror(errno));
|
||||
nsh_output(handle, g_fmtcmdfailed, argv[0], "mkdir", NSH_ERRNO);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@ -683,7 +683,7 @@ void cmd_mount(FAR void *handle, int argc, char **argv)
|
||||
result = mount(argv[optind], argv[optind+1], filesystem, 0, NULL);
|
||||
if ( result < 0)
|
||||
{
|
||||
nsh_output(handle, g_fmtcmdfailed, argv[0], "mount", strerror(errno));
|
||||
nsh_output(handle, g_fmtcmdfailed, argv[0], "mount", NSH_ERRNO);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@ -698,7 +698,7 @@ void cmd_rm(FAR void *handle, int argc, char **argv)
|
||||
{
|
||||
if (unlink(argv[1]) < 0)
|
||||
{
|
||||
nsh_output(handle, g_fmtcmdfailed, argv[0], "unlink", strerror(errno));
|
||||
nsh_output(handle, g_fmtcmdfailed, argv[0], "unlink", NSH_ERRNO);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@ -712,7 +712,7 @@ void cmd_rmdir(FAR void *handle, int argc, char **argv)
|
||||
{
|
||||
if (rmdir(argv[1]) < 0)
|
||||
{
|
||||
nsh_output(handle, g_fmtcmdfailed, argv[0], "rmdir", strerror(errno));
|
||||
nsh_output(handle, g_fmtcmdfailed, argv[0], "rmdir", NSH_ERRNO);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@ -729,7 +729,7 @@ void cmd_umount(FAR void *handle, int argc, char **argv)
|
||||
int result = umount(argv[1]);
|
||||
if ( result < 0)
|
||||
{
|
||||
nsh_output(handle, g_fmtcmdfailed, argv[0], "umount", strerror(errno));
|
||||
nsh_output(handle, g_fmtcmdfailed, argv[0], "umount", NSH_ERRNO);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -132,7 +132,11 @@ const char g_fmtcmdnotfound[] = "nsh: %s: command not found\n";
|
||||
const char g_fmtcmdnotimpl[] = "nsh: %s: command not implemented\n";
|
||||
const char g_fmtnosuch[] = "nsh: %s: no such %s: %s\n";
|
||||
const char g_fmttoomanyargs[] = "nsh: %s: too many arguments\n";
|
||||
#ifdef CONFIG_NSH_STRERROR
|
||||
const char g_fmtcmdfailed[] = "nsh: %s: %s failed: %s\n";
|
||||
#else
|
||||
const char g_fmtcmdfailed[] = "nsh: %s: %s failed: %d\n";
|
||||
#endif
|
||||
const char g_fmtcmdoutofmemory[] = "nsh: %s: out of memory\n";
|
||||
|
||||
/****************************************************************************
|
||||
|
@ -209,6 +209,7 @@ int ifconfig_callback(FAR struct uip_driver_s *dev, void *arg)
|
||||
nsh_output(arg, "DRaddr:%s ", inet_ntoa(addr));
|
||||
addr.s_addr = dev->d_netmask;
|
||||
nsh_output(arg, "Mask:%s\n\n", inet_ntoa(addr));
|
||||
return OK;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
@ -95,7 +95,6 @@ static const char *g_statenames[] =
|
||||
|
||||
static void ps_task(FAR _TCB *tcb, FAR void *arg)
|
||||
{
|
||||
boolean needcomma = FALSE;
|
||||
int i;
|
||||
|
||||
/* Show task status */
|
||||
|
Loading…
Reference in New Issue
Block a user