X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=src%2Fdatabase.c;h=21cf7bc84e39f52f7c476b49885c07e3f5d1c0b8;hb=98f1518a09e923a4f8b14b6a637cc283f02719bd;hp=e7750b6ed252ec436bcb78b249c1fe102020659d;hpb=a1655b870904de973c366d85ebdc8adde4ef5e1e;p=chise%2Fxemacs-chise.git- diff --git a/src/database.c b/src/database.c index e7750b6..21cf7bc 100644 --- a/src/database.c +++ b/src/database.c @@ -59,6 +59,9 @@ typedef uint64_t u_int64_t; #endif /* DB_VERSION_MAJOR */ Lisp_Object Qberkeley_db; Lisp_Object Qhash, Qbtree, Qrecno, Qunknown; +#if DB_VERSION_MAJOR > 2 +Lisp_Object Qqueue; +#endif #endif /* HAVE_BERKELEY_DB */ #ifdef HAVE_DBM @@ -144,9 +147,9 @@ allocate_database (void) } static Lisp_Object -mark_database (Lisp_Object obj) +mark_database (Lisp_Object object) { - Lisp_Database *db = XDATABASE (obj); + Lisp_Database *db = XDATABASE (object); return db->fname; } @@ -178,11 +181,11 @@ finalize_database (void *header, int for_disksave) if (for_disksave) { - Lisp_Object obj; - XSETDATABASE (obj, db); + Lisp_Object object; + XSETDATABASE (object, db); signal_simple_error - ("Can't dump an emacs containing database objects", obj); + ("Can't dump an emacs containing database objects", object); } db->funcs->close (db); } @@ -226,11 +229,12 @@ Return the subtype of database DATABASE, if any. } DEFUN ("database-live-p", Fdatabase_live_p, 1, 1, 0, /* -Return t if OBJ is an active database. +Return t if OBJECT is an active database. */ - (obj)) + (object)) { - return DATABASEP (obj) && DATABASE_LIVE_P (XDATABASE (obj)) ? Qt : Qnil; + return DATABASEP (object) && DATABASE_LIVE_P (XDATABASE (object)) ? + Qt : Qnil; } DEFUN ("database-file-name", Fdatabase_file_name, 1, 1, 0, /* @@ -244,11 +248,11 @@ Return the filename associated with the database DATABASE. } DEFUN ("databasep", Fdatabasep, 1, 1, 0, /* -Return t if OBJ is a database. +Return t if OBJECT is a database. */ - (obj)) + (object)) { - return DATABASEP (obj) ? Qt : Qnil; + return DATABASEP (object) ? Qt : Qnil; } #ifdef HAVE_DBM @@ -368,6 +372,9 @@ berkdb_subtype (Lisp_Database *db) case DB_BTREE: return Qbtree; case DB_HASH: return Qhash; case DB_RECNO: return Qrecno; +#if DB_VERSION_MAJOR > 2 + case DB_QUEUE: return Qqueue; +#endif default: return Qunknown; } } @@ -643,6 +650,10 @@ and defaults to 0755. real_subtype = DB_BTREE; else if (EQ (subtype, Qrecno)) real_subtype = DB_RECNO; +#if DB_VERSION_MAJOR > 2 + else if (EQ (subtype, Qqueue)) + real_subtype = DB_QUEUE; +#endif else signal_simple_error ("Unsupported subtype", subtype); @@ -668,10 +679,25 @@ and defaults to 0755. if (strchr (acc, 'r') && !strchr (acc, 'w')) accessmask |= DB_RDONLY; } +#if DB_VERSION_MAJOR == 2 status = db_open (filename, real_subtype, accessmask, modemask, NULL , NULL, &dbase); if (status) return Qnil; +#else + status = db_create (&dbase, NULL, 0); + if (status) + return Qnil; + status = dbase->open (dbase, filename, NULL, + real_subtype, accessmask, modemask); + if (status) + { + dbase->close (dbase, 0); + return Qnil; + } +#endif /* DB_VERSION_MAJOR > 2 */ + /* Normalize into system specific file modes. Only for printing */ + accessmask = accessmask & DB_RDONLY ? O_RDONLY : O_RDWR; #endif /* DB_VERSION_MAJOR */ db = allocate_database (); @@ -743,7 +769,7 @@ If there is no corresponding value, return DEFAULT (defaults to nil). } } -DEFUN ("map-database", Fmapdatabase, 2, 2, 0, /* +DEFUN ("map-database", Fmap_database, 2, 2, 0, /* Map FUNCTION over entries in DATABASE, calling it with two args, each key and value in the database. */ @@ -770,12 +796,15 @@ syms_of_database (void) defsymbol (&Qhash, "hash"); defsymbol (&Qbtree, "btree"); defsymbol (&Qrecno, "recno"); +#if DB_VERSION_MAJOR > 2 + defsymbol (&Qqueue, "queue"); +#endif defsymbol (&Qunknown, "unknown"); #endif DEFSUBR (Fopen_database); DEFSUBR (Fdatabasep); - DEFSUBR (Fmapdatabase); + DEFSUBR (Fmap_database); DEFSUBR (Fput_database); DEFSUBR (Fget_database); DEFSUBR (Fremove_database);