home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / perl560.zip / ext / SDBM_File / sdbm / util.c < prev   
C/C++ Source or Header  |  1999-07-20  |  754b  |  48 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(register char *s1, register char *s2)
  10. {
  11.     extern int errno, sys_nerr;
  12.     extern char *sys_errlist[];
  13.     extern char *progname;
  14.  
  15.     if (progname)
  16.         fprintf(stderr, "%s: ", progname);
  17.     fprintf(stderr, s1, s2);
  18.     if (errno > 0 && errno < sys_nerr)
  19.         fprintf(stderr, " (%s)", sys_errlist[errno]);
  20.     fprintf(stderr, "\n");
  21.     exit(1);
  22. }
  23.  
  24. int
  25. okpage(char *pag)
  26. {
  27.     register unsigned n;
  28.     register off;
  29.     register short *ino = (short *) pag;
  30.  
  31.     if ((n = ino[0]) > PBLKSIZ / sizeof(short))
  32.         return 0;
  33.  
  34.     if (!n)
  35.         return 1;
  36.  
  37.     off = PBLKSIZ;
  38.     for (ino++; n; ino += 2) {
  39.         if (ino[0] > off || ino[1] > off ||
  40.             ino[1] > ino[0])
  41.             return 0;
  42.         off = ino[1];
  43.         n -= 2;
  44.     }
  45.  
  46.     return 1;
  47. }
  48.