diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2008-11-14 15:11:26 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2008-11-14 15:11:26 +0000 |
commit | 33750aac935ce4f0f9c2e44ab1e43cd196c95ce9 (patch) | |
tree | a1ae161c2388d2d02a0ff95f1ec26a92082cbcd7 /nuttx/examples | |
parent | eb82956af4b42337b8b2baced2d3931769771ebd (diff) | |
download | px4-nuttx-33750aac935ce4f0f9c2e44ab1e43cd196c95ce9.tar.gz px4-nuttx-33750aac935ce4f0f9c2e44ab1e43cd196c95ce9.tar.bz2 px4-nuttx-33750aac935ce4f0f9c2e44ab1e43cd196c95ce9.zip |
Allow each NSH command to be disabled
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@1234 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/examples')
-rw-r--r-- | nuttx/examples/nsh/README.txt | 16 | ||||
-rw-r--r-- | nuttx/examples/nsh/nsh.h | 122 | ||||
-rw-r--r-- | nuttx/examples/nsh/nsh_dbgcmds.c | 10 | ||||
-rw-r--r-- | nuttx/examples/nsh/nsh_envcmds.c | 10 | ||||
-rw-r--r-- | nuttx/examples/nsh/nsh_fscmds.c | 24 | ||||
-rw-r--r-- | nuttx/examples/nsh/nsh_main.c | 121 | ||||
-rw-r--r-- | nuttx/examples/nsh/nsh_netcmds.c | 11 | ||||
-rw-r--r-- | nuttx/examples/nsh/nsh_proccmds.c | 10 | ||||
-rw-r--r-- | nuttx/examples/nsh/nsh_test.c | 4 |
9 files changed, 284 insertions, 44 deletions
diff --git a/nuttx/examples/nsh/README.txt b/nuttx/examples/nsh/README.txt index f1236ff45..5be43dbc0 100644 --- a/nuttx/examples/nsh/README.txt +++ b/nuttx/examples/nsh/README.txt @@ -720,6 +720,22 @@ Command Dependencies on Configuration Settings 4. CONFIG_FS_WRITABLE is not a user configuration but is set automatically if any writable filesystem is selected. At present, this is only CONFIG_FS_FAT. +In addition, each NSH command can be individually disabled via one of the following +settings. All of these settings make the configuration of NSH potentially complex but +also allow it to squeeze into very small memory footprints. + + CONFIG_EXAMPLES_NSH_DISABLE_CAT, CONFIG_EXAMPLES_NSH_DISABLE_CD, CONFIG_EXAMPLES_NSH_DISABLE_CP, + CONFIG_EXAMPLES_NSH_DISABLE_ECHO, CONFIG_EXAMPLES_NSH_DISABLE_EXEC, CONFIG_EXAMPLES_NSH_DISABLE_EXIT, + CONFIG_EXAMPLES_NSH_DISABLE_GET, CONFIG_EXAMPLES_NSH_DISABLE_HELP, CONFIG_EXAMPLES_NSH_DISABLE_IFCONFIG, + CONFIG_EXAMPLES_NSH_DISABLE_LS, CONFIG_EXAMPLES_NSH_DISABLE_MB, CONFIG_EXAMPLES_NSH_DISABLE_MEM, + CONFIG_EXAMPLES_NSH_DISABLE_MKDIR, CONFIG_EXAMPLES_NSH_DISABLE_MKFATFS, CONFIG_EXAMPLES_NSH_DISABLE_MKFIFO, + CONFIG_EXAMPLES_NSH_DISABLE_MKRD, CONFIG_EXAMPLES_NSH_DISABLE_MH, CONFIG_EXAMPLES_NSH_DISABLE_MOUNT, + CONFIG_EXAMPLES_NSH_DISABLE_MW, CONFIG_EXAMPLES_NSH_DISABLE_PS, CONFIG_EXAMPLES_NSH_DISABLE_PING, + CONFIG_EXAMPLES_NSH_DISABLE_PUT, CONFIG_EXAMPLES_NSH_DISABLE_PWD, CONFIG_EXAMPLES_NSH_DISABLE_RM, + CONFIG_EXAMPLES_NSH_DISABLE_RMDIR, CONFIG_EXAMPLES_NSH_DISABLE_SET, CONFIG_EXAMPLES_NSH_DISABLE_SH, + CONFIG_EXAMPLES_NSH_DISABLE_SLEEP, CONFIG_EXAMPLES_NSH_DISABLE_TEST, CONFIG_EXAMPLES_NSH_DISABLE_UMOUNT, + CONFIG_EXAMPLES_NSH_DISABLE_UNSET, CONFIG_EXAMPLES_NSH_DISABLE_USLEEP, CONFIG_EXAMPLES_NSH_DISABLE_XD, + NSH-Specific Configuration Settings ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/nuttx/examples/nsh/nsh.h b/nuttx/examples/nsh/nsh.h index c4374198f..1c795c94f 100644 --- a/nuttx/examples/nsh/nsh.h +++ b/nuttx/examples/nsh/nsh.h @@ -329,69 +329,129 @@ extern void nsh_dumpbuffer(FAR struct nsh_vtbl_s *vtbl, const char *msg, /* Shell command handlers */ -extern int cmd_echo(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv); -extern int cmd_exec(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv); -extern int cmd_mb(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv); -extern int cmd_mh(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv); -extern int cmd_mw(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv); -extern int cmd_mem(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv); -extern int cmd_ps(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv); -extern int cmd_xd(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv); +#ifndef CONFIG_EXAMPLES_NSH_DISABLE_ECHO + extern int cmd_echo(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv); +#endif +#ifndef CONFIG_EXAMPLES_NSH_DISABLE_EXEC + extern int cmd_exec(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv); +#endif +#ifndef CONFIG_EXAMPLES_NSH_DISABLE_MB + extern int cmd_mb(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv); +#endif +#ifndef CONFIG_EXAMPLES_NSH_DISABLE_MH + extern int cmd_mh(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv); +#endif +#ifndef CONFIG_EXAMPLES_NSH_DISABLE_MW + extern int cmd_mw(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv); +#endif +#ifndef CONFIG_EXAMPLES_NSH_DISABLE_MEM + extern int cmd_mem(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv); +#endif +#ifndef CONFIG_EXAMPLES_NSH_DISABLE_PS + extern int cmd_ps(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv); +#endif +#ifndef CONFIG_EXAMPLES_NSH_DISABLE_XD + extern int cmd_xd(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv); +#endif -#ifndef CONFIG_EXAMPLES_NSH_DISABLESCRIPT +#if !defined(CONFIG_EXAMPLES_NSH_DISABLESCRIPT) && !defined(CONFIG_EXAMPLES_NSH_DISABLE_TEST) extern int cmd_test(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv); extern int cmd_lbracket(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv); #endif #if CONFIG_NFILE_DESCRIPTORS > 0 - extern int cmd_cat(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv); - extern int cmd_cp(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv); - extern int cmd_ls(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv); +# ifndef CONFIG_EXAMPLES_NSH_DISABLE_CAT + extern int cmd_cat(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv); +# endif +# ifndef CONFIG_EXAMPLES_NSH_DISABLE_CP + extern int cmd_cp(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv); +# endif +# ifndef CONFIG_EXAMPLES_NSH_DISABLE_LS + extern int cmd_ls(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv); +# endif # if CONFIG_NFILE_STREAMS > 0 && !defined(CONFIG_EXAMPLES_NSH_DISABLESCRIPT) - extern int cmd_sh(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv); +# ifndef CONFIG_EXAMPLES_NSH_DISABLE_SH + extern int cmd_sh(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv); +# endif # endif /* CONFIG_NFILE_STREAMS && !CONFIG_EXAMPLES_NSH_DISABLESCRIPT */ # ifndef CONFIG_DISABLE_MOUNTPOINT - extern int cmd_mkfifo(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv); +# ifndef CONFIG_EXAMPLES_NSH_DISABLE_MKFIFO + extern int cmd_mkfifo(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv); +# endif # ifdef CONFIG_FS_READABLE - extern int cmd_mount(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv); - extern int cmd_umount(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv); +# ifndef CONFIG_EXAMPLES_NSH_DISABLE_MOUNT + extern int cmd_mount(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv); +# endif +# ifndef CONFIG_EXAMPLES_NSH_DISABLE_UMOUNT + extern int cmd_umount(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv); +# endif # ifdef CONFIG_FS_WRITABLE - extern int cmd_mkdir(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv); - extern int cmd_mkrd(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv); - extern int cmd_rm(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv); - extern int cmd_rmdir(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv); +# ifndef CONFIG_EXAMPLES_NSH_DISABLE_MKDIR + extern int cmd_mkdir(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv); +# endif +# ifndef CONFIG_EXAMPLES_NSH_DISABLE_MKRD + extern int cmd_mkrd(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv); +# endif +# ifndef CONFIG_EXAMPLES_NSH_DISABLE_RM + extern int cmd_rm(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv); +# endif +# ifndef CONFIG_EXAMPLES_NSH_DISABLE_RMDIR + extern int cmd_rmdir(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv); +# endif # endif /* CONFIG_FS_WRITABLE */ # endif /* CONFIG_FS_READABLE */ # ifdef CONFIG_FS_FAT - extern int cmd_mkfatfs(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv); +# ifndef CONFIG_EXAMPLES_NSH_DISABLE_MKFATFS + extern int cmd_mkfatfs(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv); +# endif # endif /* CONFIG_FS_FAT */ # endif /* !CONFIG_DISABLE_MOUNTPOINT */ # if !defined(CONFIG_DISABLE_ENVIRON) - extern int cmd_cd(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv); - extern int cmd_pwd(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv); +# ifndef CONFIG_EXAMPLES_NSH_DISABLE_CD + extern int cmd_cd(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv); +# endif +# ifndef CONFIG_EXAMPLES_NSH_DISABLE_PWD + extern int cmd_pwd(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv); +# endif # endif /* !CONFIG_DISABLE_MOUNTPOINT */ #endif /* CONFIG_NFILE_DESCRIPTORS */ #if defined(CONFIG_NET) - extern int cmd_ifconfig(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv); +# ifndef CONFIG_EXAMPLES_NSH_DISABLE_IFCONFIG + extern int cmd_ifconfig(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv); +# endif #if defined(CONFIG_NET_UDP) && CONFIG_NFILE_DESCRIPTORS > 0 - extern int cmd_get(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv); - extern int cmd_put(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv); +# ifndef CONFIG_EXAMPLES_NSH_DISABLE_GET + extern int cmd_get(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv); +# endif +# ifndef CONFIG_EXAMPLES_NSH_DISABLE_PUT + extern int cmd_put(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv); +# endif #endif #if defined(CONFIG_NET_ICMP) && defined(CONFIG_NET_ICMP_PING) && \ !defined(CONFIG_DISABLE_CLOCK) && !defined(CONFIG_DISABLE_SIGNALS) - extern int cmd_ping(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv); +# ifndef CONFIG_EXAMPLES_NSH_DISABLE_PING + extern int cmd_ping(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv); +# endif #endif #endif #ifndef CONFIG_DISABLE_ENVIRON - extern int cmd_set(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv); - extern int cmd_unset(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv); +# ifndef CONFIG_EXAMPLES_NSH_DISABLE_SET + extern int cmd_set(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv); +# endif +# ifndef CONFIG_EXAMPLES_NSH_DISABLE_UNSET + extern int cmd_unset(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv); +# endif #endif /* CONFIG_DISABLE_ENVIRON */ #ifndef CONFIG_DISABLE_SIGNALS - extern int cmd_sleep(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv); - extern int cmd_usleep(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv); +# ifndef CONFIG_EXAMPLES_NSH_DISABLE_SLEEP + extern int cmd_sleep(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv); +# endif +# ifndef CONFIG_EXAMPLES_NSH_DISABLE_USLEEP + extern int cmd_usleep(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv); +# endif #endif /* CONFIG_DISABLE_SIGNALS */ #endif /* __NSH_H */ diff --git a/nuttx/examples/nsh/nsh_dbgcmds.c b/nuttx/examples/nsh/nsh_dbgcmds.c index bab37323c..8e8e12d1c 100644 --- a/nuttx/examples/nsh/nsh_dbgcmds.c +++ b/nuttx/examples/nsh/nsh_dbgcmds.c @@ -136,6 +136,7 @@ int mem_parse(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv, * Name: cmd_mb ****************************************************************************/ +#ifndef CONFIG_EXAMPLES_NSH_DISABLE_MB int cmd_mb(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) { struct dbgmem_s mem; @@ -182,11 +183,13 @@ int cmd_mb(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) } return ret; } +#endif /**************************************************************************** * Name: cmd_mh ****************************************************************************/ +#ifndef CONFIG_EXAMPLES_NSH_DISABLE_MH int cmd_mh(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) { struct dbgmem_s mem; @@ -233,11 +236,13 @@ int cmd_mh(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) } return ret; } +#endif /**************************************************************************** * Name: cmd_mw ****************************************************************************/ +#ifndef CONFIG_EXAMPLES_NSH_DISABLE_MW int cmd_mw(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) { struct dbgmem_s mem; @@ -276,11 +281,13 @@ int cmd_mw(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) } return ret; } +#endif /**************************************************************************** * Name: cmd_mem ****************************************************************************/ +#ifndef CONFIG_EXAMPLES_NSH_DISABLE_MEM int cmd_mem(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) { struct mallinfo mem; @@ -298,6 +305,7 @@ int cmd_mem(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) nsh_output(vtbl, " fordblks: %8x\n", mem.fordblks); return OK; } +#endif /**************************************************************************** * Name: nsh_dumpbuffer @@ -344,6 +352,7 @@ void nsh_dumpbuffer(FAR struct nsh_vtbl_s *vtbl, const char *msg, * Name: cmd_xd ****************************************************************************/ +#ifndef CONFIG_EXAMPLES_NSH_DISABLE_XD int cmd_xd(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) { char *addr; @@ -365,4 +374,5 @@ int cmd_xd(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) nsh_dumpbuffer(vtbl, "Hex dump", addr, nbytes); return OK; } +#endif diff --git a/nuttx/examples/nsh/nsh_envcmds.c b/nuttx/examples/nsh/nsh_envcmds.c index f8bedc461..b0d714550 100644 --- a/nuttx/examples/nsh/nsh_envcmds.c +++ b/nuttx/examples/nsh/nsh_envcmds.c @@ -209,6 +209,7 @@ void nsh_freefullpath(char *relpath) ****************************************************************************/ #if CONFIG_NFILE_DESCRIPTORS > 0 && !defined(CONFIG_DISABLE_ENVIRON) +#ifndef CONFIG_EXAMPLES_NSH_DISABLE_CD int cmd_cd(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) { const char *path = argv[1]; @@ -260,11 +261,13 @@ int cmd_cd(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) return ret; } #endif +#endif /**************************************************************************** * Name: cmd_echo ****************************************************************************/ +#ifndef CONFIG_EXAMPLES_NSH_DISABLE_ECHO int cmd_echo(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) { int i; @@ -280,24 +283,28 @@ int cmd_echo(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) nsh_output(vtbl, "\n"); return OK; } +#endif /**************************************************************************** * Name: cmd_pwd ****************************************************************************/ #if CONFIG_NFILE_DESCRIPTORS > 0 && !defined(CONFIG_DISABLE_ENVIRON) +#ifndef CONFIG_EXAMPLES_NSH_DISABLE_PWD int cmd_pwd(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) { nsh_output(vtbl, "%s\n", nsh_getcwd()); return OK; } #endif +#endif /**************************************************************************** * Name: cmd_set ****************************************************************************/ #ifndef CONFIG_DISABLE_ENVIRON +#ifndef CONFIG_EXAMPLES_NSH_DISABLE_SET int cmd_set(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) { int ret = setenv(argv[1], argv[2], TRUE); @@ -308,12 +315,14 @@ int cmd_set(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) return ret; } #endif +#endif /**************************************************************************** * Name: cmd_unset ****************************************************************************/ #ifndef CONFIG_DISABLE_ENVIRON +#ifndef CONFIG_EXAMPLES_NSH_DISABLE_UNSET int cmd_unset(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) { int ret = unsetenv(argv[1]); @@ -324,3 +333,4 @@ int cmd_unset(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) return ret; } #endif +#endif diff --git a/nuttx/examples/nsh/nsh_fscmds.c b/nuttx/examples/nsh/nsh_fscmds.c index 33d1ae6d2..8dcf90372 100644 --- a/nuttx/examples/nsh/nsh_fscmds.c +++ b/nuttx/examples/nsh/nsh_fscmds.c @@ -392,6 +392,7 @@ static int ls_recursive(FAR struct nsh_vtbl_s *vtbl, const char *dirpath, ****************************************************************************/ #if CONFIG_NFILE_DESCRIPTORS > 0 +#ifndef CONFIG_EXAMPLES_NSH_DISABLE_CAT int cmd_cat(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) { char buffer[IOBUFFERSIZE]; @@ -484,12 +485,14 @@ int cmd_cat(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) return ret; } #endif +#endif /**************************************************************************** * Name: cmd_cp ****************************************************************************/ #if CONFIG_NFILE_DESCRIPTORS > 0 +#ifndef CONFIG_EXAMPLES_NSH_DISABLE_CP int cmd_cp(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) { struct stat buf; @@ -642,12 +645,14 @@ errout: return ret; } #endif +#endif /**************************************************************************** * Name: cmd_ls ****************************************************************************/ #if CONFIG_NFILE_DESCRIPTORS > 0 +#ifndef CONFIG_EXAMPLES_NSH_DISABLE_LS int cmd_ls(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) { const char *relpath; @@ -724,12 +729,14 @@ int cmd_ls(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) return ret; } #endif +#endif /**************************************************************************** * Name: cmd_mkdir ****************************************************************************/ #if !defined(CONFIG_DISABLE_MOUNTPOINT) && CONFIG_NFILE_DESCRIPTORS > 0 && defined(CONFIG_FS_WRITABLE) +#ifndef CONFIG_EXAMPLES_NSH_DISABLE_MKDIR int cmd_mkdir(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) { char *fullpath = nsh_getfullpath(vtbl, argv[1]); @@ -747,12 +754,14 @@ int cmd_mkdir(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) return ret; } #endif +#endif /**************************************************************************** * Name: cmd_mkfatfs ****************************************************************************/ #if !defined(CONFIG_DISABLE_MOUNTPOINT) && CONFIG_NFILE_DESCRIPTORS > 0 && defined(CONFIG_FS_FAT) +#ifndef CONFIG_EXAMPLES_NSH_DISABLE_MKFATFS int cmd_mkfatfs(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) { struct fat_format_s fmt = FAT_FORMAT_INITIALIZER; @@ -771,12 +780,14 @@ int cmd_mkfatfs(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) return ret; } #endif +#endif /**************************************************************************** * Name: cmd_mkfifo ****************************************************************************/ #if CONFIG_NFILE_DESCRIPTORS > 0 +#ifndef CONFIG_EXAMPLES_NSH_DISABLE_MKFIFO int cmd_mkfifo(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) { char *fullpath = nsh_getfullpath(vtbl, argv[1]); @@ -794,12 +805,14 @@ int cmd_mkfifo(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) return ret; } #endif +#endif /**************************************************************************** * Name: cmd_mkrd ****************************************************************************/ #if !defined(CONFIG_DISABLE_MOUNTPOINT) && CONFIG_NFILE_DESCRIPTORS > 0 && defined(CONFIG_FS_WRITABLE) +#ifndef CONFIG_EXAMPLES_NSH_DISABLE_MKRD int cmd_mkrd(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) { const char *fmt; @@ -892,12 +905,14 @@ errout_with_fmt: return ERROR; } #endif +#endif /**************************************************************************** * Name: cmd_mount ****************************************************************************/ #if !defined(CONFIG_DISABLE_MOUNTPOINT) && CONFIG_NFILE_DESCRIPTORS > 0 && defined(CONFIG_FS_READABLE) +#ifndef CONFIG_EXAMPLES_NSH_DISABLE_MOUNT int cmd_mount(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) { char *source; @@ -970,12 +985,14 @@ int cmd_mount(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) return ret; } #endif +#endif /**************************************************************************** * Name: cmd_rm ****************************************************************************/ #if !defined(CONFIG_DISABLE_MOUNTPOINT) && CONFIG_NFILE_DESCRIPTORS > 0 && defined(CONFIG_FS_WRITABLE) +#ifndef CONFIG_EXAMPLES_NSH_DISABLE_RM int cmd_rm(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) { char *fullpath = nsh_getfullpath(vtbl, argv[1]); @@ -993,12 +1010,14 @@ int cmd_rm(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) return ret; } #endif +#endif /**************************************************************************** * Name: cmd_rmdir ****************************************************************************/ #if !defined(CONFIG_DISABLE_MOUNTPOINT) && CONFIG_NFILE_DESCRIPTORS > 0 && defined(CONFIG_FS_WRITABLE) +#ifndef CONFIG_EXAMPLES_NSH_DISABLE_RMDIR int cmd_rmdir(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) { char *fullpath = nsh_getfullpath(vtbl, argv[1]); @@ -1016,6 +1035,7 @@ int cmd_rmdir(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) return ret; } #endif +#endif /**************************************************************************** * Name: nsh_script @@ -1087,17 +1107,20 @@ int nsh_script(FAR struct nsh_vtbl_s *vtbl, const char *cmd, const char *path) ****************************************************************************/ #if CONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_NFILE_STREAMS > 0 && !defined(CONFIG_EXAMPLES_NSH_DISABLESCRIPT) +#ifndef CONFIG_EXAMPLES_NSH_DISABLE_SH int cmd_sh(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) { return nsh_script(vtbl, argv[0], argv[1]); } #endif +#endif /**************************************************************************** * Name: cmd_umount ****************************************************************************/ #if !defined(CONFIG_DISABLE_MOUNTPOINT) && CONFIG_NFILE_DESCRIPTORS > 0 && defined(CONFIG_FS_READABLE) +#ifndef CONFIG_EXAMPLES_NSH_DISABLE_UMOUNT int cmd_umount(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) { char *fullpath = nsh_getfullpath(vtbl, argv[1]); @@ -1117,3 +1140,4 @@ int cmd_umount(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) return ret; } #endif +#endif diff --git a/nuttx/examples/nsh/nsh_main.c b/nuttx/examples/nsh/nsh_main.c index 7579c9fa3..b333cbc54 100644 --- a/nuttx/examples/nsh/nsh_main.c +++ b/nuttx/examples/nsh/nsh_main.c @@ -111,8 +111,13 @@ struct cmdarg_s * Private Function Prototypes ****************************************************************************/ -static int cmd_help(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv); -static int cmd_exit(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv); +#ifndef CONFIG_EXAMPLES_NSH_DISABLE_HELP + static int cmd_help(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv); +#endif + +#ifndef CONFIG_EXAMPLES_NSH_DISABLE_EXIT + static int cmd_exit(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv); +#endif static int cmd_unrecognized(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv); /**************************************************************************** @@ -128,89 +133,181 @@ static const char g_failure[] = "1"; static const struct cmdmap_s g_cmdmap[] = { -#ifndef CONFIG_EXAMPLES_NSH_DISABLESCRIPT +#if !defined(CONFIG_EXAMPLES_NSH_DISABLESCRIPT) && !defined(CONFIG_EXAMPLES_NSH_DISABLE_TEST) { "[", cmd_lbracket, 4, NSH_MAX_ARGUMENTS, "<expression> ]" }, #endif + #if CONFIG_NFILE_DESCRIPTORS > 0 +# ifndef CONFIG_EXAMPLES_NSH_DISABLE_CAT { "cat", cmd_cat, 2, NSH_MAX_ARGUMENTS, "<path> [<path> [<path> ...]]" }, +# endif #ifndef CONFIG_DISABLE_ENVIRON +# ifndef CONFIG_EXAMPLES_NSH_DISABLE_CD { "cd", cmd_cd, 1, 2, "[<dir-path>|-|~|..]" }, +# endif #endif +# ifndef CONFIG_EXAMPLES_NSH_DISABLE_CP { "cp", cmd_cp, 3, 3, "<source-path> <dest-path>" }, +# endif #endif -#ifndef CONFIG_DISABLE_ENVIRON + +#ifndef CONFIG_EXAMPLES_NSH_DISABLE_ECHO +# ifndef CONFIG_DISABLE_ENVIRON { "echo", cmd_echo, 0, NSH_MAX_ARGUMENTS, "[<string|$name> [<string|$name>...]]" }, -#else +# else { "echo", cmd_echo, 0, NSH_MAX_ARGUMENTS, "[<string> [<string>...]]" }, +# endif #endif + +#ifndef CONFIG_EXAMPLES_NSH_DISABLE_EXEC { "exec", cmd_exec, 2, 3, "<hex-address>" }, +#endif +#ifndef CONFIG_EXAMPLES_NSH_DISABLE_EXIT { "exit", cmd_exit, 1, 1, NULL }, +#endif + #if defined(CONFIG_NET_UDP) && CONFIG_NFILE_DESCRIPTORS > 0 +# ifndef CONFIG_EXAMPLES_NSH_DISABLE_GET { "get", cmd_get, 4, 7, "[-b|-n] [-f <local-path>] -h <ip-address> <remote-path>" }, +# endif #endif + +#ifndef CONFIG_EXAMPLES_NSH_DISABLE_HELP { "help", cmd_help, 1, 1, NULL }, +#endif + #ifdef CONFIG_NET +# ifndef CONFIG_EXAMPLES_NSH_DISABLE_IFCONFIG { "ifconfig", cmd_ifconfig, 1, 1, NULL }, +# endif #endif + #if CONFIG_NFILE_DESCRIPTORS > 0 +# ifndef CONFIG_EXAMPLES_NSH_DISABLE_LS { "ls", cmd_ls, 1, 5, "[-lRs] <dir-path>" }, +# endif #endif + +#ifndef CONFIG_EXAMPLES_NSH_DISABLE_MB { "mb", cmd_mb, 2, 3, "<hex-address>[=<hex-value>][ <hex-byte-count>]" }, +#endif +#ifndef CONFIG_EXAMPLES_NSH_DISABLE_MEM { "mem", cmd_mem, 1, 1, NULL }, +#endif + #if !defined(CONFIG_DISABLE_MOUNTPOINT) && CONFIG_NFILE_DESCRIPTORS > 0 && defined(CONFIG_FS_WRITABLE) +# ifndef CONFIG_EXAMPLES_NSH_DISABLE_MKDIR { "mkdir", cmd_mkdir, 2, 2, "<path>" }, +# endif #endif + #if !defined(CONFIG_DISABLE_MOUNTPOINT) && CONFIG_NFILE_DESCRIPTORS > 0 && defined(CONFIG_FS_FAT) +# ifndef CONFIG_EXAMPLES_NSH_DISABLE_MKFATFS { "mkfatfs", cmd_mkfatfs, 2, 2, "<path>" }, +# endif #endif + #if !defined(CONFIG_DISABLE_MOUNTPOINT) && CONFIG_NFILE_DESCRIPTORS > 0 +# ifndef CONFIG_EXAMPLES_NSH_DISABLE_MKFIFO { "mkfifo", cmd_mkfifo, 2, 2, "<path>" }, +# endif #endif + #if !defined(CONFIG_DISABLE_MOUNTPOINT) && CONFIG_NFILE_DESCRIPTORS > 0 && defined(CONFIG_FS_WRITABLE) +# ifndef CONFIG_EXAMPLES_NSH_DISABLE_MKRD { "mkrd", cmd_mkrd, 2, 6, "[-m <minor>] [-s <sector-size>] <nsectors>" }, +# endif #endif + +#ifndef CONFIG_EXAMPLES_NSH_DISABLE_MH { "mh", cmd_mh, 2, 3, "<hex-address>[=<hex-value>][ <hex-byte-count>]" }, +#endif + #if !defined(CONFIG_DISABLE_MOUNTPOINT) && CONFIG_NFILE_DESCRIPTORS > 0 && defined(CONFIG_FS_READABLE) +# ifndef CONFIG_EXAMPLES_NSH_DISABLE_MOUNT { "mount", cmd_mount, 4, 5, "-t <fstype> <block-device> <dir-path>" }, +# endif #endif + +#ifndef CONFIG_EXAMPLES_NSH_DISABLE_MW { "mw", cmd_mw, 2, 3, "<hex-address>[=<hex-value>][ <hex-byte-count>]" }, - { "ps", cmd_ps, 1, 1, NULL }, +#endif + #if defined(CONFIG_NET) && defined(CONFIG_NET_ICMP) && defined(CONFIG_NET_ICMP_PING) && \ !defined(CONFIG_DISABLE_CLOCK) && !defined(CONFIG_DISABLE_SIGNALS) +# ifndef CONFIG_EXAMPLES_NSH_DISABLE_PING { "ping", cmd_ping, 2, 6, "[-c <count>] [-i <interval>] <ip-address>" }, +# endif #endif + +#ifndef CONFIG_EXAMPLES_NSH_DISABLE_PS + { "ps", cmd_ps, 1, 1, NULL }, +#endif + #if defined(CONFIG_NET_UDP) && CONFIG_NFILE_DESCRIPTORS > 0 +# ifndef CONFIG_EXAMPLES_NSH_DISABLE_PUT { "put", cmd_put, 4, 7, "[-b|-n] [-f <remote-path>] -h <ip-address> <local-path>" }, +# endif #endif + #if CONFIG_NFILE_DESCRIPTORS > 0 && !defined(CONFIG_DISABLE_ENVIRON) +# ifndef CONFIG_EXAMPLES_NSH_DISABLE_PWD { "pwd", cmd_pwd, 1, 1, NULL }, +# endif #endif + #if !defined(CONFIG_DISABLE_MOUNTPOINT) && CONFIG_NFILE_DESCRIPTORS > 0 && defined(CONFIG_FS_WRITABLE) +# ifndef CONFIG_EXAMPLES_NSH_DISABLE_RM { "rm", cmd_rm, 2, 2, "<file-path>" }, +# endif +# ifndef CONFIG_EXAMPLES_NSH_DISABLE_RMDIR { "rmdir", cmd_rmdir, 2, 2, "<dir-path>" }, +# endif #endif + #ifndef CONFIG_DISABLE_ENVIRON +# ifndef CONFIG_EXAMPLES_NSH_DISABLE_SET { "set", cmd_set, 3, 3, "<name> <value>" }, +# endif #endif + #if CONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_NFILE_STREAMS > 0 && !defined(CONFIG_EXAMPLES_NSH_DISABLESCRIPT) +# ifndef CONFIG_EXAMPLES_NSH_DISABLE_SH { "sh", cmd_sh, 2, 2, "<script-path>" }, -#endif /* CONFIG_NFILE_DESCRIPTORS && CONFIG_NFILE_STREAMS */ +# endif +#endif + #ifndef CONFIG_DISABLE_SIGNALS +# ifndef CONFIG_EXAMPLES_NSH_DISABLE_SLEEP { "sleep", cmd_sleep, 2, 2, "<sec>" }, -#endif /* CONFIG_DISABLE_SIGNALS */ -#ifndef CONFIG_EXAMPLES_NSH_DISABLESCRIPT +# endif +#endif + +#if !defined(CONFIG_EXAMPLES_NSH_DISABLESCRIPT) && !defined(CONFIG_EXAMPLES_NSH_DISABLE_TEST) { "test", cmd_test, 3, NSH_MAX_ARGUMENTS, "<expression>" }, #endif + #if !defined(CONFIG_DISABLE_MOUNTPOINT) && CONFIG_NFILE_DESCRIPTORS > 0 && defined(CONFIG_FS_READABLE) +# ifndef CONFIG_EXAMPLES_NSH_DISABLE_UMOUNT { "umount", cmd_umount, 2, 2, "<dir-path>" }, +# endif #endif + #ifndef CONFIG_DISABLE_ENVIRON +# ifndef CONFIG_EXAMPLES_NSH_DISABLE_UNSET { "unset", cmd_unset, 2, 2, "<name>" }, +# endif #endif + #ifndef CONFIG_DISABLE_SIGNALS +# ifndef CONFIG_EXAMPLES_NSH_DISABLE_USLEEP { "usleep", cmd_usleep, 2, 2, "<usec>" }, -#endif /* CONFIG_DISABLE_SIGNALS */ +# endif +#endif + +#ifndef CONFIG_EXAMPLES_NSH_DISABLE_XD { "xd", cmd_xd, 3, 3, "<hex-address> <byte-count>" }, +#endif { NULL, NULL, 1, 1, NULL } }; @@ -245,6 +342,7 @@ const char g_fmtinternalerror[] = "nsh: %s: Internal error\n"; * Name: cmd_help ****************************************************************************/ +#ifndef CONFIG_EXAMPLES_NSH_DISABLE_HELP static int cmd_help(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) { const struct cmdmap_s *ptr; @@ -278,6 +376,7 @@ static int cmd_help(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) } return OK; } +#endif /**************************************************************************** * Name: cmd_unrecognized @@ -293,11 +392,13 @@ static int cmd_unrecognized(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) * Name: cmd_exit ****************************************************************************/ +#ifndef CONFIG_EXAMPLES_NSH_DISABLE_EXIT static int cmd_exit(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) { nsh_exit(vtbl); return OK; } +#endif /**************************************************************************** * Name: nsh_execute diff --git a/nuttx/examples/nsh/nsh_netcmds.c b/nuttx/examples/nsh/nsh_netcmds.c index 3bc0d1e7e..56dce7bd2 100644 --- a/nuttx/examples/nsh/nsh_netcmds.c +++ b/nuttx/examples/nsh/nsh_netcmds.c @@ -133,7 +133,7 @@ static inline uint16 ping_newid(void) * Name: uip_statistics ****************************************************************************/ -#ifdef CONFIG_NET_STATISTICS +#if defined(CONFIG_NET_STATISTICS) && !defined(CONFIG_EXAMPLES_NSH_DISABLE_IFCONFIG) static inline void uip_statistics(FAR struct nsh_vtbl_s *vtbl) { nsh_output(vtbl, "uIP IP "); @@ -242,6 +242,7 @@ static inline void uip_statistics(FAR struct nsh_vtbl_s *vtbl) # define uip_statistics(vtbl) #endif + /**************************************************************************** * Name: ifconfig_callback ****************************************************************************/ @@ -386,6 +387,7 @@ errout: ****************************************************************************/ #if defined(CONFIG_NET_UDP) && CONFIG_NFILE_DESCRIPTORS > 0 +#ifndef CONFIG_EXAMPLES_NSH_DISABLE_GET int cmd_get(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) { struct tftpc_args_s args; @@ -419,17 +421,20 @@ int cmd_get(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) return OK; } #endif +#endif /**************************************************************************** * Name: cmd_ifconfig ****************************************************************************/ +#ifndef CONFIG_EXAMPLES_NSH_DISABLE_IFCONFIG int cmd_ifconfig(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) { netdev_foreach(ifconfig_callback, vtbl); uip_statistics(vtbl); return OK; } +#endif /**************************************************************************** * Name: cmd_ping @@ -437,6 +442,7 @@ int cmd_ifconfig(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) #if defined(CONFIG_NET_ICMP) && defined(CONFIG_NET_ICMP_PING) && \ !defined(CONFIG_DISABLE_CLOCK) && !defined(CONFIG_DISABLE_SIGNALS) +#ifndef CONFIG_EXAMPLES_NSH_DISABLE_PING int cmd_ping(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) { FAR const char *fmt = g_fmtarginvalid; @@ -576,6 +582,7 @@ errout: nsh_output(vtbl, fmt, argv[0]); return ERROR; } +#endif #endif /* CONFIG_NET_ICMP && CONFIG_NET_ICMP_PING */ /**************************************************************************** @@ -583,6 +590,7 @@ errout: ****************************************************************************/ #if defined(CONFIG_NET_UDP) && CONFIG_NFILE_DESCRIPTORS > 0 +#ifndef CONFIG_EXAMPLES_NSH_DISABLE_PUT int cmd_put(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) { struct tftpc_args_s args; @@ -616,5 +624,6 @@ int cmd_put(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) return OK; } #endif +#endif #endif /* CONFIG_NET */ diff --git a/nuttx/examples/nsh/nsh_proccmds.c b/nuttx/examples/nsh/nsh_proccmds.c index cb9f53062..abf0dc66c 100644 --- a/nuttx/examples/nsh/nsh_proccmds.c +++ b/nuttx/examples/nsh/nsh_proccmds.c @@ -98,6 +98,7 @@ static const char *g_statenames[] = * Name: ps_task ****************************************************************************/ +#ifndef CONFIG_EXAMPLES_NSH_DISABLE_PS static void ps_task(FAR _TCB *tcb, FAR void *arg) { struct nsh_vtbl_s *vtbl = (struct nsh_vtbl_s*)arg; @@ -134,6 +135,7 @@ static void ps_task(FAR _TCB *tcb, FAR void *arg) #endif nsh_output(vtbl, ")\n"); } +#endif /**************************************************************************** * Public Functions @@ -143,6 +145,7 @@ static void ps_task(FAR _TCB *tcb, FAR void *arg) * Name: cmd_exec ****************************************************************************/ +#ifndef CONFIG_EXAMPLES_NSH_DISABLE_EXEC int cmd_exec(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) { char *endptr; @@ -158,23 +161,27 @@ int cmd_exec(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) nsh_output(vtbl, "Calling %p\n", (exec_t)addr); return ((exec_t)addr)(); } +#endif /**************************************************************************** * Name: cmd_ps ****************************************************************************/ +#ifndef CONFIG_EXAMPLES_NSH_DISABLE_PS int cmd_ps(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) { nsh_output(vtbl, "PID PRI SCHD TYPE NP STATE NAME\n"); sched_foreach(ps_task, vtbl); return OK; } +#endif /**************************************************************************** * Name: cmd_sleep ****************************************************************************/ #ifndef CONFIG_DISABLE_SIGNALS +#ifndef CONFIG_EXAMPLES_NSH_DISABLE_SLEEP int cmd_sleep(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) { char *endptr; @@ -190,12 +197,14 @@ int cmd_sleep(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) return OK; } #endif +#endif /**************************************************************************** * Name: cmd_usleep ****************************************************************************/ #ifndef CONFIG_DISABLE_SIGNALS +#ifndef CONFIG_EXAMPLES_NSH_DISABLE_USLEEP int cmd_usleep(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) { char *endptr; @@ -211,3 +220,4 @@ int cmd_usleep(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) return OK; } #endif +#endif diff --git a/nuttx/examples/nsh/nsh_test.c b/nuttx/examples/nsh/nsh_test.c index 400bfe43c..fb76b473d 100644 --- a/nuttx/examples/nsh/nsh_test.c +++ b/nuttx/examples/nsh/nsh_test.c @@ -70,7 +70,7 @@ #include "nsh.h" -#ifndef CONFIG_EXAMPLES_NSH_DISABLESCRIPT +#if !defined(CONFIG_EXAMPLES_NSH_DISABLESCRIPT) && !defined(CONFIG_EXAMPLES_NSH_DISABLE_TEST) /**************************************************************************** * Definitions @@ -434,4 +434,4 @@ int cmd_lbracket(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) } } -#endif /* !CONFIG_EXAMPLES_NSH_DISABLESCRIPT */ +#endif /* !CONFIG_EXAMPLES_NSH_DISABLESCRIPT && !CONFIG_EXAMPLES_NSH_DISABLE_TEST */ |