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

37 lines
754 B
C
Raw Normal View History

2022-10-06 17:47:49 +08:00
#include "fastfetch.h"
#include "users.h"
2023-08-14 10:05:43 +08:00
#if __has_include(<utmpx.h>)
2022-10-06 17:47:49 +08:00
#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");
}