diff options
author | Philippe Charnier <charnier@FreeBSD.org> | 1998-05-05 06:13:47 +0000 |
---|---|---|
committer | Philippe Charnier <charnier@FreeBSD.org> | 1998-05-05 06:13:47 +0000 |
commit | d4eaae7abd6d755df561c17cae8795f162f22b6e (patch) | |
tree | f667f2e64dba7ac9b72f1c29ee221b8ff256f38b /usr.bin/mktemp | |
parent | 14a28dc644b0f6f0a7bfda1d55ab2c057be10f9f (diff) | |
download | src-test-d4eaae7abd6d755df561c17cae8795f162f22b6e.tar.gz src-test-d4eaae7abd6d755df561c17cae8795f162f22b6e.zip |
Add usage() and rcsid. Remove unused #include. -Wall.
Notes
Notes:
svn path=/head/; revision=35733
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 0ea4ebfb39419..109769437286c 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 964fe972a167a..381872d45ee45 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); +} |