Initial import of the CDE 2.1.30 sources from the Open Group.
This commit is contained in:
65
cde/lib/tt/bin/ttdbserverd/Imakefile
Normal file
65
cde/lib/tt/bin/ttdbserverd/Imakefile
Normal file
@@ -0,0 +1,65 @@
|
||||
XCOMM $XConsortium: Imakefile /main/15 1996/09/30 13:50:43 drk $
|
||||
|
||||
#define CplusplusSource YES
|
||||
DEPEND_DEFINES = $(CXXDEPENDINCLUDES)
|
||||
EXTRA_LOAD_FLAGS = ExtraLoadFlags $(UNSHARED_CXXLIB)
|
||||
|
||||
#include <Threads.tmpl>
|
||||
|
||||
#include "../../tooltalk.tmpl"
|
||||
|
||||
DEFINES =
|
||||
INCLUDES = -I. -I../../slib -I../../lib -I../../mini_isam
|
||||
|
||||
DEPLIBS = ../../slib/libstt.a TtClientDepLibs ../../mini_isam/libisam.a
|
||||
LOCAL_LIBRARIES = ../../slib/libstt.a TtClientLibs ../../mini_isam/libisam.a
|
||||
SYS_LIBRARIES =
|
||||
|
||||
#ifdef TtClientExtraLibs
|
||||
EXTRA_LIBRARIES = TtClientExtraLibs
|
||||
#endif
|
||||
|
||||
|
||||
SRCS = \
|
||||
db_server_functions.C \
|
||||
db_server_svc.C \
|
||||
dm_access_cache.C \
|
||||
dm_server.C \
|
||||
tt_db_message_info_utils.C \
|
||||
tt_db_msg_q_lock.C \
|
||||
tt_db_msg_q_lock_entry_utils.C \
|
||||
tt_db_partition_global_map_ref.C \
|
||||
tt_db_partition_redirection_map.C \
|
||||
tt_db_server_db.C \
|
||||
tt_db_server_db_utils.C \
|
||||
tt_isam_file.C \
|
||||
tt_isam_file_utils.C \
|
||||
tt_isam_key_descriptor.C \
|
||||
tt_isam_key_descriptor_utils.C \
|
||||
tt_isam_record.C \
|
||||
tt_isam_record_utils.C
|
||||
|
||||
OBJS = \
|
||||
db_server_functions.o \
|
||||
db_server_svc.o \
|
||||
dm_access_cache.o \
|
||||
dm_server.o \
|
||||
tt_db_message_info_utils.o \
|
||||
tt_db_msg_q_lock.o \
|
||||
tt_db_msg_q_lock_entry_utils.o \
|
||||
tt_db_partition_global_map_ref.o \
|
||||
tt_db_partition_redirection_map.o \
|
||||
tt_db_server_db.o \
|
||||
tt_db_server_db_utils.o \
|
||||
tt_isam_file.o \
|
||||
tt_isam_file_utils.o \
|
||||
tt_isam_key_descriptor.o \
|
||||
tt_isam_key_descriptor_utils.o \
|
||||
tt_isam_record.o \
|
||||
tt_isam_record_utils.o
|
||||
|
||||
NormalCplusplusObjectRule()
|
||||
|
||||
ComplexCplusplusProgramTarget(rpc.ttdbserver)
|
||||
|
||||
SpecialCplusplusObjectRule(db_server_svc,db_server_svc,$(TT_VERSION_DEFINE))
|
||||
6
cde/lib/tt/bin/ttdbserverd/Mapfile
Normal file
6
cde/lib/tt/bin/ttdbserverd/Mapfile
Normal file
@@ -0,0 +1,6 @@
|
||||
# %% (c) Copyright 1993, 1994 Hewlett-Packard Company
|
||||
# %% (c) Copyright 1993, 1994 International Business Machines Corp.
|
||||
# %% (c) Copyright 1993, 1994 Sun Microsystems, Inc.
|
||||
# %% (c) Copyright 1993, 1994 Novell, Inc.
|
||||
# %% $XConsortium: Mapfile /main/3 1995/10/20 16:39:55 rswiston $
|
||||
text=LOAD ?RXO;
|
||||
11
cde/lib/tt/bin/ttdbserverd/admindefines
Normal file
11
cde/lib/tt/bin/ttdbserverd/admindefines
Normal file
@@ -0,0 +1,11 @@
|
||||
XCOMM $XConsortium: admindefines /main/2 1996/05/07 19:16:51 drk $
|
||||
|
||||
#ifdef sun
|
||||
/*
|
||||
* Some tooltalk header files contain inline references to internal
|
||||
* functions. Attempting to compile with -g fails because these
|
||||
* inline references expand into unresolved symbols. Until tooltalk
|
||||
* is fixed force use of -g0. See CDExc20311 for details.
|
||||
*/
|
||||
# define DebuggableCplusplusDebugFlags -g0
|
||||
#endif
|
||||
2762
cde/lib/tt/bin/ttdbserverd/db_server_functions.C
Normal file
2762
cde/lib/tt/bin/ttdbserverd/db_server_functions.C
Normal file
File diff suppressed because it is too large
Load Diff
47
cde/lib/tt/bin/ttdbserverd/db_server_globals.h
Normal file
47
cde/lib/tt/bin/ttdbserverd/db_server_globals.h
Normal file
@@ -0,0 +1,47 @@
|
||||
/*%% (c) Copyright 1993, 1994 Hewlett-Packard Company */
|
||||
/*%% (c) Copyright 1993, 1994 International Business Machines Corp. */
|
||||
/*%% (c) Copyright 1993, 1994 Sun Microsystems, Inc. */
|
||||
/*%% (c) Copyright 1993, 1994 Novell, Inc. */
|
||||
/*%% $XConsortium: db_server_globals.h /main/6 1996/05/07 13:51:43 drk $ */
|
||||
/*
|
||||
* db_server_globals.h - Declares the global variables that were defined
|
||||
* in the old DB server and needed by the new DB
|
||||
* server.
|
||||
*
|
||||
* Copyright (c) 1992 by Sun Microsystems, Inc.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _DB_SERVER_GLOBALS_H
|
||||
#define _DB_SERVER_GLOBALS_H
|
||||
|
||||
#include <limits.h>
|
||||
|
||||
#if defined(OPT_GARBAGE_THREADS)
|
||||
#include <synch.h>
|
||||
#endif // OPT_GARBAGE_THREADS
|
||||
|
||||
extern uid_t _tt_uid;
|
||||
extern gid_t _tt_gid;
|
||||
extern gid_t _tt_gidlist [NGROUPS_MAX];
|
||||
extern int _tt_gidlen;
|
||||
extern int _tt_auth_level;
|
||||
|
||||
#if defined(OPT_GARBAGE_THREADS)
|
||||
extern mutex_t rpc_client_busy; /* Used to sync calls with the RPC clients.*/
|
||||
extern mutex_t garbage_run_in_process;
|
||||
|
||||
#define LOCK_RPC() mutex_lock(&rpc_client_busy);
|
||||
#define UNLOCK_RPC() mutex_unlock(&rpc_client_busy);
|
||||
|
||||
#else /* Else if ! defined(OPT_GARBAGE_THREADS) */
|
||||
|
||||
#define LOCK_RPC() /*EMPTY*/
|
||||
#define UNLOCK_RPC() /*EMPTY*/
|
||||
|
||||
extern int _tt_garbage_id;
|
||||
extern char **global_argv;
|
||||
extern char **global_envp;
|
||||
#endif /* OPT_GARBAGE_THREADS */
|
||||
|
||||
#endif /* _DB_SERVER_GLOBALS_H */
|
||||
1527
cde/lib/tt/bin/ttdbserverd/db_server_svc.C
Normal file
1527
cde/lib/tt/bin/ttdbserverd/db_server_svc.C
Normal file
File diff suppressed because it is too large
Load Diff
512
cde/lib/tt/bin/ttdbserverd/dm_access_cache.C
Normal file
512
cde/lib/tt/bin/ttdbserverd/dm_access_cache.C
Normal file
@@ -0,0 +1,512 @@
|
||||
//%% (c) Copyright 1993, 1994 Hewlett-Packard Company
|
||||
//%% (c) Copyright 1993, 1994 International Business Machines Corp.
|
||||
//%% (c) Copyright 1993, 1994 Sun Microsystems, Inc.
|
||||
//%% (c) Copyright 1993, 1994 Novell, Inc.
|
||||
//%% $XConsortium: dm_access_cache.C /main/3 1995/10/20 16:40:39 rswiston $
|
||||
/*
|
||||
* Tool Talk Database Manager - dm_access_cache.h
|
||||
*
|
||||
* Copyright (c) 1989 Sun Microsystems, Inc.
|
||||
*
|
||||
* This file contains class implementation for the oid access info cache.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "dm_access_cache.h"
|
||||
#include <memory.h>
|
||||
#include <stdlib.h>
|
||||
#include <isam.h>
|
||||
|
||||
implement_ptr_to(_Tt_oid_access)
|
||||
implement_ptr_to(_Tt_oid_access_elem)
|
||||
implement_ptr_to(_Tt_oid_access_queue)
|
||||
implement_ptr_to(_Tt_link_access)
|
||||
implement_ptr_to(_Tt_link_access_elem)
|
||||
implement_ptr_to(_Tt_link_access_queue)
|
||||
|
||||
static char _tt_access_record[ISMAXRECLEN];
|
||||
|
||||
/*
|
||||
* class _Tt_oid_access
|
||||
*/
|
||||
|
||||
_Tt_oid_access::_Tt_oid_access(char *ku)
|
||||
{
|
||||
memcpy(_key, ku, OID_KEY_LENGTH);
|
||||
memcpy((char *)&_user, ku + OID_KEY_LENGTH, sizeof(uid_t));
|
||||
memcpy((char *)&_group, ku + OID_KEY_LENGTH + sizeof(uid_t),
|
||||
sizeof(gid_t));
|
||||
memcpy((char *)&_mode,
|
||||
ku + OID_KEY_LENGTH + sizeof(uid_t) + sizeof(gid_t),
|
||||
sizeof(mode_t));
|
||||
}
|
||||
|
||||
_Tt_oid_access::_Tt_oid_access(const char *key, uid_t user, gid_t group,
|
||||
mode_t mode)
|
||||
{
|
||||
memcpy(_key, key, OID_KEY_LENGTH);
|
||||
_user = user;
|
||||
_group = group;
|
||||
_mode = mode;
|
||||
}
|
||||
|
||||
_Tt_oid_access::~_Tt_oid_access()
|
||||
{
|
||||
}
|
||||
|
||||
char *
|
||||
_Tt_oid_access::rec()
|
||||
{
|
||||
memcpy(_tt_access_record, _key, OID_KEY_LENGTH);
|
||||
memcpy(_tt_access_record + OID_KEY_LENGTH, (char *)&_user,
|
||||
sizeof(uid_t));
|
||||
memcpy(_tt_access_record + OID_KEY_LENGTH + sizeof(uid_t),
|
||||
(char *)&_group, sizeof(gid_t));
|
||||
memcpy(_tt_access_record + OID_KEY_LENGTH + sizeof(uid_t) + sizeof(gid_t),
|
||||
(char *)&_mode, sizeof(mode_t));
|
||||
return _tt_access_record;
|
||||
}
|
||||
|
||||
void
|
||||
_Tt_oid_access::print(FILE *fs) const
|
||||
{
|
||||
fprintf(fs, "oid-access entry: ");
|
||||
fprintf(fs, "key - <%d, %d, %d, %d>, user = %d\n",
|
||||
*((short *) ((char *)_key)),
|
||||
*((int *) ((char *)_key + 4)), *((int *) ((char *)_key + 8)),
|
||||
*((int *) ((char *)_key + 12)), _user);
|
||||
}
|
||||
|
||||
/*
|
||||
* class _Tt_oid_access_elem
|
||||
*/
|
||||
|
||||
_Tt_oid_access_elem::_Tt_oid_access_elem(_Tt_oid_access_ptr oa,
|
||||
_Tt_oid_access_elem_ptr next)
|
||||
{
|
||||
_oa = oa;
|
||||
_next = next;
|
||||
}
|
||||
|
||||
void
|
||||
_Tt_oid_access_elem::print(FILE *fs) const
|
||||
{
|
||||
_oa->print(fs);
|
||||
}
|
||||
|
||||
/*
|
||||
* class _Tt_oid_access_queue
|
||||
*/
|
||||
|
||||
_Tt_oid_access_queue::_Tt_oid_access_queue()
|
||||
{
|
||||
_head = _tail = 0;
|
||||
_len = 0;
|
||||
for (int i = 0; i < DM_OID_ACCESS_BUCKETS; i++) {
|
||||
_table[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
_Tt_oid_access_queue::~_Tt_oid_access_queue()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
_Tt_oid_access_queue::enqueue(_Tt_oid_access_ptr oa)
|
||||
{
|
||||
if (_len == DM_MAX_ACCESS_ELEMS) {
|
||||
dequeue();
|
||||
}
|
||||
/* put the new element on the LRU list */
|
||||
_Tt_oid_access_elem_ptr oae = new _Tt_oid_access_elem(oa, _head);
|
||||
if (_head.is_null()) {
|
||||
_tail = oae;
|
||||
}
|
||||
_head = oae;
|
||||
/* put the new element in the lookup table */
|
||||
int bucket = hash(oa->key());
|
||||
_table[bucket] = new _Tt_oid_access_elem(oa, _table[bucket]);
|
||||
_len++;
|
||||
}
|
||||
|
||||
_Tt_oid_access_ptr
|
||||
_Tt_oid_access_queue::lookup(const char *key)
|
||||
{
|
||||
if (!key) { /* erroneous condition, read by record number needs key */
|
||||
return 0;
|
||||
}
|
||||
int bucket_no = hash(key);
|
||||
_Tt_oid_access_elem_ptr e = _table[bucket_no];
|
||||
while (!e.is_null()) {
|
||||
_Tt_oid_access_ptr oa = e->oa();
|
||||
if (memcmp(oa->key(), key, OID_KEY_LENGTH) == 0) {
|
||||
return oa;
|
||||
}
|
||||
e = e->next();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* remove - remove the oid access element from both the LRU list and the lookup
|
||||
* table. Does not delete the element.
|
||||
*/
|
||||
|
||||
void
|
||||
_Tt_oid_access_queue::remove(_Tt_oid_access_ptr oa)
|
||||
{
|
||||
/* remove from the LRU list */
|
||||
_Tt_oid_access_elem_ptr prev = 0;
|
||||
_Tt_oid_access_elem_ptr cur = _head;
|
||||
while (!cur.is_null()) {
|
||||
if (cur->oa().is_eq(oa)) {
|
||||
if (prev.is_null()) {
|
||||
_head = _head->next();
|
||||
} else {
|
||||
prev->set_next(cur->next());
|
||||
}
|
||||
if (cur.is_eq(_tail)) {
|
||||
_tail = prev;
|
||||
}
|
||||
break;
|
||||
} else {
|
||||
prev = cur;
|
||||
cur = cur->next();
|
||||
}
|
||||
}
|
||||
/* remove from the lookup table */
|
||||
int bucket = hash(oa->key());
|
||||
prev = 0;
|
||||
cur = _table[bucket];
|
||||
while (!cur.is_null()) {
|
||||
if (cur->oa().is_eq(oa)) {
|
||||
if (prev.is_null()) {
|
||||
_table[bucket] = _table[bucket]->next();
|
||||
} else {
|
||||
prev->set_next(cur->next());
|
||||
}
|
||||
break;
|
||||
} else {
|
||||
prev = cur;
|
||||
cur = cur->next();
|
||||
}
|
||||
}
|
||||
--_len;
|
||||
}
|
||||
|
||||
/*
|
||||
* promote - promote the oid access element to the front of the LRU list.
|
||||
*/
|
||||
|
||||
void
|
||||
_Tt_oid_access_queue::promote(_Tt_oid_access_ptr oa)
|
||||
{
|
||||
if (_head->oa().is_eq(oa)) {
|
||||
return;
|
||||
}
|
||||
/* remove from the LRU list */
|
||||
_Tt_oid_access_elem_ptr prev = _head;
|
||||
_Tt_oid_access_elem_ptr cur = prev->next();
|
||||
while (!cur.is_null()) {
|
||||
if (cur->oa().is_eq(oa)) {
|
||||
prev->set_next(cur->next());
|
||||
if (cur.is_eq(_tail)) {
|
||||
_tail = prev;
|
||||
}
|
||||
cur->set_next(_head);
|
||||
_head = cur;
|
||||
break;
|
||||
} else {
|
||||
prev = cur;
|
||||
cur = cur->next();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Remove the LRU element from the LRU list and lookup table and deletes it.
|
||||
*/
|
||||
|
||||
void
|
||||
_Tt_oid_access_queue::dequeue()
|
||||
{
|
||||
if (!_tail.is_null()) {
|
||||
remove(_tail->oa());
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
_Tt_oid_access_queue::hash(const char *key)
|
||||
{
|
||||
int hash_value = 0;
|
||||
for (int i = 0; i < OID_KEY_LENGTH; i++) {
|
||||
hash_value += key[i] & 0177; /* ignore sign */
|
||||
}
|
||||
hash_value = abs(hash_value);
|
||||
return (hash_value % DM_OID_ACCESS_BUCKETS);
|
||||
}
|
||||
|
||||
void
|
||||
_Tt_oid_access_queue::print(FILE *fs) const
|
||||
{
|
||||
fprintf(fs, "\nOID-ACCESS QUEUE list (len = %d):\n", _len);
|
||||
_Tt_oid_access_elem_ptr e = _head;
|
||||
while (!e.is_null()) {
|
||||
e->print(fs);
|
||||
e = e->next();
|
||||
}
|
||||
fprintf(fs, "OID-ACCESS QUEUE table:\n");
|
||||
for (int i = 0; i < DM_OID_ACCESS_BUCKETS; i++) {
|
||||
e = _table[i];
|
||||
if (!e.is_null()) {
|
||||
fprintf(fs, "bucket %d:\n", i);
|
||||
while (!e.is_null()) {
|
||||
e->print(fs);
|
||||
e = e->next();
|
||||
}
|
||||
}
|
||||
}
|
||||
fprintf(fs, "\n");
|
||||
}
|
||||
|
||||
/*
|
||||
* class _Tt_link_access
|
||||
*/
|
||||
|
||||
_Tt_link_access::_Tt_link_access(char *kp)
|
||||
{
|
||||
memcpy(_key, kp, OID_KEY_LENGTH);
|
||||
memcpy((char *)&_user, kp + OID_KEY_LENGTH, sizeof(uid_t));
|
||||
memcpy((char *)&_group, kp + OID_KEY_LENGTH + sizeof(uid_t),
|
||||
sizeof(gid_t));
|
||||
memcpy((char *)&_mode,
|
||||
kp + OID_KEY_LENGTH + sizeof(uid_t) + sizeof(gid_t),
|
||||
sizeof(mode_t));
|
||||
}
|
||||
|
||||
_Tt_link_access::_Tt_link_access(const char *key, uid_t user, gid_t group,
|
||||
mode_t mode)
|
||||
{
|
||||
memcpy(_key, key, OID_KEY_LENGTH);
|
||||
_user = user;
|
||||
_group = group;
|
||||
_mode = mode;
|
||||
}
|
||||
|
||||
_Tt_link_access::~_Tt_link_access()
|
||||
{
|
||||
}
|
||||
|
||||
char *
|
||||
_Tt_link_access::rec()
|
||||
{
|
||||
memcpy(_tt_access_record, _key, OID_KEY_LENGTH);
|
||||
memcpy(_tt_access_record + OID_KEY_LENGTH, (char *)&_user,
|
||||
sizeof(uid_t));
|
||||
memcpy(_tt_access_record + OID_KEY_LENGTH + sizeof(uid_t),
|
||||
(char *)&_group, sizeof(gid_t));
|
||||
memcpy(_tt_access_record + OID_KEY_LENGTH + sizeof(uid_t) + sizeof(gid_t),
|
||||
(char *)&_mode, sizeof(mode_t));
|
||||
return _tt_access_record;
|
||||
}
|
||||
|
||||
void
|
||||
_Tt_link_access::print(FILE *fs) const
|
||||
{
|
||||
fprintf(fs, "link-access entry: ");
|
||||
fprintf(fs, "key - <%d, %d, %d, %d>, user = %d\n",
|
||||
*((short *) ((char *)_key)),
|
||||
*((int *) ((char *)_key + 4)), *((int *) ((char *)_key + 8)),
|
||||
*((int *) ((char *)_key + 12)), _user);
|
||||
}
|
||||
|
||||
/*
|
||||
* class _Tt_link_access_elem
|
||||
*/
|
||||
|
||||
_Tt_link_access_elem::_Tt_link_access_elem(_Tt_link_access_ptr oa,
|
||||
_Tt_link_access_elem_ptr next)
|
||||
{
|
||||
_oa = oa;
|
||||
_next = next;
|
||||
}
|
||||
|
||||
void
|
||||
_Tt_link_access_elem::print(FILE *fs) const
|
||||
{
|
||||
_oa->print(fs);
|
||||
}
|
||||
|
||||
/*
|
||||
* class _Tt_link_access_queue
|
||||
*/
|
||||
|
||||
_Tt_link_access_queue::_Tt_link_access_queue()
|
||||
{
|
||||
_head = _tail = 0;
|
||||
_len = 0;
|
||||
for (int i = 0; i < DM_OID_ACCESS_BUCKETS; i++) {
|
||||
_table[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
_Tt_link_access_queue::~_Tt_link_access_queue()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
_Tt_link_access_queue::enqueue(_Tt_link_access_ptr oa)
|
||||
{
|
||||
if (_len == DM_MAX_ACCESS_ELEMS) {
|
||||
dequeue();
|
||||
}
|
||||
/* put the new element on the LRU list */
|
||||
_Tt_link_access_elem_ptr oae = new _Tt_link_access_elem(oa, _head);
|
||||
if (_head.is_null()) {
|
||||
_tail = oae;
|
||||
}
|
||||
_head = oae;
|
||||
/* put the new element in the lookup table */
|
||||
int bucket = hash(oa->key());
|
||||
_table[bucket] = new _Tt_link_access_elem(oa, _table[bucket]);
|
||||
_len++;
|
||||
}
|
||||
|
||||
_Tt_link_access_ptr
|
||||
_Tt_link_access_queue::lookup(const char *key)
|
||||
{
|
||||
if (!key) { /* erroneous condition, read by record number needs key */
|
||||
return 0;
|
||||
}
|
||||
_Tt_link_access_elem_ptr e = _table[hash(key)];
|
||||
while (!e.is_null()) {
|
||||
_Tt_link_access_ptr oa = e->oa();
|
||||
if (memcmp(oa->key(), key, OID_KEY_LENGTH) == 0) {
|
||||
return oa;
|
||||
}
|
||||
e = e->next();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* remove - remove the oid access element from both the LRU list and the lookup
|
||||
* table. Does not delete the element.
|
||||
*/
|
||||
|
||||
void
|
||||
_Tt_link_access_queue::remove(_Tt_link_access_ptr oa)
|
||||
{
|
||||
/* remove from the LRU list */
|
||||
_Tt_link_access_elem_ptr prev = 0;
|
||||
_Tt_link_access_elem_ptr cur = _head;
|
||||
while (!cur.is_null()) {
|
||||
if (cur->oa().is_eq(oa)) {
|
||||
if (prev.is_null()) {
|
||||
_head = _head->next();
|
||||
} else {
|
||||
prev->set_next(cur->next());
|
||||
}
|
||||
if (cur.is_eq(_tail)) {
|
||||
_tail = prev;
|
||||
}
|
||||
break;
|
||||
} else {
|
||||
prev = cur;
|
||||
cur = cur->next();
|
||||
}
|
||||
}
|
||||
/* remove from the lookup table */
|
||||
int bucket = hash(oa->key());
|
||||
prev = 0;
|
||||
cur = _table[bucket];
|
||||
while (!cur.is_null()) {
|
||||
if (cur->oa().is_eq(oa)) {
|
||||
if (prev.is_null()) {
|
||||
_table[bucket] = _table[bucket]->next();
|
||||
} else {
|
||||
prev->set_next(cur->next());
|
||||
}
|
||||
break;
|
||||
} else {
|
||||
prev = cur;
|
||||
cur = cur->next();
|
||||
}
|
||||
}
|
||||
--_len;
|
||||
}
|
||||
|
||||
/*
|
||||
* promote - promote the oid access element to the front of the LRU list.
|
||||
*/
|
||||
|
||||
void
|
||||
_Tt_link_access_queue::promote(_Tt_link_access_ptr oa)
|
||||
{
|
||||
if (_head->oa().is_eq(oa)) {
|
||||
return;
|
||||
}
|
||||
/* remove from the LRU list */
|
||||
_Tt_link_access_elem_ptr prev = _head;
|
||||
_Tt_link_access_elem_ptr cur = prev->next();
|
||||
while (!cur.is_null()) {
|
||||
if (cur->oa().is_eq(oa)) {
|
||||
prev->set_next(cur->next());
|
||||
if (cur.is_eq(_tail)) {
|
||||
_tail = prev;
|
||||
}
|
||||
cur->set_next(_head);
|
||||
_head = cur;
|
||||
break;
|
||||
} else {
|
||||
prev = cur;
|
||||
cur = cur->next();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Remove the LRU element from the LRU list and lookup table and deletes it.
|
||||
*/
|
||||
|
||||
void
|
||||
_Tt_link_access_queue::dequeue()
|
||||
{
|
||||
if (!_tail.is_null()) {
|
||||
remove(_tail->oa());
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
_Tt_link_access_queue::hash(const char *key)
|
||||
{
|
||||
int hash_value = 0;
|
||||
for (int i = 0; i < OID_KEY_LENGTH; i++) {
|
||||
hash_value += key[i] & 0177; /* ignore sign */
|
||||
}
|
||||
hash_value = abs(hash_value);
|
||||
return (hash_value % DM_OID_ACCESS_BUCKETS);
|
||||
}
|
||||
|
||||
void
|
||||
_Tt_link_access_queue::print(FILE *fs) const
|
||||
{
|
||||
fprintf(fs, "\nLINK-ACCESS QUEUE list (len = %d):\n", _len);
|
||||
_Tt_link_access_elem_ptr e = _head;
|
||||
while (!e.is_null()) {
|
||||
e->print(fs);
|
||||
e = e->next();
|
||||
}
|
||||
fprintf(fs, "LINK-ACCESS QUEUE table:\n");
|
||||
for (int i = 0; i < DM_OID_ACCESS_BUCKETS; i++) {
|
||||
e = _table[i];
|
||||
if (!e.is_null()) {
|
||||
fprintf(fs, "bucket %d:\n", i);
|
||||
while (!e.is_null()) {
|
||||
e->print(fs);
|
||||
e = e->next();
|
||||
}
|
||||
}
|
||||
}
|
||||
fprintf(fs, "\n");
|
||||
}
|
||||
191
cde/lib/tt/bin/ttdbserverd/dm_access_cache.h
Normal file
191
cde/lib/tt/bin/ttdbserverd/dm_access_cache.h
Normal file
@@ -0,0 +1,191 @@
|
||||
/*%% (c) Copyright 1993, 1994 Hewlett-Packard Company */
|
||||
/*%% (c) Copyright 1993, 1994 International Business Machines Corp. */
|
||||
/*%% (c) Copyright 1993, 1994 Sun Microsystems, Inc. */
|
||||
/*%% (c) Copyright 1993, 1994 Novell, Inc. */
|
||||
/*%% $XConsortium: dm_access_cache.h /main/3 1995/10/20 16:40:47 rswiston $ */
|
||||
/*
|
||||
* Tool Talk Database Manager - dm_access_cache.h
|
||||
*
|
||||
* Copyright (c) 1989 Sun Microsystems, Inc.
|
||||
*
|
||||
* This file contains class declarations for the oid access info cache.
|
||||
*
|
||||
*/
|
||||
|
||||
#if !defined(_DM_ACCESS_CACHE_H)
|
||||
#define _DM_ACCESS_CACHE_H
|
||||
|
||||
#include <util/tt_object.h>
|
||||
#include <util/tt_string.h>
|
||||
#include <tt_const.h>
|
||||
#include <sys/param.h>
|
||||
|
||||
#include <limits.h>
|
||||
#if !defined(NGROUPS)
|
||||
#define NGROUPS NGROUPS_MAX
|
||||
#endif
|
||||
|
||||
#define DM_OID_ACCESS_BUCKETS 97
|
||||
#define DM_MAX_ACCESS_ELEMS (5 * DM_OID_ACCESS_BUCKETS)
|
||||
|
||||
/*
|
||||
* OID keys' access info cache
|
||||
*/
|
||||
|
||||
class _Tt_oid_access : public _Tt_object {
|
||||
public:
|
||||
_Tt_oid_access() {}
|
||||
_Tt_oid_access(const char *key, uid_t user, gid_t group, mode_t mode);
|
||||
_Tt_oid_access(char *ku);
|
||||
~_Tt_oid_access();
|
||||
const char *key() const { return _key; }
|
||||
uid_t user() const { return _user; }
|
||||
gid_t group() const { return _group; }
|
||||
mode_t mode() const { return _mode; }
|
||||
void set_user(uid_t user) { _user = user; }
|
||||
void set_group(gid_t group) { _group = group; }
|
||||
void set_mode(mode_t mode) { _mode = mode; }
|
||||
int reclen() const { return OID_KEY_LENGTH +
|
||||
sizeof(uid_t) + sizeof(gid_t) +
|
||||
sizeof(mode_t); }
|
||||
char *rec();
|
||||
void print(FILE *fs = stdout) const;
|
||||
private:
|
||||
char _key[OID_KEY_LENGTH];
|
||||
uid_t _user;
|
||||
gid_t _group;
|
||||
mode_t _mode;
|
||||
};
|
||||
|
||||
declare_ptr_to(_Tt_oid_access)
|
||||
|
||||
class _Tt_oid_access_elem;
|
||||
declare_ptr_to(_Tt_oid_access_elem)
|
||||
|
||||
class _Tt_oid_access_elem : public _Tt_object {
|
||||
public:
|
||||
_Tt_oid_access_elem() {}
|
||||
_Tt_oid_access_elem(_Tt_oid_access_ptr oa, _Tt_oid_access_elem_ptr next);
|
||||
_Tt_oid_access_ptr oa() { return _oa; }
|
||||
_Tt_oid_access_elem_ptr next() { return _next; }
|
||||
void set_next(_Tt_oid_access_elem_ptr next)
|
||||
{ _next = next; }
|
||||
void print(FILE *fs = stdout) const;
|
||||
private:
|
||||
_Tt_oid_access_ptr _oa;
|
||||
_Tt_oid_access_elem_ptr _next;
|
||||
};
|
||||
|
||||
class _Tt_oid_access_queue : public _Tt_object {
|
||||
public:
|
||||
_Tt_oid_access_queue();
|
||||
~_Tt_oid_access_queue();
|
||||
void enqueue(_Tt_oid_access_ptr oa);
|
||||
_Tt_oid_access_ptr lookup(const char *key);
|
||||
void remove(_Tt_oid_access_ptr oa);
|
||||
void promote(_Tt_oid_access_ptr oa);
|
||||
void print(FILE *fs = stdout) const;
|
||||
private:
|
||||
void dequeue();
|
||||
int hash(const char *key);
|
||||
|
||||
_Tt_oid_access_elem_ptr _head;
|
||||
_Tt_oid_access_elem_ptr _tail;
|
||||
int _len;
|
||||
_Tt_oid_access_elem_ptr _table[DM_OID_ACCESS_BUCKETS];
|
||||
};
|
||||
|
||||
declare_ptr_to(_Tt_oid_access_queue)
|
||||
|
||||
|
||||
/*
|
||||
* LINK keys' access info cache
|
||||
*/
|
||||
|
||||
class _Tt_link_access : public _Tt_object {
|
||||
public:
|
||||
_Tt_link_access() {}
|
||||
_Tt_link_access(const char *key, uid_t user, gid_t group, mode_t mode);
|
||||
_Tt_link_access(char *ku);
|
||||
~_Tt_link_access();
|
||||
const char *key() const { return _key; }
|
||||
uid_t user() const { return _user; }
|
||||
gid_t group() const { return _group; }
|
||||
mode_t mode() const { return _mode; }
|
||||
void set_user(uid_t user) { _user = user; }
|
||||
void set_group(gid_t group) { _group = group; }
|
||||
void set_mode(mode_t mode) { _mode = mode; }
|
||||
int reclen() const { return OID_KEY_LENGTH +
|
||||
sizeof(uid_t) + sizeof(gid_t) +
|
||||
sizeof(mode_t); }
|
||||
char *rec();
|
||||
void print(FILE *fs = stdout) const;
|
||||
private:
|
||||
char _key[OID_KEY_LENGTH];
|
||||
uid_t _user;
|
||||
gid_t _group;
|
||||
mode_t _mode;
|
||||
};
|
||||
|
||||
declare_ptr_to(_Tt_link_access)
|
||||
|
||||
class _Tt_link_access_elem;
|
||||
declare_ptr_to(_Tt_link_access_elem)
|
||||
|
||||
class _Tt_link_access_elem : public _Tt_object {
|
||||
public:
|
||||
_Tt_link_access_elem() {}
|
||||
_Tt_link_access_elem(_Tt_link_access_ptr oa, _Tt_link_access_elem_ptr next);
|
||||
_Tt_link_access_ptr oa() { return _oa; }
|
||||
_Tt_link_access_elem_ptr next() { return _next; }
|
||||
void set_next(_Tt_link_access_elem_ptr next)
|
||||
{ _next = next; }
|
||||
void print(FILE *fs = stdout) const;
|
||||
private:
|
||||
_Tt_link_access_ptr _oa;
|
||||
_Tt_link_access_elem_ptr _next;
|
||||
};
|
||||
|
||||
class _Tt_link_access_queue : public _Tt_object {
|
||||
public:
|
||||
_Tt_link_access_queue();
|
||||
~_Tt_link_access_queue();
|
||||
void enqueue(_Tt_link_access_ptr oa);
|
||||
_Tt_link_access_ptr lookup(const char *key);
|
||||
void remove(_Tt_link_access_ptr oa);
|
||||
void promote(_Tt_link_access_ptr oa);
|
||||
void print(FILE *fs = stdout) const;
|
||||
private:
|
||||
void dequeue();
|
||||
int hash(const char *key);
|
||||
|
||||
_Tt_link_access_elem_ptr _head;
|
||||
_Tt_link_access_elem_ptr _tail;
|
||||
int _len;
|
||||
_Tt_link_access_elem_ptr _table[DM_OID_ACCESS_BUCKETS];
|
||||
};
|
||||
|
||||
declare_ptr_to(_Tt_link_access_queue)
|
||||
|
||||
// Here follow a bunch of common declarations for dbserver components.
|
||||
// They really should have their own file. (dbserver_commmon.h?)
|
||||
// They got stuck in dm_access_cache since they have do do with
|
||||
// internal dbserver caching (but for fd's.)
|
||||
#define _TT_MAX_ISFD 128
|
||||
|
||||
/* structure containing info open ISAM files: full path and opener's uids */
|
||||
struct _Tt_db_info {
|
||||
_Tt_string db_path;
|
||||
uid_t opener_uid;
|
||||
int open_mode; // mode file was opened with
|
||||
int client_has_open; // 1 iff we think somebodys using it
|
||||
int server_has_open; // 1 iff we opened it
|
||||
int reftime; // "time" of last reference for LRU
|
||||
};
|
||||
|
||||
int cached_isopen(const char *filepath, int mode);
|
||||
int cached_isclose(int isfd);
|
||||
void isgarbage_collect();
|
||||
|
||||
|
||||
#endif /* _DM_ACCESS_CACHE_H */
|
||||
2267
cde/lib/tt/bin/ttdbserverd/dm_server.C
Normal file
2267
cde/lib/tt/bin/ttdbserverd/dm_server.C
Normal file
File diff suppressed because it is too large
Load Diff
79
cde/lib/tt/bin/ttdbserverd/tt_db_message_info.h
Normal file
79
cde/lib/tt/bin/ttdbserverd/tt_db_message_info.h
Normal file
@@ -0,0 +1,79 @@
|
||||
/*%% (c) Copyright 1993, 1994 Hewlett-Packard Company */
|
||||
/*%% (c) Copyright 1993, 1994 International Business Machines Corp. */
|
||||
/*%% (c) Copyright 1993, 1994 Sun Microsystems, Inc. */
|
||||
/*%% (c) Copyright 1993, 1994 Novell, Inc. */
|
||||
/*%% $XConsortium: tt_db_message_info.h /main/3 1995/10/20 16:41:14 rswiston $ */
|
||||
/* @(#)tt_db_message_info.h 1.8 93/09/07
|
||||
* tt_db_message_info.h - Used to create a database record that stores
|
||||
* queued message info in a way that is reasonable
|
||||
* for the new DB server and compatible with the
|
||||
* old DB server.
|
||||
*
|
||||
* Copyright (c) 1992 by Sun Microsystems, Inc.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _TT_DB_MESSAGE_INFO_H
|
||||
#define _TT_DB_MESSAGE_INFO_H
|
||||
|
||||
#include "util/tt_object.h"
|
||||
#include "util/tt_string.h"
|
||||
#include "util/tt_xdr_version.h"
|
||||
|
||||
class _Tt_db_message_info : public _Tt_object {
|
||||
public:
|
||||
_Tt_db_message_info () {}
|
||||
~_Tt_db_message_info () {}
|
||||
|
||||
int messageID;
|
||||
int numParts;
|
||||
int messageSize;
|
||||
_Tt_string_list_ptr ptypes;
|
||||
|
||||
bool_t xdr (XDR *xdrs)
|
||||
{
|
||||
int dummy_int = 0;
|
||||
_Tt_string dummy_string = "";
|
||||
bool_t results;
|
||||
_Tt_xdr_version xvers(1);
|
||||
|
||||
results = xdr_int(xdrs, &dummy_int);
|
||||
|
||||
if (results) {
|
||||
results = xdr_int(xdrs, &messageID);
|
||||
}
|
||||
|
||||
if (results) {
|
||||
results = xdr_int(xdrs, &numParts);
|
||||
}
|
||||
|
||||
if (results) {
|
||||
results = xdr_int(xdrs, &messageSize);
|
||||
}
|
||||
|
||||
if (results) {
|
||||
int count = (ptypes.is_null() ? 0 : ptypes->count());
|
||||
results = xdr_int(xdrs, &count);
|
||||
|
||||
for (int i=0; results && (i < count); i++) {
|
||||
results = xdr_int(xdrs, &dummy_int);
|
||||
}
|
||||
}
|
||||
|
||||
if (results) {
|
||||
results = ptypes.xdr(xdrs);
|
||||
}
|
||||
|
||||
if (results) {
|
||||
results = xdr_int(xdrs, &dummy_int);
|
||||
}
|
||||
|
||||
if (results) {
|
||||
results = dummy_string.xdr(xdrs);
|
||||
}
|
||||
|
||||
return results;
|
||||
}
|
||||
};
|
||||
|
||||
#endif /* _TT_DB_MESSAGE_INFO_H */
|
||||
14
cde/lib/tt/bin/ttdbserverd/tt_db_message_info_utils.C
Normal file
14
cde/lib/tt/bin/ttdbserverd/tt_db_message_info_utils.C
Normal file
@@ -0,0 +1,14 @@
|
||||
//%% (c) Copyright 1993, 1994 Hewlett-Packard Company
|
||||
//%% (c) Copyright 1993, 1994 International Business Machines Corp.
|
||||
//%% (c) Copyright 1993, 1994 Sun Microsystems, Inc.
|
||||
//%% (c) Copyright 1993, 1994 Novell, Inc.
|
||||
//%% $XConsortium: tt_db_message_info_utils.C /main/3 1995/10/20 16:41:22 rswiston $
|
||||
/*
|
||||
* tt_db_message_info.cc - Defines the _Tt_db_message_info utilities.
|
||||
*
|
||||
* Copyright (c) 1992 by Sun Microsystems, Inc.
|
||||
*/
|
||||
|
||||
#include "tt_db_message_info_utils.h"
|
||||
|
||||
implement_ptr_to(_Tt_db_message_info)
|
||||
19
cde/lib/tt/bin/ttdbserverd/tt_db_message_info_utils.h
Normal file
19
cde/lib/tt/bin/ttdbserverd/tt_db_message_info_utils.h
Normal file
@@ -0,0 +1,19 @@
|
||||
/*%% (c) Copyright 1993, 1994 Hewlett-Packard Company */
|
||||
/*%% (c) Copyright 1993, 1994 International Business Machines Corp. */
|
||||
/*%% (c) Copyright 1993, 1994 Sun Microsystems, Inc. */
|
||||
/*%% (c) Copyright 1993, 1994 Novell, Inc. */
|
||||
/*%% $XConsortium: tt_db_message_info_utils.h /main/3 1995/10/20 16:41:33 rswiston $ */
|
||||
/*
|
||||
* tt_db_message_info_utils.h - Declare the _Tt_db_message_info utilities.
|
||||
*
|
||||
* Copyright (c) 1992 by Sun Microsystems, Inc.
|
||||
*/
|
||||
|
||||
#ifndef _TT_DB_MESSAGE_INFO_UTILS_H
|
||||
#define _TT_DB_MESSAGE_INFO_UTILS_H
|
||||
|
||||
#include "tt_db_message_info.h"
|
||||
|
||||
declare_ptr_to(_Tt_db_message_info)
|
||||
|
||||
#endif // _TT_DB_MESSAGE_INFO_UTILS_H
|
||||
92
cde/lib/tt/bin/ttdbserverd/tt_db_msg_q_lock.C
Normal file
92
cde/lib/tt/bin/ttdbserverd/tt_db_msg_q_lock.C
Normal file
@@ -0,0 +1,92 @@
|
||||
//%% (c) Copyright 1993, 1994 Hewlett-Packard Company
|
||||
//%% (c) Copyright 1993, 1994 International Business Machines Corp.
|
||||
//%% (c) Copyright 1993, 1994 Sun Microsystems, Inc.
|
||||
//%% (c) Copyright 1993, 1994 Novell, Inc.
|
||||
//%% $XConsortium: tt_db_msg_q_lock.C /main/3 1995/10/20 16:41:41 rswiston $
|
||||
/*
|
||||
* tt_db_msg_q_lock.cc - Defines a class for managing the locking and unlocking
|
||||
* the message queue for a particular file.
|
||||
*
|
||||
* Copyright (c) 1992 by Sun Microsystems, Inc.
|
||||
*/
|
||||
|
||||
#include "tt_db_msg_q_lock.h"
|
||||
#include "tt_db_msg_q_lock_entry_utils.h"
|
||||
|
||||
_Tt_db_msg_q_lock_entry_list_ptr*
|
||||
_Tt_db_msg_q_lock::locks = (_Tt_db_msg_q_lock_entry_list_ptr *)NULL;
|
||||
|
||||
_Tt_db_msg_q_lock::_Tt_db_msg_q_lock ()
|
||||
{
|
||||
if (!locks) {
|
||||
locks = new _Tt_db_msg_q_lock_entry_list_ptr;
|
||||
*locks = new _Tt_db_msg_q_lock_entry_list;
|
||||
}
|
||||
}
|
||||
|
||||
_Tt_db_msg_q_lock::~_Tt_db_msg_q_lock ()
|
||||
{
|
||||
}
|
||||
|
||||
bool_t _Tt_db_msg_q_lock::testAndSetLock (const _Tt_string &client_id,
|
||||
const _Tt_string &file_key)
|
||||
{
|
||||
bool_t found = FALSE;
|
||||
bool_t results = FALSE;
|
||||
|
||||
_Tt_db_msg_q_lock_entry_list_cursor locks_cursor(*locks);
|
||||
while (locks_cursor.next()) {
|
||||
if ((locks_cursor->clientID == client_id) &&
|
||||
(locks_cursor->fileKey == file_key)) {
|
||||
found = TRUE;
|
||||
results = TRUE;
|
||||
break;
|
||||
}
|
||||
else if (locks_cursor->fileKey == file_key) {
|
||||
found = TRUE;
|
||||
results = FALSE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!found) {
|
||||
_Tt_db_msg_q_lock_entry_ptr lock = new _Tt_db_msg_q_lock_entry;
|
||||
lock->clientID = (char *)client_id;
|
||||
lock->fileKey = (char *)file_key;
|
||||
(*locks)->append(lock);
|
||||
|
||||
results = TRUE;
|
||||
}
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
void _Tt_db_msg_q_lock::unsetLock (const _Tt_string &client_id,
|
||||
const _Tt_string &file_key)
|
||||
{
|
||||
_Tt_db_msg_q_lock_entry_list_cursor locks_cursor(*locks);
|
||||
while (locks_cursor.next()) {
|
||||
if ((locks_cursor->clientID == client_id) &&
|
||||
(locks_cursor->fileKey == file_key)) {
|
||||
locks_cursor.remove();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool_t _Tt_db_msg_q_lock::checkLock (const _Tt_string &client_id,
|
||||
const _Tt_string &file_key)
|
||||
{
|
||||
bool_t found = FALSE;
|
||||
|
||||
_Tt_db_msg_q_lock_entry_list_cursor locks_cursor(*locks);
|
||||
while (locks_cursor.next()) {
|
||||
if ((locks_cursor->clientID == client_id) &&
|
||||
(locks_cursor->fileKey == file_key)) {
|
||||
found = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return found;
|
||||
}
|
||||
41
cde/lib/tt/bin/ttdbserverd/tt_db_msg_q_lock.h
Normal file
41
cde/lib/tt/bin/ttdbserverd/tt_db_msg_q_lock.h
Normal file
@@ -0,0 +1,41 @@
|
||||
/*%% (c) Copyright 1993, 1994 Hewlett-Packard Company */
|
||||
/*%% (c) Copyright 1993, 1994 International Business Machines Corp. */
|
||||
/*%% (c) Copyright 1993, 1994 Sun Microsystems, Inc. */
|
||||
/*%% (c) Copyright 1993, 1994 Novell, Inc. */
|
||||
/*%% $XConsortium: tt_db_msg_q_lock.h /main/3 1995/10/20 16:41:50 rswiston $ */
|
||||
/*
|
||||
* tt_db_msg_q_lock.h - Defines a class for managing the locking and unlocking
|
||||
* the message queue for a particular file.
|
||||
*
|
||||
* Copyright (c) 1992 by Sun Microsystems, Inc.
|
||||
*/
|
||||
|
||||
#ifndef _TT_DB_MSG_Q_LOCK_H
|
||||
#define _TT_DB_MSG_Q_LOCK_H
|
||||
|
||||
#include "util/tt_new.h"
|
||||
#include "util/tt_string.h"
|
||||
#include "tt_db_msg_q_lock_entry_utils.h"
|
||||
|
||||
class _Tt_db_msg_q_lock : public _Tt_allocated {
|
||||
public:
|
||||
_Tt_db_msg_q_lock ();
|
||||
~_Tt_db_msg_q_lock ();
|
||||
|
||||
bool_t testAndSetLock (const _Tt_string &client_id,
|
||||
const _Tt_string &file_key);
|
||||
void unsetLock (const _Tt_string &client_id,
|
||||
const _Tt_string &file_key);
|
||||
bool_t checkLock (const _Tt_string &client_id,
|
||||
const _Tt_string &file_key);
|
||||
|
||||
void unsetAllLocks ()
|
||||
{
|
||||
(*locks)->flush();
|
||||
}
|
||||
|
||||
private:
|
||||
static _Tt_db_msg_q_lock_entry_list_ptr *locks;
|
||||
};
|
||||
|
||||
#endif /* _TT_DB_MSG_Q_LOCK_H */
|
||||
28
cde/lib/tt/bin/ttdbserverd/tt_db_msg_q_lock_entry.h
Normal file
28
cde/lib/tt/bin/ttdbserverd/tt_db_msg_q_lock_entry.h
Normal file
@@ -0,0 +1,28 @@
|
||||
/*%% (c) Copyright 1993, 1994 Hewlett-Packard Company */
|
||||
/*%% (c) Copyright 1993, 1994 International Business Machines Corp. */
|
||||
/*%% (c) Copyright 1993, 1994 Sun Microsystems, Inc. */
|
||||
/*%% (c) Copyright 1993, 1994 Novell, Inc. */
|
||||
/*%% $XConsortium: tt_db_msg_q_lock_entry.h /main/3 1995/10/20 16:41:58 rswiston $ */
|
||||
/*
|
||||
* tt_db_msg_q_lock_entry.h - Defines a class for holding lock information in the
|
||||
* locks list in the tt_db_msg_q_lock class.
|
||||
*
|
||||
* Copyright (c) 1992 by Sun Microsystems, Inc.
|
||||
*/
|
||||
|
||||
#ifndef _TT_DB_MSG_Q_LOCK_ENTRY_H
|
||||
#define _TT_DB_MSG_Q_LOCK_ENTRY_H
|
||||
|
||||
#include "util/tt_object.h"
|
||||
#include "util/tt_string.h"
|
||||
|
||||
class _Tt_db_msg_q_lock_entry : public _Tt_object {
|
||||
public:
|
||||
_Tt_db_msg_q_lock_entry () {}
|
||||
~_Tt_db_msg_q_lock_entry () {}
|
||||
|
||||
_Tt_string clientID;
|
||||
_Tt_string fileKey;
|
||||
};
|
||||
|
||||
#endif /* _TT_DB_MSG_Q_LOCK_ENTRY_H */
|
||||
15
cde/lib/tt/bin/ttdbserverd/tt_db_msg_q_lock_entry_utils.C
Normal file
15
cde/lib/tt/bin/ttdbserverd/tt_db_msg_q_lock_entry_utils.C
Normal file
@@ -0,0 +1,15 @@
|
||||
//%% (c) Copyright 1993, 1994 Hewlett-Packard Company
|
||||
//%% (c) Copyright 1993, 1994 International Business Machines Corp.
|
||||
//%% (c) Copyright 1993, 1994 Sun Microsystems, Inc.
|
||||
//%% (c) Copyright 1993, 1994 Novell, Inc.
|
||||
//%% $XConsortium: tt_db_msg_q_lock_entry_utils.C /main/3 1995/10/20 16:42:08 rswiston $
|
||||
/*
|
||||
* tt_db_msg_q_lock_entry_utils.cc - Defines the _Tt_db_msg_q_lock_entry
|
||||
* utilities.
|
||||
*
|
||||
* Copyright (c) 1992 by Sun Microsystems, Inc.
|
||||
*/
|
||||
|
||||
#include "tt_db_msg_q_lock_entry_utils.h"
|
||||
|
||||
implement_list_of(_Tt_db_msg_q_lock_entry)
|
||||
21
cde/lib/tt/bin/ttdbserverd/tt_db_msg_q_lock_entry_utils.h
Normal file
21
cde/lib/tt/bin/ttdbserverd/tt_db_msg_q_lock_entry_utils.h
Normal file
@@ -0,0 +1,21 @@
|
||||
/*%% (c) Copyright 1993, 1994 Hewlett-Packard Company */
|
||||
/*%% (c) Copyright 1993, 1994 International Business Machines Corp. */
|
||||
/*%% (c) Copyright 1993, 1994 Sun Microsystems, Inc. */
|
||||
/*%% (c) Copyright 1993, 1994 Novell, Inc. */
|
||||
/*%% $XConsortium: tt_db_msg_q_lock_entry_utils.h /main/3 1995/10/20 16:42:16 rswiston $ */
|
||||
/*
|
||||
* tt_db_msg_q_lock_entry_utils.h - Declares the _Tt_db_msg_q_lock_entry class
|
||||
* utilities.
|
||||
*
|
||||
* Copyright (c) 1992 by Sun Microsystems, Inc.
|
||||
*/
|
||||
|
||||
#ifndef _TT_DB_MSG_Q_LOCK_ENTRY_UTILS_H
|
||||
#define _TT_DB_MSG_Q_LOCK_ENTRY_UTILS_H
|
||||
|
||||
#include "util/tt_list.h"
|
||||
#include "tt_db_msg_q_lock_entry.h"
|
||||
|
||||
declare_list_of(_Tt_db_msg_q_lock_entry)
|
||||
|
||||
#endif // _TT_DB_MSG_Q_LOCK_ENTRY_UTILS_H
|
||||
267
cde/lib/tt/bin/ttdbserverd/tt_db_partition_global_map_ref.C
Normal file
267
cde/lib/tt/bin/ttdbserverd/tt_db_partition_global_map_ref.C
Normal file
@@ -0,0 +1,267 @@
|
||||
//%% (c) Copyright 1993, 1994 Hewlett-Packard Company
|
||||
//%% (c) Copyright 1993, 1994 International Business Machines Corp.
|
||||
//%% (c) Copyright 1993, 1994 Sun Microsystems, Inc.
|
||||
//%% (c) Copyright 1993, 1994 Novell, Inc.
|
||||
//%% $XConsortium: tt_db_partition_global_map_ref.C /main/3 1995/10/20 16:42:23 rswiston $
|
||||
/*
|
||||
* tt_db_partition_global_map_ref.cc - Define the TT DB server partition
|
||||
* global map ref class.
|
||||
*
|
||||
* Copyright (c) 1992 by Sun Microsystems, Inc.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <errno.h>
|
||||
#include <sys/stat.h>
|
||||
#include "util/tt_port.h"
|
||||
#include "util/tt_gettext.h"
|
||||
#include "tt_isam_file_utils.h"
|
||||
#include "tt_isam_record_utils.h"
|
||||
#include "tt_db_partition_redirection_map.h"
|
||||
#include "tt_db_partition_global_map_ref.h"
|
||||
#include "tt_db_server_consts.h"
|
||||
|
||||
extern _Tt_db_partition_redirection_map *db_pr_map;
|
||||
extern FILE *errstr;
|
||||
|
||||
_Tt_db_server_db_table_ptr*
|
||||
_Tt_db_partition_global_map_ref::dbPartitionMap = (_Tt_db_server_db_table_ptr *)
|
||||
NULL;
|
||||
|
||||
_Tt_db_partition_global_map_ref::_Tt_db_partition_global_map_ref ()
|
||||
{
|
||||
if (!dbPartitionMap) {
|
||||
dbPartitionMap = new _Tt_db_server_db_table_ptr;
|
||||
*dbPartitionMap = new _Tt_db_server_db_table ((_Tt_object_table_keyfn)
|
||||
&dbPartitionMapKey);
|
||||
}
|
||||
}
|
||||
|
||||
_Tt_db_partition_global_map_ref::~_Tt_db_partition_global_map_ref ()
|
||||
{
|
||||
// The static table is freed up when the application dies.
|
||||
}
|
||||
|
||||
void _Tt_db_partition_global_map_ref::addDB (_Tt_db_server_db_ptr &db)
|
||||
{
|
||||
(*dbPartitionMap)->insert(db);
|
||||
}
|
||||
|
||||
void _Tt_db_partition_global_map_ref::removeDB (const _Tt_string &partition)
|
||||
{
|
||||
(*dbPartitionMap)->remove(partition);
|
||||
}
|
||||
|
||||
_Tt_db_server_db_ptr
|
||||
_Tt_db_partition_global_map_ref::getDB (const _Tt_string &partition)
|
||||
{
|
||||
_Tt_string real_partition = db_pr_map->findEntry(partition);
|
||||
if (real_partition.is_null() || !real_partition.len()) {
|
||||
real_partition = partition;
|
||||
}
|
||||
|
||||
_Tt_db_server_db_ptr db_ptr = (*dbPartitionMap)->lookup(real_partition);
|
||||
if (db_ptr.is_null()) {
|
||||
if (!checkForOldDB(real_partition)) {
|
||||
db_ptr = new _Tt_db_server_db(real_partition);
|
||||
|
||||
_Tt_db_results results = db_ptr->getDBResults();
|
||||
if (results != TT_DB_OK) {
|
||||
_tt_syslog(errstr, LOG_ERR,
|
||||
"_Tt_db_server_db(\"%s\"): %d (%s)",
|
||||
(char *)real_partition, results,
|
||||
(char *)db_ptr->getLastFileAccessed());
|
||||
db_ptr = (_Tt_db_server_db *)NULL;
|
||||
}
|
||||
else {
|
||||
addDB(db_ptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return db_ptr;
|
||||
}
|
||||
|
||||
_Tt_string
|
||||
_Tt_db_partition_global_map_ref::dbPartitionMapKey (_Tt_object_ptr &db)
|
||||
{
|
||||
return (((_Tt_db_server_db *)db.c_pointer())->getPartition());
|
||||
}
|
||||
|
||||
bool_t
|
||||
_Tt_db_partition_global_map_ref::checkForOldDB(const _Tt_string &partition)
|
||||
{
|
||||
if (checkForOldDBTable(partition, "docoid_path", TT_DB_FILE_TABLE_FILE)) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (checkForOldDBTable(partition,
|
||||
"oid_container",
|
||||
TT_DB_FILE_OBJECT_MAP_FILE)) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (checkForOldDBTable(partition, "oid_prop", TT_DB_PROPERTY_TABLE_FILE)) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (checkForOldDBTable(partition, "oid_access", TT_DB_ACCESS_TABLE_FILE)) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool_t _Tt_db_partition_global_map_ref
|
||||
::checkForOldDBTable (const _Tt_string &partition,
|
||||
const _Tt_string &old_file,
|
||||
const _Tt_string &new_file)
|
||||
{
|
||||
static bool_t old_db_diagnostic = FALSE;
|
||||
|
||||
_Tt_string base_dir = (char *)partition;
|
||||
if (base_dir[base_dir.len()-1] != '/') {
|
||||
base_dir = base_dir.cat("/");
|
||||
}
|
||||
base_dir = base_dir.cat("TT_DB/");
|
||||
|
||||
_Tt_string old_db_file(base_dir);
|
||||
old_db_file = old_db_file.cat(old_file);
|
||||
|
||||
_Tt_string new_db_file(base_dir);
|
||||
new_db_file = new_db_file.cat(new_file);
|
||||
|
||||
_Tt_string old_db_index(old_db_file);
|
||||
old_db_index = old_db_index.cat(".ind");
|
||||
|
||||
_Tt_string new_db_index(new_db_file);
|
||||
new_db_index = new_db_index.cat(".ind");
|
||||
|
||||
struct stat stat_buf;
|
||||
int temp_errno = 0;
|
||||
|
||||
// If there is no new DB and there is an old DB...
|
||||
if (stat((char *)new_db_index, &stat_buf) &&
|
||||
((temp_errno = errno) == ENOENT) &&
|
||||
!stat((char *)old_db_index, &stat_buf)) {
|
||||
if (new_file == TT_DB_ACCESS_TABLE_FILE) {
|
||||
_Tt_isam_file_ptr old_db_table =
|
||||
new _Tt_isam_file(old_db_file, ISFIXLEN+ISINOUT+ISEXCLLOCK);
|
||||
_Tt_isam_file_ptr access_table;
|
||||
|
||||
int results = old_db_table->getErrorStatus();
|
||||
|
||||
if (!results) {
|
||||
_Tt_isam_key_descriptor_ptr access_key = new _Tt_isam_key_descriptor;
|
||||
access_key->addKeyPart(0, TT_DB_KEY_LENGTH, BINTYPE);
|
||||
|
||||
access_table =
|
||||
new _Tt_isam_file(new_db_file,
|
||||
TT_DB_KEY_LENGTH+3*TT_DB_LONG_SIZE,
|
||||
TT_DB_KEY_LENGTH+3*TT_DB_LONG_SIZE,
|
||||
access_key,
|
||||
ISFIXLEN+ISINOUT+ISEXCLLOCK);
|
||||
results = access_table->getErrorStatus();
|
||||
|
||||
if (!results) {
|
||||
results = access_table->writeMagicString(_Tt_string(TT_DB_VERSION));
|
||||
}
|
||||
}
|
||||
|
||||
if (!results) {
|
||||
_Tt_isam_record_ptr new_record = access_table->getEmptyRecord();
|
||||
_Tt_isam_record_ptr record;
|
||||
|
||||
while (!results) {
|
||||
record = old_db_table->readRecord(ISNEXT);
|
||||
results = old_db_table->getErrorStatus();
|
||||
|
||||
if (!results) {
|
||||
memset((char *)new_record->getRecord(),
|
||||
'\0',
|
||||
new_record->getLength());
|
||||
|
||||
memcpy((char *)new_record->getRecord(),
|
||||
(char *)record->getRecord(),
|
||||
TT_DB_KEY_LENGTH);
|
||||
|
||||
short n_user = *(short *)
|
||||
((char *)record->getRecord()+TT_DB_KEY_LENGTH);
|
||||
long user = (long)ntohs(n_user);
|
||||
u_long nl_user = htonl(user);
|
||||
memcpy((char *)new_record->getRecord()+TT_DB_ACCESS_USER_OFFSET,
|
||||
(char *)&nl_user,
|
||||
TT_DB_LONG_SIZE);
|
||||
|
||||
short n_group = *(short *)
|
||||
((char *)record->getRecord()+
|
||||
TT_DB_KEY_LENGTH+TT_DB_SHORT_SIZE);
|
||||
long group = (long)ntohs(n_group);
|
||||
u_long nl_group = htonl(group);
|
||||
memcpy((char *)new_record->getRecord()+TT_DB_ACCESS_GROUP_OFFSET,
|
||||
(char *)&nl_group,
|
||||
TT_DB_LONG_SIZE);
|
||||
|
||||
short n_mode = *(short *)
|
||||
((char *)record->getRecord()+
|
||||
TT_DB_KEY_LENGTH+2*TT_DB_SHORT_SIZE);
|
||||
long mode = (long)ntohs(n_mode);
|
||||
u_long nl_mode = htonl(mode);
|
||||
memcpy((char *)new_record->getRecord()+TT_DB_ACCESS_MODE_OFFSET,
|
||||
(char *)&nl_mode,
|
||||
TT_DB_LONG_SIZE);
|
||||
|
||||
results = access_table->writeRecord(new_record);
|
||||
}
|
||||
}
|
||||
|
||||
if (results == EENDFILE) {
|
||||
results = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (!results) {
|
||||
(void)iserase((char *)old_db_file);
|
||||
}
|
||||
|
||||
if (results) {
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (isrename((char *)old_db_file, (char *)new_db_file)) {
|
||||
return TRUE;
|
||||
}
|
||||
else {
|
||||
_Tt_isam_file_ptr new_db_table =
|
||||
new _Tt_isam_file(new_db_file, ISFIXLEN+ISINOUT+ISEXCLLOCK);
|
||||
int results = new_db_table->getErrorStatus();
|
||||
|
||||
if (results) {
|
||||
new_db_table = new _Tt_isam_file(new_db_file,
|
||||
ISVARLEN+ISINOUT+ISEXCLLOCK);
|
||||
results = new_db_table->getErrorStatus();
|
||||
}
|
||||
|
||||
if (!results) {
|
||||
(void)new_db_table->writeMagicString(TT_DB_VERSION);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (temp_errno && (temp_errno != ENOENT)) {
|
||||
return TRUE;
|
||||
}
|
||||
else if (!stat((char *)old_db_index, &stat_buf)) {
|
||||
if (old_db_diagnostic == FALSE) {
|
||||
_tt_syslog(errstr, LOG_ERR,
|
||||
catgets(_ttcatd, 5, 5,
|
||||
"Any data written using an old (<= 1.0.2) "
|
||||
"rpc.ttdbserverd after using a new (>= 1.1) "
|
||||
"rpc.ttdbserverd will be ignored"));
|
||||
old_db_diagnostic = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
44
cde/lib/tt/bin/ttdbserverd/tt_db_partition_global_map_ref.h
Normal file
44
cde/lib/tt/bin/ttdbserverd/tt_db_partition_global_map_ref.h
Normal file
@@ -0,0 +1,44 @@
|
||||
/*%% (c) Copyright 1993, 1994 Hewlett-Packard Company */
|
||||
/*%% (c) Copyright 1993, 1994 International Business Machines Corp. */
|
||||
/*%% (c) Copyright 1993, 1994 Sun Microsystems, Inc. */
|
||||
/*%% (c) Copyright 1993, 1994 Novell, Inc. */
|
||||
/*%% $XConsortium: tt_db_partition_global_map_ref.h /main/3 1995/10/20 16:42:31 rswiston $ */
|
||||
/*
|
||||
* tt_db_partition_global_map_ref.h - Declare the TT DB server partition
|
||||
* global map ref class. This class contains
|
||||
* a global map that provides a partition to
|
||||
* DB server DB mapping. This way only one set
|
||||
* of ISAM file connections is made per partition
|
||||
* on a particular machine.
|
||||
*
|
||||
* Copyright (c) 1992 by Sun Microsystems, Inc.
|
||||
*/
|
||||
|
||||
#ifndef _TT_DB_PARTITION_GLOBAL_MAP_REF_H
|
||||
#define _TT_DB_PARTITION_GLOBAL_MAP_REF_H
|
||||
|
||||
#include "util/tt_new.h"
|
||||
#include "util/tt_string.h"
|
||||
#include "tt_db_server_db_utils.h"
|
||||
|
||||
class _Tt_db_partition_global_map_ref : public _Tt_allocated {
|
||||
public:
|
||||
_Tt_db_partition_global_map_ref ();
|
||||
~_Tt_db_partition_global_map_ref ();
|
||||
|
||||
void addDB (_Tt_db_server_db_ptr &db);
|
||||
void removeDB (const _Tt_string &partition);
|
||||
_Tt_db_server_db_ptr getDB (const _Tt_string &partition);
|
||||
|
||||
static _Tt_string dbPartitionMapKey (_Tt_object_ptr &db);
|
||||
|
||||
private:
|
||||
static _Tt_db_server_db_table_ptr *dbPartitionMap;
|
||||
|
||||
bool_t checkForOldDB (const _Tt_string&);
|
||||
bool_t checkForOldDBTable (const _Tt_string&,
|
||||
const _Tt_string&,
|
||||
const _Tt_string&);
|
||||
};
|
||||
|
||||
#endif // _TT_DB_PARTITION_GLOBAL_MAP_REF_H
|
||||
51
cde/lib/tt/bin/ttdbserverd/tt_db_partition_redirection_map.C
Normal file
51
cde/lib/tt/bin/ttdbserverd/tt_db_partition_redirection_map.C
Normal file
@@ -0,0 +1,51 @@
|
||||
//%% (c) Copyright 1993, 1994 Hewlett-Packard Company
|
||||
//%% (c) Copyright 1993, 1994 International Business Machines Corp.
|
||||
//%% (c) Copyright 1993, 1994 Sun Microsystems, Inc.
|
||||
//%% (c) Copyright 1993, 1994 Novell, Inc.
|
||||
//%% $XConsortium: tt_db_partition_redirection_map.C /main/3 1995/10/20 16:42:41 rswiston $
|
||||
/*
|
||||
* Tool Talk Utility - tt_partition_redirection_map.cc
|
||||
*
|
||||
* Copyright (c) 1990 by Sun Microsystems, Inc.
|
||||
*
|
||||
* Defines a partition redirection map. A global version
|
||||
* of this object is in declared db_server_svc.cc.
|
||||
*/
|
||||
|
||||
#include "tt_db_partition_redirection_map.h"
|
||||
#include "util/tt_string_map.h"
|
||||
#include "util/tt_map_entry.h"
|
||||
#include "util/tt_path.h"
|
||||
|
||||
const char *pr_map_file = "partition_map";
|
||||
const char *pr_map_env = "_SUN_TT_PARTITION_MAP";
|
||||
const char *pr_cde_map_env = "TT_PARTITION_MAP";
|
||||
|
||||
_Tt_db_partition_redirection_map::
|
||||
_Tt_db_partition_redirection_map ()
|
||||
{
|
||||
map = new _Tt_string_map((_Tt_object_table_keyfn)
|
||||
&_Tt_map_entry::getPathAddress);
|
||||
}
|
||||
|
||||
_Tt_db_partition_redirection_map::
|
||||
~_Tt_db_partition_redirection_map ()
|
||||
{
|
||||
}
|
||||
|
||||
_Tt_string _Tt_db_partition_redirection_map::
|
||||
findEntry(const _Tt_string &address)
|
||||
{
|
||||
return map->findEntry(address);
|
||||
}
|
||||
|
||||
void _Tt_db_partition_redirection_map::refresh ()
|
||||
{
|
||||
// give preference to the cde named setting
|
||||
const char* pr_map_env_to_use = (getenv(pr_cde_map_env) ? pr_cde_map_env : pr_map_env);
|
||||
|
||||
_Tt_string path = _tt_user_path (pr_map_file, pr_map_env_to_use, TRUE);
|
||||
if (path.len()) {
|
||||
map->loadFile(path);
|
||||
}
|
||||
}
|
||||
31
cde/lib/tt/bin/ttdbserverd/tt_db_partition_redirection_map.h
Normal file
31
cde/lib/tt/bin/ttdbserverd/tt_db_partition_redirection_map.h
Normal file
@@ -0,0 +1,31 @@
|
||||
/*%% (c) Copyright 1993, 1994 Hewlett-Packard Company */
|
||||
/*%% (c) Copyright 1993, 1994 International Business Machines Corp. */
|
||||
/*%% (c) Copyright 1993, 1994 Sun Microsystems, Inc. */
|
||||
/*%% (c) Copyright 1993, 1994 Novell, Inc. */
|
||||
/*%% $XConsortium: tt_db_partition_redirection_map.h /main/3 1995/10/20 16:42:49 rswiston $ */
|
||||
/*
|
||||
* Tool Talk Utility - tt_partition_redirection_map.h
|
||||
*
|
||||
* Copyright (c) 1990 by Sun Microsystems, Inc.
|
||||
*
|
||||
* Declares a partition redirection map. A global version
|
||||
* of this object is declared in db_server_svc.cc.
|
||||
*/
|
||||
|
||||
#ifndef _TT_PARTITION_REDIRECTION_MAP_H
|
||||
#define _TT_PARTITION_REDIRECTION_MAP_H
|
||||
|
||||
#include "util/tt_new.h"
|
||||
#include "util/tt_string_map_utils.h"
|
||||
|
||||
class _Tt_db_partition_redirection_map : public _Tt_allocated {
|
||||
public:
|
||||
_Tt_db_partition_redirection_map ();
|
||||
~_Tt_db_partition_redirection_map ();
|
||||
void refresh ();
|
||||
_Tt_string findEntry(const _Tt_string &address);
|
||||
private:
|
||||
_Tt_string_map_ptr map;
|
||||
};
|
||||
|
||||
#endif /* _TT_PARTITION_REDIRECTION_MAP_H */
|
||||
1905
cde/lib/tt/bin/ttdbserverd/tt_db_server_db.C
Normal file
1905
cde/lib/tt/bin/ttdbserverd/tt_db_server_db.C
Normal file
File diff suppressed because it is too large
Load Diff
300
cde/lib/tt/bin/ttdbserverd/tt_db_server_db.h
Normal file
300
cde/lib/tt/bin/ttdbserverd/tt_db_server_db.h
Normal file
@@ -0,0 +1,300 @@
|
||||
/*%% (c) Copyright 1993, 1994 Hewlett-Packard Company */
|
||||
/*%% (c) Copyright 1993, 1994 International Business Machines Corp. */
|
||||
/*%% (c) Copyright 1993, 1994 Sun Microsystems, Inc. */
|
||||
/*%% (c) Copyright 1993, 1994 Novell, Inc. */
|
||||
/*%% $XConsortium: tt_db_server_db.h /main/3 1995/10/20 16:43:06 rswiston $ */
|
||||
/*
|
||||
* tt_db_server_db.h - Defines the TT DB server database. This class
|
||||
* represents the actual data model currently being
|
||||
* used to store ToolTalk databse information.
|
||||
*
|
||||
* The actual database schema is the following:
|
||||
*
|
||||
* Table Fields Length Description
|
||||
* ----- ------ ------ -----------
|
||||
* File Table Contains the names of all
|
||||
* the that have properties
|
||||
* or objects in the db.
|
||||
*
|
||||
* File Key TT_DB_KEY_LENGTH Unique key that is used
|
||||
* to search (16 bytes) for
|
||||
* a file's properties and
|
||||
* objects in the other
|
||||
* tables.
|
||||
*
|
||||
* File Name Variable up to The name of the file.
|
||||
* MAXPATHLEN (256)
|
||||
*
|
||||
* Table Fields Length Description
|
||||
* ----- ------ ------ -----------
|
||||
* File-object Contains all of the
|
||||
* Map mappings of file keys to
|
||||
* the keys of the objects
|
||||
* in the file.
|
||||
*
|
||||
* Object Key TT_DB_KEY_LENGTH Unique key of an object
|
||||
* in a file.
|
||||
*
|
||||
* File Key TT_DB_KEY_LENGTH Unique key of a file.
|
||||
*
|
||||
* Table Fields Length Description
|
||||
* ----- ------ ------ -----------
|
||||
* Property Contains all of the
|
||||
* Table properties corresponding
|
||||
* to files and objects in
|
||||
* the db.
|
||||
*
|
||||
* Key TT_DB_KEY_LENGTH Unique key of an object
|
||||
* or a file.
|
||||
*
|
||||
* Property Name TT_DB_PROP_NAME_LENGTH The name of a file or
|
||||
* object property.
|
||||
*
|
||||
* Property Variable up to The value of the property.
|
||||
* ISMAXRECLEN.
|
||||
*
|
||||
* Table Fields Length Description
|
||||
* ----- ------ ------ -----------
|
||||
* Access Table Contains the access
|
||||
* privileges of all the
|
||||
* files and objects in
|
||||
* the db.
|
||||
*
|
||||
* Key TT_DB_KEY_LENGTH Unique key of an object
|
||||
* or a file.
|
||||
*
|
||||
* User ID XDR_LONG_SIZE The user ID of the owner
|
||||
* of the object or file.
|
||||
*
|
||||
* Group ID XDR_LONG_SIZE The group ID of the
|
||||
* object or file.
|
||||
*
|
||||
* Mode XDR_LONG_SIZE The access mode of the
|
||||
* object or file.
|
||||
*
|
||||
* Copyright (c) 1992 by Sun Microsystems, Inc.
|
||||
*/
|
||||
|
||||
#ifndef _TT_DB_SERVER_DB_H
|
||||
#define _TT_DB_SERVER_DB_H
|
||||
|
||||
#include "util/tt_object.h"
|
||||
#include "util/tt_string.h"
|
||||
#include "tt_isam_file_utils.h"
|
||||
#include "db/tt_db_access_utils.h"
|
||||
#include "db/tt_db_key_utils.h"
|
||||
#include "db/tt_db_property_utils.h"
|
||||
#include "db/tt_db_results.h"
|
||||
|
||||
class _Tt_db_server_db : public _Tt_object {
|
||||
public:
|
||||
_Tt_db_server_db ();
|
||||
_Tt_db_server_db (const _Tt_string&);
|
||||
~_Tt_db_server_db ();
|
||||
|
||||
// Returns the partition this DB object is connected to
|
||||
_Tt_string getPartition () const
|
||||
{
|
||||
_Tt_string partition = (char *)dbPartition;
|
||||
return partition;
|
||||
}
|
||||
|
||||
// Creates a file in the TT DB and sets the access permissions of the
|
||||
// file.
|
||||
_Tt_db_results createFile (const _Tt_string &file,
|
||||
const _Tt_db_access_ptr &access);
|
||||
|
||||
// Creates an object in the TT DB. If the file is not in the database,
|
||||
// the file will be created using the "file_access" argument to specify
|
||||
// its access permission. If no file is specified, this is a special
|
||||
// object being created just to hold a forward pointer.
|
||||
_Tt_db_results createObject (const _Tt_string &file,
|
||||
const _Tt_string &objid,
|
||||
const _Tt_db_access_ptr &object_access,
|
||||
const _Tt_db_access_ptr &file_access);
|
||||
|
||||
_Tt_db_results removeFile (const _Tt_string &file,
|
||||
const _Tt_db_access_ptr &access);
|
||||
|
||||
_Tt_db_results removeObject (const _Tt_string &objid,
|
||||
const _Tt_db_access_ptr &access);
|
||||
|
||||
_Tt_db_results moveFile (const _Tt_string &file,
|
||||
const _Tt_string &new_file,
|
||||
const _Tt_db_access_ptr &access);
|
||||
|
||||
_Tt_db_results setFileProperty (const _Tt_string &file,
|
||||
const _Tt_db_property_ptr &property,
|
||||
const _Tt_db_access_ptr &access);
|
||||
|
||||
_Tt_db_results setFileProperties (const _Tt_string &file,
|
||||
const _Tt_db_property_list_ptr &properties,
|
||||
const _Tt_db_access_ptr &access);
|
||||
|
||||
_Tt_db_results addFileProperty (const _Tt_string &file,
|
||||
const _Tt_db_property_ptr &property,
|
||||
bool_t unique,
|
||||
const _Tt_db_access_ptr &access);
|
||||
|
||||
_Tt_db_results deleteFileProperty (const _Tt_string &file,
|
||||
const _Tt_db_property_ptr &property,
|
||||
const _Tt_db_access_ptr &access);
|
||||
|
||||
_Tt_db_results deleteFileProperties (const _Tt_string &file,
|
||||
const _Tt_db_access_ptr &access);
|
||||
|
||||
_Tt_db_results getFileProperty (const _Tt_string &file,
|
||||
const _Tt_string &name,
|
||||
const _Tt_db_access_ptr &access,
|
||||
_Tt_db_property_ptr &property);
|
||||
|
||||
_Tt_db_results getFileProperties (const _Tt_string &file,
|
||||
const _Tt_db_access_ptr &access,
|
||||
_Tt_db_property_list_ptr &properties);
|
||||
|
||||
_Tt_db_results getFileObjects (const _Tt_string &file,
|
||||
const _Tt_db_access_ptr &access,
|
||||
_Tt_string_list_ptr &objids);
|
||||
|
||||
_Tt_db_results deleteFileObjects (const _Tt_string &file,
|
||||
const _Tt_db_access_ptr &access);
|
||||
|
||||
_Tt_db_results setFileFile (const _Tt_string &file,
|
||||
const _Tt_string &new_file,
|
||||
const _Tt_db_access_ptr &access);
|
||||
|
||||
// If the specified file is a directory, this returns all of the
|
||||
// file names stored in the database that are in the directory.
|
||||
// The file itself is also in the return list.
|
||||
_Tt_db_results getFileChildren (const _Tt_string &file,
|
||||
_Tt_string_list_ptr &children);
|
||||
|
||||
_Tt_db_results setFileAccess (const _Tt_string &file,
|
||||
const _Tt_db_access_ptr &new_access,
|
||||
const _Tt_db_access_ptr &access);
|
||||
|
||||
_Tt_db_results getFileAccess (const _Tt_string &file,
|
||||
const _Tt_db_access_ptr &access,
|
||||
_Tt_db_access_ptr ¤t_access);
|
||||
|
||||
_Tt_db_results setObjectProperty (const _Tt_string &objid,
|
||||
const _Tt_db_property_ptr &property,
|
||||
const _Tt_db_access_ptr &access);
|
||||
|
||||
_Tt_db_results
|
||||
setObjectProperties (const _Tt_string &objid,
|
||||
const _Tt_db_property_list_ptr &properties,
|
||||
const _Tt_db_access_ptr &access);
|
||||
|
||||
_Tt_db_results addObjectProperty (const _Tt_string &objid,
|
||||
const _Tt_db_property_ptr &property,
|
||||
bool_t unique,
|
||||
const _Tt_db_access_ptr &access);
|
||||
|
||||
_Tt_db_results deleteObjectProperty (const _Tt_string &objid,
|
||||
const _Tt_db_property_ptr &property,
|
||||
const _Tt_db_access_ptr &access);
|
||||
|
||||
_Tt_db_results deleteObjectProperties (const _Tt_string &objid,
|
||||
const _Tt_db_access_ptr &access);
|
||||
|
||||
_Tt_db_results getObjectProperty (const _Tt_string &objid,
|
||||
const _Tt_string &name,
|
||||
const _Tt_db_access_ptr &access,
|
||||
_Tt_db_property_ptr &property);
|
||||
|
||||
_Tt_db_results
|
||||
getObjectProperties (const _Tt_string &objid,
|
||||
const _Tt_db_access_ptr &access,
|
||||
_Tt_db_property_list_ptr &properties);
|
||||
|
||||
// Used to facilitate moving an object to a new file on the same
|
||||
// partition. The file specified must be on the partition this DB
|
||||
// server object is connected to. If the file is not in the database,
|
||||
// it will be created with the access permissions of the object.
|
||||
_Tt_db_results setObjectFile (const _Tt_string &objid,
|
||||
const _Tt_string &file,
|
||||
const _Tt_db_access_ptr &access);
|
||||
|
||||
_Tt_db_results getObjectFile (const _Tt_string &objid,
|
||||
const _Tt_db_access_ptr &access,
|
||||
_Tt_string &file);
|
||||
|
||||
_Tt_db_results setObjectAccess (const _Tt_string &objid,
|
||||
const _Tt_db_access_ptr &new_access,
|
||||
const _Tt_db_access_ptr &access);
|
||||
|
||||
_Tt_db_results getObjectAccess (const _Tt_string &objid,
|
||||
const _Tt_db_access_ptr &access,
|
||||
_Tt_db_access_ptr ¤t_access);
|
||||
|
||||
_Tt_db_results getDBResults () const
|
||||
{
|
||||
return dbResults;
|
||||
}
|
||||
|
||||
const _Tt_string &getLastFileAccessed () const
|
||||
{
|
||||
return dbLastFileAccessed;
|
||||
}
|
||||
|
||||
private:
|
||||
_Tt_isam_key_descriptor_ptr fileTableFileKey;
|
||||
_Tt_isam_key_descriptor_ptr fileTableFilePathKey;
|
||||
_Tt_isam_file_ptr fileTable;
|
||||
|
||||
_Tt_isam_key_descriptor_ptr fileObjectMapFileKey;
|
||||
_Tt_isam_key_descriptor_ptr fileObjectMapObjectKey;
|
||||
_Tt_isam_file_ptr fileObjectMap;
|
||||
|
||||
_Tt_isam_key_descriptor_ptr propertyTablePropertyKey;
|
||||
_Tt_isam_file_ptr propertyTable;
|
||||
|
||||
_Tt_isam_key_descriptor_ptr accessTableKey;
|
||||
_Tt_isam_file_ptr accessTable;
|
||||
|
||||
_Tt_string dbHostname;
|
||||
_Tt_string dbPartition;
|
||||
_Tt_db_results dbResults;
|
||||
_Tt_string dbLastFileAccessed;
|
||||
|
||||
void connectToDB (const _Tt_string &partition);
|
||||
|
||||
_Tt_db_results verifyObjectAccess (const _Tt_string&,
|
||||
const _Tt_db_access_ptr&,
|
||||
bool_t=FALSE,
|
||||
bool_t=FALSE);
|
||||
_Tt_db_results verifyUserOnlyObjectAccess (const _Tt_string&,
|
||||
const _Tt_db_access_ptr&);
|
||||
_Tt_db_results verifyAccess (const _Tt_string&,
|
||||
const _Tt_db_access_ptr&,
|
||||
bool_t=FALSE,
|
||||
bool_t=FALSE);
|
||||
_Tt_db_results getFileKey (const _Tt_string&, _Tt_string&);
|
||||
_Tt_string getObjectKey (const _Tt_string&);
|
||||
|
||||
_Tt_db_results setProperty (const _Tt_string&, const _Tt_db_property_ptr&);
|
||||
_Tt_db_results setProperties (const _Tt_string&,
|
||||
const _Tt_db_property_list_ptr&);
|
||||
_Tt_db_results addProperty (const _Tt_string&,
|
||||
const _Tt_db_property_ptr&,
|
||||
bool_t);
|
||||
_Tt_db_results deleteProperty (const _Tt_string&,
|
||||
const _Tt_db_property_ptr&);
|
||||
_Tt_db_results deleteProperties (const _Tt_string&,
|
||||
bool_t=FALSE);
|
||||
_Tt_db_results getProperty (const _Tt_string&,
|
||||
const _Tt_string&,
|
||||
_Tt_db_property_ptr&);
|
||||
_Tt_db_results getProperties (const _Tt_string&,
|
||||
_Tt_db_property_list_ptr&);
|
||||
_Tt_db_results setAccess (const _Tt_string&, const _Tt_db_access_ptr&);
|
||||
_Tt_db_results getAccess (const _Tt_string&, _Tt_db_access_ptr&);
|
||||
_Tt_db_results getFile (const _Tt_string&, _Tt_string&);
|
||||
|
||||
_Tt_db_results addPropertyValue (const _Tt_string&,
|
||||
const _Tt_string&,
|
||||
const _Tt_string&);
|
||||
};
|
||||
|
||||
#endif /* _TT_DB_SERVER_DB_H */
|
||||
15
cde/lib/tt/bin/ttdbserverd/tt_db_server_db_utils.C
Normal file
15
cde/lib/tt/bin/ttdbserverd/tt_db_server_db_utils.C
Normal file
@@ -0,0 +1,15 @@
|
||||
//%% (c) Copyright 1993, 1994 Hewlett-Packard Company
|
||||
//%% (c) Copyright 1993, 1994 International Business Machines Corp.
|
||||
//%% (c) Copyright 1993, 1994 Sun Microsystems, Inc.
|
||||
//%% (c) Copyright 1993, 1994 Novell, Inc.
|
||||
//%% $XConsortium: tt_db_server_db_utils.C /main/3 1995/10/20 16:43:15 rswiston $
|
||||
/*
|
||||
* tt_db_server_db_utils.cc - Defines the _Tt_db_server_db utilities.
|
||||
*
|
||||
* Copyright (c) 1992 by Sun Microsystems, Inc.
|
||||
*/
|
||||
|
||||
#include "tt_db_server_db_utils.h"
|
||||
|
||||
implement_list_of(_Tt_db_server_db)
|
||||
implement_table_of(_Tt_db_server_db)
|
||||
22
cde/lib/tt/bin/ttdbserverd/tt_db_server_db_utils.h
Normal file
22
cde/lib/tt/bin/ttdbserverd/tt_db_server_db_utils.h
Normal file
@@ -0,0 +1,22 @@
|
||||
/*%% (c) Copyright 1993, 1994 Hewlett-Packard Company */
|
||||
/*%% (c) Copyright 1993, 1994 International Business Machines Corp. */
|
||||
/*%% (c) Copyright 1993, 1994 Sun Microsystems, Inc. */
|
||||
/*%% (c) Copyright 1993, 1994 Novell, Inc. */
|
||||
/*%% $XConsortium: tt_db_server_db_utils.h /main/3 1995/10/20 16:43:23 rswiston $ */
|
||||
/*
|
||||
* tt_db_server_db_utils.h - Declare the _Tt_db_server_db utilities.
|
||||
*
|
||||
* Copyright (c) 1992 by Sun Microsystems, Inc.
|
||||
*/
|
||||
|
||||
#ifndef _TT_DB_SERVER_DB_UTILS_H
|
||||
#define _TT_DB_SERVER_DB_UTILS_H
|
||||
|
||||
#include "util/tt_list.h"
|
||||
#include "util/tt_table.h"
|
||||
#include "tt_db_server_db.h"
|
||||
|
||||
declare_list_of(_Tt_db_server_db)
|
||||
declare_table_of(_Tt_db_server_db)
|
||||
|
||||
#endif // _TT_DB_SERVER_DB_UTILS_H
|
||||
41
cde/lib/tt/bin/ttdbserverd/tt_isam.h
Normal file
41
cde/lib/tt/bin/ttdbserverd/tt_isam.h
Normal file
@@ -0,0 +1,41 @@
|
||||
/*%% (c) Copyright 1993, 1994 Hewlett-Packard Company */
|
||||
/*%% (c) Copyright 1993, 1994 International Business Machines Corp. */
|
||||
/*%% (c) Copyright 1993, 1994 Sun Microsystems, Inc. */
|
||||
/*%% (c) Copyright 1993, 1994 Novell, Inc. */
|
||||
/*%% $XConsortium: tt_isam.h /main/3 1995/10/20 16:43:31 rswiston $ */
|
||||
/*
|
||||
* @(#)tt_isam.h 1.9 95/04/10
|
||||
*
|
||||
* TT version of the NetISAM isam.h file.
|
||||
*
|
||||
* Copyright (c) 1992 by Sun Microsystems, Inc.
|
||||
*/
|
||||
|
||||
#ifndef _TT_ISAM_H
|
||||
#define _TT_ISAM_H
|
||||
|
||||
#include <isam.h>
|
||||
|
||||
extern "C" { int isaddindex(int, keydesc*); }
|
||||
extern "C" { int isbuild(const char*, int, keydesc*, int); }
|
||||
extern "C" { int isclose(int); }
|
||||
extern "C" { int iscntl(int, int, ...); }
|
||||
extern "C" { int isdelcurr(int); }
|
||||
extern "C" { int isdelrec(int, long); }
|
||||
extern "C" { int iserase(const char*); }
|
||||
extern "C" { int isfsync(int); }
|
||||
extern "C" { int isindexinfo(int, keydesc *, int); }
|
||||
extern "C" { int isopen(const char*, int); }
|
||||
extern "C" { int isread(int, char*, int); }
|
||||
extern "C" { int isrename(char*, char*); }
|
||||
extern "C" { int isrewcurr(int, char*); }
|
||||
extern "C" { int isrewrec(int, long, char*); }
|
||||
extern "C" { int isstart(int, keydesc*, int, char*, int); }
|
||||
extern "C" { int iswrite(int, char*); }
|
||||
extern "C" { int islock(int); }
|
||||
extern "C" { int isunlock(int); }
|
||||
extern "C" { int isgarbage(char *); }
|
||||
extern "C" { int isgetcurpos(int isfd, int *len, char **buf); }
|
||||
extern "C" { int issetcurpos(int isfd, char *buf); }
|
||||
|
||||
#endif /* _TT_ISAM_H */
|
||||
378
cde/lib/tt/bin/ttdbserverd/tt_isam_file.C
Normal file
378
cde/lib/tt/bin/ttdbserverd/tt_isam_file.C
Normal file
@@ -0,0 +1,378 @@
|
||||
//%% (c) Copyright 1993, 1994 Hewlett-Packard Company
|
||||
//%% (c) Copyright 1993, 1994 International Business Machines Corp.
|
||||
//%% (c) Copyright 1993, 1994 Sun Microsystems, Inc.
|
||||
//%% (c) Copyright 1993, 1994 Novell, Inc.
|
||||
//%% $XConsortium: tt_isam_file.C /main/3 1995/10/20 16:43:39 rswiston $
|
||||
/*
|
||||
* tt_isam_file.cc - Defines the TT ISAM file class. This class simplifies
|
||||
* opening, closing, reading and writing an ISAM file.
|
||||
*
|
||||
* Copyright (c) 1992 by Sun Microsystems, Inc.
|
||||
*/
|
||||
|
||||
#include "tt_isam_file.h"
|
||||
#include "util/tt_port.h"
|
||||
#include "dm_access_cache.h"
|
||||
|
||||
extern FILE *errstr;
|
||||
|
||||
bool_t _Tt_isam_file::isamFatalErrorHandlerSet = FALSE;
|
||||
|
||||
_Tt_isam_file::_Tt_isam_file (const _Tt_string &file, int mode)
|
||||
{
|
||||
setTtISAMFileDefaults();
|
||||
fileName = file;
|
||||
fileMode = mode;
|
||||
|
||||
if ((fileDescriptor = cached_isopen(file, mode)) != -1) {
|
||||
getISAMFileInfo();
|
||||
}
|
||||
else {
|
||||
getStatusInfo();
|
||||
}
|
||||
}
|
||||
|
||||
_Tt_isam_file
|
||||
::_Tt_isam_file (const _Tt_string &file,
|
||||
int max_record_length,
|
||||
int min_record_length,
|
||||
_Tt_isam_key_descriptor_ptr primary_key_descriptor,
|
||||
int mode)
|
||||
{
|
||||
setTtISAMFileDefaults();
|
||||
fileName = file;
|
||||
fileMode = mode;
|
||||
|
||||
if ((fileDescriptor = cached_isopen(file, mode)) == -1) {
|
||||
newFlag = TRUE;
|
||||
isreclen = min_record_length;
|
||||
fileDescriptor = isbuild(file,
|
||||
max_record_length,
|
||||
primary_key_descriptor->getKeyDescriptor(),
|
||||
mode);
|
||||
}
|
||||
|
||||
if (fileDescriptor != -1) {
|
||||
getISAMFileInfo();
|
||||
}
|
||||
else {
|
||||
errorStatus = iserrno;
|
||||
currentRecordLength = -1;
|
||||
currentRecordNumber = -1;
|
||||
}
|
||||
}
|
||||
|
||||
void _Tt_isam_file::setTtISAMFileDefaults ()
|
||||
{
|
||||
eraseFlag = FALSE;
|
||||
fileName = (char *)NULL;
|
||||
fileMode = 0;
|
||||
keyDescriptorList = new _Tt_isam_key_descriptor_list;
|
||||
newFlag = FALSE;
|
||||
|
||||
if (!isamFatalErrorHandlerSet) {
|
||||
isamFatalErrorHandlerSet = TRUE;
|
||||
(void)iscntl(ALLISFD, ISCNTL_FATAL, &_Tt_isam_file::isamFatalErrorHandler);
|
||||
}
|
||||
|
||||
iserrno = 0;
|
||||
}
|
||||
|
||||
_Tt_isam_file::~_Tt_isam_file ()
|
||||
{
|
||||
if (eraseFlag) {
|
||||
(void)iserase(fileName);
|
||||
}
|
||||
else {
|
||||
(void)cached_isclose(fileDescriptor);
|
||||
}
|
||||
}
|
||||
|
||||
void _Tt_isam_file::setErase (bool_t flag)
|
||||
{
|
||||
eraseFlag = flag;
|
||||
}
|
||||
|
||||
int _Tt_isam_file::sync ()
|
||||
{
|
||||
iserrno = 0;
|
||||
|
||||
(void)isfsync(fileDescriptor);
|
||||
|
||||
errorStatus = iserrno;
|
||||
return errorStatus;
|
||||
}
|
||||
|
||||
//
|
||||
// islock and isunlock are not supported by mini-isam
|
||||
//
|
||||
//int _Tt_isam_file::lock ()
|
||||
//{
|
||||
// iserrno = 0;
|
||||
//
|
||||
// (void)islock(fileDescriptor);
|
||||
//
|
||||
// errorStatus = iserrno;
|
||||
// return errorStatus;
|
||||
//}
|
||||
//
|
||||
//int _Tt_isam_file::unlock ()
|
||||
//{
|
||||
// iserrno = 0;
|
||||
//
|
||||
// (void)isunlock(fileDescriptor);
|
||||
//
|
||||
// errorStatus = iserrno;
|
||||
// return errorStatus;
|
||||
//}
|
||||
|
||||
int _Tt_isam_file::rename (const _Tt_string &new_file)
|
||||
{
|
||||
iserrno = 0;
|
||||
|
||||
int results = isrename(fileName, new_file);
|
||||
|
||||
errorStatus = iserrno;
|
||||
if (!results) {
|
||||
fileName = new_file;
|
||||
newFlag = FALSE;
|
||||
|
||||
if ((fileDescriptor = cached_isopen(new_file, fileMode)) != -1) {
|
||||
getISAMFileInfo();
|
||||
}
|
||||
else {
|
||||
getStatusInfo();
|
||||
}
|
||||
}
|
||||
|
||||
return errorStatus;
|
||||
}
|
||||
|
||||
int _Tt_isam_file::addIndex (_Tt_isam_key_descriptor_ptr key_descriptor)
|
||||
{
|
||||
iserrno = 0;
|
||||
|
||||
int results = isaddindex(fileDescriptor, key_descriptor->getKeyDescriptor());
|
||||
|
||||
errorStatus = iserrno;
|
||||
if (!results) {
|
||||
getISAMFileInfo();
|
||||
}
|
||||
|
||||
return errorStatus;
|
||||
}
|
||||
|
||||
_Tt_isam_record_ptr _Tt_isam_file::getEmptyRecord ()
|
||||
{
|
||||
return (new _Tt_isam_record(keyDescriptorList,
|
||||
maxRecordLength,
|
||||
minRecordLength));
|
||||
}
|
||||
|
||||
int _Tt_isam_file
|
||||
::findStartRecord (const _Tt_isam_key_descriptor_ptr &key_descriptor,
|
||||
int length,
|
||||
const _Tt_isam_record_ptr &record,
|
||||
int mode)
|
||||
{
|
||||
iserrno = 0;
|
||||
|
||||
(void)isstart(fileDescriptor,
|
||||
key_descriptor->getKeyDescriptor(),
|
||||
length,
|
||||
(char *)record->getRecord(),
|
||||
mode);
|
||||
|
||||
getStatusInfo();
|
||||
return errorStatus;
|
||||
}
|
||||
|
||||
_Tt_isam_record_ptr _Tt_isam_file::readRecord (int mode)
|
||||
{
|
||||
iserrno = 0;
|
||||
|
||||
_Tt_isam_record_ptr record = (_Tt_isam_record *)NULL;
|
||||
_Tt_string record_buffer(maxRecordLength);
|
||||
int results = isread(fileDescriptor,
|
||||
(char *)record_buffer,
|
||||
mode);
|
||||
|
||||
getStatusInfo();
|
||||
if (!results) {
|
||||
record = getFullRecord(record_buffer);
|
||||
}
|
||||
|
||||
return record;
|
||||
}
|
||||
|
||||
int _Tt_isam_file::readRecord (int mode,
|
||||
const _Tt_isam_record_ptr &record)
|
||||
{
|
||||
iserrno = 0;
|
||||
|
||||
int results = isread(fileDescriptor, (char *)record->getRecord(), mode);
|
||||
|
||||
getStatusInfo();
|
||||
if (!results) {
|
||||
record->setLength(currentRecordLength);
|
||||
}
|
||||
|
||||
return errorStatus;
|
||||
}
|
||||
|
||||
int _Tt_isam_file::updateCurrentRecord (const _Tt_isam_record_ptr &record)
|
||||
{
|
||||
iserrno = 0;
|
||||
|
||||
isreclen = record->getLength();
|
||||
(void)isrewcurr(fileDescriptor, (char *)record->getRecord());
|
||||
|
||||
getStatusInfo();
|
||||
return errorStatus;
|
||||
}
|
||||
|
||||
int
|
||||
_Tt_isam_file::updateRecord (long recnum, const _Tt_isam_record_ptr &record)
|
||||
{
|
||||
iserrno = 0;
|
||||
|
||||
isreclen = record->getLength();
|
||||
(void)isrewrec(fileDescriptor, recnum, (char *)record->getRecord());
|
||||
|
||||
getStatusInfo();
|
||||
return errorStatus;
|
||||
}
|
||||
|
||||
int _Tt_isam_file::writeRecord (const _Tt_isam_record_ptr &record)
|
||||
{
|
||||
iserrno = 0;
|
||||
|
||||
isreclen = record->getLength();
|
||||
(void)iswrite(fileDescriptor, (char *)record->getRecord());
|
||||
|
||||
getStatusInfo();
|
||||
return errorStatus;
|
||||
}
|
||||
|
||||
int _Tt_isam_file::deleteCurrentRecord ()
|
||||
{
|
||||
iserrno = 0;
|
||||
|
||||
(void)isdelcurr(fileDescriptor);
|
||||
|
||||
getStatusInfo();
|
||||
return errorStatus;
|
||||
}
|
||||
|
||||
int _Tt_isam_file::deleteRecord (long recnum)
|
||||
{
|
||||
iserrno = 0;
|
||||
|
||||
(void)isdelrec(fileDescriptor, recnum);
|
||||
|
||||
getStatusInfo();
|
||||
return errorStatus;
|
||||
}
|
||||
|
||||
int _Tt_isam_file::writeMagicString (const _Tt_string &magic_string)
|
||||
{
|
||||
iserrno = 0;
|
||||
|
||||
(void)iscntl(fileDescriptor,
|
||||
ISCNTL_APPLMAGIC_WRITE,
|
||||
(char *)magic_string);
|
||||
|
||||
errorStatus = iserrno;
|
||||
return errorStatus;
|
||||
}
|
||||
|
||||
_Tt_string _Tt_isam_file::readMagicString ()
|
||||
{
|
||||
iserrno = 0;
|
||||
|
||||
_Tt_string magic_string_bytes(ISAPPLMAGICLEN);
|
||||
memset((char *)magic_string_bytes, '\0', ISAPPLMAGICLEN);
|
||||
|
||||
(void)iscntl(fileDescriptor,
|
||||
ISCNTL_APPLMAGIC_READ,
|
||||
(char *)magic_string_bytes);
|
||||
|
||||
errorStatus = iserrno;
|
||||
|
||||
_Tt_string magic_string = (char *)magic_string_bytes;
|
||||
return magic_string;
|
||||
}
|
||||
|
||||
int _Tt_isam_file::setFatalErrorHandler (FatalErrorHandlerFunction function)
|
||||
{
|
||||
iserrno = 0;
|
||||
|
||||
(void)iscntl(fileDescriptor, ISCNTL_FATAL, function);
|
||||
|
||||
errorStatus = iserrno;
|
||||
return errorStatus;
|
||||
}
|
||||
|
||||
_Tt_isam_record_ptr
|
||||
_Tt_isam_file::getFullRecord (const _Tt_string &record_buffer)
|
||||
{
|
||||
_Tt_isam_record_ptr record_ptr = new _Tt_isam_record(keyDescriptorList,
|
||||
maxRecordLength,
|
||||
minRecordLength);
|
||||
record_ptr->setBytes(0, currentRecordLength, record_buffer);
|
||||
record_ptr->setLength(currentRecordLength);
|
||||
|
||||
return record_ptr;
|
||||
}
|
||||
|
||||
void _Tt_isam_file::getISAMFileInfo ()
|
||||
{
|
||||
iserrno = 0;
|
||||
|
||||
struct dictinfo file_info;
|
||||
struct keydesc key_descriptor;
|
||||
short num_keys;
|
||||
int results = isindexinfo(fileDescriptor,
|
||||
(keydesc *)&file_info,
|
||||
0);
|
||||
|
||||
getStatusInfo();
|
||||
if (!results) {
|
||||
keyDescriptorList->flush();
|
||||
|
||||
// If the file has var length records, the MSB is set in the di_nkeys
|
||||
// field. This guarantees to turn the bit off...
|
||||
num_keys = file_info.di_nkeys & ~DICTVARLENBIT;
|
||||
|
||||
if (num_keys == 1) {
|
||||
(void)isindexinfo(fileDescriptor, &key_descriptor, 1);
|
||||
if (key_descriptor.k_nparts == 0) {
|
||||
num_keys = 0;
|
||||
}
|
||||
else {
|
||||
num_keys = 1;
|
||||
}
|
||||
}
|
||||
|
||||
maxRecordLength = file_info.di_recsize;
|
||||
minRecordLength = isreclen;
|
||||
|
||||
for (int i=1; i <= num_keys; i++) {
|
||||
isindexinfo(fileDescriptor, &key_descriptor, i);
|
||||
|
||||
_Tt_isam_key_descriptor_ptr key_descriptor_ptr =
|
||||
new _Tt_isam_key_descriptor;
|
||||
key_descriptor_ptr->keyDescriptor = key_descriptor;
|
||||
|
||||
keyDescriptorList->append(key_descriptor_ptr);
|
||||
}
|
||||
|
||||
errorStatus = iserrno;
|
||||
}
|
||||
}
|
||||
|
||||
int _Tt_isam_file::isamFatalErrorHandler (char *msg)
|
||||
{
|
||||
_tt_syslog(errstr, LOG_ERR, "NetISAM: %s", msg);
|
||||
return 1;
|
||||
}
|
||||
122
cde/lib/tt/bin/ttdbserverd/tt_isam_file.h
Normal file
122
cde/lib/tt/bin/ttdbserverd/tt_isam_file.h
Normal file
@@ -0,0 +1,122 @@
|
||||
/*%% (c) Copyright 1993, 1994 Hewlett-Packard Company */
|
||||
/*%% (c) Copyright 1993, 1994 International Business Machines Corp. */
|
||||
/*%% (c) Copyright 1993, 1994 Sun Microsystems, Inc. */
|
||||
/*%% (c) Copyright 1993, 1994 Novell, Inc. */
|
||||
/*%% $XConsortium: tt_isam_file.h /main/3 1995/10/20 16:43:47 rswiston $ */
|
||||
/*
|
||||
* tt_isam_file.h - Defines the TT ISAM file class. This class simplifies
|
||||
* opening, closing, reading and writing an ISAM file.
|
||||
*
|
||||
* Copyright (c) 1992 by Sun Microsystems, Inc.
|
||||
*/
|
||||
|
||||
#ifndef _TT_ISAM_FILE_H
|
||||
#define _TT_ISAM_FILE_H
|
||||
|
||||
#include "util/tt_object.h"
|
||||
#include "tt_isam.h"
|
||||
#include "tt_isam_key_descriptor_utils.h"
|
||||
#include "tt_isam_record_utils.h"
|
||||
|
||||
typedef int (*FatalErrorHandlerFunction) (char *);
|
||||
|
||||
class _Tt_isam_file : public _Tt_object {
|
||||
public:
|
||||
// Dummy constructor needed to make _tt_isam_file_utils.cc happy
|
||||
_Tt_isam_file () {}
|
||||
|
||||
// Real constructors
|
||||
_Tt_isam_file (const _Tt_string &file, int mode);
|
||||
_Tt_isam_file (const _Tt_string &file,
|
||||
int max_record_length,
|
||||
int min_record_length,
|
||||
_Tt_isam_key_descriptor_ptr primary_key_descriptor,
|
||||
int mode);
|
||||
~_Tt_isam_file ();
|
||||
|
||||
void setErase (bool_t);
|
||||
int sync ();
|
||||
|
||||
//
|
||||
// islock and isunlock are not supported by mini-isam
|
||||
//
|
||||
// int lock ();
|
||||
// int unlock ();
|
||||
|
||||
int rename (const _Tt_string&);
|
||||
|
||||
int addIndex (_Tt_isam_key_descriptor_ptr);
|
||||
_Tt_isam_record_ptr getEmptyRecord ();
|
||||
|
||||
int findStartRecord (const _Tt_isam_key_descriptor_ptr &key_descriptor,
|
||||
int length,
|
||||
const _Tt_isam_record_ptr &record,
|
||||
int mode);
|
||||
|
||||
_Tt_isam_record_ptr readRecord (int mode);
|
||||
int readRecord (int mode, const _Tt_isam_record_ptr&);
|
||||
int updateCurrentRecord (const _Tt_isam_record_ptr&);
|
||||
int updateRecord (long recnum, const _Tt_isam_record_ptr&);
|
||||
int writeRecord (const _Tt_isam_record_ptr&);
|
||||
int deleteCurrentRecord ();
|
||||
int deleteRecord (long recnum);
|
||||
|
||||
int writeMagicString (const _Tt_string&);
|
||||
_Tt_string readMagicString ();
|
||||
|
||||
int setFatalErrorHandler (FatalErrorHandlerFunction);
|
||||
|
||||
long getLastRecordNumber () const
|
||||
{
|
||||
return currentRecordNumber;
|
||||
}
|
||||
|
||||
int getFileDescriptor () const
|
||||
{
|
||||
return fileDescriptor;
|
||||
}
|
||||
|
||||
const _Tt_string &getName () const
|
||||
{
|
||||
return fileName;
|
||||
}
|
||||
|
||||
int getErrorStatus () const
|
||||
{
|
||||
return errorStatus;
|
||||
}
|
||||
|
||||
bool_t isNew () const
|
||||
{
|
||||
return newFlag;
|
||||
}
|
||||
|
||||
private:
|
||||
int currentRecordLength;
|
||||
long currentRecordNumber;
|
||||
bool_t eraseFlag;
|
||||
int errorStatus;
|
||||
int fileDescriptor;
|
||||
_Tt_string fileName;
|
||||
int fileMode;
|
||||
_Tt_isam_key_descriptor_list_ptr keyDescriptorList;
|
||||
int maxRecordLength;
|
||||
int minRecordLength;
|
||||
bool_t newFlag;
|
||||
|
||||
void setTtISAMFileDefaults ();
|
||||
_Tt_isam_record_ptr getFullRecord (const _Tt_string&);
|
||||
void getISAMFileInfo ();
|
||||
|
||||
void getStatusInfo ()
|
||||
{
|
||||
currentRecordLength = isreclen;
|
||||
currentRecordNumber = isrecnum;
|
||||
errorStatus = iserrno;
|
||||
}
|
||||
|
||||
static bool_t isamFatalErrorHandlerSet;
|
||||
static int isamFatalErrorHandler (char *message);
|
||||
};
|
||||
|
||||
#endif /* _TT_ISAM_FILE_H */
|
||||
15
cde/lib/tt/bin/ttdbserverd/tt_isam_file_utils.C
Normal file
15
cde/lib/tt/bin/ttdbserverd/tt_isam_file_utils.C
Normal file
@@ -0,0 +1,15 @@
|
||||
//%% (c) Copyright 1993, 1994 Hewlett-Packard Company
|
||||
//%% (c) Copyright 1993, 1994 International Business Machines Corp.
|
||||
//%% (c) Copyright 1993, 1994 Sun Microsystems, Inc.
|
||||
//%% (c) Copyright 1993, 1994 Novell, Inc.
|
||||
//%% $XConsortium: tt_isam_file_utils.C /main/3 1995/10/20 16:43:55 rswiston $
|
||||
/*
|
||||
* tt_isam_file_utils.cc - Defines the _Tt_isam_file class
|
||||
* utilities.
|
||||
*
|
||||
* Copyright (c) 1992 by Sun Microsystems, Inc.
|
||||
*/
|
||||
|
||||
#include "tt_isam_file_utils.h"
|
||||
|
||||
implement_ptr_to(_Tt_isam_file)
|
||||
20
cde/lib/tt/bin/ttdbserverd/tt_isam_file_utils.h
Normal file
20
cde/lib/tt/bin/ttdbserverd/tt_isam_file_utils.h
Normal file
@@ -0,0 +1,20 @@
|
||||
/*%% (c) Copyright 1993, 1994 Hewlett-Packard Company */
|
||||
/*%% (c) Copyright 1993, 1994 International Business Machines Corp. */
|
||||
/*%% (c) Copyright 1993, 1994 Sun Microsystems, Inc. */
|
||||
/*%% (c) Copyright 1993, 1994 Novell, Inc. */
|
||||
/*%% $XConsortium: tt_isam_file_utils.h /main/3 1995/10/20 16:44:05 rswiston $ */
|
||||
/*
|
||||
* tt_isam_file_utils.h - Declares the _Tt_isam_file class
|
||||
* utilities.
|
||||
*
|
||||
* Copyright (c) 1992 by Sun Microsystems, Inc.
|
||||
*/
|
||||
|
||||
#ifndef _TT_ISAM_FILE_UTILS_H
|
||||
#define _TT_ISAM_FILE_UTILS_H
|
||||
|
||||
#include "tt_isam_file.h"
|
||||
|
||||
declare_ptr_to(_Tt_isam_file)
|
||||
|
||||
#endif // _TT_ISAM_FILE_UTILS_H
|
||||
85
cde/lib/tt/bin/ttdbserverd/tt_isam_key_descriptor.C
Normal file
85
cde/lib/tt/bin/ttdbserverd/tt_isam_key_descriptor.C
Normal file
@@ -0,0 +1,85 @@
|
||||
//%% (c) Copyright 1993, 1994 Hewlett-Packard Company
|
||||
//%% (c) Copyright 1993, 1994 International Business Machines Corp.
|
||||
//%% (c) Copyright 1993, 1994 Sun Microsystems, Inc.
|
||||
//%% (c) Copyright 1993, 1994 Novell, Inc.
|
||||
//%% $XConsortium: tt_isam_key_descriptor.C /main/3 1995/10/20 16:44:18 rswiston $
|
||||
/*
|
||||
* tt_isam_key_descriptor.cc - Defines the TT ISAM key descriptor class.
|
||||
* This class is used to hold the information required
|
||||
* to create a NetISAM key descriptor. It also makes
|
||||
* it very easy to construct the descriptor.
|
||||
*
|
||||
* Copyright (c) 1992 by Sun Microsystems, Inc.
|
||||
*/
|
||||
|
||||
#include "tt_isam_key_descriptor.h"
|
||||
|
||||
_Tt_isam_key_descriptor::_Tt_isam_key_descriptor ()
|
||||
{
|
||||
keyDescriptor.k_flags = 0;
|
||||
keyDescriptor.k_nparts = 0;
|
||||
}
|
||||
|
||||
_Tt_isam_key_descriptor::~_Tt_isam_key_descriptor ()
|
||||
{
|
||||
}
|
||||
|
||||
short _Tt_isam_key_descriptor::addKeyPart (short start, short length, short type)
|
||||
{
|
||||
int index = -1;
|
||||
|
||||
if (keyDescriptor.k_nparts < NPARTS-1) {
|
||||
index = keyDescriptor.k_nparts;
|
||||
|
||||
keyDescriptor.k_part [index].kp_start = start;
|
||||
keyDescriptor.k_part [index].kp_leng = length;
|
||||
keyDescriptor.k_part [index].kp_type = type;
|
||||
|
||||
keyDescriptor.k_nparts++;
|
||||
}
|
||||
|
||||
return index;
|
||||
}
|
||||
|
||||
short _Tt_isam_key_descriptor::setKeyPart (short index,
|
||||
short start,
|
||||
short length,
|
||||
short type)
|
||||
{
|
||||
short error = 0;
|
||||
|
||||
if ((index > -1) && (index < keyDescriptor.k_nparts)) {
|
||||
keyDescriptor.k_part [index].kp_start = start;
|
||||
keyDescriptor.k_part [index].kp_leng = length;
|
||||
keyDescriptor.k_part [index].kp_type = type;
|
||||
}
|
||||
else {
|
||||
error = -1;
|
||||
}
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
short _Tt_isam_key_descriptor::getKeyPart (short index,
|
||||
short &start,
|
||||
short &length,
|
||||
short &type) const
|
||||
{
|
||||
short error = 0;
|
||||
|
||||
if ((index > -1) && (index < keyDescriptor.k_nparts)) {
|
||||
|
||||
|
||||
start = keyDescriptor.k_part [index].kp_start;
|
||||
length = keyDescriptor.k_part [index].kp_leng;
|
||||
type = keyDescriptor.k_part [index].kp_type;
|
||||
}
|
||||
else {
|
||||
start = -1;
|
||||
length = -1;
|
||||
type = -1;
|
||||
error = -1;
|
||||
}
|
||||
|
||||
return error;
|
||||
}
|
||||
82
cde/lib/tt/bin/ttdbserverd/tt_isam_key_descriptor.h
Normal file
82
cde/lib/tt/bin/ttdbserverd/tt_isam_key_descriptor.h
Normal file
@@ -0,0 +1,82 @@
|
||||
/*%% (c) Copyright 1993, 1994 Hewlett-Packard Company */
|
||||
/*%% (c) Copyright 1993, 1994 International Business Machines Corp. */
|
||||
/*%% (c) Copyright 1993, 1994 Sun Microsystems, Inc. */
|
||||
/*%% (c) Copyright 1993, 1994 Novell, Inc. */
|
||||
/*%% $XConsortium: tt_isam_key_descriptor.h /main/3 1995/10/20 16:44:29 rswiston $ */
|
||||
/*
|
||||
* tt_isam_key_descriptor.h - Defines the TT ISAM key descriptor class.
|
||||
* This class is used to hold the information required
|
||||
* to create a NetISAM key descriptor. It also makes
|
||||
* it very easy to construct the descriptor.
|
||||
*
|
||||
* Copyright (c) 1992 by Sun Microsystems, Inc.
|
||||
*/
|
||||
|
||||
#ifndef _TT_ISAM_KEY_DESCRIPTOR_H
|
||||
#define _TT_ISAM_KEY_DESCRIPTOR_H
|
||||
|
||||
#include "util/tt_object.h"
|
||||
#include "tt_isam.h"
|
||||
|
||||
class _Tt_isam_key_descriptor : public _Tt_object {
|
||||
public:
|
||||
_Tt_isam_key_descriptor ();
|
||||
~_Tt_isam_key_descriptor ();
|
||||
|
||||
void setCompress (bool_t flag)
|
||||
{
|
||||
if (flag) {
|
||||
keyDescriptor.k_flags |= COMPRESS;
|
||||
}
|
||||
else {
|
||||
keyDescriptor.k_flags &= (short) (0xFFFF - COMPRESS);
|
||||
}
|
||||
}
|
||||
|
||||
bool_t isCompressSet ()
|
||||
{
|
||||
return ((keyDescriptor.k_flags & COMPRESS) ? TRUE : FALSE);
|
||||
}
|
||||
|
||||
void setDuplicates (bool_t flag)
|
||||
{
|
||||
if (flag) {
|
||||
keyDescriptor.k_flags &= (short) (0xFFFF - ISNODUPS);
|
||||
keyDescriptor.k_flags |= ISDUPS;
|
||||
}
|
||||
else {
|
||||
keyDescriptor.k_flags &= (short) (0xFFFF - ISDUPS);
|
||||
keyDescriptor.k_flags |= ISNODUPS;
|
||||
}
|
||||
}
|
||||
|
||||
bool_t isDuplicatesSet ()
|
||||
{
|
||||
return ((keyDescriptor.k_flags & ISDUPS) ? TRUE : FALSE);
|
||||
}
|
||||
|
||||
short addKeyPart (short start, short length, short type);
|
||||
short setKeyPart (short index, short start, short length, short type);
|
||||
|
||||
short getKeyPart (short index,
|
||||
short &start,
|
||||
short &length,
|
||||
short &type) const;
|
||||
|
||||
short getNumberOfParts () const
|
||||
{
|
||||
return keyDescriptor.k_nparts;
|
||||
}
|
||||
|
||||
private:
|
||||
struct keydesc keyDescriptor;
|
||||
|
||||
keydesc *getKeyDescriptor ()
|
||||
{
|
||||
return &keyDescriptor;
|
||||
}
|
||||
|
||||
friend class _Tt_isam_file;
|
||||
};
|
||||
|
||||
#endif /* _TT_ISAM_KEY_DESCRIPTOR_H */
|
||||
15
cde/lib/tt/bin/ttdbserverd/tt_isam_key_descriptor_utils.C
Normal file
15
cde/lib/tt/bin/ttdbserverd/tt_isam_key_descriptor_utils.C
Normal file
@@ -0,0 +1,15 @@
|
||||
//%% (c) Copyright 1993, 1994 Hewlett-Packard Company
|
||||
//%% (c) Copyright 1993, 1994 International Business Machines Corp.
|
||||
//%% (c) Copyright 1993, 1994 Sun Microsystems, Inc.
|
||||
//%% (c) Copyright 1993, 1994 Novell, Inc.
|
||||
//%% $XConsortium: tt_isam_key_descriptor_utils.C /main/3 1995/10/20 16:44:40 rswiston $
|
||||
/*
|
||||
* tt_isam_key_descriptor_utils.cc - Defines the _Tt_isam_key_descriptor class
|
||||
* utilities.
|
||||
*
|
||||
* Copyright (c) 1992 by Sun Microsystems, Inc.
|
||||
*/
|
||||
|
||||
#include "tt_isam_key_descriptor_utils.h"
|
||||
|
||||
implement_list_of(_Tt_isam_key_descriptor)
|
||||
21
cde/lib/tt/bin/ttdbserverd/tt_isam_key_descriptor_utils.h
Normal file
21
cde/lib/tt/bin/ttdbserverd/tt_isam_key_descriptor_utils.h
Normal file
@@ -0,0 +1,21 @@
|
||||
/*%% (c) Copyright 1993, 1994 Hewlett-Packard Company */
|
||||
/*%% (c) Copyright 1993, 1994 International Business Machines Corp. */
|
||||
/*%% (c) Copyright 1993, 1994 Sun Microsystems, Inc. */
|
||||
/*%% (c) Copyright 1993, 1994 Novell, Inc. */
|
||||
/*%% $XConsortium: tt_isam_key_descriptor_utils.h /main/3 1995/10/20 16:44:48 rswiston $ */
|
||||
/*
|
||||
* tt_isam_key_descriptor_utils.h - Declares the _Tt_isam_key_descriptor class
|
||||
* utilities.
|
||||
*
|
||||
* Copyright (c) 1992 by Sun Microsystems, Inc.
|
||||
*/
|
||||
|
||||
#ifndef _TT_ISAM_KEY_DESCRIPTOR_UTILS_H
|
||||
#define _TT_ISAM_KEY_DESCRIPTOR_UTILS_H
|
||||
|
||||
#include "util/tt_list.h"
|
||||
#include "tt_isam_key_descriptor.h"
|
||||
|
||||
declare_list_of(_Tt_isam_key_descriptor)
|
||||
|
||||
#endif // _TT_ISAM_KEY_DESCRIPTOR_UTILS_H
|
||||
128
cde/lib/tt/bin/ttdbserverd/tt_isam_record.C
Normal file
128
cde/lib/tt/bin/ttdbserverd/tt_isam_record.C
Normal file
@@ -0,0 +1,128 @@
|
||||
//%% (c) Copyright 1993, 1994 Hewlett-Packard Company
|
||||
//%% (c) Copyright 1993, 1994 International Business Machines Corp.
|
||||
//%% (c) Copyright 1993, 1994 Sun Microsystems, Inc.
|
||||
//%% (c) Copyright 1993, 1994 Novell, Inc.
|
||||
//%% $XConsortium: tt_isam_record.C /main/3 1995/10/20 16:44:57 rswiston $
|
||||
/*
|
||||
* tt_isam_record.cc - Defines the TT ISAM record class.
|
||||
*
|
||||
* Copyright (c) 1992 by Sun Microsystems, Inc.
|
||||
*/
|
||||
|
||||
#include "tt_isam_record.h"
|
||||
|
||||
_Tt_isam_record::
|
||||
_Tt_isam_record (const _Tt_isam_key_descriptor_list_ptr &key_descriptor_list,
|
||||
int max_record_length,
|
||||
int min_record_length)
|
||||
{
|
||||
_Tt_string new_buffer(max_record_length);
|
||||
memset((char *)new_buffer, '\0', max_record_length);
|
||||
|
||||
buffer = new_buffer;
|
||||
keyDescriptorList = key_descriptor_list;
|
||||
currentLength = min_record_length;
|
||||
maxLength = max_record_length;
|
||||
minLength = min_record_length;
|
||||
}
|
||||
|
||||
_Tt_isam_record::~_Tt_isam_record ()
|
||||
{
|
||||
}
|
||||
|
||||
int _Tt_isam_record::getNumberOfKeys () const
|
||||
{
|
||||
return keyDescriptorList->count();
|
||||
}
|
||||
|
||||
_Tt_isam_key_descriptor_ptr _Tt_isam_record::getKeyDescriptor (int index) const
|
||||
{
|
||||
_Tt_isam_key_descriptor_ptr descriptor_ptr = (_Tt_isam_key_descriptor *)NULL;
|
||||
|
||||
if ((index > -1) && (index < keyDescriptorList->count())) {
|
||||
descriptor_ptr = (*keyDescriptorList) [index];
|
||||
}
|
||||
|
||||
return descriptor_ptr;
|
||||
}
|
||||
|
||||
_Tt_string _Tt_isam_record::getKeyPartValue (int index, int part) const
|
||||
{
|
||||
_Tt_string value;
|
||||
|
||||
short key_part_start;
|
||||
short key_part_length;
|
||||
short key_part_type;
|
||||
|
||||
if ((index > -1) && (index < keyDescriptorList->count())) {
|
||||
_Tt_isam_key_descriptor_ptr descriptor_ptr = (*keyDescriptorList) [index];
|
||||
|
||||
if ((part > -1) && (part < descriptor_ptr->getNumberOfParts())) {
|
||||
descriptor_ptr->getKeyPart(part,
|
||||
key_part_start,
|
||||
key_part_length,
|
||||
key_part_type);
|
||||
|
||||
_Tt_string key_part(key_part_length);
|
||||
(void)memcpy((char *)key_part,
|
||||
(char *)buffer+key_part_start,
|
||||
key_part_length);
|
||||
value = key_part;
|
||||
}
|
||||
else {
|
||||
_Tt_string null_string((char *)NULL);
|
||||
value = null_string;
|
||||
}
|
||||
}
|
||||
else {
|
||||
_Tt_string null_string((char *)NULL);
|
||||
value = null_string;
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
void _Tt_isam_record::setKeyPartValue (int index,
|
||||
int part,
|
||||
const _Tt_string &value)
|
||||
{
|
||||
short key_part_start;
|
||||
short key_part_length;
|
||||
short key_part_type;
|
||||
|
||||
if ((index > -1) && (index < keyDescriptorList->count())) {
|
||||
_Tt_isam_key_descriptor_ptr descriptor_ptr = (*keyDescriptorList) [index];
|
||||
|
||||
descriptor_ptr->getKeyPart(part,
|
||||
key_part_start,
|
||||
key_part_length,
|
||||
key_part_type);
|
||||
|
||||
int length = ((value.len() < key_part_length) ?
|
||||
value.len() : key_part_length);
|
||||
(void)memcpy((char *)buffer+key_part_start, (char *)value, length);
|
||||
}
|
||||
}
|
||||
|
||||
_Tt_string _Tt_isam_record::getBytes (int start, int length) const
|
||||
{
|
||||
if (length < 1) {
|
||||
length = currentLength - start;
|
||||
}
|
||||
|
||||
_Tt_string value(length);
|
||||
(void)memcpy((char *)value, (char *)buffer+start, length);
|
||||
return value;
|
||||
}
|
||||
|
||||
void _Tt_isam_record::setBytes (int start, const _Tt_string &value)
|
||||
{
|
||||
(void)memcpy((char *)buffer+start, (char *)value, value.len());
|
||||
}
|
||||
|
||||
void _Tt_isam_record::setBytes (int start,
|
||||
int length,
|
||||
const _Tt_string &value)
|
||||
{
|
||||
(void)memcpy((char *)buffer+start, (char *)value, length);
|
||||
}
|
||||
75
cde/lib/tt/bin/ttdbserverd/tt_isam_record.h
Normal file
75
cde/lib/tt/bin/ttdbserverd/tt_isam_record.h
Normal file
@@ -0,0 +1,75 @@
|
||||
/*%% (c) Copyright 1993, 1994 Hewlett-Packard Company */
|
||||
/*%% (c) Copyright 1993, 1994 International Business Machines Corp. */
|
||||
/*%% (c) Copyright 1993, 1994 Sun Microsystems, Inc. */
|
||||
/*%% (c) Copyright 1993, 1994 Novell, Inc. */
|
||||
/*%% $XConsortium: tt_isam_record.h /main/3 1995/10/20 16:45:07 rswiston $ */
|
||||
/*
|
||||
* tt_isam_record.h - Defines the TT ISAM record class. This class simplifies
|
||||
* putting data in a record. To get an empty record ready
|
||||
* to be filled with data, call the _Tt_isam_file::getEmptyRecord.
|
||||
*
|
||||
* Copyright (c) 1992 by Sun Microsystems, Inc.
|
||||
*/
|
||||
|
||||
#ifndef _TT_ISAM_RECORD_H
|
||||
#define _TT_ISAM_RECORD_H
|
||||
|
||||
#include "util/tt_object.h"
|
||||
#include "util/tt_string.h"
|
||||
#include "tt_isam_key_descriptor_utils.h"
|
||||
|
||||
class _Tt_isam_record : public _Tt_object {
|
||||
public:
|
||||
// Dummy constructor needed to make tt_isam_record_utils.cc happy
|
||||
_Tt_isam_record () {}
|
||||
|
||||
// Real constructor
|
||||
_Tt_isam_record (const _Tt_isam_key_descriptor_list_ptr &key_descriptor_list,
|
||||
int max_record_length,
|
||||
int min_record_length);
|
||||
~_Tt_isam_record ();
|
||||
|
||||
int getNumberOfKeys () const;
|
||||
_Tt_isam_key_descriptor_ptr getKeyDescriptor (int) const;
|
||||
|
||||
_Tt_string getKeyPartValue (int, int) const;
|
||||
void setKeyPartValue (int, int, const _Tt_string&);
|
||||
|
||||
_Tt_string getBytes (int, int) const;
|
||||
void setBytes (int, const _Tt_string&);
|
||||
void setBytes (int, int, const _Tt_string&);
|
||||
|
||||
void setLength (int length)
|
||||
{
|
||||
currentLength = length;
|
||||
}
|
||||
|
||||
int getLength () const
|
||||
{
|
||||
return currentLength;
|
||||
}
|
||||
|
||||
int getMaxLength () const
|
||||
{
|
||||
return maxLength;
|
||||
}
|
||||
|
||||
int getMinLength () const
|
||||
{
|
||||
return minLength;
|
||||
}
|
||||
|
||||
const _Tt_string &getRecord () const
|
||||
{
|
||||
return buffer;
|
||||
}
|
||||
|
||||
private:
|
||||
_Tt_string buffer;
|
||||
_Tt_isam_key_descriptor_list_ptr keyDescriptorList;
|
||||
int currentLength;
|
||||
int maxLength;
|
||||
int minLength;
|
||||
};
|
||||
|
||||
#endif /* _TT_ISAM_RECORD_H */
|
||||
15
cde/lib/tt/bin/ttdbserverd/tt_isam_record_utils.C
Normal file
15
cde/lib/tt/bin/ttdbserverd/tt_isam_record_utils.C
Normal file
@@ -0,0 +1,15 @@
|
||||
//%% (c) Copyright 1993, 1994 Hewlett-Packard Company
|
||||
//%% (c) Copyright 1993, 1994 International Business Machines Corp.
|
||||
//%% (c) Copyright 1993, 1994 Sun Microsystems, Inc.
|
||||
//%% (c) Copyright 1993, 1994 Novell, Inc.
|
||||
//%% $XConsortium: tt_isam_record_utils.C /main/3 1995/10/20 16:45:16 rswiston $
|
||||
/*
|
||||
* tt_isam_record_utils.cc - Defines the _Tt_isam_record class
|
||||
* utilities.
|
||||
*
|
||||
* Copyright (c) 1992 by Sun Microsystems, Inc.
|
||||
*/
|
||||
|
||||
#include "tt_isam_record_utils.h"
|
||||
|
||||
implement_list_of(_Tt_isam_record)
|
||||
21
cde/lib/tt/bin/ttdbserverd/tt_isam_record_utils.h
Normal file
21
cde/lib/tt/bin/ttdbserverd/tt_isam_record_utils.h
Normal file
@@ -0,0 +1,21 @@
|
||||
/*%% (c) Copyright 1993, 1994 Hewlett-Packard Company */
|
||||
/*%% (c) Copyright 1993, 1994 International Business Machines Corp. */
|
||||
/*%% (c) Copyright 1993, 1994 Sun Microsystems, Inc. */
|
||||
/*%% (c) Copyright 1993, 1994 Novell, Inc. */
|
||||
/*%% $XConsortium: tt_isam_record_utils.h /main/3 1995/10/20 16:45:28 rswiston $ */
|
||||
/*
|
||||
* tt_isam_record_utils.h - Declares the _Tt_isam_record class
|
||||
* utilities.
|
||||
*
|
||||
* Copyright (c) 1992 by Sun Microsystems, Inc.
|
||||
*/
|
||||
|
||||
#ifndef _TT_ISAM_RECORD_UTILS_H
|
||||
#define _TT_ISAM_RECORD_UTILS_H
|
||||
|
||||
#include "util/tt_list.h"
|
||||
#include "tt_isam_record.h"
|
||||
|
||||
declare_list_of(_Tt_isam_record)
|
||||
|
||||
#endif // _TT_ISAM_RECORD_UTILS_H
|
||||
Reference in New Issue
Block a user