coreutils

General Software Utilities
git clone http://git.omkov.net/coreutils
Log | Tree | Refs | README | LICENCE | Download

coreutils/src/logname.c (17 lines, 328 B) -rw-r--r-- file download

c6fc8c9 Jamozed 2020-07-06 22:46:57
0
// logname.c, version 1.0.1
4e723d6 Jamozed 2020-06-26 22:33:17
1
// OMKOV coreutils implementation of POSIX logname
4e723d6 Jamozed 2020-06-26 22:33:17
2
// Copyright (C) 2020, Jakob Wakeling
e2140ec Jamozed 2022-03-06 15:27:45
3
// MIT Licence
4e723d6 Jamozed 2020-06-26 22:33:17
4
b181413 Jamozed 2022-02-05 22:32:00
5
#include "util/error.h"
4e723d6 Jamozed 2020-06-26 22:33:17
6
4e723d6 Jamozed 2020-06-26 22:33:17
7
#include <unistd.h>
4e723d6 Jamozed 2020-06-26 22:33:17
8
4e723d6 Jamozed 2020-06-26 22:33:17
9
#include <stdio.h>
4e723d6 Jamozed 2020-06-26 22:33:17
10
b634f01 Jamozed 2020-07-09 22:11:16
11
int main(void) {
4e723d6 Jamozed 2020-06-26 22:33:17
12
	register char *login = getlogin();
c6fc8c9 Jamozed 2020-07-06 22:46:57
13
	if (!login) { error(1, "%s", serr()); }
b634f01 Jamozed 2020-07-09 22:11:16
14
	else { puts(login); } return 0;
4e723d6 Jamozed 2020-06-26 22:33:17
15
}
16