home *** CD-ROM | disk | FTP | other *** search
/ PC-Online 1996 May / PCOnline_05_1996.bin / linux / source / contrib / smail / smail-3.1 / smail-3 / smail-3.1.28 / util / dbm_compat.h < prev    next >
C/C++ Source or Header  |  1992-09-06  |  858b  |  43 lines

  1. /* @(#)util/dbm_compat.h    1.6 9/6/92 01:09:15 */
  2.  
  3. /*
  4.  * dbm_compat.h:
  5.  *    Low-functionality compatibility header for dbm and ndbm.
  6.  */
  7.  
  8. #undef NULL        /* dbm.h often defines NULL */
  9.  
  10. #ifdef HAVE_DBM
  11.  
  12. #ifdef DBM_INCLUDE_FILE
  13. #include DBM_INCLUDE_FILE
  14. #else
  15. #include <dbm.h>
  16. #endif
  17.  
  18. #else    /* !HAVE_DBM */
  19.  
  20. #ifdef HAVE_NDBM
  21. # ifdef NDBM_INCLUDE_FILE
  22. # include NDBM_INCLUDE_FILE
  23. # else
  24. # include <ndbm.h>
  25. # endif
  26. #else    /* not HAVE_NDBM */
  27. #include "sdbm.h"
  28. #endif    /* HAVE_NDBM */
  29.  
  30. /* Imitate dbm using  */
  31.  
  32. static DBM *db;
  33. #define dbminit(f) \
  34.   ((db = dbm_open((f),2,0)) ? 0 : (db = dbm_open((f),0,0)) ? 0 : -1)
  35. #define dbmclose()  ((db ? (dbm_close(db),0) : 0), db = (DBM *)NULL, 0)
  36. #define store(k,v)  dbm_store(db,k,v,DBM_INSERT)
  37. #define fetch(k)    dbm_fetch(db,(k))
  38.  
  39. #endif    /* !HAVE_DBM */
  40.  
  41. #undef NULL        /* in case dbm.h does not define NULL */
  42. #define NULL 0
  43.