[BusyBox-cvs] busybox/debianutils mktemp.c,1.2,1.3
Glenn McGrath
bug1 at busybox.net
Sat Apr 26 04:56:20 UTC 2003
Update of /var/cvs/busybox/debianutils
In directory winder:/tmp/cvs-serv2865/debianutils
Modified Files:
mktemp.c
Log Message:
Add the -d option, its used by old versions of config.guess, change to
use getopt.
Index: mktemp.c
===================================================================
RCS file: /var/cvs/busybox/debianutils/mktemp.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- mktemp.c 19 Mar 2003 09:11:41 -0000 1.2
+++ mktemp.c 26 Apr 2003 04:56:17 -0000 1.3
@@ -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;
}
More information about the busybox-cvs
mailing list