#include <string.h>
#include <time.h>
#include <unistd.h>
+#include <uuid.h>
#include "c.h"
#include "closestream.h"
#include "optutils.h"
#include "strutils.h"
#include "timeutils.h"
-#include "uuid.h"
#include "xalloc.h"
-#define UUID_STR_LEN 37
-
/* column IDs */
enum {
COL_UUID = 0,
fprintf(stdout, _(" %s [options] <uuid ...>\n"), program_invocation_short_name);
fputs(USAGE_OPTIONS, stdout);
- puts(_(" -J, --json use JSON output format"));
- puts(_(" -n, --noheadings don't print headings"));
- puts(_(" -o, --output <list> COLUMNS to display (see below)"));
- puts(_(" -r, --raw use the raw output format"));
- printf(USAGE_HELP_OPTIONS(24));
+ fputsln(_(" -J, --json use JSON output format"), stdout);
+ fputsln(_(" -n, --noheadings don't print headings"), stdout);
+ fputsln(_(" -o, --output <list> COLUMNS to display (see below)"), stdout);
+ fputsln(_(" -r, --raw use the raw output format"), stdout);
+ fprintf(stdout, USAGE_HELP_OPTIONS(24));
fputs(USAGE_COLUMNS, stdout);
for (i = 0; i < ARRAY_SIZE(infos); i++)
fprintf(stdout, " %8s %s\n", infos[i].name, _(infos[i].help));
- printf(USAGE_MAN_TAIL("uuidparse(1)"));
+ fprintf(stdout, USAGE_MAN_TAIL("uuidparse(1)"));
exit(EXIT_SUCCESS);
}
size_t i;
uuid_t buf;
int invalid = 0;
- int variant, type;
+ int variant = -1, type = -1;
assert(tb);
assert(uuid);
str = xstrdup(_("invalid"));
break;
}
+ if (variant != UUID_VARIANT_DCE)
+ break;
switch (type) {
- case 0:
- if (strspn(uuid, "0-") == 36)
+ case UUID_TYPE_DCE_NIL:
+ if (uuid_is_null(buf))
str = xstrdup(_("nil"));
else
str = xstrdup(_("unknown"));
break;
- case 1:
+ case UUID_TYPE_DCE_TIME:
str = xstrdup(_("time-based"));
break;
- case 2:
+ case UUID_TYPE_DCE_SECURITY:
str = xstrdup("DCE");
break;
- case 3:
+ case UUID_TYPE_DCE_MD5:
str = xstrdup(_("name-based"));
break;
- case 4:
+ case UUID_TYPE_DCE_RANDOM:
str = xstrdup(_("random"));
break;
- case 5:
+ case UUID_TYPE_DCE_SHA1:
str = xstrdup(_("sha1-based"));
break;
default:
str = xstrdup(_("invalid"));
break;
}
- if (variant == UUID_VARIANT_DCE && type == 1) {
+ if (variant == UUID_VARIANT_DCE && type == UUID_TYPE_DCE_TIME) {
struct timeval tv;
- char date_buf[ISO_8601_BUFSIZ + 4];
+ char date_buf[ISO_BUFSIZ];
uuid_time(buf, &tv);
- strtimeval_iso(&tv,
- ISO_8601_DATE |
- ISO_8601_TIME |
- ISO_8601_COMMAUSEC |
- ISO_8601_TIMEZONE |
- ISO_8601_SPACE,
- date_buf,
- sizeof(date_buf));
+ strtimeval_iso(&tv, ISO_TIMESTAMP_COMMA,
+ date_buf, sizeof(date_buf));
str = xstrdup(date_buf);
}
break;
if (i == 0) {
char uuid[UUID_STR_LEN];
- while (scanf(" %" stringify_value(UUID_STR_LEN)
- "[^ \t\n]%*c", uuid) && !feof(stdin))
+ while (scanf(" %36[^ \t\n]%*c", uuid) && !feof(stdin))
fill_table_row(tb, uuid);
}
scols_print_table(tb);
setlocale(LC_ALL, "");
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
- atexit(close_stdout);
+ close_stdout_atexit();
while ((c = getopt_long(argc, argv, "Jno:rVh", longopts, NULL)) != -1) {
err_exclusive_options(c, longopts, excl, excl_st);
case 'r':
ctrl.raw = 1;
break;
+
case 'V':
- printf(UTIL_LINUX_VERSION);
- return EXIT_SUCCESS;
+ print_version(EXIT_SUCCESS);
case 'h':
usage();
default: