You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2022/12/04 11:25:04 UTC

[nuttx-apps] 02/03: nshlib:add platform skip login function

This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx-apps.git

commit 88fff23d3497de541d74325690c79c0616f31d6a
Author: huangjian <hu...@xiaomi.com>
AuthorDate: Fri Nov 4 20:39:26 2022 +0800

    nshlib:add platform skip login function
    
    Signed-off-by: huangjian <hu...@xiaomi.com>
---
 nshlib/Kconfig        | 11 +++++++++++
 nshlib/nsh_login.c    |  7 +++++++
 nshlib/nsh_stdlogin.c |  7 +++++++
 3 files changed, 25 insertions(+)

diff --git a/nshlib/Kconfig b/nshlib/Kconfig
index a0ac2a0ec..6a8a14362 100644
--- a/nshlib/Kconfig
+++ b/nshlib/Kconfig
@@ -1285,6 +1285,17 @@ config NSH_PLATFORM_CHALLENGE
                 which may be included like:
 
                         #include "nshlib/nshlib.h"
+
+config NSH_PLATFORM_SKIP_LOGIN
+        bool "Platform skip login"
+        default n
+        ---help---
+                If this option is selected, the NSH will call into platform-specific
+                logic in order to skip login.  The function prototype for this
+                call is:
+
+                        int platform_skip_login(void);
+
 endif # NSH_LOGIN
 endif # NSH_LIBRARY
 endmenu # NSH Library
diff --git a/nshlib/nsh_login.c b/nshlib/nsh_login.c
index 8f3b48497..3e7e370ca 100644
--- a/nshlib/nsh_login.c
+++ b/nshlib/nsh_login.c
@@ -150,6 +150,13 @@ int nsh_login(FAR struct console_stdio_s *pstate)
   int ret;
   int i;
 
+#ifdef CONFIG_NSH_PLATFORM_SKIP_LOGIN
+  if (platform_skip_login() == OK)
+    {
+      return OK;
+    }
+#endif
+
   /* Loop for the configured number of retries */
 
   for (i = 0; i < CONFIG_NSH_LOGIN_FAILCOUNT; i++)
diff --git a/nshlib/nsh_stdlogin.c b/nshlib/nsh_stdlogin.c
index 4e79acf39..d4f93f599 100644
--- a/nshlib/nsh_stdlogin.c
+++ b/nshlib/nsh_stdlogin.c
@@ -150,6 +150,13 @@ int nsh_stdlogin(FAR struct console_stdio_s *pstate)
   int ret;
   int i;
 
+#ifdef CONFIG_NSH_PLATFORM_SKIP_LOGIN
+  if (platform_skip_login() == OK)
+    {
+      return OK;
+    }
+#endif
+
   /* Loop for the configured number of retries */
 
   for (i = 0; i < CONFIG_NSH_LOGIN_FAILCOUNT; i++)