ftpiiu_plugin/source/switch/init.c

85 lines
2.0 KiB
C
Raw Normal View History

2020-04-05 21:16:16 +02:00
// ftpd is a server implementation based on the following:
// - RFC 959 (https://tools.ietf.org/html/rfc959)
// - RFC 3659 (https://tools.ietf.org/html/rfc3659)
// - suggested implementation details from https://cr.yp.to/ftp/filesystem.html
//
// Copyright (C) 2020 Michael Theall
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#include <switch.h>
#include <unistd.h>
#ifndef NDEBUG
2020-04-06 07:36:03 +02:00
/// \brief nxlink socket fd
2020-04-05 21:16:16 +02:00
static int s_fd = -1;
#endif
2020-04-06 07:36:03 +02:00
/// \brief Socket initialization configuration
2020-04-05 21:16:16 +02:00
static SocketInitConfig const s_socketInitConfig = {
.bsdsockets_version = 1,
.tcp_tx_buf_size = 1 * 1024 * 1024,
.tcp_rx_buf_size = 1 * 1024 * 1024,
.tcp_tx_buf_max_size = 4 * 1024 * 1024,
.tcp_rx_buf_max_size = 4 * 1024 * 1024,
.udp_tx_buf_size = 0x2400,
.udp_rx_buf_size = 0xA500,
.sb_efficiency = 8,
2020-04-24 22:51:43 +02:00
.num_bsd_sessions = 2,
2020-04-05 21:16:16 +02:00
.bsd_service_type = BsdServiceType_User,
};
2020-04-06 07:36:03 +02:00
/// \brief Number of FS sessions
2020-04-09 06:59:24 +02:00
u32 __nx_fs_num_sessions = 1;
2020-04-05 21:16:16 +02:00
2020-04-06 07:36:03 +02:00
/// \brief Called before main ()
2020-04-05 21:16:16 +02:00
void userAppInit ()
{
2020-04-06 07:36:03 +02:00
// disable immediate app close
2020-04-05 21:16:16 +02:00
appletLockExit ();
romfsInit ();
plInitialize ();
2020-04-10 07:46:46 +02:00
psmInitialize ();
nifmInitialize (NifmServiceType_User);
socketInitialize (&s_socketInitConfig);
2020-04-05 21:16:16 +02:00
#ifndef NDEBUG
// s_fd = nxlinkStdioForDebug ();
2020-04-05 21:16:16 +02:00
#endif
}
void userAppExit ()
{
#ifndef NDEBUG
if (s_fd >= 0)
{
close (s_fd);
s_fd = -1;
}
#endif
2020-04-09 06:59:24 +02:00
socketExit ();
nifmExit ();
2020-04-10 07:46:46 +02:00
psmExit ();
2020-04-05 21:16:16 +02:00
plExit ();
romfsExit ();
appletUnlockExit ();
}