File: utmpx-wrapper.c

package info (click to toggle)
wuzzah 0.53-3.1
  • links: PTS
  • area: main
  • in suites: bookworm, bullseye
  • size: 596 kB
  • sloc: ansic: 1,830; sh: 330; makefile: 36
file content (20 lines) | stat: -rw-r--r-- 498 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include "utmpx-wrapper.h"

static int ut_fd = -1;
static STRUCT_UTMPX cur;

void setutent_wrapper(void){
	ut_fd = open(_PATH_UTMP, O_RDONLY);
	if(ut_fd < 0) bail("shit man, no utmp record?", 1);
}

STRUCT_UTMPX *getutent_wrapper(void){
	int amt_read = read(ut_fd, &cur, sizeof(STRUCT_UTMPX));
	if(amt_read < 0) bail("error reading utmp record", 1);
	else if(amt_read == 0) return NULL;
	else return &cur;
}

void endutent_wrapper(void){
	if(close(ut_fd)<0) bail("error closing utmpx file!", 1);
}