mktemp.c revision 7c4dcc5546f9f002dfc2b95de47c90f00d07c066
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*
* Create unique plain files or directories.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <locale.h>
static void
usage(void)
{
gettext("Usage: mktemp [-dqtu] [-p prefix_dir] [template]\n"));
exit(1);
/* NOTREACHED */
}
int
{
int opt;
char template[] = "tmp.XXXXXX";
char *tmpl;
#ifndef TEXT_DOMAIN
#define TEXT_DOMAIN "SYS_TEST"
#endif
(void) textdomain(TEXT_DOMAIN);
opterr = 0;
switch (opt) {
case 'd':
break;
case 'q':
break;
case 'p':
/* FALLTHROUGH - -p implies -t */
case 't':
break;
case 'u':
break;
default:
usage();
}
}
switch (argc) {
case 0:
break;
case 1:
break;
default:
usage();
}
if (usetmpdir) {
gettext("mktemp: template argument specified "
"with -t/-p option must not contain '/'"
"\n"));
return (1);
}
/* TMPDIR overrides -p so that scripts will honor $TMPDIR */
prefix = "/tmp";
perror("malloc");
return (1);
}
}
if (domkdir) {
if (!quiet) {
gettext("mktemp: failed to create "
"directory: %s\n"), tmpl);
}
return (1);
}
if (dounlink)
} else {
if (!quiet) {
gettext("mktemp: failed to create file: "
"%s\n"), tmpl);
}
return (1);
}
if (dounlink)
}
return (0);
}