Changeset View
Changeset View
Standalone View
Standalone View
usr.bin/mktemp/mktemp.c
Show First 20 Lines • Show All 91 Lines • ▼ Show 20 Lines | main(int argc, char **argv) | ||||
if (!tflag && argc < 1) { | if (!tflag && argc < 1) { | ||||
tflag = 1; | tflag = 1; | ||||
prefix = "tmp"; | prefix = "tmp"; | ||||
} | } | ||||
if (tflag) { | if (tflag) { | ||||
tmpdir = getenv("TMPDIR"); | tmpdir = getenv("TMPDIR"); | ||||
if (tmpdir == NULL) | if (tmpdir == NULL) | ||||
asprintf(&name, "%s%s.XXXXXXXX", _PATH_TMP, prefix); | asprintf(&name, "%s%s.XXXXXXXXXX", _PATH_TMP, prefix); | ||||
else | else | ||||
asprintf(&name, "%s/%s.XXXXXXXX", tmpdir, prefix); | asprintf(&name, "%s/%s.XXXXXXXXXX", tmpdir, prefix); | ||||
/* if this fails, the program is in big trouble already */ | /* if this fails, the program is in big trouble already */ | ||||
if (name == NULL) { | if (name == NULL) { | ||||
if (qflag) | if (qflag) | ||||
return (1); | return (1); | ||||
else | else | ||||
errx(1, "cannot generate template"); | errx(1, "cannot generate template"); | ||||
} | } | ||||
} | } | ||||
▲ Show 20 Lines • Show All 48 Lines • Show Last 20 Lines |