home *** CD-ROM | disk | FTP | other *** search
/ OpenStep 4.2J (Developer) / os42jdev.iso / NextDeveloper / Source / GNU / perl / Perl / ext / SDBM_File / sdbm / util.c < prev   
Encoding:
C/C++ Source or Header  |  1994-10-18  |  767 b   |  51 lines

  1. #include <stdio.h>
  2. #ifdef SDBM
  3. #include "sdbm.h"
  4. #else
  5. #include "ndbm.h"
  6. #endif
  7.  
  8. void
  9. oops(s1, s2)
  10. register char *s1;
  11. register char *s2;
  12. {
  13.     extern int errno, sys_nerr;
  14.     extern char *sys_errlist[];
  15.     extern char *progname;
  16.  
  17.     if (progname)
  18.         fprintf(stderr, "%s: ", progname);
  19.     fprintf(stderr, s1, s2);
  20.     if (errno > 0 && errno < sys_nerr)
  21.         fprintf(stderr, " (%s)", sys_errlist[errno]);
  22.     fprintf(stderr, "\n");
  23.     exit(1);
  24. }
  25.  
  26. int
  27. okpage(pag)
  28. char *pag;
  29. {
  30.     register unsigned n;
  31.     register off;
  32.     register short *ino = (short *) pag;
  33.  
  34.     if ((n = ino[0]) > PBLKSIZ / sizeof(short))
  35.         return 0;
  36.  
  37.     if (!n)
  38.         return 1;
  39.  
  40.     off = PBLKSIZ;
  41.     for (ino++; n; ino += 2) {
  42.         if (ino[0] > off || ino[1] > off ||
  43.             ino[1] > ino[0])
  44.             return 0;
  45.         off = ino[1];
  46.         n -= 2;
  47.     }
  48.  
  49.     return 1;
  50. }
  51.