source: MondoRescue/branches/2.2.5/mindi-busybox/debianutils/mktemp.c

Last change on this file was 1765, checked in by Bruno Cornec, 17 years ago

Update to busybox 1.7.2

File size: 815 bytes
RevLine 
[821]1/* vi: set sw=4 ts=4: */
2/*
3 * Mini mktemp implementation for busybox
4 *
5 *
6 * Copyright (C) 2000 by Daniel Jacobowitz
7 * Written by Daniel Jacobowitz <dan@debian.org>
8 *
9 * Licensed under the GPL v2 or later, see the file LICENSE in this tarball.
10 */
11
[1765]12#include "libbb.h"
[821]13
[1765]14int mktemp_main(int argc, char **argv);
[821]15int mktemp_main(int argc, char **argv)
16{
[1765]17 unsigned long flags = getopt32(argv, "dqt");
18 char *chp;
[821]19
20 if (optind + 1 != argc)
21 bb_show_usage();
22
[1765]23 chp = argv[optind];
24
25 if (flags & 4) {
26 char *dir = getenv("TMPDIR");
27 if (dir && *dir != '\0')
28 chp = concat_path_file(dir, chp);
29 else
30 chp = concat_path_file("/tmp/", chp);
31 }
32
[821]33 if (flags & 1) {
[1765]34 if (mkdtemp(chp) == NULL)
[821]35 return EXIT_FAILURE;
[1765]36 } else {
37 if (mkstemp(chp) < 0)
[821]38 return EXIT_FAILURE;
39 }
40
[1765]41 puts(chp);
[821]42
43 return EXIT_SUCCESS;
44}
Note: See TracBrowser for help on using the repository browser.