Mercurial > hg > xemacs-beta
comparison src/database.c @ 5140:e5380fdaf8f1
merge
| author | Ben Wing <ben@xemacs.org> |
|---|---|
| date | Sat, 13 Mar 2010 05:38:34 -0600 |
| parents | a9c41067dd88 |
| children | f965e31a35f0 |
comparison
equal
deleted
inserted
replaced
| 5139:a48ef26d87ee | 5140:e5380fdaf8f1 |
|---|---|
| 1 /* Database access routines | 1 /* Database access routines |
| 2 Copyright (C) 1996, William M. Perry | 2 Copyright (C) 1996, William M. Perry |
| 3 Copyright (C) 2001, 2002, 2005 Ben Wing. | 3 Copyright (C) 2001, 2002, 2005, 2010 Ben Wing. |
| 4 | 4 |
| 5 This file is part of XEmacs. | 5 This file is part of XEmacs. |
| 6 | 6 |
| 7 XEmacs is free software; you can redistribute it and/or modify it | 7 XEmacs is free software; you can redistribute it and/or modify it |
| 8 under the terms of the GNU General Public License as published by the | 8 under the terms of the GNU General Public License as published by the |
| 145 Lisp_Object (*last_error) (Lisp_Database *); | 145 Lisp_Object (*last_error) (Lisp_Database *); |
| 146 } DB_FUNCS; | 146 } DB_FUNCS; |
| 147 | 147 |
| 148 struct Lisp_Database | 148 struct Lisp_Database |
| 149 { | 149 { |
| 150 struct LCRECORD_HEADER header; | 150 NORMAL_LISP_OBJECT_HEADER header; |
| 151 Lisp_Object fname; | 151 Lisp_Object fname; |
| 152 int mode; | 152 int mode; |
| 153 int access_; | 153 int access_; |
| 154 int dberrno; | 154 int dberrno; |
| 155 int live_p; | 155 int live_p; |
| 178 | 178 |
| 179 | 179 |
| 180 static Lisp_Database * | 180 static Lisp_Database * |
| 181 allocate_database (void) | 181 allocate_database (void) |
| 182 { | 182 { |
| 183 Lisp_Database *db = ALLOC_LCRECORD_TYPE (Lisp_Database, &lrecord_database); | 183 Lisp_Object obj = ALLOC_NORMAL_LISP_OBJECT (database); |
| 184 Lisp_Database *db = XDATABASE (obj); | |
| 184 | 185 |
| 185 db->fname = Qnil; | 186 db->fname = Qnil; |
| 186 db->live_p = 0; | 187 db->live_p = 0; |
| 187 #ifdef HAVE_BERKELEY_DB | 188 #ifdef HAVE_BERKELEY_DB |
| 188 db->db_handle = NULL; | 189 db->db_handle = NULL; |
| 233 | 234 |
| 234 write_fmt_string (printcharfun, "0x%x>", db->header.uid); | 235 write_fmt_string (printcharfun, "0x%x>", db->header.uid); |
| 235 } | 236 } |
| 236 | 237 |
| 237 static void | 238 static void |
| 238 finalize_database (void *header, int for_disksave) | 239 finalize_database (Lisp_Object obj) |
| 239 { | 240 { |
| 240 Lisp_Database *db = (Lisp_Database *) header; | 241 Lisp_Database *db = XDATABASE (obj); |
| 241 | 242 |
| 242 if (for_disksave) | |
| 243 { | |
| 244 invalid_operation | |
| 245 ("Can't dump an emacs containing database objects", | |
| 246 wrap_database (db)); | |
| 247 } | |
| 248 db->funcs->close (db); | 243 db->funcs->close (db); |
| 249 } | 244 } |
| 250 | 245 |
| 251 DEFINE_LRECORD_IMPLEMENTATION ("database", database, | 246 DEFINE_NODUMP_LISP_OBJECT ("database", database, |
| 252 0, /*dumpable-flag*/ | 247 mark_database, print_database, |
| 253 mark_database, print_database, | 248 finalize_database, 0, 0, |
| 254 finalize_database, 0, 0, | 249 database_description, |
| 255 database_description, | 250 Lisp_Database); |
| 256 Lisp_Database); | |
| 257 | 251 |
| 258 DEFUN ("close-database", Fclose_database, 1, 1, 0, /* | 252 DEFUN ("close-database", Fclose_database, 1, 1, 0, /* |
| 259 Close database DATABASE. | 253 Close database DATABASE. |
| 260 */ | 254 */ |
| 261 (database)) | 255 (database)) |
| 858 } | 852 } |
| 859 | 853 |
| 860 void | 854 void |
| 861 syms_of_database (void) | 855 syms_of_database (void) |
| 862 { | 856 { |
| 863 INIT_LRECORD_IMPLEMENTATION (database); | 857 INIT_LISP_OBJECT (database); |
| 864 | 858 |
| 865 DEFSYMBOL (Qdatabasep); | 859 DEFSYMBOL (Qdatabasep); |
| 866 #ifdef HAVE_DBM | 860 #ifdef HAVE_DBM |
| 867 DEFSYMBOL (Qdbm); | 861 DEFSYMBOL (Qdbm); |
| 868 #endif | 862 #endif |
