diff --git a/.gitignore b/.gitignore index 5b6020f..b5d70e0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +build/* build.* output/ ftpd diff --git a/Makefile.switch b/Makefile.switch index cf563c9..d1c5c00 100644 --- a/Makefile.switch +++ b/Makefile.switch @@ -50,7 +50,7 @@ CFLAGS := -g -Wall -O2 \ -ffast-math \ $(ARCH) $(DEFINES) -CFLAGS += $(INCLUDE) -DSWITCH -DSTATUS_STRING="\"ftpd v$(VERSION)\"" +CFLAGS += $(INCLUDE) -D__SWITCH__ -DSTATUS_STRING="\"ftpd v$(VERSION)\"" CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++11 diff --git a/include/console.h b/include/console.h index 6bfa700..cc489f7 100644 --- a/include/console.h +++ b/include/console.h @@ -2,11 +2,11 @@ #ifdef _3DS #include <3ds.h> -#elif defined(SWITCH) +#elif defined(__SWITCH__) #include #endif -#if defined(_3DS) || defined(SWITCH) +#if defined(_3DS) || defined(__SWITCH__) #define ESC(x) "\x1b[" #x #define RESET ESC(0m) #define BLACK ESC(30m) diff --git a/source/console.c b/source/console.c index 0d9e90c..41031d6 100644 --- a/source/console.c +++ b/source/console.c @@ -10,7 +10,7 @@ #include <3ds.h> #define CONSOLE_WIDTH 50 #define CONSOLE_HEIGHT 30 -#elif defined(SWITCH) +#elif defined(__SWITCH__) #include #define CONSOLE_WIDTH 80 #define CONSOLE_HEIGHT 45 @@ -134,7 +134,7 @@ print_tcp_table(void) #endif } -#elif defined(SWITCH) +#elif defined(__SWITCH__) /*! initialize console subsystem */ void console_init(void) @@ -149,7 +149,7 @@ console_init(void) } #endif -#if defined(_3DS) || defined(SWITCH) +#if defined(_3DS) || defined(__SWITCH__) /*! set status bar contents diff --git a/source/ftp.c b/source/ftp.c index 385719a..7bf9d0c 100644 --- a/source/ftp.c +++ b/source/ftp.c @@ -26,7 +26,7 @@ #ifdef _3DS #include <3ds.h> #define lstat stat -#elif defined(SWITCH) +#elif defined(__SWITCH__) #include #define lstat stat #else @@ -37,7 +37,7 @@ #define POLL_UNKNOWN (~(POLLIN|POLLPRI|POLLOUT)) -#ifndef SWITCH +#ifndef __SWITCH__ #define XFER_BUFFERSIZE 32768 #define SOCK_BUFFERSIZE 32768 #define FILE_BUFFERSIZE 65536 @@ -266,7 +266,7 @@ static bool lcd_power = true; /*! aptHook cookie */ static aptHookCookie cookie; -#elif defined(SWITCH) +#elif defined(__SWITCH__) /*! appletHook cookie */ static AppletHookCookie cookie; @@ -750,7 +750,7 @@ ftp_session_fill_dirent_type(ftp_session_t *session, const struct stat *st, 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)) @@ -862,7 +862,7 @@ ftp_session_fill_dirent_type(ftp_session_t *session, const struct stat *st, "%c%c%c%c%c%c%c%c%c%c %lu 3DS 3DS %lld ", 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' : @@ -1758,7 +1758,7 @@ ftp_session_poll(ftp_session_t *session) static void update_free_space(void) { -#if defined(_3DS) || defined(SWITCH) +#if defined(_3DS) || defined(__SWITCH__) #define KiB (1024.0) #define MiB (1024.0*KiB) #define GiB (1024.0*MiB) @@ -1804,7 +1804,7 @@ update_free_space(void) static int update_status(void) { -#if defined(_3DS) || defined(SWITCH) +#if defined(_3DS) || defined(__SWITCH__) console_set_status("\n" GREEN STATUS_STRING " " #ifdef ENABLE_LOGGING "DEBUG " @@ -1813,7 +1813,7 @@ update_status(void) inet_ntoa(serv_addr.sin_addr), ntohs(serv_addr.sin_port)); update_free_space(); -#elif 0//defined(SWITCH) +#elif 0//defined(__SWITCH__) char hostname[128]; socklen_t addrlen = sizeof(serv_addr); int rc; @@ -1900,7 +1900,7 @@ apt_hook(APT_HookType type, break; } } -#elif defined(SWITCH) +#elif defined(__SWITCH__) /*! Handle applet events * * @param[in] type Event type @@ -1983,7 +1983,7 @@ ftp_init(void) console_print(RED "socInit: %08X\n" RESET, (unsigned int)ret); goto soc_fail; } -#elif defined(SWITCH) +#elif defined(__SWITCH__) static const SocketInitConfig socketInitConfig = { .bsdsockets_version = 1, @@ -2108,7 +2108,7 @@ ftp_exit(void) console_print(RED "socExit: 0x%08X\n" RESET, (unsigned int)ret); free(SOCU_buffer); } -#elif defined(SWITCH) +#elif defined(__SWITCH__) /* deinitialize socket driver */ console_render(); console_print(CYAN "Waiting for socketExit()...\n" RESET); @@ -2177,7 +2177,7 @@ ftp_loop(void) lcd_power = !lcd_power; apt_hook(APTHOOK_ONRESTORE, NULL); } -#elif defined(SWITCH) +#elif defined(__SWITCH__) /* check if the user wants to exit */ hidScanInput(); u32 down = hidKeysDown(CONTROLLER_P1_AUTO); @@ -3496,7 +3496,7 @@ FTP_DECLARE(PASV) /* grab a new port */ session->pasv_addr.sin_port = htons(next_data_port()); -#if defined(_3DS) || defined(SWITCH) +#if defined(_3DS) || defined(__SWITCH__) console_print(YELLOW "binding to %s:%u\n" RESET, inet_ntoa(session->pasv_addr.sin_addr), ntohs(session->pasv_addr.sin_port)); diff --git a/source/main.c b/source/main.c index edce2e8..27b887f 100644 --- a/source/main.c +++ b/source/main.c @@ -6,7 +6,7 @@ #include #ifdef _3DS #include <3ds.h> -#elif defined(SWITCH) +#elif defined(__SWITCH__) #include #endif #include "console.h" @@ -32,7 +32,7 @@ loop(loop_status_t (*callback)(void)) return status; } return LOOP_EXIT; -#elif defined(SWITCH) +#elif defined(__SWITCH__) while(appletMainLoop()) { status = callback(); @@ -66,7 +66,7 @@ wait_for_b(void) /* B was not pressed */ return LOOP_CONTINUE; } -#elif defined(SWITCH) +#elif defined(__SWITCH__) /*! wait until the B button is pressed * * @returns loop status @@ -105,7 +105,7 @@ main(int argc, gfxInitDefault(); gfxSet3D(false); sdmcWriteSafe(false); -#elif defined(SWITCH) +#elif defined(__SWITCH__) //gfxInitResolution(644, 480); gfxInitDefault(); #endif @@ -155,7 +155,7 @@ main(int argc, status = LOOP_EXIT; } -#if defined(_3DS) || defined(SWITCH) +#if defined(_3DS) || defined(__SWITCH__) console_print("Press B to exit\n"); #endif @@ -171,7 +171,7 @@ log_fail: /* deinitialize 3DS services */ gfxExit(); acExit(); -#elif defined(SWITCH) +#elif defined(__SWITCH__) loop(wait_for_b); /* deinitialize Switch services */