2 * This file and its contents are supplied under the terms of the
3 * Common Development and Distribution License ("CDDL"), version 1.0.
4 * You may only use this file in accordance with the terms of version
7 * A full copy of the text of the CDDL should have accompanied this
8 * source. A copy of the CDDL is also available via the Internet at
9 * http://www.illumos.org/license/CDDL.
13 * Copyright 2015 Nexenta Systems, Inc. All rights reserved.
19 #include <uuid/uuid.h>
23 static char *progname
;
24 static int rflag
, tflag
;
25 static char uu_string
[UUID_PRINTABLE_STRING_LENGTH
];
30 (void) fprintf(stderr
, gettext(
31 "Usage: %s [-r | -t] [-o filename]\n"), progname
);
36 main(int argc
, char *argv
[])
42 (void) setlocale(LC_ALL
, "");
44 #if !defined(TEXT_DOMAIN)
45 #define TEXT_DOMAIN "SYS_TEST"
47 (void) textdomain(TEXT_DOMAIN
);
49 progname
= basename(argv
[0]);
51 while ((c
= getopt(argc
, argv
, ":rto:")) != EOF
) {
60 if ((out
= fopen(optarg
, "w")) == NULL
) {
61 (void) fprintf(stderr
, gettext(
62 "%s: cannot open %s\n"),
67 case '?': /* fallthrough */
73 if ((rflag
&& tflag
) || optind
!= argc
) {
79 uuid_generate_random(uu
);
82 uuid_generate_time(uu
);
87 if (uuid_is_null(uu
) != 0) {
88 (void) fprintf(stderr
, gettext(
90 "generate uuid\n"), progname
);
94 uuid_unparse(uu
, uu_string
);
96 (void) fprintf(out
, "%s\n", uu_string
);
98 if (out
!= NULL
&& out
!= stdout
)