From 7364ea7dd5258a703c43d5bae4b9709c2c00f1da Mon Sep 17 00:00:00 2001 From: Michael Theall Date: Thu, 31 Mar 2022 11:53:47 -0500 Subject: [PATCH] _3DS -> __3DS__ --- Makefile.3ds | 2 +- Makefile.switch | 2 +- include/ftpConfig.h | 6 +++--- include/ftpServer.h | 2 +- include/ftpSession.h | 2 +- include/licenses.h | 4 ++-- include/platform.h | 4 ++-- include/sockAddr.h | 4 ++-- source/fs.cpp | 2 +- source/ftpConfig.cpp | 10 +++++----- source/ftpServer.cpp | 30 +++++++++++++++--------------- source/ftpSession.cpp | 20 ++++++++++---------- source/licenses.cpp | 6 +++--- source/log.cpp | 2 +- source/sockAddr.cpp | 4 ++-- 15 files changed, 50 insertions(+), 50 deletions(-) diff --git a/Makefile.3ds b/Makefile.3ds index f31477f..5fc2f56 100644 --- a/Makefile.3ds +++ b/Makefile.3ds @@ -68,7 +68,7 @@ CFLAGS := -g -Wall $(OPTIMIZE) -mword-relocations \ -fomit-frame-pointer -ffunction-sections -fdata-sections \ $(ARCH) $(DEFINES) $(CLASSIC) -CFLAGS += $(INCLUDE) -DARM11 -D_3DS \ +CFLAGS += $(INCLUDE) -DARM11 -D__3DS__ \ -DSTATUS_STRING="\"ftpd v$(VERSION)\"" \ -DIMGUI_DISABLE_INCLUDE_IMCONFIG_H=1 \ -DNO_IPV6 -DFTPDCONFIG="\"/config/ftpd/ftpd.cfg\"" \ diff --git a/Makefile.switch b/Makefile.switch index 2141f46..bf08bdf 100644 --- a/Makefile.switch +++ b/Makefile.switch @@ -46,7 +46,7 @@ DATA := data INCLUDES := include ifeq ($(strip $(CLASSIC)),) -APP_TITLE := ftpd pro $(VERSION) +APP_TITLE := ftpd Issue \#139 TARGET := switch/ftpd BUILD := switch/build SOURCES += source/imgui diff --git a/include/ftpConfig.h b/include/ftpConfig.h index 1aabab1..64c3959 100644 --- a/include/ftpConfig.h +++ b/include/ftpConfig.h @@ -60,7 +60,7 @@ public: /// \brief Get port std::uint16_t port () const; -#ifdef _3DS +#ifdef __3DS__ /// \brief Whether to get mtime /// \note only effective on 3DS bool getMTime () const; @@ -93,7 +93,7 @@ public: /// \param port_ Listen port bool setPort (std::uint16_t port_); -#ifdef _3DS +#ifdef __3DS__ /// \brief Set whether to get mtime /// \param getMTime_ Whether to get mtime void setGetMTime (bool getMTime_); @@ -130,7 +130,7 @@ private: /// \brief Listen port std::uint16_t m_port; -#ifdef _3DS +#ifdef __3DS__ /// \brief Whether to get mtime bool m_getMTime = true; #endif diff --git a/include/ftpServer.h b/include/ftpServer.h index c4389e0..a0a21f0 100644 --- a/include/ftpServer.h +++ b/include/ftpServer.h @@ -128,7 +128,7 @@ private: /// \brief Port setting std::uint16_t m_portSetting; -#ifdef _3DS +#ifdef __3DS__ /// \brief getMTime setting bool m_getMTimeSetting; #endif diff --git a/include/ftpSession.h b/include/ftpSession.h index 6480b8c..9f58432 100644 --- a/include/ftpSession.h +++ b/include/ftpSession.h @@ -83,7 +83,7 @@ private: /// \brief Amount of file position history to keep constexpr static auto POSITION_HISTORY = 60; -#elif defined(_3DS) +#elif defined(__3DS__) /// \brief Socket buffer size constexpr static auto SOCK_BUFFERSIZE = 32768; diff --git a/include/licenses.h b/include/licenses.h index 80deb9d..e5de87e 100644 --- a/include/licenses.h +++ b/include/licenses.h @@ -26,7 +26,7 @@ extern char const *const g_dearImGuiVersion; extern char const *const g_dearImGuiCopyright; extern char const *const g_mitLicense; -#ifdef _3DS +#ifdef __3DS__ extern char const *const g_libctruVersion; extern char const *const g_citro3dVersion; extern char const *const g_citro3dCopyright; @@ -47,7 +47,7 @@ extern char const *const g_bsdLicense; extern char const *const g_zlibLicense; #endif -#if !defined(NDS) && !defined(_3DS) && !defined(__SWITCH__) +#if !defined(NDS) && !defined(__3DS__) && !defined(__SWITCH__) extern char const *const g_glfwVersion; extern char const *const g_glfwCopyright; #endif diff --git a/include/platform.h b/include/platform.h index 7c6b5bc..e34041a 100644 --- a/include/platform.h +++ b/include/platform.h @@ -24,7 +24,7 @@ #if defined(NDS) #include -#elif defined(_3DS) +#elif defined(__3DS__) #include <3ds.h> #elif defined(__SWITCH__) #include @@ -80,7 +80,7 @@ void render (); /// \brief Deinitialize platform void exit (); -#ifdef _3DS +#ifdef __3DS__ /// \brief Steady clock struct steady_clock { diff --git a/include/sockAddr.h b/include/sockAddr.h index 9b7793b..b3af3c6 100644 --- a/include/sockAddr.h +++ b/include/sockAddr.h @@ -65,7 +65,7 @@ public: /// \param addr_ Address SockAddr (struct sockaddr_in const &addr_); -#ifndef _3DS +#ifndef __3DS__ /// \param Parameterized constructor /// \param addr_ Address SockAddr (struct sockaddr_in6 const &addr_); @@ -78,7 +78,7 @@ public: /// \param sockaddr_in cast operator operator struct sockaddr_in const & () const; -#ifndef _3DS +#ifndef __3DS__ /// \param sockaddr_in6 cast operator operator struct sockaddr_in6 const & () const; #endif diff --git a/source/fs.cpp b/source/fs.cpp index b6cdc08..4c0efa9 100644 --- a/source/fs.cpp +++ b/source/fs.cpp @@ -25,7 +25,7 @@ #include #include -#if defined(NDS) || defined(_3DS) || defined(__SWITCH__) +#if defined(NDS) || defined(__3DS__) || defined(__SWITCH__) #define getline __getline #endif diff --git a/source/ftpConfig.cpp b/source/ftpConfig.cpp index 3c9177b..52cc687 100644 --- a/source/ftpConfig.cpp +++ b/source/ftpConfig.cpp @@ -153,7 +153,7 @@ UniqueFtpConfig FtpConfig::load (char const *const path_) config->m_pass = val; else if (key == "port") parseInt (port, val); -#ifdef _3DS +#ifdef __3DS__ else if (key == "mtime") { if (val == "0") @@ -208,7 +208,7 @@ bool FtpConfig::save (char const *const path_) std::fprintf (fp, "pass=%s\n", m_pass.c_str ()); std::fprintf (fp, "port=%u\n", m_port); -#ifdef _3DS +#ifdef __3DS__ std::fprintf (fp, "mtime=%u\n", m_getMTime); #endif @@ -238,7 +238,7 @@ std::uint16_t FtpConfig::port () const return m_port; } -#ifdef _3DS +#ifdef __3DS__ bool FtpConfig::getMTime () const { return m_getMTime; @@ -290,7 +290,7 @@ bool FtpConfig::setPort (std::uint16_t const port_) errno = EPERM; return false; } -#elif defined(NDS) || defined(_3DS) +#elif defined(NDS) || defined(__3DS__) // 3DS is allowed < 1024, but not 0 // NDS is allowed < 1024, but 0 crashes the app if (port_ == 0) @@ -304,7 +304,7 @@ bool FtpConfig::setPort (std::uint16_t const port_) return true; } -#ifdef _3DS +#ifdef __3DS__ void FtpConfig::setGetMTime (bool const getMTime_) { m_getMTime = getMTime_; diff --git a/source/ftpServer.cpp b/source/ftpServer.cpp index 00d0354..fcd21ac 100644 --- a/source/ftpServer.cpp +++ b/source/ftpServer.cpp @@ -157,7 +157,7 @@ void FtpServer::draw () auto const height = io.DisplaySize.y; ImGui::SetNextWindowPos (ImVec2 (0, 0), ImGuiCond_FirstUseEver); -#ifdef _3DS +#ifdef __3DS__ // top screen ImGui::SetNextWindowSize (ImVec2 (width, height * 0.5f)); #else @@ -177,26 +177,26 @@ void FtpServer::draw () ImGui::Begin (title, nullptr, ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize -#ifndef _3DS +#ifndef __3DS__ | ImGuiWindowFlags_MenuBar #endif ); } -#ifndef _3DS +#ifndef __3DS__ showMenu (); #endif -#ifndef _3DS +#ifndef __3DS__ ImGui::BeginChild ( "Logs", ImVec2 (0, 0.5f * height), false, ImGuiWindowFlags_HorizontalScrollbar); #endif drawLog (); -#ifndef _3DS +#ifndef __3DS__ ImGui::EndChild (); #endif -#ifdef _3DS +#ifdef __3DS__ ImGui::End (); // bottom screen @@ -242,7 +242,7 @@ std::string FtpServer::getFreeSpace () void FtpServer::updateFreeSpace () { struct statvfs st; -#if defined(NDS) || defined(_3DS) || defined(__SWITCH__) +#if defined(NDS) || defined(__3DS__) || defined(__SWITCH__) if (::statvfs ("sdmc:/", &st) != 0) #else if (::statvfs ("/", &st) != 0) @@ -329,7 +329,7 @@ void FtpServer::showMenu () if (ImGui::BeginMenuBar ()) { -#if defined(_3DS) || defined(__SWITCH__) +#if defined(__3DS__) || defined(__SWITCH__) if (ImGui::BeginMenu (u8"Menu \xee\x80\x83")) // Y Button #else if (ImGui::BeginMenu ("Menu")) @@ -362,7 +362,7 @@ void FtpServer::showMenu () m_portSetting = m_config->port (); -#ifdef _3DS +#ifdef __3DS__ m_getMTimeSetting = m_config->getMTime (); #endif @@ -393,7 +393,7 @@ void FtpServer::showMenu () void FtpServer::showSettings () { -#ifdef _3DS +#ifdef __3DS__ auto const &io = ImGui::GetIO (); auto const width = io.DisplaySize.x; auto const height = io.DisplaySize.y; @@ -425,7 +425,7 @@ void FtpServer::showSettings () "%u", ImGuiInputTextFlags_AutoSelectAll); -#ifdef _3DS +#ifdef __3DS__ ImGui::Checkbox ("Get mtime", &m_getMTimeSetting); #endif @@ -491,7 +491,7 @@ void FtpServer::showSettings () m_config->setPass (m_passSetting); m_config->setPort (m_portSetting); -#ifdef _3DS +#ifdef __3DS__ m_config->setGetMTime (m_getMTimeSetting); #endif @@ -522,7 +522,7 @@ void FtpServer::showSettings () m_userSetting = defaults->user (); m_passSetting = defaults->pass (); m_portSetting = defaults->port (); -#ifdef _3DS +#ifdef __3DS__ m_getMTimeSetting = defaults->getMTime (); #endif @@ -549,7 +549,7 @@ void FtpServer::showAbout () auto const width = io.DisplaySize.x; auto const height = io.DisplaySize.y; -#ifdef _3DS +#ifdef __3DS__ ImGui::SetNextWindowSize (ImVec2 (width * 0.8f, height * 0.5f)); ImGui::SetNextWindowPos (ImVec2 (width * 0.1f, height * 0.5f)); #else @@ -582,7 +582,7 @@ void FtpServer::showAbout () } #if defined(NDS) -#elif defined(_3DS) +#elif defined(__3DS__) if (ImGui::TreeNode (g_libctruVersion)) { ImGui::TextWrapped (g_zlibLicense); diff --git a/source/ftpSession.cpp b/source/ftpSession.cpp index 78afa1e..9fd41ec 100644 --- a/source/ftpSession.cpp +++ b/source/ftpSession.cpp @@ -40,7 +40,7 @@ #include using namespace std::chrono_literals; -#if defined(NDS) || defined(_3DS) || defined(__SWITCH__) +#if defined(NDS) || defined(__3DS__) || defined(__SWITCH__) #define lstat stat #endif @@ -341,7 +341,7 @@ void FtpSession::draw () std::fputs (m_workItem.empty () ? m_cwd.c_str () : m_workItem.c_str (), stdout); #else -#ifdef _3DS +#ifdef __3DS__ ImGui::BeginChild (m_windowName.c_str (), ImVec2 (0.0f, 45.0f), true); #else ImGui::BeginChild (m_windowName.c_str (), ImVec2 (0.0f, 80.0f), true); @@ -718,7 +718,7 @@ bool FtpSession::dataAccept () return false; } -#ifndef _3DS +#ifndef __3DS__ m_dataSocket->setRecvBufferSize (SOCK_BUFFERSIZE); m_dataSocket->setSendBufferSize (SOCK_BUFFERSIZE); #endif @@ -793,7 +793,7 @@ int FtpSession::fillDirent (struct stat const &st_, std::string_view const path_ type_ = "file"; else if (S_ISDIR (st_.st_mode)) type_ = "dir"; -#if !defined(_3DS) && !defined(__SWITCH__) +#if !defined(__3DS__) && !defined(__SWITCH__) else if (S_ISLNK (st_.st_mode)) type_ = "os.unix=symlink"; else if (S_ISCHR (st_.st_mode)) @@ -970,7 +970,7 @@ int FtpSession::fillDirent (struct stat const &st_, std::string_view const path_ buffer[pos++] = ' '; } -#ifdef _3DS +#ifdef __3DS__ auto const owner = "3DS"; auto const group = "3DS"; #elif defined(__SWITCH__) @@ -989,7 +989,7 @@ int FtpSession::fillDirent (struct stat const &st_, std::string_view const path_ // clang-format off S_ISREG (st_.st_mode) ? '-' : S_ISDIR (st_.st_mode) ? 'd' : -#if !defined(_3DS) && !defined(__SWITCH__) +#if !defined(__3DS__) && !defined(__SWITCH__) S_ISLNK (st_.st_mode) ? 'l' : S_ISCHR (st_.st_mode) ? 'c' : S_ISBLK (st_.st_mode) ? 'b' : @@ -1648,7 +1648,7 @@ bool FtpSession::listTransfer () auto const fullPath = buildPath (m_lwd, dent->d_name); struct stat st; -#ifdef _3DS +#ifdef __3DS__ // the sdmc directory entry already has the type and size, so no need to do a slow stat auto const dp = static_cast (m_dir); auto const magic = *reinterpret_cast (dp->dirData->dirStruct); @@ -2226,7 +2226,7 @@ void FtpSession::PASV (char const *args_) // create an address to bind struct sockaddr_in addr = m_commandSocket->sockName (); -#if defined(NDS) || defined(_3DS) +#if defined(NDS) || defined(__3DS__) static std::uint16_t ephemeralPort = 5001; if (ephemeralPort > 10000) ephemeralPort = 5001; @@ -2550,7 +2550,7 @@ void FtpSession::SITE (char const *args_) " Set username: SITE USER \r\n" " Set password: SITE PASS \r\n" " Set port: SITE PORT \r\n" -#ifdef _3DS +#ifdef __3DS__ " Set getMTime: SITE MTIME [0|1]\r\n" #endif " Save config: SITE SAVE\r\n" @@ -2608,7 +2608,7 @@ void FtpSession::SITE (char const *args_) sendResponse ("200 OK\r\n"); return; } -#ifdef _3DS +#ifdef __3DS__ else if (::strcasecmp (command.c_str (), "MTIME") == 0) { if (arg == "0") diff --git a/source/licenses.cpp b/source/licenses.cpp index 664ea14..5dd482a 100644 --- a/source/licenses.cpp +++ b/source/licenses.cpp @@ -26,7 +26,7 @@ #include #endif -#if !defined(NDS) && !defined(_3DS) && !defined(__SWITCH__) +#if !defined(NDS) && !defined(__3DS__) && !defined(__SWITCH__) #include #endif @@ -52,7 +52,7 @@ char const *const g_mitLicense = "ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE " "SOFTWARE."; -#ifdef _3DS +#ifdef __3DS__ char const *const g_libctruVersion = "libctru"; char const *const g_citro3dVersion = "citro3d"; @@ -125,7 +125,7 @@ char const *const g_zlibLicense = "3. This notice may not be removed or altered from any source distribution."; #endif -#if !defined(NDS) && !defined(_3DS) && !defined(__SWITCH__) +#if !defined(NDS) && !defined(__3DS__) && !defined(__SWITCH__) #define STR(x) #x #define XSTR(x) STR (x) #define GLFW_VERSION_STRING \ diff --git a/source/log.cpp b/source/log.cpp index f7d8cb6..6ec4594 100644 --- a/source/log.cpp +++ b/source/log.cpp @@ -29,7 +29,7 @@ namespace { -#ifdef _3DS +#ifdef __3DS__ /// \brief Maximum number of log messages to keep constexpr auto MAX_LOGS = 250; #else diff --git a/source/sockAddr.cpp b/source/sockAddr.cpp index c840063..4acc2c1 100644 --- a/source/sockAddr.cpp +++ b/source/sockAddr.cpp @@ -65,7 +65,7 @@ SockAddr::SockAddr (struct sockaddr_in const &addr_) assert (m_addr.ss_family == AF_INET); } -#ifndef _3DS +#ifndef __3DS__ SockAddr::SockAddr (struct sockaddr_in6 const &addr_) : SockAddr (reinterpret_cast (addr_)) { @@ -84,7 +84,7 @@ SockAddr::operator struct sockaddr_in const & () const return reinterpret_cast (m_addr); } -#ifndef _3DS +#ifndef __3DS__ SockAddr::operator struct sockaddr_in6 const & () const { assert (m_addr.ss_family == AF_INET6);