summaryrefslogtreecommitdiff
path: root/nuttx/examples
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2008-02-20 18:02:55 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2008-02-20 18:02:55 +0000
commit9c6d2638a2c2b84a434d2a88aebfe03da6c18482 (patch)
tree4b95f487fa38221ffc958b2c0fbbfc172f292574 /nuttx/examples
parentc2bbba7b6914bff65b42c1910a31598c2eadb45f (diff)
downloadpx4-nuttx-9c6d2638a2c2b84a434d2a88aebfe03da6c18482.tar.gz
px4-nuttx-9c6d2638a2c2b84a434d2a88aebfe03da6c18482.tar.bz2
px4-nuttx-9c6d2638a2c2b84a434d2a88aebfe03da6c18482.zip
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
Diffstat (limited to 'nuttx/examples')
-rw-r--r--nuttx/examples/nsh/nsh.h12
-rw-r--r--nuttx/examples/nsh/nsh_envcmds.c8
-rw-r--r--nuttx/examples/nsh/nsh_fscmds.c26
-rw-r--r--nuttx/examples/nsh/nsh_main.c4
-rw-r--r--nuttx/examples/nsh/nsh_netcmds.c1
-rw-r--r--nuttx/examples/nsh/nsh_proccmds.c1
6 files changed, 34 insertions, 18 deletions
diff --git a/nuttx/examples/nsh/nsh.h b/nuttx/examples/nsh/nsh.h
index 015c0aa88..71d5d5100 100644
--- a/nuttx/examples/nsh/nsh.h
+++ b/nuttx/examples/nsh/nsh.h
@@ -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
****************************************************************************/
diff --git a/nuttx/examples/nsh/nsh_envcmds.c b/nuttx/examples/nsh/nsh_envcmds.c
index 4af3d026d..0a96206df 100644
--- a/nuttx/examples/nsh/nsh_envcmds.c
+++ b/nuttx/examples/nsh/nsh_envcmds.c
@@ -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
diff --git a/nuttx/examples/nsh/nsh_fscmds.c b/nuttx/examples/nsh/nsh_fscmds.c
index d5dc1c947..84c36b8fd 100644
--- a/nuttx/examples/nsh/nsh_fscmds.c
+++ b/nuttx/examples/nsh/nsh_fscmds.c
@@ -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
diff --git a/nuttx/examples/nsh/nsh_main.c b/nuttx/examples/nsh/nsh_main.c
index 3bf3044ea..204ff3479 100644
--- a/nuttx/examples/nsh/nsh_main.c
+++ b/nuttx/examples/nsh/nsh_main.c
@@ -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";
/****************************************************************************
diff --git a/nuttx/examples/nsh/nsh_netcmds.c b/nuttx/examples/nsh/nsh_netcmds.c
index 3874d3a53..6c26584df 100644
--- a/nuttx/examples/nsh/nsh_netcmds.c
+++ b/nuttx/examples/nsh/nsh_netcmds.c
@@ -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;
}
/****************************************************************************
diff --git a/nuttx/examples/nsh/nsh_proccmds.c b/nuttx/examples/nsh/nsh_proccmds.c
index d7cf37e1b..7cd14e437 100644
--- a/nuttx/examples/nsh/nsh_proccmds.c
+++ b/nuttx/examples/nsh/nsh_proccmds.c
@@ -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 */