mirror of
https://github.com/switchbrew/libnx.git
synced 2025-07-05 02:52:13 +02:00
Added wrapper for accountListAllUsers
This commit is contained in:
parent
fe4fe73513
commit
a590ed50da
@ -39,10 +39,12 @@ Service* accountGetService(void);
|
||||
Result accountGetUserCount(s32* user_count);
|
||||
|
||||
/**
|
||||
* @brief Get a list of all user IDs
|
||||
* @param userIDs Pointer to array of user IDs, array must be exactly ACC_USER_LIST_SIZE
|
||||
* @brief Get a list of all user IDs. The returned list will never be larger than ACC_USER_LIST_SIZE
|
||||
* @param userIDs Pointer to array of user IDs
|
||||
* @param max_userIDs Maximum number of user IDs to return
|
||||
* @param actual_total The actual total number of user IDs found
|
||||
*/
|
||||
Result accountListAllUsers(u128* userIDs);
|
||||
Result accountListAllUsers(u128* userIDs, size_t max_userIDs, size_t *actual_total);
|
||||
|
||||
/// Get the userID for the currently active user. The output userID is only valid when the output account_selected==1, otherwise no user is currently selected.
|
||||
/// An user is only selected when the user-account selection applet was used to select an user at least once before.
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include <string.h>
|
||||
#include <malloc.h>
|
||||
|
||||
#include "types.h"
|
||||
#include "arm/atomics.h"
|
||||
@ -70,7 +71,7 @@ Result accountGetUserCount(s32* user_count)
|
||||
return rc;
|
||||
}
|
||||
|
||||
Result accountListAllUsers(u128* userIDs)
|
||||
static Result _accountListAllUsers(u128* userIDs)
|
||||
{
|
||||
IpcCommand c;
|
||||
ipcInitialize(&c);
|
||||
@ -108,6 +109,38 @@ Result accountListAllUsers(u128* userIDs)
|
||||
return rc;
|
||||
}
|
||||
|
||||
Result accountListAllUsers(u128* userIDs, size_t max_userIDs, size_t *actual_total)
|
||||
{
|
||||
Result rc=0;
|
||||
|
||||
u128 *temp_userIDs;
|
||||
temp_userIDs = malloc(sizeof(u128) * ACC_USER_LIST_SIZE);
|
||||
|
||||
rc = _accountListAllUsers(temp_userIDs);
|
||||
|
||||
if (R_SUCCEEDED(rc)) {
|
||||
size_t total_userIDs = 0;
|
||||
|
||||
for (int i = 0; i < ACC_USER_LIST_SIZE; i++) {
|
||||
if (temp_userIDs[i]) {
|
||||
total_userIDs++;
|
||||
}
|
||||
}
|
||||
|
||||
if (max_userIDs > total_userIDs) {
|
||||
max_userIDs = total_userIDs;
|
||||
}
|
||||
|
||||
for (int i = 0; i < max_userIDs; i++) {
|
||||
userIDs[i] = temp_userIDs[i];
|
||||
}
|
||||
|
||||
*actual_total = total_userIDs;
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
Result accountGetActiveUser(u128 *userID, bool *account_selected)
|
||||
{
|
||||
IpcCommand c;
|
||||
|
Loading…
Reference in New Issue
Block a user