/*- * Copyright (c) 1991, 1993 * The Regents of the University of California. All rights reserved. * * %sccs.include.redist.c% */ #ifndef lint static char copyright[] = "@(#) Copyright (c) 1991, 1993\n\ The Regents of the University of California. All rights reserved.\n"; #endif /* not lint */ #ifndef lint static char sccsid[] = "@(#)logname.c 8.1 (Berkeley) 06/09/93"; #endif /* not lint */ #include #include #include #include #include main(argc, argv) int argc; char *argv[]; { int ch; char *p; while ((ch = getopt(argc, argv, "")) != EOF) switch(ch) { case '?': default: usage(); } argc -= optind; argv += optind; if ((p = getlogin()) == NULL) { (void)fprintf(stderr, "logname: %s\n", strerror(errno)); exit(1); } (void)printf("%s\n", p); exit(0); } usage() { (void)fprintf(stderr, "usage: logname\n"); exit(1); }