diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2012-02-04 21:02:45 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2012-02-04 21:02:45 +0000 |
commit | e82f3f21bff1cf021e036ce3e67d5cc12eb41ebe (patch) | |
tree | f564a8e1329d499be76176d46618c76225e04b37 /apps/examples | |
parent | 07944e1dd7c38a2de22861c695b295156ea8cafd (diff) | |
download | nuttx-e82f3f21bff1cf021e036ce3e67d5cc12eb41ebe.tar.gz nuttx-e82f3f21bff1cf021e036ce3e67d5cc12eb41ebe.tar.bz2 nuttx-e82f3f21bff1cf021e036ce3e67d5cc12eb41ebe.zip |
Add the beginnings of an FTP server
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4368 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'apps/examples')
-rwxr-xr-x | apps/examples/ftpd/ftpd_main.c | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/apps/examples/ftpd/ftpd_main.c b/apps/examples/ftpd/ftpd_main.c new file mode 100755 index 000000000..b5f81f975 --- /dev/null +++ b/apps/examples/ftpd/ftpd_main.c @@ -0,0 +1,72 @@ +#include "ftpd.h" + +struct fptd_account_s +{ + uint8_t flags; + FAR const char *user; + FAR const char *password; + FAR const char *home; +} + +static const struct fptd_account_s g_ftpdaccounts[] = +{ + { FTPD_ACCOUNTFLAG_SYSTEM, "root", "abc123", NULL) }, + { FTPD_ACCOUNTFLAG_GUEST, "ftp", NULL, NULL }, + { FTPD_ACCOUNTFLAG_GUEST, "anonymous", NULL, NULL }, +}; +#define NACCOUNTS (sizeof(g_ftpdaccounts) / sizeof(struct fptd_account_s)) + +static void ftpd_accounts(FTPD_SESSION handle) +{ + FAR onst struct fptd_account_s *account; + int i; + + for (i = 0; i < NACCOUNTS; i++) + { + account = &g_ftpdaccounts[i]; + ftpd_add_user(handle, account->flags, account->user, account->password, account->home); + } +} + +int ftpd_main(int s_argc, char **s_argv) +{ + FTPD_SESSION handle; + int ret; + + /* Bring up the network */ + + ret = ftpd_netinit(); + if (ret < 0) + { + ndbg("Failed to initialize the network\n"); + return EXIT_FAILURE; + } + + /* Open FTPD */ + + handle = ftpd_open(); + if (!handle) + { + ndbg("Failed to open FTPD\n"); + return EXIT_FAILURE; + } + + /* Configure acounts */ + + (void)ftpd_accounts(handle); + + /* Then drive the FTPD server */ + + while (g_ftpd_break == 0) + { + (void)ftpd_run(handle, 1000); + } + + /* Close the FTPD server and exit */ + + ftpd_close(handle); + return EXIT_SUCCESS; +} + +/* vim: set expandtab: */ +/* End of source */ |