## ## OSSP uuid - Universally Unique Identifier ## Copyright (c) 2004-2007 Ralf S. Engelschall ## Copyright (c) 2004-2007 The OSSP Project ## ## 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 Perl Binding =head1 DESCRIPTION B 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 (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 is the Perl binding to the B 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 =item BC< my $uuid, 'OSSP::uuid::tie', $mode, ...;> =item C<$uuid = [ $mode, ... ];> =item C =item C =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 =item CBC< OSSP::uuid;> =item C<$uuid-E>BC<($name);> =item C<$uuid-E>BC<($mode, ...);> =item C<$result = $uuid-E>BC<();> =item C<$result = $uuid-E>BC<($uuid2);> =item C<$uuid-E>BC<($fmt, $data_ptr);> =item C<$data_ptr = $uuid-E>BC<($fmt);> =item C<[(]$str[, $rc)] = $uuid-E>BC<();> =item C<$ver = $uuid-E>BC<();> =item C =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 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 =item CBC<($uuid);> =item C<$rc = >BC<($uuid, $name);> =item C<$rc = >BC<($uuid, $mode, ...);> =item C<$rc = >BC<($uuid, $result);> =item C<$rc = >BC<($uuid, $uuid2, $result);> =item C<$rc = >BC<($uuid, $fmt, $data_ptr, $data_len);> =item C<$rc = >BC<($uuid, $fmt, $data_ptr, $data_len);> =item C<$str = >BC<($rc);> =item C<$ver = >BC<();> =item C<$rc = >BC<($uuid);> =back Additionally, the following constants are exported for use in C<$rc>, C<$mode>, C<$fmt> and C<$ver>: C, C, C, C, C, C, C, C, C, C, C, C, C, C, C, C, C, C. =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 to B was implemented in November 2004 by Ralf S. Engelschall Erse@engelschall.comE. =cut