remove libuuid from tree

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@16072 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Michael Jerris 2009-12-29 02:05:51 +00:00
parent 4809a944a0
commit 7ad6094850
80 changed files with 1 additions and 19094 deletions

View File

@ -215,12 +215,10 @@ CORE_CFLAGS += -I$(switch_srcdir)/libs/pcre
CORE_CFLAGS += -I$(switch_srcdir)/libs/speex/include -Ilibs/speex/include
CORE_CFLAGS += -I$(switch_srcdir)/libs/srtp/include
CORE_CFLAGS += -I$(switch_srcdir)/libs/srtp/crypto/include -Ilibs/srtp/crypto/include
CORE_CFLAGS += -I$(switch_builddir)/libs/uuid
CORE_CFLAGS += -I$(switch_srcdir)/libs/uuid
CORE_LIBS = libs/apr-util/libaprutil-1.la libs/apr/libapr-1.la
CORE_LIBS += libs/sqlite/libsqlite3.la libs/pcre/libpcre.la libs/speex/libspeex/libspeexdsp.la
CORE_LIBS += libs/srtp/libsrtp.la libs/uuid/libuuid.la
CORE_LIBS += libs/srtp/libsrtp.la
lib_LTLIBRARIES = libfreeswitch.la
libfreeswitch_la_CFLAGS = $(CORE_CFLAGS) $(AM_CFLAGS)
@ -370,18 +368,6 @@ nodepends: .nodepends
yesdepends:
rm .nodepends
libs/uuid/configure:
test -f $@ || $(MAKE) uuid-reconf
@$(TOUCH_TARGET)
libs/uuid/Makefile: libs/uuid/configure
test -f $@ || cd $(top_builddir)/libs/uuid && $(SHELL) ./config.status Makefile
@$(TOUCH_TARGET)
libs/uuid/libuuid.la: libs/uuid libs/uuid/.update libs/uuid/Makefile
@cd libs/uuid && $(MAKE)
@$(TOUCH_TARGET)
libs/apr/libapr-1.la: libs/apr libs/apr/.update
@cd libs/apr && $(MAKE)
@$(TOUCH_TARGET)
@ -494,12 +480,6 @@ iks-reconf:
cd libs/iksemel && sh ./configure.gnu --prefix=$(PREFIX)
$(MAKE) mod_dingaling-clean
uuid-reconf:
cd libs/uuid && $(MAKE) clean || echo
cd libs/uuid && autoreconf -fi
cd libs/uuid && sh ./configure.gnu --prefix=$(PREFIX)
cd libs/uuid && $(MAKE)
spandsp-reconf:
cd libs/spandsp && $(MAKE) clean || echo
cd libs/spandsp && autoreconf -fi

View File

@ -1 +0,0 @@
Tue Dec 22 14:12:35 EST 2009

View File

@ -1,15 +0,0 @@
_ ___ ____ ____ ____ _ _
|_|_ _ / _ \/ ___/ ___|| _ \ _ _ _ _(_) __| |
_|_||_| | | | \___ \___ \| |_) | | | | | | | | |/ _` |
|_||_|_| | |_| |___) |__) | __/ | |_| | |_| | | (_| |
|_|_|_| \___/|____/____/|_| \__,_|\__,_|_|\__,_|
OSSP uuid - Universally Unique Identifier
AUTHORS
This is a list of authors who have written
or edited major parts of the OSSP uuid sources.
Ralf S. Engelschall <rse@engelschall.com>

View File

@ -1,35 +0,0 @@
_ ___ ____ ____ ____ _ _
|_|_ _ / _ \/ ___/ ___|| _ \ _ _ _ _(_) __| |
_|_||_| | | | \___ \___ \| |_) | | | | | | | | |/ _` |
|_||_|_| | |_| |___) |__) | __/ | |_| | |_| | | (_| |
|_|_|_| \___/|____/____/|_| \__,_|\__,_|_|\__,_|
OSSP uuid - Universally Unique Identifier
LANGUAGE BINDINGS
Various programming language bindings exist for OSSP uuid.
The following is the list of known bindings:
o C
(native API)
o C++
(addon API; part of the OSSP uuid distribution; see uuid++.* files)
o Perl
(addon API; part of the OSSP uuid distribution; see perl/ directory)
o PHP
(addon API; part of the OSSP uuid distribution; see php/ directory)
o PostgreSQL
(addon API; part of the OSSP uuid distribution; see pgsql/ directory)
o GNU Guile GEE (Scheme)
https://gna.org/projects/gee
o Chicken (Scheme)
http://www.call-with-current-continuation.org/eggs/uuid-ossp.html

View File

@ -1,624 +0,0 @@
_ ___ ____ ____ ____ _ _
|_|_ _ / _ \/ ___/ ___|| _ \ _ _ _ _(_) __| |
_|_||_| | | | \___ \___ \| |_) | | | | | | | | |/ _` |
|_||_|_| | |_| |___) |__) | __/ | |_| | |_| | | (_| |
|_|_|_| \___/|____/____/|_| \__,_|\__,_|_|\__,_|
OSSP uuid - Universally Unique Identifier
CHANGELOG
This is a list of all changes to OSSP uuid.
For a more brief summary please have a look at the NEWS file.
Changes between 1.6.1 and 1.6.2 (21-Feb-2008 to 04-Jul-2008)
o Adjust "devtool.func" for latest GNU Libtool compatibility.
[Ralf S. Engelschall]
o Improve PRNG under Win32.
[Hiroshi Saito]
o Consistently annotate "RFC-XXXX" with "IETF" to clearly
indicate from which standards body this comes from.
[Ralf S. Engelschall]
o Resolve namespace conflicts of recently introduced time_xxx()
functions by using a propoer "uuid_" prefix.
[Ralf S. Engelschall]
o Remove unused "struct timezone" from time_gettimeofday() in
order to simplify portability.
[Ralf S. Engelschall]
o Add support for POSIX clock_gettime(3) in case the Unix/POSIX
gettimeofday(3) is not available.
[Ralf S. Engelschall]
o Upgrade build environment to GNU autoconf 2.62.
[Ralf S. Engelschall]
o Upgrade build environment to GNU libtool 2.2.4.
[Ralf S. Engelschall]
Changes between 1.6.0 and 1.6.1 (19-May-2007 to 21-Feb-2008)
o Port to Win32 API.
[Hiroshi Saito, Wu Yongwei, Ralf S. Engelschall]
o Adjust copyright messages for new year 2008.
[Ralf S. Engelschall]
o Fix __VA_COPY_USE_{CSP,CPP} fallback macros for va_copy.
[Mark A. Lindner <mark.a.lindner@gmail.com>]
o PostgreSQL bindings: use SET_VARSIZE() instead
of assigning to bytea->v_len under PostgreSQL >= 8.3
[Ralf S. Engelschall]
o Upgrade build environment to GNU libtool 1.5.26
[Ralf S. Engelschall]
Changes between 1.5.1 and 1.6.0 (31-Jul-2006 to 19-May-2007)
o Expand unused "datarootdir" in Makefile.in and uuid-config.in to
make newer GNU autoconf versions happy.
[Ralf S. Engelschall]
o Upgrade build environment to GNU shtool 2.0.7
[Ralf S. Engelschall]
o Make GNU autoconf procedure of PHP binding more robust by using
-Wl,-Bsymbolic only on platforms where uuid_create(3) actually
exists and where -Wl,-Bsymbolic is really accepted by the tool
chain. This especially unbreaks MacOS X.
[Ralf S. Engelschall]
o Fix "uuid_export" function in PHP bindings under
UUID_FMT_SIV, UUID_FMT_STR and UUID_FMT_TXT where the
NUL-termination character should be not passed back to PHP.
[Neil Caunt <retardis@gmail.com>, Ralf S. Engelschall]
o Adjust copyright messages for new year 2007.
[Ralf S. Engelschall]
o Upgrade build environment to GNU autoconf 2.61
[Ralf S. Engelschall]
o Disable PostgreSQL "(CSTRING AS uuid)" and "(uuid AS CSTRING)"
CASTS as PostgreSQL 8.2 and higher explicitly disallow this.
[David Wheeler <david@kineticode.com>, Ralf S. Engelschall]
o Fix PostgreSQL bindings by mapping the correct DSO symbol
to the functions "uuid_send" and "uuid_recv".
[Ralf S. Engelschall]
o Silence PostgreSQL processing messages
[David Wheeler <david@kineticode.com>]
o Support MacOS X (aka Darwin) in PostgreSQL bindings by passing
a "-bundle_loader" option to the linker in order to resolve the
"undefined symbols" problem.
[David Wheeler <david@kineticode.com>, Ralf S. Engelschall]
o Pass the correct type to PostgreSQL's errmsg().
[David Wheeler <david@kineticode.com>, Ralf S. Engelschall]
o Added PostgreSQL 8.2 PG_MODULE_MAGIC support.
[David Wheeler <david@kineticode.com>]
o Fix the Data::UUID::to_b64string() function of the Perl backward
compatibility API: an empty string was not supplied as the EOL
marker to MIME::Base64::encode_base64() and hence the returned
string ended with a newline character (which in turn breaks many
applications using Data::UUID).
[Piotr Roszatycki <dexter@debian.org>]
o Change type of "data_ptr" argument in uuid_export() API signature
from "void **" to "void *" as there is unfortunately no
"generic pointer to pointer type" in ISO C (see also
http://c-faq.com/ptrs/genericpp.html) and "void **" is just a
"pointer to a 'void *'".
The "void **" especially had the nasty side-effect that it breaks
strict pointer aliasing rules of ISO C and hence would require
fiddling with temporary variables on all uuid_export() calls if
one would be 100% correct and avoid aliasing related compiler
warnings. Instead, as uuid_export() internally has to cast the
"data_ptr" to the particular expected type anyway, it is better
to have "data_ptr" just be a really generic "void *" in the API
signature.
Keep in mind that although this is an API change, it doesn't cause
any incompatibilities as the function still expects the same
"pointer to a pointer of a particular type". This expected pointer
is just now passed the more correct although less intuitive way.
[Hrvoje Niksic <hniksic@xemacs.org>, Ralf S. Engelschall]
o Optional DMALLOC based memory debugging support.
[Ralf S. Engelschall]
o Consistently include "uuid_ac.h" in all source files to have GNU
autoconf results and standard system defines available everywhere.
[Ralf S. Engelschall]
Changes between 1.5.0 and 1.5.1 (28-Jul-2006 to 31-Jul-2006)
o Use "MODULE_PATHNAME" instead of "@MODULE_PATHNAME@" in
uuid.sql.in to be more aligned to the PostgreSQL styles.
[Simon "janus" Dassow <janus@errornet.de>]
o Use the available variables $(LIB_NAME), $(DCE_NAME) and
$(CXX_NAME) more consistently in Makefile.in to allow packagers to
override the library name with less patching.
[Piotr Roszatycki <dexter@debian.org>]
o Fix the "make distclean" target of php/Makefile.local
to make sure the ".deps" file is not left over.
[Ralf S. Engelschall]
o Fix the tarball rolling procedure to make sure we
do not distribute binary files again. This now especially uses
a MANIFEST file which explicitly lists all files which form the
distribution tarball. We compare the tarball and the MANIFEST file
for differences in the "devtool dist" now.
[Ralf S. Engelschall]
Changes between 1.4.2 and 1.5.0 (13-Mar-2006 to 28-Jul-2006)
o Fixed potential memory leak in uuid_create() as spotted by SPLINT.
[Ralf S. Engelschall]
o Cleanup source code according to complains by SPLINT.
[Ralf S. Engelschall]
o Cleanup internal uuid_mac.h header.
[Ralf S. Engelschall]
o Numerous fixed to the error handling in the PostgreSQL bindings.
[Neil Conway <neilc@samurai.com>]
o Add Hash indexing support UUID data type of PostgreSQL bindings.
[Ralf S. Engelschall]
o Add comparison operators and B-Tree indexing support UUID data
type of PostgreSQL bindings.
[Roman Neuhauser <neuhauser@sigpipe.cz>]
o Fix PHP bindings: the wrong argument to uuid_create()
was forced to a reference
[Roman Neuhauser <neuhauser@sigpipe.cz>]
o Add full support for Single Integer Value (SIV) UUID representation
for both importing and exporting in C/C++/Perl/PHP APIs.
[Ralf S. Engelschall]
o Upgrade build environment to GNU shtool 2.0.6 and GNU autoconf 2.60
[Ralf S. Engelschall]
o Added an "OVERVIEW" file which tries to give the "big picture"
about UUIDs and allows to survice during the nasty UUID bit fiddling.
[Ralf S. Engelschall]
o Replaced "clock_seq_and_reserved" with
"clock_seq_high_and_reserved" in uuid.pod to already reflect the
description in the forthcoming RFC.
[Ralf S. Engelschall]
o Speed up processing in uuid_str.c by reducing va_copy() calls from
two to just one per formatting.
[Ralf S. Engelschall]
Changes between 1.4.1 and 1.4.2 (07-Feb-2006 to 13-Mar-2006)
o Fix uuid_export() function by fixing the internal
uuid_s[ar]printf() functions which require the backup of va_list
arguments between subsequent processing.
[Ralf S. Engelschall, Thomas Lotterer <thomas@lotterer.net>]
o Fix Perl API's "export" function by not taking over NUL-termination
character under UUID_FMT_TXT.
[Thomas Lotterer <thomas@lotterer.net>]
o Declare "install", "uninstall" and "clean" make(1) targets
".PHONY". This especially workarounds problems on case insensitive
filesystems (like MacOS X' filesystem) where the "INSTALL" document
conflicts with the "install" target.
[Ralf S. Engelschall, David Wheeler <david@kineticode.com>]
Changes between 1.4.0 and 1.4.1 (15-Jan-2006 to 07-Feb-2006)
o Upgrade to GNU shtool 2.0.5
[Ralf S. Engelschall]
o Apply workaround to uuid.h to avoid conflicts with
vendor UUID implementations where uuid_t (Darwin/MacOSX)
or uuid_create/uuid_compare (POSIX) might exist.
[Ralf S. Engelschall]
Changes between 1.3.2 and 1.4.0 (06-Dec-2005 to 15-Jan-2006)
o Created a top-level Perl ExtUtils::MakeMaker wrapper script
[Ralf S. Engelschall]
o Adjust copyright messages for new year 2006.
[Ralf S. Engelschall]
o Added experimental PostgreSQL bindings.
[Ralf S. Engelschall]
o Fixed documentation of uuid_make() function.
[Ralf S. Engelschall]
o Upgrade build environment to GNU libtool 1.5.22
[Ralf S. Engelschall]
Changes between 1.3.1 and 1.3.2 (24-Sep-2005 to 06-Dec-2005)
o Cleaned up and speed optimized perl/uuid_compat.pm
(the Data::UUID compatibility module for Perl)
[David Wheeler <david@justatheory.com>]
o Upgrade to GNU shtool 2.0.3
[Ralf S. Engelschall]
o Consistently use "return" in uuid++.cc
[Ralf S. Engelschall]
Changes between 1.3.0 and 1.3.1 (02-Sep-2005 to 24-Sep-2005)
o Fix two incorrect casts, detected by compiling the C code
under C++ constraints.
[Ralf S. Engelschall]
o Remove a compiler warning in the PHP bindings.
[Ralf S. Engelschall]
o Plug memory leak in PRNG sub-library.
[Ralf S. Engelschall]
o Add VPATH/srcdir support for at the default
build procedure plus at least C++ and DCE build options.
[Ralf S. Engelschall]
Changes between 1.2.1 and 1.3.0 (30-Aug-2005 to 02-Sep-2005)
o Add an experimental PHP 4/5 language API binding which
can be enabled under build-time with opption --with-php.
[Ralf S. Engelschall]
o Upgrade to GNU libtool 1.5.20
[Ralf S. Engelschall]
o Add missing "const" in manual page.
[Ralf S. Engelschall]
o Add an experimental C++ API binding which can be
enabled under build-time with option --with-cxx.
[Ralf S. Engelschall]
o Cleanup the internals of the uuid_create() function and
add a new corresponding uuid_clone() API function.
[Ralf S. Engelschall]
o Cleanup some Makefile parts.
[Ralf S. Engelschall]
o Added a pkg-config(1) specification uuid.pc which is also
installed by default in addition to the old-style uuid-config tool.
[Ralf S. Engelschall]
o Added optional Data::UUID backward compatibility Perl API which can
be enabled with the build-time option --with-perl-compat.
[Piotr Roszatycki <dexter@debian.org>, Ralf S. Engelschall]
o Add a functionality-reduced TIE-style Perl API OSSP::uuid::tie,
intended for very high-level convenience programming.
[Ralf S. Engelschall]
o Reference the new officially published RFC 4122.
[Ralf S. Engelschall]
Changes between 1.2.0 and 1.2.1 (23-Jan-2005 to 30-Aug-2005)
o Add SEEALSO document which references all known
UUID implementations.
[Ralf S. Engelschall]
o Improve the PRNG in case no stronger system PRNG device is
available by passing time and rand(3) based entropy into the MD5
one-way hash function to achieve at least some sort of weaker PRN data.
[Ralf S. Engelschall]
o Fix MAC address determination under Solaris by using the result of
ioctl(...,SIOCGARP,...) only if arp_flags had ATF_COM set.
[Ralf S. Engelschall]
o Upgrade to GNU libtool 1.5.18 and GNU shtool 2.0.2.
[Ralf S. Engelschall]
o Cleanup the source code even more by following a large
set of FlexeLint's suggestions.
[Ralf S. Engelschall]
o Fixed generated "section" number in uuid-config(1).
[Piotr Roszatycki <dexter@debian.org>]
Changes between 1.1.2 and 1.2.0 (13-Jan-2005 to 23-Jan-2005)
o Added support for new version 5 UUIDs (name-based, SHA-1)
according to latest draft-mealling-uuid-urn-05.txt.
[Ralf S. Engelschall]
o Reference new ISO/IEC 9834-8:2004 / ITU-T Rec. X.667 2004 standard
and latest IETF draft-mealling-uuid-urn-05.txt.
[Ralf S. Engelschall]
Changes between 1.1.1 and 1.1.2 (18-Nov-2004 to 13-Jan-2005)
o Fix generation of v3 UUIDs by adding support for 64-bit platforms
to the underlying uuid_md5.c code (which internally is based on
the RFC reference code which in turn assumes a 32-bit environment).
[Ralf S. Engelschall, Piotr Roszatycki <Piotr_Roszatycki@netia.net.pl>]
o Optimize internal md5_store() function by directly finalizing MD5
calculation on buffer copy instead of finalizing original buffer
and having to restore it from the buffer copy.
[Ralf S. Engelschall]
o Adjust copyright messages for new year 2005.
[Ralf S. Engelschall]
o Do not rebuild the Perl API if there were no actual changes.
[Ralf S. Engelschall]
Changes between 1.1.0 and 1.1.1 (03-Nov-2004 to 18-Nov-2004)
o Apply the FreeBSD libc uuid_create() related workaround
in the Perl bindings also under FreeBSD 6.0-CURRENT.
[Ralf S. Engelschall]
o Fix --with-perl configure option processing: Perl is
only required if --with-perl is used although we search for Perl
always in order to provide the PERL variable substitution.
[Ralf S. Engelschall]
Changes between 1.0.4 and 1.1.0 (16-Oct-2004 to 03-Nov-2004)
o Add --with-perl configure option for optionally enabling
the Perl language bindings.
[Ralf S. Engelschall]
o Add Perl language bindings providing both a C-style and OO-style API.
[Ralf S. Engelschall]
Changes between 1.0.3 and 1.0.4 (15-Oct-2004 to 16-Oct-2004)
o Fix version detection from uuid_vers.h
[Ralf S. Engelschall]
Changes between 1.0.2 and 1.0.3 (12-Sep-2004 to 15-Oct-2004)
o Support configuring/building/installing from an arbitrary
directory via srcdir/top_srcdir/VPATH.
[David Lee <t.d.lee@durham.ac.uk>, Ralf S. Engelschall]
o Upgrade build environment to GNU libtool 1.5.10.
[Ralf S. Engelschall]
Changes between 1.0.1 and 1.0.2 (16-Jul-2004 to 12-Sep-2004)
o Upgrade build environment to GNU libtool 1.5.8 and GNU shtool 2.0.1
[Ralf S. Engelschall]
Changes between 1.0.0 and 1.0.1 (16-Feb-2004 to 16-Jul-2004)
o Made documentation of uuid_export() more clear.
[Ralf S. Engelschall]
o Upgrade build environment to GNU libtool 1.5.6 and GNU shtool 2.0.0
[Ralf S. Engelschall]
o Remove some warnings occurring under GCC 3.5
[Ralf S. Engelschall]
Changes between 0.9.7 and 1.0.0 (13-Feb-2004 to 16-Feb-2004)
o Replace remaining (old) UUID_VERSIONX names with UUID_MAKE_VX
in the documentation (uuid.pod).
[Ralf S. Engelschall]
o Resolve namespace conflicts with GCC 3.4 internal pow10() and round()
functions within uuid_str.c.
[Ralf S. Engelschall]
o Fix buffer handling in "uuid_export(..., UUID_FMT_TXT, vp, ...)" in
case "vp" is not NULL.
[Fuyuki <fuyuki@nigredo.org>]
Changes between 0.9.6 and 0.9.7 (11-Feb-2004 to 13-Feb-2004)
o remove --with-rfc2518 option and functionality because
even the IETF/IESG has finally approved our report about the broken
random multicast MAC address generation in the standard (and
will fix it in new versions of the draft-mealling-uuid-urn). So,
finally get rid of this broken-by-design backward compatibility
functionality.
[Ralf S. Engelschall]
o Add support to uuid(1) CLI for decoding from stdin for
both binary and string representations.
[Ralf S. Engelschall]
o Add missing documentation entries for UUID_XXXX API constants and
uuid_version() function.
[Fuyuki <fuyuki@nigredo.org>]
o Adjust references for new draft-mealling-uuid-urn-02.txt.
[Fuyuki <fuyuki@nigredo.org>]
o Replaced overlooked references to old
uuid_{unpack,pack,parse,format,dump}() functions with their
current uuid_{import,export}() replacements.
[Fuyuki <fuyuki@nigredo.org>]
o Fixed "uuid -h" command.
[Fuyuki <fuyuki@nigredo.org>]
Changes between 0.9.5 and 0.9.6 (06-Feb-2004 to 11-Feb-2004)
o Added an experimental additional DCE 1.1 API for backward
compatibility with existing applications.
[Ralf S. Engelschall]
Changes between 0.9.4 and 0.9.5 (19-Jan-2004 to 06-Feb-2004)
o Fixed filedescriptor leak in the PRNG sub-API.
[Guerry Semones <guerry@tsunamiresearch.com>]
o Upgraded build environment to GNU libtool 1.5.2.
[Ralf S. Engelschall]
Changes between 0.9.3 and 0.9.4 (16-Jan-2004 to 19-Jan-2004)
o Include <string.h> in uuid.h because of size_t usage.
[Ralf S. Engelschall]
o INCOMPATIBILITY: Refactor the API and rename uuid_generate()
to uuid_make() and use a "uuid_t" pointer for the namespace
on UUID_VERSION3 generation. To allow access to the internal
pre-defined namespace UUIDs, provide a new uuid_load() function.
Because uuid_load() now also allows the loading of the "nil" UUID,
remove uuid_nil() from the API. After this second refactoring the
API is now the one we originally wished for the forthcoming version
1.0 of OSSP uuid.
[Ralf S. Engelschall]
o INCOMPATIBILITY: rename UUID_VERSIONx to UUID_MAKE_Vx and
UUID_MCASTRND to UUID_MAKE_MC to be more consistent throughout API.
[Ralf S. Engelschall]
o Add version support to API via UUID_VERSION (compile-time)
and uuid_version() (link-time).
[Ralf S. Engelschall]
o INCOMPATIBILITY: Refactor the API by merging
uuid_{unpack,pack,parse,format,dump}() functions into unified
uuid_{import,export}() functions. This allows us to easily add
support for other formats (e.g. XML) in the future without having
the change the API in principle.
[Ralf S. Engelschall]
o Document what DCE 1.1 UUID versions exist and what they are
intended for.
[Ralf S. Engelschall]
o Cleanup the C code to also pass warning-free a C++ compiler.
[Ralf S. Engelschall]
o Support C++ by enclosing the C API declarations in
'extern "C" {...}' within uuid.h.
[Guerry Semones <guerry@tsunamiresearch.com>]
o Improvide decoding in uuid_dump() by at least hex-dumping the
binary representation in case of v3, v4 and Nil UUIDs. Also,
annotate with better hints.
[Ralf S. Engelschall]
o Recognize special "Nil UUID" on decoding in uuid_dump().
[Ralf S. Engelschall]
Changes between 0.9.2 and 0.9.3 (15-Jan-2004 to 16-Jan-2004)
o Tested OSSP uuid on 16 particular Unix platforms and list
those in the new PORTING file.
[Ralf S. Engelschall]
o Fixed minor formatting bug in call to str_rsprintf().
[Ralf S. Engelschall]
o Fix syntax error in uuid.ac.
[Ralf S. Engelschall]
Changes between 0.9.1 and 0.9.2 (13-Jan-2004 to 15-Jan-2004)
o Provide both incorrect RFC2518-based and correct IEEE 802
multicast address generation. The default now is the correct
IEEE 802 multicast address generation but compile-time option
--with-rfc2518 selects the broken variant.
[Ralf S. Engelschall]
o Decode also the IEEE 802 MAC address local/global bit.
[Ralf S. Engelschall]
o Added missing documentation for uuid_dump().
[Ralf S. Engelschall]
o Fixed BM_POW2() macro implementation.
[Ralf S. Engelschall]
o Use BM_XXX() and str_xxx() APIs throughout internal implementation.
[Ralf S. Engelschall]
o Added missing manual page uuid-config(1).
[Ralf S. Engelschall]
o Fixed output of "uuid-config --version"
[Ralf S. Engelschall]
o Fixed typos in uuid.pod
[Ralf S. Engelschall]
o Cleanup uuid.ac for unused elements.
[Ralf S. Engelschall]
o Moved uuid_[u]int{8,16,32}_t auto-configuration into
own internal header uuid_ac.h.
[Ralf S. Engelschall]
o Fixed portability by replacing accidentally introduced
uint{8,16,32}_t with the portable uuid_uint{8,16,32}_t.
[Guerry Semones <guerry@tsunamiresearch.com>]
o Prefix all variable symbols in uuid.h with underscores
to avoid namespace conflicts.
[Ralf S. Engelschall]
o Add decoding examples to uuid(1) manual page.
[Ralf S. Engelschall]
Changes between 0.9.0 and 0.9.1 (11-Jan-2004 to 13-Jan-2004)
o Make "md5_init" and "mac_address" symbols namespace clean
by adding correct embedding support via "uuid_" prefix.
[Ralf S. Engelschall]
o Implement uuid_dump() and corresponding uuid CLI "-d"
option for dumping a given UUID into clear text. For convenience
reasons add uuid_bm.h (bit mask API) and uuid_str (string
formatting API) sub-modules.
[Ralf S. Engelschall]
o Add "-m" option to CLI for allowing to generate v1 UUIDs
with random multi-cast addresses (API UUID_MCASTRND option).
[Ralf S. Engelschall]
o Disable the C++ and F77 checks in GNU libtool.
[Ralf S. Engelschall]
o Print involved option character (instead of '?') on invalid
option for uuid(1) CLI.
[Matthias Andree <matthias.andree@gmx.de>]
o Fixed "make install" and "make uninstall": the uuid(1) CLI
has to be [un]installed through GNU libtool, too.
[Matthias Andree <matthias.andree@gmx.de>]
o Document in uuid(1) [uuid_cli.pod] that for version 3
UUIDs additional arguments are required and what pre-defined
namespace ids are known.
[Ralf S. Engelschall, M.Daniel <mdaniel@scdi.com>]
o cleaned up source tree documentation files.
[Ralf S. Engelschall]

View File

@ -1,358 +0,0 @@
_ ___ ____ ____ ____ _ _
|_|_ _ / _ \/ ___/ ___|| _ \ _ _ _ _(_) __| |
_|_||_| | | | \___ \___ \| |_) | | | | | | | | |/ _` |
|_||_|_| | |_| |___) |__) | __/ | |_| | |_| | | (_| |
|_|_|_| \___/|____/____/|_| \__,_|\__,_|_|\__,_|
OSSP uuid - Universally Unique Identifier
HISTORY
During OSSP uuid we were totally puzzled by a subtle bug in the UUID
standards related to the generation of multi-cast MAC addresses.
This part of the history shows a very interesting technical bug,
the unusual way of having to fix a standard (which was multiple
times revised by different standard authorities, including the
IETF, the OpenGroup and ISO/IEC) afterwards plus the fixing of six
implementations into which the bug was inherited similarly. Below are
some snapshot of this part of history: the first implementation fix
(for FreeBSD) and the notification of the IETF standards authors.
___________________________________________________________________________
Date: Fri, 13 Feb 2004 16:09:31 +0100
From: "Ralf S. Engelschall" <rse@en1.engelschall.com>
To: paulle@microsoft.com, michael@neonym.net, rsalz@datapower.com
Subject: [PATCH] draft-mealling-uuid-urn-02.txt
Message-ID: <20040213150931.GA7656@engelschall.com>
During implementation of OSSP uuid (a flexible CLI and C API for
generation and partial decoding of version 1, 3 and 4 UUIDs, see
http://www.ossp.org/pkg/lib/uuid/ for details), I discovered a nasty bug
in the generation of random multicast MAC addresses. It is present in
all standards and drafts (both expired ones and current ones) and was
also inherited (until I fixed it by submitting patches to the authors
recently) by all six freely available UUID implementations (Apache APR,
FreeBSD uuidgen(2), Java JUG, Linux's libuuid from e2fsutil, Perl's
Data::UUID and WINE's UUID generator)).
In case no real/physical IEEE 802 address is available, both the
expired "draft-leach-uuids-guids-01" (section "4. Node IDs when no IEEE
802 network card is available"), RFC 2518 (section "6.4.1 Node Field
Generation Without the IEEE 802 Address") and now even your current
"draft-mealling-uuid-urn-02.txt" (section "4.5 Node IDs that do not
identify the host") recommend:
"A better solution is to obtain a 47-bit cryptographic quality
random number, and use it as the low 47 bits of the node ID, with
the _most_ significant bit of the first octet of the node ID set to
one. This bit is the unicast/multicast bit, which will never be set
in IEEE 802 addresses obtained from network cards; hence, there can
never be a conflict between UUIDs generated by machines with and
without network cards."
Unfortunately, this incorrectly explains how to implement this and even
the example implementation (draft-mealling-uuid-urn-02.txt, "Appendix
A. Appendix A - Sample Implementation") inherited this. Correct is
"the _least_ significant bit of the first octet of the node ID" as the
multicast bit in a memory and hexadecimal string representation of a
48-bit IEEE 802 MAC address.
This standards bug arised from a false interpretation, as the multicast
bit is actually the _most_ significant bit in IEEE 802.3 (Ethernet)
_transmission order_ of an IEEE 802 MAC address. But you forgot that the
bitwise order of an _octet_ from a MAC address _memory_ and hexadecimal
string representation is still always from left (MSB, bit 7) to right
(LSB, bit 0). And the standard deals with memory representations only,
so the transmission order of a MAC doesnt' matter here.
As mentioned, OSSP uuid already implements this correctly. The FreeBSD
uuidgen(2) and Apache APR generators I've also fixed myself recently in
CVS. And for the remaining implementations I've submitted patches to the
authors and they all (except for WINE) responded that they took over the
patch. So the results of this long-standing bug we were able to fix --
at least for the free software world ;-). What is now remaining is that
you finally also should fix this in your standard so the bug does not
spread any longer into other implementations.
Here is the minimal required patch against your draft:
--- draft-mealling-uuid-urn-02.txt.orig Mon Feb 2 21:50:35 2004
+++ draft-mealling-uuid-urn-02.txt Fri Feb 13 15:41:49 2004
@@ -751,7 +751,7 @@
[6], and the cost was US$550.
A better solution is to obtain a 47-bit cryptographic quality random
- number, and use it as the low 47 bits of the node ID, with the most
+ number, and use it as the low 47 bits of the node ID, with the least
significant bit of the first octet of the node ID set to one. This
bit is the unicast/multicast bit, which will never be set in IEEE 802
addresses obtained from network cards; hence, there can never be a
@@ -1369,7 +1369,7 @@
}
else {
get_random_info(seed);
- seed[0] |= 0x80;
+ seed[0] |= 0x01;
memcpy(&saved_node, seed, sizeof saved_node);
fp = fopen("nodeid", "wb");
if (fp) {
But I recommend you to perhaps also add one or two sentences which
explain what I explained above (the difference between memory and
transmission order), just to make sure people are not confused in the
other direction and then think there is a bug (in the then fixed and
correct) standard, because they know about the transmission order of MAC
addresses.
Yours,
Ralf S. Engelschall
rse@engelschall.com
www.engelschall.com
Date: Fri, 13 Feb 2004 11:05:51 -0500
From: Rich Salz <rsalz@datapower.com>
To: rse@engelschall.com
Cc: paulle@microsoft.com, michael@neonym.net
Message-ID: <402CF5DF.4020601@datapower.com>
Subject: Re: [PATCH] draft-mealling-uuid-urn-02.txt
References: <20040213150931.GA7656@engelschall.com>
Content-Length: 431
Lines: 11
Thanks for writing, Ralf.
You're correct, and this has been noted by the IESG and will be fixed in
the next draft. It's unfortunate we made it this far with the bug.
/r$
--
Rich Salz, Chief Security Architect
DataPower Technology http://www.datapower.com
XS40 XML Security Gateway http://www.datapower.com/products/xs40.html
XML Security Overview http://www.datapower.com/xmldev/xmlsecurity.html
Date: Thu, 22 Jan 2004 05:34:11 -0800 (PST)
From: "Ralf S. Engelschall" <rse@FreeBSD.org>
Message-Id: <200401221334.i0MDYB1K018137@repoman.freebsd.org>
To: src-committers@FreeBSD.org, cvs-src@FreeBSD.org, cvs-all@FreeBSD.org
Subject: cvs commit: src/sys/kern kern_uuid.c
X-FreeBSD-CVS-Branch: HEAD
X-Loop: FreeBSD.ORG
Content-Length: 1907
Lines: 42
rse 2004/01/22 05:34:11 PST
FreeBSD src repository
Modified files:
sys/kern kern_uuid.c
Log:
Fix generation of random multicast MAC address.
In case no real/physical IEEE 802 address is available, both the expired
"draft-leach-uuids-guids-01" (section "4. Node IDs when no IEEE 802
network card is available") and RFC 2518 (section "6.4.1 Node Field
Generation Without the IEEE 802 Address") recommend (quoted from RFC
2518):
"The ideal solution is to obtain a 47 bit cryptographic quality random
number, and use it as the low 47 bits of the node ID, with the _most_
significant bit of the first octet of the node ID set to 1. This bit
is the unicast/multicast bit, which will never be set in IEEE 802
addresses obtained from network cards; hence, there can never be a
conflict between UUIDs generated by machines with and without network
cards."
Unfortunately, this incorrectly explains how to implement this and
the FreeBSD UUID generator code inherited this generation bug from
the broken reference code in the standards draft. They should instead
specify the "_least_ significant bit of the first octet of the node ID"
as the multicast bit in a memory and hexadecimal string representation
of a 48-bit IEEE 802 MAC address.
This standards bug arised from a false interpretation, as the multicast
bit is actually the _most_ significant bit in IEEE 802.3 (Ethernet)
_transmission order_ of an IEEE 802 MAC address. The standards authors
forgot that the bitwise order of an _octet_ from a MAC address _memory_
and hexadecimal string representation is still always from left (MSB,
bit 7) to right (LSB, bit 0).
Fortunately, this UUID generation bug could have occurred on systems
without any Ethernet NICs only.
Revision Changes Path
1.7 +1 -1 src/sys/kern/kern_uuid.c
Date: Thu, 22 Jan 2004 15:20:22 -0800
From: Marcel Moolenaar <marcel@xcllnt.net>
To: "Ralf S. Engelschall" <rse@FreeBSD.org>
Cc: src-committers@FreeBSD.org, cvs-src@FreeBSD.org, cvs-all@FreeBSD.org
Subject: Re: cvs commit: src/sys/kern kern_uuid.c
Message-ID: <20040122232022.GA77798@ns1.xcllnt.net>
References: <200401221334.i0MDYB1K018137@repoman.freebsd.org>
Content-Length: 380
Lines: 14
On Thu, Jan 22, 2004 at 05:34:11AM -0800, Ralf S. Engelschall wrote:
> rse 2004/01/22 05:34:11 PST
>
> FreeBSD src repository
>
> Modified files:
> sys/kern kern_uuid.c
> Log:
> Fix generation of random multicast MAC address.
An excellent catch and an outstanding commit log. Chapeau!
--
Marcel Moolenaar USPA: A-39004 marcel@xcllnt.net
___________________________________________________________________________
Index: ChangeLog
===================================================================
RCS file: /e/ossp/cvs/ossp-pkg/uuid/ChangeLog,v
retrieving revision 1.42
diff -u -d -r1.42 ChangeLog
--- ChangeLog 13 Feb 2004 16:17:07 -0000 1.42
+++ ChangeLog 13 Feb 2004 21:01:07 -0000
@@ -13,6 +13,14 @@
Changes between 0.9.6 and 0.9.7 (11-Feb-2004 to 13-Feb-2004)
+ o remove --with-rfc2518 option and functionality because
+ even the IETF/IESG has finally approved our report about the broken
+ random multicast MAC address generation in the standard (and
+ will fix it in new versions of the draft-mealling-uuid-urn). So,
+ finally get rid of this broken-by-design backward compatibility
+ functionality.
+ [Ralf S. Engelschall]
+
o Add support to uuid(1) CLI for decoding from stdin for
both binary and string representations.
[Ralf S. Engelschall]
Index: uuid.ac
===================================================================
RCS file: /e/ossp/cvs/ossp-pkg/uuid/uuid.ac,v
retrieving revision 1.10
diff -u -d -r1.10 uuid.ac
--- uuid.ac 11 Feb 2004 14:38:40 -0000 1.10
+++ uuid.ac 13 Feb 2004 19:20:32 -0000
@@ -71,12 +71,6 @@
AC_CHECK_SIZEOF(unsigned long long, 8)
dnl # options
- AC_ARG_WITH(rfc2518,
- AC_HELP_STRING([--with-rfc2518], [use incorrect generation of IEEE 802 multicast addresses according to RFC2518]),
- [ac_cv_with_rfc2518=$withval], [ac_cv_with_rfc2518=no])
- if test ".$ac_cv_with_rfc2518" = ".yes"; then
- AC_DEFINE(WITH_RFC2518, 1, [whether to use incorrect generation of IEEE 802 multicast addresses according to RFC2518])
- fi
AC_ARG_WITH(dce,
AC_HELP_STRING([--with-dce], [build DCE 1.1 backward compatibility API]),
[ac_cv_with_dce=$withval], [ac_cv_with_dce=no])
Index: uuid.c
===================================================================
RCS file: /e/ossp/cvs/ossp-pkg/uuid/uuid.c,v
retrieving revision 1.44
diff -u -d -r1.44 uuid.c
--- uuid.c 19 Jan 2004 14:56:35 -0000 1.44
+++ uuid.c 13 Feb 2004 19:22:01 -0000
@@ -61,69 +61,9 @@
Unix UTC base time is January 1, 1970) */
#define UUID_TIMEOFFSET "01B21DD213814000"
-/* IEEE 802 MAC address encoding/decoding bit fields
-
- ATTENTION:
-
- In case no real/physical IEEE 802 address is available, both
- "draft-leach-uuids-guids-01" (section "4. Node IDs when no IEEE 802
- network card is available") and RFC 2518 (section "6.4.1 Node Field
- Generation Without the IEEE 802 Address") recommend (quoted from RFC
- 2518):
-
- "The ideal solution is to obtain a 47 bit cryptographic quality
- random number, and use it as the low 47 bits of the node ID, with
- the most significant bit of the first octet of the node ID set to
- 1. This bit is the unicast/multicast bit, which will never be set
- in IEEE 802 addresses obtained from network cards; hence, there can
- never be a conflict between UUIDs generated by machines with and
- without network cards."
-
- This passage clearly explains the intention to use IEEE 802 multicast
- addresses. Unfortunately, it incorrectly explains how to implement
- this! It should instead specify the "*LEAST* significant bit of the
- first octet of the node ID" as the multicast bit in a memory and
- hexadecimal string representation of a 48-bit IEEE 802 MAC address.
-
- Unfortunately, even the reference implementation included in the
- expired IETF "draft-leach-uuids-guids-01" incorrectly set the
- multicast bit with an OR bit operation and an incorrect mask of
- 0x80. Hence, several other UUID implementations found on the
- Internet have inherited this bug.
-
- Luckily, neither DCE 1.1 nor ISO/IEC 11578:1996 are affected by this
- problem. They disregard the topic of missing IEEE 802 addresses
- entirely, and thus avoid adopting this bug from the original draft
- and code ;-)
-
- It seems that this standards bug arises from a false interpretation,
- as the multicast bit is actually the *MOST* significant bit in IEEE
- 802.3 (Ethernet) _transmission order_ of an IEEE 802 MAC address. The
- authors were likely not aware that the bitwise order of an octet from
- a MAC address memory and hexadecimal string representation is still
- always from left (MSB, bit 7) to right (LSB, bit 0).
-
- For more information, see "Understanding Physical Addresses" in
- "Ethernet -- The Definitive Guide", p.43, and the section "ETHERNET
- MULTICAST ADDRESSES" in http://www.iana.org/assignments/ethernet-numbers.
-
- At OSSP, we do it the intended/correct way and generate a real
- IEEE 802 multicast address. Those wanting to encode broken IEEE
- 802 MAC addresses (as specified) can nevertheless use a brain dead
- compile-time option to switch off the correct behavior. When decoding
- we always use the correct behavior of course. */
-
-/* encoding */
-#ifdef WITH_RFC2518
-#define IEEE_MAC_MCBIT_ENC BM_OCTET(1,0,0,0,0,0,0,0)
-#else
-#define IEEE_MAC_MCBIT_ENC BM_OCTET(0,0,0,0,0,0,0,1)
-#endif
-#define IEEE_MAC_LOBIT_ENC BM_OCTET(0,0,0,0,0,0,1,0)
-
-/* decoding */
-#define IEEE_MAC_MCBIT_DEC BM_OCTET(0,0,0,0,0,0,0,1)
-#define IEEE_MAC_LOBIT_DEC BM_OCTET(0,0,0,0,0,0,1,0)
+/* IEEE 802 MAC address encoding/decoding bit fields */
+#define IEEE_MAC_MCBIT BM_OCTET(0,0,0,0,0,0,0,1)
+#define IEEE_MAC_LOBIT BM_OCTET(0,0,0,0,0,0,1,0)
/* IEEE 802 MAC address octet length */
#define IEEE_MAC_OCTETS 6
@@ -622,8 +562,8 @@
(unsigned int)uuid->obj.node[3],
(unsigned int)uuid->obj.node[4],
(unsigned int)uuid->obj.node[5],
- (uuid->obj.node[0] & IEEE_MAC_LOBIT_DEC ? "local" : "global"),
- (uuid->obj.node[0] & IEEE_MAC_MCBIT_DEC ? "multicast" : "unicast"));
+ (uuid->obj.node[0] & IEEE_MAC_LOBIT ? "local" : "global"),
+ (uuid->obj.node[0] & IEEE_MAC_MCBIT ? "multicast" : "unicast"));
}
else {
/* decode anything else as hexadecimal byte-string only */
@@ -843,8 +783,8 @@
if ((mode & UUID_MAKE_MC) || (uuid->mac[0] & BM_OCTET(1,0,0,0,0,0,0,0))) {
/* generate random IEEE 802 local multicast MAC address */
prng_data(uuid->prng, (void *)&(uuid->obj.node), sizeof(uuid->obj.node));
- uuid->obj.node[0] |= IEEE_MAC_MCBIT_ENC;
- uuid->obj.node[0] |= IEEE_MAC_LOBIT_ENC;
+ uuid->obj.node[0] |= IEEE_MAC_MCBIT;
+ uuid->obj.node[0] |= IEEE_MAC_LOBIT;
}
else {
/* use real regular MAC address */

View File

@ -1,23 +0,0 @@
_ ___ ____ ____ ____ _ _
|_|_ _ / _ \/ ___/ ___|| _ \ _ _ _ _(_) __| |
_|_||_| | | | \___ \___ \| |_) | | | | | | | | |/ _` |
|_||_|_| | |_| |___) |__) | __/ | |_| | |_| | | (_| |
|_|_|_| \___/|____/____/|_| \__,_|\__,_|_|\__,_|
OSSP uuid - Universally Unique Identifier
INSTALLATION
To install OSSP uuid into /path/to/uuid/ perform
the following steps in your shell:
$ ./configure
--prefix=/path/to/uuid
[--with-dce]
[--with-perl[=/path/to/[bin[/perl]
--with-perl-compat]]
[--with-php]
$ make
$ make check
$ make install [DESTDIR=/path/to/temp/root]

View File

@ -1,83 +0,0 @@
AUTHORS
BINDINGS
ChangeLog
HISTORY
INSTALL
MANIFEST
Makefile.PL
Makefile.in
NEWS
OVERVIEW
PORTING
README
SEEALSO
THANKS
TODO
USERS
aclocal.m4
config.guess
config.h.in
config.sub
configure
configure.ac
libtool.m4
ltmain.sh
perl/MANIFEST
perl/Makefile.PL
perl/uuid.pm
perl/uuid.pod
perl/uuid.tm
perl/uuid.ts
perl/uuid.xs
perl/uuid_compat.pm
perl/uuid_compat.pod
perl/uuid_compat.ts
pgsql/Makefile
pgsql/uuid.c
pgsql/uuid.sql.in
pgsql/uuid.txt
php/Makefile.local
php/config.m4
php/package.xml
php/uuid.c
php/uuid.php4
php/uuid.php5
php/uuid.ts
shtool
uuid++.3
uuid++.cc
uuid++.hh
uuid++.pod
uuid-config.1
uuid-config.in
uuid-config.pod
uuid.1
uuid.3
uuid.ac
uuid.c
uuid.h.in
uuid.pc.in
uuid.pod
uuid_ac.h
uuid_bm.h
uuid_cli.c
uuid_cli.pod
uuid_dce.c
uuid_dce.h
uuid_mac.c
uuid_mac.h
uuid_md5.c
uuid_md5.h
uuid_prng.c
uuid_prng.h
uuid_sha1.c
uuid_sha1.h
uuid_str.c
uuid_str.h
uuid_time.c
uuid_time.h
uuid_ui128.c
uuid_ui128.h
uuid_ui64.c
uuid_ui64.h
uuid_vers.h

View File

@ -1,67 +0,0 @@
##
## OSSP uuid - Universally Unique Identifier
## Copyright (c) 2004-2008 Ralf S. Engelschall <rse@engelschall.com>
## Copyright (c) 2004-2008 The OSSP Project <http://www.ossp.org/>
##
## This file is part of OSSP uuid, a library for the generation
## of UUIDs which can found at http://www.ossp.org/pkg/lib/uuid/
##
## Permission to use, copy, modify, and distribute this software for
## any purpose with or without fee is hereby granted, provided that
## the above copyright notice and this permission notice appear in all
## copies.
##
## THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
## WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
## IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
## CONTRIBUTORS 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 ADVISED OF THE POSSIBILITY OF
## SUCH DAMAGE.
##
## Makefile.PL: top-level Perl ExtUtils::MakeMaker wrapper script
##
require 5.008;
use IO::File;
my $ARGS = join(" ", @ARGV);
print "++ writing Makefile\n";
my $mk = new IO::File ">Makefile" or die;
$mk->print(<< "EOF");
PERL = $^X
FULLPERL = $^X
ARGS = $ARGS
all pure_all:
\@if [ ! -d build ]; then mkdir build; fi
\@if [ ! -f build/Makefile ]; then (cd build && ../configure --disable-shared); fi
\@if [ ! -f build/libuuid.la ]; then (cd build && \$(MAKE) \$(MFLAGS) libuuid.la); fi
\@if [ ! -f perl/Makefile ]; then (cd perl && \$(PERL) Makefile.PL \$(ARGS)); fi
\@cd perl && \$(MAKE) \$(MFLAGS) \$\@
install pure_install test:
\@cd perl && \$(MAKE) \$(MFLAGS) \$\@
clean:
\@cd build && \$(MAKE) \$(MFLAGS) \$\@
\@cd perl && \$(MAKE) \$(MFLAGS) \$\@
distclean realclean:
\@cd build && \$(MAKE) \$(MFLAGS) \$\@
\@cd perl && \$(MAKE) \$(MFLAGS) \$\@
-rm -rf build || true
-rm -rf Makefile || true
EOF
$mk->close();

View File

@ -1,357 +0,0 @@
##
## OSSP uuid - Universally Unique Identifier
## Copyright (c) 2004-2008 Ralf S. Engelschall <rse@engelschall.com>
## Copyright (c) 2004-2008 The OSSP Project <http://www.ossp.org/>
##
## This file is part of OSSP uuid, a library for the generation
## of UUIDs which can found at http://www.ossp.org/pkg/lib/uuid/
##
## Permission to use, copy, modify, and distribute this software for
## any purpose with or without fee is hereby granted, provided that
## the above copyright notice and this permission notice appear in all
## copies.
##
## THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
## WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
## IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
## CONTRIBUTORS 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 ADVISED OF THE POSSIBILITY OF
## SUCH DAMAGE.
##
## Makefile.in: make(1) build procedure
##
@SET_MAKE@
VPATH = @srcdir@
srcdir = @srcdir@
top_srcdir = @top_srcdir@
S = $(srcdir)
C = .
DESTDIR =
prefix = @prefix@
exec_prefix = @exec_prefix@
datarootdir = @datarootdir@
bindir = @bindir@
libdir = @libdir@
includedir = @includedir@
mandir = @mandir@
CC = @CC@
CXX = @CXX@
CPPFLAGS = -I. -I$(S) @CPPFLAGS@ @DEFS@
CFLAGS = @CFLAGS@
CXXFLAGS = @CXXFLAGS@
LDFLAGS = @LDFLAGS@
LIBS = @LIBS@
RM = rm -f
CP = cp
RMDIR = rmdir
SHTOOL = $(S)/shtool
LIBTOOL = $(C)/libtool
TRUE = true
POD2MAN = pod2man
PERL = @PERL@
PHP = @PHP@
PG_CONFIG = @PG_CONFIG@
LIB_NAME = libuuid.la
LIB_OBJS = uuid.lo uuid_md5.lo uuid_sha1.lo uuid_prng.lo uuid_mac.lo uuid_time.lo uuid_ui64.lo uuid_ui128.lo uuid_str.lo
DCE_NAME = libuuid_dce.la
DCE_OBJS = uuid_dce.lo $(LIB_OBJS)
CXX_NAME = libuuid++.la
CXX_OBJS = uuid++.lo $(LIB_OBJS)
PRG_NAME = uuid
PRG_OBJS = uuid_cli.o
MAN_NAME = uuid.3 uuid++.3 uuid.1
PERL_NAME = $(S)/perl/blib/lib/OSSP/uuid.pm
PERL_OBJS = $(S)/perl/uuid.pm
PHP_NAME = $(S)/php/modules/uuid.so
PHP_OBJS = $(S)/php/uuid.c
PGSQL_NAME = $(S)/pgsql/libuuid.so
PGSQL_OBJS = $(S)/pgsql/uuid.c
TARGETS = $(LIB_NAME) @DCE_NAME@ @CXX_NAME@ $(PRG_NAME) @PERL_NAME@ @PHP_NAME@ @PGSQL_NAME@
WITH_DCE = @WITH_DCE@
WITH_CXX = @WITH_CXX@
WITH_PERL = @WITH_PERL@
WITH_PERL_COMPAT = @WITH_PERL_COMPAT@
WITH_PHP = @WITH_PHP@
WITH_PGSQL = @WITH_PGSQL@
.SUFFIXES:
.SUFFIXES: .c .cc .o .lo
all: $(TARGETS)
.c.o:
$(CC) $(CPPFLAGS) $(CFLAGS) -c $<
.cc.o:
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $<
.c.lo:
@$(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) $(CFLAGS) -c $<
.cc.lo:
@$(LIBTOOL) --mode=compile $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $<
$(LIB_NAME): $(LIB_OBJS)
@$(LIBTOOL) --mode=link $(CC) -o $(LIB_NAME) $(LIB_OBJS) -rpath $(libdir) \
-version-info `$(SHTOOL) version -l c -d libtool $(S)/uuid_vers.h`
$(DCE_NAME): $(DCE_OBJS)
@$(LIBTOOL) --mode=link $(CC) -o $(DCE_NAME) $(DCE_OBJS) -rpath $(libdir) \
-version-info `$(SHTOOL) version -l c -d libtool $(S)/uuid_vers.h`
$(CXX_NAME): $(CXX_OBJS)
@$(LIBTOOL) --mode=link $(CXX) -o $(CXX_NAME) $(CXX_OBJS) -rpath $(libdir) \
-version-info `$(SHTOOL) version -l c -d libtool $(S)/uuid_vers.h`
$(PRG_NAME): $(PRG_OBJS) $(LIB_NAME)
@$(LIBTOOL) --mode=link $(CC) $(LDFLAGS) -o $(PRG_NAME) $(PRG_OBJS) $(LIB_NAME) $(LIBS)
$(PERL_NAME): $(PERL_OBJS) $(LIB_NAME)
@cd $(S)/perl && $(PERL) Makefile.PL PREFIX=$(prefix) COMPAT=$(WITH_PERL_COMPAT) && $(MAKE) $(MFLAGS) all
@touch $(PERL_NAME)
$(PHP_NAME): $(PHP_OBJS) $(LIB_NAME)
@cd $(S)/php && $(MAKE) $(MFLAGS) -f Makefile.local PHP=$(PHP)
@touch $(PHP_NAME)
$(PGSQL_NAME): $(PGSQL_OBJS) $(LIB_NAME)
@cd $(S)/pgsql && $(MAKE) $(MFLAGS) PG_CONFIG=$(PG_CONFIG)
@touch $(PGSQL_NAME)
uuid.lo: $(S)/uuid.c uuid.h $(S)/uuid_md5.h $(S)/uuid_sha1.h $(S)/uuid_prng.h $(S)/uuid_mac.h $(S)/uuid_ui64.h $(S)/uuid_ui128.h $(S)/uuid_str.h $(S)/uuid_bm.h $(S)/uuid_ac.h
uuid_mac.lo: $(S)/uuid_mac.c $(S)/uuid_mac.h
uuid_md5.lo: $(S)/uuid_md5.c $(S)/uuid_md5.h
uuid_sha1.lo: $(S)/uuid_sha1.c $(S)/uuid_sha1.h
uuid_prng.lo: $(S)/uuid_prng.c $(S)/uuid_prng.h
uuid_str.lo: $(S)/uuid_str.c $(S)/uuid_str.h
uuid_ui64.lo: $(S)/uuid_ui64.c $(S)/uuid_ui64.h
uuid_ui128.lo: $(S)/uuid_ui64.c $(S)/uuid_ui128.h
uuid_dce.lo: $(S)/uuid_dce.c uuid.h $(S)/uuid_dce.h
uuid_cli.o: $(S)/uuid_cli.c uuid.h
uuid++.lo: $(S)/uuid++.cc $(S)/uuid++.hh
man: uuid.3 uuid++.3 uuid-config.1 uuid.1
uuid.3: uuid.pod
V1=`$(SHTOOL) version -l c -d short $(S)/uuid_vers.h`; \
V2=`$(SHTOOL) version -l c -d long $(S)/uuid_vers.h`; \
D=`$(SHTOOL) version -l c -d long $(S)/uuid_vers.h | sed -e 's;.*(;;' -e 's;).*;;'`; \
$(POD2MAN) --quotes=none \
--section=3 --center="Universally Unique Identifier" \
--release="$$D" --date="OSSP uuid $$V1" $(S)/uuid.pod | \
sed -e "s;UUID_VERSION_STR;$$V2;" >uuid.3
uuid++.3: uuid++.pod
V1=`$(SHTOOL) version -l c -d short $(S)/uuid_vers.h`; \
V2=`$(SHTOOL) version -l c -d long $(S)/uuid_vers.h`; \
D=`$(SHTOOL) version -l c -d long $(S)/uuid_vers.h | sed -e 's;.*(;;' -e 's;).*;;'`; \
$(POD2MAN) --quotes=none \
--section=3 --center="Universally Unique Identifier" \
--release="$$D" --date="OSSP uuid $$V1" $(S)/uuid++.pod | \
sed -e "s;UUID_VERSION_STR;$$V2;" >uuid++.3
uuid-config.1: uuid-config.pod
V1=`$(SHTOOL) version -l c -d short $(S)/uuid_vers.h`; \
V2=`$(SHTOOL) version -l c -d long $(S)/uuid_vers.h`; \
D=`$(SHTOOL) version -l c -d long $(S)/uuid_vers.h | sed -e 's;.*(;;' -e 's;).*;;'`; \
$(POD2MAN) --quotes=none \
--section=1 --center="Universally Unique Identifier" \
--release="$$D" --date="OSSP uuid $$V1" $(S)/uuid-config.pod | \
sed -e "s;UUID_VERSION_STR;$$V2;" >uuid-config.1
uuid.1: uuid_cli.pod
V1=`$(SHTOOL) version -l c -d short $(S)/uuid_vers.h`; \
V2=`$(SHTOOL) version -l c -d long $(S)/uuid_vers.h`; \
D=`$(SHTOOL) version -l c -d long $(S)/uuid_vers.h | sed -e 's;.*(;;' -e 's;).*;;'`; \
$(CP) $(S)/uuid_cli.pod /tmp/uuid.pod; \
$(POD2MAN) --quotes=none \
--section=1 --center="Universally Unique Identifier" \
--release="$$D" --date="OSSP uuid $$V1" /tmp/uuid.pod | \
sed -e "s;UUID_VERSION_STR;$$V2;" >uuid.1; \
$(RM) /tmp/uuid.pod
check: all
@echo "==== UUID version 1 (time and node based): 4 single iterations"; \
$(LIBTOOL) --mode=execute ./$(PRG_NAME) -v1 -n 4 -1
@echo "==== UUID version 1 (time and node based): 4 subsequent iterations"; \
$(LIBTOOL) --mode=execute ./$(PRG_NAME) -v1 -n 4
@echo "==== UUID version 3 (name based, MD5): 2 times repeated"; \
$(LIBTOOL) --mode=execute ./$(PRG_NAME) -v3 -n 2 ns:URL http://www.ossp.org/
@echo "==== UUID version 5 (name based, SHA-1): 2 times repeated"; \
$(LIBTOOL) --mode=execute ./$(PRG_NAME) -v5 -n 2 ns:URL http://www.ossp.org/
@echo "==== UUID version 4 (random data based): 4 single iterations"; \
$(LIBTOOL) --mode=execute ./$(PRG_NAME) -v4 -n 4 -1
@echo "==== UUID version 4 (random data based): 4 subsequent iterations"; \
$(LIBTOOL) --mode=execute ./$(PRG_NAME) -v4 -n 4
@echo "==== UUID version 1 generation and decoding"; \
$(LIBTOOL) --mode=execute ./$(PRG_NAME) -d `$(LIBTOOL) --mode=execute ./$(PRG_NAME) -v1`; \
$(LIBTOOL) --mode=execute ./$(PRG_NAME) -d `$(LIBTOOL) --mode=execute ./$(PRG_NAME) -v1 -m`
@echo "==== UUID version 3 generation and decoding"; \
$(LIBTOOL) --mode=execute ./$(PRG_NAME) -d `$(LIBTOOL) --mode=execute ./$(PRG_NAME) -v3 ns:URL http://www.ossp.org/`
@echo "==== UUID version 5 generation and decoding"; \
$(LIBTOOL) --mode=execute ./$(PRG_NAME) -d `$(LIBTOOL) --mode=execute ./$(PRG_NAME) -v5 ns:URL http://www.ossp.org/`
@echo "==== UUID version 3 generation and decoding"; \
$(LIBTOOL) --mode=execute ./$(PRG_NAME) -d `$(LIBTOOL) --mode=execute ./$(PRG_NAME) -v4`
-@if [ ".$(WITH_PERL)" = .yes ]; then \
echo "==== Perl bindings to C API"; \
(cd $(S)/perl && $(MAKE) $(MFLAGS) test); \
fi
-@if [ ".$(WITH_PHP)" = .yes ]; then \
echo "==== PHP bindings to C API"; \
(cd $(S)/php && $(MAKE) $(MFLAGS) -f Makefile.local test PHP=$(PHP)); \
fi
-@if [ ".$(WITH_PGSQL)" = .yes ]; then \
echo "==== PGSQL bindings to C API"; \
(cd $(S)/pgsql && $(MAKE) $(MFLAGS) test PG_CONFIG=$(PG_CONFIG)); \
fi
.PHONY: install
install:
$(SHTOOL) mkdir -f -p -m 755 $(DESTDIR)$(prefix)
$(SHTOOL) mkdir -f -p -m 755 $(DESTDIR)$(bindir)
$(SHTOOL) mkdir -f -p -m 755 $(DESTDIR)$(includedir)
$(SHTOOL) mkdir -f -p -m 755 $(DESTDIR)$(libdir)/pkgconfig
$(SHTOOL) mkdir -f -p -m 755 $(DESTDIR)$(mandir)/man3
$(SHTOOL) mkdir -f -p -m 755 $(DESTDIR)$(mandir)/man1
$(SHTOOL) install -c -m 755 uuid-config $(DESTDIR)$(bindir)/
$(SHTOOL) install -c -m 644 $(S)/uuid-config.1 $(DESTDIR)$(mandir)/man1/
$(SHTOOL) install -c -m 644 $(S)/uuid.pc $(DESTDIR)$(libdir)/pkgconfig/
$(SHTOOL) install -c -m 644 uuid.h $(DESTDIR)$(includedir)/
-@if [ ".$(WITH_DCE)" = .yes ]; then \
echo "$(SHTOOL) install -c -m 644 $(S)/uuid_dce.h $(DESTDIR)$(includedir)/"; \
$(SHTOOL) install -c -m 644 $(S)/uuid_dce.h $(DESTDIR)$(includedir)/; \
fi
-@if [ ".$(WITH_CXX)" = .yes ]; then \
echo "$(SHTOOL) install -c -m 644 $(S)/uuid++.hh $(DESTDIR)$(includedir)/"; \
$(SHTOOL) install -c -m 644 $(S)/uuid++.hh $(DESTDIR)$(includedir)/; \
fi
$(SHTOOL) install -c -m 644 $(S)/uuid.3 $(DESTDIR)$(mandir)/man3/
-@if [ ".$(WITH_CXX)" = .yes ]; then \
echo "$(SHTOOL) install -c -m 644 $(S)/uuid++.3 $(DESTDIR)$(mandir)/man3/"; \
$(SHTOOL) install -c -m 644 $(S)/uuid++.3 $(DESTDIR)$(mandir)/man3/; \
fi
@$(LIBTOOL) --mode=install $(SHTOOL) install -c -m 644 $(LIB_NAME) $(DESTDIR)$(libdir)/
-@if [ ".$(WITH_DCE)" = .yes ]; then \
$(LIBTOOL) --mode=install $(SHTOOL) install -c -m 644 $(DCE_NAME) $(DESTDIR)$(libdir)/; \
fi
-@if [ ".$(WITH_CXX)" = .yes ]; then \
$(LIBTOOL) --mode=install $(SHTOOL) install -c -m 644 $(CXX_NAME) $(DESTDIR)$(libdir)/; \
fi
@$(LIBTOOL) --mode=install $(SHTOOL) install -c -s -m 755 uuid $(DESTDIR)$(bindir)/
$(SHTOOL) install -c -m 644 $(S)/uuid.1 $(DESTDIR)$(mandir)/man1/
-@if [ ".$(WITH_PERL)" = .yes ]; then \
(cd $(S)/perl && $(MAKE) $(MFLAGS) install DESTDIR=$(DESTDIR)); \
fi
-@if [ ".$(WITH_PHP)" = .yes ]; then \
(cd $(S)/php && $(MAKE) $(MFLAGS) -f Makefile.local install EXTDIR=$(prefix)/lib/php PHP=$(PHP) DESTDIR=$(DESTDIR)); \
fi
-@if [ ".$(WITH_PGSQL)" = .yes ]; then \
(cd $(S)/pgsql && $(MAKE) $(MFLAGS) install DESTDIR=$(DESTDIR) PG_CONFIG=$(PG_CONFIG)); \
fi
.PHONY: uninstall
uninstall:
-$(RM) $(DESTDIR)$(mandir)/man1/uuid.1
-@$(LIBTOOL) --mode=uninstall $(RM) $(DESTDIR)$(bindir)/uuid
-@$(LIBTOOL) --mode=uninstall $(RM) $(DESTDIR)$(libdir)/$(LIB_NAME)
-@if [ ".$(WITH_DCE)" = .yes ]; then \
$(LIBTOOL) --mode=uninstall $(RM) $(DESTDIR)$(libdir)/$(DCE_NAME); \
fi
-@if [ ".$(WITH_CXX)" = .yes ]; then \
$(LIBTOOL) --mode=uninstall $(RM) $(DESTDIR)$(libdir)/$(CXX_NAME); \
fi
-$(RM) $(DESTDIR)$(mandir)/man3/uuid.3
-@if [ ".$(WITH_CXX)" = .yes ]; then \
echo "$(RM) $(DESTDIR)$(mandir)/man3/uuid++.3"; \
$(RM) $(DESTDIR)$(mandir)/man3/uuid++.3; \
fi
-$(RM) $(DESTDIR)$(includedir)/uuid.h
-@if [ ".$(WITH_DCE)" = .yes ]; then \
echo "$(RM) $(DESTDIR)$(includedir)/uuid_dce.h"; \
$(RM) $(DESTDIR)$(includedir)/uuid_dce.h; \
fi
-@if [ ".$(WITH_CXX)" = .yes ]; then \
echo "$(RM) $(DESTDIR)$(includedir)/uuid++.hh"; \
$(RM) $(DESTDIR)$(includedir)/uuid++.hh; \
fi
-$(RM) $(DESTDIR)$(libdir)/pkgconfig/uuid.pc
-$(RM) $(DESTDIR)$(mandir)/man1/uuid-config.1
-$(RM) $(DESTDIR)$(bindir)/uuid-config
-$(RMDIR) $(DESTDIR)$(mandir)/man1 >/dev/null 2>&1 || $(TRUE)
-$(RMDIR) $(DESTDIR)$(mandir)/man3 >/dev/null 2>&1 || $(TRUE)
-$(RMDIR) $(DESTDIR)$(mandir) >/dev/null 2>&1 || $(TRUE)
-$(RMDIR) $(DESTDIR)$(libdir)/pkgconfig >/dev/null 2>&1 || $(TRUE)
-$(RMDIR) $(DESTDIR)$(libdir) >/dev/null 2>&1 || $(TRUE)
-$(RMDIR) $(DESTDIR)$(includedir) >/dev/null 2>&1 || $(TRUE)
-$(RMDIR) $(DESTDIR)$(bindir) >/dev/null 2>&1 || $(TRUE)
-$(RMDIR) $(DESTDIR)$(prefix) >/dev/null 2>&1 || $(TRUE)
.PHONY: clean
clean:
-$(RM) $(LIB_NAME) $(LIB_OBJS)
-@if [ ".$(WITH_DCE)" = .yes ]; then \
echo "$(RM) $(DCE_NAME) $(DCE_OBJS)"; \
$(RM) $(DCE_NAME) $(DCE_OBJS); \
fi
-@if [ ".$(WITH_CXX)" = .yes ]; then \
echo "$(RM) $(CXX_NAME) $(CXX_OBJS)"; \
$(RM) $(CXX_NAME) $(CXX_OBJS); \
fi
-$(RM) $(PRG_NAME) $(PRG_OBJS)
-$(RM) -r .libs >/dev/null 2>&1 || $(TRUE)
-$(RM) *.o *.lo
-@if [ ".$(WITH_PERL)" = .yes ]; then \
(cd $(S)/perl && $(MAKE) $(MFLAGS) clean || true); \
fi
-@if [ ".$(WITH_PHP)" = .yes ]; then \
(cd $(S)/php && $(MAKE) $(MFLAGS) -f Makefile.local clean || true); \
fi
-@if [ ".$(WITH_PGSQL)" = .yes ]; then \
(cd $(S)/pgsql && $(MAKE) $(MFLAGS) clean PG_CONFIG=$(PG_CONFIG) || true); \
fi
distclean: clean
-$(RM) config.log config.status config.cache
-$(RM) Makefile config.h uuid-config uuid.h uuid.pc
-$(RM) libtool
-@if [ ".$(WITH_PERL)" = .yes ]; then \
(cd $(S)/perl && $(MAKE) $(MFLAGS) distclean || true; rm -f Makefile.old); \
fi
-@if [ ".$(WITH_PHP)" = .yes ]; then \
(cd $(S)/php && $(MAKE) $(MFLAGS) -f Makefile.local distclean || true); \
fi
-@if [ ".$(WITH_PGSQL)" = .yes ]; then \
(cd $(S)/pgsql && $(MAKE) $(MFLAGS) distclean PG_CONFIG=$(PG_CONFIG) || true); \
fi
realclean: distclean
-$(RM) uuid.3 uuid.1
-$(RM) configure config.h.in
-$(RM) shtool
-$(RM) ltmain.sh libtool.m4 config.guess config.sub
-@if [ ".$(WITH_PERL)" = .yes ]; then \
(cd $(S)/perl && $(MAKE) $(MFLAGS) realclean || true; rm -f Makefile.old); \
fi
-@if [ ".$(WITH_PHP)" = .yes ]; then \
(cd $(S)/php && $(MAKE) $(MFLAGS) -f Makefile.local realclean || true); \
fi
-@if [ ".$(WITH_PGSQL)" = .yes ]; then \
(cd $(S)/pgsql && $(MAKE) $(MFLAGS) realclean PG_CONFIG=$(PG_CONFIG) || true); \
fi

View File

@ -1,42 +0,0 @@
_ ___ ____ ____ ____ _ _
|_|_ _ / _ \/ ___/ ___|| _ \ _ _ _ _(_) __| |
_|_||_| | | | \___ \___ \| |_) | | | | | | | | |/ _` |
|_||_|_| | |_| |___) |__) | __/ | |_| | |_| | | (_| |
|_|_|_| \___/|____/____/|_| \__,_|\__,_|_|\__,_|
OSSP uuid - Universally Unique Identifier
NEWS
This is a list of major changes to OSSP uuid. For more detailed
change descriptions, please have a look at the ChangeLog file.
Major changes between 1.4 and 1.5
o Many internal code cleanups and fixes.
o Improved and fixed PostgreSQL API.
o Improved and fixed PHP API.
Major changes between 1.3 and 1.4
o Added PostgreSQL API.
Major changes between 1.2 and 1.3
o Added Perl TIE-style API.
o Added Perl Data::UUID backward compatibility API.
o Added C++ API.
o Added PHP API.
Major changes between 1.1 and 1.2
o Added support for version 5 UUIDs (name-based, SHA-1)
Major changes between 1.0 and 1.1
o Added Perl API
Major changes between 0.9 and 1.0
o Initial functionality

View File

@ -1,81 +0,0 @@
_ ___ ____ ____ ____ _ _
|_|_ _ / _ \/ ___/ ___|| _ \ _ _ _ _(_) __| |
_|_||_| | | | \___ \___ \| |_) | | | | | | | | |/ _` |
|_||_|_| | |_| |___) |__) | __/ | |_| | |_| | | (_| |
|_|_|_| \___/|____/____/|_| \__,_|\__,_|_|\__,_|
OSSP uuid - Universally Unique Identifier
OVERVIEW
A UUID consists of 128 bits (16-octets) which are split into 6
octet-bounded unsigned integer fields ("time_low", "time_mid",
"time_hi_and_version", "clk_seq_hi_res", "clk_seq_low" and "node") and
where two fields are multiplexed with a fixed size 4-bit "version" and
a variable sized 2-3 bit "variant" field.
The UUID octets are counted from left to right 15 to 0 and the bits
in each octet are counted from left to right 7 to 0 (most significant
bit first, least significant bit last). The unsigned integer fields
formed out of multiple octets are stored in "network byte order" (most
significant octet first, least significant octet last). A UUID is
stored and transmitted from left to right, i.e., in "network byte
order" with the most significant octet first and the least significant
octet last.
Illustration 1:
(single octet array, less compact, more annotations)
Bits: [4] [2-3]
Field: version variant
MSO -->| |<-- -->| |<-- LSO
\ | | | | /
Octet: 15 14 13 12 11 10 | |9 8 | | 7 6 5 4 3 2 1 0
+------++------++------++------++------++------++------++------++------++------++------++------++------++------++------++------+
UUID: | || || || || || |#### || |##: || || || || || || || |
+------++------++------++------++------++------++------++------++------++------++------++------++------++------++------++------+
Bit: 76543210765432107654321076543210765432107654321076543210765432107654321076543210765432107654321076543210765432107654321076543210
/| || || || || || |\
MSB | || || || || || | LSB
|<---------------------------->||<------------>||<------------>||<---->||<---->||<-------------------------------------------->|
time_hi clk_seq clk_seq
Field: time_low time_mid _and_version _hi_res _low node
Bits: [32] [16] [16] [5-6] [8] [48]
Illustration 2:
(two octet arrays, more compact, less annotations)
[4]
version
-->| |<--
| |
| | [16]
[32] [16] | |time_hi
time_low time_mid | _and_version
|<---------------------------->||<------------>||<------------>|
| MSO || || | |
| / || || | |
| 15 14 13 12 || 11 10 || |9 8 |
7654321076543210765432107654321076543210765432107654321076543210
/+------++------++------++------++------++------++------++------+~
MSB | || || || || || |#### || | ...
+------++------++------++------++------++------++------++------+~
~+------++------++------++------++------++------++------++------+
... ##: || || || || || || || | LSB
~+------++------++------++------++------++------++------++------+/
7654321076543210765432107654321076543210765432107654321076543210
| | 7 || 6 || 5 4 3 2 1 0 |
| | || || / |
| | || || LSO |
|<---->||<---->||<-------------------------------------------->|
|clk_seq clk_seq node
|_hi_res _low [48]
|[5-6] [8]
| |
-->| |<--
variant
[2-3]

View File

@ -1,33 +0,0 @@
_ ___ ____ ____ ____ _ _
|_|_ _ / _ \/ ___/ ___|| _ \ _ _ _ _(_) __| |
_|_||_| | | | \___ \___ \| |_) | | | | | | | | |/ _` |
|_||_|_| | |_| |___) |__) | __/ | |_| | |_| | | (_| |
|_|_|_| \___/|____/____/|_| \__,_|\__,_|_|\__,_|
OSSP uuid - Universally Unique Identifier
PORTING
OSSP uuid was already written with maximum portability in mind, so
there should be no great effort required to get it running on any Unix
platform with a reasonable POSIX API. Additionally, the portability
was tested by successfully building and running it on the following
particular Unix platforms (syntax is "<cpu>-<os> (<compiler>)"):
alpha-tru644.0 (cc)
alpha-tru645.1 (gcc, cc)
hppa-hpux11.11 (cc)
ia64-hpux11.23 (cc)
ix86-debian2.2 (gcc, icc)
ix86-debian3.0 (gcc)
ix86-debian3.1 (gcc)
ix86-freebsd4.9 (gcc)
ix86-freebsd5.2 (gcc, icc)
ix86-netbsd1.6 (gcc)
ix86-qnx6.2 (gcc)
ix86-solaris10 (gcc)
ix86-unixware7.1.3 (cc)
mips64-irix6.5 (gcc)
sparc64-solaris8 (gcc, forte)
sparc64-solaris9 (gcc)

View File

@ -1,62 +0,0 @@
_ ___ ____ ____ ____ _ _
|_|_ _ / _ \/ ___/ ___|| _ \ _ _ _ _(_) __| |
_|_||_| | | | \___ \___ \| |_) | | | | | | | | |/ _` |
|_||_|_| | |_| |___) |__) | __/ | |_| | |_| | | (_| |
|_|_|_| \___/|____/____/|_| \__,_|\__,_|_|\__,_|
OSSP uuid - Universally Unique Identifier
Version 1.6.2 (04-Jul-2008)
ABSTRACT
OSSP uuid is a ISO-C:1999 application programming interface (API)
and corresponding command line interface (CLI) for the generation of
DCE 1.1, ISO/IEC 11578:1996 and IETF RFC-4122 compliant Universally
Unique Identifier (UUID). It supports DCE 1.1 variant UUIDs of version
1 (time and node based), version 3 (name based, MD5), version 4
(random number based) and version 5 (name based, SHA-1). Additional
API bindings are provided for the languages ISO-C++:1998, Perl:5 and
PHP:4/5. Optional backward compatibility exists for the ISO-C DCE-1.1
and Perl Data::UUID APIs.
UUIDs are 128 bit numbers which are intended to have a high likelihood
of uniqueness over space and time and are computationally difficult
to guess. They are globally unique identifiers which can be locally
generated without contacting a global registration authority. UUIDs
are intended as unique identifiers for both mass tagging objects
with an extremely short lifetime and to reliably identifying very
persistent objects across a network.
COPYRIGHT AND LICENSE
Copyright (c) 2004-2008 Ralf S. Engelschall <rse@engelschall.com>
Copyright (c) 2004-2008 The OSSP Project <http://www.ossp.org/>
This file is part of OSSP uuid, a library for the generation
of UUIDs which can found at http://www.ossp.org/pkg/lib/uuid/
Permission to use, copy, modify, and distribute this software for
any purpose with or without fee is hereby granted, provided that
the above copyright notice and this permission notice appear in all
copies.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
CONTRIBUTORS 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 ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
HOME AND DOCUMENTATION
The documentation and latest release can be found on
o http://www.ossp.org/pkg/lib/uuid/
o ftp://ftp.ossp.org/pkg/lib/uuid/

View File

@ -1,52 +0,0 @@
_ ___ ____ ____ ____ _ _
|_|_ _ / _ \/ ___/ ___|| _ \ _ _ _ _(_) __| |
_|_||_| | | | \___ \___ \| |_) | | | | | | | | |/ _` |
|_||_|_| | |_| |___) |__) | __/ | |_| | |_| | | (_| |
|_|_|_| \___/|____/____/|_| \__,_|\__,_|_|\__,_|
OSSP uuid - Universally Unique Identifier
SEE ALSO
Although we consider OSSP uuid the ultimate reference implementation
of an UUID generator, there are multiple alternatives available.
Following is a short reference of all currently known UUID
implementations for platforms with an Unix/POSIX API:
o OSSP uuid (ISO-C), OSSP::uuid (Perl)
http://www.ossp.org/pkg/lib/uuid/
http://cvs.ossp.org/ossp-pkg/uuid/
o FreeBSD libc (ISO-C)
http://www.freebsd.org/
http://www.freebsd.org/cgi/cvsweb.cgi/src/lib/libc/uuid/
o Sun Solaris libc (ISO-C), DCE::UUID (Perl/XS)
http://www.opensolaris.org/
http://cvs.opensolaris.org/source/xref/usr/src/lib/libuuid/
o APR libaprutil (ISO-C), APR::UUID (Perl/XS)
http://svn.apache.org/repos/asf/apr/apr-util/trunk/crypto/
o e2fsprogs/libuuid (ISO-C), UUID (Perl/XS)
http://e2fsprogs.sourceforge.net/
http://thunk.org/hg/e2fsprogs/
o Wine rpcrt4 DLL (ISO-C)
http://www.winehq.org/
o Data::UUID (Perl/XS)
http://search.cpan.org/src/AGOLOMSH/
http://www.cpan.org/modules/by-module/Data/
o JUG (Java/JNI)
http://www.doomdark.org/doomdark/proj/jug/
o Mozilla (ISO-C, ISO-C++)
http://www.mozilla.org/
http://lxr.mozilla.org/mozilla1.7/source/calendar/libxpical/token.c
o HelixPlayer (ISO-C, ISO-C++)
https://player.helixcommunity.org/
common/util/chxuuid.cpp

View File

@ -1,29 +0,0 @@
_ ___ ____ ____ ____ _ _
|_|_ _ / _ \/ ___/ ___|| _ \ _ _ _ _(_) __| |
_|_||_| | | | \___ \___ \| |_) | | | | | | | | |/ _` |
|_||_|_| | |_| |___) |__) | __/ | |_| | |_| | | (_| |
|_|_|_| \___/|____/____/|_| \__,_|\__,_|_|\__,_|
OSSP uuid - Universally Unique Identifier
THANKS
Credit has to be given to the following people who contributed ideas,
bugfixes, hints, gave platform feedback, etc. (in alphabetical order):
o Matthias Andree <matthias.andree@gmx.de>
o Neil Caunt <retardis@gmail.com>
o Neil Conway <neilc@samurai.com>
o M. Daniel <mdaniel@scdi.com>
o Simon "janus" Dassow <janus@errornet.de>
o Fuyuki <fuyuki@nigredo.org>
o Thomas Lotterer <thomas@lotterer.net>
o Roman Neuhauser <neuhauser@sigpipe.cz>
o Hrvoje Niksic <hniksic@xemacs.org>
o Piotr Roszatycki <dexter@debian.org>
o Hiroshi Saito <z-saito@guitar.ocn.ne.jp>
o Michael Schloh <michael@schloh.com>
o Guerry Semones <guerry@tsunamiresearch.com>
o David Wheeler <david@justatheory.com>
o Wu Yongwei <wuyongwei@gmail.com>

View File

@ -1,23 +0,0 @@
_ ___ ____ ____ ____ _ _
|_|_ _ / _ \/ ___/ ___|| _ \ _ _ _ _(_) __| |
_|_||_| | | | \___ \___ \| |_) | | | | | | | | |/ _` |
|_||_|_| | |_| |___) |__) | __/ | |_| | |_| | | (_| |
|_|_|_| \___/|____/____/|_| \__,_|\__,_|_|\__,_|
OSSP uuid - Universally Unique Identifier
TODO
====
- <none>
CANDO
=====
- allow to re-create version 1 UUIDs by specifying time, etc.
- getopt_long support for CLI?
- a more sophisticated test suite with UUID references?!
- more platform support in uuid_mac.c?!
- global memory locking according to standard hints??
- persistent/non-volatile state writing according to standard hints??

View File

@ -1,49 +0,0 @@
_ ___ ____ ____ ____ _ _
|_|_ _ / _ \/ ___/ ___|| _ \ _ _ _ _(_) __| |
_|_||_| | | | \___ \___ \| |_) | | | | | | | | |/ _` |
|_||_|_| | |_| |___) |__) | __/ | |_| | |_| | | (_| |
|_|_|_| \___/|____/____/|_| \__,_|\__,_|_|\__,_|
OSSP uuid - Universally Unique Identifier
USERS
OSSP uuid is known to be used by at least the following
Open Source software packages:
o PostgreSQL
Relational Database Management System (RDBMS)
http://www.postgresql.org/
o Aegis
Software Configuration Management (SCM) System
http://aegis.sourceforge.net/
o Heartbeat
Core component of the High-Availability Linux (Linux-HA) project
http://linux-ha.org/heartbeat/
o GAT
Grid Application Toolkit (GAT)
https://www.gridlab.org/WorkPackages/wp-1/
o Menes
High-Level C++ Library for mutexes, networking, etc.
http://www.saurik.com/
http://svn.saurik.com/repos/menes/trunk/
o OpenAether OAPR
C++ wrapper for NSPR
http://www.openaether.org/oapr.html
o Gauche Scheme Interpreter, UUID extension
http://cvs.sourceforge.jp/cgi-bin/viewcvs.cgi/gauche/Gauche-uuid/
http://www.shiro.dreamhost.com/scheme/gauche/
o Guile Extension Examples (GEE)
https://gna.org/projects/gee
o CGI::Session::ID::uuid
UUID based ID generator backend for CGI::Session
http://www.cpan.org/modules/by-authors/id/RSE/

View File

@ -1,352 +0,0 @@
dnl ##
dnl ## SA - OSSP Socket Abstraction Library
dnl ## Copyright (c) 2001-2003 Ralf S. Engelschall <rse@engelschall.com>
dnl ## Copyright (c) 2001-2003 The OSSP Project <http://www.ossp.org/>
dnl ## Copyright (c) 2001-2003 Cable & Wireless Deutschland <http://www.cw.com/de/>
dnl ##
dnl ## This file is part of OSSP SA, a socket abstraction library which
dnl ## can be found at http://www.ossp.org/pkg/sa/.
dnl ##
dnl ## Permission to use, copy, modify, and distribute this software for
dnl ## any purpose with or without fee is hereby granted, provided that
dnl ## the above copyright notice and this permission notice appear in all
dnl ## copies.
dnl ##
dnl ## THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
dnl ## WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
dnl ## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
dnl ## IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
dnl ## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
dnl ## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
dnl ## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
dnl ## USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
dnl ## ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
dnl ## OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
dnl ## OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
dnl ## SUCH DAMAGE.
dnl ##
dnl ## aclocal.m4: GNU Autoconf local macro definitions
dnl ##
dnl ##
dnl ## Check whether compiler option works
dnl ##
dnl ## configure.in:
dnl ## AC_COMPILER_OPTION(<name>, <display>, <option>,
dnl ## <action-success>, <action-failure>)
dnl ##
AC_DEFUN([AC_COMPILER_OPTION],[dnl
AC_MSG_CHECKING(whether compiler option(s) $2 work)
AC_CACHE_VAL(ac_cv_compiler_option_$1,[
SAVE_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS $3"
AC_TRY_COMPILE([],[], ac_cv_compiler_option_$1=yes, ac_cv_compiler_option_$1=no)
CFLAGS="$SAVE_CFLAGS"
])dnl
if test ".$ac_cv_compiler_option_$1" = .yes; then
ifelse([$4], , :, [$4])
else
ifelse([$5], , :, [$5])
fi
AC_MSG_RESULT([$ac_cv_compiler_option_$1])
])dnl
dnl ##
dnl ## Debugging Support
dnl ##
dnl ## configure.in:
dnl ## AC_CHECK_DEBUGGING
dnl ##
AC_DEFUN([AC_CHECK_DEBUGGING],[dnl
AC_ARG_ENABLE(debug,dnl
[ --enable-debug build for debugging (default=no)],
[dnl
if test ".$ac_cv_prog_gcc" = ".yes"; then
case "$CFLAGS" in
*-O* ) ;;
* ) CFLAGS="$CFLAGS -O2" ;;
esac
case "$CFLAGS" in
*-g* ) ;;
* ) CFLAGS="$CFLAGS -g" ;;
esac
case "$CFLAGS" in
*-pipe* ) ;;
* ) AC_COMPILER_OPTION(pipe, -pipe, -pipe, CFLAGS="$CFLAGS -pipe") ;;
esac
AC_COMPILER_OPTION(defdbg, -DDEBUG, -DDEBUG, CFLAGS="$CFLAGS -DDEBUG")
CFLAGS="$CFLAGS -pedantic"
CFLAGS="$CFLAGS -Wall"
WMORE="-Wshadow -Wpointer-arith -Wcast-align -Winline"
WMORE="$WMORE -Wmissing-prototypes -Wmissing-declarations -Wnested-externs"
AC_COMPILER_OPTION(wmore, -W<xxx>, $WMORE, CFLAGS="$CFLAGS $WMORE")
AC_COMPILER_OPTION(wnolonglong, -Wno-long-long, -Wno-long-long, CFLAGS="$CFLAGS -Wno-long-long")
else
case "$CFLAGS" in
*-g* ) ;;
* ) CFLAGS="$CFLAGS -g" ;;
esac
fi
msg="enabled"
],[
if test ".$ac_cv_prog_gcc" = ".yes"; then
case "$CFLAGS" in
*-pipe* ) ;;
* ) AC_COMPILER_OPTION(pipe, -pipe, -pipe, CFLAGS="$CFLAGS -pipe") ;;
esac
fi
case "$CFLAGS" in
*-g* ) CFLAGS=`echo "$CFLAGS" |\
sed -e 's/ -g / /g' -e 's/ -g$//' -e 's/^-g //g' -e 's/^-g$//'` ;;
esac
case "$CXXFLAGS" in
*-g* ) CXXFLAGS=`echo "$CXXFLAGS" |\
sed -e 's/ -g / /g' -e 's/ -g$//' -e 's/^-g //g' -e 's/^-g$//'` ;;
esac
msg=disabled
])dnl
AC_MSG_CHECKING(for compilation debug mode)
AC_MSG_RESULT([$msg])
if test ".$msg" = .enabled; then
enable_shared=no
fi
])
dnl ##
dnl ## Check for C99 va_copy() implementation
dnl ## (and provide fallback implementation if neccessary)
dnl ##
dnl ## configure.in:
dnl ## AC_CHECK_VA_COPY
dnl ## foo.c:
dnl ## #include "config.h"
dnl ## [...]
dnl ## va_copy(d,s)
dnl ##
dnl ## This check is rather complex: first because we really have to
dnl ## try various possible implementations in sequence and second, we
dnl ## cannot define a macro in config.h with parameters directly.
dnl ##
dnl # test program for va_copy() implementation
changequote(<<,>>)
m4_define(__va_copy_test, <<[
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#define DO_VA_COPY(d, s) $1
void test(char *str, ...)
{
va_list ap, ap2;
int i;
va_start(ap, str);
DO_VA_COPY(ap2, ap);
for (i = 1; i <= 9; i++) {
int k = (int)va_arg(ap, int);
if (k != i)
abort();
}
DO_VA_COPY(ap, ap2);
for (i = 1; i <= 9; i++) {
int k = (int)va_arg(ap, int);
if (k != i)
abort();
}
va_end(ap);
}
int main(int argc, char *argv[])
{
test("test", 1, 2, 3, 4, 5, 6, 7, 8, 9);
exit(0);
}
]>>)
changequote([,])
dnl # test driver for va_copy() implementation
m4_define(__va_copy_check, [
AH_VERBATIM($1,
[/* Predefined possible va_copy() implementation (id: $1) */
#define __VA_COPY_USE_$1(d, s) $2])
if test ".$ac_cv_va_copy" = .; then
AC_TRY_RUN(__va_copy_test($2), [ac_cv_va_copy="$1"])
fi
])
dnl # Autoconf check for va_copy() implementation checking
AC_DEFUN([AC_CHECK_VA_COPY],[
dnl # provide Autoconf display check message
AC_MSG_CHECKING(for va_copy() function)
dnl # check for various implementations in priorized sequence
AC_CACHE_VAL(ac_cv_va_copy, [
ac_cv_va_copy=""
dnl # 1. check for standardized C99 macro
__va_copy_check(C99, [va_copy((d), (s))])
dnl # 2. check for alternative/deprecated GCC macro
__va_copy_check(GCM, [VA_COPY((d), (s))])
dnl # 3. check for internal GCC macro (high-level define)
__va_copy_check(GCH, [__va_copy((d), (s))])
dnl # 4. check for internal GCC macro (built-in function)
__va_copy_check(GCB, [__builtin_va_copy((d), (s))])
dnl # 5. check for assignment approach (assuming va_list is a struct)
__va_copy_check(ASS, [do { (d) = (s); } while (0)])
dnl # 6. check for assignment approach (assuming va_list is a pointer)
__va_copy_check(ASP, [do { *(d) = *(s); } while (0)])
dnl # 7. check for memory copying approach (assuming va_list is a struct)
__va_copy_check(CPS, [memcpy((void *)&(d), (void *)&(s), sizeof((s)))])
dnl # 8. check for memory copying approach (assuming va_list is a pointer)
__va_copy_check(CPP, [memcpy((void *)(d), (void *)(s), sizeof(*(s)))])
if test ".$ac_cv_va_copy" = .; then
AC_ERROR([no working implementation found])
fi
])
dnl # optionally activate the fallback implementation
if test ".$ac_cv_va_copy" = ".C99"; then
AC_DEFINE(HAVE_VA_COPY, 1, [Define if va_copy() macro exists (and no fallback implementation is required)])
fi
dnl # declare which fallback implementation to actually use
AC_DEFINE_UNQUOTED([__VA_COPY_USE], [__VA_COPY_USE_$ac_cv_va_copy],
[Define to id of used va_copy() implementation])
dnl # provide activation hook for fallback implementation
AH_VERBATIM([__VA_COPY_ACTIVATION],
[/* Optional va_copy() implementation activation */
#ifndef HAVE_VA_COPY
#define va_copy(d, s) __VA_COPY_USE(d, s)
#endif
])
dnl # provide Autoconf display result message
if test ".$ac_cv_va_copy" = ".C99"; then
AC_MSG_RESULT([yes])
else
AC_MSG_RESULT([no (using fallback implementation)])
fi
])
dnl ##
dnl ## Check for an external/extension library.
dnl ## - is aware of <libname>-config style scripts
dnl ## - searches under standard paths include, lib, etc.
dnl ## - searches under subareas like .libs, etc.
dnl ##
dnl ## configure.in:
dnl ## AC_CHECK_EXTLIB(<realname>, <libname>, <func>, <header>,
dnl ## [<success-action> [, <fail-action>]])
dnl ## Makefile.in:
dnl ## CFLAGS = @CFLAGS@
dnl ## LDFLAGS = @LDFLAGS@
dnl ## LIBS = @LIBS@
dnl ## shell:
dnl ## $ ./configure --with-<libname>[=DIR]
dnl ##
AC_DEFUN([AC_CHECK_EXTLIB],[dnl
AC_ARG_WITH($2, [dnl
[ --with-]m4_substr([$2[[=DIR]] ], 0, 19)[build with external $1 library (default=no)]], [dnl
if test ".$with_$2" = .yes; then
# via config script in PATH
$2_version=`($2-config --version) 2>/dev/null`
if test ".$$2_version" != .; then
CPPFLAGS="$CPPFLAGS `$2-config --cflags`"
CFLAGS="$CFLAGS `$2-config --cflags`"
LDFLAGS="$LDFLAGS `$2-config --ldflags`"
fi
else
if test -d "$with_$2"; then
found=0
# via config script
for dir in $with_$2/bin $with_$2; do
if test -f "$dir/$2-config" && test ! -f "$dir/$2-config.in"; then
$2_version=`($dir/$2-config --version) 2>/dev/null`
if test ".$$2_version" != .; then
CPPFLAGS="$CPPFLAGS `$dir/$2-config --cflags`"
CFLAGS="$CFLAGS `$dir/$2-config --cflags`"
LDFLAGS="$LDFLAGS `$dir/$2-config --ldflags`"
found=1
break
fi
fi
done
# in standard sub-areas
if test ".$found" = .0; then
for dir in $with_$2/include/$2 $with_$2/include $with_$2; do
if test -f "$dir/$4"; then
CPPFLAGS="$CPPFLAGS -I$dir"
CFLAGS="$CFLAGS -I$dir"
found=1
break
fi
done
for dir in $with_$2/lib/$2 $with_$2/lib $with_$2; do
if test -f "$dir/lib$2.la" && test -d "$dir/.libs"; then
LDFLAGS="$LDFLAGS -L$dir -L$dir/.libs"
found=1
break
elif test -f "$dir/lib$2.a" || test -f "$dir/lib$2.so"; then
LDFLAGS="$LDFLAGS -L$dir"
found=1
break
fi
done
fi
# in any sub-area
if test ".$found" = .0; then
changequote(, )dnl
for file in x `find $with_$2 -name "$4" -type f -print`; do
test .$file = .x && continue
dir=`echo $file | sed -e 's;[^/]*$;;' -e 's;\(.\)/$;\1;'`
CPPFLAGS="$CPPFLAGS -I$dir"
CFLAGS="$CFLAGS -I$dir"
done
for file in x `find $with_$2 -name "lib$2.[aso]" -type f -print`; do
test .$file = .x && continue
dir=`echo $file | sed -e 's;[^/]*$;;' -e 's;\(.\)/$;\1;'`
LDFLAGS="$LDFLAGS -L$dir"
done
changequote([, ])dnl
fi
fi
fi
AC_HAVE_HEADERS($4)
AC_CHECK_LIB($2, $3)
with_$2=yes
ac_var="ac_cv_header_`echo $4 | sed 'y%./+-%__p_%'`"
eval "ac_val=\$$ac_var"
if test ".$ac_val" != .yes; then
with_$2=no
fi
if test ".$ac_cv_lib_$2_$3" != .yes; then
with_$2=no
fi
if test ".$with_$2" = .no; then
AC_ERROR([Unable to find $1 library])
fi
], [dnl
if test ".$with_$2" = .; then
with_$2=no
fi
])dnl
AC_MSG_CHECKING(whether to build against external $1 library)
if test ".$with_$2" = .yes; then
ifelse([$5], , :, [$5])
else
ifelse([$6], , :, [$6])
fi
AC_MSG_RESULT([$with_$2])
])dnl
dnl ##
dnl ## Check whether to activate Dmalloc
dnl ##
dnl ## configure.in:
dnl ## AC_CHECK_DMALLOC
dnl ##
AC_DEFUN([AC_CHECK_DMALLOC],[dnl
AC_CHECK_EXTLIB(Dmalloc, dmalloc, dmalloc_debug, dmalloc.h,
AC_DEFINE(WITH_DMALLOC, 1, [define if building with Dmalloc]))
if test ".$with_dmalloc" = .yes; then
CFLAGS=`echo "X$CFLAGS" | sed -e 's;^X;;' -e 's; -Wredundant-decls;;'`
fi
])dnl

View File

@ -1,57 +0,0 @@
dnl ##
dnl ## OSSP uuid - Universally Unique Identifier
dnl ## Copyright (c) 2004-2008 Ralf S. Engelschall <rse@engelschall.com>
dnl ## Copyright (c) 2004-2008 The OSSP Project <http://www.ossp.org/>
dnl ##
dnl ## This file is part of OSSP uuid, a library for the generation
dnl ## of UUIDs which can found at http://www.ossp.org/pkg/lib/uuid/
dnl ##
dnl ## Permission to use, copy, modify, and distribute this software for
dnl ## any purpose with or without fee is hereby granted, provided that
dnl ## the above copyright notice and this permission notice appear in all
dnl ## copies.
dnl ##
dnl ## THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
dnl ## WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
dnl ## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
dnl ## IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
dnl ## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
dnl ## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
dnl ## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
dnl ## USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
dnl ## ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
dnl ## OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
dnl ## OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
dnl ## SUCH DAMAGE.
dnl ##
dnl ## configure.ac: GNU Autoconf source script
dnl ##
AC_PREREQ(2.53)
AC_INIT
UUID_VERSION_RAW=`$ac_confdir/shtool version -l c -d short uuid_vers.h`
UUID_VERSION_STR=`$ac_confdir/shtool version -l c -d long uuid_vers.h`
UUID_VERSION_HEX=`$ac_confdir/shtool version -l c -d hex uuid_vers.h`
$ac_confdir/shtool echo -e \
"Configuring %BOSSP uuid%b (Universally Unique Identifier), version %B${UUID_VERSION_STR}%b"
AC_SUBST(UUID_VERSION_RAW)
AC_SUBST(UUID_VERSION_STR)
AC_SUBST(UUID_VERSION_HEX)
AC_PROG_MAKE_SET
AC_PROG_CC
AC_CHECK_DEBUGGING
AC_CHECK_DMALLOC
with_tags=""
sinclude(libtool.m4)
AC_PROG_LIBTOOL
sinclude(uuid.ac)
UUID_CHECK_ALL
AC_CONFIG_HEADERS(config.h)
AC_CONFIG_FILES([Makefile uuid-config uuid.pc uuid.h])
AC_CONFIG_COMMANDS([adjustment], [chmod a-w uuid.h; chmod a+x uuid-config])
AC_OUTPUT

View File

@ -1,4 +0,0 @@
#! /bin/sh
srcpath=$(dirname $0 2>/dev/null ) || srcpath="."
$srcpath/configure "$@" --disable-shared --with-pic

View File

@ -1,10 +0,0 @@
MANIFEST
Makefile.PL
uuid.xs
uuid.tm
uuid.pm
uuid.pod
uuid.ts
uuid_compat.pm
uuid_compat.pod
uuid_compat.ts

View File

@ -1,68 +0,0 @@
##
## OSSP uuid - Universally Unique Identifier
## Copyright (c) 2004-2007 Ralf S. Engelschall <rse@engelschall.com>
## Copyright (c) 2004-2007 The OSSP Project <http://www.ossp.org/>
##
## This file is part of OSSP uuid, a library for the generation
## of UUIDs which can found at http://www.ossp.org/pkg/lib/uuid/
##
## Permission to use, copy, modify, and distribute this software for
## any purpose with or without fee is hereby granted, provided that
## the above copyright notice and this permission notice appear in all
## copies.
##
## THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
## WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
## IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
## CONTRIBUTORS 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 ADVISED OF THE POSSIBILITY OF
## SUCH DAMAGE.
##
## Makefile.PL: Perl MakeMaker build source procedure
##
require 5.008;
use Config;
use ExtUtils::MakeMaker;
# determine source directory
my ($srcdir) = map { my $d = $_; $d =~ s/\/libuuid\.la$//; $d }
grep { -f $_ } ("../libuuid.la", glob("../*/libuuid.la"))
or die "no source directory found (where libuuid.la is located)";
# determine extra build options
my $compat = 0;
@ARGV = grep { $_ =~ m/^COMPAT=(\d+)$/i ? ($compat = $1, 0) : 1 } @ARGV;
# generate Makefile
WriteMakefile(
NAME => 'OSSP::uuid',
VERSION_FROM => 'uuid.pm',
ABSTRACT_FROM => 'uuid.pod',
PREREQ_PM => {},
LIBS => [ "-L$srcdir/.libs -L$srcdir -luuid" ],
DEFINE => '',
INC => "-I. -I$srcdir",
PM => { 'uuid.pm' => '$(INST_LIBDIR)/uuid.pm',
'uuid.pod' => '$(INST_LIBDIR)/uuid.pod',
($compat ? ('uuid_compat.pm' => '$(INST_LIBDIR)/../Data/UUID.pm') : ()),
($compat ? ('uuid_compat.pod' => '$(INST_LIBDIR)/../Data/UUID.pod') : ()), },
MAN3PODS => { 'uuid.pod' => '$(INST_MAN3DIR)/OSSP::uuid.3',
($compat ? ('uuid_compat.pod' => '$(INST_MAN3DIR)/Data::UUID.3') : ()), },
TYPEMAPS => [ 'uuid.tm' ],
test => { TESTS => 'uuid.ts' . ($compat ? ' uuid_compat.ts' : '') },
NO_META => 1,
# cruel hack to workaround the conflict between OSSP uuid's
# uuid_create() function and one from FreeBSD's libc
(( "$Config{'osname'}$Config{'osvers'}" =~ m/^freebsd[56]\./
and $Config{'ld'} =~ m/cc$/ and -f "/usr/include/uuid.h") ?
( LDDLFLAGS => $Config{'lddlflags'} . ' -Wl,-Bsymbolic') : ())
);

View File

@ -1,334 +0,0 @@
##
## OSSP uuid - Universally Unique Identifier
## Copyright (c) 2004-2007 Ralf S. Engelschall <rse@engelschall.com>
## Copyright (c) 2004-2007 The OSSP Project <http://www.ossp.org/>
##
## This file is part of OSSP uuid, a library for the generation
## of UUIDs which can found at http://www.ossp.org/pkg/lib/uuid/
##
## Permission to use, copy, modify, and distribute this software for
## any purpose with or without fee is hereby granted, provided that
## the above copyright notice and this permission notice appear in all
## copies.
##
## THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
## WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
## IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
## CONTRIBUTORS 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 ADVISED OF THE POSSIBILITY OF
## SUCH DAMAGE.
##
## uuid.pm: Perl Binding (Perl part)
##
##
## High-Level Perl Module TIE-style API
## (just a functionality-reduced TIE wrapper around the OO-style API)
##
package OSSP::uuid::tie;
use 5.008;
use strict;
use warnings;
use Carp;
# inhert from Tie::Scalar
require Tie::Scalar;
our @ISA = qw(Tie::Scalar);
# helper function
sub mode_sanity {
my ($mode) = @_;
if (not ( defined($mode)
and ref($mode) eq 'ARRAY'
and ( (@{$mode} == 1 and $mode->[0] =~ m|^v[14]$|)
or (@{$mode} == 3 and $mode->[0] =~ m|^v[35]$|)))) {
return (undef, "invalid UUID generation mode specification");
}
if ($mode->[0] =~ m|^v[35]$|) {
my $uuid_ns = new OSSP::uuid;
$uuid_ns->load($mode->[1])
or return (undef, "failed to load UUID $mode->[0] namespace");
$mode->[1] = $uuid_ns;
}
return ($mode, undef);
}
# constructor
sub TIESCALAR {
my ($class, @args) = @_;
my $self = {};
bless ($self, $class);
$self->{-uuid} = new OSSP::uuid
or croak "failed to create OSSP::uuid object";
my ($mode, $error) = mode_sanity(defined($args[0]) ? [ @args ] : [ "v1" ]);
croak $error if defined($error);
$self->{-mode} = $mode;
return $self;
}
# destructor
sub DESTROY {
my ($self) = @_;
delete $self->{-uuid};
delete $self->{-mode};
return;
}
# fetch value from scalar
# (applied semantic: export UUID in string format)
sub FETCH {
my ($self) = @_;
$self->{-uuid}->make(@{$self->{-mode}})
or croak "failed to generate new UUID";
my $value = $self->{-uuid}->export("str")
or croak "failed to export new UUID";
return $value;
}
# store value into scalar
# (applied semantic: configure new UUID generation mode)
sub STORE {
my ($self, $value) = @_;
my ($mode, $error) = mode_sanity($value);
croak $error if defined($error);
$self->{-mode} = $mode;
return;
}
##
## High-Level Perl Module OO-style API
## (just an OO wrapper around the C-style API)
##
package OSSP::uuid;
use 5.008;
use strict;
use warnings;
use Carp;
use XSLoader;
use Exporter;
# API version
our $VERSION = do { my @v = ('1.6.2' =~ m/\d+/g); sprintf("%d.".("%02d"x$#v), @v); };
# API inheritance
our @ISA = qw(Exporter);
# API symbols
my $symbols = {
'const' => [qw(
UUID_VERSION
UUID_LEN_BIN
UUID_LEN_STR
UUID_LEN_SIV
UUID_RC_OK
UUID_RC_ARG
UUID_RC_MEM
UUID_RC_SYS
UUID_RC_INT
UUID_RC_IMP
UUID_MAKE_V1
UUID_MAKE_V3
UUID_MAKE_V4
UUID_MAKE_V5
UUID_MAKE_MC
UUID_FMT_BIN
UUID_FMT_STR
UUID_FMT_SIV
UUID_FMT_TXT
)],
'func' => [qw(
uuid_create
uuid_destroy
uuid_load
uuid_make
uuid_isnil
uuid_compare
uuid_import
uuid_export
uuid_error
uuid_version
)]
};
# API symbol exportation
our %EXPORT_TAGS = (
'all' => [ @{$symbols->{'const'}}, @{$symbols->{'func'}} ],
'const' => [ @{$symbols->{'const'}} ],
'func' => [ @{$symbols->{'func'}} ]
);
our @EXPORT_OK = @{$EXPORT_TAGS{'all'}};
our @EXPORT = ();
# constructor
sub new {
my $proto = shift;
my $class = ref($proto) || $proto;
my $self = {};
bless ($self, $class);
$self->{-uuid} = undef;
$self->{-rc} = $self->UUID_RC_OK;
my $rc = uuid_create($self->{-uuid});
if ($rc != $self->UUID_RC_OK) {
croak(sprintf("OSSP::uuid::new: uuid_create: %s (%d)", uuid_error($rc), $rc));
return undef;
}
return $self;
}
# destructor
sub DESTROY ($) {
my ($self) = @_;
$self->{-rc} = uuid_destroy($self->{-uuid}) if (defined($self->{-uuid}));
if ($self->{-rc} != $self->UUID_RC_OK) {
carp(sprintf("OSSP::uuid::DESTROY: uuid_destroy: %s (%d)", uuid_error($self->{-rc}), $self->{-rc}));
return;
}
$self->{-uuid} = undef;
$self->{-rc} = undef;
return;
}
sub load ($$) {
my ($self, $name) = @_;
$self->{-rc} = uuid_load($self->{-uuid}, $name);
return ($self->{-rc} == $self->UUID_RC_OK);
}
sub make ($$;@) {
my ($self, $mode, @valist) = @_;
my $mode_code = 0;
foreach my $spec (split(/,/, $mode)) {
if ($spec eq 'v1') { $mode_code |= $self->UUID_MAKE_V1; }
elsif ($spec eq 'v3') { $mode_code |= $self->UUID_MAKE_V3; }
elsif ($spec eq 'v4') { $mode_code |= $self->UUID_MAKE_V4; }
elsif ($spec eq 'v5') { $mode_code |= $self->UUID_MAKE_V5; }
elsif ($spec eq 'mc') { $mode_code |= $self->UUID_MAKE_MC; }
else { croak("invalid mode specification \"$spec\""); }
}
if (($mode_code & $self->UUID_MAKE_V3) or ($mode_code & $self->UUID_MAKE_V5)) {
if (not (ref($valist[0]) and $valist[0]->isa("OSSP::uuid"))) {
croak("UUID_MAKE_V3/UUID_MAKE_V5 requires namespace argument to be OSSP::uuid object");
}
my $ns = $valist[0]->{-uuid};
my $name = $valist[1];
$self->{-rc} = uuid_make($self->{-uuid}, $mode_code, $ns, $name);
}
else {
$self->{-rc} = uuid_make($self->{-uuid}, $mode_code);
}
return ($self->{-rc} == $self->UUID_RC_OK);
}
sub isnil ($) {
my ($self) = @_;
my $result;
$self->{-rc} = uuid_isnil($self->{-uuid}, $result);
return ($self->{-rc} == $self->UUID_RC_OK ? $result : undef);
}
sub compare ($$) {
my ($self, $other) = @_;
my $result = 0;
if (not (ref($other) and $other->isa("OSSP::uuid"))) {
croak("argument has to an OSSP::uuid object");
}
$self->{-rc} = uuid_compare($self->{-uuid}, $other->{-uuid}, $result);
return ($self->{-rc} == $self->UUID_RC_OK ? $result : undef);
}
sub import {
# ATTENTION: The OSSP uuid API function "import" conflicts with
# the standardized "import" method the Perl world expects from
# their modules. In order to keep the Perl binding consist
# with the C API, we solve the conflict under run-time by
# distinguishing between the two types of "import" calls.
if (defined($_[0]) and ref($_[0]) =~ m/^OSSP::uuid/) {
# the regular OSSP::uuid "import" method
croak("import method expects 3 or 4 arguments") if (@_ < 3 or @_ > 4); # emulate prototype
my ($self, $fmt, $data_ptr, $data_len) = @_;
if ($fmt eq 'bin') { $fmt = $self->UUID_FMT_BIN; }
elsif ($fmt eq 'str') { $fmt = $self->UUID_FMT_STR; }
elsif ($fmt eq 'siv') { $fmt = $self->UUID_FMT_SIV; }
elsif ($fmt eq 'txt') { $fmt = $self->UUID_FMT_TXT; }
else { croak("invalid format \"$fmt\""); }
$data_len ||= length($data_ptr); # functional redudant, but Perl dislikes undef value here
$self->{-rc} = uuid_import($self->{-uuid}, $fmt, $data_ptr, $data_len);
return ($self->{-rc} == $self->UUID_RC_OK);
}
else {
# the special Perl "import" method
# (usually inherited from the Exporter)
no strict "refs";
return OSSP::uuid->export_to_level(1, @_);
}
}
sub export {
# ATTENTION: The OSSP uuid API function "export" conflicts with
# the standardized "export" method the Perl world expects from
# their modules. In order to keep the Perl binding consist
# with the C API, we solve the conflict under run-time by
# distinguishing between the two types of "export" calls.
if (defined($_[0]) and ref($_[0]) =~ m/^OSSP::uuid/) {
# the regular OSSP::uuid "export" method
croak("export method expects 2 arguments") if (@_ != 2); # emulate prototype
my ($self, $fmt) = @_;
my $data_ptr;
if ($fmt eq 'bin') { $fmt = $self->UUID_FMT_BIN; }
elsif ($fmt eq 'str') { $fmt = $self->UUID_FMT_STR; }
elsif ($fmt eq 'siv') { $fmt = $self->UUID_FMT_SIV; }
elsif ($fmt eq 'txt') { $fmt = $self->UUID_FMT_TXT; }
else { croak("invalid format \"$fmt\""); }
$self->{-rc} = uuid_export($self->{-uuid}, $fmt, $data_ptr, undef);
return ($self->{-rc} == $self->UUID_RC_OK ? $data_ptr : undef);
}
else {
# the special Perl "export" method
# (usually inherited from the Exporter)
return Exporter::export(@_);
}
}
sub error ($;$) {
my ($self, $rc) = @_;
$rc = $self->{-rc} if (not defined($rc));
return wantarray ? (uuid_error($rc), $rc) : uuid_error($rc);
}
sub version (;$) {
my ($self) = @_;
return uuid_version();
}
##
## Low-Level Perl XS C-style API
## (actually just the activation of the XS part)
##
# auto-loading constants
sub AUTOLOAD {
my $constname;
our $AUTOLOAD;
($constname = $AUTOLOAD) =~ s/.*:://;
croak "&OSSP::uuid::constant not defined" if ($constname eq 'constant');
my ($error, $val) = constant($constname);
croak $error if ($error);
{ no strict 'refs'; *$AUTOLOAD = sub { $val }; }
goto &$AUTOLOAD;
}
# static-loading functions
XSLoader::load('OSSP::uuid', $VERSION);
1;

View File

@ -1,207 +0,0 @@
##
## OSSP uuid - Universally Unique Identifier
## Copyright (c) 2004-2007 Ralf S. Engelschall <rse@engelschall.com>
## Copyright (c) 2004-2007 The OSSP Project <http://www.ossp.org/>
##
## This file is part of OSSP uuid, a library for the generation
## of UUIDs which can found at http://www.ossp.org/pkg/lib/uuid/
##
## Permission to use, copy, modify, and distribute this software for
## any purpose with or without fee is hereby granted, provided that
## the above copyright notice and this permission notice appear in all
## copies.
##
## THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
## WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
## IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
## CONTRIBUTORS 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 ADVISED OF THE POSSIBILITY OF
## SUCH DAMAGE.
##
## uuid.pod: Perl Binding (Perl/POD part)
##
=pod
=head1 NAME
OSSP::uuid - B<OSSP uuid> Perl Binding
=head1 DESCRIPTION
B<OSSP uuid> is a ISO-C:1999 application programming interface (API)
and corresponding command line interface (CLI) for the generation of
DCE 1.1, ISO/IEC 11578:1996 and RFC 4122 compliant I<Universally Unique
Identifier> (UUID). It supports DCE 1.1 variant UUIDs of version 1 (time
and node based), version 3 (name based, MD5), version 4 (random number
based) and version 5 (name based, SHA-1). Additional API bindings are
provided for the languages ISO-C++:1998, Perl:5 and PHP:4/5. Optional
backward compatibility exists for the ISO-C DCE-1.1 and Perl Data::UUID
APIs.
B<OSSP::uuid> is the Perl binding to the B<OSSP uuid> API.
Three variants are provided:
=head2 TIE-STYLE API
The TIE-style API is a functionality-reduced wrapper around the OO-style
API and intended for very high-level convenience programming:
=over 4
=item C<use OSSP::uuid;>
=item B<tie>C< my $uuid, 'OSSP::uuid::tie', $mode, ...;>
=item C<$uuid = [ $mode, ... ];>
=item C<print "UUID=$uuid\n";>
=item C<untie $uuid;>
=back
=head2 OO-STYLE API
The OO-style API is a wrapper around the C-style API and intended for
high-level regular programming.
=over 4
=item C<use OSSP::uuid;>
=item C<my $uuid = >B<new>C< OSSP::uuid;>
=item C<$uuid-E<gt>>B<load>C<($name);>
=item C<$uuid-E<gt>>B<make>C<($mode, ...);>
=item C<$result = $uuid-E<gt>>B<isnil>C<();>
=item C<$result = $uuid-E<gt>>B<compare>C<($uuid2);>
=item C<$uuid-E<gt>>B<import>C<($fmt, $data_ptr);>
=item C<$data_ptr = $uuid-E<gt>>B<export>C<($fmt);>
=item C<[(]$str[, $rc)] = $uuid-E<gt>>B<error>C<();>
=item C<$ver = $uuid-E<gt>>B<version>C<();>
=item C<undef $uuid;>
=back
Additionally, the strings C<"v1">, C<"v3">, C<"v4">, C<"v5"> and C<"mc">
can be used in C<$mode> and the strings C<"bin">, C<"str">, and C<"txt">
can be used for C<$fmt>.
=head2 C-STYLE API
The C-style API is a direct mapping
of the B<OSSP uuid> ISO-C API to Perl and is intended for low-level
programming. See uuid(3) for a description of the functions and
their expected arguments.
=over 4
=item C<use OSSP::uuid qw(:all);>
=item C<my $uuid; $rc = >B<uuid_create>C<($uuid);>
=item C<$rc = >B<uuid_load>C<($uuid, $name);>
=item C<$rc = >B<uuid_make>C<($uuid, $mode, ...);>
=item C<$rc = >B<uuid_isnil>C<($uuid, $result);>
=item C<$rc = >B<uuid_compare>C<($uuid, $uuid2, $result);>
=item C<$rc = >B<uuid_import>C<($uuid, $fmt, $data_ptr, $data_len);>
=item C<$rc = >B<uuid_export>C<($uuid, $fmt, $data_ptr, $data_len);>
=item C<$str = >B<uuid_error>C<($rc);>
=item C<$ver = >B<uuid_version>C<();>
=item C<$rc = >B<uuid_destroy>C<($uuid);>
=back
Additionally, the following constants are exported for use in C<$rc>, C<$mode>, C<$fmt> and C<$ver>:
C<UUID_VERSION>,
C<UUID_LEN_BIN>,
C<UUID_LEN_STR>,
C<UUID_RC_OK>,
C<UUID_RC_ARG>,
C<UUID_RC_MEM>,
C<UUID_RC_SYS>,
C<UUID_RC_INT>,
C<UUID_RC_IMP>,
C<UUID_MAKE_V1>,
C<UUID_MAKE_V3>,
C<UUID_MAKE_V4>,
C<UUID_MAKE_V5>,
C<UUID_MAKE_MC>,
C<UUID_FMT_BIN>,
C<UUID_FMT_STR>,
C<UUID_FMT_SIV>,
C<UUID_FMT_TXT>.
=head1 EXAMPLES
The following two examples create the version 3 UUID
C<02d9e6d5-9467-382e-8f9b-9300a64ac3cd>, both via the OO-style and the
C-style API. Error handling is omitted here for easier reading, but has
to be added for production-quality code.
# TIE-style API (very high-level)
use OSSP::uuid;
tie my $uuid, 'OSSP::uuid::tie';
$uuid = [ "v1" ];
print "UUIDs: $uuid, $uuid, $uuid\n";
$uuid = [ "v3", "ns:URL", "http://www.ossp.org/" ];
print "UUIDs: $uuid, $uuid, $uuid\n";
untie $uuid;
# OO-style API (high-level)
use OSSP::uuid;
my $uuid = new OSSP::uuid;
my $uuid_ns = new OSSP::uuid;
$uuid_ns->load("ns:URL");
$uuid->make("v3", $uuid_ns, "http://www.ossp.org/");
undef $uuid_ns;
my $str = $uuid->export("str");
undef $uuid;
print "$str\n";
# C-style API (low-level)
use OSSP::uuid qw(:all);
my $uuid; uuid_create($uuid);
my $uuid_ns; uuid_create($uuid_ns);
uuid_load($uuid_ns, "ns:URL");
uuid_make($uuid, UUID_MAKE_V3, $uuid_ns, "http://www.ossp.org/");
uuid_destroy($uuid_ns);
my $str; uuid_export($uuid, UUID_FMT_STR, $str, undef);
uuid_destroy($uuid);
print "$str\n";
=head1 SEE ALSO
uuid(1), uuid-config(1), uuid(3).
=head1 HISTORY
The Perl binding B<OSSP::uuid> to B<OSSP uuid> was implemented in
November 2004 by Ralf S. Engelschall E<lt>rse@engelschall.comE<gt>.
=cut

View File

@ -1,39 +0,0 @@
##
## OSSP uuid - Universally Unique Identifier
## Copyright (c) 2004-2007 Ralf S. Engelschall <rse@engelschall.com>
## Copyright (c) 2004-2007 The OSSP Project <http://www.ossp.org/>
##
## This file is part of OSSP uuid, a library for the generation
## of UUIDs which can found at http://www.ossp.org/pkg/lib/uuid/
##
## Permission to use, copy, modify, and distribute this software for
## any purpose with or without fee is hereby granted, provided that
## the above copyright notice and this permission notice appear in all
## copies.
##
## THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
## WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
## IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
## CONTRIBUTORS 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 ADVISED OF THE POSSIBILITY OF
## SUCH DAMAGE.
##
## uuid.tm: Perl XS typemap for xsubpp(1)
##
TYPEMAP
uuid_t * T_PTRREF
uuid_t ** T_PTRREF
uuid_rc_t T_IV
uuid_fmt_t T_IV
int * T_PV
size_t * T_PV
const void * T_PV
void ** T_PV

View File

@ -1,171 +0,0 @@
##
## OSSP uuid - Universally Unique Identifier
## Copyright (c) 2004-2007 Ralf S. Engelschall <rse@engelschall.com>
## Copyright (c) 2004-2007 The OSSP Project <http://www.ossp.org/>
##
## This file is part of OSSP uuid, a library for the generation
## of UUIDs which can found at http://www.ossp.org/pkg/lib/uuid/
##
## Permission to use, copy, modify, and distribute this software for
## any purpose with or without fee is hereby granted, provided that
## the above copyright notice and this permission notice appear in all
## copies.
##
## THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
## WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
## IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
## CONTRIBUTORS 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 ADVISED OF THE POSSIBILITY OF
## SUCH DAMAGE.
##
## uuid.ts: Perl Binding (Perl test suite part)
##
use Test::More tests => 36;
##
## Module Loading
##
BEGIN {
use_ok('OSSP::uuid');
};
BEGIN {
use OSSP::uuid qw(:all);
ok(defined(UUID_VERSION), "UUID_VERSION");
ok(UUID_RC_OK == 0, "UUID_RC_OK");
};
##
## C-Style API
##
my ($rc, $result, $uuid, $uuid_ns, $str, $ptr, $len);
$rc = uuid_create($uuid);
ok($rc == UUID_RC_OK, "uuid_create (1)");
$rc = uuid_create($uuid_ns);
ok($rc == UUID_RC_OK, "uuid_create (2)");
$rc = uuid_isnil($uuid, $result);
ok(($rc == UUID_RC_OK and $result == 1), "uuid_isnil (1)");
$rc = uuid_isnil($uuid_ns, $result);
ok(($rc == UUID_RC_OK and $result == 1), "uuid_isnil (2)");
$rc = uuid_compare($uuid, $uuid_ns, $result);
ok(($rc == UUID_RC_OK and $result == 0), "uuid_compare (1)");
$rc = uuid_export($uuid, UUID_FMT_STR, $ptr, $len);
ok(( $rc == UUID_RC_OK
and $ptr eq "00000000-0000-0000-0000-000000000000"
and $len == UUID_LEN_STR), "uuid_export (1)");
$rc = uuid_load($uuid_ns, "ns:URL");
ok($rc == UUID_RC_OK, "uuid_load (1)");
$rc = uuid_export($uuid_ns, UUID_FMT_STR, $ptr, $len);
ok(( $rc == UUID_RC_OK
and $ptr eq "6ba7b811-9dad-11d1-80b4-00c04fd430c8"
and $len == UUID_LEN_STR), "uuid_export (2)");
$rc = uuid_make($uuid, UUID_MAKE_V3, $uuid_ns, "http://www.ossp.org/");
ok($rc == UUID_RC_OK, "uuid_make (1)");
$rc = uuid_export($uuid, UUID_FMT_STR, $ptr, $len);
ok(( $rc == UUID_RC_OK
and $ptr eq "02d9e6d5-9467-382e-8f9b-9300a64ac3cd"
and $len == UUID_LEN_STR), "uuid_export (3)");
$rc = uuid_export($uuid, UUID_FMT_BIN, $ptr, $len);
ok(( $rc == UUID_RC_OK
and $len == UUID_LEN_BIN), "uuid_export (4)");
$rc = uuid_import($uuid_ns, UUID_FMT_BIN, $ptr, $len);
ok($rc == UUID_RC_OK, "uuid_import (1)");
$rc = uuid_export($uuid_ns, UUID_FMT_STR, $ptr, $len);
ok(( $rc == UUID_RC_OK
and $ptr eq "02d9e6d5-9467-382e-8f9b-9300a64ac3cd"
and $len == UUID_LEN_STR), "uuid_export (5)");
$rc = uuid_export($uuid_ns, UUID_FMT_SIV, $ptr, $len);
ok(( $rc == UUID_RC_OK
and $ptr eq "3789866285607910888100818383505376205"
and $len <= UUID_LEN_SIV), "uuid_export (6)");
$rc = uuid_destroy($uuid_ns);
ok($rc == UUID_RC_OK, "uuid_destroy (1)");
$rc = uuid_destroy($uuid);
ok($rc == UUID_RC_OK, "uuid_destroy (2)");
##
## OO-style API
##
$uuid = new OSSP::uuid;
ok(defined($uuid), "new OSSP::uuid (1)");
$uuid_ns = new OSSP::uuid;
ok(defined($uuid_ns), "new OSSP::uuid (2)");
$rc = $uuid->isnil();
ok((defined($rc) and $rc == 1), "isnil (1)");
$rc = $uuid_ns->isnil();
ok((defined($rc) and $rc == 1), "isnil (2)");
$rc = $uuid->compare($uuid_ns);
ok((defined($rc) and $rc == 0), "compare (1)");
$ptr = $uuid->export("str");
ok(( defined($ptr)
and $ptr eq "00000000-0000-0000-0000-000000000000"
and length($ptr) == UUID_LEN_STR), "export (1)");
$rc = $uuid_ns->load("ns:URL");
ok(defined($rc), "uuid_load (1)");
$ptr = $uuid_ns->export("str");
ok(( defined($ptr)
and $ptr eq "6ba7b811-9dad-11d1-80b4-00c04fd430c8"
and length($ptr) == UUID_LEN_STR), "export (2)");
$rc = $uuid->make("v3", $uuid_ns, "http://www.ossp.org/");
ok(defined($rc), "make (1)");
$ptr = $uuid->export("str");
ok(( defined($ptr)
and $ptr eq "02d9e6d5-9467-382e-8f9b-9300a64ac3cd"
and length($ptr) == UUID_LEN_STR), "export (3)");
$ptr = $uuid->export("bin");
ok(( defined($ptr)
and length($ptr) == UUID_LEN_BIN), "export (4)");
$rc = $uuid_ns->import("bin", $ptr);
ok(defined($rc), "import (1)");
$ptr = $uuid_ns->export("str");
ok(( defined($ptr)
and $ptr eq "02d9e6d5-9467-382e-8f9b-9300a64ac3cd"
and length($ptr) == UUID_LEN_STR), "export (5)");
undef $uuid;
undef $uuid_ns;
##
## TIE API
##
$uuid = new OSSP::uuid;
tie my $var, 'OSSP::uuid::tie';
my $val_get1 = $var;
my $val_get2 = $var;
ok($val_get1 ne $val_get2, "subsequent generation");
$uuid->import("str", $val_get1);
my $val_cmp1 = $uuid->export("str");
$uuid->import("str", $val_get2);
my $val_cmp2 = $uuid->export("str");
ok($val_get1 eq $val_cmp1, "validity comparison 1");
ok($val_get2 eq $val_cmp2, "validity comparison 2");
$var = [ "v3", "ns:URL", "http://www.ossp.org/" ];
$val_get1 = $var;
ok($val_get1 eq "02d9e6d5-9467-382e-8f9b-9300a64ac3cd", "generation of UUID v3");

View File

@ -1,236 +0,0 @@
/*
** OSSP uuid - Universally Unique Identifier
** Copyright (c) 2004-2007 Ralf S. Engelschall <rse@engelschall.com>
** Copyright (c) 2004-2007 The OSSP Project <http://www.ossp.org/>
**
** This file is part of OSSP uuid, a library for the generation
** of UUIDs which can found at http://www.ossp.org/pkg/lib/uuid/
**
** Permission to use, copy, modify, and distribute this software for
** any purpose with or without fee is hereby granted, provided that
** the above copyright notice and this permission notice appear in all
** copies.
**
** THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
** WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
** MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
** IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
** CONTRIBUTORS 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 ADVISED OF THE POSSIBILITY OF
** SUCH DAMAGE.
**
** uuid.xs: Perl Binding (Perl/XS part)
*/
#include "uuid.h"
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
MODULE = OSSP::uuid PACKAGE = OSSP::uuid
void
constant(sv)
PREINIT:
dXSTARG;
STRLEN len;
int i;
static struct {
const char *name;
int value;
} constant_table[] = {
{ "UUID_VERSION", UUID_VERSION },
{ "UUID_LEN_BIN", UUID_LEN_BIN },
{ "UUID_LEN_STR", UUID_LEN_STR },
{ "UUID_LEN_SIV", UUID_LEN_SIV },
{ "UUID_RC_OK", UUID_RC_OK },
{ "UUID_RC_ARG", UUID_RC_ARG },
{ "UUID_RC_MEM", UUID_RC_MEM },
{ "UUID_RC_SYS", UUID_RC_SYS },
{ "UUID_RC_INT", UUID_RC_INT },
{ "UUID_RC_IMP", UUID_RC_IMP },
{ "UUID_MAKE_V1", UUID_MAKE_V1 },
{ "UUID_MAKE_V3", UUID_MAKE_V3 },
{ "UUID_MAKE_V4", UUID_MAKE_V4 },
{ "UUID_MAKE_V5", UUID_MAKE_V5 },
{ "UUID_MAKE_MC", UUID_MAKE_MC },
{ "UUID_FMT_BIN", UUID_FMT_BIN },
{ "UUID_FMT_STR", UUID_FMT_STR },
{ "UUID_FMT_SIV", UUID_FMT_SIV },
{ "UUID_FMT_TXT", UUID_FMT_TXT }
};
INPUT:
SV *sv;
const char *s = SvPV(sv, len);
PPCODE:
for (i = 0; i < sizeof(constant_table)/sizeof(constant_table[0]); i++) {
if (strcmp(s, constant_table[i].name) == 0) {
EXTEND(SP, 1);
PUSHs(&PL_sv_undef);
PUSHi(constant_table[i].value);
break;
}
}
if (i == sizeof(constant_table)/sizeof(constant_table[0])) {
sv = sv_2mortal(newSVpvf("unknown contant OSSP::uuid::%s", s));
PUSHs(sv);
}
uuid_rc_t
uuid_create(uuid)
PROTOTYPE:
$
INPUT:
uuid_t *&uuid = NO_INIT
CODE:
RETVAL = uuid_create(&uuid);
OUTPUT:
uuid
RETVAL
uuid_rc_t
uuid_destroy(uuid)
PROTOTYPE:
$
INPUT:
uuid_t *uuid
CODE:
RETVAL = uuid_destroy(uuid);
OUTPUT:
RETVAL
uuid_rc_t
uuid_load(uuid,name)
PROTOTYPE:
$$
INPUT:
uuid_t *uuid
const char *name
CODE:
RETVAL = uuid_load(uuid, name);
OUTPUT:
RETVAL
uuid_rc_t
uuid_make(uuid,mode,...)
PROTOTYPE:
$$;$$
INPUT:
uuid_t *uuid
unsigned int mode
PREINIT:
uuid_t *ns;
const char *name;
CODE:
if ((mode & UUID_MAKE_V3) || (mode & UUID_MAKE_V5)) {
if (items != 4)
croak("mode UUID_MAKE_V3/UUID_MAKE_V5 requires two additional arguments to uuid_make()");
if (!SvROK(ST(2)))
croak("mode UUID_MAKE_V3/UUID_MAKE_V5 requires a UUID object as namespace");
ns = INT2PTR(uuid_t *, SvIV((SV*)SvRV(ST(2))));
name = (const char *)SvPV_nolen(ST(3));
RETVAL = uuid_make(uuid, mode, ns, name);
}
else {
if (items != 2)
croak("invalid number of arguments to uuid_make()");
RETVAL = uuid_make(uuid, mode);
}
OUTPUT:
RETVAL
uuid_rc_t
uuid_isnil(uuid,result)
PROTOTYPE:
$$
INPUT:
uuid_t *uuid
int &result = NO_INIT
CODE:
RETVAL = uuid_isnil(uuid, &result);
OUTPUT:
result
RETVAL
uuid_rc_t
uuid_compare(uuid,uuid2,result)
PROTOTYPE:
$$$
INPUT:
uuid_t *uuid
uuid_t *uuid2
int &result = NO_INIT
CODE:
RETVAL = uuid_compare(uuid, uuid2, &result);
OUTPUT:
result
RETVAL
uuid_rc_t
uuid_import(uuid,fmt,data_ptr,data_len)
PROTOTYPE:
$$$$
INPUT:
uuid_t *uuid
uuid_fmt_t fmt
const void *data_ptr
size_t data_len
CODE:
if (ST(3) == &PL_sv_undef)
data_len = sv_len(ST(2));
RETVAL = uuid_import(uuid, fmt, data_ptr, data_len);
OUTPUT:
RETVAL
uuid_rc_t
uuid_export(uuid,fmt,data_ptr,data_len)
PROTOTYPE:
$$$$
INPUT:
uuid_t *uuid
uuid_fmt_t fmt
void *&data_ptr = NO_INIT
size_t &data_len = NO_INIT
PPCODE:
data_ptr = NULL;
data_len = 0;
RETVAL = uuid_export(uuid, fmt, &data_ptr, &data_len);
if (RETVAL == UUID_RC_OK) {
if (fmt == UUID_FMT_SIV)
data_len = strlen((char *)data_ptr);
else if (fmt == UUID_FMT_STR || fmt == UUID_FMT_TXT)
data_len--; /* Perl doesn't wish NUL-termination on strings */
sv_setpvn(ST(2), data_ptr, data_len);
free(data_ptr);
if (ST(3) != &PL_sv_undef)
sv_setuv(ST(3), (UV)data_len);
}
PUSHi((IV)RETVAL);
char *
uuid_error(rc)
PROTOTYPE:
$
INPUT:
uuid_rc_t rc
CODE:
RETVAL = uuid_error(rc);
OUTPUT:
RETVAL
unsigned long
uuid_version()
PROTOTYPE:
INPUT:
CODE:
RETVAL = uuid_version();
OUTPUT:
RETVAL

View File

@ -1,176 +0,0 @@
##
## OSSP uuid - Universally Unique Identifier
## Copyright (c) 2004-2007 Ralf S. Engelschall <rse@engelschall.com>
## Copyright (c) 2004-2007 The OSSP Project <http://www.ossp.org/>
## Copyright (c) 2004 Piotr Roszatycki <dexter@debian.org>
##
## This file is part of OSSP uuid, a library for the generation
## of UUIDs which can found at http://www.ossp.org/pkg/lib/uuid/
##
## Permission to use, copy, modify, and distribute this software for
## any purpose with or without fee is hereby granted, provided that
## the above copyright notice and this permission notice appear in all
## copies.
##
## THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
## WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
## IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
## CONTRIBUTORS 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 ADVISED OF THE POSSIBILITY OF
## SUCH DAMAGE.
##
## uuid_compat.pm: Data::UUID Backward Compatibility Perl API
##
package Data::UUID;
use 5.006;
use warnings;
use strict;
use OSSP::uuid;
use MIME::Base64 qw();
require Exporter;
our @ISA = qw(Exporter);
our @EXPORT = qw(NameSpace_DNS NameSpace_OID NameSpace_URL NameSpace_X500);
our $VERSION = do { my @v = ('1.6.2' =~ m/\d+/g); sprintf("%d.".("%02d"x$#v), @v); };
sub new {
my $class = shift;
my $self = bless {}, $class;
return $self;
}
sub create {
my ($self) = @_;
my $uuid = OSSP::uuid->new;
$uuid->make('v4');
return $uuid->export('bin');
}
sub create_from_name {
my ($self, $nsid, $name) = @_;
my $uuid = OSSP::uuid->new;
my $nsiduuid = OSSP::uuid->new;
$nsiduuid->import('bin', $nsiduuid);
$uuid = OSSP::uuid->new;
$uuid->make('v3', $nsiduuid, $name);
return $uuid->export('bin');
}
sub to_string {
my ($self, $bin) = @_;
my $uuid = OSSP::uuid->new;
$uuid->import('bin', $bin);
return $uuid->export('str');
}
sub to_hexstring {
my ($self, $bin) = @_;
my $uuid = OSSP::uuid->new;
$uuid->import('bin', $bin);
(my $string = '0x' . $uuid->export('str')) =~ s/-//g;
return $string;
}
sub to_b64string {
my ($self, $bin) = @_;
return MIME::Base64::encode_base64($bin, '');
}
sub from_string {
my ($self, $str) = @_;
my $uuid = OSSP::uuid->new;
$uuid->import('str',
$str =~ /^0x/
? join '-', unpack('x2 a8 a4 a4 a4 a12', $str)
: $str
);
return $uuid->export('bin');
}
sub from_hexstring {
my ($self, $str) = @_;
my $uuid = OSSP::uuid->new;
$uuid->import('str', join '-', unpack('x2 a8 a4 a4 a4 a12', $str));
return $uuid->export('bin');
}
sub from_b64string {
my ($self, $b64) = @_;
return MIME::Base64::decode_base64($b64);
}
sub compare {
my ($self, $bin1, $bin2) = @_;
my $uuid1 = OSSP::uuid->new;
my $uuid2 = OSSP::uuid->new;
$uuid1->import('bin', $bin1);
$uuid2->import('bin', $bin2);
return $uuid1->compare($uuid2);
}
my %NS = (
'NameSpace_DNS' => 'ns:DNS',
'NameSpace_URL' => 'ns:URL',
'NameSpace_OID' => 'ns:OID',
'NameSpace_X500' => 'ns:X500',
);
while (my ($k, $v) = each %NS) {
no strict 'refs';
*{$k} = sub () {
my $uuid = OSSP::uuid->new;
$uuid->load($v);
return $uuid->export('bin');
};
}
sub constant {
my ($self, $arg) = @_;
my $uuid = OSSP::uuid->new;
$uuid->load($NS{$arg} || 'nil');
return $uuid->export('bin');
}
sub create_str {
my $self = shift;
return $self->to_string($self->create);
}
sub create_hex {
my $self = shift;
return $self->to_hexstring($self->create);
}
sub create_b64 {
my $self = shift;
return $self->to_b64string($self->create);
}
sub create_from_name_str {
my $self = shift;
return $self->to_string($self->create_from_name(@_));
}
sub create_from_name_hex {
my $self = shift;
return $self->to_hexstring($self->create_from_name(@_));
}
sub create_from_name_b64 {
my $self = shift;
return $self->to_b64string($self->create_from_name(@_));
}
1;

View File

@ -1,55 +0,0 @@
##
## OSSP uuid - Universally Unique Identifier
## Copyright (c) 2004-2007 Ralf S. Engelschall <rse@engelschall.com>
## Copyright (c) 2004-2007 The OSSP Project <http://www.ossp.org/>
##
## This file is part of OSSP uuid, a library for the generation
## of UUIDs which can found at http://www.ossp.org/pkg/lib/uuid/
##
## Permission to use, copy, modify, and distribute this software for
## any purpose with or without fee is hereby granted, provided that
## the above copyright notice and this permission notice appear in all
## copies.
##
## THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
## WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
## IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
## CONTRIBUTORS 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 ADVISED OF THE POSSIBILITY OF
## SUCH DAMAGE.
##
## uuid_compat.pod: Data::UUID Backward Compatibility Perl API (Perl/POD part)
##
=pod
=head1 NAME
Data::UUID - B<OSSP uuid> Backward Compatibility Perl Binding
=head1 DESCRIPTION
B<Data::UUID> is the B<OSSP uuid> backward compatibility Perl binding
to the API of the original B<Data::UUID> module. It allows other
B<Data::UUID> based Perl modules to run with B<OSSP::uuid> without
changes.
=head1 SEE ALSO
B<OSSP::uuid>.
=head1 HISTORY
The backward compatibility Perl binding B<Data::UUID> for B<OSSP
uuid> was originally implemented in 2004 by Piotr Roszatycki
E<lt>dexter@debian.orgE<gt>. It was later cleaned up and speed optimized
in December 2005 by David Wheeler E<lt>david@justatheory.comE<gt>.
=cut

View File

@ -1,55 +0,0 @@
##
## OSSP uuid - Universally Unique Identifier
## Copyright (c) 2004-2007 Ralf S. Engelschall <rse@engelschall.com>
## Copyright (c) 2004-2007 The OSSP Project <http://www.ossp.org/>
## Copyright (c) 2004 Piotr Roszatycki <dexter@debian.org>
##
## This file is part of OSSP uuid, a library for the generation
## of UUIDs which can found at http://www.ossp.org/pkg/lib/uuid/
##
## Permission to use, copy, modify, and distribute this software for
## any purpose with or without fee is hereby granted, provided that
## the above copyright notice and this permission notice appear in all
## copies.
##
## THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
## WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
## IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
## CONTRIBUTORS 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 ADVISED OF THE POSSIBILITY OF
## SUCH DAMAGE.
##
## uuid_compat.ts: Data::UUID Backward Compatibility Perl API (Perl test suite part)
##
use Test::More tests => 14;
BEGIN {
use_ok('Data::UUID');
use Data::UUID;
};
ok($ug = new Data::UUID);
ok($uuid1 = $ug->create());
ok($uuid2 = $ug->to_hexstring($uuid1));
ok($uuid3 = $ug->from_string($uuid2));
ok($ug->compare($uuid1, $uuid3) == 0);
ok($uuid4 = $ug->to_b64string($uuid1));
ok($uuid5 = $ug->to_b64string($uuid3));
ok($uuid4 eq $uuid5);
ok($uuid6 = $ug->from_b64string($uuid5));
ok($ug->compare($uuid6, $uuid1) == 0);
ok($uuid7 = NameSpace_URL);
ok($uuid8 = $ug->from_string("6ba7b811-9dad-11d1-80b4-00c04fd430c8"));
ok($ug->compare($uuid7, $uuid8) == 0);

View File

@ -1,57 +0,0 @@
##
## Makefile for PostgreSQL extension module
##
# NOTICE: This requires GNU make as the PostgreSQL PGXS build
# environment is based on GNU make features!
#
# NOTICE: Usually one would just use "PGXS := $(shell pg_config
# --pgxs)" followed by "include $(PGXS)" as the template. The problem
# just is that this way (at least still under PostgreSQL 8.1) one
# cannot pass the "-L../.libs -luuid" to the command which links the
# DSO. Hence we fiddle around with the Makefiles which "PGXS" uses
# itself ourself.
PG_CONFIG ?= pg_config
PGXS := $(shell $(PG_CONFIG) --pgxs)
POSTGRES := $(shell $(PG_CONFIG) --bindir)/postgres
top_builddir := $(dir $(PGXS))../..
include $(top_builddir)/src/Makefile.global
NAME = uuid
OBJS = uuid.o
SO_MAJOR_VERSION = 1
SO_MINOR_VERSION = 0
override CPPFLAGS := -I.. $(CPPFLAGS)
SHLIB_LINK := -L../.libs -luuid
SHLIB_LINK += $(shell test $(shell uname -s) = FreeBSD && echo "-Wl,-Bsymbolic")
SHLIB_LINK += $(shell test $(shell uname -s) = Darwin && echo "-bundle_loader $(POSTGRES)")
rpath :=
all: uuid.sql all-lib
enable_shared = yes
include $(top_builddir)/src/Makefile.shlib
uuid.sql: uuid.sql.in
sed -e 's;MODULE_PATHNAME;$(DESTDIR)$(pkglibdir)/uuid$(DLSUFFIX);g' <uuid.sql.in >uuid.sql
install: all
$(mkinstalldirs) $(DESTDIR)$(pkglibdir)
$(mkinstalldirs) $(DESTDIR)$(datadir)
$(INSTALL_SHLIB) $(shlib) $(DESTDIR)$(pkglibdir)/uuid$(DLSUFFIX)
$(INSTALL_DATA) uuid.sql $(DESTDIR)$(datadir)/uuid.sql
uninstall:
-rm -f $(DESTDIR)$(pkglibdir)/uuid$(DLSUFFIX)
-rm -f $(DESTDIR)$(datadir)/uuid.sql
clean distclean: clean-lib
rm -f $(OBJS)
rm -f uuid.sql
realclean: distclean
test:

View File

@ -1,436 +0,0 @@
/*
** OSSP uuid - Universally Unique Identifier
** Copyright (c) 2004-2007 Ralf S. Engelschall <rse@engelschall.com>
** Copyright (c) 2004-2007 The OSSP Project <http://www.ossp.org/>
**
** This file is part of OSSP uuid, a library for the generation
** of UUIDs which can found at http://www.ossp.org/pkg/lib/uuid/
**
** Permission to use, copy, modify, and distribute this software for
** any purpose with or without fee is hereby granted, provided that
** the above copyright notice and this permission notice appear in all
** copies.
**
** THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
** WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
** MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
** IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
** CONTRIBUTORS 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 ADVISED OF THE POSSIBILITY OF
** SUCH DAMAGE.
**
** uuid.c: PostgreSQL Binding (C part)
*/
/* own headers */
#include "uuid.h"
/* PostgreSQL (part 1/2) headers */
#include "postgres.h"
/* system headers */
#include <string.h>
/* PostgreSQL (part 2/2) headers */
#include "fmgr.h"
#include "lib/stringinfo.h"
#include "access/hash.h"
/* PostgreSQL module magic cookie
(PostgreSQL >= 8.2 only) */
#ifdef PG_MODULE_MAGIC
PG_MODULE_MAGIC;
#endif
/* internal UUID datum data structure */
typedef struct {
unsigned char uuid_bin[UUID_LEN_BIN];
} uuid_datum_t;
/* forward declarations */
Datum pg_uuid_in (PG_FUNCTION_ARGS);
Datum pg_uuid_out (PG_FUNCTION_ARGS);
Datum pg_uuid_recv (PG_FUNCTION_ARGS);
Datum pg_uuid_send (PG_FUNCTION_ARGS);
Datum pg_uuid_hash (PG_FUNCTION_ARGS);
Datum pg_uuid_make (PG_FUNCTION_ARGS);
Datum pg_uuid_eq (PG_FUNCTION_ARGS);
Datum pg_uuid_ne (PG_FUNCTION_ARGS);
Datum pg_uuid_lt (PG_FUNCTION_ARGS);
Datum pg_uuid_gt (PG_FUNCTION_ARGS);
Datum pg_uuid_le (PG_FUNCTION_ARGS);
Datum pg_uuid_ge (PG_FUNCTION_ARGS);
Datum pg_uuid_cmp (PG_FUNCTION_ARGS);
/* API function: uuid_in */
PG_FUNCTION_INFO_V1(pg_uuid_in);
Datum pg_uuid_in(PG_FUNCTION_ARGS)
{
char *uuid_str;
uuid_datum_t *uuid_datum;
uuid_rc_t rc;
uuid_t *uuid;
void *vp;
size_t len;
/* sanity check input argument */
if ((uuid_str = PG_GETARG_CSTRING(0)) == NULL)
ereport(ERROR, (errcode(ERRCODE_DATA_EXCEPTION),
errmsg("invalid UUID string")));
if ((len = strlen(uuid_str)) != UUID_LEN_STR)
ereport(ERROR, (errcode(ERRCODE_DATA_EXCEPTION),
errmsg("invalid UUID string length %d (expected %d)", (int)len, UUID_LEN_STR)));
/* import as string representation */
if ((rc = uuid_create(&uuid)) != UUID_RC_OK)
ereport(ERROR, (errcode(ERRCODE_DATA_EXCEPTION),
errmsg("failed to create UUID object: %s", uuid_error(rc))));
if ((rc = uuid_import(uuid, UUID_FMT_STR, uuid_str, len)) != UUID_RC_OK) {
uuid_destroy(uuid);
ereport(ERROR, (errcode(ERRCODE_DATA_EXCEPTION),
errmsg("failed to import UUID string representation: %s", uuid_error(rc))));
}
/* export as binary representation */
if ((uuid_datum = (uuid_datum_t *)palloc(sizeof(uuid_datum_t))) == NULL) {
uuid_destroy(uuid);
ereport(ERROR, (errcode(ERRCODE_DATA_EXCEPTION),
errmsg("failed to allocate UUID datum")));
}
vp = &(uuid_datum->uuid_bin);
len = sizeof(uuid_datum->uuid_bin);
if ((rc = uuid_export(uuid, UUID_FMT_BIN, &vp, &len)) != UUID_RC_OK) {
uuid_destroy(uuid);
ereport(ERROR, (errcode(ERRCODE_DATA_EXCEPTION),
errmsg("failed to export UUID binary representation: %s", uuid_error(rc))));
}
uuid_destroy(uuid);
/* return UUID datum */
PG_RETURN_POINTER(uuid_datum);
}
/* API function: uuid_out */
PG_FUNCTION_INFO_V1(pg_uuid_out);
Datum pg_uuid_out(PG_FUNCTION_ARGS)
{
uuid_datum_t *uuid_datum;
uuid_rc_t rc;
uuid_t *uuid;
char *uuid_str;
void *vp;
size_t len;
/* sanity check input argument */
if ((uuid_datum = (uuid_datum_t *)PG_GETARG_POINTER(0)) == NULL)
ereport(ERROR, (errcode(ERRCODE_DATA_EXCEPTION),
errmsg("invalid UUID datum")));
/* import as binary representation */
if ((rc = uuid_create(&uuid)) != UUID_RC_OK)
ereport(ERROR, (errcode(ERRCODE_DATA_EXCEPTION),
errmsg("failed to create UUID object: %s", uuid_error(rc))));
if ((rc = uuid_import(uuid, UUID_FMT_BIN, uuid_datum->uuid_bin, sizeof(uuid_datum->uuid_bin))) != UUID_RC_OK) {
uuid_destroy(uuid);
ereport(ERROR, (errcode(ERRCODE_DATA_EXCEPTION),
errmsg("failed to import UUID binary representation: %s", uuid_error(rc))));
}
/* export as string representation */
len = UUID_LEN_STR+1;
if ((vp = uuid_str = (char *)palloc(len)) == NULL) {
uuid_destroy(uuid);
ereport(ERROR, (errcode(ERRCODE_DATA_EXCEPTION),
errmsg("failed to allocate UUID string")));
}
if ((rc = uuid_export(uuid, UUID_FMT_STR, &vp, &len)) != UUID_RC_OK) {
uuid_destroy(uuid);
ereport(ERROR, (errcode(ERRCODE_DATA_EXCEPTION),
errmsg("failed to export UUID string representation: %s", uuid_error(rc))));
}
uuid_destroy(uuid);
/* return UUID string */
PG_RETURN_CSTRING(uuid_str);
}
/* API function: uuid_recv */
PG_FUNCTION_INFO_V1(pg_uuid_recv);
Datum pg_uuid_recv(PG_FUNCTION_ARGS)
{
StringInfo uuid_internal;
uuid_datum_t *uuid_datum;
/* sanity check input argument */
if ((uuid_internal = (StringInfo)PG_GETARG_POINTER(0)) == NULL)
ereport(ERROR, (errcode(ERRCODE_DATA_EXCEPTION),
errmsg("invalid UUID StringInfo object")));
if (uuid_internal->len != UUID_LEN_BIN)
ereport(ERROR, (errcode(ERRCODE_DATA_EXCEPTION),
errmsg("invalid UUID binary length %d (expected %d)", uuid_internal->len, UUID_LEN_BIN)));
/* import as binary representation */
if ((uuid_datum = (uuid_datum_t *)palloc(sizeof(uuid_datum_t))) == NULL)
ereport(ERROR, (errcode(ERRCODE_DATA_EXCEPTION),
errmsg("failed to allocate UUID datum")));
memcpy(uuid_datum->uuid_bin, uuid_internal->data, uuid_internal->len);
/* return UUID datum */
PG_RETURN_POINTER(uuid_datum);
}
/* API function: uuid_send */
PG_FUNCTION_INFO_V1(pg_uuid_send);
Datum pg_uuid_send(PG_FUNCTION_ARGS)
{
uuid_datum_t *uuid_datum;
bytea *uuid_bytea;
/* sanity check input argument */
if ((uuid_datum = (uuid_datum_t *)PG_GETARG_POINTER(0)) == NULL)
ereport(ERROR, (errcode(ERRCODE_DATA_EXCEPTION),
errmsg("invalid UUID datum")));
/* export as binary representation */
if ((uuid_bytea = (bytea *)palloc(VARHDRSZ + UUID_LEN_BIN)) == NULL)
ereport(ERROR, (errcode(ERRCODE_DATA_EXCEPTION),
errmsg("failed to allocate UUID bytea")));
#if defined(SET_VARSIZE) /* PostgreSQL >= 8.3 */
SET_VARSIZE(uuid_bytea, VARHDRSZ + UUID_LEN_BIN);
#else
uuid_bytea->vl_len = VARHDRSZ + UUID_LEN_BIN;
#endif
memcpy(uuid_bytea->vl_dat, uuid_datum->uuid_bin, UUID_LEN_BIN);
/* return UUID bytea */
PG_RETURN_BYTEA_P(uuid_bytea);
}
/* API function: uuid_make */
PG_FUNCTION_INFO_V1(pg_uuid_make);
Datum pg_uuid_make(PG_FUNCTION_ARGS)
{
uuid_t *uuid;
uuid_t *uuid_ns;
uuid_rc_t rc;
int version;
unsigned int mode = 0;
uuid_datum_t *uuid_datum;
char *str_ns;
char *str_name;
void *vp;
size_t len;
/* sanity check input argument */
version = (int)PG_GETARG_INT32(0);
switch (version) {
case 1: mode = UUID_MAKE_V1; break;
case 3: mode = UUID_MAKE_V3; break;
case 4: mode = UUID_MAKE_V4; break;
case 5: mode = UUID_MAKE_V5; break;
default:
ereport(ERROR, (errcode(ERRCODE_DATA_EXCEPTION),
errmsg("invalid UUID version %d (expected 1, 3, 4 or 5)", version)));
}
if ( ((mode & (UUID_MAKE_V1|UUID_MAKE_V4)) && PG_NARGS() != 1)
|| ((mode & (UUID_MAKE_V3|UUID_MAKE_V5)) && PG_NARGS() != 3))
ereport(ERROR, (errcode(ERRCODE_DATA_EXCEPTION),
errmsg("invalid number (%d) of arguments", PG_NARGS())));
/* make a new UUID */
if ((rc = uuid_create(&uuid)) != UUID_RC_OK)
ereport(ERROR, (errcode(ERRCODE_DATA_EXCEPTION),
errmsg("failed to create UUID object: %s", uuid_error(rc))));
if (version == 3 || version == 5) {
if ((str_ns = PG_GETARG_CSTRING(1)) == NULL)
ereport(ERROR, (errcode(ERRCODE_DATA_EXCEPTION),
errmsg("invalid namespace UUID string")));
if ((str_name = PG_GETARG_CSTRING(2)) == NULL)
ereport(ERROR, (errcode(ERRCODE_DATA_EXCEPTION),
errmsg("invalid name string")));
if ((rc = uuid_create(&uuid_ns)) != UUID_RC_OK)
ereport(ERROR, (errcode(ERRCODE_DATA_EXCEPTION),
errmsg("failed to create UUID namespace object: %s", uuid_error(rc))));
if ((rc = uuid_load(uuid_ns, str_ns)) != UUID_RC_OK) {
if ((rc = uuid_import(uuid_ns, UUID_FMT_STR, str_ns, strlen(str_ns))) != UUID_RC_OK)
ereport(ERROR, (errcode(ERRCODE_DATA_EXCEPTION),
errmsg("failed to import UUID namespace: %s", uuid_error(rc))));
}
if ((rc = uuid_make(uuid, mode, uuid_ns, str_name)) != UUID_RC_OK) {
uuid_destroy(uuid);
ereport(ERROR, (errcode(ERRCODE_DATA_EXCEPTION),
errmsg("failed to make v%d UUID: %s", version, uuid_error(rc))));
}
uuid_destroy(uuid_ns);
}
else {
if ((rc = uuid_make(uuid, mode)) != UUID_RC_OK) {
uuid_destroy(uuid);
ereport(ERROR, (errcode(ERRCODE_DATA_EXCEPTION),
errmsg("failed to make v%d UUID: %s", version, uuid_error(rc))));
}
}
/* export as binary representation */
if ((uuid_datum = (uuid_datum_t *)palloc(sizeof(uuid_datum_t))) == NULL) {
uuid_destroy(uuid);
ereport(ERROR, (errcode(ERRCODE_DATA_EXCEPTION),
errmsg("failed to allocate UUID datum")));
}
vp = &(uuid_datum->uuid_bin);
len = sizeof(uuid_datum->uuid_bin);
if ((rc = uuid_export(uuid, UUID_FMT_BIN, &vp, &len)) != UUID_RC_OK) {
uuid_destroy(uuid);
ereport(ERROR, (errcode(ERRCODE_DATA_EXCEPTION),
errmsg("failed to export UUID binary representation: %s", uuid_error(rc))));
}
uuid_destroy(uuid);
PG_RETURN_POINTER(uuid_datum);
}
/* API function: uuid_hash */
PG_FUNCTION_INFO_V1(pg_uuid_hash);
Datum pg_uuid_hash(PG_FUNCTION_ARGS)
{
uuid_datum_t *uuid_datum;
/* sanity check input argument */
if ((uuid_datum = (uuid_datum_t *)PG_GETARG_POINTER(0)) == NULL)
ereport(ERROR, (errcode(ERRCODE_DATA_EXCEPTION),
errmsg("invalid UUID datum argument")));
/* return hash value of the UUID */
PG_RETURN_INT32(hash_any(uuid_datum->uuid_bin, sizeof(uuid_datum->uuid_bin)));
}
/* INTERNAL function: _uuid_cmp */
static int _uuid_cmp(PG_FUNCTION_ARGS)
{
uuid_datum_t *uuid_datum1;
uuid_datum_t *uuid_datum2;
uuid_t *uuid1;
uuid_t *uuid2;
uuid_rc_t rc;
int result;
/* sanity check input argument */
if ((uuid_datum1 = (uuid_datum_t *)PG_GETARG_POINTER(0)) == NULL)
ereport(ERROR, (errcode(ERRCODE_DATA_EXCEPTION),
errmsg("invalid first UUID datum argument")));
if ((uuid_datum2 = (uuid_datum_t *)PG_GETARG_POINTER(1)) == NULL)
ereport(ERROR, (errcode(ERRCODE_DATA_EXCEPTION),
errmsg("invalid second UUID datum argument")));
/* load both UUIDs */
if ((rc = uuid_create(&uuid1)) != UUID_RC_OK)
ereport(ERROR, (errcode(ERRCODE_DATA_EXCEPTION),
errmsg("failed to create UUID object: %s", uuid_error(rc))));
if ((rc = uuid_create(&uuid2)) != UUID_RC_OK) {
uuid_destroy(uuid1);
ereport(ERROR, (errcode(ERRCODE_DATA_EXCEPTION),
errmsg("failed to create UUID object: %s", uuid_error(rc))));
}
if ((rc = uuid_import(uuid1, UUID_FMT_BIN, uuid_datum1->uuid_bin, sizeof(uuid_datum1->uuid_bin))) != UUID_RC_OK) {
uuid_destroy(uuid1);
uuid_destroy(uuid2);
ereport(ERROR, (errcode(ERRCODE_DATA_EXCEPTION),
errmsg("failed to import UUID: %s", uuid_error(rc))));
}
if ((rc = uuid_import(uuid2, UUID_FMT_BIN, uuid_datum2->uuid_bin, sizeof(uuid_datum2->uuid_bin))) != UUID_RC_OK) {
uuid_destroy(uuid1);
uuid_destroy(uuid2);
ereport(ERROR, (errcode(ERRCODE_DATA_EXCEPTION),
errmsg("failed to import UUID: %s", uuid_error(rc))));
}
/* compare UUIDs */
if ((rc = uuid_compare(uuid1, uuid2, &result)) != UUID_RC_OK) {
uuid_destroy(uuid1);
uuid_destroy(uuid2);
ereport(ERROR, (errcode(ERRCODE_DATA_EXCEPTION),
errmsg("failed to compare UUID objects: %s", uuid_error(rc))));
}
/* cleanup */
uuid_destroy(uuid1);
uuid_destroy(uuid2);
/* return result */
return result;
}
/* API function: uuid_eq */
PG_FUNCTION_INFO_V1(pg_uuid_eq);
Datum pg_uuid_eq(PG_FUNCTION_ARGS)
{
int rc;
rc = _uuid_cmp(fcinfo);
PG_RETURN_BOOL(rc == 0);
}
/* API function: uuid_ne */
PG_FUNCTION_INFO_V1(pg_uuid_ne);
Datum pg_uuid_ne(PG_FUNCTION_ARGS)
{
int rc;
rc = _uuid_cmp(fcinfo);
PG_RETURN_BOOL(rc != 0);
}
/* API function: uuid_lt */
PG_FUNCTION_INFO_V1(pg_uuid_lt);
Datum pg_uuid_lt(PG_FUNCTION_ARGS)
{
int rc;
rc = _uuid_cmp(fcinfo);
PG_RETURN_BOOL(rc == -1);
}
/* API function: uuid_gt */
PG_FUNCTION_INFO_V1(pg_uuid_gt);
Datum pg_uuid_gt(PG_FUNCTION_ARGS)
{
int rc;
rc = _uuid_cmp(fcinfo);
PG_RETURN_BOOL(rc == 1);
}
/* API function: uuid_le */
PG_FUNCTION_INFO_V1(pg_uuid_le);
Datum pg_uuid_le(PG_FUNCTION_ARGS)
{
int rc;
rc = _uuid_cmp(fcinfo);
PG_RETURN_BOOL(rc < 1);
}
/* API function: uuid_ge */
PG_FUNCTION_INFO_V1(pg_uuid_ge);
Datum pg_uuid_ge(PG_FUNCTION_ARGS)
{
int rc;
rc = _uuid_cmp(fcinfo);
PG_RETURN_BOOL(rc > -1);
}
/* API function: uuid_cmp */
PG_FUNCTION_INFO_V1(pg_uuid_cmp);
Datum pg_uuid_cmp(PG_FUNCTION_ARGS)
{
int rc;
rc = _uuid_cmp(fcinfo);
PG_RETURN_INT32(rc);
}

View File

@ -1,244 +0,0 @@
--
-- OSSP uuid - Universally Unique Identifier
-- Copyright (c) 2004-2007 Ralf S. Engelschall <rse@engelschall.com>
-- Copyright (c) 2004-2007 The OSSP Project <http://www.ossp.org/>
--
-- This file is part of OSSP uuid, a library for the generation
-- of UUIDs which can found at http://www.ossp.org/pkg/lib/uuid/
--
-- Permission to use, copy, modify, and distribute this software for
-- any purpose with or without fee is hereby granted, provided that
-- the above copyright notice and this permission notice appear in all
-- copies.
--
-- THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
-- WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-- MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-- IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
-- CONTRIBUTORS 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 ADVISED OF THE POSSIBILITY OF
-- SUCH DAMAGE.
--
-- uuid.sql: PostgreSQL Binding (SQL part)
--
--
-- prolog
--
SET search_path TO public;
SET client_min_messages TO warning;
DROP FUNCTION uuid_in(CSTRING) CASCADE;
DROP FUNCTION uuid_out(uuid) CASCADE;
DROP FUNCTION uuid_recv(INTERNAL) CASCADE;
DROP FUNCTION uuid_send(uuid) CASCADE;
DROP TYPE uuid CASCADE;
DROP CAST (CSTRING AS uuid) CASCADE;
DROP CAST (uuid AS CSTRING) CASCADE;
DROP FUNCTION uuid(CSTRING) CASCADE;
DROP FUNCTION uuid(INTEGER) CASCADE;
DROP FUNCTION uuid(INTEGER, CSTRING, CSTRING) CASCADE;
DROP FUNCTION uuid_eq(uuid) CASCADE;
DROP FUNCTION uuid_ne(uuid) CASCADE;
DROP FUNCTION uuid_lt(uuid, uuid) CASCADE;
DROP FUNCTION uuid_gt(uuid, uuid) CASCADE;
DROP FUNCTION uuid_le(uuid, uuid) CASCADE;
DROP FUNCTION uuid_ge(uuid, uuid) CASCADE;
DROP OPERATOR =(uuid,uuid) CASCADE;
DROP OPERATOR <>(uuid,uuid) CASCADE;
DROP OPERATOR <(uuid,uuid) CASCADE;
DROP OPERATOR >(uuid,uuid) CASCADE;
DROP OPERATOR <=(uuid,uuid) CASCADE;
DROP OPERATOR >=(uuid,uuid) CASCADE;
DROP FUNCTION uuid_hash(uuid) CASCADE;
DROP FUNCTION uuid_cmp(uuid, uuid) CASCADE;
DROP OPERATOR CLASS uuid_ops USING hash CASCADE;
DROP OPERATOR CLASS uuid_ops USING btree CASCADE;
BEGIN;
--
-- the UUID data type
--
CREATE FUNCTION
uuid_in(CSTRING) RETURNS uuid
STRICT
LANGUAGE C AS 'MODULE_PATHNAME', 'pg_uuid_in';
CREATE FUNCTION
uuid_out(uuid) RETURNS CSTRING
STRICT
LANGUAGE C AS 'MODULE_PATHNAME', 'pg_uuid_out';
CREATE FUNCTION
uuid_recv(INTERNAL) RETURNS uuid
STRICT
LANGUAGE C AS 'MODULE_PATHNAME', 'pg_uuid_recv';
CREATE FUNCTION
uuid_send(uuid) RETURNS BYTEA
STRICT
LANGUAGE C AS 'MODULE_PATHNAME', 'pg_uuid_send';
CREATE TYPE uuid (
INPUT = uuid_in, -- for SQL input
OUTPUT = uuid_out, -- for SQL output
RECEIVE = uuid_recv, -- for DB input
SEND = uuid_send, -- for DB output
DEFAULT = 'uuid(1)',
INTERNALLENGTH = 16,
ALIGNMENT = char
);
COMMENT ON TYPE uuid
IS 'UUID type';
-- CREATE CAST (CSTRING AS uuid)
-- WITH FUNCTION uuid_in(CSTRING) AS ASSIGNMENT;
--
-- CREATE CAST (uuid AS CSTRING)
-- WITH FUNCTION uuid_out(uuid) AS ASSIGNMENT;
--
-- the UUID constructor function
--
CREATE FUNCTION
uuid(CSTRING) RETURNS uuid
IMMUTABLE STRICT
LANGUAGE C AS 'MODULE_PATHNAME', 'pg_uuid_in';
CREATE FUNCTION
uuid(INTEGER) RETURNS uuid
VOLATILE CALLED ON NULL INPUT
LANGUAGE C AS 'MODULE_PATHNAME', 'pg_uuid_make';
CREATE FUNCTION
uuid(INTEGER, CSTRING, CSTRING) RETURNS uuid
VOLATILE CALLED ON NULL INPUT
LANGUAGE C AS 'MODULE_PATHNAME', 'pg_uuid_make';
--
-- the UUID operators
--
CREATE FUNCTION
uuid_eq(uuid, uuid) RETURNS BOOL
IMMUTABLE STRICT
LANGUAGE C AS 'MODULE_PATHNAME', 'pg_uuid_eq';
CREATE FUNCTION
uuid_ne(uuid, uuid) RETURNS BOOL
IMMUTABLE STRICT
LANGUAGE C AS 'MODULE_PATHNAME', 'pg_uuid_ne';
CREATE FUNCTION
uuid_lt(uuid, uuid) RETURNS BOOL
IMMUTABLE STRICT
LANGUAGE C AS 'MODULE_PATHNAME', 'pg_uuid_lt';
CREATE FUNCTION
uuid_gt(uuid, uuid) RETURNS BOOL
IMMUTABLE STRICT
LANGUAGE C AS 'MODULE_PATHNAME', 'pg_uuid_gt';
CREATE FUNCTION
uuid_le(uuid, uuid) RETURNS BOOL
IMMUTABLE STRICT
LANGUAGE C AS 'MODULE_PATHNAME', 'pg_uuid_le';
CREATE FUNCTION
uuid_ge(uuid, uuid) RETURNS BOOL
IMMUTABLE STRICT
LANGUAGE C AS 'MODULE_PATHNAME', 'pg_uuid_ge';
CREATE OPERATOR = (
leftarg = uuid,
rightarg = uuid,
negator = <>,
procedure = uuid_eq
);
CREATE OPERATOR <> (
leftarg = uuid,
rightarg = uuid,
negator = =,
procedure = uuid_ne
);
CREATE OPERATOR < (
leftarg = uuid,
rightarg = uuid,
commutator = >,
negator = >=,
procedure = uuid_lt
);
CREATE OPERATOR > (
leftarg = uuid,
rightarg = uuid,
commutator = <,
negator = <=,
procedure = uuid_gt
);
CREATE OPERATOR <= (
leftarg = uuid,
rightarg = uuid,
commutator = >=,
negator = >,
procedure = uuid_le
);
CREATE OPERATOR >= (
leftarg = uuid,
rightarg = uuid,
commutator = <=,
negator = <,
procedure = uuid_ge
);
--
-- the UUID support for indexing
--
CREATE FUNCTION
uuid_hash(uuid) RETURNS INTEGER
IMMUTABLE STRICT
LANGUAGE C AS 'MODULE_PATHNAME', 'pg_uuid_hash';
CREATE FUNCTION
uuid_cmp(uuid, uuid) RETURNS INTEGER
IMMUTABLE STRICT
LANGUAGE C AS 'MODULE_PATHNAME', 'pg_uuid_cmp';
CREATE OPERATOR CLASS uuid_ops
DEFAULT FOR TYPE uuid USING hash AS
OPERATOR 1 =, -- 1: equal
FUNCTION 1 uuid_hash(uuid);
CREATE OPERATOR CLASS uuid_ops
DEFAULT FOR TYPE uuid USING btree AS
OPERATOR 1 <, -- 1: less than
OPERATOR 2 <=, -- 2: less than or equal
OPERATOR 3 =, -- 3: equal
OPERATOR 4 >=, -- 4: greater than or equal
OPERATOR 5 >, -- 5: greater than
FUNCTION 1 uuid_cmp(uuid, uuid);
--
-- epilog
--
COMMIT;

View File

@ -1,36 +0,0 @@
OSSP uuid bindings for PostgreSQL
=================================
This is the OSSP uuid binding for the PostgreSQL RDBMS, providing
native UUID data type support.
Installation
------------
In order to install the OSSP uuid binding into the PostgreSQL database
<database> one has run:
$ <prefix>/bin/psql \
-d <database> \
-U postgresql \
-f <prefix>/share/postgresql/uuid.sql
Usage
-----
psql -d <database>
psql> CREATE TABLE test (id UUID DEFAULT uuid(1), name TEXT);
psql> INSERT INTO test (name) VALUES
('foo');
psql> INSERT INTO test (id, name) VALUES
(uuid(1), 'bar');
psql> INSERT INTO test (id, name) VALUES
(uuid(3, 'ns:URL', 'http://www.ossp.org/'), 'baz');
psql> INSERT INTO test (id, name) VALUES
(uuid(3, '6ba7b811-9dad-11d1-80b4-00c04fd430c8',
'http://www.ossp.org/'), 'quux');
psql> SELECT uuid(4);
psql> SELECT * FROM test WHERE id = uuid(3, 'ns:URL', 'http://www.ossp.org/');
psql> DROP TABLE test;

View File

@ -1,71 +0,0 @@
##
## OSSP uuid - Universally Unique Identifier
## Copyright (c) 2004-2007 Ralf S. Engelschall <rse@engelschall.com>
## Copyright (c) 2004-2007 The OSSP Project <http://www.ossp.org/>
##
## This file is part of OSSP uuid, a library for the generation
## of UUIDs which can found at http://www.ossp.org/pkg/lib/uuid/
##
## Permission to use, copy, modify, and distribute this software for
## any purpose with or without fee is hereby granted, provided that
## the above copyright notice and this permission notice appear in all
## copies.
##
## THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
## WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
## IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
## CONTRIBUTORS 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 ADVISED OF THE POSSIBILITY OF
## SUCH DAMAGE.
##
## Makefile.local: PHP/Zend API build procedure (language: make)
##
PHP = php
EXTDIR = `$(PHP)-config --extension-dir`
DESTDIR =
all: build
config:
@if [ ! -f ./configure ]; then $(PHP)ize 2>/dev/null; fi
@if [ ! -f ./Makefile ]; then ./configure --with-php-config=$(PHP)-config; fi
build: config
@$(MAKE) $(MFLAGS) -f Makefile
test: build
@version=`$(PHP)-config --version | sed -e 's;^\([0-9]\).*$$;\1;'`; \
$(PHP) -q -d "safe_mode=0" -d "extension_dir=./" uuid.ts $$version
install: build
@version=`$(PHP)-config --version | sed -e 's;^\([0-9]\).*$$;\1;'`; extdir="$(EXTDIR)"; \
echo "installing PHP$$version API into $$extdir"; \
./build/shtool mkdir -f -p -m 755 $(DESTDIR)$$extdir; \
./build/shtool install -c -m 755 modules/uuid.so $(DESTDIR)$$extdir/uuid.so; \
./build/shtool install -c -m 644 uuid.php$$version $(DESTDIR)$$extdir/uuid.php
clean:
@$(MAKE) $(MFLAGS) -f Makefile clean || true
distclean: clean
-rm -f Makefile .deps
-rm -f config.status configure.lineno
-rm -f config.h config.log
-rm -f *.core *~
realclean: distclean
-rm -rf autom4te.cache build include modules
-rm -f Makefile.fragments Makefile.objects Makefile.global
-rm -f acinclude.m4 aclocal.m4
-rm -f config.guess config.h.in config.nice config.sub
-rm -f configure configure.in
-rm -f install-sh libtool ltmain.sh missing mkinstalldirs
-rm -f run-tests.php

View File

@ -1,48 +0,0 @@
dnl
dnl OSSP uuid - Universally Unique Identifier
dnl Copyright (c) 2004-2007 Ralf S. Engelschall <rse@engelschall.com>
dnl Copyright (c) 2004-2007 The OSSP Project <http://www.ossp.org/>
dnl
dnl This file is part of OSSP uuid, a library for the generation
dnl of UUIDs which can found at http://www.ossp.org/pkg/lib/uuid/
dnl
dnl Permission to use, copy, modify, and distribute this software for
dnl any purpose with or without fee is hereby granted, provided that
dnl the above copyright notice and this permission notice appear in all
dnl copies.
dnl
dnl THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
dnl WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
dnl MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
dnl IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
dnl CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
dnl SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
dnl LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
dnl USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
dnl ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
dnl OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
dnl OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
dnl SUCH DAMAGE.
dnl
dnl config.m4: PHP/Zend API build-time configuration (language: m4)
dnl
PHP_ARG_ENABLE(uuid, OSSP uuid module,
[ --enable-uuid Enable OSSP uuid extension module.])
if test "$PHP_UUID" != "no"; then
PHP_NEW_EXTENSION(uuid, uuid.c, $ext_shared)
AC_DEFINE(HAVE_UUID, 1, [Have OSSP uuid library])
PHP_ADD_LIBPATH([..], )
PHP_ADD_LIBRARY([uuid],, UUID_SHARED_LIBADD)
PHP_ADD_INCLUDE([..])
PHP_SUBST(UUID_SHARED_LIBADD)
dnl avoid linking conflict with a potentially existing uuid_create(3) in libc
AC_CHECK_FUNC(uuid_create,[
SAVE_LDFLAGS="$LDFLAGS"
LDFLAGS="$LDFLAGS -Wl,-Bsymbolic"
AC_TRY_LINK([],[], [EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-Bsymbolic"])
LDFLAGS="$SAVE_LDFLAGS"])
fi

View File

@ -1,35 +0,0 @@
<?xml version="1.0" encoding="ISO-8859-1" ?>
<package>
<name>uuid</name>
<summary>Universally Unique Identifiers (UUID) extension</summary>
<description>
UUID is a PHP extension for the creation
of Universally Unique Identifiers (UUID).
</description>
<license>MIT-Style License</license>
<maintainers>
<maintainer>
<user>rse</user>
<name>Ralf S. Engelschall</name>
<email>rse@engelschall.com</email>
</maintainer>
</maintainers>
<release>
<version>1.0</version>
<date>2003-05-17</date>
<state>unstable</state>
</release>
<configureoptions>
<configureoption name="with-uuid" default="autodetect" prompt="path to OSSP uuid?"/>
</configureoptions>
<filelist>
<dir role="src" name="/">
<file role="src">Makefile.local</file>
<file role="src">config.m4</file>
<file role="src">uuid.c</file>
<file role="php">uuid.php4</file>
<file role="php">uuid.php5</file>
<file role="src">uuid.ts</file>
</dir>
</filelist>
</package>

View File

@ -1,531 +0,0 @@
/*
** OSSP uuid - Universally Unique Identifier
** Copyright (c) 2004-2007 Ralf S. Engelschall <rse@engelschall.com>
** Copyright (c) 2004-2007 The OSSP Project <http://www.ossp.org/>
**
** This file is part of OSSP uuid, a library for the generation
** of UUIDs which can found at http://www.ossp.org/pkg/lib/uuid/
**
** Permission to use, copy, modify, and distribute this software for
** any purpose with or without fee is hereby granted, provided that
** the above copyright notice and this permission notice appear in all
** copies.
**
** THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
** WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
** MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
** IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
** CONTRIBUTORS 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 ADVISED OF THE POSSIBILITY OF
** SUCH DAMAGE.
**
** uuid.c: PHP/Zend API (language: C)
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "uuid.h"
#include "php.h"
#include "ext/standard/info.h"
/* context structure */
typedef struct {
uuid_t *uuid;
} ctx_t;
/* context implicit destruction */
static void ctx_destructor(zend_rsrc_list_entry *rsrc TSRMLS_DC)
{
ctx_t *ctx = (ctx_t *)rsrc->ptr;
if (ctx != NULL) {
if (ctx->uuid != NULL) {
uuid_destroy(ctx->uuid);
ctx->uuid = NULL;
}
free(ctx);
}
return;
}
/* context resource identification */
static int ctx_id; /* internal number */
#define ctx_name "UUID context" /* external name */
/* module initialization */
PHP_MINIT_FUNCTION(uuid)
{
/* register resource identifier */
ctx_id = zend_register_list_destructors_ex(
ctx_destructor, NULL, ctx_name, module_number);
/* register API constants */
REGISTER_LONG_CONSTANT("UUID_VERSION", UUID_VERSION, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("UUID_LEN_BIN", UUID_LEN_BIN, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("UUID_LEN_STR", UUID_LEN_STR, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("UUID_LEN_SIV", UUID_LEN_SIV, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("UUID_RC_OK", UUID_RC_OK, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("UUID_RC_ARG", UUID_RC_ARG, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("UUID_RC_MEM", UUID_RC_MEM, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("UUID_RC_SYS", UUID_RC_SYS, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("UUID_RC_INT", UUID_RC_INT, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("UUID_RC_IMP", UUID_RC_IMP, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("UUID_MAKE_V1", UUID_MAKE_V1, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("UUID_MAKE_V3", UUID_MAKE_V3, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("UUID_MAKE_V4", UUID_MAKE_V4, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("UUID_MAKE_V5", UUID_MAKE_V5, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("UUID_MAKE_MC", UUID_MAKE_MC, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("UUID_FMT_BIN", UUID_FMT_BIN, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("UUID_FMT_STR", UUID_FMT_STR, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("UUID_FMT_SIV", UUID_FMT_SIV, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("UUID_FMT_TXT", UUID_FMT_TXT, CONST_CS|CONST_PERSISTENT);
return SUCCESS;
}
/* module shutdown */
PHP_MSHUTDOWN_FUNCTION(uuid)
{
return SUCCESS;
}
/* module information */
PHP_MINFO_FUNCTION(uuid)
{
char version[32];
/* provide PHP module information */
sprintf(version, "%lx", uuid_version());
php_info_print_table_start();
php_info_print_table_row(2, "UUID (Universally Unique Identifier) Support", "enabled");
php_info_print_table_row(2, "UUID Library Version", version);
php_info_print_table_end();
return;
}
/* API FUNCTION:
proto rc uuid_create(ctx)
$rc = uuid_create(&$uuid);
create UUID context */
PHP_FUNCTION(uuid_create)
{
zval *z_ctx;
ctx_t *ctx;
uuid_rc_t rc;
/* parse parameters */
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &z_ctx) == FAILURE)
RETURN_LONG((long)UUID_RC_ARG);
/* post-process and sanity check parameters */
if (!PZVAL_IS_REF(z_ctx)) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "uuid_create: parameter wasn't passed by reference");
RETURN_LONG((long)UUID_RC_ARG);
}
/* perform operation */
if ((ctx = (ctx_t *)malloc(sizeof(ctx_t))) == NULL)
RETURN_LONG((long)UUID_RC_MEM);
if ((rc = uuid_create(&ctx->uuid)) != UUID_RC_OK) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "uuid_create: %s", uuid_error(rc));
RETURN_LONG((long)rc);
}
ZEND_REGISTER_RESOURCE(z_ctx, ctx, ctx_id);
RETURN_LONG((long)rc);
}
/* API FUNCTION:
proto rc uuid_destroy(ctx)
$rc = uuid_destroy($uuid);
destroy UUID context */
PHP_FUNCTION(uuid_destroy)
{
zval *z_ctx;
ctx_t *ctx;
uuid_rc_t rc;
/* parse parameters */
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &z_ctx) == FAILURE)
RETURN_LONG((long)UUID_RC_ARG);
/* post-process and sanity check parameters */
ZEND_FETCH_RESOURCE(ctx, ctx_t *, &z_ctx, -1, ctx_name, ctx_id);
if (ctx == NULL || ctx->uuid == NULL) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "uuid_destroy: invalid context");
RETURN_LONG((long)UUID_RC_ARG);
}
/* perform operation */
if ((rc = uuid_destroy(ctx->uuid)) != UUID_RC_OK) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "uuid_destroy: %s", uuid_error(rc));
RETURN_LONG((long)rc);
}
ctx->uuid = NULL;
RETURN_LONG((long)rc);
}
/* API FUNCTION:
proto rc uuid_clone(ctx, &ctx2)
$rc = uuid_clone($uuid, &$uuid);
clone UUID context */
PHP_FUNCTION(uuid_clone)
{
zval *z_ctx;
ctx_t *ctx;
zval *z_clone;
ctx_t *clone;
uuid_rc_t rc;
/* parse parameters */
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rz", &z_ctx, &z_clone) == FAILURE)
RETURN_LONG((long)UUID_RC_ARG);
/* post-process and sanity check parameters */
ZEND_FETCH_RESOURCE(ctx, ctx_t *, &z_ctx, -1, ctx_name, ctx_id);
if (ctx == NULL || ctx->uuid == NULL) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "uuid_clone: invalid context");
RETURN_LONG((long)UUID_RC_ARG);
}
if (!PZVAL_IS_REF(z_clone)) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "uuid_clone: clone parameter wasn't passed by reference");
RETURN_LONG((long)UUID_RC_ARG);
}
/* perform operation */
if ((clone = (ctx_t *)malloc(sizeof(ctx_t))) == NULL)
RETURN_LONG((long)UUID_RC_MEM);
if ((rc = uuid_clone(ctx->uuid, &clone->uuid)) != UUID_RC_OK) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "uuid_clone: %s", uuid_error(rc));
RETURN_LONG((long)rc);
}
ZEND_REGISTER_RESOURCE(z_clone, clone, ctx_id);
RETURN_LONG((long)rc);
}
/* API FUNCTION:
proto rc uuid_load(ctx, name)
$rc = uuid_name($uuid, $name);
load an existing UUID */
PHP_FUNCTION(uuid_load)
{
zval *z_ctx;
ctx_t *ctx;
char *name;
size_t name_len;
uuid_rc_t rc;
/* parse parameters */
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs", &z_ctx, &name, &name_len) == FAILURE)
RETURN_LONG((long)UUID_RC_ARG);
/* post-process and sanity check parameters */
ZEND_FETCH_RESOURCE(ctx, ctx_t *, &z_ctx, -1, ctx_name, ctx_id);
if (ctx == NULL || ctx->uuid == NULL) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "uuid_load: invalid context");
RETURN_LONG((long)UUID_RC_ARG);
}
/* perform operation */
if ((rc = uuid_load(ctx->uuid, name)) != UUID_RC_OK) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "uuid_load: %s", uuid_error(rc));
RETURN_LONG((long)rc);
}
RETURN_LONG((long)rc);
}
/* API FUNCTION:
proto rc uuid_make(ctx, mode[, ..., ...])
$rc = uuid_make($uuid, $mode[, ..., ...]);
make a new UUID */
PHP_FUNCTION(uuid_make)
{
zval *z_ctx;
ctx_t *ctx;
uuid_rc_t rc;
long z_mode;
unsigned long mode;
zval *z_ctx_ns;
ctx_t *ctx_ns;
char *url;
size_t url_len;
/* parse parameters */
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl|rs", &z_ctx, &z_mode, &z_ctx_ns, &url, &url_len) == FAILURE)
RETURN_LONG((long)UUID_RC_ARG);
/* post-process and sanity check parameters */
ZEND_FETCH_RESOURCE(ctx, ctx_t *, &z_ctx, -1, ctx_name, ctx_id);
if (ctx == NULL || ctx->uuid == NULL) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "uuid_make: invalid context");
RETURN_LONG((long)UUID_RC_ARG);
}
mode = (unsigned long)z_mode;
/* perform operation */
if (ZEND_NUM_ARGS() == 2 && ((mode & UUID_MAKE_V1) || (mode & UUID_MAKE_V4))) {
if ((rc = uuid_make(ctx->uuid, mode)) != UUID_RC_OK) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "uuid_make: %s", uuid_error(rc));
RETURN_LONG((long)rc);
}
}
else if (ZEND_NUM_ARGS() == 4 && ((mode & UUID_MAKE_V3) || (mode & UUID_MAKE_V5))) {
ZEND_FETCH_RESOURCE(ctx_ns, ctx_t *, &z_ctx_ns, -1, ctx_name, ctx_id);
if (ctx_ns == NULL) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "uuid_make: invalid namespace context");
RETURN_LONG((long)UUID_RC_ARG);
}
if (url == NULL) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "uuid_make: invalid URL");
RETURN_LONG((long)UUID_RC_ARG);
}
if ((rc = uuid_make(ctx->uuid, mode, ctx_ns->uuid, url)) != UUID_RC_OK) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "uuid_make: %s", uuid_error(rc));
RETURN_LONG((long)rc);
}
}
else {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "uuid_make: invalid mode");
RETURN_LONG((long)UUID_RC_ARG);
}
RETURN_LONG((long)rc);
}
/* API FUNCTION:
proto rc uuid_isnil(ctx, result)
$rc = uuid_isnil($uuid, &$result);
compare UUID for being Nil UUID */
PHP_FUNCTION(uuid_isnil)
{
zval *z_ctx;
ctx_t *ctx;
uuid_rc_t rc;
zval *z_result;
int result;
/* parse parameters */
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rz", &z_ctx, &z_result) == FAILURE)
RETURN_LONG((long)UUID_RC_ARG);
/* post-process and sanity check parameters */
ZEND_FETCH_RESOURCE(ctx, ctx_t *, &z_ctx, -1, ctx_name, ctx_id);
if (ctx == NULL || ctx->uuid == NULL) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "uuid_isnil: invalid context");
RETURN_LONG((long)UUID_RC_ARG);
}
if (!PZVAL_IS_REF(z_result)) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "uuid_isnil: result parameter wasn't passed by reference");
RETURN_LONG((long)UUID_RC_ARG);
}
/* perform operation */
if ((rc = uuid_isnil(ctx->uuid, &result)) != UUID_RC_OK) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "uuid_isnil: %s", uuid_error(rc));
RETURN_LONG((long)rc);
}
ZVAL_LONG(z_result, (long)result);
RETURN_LONG((long)rc);
}
/* API FUNCTION:
proto rc uuid_compare(ctx, ctx2, result)
$rc = uuid_compare($uuid, $uuid2, &$result);
compare two UUIDs */
PHP_FUNCTION(uuid_compare)
{
zval *z_ctx;
ctx_t *ctx;
zval *z_ctx2;
ctx_t *ctx2;
uuid_rc_t rc;
zval *z_result;
int result;
/* parse parameters */
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rrz", &z_ctx, &z_ctx2, &z_result) == FAILURE)
RETURN_LONG((long)UUID_RC_ARG);
/* post-process and sanity check parameters */
ZEND_FETCH_RESOURCE(ctx, ctx_t *, &z_ctx, -1, ctx_name, ctx_id);
if (ctx == NULL || ctx->uuid == NULL) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "uuid_compare: invalid context");
RETURN_LONG((long)UUID_RC_ARG);
}
ZEND_FETCH_RESOURCE(ctx2, ctx_t *, &z_ctx2, -1, ctx_name, ctx_id);
if (ctx2 == NULL || ctx2->uuid) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "uuid_compare: invalid context");
RETURN_LONG((long)UUID_RC_ARG);
}
if (!PZVAL_IS_REF(z_result)) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "uuid_compare: result parameter wasn't passed by reference");
RETURN_LONG((long)UUID_RC_ARG);
}
/* perform operation */
if ((rc = uuid_compare(ctx->uuid, ctx2->uuid, &result)) != UUID_RC_OK) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "uuid_compare: %s", uuid_error(rc));
RETURN_LONG((long)rc);
}
ZVAL_LONG(z_result, (long)result);
RETURN_LONG((long)rc);
}
/* API FUNCTION:
proto rc uuid_import(ctx, fmt, data)
$rc = uuid_import($ctx, $fmt, $data);
import UUID from variable */
PHP_FUNCTION(uuid_import)
{
zval *z_ctx;
ctx_t *ctx;
long z_fmt;
unsigned long fmt;
zval *z_data;
uuid_rc_t rc;
void *data_ptr;
size_t data_len;
/* parse parameters */
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rls", &z_ctx, &z_fmt, &data_ptr, &data_len) == FAILURE)
RETURN_LONG((long)UUID_RC_ARG);
/* post-process and sanity check parameters */
ZEND_FETCH_RESOURCE(ctx, ctx_t *, &z_ctx, -1, ctx_name, ctx_id);
if (ctx == NULL || ctx->uuid == NULL) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "uuid_import: invalid context");
RETURN_LONG((long)UUID_RC_ARG);
}
fmt = (unsigned long)z_fmt;
/* perform operation */
if ((rc = uuid_import(ctx->uuid, fmt, data_ptr, data_len)) != UUID_RC_OK) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "uuid_import: %s", uuid_error(rc));
RETURN_LONG((long)rc);
}
RETURN_LONG((long)rc);
}
/* API FUNCTION:
proto rc uuid_export(ctx, fmt, data)
$rc = uuid_error($ctx, $fmt, &$data);
export UUID into variable */
PHP_FUNCTION(uuid_export)
{
zval *z_ctx;
ctx_t *ctx;
long z_fmt;
unsigned long fmt;
zval *z_data;
uuid_rc_t rc;
void *data_ptr;
size_t data_len;
/* parse parameters */
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rlz", &z_ctx, &z_fmt, &z_data) == FAILURE)
RETURN_LONG((long)UUID_RC_ARG);
/* post-process and sanity check parameters */
ZEND_FETCH_RESOURCE(ctx, ctx_t *, &z_ctx, -1, ctx_name, ctx_id);
if (ctx == NULL || ctx->uuid == NULL) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "uuid_export: invalid context");
RETURN_LONG((long)UUID_RC_ARG);
}
fmt = (unsigned long)z_fmt;
if (!PZVAL_IS_REF(z_data)) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "uuid_export: data parameter wasn't passed by reference");
RETURN_LONG((long)UUID_RC_ARG);
}
/* perform operation */
data_ptr = NULL;
data_len = 0;
if ((rc = uuid_export(ctx->uuid, fmt, &data_ptr, &data_len)) != UUID_RC_OK) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "uuid_export: %s", uuid_error(rc));
RETURN_LONG((long)rc);
}
if (fmt == UUID_FMT_SIV)
data_len = strlen((char *)data_ptr);
else if (fmt == UUID_FMT_STR || fmt == UUID_FMT_TXT)
data_len--; /* PHP doesn't wish NUL-termination on strings */
ZVAL_STRINGL(z_data, data_ptr, data_len, 1);
free(data_ptr);
RETURN_LONG((long)rc);
}
/* API FUNCTION:
proto rc uuid_error(ctx)
$error = uuid_error($rc);
return error string corresponding to error return code */
PHP_FUNCTION(uuid_error)
{
int z_rc;
uuid_rc_t rc;
char *error;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &z_rc) == FAILURE)
RETURN_NULL();
rc = (uuid_rc_t)z_rc;
if ((error = uuid_error(rc)) == NULL)
RETURN_NULL();
RETURN_STRING(error, 1);
}
/* API FUNCTION:
proto int uuid_version()
$version = uuid_version();
return library version number */
PHP_FUNCTION(uuid_version)
{
RETURN_LONG((long)uuid_version());
}
/* module function table */
static function_entry uuid_functions[] = {
PHP_FE(uuid_create, NULL)
PHP_FE(uuid_destroy, NULL)
PHP_FE(uuid_clone, NULL)
PHP_FE(uuid_load, NULL)
PHP_FE(uuid_make, NULL)
PHP_FE(uuid_isnil, NULL)
PHP_FE(uuid_compare, NULL)
PHP_FE(uuid_import, NULL)
PHP_FE(uuid_export, NULL)
PHP_FE(uuid_error, NULL)
PHP_FE(uuid_version, NULL)
{ NULL, NULL, NULL }
};
/* module entry table */
zend_module_entry uuid_module_entry = {
STANDARD_MODULE_HEADER,
"uuid",
uuid_functions,
PHP_MINIT(uuid),
PHP_MSHUTDOWN(uuid),
NULL,
NULL,
PHP_MINFO(uuid),
NO_VERSION_YET,
STANDARD_MODULE_PROPERTIES
};
#ifdef COMPILE_DL_UUID
ZEND_GET_MODULE(uuid)
#endif

View File

@ -1,78 +0,0 @@
<?php
##
## OSSP uuid - Universally Unique Identifier
## Copyright (c) 2004-2007 Ralf S. Engelschall <rse@engelschall.com>
## Copyright (c) 2004-2007 The OSSP Project <http://www.ossp.org/>
##
## This file is part of OSSP uuid, a library for the generation
## of UUIDs which can found at http://www.ossp.org/pkg/lib/uuid/
##
## Permission to use, copy, modify, and distribute this software for
## any purpose with or without fee is hereby granted, provided that
## the above copyright notice and this permission notice appear in all
## copies.
##
## THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
## WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
## IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
## CONTRIBUTORS 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 ADVISED OF THE POSSIBILITY OF
## SUCH DAMAGE.
##
## uuid.php: PHP/Zend API (language: php 4.x)
##
class UUID {
var $uuid = null;
function UUID() {
uuid_create(&$this->uuid);
}
function clone() {
$clone = new UUID;
uuid_clone($this->uuid, &$clone->uuid);
return $clone;
}
function load($name) {
uuid_load($this->uuid, $name);
}
function make($fmt, $ns = null, $url = null) {
if (func_num_args() == 3) {
uuid_make($this->uuid, $fmt, $ns->uuid, $url);
}
else {
uuid_make($this->uuid, $fmt);
}
}
function isnil() {
$result = 0;
uuid_isnil($this->uuid, &$result);
return $result;
}
function compare($other) {
$result = 0;
uuid_compare($this->uuid, $other->uuid, &$result);
return $result;
}
function import($fmt, $data) {
uuid_import($this->uuid, $fmt, $data);
}
function export($fmt) {
$data = "";
uuid_export($this->uuid, $fmt, &$data);
return $data;
}
function error($rc) {
return uuid_error($this->uuid, $rc);
}
function version() {
return uuid_version();
}
}
?>

View File

@ -1,81 +0,0 @@
<?php
##
## OSSP uuid - Universally Unique Identifier
## Copyright (c) 2004-2007 Ralf S. Engelschall <rse@engelschall.com>
## Copyright (c) 2004-2007 The OSSP Project <http://www.ossp.org/>
##
## This file is part of OSSP uuid, a library for the generation
## of UUIDs which can found at http://www.ossp.org/pkg/lib/uuid/
##
## Permission to use, copy, modify, and distribute this software for
## any purpose with or without fee is hereby granted, provided that
## the above copyright notice and this permission notice appear in all
## copies.
##
## THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
## WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
## IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
## CONTRIBUTORS 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 ADVISED OF THE POSSIBILITY OF
## SUCH DAMAGE.
##
## uuid.php: PHP/Zend API (language: php 5.x)
##
class UUID {
private $uuid = null;
public function __construct() {
uuid_create(&$this->uuid);
}
public function __destruct() {
uuid_destroy($this->uuid);
}
public function __clone() {
$uuid = null;
uuid_clone($this->uuid, &$uuid);
$this->uuid = $uuid;
}
public function load($name) {
uuid_load($this->uuid, $name);
}
public function make($fmt, $ns = null, $url = null) {
if (func_num_args() == 3) {
uuid_make($this->uuid, $fmt, $ns->uuid, $url);
}
else {
uuid_make($this->uuid, $fmt);
}
}
public function isnil() {
$result = 0;
uuid_isnil($this->uuid, &$result);
return $result;
}
public function compare($other) {
$result = 0;
uuid_compare($this->uuid, $other->uuid, &$result);
return $result;
}
public function import($fmt, $data) {
uuid_import($this->uuid, $fmt, $data);
}
public function export($fmt) {
$data = "";
uuid_export($this->uuid, $fmt, &$data);
return $data;
}
public function error($rc) {
return uuid_error($this->uuid, $rc);
}
public function version() {
return uuid_version();
}
}
?>

View File

@ -1,161 +0,0 @@
<?php
##
## OSSP uuid - Universally Unique Identifier
## Copyright (c) 2004-2007 Ralf S. Engelschall <rse@engelschall.com>
## Copyright (c) 2004-2007 The OSSP Project <http://www.ossp.org/>
##
## This file is part of OSSP uuid, a library for the generation
## of UUIDs which can found at http://www.ossp.org/pkg/lib/uuid/
##
## Permission to use, copy, modify, and distribute this software for
## any purpose with or without fee is hereby granted, provided that
## the above copyright notice and this permission notice appear in all
## copies.
##
## THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
## WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
## IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
## CONTRIBUTORS 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 ADVISED OF THE POSSIBILITY OF
## SUCH DAMAGE.
##
## uuid.ts: PHP/Zend API test procedure (language: php)
##
##
## INITIALIZATION
##
$php_version = $argv[1];
print "++ loading DSO uuid.so (low-level API)\n";
if (!extension_loaded('uuid')) {
dl('modules/uuid.so');
}
print "++ loading PHP uuid.php${php_version} (high-level API)\n";
require "uuid.php${php_version}";
print "++ establishing assertion environment\n";
assert_options(ASSERT_ACTIVE, 1);
assert_options(ASSERT_WARNING, 0);
assert_options(ASSERT_QUIET_EVAL, 1);
function my_assert_handler($file, $line, $code)
{
echo "ASSERTION FAILED: $file: $line: $code\n";
exit(1);
}
assert_options(ASSERT_CALLBACK, 'my_assert_handler');
##
## LOW-LEVEL API TESTING
##
print "++ testing low-level C-style API:\n";
$uuid = 42;
$rc = uuid_create(&$uuid);
assert('$rc == 0');
assert('$uuid != 42');
$rc = uuid_make($uuid, UUID_MAKE_V1);
assert('$rc == 0');
$str = "foo";
$rc = uuid_export($uuid, UUID_FMT_STR, &$str);
assert('$rc == 0');
assert('$str != "foo"');
print "UUID: $str\n";
$uuid_ns = 42;
$rc = uuid_create(&$uuid_ns);
assert('$rc == 0');
$rc = uuid_load($uuid_ns, "ns:URL");
assert('$rc == 0');
$rc = uuid_make($uuid, UUID_MAKE_V3, $uuid_ns, "http://www.ossp.org/");
assert('$rc == 0');
$str = "bar";
$rc = uuid_export($uuid, UUID_FMT_STR, &$str);
assert('$rc == 0');
assert('$str != "bar"');
#assert('$str == "02d9e6d5-9467-382e-8f9b-9300a64ac3cd"');
print "UUID: $str\n";
$rc = uuid_destroy($uuid);
assert('$rc == 0');
$rc = uuid_create(&$uuid);
assert('$rc == 0');
$rc = uuid_import($uuid, UUID_FMT_STR, $str);
assert('$rc == 0');
$str = "baz";
$rc = uuid_export($uuid, UUID_FMT_STR, &$str);
assert('$rc == 0');
assert('$str != "baz"');
#assert('$str == "02d9e6d5-9467-382e-8f9b-9300a64ac3cd"');
print "UUID: $str\n";
$clone = null;
$rc = uuid_clone($uuid, &$clone);
assert('$rc == 0');
assert('$clone != null');
$rc = uuid_destroy($uuid);
assert('$rc == 0');
$str = "quux";
$rc = uuid_export($clone, UUID_FMT_STR, &$str);
assert('$rc == 0');
assert('$str != "quux"');
#assert('$str == "02d9e6d5-9467-382e-8f9b-9300a64ac3cd"');
print "UUID: $str\n";
##
## HIGH-LEVEL API TESTING
##
print "++ testing high-level OO-style API:\n";
$uuid = new UUID;
$uuid->make(UUID_MAKE_V1);
$str = $uuid->export(UUID_FMT_STR);
print "UUID: $str\n";
$uuid_ns = new UUID;
$uuid_ns->load("ns:URL");
$uuid->make(UUID_MAKE_V3, $uuid_ns, "http://www.ossp.org/");
$str = $uuid->export(UUID_FMT_STR);
print "UUID: $str\n";
$uuid = null;
$uuid_ns = null;
$uuid = new UUID;
$uuid->import(UUID_FMT_STR, $str);
$str = $uuid->export(UUID_FMT_STR);
print "UUID: $str\n";
if ($php_version == 4) {
eval('$clone = $uuid->clone();');
}
else {
eval('$clone = clone $uuid;');
}
$uuid = null;
$str = $clone->export(UUID_FMT_STR);
print "UUID: $str\n";
$clone = null;
?>

File diff suppressed because it is too large Load Diff

View File

@ -1,307 +0,0 @@
.\" Automatically generated by Pod::Man 2.16 (Pod::Simple 3.07)
.\"
.\" Standard preamble:
.\" ========================================================================
.de Sh \" Subsection heading
.br
.if t .Sp
.ne 5
.PP
\fB\\$1\fR
.PP
..
.de Sp \" Vertical space (when we can't use .PP)
.if t .sp .5v
.if n .sp
..
.de Vb \" Begin verbatim text
.ft CW
.nf
.ne \\$1
..
.de Ve \" End verbatim text
.ft R
.fi
..
.\" Set up some character translations and predefined strings. \*(-- will
.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
.\" double quote, and \*(R" will give a right double quote. \*(C+ will
.\" give a nicer C++. Capital omega is used to do unbreakable dashes and
.\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff,
.\" nothing in troff, for use with C<>.
.tr \(*W-
.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
.ie n \{\
. ds -- \(*W-
. ds PI pi
. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
. ds L" ""
. ds R" ""
. ds C`
. ds C'
'br\}
.el\{\
. ds -- \|\(em\|
. ds PI \(*p
. ds L" ``
. ds R" ''
'br\}
.\"
.\" Escape single quotes in literal strings from groff's Unicode transform.
.ie \n(.g .ds Aq \(aq
.el .ds Aq '
.\"
.\" If the F register is turned on, we'll generate index entries on stderr for
.\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index
.\" entries marked with X<> in POD. Of course, you'll have to process the
.\" output yourself in some meaningful fashion.
.ie \nF \{\
. de IX
. tm Index:\\$1\t\\n%\t"\\$2"
..
. nr % 0
. rr F
.\}
.el \{\
. de IX
..
.\}
.\"
.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
.\" Fear. Run. Save yourself. No user-serviceable parts.
. \" fudge factors for nroff and troff
.if n \{\
. ds #H 0
. ds #V .8m
. ds #F .3m
. ds #[ \f1
. ds #] \fP
.\}
.if t \{\
. ds #H ((1u-(\\\\n(.fu%2u))*.13m)
. ds #V .6m
. ds #F 0
. ds #[ \&
. ds #] \&
.\}
. \" simple accents for nroff and troff
.if n \{\
. ds ' \&
. ds ` \&
. ds ^ \&
. ds , \&
. ds ~ ~
. ds /
.\}
.if t \{\
. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
.\}
. \" troff and (daisy-wheel) nroff accents
.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
.ds 8 \h'\*(#H'\(*b\h'-\*(#H'
.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
.ds ae a\h'-(\w'a'u*4/10)'e
.ds Ae A\h'-(\w'A'u*4/10)'E
. \" corrections for vroff
.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
. \" for low resolution devices (crt and lpr)
.if \n(.H>23 .if \n(.V>19 \
\{\
. ds : e
. ds 8 ss
. ds o a
. ds d- d\h'-1'\(ga
. ds D- D\h'-1'\(hy
. ds th \o'bp'
. ds Th \o'LP'
. ds ae ae
. ds Ae AE
.\}
.rm #[ #] #H #V #F C
.\" ========================================================================
.\"
.IX Title ".::uuid++ 3"
.TH .::uuid++ 3 "OSSP uuid 1.6.2" "04-Jul-2008" "Universally Unique Identifier"
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.if n .ad l
.nh
.SH "NAME"
\&\fB\s-1OSSP\s0 uuid\fR \- \fBUniversally Unique Identifier\fR (\*(C+ \s-1API\s0)
.SH "VERSION"
.IX Header "VERSION"
\&\s-1OSSP\s0 uuid \s-11.6.2 (04-Jul-2008)\s0
.SH "DESCRIPTION"
.IX Header "DESCRIPTION"
\&\fBuuid++\fR is the \s-1ISO\-\*(C+\s0 language binding of the \fB\s-1OSSP\s0 uuid\fR C \s-1API\s0.
It provides a thin \s-1ISO\-\*(C+\s0 class \fBuuid\fR wrapping the ISO-C \s-1API\s0 type
\&\fBuuid_t\fR.
.SH "APPLICATION PROGRAMMING INTERFACE"
.IX Header "APPLICATION PROGRAMMING INTERFACE"
The \s-1ISO\-\*(C+\s0 Application Programming Interface (\s-1API\s0) of \fB\s-1OSSP\s0 uuid\fR
consists of the following components:
.Sh "\s-1CONSTANTS\s0"
.IX Subsection "CONSTANTS"
The constants are the same to those provided by the ISO-C \s-1API\s0.
See \fIuuid\fR\|(3) for details.
.Sh "\s-1CLASSES\s0"
.IX Subsection "CLASSES"
The following classes are provided:
.IP "\fBuuid\fR" 4
.IX Item "uuid"
This is the class corresponding to the C \s-1API\s0 type \fBuuid_t\fR.
It is the main object.
.IP "\fBuuid_error_t\fR" 4
.IX Item "uuid_error_t"
This is the class corresponding to the C \s-1API\s0 function \fBuuid_error\fR.
It is the object thrown as an exception in case of any errors.
.Sh "\s-1METHODS\s0"
.IX Subsection "METHODS"
The following methods are provided:
.IP "\fBuuid\fR();" 4
.IX Item "uuid();"
The standard constructor.
.IP "\fBuuid\fR(const uuid &_obj);" 4
.IX Item "uuid(const uuid &_obj);"
The copy constructor for \fBuuid\fR class.
.IP "\fBuuid\fR(const uuid_t *_obj);" 4
.IX Item "uuid(const uuid_t *_obj);"
The import constructor for C \s-1API\s0 objects.
.IP "\fBuuid\fR(const void *_bin);" 4
.IX Item "uuid(const void *_bin);"
The import constructor for binary representation.
.IP "\fBuuid\fR(const char *_str);" 4
.IX Item "uuid(const char *_str);"
The import constructor for string representation.
.IP "~\fBuuid\fR();" 4
.IX Item "~uuid();"
The standard destructor for \fBuuid\fR class.
.IP "uuid &\fBuuid::operator=\fR(const uuid &_obj);" 4
.IX Item "uuid &uuid::operator=(const uuid &_obj);"
The assignment operator corresponding to the copy constructor.
.IP "uuid &\fBuuid::operator=\fR(const uuid_t *_obj);" 4
.IX Item "uuid &uuid::operator=(const uuid_t *_obj);"
The assignment operator corresponding to the import constructor for C \s-1API\s0 objects.
.IP "uuid &\fBuuid::operator=\fR(const void *_bin);" 4
.IX Item "uuid &uuid::operator=(const void *_bin);"
The assignment operator corresponding to the import constructor for binary representation.
.IP "uuid &\fBuuid::operator=\fR(const char *_str);" 4
.IX Item "uuid &uuid::operator=(const char *_str);"
The assignment operator corresponding to the import constructor for string and single integer value representation.
.IP "uuid \fBuuid::clone\fR(void);" 4
.IX Item "uuid uuid::clone(void);"
Regular method corresponding to the C \s-1API\s0 function \fBuuid_clone\fR.
.IP "void \fBuuid::load\fR(const char *_name);" 4
.IX Item "void uuid::load(const char *_name);"
Regular method corresponding to the C \s-1API\s0 function \fBuuid_load\fR.
.IP "void \fBuuid::make\fR(unsigned int _mode, ...);" 4
.IX Item "void uuid::make(unsigned int _mode, ...);"
Regular method corresponding to the C \s-1API\s0 function \fBuuid_make\fR.
.IP "int \fBuuid::isnil\fR(void);" 4
.IX Item "int uuid::isnil(void);"
Regular method corresponding to the C \s-1API\s0 function \fBuuid_isnil\fR.
.IP "int \fBuuid::compare\fR(const uuid &_obj);" 4
.IX Item "int uuid::compare(const uuid &_obj);"
Regular method corresponding to the C \s-1API\s0 function \fBuuid_compare\fR.
.IP "int \fBuuid::operator==\fR(const uuid &_obj);" 4
.IX Item "int uuid::operator==(const uuid &_obj);"
The comparison operator corresponding to \fBuuid_compare\fR usage for equality.
.IP "int \fBuuid::operator!=\fR(const uuid &_obj);" 4
.IX Item "int uuid::operator!=(const uuid &_obj);"
The comparison operator corresponding to \fBuuid_compare\fR usage for inequality.
.IP "int \fBuuid::operator<\fR(const uuid &_obj);" 4
.IX Item "int uuid::operator<(const uuid &_obj);"
The comparison operator corresponding to \fBuuid_compare\fR usage for less-than.
.IP "int \fBuuid::operator<=\fR(const uuid &_obj);" 4
.IX Item "int uuid::operator<=(const uuid &_obj);"
The comparison operator corresponding to \fBuuid_compare\fR usage for less-than-or-equal.
.IP "int \fBuuid::operator>\fR(const uuid &_obj);" 4
.IX Item "int uuid::operator>(const uuid &_obj);"
The comparison operator corresponding to \fBuuid_compare\fR usage for greater-than.
.IP "int \fBuuid::operator>=\fR(const uuid &_obj);" 4
.IX Item "int uuid::operator>=(const uuid &_obj);"
The comparison operator corresponding to \fBuuid_compare\fR usage for greater-than-or-equal.
.IP "void \fBuuid::import\fR(const void *_bin);" 4
.IX Item "void uuid::import(const void *_bin);"
Regular method corresponding to the C \s-1API\s0 function \fBuuid_import\fR for binary representation usage.
.IP "void \fBuuid::import\fR(const char *_str);" 4
.IX Item "void uuid::import(const char *_str);"
Regular method corresponding to the C \s-1API\s0 function \fBuuid_import\fR for string representation usage.
.IP "void *\fBuuid::binary\fR(void);" 4
.IX Item "void *uuid::binary(void);"
Regular method corresponding to the C \s-1API\s0 function \fBuuid_export\fR for binary representation usage.
.IP "char *\fBuuid::string\fR(void);" 4
.IX Item "char *uuid::string(void);"
Regular method corresponding to the C \s-1API\s0 function \fBuuid_export\fR for string representation usage.
.IP "char *\fBuuid::integer\fR(void);" 4
.IX Item "char *uuid::integer(void);"
Regular method corresponding to the C \s-1API\s0 function \fBuuid_export\fR for single integer value representation usage.
.IP "char *\fBuuid::summary\fR(void);" 4
.IX Item "char *uuid::summary(void);"
Regular method corresponding to the C \s-1API\s0 function \fBuuid_export\fR for textual summary representation usage.
.IP "unsigned long \fBuuid::version\fR(void);" 4
.IX Item "unsigned long uuid::version(void);"
Regular method corresponding to the C \s-1API\s0 function \fBuuid_version\fR.
.IP "\fBuuid_error_t\fR()" 4
.IX Item "uuid_error_t()"
The standard constructor for \fBuuid_error_t\fR class.
.IP "\fBuuid_error_t\fR(uuid_rc_t _code)" 4
.IX Item "uuid_error_t(uuid_rc_t _code)"
The standard constructor for \fBuuid_error_t\fR class with return code initialization.
.IP "~\fBuuid_error_t\fR()" 4
.IX Item "~uuid_error_t()"
The standard destructor for \fBuuid_error_t\fR class.
.IP "void \fBuuid_error_t::code\fR(uuid_rc_t _code)" 4
.IX Item "void uuid_error_t::code(uuid_rc_t _code)"
Regular method for setting the return code.
.IP "uuid_rc_t \fBuuid_error_t::code\fR(void)" 4
.IX Item "uuid_rc_t uuid_error_t::code(void)"
Regular method for fetching the return code.
.IP "char *\fBuuid_error_t::string\fR(void)" 4
.IX Item "char *uuid_error_t::string(void)"
Regular method for fetching the string corresponding to the current return code.
.SH "EXAMPLE"
.IX Header "EXAMPLE"
The following shows an example usage of the \*(C+ \s-1API\s0. Exception handling is
omitted for code simplification and has to be re-added for production
code.
.PP
.Vb 5
\& /* generate a DCE 1.1 v1 UUID from system environment */
\& char *uuid_v1(void)
\& {
\& uuid id;
\& char *str;
\&
\& id.make(UUID_MAKE_V1);
\& str = id.string();
\& return str;
\& }
\&
\& /* generate a DCE 1.1 v3 UUID from an URL */
\& char *uuid_v3(const char *url)
\& {
\& uuid id;
\& uuid id_ns;
\& char *str;
\&
\& id_ns.load("ns:URL");
\& id.make(UUID_MAKE_V3, &id_ns, url);
\& str = id.string();
\& return str;
\& }
.Ve
.SH "SEE ALSO"
.IX Header "SEE ALSO"
\&\fIuuid\fR\|(3).

View File

@ -1,301 +0,0 @@
/*
** OSSP uuid - Universally Unique Identifier
** Copyright (c) 2004-2008 Ralf S. Engelschall <rse@engelschall.com>
** Copyright (c) 2004-2008 The OSSP Project <http://www.ossp.org/>
**
** This file is part of OSSP uuid, a library for the generation
** of UUIDs which can found at http://www.ossp.org/pkg/lib/uuid/
**
** Permission to use, copy, modify, and distribute this software for
** any purpose with or without fee is hereby granted, provided that
** the above copyright notice and this permission notice appear in all
** copies.
**
** THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
** WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
** MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
** IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
** CONTRIBUTORS 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 ADVISED OF THE POSSIBILITY OF
** SUCH DAMAGE.
**
** uuid++.cc: library C++ API implementation
*/
#include <string.h>
#include <stdarg.h>
#include "uuid++.hh"
/* standard constructor */
uuid::uuid()
{
uuid_rc_t rc;
if ((rc = uuid_create(&ctx)) != UUID_RC_OK)
throw uuid_error_t(rc);
}
/* copy constructor */
uuid::uuid(const uuid &obj)
{
/* Notice: the copy constructor is the same as the assignment
operator (with the object as the argument) below, except that
(1) no check for self-assignment is required, (2) no existing
internals have to be destroyed and (3) no return value is given back. */
uuid_rc_t rc;
if ((rc = uuid_clone(obj.ctx, &ctx)) != UUID_RC_OK)
throw uuid_error_t(rc);
return;
}
/* extra constructor via C API object */
uuid::uuid(const uuid_t *obj)
{
uuid_rc_t rc;
if (obj == NULL)
throw uuid_error_t(UUID_RC_ARG);
if ((rc = uuid_clone(obj, &ctx)) != UUID_RC_OK)
throw uuid_error_t(rc);
return;
}
/* extra constructor via binary representation */
uuid::uuid(const void *bin)
{
uuid_rc_t rc;
if (bin == NULL)
throw uuid_error_t(UUID_RC_ARG);
if ((rc = uuid_create(&ctx)) != UUID_RC_OK)
throw uuid_error_t(rc);
import(bin);
return;
}
/* extra constructor via string representation */
uuid::uuid(const char *str)
{
uuid_rc_t rc;
if (str == NULL)
throw uuid_error_t(UUID_RC_ARG);
if ((rc = uuid_create(&ctx)) != UUID_RC_OK)
throw uuid_error_t(rc);
import(str);
return;
}
/* standard destructor */
uuid::~uuid()
{
uuid_destroy(ctx);
return;
}
/* assignment operator: import of other C++ API object */
uuid &uuid::operator=(const uuid &obj)
{
uuid_rc_t rc;
if (this == &obj)
return *this;
if ((rc = uuid_destroy(ctx)) != UUID_RC_OK)
throw uuid_error_t(rc);
if ((rc = uuid_clone(obj.ctx, &ctx)) != UUID_RC_OK)
throw uuid_error_t(rc);
return *this;
}
/* assignment operator: import of other C API object */
uuid &uuid::operator=(const uuid_t *obj)
{
uuid_rc_t rc;
if (obj == NULL)
throw uuid_error_t(UUID_RC_ARG);
if ((rc = uuid_clone(obj, &ctx)) != UUID_RC_OK)
throw uuid_error_t(rc);
return *this;
}
/* assignment operator: import of binary representation */
uuid &uuid::operator=(const void *bin)
{
if (bin == NULL)
throw uuid_error_t(UUID_RC_ARG);
import(bin);
return *this;
}
/* assignment operator: import of string representation */
uuid &uuid::operator=(const char *str)
{
if (str == NULL)
throw uuid_error_t(UUID_RC_ARG);
import(str);
return *this;
}
/* method: clone object */
uuid uuid::clone(void)
{
return new uuid(this);
}
/* method: loading existing UUID by name */
void uuid::load(const char *name)
{
uuid_rc_t rc;
if (name == NULL)
throw uuid_error_t(UUID_RC_ARG);
if ((rc = uuid_load(ctx, name)) != UUID_RC_OK)
throw uuid_error_t(rc);
return;
}
/* method: making new UUID one from scratch */
void uuid::make(unsigned int mode, ...)
{
uuid_rc_t rc;
va_list ap;
va_start(ap, mode);
if ((mode & UUID_MAKE_V3) || (mode & UUID_MAKE_V5)) {
const uuid *ns = (const uuid *)va_arg(ap, const uuid *);
const char *name = (const char *)va_arg(ap, char *);
if (ns == NULL || name == NULL)
throw uuid_error_t(UUID_RC_ARG);
rc = uuid_make(ctx, mode, ns->ctx, name);
}
else
rc = uuid_make(ctx, mode);
va_end(ap);
if (rc != UUID_RC_OK)
throw uuid_error_t(rc);
return;
}
/* method: comparison for Nil UUID */
int uuid::isnil(void)
{
uuid_rc_t rc;
int rv;
if ((rc = uuid_isnil(ctx, &rv)) != UUID_RC_OK)
throw uuid_error_t(rc);
return rv;
}
/* method: comparison against other object */
int uuid::compare(const uuid &obj)
{
uuid_rc_t rc;
int rv;
if ((rc = uuid_compare(ctx, obj.ctx, &rv)) != UUID_RC_OK)
throw uuid_error_t(rc);
return rv;
}
/* method: comparison for equality */
int uuid::operator==(const uuid &obj)
{
return (compare(obj) == 0);
}
/* method: comparison for inequality */
int uuid::operator!=(const uuid &obj)
{
return (compare(obj) != 0);
}
/* method: comparison for lower-than */
int uuid::operator<(const uuid &obj)
{
return (compare(obj) < 0);
}
/* method: comparison for lower-than-or-equal */
int uuid::operator<=(const uuid &obj)
{
return (compare(obj) <= 0);
}
/* method: comparison for greater-than */
int uuid::operator>(const uuid &obj)
{
return (compare(obj) > 0);
}
/* method: comparison for greater-than-or-equal */
int uuid::operator>=(const uuid &obj)
{
return (compare(obj) >= 0);
}
/* method: import binary representation */
void uuid::import(const void *bin)
{
uuid_rc_t rc;
if ((rc = uuid_import(ctx, UUID_FMT_BIN, bin, UUID_LEN_BIN)) != UUID_RC_OK)
throw uuid_error_t(rc);
return;
}
/* method: import string or single integer value representation */
void uuid::import(const char *str)
{
uuid_rc_t rc;
if ((rc = uuid_import(ctx, UUID_FMT_STR, str, UUID_LEN_STR)) != UUID_RC_OK)
if ((rc = uuid_import(ctx, UUID_FMT_SIV, str, UUID_LEN_SIV)) != UUID_RC_OK)
throw uuid_error_t(rc);
return;
}
/* method: export binary representation */
void *uuid::binary(void)
{
uuid_rc_t rc;
void *bin = NULL;
if ((rc = uuid_export(ctx, UUID_FMT_BIN, &bin, NULL)) != UUID_RC_OK)
throw uuid_error_t(rc);
return bin;
}
/* method: export string representation */
char *uuid::string(void)
{
uuid_rc_t rc;
char *str = NULL;
if ((rc = uuid_export(ctx, UUID_FMT_STR, (void **)&str, NULL)) != UUID_RC_OK)
throw uuid_error_t(rc);
return str;
}
/* method: export single integer value representation */
char *uuid::integer(void)
{
uuid_rc_t rc;
char *str = NULL;
if ((rc = uuid_export(ctx, UUID_FMT_SIV, (void **)&str, NULL)) != UUID_RC_OK)
throw uuid_error_t(rc);
return str;
}
/* method: export textual summary representation */
char *uuid::summary(void)
{
uuid_rc_t rc;
char *txt = NULL;
if ((rc = uuid_export(ctx, UUID_FMT_TXT, (void **)&txt, NULL)) != UUID_RC_OK)
throw uuid_error_t(rc);
return txt;
}
/* method: return library version */
unsigned long uuid::version(void)
{
return uuid_version();
}

View File

@ -1,98 +0,0 @@
/*
** OSSP uuid - Universally Unique Identifier
** Copyright (c) 2004-2008 Ralf S. Engelschall <rse@engelschall.com>
** Copyright (c) 2004-2008 The OSSP Project <http://www.ossp.org/>
**
** This file is part of OSSP uuid, a library for the generation
** of UUIDs which can found at http://www.ossp.org/pkg/lib/uuid/
**
** Permission to use, copy, modify, and distribute this software for
** any purpose with or without fee is hereby granted, provided that
** the above copyright notice and this permission notice appear in all
** copies.
**
** THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
** WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
** MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
** IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
** CONTRIBUTORS 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 ADVISED OF THE POSSIBILITY OF
** SUCH DAMAGE.
**
** uuid++.hh: library C++ API definition
*/
#ifndef __UUIDXX_HH__
#define __UUIDXX_HH__
/* required C API header */
#include <stdlib.h>
#include "uuid.h"
/* UUID object class */
class uuid {
public:
/* construction & destruction */
uuid (); /* standard constructor */
uuid (const uuid &_obj); /* copy constructor */
uuid (const uuid_t *_obj); /* import constructor */
uuid (const void *_bin); /* import constructor */
uuid (const char *_str); /* import constructor */
~uuid (); /* destructor */
/* copying & cloning */
uuid &operator= (const uuid &_obj); /* copy assignment operator */
uuid &operator= (const uuid_t *_obj); /* import assignment operator */
uuid &operator= (const void *_bin); /* import assignment operator */
uuid &operator= (const char *_str); /* import assignment operator */
uuid clone (void); /* regular method */
/* content generation */
void load (const char *_name); /* regular method */
void make (unsigned int _mode, ...); /* regular method */
/* content comparison */
int isnil (void); /* regular method */
int compare (const uuid &_obj); /* regular method */
int operator== (const uuid &_obj); /* comparison operator */
int operator!= (const uuid &_obj); /* comparison operator */
int operator< (const uuid &_obj); /* comparison operator */
int operator<= (const uuid &_obj); /* comparison operator */
int operator> (const uuid &_obj); /* comparison operator */
int operator>= (const uuid &_obj); /* comparison operator */
/* content importing & exporting */
void import (const void *_bin); /* regular method */
void import (const char *_str); /* regular method */
void *binary (void); /* regular method */
char *string (void); /* regular method */
char *integer (void); /* regular method */
char *summary (void); /* regular method */
unsigned long version (void); /* regular method */
private:
uuid_t *ctx;
};
/* UUID exception class */
class uuid_error_t {
public:
uuid_error_t () { code(UUID_RC_OK); };
uuid_error_t (uuid_rc_t _code) { code(_code); };
~uuid_error_t () { };
void code (uuid_rc_t _code) { rc = _code; };
uuid_rc_t code (void) { return rc; };
char *string (void) { return uuid_error(rc); };
private:
uuid_rc_t rc;
};
#endif /* __UUIDXX_HH__ */

View File

@ -1,253 +0,0 @@
##
## OSSP uuid - Universally Unique Identifier
## Copyright (c) 2004-2008 Ralf S. Engelschall <rse@engelschall.com>
## Copyright (c) 2004-2008 The OSSP Project <http://www.ossp.org/>
##
## This file is part of OSSP uuid, a library for the generation
## of UUIDs which can found at http://www.ossp.org/pkg/lib/uuid/
##
## Permission to use, copy, modify, and distribute this software for
## any purpose with or without fee is hereby granted, provided that
## the above copyright notice and this permission notice appear in all
## copies.
##
## THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
## WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
## IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
## CONTRIBUTORS 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 ADVISED OF THE POSSIBILITY OF
## SUCH DAMAGE.
##
## uuid++.pod: manual page for C++ API
##
=pod
=head1 NAME
B<OSSP uuid> - B<Universally Unique Identifier> (C++ API)
=head1 VERSION
OSSP uuid UUID_VERSION_STR
=head1 DESCRIPTION
B<uuid++> is the ISO-C++ language binding of the B<OSSP uuid> C API.
It provides a thin ISO-C++ class B<uuid> wrapping the ISO-C API type
B<uuid_t>.
=head1 APPLICATION PROGRAMMING INTERFACE
The ISO-C++ Application Programming Interface (API) of B<OSSP uuid>
consists of the following components:
=head2 CONSTANTS
The constants are the same to those provided by the ISO-C API.
See uuid(3) for details.
=head2 CLASSES
The following classes are provided:
=over 4
=item B<uuid>
This is the class corresponding to the C API type B<uuid_t>.
It is the main object.
=item B<uuid_error_t>
This is the class corresponding to the C API function B<uuid_error>.
It is the object thrown as an exception in case of any errors.
=back
=head2 METHODS
The following methods are provided:
=over 4
=item B<uuid>();
The standard constructor.
=item B<uuid>(const uuid &_obj);
The copy constructor for B<uuid> class.
=item B<uuid>(const uuid_t *_obj);
The import constructor for C API objects.
=item B<uuid>(const void *_bin);
The import constructor for binary representation.
=item B<uuid>(const char *_str);
The import constructor for string representation.
=item ~B<uuid>();
The standard destructor for B<uuid> class.
=item uuid &B<uuid::operator=>(const uuid &_obj);
The assignment operator corresponding to the copy constructor.
=item uuid &B<uuid::operator=>(const uuid_t *_obj);
The assignment operator corresponding to the import constructor for C API objects.
=item uuid &B<uuid::operator=>(const void *_bin);
The assignment operator corresponding to the import constructor for binary representation.
=item uuid &B<uuid::operator=>(const char *_str);
The assignment operator corresponding to the import constructor for string and single integer value representation.
=item uuid B<uuid::clone>(void);
Regular method corresponding to the C API function B<uuid_clone>.
=item void B<uuid::load>(const char *_name);
Regular method corresponding to the C API function B<uuid_load>.
=item void B<uuid::make>(unsigned int _mode, ...);
Regular method corresponding to the C API function B<uuid_make>.
=item int B<uuid::isnil>(void);
Regular method corresponding to the C API function B<uuid_isnil>.
=item int B<uuid::compare>(const uuid &_obj);
Regular method corresponding to the C API function B<uuid_compare>.
=item int B<uuid::operator==>(const uuid &_obj);
The comparison operator corresponding to B<uuid_compare> usage for equality.
=item int B<uuid::operator!=>(const uuid &_obj);
The comparison operator corresponding to B<uuid_compare> usage for inequality.
=item int B<uuid::operatorE<lt>>(const uuid &_obj);
The comparison operator corresponding to B<uuid_compare> usage for less-than.
=item int B<uuid::operatorE<lt>=>(const uuid &_obj);
The comparison operator corresponding to B<uuid_compare> usage for less-than-or-equal.
=item int B<uuid::operatorE<gt>>(const uuid &_obj);
The comparison operator corresponding to B<uuid_compare> usage for greater-than.
=item int B<uuid::operatorE<gt>=>(const uuid &_obj);
The comparison operator corresponding to B<uuid_compare> usage for greater-than-or-equal.
=item void B<uuid::import>(const void *_bin);
Regular method corresponding to the C API function B<uuid_import> for binary representation usage.
=item void B<uuid::import>(const char *_str);
Regular method corresponding to the C API function B<uuid_import> for string representation usage.
=item void *B<uuid::binary>(void);
Regular method corresponding to the C API function B<uuid_export> for binary representation usage.
=item char *B<uuid::string>(void);
Regular method corresponding to the C API function B<uuid_export> for string representation usage.
=item char *B<uuid::integer>(void);
Regular method corresponding to the C API function B<uuid_export> for single integer value representation usage.
=item char *B<uuid::summary>(void);
Regular method corresponding to the C API function B<uuid_export> for textual summary representation usage.
=item unsigned long B<uuid::version>(void);
Regular method corresponding to the C API function B<uuid_version>.
=item B<uuid_error_t>()
The standard constructor for B<uuid_error_t> class.
=item B<uuid_error_t>(uuid_rc_t _code)
The standard constructor for B<uuid_error_t> class with return code initialization.
=item ~B<uuid_error_t>()
The standard destructor for B<uuid_error_t> class.
=item void B<uuid_error_t::code>(uuid_rc_t _code)
Regular method for setting the return code.
=item uuid_rc_t B<uuid_error_t::code>(void)
Regular method for fetching the return code.
=item char *B<uuid_error_t::string>(void)
Regular method for fetching the string corresponding to the current return code.
=back
=head1 EXAMPLE
The following shows an example usage of the C++ API. Exception handling is
omitted for code simplification and has to be re-added for production
code.
/* generate a DCE 1.1 v1 UUID from system environment */
char *uuid_v1(void)
{
uuid id;
char *str;
id.make(UUID_MAKE_V1);
str = id.string();
return str;
}
/* generate a DCE 1.1 v3 UUID from an URL */
char *uuid_v3(const char *url)
{
uuid id;
uuid id_ns;
char *str;
id_ns.load("ns:URL");
id.make(UUID_MAKE_V3, &id_ns, url);
str = id.string();
return str;
}
=head1 SEE ALSO
uuid(3).
=cut

View File

@ -1,236 +0,0 @@
.\" Automatically generated by Pod::Man 2.16 (Pod::Simple 3.07)
.\"
.\" Standard preamble:
.\" ========================================================================
.de Sh \" Subsection heading
.br
.if t .Sp
.ne 5
.PP
\fB\\$1\fR
.PP
..
.de Sp \" Vertical space (when we can't use .PP)
.if t .sp .5v
.if n .sp
..
.de Vb \" Begin verbatim text
.ft CW
.nf
.ne \\$1
..
.de Ve \" End verbatim text
.ft R
.fi
..
.\" Set up some character translations and predefined strings. \*(-- will
.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
.\" double quote, and \*(R" will give a right double quote. \*(C+ will
.\" give a nicer C++. Capital omega is used to do unbreakable dashes and
.\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff,
.\" nothing in troff, for use with C<>.
.tr \(*W-
.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
.ie n \{\
. ds -- \(*W-
. ds PI pi
. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
. ds L" ""
. ds R" ""
. ds C`
. ds C'
'br\}
.el\{\
. ds -- \|\(em\|
. ds PI \(*p
. ds L" ``
. ds R" ''
'br\}
.\"
.\" Escape single quotes in literal strings from groff's Unicode transform.
.ie \n(.g .ds Aq \(aq
.el .ds Aq '
.\"
.\" If the F register is turned on, we'll generate index entries on stderr for
.\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index
.\" entries marked with X<> in POD. Of course, you'll have to process the
.\" output yourself in some meaningful fashion.
.ie \nF \{\
. de IX
. tm Index:\\$1\t\\n%\t"\\$2"
..
. nr % 0
. rr F
.\}
.el \{\
. de IX
..
.\}
.\"
.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
.\" Fear. Run. Save yourself. No user-serviceable parts.
. \" fudge factors for nroff and troff
.if n \{\
. ds #H 0
. ds #V .8m
. ds #F .3m
. ds #[ \f1
. ds #] \fP
.\}
.if t \{\
. ds #H ((1u-(\\\\n(.fu%2u))*.13m)
. ds #V .6m
. ds #F 0
. ds #[ \&
. ds #] \&
.\}
. \" simple accents for nroff and troff
.if n \{\
. ds ' \&
. ds ` \&
. ds ^ \&
. ds , \&
. ds ~ ~
. ds /
.\}
.if t \{\
. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
.\}
. \" troff and (daisy-wheel) nroff accents
.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
.ds 8 \h'\*(#H'\(*b\h'-\*(#H'
.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
.ds ae a\h'-(\w'a'u*4/10)'e
.ds Ae A\h'-(\w'A'u*4/10)'E
. \" corrections for vroff
.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
. \" for low resolution devices (crt and lpr)
.if \n(.H>23 .if \n(.V>19 \
\{\
. ds : e
. ds 8 ss
. ds o a
. ds d- d\h'-1'\(ga
. ds D- D\h'-1'\(hy
. ds th \o'bp'
. ds Th \o'LP'
. ds ae ae
. ds Ae AE
.\}
.rm #[ #] #H #V #F C
.\" ========================================================================
.\"
.IX Title "UUID-CONFIG 1"
.TH UUID-CONFIG 1 "OSSP uuid 1.6.2" "04-Jul-2008" "Universally Unique Identifier"
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.if n .ad l
.nh
.SH "NAME"
\&\fBuuid-config\fR \- \fB\s-1OSSP\s0 uuid \s-1API\s0 build utility\fR
.SH "VERSION"
.IX Header "VERSION"
\&\s-1OSSP\s0 uuid \s-11.6.2 (04-Jul-2008)\s0
.SH "SYNOPSIS"
.IX Header "SYNOPSIS"
\&\fBuuid-config\fR
[\fB\-\-help\fR]
[\fB\-\-version\fR]
[\fB\-\-all\fR]
[\fB\-\-prefix\fR]
[\fB\-\-exec\-prefix\fR]
[\fB\-\-bindir\fR]
[\fB\-\-libdir\fR]
[\fB\-\-includedir\fR]
[\fB\-\-mandir\fR]
[\fB\-\-datadir\fR]
[\fB\-\-acdir\fR]
[\fB\-\-cflags\fR]
[\fB\-\-ldflags\fR]
[\fB\-\-libs\fR]
.SH "DESCRIPTION"
.IX Header "DESCRIPTION"
The \fBuuid-config\fR program is a little helper utility for easy configuring and
building applications based on the \fIuuid\fR\|(3) library. It can be used to query the
C compiler and linker flags which are required to correctly compile and link
the application against the \fIuuid\fR\|(3) library.
.SH "OPTIONS"
.IX Header "OPTIONS"
\&\fBuuid-config\fR accepts the following options:
.IP "\fB\-\-help\fR" 2
.IX Item "--help"
Prints the short usage information.
.IP "\fB\-\-version\fR" 2
.IX Item "--version"
Prints the version number and date of the installed \fIuuid\fR\|(3) library.
.IP "\fB\-\-all\fR" 2
.IX Item "--all"
Forces the output of all flags, that is, including extra flags which are not
\&\fB\s-1OSSP\s0 uuid\fR specific.
.IP "\fB\-\-prefix\fR" 2
.IX Item "--prefix"
Prints the installation prefix of architecture independent files
.IP "\fB\-\-exec\-prefix\fR" 2
.IX Item "--exec-prefix"
Prints the installation prefix of architecture dependent files.
.IP "\fB\-\-bindir\fR" 2
.IX Item "--bindir"
Prints the installation directory of binaries.
.IP "\fB\-\-libdir\fR" 2
.IX Item "--libdir"
Prints the installation directory of libraries.
.IP "\fB\-\-includedir\fR" 2
.IX Item "--includedir"
Prints the installation directory of include headers.
.IP "\fB\-\-mandir\fR" 2
.IX Item "--mandir"
Prints the installation directory of manual pages.
.IP "\fB\-\-datadir\fR" 2
.IX Item "--datadir"
Prints the installation directory of shared data.
.IP "\fB\-\-acdir\fR" 2
.IX Item "--acdir"
Prints the installation directory of \fBautoconf\fR data.
.IP "\fB\-\-cflags\fR" 2
.IX Item "--cflags"
Prints the C compiler flags which are needed to compile the \fIuuid\fR\|(3)\-based
application. The output is usually added to the \f(CW\*(C`CFLAGS\*(C'\fR uuidiable of the
applications \f(CW\*(C`Makefile\*(C'\fR.
.IP "\fB\-\-ldflags\fR" 2
.IX Item "--ldflags"
Prints the linker flags (\f(CW\*(C`\-L\*(C'\fR) which are needed to link the application with
the \fIuuid\fR\|(3) library. The output is usually added to the \f(CW\*(C`LDFLAGS\*(C'\fR uuidiable of
the applications \f(CW\*(C`Makefile\*(C'\fR.
.IP "\fB\-\-libs\fR" 2
.IX Item "--libs"
Prints the library flags (\f(CW\*(C`\-l\*(C'\fR) which are needed to link the application with
the C \fIuuid\fR\|(3) library. The output is usually added to the \f(CW\*(C`LIBS\*(C'\fR uuidiable of the
applications \f(CW\*(C`Makefile\*(C'\fR.
.SH "EXAMPLE"
.IX Header "EXAMPLE"
.Vb 4
\& CC = cc
\& CFLAGS = \-O \`uuid\-config \-\-cflags\`
\& LDFLAGS = \`uuid\-config \-\-ldflags\`
\& LIBS = \-lm \`uuid\-config \-\-libs\`
\&
\& all: foo
\& foo: foo.o
\& $(CC) $(LDFLAGS) \-o foo foo.o $(LIBS)
\& foo.o: foo.c
\& $(CC) $(CFLAGS) \-c foo.c
.Ve
.SH "SEE ALSO"
.IX Header "SEE ALSO"
\&\fIuuid\fR\|(3), \fIuuid\fR\|(1), \fIOSSP::uuid\fR\|(3).

View File

@ -1,145 +0,0 @@
#!/bin/sh
##
## OSSP uuid - Universally Unique Identifier
## Copyright (c) 2004-2008 Ralf S. Engelschall <rse@engelschall.com>
## Copyright (c) 2004-2008 The OSSP Project <http://www.ossp.org/>
##
## This file is part of OSSP uuid, a library for the generation
## of UUIDs which can found at http://www.ossp.org/pkg/lib/uuid/
##
## Permission to use, copy, modify, and distribute this software for
## any purpose with or without fee is hereby granted, provided that
## the above copyright notice and this permission notice appear in all
## copies.
##
## THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
## WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
## IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
## CONTRIBUTORS 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 ADVISED OF THE POSSIBILITY OF
## SUCH DAMAGE.
##
## uuid-config.in: library build utility
##
DIFS='
'
prefix="@prefix@"
exec_prefix="@exec_prefix@"
datarootdir="@datarootdir@"
uuid_prefix="$prefix"
uuid_exec_prefix="$exec_prefix"
uuid_bindir="@bindir@"
uuid_libdir="@libdir@"
uuid_includedir="@includedir@"
uuid_mandir="@mandir@"
uuid_datadir="@datadir@"
uuid_acdir="@datadir@/aclocal"
uuid_cflags="@CFLAGS@"
uuid_ldflags="@LDFLAGS@"
uuid_libs="@LIBS@"
uuid_version="@UUID_VERSION_STR@"
help=no
version=no
usage="uuid-config"
usage="$usage [--help] [--version] [--all]"
usage="$usage [--prefix] [--exec-prefix] [--bindir] [--libdir] [--includedir] [--mandir] [--datadir] [--acdir]"
usage="$usage [--cflags] [--ldflags] [--libs]"
if [ $# -eq 0 ]; then
echo "uuid-config:Error: Invalid option" 1>&2
echo "uuid-config:Usage: $usage" 1>&2
exit 1
fi
output=''
output_extra=''
all=no
prev=''
OIFS="$IFS" IFS="$DIFS"
for option
do
if [ ".$prev" != . ]; then
eval "$prev=\$option"
prev=''
continue
fi
case "$option" in
-*=*) optarg=`echo "$option" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
*) optarg='' ;;
esac
case "$option" in
--help|-h)
echo "Usage: $usage"
exit 0
;;
--version|-v)
echo "OSSP uuid $uuid_version"
exit 0
;;
--all)
all=yes
;;
--prefix)
output="$output $uuid_prefix"
;;
--exec-prefix)
output="$output $uuid_exec_prefix"
;;
--bindir)
output="$output $uuid_bindir"
;;
--libdir)
output="$output $uuid_libdir"
;;
--includedir)
output="$output $uuid_includedir"
;;
--mandir)
output="$output $uuid_mandir"
;;
--datadir)
output="$output $uuid_datadir"
;;
--acdir)
output="$output $uuid_acdir"
;;
--cflags)
output="$output -I$uuid_includedir"
output_extra="$output_extra $uuid_cflags"
;;
--ldflags)
output="$output -L$uuid_libdir"
output_extra="$output_extra $uuid_ldflags"
;;
--libs)
output="$output -luuid"
output_extra="$output_extra $uuid_libs"
;;
* )
echo "uuid-config:Error: Invalid option" 1>&2
echo "uuid-config:Usage: $usage" 1>&2
exit 1;
;;
esac
done
IFS="$OIFS"
if [ ".$prev" != . ]; then
echo "uuid-config:Error: missing argument to --`echo $prev | sed 's/_/-/g'`" 1>&2
exit 1
fi
if [ ".$output" != . ]; then
if [ ".$all" = .yes ]; then
output="$output $output_extra"
fi
echo $output
fi

View File

@ -1,155 +0,0 @@
#!/bin/sh
##
## OSSP uuid - Universally Unique Identifier
## Copyright (c) 2004-2008 Ralf S. Engelschall <rse@engelschall.com>
## Copyright (c) 2004-2008 The OSSP Project <http://www.ossp.org/>
##
## This file is part of OSSP uuid, a library for the generation
## of UUIDs which can found at http://www.ossp.org/pkg/lib/uuid/
##
## Permission to use, copy, modify, and distribute this software for
## any purpose with or without fee is hereby granted, provided that
## the above copyright notice and this permission notice appear in all
## copies.
##
## THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
## WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
## IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
## CONTRIBUTORS 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 ADVISED OF THE POSSIBILITY OF
## SUCH DAMAGE.
##
## uuid-config.pod: library build utility manpage
##
=pod
=head1 NAME
B<uuid-config> - B<OSSP uuid API build utility>
=head1 VERSION
OSSP uuid UUID_VERSION_STR
=head1 SYNOPSIS
B<uuid-config>
[B<--help>]
[B<--version>]
[B<--all>]
[B<--prefix>]
[B<--exec-prefix>]
[B<--bindir>]
[B<--libdir>]
[B<--includedir>]
[B<--mandir>]
[B<--datadir>]
[B<--acdir>]
[B<--cflags>]
[B<--ldflags>]
[B<--libs>]
=head1 DESCRIPTION
The B<uuid-config> program is a little helper utility for easy configuring and
building applications based on the uuid(3) library. It can be used to query the
C compiler and linker flags which are required to correctly compile and link
the application against the uuid(3) library.
=head1 OPTIONS
B<uuid-config> accepts the following options:
=over 2
=item B<--help>
Prints the short usage information.
=item B<--version>
Prints the version number and date of the installed uuid(3) library.
=item B<--all>
Forces the output of all flags, that is, including extra flags which are not
B<OSSP uuid> specific.
=item B<--prefix>
Prints the installation prefix of architecture independent files
=item B<--exec-prefix>
Prints the installation prefix of architecture dependent files.
=item B<--bindir>
Prints the installation directory of binaries.
=item B<--libdir>
Prints the installation directory of libraries.
=item B<--includedir>
Prints the installation directory of include headers.
=item B<--mandir>
Prints the installation directory of manual pages.
=item B<--datadir>
Prints the installation directory of shared data.
=item B<--acdir>
Prints the installation directory of B<autoconf> data.
=item B<--cflags>
Prints the C compiler flags which are needed to compile the uuid(3)-based
application. The output is usually added to the C<CFLAGS> uuidiable of the
applications C<Makefile>.
=item B<--ldflags>
Prints the linker flags (C<-L>) which are needed to link the application with
the uuid(3) library. The output is usually added to the C<LDFLAGS> uuidiable of
the applications C<Makefile>.
=item B<--libs>
Prints the library flags (C<-l>) which are needed to link the application with
the C uuid(3) library. The output is usually added to the C<LIBS> uuidiable of the
applications C<Makefile>.
=back
=head1 EXAMPLE
CC = cc
CFLAGS = -O `uuid-config --cflags`
LDFLAGS = `uuid-config --ldflags`
LIBS = -lm `uuid-config --libs`
all: foo
foo: foo.o
$(CC) $(LDFLAGS) -o foo foo.o $(LIBS)
foo.o: foo.c
$(CC) $(CFLAGS) -c foo.c
=head1 SEE ALSO
uuid(3), uuid(1), OSSP::uuid(3).
=cut

View File

@ -1,291 +0,0 @@
.\" Automatically generated by Pod::Man 2.16 (Pod::Simple 3.07)
.\"
.\" Standard preamble:
.\" ========================================================================
.de Sh \" Subsection heading
.br
.if t .Sp
.ne 5
.PP
\fB\\$1\fR
.PP
..
.de Sp \" Vertical space (when we can't use .PP)
.if t .sp .5v
.if n .sp
..
.de Vb \" Begin verbatim text
.ft CW
.nf
.ne \\$1
..
.de Ve \" End verbatim text
.ft R
.fi
..
.\" Set up some character translations and predefined strings. \*(-- will
.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
.\" double quote, and \*(R" will give a right double quote. \*(C+ will
.\" give a nicer C++. Capital omega is used to do unbreakable dashes and
.\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff,
.\" nothing in troff, for use with C<>.
.tr \(*W-
.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
.ie n \{\
. ds -- \(*W-
. ds PI pi
. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
. ds L" ""
. ds R" ""
. ds C`
. ds C'
'br\}
.el\{\
. ds -- \|\(em\|
. ds PI \(*p
. ds L" ``
. ds R" ''
'br\}
.\"
.\" Escape single quotes in literal strings from groff's Unicode transform.
.ie \n(.g .ds Aq \(aq
.el .ds Aq '
.\"
.\" If the F register is turned on, we'll generate index entries on stderr for
.\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index
.\" entries marked with X<> in POD. Of course, you'll have to process the
.\" output yourself in some meaningful fashion.
.ie \nF \{\
. de IX
. tm Index:\\$1\t\\n%\t"\\$2"
..
. nr % 0
. rr F
.\}
.el \{\
. de IX
..
.\}
.\"
.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
.\" Fear. Run. Save yourself. No user-serviceable parts.
. \" fudge factors for nroff and troff
.if n \{\
. ds #H 0
. ds #V .8m
. ds #F .3m
. ds #[ \f1
. ds #] \fP
.\}
.if t \{\
. ds #H ((1u-(\\\\n(.fu%2u))*.13m)
. ds #V .6m
. ds #F 0
. ds #[ \&
. ds #] \&
.\}
. \" simple accents for nroff and troff
.if n \{\
. ds ' \&
. ds ` \&
. ds ^ \&
. ds , \&
. ds ~ ~
. ds /
.\}
.if t \{\
. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
.\}
. \" troff and (daisy-wheel) nroff accents
.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
.ds 8 \h'\*(#H'\(*b\h'-\*(#H'
.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
.ds ae a\h'-(\w'a'u*4/10)'e
.ds Ae A\h'-(\w'A'u*4/10)'E
. \" corrections for vroff
.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
. \" for low resolution devices (crt and lpr)
.if \n(.H>23 .if \n(.V>19 \
\{\
. ds : e
. ds 8 ss
. ds o a
. ds d- d\h'-1'\(ga
. ds D- D\h'-1'\(hy
. ds th \o'bp'
. ds Th \o'LP'
. ds ae ae
. ds Ae AE
.\}
.rm #[ #] #H #V #F C
.\" ========================================================================
.\"
.IX Title "UUID 1"
.TH UUID 1 "OSSP uuid 1.6.2" "04-Jul-2008" "Universally Unique Identifier"
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.if n .ad l
.nh
.SH "NAME"
\&\fB\s-1OSSP\s0 uuid\fR \- \fBUniversally Unique Identifier Command-Line Tool\fR
.SH "VERSION"
.IX Header "VERSION"
\&\s-1OSSP\s0 uuid \s-11.6.2 (04-Jul-2008)\s0
.SH "SYNOPSIS"
.IX Header "SYNOPSIS"
\&\fBuuid\fR
[\fB\-v\fR \fIversion\fR]
[\fB\-m\fR]
[\fB\-n\fR \fIcount\fR]
[\fB\-1\fR]
[\fB\-F\fR \fIformat\fR]
[\fB\-o\fR \fIfilename\fR]
[\fInamespace\fR \fIname\fR]
.PP
\&\fBuuid\fR
\&\fB\-d\fR
[\fB\-r\fR]
[\fB\-o\fR \fIfilename\fR]
\&\fIuuid\fR
.SH "DESCRIPTION"
.IX Header "DESCRIPTION"
\&\fB\s-1OSSP\s0 uuid\fR is a \s-1ISO\-C:1999\s0 application programming interface (\s-1API\s0) and
corresponding command line interface (\s-1CLI\s0) for the generation of \s-1DCE\s0
1.1, \s-1ISO/IEC\s0 11578:1996 and \s-1IETF\s0 \s-1RFC\-4122\s0 compliant \fIUniversally Unique
Identifier\fR (\s-1UUID\s0). It supports \s-1DCE\s0 1.1 variant UUIDs of version 1 (time
and node based), version 3 (name based, \s-1MD5\s0), version 4 (random number
based) and version 5 (name based, \s-1SHA\-1\s0). Additional \s-1API\s0 bindings are
provided for the languages \s-1ISO\-\*(C+:1998\s0, Perl:5 and \s-1PHP:4/5\s0. Optional
backward compatibility exists for the ISO-C \s-1DCE\-1\s0.1 and Perl Data::UUID
APIs.
.PP
UUIDs are 128 bit numbers which are intended to have a high likelihood
of uniqueness over space and time and are computationally difficult
to guess. They are globally unique identifiers which can be locally
generated without contacting a global registration authority. UUIDs
are intended as unique identifiers for both mass tagging objects
with an extremely short lifetime and to reliably identifying very
persistent objects across a network.
.PP
This is the command line interface (\s-1CLI\s0) of \fB\s-1OSSP\s0 uuid\fR. For a
detailed description of UUIDs see the documentation of the application
programming interface (\s-1API\s0) in \fIuuid\fR\|(3).
.SH "OPTIONS"
.IX Header "OPTIONS"
.IP "\fB\-v\fR \fIversion\fR" 3
.IX Item "-v version"
Sets the version of the generated \s-1DCE\s0 1.1 variant \s-1UUID\s0. Supported
are \fIversion\fR "\f(CW1\fR\*(L", \*(R"\f(CW3\fR\*(L", \*(R"\f(CW4\fR\*(L" and \*(R"\f(CW5\fR\*(L". The default is \*(R"\f(CW1\fR".
.Sp
For version 3 and version 5 UUIDs the additional command line arguments
\&\fInamespace\fR and \fIname\fR have to be given. The \fInamespace\fR is either
a \s-1UUID\s0 in string representation or an identifier for internally
pre-defined namespace UUIDs (currently known are "\f(CW\*(C`ns:DNS\*(C'\fR\*(L",
\&\*(R"\f(CW\*(C`ns:URL\*(C'\fR\*(L", \*(R"\f(CW\*(C`ns:OID\*(C'\fR\*(L", and \*(R"\f(CW\*(C`ns:X500\*(C'\fR"). The \fIname\fR is a string of
arbitrary length.
.IP "\fB\-m\fR" 3
.IX Item "-m"
Forces the use of a random multi-cast \s-1MAC\s0 address when generating
version 1 UUIDs. By default the real physical \s-1MAC\s0 address of the system
is used.
.IP "\fB\-n\fR \fIcount\fR" 3
.IX Item "-n count"
Generate \fIcount\fR UUIDs instead of just a single one (the default).
.IP "\fB\-1\fR" 3
.IX Item "-1"
If option \fB\-n\fR is used with a \fIcount\fR greater than \f(CW1\fR, then this
option can enforce the reset the \s-1UUID\s0 context for each generated \s-1UUID\s0.
This makes no difference for \fIversion\fR \f(CW3\fR, \f(CW4\fR and \f(CW5\fR UUIDs. But
version \f(CW1\fR UUIDs are based on the previously generated \s-1UUID\s0 which is
remembered in the \s-1UUID\s0 context of the \s-1API\s0. Option \fB\-1\fR deletes the
remembered \s-1UUID\s0 on each iteration.
.IP "\fB\-F\fR \fIformat\fR" 3
.IX Item "-F format"
Representation format for importing or exporting an \s-1UUID\s0. The
following (case insensitive) format identifiers are currently recognized:
.RS 3
.ie n .IP "\*(C`BIN\*(C' (binary representation)" 4
.el .IP "\f(CW\*(C`BIN\*(C'\fR (binary representation)" 4
.IX Item "BIN (binary representation)"
This is the raw 128 bit network byte order binary representation of a
\&\s-1UUID\s0. Example is the octet stream \f(CW\*(C`0xF8 0x1D 0x4F 0xAE 0x7D 0xEC 0x11
0xD0 0xA7 0x65 0x00 0xA0 0xC9 0x1E 0x6B 0xF6\*(C'\fR.
.ie n .IP "\*(C`STR\*(C' (string representation)" 4
.el .IP "\f(CW\*(C`STR\*(C'\fR (string representation)" 4
.IX Item "STR (string representation)"
This is the 36 character hexadecimal \s-1ASCII\s0 string representation of a
\&\s-1UUID\s0. Example is the string "\f(CW\*(C`f81d4fae\-7dec\-11d0\-a765\-00a0c91e6bf6\*(C'\fR".
.ie n .IP "\*(C`SIV\*(C' (single integer value representation)" 4
.el .IP "\f(CW\*(C`SIV\*(C'\fR (single integer value representation)" 4
.IX Item "SIV (single integer value representation)"
This is the maximum 39 character long single integer
value representation of a \s-1UUID\s0. Example is the string
"\f(CW329800735698586629295641978511506172918\fR".
.RE
.RS 3
.RE
.IP "\fB\-o\fR \fIfilename\fR" 3
.IX Item "-o filename"
Write output to \fIfilename\fR instead of to \fIstdout\fR.
.IP "\fB\-d\fR" 3
.IX Item "-d"
Decode a given \s-1UUID\s0 (given as a command line argument or if the command
line argument is "\f(CW\*(C`\-\*(C'\fR" the \s-1UUID\s0 is read from \fIstdin\fR) and dump textual
information about the \s-1UUID\s0.
.SH "EXAMPLES"
.IX Header "EXAMPLES"
.Vb 3
\& # generate DCE 1.1 v1 UUID (time and node based)
\& $ uuid \-v1
\& 01c47915\-4777\-11d8\-bc70\-0090272ff725
\&
\& # decode and dump DCE 1.1 v1 UUID (time and node based)
\& $ uuid \-d 01c47915\-4777\-11d8\-bc70\-0090272ff725
\& encode: STR: 01c47915\-4777\-11d8\-bc70\-0090272ff725
\& SIV: 2349374037528578887923094374772111141
\& decode: variant: DCE 1.1, ISO/IEC 11578:1996
\& version: 1 (time and node based)
\& content: time: 2004\-01\-15 16:22:26.376322.1 UTC
\& clock: 15472 (usually random)
\& node: 00:90:27:2f:f7:25 (global unicast)
\&
\& # generate DCE 1.1 v3 UUID (name based)
\& $ uuid \-v3 ns:URL http://www.ossp.org/
\& 02d9e6d5\-9467\-382e\-8f9b\-9300a64ac3cd
\&
\& # decode and dump DCE 1.1 v3 UUID (name based)
\& $ uuid \-d 02d9e6d5\-9467\-382e\-8f9b\-9300a64ac3cd
\& encode: STR: 02d9e6d5\-9467\-382e\-8f9b\-9300a64ac3cd
\& SIV: 3789866285607910888100818383505376205
\& decode: variant: DCE 1.1, ISO/IEC 11578:1996
\& version: 3 (name based, MD5)
\& content: 02:D9:E6:D5:94:67:08:2E:0F:9B:93:00:A6:4A:C3:CD
\& (not decipherable: MD5 message digest only)
\&
\& # generate DCE 1.1 v4 UUID 4 (random data based)
\& $ uuid \-v4
\& eb424026\-6f54\-4ef8\-a4d0\-bb658a1fc6cf
\&
\& # decode and dump DCE 1.1 v4 UUID 4 (random data based)
\& $ uuid \-d eb424026\-6f54\-4ef8\-a4d0\-bb658a1fc6cf
\& encode: STR: eb424026\-6f54\-4ef8\-a4d0\-bb658a1fc6cf
\& SIV: 312712571721458096795100956955942831823
\& decode: variant: DCE 1.1, ISO/IEC 11578:1996
\& version: 4 (random data based)
\& content: EB:42:40:26:6F:54:0E:F8:24:D0:BB:65:8A:1F:C6:CF
\& (no semantics: random data only)
.Ve
.SH "SEE ALSO"
.IX Header "SEE ALSO"
\&\fIuuid\fR\|(3), \fIOSSP::uuid\fR\|(3).

View File

@ -1,578 +0,0 @@
.\" Automatically generated by Pod::Man 2.16 (Pod::Simple 3.07)
.\"
.\" Standard preamble:
.\" ========================================================================
.de Sh \" Subsection heading
.br
.if t .Sp
.ne 5
.PP
\fB\\$1\fR
.PP
..
.de Sp \" Vertical space (when we can't use .PP)
.if t .sp .5v
.if n .sp
..
.de Vb \" Begin verbatim text
.ft CW
.nf
.ne \\$1
..
.de Ve \" End verbatim text
.ft R
.fi
..
.\" Set up some character translations and predefined strings. \*(-- will
.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
.\" double quote, and \*(R" will give a right double quote. \*(C+ will
.\" give a nicer C++. Capital omega is used to do unbreakable dashes and
.\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff,
.\" nothing in troff, for use with C<>.
.tr \(*W-
.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
.ie n \{\
. ds -- \(*W-
. ds PI pi
. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
. ds L" ""
. ds R" ""
. ds C`
. ds C'
'br\}
.el\{\
. ds -- \|\(em\|
. ds PI \(*p
. ds L" ``
. ds R" ''
'br\}
.\"
.\" Escape single quotes in literal strings from groff's Unicode transform.
.ie \n(.g .ds Aq \(aq
.el .ds Aq '
.\"
.\" If the F register is turned on, we'll generate index entries on stderr for
.\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index
.\" entries marked with X<> in POD. Of course, you'll have to process the
.\" output yourself in some meaningful fashion.
.ie \nF \{\
. de IX
. tm Index:\\$1\t\\n%\t"\\$2"
..
. nr % 0
. rr F
.\}
.el \{\
. de IX
..
.\}
.\"
.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
.\" Fear. Run. Save yourself. No user-serviceable parts.
. \" fudge factors for nroff and troff
.if n \{\
. ds #H 0
. ds #V .8m
. ds #F .3m
. ds #[ \f1
. ds #] \fP
.\}
.if t \{\
. ds #H ((1u-(\\\\n(.fu%2u))*.13m)
. ds #V .6m
. ds #F 0
. ds #[ \&
. ds #] \&
.\}
. \" simple accents for nroff and troff
.if n \{\
. ds ' \&
. ds ` \&
. ds ^ \&
. ds , \&
. ds ~ ~
. ds /
.\}
.if t \{\
. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
.\}
. \" troff and (daisy-wheel) nroff accents
.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
.ds 8 \h'\*(#H'\(*b\h'-\*(#H'
.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
.ds ae a\h'-(\w'a'u*4/10)'e
.ds Ae A\h'-(\w'A'u*4/10)'E
. \" corrections for vroff
.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
. \" for low resolution devices (crt and lpr)
.if \n(.H>23 .if \n(.V>19 \
\{\
. ds : e
. ds 8 ss
. ds o a
. ds d- d\h'-1'\(ga
. ds D- D\h'-1'\(hy
. ds th \o'bp'
. ds Th \o'LP'
. ds ae ae
. ds Ae AE
.\}
.rm #[ #] #H #V #F C
.\" ========================================================================
.\"
.IX Title ".::uuid 3"
.TH .::uuid 3 "OSSP uuid 1.6.2" "04-Jul-2008" "Universally Unique Identifier"
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.if n .ad l
.nh
.SH "NAME"
\&\fB\s-1OSSP\s0 uuid\fR \- \fBUniversally Unique Identifier\fR
.SH "VERSION"
.IX Header "VERSION"
\&\s-1OSSP\s0 uuid \s-11.6.2 (04-Jul-2008)\s0
.SH "DESCRIPTION"
.IX Header "DESCRIPTION"
\&\fB\s-1OSSP\s0 uuid\fR is a \s-1ISO\-C:1999\s0 application programming interface (\s-1API\s0) and
corresponding command line interface (\s-1CLI\s0) for the generation of \s-1DCE\s0
1.1, \s-1ISO/IEC\s0 11578:1996 and \s-1IETF\s0 \s-1RFC\-4122\s0 compliant \fIUniversally Unique
Identifier\fR (\s-1UUID\s0). It supports \s-1DCE\s0 1.1 variant UUIDs of version 1 (time
and node based), version 3 (name based, \s-1MD5\s0), version 4 (random number
based) and version 5 (name based, \s-1SHA\-1\s0). Additional \s-1API\s0 bindings are
provided for the languages \s-1ISO\-\*(C+:1998\s0, Perl:5 and \s-1PHP:4/5\s0. Optional
backward compatibility exists for the ISO-C \s-1DCE\-1\s0.1 and Perl Data::UUID
APIs.
.PP
UUIDs are 128 bit numbers which are intended to have a high likelihood
of uniqueness over space and time and are computationally difficult
to guess. They are globally unique identifiers which can be locally
generated without contacting a global registration authority. UUIDs
are intended as unique identifiers for both mass tagging objects
with an extremely short lifetime and to reliably identifying very
persistent objects across a network.
.PP
This is the ISO-C application programming interface (\s-1API\s0) of \fB\s-1OSSP\s0 uuid\fR.
.Sh "\s-1UUID\s0 Binary Representation"
.IX Subsection "UUID Binary Representation"
According to the \s-1DCE\s0 1.1, \s-1ISO/IEC\s0 11578:1996 and \s-1IETF\s0 \s-1RFC\-4122\s0
standards, a \s-1DCE\s0 1.1 variant \s-1UUID\s0 is a 128 bit number defined out of 7
fields, each field a multiple of an octet in size and stored in network
byte order:
.PP
.Vb 11
\& [4]
\& version
\& \-\->| |<\-\-
\& | |
\& | | [16]
\& [32] [16] | |time_hi
\& time_low time_mid | _and_version
\& |<\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\->||<\-\-\-\-\-\-\-\-\-\-\-\->||<\-\-\-\-\-\-\-\-\-\-\-\->|
\& | MSB || || | |
\& | / || || | |
\& |/ || || | |
\&
\& +\-\-\-\-\-\-++\-\-\-\-\-\-++\-\-\-\-\-\-++\-\-\-\-\-\-++\-\-\-\-\-\-++\-\-\-\-\-\-++\-\-\-\-\-\-++\-\-\-\-\-\-+~~
\& | 15 || 14 || 13 || 12 || 11 || 10 |####9 || 8 |
\& | MSO || || || || || |#### || |
\& +\-\-\-\-\-\-++\-\-\-\-\-\-++\-\-\-\-\-\-++\-\-\-\-\-\-++\-\-\-\-\-\-++\-\-\-\-\-\-++\-\-\-\-\-\-++\-\-\-\-\-\-+~~
\& 7654321076543210765432107654321076543210765432107654321076543210
\&
\& ~~+\-\-\-\-\-\-++\-\-\-\-\-\-++\-\-\-\-\-\-++\-\-\-\-\-\-++\-\-\-\-\-\-++\-\-\-\-\-\-++\-\-\-\-\-\-++\-\-\-\-\-\-+
\& ##* 7 || 6 || 5 || 4 || 3 || 2 || 1 || 0 |
\& ##* || || || || || || || LSO |
\& ~~+\-\-\-\-\-\-++\-\-\-\-\-\-++\-\-\-\-\-\-++\-\-\-\-\-\-++\-\-\-\-\-\-++\-\-\-\-\-\-++\-\-\-\-\-\-++\-\-\-\-\-\-+
\& 7654321076543210765432107654321076543210765432107654321076543210
\&
\& | | || || /|
\& | | || || / |
\& | | || || LSB |
\& |<\-\-\-\->||<\-\-\-\->||<\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\->|
\& |clk_seq clk_seq node
\& |_hi_res _low [48]
\& |[5\-6] [8]
\& | |
\& \-\->| |<\-\-
\& variant
\& [2\-3]
.Ve
.PP
An example of a \s-1UUID\s0 binary representation is the octet stream \f(CW\*(C`0xF8
0x1D 0x4F 0xAE 0x7D 0xEC 0x11 0xD0 0xA7 0x65 0x00 0xA0 0xC9 0x1E 0x6B
0xF6\*(C'\fR. The binary representation format is exactly what the \fB\s-1OSSP\s0 uuid\fR
\&\s-1API\s0 functions \fBuuid_import\fR() and \fBuuid_export\fR() deal with under
\&\f(CW\*(C`UUID_FMT_BIN\*(C'\fR.
.Sh "\s-1UUID\s0 \s-1ASCII\s0 String Representation"
.IX Subsection "UUID ASCII String Representation"
According to the \s-1DCE\s0 1.1, \s-1ISO/IEC\s0 11578:1996 and \s-1IETF\s0 \s-1RFC\-4122\s0
standards, a \s-1DCE\s0 1.1 variant \s-1UUID\s0 is represented as an \s-1ASCII\s0 string
consisting of 8 hexadecimal digits followed by a hyphen, then three
groups of 4 hexadecimal digits each followed by a hyphen, then 12
hexadecimal digits. Formally, the string representation is defined by
the following grammar:
.PP
.Vb 10
\& uuid = <time_low> "\-"
\& <time_mid> "\-"
\& <time_high_and_version> "\-"
\& <clock_seq_high_and_reserved>
\& <clock_seq_low> "\-"
\& <node>
\& time_low = 4*<hex_octet>
\& time_mid = 2*<hex_octet>
\& time_high_and_version = 2*<hex_octet>
\& clock_seq_high_and_reserved = <hex_octet>
\& clock_seq_low = <hex_octet>
\& node = 6*<hex_octet>
\& hex_octet = <hex_digit> <hex_digit>
\& hex_digit = "0"|"1"|"2"|"3"|"4"|"5"|"6"|"7"|"8"|"9"
\& |"a"|"b"|"c"|"d"|"e"|"f"
\& |"A"|"B"|"C"|"D"|"E"|"F"
.Ve
.PP
An example of a \s-1UUID\s0 string representation is the \s-1ASCII\s0 string
"\f(CW\*(C`f81d4fae\-7dec\-11d0\-a765\-00a0c91e6bf6\*(C'\fR". The string representation
format is exactly what the \fB\s-1OSSP\s0 uuid\fR \s-1API\s0 functions \fBuuid_import\fR()
and \fBuuid_export\fR() deal with under \f(CW\*(C`UUID_FMT_STR\*(C'\fR.
.PP
Notice: a corresponding \s-1URL\s0 can be generated out of a \s-1ASCII\s0 string
representation of an \s-1UUID\s0 by prefixing with "\f(CW\*(C`urn:uuid:\*(C'\fR\*(L" as in
\&\*(R"\f(CW\*(C`urn:uuid:f81d4fae\-7dec\-11d0\-a765\-00a0c91e6bf6\*(C'\fR".
.Sh "\s-1UUID\s0 Single Integer Value Representation"
.IX Subsection "UUID Single Integer Value Representation"
According to the \s-1ISO/IEC\s0 11578:1996 and ITU-T Rec. X.667 standards, a
\&\s-1DCE\s0 1.1 variant \s-1UUID\s0 can be also represented as a single integer value
consisting of a decimal number with up to 39 digits.
.PP
An example of a \s-1UUID\s0 single integer value representation is the decimal
number "\f(CW329800735698586629295641978511506172918\fR". The string
representation format is exactly what the \fB\s-1OSSP\s0 uuid\fR \s-1API\s0 functions
\&\fBuuid_import\fR() and \fBuuid_export\fR() deal with under \f(CW\*(C`UUID_FMT_SIV\*(C'\fR.
.PP
Notice: a corresponding \s-1ISO\s0 \s-1OID\s0 can be generated under the
\&\*(L"{\fIjoint\-iso\-itu\-t\fR\|(2) uuid(25)}\*(R" arc out of a single integer value
representation of a \s-1UUID\s0 by prefixing with "\f(CW2.25.\fR\*(L". An example \s-1OID\s0
is \*(R"\f(CW2.25.329800735698586629295641978511506172918\fR\*(L". Additionally,
an \s-1URL\s0 can be generated by further prefixing with \*(R"\f(CW\*(C`urn:oid:\*(C'\fR\*(L" as in
\&\*(R"\f(CW\*(C`urn:oid:2.25.329800735698586629295641978511506172918\*(C'\fR".
.Sh "\s-1UUID\s0 Variants and Versions"
.IX Subsection "UUID Variants and Versions"
A \s-1UUID\s0 has a variant and version. The variant defines the layout of the
\&\s-1UUID\s0. The version defines the content of the \s-1UUID\s0. The \s-1UUID\s0 variant
supported in \fB\s-1OSSP\s0 uuid\fR is the \s-1DCE\s0 1.1 variant only. The \s-1DCE\s0 1.1 \s-1UUID\s0
variant versions supported in \fB\s-1OSSP\s0 uuid\fR are:
.IP "\fBVersion 1\fR (time and node based)" 4
.IX Item "Version 1 (time and node based)"
These are the classical UUIDs, created out of a 60\-bit system time,
a 14\-bit local clock sequence and 48\-bit system \s-1MAC\s0 address. The \s-1MAC\s0
address can be either the real one of a physical network interface card
(\s-1NIC\s0) or a random multi-cast \s-1MAC\s0 address. Version 1 UUIDs are usually
used as one-time global unique identifiers.
.IP "\fBVersion 3\fR (name based, \s-1MD5\s0)" 4
.IX Item "Version 3 (name based, MD5)"
These are UUIDs which are based on the 128\-bit \s-1MD5\s0 message digest of the
concatenation of a 128\-bit namespace \s-1UUID\s0 and a name string of arbitrary
length. Version 3 UUIDs are usually used for non-unique but repeatable
message digest identifiers.
.IP "\fBVersion 4\fR (random data based)" 4
.IX Item "Version 4 (random data based)"
These are UUIDs which are based on just 128\-bit of random data. Version
4 UUIDs are usually used as one-time local unique identifiers.
.IP "\fBVersion 5\fR (name based, \s-1SHA\-1\s0)" 4
.IX Item "Version 5 (name based, SHA-1)"
These are UUIDs which are based on the 160\-bit \s-1SHA\-1\s0 message digest of the
concatenation of a 128\-bit namespace \s-1UUID\s0 and a name string of arbitrary
length. Version 5 UUIDs are usually used for non-unique but repeatable
message digest identifiers.
.Sh "\s-1UUID\s0 Uniqueness"
.IX Subsection "UUID Uniqueness"
Version 1 UUIDs are guaranteed to be unique through combinations of
hardware addresses, time stamps and random seeds. There is a reference
in the \s-1UUID\s0 to the hardware (\s-1MAC\s0) address of the first network interface
card (\s-1NIC\s0) on the host which generated the \s-1UUID\s0 \*(-- this reference
is intended to ensure the \s-1UUID\s0 will be unique in space as the \s-1MAC\s0
address of every network card is assigned by a single global authority
(\s-1IEEE\s0) and is guaranteed to be unique. The next component in a \s-1UUID\s0
is a timestamp which, as clock always (should) move forward, will
be unique in time. Just in case some part of the above goes wrong
(the hardware address cannot be determined or the clock moved steps
backward), there is a random clock sequence component placed into the
\&\s-1UUID\s0 as a \*(L"catch-all\*(R" for uniqueness.
.PP
Version 3 and version 5 UUIDs are guaranteed to be inherently globally
unique if the combination of namespace and name used to generate them is
unique.
.PP
Version 4 UUIDs are not guaranteed to be globally unique, because they
are generated out of locally gathered pseudo-random numbers only.
Nevertheless there is still a high likelihood of uniqueness over space
and time and that they are computationally difficult to guess.
.Sh "Nil \s-1UUID\s0"
.IX Subsection "Nil UUID"
There is a special \fINil\fR \s-1UUID\s0 consisting of all octets set to zero in
the binary representation. It can be used as a special \s-1UUID\s0 value which does
not conflict with real UUIDs.
.SH "APPLICATION PROGRAMMING INTERFACE"
.IX Header "APPLICATION PROGRAMMING INTERFACE"
The ISO-C Application Programming Interface (\s-1API\s0) of \fB\s-1OSSP\s0 uuid\fR
consists of the following components.
.Sh "\s-1CONSTANTS\s0"
.IX Subsection "CONSTANTS"
The following constants are provided:
.IP "\fB\s-1UUID_VERSION\s0\fR" 4
.IX Item "UUID_VERSION"
The hexadecimal encoded \fB\s-1OSSP\s0 uuid\fR version. This allows compile-time
checking of the \fB\s-1OSSP\s0 uuid\fR version. For run-time checking use
\&\fBuuid_version\fR() instead.
.Sp
The hexadecimal encoding for a version "$\fIv\fR.$\fIr\fR$\fIt\fR$\fIl\fR" is
calculated with the \fB\s-1GNU\s0 shtool\fR \fBversion\fR command and is (in
Perl-style for concise description) "sprintf('0x%x%02x%d%02x', $\fIv\fR,
$\fIr\fR, {qw(s 9 . 2 b 1 a 0)}\->{$\fIt\fR}, ($\fIt\fR eq 's' ? 99 : $\fIl\fR))\*(L",
i.e., the version 0.9.6 is encoded as \*(R"0x009206".
.IP "\fB\s-1UUID_LEN_BIN\s0\fR, \fB\s-1UUID_LEN_STR\s0\fR, \fB\s-1UUID_LEN_SIV\s0\fR" 4
.IX Item "UUID_LEN_BIN, UUID_LEN_STR, UUID_LEN_SIV"
The number of octets of the \s-1UUID\s0 binary and string representations.
Notice that the lengths of the string representation (\fB\s-1UUID_LEN_STR\s0\fR)
and the lengths of the single integer value representation
(\fB\s-1UUID_LEN_SIV\s0\fR) does \fInot\fR include the necessary \f(CW\*(C`NUL\*(C'\fR termination
character.
.IP "\fB\s-1UUID_MAKE_V1\s0\fR, \fB\s-1UUID_MAKE_V3\s0\fR, \fB\s-1UUID_MAKE_V4\s0\fR, \fB\s-1UUID_MAKE_V5\s0\fR, \fB\s-1UUID_MAKE_MC\s0\fR" 4
.IX Item "UUID_MAKE_V1, UUID_MAKE_V3, UUID_MAKE_V4, UUID_MAKE_V5, UUID_MAKE_MC"
The \fImode\fR bits for use with \fBuuid_make\fR(). The \fB\s-1UUID_MAKE_V\s0\fR\fIN\fR
specify which \s-1UUID\s0 version to generate. The \fB\s-1UUID_MAKE_MC\s0\fR forces the
use of a random multi-cast \s-1MAC\s0 address instead of the real physical \s-1MAC\s0
address in version 1 UUIDs.
.IP "\fB\s-1UUID_RC_OK\s0\fR, \fB\s-1UUID_RC_ARG\s0\fR, \fB\s-1UUID_RC_MEM\s0\fR, \fB\s-1UUID_RC_SYS\s0\fR, \fB\s-1UUID_RC_INT\s0\fR, \fB\s-1UUID_RC_IMP\s0\fR" 4
.IX Item "UUID_RC_OK, UUID_RC_ARG, UUID_RC_MEM, UUID_RC_SYS, UUID_RC_INT, UUID_RC_IMP"
The possible numerical return-codes of \s-1API\s0 functions.
The \f(CW\*(C`UUID_RC_OK\*(C'\fR indicates success, the others indicate errors.
Use \fBuuid_error\fR() to translate them into string versions.
.IP "\fB\s-1UUID_FMT_BIN\s0\fR, \fB\s-1UUID_FMT_STR\s0\fR, \fB\s-1UUID_FMT_SIV\s0\fR, \fB\s-1UUID_FMT_TXT\s0\fR" 4
.IX Item "UUID_FMT_BIN, UUID_FMT_STR, UUID_FMT_SIV, UUID_FMT_TXT"
The \fIfmt\fR formats for use with \fBuuid_import\fR() and \fBuuid_export\fR().
The \fB\s-1UUID_FMT_BIN\s0\fR indicates the \s-1UUID\s0 binary representation (of
length \fB\s-1UUID_LEN_BIN\s0\fR), the \fB\s-1UUID_FMT_STR\s0\fR indicates the \s-1UUID\s0 string
representation (of length \fB\s-1UUID_LEN_STR\s0\fR), the \fB\s-1UUID_FMT_SIV\s0\fR
indicates the \s-1UUID\s0 single integer value representation (of maximum
length \fB\s-1UUID_LEN_SIV\s0\fR) and the \fB\s-1UUID_FMT_TXT\s0\fR indicates the textual
description (of arbitrary length) of a \s-1UUID\s0.
.Sh "\s-1FUNCTIONS\s0"
.IX Subsection "FUNCTIONS"
The following functions are provided:
.IP "uuid_rc_t \fBuuid_create\fR(uuid_t **\fIuuid\fR);" 4
.IX Item "uuid_rc_t uuid_create(uuid_t **uuid);"
Create a new \s-1UUID\s0 object and store a pointer to it in \f(CW\*(C`*\*(C'\fR\fIuuid\fR.
A \s-1UUID\s0 object consists of an internal representation of a \s-1UUID\s0, the
internal \s-1PRNG\s0 and \s-1MD5\s0 generator contexts, and cached \s-1MAC\s0 address and
timestamp information. The initial \s-1UUID\s0 is the \fINil\fR \s-1UUID\s0.
.IP "uuid_rc_t \fBuuid_destroy\fR(uuid_t *\fIuuid\fR);" 4
.IX Item "uuid_rc_t uuid_destroy(uuid_t *uuid);"
Destroy \s-1UUID\s0 object \fIuuid\fR.
.IP "uuid_rc_t \fBuuid_clone\fR(const uuid_t *\fIuuid\fR, uuid_t **\fIuuid_clone\fR);" 4
.IX Item "uuid_rc_t uuid_clone(const uuid_t *uuid, uuid_t **uuid_clone);"
Clone \s-1UUID\s0 object \fIuuid\fR and store new \s-1UUID\s0 object in \fIuuid_clone\fR.
.IP "uuid_rc_t \fBuuid_isnil\fR(const uuid_t *\fIuuid\fR, int *\fIresult\fR);" 4
.IX Item "uuid_rc_t uuid_isnil(const uuid_t *uuid, int *result);"
Checks whether the \s-1UUID\s0 in \fIuuid\fR is the \fINil\fR \s-1UUID\s0.
If this is the case, it returns \fItrue\fR in \f(CW\*(C`*\*(C'\fR\fIresult\fR.
Else it returns \fIfalse\fR in \f(CW\*(C`*\*(C'\fR\fIresult\fR.
.IP "uuid_rc_t \fBuuid_compare\fR(const uuid_t *\fIuuid\fR, const uuid_t *\fIuuid2\fR, int *\fIresult\fR);" 4
.IX Item "uuid_rc_t uuid_compare(const uuid_t *uuid, const uuid_t *uuid2, int *result);"
Compares the order of the two UUIDs in \fIuuid1\fR and \fIuuid2\fR
and returns the result in \f(CW\*(C`*\*(C'\fR\fIresult\fR: \f(CW\*(C`\-1\*(C'\fR if \fIuuid1\fR is
smaller than \fIuuid2\fR, \f(CW0\fR if \fIuuid1\fR is equal to \fIuuid2\fR
and \f(CW+1\fR if \fIuuid1\fR is greater than \fIuuid2\fR.
.IP "uuid_rc_t \fBuuid_import\fR(uuid_t *\fIuuid\fR, uuid_fmt_t \fIfmt\fR, const void *\fIdata_ptr\fR, size_t \fIdata_len\fR);" 4
.IX Item "uuid_rc_t uuid_import(uuid_t *uuid, uuid_fmt_t fmt, const void *data_ptr, size_t data_len);"
Imports a \s-1UUID\s0 \fIuuid\fR from an external representation of format \fIfmt\fR.
The data is read from the buffer at \fIdata_ptr\fR which contains at least
\&\fIdata_len\fR bytes.
.Sp
The format of the external representation is specified by \fIfmt\fR and the
minimum expected length in \fIdata_len\fR depends on it. Valid values for
\&\fIfmt\fR are \fB\s-1UUID_FMT_BIN\s0\fR, \fB\s-1UUID_FMT_STR\s0\fR and \fB\s-1UUID_FMT_SIV\s0\fR.
.IP "uuid_rc_t \fBuuid_export\fR(const uuid_t *\fIuuid\fR, uuid_fmt_t \fIfmt\fR, void *\fIdata_ptr\fR, size_t *\fIdata_len\fR);" 4
.IX Item "uuid_rc_t uuid_export(const uuid_t *uuid, uuid_fmt_t fmt, void *data_ptr, size_t *data_len);"
Exports a \s-1UUID\s0 \fIuuid\fR into an external representation of format
\&\fIfmt\fR. Valid values for \fIfmt\fR are \fB\s-1UUID_FMT_BIN\s0\fR, \fB\s-1UUID_FMT_STR\s0\fR,
\&\fB\s-1UUID_FMT_SIV\s0\fR and \fB\s-1UUID_FMT_TXT\s0\fR.
.Sp
The data is written to the buffer whose location is obtained
by dereferencing \fIdata_ptr\fR after a \*(L"cast\*(R" to the appropriate
pointer-to-pointer type. Hence the generic pointer argument \fIdata_ptr\fR
is expected to be a pointer to a \*(L"pointer of a particular type\*(R", i.e.,
it has to be of type "\f(CW\*(C`unsigned char **\*(C'\fR" for \fB\s-1UUID_FMT_BIN\s0\fR and
"\f(CW\*(C`char **\*(C'\fR" for \fB\s-1UUID_FMT_STR\s0\fR, \fB\s-1UUID_FMT_SIV\s0\fR and \fB\s-1UUID_FMT_TXT\s0\fR.
.Sp
The buffer has to be room for at least \f(CW\*(C`*\*(C'\fR\fIdata_len\fR bytes. If the
value of the pointer after \*(L"casting\*(R" and dereferencing \fIdata_ptr\fR
is \f(CW\*(C`NULL\*(C'\fR, \fIdata_len\fR is ignored as input and a new buffer is
allocated and returned in the pointer after \*(L"casting\*(R" and dereferencing
\&\fIdata_ptr\fR (the caller has to \fIfree\fR\|(3) it later on).
.Sp
If \fIdata_len\fR is not \f(CW\*(C`NULL\*(C'\fR, the number of available bytes in the
buffer has to be provided in \f(CW\*(C`*\*(C'\fR\fIdata_len\fR and the number of actually
written bytes are returned in \f(CW\*(C`*\*(C'\fR\fIdata_len\fR again. The minimum
required buffer length depends on the external representation as
specified by \fIfmt\fR and is at least \fB\s-1UUID_LEN_BIN\s0\fR for \fB\s-1UUID_FMT_BIN\s0\fR,
\&\fB\s-1UUID_LEN_STR\s0\fR for \fB\s-1UUID_FMT_STR\s0\fR and \fB\s-1UUID_LEN_SIV\s0\fR for
\&\fB\s-1UUID_FMT_SIV\s0\fR. For \fB\s-1UUID_FMT_TXT\s0\fR a buffer of unspecified length is
required and hence it is recommended to allow \fB\s-1OSSP\s0 uuid\fR to allocate
the buffer as necessary.
.IP "uuid_rc_t \fBuuid_load\fR(uuid_t *\fIuuid\fR, const char *\fIname\fR);" 4
.IX Item "uuid_rc_t uuid_load(uuid_t *uuid, const char *name);"
Loads a pre-defined \s-1UUID\s0 value into the \s-1UUID\s0 object \fIuuid\fR. The
following \fIname\fR arguments are currently known:
.RS 4
.IP "\fIname\fR \fI\s-1UUID\s0\fR" 4
.IX Item "name UUID"
.PD 0
.IP "nil 00000000\-0000\-0000\-0000\-000000000000" 4
.IX Item "nil 00000000-0000-0000-0000-000000000000"
.IP "ns:DNS 6ba7b810\-9dad\-11d1\-80b4\-00c04fd430c8" 4
.IX Item "ns:DNS 6ba7b810-9dad-11d1-80b4-00c04fd430c8"
.IP "ns:URL 6ba7b811\-9dad\-11d1\-80b4\-00c04fd430c8" 4
.IX Item "ns:URL 6ba7b811-9dad-11d1-80b4-00c04fd430c8"
.IP "ns:OID 6ba7b812\-9dad\-11d1\-80b4\-00c04fd430c8" 4
.IX Item "ns:OID 6ba7b812-9dad-11d1-80b4-00c04fd430c8"
.IP "ns:X500 6ba7b814\-9dad\-11d1\-80b4\-00c04fd430c8" 4
.IX Item "ns:X500 6ba7b814-9dad-11d1-80b4-00c04fd430c8"
.RE
.RS 4
.PD
.Sp
The "\f(CW\*(C`ns:\*(C'\fR\fI\s-1XXX\s0\fR" are names of pre-defined name-space UUIDs for use in
the generation of \s-1DCE\s0 1.1 version 3 and version 5 UUIDs.
.RE
.IP "uuid_rc_t \fBuuid_make\fR(uuid_t *\fIuuid\fR, unsigned int \fImode\fR, ...);" 4
.IX Item "uuid_rc_t uuid_make(uuid_t *uuid, unsigned int mode, ...);"
Generates a new \s-1UUID\s0 in \fIuuid\fR according to \fImode\fR and optional
arguments (dependent on \fImode\fR).
.Sp
If \fImode\fR contains the \f(CW\*(C`UUID_MAKE_V1\*(C'\fR bit, a \s-1DCE\s0 1.1 variant \s-1UUID\s0 of
version 1 is generated. Then optionally the bit \f(CW\*(C`UUID_MAKE_MC\*(C'\fR forces
the use of random multi-cast \s-1MAC\s0 address instead of the real physical
\&\s-1MAC\s0 address (the default). The \s-1UUID\s0 is generated out of the 60\-bit current
system time, a 12\-bit clock sequence and the 48\-bit \s-1MAC\s0 address.
.Sp
If \fImode\fR contains the \f(CW\*(C`UUID_MAKE_V3\*(C'\fR or \f(CW\*(C`UUID_MAKE_V5\*(C'\fR bit, a \s-1DCE\s0
1.1 variant \s-1UUID\s0 of version 3 or 5 is generated and two additional
arguments are expected: first, a namespace \s-1UUID\s0 object (\f(CW\*(C`uuid_t *\*(C'\fR).
Second, a name string of arbitrary length (\f(CW\*(C`const char *\*(C'\fR). The \s-1UUID\s0 is
generated out of the 128\-bit \s-1MD5\s0 or 160\-bit \s-1SHA\-1\s0 from the concatenated
octet stream of namespace \s-1UUID\s0 and name string.
.Sp
If \fImode\fR contains the \f(CW\*(C`UUID_MAKE_V4\*(C'\fR bit, a \s-1DCE\s0 1.1 variant \s-1UUID\s0
of version 4 is generated. The \s-1UUID\s0 is generated out of 128\-bit random
data.
.IP "char *\fBuuid_error\fR(uuid_rc_t \fIrc\fR);" 4
.IX Item "char *uuid_error(uuid_rc_t rc);"
Returns a constant string representation corresponding to the
return-code \fIrc\fR for use in displaying \fB\s-1OSSP\s0 uuid\fR errors.
.IP "unsigned long \fBuuid_version\fR(void);" 4
.IX Item "unsigned long uuid_version(void);"
Returns the hexadecimal encoded \fB\s-1OSSP\s0 uuid\fR version as compiled into
the library object files. This allows run-time checking of the \fB\s-1OSSP\s0
uuid\fR version. For compile-time checking use \f(CW\*(C`UUID_VERSION\*(C'\fR instead.
.SH "EXAMPLE"
.IX Header "EXAMPLE"
The following shows an example usage of the \s-1API\s0. Error handling is
omitted for code simplification and has to be re-added for production
code.
.PP
.Vb 5
\& /* generate a DCE 1.1 v1 UUID from system environment */
\& char *uuid_v1(void)
\& {
\& uuid_t *uuid;
\& char *str;
\&
\& uuid_create(&uuid);
\& uuid_make(uuid, UUID_MAKE_V1);
\& str = NULL;
\& uuid_export(uuid, UUID_FMT_STR, &str, NULL);
\& uuid_destroy(uuid);
\& return str;
\& }
\&
\& /* generate a DCE 1.1 v3 UUID from an URL */
\& char *uuid_v3(const char *url)
\& {
\& uuid_t *uuid;
\& uuid_t *uuid_ns;
\& char *str;
\&
\& uuid_create(&uuid);
\& uuid_create(&uuid_ns);
\& uuid_load(uuid_ns, "ns:URL");
\& uuid_make(uuid, UUID_MAKE_V3, uuid_ns, url);
\& str = NULL;
\& uuid_export(uuid, UUID_FMT_STR, &str, NULL);
\& uuid_destroy(uuid_ns);
\& uuid_destroy(uuid);
\& return str;
\& }
.Ve
.SH "SEE ALSO"
.IX Header "SEE ALSO"
The following are references to \fB\s-1UUID\s0\fR documentation and specifications:
.IP "\(bu" 4
\&\fBA Universally Unique IDentifier (\s-1UUID\s0) \s-1URN\s0 Namespace\fR,
P. Leach, M. Mealling, R. Salz,
\&\s-1IETF\s0 \s-1RFC\-4122\s0,
July 2005, 32 pages,
http://www.ietf.org/rfc/rfc4122.txt
.IP "\(bu" 4
Information Technology \*(-- Open Systems Interconnection (\s-1OSI\s0),
\&\fBProcedures for the operation of \s-1OSI\s0 Registration Authorities:
Generation and Registration of Universally Unique Identifiers (UUIDs)
and their Use as \s-1ASN\s0.1 Object Identifier Components\fR,
\&\s-1ISO/IEC\s0 9834\-8:2004 / ITU-T Rec. X.667, 2004,
December 2004, 25 pages,
http://www.itu.int/ITU\-T/studygroups/com17/oid/X.667\-E.pdf
.IP "\(bu" 4
\&\fB\s-1DCE\s0 1.1: Remote Procedure Call\fR,
appendix \fBUniversally Unique Identifier\fR,
Open Group Technical Standard
Document Number C706, August 1997, 737 pages,
(supersedes C309 \s-1DCE:\s0 Remote Procedure Call 8/1994,
which was basis for \s-1ISO/IEC\s0 11578:1996 specification),
http://www.opengroup.org/publications/catalog/c706.htm
.IP "\(bu" 4
Information technology \*(-- Open Systems Interconnection (\s-1OSI\s0),
\&\fBRemote Procedure Call (\s-1RPC\s0)\fR,
\&\s-1ISO/IEC\s0 11578:1996,
August 2001, 570 pages, (\s-1CHF\s0 340,00),
http://www.iso.ch/cate/d2229.html
.IP "\(bu" 4
\&\fB\s-1HTTP\s0 Extensions for Distributed Authoring (WebDAV)\fR,
section \fB6.4.1 Node Field Generation Without the \s-1IEEE\s0 802 Address\fR,
\&\s-1IETF\s0 \s-1RFC\-2518\s0,
February 1999, 94 pages,
http://www.ietf.org/rfc/rfc2518.txt
.IP "\(bu" 4
\&\fB\s-1DCE\s0 1.1 compliant \s-1UUID\s0 functions\fR,
FreeBSD manual pages \fIuuid\fR\|(3) and \fIuuidgen\fR\|(2),
http://www.freebsd.org/cgi/man.cgi?query=uuid&manpath=FreeBSD+6.0\-RELEASE
.SH "HISTORY"
.IX Header "HISTORY"
\&\fB\s-1OSSP\s0 uuid\fR was implemented in January 2004 by Ralf S. Engelschall
<rse@engelschall.com>. It was prompted by the use of UUIDs
in the \fB\s-1OSSP\s0 as\fR and \fBOpenPKG\fR projects. It is a clean room
implementation intended to be strictly standards compliant and maximum
portable.
.SH "SEE ALSO"
.IX Header "SEE ALSO"
\&\fIuuid\fR\|(1), \fIuuid\-config\fR\|(1), \fIOSSP::uuid\fR\|(3).

View File

@ -1,206 +0,0 @@
dnl ##
dnl ## OSSP uuid - Universally Unique Identifier
dnl ## Copyright (c) 2004-2008 Ralf S. Engelschall <rse@engelschall.com>
dnl ## Copyright (c) 2004-2008 The OSSP Project <http://www.ossp.org/>
dnl ##
dnl ## This file is part of OSSP uuid, a library for the generation
dnl ## of UUIDs which can found at http://www.ossp.org/pkg/lib/uuid/
dnl ##
dnl ## Permission to use, copy, modify, and distribute this software for
dnl ## any purpose with or without fee is hereby granted, provided that
dnl ## the above copyright notice and this permission notice appear in all
dnl ## copies.
dnl ##
dnl ## THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
dnl ## WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
dnl ## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
dnl ## IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
dnl ## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
dnl ## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
dnl ## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
dnl ## USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
dnl ## ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
dnl ## OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
dnl ## OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
dnl ## SUCH DAMAGE.
dnl ##
dnl ## uuid.ac: UUID specific Autoconf checks
dnl ##
dnl # Check for anything OSSP uuid wants to know
dnl # configure.in:
dnl # UUID_CHECK_ALL
AC_DEFUN([UUID_CHECK_ALL],[
dnl # make sure libnsl and libsocket are linked in if they exist
AC_CHECK_LIB(nsl, gethostname)
if test ".`echo $LIBS | grep nsl`" = .; then
AC_CHECK_LIB(nsl, gethostbyname)
fi
AC_CHECK_LIB(socket, accept)
dnl # check for portable va_copy()
AC_CHECK_VA_COPY()
dnl # check for system headers
AC_CHECK_HEADERS(sys/types.h sys/param.h sys/time.h sys/socket.h sys/sockio.h sys/ioctl.h sys/select.h)
AC_CHECK_HEADERS(netdb.h ifaddrs.h net/if.h net/if_dl.h net/if_arp.h netinet/in.h arpa/inet.h,,,
[[
#if HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#if HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
#if HAVE_SYS_IOCTL_H
#include <sys/ioctl.h>
#endif
]])
dnl # check for existence of particular C structures
AC_MSG_CHECKING(for struct timeval)
AC_TRY_COMPILE([
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#endif
#include <time.h>
],[ struct timeval tv; ],
[ msg="yes" ], [ msg="no" ])
if test ".$msg" = .yes; then
AC_DEFINE(HAVE_STRUCT_TIMEVAL, 1, [define if exists "struct timeval"])
fi
AC_MSG_RESULT([$msg])
dnl # check for functions
AC_CHECK_FUNCS(getifaddrs nanosleep Sleep gettimeofday clock_gettime)
dnl # check size of built-in types
AC_CHECK_TYPES([long long, long double])
AC_CHECK_SIZEOF(char, 1)
AC_CHECK_SIZEOF(unsigned char, 1)
AC_CHECK_SIZEOF(short, 2)
AC_CHECK_SIZEOF(unsigned short, 2)
AC_CHECK_SIZEOF(int, 4)
AC_CHECK_SIZEOF(unsigned int, 4)
AC_CHECK_SIZEOF(long, 4)
AC_CHECK_SIZEOF(unsigned long, 4)
AC_CHECK_SIZEOF(long long, 8)
AC_CHECK_SIZEOF(unsigned long long, 8)
dnl # configure option --with-dce
AC_ARG_WITH([dce],
AC_HELP_STRING([--with-dce], [build DCE 1.1 backward compatibility API]),
[ac_cv_with_dce=$withval], [ac_cv_with_dce=no])
AC_CACHE_CHECK([whether to build DCE 1.1 backward compatibility API], [ac_cv_with_dce], [ac_cv_with_dce=no])
if test ".$ac_cv_with_dce" = ".yes"; then
AC_DEFINE(WITH_DCE, 1, [whether to build DCE 1.1 backward compatibility API])
WITH_DCE='yes'
DCE_NAME='$(DCE_NAME)'
else
WITH_DCE='no'
DCE_NAME=''
fi
AC_SUBST(WITH_DCE)
AC_SUBST(DCE_NAME)
dnl # configure option --with-cxx
AC_ARG_WITH([cxx],
AS_HELP_STRING([--with-cxx], [build C++ bindings to C API]),
[ac_cv_with_cxx=$withval], [ac_cv_with_cxx=no])
AC_CACHE_CHECK([whether to build C++ bindings to C API], [ac_cv_with_cxx], [ac_cv_with_cxx=no])
if test ".$ac_cv_with_cxx" = ".yes"; then
AC_DEFINE(WITH_CXX, 1, [whether to build C++ bindings to C API])
WITH_CXX='yes'
CXX_NAME='$(CXX_NAME)'
AC_PROG_CXX
else
WITH_CXX='no'
CXX_NAME=''
fi
AC_SUBST(CXX_NAME)
AC_SUBST(WITH_CXX)
dnl # configure option --with-perl
AC_ARG_WITH([perl],
AS_HELP_STRING([--with-perl], [build Perl bindings to C API]),
[ac_cv_with_perl=$withval], [ac_cv_with_perl=no])
AC_CACHE_CHECK([whether to build Perl bindings to C API], [ac_cv_with_perl], [ac_cv_with_perl=no])
AC_ARG_WITH([perl-compat],
AS_HELP_STRING([--with-perl-compat], [build Perl compatibility API]),
[ac_cv_with_perl_compat=$withval], [ac_cv_with_perl_compat=no])
AC_CACHE_CHECK([whether to build Perl compatibility API], [ac_cv_with_perl_compat], [ac_cv_with_perl_compat=no])
if test ".$ac_cv_with_perl" = ".yes"; then
AC_DEFINE(WITH_PERL, 1, [whether to build Perl bindings to C API])
WITH_PERL='yes'
PERL_NAME='$(PERL_NAME)'
else
WITH_PERL='no'
PERL_NAME=''
fi
if test ".$ac_cv_with_perl_compat" = ".yes"; then
AC_DEFINE(WITH_PERL_COMPAT, 1, [whether to build Perl compatibility API])
WITH_PERL_COMPAT=1
else
WITH_PERL_COMPAT=0
fi
AC_SUBST(PERL_NAME)
AC_SUBST(WITH_PERL)
AC_SUBST(WITH_PERL_COMPAT)
AC_PATH_PROG(PERL, perl, NA)
if test ".$ac_cv_with_perl" = ".yes" -a ".$PERL" = ".NA"; then
AC_ERROR([required Perl interpreter not found in \$PATH])
fi
dnl # configure option --with-php
AC_ARG_WITH([php],
AS_HELP_STRING([--with-php], [build PHP bindings to C API]),
[ac_cv_with_php=$withval], [ac_cv_with_php=no])
AC_CACHE_CHECK([whether to build PHP bindings to C API], [ac_cv_with_php], [ac_cv_with_php=no])
if test ".$ac_cv_with_php" = ".yes"; then
AC_DEFINE(WITH_PHP, 1, [whether to build PHP bindings to C API])
WITH_PHP='yes'
PHP_NAME='$(PHP_NAME)'
else
WITH_PHP='no'
PHP_NAME=''
fi
AC_SUBST(PHP_NAME)
AC_SUBST(WITH_PHP)
AC_PATH_PROGS(PHP, php5 php, NA)
if test ".$ac_cv_with_php" = ".yes" -a ".$PHP" = ".NA"; then
AC_ERROR([required PHP interpreter not found in \$PATH])
fi
if test ".$ac_cv_with_php" = ".yes"; then
(cd php && make -f Makefile.local config PHP=$PHP)
fi
dnl # configure option --with-pgsql
AC_ARG_WITH([pgsql],
AS_HELP_STRING([--with-pgsql], [build PostgreSQL bindings to C API]),
[ac_cv_with_pgsql=$withval], [ac_cv_with_pgsql=no])
AC_CACHE_CHECK([whether to build PostgreSQL bindings to C API], [ac_cv_with_pgsql], [ac_cv_with_pgsql=no])
if test ".$ac_cv_with_pgsql" = ".yes"; then
AC_DEFINE(WITH_PGSQL, 1, [whether to build PostgreSQL bindings to C API])
WITH_PGSQL='yes'
PGSQL_NAME='$(PGSQL_NAME)'
else
WITH_PGSQL='no'
PGSQL_NAME=''
fi
AC_SUBST(PGSQL_NAME)
AC_SUBST(WITH_PGSQL)
AC_PATH_PROGS(PG_CONFIG, pg_config, NA)
if test ".$ac_cv_with_pgsql" = ".yes" -a ".$PG_CONFIG" = ".NA"; then
AC_ERROR([required PostgreSQL pg_config utility not found in \$PATH])
fi
if test ".$ac_cv_with_pgsql" = ".yes" -a ".`${MAKE-make} -v 2>/dev/null | grep GNU`" = .; then
AC_ERROR([PostgreSQL bindings require GNU make to build])
fi
])

File diff suppressed because it is too large Load Diff

View File

@ -1,120 +0,0 @@
/*
** OSSP uuid - Universally Unique Identifier
** Copyright (c) 2004-2008 Ralf S. Engelschall <rse@engelschall.com>
** Copyright (c) 2004-2008 The OSSP Project <http://www.ossp.org/>
**
** This file is part of OSSP uuid, a library for the generation
** of UUIDs which can found at http://www.ossp.org/pkg/lib/uuid/
**
** Permission to use, copy, modify, and distribute this software for
** any purpose with or without fee is hereby granted, provided that
** the above copyright notice and this permission notice appear in all
** copies.
**
** THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
** WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
** MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
** IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
** CONTRIBUTORS 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 ADVISED OF THE POSSIBILITY OF
** SUCH DAMAGE.
**
** uuid.h: library API definition
*/
#ifndef __UUID_H__
#define __UUID_H__
/* workaround conflicts with system headers */
#define uuid_t __vendor_uuid_t
#define uuid_create __vendor_uuid_create
#define uuid_compare __vendor_uuid_compare
#include <sys/types.h>
#include <unistd.h>
#undef uuid_t
#undef uuid_create
#undef uuid_compare
/* required system headers */
#include <string.h>
/* minimum C++ support */
#ifdef __cplusplus
#define DECLARATION_BEGIN extern "C" {
#define DECLARATION_END }
#else
#define DECLARATION_BEGIN
#define DECLARATION_END
#endif
DECLARATION_BEGIN
/* OSSP uuid version (compile-time information) */
#define UUID_VERSION @UUID_VERSION_HEX@
/* encoding octet stream lengths */
#define UUID_LEN_BIN (128 /*bit*/ / 8 /*bytes*/)
#define UUID_LEN_STR (128 /*bit*/ / 4 /*nibbles*/ + 4 /*hyphens*/)
#define UUID_LEN_SIV (39 /*int(log(10,exp(2,128)-1)+1) digits*/)
/* API return codes */
typedef enum {
UUID_RC_OK = 0, /* everything ok */
UUID_RC_ARG = 1, /* invalid argument */
UUID_RC_MEM = 2, /* out of memory */
UUID_RC_SYS = 3, /* system error */
UUID_RC_INT = 4, /* internal error */
UUID_RC_IMP = 5 /* not implemented */
} uuid_rc_t;
/* UUID make modes */
enum {
UUID_MAKE_V1 = (1 << 0), /* DCE 1.1 v1 UUID */
UUID_MAKE_V3 = (1 << 1), /* DCE 1.1 v3 UUID */
UUID_MAKE_V4 = (1 << 2), /* DCE 1.1 v4 UUID */
UUID_MAKE_V5 = (1 << 3), /* DCE 1.1 v5 UUID */
UUID_MAKE_MC = (1 << 4) /* enforce multi-cast MAC address */
};
/* UUID import/export formats */
typedef enum {
UUID_FMT_BIN = 0, /* binary representation (import/export) */
UUID_FMT_STR = 1, /* string representation (import/export) */
UUID_FMT_SIV = 2, /* single integer value (import/export) */
UUID_FMT_TXT = 3 /* textual description (export only) */
} uuid_fmt_t;
/* UUID abstract data type */
struct uuid_st;
typedef struct uuid_st uuid_t;
/* UUID object handling */
extern uuid_rc_t uuid_create ( uuid_t **_uuid);
extern uuid_rc_t uuid_destroy ( uuid_t *_uuid);
extern uuid_rc_t uuid_clone (const uuid_t *_uuid, uuid_t **_clone);
/* UUID generation */
extern uuid_rc_t uuid_load ( uuid_t *_uuid, const char *_name);
extern uuid_rc_t uuid_make ( uuid_t *_uuid, unsigned int _mode, ...);
/* UUID comparison */
extern uuid_rc_t uuid_isnil (const uuid_t *_uuid, int *_result);
extern uuid_rc_t uuid_compare (const uuid_t *_uuid, const uuid_t *_uuid2, int *_result);
/* UUID import/export */
extern uuid_rc_t uuid_import ( uuid_t *_uuid, uuid_fmt_t _fmt, const void *_data_ptr, size_t _data_len);
extern uuid_rc_t uuid_export (const uuid_t *_uuid, uuid_fmt_t _fmt, void *_data_ptr, size_t *_data_len);
/* library utilities */
extern char *uuid_error (uuid_rc_t _rc);
extern unsigned long uuid_version (void);
DECLARATION_END
#endif /* __UUID_H__ */

View File

@ -1,42 +0,0 @@
##
## OSSP uuid - Universally Unique Identifier
## Copyright (c) 2004-2008 Ralf S. Engelschall <rse@engelschall.com>
## Copyright (c) 2004-2008 The OSSP Project <http://www.ossp.org/>
##
## This file is part of OSSP uuid, a library for the generation
## of UUIDs which can found at http://www.ossp.org/pkg/lib/uuid/
##
## Permission to use, copy, modify, and distribute this software for
## any purpose with or without fee is hereby granted, provided that
## the above copyright notice and this permission notice appear in all
## copies.
##
## THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
## WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
## IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
## CONTRIBUTORS 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 ADVISED OF THE POSSIBILITY OF
## SUCH DAMAGE.
##
## uuid.pc.in: pkg-config(1) specification
##
prefix=@prefix@
exec_prefix=${prefix}
includedir=${prefix}/include
libdir=${exec_prefix}/lib
Name: OSSP uuid
Description: Universally Unique Identifier (UUID) Library
Version: @UUID_VERSION_RAW@
URL: http://www.ossp.org/pkg/lib/uuid/
Cflags: -I${includedir}
Libs: -L${libdir} -luuid
Libs.private: @LIBS@

View File

@ -1,529 +0,0 @@
##
## OSSP uuid - Universally Unique Identifier
## Copyright (c) 2004-2008 Ralf S. Engelschall <rse@engelschall.com>
## Copyright (c) 2004-2008 The OSSP Project <http://www.ossp.org/>
##
## This file is part of OSSP uuid, a library for the generation
## of UUIDs which can found at http://www.ossp.org/pkg/lib/uuid/
##
## Permission to use, copy, modify, and distribute this software for
## any purpose with or without fee is hereby granted, provided that
## the above copyright notice and this permission notice appear in all
## copies.
##
## THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
## WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
## IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
## CONTRIBUTORS 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 ADVISED OF THE POSSIBILITY OF
## SUCH DAMAGE.
##
## uuid.pod: manual page
##
=pod
=head1 NAME
B<OSSP uuid> - B<Universally Unique Identifier>
=head1 VERSION
OSSP uuid UUID_VERSION_STR
=head1 DESCRIPTION
B<OSSP uuid> is a ISO-C:1999 application programming interface (API) and
corresponding command line interface (CLI) for the generation of DCE
1.1, ISO/IEC 11578:1996 and IETF RFC-4122 compliant I<Universally Unique
Identifier> (UUID). It supports DCE 1.1 variant UUIDs of version 1 (time
and node based), version 3 (name based, MD5), version 4 (random number
based) and version 5 (name based, SHA-1). Additional API bindings are
provided for the languages ISO-C++:1998, Perl:5 and PHP:4/5. Optional
backward compatibility exists for the ISO-C DCE-1.1 and Perl Data::UUID
APIs.
UUIDs are 128 bit numbers which are intended to have a high likelihood
of uniqueness over space and time and are computationally difficult
to guess. They are globally unique identifiers which can be locally
generated without contacting a global registration authority. UUIDs
are intended as unique identifiers for both mass tagging objects
with an extremely short lifetime and to reliably identifying very
persistent objects across a network.
This is the ISO-C application programming interface (API) of B<OSSP uuid>.
=head2 UUID Binary Representation
According to the DCE 1.1, ISO/IEC 11578:1996 and IETF RFC-4122
standards, a DCE 1.1 variant UUID is a 128 bit number defined out of 7
fields, each field a multiple of an octet in size and stored in network
byte order:
[4]
version
-->| |<--
| |
| | [16]
[32] [16] | |time_hi
time_low time_mid | _and_version
|<---------------------------->||<------------>||<------------>|
| MSB || || | |
| / || || | |
|/ || || | |
+------++------++------++------++------++------++------++------+~~
| 15 || 14 || 13 || 12 || 11 || 10 |####9 || 8 |
| MSO || || || || || |#### || |
+------++------++------++------++------++------++------++------+~~
7654321076543210765432107654321076543210765432107654321076543210
~~+------++------++------++------++------++------++------++------+
##* 7 || 6 || 5 || 4 || 3 || 2 || 1 || 0 |
##* || || || || || || || LSO |
~~+------++------++------++------++------++------++------++------+
7654321076543210765432107654321076543210765432107654321076543210
| | || || /|
| | || || / |
| | || || LSB |
|<---->||<---->||<-------------------------------------------->|
|clk_seq clk_seq node
|_hi_res _low [48]
|[5-6] [8]
| |
-->| |<--
variant
[2-3]
An example of a UUID binary representation is the octet stream C<0xF8
0x1D 0x4F 0xAE 0x7D 0xEC 0x11 0xD0 0xA7 0x65 0x00 0xA0 0xC9 0x1E 0x6B
0xF6>. The binary representation format is exactly what the B<OSSP uuid>
API functions B<uuid_import>() and B<uuid_export>() deal with under
C<UUID_FMT_BIN>.
=head2 UUID ASCII String Representation
According to the DCE 1.1, ISO/IEC 11578:1996 and IETF RFC-4122
standards, a DCE 1.1 variant UUID is represented as an ASCII string
consisting of 8 hexadecimal digits followed by a hyphen, then three
groups of 4 hexadecimal digits each followed by a hyphen, then 12
hexadecimal digits. Formally, the string representation is defined by
the following grammar:
uuid = <time_low> "-"
<time_mid> "-"
<time_high_and_version> "-"
<clock_seq_high_and_reserved>
<clock_seq_low> "-"
<node>
time_low = 4*<hex_octet>
time_mid = 2*<hex_octet>
time_high_and_version = 2*<hex_octet>
clock_seq_high_and_reserved = <hex_octet>
clock_seq_low = <hex_octet>
node = 6*<hex_octet>
hex_octet = <hex_digit> <hex_digit>
hex_digit = "0"|"1"|"2"|"3"|"4"|"5"|"6"|"7"|"8"|"9"
|"a"|"b"|"c"|"d"|"e"|"f"
|"A"|"B"|"C"|"D"|"E"|"F"
An example of a UUID string representation is the ASCII string
"C<f81d4fae-7dec-11d0-a765-00a0c91e6bf6>". The string representation
format is exactly what the B<OSSP uuid> API functions B<uuid_import>()
and B<uuid_export>() deal with under C<UUID_FMT_STR>.
Notice: a corresponding URL can be generated out of a ASCII string
representation of an UUID by prefixing with "C<urn:uuid:>" as in
"C<urn:uuid:f81d4fae-7dec-11d0-a765-00a0c91e6bf6>".
=head2 UUID Single Integer Value Representation
According to the ISO/IEC 11578:1996 and ITU-T Rec. X.667 standards, a
DCE 1.1 variant UUID can be also represented as a single integer value
consisting of a decimal number with up to 39 digits.
An example of a UUID single integer value representation is the decimal
number "C<329800735698586629295641978511506172918>". The string
representation format is exactly what the B<OSSP uuid> API functions
B<uuid_import>() and B<uuid_export>() deal with under C<UUID_FMT_SIV>.
Notice: a corresponding ISO OID can be generated under the
"{joint-iso-itu-t(2) uuid(25)}" arc out of a single integer value
representation of a UUID by prefixing with "C<2.25.>". An example OID
is "C<2.25.329800735698586629295641978511506172918>". Additionally,
an URL can be generated by further prefixing with "C<urn:oid:>" as in
"C<urn:oid:2.25.329800735698586629295641978511506172918>".
=head2 UUID Variants and Versions
A UUID has a variant and version. The variant defines the layout of the
UUID. The version defines the content of the UUID. The UUID variant
supported in B<OSSP uuid> is the DCE 1.1 variant only. The DCE 1.1 UUID
variant versions supported in B<OSSP uuid> are:
=over 4
=item B<Version 1> (time and node based)
These are the classical UUIDs, created out of a 60-bit system time,
a 14-bit local clock sequence and 48-bit system MAC address. The MAC
address can be either the real one of a physical network interface card
(NIC) or a random multi-cast MAC address. Version 1 UUIDs are usually
used as one-time global unique identifiers.
=item B<Version 3> (name based, MD5)
These are UUIDs which are based on the 128-bit MD5 message digest of the
concatenation of a 128-bit namespace UUID and a name string of arbitrary
length. Version 3 UUIDs are usually used for non-unique but repeatable
message digest identifiers.
=item B<Version 4> (random data based)
These are UUIDs which are based on just 128-bit of random data. Version
4 UUIDs are usually used as one-time local unique identifiers.
=item B<Version 5> (name based, SHA-1)
These are UUIDs which are based on the 160-bit SHA-1 message digest of the
concatenation of a 128-bit namespace UUID and a name string of arbitrary
length. Version 5 UUIDs are usually used for non-unique but repeatable
message digest identifiers.
=back
=head2 UUID Uniqueness
Version 1 UUIDs are guaranteed to be unique through combinations of
hardware addresses, time stamps and random seeds. There is a reference
in the UUID to the hardware (MAC) address of the first network interface
card (NIC) on the host which generated the UUID -- this reference
is intended to ensure the UUID will be unique in space as the MAC
address of every network card is assigned by a single global authority
(IEEE) and is guaranteed to be unique. The next component in a UUID
is a timestamp which, as clock always (should) move forward, will
be unique in time. Just in case some part of the above goes wrong
(the hardware address cannot be determined or the clock moved steps
backward), there is a random clock sequence component placed into the
UUID as a "catch-all" for uniqueness.
Version 3 and version 5 UUIDs are guaranteed to be inherently globally
unique if the combination of namespace and name used to generate them is
unique.
Version 4 UUIDs are not guaranteed to be globally unique, because they
are generated out of locally gathered pseudo-random numbers only.
Nevertheless there is still a high likelihood of uniqueness over space
and time and that they are computationally difficult to guess.
=head2 Nil UUID
There is a special I<Nil> UUID consisting of all octets set to zero in
the binary representation. It can be used as a special UUID value which does
not conflict with real UUIDs.
=head1 APPLICATION PROGRAMMING INTERFACE
The ISO-C Application Programming Interface (API) of B<OSSP uuid>
consists of the following components.
=head2 CONSTANTS
The following constants are provided:
=over 4
=item B<UUID_VERSION>
The hexadecimal encoded B<OSSP uuid> version. This allows compile-time
checking of the B<OSSP uuid> version. For run-time checking use
B<uuid_version>() instead.
The hexadecimal encoding for a version "$I<v>.$I<r>$I<t>$I<l>" is
calculated with the B<GNU shtool> B<version> command and is (in
Perl-style for concise description) "sprintf('0x%x%02x%d%02x', $I<v>,
$I<r>, {qw(s 9 . 2 b 1 a 0)}->{$I<t>}, ($I<t> eq 's' ? 99 : $I<l>))",
i.e., the version 0.9.6 is encoded as "0x009206".
=item B<UUID_LEN_BIN>, B<UUID_LEN_STR>, B<UUID_LEN_SIV>
The number of octets of the UUID binary and string representations.
Notice that the lengths of the string representation (B<UUID_LEN_STR>)
and the lengths of the single integer value representation
(B<UUID_LEN_SIV>) does I<not> include the necessary C<NUL> termination
character.
=item B<UUID_MAKE_V1>, B<UUID_MAKE_V3>, B<UUID_MAKE_V4>, B<UUID_MAKE_V5>, B<UUID_MAKE_MC>
The I<mode> bits for use with B<uuid_make>(). The B<UUID_MAKE_V>I<N>
specify which UUID version to generate. The B<UUID_MAKE_MC> forces the
use of a random multi-cast MAC address instead of the real physical MAC
address in version 1 UUIDs.
=item B<UUID_RC_OK>, B<UUID_RC_ARG>, B<UUID_RC_MEM>, B<UUID_RC_SYS>, B<UUID_RC_INT>, B<UUID_RC_IMP>
The possible numerical return-codes of API functions.
The C<UUID_RC_OK> indicates success, the others indicate errors.
Use B<uuid_error>() to translate them into string versions.
=item B<UUID_FMT_BIN>, B<UUID_FMT_STR>, B<UUID_FMT_SIV>, B<UUID_FMT_TXT>
The I<fmt> formats for use with B<uuid_import>() and B<uuid_export>().
The B<UUID_FMT_BIN> indicates the UUID binary representation (of
length B<UUID_LEN_BIN>), the B<UUID_FMT_STR> indicates the UUID string
representation (of length B<UUID_LEN_STR>), the B<UUID_FMT_SIV>
indicates the UUID single integer value representation (of maximum
length B<UUID_LEN_SIV>) and the B<UUID_FMT_TXT> indicates the textual
description (of arbitrary length) of a UUID.
=back
=head2 FUNCTIONS
The following functions are provided:
=over 4
=item uuid_rc_t B<uuid_create>(uuid_t **I<uuid>);
Create a new UUID object and store a pointer to it in C<*>I<uuid>.
A UUID object consists of an internal representation of a UUID, the
internal PRNG and MD5 generator contexts, and cached MAC address and
timestamp information. The initial UUID is the I<Nil> UUID.
=item uuid_rc_t B<uuid_destroy>(uuid_t *I<uuid>);
Destroy UUID object I<uuid>.
=item uuid_rc_t B<uuid_clone>(const uuid_t *I<uuid>, uuid_t **I<uuid_clone>);
Clone UUID object I<uuid> and store new UUID object in I<uuid_clone>.
=item uuid_rc_t B<uuid_isnil>(const uuid_t *I<uuid>, int *I<result>);
Checks whether the UUID in I<uuid> is the I<Nil> UUID.
If this is the case, it returns I<true> in C<*>I<result>.
Else it returns I<false> in C<*>I<result>.
=item uuid_rc_t B<uuid_compare>(const uuid_t *I<uuid>, const uuid_t *I<uuid2>, int *I<result>);
Compares the order of the two UUIDs in I<uuid1> and I<uuid2>
and returns the result in C<*>I<result>: C<-1> if I<uuid1> is
smaller than I<uuid2>, C<0> if I<uuid1> is equal to I<uuid2>
and C<+1> if I<uuid1> is greater than I<uuid2>.
=item uuid_rc_t B<uuid_import>(uuid_t *I<uuid>, uuid_fmt_t I<fmt>, const void *I<data_ptr>, size_t I<data_len>);
Imports a UUID I<uuid> from an external representation of format I<fmt>.
The data is read from the buffer at I<data_ptr> which contains at least
I<data_len> bytes.
The format of the external representation is specified by I<fmt> and the
minimum expected length in I<data_len> depends on it. Valid values for
I<fmt> are B<UUID_FMT_BIN>, B<UUID_FMT_STR> and B<UUID_FMT_SIV>.
=item uuid_rc_t B<uuid_export>(const uuid_t *I<uuid>, uuid_fmt_t I<fmt>, void *I<data_ptr>, size_t *I<data_len>);
Exports a UUID I<uuid> into an external representation of format
I<fmt>. Valid values for I<fmt> are B<UUID_FMT_BIN>, B<UUID_FMT_STR>,
B<UUID_FMT_SIV> and B<UUID_FMT_TXT>.
The data is written to the buffer whose location is obtained
by dereferencing I<data_ptr> after a "cast" to the appropriate
pointer-to-pointer type. Hence the generic pointer argument I<data_ptr>
is expected to be a pointer to a "pointer of a particular type", i.e.,
it has to be of type "C<unsigned char **>" for B<UUID_FMT_BIN> and
"C<char **>" for B<UUID_FMT_STR>, B<UUID_FMT_SIV> and B<UUID_FMT_TXT>.
The buffer has to be room for at least C<*>I<data_len> bytes. If the
value of the pointer after "casting" and dereferencing I<data_ptr>
is C<NULL>, I<data_len> is ignored as input and a new buffer is
allocated and returned in the pointer after "casting" and dereferencing
I<data_ptr> (the caller has to free(3) it later on).
If I<data_len> is not C<NULL>, the number of available bytes in the
buffer has to be provided in C<*>I<data_len> and the number of actually
written bytes are returned in C<*>I<data_len> again. The minimum
required buffer length depends on the external representation as
specified by I<fmt> and is at least B<UUID_LEN_BIN> for B<UUID_FMT_BIN>,
B<UUID_LEN_STR> for B<UUID_FMT_STR> and B<UUID_LEN_SIV> for
B<UUID_FMT_SIV>. For B<UUID_FMT_TXT> a buffer of unspecified length is
required and hence it is recommended to allow B<OSSP uuid> to allocate
the buffer as necessary.
=item uuid_rc_t B<uuid_load>(uuid_t *I<uuid>, const char *I<name>);
Loads a pre-defined UUID value into the UUID object I<uuid>. The
following I<name> arguments are currently known:
=over 4
=item I<name> I<UUID>
=item nil 00000000-0000-0000-0000-000000000000
=item ns:DNS 6ba7b810-9dad-11d1-80b4-00c04fd430c8
=item ns:URL 6ba7b811-9dad-11d1-80b4-00c04fd430c8
=item ns:OID 6ba7b812-9dad-11d1-80b4-00c04fd430c8
=item ns:X500 6ba7b814-9dad-11d1-80b4-00c04fd430c8
=back
The "C<ns:>I<XXX>" are names of pre-defined name-space UUIDs for use in
the generation of DCE 1.1 version 3 and version 5 UUIDs.
=item uuid_rc_t B<uuid_make>(uuid_t *I<uuid>, unsigned int I<mode>, ...);
Generates a new UUID in I<uuid> according to I<mode> and optional
arguments (dependent on I<mode>).
If I<mode> contains the C<UUID_MAKE_V1> bit, a DCE 1.1 variant UUID of
version 1 is generated. Then optionally the bit C<UUID_MAKE_MC> forces
the use of random multi-cast MAC address instead of the real physical
MAC address (the default). The UUID is generated out of the 60-bit current
system time, a 12-bit clock sequence and the 48-bit MAC address.
If I<mode> contains the C<UUID_MAKE_V3> or C<UUID_MAKE_V5> bit, a DCE
1.1 variant UUID of version 3 or 5 is generated and two additional
arguments are expected: first, a namespace UUID object (C<uuid_t *>).
Second, a name string of arbitrary length (C<const char *>). The UUID is
generated out of the 128-bit MD5 or 160-bit SHA-1 from the concatenated
octet stream of namespace UUID and name string.
If I<mode> contains the C<UUID_MAKE_V4> bit, a DCE 1.1 variant UUID
of version 4 is generated. The UUID is generated out of 128-bit random
data.
=item char *B<uuid_error>(uuid_rc_t I<rc>);
Returns a constant string representation corresponding to the
return-code I<rc> for use in displaying B<OSSP uuid> errors.
=item unsigned long B<uuid_version>(void);
Returns the hexadecimal encoded B<OSSP uuid> version as compiled into
the library object files. This allows run-time checking of the B<OSSP
uuid> version. For compile-time checking use C<UUID_VERSION> instead.
=back
=head1 EXAMPLE
The following shows an example usage of the API. Error handling is
omitted for code simplification and has to be re-added for production
code.
/* generate a DCE 1.1 v1 UUID from system environment */
char *uuid_v1(void)
{
uuid_t *uuid;
char *str;
uuid_create(&uuid);
uuid_make(uuid, UUID_MAKE_V1);
str = NULL;
uuid_export(uuid, UUID_FMT_STR, &str, NULL);
uuid_destroy(uuid);
return str;
}
/* generate a DCE 1.1 v3 UUID from an URL */
char *uuid_v3(const char *url)
{
uuid_t *uuid;
uuid_t *uuid_ns;
char *str;
uuid_create(&uuid);
uuid_create(&uuid_ns);
uuid_load(uuid_ns, "ns:URL");
uuid_make(uuid, UUID_MAKE_V3, uuid_ns, url);
str = NULL;
uuid_export(uuid, UUID_FMT_STR, &str, NULL);
uuid_destroy(uuid_ns);
uuid_destroy(uuid);
return str;
}
=head1 SEE ALSO
The following are references to B<UUID> documentation and specifications:
=over 4
=item
B<A Universally Unique IDentifier (UUID) URN Namespace>,
P. Leach, M. Mealling, R. Salz,
IETF RFC-4122,
July 2005, 32 pages,
http://www.ietf.org/rfc/rfc4122.txt
=item
Information Technology -- Open Systems Interconnection (OSI),
B<Procedures for the operation of OSI Registration Authorities:
Generation and Registration of Universally Unique Identifiers (UUIDs)
and their Use as ASN.1 Object Identifier Components>,
ISO/IEC 9834-8:2004 / ITU-T Rec. X.667, 2004,
December 2004, 25 pages,
http://www.itu.int/ITU-T/studygroups/com17/oid/X.667-E.pdf
=item
B<DCE 1.1: Remote Procedure Call>,
appendix B<Universally Unique Identifier>,
Open Group Technical Standard
Document Number C706, August 1997, 737 pages,
(supersedes C309 DCE: Remote Procedure Call 8/1994,
which was basis for ISO/IEC 11578:1996 specification),
http://www.opengroup.org/publications/catalog/c706.htm
=item
Information technology -- Open Systems Interconnection (OSI),
B<Remote Procedure Call (RPC)>,
ISO/IEC 11578:1996,
August 2001, 570 pages, (CHF 340,00),
http://www.iso.ch/cate/d2229.html
=item
B<HTTP Extensions for Distributed Authoring (WebDAV)>,
section B<6.4.1 Node Field Generation Without the IEEE 802 Address>,
IETF RFC-2518,
February 1999, 94 pages,
http://www.ietf.org/rfc/rfc2518.txt
=item
B<DCE 1.1 compliant UUID functions>,
FreeBSD manual pages uuid(3) and uuidgen(2),
http://www.freebsd.org/cgi/man.cgi?query=uuid&manpath=FreeBSD+6.0-RELEASE
=back
=head1 HISTORY
B<OSSP uuid> was implemented in January 2004 by Ralf S. Engelschall
E<lt>rse@engelschall.comE<gt>. It was prompted by the use of UUIDs
in the B<OSSP as> and B<OpenPKG> projects. It is a clean room
implementation intended to be strictly standards compliant and maximum
portable.
=head1 SEE ALSO
uuid(1), uuid-config(1), OSSP::uuid(3).
=cut

View File

@ -1,109 +0,0 @@
/*
** OSSP uuid - Universally Unique Identifier
** Copyright (c) 2004-2008 Ralf S. Engelschall <rse@engelschall.com>
** Copyright (c) 2004-2008 The OSSP Project <http://www.ossp.org/>
**
** This file is part of OSSP uuid, a library for the generation
** of UUIDs which can found at http://www.ossp.org/pkg/lib/uuid/
**
** Permission to use, copy, modify, and distribute this software for
** any purpose with or without fee is hereby granted, provided that
** the above copyright notice and this permission notice appear in all
** copies.
**
** THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
** WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
** MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
** IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
** CONTRIBUTORS 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 ADVISED OF THE POSSIBILITY OF
** SUCH DAMAGE.
**
** uuid_ac.c: auto-configuration
*/
#ifndef __UUID_AC_H__
#define __UUID_AC_H__
/* include GNU autoconf results */
#include "config.h" /* HAVE_xxx */
/* include standard system headers */
#include <stdio.h> /* NULL, etc. */
#include <stdlib.h> /* malloc, NULL, etc. */
#include <stdarg.h> /* va_list, etc. */
#include <string.h> /* size_t, strlen, etc. */
#include <unistd.h> /* dmalloc pre-loading */
/* enable optional "dmalloc" support */
#ifdef WITH_DMALLOC
#include <dmalloc.h> /* malloc override, etc */
#endif
/* define boolean values */
#define UUID_FALSE 0
#define UUID_TRUE (/*lint -save -e506*/ !UUID_FALSE /*lint -restore*/)
/* determine types of 8-bit size */
#if SIZEOF_CHAR == 1
typedef char uuid_int8_t;
#else
#error unexpected: sizeof(char) != 1 !?
#endif
#if SIZEOF_UNSIGNED_CHAR == 1
typedef unsigned char uuid_uint8_t;
#else
#error unexpected: sizeof(unsigned char) != 1 !?
#endif
/* determine types of 16-bit size */
#if SIZEOF_SHORT == 2
typedef short uuid_int16_t;
#elif SIZEOF_INT == 2
typedef int uuid_int16_t;
#elif SIZEOF_LONG == 2
typedef long uuid_int16_t;
#else
#error unexpected: no type found for uuid_int16_t
#endif
#if SIZEOF_UNSIGNED_SHORT == 2
typedef unsigned short uuid_uint16_t;
#elif SIZEOF_UNSIGNED_INT == 2
typedef unsigned int uuid_uint16_t;
#elif SIZEOF_UNSIGNED_LONG == 2
typedef unsigned long uuid_uint16_t;
#else
#error unexpected: no type found for uuid_uint16_t
#endif
/* determine types of 32-bit size */
#if SIZEOF_SHORT == 4
typedef short uuid_int32_t;
#elif SIZEOF_INT == 4
typedef int uuid_int32_t;
#elif SIZEOF_LONG == 4
typedef long uuid_int32_t;
#elif SIZEOF_LONG_LONG == 4
typedef long long uuid_int32_t;
#else
#error unexpected: no type found for uuid_int32_t
#endif
#if SIZEOF_UNSIGNED_SHORT == 4
typedef unsigned short uuid_uint32_t;
#elif SIZEOF_UNSIGNED_INT == 4
typedef unsigned int uuid_uint32_t;
#elif SIZEOF_UNSIGNED_LONG == 4
typedef unsigned long uuid_uint32_t;
#elif SIZEOF_UNSIGNED_LONG_LONG == 4
typedef unsigned long long uuid_uint32_t;
#else
#error unexpected: no type found for uuid_uint32_t
#endif
#endif /* __UUID_AC_H__ */

View File

@ -1,80 +0,0 @@
/*
** OSSP uuid - Universally Unique Identifier
** Copyright (c) 2004-2008 Ralf S. Engelschall <rse@engelschall.com>
** Copyright (c) 2004-2008 The OSSP Project <http://www.ossp.org/>
**
** This file is part of OSSP uuid, a library for the generation
** of UUIDs which can found at http://www.ossp.org/pkg/lib/uuid/
**
** Permission to use, copy, modify, and distribute this software for
** any purpose with or without fee is hereby granted, provided that
** the above copyright notice and this permission notice appear in all
** copies.
**
** THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
** WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
** MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
** IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
** CONTRIBUTORS 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 ADVISED OF THE POSSIBILITY OF
** SUCH DAMAGE.
**
** uuid_bm.c: bitmask API implementation
*/
#ifndef __UUID_BM_H__
#define __UUID_BM_H__
/*
* Bitmask Calculation Macros (up to 32 bit only)
* (Notice: bit positions are counted n...0, i.e. lowest bit is position 0)
*/
/* generate a bitmask consisting of 1 bits from (and including)
bit position `l' (left) to (and including) bit position `r' */
#define BM_MASK(l,r) \
((((unsigned int)1<<(((l)-(r))+1))-1)<<(r))
/* extract a value v from a word w at position `l' to `r' and return value */
#define BM_GET(w,l,r) \
(((w)>>(r))&BM_MASK((l)-(r),0))
/* insert a value v into a word w at position `l' to `r' and return word */
#define BM_SET(w,l,r,v) \
((w)|(((v)&BM_MASK((l)-(r),0))<<(r)))
/* generate a single bit `b' (0 or 1) at bit position `n' */
#define BM_BIT(n,b) \
((b)<<(n))
/* generate a quad word octet of bits (a half byte, i.e. bit positions 3 to 0) */
#define BM_QUAD(b3,b2,b1,b0) \
(BM_BIT(3,(b3))|BM_BIT(2,(b2))|BM_BIT(1,(b1))|BM_BIT(0,(b0)))
/* generate an octet word of bits (a byte, i.e. bit positions 7 to 0) */
#define BM_OCTET(b7,b6,b5,b4,b3,b2,b1,b0) \
((BM_QUAD(b7,b6,b5,b4)<<4)|BM_QUAD(b3,b2,b1,b0))
/* generate the value 2^n */
#define BM_POW2(n) \
BM_BIT(n,1)
/* shift word w k bits to the left or to the right */
#define BM_SHL(w,k) \
((w)<<(k))
#define BM_SHR(w,k) \
((w)>>(k))
/* rotate word w (of bits n..0) k bits to the left or to the right */
#define BM_ROL(w,n,k) \
((BM_SHL((w),(k))&BM_MASK(n,0))|BM_SHR(((w)&BM_MASK(n,0)),(n)-(k)))
#define BM_ROR(w,n,k) \
((BM_SHR(((w)&BM_MASK(n,0)),(k)))|BM_SHL(((w),(n)-(k))&BM_MASK(n,0)))
#endif /* __UUID_BM_H__ */

View File

@ -1,283 +0,0 @@
/*
** OSSP uuid - Universally Unique Identifier
** Copyright (c) 2004-2008 Ralf S. Engelschall <rse@engelschall.com>
** Copyright (c) 2004-2008 The OSSP Project <http://www.ossp.org/>
**
** This file is part of OSSP uuid, a library for the generation
** of UUIDs which can found at http://www.ossp.org/pkg/lib/uuid/
**
** Permission to use, copy, modify, and distribute this software for
** any purpose with or without fee is hereby granted, provided that
** the above copyright notice and this permission notice appear in all
** copies.
**
** THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
** WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
** MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
** IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
** CONTRIBUTORS 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 ADVISED OF THE POSSIBILITY OF
** SUCH DAMAGE.
**
** uuid_cli.c: command line tool
*/
/* own headers */
#include "uuid.h"
#include "uuid_ac.h"
/* system headers */
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
/* error handler */
static void
error(int ec, const char *str, ...)
{
va_list ap;
va_start(ap, str);
fprintf(stderr, "uuid:ERROR: ");
vfprintf(stderr, str, ap);
fprintf(stderr, "\n");
va_end(ap);
exit(ec);
}
/* usage handler */
static void
usage(const char *str, ...)
{
va_list ap;
va_start(ap, str);
if (str != NULL) {
fprintf(stderr, "uuid:ERROR: ");
vfprintf(stderr, str, ap);
fprintf(stderr, "\n");
}
fprintf(stderr, "usage: uuid [-v version] [-m] [-n count] [-1] [-F format] [-o filename] [namespace name]\n");
fprintf(stderr, "usage: uuid -d [-F format] [-o filename] [uuid]\n");
va_end(ap);
exit(1);
}
/* main procedure */
int main(int argc, char *argv[])
{
char uuid_buf_bin[UUID_LEN_BIN];
char uuid_buf_str[UUID_LEN_STR+1];
char uuid_buf_siv[UUID_LEN_SIV+1];
uuid_t *uuid;
uuid_t *uuid_ns;
uuid_rc_t rc;
FILE *fp;
char *p;
int ch;
int count;
int i;
int iterate;
uuid_fmt_t fmt;
int decode;
void *vp;
size_t n;
unsigned int version;
/* command line parsing */
count = -1; /* no count yet */
fp = stdout; /* default output file */
iterate = 0; /* not one at a time */
fmt = UUID_FMT_STR; /* default is ASCII output */
decode = 0; /* default is to encode */
version = UUID_MAKE_V1;
while ((ch = getopt(argc, argv, "1n:rF:dmo:v:h")) != -1) {
switch (ch) {
case '1':
iterate = 1;
break;
case 'n':
if (count > 0)
usage("option 'n' specified multiple times");
count = strtol(optarg, &p, 10);
if (*p != '\0' || count < 1)
usage("invalid argument to option 'n'");
break;
case 'r':
fmt = UUID_FMT_BIN;
break;
case 'F':
if (strcasecmp(optarg, "bin") == 0)
fmt = UUID_FMT_BIN;
else if (strcasecmp(optarg, "str") == 0)
fmt = UUID_FMT_STR;
else if (strcasecmp(optarg, "siv") == 0)
fmt = UUID_FMT_SIV;
else
error(1, "invalid format \"%s\" (has to be \"bin\", \"str\" or \"siv\")", optarg);
break;
case 'd':
decode = 1;
break;
case 'o':
if (fp != stdout)
error(1, "multiple output files are not allowed");
if ((fp = fopen(optarg, "w")) == NULL)
error(1, "fopen: %s", strerror(errno));
break;
case 'm':
version |= UUID_MAKE_MC;
break;
case 'v':
i = strtol(optarg, &p, 10);
if (*p != '\0')
usage("invalid argument to option 'v'");
switch (i) {
case 1: version = UUID_MAKE_V1; break;
case 3: version = UUID_MAKE_V3; break;
case 4: version = UUID_MAKE_V4; break;
case 5: version = UUID_MAKE_V5; break;
default:
usage("invalid version on option 'v'");
break;
}
break;
case 'h':
usage(NULL);
break;
default:
usage("invalid option '%c'", optopt);
}
}
argv += optind;
argc -= optind;
if (count == -1)
count = 1;
if (decode) {
/* decoding */
if ((rc = uuid_create(&uuid)) != UUID_RC_OK)
error(1, "uuid_create: %s", uuid_error(rc));
if (argc != 1)
usage("invalid number of arguments");
if (strcmp(argv[0], "-") == 0) {
if (fmt == UUID_FMT_BIN) {
if (fread(uuid_buf_bin, UUID_LEN_BIN, 1, stdin) != 1)
error(1, "fread: failed to read %d (UUID_LEN_BIN) bytes from stdin", UUID_LEN_BIN);
if ((rc = uuid_import(uuid, UUID_FMT_BIN, uuid_buf_bin, UUID_LEN_BIN)) != UUID_RC_OK)
error(1, "uuid_import: %s", uuid_error(rc));
}
else if (fmt == UUID_FMT_STR) {
if (fread(uuid_buf_str, UUID_LEN_STR, 1, stdin) != 1)
error(1, "fread: failed to read %d (UUID_LEN_STR) bytes from stdin", UUID_LEN_STR);
uuid_buf_str[UUID_LEN_STR] = '\0';
if ((rc = uuid_import(uuid, UUID_FMT_STR, uuid_buf_str, UUID_LEN_STR)) != UUID_RC_OK)
error(1, "uuid_import: %s", uuid_error(rc));
}
else if (fmt == UUID_FMT_SIV) {
if (fread(uuid_buf_siv, UUID_LEN_SIV, 1, stdin) != 1)
error(1, "fread: failed to read %d (UUID_LEN_SIV) bytes from stdin", UUID_LEN_SIV);
uuid_buf_siv[UUID_LEN_SIV] = '\0';
if ((rc = uuid_import(uuid, UUID_FMT_SIV, uuid_buf_siv, UUID_LEN_SIV)) != UUID_RC_OK)
error(1, "uuid_import: %s", uuid_error(rc));
}
}
else {
if (fmt == UUID_FMT_BIN) {
error(1, "binary input mode only possible if reading from stdin");
}
else if (fmt == UUID_FMT_STR) {
if ((rc = uuid_import(uuid, UUID_FMT_STR, argv[0], strlen(argv[0]))) != UUID_RC_OK)
error(1, "uuid_import: %s", uuid_error(rc));
}
else if (fmt == UUID_FMT_SIV) {
if ((rc = uuid_import(uuid, UUID_FMT_SIV, argv[0], strlen(argv[0]))) != UUID_RC_OK)
error(1, "uuid_import: %s", uuid_error(rc));
}
}
vp = NULL;
if ((rc = uuid_export(uuid, UUID_FMT_TXT, &vp, NULL)) != UUID_RC_OK)
error(1, "uuid_export: %s", uuid_error(rc));
fprintf(stdout, "%s", (char *)vp);
free(vp);
if ((rc = uuid_destroy(uuid)) != UUID_RC_OK)
error(1, "uuid_destroy: %s", uuid_error(rc));
}
else {
/* encoding */
if ( (version == UUID_MAKE_V1 && argc != 0)
|| (version == UUID_MAKE_V3 && argc != 2)
|| (version == UUID_MAKE_V4 && argc != 0)
|| (version == UUID_MAKE_V5 && argc != 2))
usage("invalid number of arguments");
if ((rc = uuid_create(&uuid)) != UUID_RC_OK)
error(1, "uuid_create: %s", uuid_error(rc));
if (argc == 1) {
/* load initial UUID for setting old generator state */
if (strlen(argv[0]) != UUID_LEN_STR)
error(1, "invalid length of UUID string representation");
if ((rc = uuid_import(uuid, UUID_FMT_STR, argv[0], strlen(argv[0]))) != UUID_RC_OK)
error(1, "uuid_import: %s", uuid_error(rc));
}
for (i = 0; i < count; i++) {
if (iterate) {
if ((rc = uuid_load(uuid, "nil")) != UUID_RC_OK)
error(1, "uuid_load: %s", uuid_error(rc));
}
if (version == UUID_MAKE_V3 || version == UUID_MAKE_V5) {
if ((rc = uuid_create(&uuid_ns)) != UUID_RC_OK)
error(1, "uuid_create: %s", uuid_error(rc));
if ((rc = uuid_load(uuid_ns, argv[0])) != UUID_RC_OK) {
if ((rc = uuid_import(uuid_ns, UUID_FMT_STR, argv[0], strlen(argv[0]))) != UUID_RC_OK)
error(1, "uuid_import: %s", uuid_error(rc));
}
if ((rc = uuid_make(uuid, version, uuid_ns, argv[1])) != UUID_RC_OK)
error(1, "uuid_make: %s", uuid_error(rc));
if ((rc = uuid_destroy(uuid_ns)) != UUID_RC_OK)
error(1, "uuid_destroy: %s", uuid_error(rc));
}
else {
if ((rc = uuid_make(uuid, version)) != UUID_RC_OK)
error(1, "uuid_make: %s", uuid_error(rc));
}
if (fmt == UUID_FMT_BIN) {
vp = NULL;
if ((rc = uuid_export(uuid, UUID_FMT_BIN, &vp, &n)) != UUID_RC_OK)
error(1, "uuid_export: %s", uuid_error(rc));
fwrite(vp, n, 1, fp);
free(vp);
}
else if (fmt == UUID_FMT_STR) {
vp = NULL;
if ((rc = uuid_export(uuid, UUID_FMT_STR, &vp, &n)) != UUID_RC_OK)
error(1, "uuid_export: %s", uuid_error(rc));
fprintf(fp, "%s\n", (char *)vp);
free(vp);
}
else if (fmt == UUID_FMT_SIV) {
vp = NULL;
if ((rc = uuid_export(uuid, UUID_FMT_SIV, &vp, &n)) != UUID_RC_OK)
error(1, "uuid_export: %s", uuid_error(rc));
fprintf(fp, "%s\n", (char *)vp);
free(vp);
}
}
if ((rc = uuid_destroy(uuid)) != UUID_RC_OK)
error(1, "uuid_destroy: %s", uuid_error(rc));
}
/* close output channel */
if (fp != stdout)
fclose(fp);
return 0;
}

View File

@ -1,201 +0,0 @@
##
## OSSP uuid - Universally Unique Identifier
## Copyright (c) 2004-2008 Ralf S. Engelschall <rse@engelschall.com>
## Copyright (c) 2004-2008 The OSSP Project <http://www.ossp.org/>
##
## This file is part of OSSP uuid, a library for the generation
## of UUIDs which can found at http://www.ossp.org/pkg/lib/uuid/
##
## Permission to use, copy, modify, and distribute this software for
## any purpose with or without fee is hereby granted, provided that
## the above copyright notice and this permission notice appear in all
## copies.
##
## THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
## WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
## IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
## CONTRIBUTORS 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 ADVISED OF THE POSSIBILITY OF
## SUCH DAMAGE.
##
## uuid_cli.pod: manual page
##
=pod
=head1 NAME
B<OSSP uuid> - B<Universally Unique Identifier Command-Line Tool>
=head1 VERSION
OSSP uuid UUID_VERSION_STR
=head1 SYNOPSIS
B<uuid>
[B<-v> I<version>]
[B<-m>]
[B<-n> I<count>]
[B<-1>]
[B<-F> I<format>]
[B<-o> I<filename>]
[I<namespace> I<name>]
B<uuid>
B<-d>
[B<-r>]
[B<-o> I<filename>]
I<uuid>
=head1 DESCRIPTION
B<OSSP uuid> is a ISO-C:1999 application programming interface (API) and
corresponding command line interface (CLI) for the generation of DCE
1.1, ISO/IEC 11578:1996 and IETF RFC-4122 compliant I<Universally Unique
Identifier> (UUID). It supports DCE 1.1 variant UUIDs of version 1 (time
and node based), version 3 (name based, MD5), version 4 (random number
based) and version 5 (name based, SHA-1). Additional API bindings are
provided for the languages ISO-C++:1998, Perl:5 and PHP:4/5. Optional
backward compatibility exists for the ISO-C DCE-1.1 and Perl Data::UUID
APIs.
UUIDs are 128 bit numbers which are intended to have a high likelihood
of uniqueness over space and time and are computationally difficult
to guess. They are globally unique identifiers which can be locally
generated without contacting a global registration authority. UUIDs
are intended as unique identifiers for both mass tagging objects
with an extremely short lifetime and to reliably identifying very
persistent objects across a network.
This is the command line interface (CLI) of B<OSSP uuid>. For a
detailed description of UUIDs see the documentation of the application
programming interface (API) in uuid(3).
=head1 OPTIONS
=over 3
=item B<-v> I<version>
Sets the version of the generated DCE 1.1 variant UUID. Supported
are I<version> "C<1>", "C<3>", "C<4>" and "C<5>". The default is "C<1>".
For version 3 and version 5 UUIDs the additional command line arguments
I<namespace> and I<name> have to be given. The I<namespace> is either
a UUID in string representation or an identifier for internally
pre-defined namespace UUIDs (currently known are "C<ns:DNS>",
"C<ns:URL>", "C<ns:OID>", and "C<ns:X500>"). The I<name> is a string of
arbitrary length.
=item B<-m>
Forces the use of a random multi-cast MAC address when generating
version 1 UUIDs. By default the real physical MAC address of the system
is used.
=item B<-n> I<count>
Generate I<count> UUIDs instead of just a single one (the default).
=item B<-1>
If option B<-n> is used with a I<count> greater than C<1>, then this
option can enforce the reset the UUID context for each generated UUID.
This makes no difference for I<version> C<3>, C<4> and C<5> UUIDs. But
version C<1> UUIDs are based on the previously generated UUID which is
remembered in the UUID context of the API. Option B<-1> deletes the
remembered UUID on each iteration.
=item B<-F> I<format>
Representation format for importing or exporting an UUID. The
following (case insensitive) format identifiers are currently recognized:
=over 4
=item C<BIN> (binary representation)
This is the raw 128 bit network byte order binary representation of a
UUID. Example is the octet stream C<0xF8 0x1D 0x4F 0xAE 0x7D 0xEC 0x11
0xD0 0xA7 0x65 0x00 0xA0 0xC9 0x1E 0x6B 0xF6>.
=item C<STR> (string representation)
This is the 36 character hexadecimal ASCII string representation of a
UUID. Example is the string "C<f81d4fae-7dec-11d0-a765-00a0c91e6bf6>".
=item C<SIV> (single integer value representation)
This is the maximum 39 character long single integer
value representation of a UUID. Example is the string
"C<329800735698586629295641978511506172918>".
=back
=item B<-o> I<filename>
Write output to I<filename> instead of to F<stdout>.
=item B<-d>
Decode a given UUID (given as a command line argument or if the command
line argument is "C<->" the UUID is read from F<stdin>) and dump textual
information about the UUID.
=back
=head1 EXAMPLES
# generate DCE 1.1 v1 UUID (time and node based)
$ uuid -v1
01c47915-4777-11d8-bc70-0090272ff725
# decode and dump DCE 1.1 v1 UUID (time and node based)
$ uuid -d 01c47915-4777-11d8-bc70-0090272ff725
encode: STR: 01c47915-4777-11d8-bc70-0090272ff725
SIV: 2349374037528578887923094374772111141
decode: variant: DCE 1.1, ISO/IEC 11578:1996
version: 1 (time and node based)
content: time: 2004-01-15 16:22:26.376322.1 UTC
clock: 15472 (usually random)
node: 00:90:27:2f:f7:25 (global unicast)
# generate DCE 1.1 v3 UUID (name based)
$ uuid -v3 ns:URL http://www.ossp.org/
02d9e6d5-9467-382e-8f9b-9300a64ac3cd
# decode and dump DCE 1.1 v3 UUID (name based)
$ uuid -d 02d9e6d5-9467-382e-8f9b-9300a64ac3cd
encode: STR: 02d9e6d5-9467-382e-8f9b-9300a64ac3cd
SIV: 3789866285607910888100818383505376205
decode: variant: DCE 1.1, ISO/IEC 11578:1996
version: 3 (name based, MD5)
content: 02:D9:E6:D5:94:67:08:2E:0F:9B:93:00:A6:4A:C3:CD
(not decipherable: MD5 message digest only)
# generate DCE 1.1 v4 UUID 4 (random data based)
$ uuid -v4
eb424026-6f54-4ef8-a4d0-bb658a1fc6cf
# decode and dump DCE 1.1 v4 UUID 4 (random data based)
$ uuid -d eb424026-6f54-4ef8-a4d0-bb658a1fc6cf
encode: STR: eb424026-6f54-4ef8-a4d0-bb658a1fc6cf
SIV: 312712571721458096795100956955942831823
decode: variant: DCE 1.1, ISO/IEC 11578:1996
version: 4 (random data based)
content: EB:42:40:26:6F:54:0E:F8:24:D0:BB:65:8A:1F:C6:CF
(no semantics: random data only)
=head1 SEE ALSO
uuid(3), OSSP::uuid(3).
=cut

View File

@ -1,294 +0,0 @@
/*
** OSSP uuid - Universally Unique Identifier
** Copyright (c) 2004-2008 Ralf S. Engelschall <rse@engelschall.com>
** Copyright (c) 2004-2008 The OSSP Project <http://www.ossp.org/>
**
** This file is part of OSSP uuid, a library for the generation
** of UUIDs which can found at http://www.ossp.org/pkg/lib/uuid/
**
** Permission to use, copy, modify, and distribute this software for
** any purpose with or without fee is hereby granted, provided that
** the above copyright notice and this permission notice appear in all
** copies.
**
** THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
** WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
** MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
** IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
** CONTRIBUTORS 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 ADVISED OF THE POSSIBILITY OF
** SUCH DAMAGE.
**
** uuid_dce.c: DCE 1.1 compatibility API implementation
*/
/* include DCE 1.1 API */
#define uuid_t uuid_dce_t
#include "uuid_dce.h"
#undef uuid_t
#undef uuid_create
#undef uuid_create_nil
#undef uuid_is_nil
#undef uuid_compare
#undef uuid_equal
#undef uuid_from_string
#undef uuid_to_string
#undef uuid_hash
/* include regular API */
#include "uuid.h"
/* helper macro */
#define LEAVE /*lint -save -e801*/ goto leave /*lint -restore*/
/* create a UUID (v1 only) */
void uuid_dce_create(uuid_dce_t *uuid_dce, int *status)
{
uuid_t *uuid;
size_t len;
void *vp;
/* initialize status */
if (status != NULL)
*status = uuid_s_error;
/* sanity check argument(s) */
if (uuid_dce == NULL)
return;
/* create UUID and export as binary representation */
if (uuid_create(&uuid) != UUID_RC_OK)
return;
if (uuid_make(uuid, UUID_MAKE_V1) != UUID_RC_OK) {
uuid_destroy(uuid);
return;
}
vp = uuid_dce;
len = UUID_LEN_BIN;
if (uuid_export(uuid, UUID_FMT_BIN, &vp, &len) != UUID_RC_OK) {
uuid_destroy(uuid);
return;
}
uuid_destroy(uuid);
/* return successfully */
if (status != NULL)
*status = uuid_s_ok;
return;
}
/* create a Nil UUID */
void uuid_dce_create_nil(uuid_dce_t *uuid_dce, int *status)
{
/* initialize status */
if (status != NULL)
*status = uuid_s_error;
/* sanity check argument(s) */
if (uuid_dce == NULL)
return;
/* short-circuit implementation, because Nil UUID is trivial to
create, so no need to use regular OSSP uuid API */
memset(uuid_dce, 0, UUID_LEN_BIN);
/* return successfully */
if (status != NULL)
*status = uuid_s_ok;
return;
}
/* check whether it is Nil UUID */
int uuid_dce_is_nil(uuid_dce_t *uuid_dce, int *status)
{
int i;
int result;
unsigned char *ucp;
/* initialize status */
if (status != NULL)
*status = uuid_s_error;
/* sanity check argument(s) */
if (uuid_dce == NULL)
return 0;
/* short-circuit implementation, because Nil UUID is trivial to
check, so no need to use regular OSSP uuid API */
result = 1;
ucp = (unsigned char *)uuid_dce;
for (i = 0; i < UUID_LEN_BIN; i++) {
if (ucp[i] != '\0') {
result = 0;
break;
}
}
/* return successfully with result */
if (status != NULL)
*status = uuid_s_ok;
return result;
}
/* compare two UUIDs */
int uuid_dce_compare(uuid_dce_t *uuid_dce1, uuid_dce_t *uuid_dce2, int *status)
{
uuid_t *uuid1 = NULL;
uuid_t *uuid2 = NULL;
int result = 0;
/* initialize status */
if (status != NULL)
*status = uuid_s_error;
/* sanity check argument(s) */
if (uuid_dce1 == NULL || uuid_dce2 == NULL)
return 0;
/* import both UUID binary representations and compare them */
if (uuid_create(&uuid1) != UUID_RC_OK)
LEAVE;
if (uuid_create(&uuid2) != UUID_RC_OK)
LEAVE;
if (uuid_import(uuid1, UUID_FMT_BIN, uuid_dce1, UUID_LEN_BIN) != UUID_RC_OK)
LEAVE;
if (uuid_import(uuid2, UUID_FMT_BIN, uuid_dce2, UUID_LEN_BIN) != UUID_RC_OK)
LEAVE;
if (uuid_compare(uuid1, uuid2, &result) != UUID_RC_OK)
LEAVE;
/* indicate successful operation */
if (status != NULL)
*status = uuid_s_ok;
/* cleanup and return */
leave:
if (uuid1 != NULL)
uuid_destroy(uuid1);
if (uuid2 != NULL)
uuid_destroy(uuid2);
return result;
}
/* compare two UUIDs (equality only) */
int uuid_dce_equal(uuid_dce_t *uuid_dce1, uuid_dce_t *uuid_dce2, int *status)
{
/* initialize status */
if (status != NULL)
*status = uuid_s_error;
/* sanity check argument(s) */
if (uuid_dce1 == NULL || uuid_dce2 == NULL)
return 0;
/* pass through to generic compare function */
return (uuid_dce_compare(uuid_dce1, uuid_dce2, status) == 0 ? 1 : 0);
}
/* import UUID from string representation */
void uuid_dce_from_string(const char *str, uuid_dce_t *uuid_dce, int *status)
{
uuid_t *uuid = NULL;
size_t len;
void *vp;
/* initialize status */
if (status != NULL)
*status = uuid_s_error;
/* sanity check argument(s) */
if (str == NULL || uuid_dce == NULL)
return;
/* import string representation and export binary representation */
if (uuid_create(&uuid) != UUID_RC_OK)
LEAVE;
if (uuid_import(uuid, UUID_FMT_STR, str, UUID_LEN_STR) != UUID_RC_OK)
LEAVE;
vp = uuid_dce;
len = UUID_LEN_BIN;
if (uuid_export(uuid, UUID_FMT_BIN, &vp, &len) != UUID_RC_OK)
LEAVE;
/* indicate successful operation */
if (status != NULL)
*status = uuid_s_ok;
/* cleanup and return */
leave:
if (uuid != NULL)
uuid_destroy(uuid);
return;
}
/* export UUID to string representation */
void uuid_dce_to_string(uuid_dce_t *uuid_dce, char **str, int *status)
{
uuid_t *uuid = NULL;
size_t len;
void *vp;
/* initialize status */
if (status != NULL)
*status = uuid_s_error;
/* sanity check argument(s) */
if (str == NULL || uuid_dce == NULL)
return;
/* import binary representation and export string representation */
if (uuid_create(&uuid) != UUID_RC_OK)
LEAVE;
if (uuid_import(uuid, UUID_FMT_BIN, uuid_dce, UUID_LEN_BIN) != UUID_RC_OK)
LEAVE;
vp = str;
len = UUID_LEN_STR;
if (uuid_export(uuid, UUID_FMT_STR, &vp, &len) != UUID_RC_OK)
LEAVE;
/* indicate successful operation */
if (status != NULL)
*status = uuid_s_ok;
/* cleanup and return */
leave:
if (uuid != NULL)
uuid_destroy(uuid);
return;
}
/* export UUID into hash value */
unsigned int uuid_dce_hash(uuid_dce_t *uuid_dce, int *status)
{
int i;
unsigned char *ucp;
unsigned int hash;
/* initialize status */
if (status != NULL)
*status = uuid_s_error;
/* sanity check argument(s) */
if (uuid_dce == NULL)
return 0;
/* generate a hash value
(DCE 1.1 actually requires 16-bit only) */
hash = 0;
ucp = (unsigned char *)uuid_dce;
for (i = UUID_LEN_BIN-1; i >= 0; i--) {
hash <<= 8;
hash |= ucp[i];
}
/* return successfully */
if (status != NULL)
*status = uuid_s_ok;
return hash;
}

View File

@ -1,88 +0,0 @@
/*
** OSSP uuid - Universally Unique Identifier
** Copyright (c) 2004-2008 Ralf S. Engelschall <rse@engelschall.com>
** Copyright (c) 2004-2008 The OSSP Project <http://www.ossp.org/>
**
** This file is part of OSSP uuid, a library for the generation
** of UUIDs which can found at http://www.ossp.org/pkg/lib/uuid/
**
** Permission to use, copy, modify, and distribute this software for
** any purpose with or without fee is hereby granted, provided that
** the above copyright notice and this permission notice appear in all
** copies.
**
** THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
** WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
** MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
** IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
** CONTRIBUTORS 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 ADVISED OF THE POSSIBILITY OF
** SUCH DAMAGE.
**
** uuid_dce.h: DCE 1.1 compatibility API definition
*/
#ifndef __UUID_DCE_H___
#define __UUID_DCE_H___
/* sanity check usage */
#ifdef __UUID_H__
#error the regular OSSP uuid API and the DCE 1.1 backward compatibility API are mutually exclusive -- you cannot use them at the same time.
#endif
/* resolve namespace conflicts (at linking level) with regular OSSP uuid API */
#define uuid_create uuid_dce_create
#define uuid_create_nil uuid_dce_create_nil
#define uuid_is_nil uuid_dce_is_nil
#define uuid_compare uuid_dce_compare
#define uuid_equal uuid_dce_equal
#define uuid_from_string uuid_dce_from_string
#define uuid_to_string uuid_dce_to_string
#define uuid_hash uuid_dce_hash
/* DCE 1.1 uuid_t type */
typedef struct {
#if 0
/* stricter but unportable version */
uuid_uint32_t time_low;
uuid_uint16_t time_mid;
uuid_uint16_t time_hi_and_version;
uuid_uint8_t clock_seq_hi_and_reserved;
uuid_uint8_t clock_seq_low;
uuid_uint8_t node[6];
#else
/* sufficient and portable version */
unsigned char data[16];
#endif
} uuid_t;
typedef uuid_t *uuid_p_t;
/* DCE 1.1 uuid_vector_t type */
typedef struct {
unsigned int count;
uuid_t *uuid[1];
} uuid_vector_t;
/* DCE 1.1 UUID API status codes */
enum {
uuid_s_ok = 0, /* standardized */
uuid_s_error = 1 /* implementation specific */
};
/* DCE 1.1 UUID API functions */
extern void uuid_create (uuid_t *, int *);
extern void uuid_create_nil (uuid_t *, int *);
extern int uuid_is_nil (uuid_t *, int *);
extern int uuid_compare (uuid_t *, uuid_t *, int *);
extern int uuid_equal (uuid_t *, uuid_t *, int *);
extern void uuid_from_string (const char *, uuid_t *, int *);
extern void uuid_to_string (uuid_t *, char **, int *);
extern unsigned int uuid_hash (uuid_t *, int *);
#endif /* __UUID_DCE_H___ */

View File

@ -1,183 +0,0 @@
/*
** OSSP uuid - Universally Unique Identifier
** Copyright (c) 2004-2008 Ralf S. Engelschall <rse@engelschall.com>
** Copyright (c) 2004-2008 The OSSP Project <http://www.ossp.org/>
**
** This file is part of OSSP uuid, a library for the generation
** of UUIDs which can found at http://www.ossp.org/pkg/lib/uuid/
**
** Permission to use, copy, modify, and distribute this software for
** any purpose with or without fee is hereby granted, provided that
** the above copyright notice and this permission notice appear in all
** copies.
**
** THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
** WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
** MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
** IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
** CONTRIBUTORS 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 ADVISED OF THE POSSIBILITY OF
** SUCH DAMAGE.
**
** uuid_mac.c: Media Access Control (MAC) resolver implementation
*/
/* own headers (part (1/2) */
#include "uuid_ac.h"
/* system headers */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <time.h>
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#endif
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif
#ifdef HAVE_SYS_IOCTL_H
#include <sys/ioctl.h>
#endif
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
#ifdef HAVE_SYS_SOCKIO_H
#include <sys/sockio.h>
#endif
#ifdef HAVE_NETDB_H
#include <netdb.h>
#endif
#ifdef HAVE_NET_IF_H
#include <net/if.h>
#endif
#ifdef HAVE_NET_IF_DL_H
#include <net/if_dl.h>
#endif
#ifdef HAVE_NET_IF_ARP_H
#include <net/if_arp.h>
#endif
#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif
#ifdef HAVE_ARPA_INET_H
#include <arpa/inet.h>
#endif
#ifdef HAVE_IFADDRS_H
#include <ifaddrs.h>
#endif
/* own headers (part (1/2) */
#include "uuid_mac.h"
#ifndef FALSE
#define FALSE 0
#endif
#ifndef TRUE
#define TRUE (/*lint -save -e506*/ !FALSE /*lint -restore*/)
#endif
/* return the Media Access Control (MAC) address of
the FIRST network interface card (NIC) */
int mac_address(unsigned char *data_ptr, size_t data_len)
{
/* sanity check arguments */
if (data_ptr == NULL || data_len < MAC_LEN)
return FALSE;
#if defined(HAVE_IFADDRS_H) && defined(HAVE_NET_IF_DL_H) && defined(HAVE_GETIFADDRS)
/* use getifaddrs(3) on BSD class platforms (xxxBSD, MacOS X, etc) */
{
struct ifaddrs *ifap;
struct ifaddrs *ifap_head;
const struct sockaddr_dl *sdl;
unsigned char *ucp;
int i;
if (getifaddrs(&ifap_head) < 0)
return FALSE;
for (ifap = ifap_head; ifap != NULL; ifap = ifap->ifa_next) {
if (ifap->ifa_addr != NULL && ifap->ifa_addr->sa_family == AF_LINK) {
sdl = (const struct sockaddr_dl *)(void *)ifap->ifa_addr;
ucp = (unsigned char *)(sdl->sdl_data + sdl->sdl_nlen);
if (sdl->sdl_alen > 0) {
for (i = 0; i < MAC_LEN && i < sdl->sdl_alen; i++, ucp++)
data_ptr[i] = (unsigned char)(*ucp & 0xff);
freeifaddrs(ifap_head);
return TRUE;
}
}
}
freeifaddrs(ifap_head);
}
#endif
#if defined(HAVE_NET_IF_H) && defined(SIOCGIFHWADDR)
/* use SIOCGIFHWADDR ioctl(2) on Linux class platforms */
{
struct ifreq ifr;
struct sockaddr *sa;
int s;
int i;
if ((s = socket(PF_INET, SOCK_DGRAM, 0)) < 0)
return FALSE;
sprintf(ifr.ifr_name, "eth0");
if (ioctl(s, SIOCGIFHWADDR, &ifr) < 0) {
close(s);
return FALSE;
}
sa = (struct sockaddr *)&ifr.ifr_addr;
for (i = 0; i < MAC_LEN; i++)
data_ptr[i] = (unsigned char)(sa->sa_data[i] & 0xff);
close(s);
return TRUE;
}
#endif
#if defined(SIOCGARP)
/* use SIOCGARP ioctl(2) on SVR4 class platforms (Solaris, etc) */
{
char hostname[MAXHOSTNAMELEN];
struct hostent *he;
struct arpreq ar;
struct sockaddr_in *sa;
int s;
int i;
if (gethostname(hostname, sizeof(hostname)) < 0)
return FALSE;
if ((he = gethostbyname(hostname)) == NULL)
return FALSE;
if ((s = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0)
return FALSE;
memset(&ar, 0, sizeof(ar));
sa = (struct sockaddr_in *)((void *)&(ar.arp_pa));
sa->sin_family = AF_INET;
memcpy(&(sa->sin_addr), *(he->h_addr_list), sizeof(struct in_addr));
if (ioctl(s, SIOCGARP, &ar) < 0) {
close(s);
return FALSE;
}
close(s);
if (!(ar.arp_flags & ATF_COM))
return FALSE;
for (i = 0; i < MAC_LEN; i++)
data_ptr[i] = (unsigned char)(ar.arp_ha.sa_data[i] & 0xff);
return TRUE;
}
#endif
return FALSE;
}

View File

@ -1,54 +0,0 @@
/*
** OSSP uuid - Universally Unique Identifier
** Copyright (c) 2004-2008 Ralf S. Engelschall <rse@engelschall.com>
** Copyright (c) 2004-2008 The OSSP Project <http://www.ossp.org/>
**
** This file is part of OSSP uuid, a library for the generation
** of UUIDs which can found at http://www.ossp.org/pkg/lib/uuid/
**
** Permission to use, copy, modify, and distribute this software for
** any purpose with or without fee is hereby granted, provided that
** the above copyright notice and this permission notice appear in all
** copies.
**
** THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
** WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
** MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
** IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
** CONTRIBUTORS 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 ADVISED OF THE POSSIBILITY OF
** SUCH DAMAGE.
**
** uuid_mac.h: Media Access Control (MAC) resolver API definition
*/
#ifndef __UUID_MAC_H__
#define __UUID_MAC_H__
#include <string.h> /* size_t */
#define MAC_PREFIX uuid_
/* embedding support */
#ifdef MAC_PREFIX
#if defined(__STDC__) || defined(__cplusplus)
#define __MAC_CONCAT(x,y) x ## y
#define MAC_CONCAT(x,y) __MAC_CONCAT(x,y)
#else
#define __MAC_CONCAT(x) x
#define MAC_CONCAT(x,y) __MAC_CONCAT(x)y
#endif
#define mac_address MAC_CONCAT(MAC_PREFIX,mac_address)
#endif
#define MAC_LEN 6
extern int mac_address(unsigned char *_data_ptr, size_t _data_len);
#endif /* __UUID_MAC_H__ */

View File

@ -1,471 +0,0 @@
/*
** OSSP uuid - Universally Unique Identifier
** Copyright (c) 2004-2008 Ralf S. Engelschall <rse@engelschall.com>
** Copyright (c) 2004-2008 The OSSP Project <http://www.ossp.org/>
**
** This file is part of OSSP uuid, a library for the generation
** of UUIDs which can found at http://www.ossp.org/pkg/lib/uuid/
**
** Permission to use, copy, modify, and distribute this software for
** any purpose with or without fee is hereby granted, provided that
** the above copyright notice and this permission notice appear in all
** copies.
**
** THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
** WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
** MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
** IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
** CONTRIBUTORS 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 ADVISED OF THE POSSIBILITY OF
** SUCH DAMAGE.
**
** uuid_md5.c: MD5 API implementation
*/
/* own headers (part 1/2) */
#include "uuid_ac.h"
/* system headers */
#include <stdlib.h>
#include <string.h>
/* own headers (part 2/2) */
#include "uuid_md5.h"
/*
* This is a RFC 1321 compliant Message Digest 5 (MD5) algorithm
* implementation. It is directly derived from the RSA code published in
* RFC 1321 with just the following functionality preserving changes:
* - converted function definitions from K&R to ANSI C
* - included contents of the "global.h" and "md5.h" headers
* - moved the SXX defines into the MD5Transform function
* - replaced MD5_memcpy() with memcpy(3) and MD5_memset() with memset(3)
* - renamed "index" variables to "idx" to avoid namespace conflicts
* - reformatted C style to conform with OSSP C style
* - added own OSSP style frontend API
*/
/*
** ==== BEGIN RFC 1321 CODE ====
*/
/*
* RSA Data Security, Inc., MD5 message-digest algorithm
* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991.
* All rights reserved.
*
* License to copy and use this software is granted provided that it
* is identified as the "RSA Data Security, Inc. MD5 Message-Digest
* Algorithm" in all material mentioning or referencing this software
* or this function.
*
* License is also granted to make and use derivative works provided
* that such works are identified as "derived from the RSA Data
* Security, Inc. MD5 Message-Digest Algorithm" in all material
* mentioning or referencing the derived work.
*
* RSA Data Security, Inc. makes no representations concerning either
* the merchantability of this software or the suitability of this
* software for any particular purpose. It is provided "as is"
* without express or implied warranty of any kind.
*
* These notices must be retained in any copies of any part of this
* documentation and/or software.
*/
/* POINTER defines a generic pointer type */
typedef unsigned char *POINTER;
/* UINT4 defines a four byte word */
#if SIZEOF_UNSIGNED_SHORT == 4
typedef unsigned short int UINT4;
#elif SIZEOF_UNSIGNED_INT == 4
typedef unsigned int UINT4;
#elif SIZEOF_UNSIGNED_LONG == 4
typedef unsigned long int UINT4;
#elif SIZEOF_UNSIGNED_LONG_LONG == 4
typedef unsigned long long int UINT4;
#else
#error ERROR: unable to determine UINT4 type (four byte word)
#endif
/* MD5 context. */
typedef struct {
UINT4 state[4]; /* state (ABCD) */
UINT4 count[2]; /* number of bits, modulo 2^64 (lsb first) */
unsigned char buffer[64]; /* input buffer */
} MD5_CTX;
/* prototypes for internal functions */
static void MD5Init (MD5_CTX *_ctx);
static void MD5Update (MD5_CTX *_ctx, unsigned char *, unsigned int);
static void MD5Final (unsigned char [], MD5_CTX *);
static void MD5Transform (UINT4 [], unsigned char []);
static void Encode (unsigned char *, UINT4 *, unsigned int);
static void Decode (UINT4 *, unsigned char *, unsigned int);
/* finalization padding */
static unsigned char PADDING[64] = {
0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
/* F, G, H and I are basic MD5 functions. */
#define F(x, y, z) (((x) & (y)) | ((~x) & (z)))
#define G(x, y, z) (((x) & (z)) | ((y) & (~z)))
#define H(x, y, z) ((x) ^ (y) ^ (z))
#define I(x, y, z) ((y) ^ ((x) | (~z)))
/* ROTATE_LEFT rotates x left n bits. */
#define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32-(n))))
/* FF, GG, HH, and II transformations for rounds 1, 2, 3, and 4.
Rotation is separate from addition to prevent recomputation. */
#define FF(a, b, c, d, x, s, ac) { \
(a) += F ((b), (c), (d)) + (x) + (UINT4)(ac); \
(a) = ROTATE_LEFT ((a), (s)); \
(a) += (b); \
}
#define GG(a, b, c, d, x, s, ac) { \
(a) += G ((b), (c), (d)) + (x) + (UINT4)(ac); \
(a) = ROTATE_LEFT ((a), (s)); \
(a) += (b); \
}
#define HH(a, b, c, d, x, s, ac) { \
(a) += H ((b), (c), (d)) + (x) + (UINT4)(ac); \
(a) = ROTATE_LEFT ((a), (s)); \
(a) += (b); \
}
#define II(a, b, c, d, x, s, ac) { \
(a) += I ((b), (c), (d)) + (x) + (UINT4)(ac); \
(a) = ROTATE_LEFT ((a), (s)); \
(a) += (b); \
}
/* MD5 initialization. Begins an MD5 operation, writing a new context. */
static void MD5Init(
MD5_CTX *context)
{
context->count[0] = context->count[1] = 0;
/* Load magic initialization constants. */
context->state[0] = 0x67452301;
context->state[1] = 0xefcdab89;
context->state[2] = 0x98badcfe;
context->state[3] = 0x10325476;
return;
}
/* MD5 block update operation. Continues an MD5 message-digest
operation, processing another message block, and updating the
context. */
static void MD5Update(
MD5_CTX *context, /* context */
unsigned char *input, /* input block */
unsigned int inputLen) /* length of input block */
{
unsigned int i, idx, partLen;
/* Compute number of bytes mod 64 */
idx = (unsigned int)((context->count[0] >> 3) & 0x3F);
/* Update number of bits */
if ((context->count[0] += ((UINT4)inputLen << 3)) < ((UINT4)inputLen << 3))
context->count[1]++;
context->count[1] += ((UINT4)inputLen >> 29);
partLen = (unsigned int)64 - idx;
/* Transform as many times as possible. */
if (inputLen >= partLen) {
memcpy((POINTER)&context->buffer[idx], (POINTER)input, (size_t)partLen);
MD5Transform(context->state, context->buffer);
for (i = partLen; i + 63 < inputLen; i += 64)
MD5Transform(context->state, &input[i]);
idx = 0;
}
else
i = 0;
/* Buffer remaining input */
memcpy((POINTER)&context->buffer[idx], (POINTER)&input[i], (size_t)(inputLen - i));
}
/* MD5 finalization. Ends an MD5 message-digest operation, writing the
the message digest and zeroizing the context. */
static void MD5Final(
unsigned char digest[], /* message digest */
MD5_CTX *context) /* context */
{
unsigned char bits[8];
unsigned int idx, padLen;
/* Save number of bits */
Encode(bits, context->count, 8);
/* Pad out to 56 mod 64. */
idx = (unsigned int)((context->count[0] >> 3) & 0x3f);
padLen = (idx < 56) ? ((unsigned int)56 - idx) : ((unsigned int)120 - idx);
MD5Update(context, PADDING, padLen);
/* Append length (before padding) */
MD5Update(context, bits, 8);
/* Store state in digest */
Encode(digest, context->state, 16);
/* Zeroize sensitive information. */
memset((POINTER)context, 0, sizeof(*context));
}
/* MD5 basic transformation. Transforms state based on block. */
static void MD5Transform(
UINT4 state[],
unsigned char block[])
{
UINT4 a = state[0], b = state[1], c = state[2], d = state[3], x[16];
Decode(x, block, 64);
/* Round 1 */
#define S11 7
#define S12 12
#define S13 17
#define S14 22
FF (a, b, c, d, x[ 0], S11, 0xd76aa478); /* 1 */
FF (d, a, b, c, x[ 1], S12, 0xe8c7b756); /* 2 */
FF (c, d, a, b, x[ 2], S13, 0x242070db); /* 3 */
FF (b, c, d, a, x[ 3], S14, 0xc1bdceee); /* 4 */
FF (a, b, c, d, x[ 4], S11, 0xf57c0faf); /* 5 */
FF (d, a, b, c, x[ 5], S12, 0x4787c62a); /* 6 */
FF (c, d, a, b, x[ 6], S13, 0xa8304613); /* 7 */
FF (b, c, d, a, x[ 7], S14, 0xfd469501); /* 8 */
FF (a, b, c, d, x[ 8], S11, 0x698098d8); /* 9 */
FF (d, a, b, c, x[ 9], S12, 0x8b44f7af); /* 10 */
FF (c, d, a, b, x[10], S13, 0xffff5bb1); /* 11 */
FF (b, c, d, a, x[11], S14, 0x895cd7be); /* 12 */
FF (a, b, c, d, x[12], S11, 0x6b901122); /* 13 */
FF (d, a, b, c, x[13], S12, 0xfd987193); /* 14 */
FF (c, d, a, b, x[14], S13, 0xa679438e); /* 15 */
FF (b, c, d, a, x[15], S14, 0x49b40821); /* 16 */
/* Round 2 */
#define S21 5
#define S22 9
#define S23 14
#define S24 20
GG (a, b, c, d, x[ 1], S21, 0xf61e2562); /* 17 */
GG (d, a, b, c, x[ 6], S22, 0xc040b340); /* 18 */
GG (c, d, a, b, x[11], S23, 0x265e5a51); /* 19 */
GG (b, c, d, a, x[ 0], S24, 0xe9b6c7aa); /* 20 */
GG (a, b, c, d, x[ 5], S21, 0xd62f105d); /* 21 */
GG (d, a, b, c, x[10], S22, 0x2441453); /* 22 */
GG (c, d, a, b, x[15], S23, 0xd8a1e681); /* 23 */
GG (b, c, d, a, x[ 4], S24, 0xe7d3fbc8); /* 24 */
GG (a, b, c, d, x[ 9], S21, 0x21e1cde6); /* 25 */
GG (d, a, b, c, x[14], S22, 0xc33707d6); /* 26 */
GG (c, d, a, b, x[ 3], S23, 0xf4d50d87); /* 27 */
GG (b, c, d, a, x[ 8], S24, 0x455a14ed); /* 28 */
GG (a, b, c, d, x[13], S21, 0xa9e3e905); /* 29 */
GG (d, a, b, c, x[ 2], S22, 0xfcefa3f8); /* 30 */
GG (c, d, a, b, x[ 7], S23, 0x676f02d9); /* 31 */
GG (b, c, d, a, x[12], S24, 0x8d2a4c8a); /* 32 */
/* Round 3 */
#define S31 4
#define S32 11
#define S33 16
#define S34 23
HH (a, b, c, d, x[ 5], S31, 0xfffa3942); /* 33 */
HH (d, a, b, c, x[ 8], S32, 0x8771f681); /* 34 */
HH (c, d, a, b, x[11], S33, 0x6d9d6122); /* 35 */
HH (b, c, d, a, x[14], S34, 0xfde5380c); /* 36 */
HH (a, b, c, d, x[ 1], S31, 0xa4beea44); /* 37 */
HH (d, a, b, c, x[ 4], S32, 0x4bdecfa9); /* 38 */
HH (c, d, a, b, x[ 7], S33, 0xf6bb4b60); /* 39 */
HH (b, c, d, a, x[10], S34, 0xbebfbc70); /* 40 */
HH (a, b, c, d, x[13], S31, 0x289b7ec6); /* 41 */
HH (d, a, b, c, x[ 0], S32, 0xeaa127fa); /* 42 */
HH (c, d, a, b, x[ 3], S33, 0xd4ef3085); /* 43 */
HH (b, c, d, a, x[ 6], S34, 0x4881d05); /* 44 */
HH (a, b, c, d, x[ 9], S31, 0xd9d4d039); /* 45 */
HH (d, a, b, c, x[12], S32, 0xe6db99e5); /* 46 */
HH (c, d, a, b, x[15], S33, 0x1fa27cf8); /* 47 */
HH (b, c, d, a, x[ 2], S34, 0xc4ac5665); /* 48 */
/* Round 4 */
#define S41 6
#define S42 10
#define S43 15
#define S44 21
II (a, b, c, d, x[ 0], S41, 0xf4292244); /* 49 */
II (d, a, b, c, x[ 7], S42, 0x432aff97); /* 50 */
II (c, d, a, b, x[14], S43, 0xab9423a7); /* 51 */
II (b, c, d, a, x[ 5], S44, 0xfc93a039); /* 52 */
II (a, b, c, d, x[12], S41, 0x655b59c3); /* 53 */
II (d, a, b, c, x[ 3], S42, 0x8f0ccc92); /* 54 */
II (c, d, a, b, x[10], S43, 0xffeff47d); /* 55 */
II (b, c, d, a, x[ 1], S44, 0x85845dd1); /* 56 */
II (a, b, c, d, x[ 8], S41, 0x6fa87e4f); /* 57 */
II (d, a, b, c, x[15], S42, 0xfe2ce6e0); /* 58 */
II (c, d, a, b, x[ 6], S43, 0xa3014314); /* 59 */
II (b, c, d, a, x[13], S44, 0x4e0811a1); /* 60 */
II (a, b, c, d, x[ 4], S41, 0xf7537e82); /* 61 */
II (d, a, b, c, x[11], S42, 0xbd3af235); /* 62 */
II (c, d, a, b, x[ 2], S43, 0x2ad7d2bb); /* 63 */
II (b, c, d, a, x[ 9], S44, 0xeb86d391); /* 64 */
state[0] += a;
state[1] += b;
state[2] += c;
state[3] += d;
/* Zeroize sensitive information. */
memset((POINTER)x, 0, sizeof(x));
}
/* Encodes input (UINT4) into output (unsigned char).
Assumes len is a multiple of 4. */
static void Encode(
unsigned char *output,
UINT4 *input,
unsigned int len)
{
unsigned int i, j;
for (i = 0, j = 0; j < len; i++, j += 4) {
output[j] = (unsigned char)( input[i] & 0xff);
output[j+1] = (unsigned char)((input[i] >> 8) & 0xff);
output[j+2] = (unsigned char)((input[i] >> 16) & 0xff);
output[j+3] = (unsigned char)((input[i] >> 24) & 0xff);
}
return;
}
/* Decodes input (unsigned char) into output (UINT4).
Assumes len is a multiple of 4. */
static void Decode(
UINT4 *output,
unsigned char *input,
unsigned int len)
{
unsigned int i, j;
for (i = 0, j = 0; j < len; i++, j += 4)
output[i] = ( (UINT4)input[j])
| (((UINT4)input[j+1]) << 8 )
| (((UINT4)input[j+2]) << 16)
| (((UINT4)input[j+3]) << 24);
return;
}
/*
** ==== END RFC 1321 CODE ====
*/
struct md5_st {
MD5_CTX ctx;
};
md5_rc_t md5_create(md5_t **md5)
{
if (md5 == NULL)
return MD5_RC_ARG;
if ((*md5 = (md5_t *)malloc(sizeof(md5_t))) == NULL)
return MD5_RC_MEM;
MD5Init(&((*md5)->ctx));
return MD5_RC_OK;
}
md5_rc_t md5_init(md5_t *md5)
{
if (md5 == NULL)
return MD5_RC_ARG;
MD5Init(&(md5->ctx));
return MD5_RC_OK;
}
md5_rc_t md5_update(md5_t *md5, const void *data_ptr, size_t data_len)
{
if (md5 == NULL)
return MD5_RC_ARG;
MD5Update(&(md5->ctx), (unsigned char *)data_ptr, (unsigned int)data_len);
return MD5_RC_OK;
}
md5_rc_t md5_store(md5_t *md5, void **data_ptr, size_t *data_len)
{
MD5_CTX ctx;
if (md5 == NULL || data_ptr == NULL)
return MD5_RC_ARG;
if (*data_ptr == NULL) {
if ((*data_ptr = malloc(MD5_LEN_BIN)) == NULL)
return MD5_RC_MEM;
if (data_len != NULL)
*data_len = MD5_LEN_BIN;
}
else {
if (data_len != NULL) {
if (*data_len < MD5_LEN_BIN)
return MD5_RC_MEM;
*data_len = MD5_LEN_BIN;
}
}
memcpy((void *)(&ctx), (void *)(&(md5->ctx)), sizeof(MD5_CTX));
MD5Final((unsigned char *)(*data_ptr), &(ctx));
return MD5_RC_OK;
}
md5_rc_t md5_format(md5_t *md5, char **data_ptr, size_t *data_len)
{
static const char hex[] = "0123456789abcdef";
unsigned char buf[MD5_LEN_BIN];
unsigned char *bufptr;
size_t buflen;
md5_rc_t rc;
int i;
if (md5 == NULL || data_ptr == NULL)
return MD5_RC_ARG;
if (*data_ptr == NULL) {
if ((*data_ptr = (char *)malloc(MD5_LEN_STR+1)) == NULL)
return MD5_RC_MEM;
if (data_len != NULL)
*data_len = MD5_LEN_STR+1;
}
else {
if (data_len != NULL) {
if (*data_len < MD5_LEN_STR+1)
return MD5_RC_MEM;
*data_len = MD5_LEN_STR+1;
}
}
bufptr = buf;
buflen = sizeof(buf);
if ((rc = md5_store(md5, (void **)((void *)&bufptr), &buflen)) != MD5_RC_OK)
return rc;
for (i = 0; i < (int)buflen; i++) {
(*data_ptr)[(i*2)+0] = hex[(int)(bufptr[i] >> 4)];
(*data_ptr)[(i*2)+1] = hex[(int)(bufptr[i] & 0x0f)];
}
(*data_ptr)[(i*2)] = '\0';
return MD5_RC_OK;
}
md5_rc_t md5_destroy(md5_t *md5)
{
if (md5 == NULL)
return MD5_RC_ARG;
free(md5);
return MD5_RC_OK;
}

View File

@ -1,76 +0,0 @@
/*
** OSSP uuid - Universally Unique Identifier
** Copyright (c) 2004-2008 Ralf S. Engelschall <rse@engelschall.com>
** Copyright (c) 2004-2008 The OSSP Project <http://www.ossp.org/>
**
** This file is part of OSSP uuid, a library for the generation
** of UUIDs which can found at http://www.ossp.org/pkg/lib/uuid/
**
** Permission to use, copy, modify, and distribute this software for
** any purpose with or without fee is hereby granted, provided that
** the above copyright notice and this permission notice appear in all
** copies.
**
** THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
** WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
** MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
** IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
** CONTRIBUTORS 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 ADVISED OF THE POSSIBILITY OF
** SUCH DAMAGE.
**
** uuid_md5.h: MD5 API definition
*/
#ifndef __MD5_H___
#define __MD5_H___
#include <string.h> /* size_t */
#define MD5_PREFIX uuid_
/* embedding support */
#ifdef MD5_PREFIX
#if defined(__STDC__) || defined(__cplusplus)
#define __MD5_CONCAT(x,y) x ## y
#define MD5_CONCAT(x,y) __MD5_CONCAT(x,y)
#else
#define __MD5_CONCAT(x) x
#define MD5_CONCAT(x,y) __MD5_CONCAT(x)y
#endif
#define md5_st MD5_CONCAT(MD5_PREFIX,md5_st)
#define md5_t MD5_CONCAT(MD5_PREFIX,md5_t)
#define md5_create MD5_CONCAT(MD5_PREFIX,md5_create)
#define md5_init MD5_CONCAT(MD5_PREFIX,md5_init)
#define md5_update MD5_CONCAT(MD5_PREFIX,md5_update)
#define md5_store MD5_CONCAT(MD5_PREFIX,md5_store)
#define md5_format MD5_CONCAT(MD5_PREFIX,md5_format)
#define md5_destroy MD5_CONCAT(MD5_PREFIX,md5_destroy)
#endif
struct md5_st;
typedef struct md5_st md5_t;
#define MD5_LEN_BIN 16
#define MD5_LEN_STR 32
typedef enum {
MD5_RC_OK = 0,
MD5_RC_ARG = 1,
MD5_RC_MEM = 2
} md5_rc_t;
extern md5_rc_t md5_create (md5_t **md5);
extern md5_rc_t md5_init (md5_t *md5);
extern md5_rc_t md5_update (md5_t *md5, const void *data_ptr, size_t data_len);
extern md5_rc_t md5_store (md5_t *md5, void **data_ptr, size_t *data_len);
extern md5_rc_t md5_format (md5_t *md5, char **data_ptr, size_t *data_len);
extern md5_rc_t md5_destroy (md5_t *md5);
#endif /* __MD5_H___ */

View File

@ -1,198 +0,0 @@
/*
** OSSP uuid - Universally Unique Identifier
** Copyright (c) 2004-2008 Ralf S. Engelschall <rse@engelschall.com>
** Copyright (c) 2004-2008 The OSSP Project <http://www.ossp.org/>
**
** This file is part of OSSP uuid, a library for the generation
** of UUIDs which can found at http://www.ossp.org/pkg/lib/uuid/
**
** Permission to use, copy, modify, and distribute this software for
** any purpose with or without fee is hereby granted, provided that
** the above copyright notice and this permission notice appear in all
** copies.
**
** THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
** WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
** MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
** IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
** CONTRIBUTORS 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 ADVISED OF THE POSSIBILITY OF
** SUCH DAMAGE.
**
** uuid_prng.c: PRNG API implementation
*/
/* own headers (part 1/2) */
#include "uuid_ac.h"
/* system headers */
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <time.h>
#include <sys/time.h>
#include <fcntl.h>
#if defined(WIN32)
#define WINVER 0x0500
#include <windows.h>
#include <wincrypt.h>
#endif
/* own headers (part 2/2) */
#include "uuid_time.h"
#include "uuid_prng.h"
#include "uuid_md5.h"
struct prng_st {
int dev; /* system PRNG device */
md5_t *md5; /* local MD5 PRNG engine */
long cnt; /* time resolution compensation counter */
};
prng_rc_t prng_create(prng_t **prng)
{
#if !defined(WIN32)
int fd = -1;
#endif
struct timeval tv;
pid_t pid;
unsigned int i;
/* sanity check argument(s) */
if (prng == NULL)
return PRNG_RC_ARG;
/* allocate object */
if ((*prng = (prng_t *)malloc(sizeof(prng_t))) == NULL)
return PRNG_RC_MEM;
/* try to open the system PRNG device */
(*prng)->dev = -1;
#if !defined(WIN32)
if ((fd = open("/dev/urandom", O_RDONLY)) == -1)
fd = open("/dev/random", O_RDONLY|O_NONBLOCK);
if (fd != -1) {
(void)fcntl(fd, F_SETFD, FD_CLOEXEC);
(*prng)->dev = fd;
}
#endif
/* initialize MD5 engine */
if (md5_create(&((*prng)->md5)) != MD5_RC_OK) {
free(*prng);
return PRNG_RC_INT;
}
/* initialize time resolution compensation counter */
(*prng)->cnt = 0;
/* seed the C library PRNG once */
(void)time_gettimeofday(&tv);
pid = getpid();
srand((unsigned int)(
((unsigned int)pid << 16)
^ (unsigned int)pid
^ (unsigned int)tv.tv_sec
^ (unsigned int)tv.tv_usec));
for (i = (unsigned int)((tv.tv_sec ^ tv.tv_usec) & 0x1F); i > 0; i--)
(void)rand();
return PRNG_RC_OK;
}
prng_rc_t prng_data(prng_t *prng, void *data_ptr, size_t data_len)
{
size_t n;
unsigned char *p;
struct {
struct timeval tv;
long cnt;
int rnd;
} entropy;
unsigned char md5_buf[MD5_LEN_BIN];
unsigned char *md5_ptr;
size_t md5_len;
int retries;
int i;
#if defined(WIN32)
HCRYPTPROV hProv;
#endif
/* sanity check argument(s) */
if (prng == NULL || data_len == 0)
return PRNG_RC_ARG;
/* prepare for generation */
p = (unsigned char *)data_ptr;
n = data_len;
/* approach 1: try to gather data via stronger system PRNG device */
if (prng->dev != -1) {
retries = 0;
while (n > 0) {
i = (int)read(prng->dev, (void *)p, n);
if (i <= 0) {
if (retries++ > 16)
break;
continue;
}
retries = 0;
n -= (unsigned int)i;
p += (unsigned int)i;
}
}
#if defined(WIN32)
else {
if (CryptAcquireContext(&hProv, NULL, NULL, PROV_RSA_FULL, 0))
CryptGenRandom(hProv, n, p);
}
#endif
/* approach 2: try to gather data via weaker libc PRNG API. */
while (n > 0) {
/* gather new entropy */
(void)time_gettimeofday(&(entropy.tv)); /* source: libc time */
entropy.rnd = rand(); /* source: libc PRNG */
entropy.cnt = prng->cnt++; /* source: local counter */
/* pass entropy into MD5 engine */
if (md5_update(prng->md5, (void *)&entropy, sizeof(entropy)) != MD5_RC_OK)
return PRNG_RC_INT;
/* store MD5 engine state as PRN output */
md5_ptr = md5_buf;
md5_len = sizeof(md5_buf);
if (md5_store(prng->md5, (void **)(void *)&md5_ptr, &md5_len) != MD5_RC_OK)
return PRNG_RC_INT;
for (i = 0; i < MD5_LEN_BIN && n > 0; i++, n--)
*p++ ^= md5_buf[i]; /* intentionally no assignment because arbitrary
caller buffer content is leveraged, too */
}
return PRNG_RC_OK;
}
prng_rc_t prng_destroy(prng_t *prng)
{
/* sanity check argument(s) */
if (prng == NULL)
return PRNG_RC_ARG;
/* close PRNG device */
if (prng->dev != -1)
(void)close(prng->dev);
/* destroy MD5 engine */
(void)md5_destroy(prng->md5);
/* free object */
free(prng);
return PRNG_RC_OK;
}

View File

@ -1,68 +0,0 @@
/*
** OSSP uuid - Universally Unique Identifier
** Copyright (c) 2004-2008 Ralf S. Engelschall <rse@engelschall.com>
** Copyright (c) 2004-2008 The OSSP Project <http://www.ossp.org/>
**
** This file is part of OSSP uuid, a library for the generation
** of UUIDs which can found at http://www.ossp.org/pkg/lib/uuid/
**
** Permission to use, copy, modify, and distribute this software for
** any purpose with or without fee is hereby granted, provided that
** the above copyright notice and this permission notice appear in all
** copies.
**
** THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
** WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
** MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
** IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
** CONTRIBUTORS 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 ADVISED OF THE POSSIBILITY OF
** SUCH DAMAGE.
**
** uuid_prng.h: PRNG API definition
*/
#ifndef __PRNG_H___
#define __PRNG_H___
#include <string.h> /* size_t */
#define PRNG_PREFIX uuid_
/* embedding support */
#ifdef PRNG_PREFIX
#if defined(__STDC__) || defined(__cplusplus)
#define __PRNG_CONCAT(x,y) x ## y
#define PRNG_CONCAT(x,y) __PRNG_CONCAT(x,y)
#else
#define __PRNG_CONCAT(x) x
#define PRNG_CONCAT(x,y) __PRNG_CONCAT(x)y
#endif
#define prng_st PRNG_CONCAT(PRNG_PREFIX,prng_st)
#define prng_t PRNG_CONCAT(PRNG_PREFIX,prng_t)
#define prng_create PRNG_CONCAT(PRNG_PREFIX,prng_create)
#define prng_data PRNG_CONCAT(PRNG_PREFIX,prng_data)
#define prng_destroy PRNG_CONCAT(PRNG_PREFIX,prng_destroy)
#endif
struct prng_st;
typedef struct prng_st prng_t;
typedef enum {
PRNG_RC_OK = 0,
PRNG_RC_ARG = 1,
PRNG_RC_MEM = 2,
PRNG_RC_INT = 3
} prng_rc_t;
extern prng_rc_t prng_create (prng_t **prng);
extern prng_rc_t prng_data (prng_t *prng, void *data_ptr, size_t data_len);
extern prng_rc_t prng_destroy (prng_t *prng);
#endif /* __PRNG_H___ */

View File

@ -1,450 +0,0 @@
/*
** OSSP uuid - Universally Unique Identifier
** Copyright (c) 2004-2008 Ralf S. Engelschall <rse@engelschall.com>
** Copyright (c) 2004-2008 The OSSP Project <http://www.ossp.org/>
**
** This file is part of OSSP uuid, a library for the generation
** of UUIDs which can found at http://www.ossp.org/pkg/lib/uuid/
**
** Permission to use, copy, modify, and distribute this software for
** any purpose with or without fee is hereby granted, provided that
** the above copyright notice and this permission notice appear in all
** copies.
**
** THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
** WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
** MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
** IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
** CONTRIBUTORS 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 ADVISED OF THE POSSIBILITY OF
** SUCH DAMAGE.
**
** uuid_sha1.c: SHA-1 API implementation
*/
/* own headers (part 1/2) */
#include "uuid_ac.h"
/* system headers */
#include <stdlib.h>
#include <string.h>
/* own headers (part 2/2) */
#include "uuid_sha1.h"
/*
* This is a RFC 3174 compliant Secure Hash Function (SHA-1) algorithm
* implementation. It is directly derived from the SHA-1 reference
* code published in RFC 3174 with just the following functionality
* preserving changes:
* - reformatted C style to conform with OSSP C style
* - added own OSSP style frontend API
* - added Autoconf based determination of sha1_uintX_t types
*/
/*
** ==== BEGIN RFC 3174 CODE ====
*/
/*
* This implements the Secure Hashing Algorithm 1 as defined in
* FIPS PUB 180-1 published April 17, 1995.
*
* The SHA-1, produces a 160-bit message digest for a given data
* stream. It should take about 2**n steps to find a message with the
* same digest as a given message and 2**(n/2) to find any two messages
* with the same digest, when n is the digest size in bits. Therefore,
* this algorithm can serve as a means of providing a "fingerprint" for
* a message.
*
* Caveats: SHA-1 is designed to work with messages less than 2^64 bits
* long. Although SHA-1 allows a message digest to be generated for
* messages of any number of bits less than 2^64, this implementation
* only works with messages with a length that is a multiple of the
* size of an 8-bit character.
*/
typedef unsigned char sha1_uint8_t;
#if SIZEOF_SHORT > 2
typedef short int sha1_int16plus_t;
#elif SIZEOF_INT > 2
typedef int sha1_int16plus_t;
#elif SIZEOF_LONG > 2
typedef long int sha1_int16plus_t;
#else
#error ERROR: unable to determine sha1_int16plus_t type (at least two byte word)
#endif
#if SIZEOF_UNSIGNED_SHORT == 4
typedef unsigned short int sha1_uint32_t;
#elif SIZEOF_UNSIGNED_INT == 4
typedef unsigned int sha1_uint32_t;
#elif SIZEOF_UNSIGNED_LONG == 4
typedef unsigned long int sha1_uint32_t;
#elif SIZEOF_UNSIGNED_LONG_LONG == 4
typedef unsigned long long int sha1_uint32_t;
#else
#error ERROR: unable to determine sha1_uint32_t type (four byte word)
#endif
enum {
shaSuccess = 0,
shaNull, /* null pointer parameter */
shaStateError /* called Input after Result */
};
#define SHA1HashSize 20
/* This structure will hold context information for the SHA-1 hashing operation */
typedef struct SHA1Context {
sha1_uint32_t Intermediate_Hash[SHA1HashSize/4]; /* Message Digest */
sha1_uint32_t Length_Low; /* Message length in bits */
sha1_uint32_t Length_High; /* Message length in bits */
sha1_int16plus_t Message_Block_Index; /* Index into message block array */
sha1_uint8_t Message_Block[64]; /* 512-bit message blocks */
int Computed; /* Is the digest computed? */
int Corrupted; /* Is the message digest corrupted? */
} SHA1Context;
/* Function Prototypes */
static int SHA1Reset (SHA1Context *);
static int SHA1Input (SHA1Context *, const sha1_uint8_t *, unsigned int);
static int SHA1Result (SHA1Context *, sha1_uint8_t Message_Digest[]);
/* Local Function Prototyptes */
static void SHA1PadMessage (SHA1Context *);
static void SHA1ProcessMessageBlock(SHA1Context *);
/* Define the SHA1 circular left shift macro */
#define SHA1CircularShift(bits,word) \
(((word) << (bits)) | ((word) >> (32-(bits))))
/*
* This function will initialize the SHA1Context in preparation for
* computing a new SHA1 message digest.
*/
static int SHA1Reset(SHA1Context *context)
{
if (context == NULL)
return shaNull;
context->Length_Low = 0;
context->Length_High = 0;
context->Message_Block_Index = 0;
context->Intermediate_Hash[0] = 0x67452301;
context->Intermediate_Hash[1] = 0xEFCDAB89;
context->Intermediate_Hash[2] = 0x98BADCFE;
context->Intermediate_Hash[3] = 0x10325476;
context->Intermediate_Hash[4] = 0xC3D2E1F0;
context->Computed = 0;
context->Corrupted = 0;
return shaSuccess;
}
/*
* This function will return the 160-bit message digest into the
* Message_Digest array provided by the caller. NOTE: The first octet
* of hash is stored in the 0th element, the last octet of hash in the
* 19th element.
*/
static int SHA1Result(SHA1Context *context, sha1_uint8_t Message_Digest[])
{
int i;
if (context == NULL || Message_Digest == NULL)
return shaNull;
if (context->Corrupted)
return context->Corrupted;
if (!context->Computed) {
SHA1PadMessage(context);
for (i = 0; i < 64; i++) {
/* message may be sensitive, clear it out */
context->Message_Block[i] = (sha1_uint8_t)0;
}
context->Length_Low = 0; /* and clear length */
context->Length_High = 0;
context->Computed = 1;
}
for (i = 0; i < SHA1HashSize; i++)
Message_Digest[i] = (sha1_uint8_t)(context->Intermediate_Hash[i>>2] >> (8 * (3 - (i & 0x03))));
return shaSuccess;
}
/*
* This function accepts an array of octets as the next portion of the
* message.
*/
static int SHA1Input(SHA1Context *context, const sha1_uint8_t *message_array, unsigned int length)
{
if (length == 0)
return shaSuccess;
if (context == NULL || message_array == NULL)
return shaNull;
if (context->Computed) {
context->Corrupted = shaStateError;
return shaStateError;
}
if (context->Corrupted)
return context->Corrupted;
while (length-- && !context->Corrupted) {
context->Message_Block[context->Message_Block_Index++] = (*message_array & 0xFF);
context->Length_Low += 8;
if (context->Length_Low == 0) {
context->Length_High++;
if (context->Length_High == 0)
context->Corrupted = 1; /* Message is too long */
}
if (context->Message_Block_Index == 64)
SHA1ProcessMessageBlock(context);
message_array++;
}
return shaSuccess;
}
/*
* This function will process the next 512 bits of the message stored
* in the Message_Block array. NOTICE: Many of the variable names in
* this code, especially the single character names, were used because
* those were the names used in the publication.
*/
static void SHA1ProcessMessageBlock(SHA1Context *context)
{
const sha1_uint32_t K[] = { /* Constants defined in SHA-1 */
0x5A827999,
0x6ED9EBA1,
0x8F1BBCDC,
0xCA62C1D6
};
int t; /* Loop counter */
sha1_uint32_t temp; /* Temporary word value */
sha1_uint32_t W[80]; /* Word sequence */
sha1_uint32_t A, B, C, D, E; /* Word buffers */
/* Initialize the first 16 words in the array W */
for (t = 0; t < 16; t++) {
W[t] = (sha1_uint32_t)(context->Message_Block[t * 4 ] << 24);
W[t] |= (sha1_uint32_t)(context->Message_Block[t * 4 + 1] << 16);
W[t] |= (sha1_uint32_t)(context->Message_Block[t * 4 + 2] << 8);
W[t] |= (sha1_uint32_t)(context->Message_Block[t * 4 + 3] );
}
for (t = 16; t < 80; t++)
W[t] = SHA1CircularShift(1, W[t-3] ^ W[t-8] ^ W[t-14] ^ W[t-16]);
A = context->Intermediate_Hash[0];
B = context->Intermediate_Hash[1];
C = context->Intermediate_Hash[2];
D = context->Intermediate_Hash[3];
E = context->Intermediate_Hash[4];
for (t = 0; t < 20; t++) {
temp = SHA1CircularShift(5, A) + ((B & C) | ((~B) & D)) + E + W[t] + K[0];
E = D;
D = C;
C = SHA1CircularShift(30, B);
B = A;
A = temp;
}
for (t = 20; t < 40; t++) {
temp = SHA1CircularShift(5, A) + (B ^ C ^ D) + E + W[t] + K[1];
E = D;
D = C;
C = SHA1CircularShift(30, B);
B = A;
A = temp;
}
for (t = 40; t < 60; t++) {
temp = SHA1CircularShift(5, A) + ((B & C) | (B & D) | (C & D)) + E + W[t] + K[2];
E = D;
D = C;
C = SHA1CircularShift(30, B);
B = A;
A = temp;
}
for (t = 60; t < 80; t++) {
temp = SHA1CircularShift(5, A) + (B ^ C ^ D) + E + W[t] + K[3];
E = D;
D = C;
C = SHA1CircularShift(30, B);
B = A;
A = temp;
}
context->Intermediate_Hash[0] += A;
context->Intermediate_Hash[1] += B;
context->Intermediate_Hash[2] += C;
context->Intermediate_Hash[3] += D;
context->Intermediate_Hash[4] += E;
context->Message_Block_Index = 0;
return;
}
/*
* According to the standard, the message must be padded to an even
* 512 bits. The first padding bit must be a '1'. The last 64 bits
* represent the length of the original message. All bits in between
* should be 0. This function will pad the message according to those
* rules by filling the Message_Block array accordingly. It will also
* call the ProcessMessageBlock function provided appropriately. When
* it returns, it can be assumed that the message digest has been
* computed.
*/
static void SHA1PadMessage(SHA1Context *context)
{
/* Check to see if the current message block is too small to hold
the initial padding bits and length. If so, we will pad the block,
process it, and then continue padding into a second block. */
if (context->Message_Block_Index > 55) {
context->Message_Block[context->Message_Block_Index++] = (sha1_uint8_t)0x80;
while (context->Message_Block_Index < 64)
context->Message_Block[context->Message_Block_Index++] = (sha1_uint8_t)0;
SHA1ProcessMessageBlock(context);
while(context->Message_Block_Index < 56)
context->Message_Block[context->Message_Block_Index++] = (sha1_uint8_t)0;
}
else {
context->Message_Block[context->Message_Block_Index++] = (sha1_uint8_t)0x80;
while(context->Message_Block_Index < 56)
context->Message_Block[context->Message_Block_Index++] = (sha1_uint8_t)0;
}
/* Store the message length as the last 8 octets */
context->Message_Block[56] = (sha1_uint8_t)(context->Length_High >> 24);
context->Message_Block[57] = (sha1_uint8_t)(context->Length_High >> 16);
context->Message_Block[58] = (sha1_uint8_t)(context->Length_High >> 8);
context->Message_Block[59] = (sha1_uint8_t)(context->Length_High );
context->Message_Block[60] = (sha1_uint8_t)(context->Length_Low >> 24);
context->Message_Block[61] = (sha1_uint8_t)(context->Length_Low >> 16);
context->Message_Block[62] = (sha1_uint8_t)(context->Length_Low >> 8);
context->Message_Block[63] = (sha1_uint8_t)(context->Length_Low );
SHA1ProcessMessageBlock(context);
return;
}
/*
** ==== END RFC 3174 CODE ====
*/
struct sha1_st {
SHA1Context ctx;
};
sha1_rc_t sha1_create(sha1_t **sha1)
{
if (sha1 == NULL)
return SHA1_RC_ARG;
if ((*sha1 = (sha1_t *)malloc(sizeof(sha1_t))) == NULL)
return SHA1_RC_MEM;
if (SHA1Reset(&((*sha1)->ctx)) != shaSuccess)
return SHA1_RC_INT;
return SHA1_RC_OK;
}
sha1_rc_t sha1_init(sha1_t *sha1)
{
if (sha1 == NULL)
return SHA1_RC_ARG;
if (SHA1Reset(&(sha1->ctx)) != shaSuccess)
return SHA1_RC_INT;
return SHA1_RC_OK;
}
sha1_rc_t sha1_update(sha1_t *sha1, const void *data_ptr, size_t data_len)
{
if (sha1 == NULL)
return SHA1_RC_ARG;
if (SHA1Input(&(sha1->ctx), (unsigned char *)data_ptr, (unsigned int)data_len) != shaSuccess)
return SHA1_RC_INT;
return SHA1_RC_OK;
}
sha1_rc_t sha1_store(sha1_t *sha1, void **data_ptr, size_t *data_len)
{
SHA1Context ctx;
if (sha1 == NULL || data_ptr == NULL)
return SHA1_RC_ARG;
if (*data_ptr == NULL) {
if ((*data_ptr = malloc(SHA1_LEN_BIN)) == NULL)
return SHA1_RC_MEM;
if (data_len != NULL)
*data_len = SHA1_LEN_BIN;
}
else {
if (data_len != NULL) {
if (*data_len < SHA1_LEN_BIN)
return SHA1_RC_MEM;
*data_len = SHA1_LEN_BIN;
}
}
memcpy((void *)(&ctx), (void *)(&(sha1->ctx)), sizeof(SHA1Context));
if (SHA1Result(&(ctx), (unsigned char *)(*data_ptr)) != shaSuccess)
return SHA1_RC_INT;
return SHA1_RC_OK;
}
sha1_rc_t sha1_format(sha1_t *sha1, char **data_ptr, size_t *data_len)
{
static const char hex[] = "0123456789abcdef";
unsigned char buf[SHA1_LEN_BIN];
unsigned char *bufptr;
size_t buflen;
sha1_rc_t rc;
int i;
if (sha1 == NULL || data_ptr == NULL)
return SHA1_RC_ARG;
if (*data_ptr == NULL) {
if ((*data_ptr = (char *)malloc(SHA1_LEN_STR+1)) == NULL)
return SHA1_RC_MEM;
if (data_len != NULL)
*data_len = SHA1_LEN_STR+1;
}
else {
if (data_len != NULL) {
if (*data_len < SHA1_LEN_STR+1)
return SHA1_RC_MEM;
*data_len = SHA1_LEN_STR+1;
}
}
bufptr = buf;
buflen = sizeof(buf);
if ((rc = sha1_store(sha1, (void **)((void *)&bufptr), &buflen)) != SHA1_RC_OK)
return rc;
for (i = 0; i < (int)buflen; i++) {
(*data_ptr)[(i*2)+0] = hex[(int)(bufptr[i] >> 4)];
(*data_ptr)[(i*2)+1] = hex[(int)(bufptr[i] & 0x0f)];
}
(*data_ptr)[(i*2)] = '\0';
return SHA1_RC_OK;
}
sha1_rc_t sha1_destroy(sha1_t *sha1)
{
if (sha1 == NULL)
return SHA1_RC_ARG;
free(sha1);
return SHA1_RC_OK;
}

View File

@ -1,77 +0,0 @@
/*
** OSSP uuid - Universally Unique Identifier
** Copyright (c) 2004-2008 Ralf S. Engelschall <rse@engelschall.com>
** Copyright (c) 2004-2008 The OSSP Project <http://www.ossp.org/>
**
** This file is part of OSSP uuid, a library for the generation
** of UUIDs which can found at http://www.ossp.org/pkg/lib/uuid/
**
** Permission to use, copy, modify, and distribute this software for
** any purpose with or without fee is hereby granted, provided that
** the above copyright notice and this permission notice appear in all
** copies.
**
** THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
** WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
** MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
** IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
** CONTRIBUTORS 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 ADVISED OF THE POSSIBILITY OF
** SUCH DAMAGE.
**
** uuid_sha1.h: SHA-1 API definition
*/
#ifndef __SHA1_H___
#define __SHA1_H___
#include <string.h> /* size_t */
#define SHA1_PREFIX uuid_
/* embedding support */
#ifdef SHA1_PREFIX
#if defined(__STDC__) || defined(__cplusplus)
#define __SHA1_CONCAT(x,y) x ## y
#define SHA1_CONCAT(x,y) __SHA1_CONCAT(x,y)
#else
#define __SHA1_CONCAT(x) x
#define SHA1_CONCAT(x,y) __SHA1_CONCAT(x)y
#endif
#define sha1_st SHA1_CONCAT(SHA1_PREFIX,sha1_st)
#define sha1_t SHA1_CONCAT(SHA1_PREFIX,sha1_t)
#define sha1_create SHA1_CONCAT(SHA1_PREFIX,sha1_create)
#define sha1_init SHA1_CONCAT(SHA1_PREFIX,sha1_init)
#define sha1_update SHA1_CONCAT(SHA1_PREFIX,sha1_update)
#define sha1_store SHA1_CONCAT(SHA1_PREFIX,sha1_store)
#define sha1_format SHA1_CONCAT(SHA1_PREFIX,sha1_format)
#define sha1_destroy SHA1_CONCAT(SHA1_PREFIX,sha1_destroy)
#endif
struct sha1_st;
typedef struct sha1_st sha1_t;
#define SHA1_LEN_BIN 20
#define SHA1_LEN_STR 40
typedef enum {
SHA1_RC_OK = 0,
SHA1_RC_ARG = 1,
SHA1_RC_MEM = 2,
SHA1_RC_INT = 3
} sha1_rc_t;
extern sha1_rc_t sha1_create (sha1_t **sha1);
extern sha1_rc_t sha1_init (sha1_t *sha1);
extern sha1_rc_t sha1_update (sha1_t *sha1, const void *data_ptr, size_t data_len);
extern sha1_rc_t sha1_store (sha1_t *sha1, void **data_ptr, size_t *data_len);
extern sha1_rc_t sha1_format (sha1_t *sha1, char **data_ptr, size_t *data_len);
extern sha1_rc_t sha1_destroy (sha1_t *sha1);
#endif /* __SHA1_H___ */

View File

@ -1,762 +0,0 @@
/*
** OSSP uuid - Universally Unique Identifier
** Copyright (c) 2004-2008 Ralf S. Engelschall <rse@engelschall.com>
** Copyright (c) 2004-2008 The OSSP Project <http://www.ossp.org/>
**
** This file is part of OSSP uuid, a library for the generation
** of UUIDs which can found at http://www.ossp.org/pkg/lib/uuid/
**
** Permission to use, copy, modify, and distribute this software for
** any purpose with or without fee is hereby granted, provided that
** the above copyright notice and this permission notice appear in all
** copies.
**
** THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
** WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
** MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
** IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
** CONTRIBUTORS 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 ADVISED OF THE POSSIBILITY OF
** SUCH DAMAGE.
**
** uuid_str.c: string formatting functions
*/
/*
* Copyright Patrick Powell 1995
* This code is based on code written by Patrick Powell <papowell@astart.com>
* It may be used for any purpose as long as this notice remains intact
* on all source code distributions.
*/
/*
* This code contains numerious changes and enhancements which were
* made by lots of contributors over the last years to Patrick Powell's
* original code:
*
* o Patrick Powell <papowell@astart.com> (1995)
* o Brandon Long <blong@fiction.net> (1996, for Mutt)
* o Thomas Roessler <roessler@guug.de> (1998, for Mutt)
* o Michael Elkins <me@cs.hmc.edu> (1998, for Mutt)
* o Andrew Tridgell <tridge@samba.org> (1998, for Samba)
* o Luke Mewburn <lukem@netbsd.org> (1999, for LukemFTP)
* o Ralf S. Engelschall <rse@engelschall.com> (1999, for OSSP)
*/
/* own headers (part 1/2) */
#include "uuid_ac.h"
/* system headers */
#include <stdlib.h>
#include <stdarg.h>
#include <string.h>
#include <ctype.h>
/* own headers (part 2/2) */
#include "uuid_str.h"
#if HAVE_LONG_LONG
#define LLONG long long
#else
#define LLONG long
#endif
#if HAVE_LONG_DOUBLE
#define LDOUBLE long double
#else
#define LDOUBLE double
#endif
static void fmtstr (char *, size_t *, size_t, char *, int, int, int);
static void fmtint (char *, size_t *, size_t, LLONG, int, int, int, int);
static void fmtfp (char *, size_t *, size_t, LDOUBLE, int, int, int);
static void dopr_outch (char *, size_t *, size_t, int);
/* format read states */
#define DP_S_DEFAULT 0
#define DP_S_FLAGS 1
#define DP_S_MIN 2
#define DP_S_DOT 3
#define DP_S_MAX 4
#define DP_S_MOD 5
#define DP_S_CONV 6
#define DP_S_DONE 7
/* format flags - Bits */
#define DP_F_MINUS (1 << 0)
#define DP_F_PLUS (1 << 1)
#define DP_F_SPACE (1 << 2)
#define DP_F_NUM (1 << 3)
#define DP_F_ZERO (1 << 4)
#define DP_F_UP (1 << 5)
#define DP_F_UNSIGNED (1 << 6)
/* conversion flags */
#define DP_C_SHORT 1
#define DP_C_LONG 2
#define DP_C_LDOUBLE 3
#define DP_C_LLONG 4
/* some handy macros */
#define char_to_int(p) (p - '0')
#define STR_MAX(p,q) ((p >= q) ? p : q)
#define NUL '\0'
static void
dopr(
char *buffer,
size_t maxlen,
size_t *retlen,
const char *format,
va_list args)
{
char ch;
LLONG value;
LDOUBLE fvalue;
char *strvalue;
int min;
int max;
int state;
int flags;
int cflags;
size_t currlen;
state = DP_S_DEFAULT;
flags = currlen = cflags = min = 0;
max = -1;
ch = *format++;
if (buffer == NULL)
maxlen = 999999;
while (state != DP_S_DONE) {
if ((ch == NUL) || (currlen >= maxlen))
state = DP_S_DONE;
switch (state) {
case DP_S_DEFAULT:
if (ch == '%')
state = DP_S_FLAGS;
else
dopr_outch(buffer, &currlen, maxlen, ch);
ch = *format++;
break;
case DP_S_FLAGS:
switch (ch) {
case '-':
flags |= DP_F_MINUS;
ch = *format++;
break;
case '+':
flags |= DP_F_PLUS;
ch = *format++;
break;
case ' ':
flags |= DP_F_SPACE;
ch = *format++;
break;
case '#':
flags |= DP_F_NUM;
ch = *format++;
break;
case '0':
flags |= DP_F_ZERO;
ch = *format++;
break;
default:
state = DP_S_MIN;
break;
}
break;
case DP_S_MIN:
if (isdigit((unsigned char)ch)) {
min = 10 * min + char_to_int(ch);
ch = *format++;
} else if (ch == '*') {
min = va_arg(args, int);
ch = *format++;
state = DP_S_DOT;
} else
state = DP_S_DOT;
break;
case DP_S_DOT:
if (ch == '.') {
state = DP_S_MAX;
ch = *format++;
} else
state = DP_S_MOD;
break;
case DP_S_MAX:
if (isdigit((unsigned char)ch)) {
if (max < 0)
max = 0;
max = 10 * max + char_to_int(ch);
ch = *format++;
} else if (ch == '*') {
max = va_arg(args, int);
ch = *format++;
state = DP_S_MOD;
} else
state = DP_S_MOD;
break;
case DP_S_MOD:
switch (ch) {
case 'h':
cflags = DP_C_SHORT;
ch = *format++;
break;
case 'l':
if (*format == 'l') {
cflags = DP_C_LLONG;
format++;
} else
cflags = DP_C_LONG;
ch = *format++;
break;
case 'q':
cflags = DP_C_LLONG;
ch = *format++;
break;
case 'L':
cflags = DP_C_LDOUBLE;
ch = *format++;
break;
default:
break;
}
state = DP_S_CONV;
break;
case DP_S_CONV:
switch (ch) {
case 'd':
case 'i':
switch (cflags) {
case DP_C_SHORT:
value = (short int)va_arg(args, int);
break;
case DP_C_LONG:
value = va_arg(args, long int);
break;
case DP_C_LLONG:
value = va_arg(args, LLONG);
break;
default:
value = va_arg(args, int);
break;
}
fmtint(buffer, &currlen, maxlen, value, 10, min, max, flags);
break;
case 'X':
flags |= DP_F_UP;
/* FALLTHROUGH */
case 'x':
case 'o':
case 'u':
flags |= DP_F_UNSIGNED;
switch (cflags) {
case DP_C_SHORT:
value = (unsigned short int)va_arg(args, unsigned int);
break;
case DP_C_LONG:
value = (LLONG)va_arg(args, unsigned long int);
break;
case DP_C_LLONG:
value = va_arg(args, unsigned LLONG);
break;
default:
value = (LLONG)va_arg(args, unsigned int);
break;
}
fmtint(buffer, &currlen, maxlen, value,
ch == 'o' ? 8 : (ch == 'u' ? 10 : 16),
min, max, flags);
break;
case 'f':
if (cflags == DP_C_LDOUBLE)
fvalue = va_arg(args, LDOUBLE);
else
fvalue = va_arg(args, double);
fmtfp(buffer, &currlen, maxlen, fvalue, min, max, flags);
break;
case 'E':
flags |= DP_F_UP;
/* FALLTHROUGH */
case 'e':
if (cflags == DP_C_LDOUBLE)
fvalue = va_arg(args, LDOUBLE);
else
fvalue = va_arg(args, double);
break;
case 'G':
flags |= DP_F_UP;
/* FALLTHROUGH */
case 'g':
if (cflags == DP_C_LDOUBLE)
fvalue = va_arg(args, LDOUBLE);
else
fvalue = va_arg(args, double);
break;
case 'c':
dopr_outch(buffer, &currlen, maxlen, va_arg(args, int));
break;
case 's':
strvalue = va_arg(args, char *);
if (max < 0)
max = maxlen;
fmtstr(buffer, &currlen, maxlen, strvalue, flags, min, max);
break;
case 'p':
value = (long)va_arg(args, void *);
fmtint(buffer, &currlen, maxlen, value, 16, min, max, flags);
break;
case 'n': /* XXX */
if (cflags == DP_C_SHORT) {
short int *num;
num = va_arg(args, short int *);
*num = currlen;
} else if (cflags == DP_C_LONG) { /* XXX */
long int *num;
num = va_arg(args, long int *);
*num = (long int) currlen;
} else if (cflags == DP_C_LLONG) { /* XXX */
LLONG *num;
num = va_arg(args, LLONG *);
*num = (LLONG) currlen;
} else {
int *num;
num = va_arg(args, int *);
*num = currlen;
}
break;
case '%':
dopr_outch(buffer, &currlen, maxlen, ch);
break;
case 'w':
/* not supported yet, treat as next char */
ch = *format++;
break;
default:
/* unknown, skip */
break;
}
ch = *format++;
state = DP_S_DEFAULT;
flags = cflags = min = 0;
max = -1;
break;
case DP_S_DONE:
break;
default:
break;
}
}
if (currlen >= maxlen - 1)
currlen = maxlen - 1;
if (buffer != NULL)
buffer[currlen] = NUL;
*retlen = currlen;
return;
}
static void
fmtstr(
char *buffer,
size_t *currlen,
size_t maxlen,
char *value,
int flags,
int min,
int max)
{
int padlen, strln;
int cnt = 0;
if (value == NULL)
value = "<NULL>";
for (strln = 0; value[strln] != '\0'; strln++)
;
padlen = min - strln;
if (padlen < 0)
padlen = 0;
if (flags & DP_F_MINUS)
padlen = -padlen;
while ((padlen > 0) && (cnt < max)) {
dopr_outch(buffer, currlen, maxlen, ' ');
--padlen;
++cnt;
}
while (*value && (cnt < max)) {
dopr_outch(buffer, currlen, maxlen, *value++);
++cnt;
}
while ((padlen < 0) && (cnt < max)) {
dopr_outch(buffer, currlen, maxlen, ' ');
++padlen;
++cnt;
}
}
static void
fmtint(
char *buffer,
size_t *currlen,
size_t maxlen,
LLONG value,
int base,
int min,
int max,
int flags)
{
int signvalue = 0;
unsigned LLONG uvalue;
char convert[20];
int place = 0;
int spadlen = 0;
int zpadlen = 0;
int caps = 0;
if (max < 0)
max = 0;
uvalue = value;
if (!(flags & DP_F_UNSIGNED)) {
if (value < 0) {
signvalue = '-';
uvalue = -value;
} else if (flags & DP_F_PLUS)
signvalue = '+';
else if (flags & DP_F_SPACE)
signvalue = ' ';
}
if (flags & DP_F_UP)
caps = 1;
do {
convert[place++] =
(caps ? "0123456789ABCDEF" : "0123456789abcdef")
[uvalue % (unsigned) base];
uvalue = (uvalue / (unsigned) base);
} while (uvalue && (place < 20));
if (place == 20)
place--;
convert[place] = 0;
zpadlen = max - place;
spadlen = min - STR_MAX(max, place) - (signvalue ? 1 : 0);
if (zpadlen < 0)
zpadlen = 0;
if (spadlen < 0)
spadlen = 0;
if (flags & DP_F_ZERO) {
zpadlen = STR_MAX(zpadlen, spadlen);
spadlen = 0;
}
if (flags & DP_F_MINUS)
spadlen = -spadlen;
/* spaces */
while (spadlen > 0) {
dopr_outch(buffer, currlen, maxlen, ' ');
--spadlen;
}
/* sign */
if (signvalue)
dopr_outch(buffer, currlen, maxlen, signvalue);
/* zeros */
if (zpadlen > 0) {
while (zpadlen > 0) {
dopr_outch(buffer, currlen, maxlen, '0');
--zpadlen;
}
}
/* digits */
while (place > 0)
dopr_outch(buffer, currlen, maxlen, convert[--place]);
/* left justified spaces */
while (spadlen < 0) {
dopr_outch(buffer, currlen, maxlen, ' ');
++spadlen;
}
return;
}
static LDOUBLE
math_abs(LDOUBLE value)
{
LDOUBLE result = value;
if (value < 0)
result = -value;
return result;
}
static LDOUBLE
math_pow10(int exponent)
{
LDOUBLE result = 1;
while (exponent > 0) {
result *= 10;
exponent--;
}
return result;
}
static long
math_round(LDOUBLE value)
{
long intpart;
intpart = (long) value;
value = value - intpart;
if (value >= 0.5)
intpart++;
return intpart;
}
static void
fmtfp(
char *buffer,
size_t *currlen,
size_t maxlen,
LDOUBLE fvalue,
int min,
int max,
int flags)
{
int signvalue = 0;
LDOUBLE ufvalue;
char iconvert[20];
char fconvert[20];
int iplace = 0;
int fplace = 0;
int padlen = 0;
int zpadlen = 0;
int caps = 0;
long intpart;
long fracpart;
if (max < 0)
max = 6;
ufvalue = math_abs(fvalue);
if (fvalue < 0)
signvalue = '-';
else if (flags & DP_F_PLUS)
signvalue = '+';
else if (flags & DP_F_SPACE)
signvalue = ' ';
intpart = (long)ufvalue;
/* sorry, we only support 9 digits past the decimal because of our
conversion method */
if (max > 9)
max = 9;
/* we "cheat" by converting the fractional part to integer by
multiplying by a factor of 10 */
fracpart = math_round((math_pow10(max)) * (ufvalue - intpart));
if (fracpart >= math_pow10(max)) {
intpart++;
fracpart -= (long)math_pow10(max);
}
/* convert integer part */
do {
iconvert[iplace++] =
(caps ? "0123456789ABCDEF"
: "0123456789abcdef")[intpart % 10];
intpart = (intpart / 10);
} while (intpart && (iplace < 20));
if (iplace == 20)
iplace--;
iconvert[iplace] = 0;
/* convert fractional part */
do {
fconvert[fplace++] =
(caps ? "0123456789ABCDEF"
: "0123456789abcdef")[fracpart % 10];
fracpart = (fracpart / 10);
} while (fracpart && (fplace < 20));
if (fplace == 20)
fplace--;
fconvert[fplace] = 0;
/* -1 for decimal point, another -1 if we are printing a sign */
padlen = min - iplace - max - 1 - ((signvalue) ? 1 : 0);
zpadlen = max - fplace;
if (zpadlen < 0)
zpadlen = 0;
if (padlen < 0)
padlen = 0;
if (flags & DP_F_MINUS)
padlen = -padlen;
if ((flags & DP_F_ZERO) && (padlen > 0)) {
if (signvalue) {
dopr_outch(buffer, currlen, maxlen, signvalue);
--padlen;
signvalue = 0;
}
while (padlen > 0) {
dopr_outch(buffer, currlen, maxlen, '0');
--padlen;
}
}
while (padlen > 0) {
dopr_outch(buffer, currlen, maxlen, ' ');
--padlen;
}
if (signvalue)
dopr_outch(buffer, currlen, maxlen, signvalue);
while (iplace > 0)
dopr_outch(buffer, currlen, maxlen, iconvert[--iplace]);
/*
* Decimal point. This should probably use locale to find the correct
* char to print out.
*/
if (max > 0) {
dopr_outch(buffer, currlen, maxlen, '.');
while (fplace > 0)
dopr_outch(buffer, currlen, maxlen, fconvert[--fplace]);
}
while (zpadlen > 0) {
dopr_outch(buffer, currlen, maxlen, '0');
--zpadlen;
}
while (padlen < 0) {
dopr_outch(buffer, currlen, maxlen, ' ');
++padlen;
}
return;
}
static void
dopr_outch(
char *buffer,
size_t *currlen,
size_t maxlen,
int c)
{
if (*currlen < maxlen) {
if (buffer != NULL)
buffer[(*currlen)] = (char)c;
(*currlen)++;
}
return;
}
int
str_vsnprintf(
char *str,
size_t count,
const char *fmt,
va_list args)
{
size_t retlen;
if (str != NULL)
str[0] = NUL;
dopr(str, count, &retlen, fmt, args);
return retlen;
}
int
str_snprintf(
char *str,
size_t count,
const char *fmt,
...)
{
va_list ap;
int rv;
va_start(ap, fmt);
rv = str_vsnprintf(str, count, fmt, ap);
va_end(ap);
return rv;
}
char *
str_vasprintf(
const char *fmt,
va_list ap)
{
char *rv;
int n;
va_list ap_tmp;
va_copy(ap_tmp, ap);
n = str_vsnprintf(NULL, 0, fmt, ap_tmp);
if ((rv = (char *)malloc(n+1)) == NULL)
return NULL;
str_vsnprintf(rv, n+1, fmt, ap);
return rv;
}
char *
str_asprintf(
const char *fmt,
...)
{
va_list ap;
char *rv;
va_start(ap, fmt);
rv = str_vasprintf(fmt, ap);
va_end(ap);
return rv;
}
int
str_vrsprintf(
char **str,
const char *fmt,
va_list ap)
{
int rv;
size_t n;
va_list ap_tmp;
if (str == NULL)
return -1;
if (*str == NULL) {
*str = str_vasprintf(fmt, ap);
rv = strlen(*str);
}
else {
va_copy(ap_tmp, ap);
n = strlen(*str);
rv = str_vsnprintf(NULL, 0, fmt, ap_tmp);
if ((*str = (char *)realloc(*str, n+rv+1)) == NULL)
return -1;
str_vsnprintf((*str)+n, rv+1, fmt, ap);
}
return rv;
}
int
str_rsprintf(
char **str,
const char *fmt,
...)
{
va_list ap;
int rv;
va_start(ap, fmt);
rv = str_vrsprintf(str, fmt, ap);
va_end(ap);
return rv;
}

View File

@ -1,63 +0,0 @@
/*
** OSSP uuid - Universally Unique Identifier
** Copyright (c) 2004-2008 Ralf S. Engelschall <rse@engelschall.com>
** Copyright (c) 2004-2008 The OSSP Project <http://www.ossp.org/>
**
** This file is part of OSSP uuid, a library for the generation
** of UUIDs which can found at http://www.ossp.org/pkg/lib/uuid/
**
** Permission to use, copy, modify, and distribute this software for
** any purpose with or without fee is hereby granted, provided that
** the above copyright notice and this permission notice appear in all
** copies.
**
** THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
** WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
** MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
** IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
** CONTRIBUTORS 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 ADVISED OF THE POSSIBILITY OF
** SUCH DAMAGE.
**
** uuid_str.h: string formatting functions
*/
#ifndef __UUID_STR_H__
#define __UUID_STR_H__
#include <stdarg.h>
#include <string.h>
#define STR_PREFIX uuid_
/* embedding support */
#ifdef STR_PREFIX
#if defined(__STDC__) || defined(__cplusplus)
#define __STR_CONCAT(x,y) x ## y
#define STR_CONCAT(x,y) __STR_CONCAT(x,y)
#else
#define __STR_CONCAT(x) x
#define STR_CONCAT(x,y) __STR_CONCAT(x)y
#endif
#define str_vsnprintf STR_CONCAT(STR_PREFIX,str_vsnprintf)
#define str_snprintf STR_CONCAT(STR_PREFIX,str_snprintf)
#define str_vrsprintf STR_CONCAT(STR_PREFIX,str_vrsprintf)
#define str_rsprintf STR_CONCAT(STR_PREFIX,str_rsprintf)
#define str_vasprintf STR_CONCAT(STR_PREFIX,str_vasprintf)
#define str_asprintf STR_CONCAT(STR_PREFIX,str_asprintf)
#endif
extern int str_vsnprintf (char *, size_t, const char *, va_list);
extern int str_snprintf (char *, size_t, const char *, ...);
extern int str_vrsprintf (char **, const char *, va_list);
extern int str_rsprintf (char **, const char *, ...);
extern char *str_vasprintf ( const char *, va_list);
extern char *str_asprintf ( const char *, ...);
#endif /* __UUID_STR_H__ */

View File

@ -1,117 +0,0 @@
/*
** OSSP uuid - Universally Unique Identifier
** Copyright (c) 2004-2008 Ralf S. Engelschall <rse@engelschall.com>
** Copyright (c) 2004-2008 The OSSP Project <http://www.ossp.org/>
**
** This file is part of OSSP uuid, a library for the generation
** of UUIDs which can found at http://www.ossp.org/pkg/lib/uuid/
**
** Permission to use, copy, modify, and distribute this software for
** any purpose with or without fee is hereby granted, provided that
** the above copyright notice and this permission notice appear in all
** copies.
**
** THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
** WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
** MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
** IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
** CONTRIBUTORS 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 ADVISED OF THE POSSIBILITY OF
** SUCH DAMAGE.
**
** uuid_time.c: Time Management
*/
/* own headers (part (1/2) */
#include "uuid_ac.h"
/* system headers */
#include <stdlib.h>
#include <unistd.h>
#include <time.h>
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#endif
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifdef HAVE_SYS_SELECT_H
#include <sys/select.h>
#endif
/* own headers (part (1/2) */
#include "uuid_time.h"
/* POSIX gettimeofday(2) abstraction (without timezone) */
int time_gettimeofday(struct timeval *tv)
{
#if defined(HAVE_GETTIMEOFDAY)
/* Unix/POSIX pass-through */
return gettimeofday(tv, NULL);
#elif defined(HAVE_CLOCK_GETTIME)
/* POSIX emulation */
struct timespec ts;
if (clock_gettime(CLOCK_MONOTONIC, &ts) == -1)
return -1;
if (tv != NULL) {
tv->tv_sec = (long)ts.tv_sec;
tv->tv_usec = (long)ts.tv_nsec / 1000;
}
return 0;
#elif defined(WIN32)
/* Windows emulation */
FILETIME ft;
LARGE_INTEGER li;
__int64 t;
static int tzflag;
#if !defined(__GNUC__)
#define EPOCHFILETIME 116444736000000000i64
#else
#define EPOCHFILETIME 116444736000000000LL
#endif
if (tv != NULL) {
GetSystemTimeAsFileTime(&ft);
li.LowPart = ft.dwLowDateTime;
li.HighPart = ft.dwHighDateTime;
t = li.QuadPart;
t -= EPOCHFILETIME;
t /= 10;
tv->tv_sec = (long)(t / 1000000);
tv->tv_usec = (long)(t % 1000000);
}
return 0;
#else
#error neither Win32 GetSystemTimeAsFileTime() nor Unix gettimeofday() nor POSIX clock_gettime() available!
#endif
}
/* BSD usleep(3) abstraction */
int time_usleep(long usec)
{
#if defined(WIN32) && defined(HAVE_SLEEP)
/* Win32 newer Sleep(3) variant */
Sleep(usec / 1000);
#elif defined(WIN32)
/* Win32 older _sleep(3) variant */
_sleep(usec / 1000);
#elif defined(HAVE_NANOSLEEP)
/* POSIX newer nanosleep(3) variant */
struct timespec ts;
ts.tv_sec = 0;
ts.tv_nsec = 1000 * usec;
nanosleep(&ts, NULL);
#else
/* POSIX older select(2) variant */
struct timeval tv;
tv.tv_sec = 0;
tv.tv_usec = usec;
select(0, NULL, NULL, NULL, &tv);
#endif
return 0;
}

View File

@ -1,83 +0,0 @@
/*
** OSSP uuid - Universally Unique Identifier
** Copyright (c) 2004-2008 Ralf S. Engelschall <rse@engelschall.com>
** Copyright (c) 2004-2008 The OSSP Project <http://www.ossp.org/>
**
** This file is part of OSSP uuid, a library for the generation
** of UUIDs which can found at http://www.ossp.org/pkg/lib/uuid/
**
** Permission to use, copy, modify, and distribute this software for
** any purpose with or without fee is hereby granted, provided that
** the above copyright notice and this permission notice appear in all
** copies.
**
** THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
** WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
** MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
** IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
** CONTRIBUTORS 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 ADVISED OF THE POSSIBILITY OF
** SUCH DAMAGE.
**
** uuid_time.h: Time Management API
*/
#ifndef __UUID_TIME_H__
#define __UUID_TIME_H__
#include "uuid_ac.h"
#if defined(WIN32)
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#endif
#include <time.h>
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#endif
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#define TIME_PREFIX uuid_
/* embedding support */
#ifdef TIME_PREFIX
#if defined(__STDC__) || defined(__cplusplus)
#define __TIME_CONCAT(x,y) x ## y
#define TIME_CONCAT(x,y) __TIME_CONCAT(x,y)
#else
#define __TIME_CONCAT(x) x
#define TIME_CONCAT(x,y) __TIME_CONCAT(x)y
#endif
#define time_gettimeofday TIME_CONCAT(TIME_PREFIX,time_gettimeofday)
#define time_usleep TIME_CONCAT(TIME_PREFIX,time_usleep)
#endif
/* minimum C++ support */
#ifdef __cplusplus
#define DECLARATION_BEGIN extern "C" {
#define DECLARATION_END }
#else
#define DECLARATION_BEGIN
#define DECLARATION_END
#endif
DECLARATION_BEGIN
#ifndef HAVE_STRUCT_TIMEVAL
struct timeval { long tv_sec; long tv_usec; };
#endif
extern int time_gettimeofday(struct timeval *);
extern int time_usleep(long usec);
DECLARATION_END
#endif /* __UUID_TIME_H__ */

View File

@ -1,591 +0,0 @@
/*
** OSSP ui128 - 128-Bit Arithmetic
** Copyright (c) 2002-2005 Ralf S. Engelschall <rse@engelschall.com>
** Copyright (c) 2002-2005 The OSSP Project <http://www.ossp.org/>
**
** This file is part of OSSP ui128, a 128-bit arithmetic library
** which can be found at http://www.ossp.org/pkg/lib/ui128/.
**
** Permission to use, copy, modify, and distribute this software for
** any purpose with or without fee is hereby granted, provided that
** the above copyright notice and this permission notice appear in all
** copies.
**
** THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
** WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
** MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
** IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
** CONTRIBUTORS 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 ADVISED OF THE POSSIBILITY OF
** SUCH DAMAGE.
**
** ui128.c: implementation of 128-bit unsigned integer arithmetic
*/
/* own headers (part 1/2) */
#include "uuid_ac.h"
/* system headers */
#include <string.h>
#include <ctype.h>
/* own headers (part 2/2) */
#include "uuid_ui128.h"
#define UI128_BASE 256 /* 2^8 */
#define UI128_DIGITS 16 /* 8*16 = 128 bit */
#define UIXX_T(n) struct { unsigned char x[n]; }
/* fill an ui128_t with a sequence of a particular digit */
#define ui128_fill(__x, __n) \
/*lint -save -e717*/ \
do { int __i; \
for (__i = 0; __i < UI128_DIGITS; __i++) \
(__x).x[__i] = (__n); \
} while (0) \
/*lint -restore*/
/* the value zero */
ui128_t ui128_zero(void)
{
ui128_t z;
ui128_fill(z, 0);
return z;
}
/* the maximum value */
ui128_t ui128_max(void)
{
ui128_t z;
ui128_fill(z, UI128_BASE-1);
return z;
}
/* convert ISO-C "unsigned long" into internal format */
ui128_t ui128_n2i(unsigned long n)
{
ui128_t z;
int i;
i = 0;
do {
z.x[i++] = (n % UI128_BASE);
} while ((n /= UI128_BASE) > 0 && i < UI128_DIGITS);
for ( ; i < UI128_DIGITS; i++)
z.x[i] = 0;
return z;
}
/* convert internal format into ISO-C "unsigned long";
truncates if sizeof(unsigned long) is less than UI128_DIGITS! */
unsigned long ui128_i2n(ui128_t x)
{
unsigned long n;
int i;
n = 0;
i = (int)sizeof(n);
/*lint -save -e774*/
if (i > UI128_DIGITS)
i = UI128_DIGITS;
/*lint -restore*/
while (--i >= 0) {
n = (n * UI128_BASE) + x.x[i];
}
return n;
}
/* convert string representation of arbitrary base into internal format */
ui128_t ui128_s2i(const char *str, char **end, int base)
{
ui128_t z;
const char *cp;
int carry;
static char map[] = {
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, /* 0...9 */
36, 36, 36, 36, 36, 36, 36, /* illegal chars */
10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, /* A...M */
23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, /* N...Z */
36, 36, 36, 36, 36, 36, /* illegal chars */
10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, /* a...m */
23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35 /* m...z */
};
ui128_fill(z, 0);
if (str == NULL || (base < 2 || base > 36))
return z;
cp = str;
while (*cp != '\0' && isspace((int)(*cp)))
cp++;
while ( *cp != '\0'
&& isalnum((int)(*cp))
&& map[(int)(*cp)-'0'] < base) {
z = ui128_muln(z, base, &carry);
if (carry)
break;
z = ui128_addn(z, map[(int)(*cp)-'0'], &carry);
if (carry)
break;
cp++;
}
if (end != NULL)
*end = (char *)cp;
return z;
}
/* convert internal format into string representation of arbitrary base */
char *ui128_i2s(ui128_t x, char *str, size_t len, int base)
{
static char map[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
char c;
int r;
int n;
int i, j;
if (str == NULL || len < 2 || (base < 2 || base > 36))
return NULL;
n = ui128_len(x);
i = 0;
do {
x = ui128_divn(x, base, &r);
str[i++] = map[r];
while (n > 1 && x.x[n-1] == 0)
n--;
} while (i < ((int)len-1) && (n > 1 || x.x[0] != 0));
str[i] = '\0';
for (j = 0; j < --i; j++) {
c = str[j];
str[j] = str[i];
str[i] = c;
}
return str;
}
/* addition of two ui128_t */
ui128_t ui128_add(ui128_t x, ui128_t y, ui128_t *ov)
{
ui128_t z;
int carry;
int i;
carry = 0;
for (i = 0; i < UI128_DIGITS; i++) {
carry += (x.x[i] + y.x[i]);
z.x[i] = (carry % UI128_BASE);
carry /= UI128_BASE;
}
if (ov != NULL)
*ov = ui128_n2i((unsigned long)carry);
return z;
}
/* addition of an ui128_t and a single digit */
ui128_t ui128_addn(ui128_t x, int y, int *ov)
{
ui128_t z;
int i;
for (i = 0; i < UI128_DIGITS; i++) {
y += x.x[i];
z.x[i] = (y % UI128_BASE);
y /= UI128_BASE;
}
if (ov != NULL)
*ov = y;
return z;
}
/* subtraction of two ui128_t */
ui128_t ui128_sub(ui128_t x, ui128_t y, ui128_t *ov)
{
ui128_t z;
int borrow;
int i;
int d;
borrow = 0;
for (i = 0; i < UI128_DIGITS; i++) {
d = ((x.x[i] + UI128_BASE) - borrow - y.x[i]);
z.x[i] = (d % UI128_BASE);
borrow = (1 - (d/UI128_BASE));
}
if (ov != NULL)
*ov = ui128_n2i((unsigned long)borrow);
return z;
}
/* subtraction of an ui128_t and a single digit */
ui128_t ui128_subn(ui128_t x, int y, int *ov)
{
ui128_t z;
int i;
int d;
for (i = 0; i < UI128_DIGITS; i++) {
d = (x.x[i] + UI128_BASE) - y;
z.x[i] = (d % UI128_BASE);
y = (1 - (d/UI128_BASE));
}
if (ov != NULL)
*ov = y;
return z;
}
/*
7 3 2
* 9 4 2 8
---------
5 8 5 6
+ 1 4 6 4
+ 2 9 2 8
+ 6 5 8 8
---------------
= 6 9 0 1 2 9 6
*/
ui128_t ui128_mul(ui128_t x, ui128_t y, ui128_t *ov)
{
UIXX_T(UI128_DIGITS+UI128_DIGITS) zx;
ui128_t z;
int carry;
int i, j;
/* clear temporary result buffer */
for (i = 0; i < (UI128_DIGITS+UI128_DIGITS); i++)
zx.x[i] = 0;
/* perform multiplication operation */
for (i = 0; i < UI128_DIGITS; i++) {
/* calculate partial product and immediately add to z */
carry = 0;
for (j = 0; j < UI128_DIGITS; j++) {
carry += (x.x[i] * y.x[j]) + zx.x[i+j];
zx.x[i+j] = (carry % UI128_BASE);
carry /= UI128_BASE;
}
/* add carry to remaining digits in z */
for ( ; j < UI128_DIGITS + UI128_DIGITS - i; j++) {
carry += zx.x[i+j];
zx.x[i+j] = (carry % UI128_BASE);
carry /= UI128_BASE;
}
}
/* provide result by splitting zx into z and ov */
memcpy(z.x, zx.x, UI128_DIGITS);
if (ov != NULL)
memcpy((*ov).x, &zx.x[UI128_DIGITS], UI128_DIGITS);
return z;
}
ui128_t ui128_muln(ui128_t x, int y, int *ov)
{
ui128_t z;
int carry;
int i;
carry = 0;
for (i = 0; i < UI128_DIGITS; i++) {
carry += (x.x[i] * y);
z.x[i] = (carry % UI128_BASE);
carry /= UI128_BASE;
}
if (ov != NULL)
*ov = carry;
return z;
}
/*
= 2078 [q]
0615367 [x] : 296 [y]
-0592 [dq]
-----
= 0233
-0000 [dq]
-----
= 2336
-2072 [dq]
-----
= 2647
-2308 [dq]
-----
= 279 [r]
*/
ui128_t ui128_div(ui128_t x, ui128_t y, ui128_t *ov)
{
ui128_t q;
ui128_t r;
int i;
int n, m;
int ovn;
/* determine actual number of involved digits */
n = ui128_len(x);
m = ui128_len(y);
if (m == 1) {
/* simple case #1: reduceable to ui128_divn() */
if (y.x[0] == 0) {
/* error case: division by zero! */
ui128_fill(q, 0);
ui128_fill(r, 0);
}
else {
q = ui128_divn(x, y.x[0], &ovn);
ui128_fill(r, 0);
r.x[0] = (unsigned char)ovn;
}
} else if (n < m) {
/* simple case #2: everything is in the remainder */
ui128_fill(q, 0);
r = x;
} else { /* n >= m, m > 1 */
/* standard case: x[0..n] / y[0..m] */
UIXX_T(UI128_DIGITS+1) rx;
UIXX_T(UI128_DIGITS+1) dq;
ui128_t t;
int km;
int k;
int qk;
unsigned long y2;
unsigned long r3;
int borrow;
int d;
/* rx is x with a leading zero in order to make
sure that n > m and not just n >= m */
memcpy(rx.x, x.x, UI128_DIGITS);
rx.x[UI128_DIGITS] = 0;
for (k = n - m; k >= 0; k--) {
/* efficiently compute qk by guessing
qk := rx[k+m-2...k+m]/y[m-2...m-1] */
km = k + m;
y2 = (y.x[m-1]*UI128_BASE) + y.x[m-2];
r3 = (rx.x[km]*(UI128_BASE*UI128_BASE)) +
(rx.x[km-1]*UI128_BASE) + rx.x[km-2];
qk = r3 / y2;
if (qk >= UI128_BASE)
qk = UI128_BASE - 1;
/* dq := y*qk (post-adjust qk if guessed incorrectly) */
t = ui128_muln(y, qk, &ovn);
memcpy(dq.x, t.x, UI128_DIGITS);
dq.x[m] = (unsigned char)ovn;
for (i = m; i > 0; i--)
if (rx.x[i+k] != dq.x[i])
break;
if (rx.x[i+k] < dq.x[i]) {
t = ui128_muln(y, --qk, &ovn);
memcpy(dq.x, t.x, UI128_DIGITS);
dq.x[m] = (unsigned char)ovn;
}
/* store qk */
q.x[k] = (unsigned char)qk;
/* rx := rx - dq*(b^k) */
borrow = 0;
for (i = 0; i < m+1; i++) {
d = ((rx.x[k+i] + UI128_BASE) - borrow - dq.x[i]);
rx.x[k+i] = (d % UI128_BASE);
borrow = (1 - (d/UI128_BASE));
}
}
memcpy(r.x, rx.x, m);
/* fill out results with leading zeros */
for (i = n-m+1; i < UI128_DIGITS; i++)
q.x[i] = 0;
for (i = m; i < UI128_DIGITS; i++)
r.x[i] = 0;
}
/* provide results */
if (ov != NULL)
*ov = r;
return q;
}
ui128_t ui128_divn(ui128_t x, int y, int *ov)
{
ui128_t z;
unsigned int carry;
int i;
carry = 0;
for (i = (UI128_DIGITS - 1); i >= 0; i--) {
carry = (carry * UI128_BASE) + x.x[i];
z.x[i] = (carry / y);
carry %= y;
}
if (ov != NULL)
*ov = carry;
return z;
}
ui128_t ui128_and(ui128_t x, ui128_t y)
{
ui128_t z;
int i;
for (i = 0; i < UI128_DIGITS; i++)
z.x[i] = (x.x[i] & y.x[i]);
return z;
}
ui128_t ui128_or(ui128_t x, ui128_t y)
{
ui128_t z;
int i;
for (i = 0; i < UI128_DIGITS; i++)
z.x[i] = (x.x[i] | y.x[i]);
return z;
}
ui128_t ui128_xor(ui128_t x, ui128_t y)
{
ui128_t z;
int i;
for (i = 0; i < UI128_DIGITS; i++)
z.x[i] = ((x.x[i] & ~(y.x[i])) | (~(x.x[i]) & (y.x[i])));
return z;
}
ui128_t ui128_not(ui128_t x)
{
ui128_t z;
int i;
for (i = 0; i < UI128_DIGITS; i++)
z.x[i] = ~(x.x[i]);
return z;
}
ui128_t ui128_rol(ui128_t x, int s, ui128_t *ov)
{
UIXX_T(UI128_DIGITS+UI128_DIGITS) zx;
ui128_t z;
int i;
int carry;
if (s <= 0) {
/* no shift at all */
if (ov != NULL)
*ov = ui128_zero();
return x;
}
else if (s > 128) {
/* too large shift */
if (ov != NULL)
*ov = ui128_zero();
return ui128_zero();
}
else if (s == 128) {
/* maximum shift */
if (ov != NULL)
*ov = x;
return ui128_zero();
}
else { /* regular shift */
/* shift (logically) left by s/8 bytes */
for (i = 0; i < UI128_DIGITS+UI128_DIGITS; i++)
zx.x[i] = 0;
for (i = 0; i < UI128_DIGITS; i++)
zx.x[i+(s/8)] = x.x[i];
/* shift (logically) left by remaining s%8 bits */
s %= 8;
if (s > 0) {
carry = 0;
for (i = 0; i < UI128_DIGITS+UI128_DIGITS; i++) {
carry += (zx.x[i] * (1 << s));
zx.x[i] = (carry % UI128_BASE);
carry /= UI128_BASE;
}
}
memcpy(z.x, zx.x, UI128_DIGITS);
if (ov != NULL)
memcpy((*ov).x, &zx.x[UI128_DIGITS], UI128_DIGITS);
}
return z;
}
ui128_t ui128_ror(ui128_t x, int s, ui128_t *ov)
{
UIXX_T(UI128_DIGITS+UI128_DIGITS) zx;
ui128_t z;
int i;
int carry;
if (s <= 0) {
/* no shift at all */
if (ov != NULL)
*ov = ui128_zero();
return x;
}
else if (s > 128) {
/* too large shift */
if (ov != NULL)
*ov = ui128_zero();
return ui128_zero();
}
else if (s == 128) {
/* maximum shift */
if (ov != NULL)
*ov = x;
return ui128_zero();
}
else { /* regular shift */
/* shift (logically) right by s/8 bytes */
for (i = 0; i < UI128_DIGITS+UI128_DIGITS; i++)
zx.x[i] = 0;
for (i = 0; i < UI128_DIGITS; i++)
zx.x[UI128_DIGITS+i-(s/8)] = x.x[i];
/* shift (logically) right by remaining s%8 bits */
s %= 8;
if (s > 0) {
carry = 0;
for (i = (UI128_DIGITS+UI128_DIGITS - 1); i >= 0; i--) {
carry = (carry * UI128_BASE) + zx.x[i];
zx.x[i] = (carry / (1 << s));
carry %= (1 << s);
}
}
memcpy(z.x, &zx.x[UI128_DIGITS], UI128_DIGITS);
if (ov != NULL)
memcpy((*ov).x, zx.x, UI128_DIGITS);
}
return z;
}
int ui128_cmp(ui128_t x, ui128_t y)
{
int i;
i = UI128_DIGITS - 1;
while (i > 0 && x.x[i] == y.x[i])
i--;
return (x.x[i] - y.x[i]);
}
int ui128_len(ui128_t x)
{
int i;
for (i = UI128_DIGITS; i > 1 && x.x[i-1] == 0; i--)
;
return i;
}

View File

@ -1,114 +0,0 @@
/*
** OSSP ui128 - 128-Bit Arithmetic
** Copyright (c) 2002-2005 Ralf S. Engelschall <rse@engelschall.com>
** Copyright (c) 2002-2005 The OSSP Project <http://www.ossp.org/>
**
** This file is part of OSSP ui128, a 128-bit arithmetic library
** which can be found at http://www.ossp.org/pkg/lib/ui128/.
**
** Permission to use, copy, modify, and distribute this software for
** any purpose with or without fee is hereby granted, provided that
** the above copyright notice and this permission notice appear in all
** copies.
**
** THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
** WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
** MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
** IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
** CONTRIBUTORS 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 ADVISED OF THE POSSIBILITY OF
** SUCH DAMAGE.
**
** ui128.h: API declaration
*/
#ifndef __UI128_H__
#define __UI128_H__
#include <string.h>
#define UI128_PREFIX uuid_
/* embedding support */
#ifdef UI128_PREFIX
#if defined(__STDC__) || defined(__cplusplus)
#define __UI128_CONCAT(x,y) x ## y
#define UI128_CONCAT(x,y) __UI128_CONCAT(x,y)
#else
#define __UI128_CONCAT(x) x
#define UI128_CONCAT(x,y) __UI128_CONCAT(x)y
#endif
#define ui128_t UI128_CONCAT(UI128_PREFIX,ui128_t)
#define ui128_zero UI128_CONCAT(UI128_PREFIX,ui128_zero)
#define ui128_max UI128_CONCAT(UI128_PREFIX,ui128_max)
#define ui128_n2i UI128_CONCAT(UI128_PREFIX,ui128_n2i)
#define ui128_i2n UI128_CONCAT(UI128_PREFIX,ui128_i2n)
#define ui128_s2i UI128_CONCAT(UI128_PREFIX,ui128_s2i)
#define ui128_i2s UI128_CONCAT(UI128_PREFIX,ui128_i2s)
#define ui128_add UI128_CONCAT(UI128_PREFIX,ui128_add)
#define ui128_addn UI128_CONCAT(UI128_PREFIX,ui128_addn)
#define ui128_sub UI128_CONCAT(UI128_PREFIX,ui128_sub)
#define ui128_subn UI128_CONCAT(UI128_PREFIX,ui128_subn)
#define ui128_mul UI128_CONCAT(UI128_PREFIX,ui128_mul)
#define ui128_muln UI128_CONCAT(UI128_PREFIX,ui128_muln)
#define ui128_div UI128_CONCAT(UI128_PREFIX,ui128_div)
#define ui128_divn UI128_CONCAT(UI128_PREFIX,ui128_divn)
#define ui128_and UI128_CONCAT(UI128_PREFIX,ui128_and)
#define ui128_or UI128_CONCAT(UI128_PREFIX,ui128_or)
#define ui128_xor UI128_CONCAT(UI128_PREFIX,ui128_xor)
#define ui128_not UI128_CONCAT(UI128_PREFIX,ui128_not)
#define ui128_rol UI128_CONCAT(UI128_PREFIX,ui128_rol)
#define ui128_ror UI128_CONCAT(UI128_PREFIX,ui128_ror)
#define ui128_len UI128_CONCAT(UI128_PREFIX,ui128_len)
#define ui128_cmp UI128_CONCAT(UI128_PREFIX,ui128_cmp)
#endif
typedef struct {
unsigned char x[16]; /* x_0, ..., x_15 */
} ui128_t;
#define ui128_cons(x15,x14,x13,x12,x11,x10,x9,x8,x7,x6,x5,x4,x3,x2,x1,x0) \
{ { 0x##x0, 0x##x1, 0x##x2, 0x##x3, 0x##x4, 0x##x5, 0x##x6, 0x##x7, \
{ { 0x##x8, 0x##x9, 0x##x10, 0x##x11, 0x##x12, 0x##x13, 0x##x14, 0x##x15 } }
/* particular values */
extern ui128_t ui128_zero (void);
extern ui128_t ui128_max (void);
/* import and export via ISO-C "unsigned long" */
extern ui128_t ui128_n2i (unsigned long n);
extern unsigned long ui128_i2n (ui128_t x);
/* import and export via ISO-C string of arbitrary base */
extern ui128_t ui128_s2i (const char *str, char **end, int base);
extern char * ui128_i2s (ui128_t x, char *str, size_t len, int base);
/* arithmetical operations */
extern ui128_t ui128_add (ui128_t x, ui128_t y, ui128_t *ov);
extern ui128_t ui128_addn (ui128_t x, int y, int *ov);
extern ui128_t ui128_sub (ui128_t x, ui128_t y, ui128_t *ov);
extern ui128_t ui128_subn (ui128_t x, int y, int *ov);
extern ui128_t ui128_mul (ui128_t x, ui128_t y, ui128_t *ov);
extern ui128_t ui128_muln (ui128_t x, int y, int *ov);
extern ui128_t ui128_div (ui128_t x, ui128_t y, ui128_t *ov);
extern ui128_t ui128_divn (ui128_t x, int y, int *ov);
/* bit operations */
extern ui128_t ui128_and (ui128_t x, ui128_t y);
extern ui128_t ui128_or (ui128_t x, ui128_t y);
extern ui128_t ui128_xor (ui128_t x, ui128_t y);
extern ui128_t ui128_not (ui128_t x);
extern ui128_t ui128_rol (ui128_t x, int s, ui128_t *ov);
extern ui128_t ui128_ror (ui128_t x, int s, ui128_t *ov);
/* other operations */
extern int ui128_len (ui128_t x);
extern int ui128_cmp (ui128_t x, ui128_t y);
#endif /* __UI128_H__ */

View File

@ -1,591 +0,0 @@
/*
** OSSP ui64 - 64-Bit Arithmetic
** Copyright (c) 2002-2005 Ralf S. Engelschall <rse@engelschall.com>
** Copyright (c) 2002-2005 The OSSP Project <http://www.ossp.org/>
**
** This file is part of OSSP ui64, a 64-bit arithmetic library
** which can be found at http://www.ossp.org/pkg/lib/ui64/.
**
** Permission to use, copy, modify, and distribute this software for
** any purpose with or without fee is hereby granted, provided that
** the above copyright notice and this permission notice appear in all
** copies.
**
** THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
** WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
** MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
** IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
** CONTRIBUTORS 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 ADVISED OF THE POSSIBILITY OF
** SUCH DAMAGE.
**
** ui64.c: implementation of 64-bit unsigned integer arithmetic
*/
/* own headers (part 1/2) */
#include "uuid_ac.h"
/* system headers */
#include <string.h>
#include <ctype.h>
/* own headers (part 2/2) */
#include "uuid_ui64.h"
#define UI64_BASE 256 /* 2^8 */
#define UI64_DIGITS 8 /* 8*8 = 64 bit */
#define UIXX_T(n) struct { unsigned char x[n]; }
/* fill an ui64_t with a sequence of a particular digit */
#define ui64_fill(__x, __n) \
/*lint -save -e717*/ \
do { int __i; \
for (__i = 0; __i < UI64_DIGITS; __i++) \
(__x).x[__i] = (__n); \
} while (0) \
/*lint -restore*/
/* the value zero */
ui64_t ui64_zero(void)
{
ui64_t z;
ui64_fill(z, 0);
return z;
}
/* the maximum value */
ui64_t ui64_max(void)
{
ui64_t z;
ui64_fill(z, UI64_BASE-1);
return z;
}
/* convert ISO-C "unsigned long" into internal format */
ui64_t ui64_n2i(unsigned long n)
{
ui64_t z;
int i;
i = 0;
do {
z.x[i++] = (n % UI64_BASE);
} while ((n /= UI64_BASE) > 0 && i < UI64_DIGITS);
for ( ; i < UI64_DIGITS; i++)
z.x[i] = 0;
return z;
}
/* convert internal format into ISO-C "unsigned long";
truncates if sizeof(unsigned long) is less than UI64_DIGITS! */
unsigned long ui64_i2n(ui64_t x)
{
unsigned long n;
int i;
n = 0;
i = (int)sizeof(n);
/*lint -save -e774*/
if (i > UI64_DIGITS)
i = UI64_DIGITS;
/*lint -restore*/
while (--i >= 0) {
n = (n * UI64_BASE) + x.x[i];
}
return n;
}
/* convert string representation of arbitrary base into internal format */
ui64_t ui64_s2i(const char *str, char **end, int base)
{
ui64_t z;
const char *cp;
int carry;
static char map[] = {
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, /* 0...9 */
36, 36, 36, 36, 36, 36, 36, /* illegal chars */
10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, /* A...M */
23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, /* N...Z */
36, 36, 36, 36, 36, 36, /* illegal chars */
10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, /* a...m */
23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35 /* m...z */
};
ui64_fill(z, 0);
if (str == NULL || (base < 2 || base > 36))
return z;
cp = str;
while (*cp != '\0' && isspace((int)(*cp)))
cp++;
while ( *cp != '\0'
&& isalnum((int)(*cp))
&& map[(int)(*cp)-'0'] < base) {
z = ui64_muln(z, base, &carry);
if (carry)
break;
z = ui64_addn(z, map[(int)(*cp)-'0'], &carry);
if (carry)
break;
cp++;
}
if (end != NULL)
*end = (char *)cp;
return z;
}
/* convert internal format into string representation of arbitrary base */
char *ui64_i2s(ui64_t x, char *str, size_t len, int base)
{
static char map[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
char c;
int r;
int n;
int i, j;
if (str == NULL || len < 2 || (base < 2 || base > 36))
return NULL;
n = ui64_len(x);
i = 0;
do {
x = ui64_divn(x, base, &r);
str[i++] = map[r];
while (n > 1 && x.x[n-1] == 0)
n--;
} while (i < ((int)len-1) && (n > 1 || x.x[0] != 0));
str[i] = '\0';
for (j = 0; j < --i; j++) {
c = str[j];
str[j] = str[i];
str[i] = c;
}
return str;
}
/* addition of two ui64_t */
ui64_t ui64_add(ui64_t x, ui64_t y, ui64_t *ov)
{
ui64_t z;
int carry;
int i;
carry = 0;
for (i = 0; i < UI64_DIGITS; i++) {
carry += (x.x[i] + y.x[i]);
z.x[i] = (carry % UI64_BASE);
carry /= UI64_BASE;
}
if (ov != NULL)
*ov = ui64_n2i((unsigned long)carry);
return z;
}
/* addition of an ui64_t and a single digit */
ui64_t ui64_addn(ui64_t x, int y, int *ov)
{
ui64_t z;
int i;
for (i = 0; i < UI64_DIGITS; i++) {
y += x.x[i];
z.x[i] = (y % UI64_BASE);
y /= UI64_BASE;
}
if (ov != NULL)
*ov = y;
return z;
}
/* subtraction of two ui64_t */
ui64_t ui64_sub(ui64_t x, ui64_t y, ui64_t *ov)
{
ui64_t z;
int borrow;
int i;
int d;
borrow = 0;
for (i = 0; i < UI64_DIGITS; i++) {
d = ((x.x[i] + UI64_BASE) - borrow - y.x[i]);
z.x[i] = (d % UI64_BASE);
borrow = (1 - (d/UI64_BASE));
}
if (ov != NULL)
*ov = ui64_n2i((unsigned long)borrow);
return z;
}
/* subtraction of an ui64_t and a single digit */
ui64_t ui64_subn(ui64_t x, int y, int *ov)
{
ui64_t z;
int i;
int d;
for (i = 0; i < UI64_DIGITS; i++) {
d = (x.x[i] + UI64_BASE) - y;
z.x[i] = (d % UI64_BASE);
y = (1 - (d/UI64_BASE));
}
if (ov != NULL)
*ov = y;
return z;
}
/*
7 3 2
* 9 4 2 8
---------
5 8 5 6
+ 1 4 6 4
+ 2 9 2 8
+ 6 5 8 8
---------------
= 6 9 0 1 2 9 6
*/
ui64_t ui64_mul(ui64_t x, ui64_t y, ui64_t *ov)
{
UIXX_T(UI64_DIGITS+UI64_DIGITS) zx;
ui64_t z;
int carry;
int i, j;
/* clear temporary result buffer */
for (i = 0; i < (UI64_DIGITS+UI64_DIGITS); i++)
zx.x[i] = 0;
/* perform multiplication operation */
for (i = 0; i < UI64_DIGITS; i++) {
/* calculate partial product and immediately add to z */
carry = 0;
for (j = 0; j < UI64_DIGITS; j++) {
carry += (x.x[i] * y.x[j]) + zx.x[i+j];
zx.x[i+j] = (carry % UI64_BASE);
carry /= UI64_BASE;
}
/* add carry to remaining digits in z */
for ( ; j < UI64_DIGITS + UI64_DIGITS - i; j++) {
carry += zx.x[i+j];
zx.x[i+j] = (carry % UI64_BASE);
carry /= UI64_BASE;
}
}
/* provide result by splitting zx into z and ov */
memcpy(z.x, zx.x, UI64_DIGITS);
if (ov != NULL)
memcpy((*ov).x, &zx.x[UI64_DIGITS], UI64_DIGITS);
return z;
}
ui64_t ui64_muln(ui64_t x, int y, int *ov)
{
ui64_t z;
int carry;
int i;
carry = 0;
for (i = 0; i < UI64_DIGITS; i++) {
carry += (x.x[i] * y);
z.x[i] = (carry % UI64_BASE);
carry /= UI64_BASE;
}
if (ov != NULL)
*ov = carry;
return z;
}
/*
= 2078 [q]
0615367 [x] : 296 [y]
-0592 [dq]
-----
= 0233
-0000 [dq]
-----
= 2336
-2072 [dq]
-----
= 2647
-2308 [dq]
-----
= 279 [r]
*/
ui64_t ui64_div(ui64_t x, ui64_t y, ui64_t *ov)
{
ui64_t q;
ui64_t r;
int i;
int n, m;
int ovn;
/* determine actual number of involved digits */
n = ui64_len(x);
m = ui64_len(y);
if (m == 1) {
/* simple case #1: reduceable to ui64_divn() */
if (y.x[0] == 0) {
/* error case: division by zero! */
ui64_fill(q, 0);
ui64_fill(r, 0);
}
else {
q = ui64_divn(x, y.x[0], &ovn);
ui64_fill(r, 0);
r.x[0] = (unsigned char)ovn;
}
} else if (n < m) {
/* simple case #2: everything is in the remainder */
ui64_fill(q, 0);
r = x;
} else { /* n >= m, m > 1 */
/* standard case: x[0..n] / y[0..m] */
UIXX_T(UI64_DIGITS+1) rx;
UIXX_T(UI64_DIGITS+1) dq;
ui64_t t;
int km;
int k;
int qk;
unsigned long y2;
unsigned long r3;
int borrow;
int d;
/* rx is x with a leading zero in order to make
sure that n > m and not just n >= m */
memcpy(rx.x, x.x, UI64_DIGITS);
rx.x[UI64_DIGITS] = 0;
for (k = n - m; k >= 0; k--) {
/* efficiently compute qk by guessing
qk := rx[k+m-2...k+m]/y[m-2...m-1] */
km = k + m;
y2 = (y.x[m-1]*UI64_BASE) + y.x[m-2];
r3 = (rx.x[km]*(UI64_BASE*UI64_BASE)) +
(rx.x[km-1]*UI64_BASE) + rx.x[km-2];
qk = r3 / y2;
if (qk >= UI64_BASE)
qk = UI64_BASE - 1;
/* dq := y*qk (post-adjust qk if guessed incorrectly) */
t = ui64_muln(y, qk, &ovn);
memcpy(dq.x, t.x, UI64_DIGITS);
dq.x[m] = (unsigned char)ovn;
for (i = m; i > 0; i--)
if (rx.x[i+k] != dq.x[i])
break;
if (rx.x[i+k] < dq.x[i]) {
t = ui64_muln(y, --qk, &ovn);
memcpy(dq.x, t.x, UI64_DIGITS);
dq.x[m] = (unsigned char)ovn;
}
/* store qk */
q.x[k] = (unsigned char)qk;
/* rx := rx - dq*(b^k) */
borrow = 0;
for (i = 0; i < m+1; i++) {
d = ((rx.x[k+i] + UI64_BASE) - borrow - dq.x[i]);
rx.x[k+i] = (d % UI64_BASE);
borrow = (1 - (d/UI64_BASE));
}
}
memcpy(r.x, rx.x, m);
/* fill out results with leading zeros */
for (i = n-m+1; i < UI64_DIGITS; i++)
q.x[i] = 0;
for (i = m; i < UI64_DIGITS; i++)
r.x[i] = 0;
}
/* provide results */
if (ov != NULL)
*ov = r;
return q;
}
ui64_t ui64_divn(ui64_t x, int y, int *ov)
{
ui64_t z;
unsigned int carry;
int i;
carry = 0;
for (i = (UI64_DIGITS - 1); i >= 0; i--) {
carry = (carry * UI64_BASE) + x.x[i];
z.x[i] = (carry / y);
carry %= y;
}
if (ov != NULL)
*ov = carry;
return z;
}
ui64_t ui64_and(ui64_t x, ui64_t y)
{
ui64_t z;
int i;
for (i = 0; i < UI64_DIGITS; i++)
z.x[i] = (x.x[i] & y.x[i]);
return z;
}
ui64_t ui64_or(ui64_t x, ui64_t y)
{
ui64_t z;
int i;
for (i = 0; i < UI64_DIGITS; i++)
z.x[i] = (x.x[i] | y.x[i]);
return z;
}
ui64_t ui64_xor(ui64_t x, ui64_t y)
{
ui64_t z;
int i;
for (i = 0; i < UI64_DIGITS; i++)
z.x[i] = ((x.x[i] & ~(y.x[i])) | (~(x.x[i]) & (y.x[i])));
return z;
}
ui64_t ui64_not(ui64_t x)
{
ui64_t z;
int i;
for (i = 0; i < UI64_DIGITS; i++)
z.x[i] = ~(x.x[i]);
return z;
}
ui64_t ui64_rol(ui64_t x, int s, ui64_t *ov)
{
UIXX_T(UI64_DIGITS+UI64_DIGITS) zx;
ui64_t z;
int i;
int carry;
if (s <= 0) {
/* no shift at all */
if (ov != NULL)
*ov = ui64_zero();
return x;
}
else if (s > 64) {
/* too large shift */
if (ov != NULL)
*ov = ui64_zero();
return ui64_zero();
}
else if (s == 64) {
/* maximum shift */
if (ov != NULL)
*ov = x;
return ui64_zero();
}
else { /* regular shift */
/* shift (logically) left by s/8 bytes */
for (i = 0; i < UI64_DIGITS+UI64_DIGITS; i++)
zx.x[i] = 0;
for (i = 0; i < UI64_DIGITS; i++)
zx.x[i+(s/8)] = x.x[i];
/* shift (logically) left by remaining s%8 bits */
s %= 8;
if (s > 0) {
carry = 0;
for (i = 0; i < UI64_DIGITS+UI64_DIGITS; i++) {
carry += (zx.x[i] * (1 << s));
zx.x[i] = (carry % UI64_BASE);
carry /= UI64_BASE;
}
}
memcpy(z.x, zx.x, UI64_DIGITS);
if (ov != NULL)
memcpy((*ov).x, &zx.x[UI64_DIGITS], UI64_DIGITS);
}
return z;
}
ui64_t ui64_ror(ui64_t x, int s, ui64_t *ov)
{
UIXX_T(UI64_DIGITS+UI64_DIGITS) zx;
ui64_t z;
int i;
int carry;
if (s <= 0) {
/* no shift at all */
if (ov != NULL)
*ov = ui64_zero();
return x;
}
else if (s > 64) {
/* too large shift */
if (ov != NULL)
*ov = ui64_zero();
return ui64_zero();
}
else if (s == 64) {
/* maximum shift */
if (ov != NULL)
*ov = x;
return ui64_zero();
}
else { /* regular shift */
/* shift (logically) right by s/8 bytes */
for (i = 0; i < UI64_DIGITS+UI64_DIGITS; i++)
zx.x[i] = 0;
for (i = 0; i < UI64_DIGITS; i++)
zx.x[UI64_DIGITS+i-(s/8)] = x.x[i];
/* shift (logically) right by remaining s%8 bits */
s %= 8;
if (s > 0) {
carry = 0;
for (i = (UI64_DIGITS+UI64_DIGITS - 1); i >= 0; i--) {
carry = (carry * UI64_BASE) + zx.x[i];
zx.x[i] = (carry / (1 << s));
carry %= (1 << s);
}
}
memcpy(z.x, &zx.x[UI64_DIGITS], UI64_DIGITS);
if (ov != NULL)
memcpy((*ov).x, zx.x, UI64_DIGITS);
}
return z;
}
int ui64_cmp(ui64_t x, ui64_t y)
{
int i;
i = UI64_DIGITS - 1;
while (i > 0 && x.x[i] == y.x[i])
i--;
return (x.x[i] - y.x[i]);
}
int ui64_len(ui64_t x)
{
int i;
for (i = UI64_DIGITS; i > 1 && x.x[i-1] == 0; i--)
;
return i;
}

View File

@ -1,113 +0,0 @@
/*
** OSSP ui64 - 64-Bit Arithmetic
** Copyright (c) 2002-2005 Ralf S. Engelschall <rse@engelschall.com>
** Copyright (c) 2002-2005 The OSSP Project <http://www.ossp.org/>
**
** This file is part of OSSP ui64, a 64-bit arithmetic library
** which can be found at http://www.ossp.org/pkg/lib/ui64/.
**
** Permission to use, copy, modify, and distribute this software for
** any purpose with or without fee is hereby granted, provided that
** the above copyright notice and this permission notice appear in all
** copies.
**
** THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
** WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
** MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
** IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
** CONTRIBUTORS 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 ADVISED OF THE POSSIBILITY OF
** SUCH DAMAGE.
**
** ui64.h: API declaration
*/
#ifndef __UI64_H__
#define __UI64_H__
#include <string.h>
#define UI64_PREFIX uuid_
/* embedding support */
#ifdef UI64_PREFIX
#if defined(__STDC__) || defined(__cplusplus)
#define __UI64_CONCAT(x,y) x ## y
#define UI64_CONCAT(x,y) __UI64_CONCAT(x,y)
#else
#define __UI64_CONCAT(x) x
#define UI64_CONCAT(x,y) __UI64_CONCAT(x)y
#endif
#define ui64_t UI64_CONCAT(UI64_PREFIX,ui64_t)
#define ui64_zero UI64_CONCAT(UI64_PREFIX,ui64_zero)
#define ui64_max UI64_CONCAT(UI64_PREFIX,ui64_max)
#define ui64_n2i UI64_CONCAT(UI64_PREFIX,ui64_n2i)
#define ui64_i2n UI64_CONCAT(UI64_PREFIX,ui64_i2n)
#define ui64_s2i UI64_CONCAT(UI64_PREFIX,ui64_s2i)
#define ui64_i2s UI64_CONCAT(UI64_PREFIX,ui64_i2s)
#define ui64_add UI64_CONCAT(UI64_PREFIX,ui64_add)
#define ui64_addn UI64_CONCAT(UI64_PREFIX,ui64_addn)
#define ui64_sub UI64_CONCAT(UI64_PREFIX,ui64_sub)
#define ui64_subn UI64_CONCAT(UI64_PREFIX,ui64_subn)
#define ui64_mul UI64_CONCAT(UI64_PREFIX,ui64_mul)
#define ui64_muln UI64_CONCAT(UI64_PREFIX,ui64_muln)
#define ui64_div UI64_CONCAT(UI64_PREFIX,ui64_div)
#define ui64_divn UI64_CONCAT(UI64_PREFIX,ui64_divn)
#define ui64_and UI64_CONCAT(UI64_PREFIX,ui64_and)
#define ui64_or UI64_CONCAT(UI64_PREFIX,ui64_or)
#define ui64_xor UI64_CONCAT(UI64_PREFIX,ui64_xor)
#define ui64_not UI64_CONCAT(UI64_PREFIX,ui64_not)
#define ui64_rol UI64_CONCAT(UI64_PREFIX,ui64_rol)
#define ui64_ror UI64_CONCAT(UI64_PREFIX,ui64_ror)
#define ui64_len UI64_CONCAT(UI64_PREFIX,ui64_len)
#define ui64_cmp UI64_CONCAT(UI64_PREFIX,ui64_cmp)
#endif
typedef struct {
unsigned char x[8]; /* x_0, ..., x_7 */
} ui64_t;
#define ui64_cons(x7,x6,x5,x4,x3,x2,x1,x0) \
{ { 0x##x0, 0x##x1, 0x##x2, 0x##x3, 0x##x4, 0x##x5, 0x##x6, 0x##x7 } }
/* particular values */
extern ui64_t ui64_zero (void);
extern ui64_t ui64_max (void);
/* import and export via ISO-C "unsigned long" */
extern ui64_t ui64_n2i (unsigned long n);
extern unsigned long ui64_i2n (ui64_t x);
/* import and export via ISO-C string of arbitrary base */
extern ui64_t ui64_s2i (const char *str, char **end, int base);
extern char * ui64_i2s (ui64_t x, char *str, size_t len, int base);
/* arithmetical operations */
extern ui64_t ui64_add (ui64_t x, ui64_t y, ui64_t *ov);
extern ui64_t ui64_addn (ui64_t x, int y, int *ov);
extern ui64_t ui64_sub (ui64_t x, ui64_t y, ui64_t *ov);
extern ui64_t ui64_subn (ui64_t x, int y, int *ov);
extern ui64_t ui64_mul (ui64_t x, ui64_t y, ui64_t *ov);
extern ui64_t ui64_muln (ui64_t x, int y, int *ov);
extern ui64_t ui64_div (ui64_t x, ui64_t y, ui64_t *ov);
extern ui64_t ui64_divn (ui64_t x, int y, int *ov);
/* bit operations */
extern ui64_t ui64_and (ui64_t x, ui64_t y);
extern ui64_t ui64_or (ui64_t x, ui64_t y);
extern ui64_t ui64_xor (ui64_t x, ui64_t y);
extern ui64_t ui64_not (ui64_t x);
extern ui64_t ui64_rol (ui64_t x, int s, ui64_t *ov);
extern ui64_t ui64_ror (ui64_t x, int s, ui64_t *ov);
/* other operations */
extern int ui64_len (ui64_t x);
extern int ui64_cmp (ui64_t x, ui64_t y);
#endif /* __UI64_H__ */

View File

@ -1,46 +0,0 @@
/*
** uuid_vers.h -- Version Information for OSSP uuid (syntax: C/C++)
** [automatically generated and maintained by GNU shtool]
*/
#ifdef _UUID_VERS_H_AS_HEADER_
#ifndef _UUID_VERS_H_
#define _UUID_VERS_H_
#define _UUID_VERSION 0x106202
typedef struct {
const int v_hex;
const char *v_short;
const char *v_long;
const char *v_tex;
const char *v_gnu;
const char *v_web;
const char *v_sccs;
const char *v_rcs;
} _uuid_version_t;
extern _uuid_version_t _uuid_version;
#endif /* _UUID_VERS_H_ */
#else /* _UUID_VERS_H_AS_HEADER_ */
#define _UUID_VERS_H_AS_HEADER_
#include "uuid_vers.h"
#undef _UUID_VERS_H_AS_HEADER_
_uuid_version_t _uuid_version = {
0x106202,
"1.6.2",
"1.6.2 (04-Jul-2008)",
"This is OSSP uuid, Version 1.6.2 (04-Jul-2008)",
"OSSP uuid 1.6.2 (04-Jul-2008)",
"OSSP uuid/1.6.2",
"@(#)OSSP uuid 1.6.2 (04-Jul-2008)",
"$Id: OSSP uuid 1.6.2 (04-Jul-2008) $"
};
#endif /* _UUID_VERS_H_AS_HEADER_ */