diff options
author | charnier <charnier@FreeBSD.org> | 1998-05-05 06:13:47 +0000 |
---|---|---|
committer | charnier <charnier@FreeBSD.org> | 1998-05-05 06:13:47 +0000 |
commit | 810a5d762ec2f1bdce027ec79177062cfda53f4f (patch) | |
tree | 87fb67fa7cf6148d636bb3d5b2c2eb45460ae35c /usr.bin/mktemp | |
parent | cbedbdf5b12a19897ba009ad9224e247dd47613b (diff) | |
download | FreeBSD-src-810a5d762ec2f1bdce027ec79177062cfda53f4f.zip FreeBSD-src-810a5d762ec2f1bdce027ec79177062cfda53f4f.tar.gz |
Add usage() and rcsid. Remove unused #include. -Wall.
Diffstat (limited to 'usr.bin/mktemp')
-rw-r--r-- | usr.bin/mktemp/mktemp.1 | 9 | ||||
-rw-r--r-- | usr.bin/mktemp/mktemp.c | 37 |
2 files changed, 27 insertions, 19 deletions
diff --git a/usr.bin/mktemp/mktemp.1 b/usr.bin/mktemp/mktemp.1 index 0ea4ebf..1097694 100644 --- a/usr.bin/mktemp/mktemp.1 +++ b/usr.bin/mktemp/mktemp.1 @@ -47,7 +47,7 @@ .Op Ar template ... .Sh DESCRIPTION The -.Nm mktemp +.Nm utility takes each of the given file name templates and overwrites a portion of it to create a file name. This file name is unique and suitable for use by the application. The template may be @@ -113,8 +113,8 @@ reasons it is suggested that .Nm be used instead. .Sh OPTIONS -.Bl -tag -width indent The available options are as follows: +.Bl -tag -width indent .It Fl d Make a directory instead of a file. .It Fl q @@ -132,7 +132,7 @@ Operate in mode. The temp file will be unlinked before .Nm exits. This is slightly better than -.Fn mktemp 3 +.Xr mktemp 3 but still introduces a race condition. Use of this option is not encouraged. .El @@ -178,5 +178,6 @@ A utility appeared in .Ox 2.1 . This implementation has been written independently based on the man page. -This man page is taken from OpenBSD. +This man page is taken from +.Bx Open . .\" Our stupid .Ox macro won't allow me to use .Ox alone. diff --git a/usr.bin/mktemp/mktemp.c b/usr.bin/mktemp/mktemp.c index 964fe97..381872d 100644 --- a/usr.bin/mktemp/mktemp.c +++ b/usr.bin/mktemp/mktemp.c @@ -23,7 +23,6 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD$ */ /* @@ -35,27 +34,31 @@ * more like the OpenBSD version - which was first to publish the interface. */ -#include <sys/types.h> +#include <err.h> +#include <paths.h> #include <stdio.h> #include <stdlib.h> -#include <unistd.h> -#include <paths.h> -#include <err.h> #include <string.h> +#include <unistd.h> + +#ifndef lint +static const char rcsid[] = + "$FreeBSD$"; +#endif /* not lint */ + +static void usage __P((void)); int main(int argc, char **argv) { int c, fd, ret; - char *usage = "[-d] [-q] [-t prefix] [-u] [template ...]"; char *tmpdir, *prefix; - char *prog; char *name; int dflag, qflag, tflag, uflag; ret = dflag = qflag = tflag = uflag = 0; + prefix = "mktemp"; name = NULL; - prog = argv[0]; /* XXX basename(argv[0]) */ while ((c = getopt(argc, argv, "dqt:u")) != -1) switch (c) { @@ -77,8 +80,7 @@ main(int argc, char **argv) break; default: - fprintf(stderr, "Usage: %s %s\n", prog, usage); - return (1); + usage(); } argc -= optind; @@ -86,8 +88,6 @@ main(int argc, char **argv) if (tflag) { tmpdir = getenv("TMPDIR"); - if (prefix == NULL) - prefix = "mktemp"; /* shouldn't happen, but.. */ if (tmpdir == NULL) asprintf(&name, "%s%s.XXXXXXXX", _PATH_TMP, prefix); else @@ -97,11 +97,10 @@ main(int argc, char **argv) if (qflag) return (1); else - err(1, "cannot generate template"); + errx(1, "cannot generate template"); } } else if (argc < 1) { - fprintf(stderr, "Usage: %s %s\n", prog, usage); - return (1); + usage(); } /* generate all requested files */ @@ -141,3 +140,11 @@ main(int argc, char **argv) } return (ret); } + +static void +usage() +{ + fprintf(stderr, + "usage: mktemp [-d] [-q] [-t prefix] [-u] [template ...]\n"); + exit (1); +} |