Index: ossp-pkg/uuid/ChangeLog RCS File: /v/ossp/cvs/ossp-pkg/uuid/Attic/ChangeLog,v rcsdiff -q -kk '-r1.57' '-r1.58' -u '/v/ossp/cvs/ossp-pkg/uuid/Attic/ChangeLog,v' 2>/dev/null --- ChangeLog 2004/10/31 11:58:47 1.57 +++ ChangeLog 2004/11/03 14:52:08 1.58 @@ -11,9 +11,10 @@ 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.0.4 and 1.0.5 (16-Oct-2004 to 31-Oct-2004) + Changes between 1.0.4 and 1.1.0 (16-Oct-2004 to xx-Nov-2004) - o ... + o Add Perl language binding 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) Index: ossp-pkg/uuid/perl/MANIFEST RCS File: /v/ossp/cvs/ossp-pkg/uuid/perl/Attic/MANIFEST,v co -q -kk -p'1.1' '/v/ossp/cvs/ossp-pkg/uuid/perl/Attic/MANIFEST,v' | diff -u /dev/null - -L'ossp-pkg/uuid/perl/MANIFEST' 2>/dev/null --- ossp-pkg/uuid/perl/MANIFEST +++ - 2024-05-21 04:33:28.772522303 +0200 @@ -0,0 +1,8 @@ +MANIFEST +Makefile.PL +uuid.xs +uuid.tm +uuid.pm +uuid.pod +uuid.ts +META.yml Module meta-data (added by MakeMaker) Index: ossp-pkg/uuid/perl/Makefile.PL RCS File: /v/ossp/cvs/ossp-pkg/uuid/perl/Attic/Makefile.PL,v co -q -kk -p'1.1' '/v/ossp/cvs/ossp-pkg/uuid/perl/Attic/Makefile.PL,v' | diff -u /dev/null - -L'ossp-pkg/uuid/perl/Makefile.PL' 2>/dev/null --- ossp-pkg/uuid/perl/Makefile.PL +++ - 2024-05-21 04:33:28.775334549 +0200 @@ -0,0 +1,53 @@ +## +## OSSP uuid - Universally Unique Identifier +## Copyright (c) 2004 Ralf S. Engelschall +## Copyright (c) 2004 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. +## +## Makefile.PL: Perl MakeMaker build source procedure +## + +use 5.008; +use Config; +use ExtUtils::MakeMaker; + +WriteMakefile( + NAME => 'OSSP::uuid', + VERSION_FROM => 'uuid.pm', + ABSTRACT_FROM => 'uuid.pod', + AUTHOR => 'Ralf S. Engelschall ', + PREREQ_PM => {}, + LIBS => [ '-L../.libs -luuid' ], + DEFINE => '', + INC => '-I. -I..', + PM => { 'uuid.pm' => '$(INST_LIBDIR)/uuid.pm', + 'uuid.pod' => '$(INST_LIBDIR)/uuid.pod' }, + TYPEMAPS => [ 'uuid.tm' ], + test => { TESTS => 'uuid.ts' }, + # cruel hack to workaround the conflict between OSSP uuid's + # uuid_create() function and one from FreeBSD's libc + (( "$Config{'osname'}$Config{'osvers'}" =~ m/^freebsd5\./ + and $Config{'ld'} =~ m/cc$/ and -f "/usr/include/uuid.h") ? + ( LDDLFLAGS => $Config{'lddlflags'} . ' -Wl,-Bsymbolic') : ()) +); + Index: ossp-pkg/uuid/perl/uuid.pm RCS File: /v/ossp/cvs/ossp-pkg/uuid/perl/Attic/uuid.pm,v co -q -kk -p'1.1' '/v/ossp/cvs/ossp-pkg/uuid/perl/Attic/uuid.pm,v' | diff -u /dev/null - -L'ossp-pkg/uuid/perl/uuid.pm' 2>/dev/null --- ossp-pkg/uuid/perl/uuid.pm +++ - 2024-05-21 04:33:28.777855020 +0200 @@ -0,0 +1,246 @@ +## +## OSSP uuid - Universally Unique Identifier +## Copyright (c) 2004 Ralf S. Engelschall +## Copyright (c) 2004 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.pm: Perl Binding (Perl part) +## + +package OSSP::uuid; + +use 5.008; +use strict; +use warnings; +use Carp; +use XSLoader; +use Exporter; + +## +## API Definition +## + +# API version +our $VERSION = do { my @v = ('1.0.4' =~ 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_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_MC + UUID_FMT_BIN + UUID_FMT_STR + 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 = (); + +## +## High-Level Perl Module OO-style API +## (just an OO wrapper around the C-style API) +## + +# 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 'mc') { $mode_code |= $self->UUID_MAKE_MC; } + else { croak("invalid mode specification \"$spec\""); } + } + if ($mode_code & $self->UUID_MAKE_V3) { + if (not (ref($valist[0]) and $valist[0]->isa("OSSP::uuid"))) { + croak("UUID_MAKE_V3 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 { + 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); + 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 '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 { + if (defined($_[0]) and ref($_[0]) =~ m/^OSSP::uuid/) { + # the regular OSSP::uuid "export" method + croak("export method expects 2 arguments") if (@_ != 2); + 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 '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; + Index: ossp-pkg/uuid/perl/uuid.pod RCS File: /v/ossp/cvs/ossp-pkg/uuid/perl/Attic/uuid.pod,v co -q -kk -p'1.1' '/v/ossp/cvs/ossp-pkg/uuid/perl/Attic/uuid.pod,v' | diff -u /dev/null - -L'ossp-pkg/uuid/perl/uuid.pod' 2>/dev/null --- ossp-pkg/uuid/perl/uuid.pod +++ - 2024-05-21 04:33:28.780525997 +0200 @@ -0,0 +1,174 @@ +## +## OSSP uuid - Universally Unique Identifier +## Copyright (c) 2004 Ralf S. Engelschall +## Copyright (c) 2004 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.pm: Perl Binding (Perl/POD part) +## + +=pod + +=head1 NAME + +OSSP::uuid - B Perl Binding + +=head1 DESCRIPTION + +B is the Perl binding to the B API. + +B is an ISO-C application programming interface (API) and +corresponding command line interface (CLI) for the generation of DCE +1.1 and ISO/IEC 11578:1996 compliant I +(UUID). It supports DCE 1.1 variant UUIDs of version 1 (time and node +based), version 3 (name based) and version 4 (random number based). + +B provides two Perl APIs: + +=head2 OO-STYLE API + +The OO-style API is a wrapper around the C-style API and intended for +high-level and 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<"v2">, C<"v3"> 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. + +=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. + + # 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(3), +http://www.ossp.org/pkg/lib/uuid/ + +=head1 AUTHOR + +Ralf S. Engelschall, Erse@engelschall.comE + +=cut + Index: ossp-pkg/uuid/perl/uuid.tm RCS File: /v/ossp/cvs/ossp-pkg/uuid/perl/Attic/uuid.tm,v co -q -kk -p'1.1' '/v/ossp/cvs/ossp-pkg/uuid/perl/Attic/uuid.tm,v' | diff -u /dev/null - -L'ossp-pkg/uuid/perl/uuid.tm' 2>/dev/null --- ossp-pkg/uuid/perl/uuid.tm +++ - 2024-05-21 04:33:28.783114814 +0200 @@ -0,0 +1,39 @@ +## +## OSSP uuid - Universally Unique Identifier +## Copyright (c) 2004 Ralf S. Engelschall +## Copyright (c) 2004 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.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 + Index: ossp-pkg/uuid/perl/uuid.ts RCS File: /v/ossp/cvs/ossp-pkg/uuid/perl/Attic/uuid.ts,v co -q -kk -p'1.1' '/v/ossp/cvs/ossp-pkg/uuid/perl/Attic/uuid.ts,v' | diff -u /dev/null - -L'ossp-pkg/uuid/perl/uuid.ts' 2>/dev/null --- ossp-pkg/uuid/perl/uuid.ts +++ - 2024-05-21 04:33:28.785622526 +0200 @@ -0,0 +1,144 @@ +## +## OSSP uuid - Universally Unique Identifier +## Copyright (c) 2004 Ralf S. Engelschall +## Copyright (c) 2004 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.ts: Perl Binding (Perl test suite part) +## + +use Test::More tests => 31; + +## +## 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_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; + Index: ossp-pkg/uuid/perl/uuid.xs RCS File: /v/ossp/cvs/ossp-pkg/uuid/perl/Attic/uuid.xs,v co -q -kk -p'1.1' '/v/ossp/cvs/ossp-pkg/uuid/perl/Attic/uuid.xs,v' | diff -u /dev/null - -L'ossp-pkg/uuid/perl/uuid.xs' 2>/dev/null --- ossp-pkg/uuid/perl/uuid.xs +++ - 2024-05-21 04:33:28.788124132 +0200 @@ -0,0 +1,231 @@ +/* +** OSSP uuid - Universally Unique Identifier +** Copyright (c) 2004 Ralf S. Engelschall +** Copyright (c) 2004 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.xs: Perl Binding (Perl/XS part) +*/ + +#include "EXTERN.h" +#include "perl.h" +#include "XSUB.h" + +#include "uuid.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_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_MC", UUID_MAKE_MC }, + { "UUID_FMT_BIN", UUID_FMT_BIN }, + { "UUID_FMT_STR", UUID_FMT_STR }, + { "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) { + if (items != 4) + croak("mode UUID_MAKE_V3 requires two additional arguments to uuid_make()"); + if (!SvROK(ST(2))) + croak("mode UUID_MAKE_V3 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_STR) + 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 +