From 3632ce21b7c3f9c564c3c0f962c4840719f1c2d6 Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Wed, 23 May 2012 09:37:38 +0200 Subject: build-sys: convert libuuid/ to module Signed-off-by: Karel Zak --- Makefile.am | 19 +++-- config/include-Makefile.am | 6 +- configure.ac | 3 - libuuid/Makefile.am | 9 --- libuuid/Makemodule.am | 9 +++ libuuid/man/Makefile.am | 23 ------ libuuid/man/Makemodule.am | 22 ++++++ libuuid/src/Makefile.am | 53 ------------- libuuid/src/Makemodule.am | 56 ++++++++++++++ libuuid/src/gen_uuid_nt.c | 92 ----------------------- libuuid/src/test_uuid.c | 180 +++++++++++++++++++++++++++++++++++++++++++++ libuuid/src/tst_uuid.c | 180 --------------------------------------------- 12 files changed, 282 insertions(+), 370 deletions(-) delete mode 100644 libuuid/Makefile.am create mode 100644 libuuid/Makemodule.am delete mode 100644 libuuid/man/Makefile.am create mode 100644 libuuid/man/Makemodule.am delete mode 100644 libuuid/src/Makefile.am create mode 100644 libuuid/src/Makemodule.am delete mode 100644 libuuid/src/gen_uuid_nt.c create mode 100644 libuuid/src/test_uuid.c delete mode 100644 libuuid/src/tst_uuid.c diff --git a/Makefile.am b/Makefile.am index 8e9171a61..cc23b7a76 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,15 +1,23 @@ include $(top_srcdir)/config/include-Makefile.am +pkgconfigdir = $(usrlib_execdir)/pkgconfig + dist_noinst_HEADERS = noinst_PROGRAMS = usrbin_exec_PROGRAMS = dist_man_MANS = +man_MANS = +pkgconfig_DATA = +usrlib_exec_LTLIBRARIES = -SHLIBS_DIRS = +INSTALL_EXEC_HOOKS = +UNINSTALL_HOOKS = -if BUILD_LIBUUID -SHLIBS_DIRS += libuuid -endif +EXTRA_DIST = +CLEANFILES = + + +SHLIBS_DIRS = if BUILD_LIBBLKID SHLIBS_DIRS += libblkid @@ -55,7 +63,7 @@ endif AUTOMAKE_OPTIONS = gnu ACLOCAL_AMFLAGS = -I m4 -EXTRA_DIST = \ +EXTRA_DIST += \ .version \ autogen.sh \ Documentation \ @@ -66,6 +74,7 @@ EXTRA_DIST = \ include include/Makemodule.am include lib/Makemodule.am include schedutils/Makemodule.am +include libuuid/Makemodule.am # Arrange so that .tarball-version appears only in the distribution diff --git a/config/include-Makefile.am b/config/include-Makefile.am index 4983b3c19..9f87e1eaa 100644 --- a/config/include-Makefile.am +++ b/config/include-Makefile.am @@ -28,11 +28,7 @@ $(ul_libblkid_la): # uuid ul_libuuid_srcdir = $(top_srcdir)/libuuid/src ul_libuuid_builddir = $(top_builddir)/libuuid/src -ul_libuuid_la = $(top_builddir)/libuuid/src/libuuid.la - -$(ul_libuuid_la): - $(MAKE) -C $(ul_libuuid_builddir) - +ul_libuuid_la = libuuid.la # mount ul_libmount_srcdir = $(top_srcdir)/libmount/src diff --git a/configure.ac b/configure.ac index 0b659f227..2636121bd 100644 --- a/configure.ac +++ b/configure.ac @@ -1320,9 +1320,6 @@ libmount/docs/version.xml libmount/mount.pc libmount/src/Makefile libmount/src/libmount.h -libuuid/Makefile -libuuid/man/Makefile -libuuid/src/Makefile libuuid/uuid.pc login-utils/Makefile man/ru/Makefile diff --git a/libuuid/Makefile.am b/libuuid/Makefile.am deleted file mode 100644 index d7c50ba49..000000000 --- a/libuuid/Makefile.am +++ /dev/null @@ -1,9 +0,0 @@ -include $(top_srcdir)/config/include-Makefile.am - -SUBDIRS = src man - -# pkg-config stuff -pkgconfigdir = $(usrlib_execdir)/pkgconfig -pkgconfig_DATA = uuid.pc - -EXTRA_DIST = uuid.pc.in diff --git a/libuuid/Makemodule.am b/libuuid/Makemodule.am new file mode 100644 index 000000000..e2db4ff76 --- /dev/null +++ b/libuuid/Makemodule.am @@ -0,0 +1,9 @@ +if BUILD_LIBUUID + +include libuuid/man/Makemodule.am +include libuuid/src/Makemodule.am + +pkgconfig_DATA += libuuid/uuid.pc +EXTRA_DIST += libuuid/uuid.pc.in + +endif # BUILD_LIBUUID diff --git a/libuuid/man/Makefile.am b/libuuid/man/Makefile.am deleted file mode 100644 index ab4a8ebff..000000000 --- a/libuuid/man/Makefile.am +++ /dev/null @@ -1,23 +0,0 @@ -include $(top_srcdir)/config/include-Makefile.am - -dist_man_MANS = \ - uuid.3 \ - uuid_clear.3 \ - uuid_compare.3 \ - uuid_copy.3 \ - uuid_generate.3 \ - uuid_is_null.3 \ - uuid_parse.3 \ - uuid_time.3 \ - uuid_unparse.3 - -UUID_GENERATE_LINKS = \ - uuid_generate_random.3 \ - uuid_generate_time.3 \ - uuid_generate_time_safe.3 - -man_MANS = $(UUID_GENERATE_LINKS) -CLEANFILES = $(man_MANS) - -$(UUID_GENERATE_LINKS): - $(AM_V_GEN)echo ".so man3/uuid_generate.3" > $@ diff --git a/libuuid/man/Makemodule.am b/libuuid/man/Makemodule.am new file mode 100644 index 000000000..9824fbc69 --- /dev/null +++ b/libuuid/man/Makemodule.am @@ -0,0 +1,22 @@ + +dist_man_MANS += \ + libuuid/man/uuid.3 \ + libuuid/man/uuid_clear.3 \ + libuuid/man/uuid_compare.3 \ + libuuid/man/uuid_copy.3 \ + libuuid/man/uuid_generate.3 \ + libuuid/man/uuid_is_null.3 \ + libuuid/man/uuid_parse.3 \ + libuuid/man/uuid_time.3 \ + libuuid/man/uuid_unparse.3 + +UUID_GENERATE_LINKS = \ + libuuid/man/uuid_generate_random.3 \ + libuuid/man/uuid_generate_time.3 \ + libuuid/man/uuid_generate_time_safe.3 + +man_MANS += $(UUID_GENERATE_LINKS) +CLEANFILES += $(man_MANS) + +$(UUID_GENERATE_LINKS): + $(AM_V_GEN)echo ".so man3/uuid_generate.3" > $@ diff --git a/libuuid/src/Makefile.am b/libuuid/src/Makefile.am deleted file mode 100644 index 8e872100b..000000000 --- a/libuuid/src/Makefile.am +++ /dev/null @@ -1,53 +0,0 @@ -include $(top_srcdir)/config/include-Makefile.am - -AM_CPPFLAGS += -I$(ul_libuuid_srcdir) - -noinst_PROGRAMS = tst_uuid -tst_uuid_LDADD = libuuid.la $(SOCKET_LIBS) #$(ul_libuuid_la) - -# includes -uuidincdir = $(includedir)/uuid -uuidinc_HEADERS = uuid.h - -usrlib_exec_LTLIBRARIES = libuuid.la - -libuuid_la_SOURCES = \ - clear.c \ - compare.c \ - copy.c \ - gen_uuid.c \ - isnull.c \ - pack.c \ - parse.c \ - unpack.c \ - unparse.c \ - uuidd.h \ - uuidd.h \ - uuidP.h \ - uuid_time.c \ - $(uuidinc_HEADERS) \ - $(top_srcdir)/lib/randutils.c - -libuuid_la_DEPENDENCIES = uuid.sym - -libuuid_la_LIBADD = $(SOCKET_LIBS) - -libuuid_la_LDFLAGS = -Wl,--version-script=$(ul_libuuid_srcdir)/uuid.sym \ - -version-info $(LIBUUID_VERSION_INFO) - -EXTRA_DIST = uuid.sym gen_uuid_nt.c - -# move lib from $(usrlib_execdir) to $(libdir) if needed -install-exec-hook: - if test "$(usrlib_execdir)" != "$(libdir)"; then \ - mkdir -p $(DESTDIR)$(libdir); \ - mv $(DESTDIR)$(usrlib_execdir)/libuuid.so.* $(DESTDIR)$(libdir); \ - so_img_name=$$(readlink $(DESTDIR)$(usrlib_execdir)/libuuid.so); \ - so_img_rel_target=$$(echo $(usrlib_execdir) | sed 's,\(^/\|\)[^/][^/]*,..,g'); \ - (cd $(DESTDIR)$(usrlib_execdir) && \ - rm -f libuuid.so && \ - $(LN_S) $$so_img_rel_target$(libdir)/$$so_img_name libuuid.so); \ - fi - -uninstall-hook: - rm -f $(DESTDIR)$(libdir)/libuuid.so* diff --git a/libuuid/src/Makemodule.am b/libuuid/src/Makemodule.am new file mode 100644 index 000000000..2332fe24f --- /dev/null +++ b/libuuid/src/Makemodule.am @@ -0,0 +1,56 @@ + +noinst_PROGRAMS += test_uuid +test_uuid_SOURCES = libuuid/src/test_uuid.c +test_uuid_LDADD = libuuid.la $(SOCKET_LIBS) +test_uuid_CFLAGS = -I$(ul_libuuid_incdir) + +# includes +uuidincdir = $(includedir)/uuid +uuidinc_HEADERS = libuuid/src/uuid.h + +usrlib_exec_LTLIBRARIES += libuuid.la + +libuuid_la_SOURCES = \ + libuuid/src/clear.c \ + libuuid/src/compare.c \ + libuuid/src/copy.c \ + libuuid/src/gen_uuid.c \ + libuuid/src/isnull.c \ + libuuid/src/pack.c \ + libuuid/src/parse.c \ + libuuid/src/unpack.c \ + libuuid/src/unparse.c \ + libuuid/src/uuidd.h \ + libuuid/src/uuidd.h \ + libuuid/src/uuidP.h \ + libuuid/src/uuid_time.c \ + $(uuidinc_HEADERS) \ + lib/randutils.c + +libuuid_la_DEPENDENCIES = libuuid/src/uuid.sym +libuuid_la_LIBADD = $(SOCKET_LIBS) +libuuid_la_CFLAGS = -I$(ul_libuuid_incdir) -Ilibuuid/src + +libuuid_la_LDFLAGS = \ + -Wl,--version-script=$(top_srcdir)/libuuid/src/uuid.sym \ + -version-info $(LIBUUID_VERSION_INFO) + +EXTRA_DIST += libuuid/src/uuid.sym + +# move lib from $(usrlib_execdir) to $(libdir) if needed +install-exec-hook-libuuid: + if test "$(usrlib_execdir)" != "$(libdir)"; then \ + mkdir -p $(DESTDIR)$(libdir); \ + mv $(DESTDIR)$(usrlib_execdir)/libuuid.so.* $(DESTDIR)$(libdir); \ + so_img_name=$$(readlink $(DESTDIR)$(usrlib_execdir)/libuuid.so); \ + so_img_rel_target=$$(echo $(usrlib_execdir) | sed 's,\(^/\|\)[^/][^/]*,..,g'); \ + (cd $(DESTDIR)$(usrlib_execdir) && \ + rm -f libuuid.so && \ + $(LN_S) $$so_img_rel_target$(libdir)/$$so_img_name libuuid.so); \ + fi + +uninstall-hook-libuuid: + rm -f $(DESTDIR)$(libdir)/libuuid.so* + +INSTALL_EXEC_HOOKS += install-exec-hook-libuuid +UNINSTALL_HOOKS += uninstall-hook-libuuid diff --git a/libuuid/src/gen_uuid_nt.c b/libuuid/src/gen_uuid_nt.c deleted file mode 100644 index aa44bfd3d..000000000 --- a/libuuid/src/gen_uuid_nt.c +++ /dev/null @@ -1,92 +0,0 @@ -/* - * gen_uuid_nt.c -- Use NT api to generate uuid - * - * Written by Andrey Shedel (andreys@ns.cr.cyco.com) - */ - - -#include "uuidP.h" - -#pragma warning(push,4) - -#pragma comment(lib, "ntdll.lib") - -// -// Here is a nice example why it's not a good idea -// to use native API in ordinary applications. -// Number of parameters in function below was changed from 3 to 4 -// for NT5. -// -// -// NTSYSAPI -// NTSTATUS -// NTAPI -// NtAllocateUuids( -// OUT PULONG p1, -// OUT PULONG p2, -// OUT PULONG p3, -// OUT PUCHAR Seed // 6 bytes -// ); -// -// - -unsigned long -__stdcall -NtAllocateUuids( - void* p1, // 8 bytes - void* p2, // 4 bytes - void* p3 // 4 bytes - ); - -typedef -unsigned long -(__stdcall* -NtAllocateUuids_2000)( - void* p1, // 8 bytes - void* p2, // 4 bytes - void* p3, // 4 bytes - void* seed // 6 bytes - ); - - - -// -// Nice, but instead of including ntddk.h ot winnt.h -// I should define it here because they MISSED __stdcall in those headers. -// - -__declspec(dllimport) -struct _TEB* -__stdcall -NtCurrentTeb(void); - - -// -// The only way to get version information from the system is to examine -// one stored in PEB. But it's pretty dangerouse because this value could -// be altered in image header. -// - -static -int -Nt5(void) -{ - //return NtCuttentTeb()->Peb->OSMajorVersion >= 5; - return (int)*(int*)((char*)(int)(*(int*)((char*)NtCurrentTeb() + 0x30)) + 0xA4) >= 5; -} - - - - -void uuid_generate(uuid_t out) -{ - if(Nt5()) - { - unsigned char seed[6]; - ((NtAllocateUuids_2000)NtAllocateUuids)(out, ((char*)out)+8, ((char*)out)+12, &seed[0] ); - } - else - { - NtAllocateUuids(out, ((char*)out)+8, ((char*)out)+12); - } -} diff --git a/libuuid/src/test_uuid.c b/libuuid/src/test_uuid.c new file mode 100644 index 000000000..e03138f7d --- /dev/null +++ b/libuuid/src/test_uuid.c @@ -0,0 +1,180 @@ +/* + * tst_uuid.c --- test program from the UUID library + * + * Copyright (C) 1996, 1997, 1998 Theodore Ts'o. + * + * %Begin-Header% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, and the entire permission notice in its entirety, + * including the disclaimer of warranties. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote + * products derived from this software without specific prior + * written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ALL OF + * WHICH ARE HEREBY DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + * USE OF THIS SOFTWARE, EVEN IF NOT ADVISED OF THE POSSIBILITY OF SUCH + * DAMAGE. + * %End-Header% + */ + +#ifdef _WIN32 +#define _WIN32_WINNT 0x0500 +#include +#define UUID MYUUID +#endif + +#include +#include + +#include "uuid.h" + +static int test_uuid(const char * uuid, int isValid) +{ + static const char * validStr[2] = {"invalid", "valid"}; + uuid_t uuidBits; + int parsedOk; + + parsedOk = uuid_parse(uuid, uuidBits) == 0; + + printf("%s is %s", uuid, validStr[isValid]); + if (parsedOk != isValid) { + printf(" but uuid_parse says %s\n", validStr[parsedOk]); + return 1; + } + printf(", OK\n"); + return 0; +} + +#ifdef __GNUC__ +#define ATTR(x) __attribute__(x) +#else +#define ATTR(x) +#endif + +int +main(int argc ATTR((unused)) , char **argv ATTR((unused))) +{ + uuid_t buf, tst; + char str[100]; + struct timeval tv; + time_t time_reg; + unsigned char *cp; + int i; + int failed = 0; + int type, variant; + + uuid_generate(buf); + uuid_unparse(buf, str); + printf("UUID generate = %s\n", str); + printf("UUID: "); + for (i=0, cp = (unsigned char *) &buf; i < 16; i++) { + printf("%02x", *cp++); + } + printf("\n"); + type = uuid_type(buf); variant = uuid_variant(buf); + printf("UUID type = %d, UUID variant = %d\n", type, variant); + if (variant != UUID_VARIANT_DCE) { + printf("Incorrect UUID Variant; was expecting DCE!\n"); + failed++; + } + printf("\n"); + + uuid_generate_random(buf); + uuid_unparse(buf, str); + printf("UUID random string = %s\n", str); + printf("UUID: "); + for (i=0, cp = (unsigned char *) &buf; i < 16; i++) { + printf("%02x", *cp++); + } + printf("\n"); + type = uuid_type(buf); variant = uuid_variant(buf); + printf("UUID type = %d, UUID variant = %d\n", type, variant); + if (variant != UUID_VARIANT_DCE) { + printf("Incorrect UUID Variant; was expecting DCE!\n"); + failed++; + } + if (type != 4) { + printf("Incorrect UUID type; was expecting " + "4 (random type)!\n"); + failed++; + } + printf("\n"); + + uuid_generate_time(buf); + uuid_unparse(buf, str); + printf("UUID string = %s\n", str); + printf("UUID time: "); + for (i=0, cp = (unsigned char *) &buf; i < 16; i++) { + printf("%02x", *cp++); + } + printf("\n"); + type = uuid_type(buf); variant = uuid_variant(buf); + printf("UUID type = %d, UUID variant = %d\n", type, variant); + if (variant != UUID_VARIANT_DCE) { + printf("Incorrect UUID Variant; was expecting DCE!\n"); + failed++; + } + if (type != 1) { + printf("Incorrect UUID type; was expecting " + "1 (time-based type)!\\n"); + failed++; + } + tv.tv_sec = 0; + tv.tv_usec = 0; + time_reg = uuid_time(buf, &tv); + printf("UUID time is: (%ld, %ld): %s\n", tv.tv_sec, tv.tv_usec, + ctime(&time_reg)); + uuid_parse(str, tst); + if (!uuid_compare(buf, tst)) + printf("UUID parse and compare succeeded.\n"); + else { + printf("UUID parse and compare failed!\n"); + failed++; + } + uuid_clear(tst); + if (uuid_is_null(tst)) + printf("UUID clear and is null succeeded.\n"); + else { + printf("UUID clear and is null failed!\n"); + failed++; + } + uuid_copy(buf, tst); + if (!uuid_compare(buf, tst)) + printf("UUID copy and compare succeeded.\n"); + else { + printf("UUID copy and compare failed!\n"); + failed++; + } + failed += test_uuid("84949cc5-4701-4a84-895b-354c584a981b", 1); + failed += test_uuid("84949CC5-4701-4A84-895B-354C584A981B", 1); + failed += test_uuid("84949cc5-4701-4a84-895b-354c584a981bc", 0); + failed += test_uuid("84949cc5-4701-4a84-895b-354c584a981", 0); + failed += test_uuid("84949cc5x4701-4a84-895b-354c584a981b", 0); + failed += test_uuid("84949cc504701-4a84-895b-354c584a981b", 0); + failed += test_uuid("84949cc5-470104a84-895b-354c584a981b", 0); + failed += test_uuid("84949cc5-4701-4a840895b-354c584a981b", 0); + failed += test_uuid("84949cc5-4701-4a84-895b0354c584a981b", 0); + failed += test_uuid("g4949cc5-4701-4a84-895b-354c584a981b", 0); + failed += test_uuid("84949cc5-4701-4a84-895b-354c584a981g", 0); + + if (failed) { + printf("%d failures.\n", failed); + exit(1); + } + return 0; +} diff --git a/libuuid/src/tst_uuid.c b/libuuid/src/tst_uuid.c deleted file mode 100644 index e03138f7d..000000000 --- a/libuuid/src/tst_uuid.c +++ /dev/null @@ -1,180 +0,0 @@ -/* - * tst_uuid.c --- test program from the UUID library - * - * Copyright (C) 1996, 1997, 1998 Theodore Ts'o. - * - * %Begin-Header% - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, and the entire permission notice in its entirety, - * including the disclaimer of warranties. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote - * products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ALL OF - * WHICH ARE HEREBY DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT - * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE - * USE OF THIS SOFTWARE, EVEN IF NOT ADVISED OF THE POSSIBILITY OF SUCH - * DAMAGE. - * %End-Header% - */ - -#ifdef _WIN32 -#define _WIN32_WINNT 0x0500 -#include -#define UUID MYUUID -#endif - -#include -#include - -#include "uuid.h" - -static int test_uuid(const char * uuid, int isValid) -{ - static const char * validStr[2] = {"invalid", "valid"}; - uuid_t uuidBits; - int parsedOk; - - parsedOk = uuid_parse(uuid, uuidBits) == 0; - - printf("%s is %s", uuid, validStr[isValid]); - if (parsedOk != isValid) { - printf(" but uuid_parse says %s\n", validStr[parsedOk]); - return 1; - } - printf(", OK\n"); - return 0; -} - -#ifdef __GNUC__ -#define ATTR(x) __attribute__(x) -#else -#define ATTR(x) -#endif - -int -main(int argc ATTR((unused)) , char **argv ATTR((unused))) -{ - uuid_t buf, tst; - char str[100]; - struct timeval tv; - time_t time_reg; - unsigned char *cp; - int i; - int failed = 0; - int type, variant; - - uuid_generate(buf); - uuid_unparse(buf, str); - printf("UUID generate = %s\n", str); - printf("UUID: "); - for (i=0, cp = (unsigned char *) &buf; i < 16; i++) { - printf("%02x", *cp++); - } - printf("\n"); - type = uuid_type(buf); variant = uuid_variant(buf); - printf("UUID type = %d, UUID variant = %d\n", type, variant); - if (variant != UUID_VARIANT_DCE) { - printf("Incorrect UUID Variant; was expecting DCE!\n"); - failed++; - } - printf("\n"); - - uuid_generate_random(buf); - uuid_unparse(buf, str); - printf("UUID random string = %s\n", str); - printf("UUID: "); - for (i=0, cp = (unsigned char *) &buf; i < 16; i++) { - printf("%02x", *cp++); - } - printf("\n"); - type = uuid_type(buf); variant = uuid_variant(buf); - printf("UUID type = %d, UUID variant = %d\n", type, variant); - if (variant != UUID_VARIANT_DCE) { - printf("Incorrect UUID Variant; was expecting DCE!\n"); - failed++; - } - if (type != 4) { - printf("Incorrect UUID type; was expecting " - "4 (random type)!\n"); - failed++; - } - printf("\n"); - - uuid_generate_time(buf); - uuid_unparse(buf, str); - printf("UUID string = %s\n", str); - printf("UUID time: "); - for (i=0, cp = (unsigned char *) &buf; i < 16; i++) { - printf("%02x", *cp++); - } - printf("\n"); - type = uuid_type(buf); variant = uuid_variant(buf); - printf("UUID type = %d, UUID variant = %d\n", type, variant); - if (variant != UUID_VARIANT_DCE) { - printf("Incorrect UUID Variant; was expecting DCE!\n"); - failed++; - } - if (type != 1) { - printf("Incorrect UUID type; was expecting " - "1 (time-based type)!\\n"); - failed++; - } - tv.tv_sec = 0; - tv.tv_usec = 0; - time_reg = uuid_time(buf, &tv); - printf("UUID time is: (%ld, %ld): %s\n", tv.tv_sec, tv.tv_usec, - ctime(&time_reg)); - uuid_parse(str, tst); - if (!uuid_compare(buf, tst)) - printf("UUID parse and compare succeeded.\n"); - else { - printf("UUID parse and compare failed!\n"); - failed++; - } - uuid_clear(tst); - if (uuid_is_null(tst)) - printf("UUID clear and is null succeeded.\n"); - else { - printf("UUID clear and is null failed!\n"); - failed++; - } - uuid_copy(buf, tst); - if (!uuid_compare(buf, tst)) - printf("UUID copy and compare succeeded.\n"); - else { - printf("UUID copy and compare failed!\n"); - failed++; - } - failed += test_uuid("84949cc5-4701-4a84-895b-354c584a981b", 1); - failed += test_uuid("84949CC5-4701-4A84-895B-354C584A981B", 1); - failed += test_uuid("84949cc5-4701-4a84-895b-354c584a981bc", 0); - failed += test_uuid("84949cc5-4701-4a84-895b-354c584a981", 0); - failed += test_uuid("84949cc5x4701-4a84-895b-354c584a981b", 0); - failed += test_uuid("84949cc504701-4a84-895b-354c584a981b", 0); - failed += test_uuid("84949cc5-470104a84-895b-354c584a981b", 0); - failed += test_uuid("84949cc5-4701-4a840895b-354c584a981b", 0); - failed += test_uuid("84949cc5-4701-4a84-895b0354c584a981b", 0); - failed += test_uuid("g4949cc5-4701-4a84-895b-354c584a981b", 0); - failed += test_uuid("84949cc5-4701-4a84-895b-354c584a981g", 0); - - if (failed) { - printf("%d failures.\n", failed); - exit(1); - } - return 0; -} -- cgit v1.2.3-55-g7522