home *** CD-ROM | disk | FTP | other *** search
/ OpenStep 4.2J (Developer) / os42jdev.iso / NextDeveloper / Source / GNU / perl / Perl / ext / NDBM_File / NDBM_File.xs < prev    next >
Text File  |  1995-01-14  |  1KB  |  71 lines

  1. #include "EXTERN.h"
  2. #include "perl.h"
  3. #include "XSUB.h"
  4. #include <ndbm.h>
  5.  
  6. typedef DBM* NDBM_File;
  7. #define dbm_TIEHASH(dbtype,filename,flags,mode) dbm_open(filename,flags,mode)
  8. #define dbm_FETCH(db,key)            dbm_fetch(db,key)
  9. #define dbm_STORE(db,key,value,flags)        dbm_store(db,key,value,flags)
  10. #define dbm_DELETE(db,key)            dbm_delete(db,key)
  11. #define dbm_FIRSTKEY(db)            dbm_firstkey(db)
  12. #define dbm_NEXTKEY(db,key)            dbm_nextkey(db)
  13.  
  14. MODULE = NDBM_File    PACKAGE = NDBM_File    PREFIX = dbm_
  15.  
  16. NDBM_File
  17. dbm_TIEHASH(dbtype, filename, flags, mode)
  18.     char *        dbtype
  19.     char *        filename
  20.     int        flags
  21.     int        mode
  22.  
  23. void
  24. dbm_DESTROY(db)
  25.     NDBM_File    db
  26.     CODE:
  27.     dbm_close(db);
  28.  
  29. datum
  30. dbm_FETCH(db, key)
  31.     NDBM_File    db
  32.     datum        key
  33.  
  34. int
  35. dbm_STORE(db, key, value, flags = DBM_REPLACE)
  36.     NDBM_File    db
  37.     datum        key
  38.     datum        value
  39.     int        flags
  40.     CLEANUP:
  41.     if (RETVAL) {
  42.         if (RETVAL < 0 && errno == EPERM)
  43.         croak("No write permission to ndbm file");
  44.         croak("ndbm store returned %d, errno %d, key \"%s\"",
  45.             RETVAL,errno,key.dptr);
  46.         dbm_clearerr(db);
  47.     }
  48.  
  49. int
  50. dbm_DELETE(db, key)
  51.     NDBM_File    db
  52.     datum        key
  53.  
  54. datum
  55. dbm_FIRSTKEY(db)
  56.     NDBM_File    db
  57.  
  58. datum
  59. dbm_NEXTKEY(db, key)
  60.     NDBM_File    db
  61.     datum        key
  62.  
  63. int
  64. dbm_error(db)
  65.     NDBM_File    db
  66.  
  67. void
  68. dbm_clearerr(db)
  69.     NDBM_File    db
  70.  
  71.