annotate toys/posix/logname.c @ 656:6df4ccc0acbe

Regularize command headers, update links to standards documents.
author Rob Landley <rob@landley.net>
date Sat, 25 Aug 2012 18:08:51 -0500
parents 2986aa63a021
children 10ad87be2c55
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
568
d5fb52b428ed Adding logname
Elie De Brauwer <eliedebrauwer@gmail.com>
parents:
diff changeset
1 /* vi: set sw=4 ts=4:
d5fb52b428ed Adding logname
Elie De Brauwer <eliedebrauwer@gmail.com>
parents:
diff changeset
2 *
d5fb52b428ed Adding logname
Elie De Brauwer <eliedebrauwer@gmail.com>
parents:
diff changeset
3 * logname.c - Print user's login name.
d5fb52b428ed Adding logname
Elie De Brauwer <eliedebrauwer@gmail.com>
parents:
diff changeset
4 *
d5fb52b428ed Adding logname
Elie De Brauwer <eliedebrauwer@gmail.com>
parents:
diff changeset
5 * Copyright 2012 Elie De Brauwer <eliedebrauwer@gmail.com>
d5fb52b428ed Adding logname
Elie De Brauwer <eliedebrauwer@gmail.com>
parents:
diff changeset
6 *
656
6df4ccc0acbe Regularize command headers, update links to standards documents.
Rob Landley <rob@landley.net>
parents: 653
diff changeset
7 * See http://opengroup.org/onlinepubs/9699919799/utilities/logname.html
568
d5fb52b428ed Adding logname
Elie De Brauwer <eliedebrauwer@gmail.com>
parents:
diff changeset
8
d5fb52b428ed Adding logname
Elie De Brauwer <eliedebrauwer@gmail.com>
parents:
diff changeset
9 USE_LOGNAME(NEWTOY(logname, ">0", TOYFLAG_BIN))
d5fb52b428ed Adding logname
Elie De Brauwer <eliedebrauwer@gmail.com>
parents:
diff changeset
10
d5fb52b428ed Adding logname
Elie De Brauwer <eliedebrauwer@gmail.com>
parents:
diff changeset
11 config LOGNAME
d5fb52b428ed Adding logname
Elie De Brauwer <eliedebrauwer@gmail.com>
parents:
diff changeset
12 bool "logname"
d5fb52b428ed Adding logname
Elie De Brauwer <eliedebrauwer@gmail.com>
parents:
diff changeset
13 default y
d5fb52b428ed Adding logname
Elie De Brauwer <eliedebrauwer@gmail.com>
parents:
diff changeset
14 help
d5fb52b428ed Adding logname
Elie De Brauwer <eliedebrauwer@gmail.com>
parents:
diff changeset
15 usage: logname
d5fb52b428ed Adding logname
Elie De Brauwer <eliedebrauwer@gmail.com>
parents:
diff changeset
16
d5fb52b428ed Adding logname
Elie De Brauwer <eliedebrauwer@gmail.com>
parents:
diff changeset
17 Prints the calling user's name or an error when this cannot be
d5fb52b428ed Adding logname
Elie De Brauwer <eliedebrauwer@gmail.com>
parents:
diff changeset
18 determined.
d5fb52b428ed Adding logname
Elie De Brauwer <eliedebrauwer@gmail.com>
parents:
diff changeset
19 */
d5fb52b428ed Adding logname
Elie De Brauwer <eliedebrauwer@gmail.com>
parents:
diff changeset
20
d5fb52b428ed Adding logname
Elie De Brauwer <eliedebrauwer@gmail.com>
parents:
diff changeset
21 #include "toys.h"
d5fb52b428ed Adding logname
Elie De Brauwer <eliedebrauwer@gmail.com>
parents:
diff changeset
22
d5fb52b428ed Adding logname
Elie De Brauwer <eliedebrauwer@gmail.com>
parents:
diff changeset
23 void logname_main(void)
d5fb52b428ed Adding logname
Elie De Brauwer <eliedebrauwer@gmail.com>
parents:
diff changeset
24 {
d5fb52b428ed Adding logname
Elie De Brauwer <eliedebrauwer@gmail.com>
parents:
diff changeset
25 if (getlogin_r(toybuf, sizeof(toybuf))){
d5fb52b428ed Adding logname
Elie De Brauwer <eliedebrauwer@gmail.com>
parents:
diff changeset
26 error_exit("no login name");
d5fb52b428ed Adding logname
Elie De Brauwer <eliedebrauwer@gmail.com>
parents:
diff changeset
27 }
d5fb52b428ed Adding logname
Elie De Brauwer <eliedebrauwer@gmail.com>
parents:
diff changeset
28 xputs(toybuf);
d5fb52b428ed Adding logname
Elie De Brauwer <eliedebrauwer@gmail.com>
parents:
diff changeset
29 }