2014-11-23 23:39:00 +01:00
|
|
|
#include <malloc.h>
|
|
|
|
#include <stdarg.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#ifdef _3DS
|
|
|
|
#include <3ds.h>
|
|
|
|
#endif
|
|
|
|
#include "console.h"
|
|
|
|
#include "ftp.h"
|
|
|
|
|
|
|
|
/*! looping mechanism
|
|
|
|
*
|
|
|
|
* @param[in] callback function to call during each iteration
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
loop(int (*callback)(void))
|
|
|
|
{
|
|
|
|
#ifdef _3DS
|
2014-11-25 20:26:37 +01:00
|
|
|
while(aptMainLoop())
|
2014-11-23 23:39:00 +01:00
|
|
|
{
|
2014-11-25 20:26:37 +01:00
|
|
|
if(callback() == 0)
|
2014-11-23 23:39:00 +01:00
|
|
|
console_render();
|
|
|
|
else
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
for(;;)
|
|
|
|
callback();
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/*! wait until the B button is pressed
|
|
|
|
*
|
|
|
|
* @returns -1 if B was pressed
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
wait_for_b(void)
|
|
|
|
{
|
|
|
|
#ifdef _3DS
|
|
|
|
/* update button state */
|
|
|
|
hidScanInput();
|
|
|
|
|
|
|
|
/* check if B was pressed */
|
|
|
|
if(hidKeysDown() & KEY_B)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
/* B was not pressed */
|
|
|
|
return 0;
|
|
|
|
#else
|
|
|
|
return -1;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/*! entry point
|
|
|
|
*
|
|
|
|
* @param[in] argc unused
|
|
|
|
* @param[in] argv unused
|
|
|
|
*
|
|
|
|
* returns exit status
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
main(int argc,
|
|
|
|
char *argv[])
|
|
|
|
{
|
|
|
|
#ifdef _3DS
|
|
|
|
/* initialize needed 3DS services */
|
2015-01-08 15:01:33 +01:00
|
|
|
gfxInitDefault();
|
2014-11-23 23:39:00 +01:00
|
|
|
gfxSet3D(false);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* initialize console subsystem */
|
|
|
|
console_init();
|
2015-01-08 06:26:01 +01:00
|
|
|
console_set_status("\n" GREEN STATUS_STRING RESET);
|
2014-11-23 23:39:00 +01:00
|
|
|
|
|
|
|
/* initialize ftp subsystem */
|
|
|
|
if(ftp_init() == 0)
|
|
|
|
{
|
|
|
|
/* ftp loop */
|
|
|
|
loop(ftp_loop);
|
|
|
|
|
|
|
|
/* done with ftp */
|
|
|
|
ftp_exit();
|
|
|
|
}
|
|
|
|
|
|
|
|
console_print("Press B to exit\n");
|
|
|
|
loop(wait_for_b);
|
|
|
|
|
|
|
|
#ifdef _3DS
|
|
|
|
/* deinitialize 3DS services */
|
|
|
|
gfxExit();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|