wangchen61698 commented on code in PR #1689:
URL: https://github.com/apache/nuttx-apps/pull/1689#discussion_r1152667073


##########
examples/ftpd/ftpd_main.c:
##########
@@ -154,35 +154,75 @@ static void ftpd_accounts(FTPD_SESSION handle)
     }
 }
 
+static void hint(void)
+{
+  fprintf(stderr,
+      "Usage: ftpd [-46] \n\
+      \t-4    Use IPv4\n\
+      \t-6    Use IPv6\n\
+      ");
+}
+
 /****************************************************************************
  * Name: ftpd_daemon
  ****************************************************************************/
 
 int ftpd_daemon(int s_argc, char **s_argv)
 {
   FTPD_SESSION handle;
-  int ret;
+  int ret = EXIT_FAILURE;
+  int option;
+  int family;
+  bool badarg = false;
 
   /* The FTPD daemon has been started */
 
   g_ftpdglob.running = true;
   printf("FTP daemon [%d] started\n", g_ftpdglob.pid);
 
-  /* Open FTPD */
-
 #if ADDR_FAMILY == AF_INET6
-  handle = ftpd_open(CONFIG_EXAMPLES_FTPD_PORT, AF_INET6);
+  family = AF_INET6;
 #else
-  handle = ftpd_open(CONFIG_EXAMPLES_FTPD_PORT, AF_INET);
+  family = AF_INET;
 #endif
 
+  while ((option = getopt(s_argc, &s_argv[1], "46")) != ERROR)
+    {
+      switch (option)
+      {
+        case '4':
+          family = AF_INET;
+          break;
+        case '6':
+          family = AF_INET6;
+          break;
+        default:
+          badarg = true;
+          break;
+      }
+    }
+
+  if (badarg)
+    {
+      hint();

Review Comment:
   The variable is to prompt user that the input is unappropriate to the 
connmand.
   
   
![图片](https://user-images.githubusercontent.com/129070278/228712911-688f27ba-8db3-4723-89c5-94a792d02bdc.png)
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to