Make changes to work with latest libnx

This commit is contained in:
TuxSH 2018-05-04 02:19:18 +02:00 committed by mtheall
parent 8338a11bd3
commit 177f00ac63
6 changed files with 26 additions and 25 deletions

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
build/*
build.* build.*
output/ output/
ftpd ftpd

View File

@ -50,7 +50,7 @@ CFLAGS := -g -Wall -O2 \
-ffast-math \ -ffast-math \
$(ARCH) $(DEFINES) $(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 CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++11

View File

@ -2,11 +2,11 @@
#ifdef _3DS #ifdef _3DS
#include <3ds.h> #include <3ds.h>
#elif defined(SWITCH) #elif defined(__SWITCH__)
#include <switch.h> #include <switch.h>
#endif #endif
#if defined(_3DS) || defined(SWITCH) #if defined(_3DS) || defined(__SWITCH__)
#define ESC(x) "\x1b[" #x #define ESC(x) "\x1b[" #x
#define RESET ESC(0m) #define RESET ESC(0m)
#define BLACK ESC(30m) #define BLACK ESC(30m)

View File

@ -10,7 +10,7 @@
#include <3ds.h> #include <3ds.h>
#define CONSOLE_WIDTH 50 #define CONSOLE_WIDTH 50
#define CONSOLE_HEIGHT 30 #define CONSOLE_HEIGHT 30
#elif defined(SWITCH) #elif defined(__SWITCH__)
#include <switch.h> #include <switch.h>
#define CONSOLE_WIDTH 80 #define CONSOLE_WIDTH 80
#define CONSOLE_HEIGHT 45 #define CONSOLE_HEIGHT 45
@ -134,7 +134,7 @@ print_tcp_table(void)
#endif #endif
} }
#elif defined(SWITCH) #elif defined(__SWITCH__)
/*! initialize console subsystem */ /*! initialize console subsystem */
void void
console_init(void) console_init(void)
@ -149,7 +149,7 @@ console_init(void)
} }
#endif #endif
#if defined(_3DS) || defined(SWITCH) #if defined(_3DS) || defined(__SWITCH__)
/*! set status bar contents /*! set status bar contents

View File

@ -26,7 +26,7 @@
#ifdef _3DS #ifdef _3DS
#include <3ds.h> #include <3ds.h>
#define lstat stat #define lstat stat
#elif defined(SWITCH) #elif defined(__SWITCH__)
#include <switch.h> #include <switch.h>
#define lstat stat #define lstat stat
#else #else
@ -37,7 +37,7 @@
#define POLL_UNKNOWN (~(POLLIN|POLLPRI|POLLOUT)) #define POLL_UNKNOWN (~(POLLIN|POLLPRI|POLLOUT))
#ifndef SWITCH #ifndef __SWITCH__
#define XFER_BUFFERSIZE 32768 #define XFER_BUFFERSIZE 32768
#define SOCK_BUFFERSIZE 32768 #define SOCK_BUFFERSIZE 32768
#define FILE_BUFFERSIZE 65536 #define FILE_BUFFERSIZE 65536
@ -266,7 +266,7 @@ static bool lcd_power = true;
/*! aptHook cookie */ /*! aptHook cookie */
static aptHookCookie cookie; static aptHookCookie cookie;
#elif defined(SWITCH) #elif defined(__SWITCH__)
/*! appletHook cookie */ /*! appletHook cookie */
static AppletHookCookie cookie; static AppletHookCookie cookie;
@ -750,7 +750,7 @@ ftp_session_fill_dirent_type(ftp_session_t *session, const struct stat *st,
type = "file"; type = "file";
else if(S_ISDIR(st->st_mode)) else if(S_ISDIR(st->st_mode))
type = "dir"; type = "dir";
#if !defined(_3DS) && !defined(SWITCH) #if !defined(_3DS) && !defined(__SWITCH__)
else if(S_ISLNK(st->st_mode)) else if(S_ISLNK(st->st_mode))
type = "os.unix=symlink"; type = "os.unix=symlink";
else if(S_ISCHR(st->st_mode)) 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 ", "%c%c%c%c%c%c%c%c%c%c %lu 3DS 3DS %lld ",
S_ISREG(st->st_mode) ? '-' : S_ISREG(st->st_mode) ? '-' :
S_ISDIR(st->st_mode) ? 'd' : S_ISDIR(st->st_mode) ? 'd' :
#if !defined(_3DS) && !defined(SWITCH) #if !defined(_3DS) && !defined(__SWITCH__)
S_ISLNK(st->st_mode) ? 'l' : S_ISLNK(st->st_mode) ? 'l' :
S_ISCHR(st->st_mode) ? 'c' : S_ISCHR(st->st_mode) ? 'c' :
S_ISBLK(st->st_mode) ? 'b' : S_ISBLK(st->st_mode) ? 'b' :
@ -1758,7 +1758,7 @@ ftp_session_poll(ftp_session_t *session)
static void static void
update_free_space(void) update_free_space(void)
{ {
#if defined(_3DS) || defined(SWITCH) #if defined(_3DS) || defined(__SWITCH__)
#define KiB (1024.0) #define KiB (1024.0)
#define MiB (1024.0*KiB) #define MiB (1024.0*KiB)
#define GiB (1024.0*MiB) #define GiB (1024.0*MiB)
@ -1804,7 +1804,7 @@ update_free_space(void)
static int static int
update_status(void) update_status(void)
{ {
#if defined(_3DS) || defined(SWITCH) #if defined(_3DS) || defined(__SWITCH__)
console_set_status("\n" GREEN STATUS_STRING " " console_set_status("\n" GREEN STATUS_STRING " "
#ifdef ENABLE_LOGGING #ifdef ENABLE_LOGGING
"DEBUG " "DEBUG "
@ -1813,7 +1813,7 @@ update_status(void)
inet_ntoa(serv_addr.sin_addr), inet_ntoa(serv_addr.sin_addr),
ntohs(serv_addr.sin_port)); ntohs(serv_addr.sin_port));
update_free_space(); update_free_space();
#elif 0//defined(SWITCH) #elif 0//defined(__SWITCH__)
char hostname[128]; char hostname[128];
socklen_t addrlen = sizeof(serv_addr); socklen_t addrlen = sizeof(serv_addr);
int rc; int rc;
@ -1900,7 +1900,7 @@ apt_hook(APT_HookType type,
break; break;
} }
} }
#elif defined(SWITCH) #elif defined(__SWITCH__)
/*! Handle applet events /*! Handle applet events
* *
* @param[in] type Event type * @param[in] type Event type
@ -1983,7 +1983,7 @@ ftp_init(void)
console_print(RED "socInit: %08X\n" RESET, (unsigned int)ret); console_print(RED "socInit: %08X\n" RESET, (unsigned int)ret);
goto soc_fail; goto soc_fail;
} }
#elif defined(SWITCH) #elif defined(__SWITCH__)
static const SocketInitConfig socketInitConfig = { static const SocketInitConfig socketInitConfig = {
.bsdsockets_version = 1, .bsdsockets_version = 1,
@ -2108,7 +2108,7 @@ ftp_exit(void)
console_print(RED "socExit: 0x%08X\n" RESET, (unsigned int)ret); console_print(RED "socExit: 0x%08X\n" RESET, (unsigned int)ret);
free(SOCU_buffer); free(SOCU_buffer);
} }
#elif defined(SWITCH) #elif defined(__SWITCH__)
/* deinitialize socket driver */ /* deinitialize socket driver */
console_render(); console_render();
console_print(CYAN "Waiting for socketExit()...\n" RESET); console_print(CYAN "Waiting for socketExit()...\n" RESET);
@ -2177,7 +2177,7 @@ ftp_loop(void)
lcd_power = !lcd_power; lcd_power = !lcd_power;
apt_hook(APTHOOK_ONRESTORE, NULL); apt_hook(APTHOOK_ONRESTORE, NULL);
} }
#elif defined(SWITCH) #elif defined(__SWITCH__)
/* check if the user wants to exit */ /* check if the user wants to exit */
hidScanInput(); hidScanInput();
u32 down = hidKeysDown(CONTROLLER_P1_AUTO); u32 down = hidKeysDown(CONTROLLER_P1_AUTO);
@ -3496,7 +3496,7 @@ FTP_DECLARE(PASV)
/* grab a new port */ /* grab a new port */
session->pasv_addr.sin_port = htons(next_data_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, console_print(YELLOW "binding to %s:%u\n" RESET,
inet_ntoa(session->pasv_addr.sin_addr), inet_ntoa(session->pasv_addr.sin_addr),
ntohs(session->pasv_addr.sin_port)); ntohs(session->pasv_addr.sin_port));

View File

@ -6,7 +6,7 @@
#include <unistd.h> #include <unistd.h>
#ifdef _3DS #ifdef _3DS
#include <3ds.h> #include <3ds.h>
#elif defined(SWITCH) #elif defined(__SWITCH__)
#include <switch.h> #include <switch.h>
#endif #endif
#include "console.h" #include "console.h"
@ -32,7 +32,7 @@ loop(loop_status_t (*callback)(void))
return status; return status;
} }
return LOOP_EXIT; return LOOP_EXIT;
#elif defined(SWITCH) #elif defined(__SWITCH__)
while(appletMainLoop()) while(appletMainLoop())
{ {
status = callback(); status = callback();
@ -66,7 +66,7 @@ wait_for_b(void)
/* B was not pressed */ /* B was not pressed */
return LOOP_CONTINUE; return LOOP_CONTINUE;
} }
#elif defined(SWITCH) #elif defined(__SWITCH__)
/*! wait until the B button is pressed /*! wait until the B button is pressed
* *
* @returns loop status * @returns loop status
@ -105,7 +105,7 @@ main(int argc,
gfxInitDefault(); gfxInitDefault();
gfxSet3D(false); gfxSet3D(false);
sdmcWriteSafe(false); sdmcWriteSafe(false);
#elif defined(SWITCH) #elif defined(__SWITCH__)
//gfxInitResolution(644, 480); //gfxInitResolution(644, 480);
gfxInitDefault(); gfxInitDefault();
#endif #endif
@ -155,7 +155,7 @@ main(int argc,
status = LOOP_EXIT; status = LOOP_EXIT;
} }
#if defined(_3DS) || defined(SWITCH) #if defined(_3DS) || defined(__SWITCH__)
console_print("Press B to exit\n"); console_print("Press B to exit\n");
#endif #endif
@ -171,7 +171,7 @@ log_fail:
/* deinitialize 3DS services */ /* deinitialize 3DS services */
gfxExit(); gfxExit();
acExit(); acExit();
#elif defined(SWITCH) #elif defined(__SWITCH__)
loop(wait_for_b); loop(wait_for_b);
/* deinitialize Switch services */ /* deinitialize Switch services */