Skip to content

Commit 1184b58

Browse files
Merge pull request #13 from BIGBIGSUI/patch-1
nx: add custom command "ACC" fixes #12
2 parents 4d59611 + 04e44a0 commit 1184b58

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

src/platform/nx/custom_commands.c

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -494,6 +494,36 @@ static int ftp_custom_cmd_TRMT(void* userdata, const char* data, char* msg_buf,
494494
return code;
495495
}
496496

497+
static int ftp_custom_cmd_ACC(void* userdata, const char* data, char* msg_buf, unsigned msg_buf_len) {
498+
Result rc;
499+
int code = FTP_DEFAULT_ERROR_CODE;
500+
AccountUid uid;
501+
AccountProfile profile;
502+
AccountProfileBase profilebase;
503+
504+
// Initialize account service
505+
if (R_FAILED(rc = accountInitialize(AccountServiceType_Application))) {
506+
snprintf(msg_buf, msg_buf_len, "Failed: accountInitialize() 0x%08X", rc);
507+
return code;
508+
}
509+
510+
// Get the last opened user
511+
if (R_SUCCEEDED(rc = accountGetLastOpenedUser(&uid))) {
512+
// Get profile for the user
513+
if (R_SUCCEEDED(rc = accountGetProfile(&profile, uid))) {
514+
// Get profile base data
515+
if (R_SUCCEEDED(rc = accountProfileGet(&profile, NULL, &profilebase))) {
516+
code = 200;
517+
snprintf(msg_buf, msg_buf_len, "%016lX %016lX %s", uid.uid[0], uid.uid[1], profilebase.nickname);
518+
}
519+
accountProfileClose(&profile);
520+
}
521+
}
522+
523+
accountExit();
524+
return code;
525+
}
526+
497527
const struct FtpSrvCustomCommand CUSTOM_COMMANDS[] = {
498528
// reboot console
499529
{ "REBT", ftp_custom_cmd_REBT, NULL, 1, 0 },
@@ -509,6 +539,8 @@ const struct FtpSrvCustomCommand CUSTOM_COMMANDS[] = {
509539
{ "TIDS", ftp_custom_cmd_TIDS, NULL, 1, 0 },
510540
// terminate tid
511541
{ "TRMT", ftp_custom_cmd_TRMT, NULL, 1, 1 },
542+
// get current user account
543+
{ "ACC", ftp_custom_cmd_ACC, NULL, 1, 0 },
512544
};
513545

514546
const unsigned CUSTOM_COMMANDS_SIZE = sizeof(CUSTOM_COMMANDS) / sizeof(CUSTOM_COMMANDS[0]);

0 commit comments

Comments
 (0)