Bug 469739 - Add support for displaying Vista UAC shield icon; r=joe sr=vladimir
[wine-gecko.git] / dbm / src / db.c
blob468bd4b629292840da0ad156202a18a048f1d9b0
1 /*-
2 * Copyright (c) 1991, 1993
3 * The Regents of the University of California. All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. ***REMOVED*** - see
14 * ftp://ftp.cs.berkeley.edu/pub/4bsd/README.Impt.License.Change
15 * 4. Neither the name of the University nor the names of its contributors
16 * may be used to endorse or promote products derived from this software
17 * without specific prior written permission.
19 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.
32 #if defined(LIBC_SCCS) && !defined(lint)
33 static char sccsid[] = "@(#)db.c 8.4 (Berkeley) 2/21/94";
34 #endif /* LIBC_SCCS and not lint */
36 #include "watcomfx.h"
38 #ifndef __DBINTERFACE_PRIVATE
39 #define __DBINTERFACE_PRIVATE
40 #endif
41 #ifdef macintosh
42 #include <unix.h>
43 #else
44 #include <sys/types.h>
45 #endif
47 #include <errno.h>
48 #include <fcntl.h>
49 #include <stddef.h>
50 #include <stdio.h>
52 #include "mcom_db.h"
54 /* a global flag that locks closed all databases */
55 int all_databases_locked_closed = 0;
57 /* set or unset a global lock flag to disable the
58 * opening of any DBM file
60 void
61 dbSetOrClearDBLock(DBLockFlagEnum type)
63 if(type == LockOutDatabase)
64 all_databases_locked_closed = 1;
65 else
66 all_databases_locked_closed = 0;
69 #if defined(__WATCOMC__) || defined(__WATCOM_CPLUSPLUS__)
70 DB *
71 #else
72 PR_IMPLEMENT(DB *)
73 #endif
74 dbopen(const char *fname, int flags,int mode, DBTYPE type, const void *openinfo)
77 /* lock out all file databases. Let in-memory databases through
79 if(all_databases_locked_closed && fname)
81 errno = EINVAL;
82 return(NULL);
85 #define DB_FLAGS (DB_LOCK | DB_SHMEM | DB_TXN)
88 #if 0 /* most systems don't have EXLOCK and SHLOCK */
89 #define USE_OPEN_FLAGS \
90 (O_CREAT | O_EXCL | O_EXLOCK | O_NONBLOCK | O_RDONLY | \
91 O_RDWR | O_SHLOCK | O_TRUNC)
92 #else
93 #define USE_OPEN_FLAGS \
94 (O_CREAT | O_EXCL | O_RDONLY | \
95 O_RDWR | O_TRUNC)
96 #endif
98 if ((flags & ~(USE_OPEN_FLAGS | DB_FLAGS)) == 0)
99 switch (type) {
100 /* we don't need btree and recno right now */
101 #if 0
102 case DB_BTREE:
103 return (__bt_open(fname, flags & USE_OPEN_FLAGS,
104 mode, openinfo, flags & DB_FLAGS));
105 case DB_RECNO:
106 return (__rec_open(fname, flags & USE_OPEN_FLAGS,
107 mode, openinfo, flags & DB_FLAGS));
108 #endif
110 case DB_HASH:
111 return (__hash_open(fname, flags & USE_OPEN_FLAGS,
112 mode, (const HASHINFO *)openinfo, flags & DB_FLAGS));
113 default:
114 break;
116 errno = EINVAL;
117 return (NULL);
120 static int
121 __dberr()
123 return (RET_ERROR);
127 * __DBPANIC -- Stop.
129 * Parameters:
130 * dbp: pointer to the DB structure.
132 void
133 __dbpanic(DB *dbp)
135 /* The only thing that can succeed is a close. */
136 dbp->del = (int (*)(const struct __db *, const DBT *, uint))__dberr;
137 dbp->fd = (int (*)(const struct __db *))__dberr;
138 dbp->get = (int (*)(const struct __db *, const DBT *, DBT *, uint))__dberr;
139 dbp->put = (int (*)(const struct __db *, DBT *, const DBT *, uint))__dberr;
140 dbp->seq = (int (*)(const struct __db *, DBT *, DBT *, uint))__dberr;
141 dbp->sync = (int (*)(const struct __db *, uint))__dberr;