annotate src/database.c @ 398:74fd4e045ea6 r21-2-29

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