Use the new library context system in the Perl module.
authorSteinar H. Gunderson <sesse@samfundet.no>
Tue, 15 Mar 2022 21:35:45 +0000 (22:35 +0100)
committerSteinar H. Gunderson <sesse@samfundet.no>
Tue, 15 Mar 2022 21:45:35 +0000 (22:45 +0100)
perl-itkacl-2.0/debian/changelog [deleted file]
perl-itkacl-2.0/itkacl.i [deleted file]
perl-itkacl-2.2/Makefile.PL [moved from perl-itkacl-2.0/Makefile.PL with 100% similarity]
perl-itkacl-2.2/debian/changelog [new file with mode: 0644]
perl-itkacl-2.2/debian/compat [moved from perl-itkacl-2.0/debian/compat with 100% similarity]
perl-itkacl-2.2/debian/control [moved from perl-itkacl-2.0/debian/control with 100% similarity]
perl-itkacl-2.2/debian/copyright [moved from perl-itkacl-2.0/debian/copyright with 100% similarity]
perl-itkacl-2.2/debian/rules [moved from perl-itkacl-2.0/debian/rules with 100% similarity]
perl-itkacl-2.2/itkacl.i [new file with mode: 0644]

diff --git a/perl-itkacl-2.0/debian/changelog b/perl-itkacl-2.0/debian/changelog
deleted file mode 100644 (file)
index 0b335fd..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-libitkacl-perl (2.0) unstable; urgency=low
-
-  * Initial release.
-
- -- Steinar H. Gunderson <sesse@samfundet.no>  Tue, 14 May 2013 01:26:44 +0200
diff --git a/perl-itkacl-2.0/itkacl.i b/perl-itkacl-2.0/itkacl.i
deleted file mode 100644 (file)
index f58703c..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-/* SWIG interface for libitkacl */
-%module itkacl
-
-/* Convert errors to Perl exceptions and keep the interface clean. */
-%inline %{
-       extern int itkacl_check(char *realm, char *user, char *errmsg, size_t errmsgsize);
-       int check(char *realm, char *user)
-       {
-               char errmsg[1024];
-               int ret = itkacl_check(realm, user, errmsg, 1024);
-
-               /* printf("check '%s' vs. '%s' gave %d\n", user, realm, ret); */
-               if (ret == -1)
-                       die(errmsg);
-               else
-                       return (ret == 0);
-       }
-       
-%}
-
diff --git a/perl-itkacl-2.2/debian/changelog b/perl-itkacl-2.2/debian/changelog
new file mode 100644 (file)
index 0000000..9040e7a
--- /dev/null
@@ -0,0 +1,11 @@
+libitkacl-perl (2.2) unstable; urgency=medium
+
+  * Use the new library contexts for higher performance with repeated calls.
+
+ -- Steinar H. Gunderson <sesse@samfundet.no>  Tue, 15 Mar 2022 22:24:46 +0100
+
+libitkacl-perl (2.0) unstable; urgency=low
+
+  * Initial release.
+
+ -- Steinar H. Gunderson <sesse@samfundet.no>  Tue, 14 May 2013 01:26:44 +0200
diff --git a/perl-itkacl-2.2/itkacl.i b/perl-itkacl-2.2/itkacl.i
new file mode 100644 (file)
index 0000000..4523e81
--- /dev/null
@@ -0,0 +1,44 @@
+/* SWIG interface for libitkacl */
+%module itkacl
+
+%perlcode %{
+_itkacl_init();
+END {
+       _itkacl_deinit();
+}
+
+%}
+
+/* Convert errors to Perl exceptions and keep the interface clean. */
+%inline %{
+       #include "itkacl.h"
+
+       struct itkacl_ctx *_ctx = NULL;
+
+       void _itkacl_init()
+       {
+               char errmsg[1024];
+               _ctx = itkacl_create_ctx(errmsg, sizeof(errmsg));
+               if (_ctx == NULL)
+                       die(errmsg);
+       }
+
+       void _itkacl_deinit()
+       {
+               itkacl_free_ctx(_ctx);
+       }
+
+       int check(char *realm, char *user)
+       {
+               char errmsg[1024];
+               int ret = itkacl_check_with_ctx(_ctx, realm, user, errmsg, 1024);
+
+               /* printf("check '%s' vs. '%s' gave %d\n", user, realm, ret); */
+               if (ret == -1)
+                       die(errmsg);
+               else
+                       return (ret == 0);
+       }
+       
+%}
+