summaryrefslogtreecommitdiffstats
path: root/tests/helpers/test_uuid_namespace.c
blob: 3ee6aca688dd68a7edcba03c4b57d8d8c73558cc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/*
 * SPDX-License-Identifier: GPL-2.0-or-later
 *
 * Copyright (C) 2017 Philip Prindeville <philipp@redfish-solutions.com>
 */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include "../libuuid/src/uuid.h"

static void get_template(const char *ns)
{
	const uuid_t *uuidptr;
	char buf[UUID_STR_LEN];

	uuidptr = uuid_get_template(ns);
	if (uuidptr == NULL)
		strcpy(buf, "NULL");
	else
		uuid_unparse_lower(*uuidptr, buf);

	printf("uuid_get_template %s returns %s\n", (ns ? ns : "NULL"), buf);
}

int main(void)
{
	get_template("dns");

	get_template("url");

	get_template("oid");

	get_template("x500");

	get_template(NULL);
	get_template("");
	get_template("unknown");

	exit(0);
}