nshlib: Remove the remaining CONFIG_FILE_STREAM dependence
continue the change from https://github.com/apache/nuttx-apps/pull/1559 Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
parent
80feb2432d
commit
359f66ad37
12
nshlib/nsh.h
12
nshlib/nsh.h
@ -29,7 +29,6 @@
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <unistd.h>
|
||||
@ -55,11 +54,6 @@
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_FILE_STREAM
|
||||
# undef CONFIG_NSH_FILE_APPS
|
||||
# undef CONFIG_NSH_CMDPARMS
|
||||
#endif
|
||||
|
||||
/* rmdir, mkdir, rm, and mv are only available if mountpoints are enabled
|
||||
* AND there is a writeable file system OR if these operations on the
|
||||
* pseudo-filesystem are not disabled.
|
||||
@ -988,11 +982,9 @@ int cmd_irqinfo(FAR struct nsh_vtbl_s *vtbl, int argc, FAR char **argv);
|
||||
#if !defined(CONFIG_NSH_DISABLE_READLINK) && defined(CONFIG_PSEUDOFS_SOFTLINKS)
|
||||
int cmd_readlink(FAR struct nsh_vtbl_s *vtbl, int argc, FAR char **argv);
|
||||
#endif
|
||||
#if defined(CONFIG_FILE_STREAM) && !defined(CONFIG_NSH_DISABLESCRIPT)
|
||||
# ifndef CONFIG_NSH_DISABLE_SOURCE
|
||||
#if !defined(CONFIG_NSH_DISABLESCRIPT) && !defined(CONFIG_NSH_DISABLE_SOURCE)
|
||||
int cmd_source(FAR struct nsh_vtbl_s *vtbl, int argc, FAR char **argv);
|
||||
# endif
|
||||
#endif /* CONFIG_FILE_STREAM && !CONFIG_NSH_DISABLESCRIPT */
|
||||
#endif
|
||||
|
||||
#ifdef NSH_HAVE_DIROPTS
|
||||
# ifndef CONFIG_NSH_DISABLE_MKDIR
|
||||
|
@ -24,7 +24,6 @@
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
@ -150,8 +149,7 @@ static int nsh_wait_inputdev(FAR struct console_stdio_s *pstate,
|
||||
* to open the keyboard device.
|
||||
*/
|
||||
|
||||
puts(msg);
|
||||
fflush(stdout);
|
||||
write(STDOUT_FILENO, msg, strlen(msg));
|
||||
msg = NULL;
|
||||
}
|
||||
|
||||
|
@ -31,6 +31,7 @@
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <errno.h>
|
||||
#include <sched.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <nuttx/lib/builtin.h>
|
||||
|
@ -28,7 +28,6 @@
|
||||
#include <sys/stat.h>
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
|
@ -87,10 +87,8 @@ static int cmd_unrecognized(FAR struct nsh_vtbl_s *vtbl, int argc,
|
||||
|
||||
static const struct cmdmap_s g_cmdmap[] =
|
||||
{
|
||||
#if defined(CONFIG_FILE_STREAM) && !defined(CONFIG_NSH_DISABLESCRIPT)
|
||||
# ifndef CONFIG_NSH_DISABLE_SOURCE
|
||||
#if !defined(CONFIG_NSH_DISABLESCRIPT) && !defined(CONFIG_NSH_DISABLE_SOURCE)
|
||||
{ ".", cmd_source, 2, 2, "<script-path>" },
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if !defined(CONFIG_NSH_DISABLESCRIPT) && !defined(CONFIG_NSH_DISABLE_TEST)
|
||||
@ -515,10 +513,8 @@ static const struct cmdmap_s g_cmdmap[] =
|
||||
{ "sleep", cmd_sleep, 2, 2, "<sec>" },
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_FILE_STREAM) && !defined(CONFIG_NSH_DISABLESCRIPT)
|
||||
# ifndef CONFIG_NSH_DISABLE_SOURCE
|
||||
#if !defined(CONFIG_NSH_DISABLESCRIPT) && !defined(CONFIG_NSH_DISABLE_SOURCE)
|
||||
{ "source", cmd_source, 2, 2, "<script-path>" },
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if !defined(CONFIG_NSH_DISABLESCRIPT) && !defined(CONFIG_NSH_DISABLE_TEST)
|
||||
|
@ -24,6 +24,7 @@
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <sys/ioctl.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@ -70,7 +71,7 @@ static void nsh_consoleredirect(FAR struct nsh_vtbl_s *vtbl, int fd,
|
||||
static void nsh_consoleundirect(FAR struct nsh_vtbl_s *vtbl,
|
||||
FAR uint8_t *save);
|
||||
static void nsh_consoleexit(FAR struct nsh_vtbl_s *vtbl,
|
||||
int exitstatus) anoreturn_function;
|
||||
int exitstatus) noreturn_function;
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
|
@ -29,7 +29,6 @@
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <errno.h>
|
||||
@ -61,7 +60,7 @@
|
||||
* See struct serialsave_s in nsh_console.c
|
||||
*/
|
||||
|
||||
#define SAVE_SIZE (2 * sizeof(int) + 2 * sizeof(FILE*))
|
||||
#define SAVE_SIZE (2 * sizeof(int))
|
||||
|
||||
/* Are we using the NuttX console for I/O? Or some other character device? */
|
||||
|
||||
|
@ -24,11 +24,8 @@
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include <sys/boardctl.h>
|
||||
|
||||
#include "nsh.h"
|
||||
#include "nsh_console.h"
|
||||
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include <sys/types.h>
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
@ -24,6 +24,8 @@
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <nuttx/clock.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
|
@ -24,7 +24,6 @@
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
|
@ -1976,8 +1976,7 @@ int cmd_rmdir(FAR struct nsh_vtbl_s *vtbl, int argc, FAR char **argv)
|
||||
* Name: cmd_source
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(CONFIG_FILE_STREAM) && !defined(CONFIG_NSH_DISABLESCRIPT)
|
||||
#ifndef CONFIG_NSH_DISABLE_SOURCE
|
||||
#if !defined(CONFIG_NSH_DISABLESCRIPT) && !defined(CONFIG_NSH_DISABLE_SOURCE)
|
||||
int cmd_source(FAR struct nsh_vtbl_s *vtbl, int argc, FAR char **argv)
|
||||
{
|
||||
UNUSED(argc);
|
||||
@ -1985,7 +1984,6 @@ int cmd_source(FAR struct nsh_vtbl_s *vtbl, int argc, FAR char **argv)
|
||||
return nsh_script(vtbl, argv[0], argv[1], true);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: cmd_cmp
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include <sys/types.h>
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
|
@ -24,7 +24,6 @@
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <unistd.h>
|
||||
|
@ -24,6 +24,8 @@
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "nsh.h"
|
||||
#include "nsh_console.h"
|
||||
|
||||
|
@ -24,10 +24,11 @@
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <nuttx/module.h>
|
||||
#include <system/readline.h>
|
||||
|
||||
#include "nsh.h"
|
||||
#include "nsh_console.h"
|
||||
@ -103,18 +104,18 @@ int cmd_rmmod(FAR struct nsh_vtbl_s *vtbl, int argc, FAR char **argv)
|
||||
#if defined(CONFIG_FS_PROCFS) && !defined(CONFIG_FS_PROCFS_EXCLUDE_MODULE)
|
||||
int cmd_lsmod(FAR struct nsh_vtbl_s *vtbl, int argc, FAR char **argv)
|
||||
{
|
||||
UNUSED(argc);
|
||||
int fd;
|
||||
|
||||
FILE *stream;
|
||||
UNUSED(argc);
|
||||
|
||||
/* Usage: lsmod */
|
||||
|
||||
/* Open /proc/modules */
|
||||
|
||||
stream = fopen("/proc/modules", "r");
|
||||
if (stream == NULL)
|
||||
fd = open("/proc/modules", O_RDONLY);
|
||||
if (fd < 0)
|
||||
{
|
||||
nsh_error(vtbl, g_fmtcmdfailed, argv[0], "fopen", NSH_ERRNO);
|
||||
nsh_error(vtbl, g_fmtcmdfailed, argv[0], "open", NSH_ERRNO);
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
@ -126,7 +127,7 @@ int cmd_lsmod(FAR struct nsh_vtbl_s *vtbl, int argc, FAR char **argv)
|
||||
|
||||
/* Read each line from the procfs "file" */
|
||||
|
||||
while (fgets(vtbl->iobuffer, IOBUFFERSIZE, stream) != NULL)
|
||||
while (readline_fd(vtbl->iobuffer, IOBUFFERSIZE, fd, -1) >= 0)
|
||||
{
|
||||
FAR char *modulename;
|
||||
FAR char *initializer;
|
||||
@ -175,7 +176,7 @@ int cmd_lsmod(FAR struct nsh_vtbl_s *vtbl, int argc, FAR char **argv)
|
||||
datasize ? datasize : "");
|
||||
}
|
||||
|
||||
fclose(stream);
|
||||
close(fd);
|
||||
return OK;
|
||||
}
|
||||
#endif /* CONFIG_FS_PROCFS && !CONFIG_FS_PROCFS_EXCLUDE_MODULE */
|
||||
|
@ -24,11 +24,14 @@
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <fcntl.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
#include <pthread.h>
|
||||
#include <sched.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#ifdef CONFIG_NSH_CMDPARMS
|
||||
@ -1958,7 +1961,7 @@ static int nsh_loop(FAR struct nsh_vtbl_s *vtbl, FAR char **ppcmd,
|
||||
SEEK_SET);
|
||||
if (ret < 0)
|
||||
{
|
||||
nsh_error(vtbl, g_fmtcmdfailed, "done", "fseek",
|
||||
nsh_error(vtbl, g_fmtcmdfailed, "done", "lseek",
|
||||
NSH_ERRNO);
|
||||
}
|
||||
|
||||
|
@ -24,7 +24,6 @@
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
|
@ -115,7 +115,7 @@ int nsh_script(FAR struct nsh_vtbl_s *vtbl, FAR const FAR char *cmd,
|
||||
{
|
||||
if (log)
|
||||
{
|
||||
nsh_error(vtbl, g_fmtcmdfailed, cmd, "fopen", NSH_ERRNO);
|
||||
nsh_error(vtbl, g_fmtcmdfailed, cmd, "open", NSH_ERRNO);
|
||||
}
|
||||
|
||||
/* Free the allocated path */
|
||||
@ -138,7 +138,7 @@ int nsh_script(FAR struct nsh_vtbl_s *vtbl, FAR const FAR char *cmd,
|
||||
/* Get the current file position. This is used to control
|
||||
* looping. If a loop begins in the next line, then this file
|
||||
* offset will be needed to locate the top of the loop in the
|
||||
* script file. Note that ftell will return -1 on failure.
|
||||
* script file. Note that lseek will return -1 on failure.
|
||||
*/
|
||||
|
||||
vtbl->np.np_foffs = lseek(vtbl->np.np_fd, 0, SEEK_CUR);
|
||||
@ -146,7 +146,7 @@ int nsh_script(FAR struct nsh_vtbl_s *vtbl, FAR const FAR char *cmd,
|
||||
|
||||
if (vtbl->np.np_foffs < 0 && log)
|
||||
{
|
||||
nsh_error(vtbl, g_fmtcmdfailed, "loop", "ftell", NSH_ERRNO);
|
||||
nsh_error(vtbl, g_fmtcmdfailed, "loop", "lseek", NSH_ERRNO);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -24,7 +24,6 @@
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
|
@ -24,7 +24,6 @@
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <unistd.h>
|
||||
|
@ -26,7 +26,6 @@
|
||||
|
||||
#include <sys/boardctl.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
@ -62,11 +61,6 @@
|
||||
|
||||
static void nsh_configstdio(int fd)
|
||||
{
|
||||
/* Make sure the stdout, and stderr are flushed */
|
||||
|
||||
fflush(stdout);
|
||||
fflush(stderr);
|
||||
|
||||
/* Dup the fd to create standard fd 0-2 */
|
||||
|
||||
dup2(fd, 0);
|
||||
|
@ -24,7 +24,7 @@
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/usb/usbdev_trace.h>
|
||||
|
Loading…
Reference in New Issue
Block a user