annotate src/database.c @ 370:bd866891f083

Added tag r21-1-14 for changeset 1d62742628b6
author cvs
date Mon, 13 Aug 2007 11:01:58 +0200
parents 54f7aa390f4f
children cc15677e0335
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 /* Database access routines
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2 Copyright (C) 1996, William M. Perry
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4 This file is part of XEmacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 XEmacs is free software; you can redistribute it and/or modify it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 under the terms of the GNU General Public License as published by the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 Free Software Foundation; either version 2, or (at your option) any
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 XEmacs is distributed in the hope that it will be useful, but WITHOUT
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 You should have received a copy of the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 along with XEmacs; see the file COPYING. If not, write to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 Boston, MA 02111-1307, USA. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 /* Synched up with: Not in FSF. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 /* Written by Bill Perry */
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
24 /* Substantially rewritten by Martin Buchholz */
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
25 /* db 2.x support added by Andreas Jaeger */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 #include <config.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 #include "lisp.h"
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
29 #include "sysfile.h"
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 #include <errno.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 94
diff changeset
32 #ifndef HAVE_DATABASE
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
33 #error HAVE_DATABASE not defined!!
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
34 #endif
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 94
diff changeset
35
157
6b37e6ddd302 Import from CVS: tag r20-3b5
cvs
parents: 151
diff changeset
36 #include "database.h" /* Our include file */
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 94
diff changeset
37
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 #ifdef HAVE_BERKELEY_DB
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 94
diff changeset
39 /* Work around Berkeley DB's use of int types which are defined
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 94
diff changeset
40 slightly differently in the not quite yet standard <inttypes.h>.
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 94
diff changeset
41 See db.h for details of why we're resorting to this... */
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
42 /* glibc 2.1 doesn't have this problem with DB 2.x */
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
43 #if !(defined __GLIBC__ && __GLIBC_MINOR__ >= 1)
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 94
diff changeset
44 #ifdef HAVE_INTTYPES_H
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 94
diff changeset
45 #define __BIT_TYPES_DEFINED__
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 94
diff changeset
46 #include <inttypes.h>
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 94
diff changeset
47 typedef uint8_t u_int8_t;
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 94
diff changeset
48 typedef uint16_t u_int16_t;
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 94
diff changeset
49 typedef uint32_t u_int32_t;
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 94
diff changeset
50 #ifdef WE_DONT_NEED_QUADS
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 94
diff changeset
51 typedef uint64_t u_int64_t;
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 94
diff changeset
52 #endif /* WE_DONT_NEED_QUADS */
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 94
diff changeset
53 #endif /* HAVE_INTTYPES_H */
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
54 #endif /* !(defined __GLIBC__ && __GLIBC_MINOR__ >= 1) */
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 94
diff changeset
55 #include DB_H_PATH /* Berkeley db's header file */
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
56 #ifndef DB_VERSION_MAJOR
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
57 # define DB_VERSION_MAJOR 1
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
58 #endif /* DB_VERSION_MAJOR */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 Lisp_Object Qberkeley_db;
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
60 Lisp_Object Qhash, Qbtree, Qrecno, Qunknown;
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 94
diff changeset
61 #endif /* HAVE_BERKELEY_DB */
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 94
diff changeset
62
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 94
diff changeset
63 #ifdef HAVE_DBM
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 94
diff changeset
64 #include <ndbm.h>
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 94
diff changeset
65 Lisp_Object Qdbm;
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 94
diff changeset
66 #endif /* HAVE_DBM */
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 94
diff changeset
67
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 94
diff changeset
68 Lisp_Object Qdatabasep;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
70 typedef enum { DB_DBM, DB_BERKELEY, DB_IS_UNKNOWN } XEMACS_DB_TYPE;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
72 struct Lisp_Database;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 94
diff changeset
74 typedef struct
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
76 Lisp_Object (*get_subtype) (struct Lisp_Database *);
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
77 Lisp_Object (*get_type) (struct Lisp_Database *);
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
78 Lisp_Object (*get) (struct Lisp_Database *, Lisp_Object);
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
79 int (*put) (struct Lisp_Database *, Lisp_Object, Lisp_Object, Lisp_Object);
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
80 int (*rem) (struct Lisp_Database *, Lisp_Object);
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
81 void (*map) (struct Lisp_Database *, Lisp_Object);
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
82 void (*close) (struct Lisp_Database *);
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
83 Lisp_Object (*last_error) (struct Lisp_Database *);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 } DB_FUNCS;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
86 struct Lisp_Database
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 struct lcrecord_header header;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 Lisp_Object fname;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 XEMACS_DB_TYPE type;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 int mode;
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 157
diff changeset
92 int access_;
94
1040fe1366ac Import from CVS: tag xemacs-20-0f2
cvs
parents: 70
diff changeset
93 int dberrno;
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
94 int live_p;
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
95 #ifdef HAVE_DBM
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
96 DBM *dbm_handle;
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
97 #endif
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
98 #ifdef HAVE_BERKELEY_DB
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
99 DB *db_handle;
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
100 #endif
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 DB_FUNCS *funcs;
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 94
diff changeset
102 #ifdef MULE
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 94
diff changeset
103 Lisp_Object coding_system;
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 94
diff changeset
104 #endif
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 };
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
107 #define XDATABASE(x) XRECORD (x, database, struct Lisp_Database)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 #define XSETDATABASE(x, p) XSETRECORD (x, p, database)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 #define DATABASEP(x) RECORDP (x, database)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 #define GC_DATABASEP(x) GC_RECORDP (x, database)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 #define CHECK_DATABASE(x) CHECK_RECORD (x, database)
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents: 207
diff changeset
112 #define CONCHECK_DATABASE(x) CONCHECK_RECORD (x, database)
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
113 #define DATABASE_LIVE_P(x) (x->live_p)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
115 #define CHECK_LIVE_DATABASE(db) do { \
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
116 CHECK_DATABASE (db); \
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
117 if (!DATABASE_LIVE_P (XDATABASE(db))) \
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
118 signal_simple_error ("Attempting to access closed database", db); \
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
119 } while (0)
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
120
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
121
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
122 static struct Lisp_Database *
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents: 207
diff changeset
123 allocate_database (void)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
125 struct Lisp_Database *db =
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
126 alloc_lcrecord_type (struct Lisp_Database, lrecord_database);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
128 db->fname = Qnil;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
129 db->live_p = 0;
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
130 #ifdef HAVE_BERKELEY_DB
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
131 db->db_handle = NULL;
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
132 #endif
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
133 #ifdef HAVE_DBM
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
134 db->dbm_handle = NULL;
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
135 #endif
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
136 db->access_ = 0;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
137 db->mode = 0;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
138 db->dberrno = 0;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
139 db->type = DB_IS_UNKNOWN;
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 94
diff changeset
140 #ifdef MULE
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
141 db->coding_system = Fget_coding_system (Qbinary);
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 94
diff changeset
142 #endif
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
143 return db;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 static Lisp_Object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 mark_database (Lisp_Object obj, void (*markobj) (Lisp_Object))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
149 struct Lisp_Database *db = XDATABASE (obj);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
151 ((markobj) (db->fname));
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 157
diff changeset
152 return Qnil;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 print_database (Lisp_Object obj, Lisp_Object printcharfun, int escapeflag)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 {
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents: 207
diff changeset
158 char buf[64];
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
159 struct Lisp_Database *db = XDATABASE (obj);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 if (print_readably)
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
162 error ("printing unreadable object #<database 0x%x>", db->header.uid);
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents: 207
diff changeset
163
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents: 207
diff changeset
164 write_c_string ("#<database \"", printcharfun);
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
165 print_internal (db->fname, printcharfun, 0);
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents: 207
diff changeset
166 sprintf (buf, "\" (%s/%s/%s) 0x%x>",
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
167 (char *) string_data (XSYMBOL (db->funcs->get_type (db))->name),
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
168 (char *) string_data (XSYMBOL (db->funcs->get_subtype (db))->name),
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
169 (!DATABASE_LIVE_P (db) ? "closed" :
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
170 (db->access_ & O_WRONLY) ? "writeonly" :
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
171 (db->access_ & O_RDWR) ? "readwrite" : "readonly"),
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
172 db->header.uid);
209
41ff10fd062f Import from CVS: tag r20-4b3
cvs
parents: 207
diff changeset
173 write_c_string (buf, printcharfun);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 finalize_database (void *header, int for_disksave)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
179 struct Lisp_Database *db = (struct Lisp_Database *) header;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 if (for_disksave)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 {
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
183 Lisp_Object obj;
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
184 XSETOBJ (obj, Lisp_Type_Record, (void *) db);
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
185
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 signal_simple_error
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
187 ("Can't dump an emacs containing database objects", obj);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 db->funcs->close (db);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
192 DEFINE_LRECORD_IMPLEMENTATION ("database", database,
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
193 mark_database, print_database,
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
194 finalize_database, 0, 0,
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
195 struct Lisp_Database);
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
196
203
850242ba4a81 Import from CVS: tag r20-3b28
cvs
parents: 187
diff changeset
197 DEFUN ("close-database", Fclose_database, 1, 1, 0, /*
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
198 Close database DATABASE.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
199 */
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
200 (database))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
202 struct Lisp_Database *db;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
203 CHECK_LIVE_DATABASE (database);
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
204 db = XDATABASE (database);
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
205 db->funcs->close (db);
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
206 db->live_p = 0;
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 157
diff changeset
207 return Qnil;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
210 DEFUN ("database-type", Fdatabase_type, 1, 1, 0, /*
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
211 Return the type of database DATABASE.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
212 */
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
213 (database))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
215 CHECK_DATABASE (database);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
217 return XDATABASE (database)->funcs->get_type (XDATABASE (database));
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
220 DEFUN ("database-subtype", Fdatabase_subtype, 1, 1, 0, /*
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
221 Return the subtype of database DATABASE, if any.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
222 */
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
223 (database))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
225 CHECK_DATABASE (database);
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
226
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
227 return XDATABASE (database)->funcs->get_subtype (XDATABASE (database));
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
230 DEFUN ("database-live-p", Fdatabase_live_p, 1, 1, 0, /*
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
231 Return t if OBJ is an active database.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
232 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
233 (obj))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
235 return DATABASEP (obj) && DATABASE_LIVE_P (XDATABASE (obj)) ? Qt : Qnil;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
238 DEFUN ("database-file-name", Fdatabase_file_name, 1, 1, 0, /*
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
239 Return the filename associated with the database DATABASE.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
240 */
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
241 (database))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
243 CHECK_DATABASE (database);
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
244
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
245 return XDATABASE (database)->fname;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
248 DEFUN ("databasep", Fdatabasep, 1, 1, 0, /*
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
249 Return t if OBJ is a database.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
250 */
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
251 (obj))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 {
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 157
diff changeset
253 return DATABASEP (obj) ? Qt : Qnil;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 #ifdef HAVE_DBM
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 static void
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
258 dbm_map (struct Lisp_Database *db, Lisp_Object func)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 datum keydatum, valdatum;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 Lisp_Object key, val;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
263 for (keydatum = dbm_firstkey (db->dbm_handle);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 keydatum.dptr != NULL;
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
265 keydatum = dbm_nextkey (db->dbm_handle))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 {
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
267 valdatum = dbm_fetch (db->dbm_handle, keydatum);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 key = make_string ((unsigned char *) keydatum.dptr, keydatum.dsize);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 val = make_string ((unsigned char *) valdatum.dptr, valdatum.dsize);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 call2 (func, key, val);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 static Lisp_Object
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
275 dbm_get (struct Lisp_Database *db, Lisp_Object key)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 datum keydatum, valdatum;
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
278
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 0
diff changeset
279 keydatum.dptr = (char *) XSTRING_DATA (key);
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 0
diff changeset
280 keydatum.dsize = XSTRING_LENGTH (key);
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
281 valdatum = dbm_fetch (db->dbm_handle, keydatum);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 return (valdatum.dptr
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 ? make_string ((unsigned char *) valdatum.dptr, valdatum.dsize)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 : Qnil);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 static int
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
289 dbm_put (struct Lisp_Database *db,
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
290 Lisp_Object key, Lisp_Object val, Lisp_Object replace)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 datum keydatum, valdatum;
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
293
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 0
diff changeset
294 valdatum.dptr = (char *) XSTRING_DATA (val);
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 0
diff changeset
295 valdatum.dsize = XSTRING_LENGTH (val);
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 0
diff changeset
296 keydatum.dptr = (char *) XSTRING_DATA (key);
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 0
diff changeset
297 keydatum.dsize = XSTRING_LENGTH (key);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
299 return !dbm_store (db->dbm_handle, keydatum, valdatum,
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
300 NILP (replace) ? DBM_INSERT : DBM_REPLACE);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 static int
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
304 dbm_remove (struct Lisp_Database *db, Lisp_Object key)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 datum keydatum;
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
307
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 0
diff changeset
308 keydatum.dptr = (char *) XSTRING_DATA (key);
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 0
diff changeset
309 keydatum.dsize = XSTRING_LENGTH (key);
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
310
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
311 return dbm_delete (db->dbm_handle, keydatum);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 static Lisp_Object
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
315 dbm_type (struct Lisp_Database *db)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 {
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 157
diff changeset
317 return Qdbm;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
320 static Lisp_Object
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
321 dbm_subtype (struct Lisp_Database *db)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
323 return Qnil;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 static Lisp_Object
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
327 dbm_lasterr (struct Lisp_Database *db)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
329 return lisp_strerror (db->dberrno);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 static void
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
333 dbm_closeit (struct Lisp_Database *db)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 {
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
335 if (db->dbm_handle)
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
336 {
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
337 dbm_close (db->dbm_handle);
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
338 db->dbm_handle = NULL;
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
339 }
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 static DB_FUNCS ndbm_func_block =
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344 dbm_subtype,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 dbm_type,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346 dbm_get,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 dbm_put,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 dbm_remove,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 dbm_map,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 dbm_closeit,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 dbm_lasterr
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 };
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
353 #endif /* HAVE_DBM */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 #ifdef HAVE_BERKELEY_DB
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356 static Lisp_Object
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
357 berkdb_type (struct Lisp_Database *db)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 {
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 157
diff changeset
359 return Qberkeley_db;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
362 static Lisp_Object
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
363 berkdb_subtype (struct Lisp_Database *db)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 {
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
365 if (!db->db_handle)
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
366 return Qnil;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
368 switch (db->db_handle->type)
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
369 {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
370 case DB_BTREE: return Qbtree;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
371 case DB_HASH: return Qhash;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
372 case DB_RECNO: return Qrecno;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
373 default: return Qunknown;
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
374 }
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377 static Lisp_Object
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
378 berkdb_lasterr (struct Lisp_Database *db)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379 {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
380 return lisp_strerror (db->dberrno);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383 static Lisp_Object
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
384 berkdb_get (struct Lisp_Database *db, Lisp_Object key)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 {
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
386 /* #### Needs mule-izing */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387 DBT keydatum, valdatum;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388 int status = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
390 #if DB_VERSION_MAJOR == 2
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
391 /* Always initialize keydatum, valdatum. */
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
392 xzero (keydatum);
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
393 xzero (valdatum);
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
394 #endif /* DV_VERSION_MAJOR = 2 */
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
395
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 0
diff changeset
396 keydatum.data = XSTRING_DATA (key);
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 0
diff changeset
397 keydatum.size = XSTRING_LENGTH (key);
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
398
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
399 #if DB_VERSION_MAJOR == 1
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
400 status = db->db_handle->get (db->db_handle, &keydatum, &valdatum, 0);
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
401 #else
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
402 status = db->db_handle->get (db->db_handle, NULL, &keydatum, &valdatum, 0);
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
403 #endif /* DB_VERSION_MAJOR */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405 if (!status)
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
406 return make_string ((Bufbyte *) valdatum.data, valdatum.size);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
408 #if DB_VERSION_MAJOR == 1
94
1040fe1366ac Import from CVS: tag xemacs-20-0f2
cvs
parents: 70
diff changeset
409 db->dberrno = (status == 1) ? -1 : errno;
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
410 #else
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
411 db->dberrno = (status < 0) ? -1 : errno;
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
412 #endif /* DB_VERSION_MAJOR */
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
413
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 157
diff changeset
414 return Qnil;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417 static int
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
418 berkdb_put (struct Lisp_Database *db,
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419 Lisp_Object key,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420 Lisp_Object val,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421 Lisp_Object replace)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423 DBT keydatum, valdatum;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424 int status = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
426 #if DB_VERSION_MAJOR == 2
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
427 /* Always initalize keydatum, valdatum. */
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
428 xzero (keydatum);
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
429 xzero (valdatum);
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
430 #endif /* DV_VERSION_MAJOR = 2 */
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
431
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 0
diff changeset
432 keydatum.data = XSTRING_DATA (key);
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 0
diff changeset
433 keydatum.size = XSTRING_LENGTH (key);
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 0
diff changeset
434 valdatum.data = XSTRING_DATA (val);
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 0
diff changeset
435 valdatum.size = XSTRING_LENGTH (val);
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
436 #if DB_VERSION_MAJOR == 1
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
437 status = db->db_handle->put (db->db_handle, &keydatum, &valdatum,
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
438 NILP (replace) ? R_NOOVERWRITE : 0);
94
1040fe1366ac Import from CVS: tag xemacs-20-0f2
cvs
parents: 70
diff changeset
439 db->dberrno = (status == 1) ? -1 : errno;
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
440 #else
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
441 status = db->db_handle->put (db->db_handle, NULL, &keydatum, &valdatum,
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
442 NILP (replace) ? DB_NOOVERWRITE : 0);
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
443 db->dberrno = (status < 0) ? -1 : errno;
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
444 #endif/* DV_VERSION_MAJOR = 2 */
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
445
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446 return status;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
448
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449 static int
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
450 berkdb_remove (struct Lisp_Database *db, Lisp_Object key)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452 DBT keydatum;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453 int status;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
455 #if DB_VERSION_MAJOR == 2
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
456 /* Always initialize keydatum. */
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
457 xzero (keydatum);
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
458 #endif /* DV_VERSION_MAJOR = 2 */
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
459
14
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 0
diff changeset
460 keydatum.data = XSTRING_DATA (key);
9ee227acff29 Import from CVS: tag r19-15b90
cvs
parents: 0
diff changeset
461 keydatum.size = XSTRING_LENGTH (key);
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
462
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
463 #if DB_VERSION_MAJOR == 1
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
464 status = db->db_handle->del (db->db_handle, &keydatum, 0);
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
465 #else
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
466 status = db->db_handle->del (db->db_handle, NULL, &keydatum, 0);
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
467 #endif /* DB_VERSION_MAJOR */
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
468
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469 if (!status)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470 return 0;
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
471
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
472 #if DB_VERSION_MAJOR == 1
94
1040fe1366ac Import from CVS: tag xemacs-20-0f2
cvs
parents: 70
diff changeset
473 db->dberrno = (status == 1) ? -1 : errno;
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
474 #else
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
475 db->dberrno = (status < 0) ? -1 : errno;
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
476 #endif /* DB_VERSION_MAJOR */
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
477
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
478 return 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
479 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481 static void
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
482 berkdb_map (struct Lisp_Database *db, Lisp_Object func)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
483 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484 DBT keydatum, valdatum;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485 Lisp_Object key, val;
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
486 DB *dbp = db->db_handle;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
487 int status;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
488
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
489 #if DB_VERSION_MAJOR == 1
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
490 for (status = dbp->seq (dbp, &keydatum, &valdatum, R_FIRST);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
491 status == 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
492 status = dbp->seq (dbp, &keydatum, &valdatum, R_NEXT))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
493 {
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
494 /* ### Needs mule-izing */
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
495 key = make_string ((Bufbyte *) keydatum.data, keydatum.size);
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
496 val = make_string ((Bufbyte *) valdatum.data, valdatum.size);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
497 call2 (func, key, val);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
498 }
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
499 #else
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
500 DBC *dbcp;
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
501 /* Initialize the key/data pair so the flags aren't set. */
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
502 xzero (keydatum);
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
503 xzero (valdatum);
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
504
335
54f7aa390f4f Import from CVS: tag r21-0-65
cvs
parents: 272
diff changeset
505 #if DB_VERSION_MAJOR > 2 || DB_VERSION_MINOR >=6
54f7aa390f4f Import from CVS: tag r21-0-65
cvs
parents: 272
diff changeset
506 status = dbp->cursor (dbp, NULL, &dbcp, 0);
54f7aa390f4f Import from CVS: tag r21-0-65
cvs
parents: 272
diff changeset
507 #else
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
508 status = dbp->cursor (dbp, NULL, &dbcp);
335
54f7aa390f4f Import from CVS: tag r21-0-65
cvs
parents: 272
diff changeset
509 #endif
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
510 for (status = dbcp->c_get (dbcp, &keydatum, &valdatum, DB_FIRST);
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
511 status == 0;
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
512 status = dbcp->c_get (dbcp, &keydatum, &valdatum, DB_NEXT))
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
513 {
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
514 /* ### Needs mule-izing */
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
515 key = make_string ((Bufbyte *) keydatum.data, keydatum.size);
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
516 val = make_string ((Bufbyte *) valdatum.data, valdatum.size);
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
517 call2 (func, key, val);
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
518 }
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
519 dbcp->c_close (dbcp);
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
520 #endif /* DB_VERSION_MAJOR */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
521 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
522
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
523 static void
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
524 berkdb_close (struct Lisp_Database *db)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
525 {
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
526 if (db->db_handle)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
527 {
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
528 #if DB_VERSION_MAJOR == 1
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
529 db->db_handle->sync (db->db_handle, 0);
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
530 db->db_handle->close (db->db_handle);
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
531 #else
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
532 db->db_handle->sync (db->db_handle, 0);
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
533 db->db_handle->close (db->db_handle, 0);
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
534 #endif /* DB_VERSION_MAJOR */
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
535 db->db_handle = NULL;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
536 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
537 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
538
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
539 static DB_FUNCS berk_func_block =
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
540 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
541 berkdb_subtype,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
542 berkdb_type,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
543 berkdb_get,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
544 berkdb_put,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
545 berkdb_remove,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
546 berkdb_map,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
547 berkdb_close,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
548 berkdb_lasterr
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
549 };
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
550 #endif /* HAVE_BERKELEY_DB */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
551
203
850242ba4a81 Import from CVS: tag r20-3b28
cvs
parents: 187
diff changeset
552 DEFUN ("database-last-error", Fdatabase_last_error, 0, 1, 0, /*
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
553 Return the last error associated with DATABASE.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
554 */
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
555 (database))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
556 {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
557 if (NILP (database))
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 149
diff changeset
558 return lisp_strerror (errno);
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
559
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
560 CHECK_DATABASE (database);
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
561
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
562 return XDATABASE (database)->funcs->last_error (XDATABASE (database));
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
563 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
564
203
850242ba4a81 Import from CVS: tag r20-3b28
cvs
parents: 187
diff changeset
565 DEFUN ("open-database", Fopen_database, 1, 5, 0, /*
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
566 Return a new database object opened on FILE.
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
567 Optional arguments TYPE and SUBTYPE specify the database type.
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
568 Optional argument ACCESS specifies the access rights, which may be any
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
569 combination of 'r' 'w' and '+', for read, write, and creation flags.
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
570 Optional argument MODE gives the permissions to use when opening FILE,
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
571 and defaults to 0755.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
572 */
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 157
diff changeset
573 (file, type, subtype, access_, mode))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
574 {
187
b405438285a2 Import from CVS: tag r20-3b20
cvs
parents: 185
diff changeset
575 /* This function can GC */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
576 int modemask;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
577 int accessmask = 0;
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
578 struct Lisp_Database *db = NULL;
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
579 char *filename;
187
b405438285a2 Import from CVS: tag r20-3b20
cvs
parents: 185
diff changeset
580 struct gcpro gcpro1, gcpro2;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
581
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 48
diff changeset
582 CHECK_STRING (file);
187
b405438285a2 Import from CVS: tag r20-3b20
cvs
parents: 185
diff changeset
583 GCPRO2 (file, access_);
b405438285a2 Import from CVS: tag r20-3b20
cvs
parents: 185
diff changeset
584 file = Fexpand_file_name (file, Qnil);
b405438285a2 Import from CVS: tag r20-3b20
cvs
parents: 185
diff changeset
585 UNGCPRO;
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
586 filename = (char *) XSTRING_DATA (file);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
587
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 157
diff changeset
588 if (NILP (access_))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
589 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
590 accessmask = O_RDWR | O_CREAT;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
591 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
592 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
593 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
594 char *acc;
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 157
diff changeset
595 CHECK_STRING (access_);
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 157
diff changeset
596 acc = (char *) XSTRING_DATA (access_);
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
597
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
598 if (strchr (acc, '+'))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
599 accessmask |= O_CREAT;
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
600
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
601 {
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
602 char *rp = strchr (acc, 'r');
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
603 char *wp = strchr (acc, 'w');
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
604 if (rp && wp) accessmask |= O_RDWR;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
605 else if (wp) accessmask |= O_WRONLY;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
606 else accessmask |= O_RDONLY;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
607 }
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
608 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
609
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
610 if (NILP (mode))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
611 {
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
612 modemask = 0755; /* rwxr-xr-x */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
613 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
614 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
615 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
616 CHECK_INT (mode);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
617 modemask = XINT (mode);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
618 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
619
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
620 #ifdef HAVE_DBM
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
621 if (NILP (type) || EQ (type, Qdbm))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
622 {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
623 DBM *dbase = dbm_open (filename, accessmask, modemask);
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
624 if (!dbase)
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
625 return Qnil;
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
626
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
627 db = allocate_database ();
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
628 db->dbm_handle = dbase;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
629 db->type = DB_DBM;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
630 db->funcs = &ndbm_func_block;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
631 goto db_done;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
632 }
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
633 #endif /* HAVE_DBM */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
634
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
635 #ifdef HAVE_BERKELEY_DB
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
636 if (NILP (type) || EQ (type, Qberkeley_db))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
637 {
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
638 DBTYPE real_subtype;
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
639 DB *dbase;
211
78478c60bfcd Import from CVS: tag r20-4b4
cvs
parents: 209
diff changeset
640 #if DB_VERSION_MAJOR != 1
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
641 int status;
211
78478c60bfcd Import from CVS: tag r20-4b4
cvs
parents: 209
diff changeset
642 #endif
78478c60bfcd Import from CVS: tag r20-4b4
cvs
parents: 209
diff changeset
643
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
644 if (EQ (subtype, Qhash) || NILP (subtype))
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
645 real_subtype = DB_HASH;
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
646 else if (EQ (subtype, Qbtree))
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
647 real_subtype = DB_BTREE;
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
648 else if (EQ (subtype, Qrecno))
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
649 real_subtype = DB_RECNO;
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
650 else
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
651 signal_simple_error ("Unsupported subtype", subtype);
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
652
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
653 #if DB_VERSION_MAJOR == 1
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
654 dbase = dbopen (filename, accessmask, modemask, real_subtype, NULL);
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
655 if (!dbase)
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
656 return Qnil;
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
657 #else
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
658 /* Berkeley DB Version 2 has only the accessmask DB_CREATE and DB_RDONLY,
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
659 other flags shouldn't be set */
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
660 if (NILP (access_))
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
661 accessmask = DB_CREATE;
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
662 else
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
663 {
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
664 char *acc;
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
665 CHECK_STRING (access_);
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
666 acc = (char *) XSTRING_DATA (access_);
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
667 accessmask = 0;
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
668
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
669 if (strchr (acc, '+'))
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
670 accessmask |= DB_CREATE;
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
671
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
672 if (strchr (acc, 'r') && !strchr (acc, 'w'))
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
673 accessmask |= DB_RDONLY;
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
674 }
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
675 status = db_open (filename, real_subtype, accessmask,
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
676 modemask, NULL , NULL, &dbase);
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
677 if (status)
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
678 return Qnil;
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 203
diff changeset
679 #endif /* DB_VERSION_MAJOR */
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
680
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
681 db = allocate_database ();
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
682 db->db_handle = dbase;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
683 db->type = DB_BERKELEY;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
684 db->funcs = &berk_func_block;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
685 goto db_done;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
686 }
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
687 #endif /* HAVE_BERKELEY_DB */
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
688
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
689 signal_simple_error ("Unsupported database type", type);
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 157
diff changeset
690 return Qnil;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
691
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
692 db_done:
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
693 db->live_p = 1;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
694 db->fname = file;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
695 db->mode = modemask;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
696 db->access_ = accessmask;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
697
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
698 {
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
699 Lisp_Object retval;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
700 XSETDATABASE (retval, db);
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
701 return retval;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
702 }
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
703 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
704
203
850242ba4a81 Import from CVS: tag r20-3b28
cvs
parents: 187
diff changeset
705 DEFUN ("put-database", Fput_database, 3, 4, 0, /*
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
706 Store KEY and VALUE in DATABASE.
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
707 If optional fourth arg REPLACE is non-nil,
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
708 replace any existing entry in the database.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
709 */
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
710 (key, value, database, replace))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
711 {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
712 CHECK_LIVE_DATABASE (database);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
713 CHECK_STRING (key);
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
714 CHECK_STRING (value);
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
715 {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
716 struct Lisp_Database *db = XDATABASE (database);
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
717 int status = db->funcs->put (db, key, value, replace);
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
718 return status ? Qt : Qnil;
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
719 }
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
720 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
721
203
850242ba4a81 Import from CVS: tag r20-3b28
cvs
parents: 187
diff changeset
722 DEFUN ("remove-database", Fremove_database, 2, 2, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
723 Remove KEY from DATABASE.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
724 */
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
725 (key, database))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
726 {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
727 CHECK_LIVE_DATABASE (database);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
728 CHECK_STRING (key);
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
729 {
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
730 struct Lisp_Database *db = XDATABASE (database);
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
731 int status = db->funcs->rem (db, key);
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
732 return status ? Qt : Qnil;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
733 }
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
734 }
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
735
203
850242ba4a81 Import from CVS: tag r20-3b28
cvs
parents: 187
diff changeset
736 DEFUN ("get-database", Fget_database, 2, 3, 0, /*
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
737 Return value for KEY in DATABASE.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
738 If there is no corresponding value, return DEFAULT (defaults to nil).
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
739 */
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
740 (key, database, default_))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
741 {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
742 CHECK_LIVE_DATABASE (database);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
743 CHECK_STRING (key);
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
744 {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
745 struct Lisp_Database *db = XDATABASE (database);
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
746 Lisp_Object retval = db->funcs->get (db, key);
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
747 return NILP (retval) ? default_ : retval;
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
748 }
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
749 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
750
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
751 DEFUN ("map-database", Fmapdatabase, 2, 2, 0, /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
752 Map FUNCTION over entries in DATABASE, calling it with two args,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
753 each key and value in the database.
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
754 */
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
755 (function, database))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
756 {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
757 CHECK_LIVE_DATABASE (database);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
758
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
759 XDATABASE (database)->funcs->map (XDATABASE (database), function);
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 177
diff changeset
760
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
761 return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
762 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
763
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
764 void
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
765 syms_of_database (void)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
766 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
767 defsymbol (&Qdatabasep, "databasep");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
768 #ifdef HAVE_DBM
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
769 defsymbol (&Qdbm, "dbm");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
770 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
771 #ifdef HAVE_BERKELEY_DB
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
772 defsymbol (&Qberkeley_db, "berkeley-db");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
773 defsymbol (&Qhash, "hash");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
774 defsymbol (&Qbtree, "btree");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
775 defsymbol (&Qrecno, "recno");
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
776 defsymbol (&Qunknown, "unknown");
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
777 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
778
203
850242ba4a81 Import from CVS: tag r20-3b28
cvs
parents: 187
diff changeset
779 DEFSUBR (Fopen_database);
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
780 DEFSUBR (Fdatabasep);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
781 DEFSUBR (Fmapdatabase);
203
850242ba4a81 Import from CVS: tag r20-3b28
cvs
parents: 187
diff changeset
782 DEFSUBR (Fput_database);
850242ba4a81 Import from CVS: tag r20-3b28
cvs
parents: 187
diff changeset
783 DEFSUBR (Fget_database);
850242ba4a81 Import from CVS: tag r20-3b28
cvs
parents: 187
diff changeset
784 DEFSUBR (Fremove_database);
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
785 DEFSUBR (Fdatabase_type);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
786 DEFSUBR (Fdatabase_subtype);
203
850242ba4a81 Import from CVS: tag r20-3b28
cvs
parents: 187
diff changeset
787 DEFSUBR (Fdatabase_last_error);
20
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
788 DEFSUBR (Fdatabase_live_p);
859a2309aef8 Import from CVS: tag r19-15b93
cvs
parents: 14
diff changeset
789 DEFSUBR (Fdatabase_file_name);
203
850242ba4a81 Import from CVS: tag r20-3b28
cvs
parents: 187
diff changeset
790 DEFSUBR (Fclose_database);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
791 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
792
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
793 void
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 211
diff changeset
794 vars_of_database (void)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
795 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
796 #ifdef HAVE_DBM
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
797 Fprovide (Qdbm);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
798 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
799 #ifdef HAVE_BERKELEY_DB
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
800 Fprovide (Qberkeley_db);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
801 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
802 }