2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
6 * These libraries and programs are free software; you can
7 * redistribute them and/or modify them under the terms of the GNU
8 * Lesser General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
12 * These libraries and programs are distributed in the hope that
13 * they will be useful, but WITHOUT ANY WARRANTY; without even the
14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these librararies and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
23 /*%% (c) Copyright 1993, 1994 Hewlett-Packard Company */
24 /*%% (c) Copyright 1993, 1994 International Business Machines Corp. */
25 /*%% (c) Copyright 1993, 1994 Sun Microsystems, Inc. */
26 /*%% (c) Copyright 1993, 1994 Novell, Inc. */
27 /*%% $XConsortium: dm_access_cache.h /main/3 1995/10/20 16:40:47 rswiston $ */
29 * Tool Talk Database Manager - dm_access_cache.h
31 * Copyright (c) 1989 Sun Microsystems, Inc.
33 * This file contains class declarations for the oid access info cache.
37 #if !defined(_DM_ACCESS_CACHE_H)
38 #define _DM_ACCESS_CACHE_H
40 #include <util/tt_object.h>
41 #include <util/tt_string.h>
43 #include <sys/param.h>
47 #define NGROUPS NGROUPS_MAX
50 #define DM_OID_ACCESS_BUCKETS 97
51 #define DM_MAX_ACCESS_ELEMS (5 * DM_OID_ACCESS_BUCKETS)
54 * OID keys' access info cache
57 class _Tt_oid_access : public _Tt_object {
60 _Tt_oid_access(const char *key, uid_t user, gid_t group, mode_t mode);
61 _Tt_oid_access(char *ku);
63 const char *key() const { return _key; }
64 uid_t user() const { return _user; }
65 gid_t group() const { return _group; }
66 mode_t mode() const { return _mode; }
67 void set_user(uid_t user) { _user = user; }
68 void set_group(gid_t group) { _group = group; }
69 void set_mode(mode_t mode) { _mode = mode; }
70 int reclen() const { return OID_KEY_LENGTH +
71 sizeof(uid_t) + sizeof(gid_t) +
74 void print(FILE *fs = stdout) const;
76 char _key[OID_KEY_LENGTH];
82 declare_ptr_to(_Tt_oid_access)
84 class _Tt_oid_access_elem;
85 declare_ptr_to(_Tt_oid_access_elem)
87 class _Tt_oid_access_elem : public _Tt_object {
89 _Tt_oid_access_elem() {}
90 _Tt_oid_access_elem(_Tt_oid_access_ptr oa, _Tt_oid_access_elem_ptr next);
91 _Tt_oid_access_ptr oa() { return _oa; }
92 _Tt_oid_access_elem_ptr next() { return _next; }
93 void set_next(_Tt_oid_access_elem_ptr next)
95 void print(FILE *fs = stdout) const;
97 _Tt_oid_access_ptr _oa;
98 _Tt_oid_access_elem_ptr _next;
101 class _Tt_oid_access_queue : public _Tt_object {
103 _Tt_oid_access_queue();
104 ~_Tt_oid_access_queue();
105 void enqueue(_Tt_oid_access_ptr oa);
106 _Tt_oid_access_ptr lookup(const char *key);
107 void remove(_Tt_oid_access_ptr oa);
108 void promote(_Tt_oid_access_ptr oa);
109 void print(FILE *fs = stdout) const;
112 int hash(const char *key);
114 _Tt_oid_access_elem_ptr _head;
115 _Tt_oid_access_elem_ptr _tail;
117 _Tt_oid_access_elem_ptr _table[DM_OID_ACCESS_BUCKETS];
120 declare_ptr_to(_Tt_oid_access_queue)
124 * LINK keys' access info cache
127 class _Tt_link_access : public _Tt_object {
130 _Tt_link_access(const char *key, uid_t user, gid_t group, mode_t mode);
131 _Tt_link_access(char *ku);
133 const char *key() const { return _key; }
134 uid_t user() const { return _user; }
135 gid_t group() const { return _group; }
136 mode_t mode() const { return _mode; }
137 void set_user(uid_t user) { _user = user; }
138 void set_group(gid_t group) { _group = group; }
139 void set_mode(mode_t mode) { _mode = mode; }
140 int reclen() const { return OID_KEY_LENGTH +
141 sizeof(uid_t) + sizeof(gid_t) +
144 void print(FILE *fs = stdout) const;
146 char _key[OID_KEY_LENGTH];
152 declare_ptr_to(_Tt_link_access)
154 class _Tt_link_access_elem;
155 declare_ptr_to(_Tt_link_access_elem)
157 class _Tt_link_access_elem : public _Tt_object {
159 _Tt_link_access_elem() {}
160 _Tt_link_access_elem(_Tt_link_access_ptr oa, _Tt_link_access_elem_ptr next);
161 _Tt_link_access_ptr oa() { return _oa; }
162 _Tt_link_access_elem_ptr next() { return _next; }
163 void set_next(_Tt_link_access_elem_ptr next)
165 void print(FILE *fs = stdout) const;
167 _Tt_link_access_ptr _oa;
168 _Tt_link_access_elem_ptr _next;
171 class _Tt_link_access_queue : public _Tt_object {
173 _Tt_link_access_queue();
174 ~_Tt_link_access_queue();
175 void enqueue(_Tt_link_access_ptr oa);
176 _Tt_link_access_ptr lookup(const char *key);
177 void remove(_Tt_link_access_ptr oa);
178 void promote(_Tt_link_access_ptr oa);
179 void print(FILE *fs = stdout) const;
182 int hash(const char *key);
184 _Tt_link_access_elem_ptr _head;
185 _Tt_link_access_elem_ptr _tail;
187 _Tt_link_access_elem_ptr _table[DM_OID_ACCESS_BUCKETS];
190 declare_ptr_to(_Tt_link_access_queue)
192 // Here follow a bunch of common declarations for dbserver components.
193 // They really should have their own file. (dbserver_commmon.h?)
194 // They got stuck in dm_access_cache since they have do do with
195 // internal dbserver caching (but for fd's.)
196 #define _TT_MAX_ISFD 128
198 /* structure containing info open ISAM files: full path and opener's uids */
202 int open_mode; // mode file was opened with
203 int client_has_open; // 1 iff we think somebodys using it
204 int server_has_open; // 1 iff we opened it
205 int reftime; // "time" of last reference for LRU
208 int cached_isopen(const char *filepath, int mode);
209 int cached_isclose(int isfd);
210 void isgarbage_collect();
213 #endif /* _DM_ACCESS_CACHE_H */