Files
fastfetch/src/detection/users/users_linux.c
T

37 lines
745 B
C
Raw Normal View History

2022-10-06 17:47:49 +08:00
#include "fastfetch.h"
#include "users.h"
#if FF_HAVE_UTMPX_H
#include <utmpx.h>
#else
//for Android compatibility
#include <utmp.h>
#define utmpx utmp
#define setutxent setutent
#define getutxent getutent
#endif
void ffDetectUsers(FFlist* users, FFstrbuf* error)
{
struct utmpx* n = NULL;
setutxent();
next:
while((n = getutxent()))
{
if(n->ut_type != USER_PROCESS)
continue;
2023-06-11 12:16:54 +08:00
FF_LIST_FOR_EACH(FFstrbuf, user, *users)
2022-10-06 17:47:49 +08:00
{
2023-06-18 12:51:58 +08:00
if(ffStrbufEqualS(user, n->ut_user))
2022-10-06 17:47:49 +08:00
goto next;
}
ffStrbufInitS((FFstrbuf*)ffListAdd(users), n->ut_user);
}
if(users->length == 0)
ffStrbufAppendS(error, "Unable to detect users");
}