diff options
author | Jason Downs <downsj@cvs.openbsd.org> | 1996-08-19 10:13:38 +0000 |
---|---|---|
committer | Jason Downs <downsj@cvs.openbsd.org> | 1996-08-19 10:13:38 +0000 |
commit | 14856225739aa48b6c9cf4c17925362b2d95cea3 (patch) | |
tree | dfd38f1b654fb5bbdfc38887c1a829b658e71530 /gnu/usr.bin/perl/ext/ODBM_File | |
parent | 77469082517e44fe6ca347d9e8dc7dffd1583637 (diff) |
Import of Perl 5.003 into the tree. Makefile.bsd-wrapper and
config.sh.OpenBSD are the only local changes.
Diffstat (limited to 'gnu/usr.bin/perl/ext/ODBM_File')
-rw-r--r-- | gnu/usr.bin/perl/ext/ODBM_File/Makefile.PL | 8 | ||||
-rw-r--r-- | gnu/usr.bin/perl/ext/ODBM_File/ODBM_File.pm | 35 | ||||
-rw-r--r-- | gnu/usr.bin/perl/ext/ODBM_File/ODBM_File.xs | 101 | ||||
-rw-r--r-- | gnu/usr.bin/perl/ext/ODBM_File/hints/dec_osf.pl | 5 | ||||
-rw-r--r-- | gnu/usr.bin/perl/ext/ODBM_File/hints/sco.pl | 4 | ||||
-rw-r--r-- | gnu/usr.bin/perl/ext/ODBM_File/hints/solaris.pl | 3 | ||||
-rw-r--r-- | gnu/usr.bin/perl/ext/ODBM_File/hints/svr4.pl | 4 | ||||
-rw-r--r-- | gnu/usr.bin/perl/ext/ODBM_File/typemap | 25 |
8 files changed, 185 insertions, 0 deletions
diff --git a/gnu/usr.bin/perl/ext/ODBM_File/Makefile.PL b/gnu/usr.bin/perl/ext/ODBM_File/Makefile.PL new file mode 100644 index 00000000000..76a5d199990 --- /dev/null +++ b/gnu/usr.bin/perl/ext/ODBM_File/Makefile.PL @@ -0,0 +1,8 @@ +use ExtUtils::MakeMaker; +WriteMakefile( + NAME => 'ODBM_File', + LIBS => ["-ldbm -lucb"], + MAN3PODS => ' ', # Pods will be built by installman. + XSPROTOARG => '-noprototypes', # XXX remove later? + VERSION_FROM => 'ODBM_File.pm', +); diff --git a/gnu/usr.bin/perl/ext/ODBM_File/ODBM_File.pm b/gnu/usr.bin/perl/ext/ODBM_File/ODBM_File.pm new file mode 100644 index 00000000000..e5386e853b7 --- /dev/null +++ b/gnu/usr.bin/perl/ext/ODBM_File/ODBM_File.pm @@ -0,0 +1,35 @@ +package ODBM_File; + +use strict; +use vars qw($VERSION @ISA); + +require Tie::Hash; +require DynaLoader; + +@ISA = qw(Tie::Hash DynaLoader); + +$VERSION = "1.00"; + +bootstrap ODBM_File $VERSION; + +1; + +__END__ + +=head1 NAME + +ODBM_File - Tied access to odbm files + +=head1 SYNOPSIS + + use ODBM_File; + + tie(%h,ODBM_File,'Op.dbmx', O_RDWR|O_CREAT, 0640); + + untie %h; + +=head1 DESCRIPTION + +See L<perlfunc/tie> + +=cut diff --git a/gnu/usr.bin/perl/ext/ODBM_File/ODBM_File.xs b/gnu/usr.bin/perl/ext/ODBM_File/ODBM_File.xs new file mode 100644 index 00000000000..c1b405ff89b --- /dev/null +++ b/gnu/usr.bin/perl/ext/ODBM_File/ODBM_File.xs @@ -0,0 +1,101 @@ +#include "EXTERN.h" +#include "perl.h" +#include "XSUB.h" + +#ifdef NULL +#undef NULL +#endif +#ifdef I_DBM +# include <dbm.h> +#else +# ifdef I_RPCSVC_DBM +# include <rpcsvc/dbm.h> +# endif +#endif + +#include <fcntl.h> + +typedef void* ODBM_File; + +#define odbm_FETCH(db,key) fetch(key) +#define odbm_STORE(db,key,value,flags) store(key,value) +#define odbm_DELETE(db,key) delete(key) +#define odbm_FIRSTKEY(db) firstkey() +#define odbm_NEXTKEY(db,key) nextkey(key) + +static int dbmrefcnt; + +#ifndef DBM_REPLACE +#define DBM_REPLACE 0 +#endif + +MODULE = ODBM_File PACKAGE = ODBM_File PREFIX = odbm_ + +ODBM_File +odbm_TIEHASH(dbtype, filename, flags, mode) + char * dbtype + char * filename + int flags + int mode + CODE: + { + char tmpbuf[1025]; + if (dbmrefcnt++) + croak("Old dbm can only open one database"); + sprintf(tmpbuf,"%s.dir",filename); + if (stat(tmpbuf, &statbuf) < 0) { + if (flags & O_CREAT) { + if (mode < 0 || close(creat(tmpbuf,mode)) < 0) + croak("ODBM_File: Can't create %s", filename); + sprintf(tmpbuf,"%s.pag",filename); + if (close(creat(tmpbuf,mode)) < 0) + croak("ODBM_File: Can't create %s", filename); + } + else + croak("ODBM_FILE: Can't open %s", filename); + } + RETVAL = (void*)(dbminit(filename) >= 0 ? &dbmrefcnt : 0); + ST(0) = sv_mortalcopy(&sv_undef); + sv_setptrobj(ST(0), RETVAL, "ODBM_File"); + } + +void +DESTROY(db) + ODBM_File db + CODE: + dbmrefcnt--; + dbmclose(); + +datum +odbm_FETCH(db, key) + ODBM_File db + datum key + +int +odbm_STORE(db, key, value, flags = DBM_REPLACE) + ODBM_File db + datum key + datum value + int flags + CLEANUP: + if (RETVAL) { + if (RETVAL < 0 && errno == EPERM) + croak("No write permission to odbm file"); + croak("odbm store returned %d, errno %d, key \"%s\"", + RETVAL,errno,key.dptr); + } + +int +odbm_DELETE(db, key) + ODBM_File db + datum key + +datum +odbm_FIRSTKEY(db) + ODBM_File db + +datum +odbm_NEXTKEY(db, key) + ODBM_File db + datum key + diff --git a/gnu/usr.bin/perl/ext/ODBM_File/hints/dec_osf.pl b/gnu/usr.bin/perl/ext/ODBM_File/hints/dec_osf.pl new file mode 100644 index 00000000000..f041bf96c00 --- /dev/null +++ b/gnu/usr.bin/perl/ext/ODBM_File/hints/dec_osf.pl @@ -0,0 +1,5 @@ +# The -hidden option causes compilation to fail on Digital Unix. +# Andy Dougherty <doughera@lafcol.lafayette.edu> +# Sat Jan 13 16:29:52 EST 1996 +$self->{LDDLFLAGS} = $Config{lddlflags}; +$self->{LDDLFLAGS} =~ s/-hidden//; diff --git a/gnu/usr.bin/perl/ext/ODBM_File/hints/sco.pl b/gnu/usr.bin/perl/ext/ODBM_File/hints/sco.pl new file mode 100644 index 00000000000..4664f2bee0f --- /dev/null +++ b/gnu/usr.bin/perl/ext/ODBM_File/hints/sco.pl @@ -0,0 +1,4 @@ +# Some versions of SCO contain a broken -ldbm library that is missing +# dbmclose. Some of those might have a fixed library installed as +# -ldbm.nfs. +$self->{LIBS} = ['-ldbm.nfs', '-ldbm']; diff --git a/gnu/usr.bin/perl/ext/ODBM_File/hints/solaris.pl b/gnu/usr.bin/perl/ext/ODBM_File/hints/solaris.pl new file mode 100644 index 00000000000..ac573932cce --- /dev/null +++ b/gnu/usr.bin/perl/ext/ODBM_File/hints/solaris.pl @@ -0,0 +1,3 @@ +# -lucb has been reported to be fatal for perl5 on Solaris. +# Thus we deliberately don't include it here. +$self->{LIBS} = ['-ldbm']; diff --git a/gnu/usr.bin/perl/ext/ODBM_File/hints/svr4.pl b/gnu/usr.bin/perl/ext/ODBM_File/hints/svr4.pl new file mode 100644 index 00000000000..3285d9a685f --- /dev/null +++ b/gnu/usr.bin/perl/ext/ODBM_File/hints/svr4.pl @@ -0,0 +1,4 @@ +# Some SVR4 systems may need to link against routines in -lucb for +# odbm. Some may also need to link against -lc to pick up things like +# ecvt. +$self->{LIBS} = ['-ldbm -lucb -lc']; diff --git a/gnu/usr.bin/perl/ext/ODBM_File/typemap b/gnu/usr.bin/perl/ext/ODBM_File/typemap new file mode 100644 index 00000000000..a6b0e5faa86 --- /dev/null +++ b/gnu/usr.bin/perl/ext/ODBM_File/typemap @@ -0,0 +1,25 @@ +# +#################################### DBM SECTION +# + +datum T_DATUM +gdatum T_GDATUM +NDBM_File T_PTROBJ +GDBM_File T_PTROBJ +SDBM_File T_PTROBJ +ODBM_File T_PTROBJ +DB_File T_PTROBJ +DBZ_File T_PTROBJ +FATALFUNC T_OPAQUEPTR + +INPUT +T_DATUM + $var.dptr = SvPV($arg, na); + $var.dsize = (int)na; +T_GDATUM + UNIMPLEMENTED +OUTPUT +T_DATUM + sv_setpvn($arg, $var.dptr, $var.dsize); +T_GDATUM + sv_usepvn($arg, $var.dptr, $var.dsize); |