summaryrefslogtreecommitdiff
path: root/debianutils/mktemp.c
diff options
context:
space:
mode:
authorGlenn L McGrath2003-04-26 04:56:17 +0000
committerGlenn L McGrath2003-04-26 04:56:17 +0000
commit69f28e7c0c2fb0f0efddad47310743d12a2b94d3 (patch)
tree514ae60d57836b1b0113108f4c0359b21c972864 /debianutils/mktemp.c
parentfbf0b8af41eb2662c40d0fb932ae85c01ea0743e (diff)
downloadbusybox-69f28e7c0c2fb0f0efddad47310743d12a2b94d3.zip
busybox-69f28e7c0c2fb0f0efddad47310743d12a2b94d3.tar.gz
Add the -d option, its used by old versions of config.guess, change to
use getopt.
Diffstat (limited to 'debianutils/mktemp.c')
-rw-r--r--debianutils/mktemp.c29
1 files changed, 26 insertions, 3 deletions
diff --git a/debianutils/mktemp.c b/debianutils/mktemp.c
index 9d8de21..ecc985f 100644
--- a/debianutils/mktemp.c
+++ b/debianutils/mktemp.c
@@ -31,10 +31,33 @@
extern int mktemp_main(int argc, char **argv)
{
- if (argc != 2 && (argc != 3 || strcmp(argv[1], "-q")))
+ unsigned char dir_flag = 0;
+ int opt;
+
+ while ((opt = getopt(argc, argv, "qd")) != -1) {
+ if (opt == 'd') {
+ dir_flag = 1;
+ }
+ else if (opt != 'q') {
+ bb_show_usage();
+ }
+ }
+
+ if (optind + 1 != argc) {
bb_show_usage();
- if(mkstemp(argv[argc-1]) < 0)
- return EXIT_FAILURE;
+ }
+
+ if (dir_flag) {
+ if (mkdtemp(argv[argc-1]) == NULL) {
+ return EXIT_FAILURE;
+ }
+ } else {
+ if (mkstemp(argv[argc-1]) < 0) {
+ return EXIT_FAILURE;
+ }
+ }
+
(void) puts(argv[argc-1]);
+
return EXIT_SUCCESS;
}