summaryrefslogtreecommitdiffstats
path: root/gnu/usr.bin/perl/ext/SDBM_File/util.c
diff options
context:
space:
mode:
authorafresh1 <afresh1@openbsd.org>2017-02-05 00:31:51 +0000
committerafresh1 <afresh1@openbsd.org>2017-02-05 00:31:51 +0000
commitb8851fcc53cbe24fd20b090f26dd149e353f6174 (patch)
tree4b7c1695865f00ab7a0da30b5632d514848ea3a2 /gnu/usr.bin/perl/ext/SDBM_File/util.c
parentAdd option PCIVERBOSE. (diff)
downloadwireguard-openbsd-b8851fcc53cbe24fd20b090f26dd149e353f6174.tar.xz
wireguard-openbsd-b8851fcc53cbe24fd20b090f26dd149e353f6174.zip
Fix merge issues, remove excess files - match perl-5.24.1 dist
Diffstat (limited to 'gnu/usr.bin/perl/ext/SDBM_File/util.c')
-rw-r--r--gnu/usr.bin/perl/ext/SDBM_File/util.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/gnu/usr.bin/perl/ext/SDBM_File/util.c b/gnu/usr.bin/perl/ext/SDBM_File/util.c
new file mode 100644
index 00000000000..a58085d559a
--- /dev/null
+++ b/gnu/usr.bin/perl/ext/SDBM_File/util.c
@@ -0,0 +1,47 @@
+#include <stdio.h>
+#ifdef SDBM
+#include "sdbm.h"
+#else
+#include "ndbm.h"
+#endif
+
+void
+oops(char *s1, char *s2)
+{
+ extern int errno, sys_nerr;
+ extern char *sys_errlist[];
+ extern char *progname;
+
+ if (progname)
+ fprintf(stderr, "%s: ", progname);
+ fprintf(stderr, s1, s2);
+ if (errno > 0 && errno < sys_nerr)
+ fprintf(stderr, " (%s)", sys_errlist[errno]);
+ fprintf(stderr, "\n");
+ exit(1);
+}
+
+int
+okpage(char *pag)
+{
+ unsigned n;
+ int off;
+ short *ino = (short *) pag;
+
+ if ((n = ino[0]) > PBLKSIZ / sizeof(short))
+ return 0;
+
+ if (!n)
+ return 1;
+
+ off = PBLKSIZ;
+ for (ino++; n; ino += 2) {
+ if (ino[0] > off || ino[1] > off ||
+ ino[1] > ino[0])
+ return 0;
+ off = ino[1];
+ n -= 2;
+ }
+
+ return 1;
+}