home *** CD-ROM | disk | FTP | other *** search
/ IRIX Patches 1995 March / SGI IRIX Patches 1995 Mar.iso / 5.3_patches / patchSG0000221 / patchSG0000221.idb / usr / include / ndbm.h.z / ndbm.h
Encoding:
C/C++ Source or Header  |  1995-03-10  |  4.2 KB  |  137 lines

  1. #ifndef __NDBM_H__
  2. #define __NDBM_H__
  3. #ident "$Revision: 1.7 $"
  4. /*
  5. *
  6. * Copyright 1992, Silicon Graphics, Inc.
  7. * All Rights Reserved.
  8. *
  9. * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
  10. * the contents of this file may not be disclosed to third parties, copied or
  11. * duplicated in any form, in whole or in part, without the prior written
  12. * permission of Silicon Graphics, Inc.
  13. *
  14. * RESTRICTED RIGHTS LEGEND:
  15. * Use, duplication or disclosure by the Government is subject to restrictions
  16. * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
  17. * and Computer Software clause at DFARS 252.227-7013, and/or in similar or
  18. * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
  19. * rights reserved under the Copyright Laws of the United States.
  20. */
  21. /*
  22.  * Copyright (c) 1983 Regents of the University of California.
  23.  * All rights reserved.  The Berkeley software License Agreement
  24.  * specifies the terms and conditions for redistribution.
  25.  *
  26.  *    @(#)ndbm.h    5.1 (Berkeley) 5/30/85
  27.  */
  28.  
  29. /*
  30.  * Hashed key data base library.
  31.  */
  32.  
  33. #ifdef __cplusplus
  34. extern "C" {
  35. #endif
  36.  
  37. #define PBLKSIZ 1024
  38. #define DBLKSIZ 4096
  39.  
  40. typedef struct {
  41.     int    dbm_dirf;        /* open directory file */
  42.     int    dbm_pagf;        /* open page file */
  43.     int    dbm_flags;        /* flags, see below */
  44.     long    dbm_maxbno;        /* last ``bit'' in dir file */
  45.     long    dbm_bitno;        /* current bit number */
  46.     long    dbm_hmask;        /* hash mask */
  47.     long    dbm_blkptr;        /* current block for dbm_nextkey */
  48.     int    dbm_keyptr;        /* current key for dbm_nextkey */
  49.     long    dbm_blkno;        /* current page to read/write */
  50.     long    dbm_pagbno;        /* current page in pagbuf */
  51.     char    dbm_pagbuf[PBLKSIZ];    /* page file block buffer */
  52.     long    dbm_dirbno;        /* current block in dirbuf */
  53.     char    dbm_dirbuf[DBLKSIZ];    /* directory file block buffer */
  54. } DBM;
  55.  
  56. #if (defined(_SGI_SOURCE) && !defined(_POSIX_SOURCE) && !defined(_XOPEN_SOURCE) && !defined(_ABI_SOURCE))
  57.  
  58. typedef struct {
  59.     int    dbm_dirf;        /* open directory file */
  60.     int    dbm_pagf;        /* open page file */
  61.     int    dbm_flags;        /* flags, see below */
  62. /* LINTED long long */
  63. long long    dbm_maxbno;        /* last ``bit'' in dir file */
  64. /* LINTED long long */
  65. long long    dbm_bitno;        /* current bit number */
  66. /* LINTED long long */
  67. long long    dbm_hmask;        /* hash mask */
  68. /* LINTED long long */
  69. long long    dbm_blkptr;        /* current block for dbm_nextkey */
  70.     int    dbm_keyptr;        /* current key for dbm_nextkey */
  71. /* LINTED long long */
  72. long long    dbm_blkno;        /* current page to read/write */
  73. /* LINTED long long */
  74. long long    dbm_pagbno;        /* current page in pagbuf */
  75.     char    dbm_pagbuf[PBLKSIZ];    /* page file block buffer */
  76. /* LINTED long long */
  77. long long    dbm_dirbno;        /* current block in dirbuf */
  78.     char    dbm_dirbuf[DBLKSIZ];    /* directory file block buffer */
  79. } DBM64;
  80. #endif
  81.  
  82. #define _DBM_RDONLY    0x1    /* data base open read-only */
  83. #define _DBM_IOERR    0x2    /* data base I/O error */
  84.  
  85. #define dbm_rdonly(db)    ((db)->dbm_flags & _DBM_RDONLY)
  86.  
  87. #define dbm_error(db)    ((db)->dbm_flags & _DBM_IOERR)
  88.     /* use this one at your own risk! */
  89. #define dbm_clearerr(db)    ((db)->dbm_flags &= ~_DBM_IOERR)
  90. #if (defined(_SGI_SOURCE) && !defined(_POSIX_SOURCE) && !defined(_XOPEN_SOURCE) && !defined(_ABI_SOURCE))
  91.  
  92. #define dbm_error64(db)    ((db)->dbm_flags & _DBM_IOERR)
  93.     /* use this one at your own risk! */
  94. #define dbm_clearerr64(db)    ((db)->dbm_flags &= ~_DBM_IOERR)
  95. #endif
  96.  
  97. /* for flock(2) and fstat(2) */
  98. #define dbm_dirfno(db)    ((db)->dbm_dirf)
  99. #define dbm_pagfno(db)    ((db)->dbm_pagf)
  100.  
  101. typedef struct {
  102.     char    *dptr;
  103.     int    dsize;
  104. } datum;
  105.  
  106. /*
  107.  * flags to dbm_store()
  108.  */
  109. #define DBM_INSERT    0
  110. #define DBM_REPLACE    1
  111.  
  112. DBM    *dbm_open(const char *, int, int);
  113. void    dbm_close(DBM *);
  114. datum    dbm_fetch(DBM *, datum);
  115. datum    dbm_firstkey(DBM *);
  116. datum    dbm_nextkey(DBM *);
  117. long    dbm_forder(DBM *, datum);
  118. int    dbm_delete(DBM *, datum);
  119. int    dbm_store(DBM *, datum, datum, int);
  120. #if (defined(_SGI_SOURCE) && !defined(_POSIX_SOURCE) && !defined(_XOPEN_SOURCE) && !defined(_ABI_SOURCE))
  121.  
  122. DBM64    *dbm_open64(const char *, int, int);
  123. void    dbm_close64(DBM64 *);
  124. datum    dbm_fetch64(DBM64 *, datum);
  125. datum    dbm_firstkey64(DBM64 *);
  126. datum    dbm_nextkey64(DBM64 *);
  127. /* LINTED long long */
  128. long long    dbm_forder64(DBM64 *, datum);
  129. int    dbm_delete64(DBM64 *, datum);
  130. int    dbm_store64(DBM64 *, datum, datum, int);
  131. #endif
  132.  
  133. #ifdef __cplusplus
  134. }
  135. #endif
  136. #endif /* !__NDBM_H__ */
  137.