]> mj.ucw.cz Git - libucw.git/commitdiff
added a perl module for fcntl locking
authorPavel Charvat <pavel.charvat@netcentrum.cz>
Sun, 25 Feb 2007 22:39:11 +0000 (23:39 +0100)
committerPavel Charvat <pavel.charvat@netcentrum.cz>
Sun, 25 Feb 2007 22:39:11 +0000 (23:39 +0100)
lib/perl/Filelock/Filelock.pm [new file with mode: 0644]
lib/perl/Filelock/Filelock.xs [new file with mode: 0644]
lib/perl/Filelock/MANIFEST [new file with mode: 0644]
lib/perl/Filelock/Makefile [new file with mode: 0644]
lib/perl/Filelock/Makefile.PL [new file with mode: 0644]
lib/perl/Makefile

diff --git a/lib/perl/Filelock/Filelock.pm b/lib/perl/Filelock/Filelock.pm
new file mode 100644 (file)
index 0000000..cace066
--- /dev/null
@@ -0,0 +1,44 @@
+# Perl module for setting process limits
+#
+# (c) 2007 Pavel Charvat <pchar@ucw.cz>
+#
+# This software may be freely distributed and used according to the terms
+# of the GNU Lesser General Public License.
+#
+#
+#
+# Interface:
+#   Sherlock::Filelock::fcntllock($handle, $type, $whence, $start, $len)
+#
+
+package Sherlock::Filelock;
+
+use 5.006;
+use strict;
+use warnings;
+
+require Exporter;
+require DynaLoader;
+
+our @ISA = qw(Exporter DynaLoader);
+unshift @DynaLoader::dl_library_path, "lib";
+
+# This allows declaration      use Filelock ':all';
+# If you do not need this, moving things directly into @EXPORT or @EXPORT_OK
+# will save memory.
+our %EXPORT_TAGS = ( 'all' => [ qw(
+
+) ] );
+
+our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
+
+our @EXPORT = qw(
+);
+our $VERSION = '0.01';
+
+bootstrap Sherlock::Filelock $VERSION;
+
+# Preloaded methods go here.
+
+1;
+__END__
diff --git a/lib/perl/Filelock/Filelock.xs b/lib/perl/Filelock/Filelock.xs
new file mode 100644 (file)
index 0000000..7b830e2
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * PerlXS module for managing file locks
+ *
+ * (c) 2007 Pavel Charvat <pchar@ucw.cz>
+ */
+
+#include "EXTERN.h"
+#include "perl.h"
+#include "XSUB.h"
+
+#include <unistd.h>
+#include <fcntl.h>
+
+
+MODULE = Sherlock::Filelock            PACKAGE = Sherlock::Filelock
+
+PROTOTYPES: ENABLED
+
+int
+fcntl_lock(IN int fd, IN int cmd, IN int type, IN int whence, IN int start, IN int len)
+CODE:
+       struct flock fl;
+       fl.l_type = type;
+       fl.l_whence = whence;
+       fl.l_start = start;
+       fl.l_len = len;
+
+       RETVAL = fcntl(fd, cmd, &fl);
+OUTPUT:
+       RETVAL
diff --git a/lib/perl/Filelock/MANIFEST b/lib/perl/Filelock/MANIFEST
new file mode 100644 (file)
index 0000000..1136c00
--- /dev/null
@@ -0,0 +1,10 @@
+Makefile
+Makefile.PL
+MANIFEST
+Fcntllock.pm
+Fcntllock.xs
+CVS/Entries
+CVS/Repository
+CVS/Root
+lib/Sherlock/.exists
+.cvsignore
diff --git a/lib/perl/Filelock/Makefile b/lib/perl/Filelock/Makefile
new file mode 100644 (file)
index 0000000..bf64672
--- /dev/null
@@ -0,0 +1,26 @@
+# Makefile for the Filelock Perl module  (c) 2007 Pavel Chrvat <pchar@ucw.cz>
+
+DIRS+=lib/perl/Filelock/arch/auto/Sherlock/Filelock
+FILELOCK_DIR=lib/perl/Filelock
+
+PROGS+=$(o)/lib/perl/Filelock/Filelock.pm
+ifdef CONFIG_DARWIN
+SOEXT=bundle
+else
+SOEXT=so
+endif
+
+extras:: $(o)/lib/perl/Filelock/arch/auto/Sherlock/Filelock/Filelock.$(SOEXT)
+
+$(o)/lib/perl/Filelock/arch/auto/Sherlock/Filelock/Filelock.$(SOEXT): $(o)/$(FILELOCK_DIR)/Filelock.xs $(o)/$(FILELOCK_DIR)/Filelock.pm $(o)/$(FILELOCK_DIR)/Makefile
+       cd $(o)/$(FILELOCK_DIR) && $(MAKE) -f Makefile
+       cp $@ run/$(DATADIR)/
+
+$(o)/$(FILELOCK_DIR)/Makefile: $(o)/$(FILELOCK_DIR)/Makefile.PL
+       cd $(o)/$(FILELOCK_DIR) && perl Makefile.PL
+
+$(o)/$(FILELOCK_DIR)/Filelock.xs: $(s)/$(FILELOCK_DIR)/Filelock.xs
+       cp $^ $@
+
+$(o)/$(FILELOCK_DIR)/Makefile.PL: $(s)/$(FILELOCK_DIR)/Makefile.PL
+       cp $^ $@
diff --git a/lib/perl/Filelock/Makefile.PL b/lib/perl/Filelock/Makefile.PL
new file mode 100644 (file)
index 0000000..b0092ea
--- /dev/null
@@ -0,0 +1,9 @@
+# Makefile for Perl MakeMaker  (c) 2007 Pavel Charvat <pchar@ucw.cz>
+
+use ExtUtils::MakeMaker;
+WriteMakefile(
+    'NAME'             => 'Sherlock::Filelock',
+    'VERSION_FROM'     => 'Filelock.pm',
+    'INST_LIB'         => 'lib',
+    'INST_ARCHLIB'     => 'arch',
+);
index 8de911408bf3f79562e0b6f009c72a16ce570a52..a95678b64250a36b0037ca5190a8dd22eb200b1a 100644 (file)
@@ -6,3 +6,7 @@ PROGS+=$(addprefix $(o)/lib/perl/,Config.pm)
 ifdef CONFIG_UCW_PERL_ULIMIT
 include $(s)/lib/perl/Ulimit/Makefile
 endif
+
+ifdef CONFIG_UCW_PERL_FILELOCK
+include $(s)/lib/perl/Filelock/Makefile
+endif