Initial import of the CDE 2.1.30 sources from the Open Group.

This commit is contained in:
Peter Howkins
2012-03-10 18:21:40 +00:00
commit 83b6996daa
18978 changed files with 3945623 additions and 0 deletions

View File

@@ -0,0 +1,68 @@
XCOMM $XConsortium: Imakefile /main/7 1996/04/21 19:12:19 drk $
#define DoNormalLib NormalLibTt
#define DoSharedLib SharedLibTt
#define DoDebugLib DebugLibTt
#define DoProfileLib ProfileLibTt
#define LibName tt
#define SoRev SOTTREV
#define LibHeaders NO
#define LibCreate NO
#define CplusplusSource YES
DEPEND_DEFINES = $(CXXDEPENDINCLUDES) $(ISAM_INCLUDES)
#include <Threads.tmpl>
#include "../../tooltalk.tmpl"
DEFINES =
INCLUDES = -I../../lib
ISAM_INCLUDES = -I../../mini_isam
/*** NOTE!
*** Every time a .o is added below it needs to be added to
*** the lib/tt/lib Imakefile in DB_OBJS and SHARED_DB_OBJS
***/
SRCS = db_server_clnt.C db_server_xdr.C \
old_db_server_functions.C tt_client_isam_file.C \
tt_client_isam_file_utils.C tt_client_isam_key_descriptor.C \
tt_client_isam_key_descriptor_utils.C tt_client_isam_record.C \
tt_client_isam_record_utils.C tt_db_access_utils.C \
tt_db_client.C tt_db_client_utils.C \
tt_db_create_objid.C tt_db_file.C \
tt_db_file_utils.C tt_db_hostname_global_map_ref.C \
tt_db_hostname_redirection_map.C tt_db_key.C \
tt_db_key_utils.C tt_db_network_path.C \
tt_db_object.C tt_db_object_utils.C \
tt_db_objid_to_key.C tt_db_property.C \
tt_db_property_utils.C tt_db_rpc_message_routines.C \
tt_db_rpc_routines.C tt_old_db.C \
tt_old_db_message_info.C tt_old_db_message_info_utils.C \
tt_old_db_partition_map_ref.C tt_old_db_utils.C
OBJS = db_server_clnt.o db_server_xdr.o \
old_db_server_functions.o tt_client_isam_file.o \
tt_client_isam_file_utils.o tt_client_isam_key_descriptor.o \
tt_client_isam_key_descriptor_utils.o tt_client_isam_record.o \
tt_client_isam_record_utils.o tt_db_access_utils.o \
tt_db_client.o tt_db_client_utils.o \
tt_db_create_objid.o tt_db_file.o \
tt_db_file_utils.o tt_db_hostname_global_map_ref.o \
tt_db_hostname_redirection_map.o tt_db_key.o \
tt_db_key_utils.o tt_db_network_path.o \
tt_db_object.o tt_db_object_utils.o \
tt_db_objid_to_key.o tt_db_property.o \
tt_db_property_utils.o tt_db_rpc_message_routines.o \
tt_db_rpc_routines.o tt_old_db.o \
tt_old_db_message_info.o tt_old_db_message_info_utils.o \
tt_old_db_partition_map_ref.o tt_old_db_utils.o
#include <Library.tmpl>
SpecialCplusplusLibObjectRule(db_server_xdr,,$(ISAM_INCLUDES))
SubdirLibraryRule($(OBJS))
DependTarget()

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,305 @@
/*%% (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_client_isam.h /main/3 1995/10/23 09:59:04 rswiston $ */
/*
@(#)isam.h
1.17 90/01/20
SMI */
/*
* Copyright (c) 1988 by Sun Microsystems, Inc.
*/
/*
* isam.h
*
* Description:
* isam.h is to be included in NetISAM C application programs.
*
* Make sure all.h changes in this file are reflected in lib/db/tt_client_isam.h
*/
#ifndef _ISAM_H
#define _ISAM_H
#include <limits.h>
#ifndef LONG_BIT
#define LONG_BIT 32
#endif
extern short ldint();
extern long ldlong();
extern float ldfloat();
extern double lddbl();
extern short ldshort();
extern ldchar(), stchar(), stlong(), stint(), stdbl(), stfloat();
extern stbin(), ldbin();
extern int iserrno; /* isam error number code */
extern long isrecnum; /* record number of last call */
extern int isreclen; /* used for variable length recs */
extern char isstat1; /* cobol status characters */
extern char isstat2;
#define CHARTYPE 0
#define CHARSIZE 1
#define INTTYPE 1
#define INTSIZE 2
#define LONGTYPE 2
#define LONGSIZE LONG_BIT/8
#define DOUBLETYPE 3
#define DOUBLESIZE 8
#define FLOATTYPE 4
#define FLOATSIZE 4
#define BINTYPE 5
#define BINSIZE 1
#define MINTYPE 0
#define MAXTYPE 6
#define ISDESC 0x80 /* add to make descending type */
#define TYPEMASK 0x7f /* type mask */
#define BYTEMASK 0xff /* mask for one byte */
#define BYTESHFT 8 /* shift for one byte */
/* mode parameter in isread() and isstart() */
#define ISFIRST 0 /* first record */
#define ISLAST 1 /* last record */
#define ISNEXT 2 /* next record */
#define ISPREV 3 /* previous record */
#define ISCURR 4 /* current record */
#define ISEQUAL 5 /* equal value */
#define ISGREAT 6 /* greater value */
#define ISGTEQ 7 /* >= value */
#define ISLESS 8 /* < */
#define ISLTEQ 9 /* <= */
/* isopen, isbuild lock modes */
#define ISAUTOLOCK 0x200 /* automatic record lock */
#define ISMANULOCK 0x400 /* manual record lock */
#define ISEXCLLOCK 0x800 /* exclusive isam file lock */
#define ISFASTLOCK 0x4000 /* no locking when EXCLLOCK! */
/* isread lock modes */
#define ISLOCK 0x100 /* lock record before reading */
#define ISSKIPLOCK 0x1000 /* advance record pointer to */
/* locked record */
/* isstart lock mode for automatic record locking */
#define ISKEEPLOCK 0x2000 /* keep record locked */
/* Fix/Variable length records mode */
#define ISFIXLEN 0
#define ISVARLEN 0x10000
/* Access remote file via NFS */
#define ISNFS 0x20000
#define ISINPUT 0 /* open for input only */
#define ISOUTPUT 1 /* open for output only */
#define ISINOUT 2 /* open for input and output */
#define MAXKEYSIZE 150 /* max number of bytes in key */
#define NPARTS 8 /* max number of key parts */
/*#define ISMAXRECLEN 8192 */ /* Maximum number of bytes in record */
#define ISMAXRECLEN 65535 /* 64 K */
#define ISMINRECLEN 4 /* Minimum number of bytes in record */
struct keypart {
unsigned short kp_start; /* starting byte of key part */
short kp_leng; /* length in bytes */
short kp_type; /* type of key part */
};
/* Because of a quirk in cfront, it is important *not* to define an array */
/* of structures. We use a relatively gross hack to avoid this. */
/* The ifdef is really just to keep the original code here to remind */
/* us what it ought to look like. */
#if !defined(__cplusplus)
struct keydesc {
short k_flags; /* flags */
short k_nparts; /* number of parts in key */
struct keypart k_part[NPARTS]; /* each part */
};
#else
struct keydesc {
short k_flags; /* flags */
short k_nparts; /* number of parts in key */
struct keypart k_part_0;
struct keypart k_part_1;
struct keypart k_part_2;
struct keypart k_part_3;
struct keypart k_part_4;
struct keypart k_part_5;
struct keypart k_part_6;
struct keypart k_part_7;
};
#endif
#define ISNODUPS 000 /* no duplicates and */
/* no compression */
#define ISDUPS 001 /* duplicates allowed */
#define COMPRESS 020 /* full compression */
struct dictinfo {
short di_nkeys; /* number of keys defined */
unsigned short di_recsize; /* data record size */
short di_idxsize; /* index record size */
long di_nrecords; /* number of records in file */
};
/* msb in di_nkeys indicates that ISAM file supports variable length records */
#define DICTVARLENBIT 0x8000
/* mask to access the true number of keys */
#define DICTNKEYSMASK (DICTVARLENBIT - 1)
#define ENOERROR 0 /* No error */
#define EDUPL 100 /* duplicate record */
#define ENOTOPEN 101 /* file not open */
#define EBADARG 102 /* illegal argument */
#define EBADKEY 103 /* illegal key desc */
#define ETOOMANY 104 /* too many files open */
#define EBADFILE 105 /* bad ISAM file format */
#define ENOTEXCL 106 /* non-exclusive access */
#define ELOCKED 107 /* record locked */
#define EKEXISTS 108 /* key already exists */
#define EPRIMKEY 109 /* is primary key */
#define EENDFILE 110 /* end/begin of file */
#define ENOREC 111 /* no record found */
#define ENOCURR 112 /* no current record */
#define EFLOCKED 113 /* file locked */
#define EFNAME 114 /* file name too long */
#define EBADMEM 116 /* cannot allocate memory */
/* NetISAM specific error codes non XOPEN compliant*/
#define ETIMEOUT 1117 /* RPC timeout */
#define ERPC 1118 /* Broken TCP/IP */
#define ETCP 1119 /* Cannot connect to server */
#define EIMPORT 1120 /* Cannot import */
#define ENODAEMON 1121 /* no local daemon */
#define EFATAL 1122 /* internal fatal error */
#define ELANG 1123 /* Locale/LANG mismatch */
#define ISOK 0 /* no error return code */
#define ISERROR -1 /* error return code */
extern struct keydesc *nokey; /* May be used as parameter
* to isbuild() if no
* primary key is to be built
*/
/* ischeckindex() diagmode values */
#define CHK_NODIAG 0 /* do not print any messages */
#define CHK_DIAG 1 /* Access Level module will print to stderr */
/* values of corrupt parameter of ischeckindex() */
#define CHK_OK 0 /* ISAM file is not corrupted */
#define CHK_DAT 1 /* .dat file is corrupted */
#define CHK_VAR 2 /* .var file is corrupted */
#define CHK_IND 3 /* .ind file is corrupted */
/* iscntl() definitions */
/* For one isfd - use iscntl(isfd, func, ...) */
#define ISCNTL_RPCS_TO_SET 1 /* short oper. timeout (in sec) */
#define ISCNTL_RPCS_TO_GET 2 /* short oper. timeout (in sec) */
#define ISCNTL_RPCL_TO_SET 3 /* long oper. timeout (in sec) */
#define ISCNTL_RPCL_TO_GET 4 /* long oper. timeout (in sec) */
#define ISCNTL_TCP_TO_SET 5 /* timeout to reconnect TCP?IP */
#define ISCNTL_TCP_TO_GET 6 /* timeout to reconnect TCP?IP */
#define ISCNTL_APPLMAGIC_WRITE 7 /* Write Appl. Magic */
#define ISCNTL_APPLMAGIC_READ 8 /* Read Appl. Magic */
#define ISCNTL_FSYNC 9 /* Flush pages to disk */
#define ISCNTL_FDLIMIT_SET 10 /* Set UNIX fd usage limit */
#define ISCNTL_FDLIMIT_GET 11 /* Get UNIX fd usage limit */
#define ISCNTL_FATAL 12 /* Specify NetISAM fatal error hadler */
#define ISCNTL_MASKSIGNALS 13 /* Enable or Disable masking signals during NetISAM operations */
#define ISAPPLMAGICLEN 32
/*
* ALLISFD in iscntl() calls means that the operation should be done
* on all open file descriptors, or the operation is not related to
* any file descriptor (e.g: maskintg signals)
*/
#define ALLISFD (-2)
/* isshowlocks() and isshowhostlocks() return an array of struct showlock */
#define IPADDRLEN 4 /* IP address length */
struct showlock {
short dev; /* Major/Minor device number,
* actually type dev_t */
long inode; /* inode number */
long recnum; /* record number */
char hostid[IPADDRLEN]; /* IP address of host */
short pid; /* UNIX process ID */
long uid; /* User ID */
short type; /* See below */
};
/* NetISAM Programmer Toolkit related definitions */
struct isfldmap {
char *flm_fldname;
short flm_recoff;
short flm_bufoff;
short flm_type;
short flm_length;
};
struct istableinfo {
char *tbi_tablename;
int tbi_reclength;
int tbi_nfields;
struct isfldmap *tbi_fields;
int tbi_nkeys;
struct keydesc *tbi_keys;
char **tbi_keynames;
};
/* record descriptor isreadm/iswritem record descriptor */
struct recorddesc {
char *rec_buffer;
long rec_number;
short rec_length;
short rec_locked;
};
/*
* The following defines and variable definitions are not used by NetISAM 1.0.
* They are defined for compatibility with VSX 2.5.
*/
#define EBADCOLL (-1)
#define IO_OPEN 0x10 /* open() */
#define IO_CREA 0x20 /* creat() */
#define IO_SEEK 0x30 /* lseek() */
#define IO_READ 0x40 /* read() */
#define IO_WRIT 0x50 /* write() */
#define IO_LOCK 0x60 /* lockf() */
#define IO_IOCTL 0x70 /* ioctl() */
#define IO_RENAME 0x80 /* rename() */
#define IO_UNLINK 0x90 /* unlink() */
extern int iserrio;
#endif /* !_ISAM_H */

View File

@@ -0,0 +1,332 @@
//%% (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_client_isam_file.C /main/3 1995/10/23 09:59:12 rswiston $
/*
* tt_client_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 "db/tt_client_isam.h"
#include "db/tt_client_isam_file.h"
#include "db/tt_old_db_consts.h"
_Tt_client_isam_file::_Tt_client_isam_file (const _Tt_string &file,
int mode,
const _Tt_db_client_ptr &db_connection)
{
dbConnection = db_connection;
setTtISAMFileDefaults();
fileName = file;
fileMode = mode;
if ((fileDescriptor = dbConnection->isopen(file, mode)) != -1) {
getISAMFileInfo();
}
else {
getStatusInfo();
}
}
_Tt_client_isam_file
::_Tt_client_isam_file (const _Tt_string &file,
int max_record_length,
int min_record_length,
_Tt_client_isam_key_descriptor_ptr primary_key_descriptor,
int mode,
const _Tt_db_client_ptr &db_connection)
{
dbConnection = db_connection;
setTtISAMFileDefaults();
fileName = file;
fileMode = mode;
// Because a old TT client may be talking with the old DB, make sure
// files are opened with a manual lock, not an exclusive lock.
if ((fileDescriptor =
dbConnection->isopen(file, mode&(~ISEXCLLOCK)|ISMANULOCK)) == -1) {
newFlag = TRUE;
dbConnection->isreclen = min_record_length;
fileDescriptor = dbConnection->isbuild(file,
(max_record_length > TT_OLD_MAX_RECORD_LENGTH ?
TT_OLD_MAX_RECORD_LENGTH : max_record_length),
primary_key_descriptor->getKeyDescriptor(),
mode);
}
if (fileDescriptor != -1) {
getISAMFileInfo();
}
else {
errorStatus = dbConnection->iserrno;
currentRecordLength = -1;
currentRecordNumber = -1;
}
}
void _Tt_client_isam_file::setTtISAMFileDefaults ()
{
eraseFlag = FALSE;
fileName = (char *)NULL;
fileMode = 0;
keyDescriptorList = new _Tt_client_isam_key_descriptor_list;
newFlag = FALSE;
dbConnection->iserrno = 0;
}
_Tt_client_isam_file::~_Tt_client_isam_file ()
{
if (eraseFlag) {
(void)dbConnection->iserase(fileName);
}
else {
(void)dbConnection->isclose(fileDescriptor);
}
}
void _Tt_client_isam_file::setErase (bool_t flag)
{
eraseFlag = flag;
}
int _Tt_client_isam_file::addIndex (_Tt_client_isam_key_descriptor_ptr key_descriptor)
{
dbConnection->iserrno = 0;
int results = dbConnection->isaddindex(fileDescriptor, key_descriptor->getKeyDescriptor());
errorStatus = dbConnection->iserrno;
if (!results) {
getISAMFileInfo();
}
return errorStatus;
}
_Tt_client_isam_record_ptr _Tt_client_isam_file::getEmptyRecord ()
{
return (new _Tt_client_isam_record(keyDescriptorList,
maxRecordLength,
minRecordLength));
}
int _Tt_client_isam_file
::findStartRecord (const _Tt_client_isam_key_descriptor_ptr &key_descriptor,
int length,
const _Tt_client_isam_record_ptr &record,
int mode)
{
dbConnection->iserrno = 0;
dbConnection->isreclen = record->getLength();
(void)dbConnection->isstart(fileDescriptor,
key_descriptor->getKeyDescriptor(),
length,
(char *)record->getRecord(),
mode);
getStatusInfo();
return errorStatus;
}
_Tt_client_isam_record_ptr _Tt_client_isam_file::readRecord (int mode)
{
dbConnection->iserrno = 0;
_Tt_client_isam_record_ptr record = (_Tt_client_isam_record *)NULL;
_Tt_string record_buffer(maxRecordLength);
dbConnection->isreclen = maxRecordLength;
int results = dbConnection->isread(fileDescriptor,
(char *)record_buffer,
mode);
getStatusInfo();
if (!results) {
record = getFullRecord(record_buffer);
}
return record;
}
int _Tt_client_isam_file::readRecord (int mode,
const _Tt_client_isam_record_ptr &record)
{
dbConnection->iserrno = 0;
dbConnection->isreclen = record->getLength();
int results = dbConnection->isread(fileDescriptor, (char *)record->getRecord(), mode);
getStatusInfo();
if (!results) {
record->setLength(currentRecordLength);
}
return errorStatus;
}
int
_Tt_client_isam_file::updateRecord (long recnum, const _Tt_client_isam_record_ptr &record)
{
dbConnection->iserrno = 0;
dbConnection->isreclen = record->getLength();
(void)dbConnection->isrewrec(fileDescriptor, recnum, (char *)record->getRecord());
getStatusInfo();
return errorStatus;
}
int _Tt_client_isam_file::writeRecord (const _Tt_client_isam_record_ptr &record)
{
dbConnection->iserrno = 0;
dbConnection->isreclen = record->getLength();
(void)dbConnection->iswrite(fileDescriptor, (char *)record->getRecord());
getStatusInfo();
return errorStatus;
}
int
_Tt_client_isam_file::deleteRecord (long recnum,
const _Tt_client_isam_record_ptr &record)
{
dbConnection->iserrno = 0;
dbConnection->isreclen = record->getLength();
(void)dbConnection->isdelrec(fileDescriptor,
recnum,
(char *)record->getRecord());
getStatusInfo();
return errorStatus;
}
int _Tt_client_isam_file::writeMagicString (const _Tt_string &magic_string)
{
dbConnection->iserrno = 0;
(void)dbConnection->iscntl(fileDescriptor,
ISCNTL_APPLMAGIC_WRITE,
(char *)magic_string);
errorStatus = dbConnection->iserrno;
return errorStatus;
}
_Tt_string _Tt_client_isam_file::readMagicString ()
{
dbConnection->iserrno = 0;
_Tt_string magic_string_bytes(ISAPPLMAGICLEN);
memset((char *)magic_string_bytes, '\0', ISAPPLMAGICLEN);
(void)dbConnection->iscntl(fileDescriptor,
ISCNTL_APPLMAGIC_READ,
(char *)magic_string_bytes);
errorStatus = dbConnection->iserrno;
_Tt_string magic_string = (char *)magic_string_bytes;
return magic_string;
}
_Tt_client_isam_record_ptr
_Tt_client_isam_file::getFullRecord (const _Tt_string &record_buffer)
{
_Tt_client_isam_record_ptr record_ptr = new _Tt_client_isam_record(keyDescriptorList,
maxRecordLength,
minRecordLength);
record_ptr->setBytes(0, currentRecordLength, record_buffer);
record_ptr->setLength(currentRecordLength);
return record_ptr;
}
void _Tt_client_isam_file::getISAMFileInfo ()
{
keyDescriptorList->flush();
if (!strcmp(TT_OLD_DB_PROPERTY_TABLE_FILE,
(char *)fileName+
fileName.len()-
strlen(TT_OLD_DB_PROPERTY_TABLE_FILE))) {
maxRecordLength = TT_OLD_MAX_RECORD_LENGTH;
minRecordLength = TT_OLD_DB_KEY_LENGTH+TT_OLD_DB_MAX_PROPERTY_NAME_LENGTH;
_Tt_client_isam_key_descriptor_ptr key_descriptor =
new _Tt_client_isam_key_descriptor;
key_descriptor->addKeyPart(TT_OLD_DB_FIRST_KEY_OFFSET,
TT_OLD_DB_KEY_LENGTH,
BINTYPE);
key_descriptor->addKeyPart(TT_OLD_DB_PROPERTY_NAME_OFFSET,
TT_OLD_DB_MAX_PROPERTY_NAME_LENGTH,
CHARTYPE);
key_descriptor->setDuplicates(TRUE);
keyDescriptorList->append(key_descriptor);
}
else if (!strcmp(TT_OLD_DB_ACCESS_TABLE_FILE,
(char *)fileName+
fileName.len()-
strlen(TT_OLD_DB_ACCESS_TABLE_FILE))) {
maxRecordLength = minRecordLength = TT_OLD_DB_KEY_LENGTH+
3*TT_OLD_DB_SHORT_SIZE;
_Tt_client_isam_key_descriptor_ptr key_descriptor =
new _Tt_client_isam_key_descriptor;
key_descriptor->addKeyPart(TT_OLD_DB_FIRST_KEY_OFFSET,
TT_OLD_DB_KEY_LENGTH,
BINTYPE);
keyDescriptorList->append(key_descriptor);
}
else if (!strcmp(TT_OLD_DB_FILE_TABLE_FILE,
(char *)fileName+
fileName.len()-
strlen(TT_OLD_DB_FILE_TABLE_FILE))) {
maxRecordLength = TT_OLD_DB_KEY_LENGTH+MAXPATHLEN;
minRecordLength = TT_OLD_DB_KEY_LENGTH+TT_OLD_DB_MAX_KEY_LENGTH;
_Tt_client_isam_key_descriptor_ptr key_descriptor =
new _Tt_client_isam_key_descriptor;
key_descriptor->addKeyPart(TT_OLD_DB_FIRST_KEY_OFFSET,
TT_OLD_DB_KEY_LENGTH,
BINTYPE);
keyDescriptorList->append(key_descriptor);
key_descriptor = new _Tt_client_isam_key_descriptor;
key_descriptor->addKeyPart(TT_OLD_DB_FILE_PATH_OFFSET,
TT_OLD_DB_MAX_KEY_LENGTH,
CHARTYPE);
keyDescriptorList->append(key_descriptor);
}
// TT_OLD_DB_FILE_OBJECT_MAP_FILE
else {
maxRecordLength = minRecordLength = 2*TT_OLD_DB_KEY_LENGTH;
_Tt_client_isam_key_descriptor_ptr key_descriptor =
new _Tt_client_isam_key_descriptor;
key_descriptor->addKeyPart(TT_OLD_DB_FIRST_KEY_OFFSET,
TT_OLD_DB_KEY_LENGTH,
BINTYPE);
keyDescriptorList->append(key_descriptor);
key_descriptor = new _Tt_client_isam_key_descriptor;
key_descriptor->addKeyPart(TT_OLD_DB_SECOND_KEY_OFFSET,
TT_OLD_DB_KEY_LENGTH,
CHARTYPE);
key_descriptor->setDuplicates(TRUE);
keyDescriptorList->append(key_descriptor);
}
errorStatus = dbConnection->iserrno = 0;
}

View File

@@ -0,0 +1,110 @@
/*%% (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_client_isam_file.h /main/3 1995/10/23 09:59:20 rswiston $ */
/*
* tt_client_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_CLIENT_ISAM_FILE_H
#define _TT_CLIENT_ISAM_FILE_H
#include "util/tt_object.h"
#include "db/tt_db_client_utils.h"
#include "db/tt_client_isam_key_descriptor_utils.h"
#include "db/tt_client_isam_record_utils.h"
#include <sys/param.h>
class _Tt_client_isam_file : public _Tt_object {
public:
// Dummy constructor needed to make _tt_client_isam_file_utils.cc happy
_Tt_client_isam_file () {}
// Real constructors
_Tt_client_isam_file (const _Tt_string &file,
int mode,
const _Tt_db_client_ptr &db_connection);
_Tt_client_isam_file (const _Tt_string &file,
int max_record_length,
int min_record_length,
_Tt_client_isam_key_descriptor_ptr primary_key_descriptor,
int mode,
const _Tt_db_client_ptr &db_connection);
~_Tt_client_isam_file ();
void setErase (bool_t);
int addIndex (_Tt_client_isam_key_descriptor_ptr);
_Tt_client_isam_record_ptr getEmptyRecord ();
int findStartRecord (const _Tt_client_isam_key_descriptor_ptr &key_descriptor,
int length,
const _Tt_client_isam_record_ptr &record,
int mode);
_Tt_client_isam_record_ptr readRecord (int mode);
int readRecord (int mode, const _Tt_client_isam_record_ptr&);
int updateRecord (long recnum, const _Tt_client_isam_record_ptr&);
int writeRecord (const _Tt_client_isam_record_ptr&);
int deleteRecord (long recnum,
const _Tt_client_isam_record_ptr &record);
int writeMagicString (const _Tt_string&);
_Tt_string readMagicString ();
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;
_Tt_db_client_ptr dbConnection;
bool_t eraseFlag;
int errorStatus;
int fileDescriptor;
_Tt_string fileName;
int fileMode;
_Tt_client_isam_key_descriptor_list_ptr keyDescriptorList;
int maxRecordLength;
int minRecordLength;
bool_t newFlag;
void setTtISAMFileDefaults ();
_Tt_client_isam_record_ptr getFullRecord (const _Tt_string&);
void getISAMFileInfo ();
void getStatusInfo ()
{
currentRecordLength = dbConnection->isreclen;
currentRecordNumber = dbConnection->isrecnum;
errorStatus = dbConnection->iserrno;
}
};
#endif /* _TT_CLIENT_ISAM_FILE_H */

View 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_client_isam_file_utils.C /main/3 1995/10/23 09:59:27 rswiston $
/*
* tt_client_isam_file_utils.cc - Defines the _Tt_client_isam_file class
* utilities.
*
* Copyright (c) 1992 by Sun Microsystems, Inc.
*/
#include "db/tt_client_isam_file_utils.h"
implement_ptr_to(_Tt_client_isam_file)

View 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_client_isam_file_utils.h /main/3 1995/10/23 09:59:34 rswiston $ */
/*
* tt_client_isam_file_utils.h - Declares the _Tt_client_isam_file class
* utilities.
*
* Copyright (c) 1992 by Sun Microsystems, Inc.
*/
#ifndef _TT_CLIENT_ISAM_FILE_UTILS_H
#define _TT_CLIENT_ISAM_FILE_UTILS_H
#include "db/tt_client_isam_file.h"
declare_ptr_to(_Tt_client_isam_file)
#endif // _TT_CLIENT_ISAM_FILE_UTILS_H

View 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_client_isam_key_descriptor.C /main/3 1995/10/23 09:59:42 rswiston $
/*
* tt_client_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 "db/tt_client_isam_key_descriptor.h"
_Tt_client_isam_key_descriptor::_Tt_client_isam_key_descriptor ()
{
keyDescriptor.k_flags = 0;
keyDescriptor.k_nparts = 0;
}
_Tt_client_isam_key_descriptor::~_Tt_client_isam_key_descriptor ()
{
}
short _Tt_client_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_0 + index)->kp_start = start;
(&keyDescriptor.k_part_0 + index)->kp_leng = length;
(&keyDescriptor.k_part_0 + index)->kp_type = type;
keyDescriptor.k_nparts++;
}
return index;
}
short _Tt_client_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_0 + index)->kp_start = start;
(&keyDescriptor.k_part_0 + index)->kp_leng = length;
(&keyDescriptor.k_part_0 + index)->kp_type = type;
}
else {
error = -1;
}
return error;
}
short _Tt_client_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_0 + index)->kp_start;
length = (&keyDescriptor.k_part_0 + index)->kp_leng;
type = (&keyDescriptor.k_part_0 + index)->kp_type;
}
else {
start = -1;
length = -1;
type = -1;
error = -1;
}
return error;
}

View 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_client_isam_key_descriptor.h /main/3 1995/10/23 09:59:50 rswiston $ */
/*
* tt_client_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_CLIENT_ISAM_KEY_DESCRIPTOR_H
#define _TT_CLIENT_ISAM_KEY_DESCRIPTOR_H
#include "db/tt_client_isam.h"
#include "util/tt_object.h"
class _Tt_client_isam_key_descriptor : public _Tt_object {
public:
_Tt_client_isam_key_descriptor ();
~_Tt_client_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;
}
keydesc *getKeyDescriptor ()
{
return &keyDescriptor;
}
private:
struct keydesc keyDescriptor;
friend class _Tt_client_isam_file;
};
#endif /* _TT_CLIENT_ISAM_KEY_DESCRIPTOR_H */

View 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_client_isam_key_descriptor_utils.C /main/3 1995/10/23 09:59:56 rswiston $
/*
* tt_client_isam_key_descriptor_utils.cc - Defines the
* _Tt_client_isam_key_descriptor class utilities.
*
* Copyright (c) 1992 by Sun Microsystems, Inc.
*/
#include "db/tt_client_isam_key_descriptor_utils.h"
implement_list_of(_Tt_client_isam_key_descriptor)

View 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_client_isam_key_descriptor_utils.h /main/3 1995/10/23 10:00:04 rswiston $ */
/*
* tt_client_isam_key_descriptor_utils.h - Declares the
* _Tt_client_isam_key_descriptor class utilities.
*
* Copyright (c) 1992 by Sun Microsystems, Inc.
*/
#ifndef _TT_CLIENT_ISAM_KEY_DESCRIPTOR_UTILS_H
#define _TT_CLIENT_ISAM_KEY_DESCRIPTOR_UTILS_H
#include "util/tt_list.h"
#include "db/tt_client_isam_key_descriptor.h"
declare_list_of(_Tt_client_isam_key_descriptor)
#endif // _TT_CLIENT_ISAM_KEY_DESCRIPTOR_UTILS_H

View 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_client_isam_record.C /main/3 1995/10/23 10:00:11 rswiston $
/*
* tt_client_isam_record.cc - Defines the TT ISAM record class.
*
* Copyright (c) 1992 by Sun Microsystems, Inc.
*/
#include "db/tt_client_isam_record.h"
_Tt_client_isam_record::
_Tt_client_isam_record (const _Tt_client_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_client_isam_record::~_Tt_client_isam_record ()
{
}
int _Tt_client_isam_record::getNumberOfKeys () const
{
return keyDescriptorList->count();
}
_Tt_client_isam_key_descriptor_ptr _Tt_client_isam_record::getKeyDescriptor (int index) const
{
_Tt_client_isam_key_descriptor_ptr descriptor_ptr = (_Tt_client_isam_key_descriptor *)NULL;
if ((index > -1) && (index < keyDescriptorList->count())) {
descriptor_ptr = (*keyDescriptorList) [index];
}
return descriptor_ptr;
}
_Tt_string _Tt_client_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_client_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_client_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_client_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_client_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_client_isam_record::setBytes (int start, const _Tt_string &value)
{
(void)memcpy((char *)buffer+start, (char *)value, value.len());
}
void _Tt_client_isam_record::setBytes (int start,
int length,
const _Tt_string &value)
{
(void)memcpy((char *)buffer+start, (char *)value, length);
}

View 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_client_isam_record.h /main/3 1995/10/23 10:00:19 rswiston $ */
/*
* tt_client_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_client_isam_file::getEmptyRecord.
*
* Copyright (c) 1992 by Sun Microsystems, Inc.
*/
#ifndef _TT_CLIENT_ISAM_RECORD_H
#define _TT_CLIENT_ISAM_RECORD_H
#include "util/tt_object.h"
#include "util/tt_string.h"
#include "db/tt_client_isam_key_descriptor_utils.h"
class _Tt_client_isam_record : public _Tt_object {
public:
// Dummy constructor needed to make tt_client_isam_record_utils.cc happy
_Tt_client_isam_record () {}
// Real constructor
_Tt_client_isam_record (const _Tt_client_isam_key_descriptor_list_ptr &key_descriptor_list,
int max_record_length,
int min_record_length);
~_Tt_client_isam_record ();
int getNumberOfKeys () const;
_Tt_client_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_client_isam_key_descriptor_list_ptr keyDescriptorList;
int currentLength;
int maxLength;
int minLength;
};
#endif /* _TT_CLIENT_ISAM_RECORD_H */

View 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_client_isam_record_utils.C /main/3 1995/10/23 10:00:26 rswiston $
/*
* tt_client_isam_record_utils.cc - Defines the _Tt_client_isam_record class
* utilities.
*
* Copyright (c) 1992 by Sun Microsystems, Inc.
*/
#include "db/tt_client_isam_record_utils.h"
implement_list_of(_Tt_client_isam_record)

View 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_client_isam_record_utils.h /main/3 1995/10/23 10:00:34 rswiston $ */
/*
* tt_client_isam_record_utils.h - Declares the _Tt_client_isam_record class
* utilities.
*
* Copyright (c) 1992 by Sun Microsystems, Inc.
*/
#ifndef _TT_CLIENT_ISAM_RECORD_UTILS_H
#define _TT_CLIENT_ISAM_RECORD_UTILS_H
#include "util/tt_list.h"
#include "db/tt_client_isam_record.h"
declare_list_of(_Tt_client_isam_record)
#endif // _TT_CLIENT_ISAM_RECORD_UTILS_H

View File

@@ -0,0 +1,30 @@
/*%% (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_access.h /main/3 1995/10/23 10:00:40 rswiston $ */
/*
* tt_db_access.h - Define the TT DB server access class. This class is used
* for specifying the access privilege of a particular object
* or file in the database.
*
* Copyright (c) 1992 by Sun Microsystems, Inc.
*/
#ifndef _TT_DB_ACCESS_H
#define _TT_DB_ACCESS_H
#include <sys/types.h>
#include "util/tt_object.h"
class _Tt_db_access : public _Tt_object {
public:
_Tt_db_access ();
virtual ~_Tt_db_access ();
uid_t user;
gid_t group;
mode_t mode;
};
#endif // _TT_DB_ACCESS_H

View File

@@ -0,0 +1,32 @@
//%% (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_access_utils.C /main/3 1995/10/23 10:00:48 rswiston $
/* @(#)tt_db_access_utils.C 1.5 @(#)
* tt_db_access_utils.cc - Defines the _Tt_db_access utilities.
*
* Copyright (c) 1992 by Sun Microsystems, Inc.
*/
#include "db/tt_db_access.h"
#include "db/tt_db_access_utils.h"
implement_ptr_to(_Tt_db_access)
// Normally, we don't put the constructors in the _utils.cc, but since
// tt_db_access.cc doesn\'t exist, it seems a waste to create it just
// to hold some null constructors.
_Tt_db_access::
_Tt_db_access()
{
user = (uid_t)-1;
group = (gid_t)-1;
mode = (mode_t)-1; // Default: Everyone can read and write it
}
_Tt_db_access::
~_Tt_db_access()
{
}

View 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_access_utils.h /main/3 1995/10/23 10:00:55 rswiston $ */
/*
* tt_db_access_utils.h - Declares the _Tt_db_access utilities.
*
* Copyright (c) 1992 by Sun Microsystems, Inc.
*/
#ifndef _TT_DB_ACCESS_UTILS_H
#define _TT_DB_ACCESS_UTILS_H
class _Tt_db_access;
declare_ptr_to(_Tt_db_access)
#endif // _TT_DB_ACCESS_UTILS_H

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,342 @@
/*%% (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_client.h /main/3 1995/10/23 10:01:13 rswiston $ */
/*
* @(#)tt_db_client.h 1.19 95/02/21
*
* Declare the TT DB client class. This class defines a
* client interface to the DB server.
*
* Copyright (c) 1992 by Sun Microsystems, Inc.
*/
#ifndef _TT_DB_CLIENT_H
#define _TT_DB_CLIENT_H
// db_server.h requires this definition by the client side code
#define _TT_DBCLIENT_SIDE
#include "mp/mp_message.h"
#include "util/tt_object.h"
#include "util/tt_string.h"
#include "db/tt_db_access_utils.h"
#include "db/tt_db_property_utils.h"
#include "db/tt_db_property.h"
#include "db/tt_db_results.h"
// ********** Old DB Compatibility Include Files **********
#include "db/tt_old_db_results.h"
#include "db/tt_client_isam.h"
// ********** Old DB Compatibility Include Files **********
class _Tt_db_client : public _Tt_object {
public:
// Connects to rpc.ttdbserverd on the specified host. If no hostname
// is provided, then the connection is made to the host the process
// is running on.
_Tt_db_client(_Tt_db_results & status);
_Tt_db_client (); // <- Yuck, it does work, we need a status.
_Tt_db_client (const _Tt_string &hostname, _Tt_db_results & status);
~_Tt_db_client ();
// Returns the results of the DB connection attempted when this object
// is instantiated.
_Tt_db_results getConnectionResults () const
{
return dbConnectionResults;
}
// returns the hostname of the machine this DB object is connected to.
_Tt_string getHostname () const
{
_Tt_string hostname = (char *)dbHostname;
return hostname;
}
// Sets and gets the current access mode to be used when reading, writing
// and removing data to and from the database. If not used, the default
// access is world read and write.
void setCurrentAccess (const _Tt_db_access_ptr &access);
_Tt_db_access_ptr getCurrentAccess () const;
// Returns the file partition name that the specified file is in and
// the real path of the file on the remote machine. It is assumed that
// the file is on the same machine that the DB connection is on.
_Tt_db_results getFilePartition (const _Tt_string &path,
_Tt_string &partition,
_Tt_string &network_path);
// Creates a file entry in the database. A list of file properties may
// be specified along with the file name. The cache level returned
// can be used to initialize the cache levels for the types of info
// stored for this file.
_Tt_db_results createFile (const _Tt_string &file,
const _Tt_db_property_list_ptr &properties,
const _Tt_db_access_ptr &access,
int &cache_level);
// Creates an object entry in the database. If the file does not already
// exist in the database, the file entry is also created. The cache level
// returned can be used to initialize the cache levels for the types of info
// stored for this object.
_Tt_db_results createObject (const _Tt_string &file,
const _Tt_string &objid,
const _Tt_string &otype,
const _Tt_db_property_list_ptr &properties,
const _Tt_db_access_ptr &access,
int &cache_level);
// Removes the specified file and all of its objects from the database.
_Tt_db_results removeFile (const _Tt_string &file);
// Removes the specified field from the databse.
_Tt_db_results removeObject (const _Tt_string &objid,
const _Tt_string &forward_pointer);
// Moves the specified file and all of its objects to the new file.
_Tt_db_results moveFile (const _Tt_string &file,
const _Tt_string &new_file);
// Writes the specified file property to the database. All values of the
// the file property with the same name are overwritten. If the value of
// the property is NULL, this deletes all properties with the same name
// from the database.
_Tt_db_results setFileProperty (const _Tt_string &file,
const _Tt_db_property_ptr &property,
int &cache_level);
// Writes the specified file properties to the database. All values of
// the the file properties with the same names are overwritten. If the
// value of some of the properties are NULL, this deletes all properties
// with the same name from the database.
_Tt_db_results
setFileProperties (const _Tt_string &file,
const _Tt_db_property_list_ptr &properties,
int &cache_level);
// Adds a file property to the list of values of the file property
// with the same name. If the property does not already exist, then
// the property is created. If the "unique" argument is TRUE, then
// the property name and value combination is guaranteed to be unique
// and will not be added to the list of values if the combination already
// exists.
_Tt_db_results addFileProperty (const _Tt_string &file,
const _Tt_db_property_ptr &property,
bool_t unique,
int &cache_level);
// Deletes the file property value with the same name and value. If
// the value is left empty, then all values of the property are deleted.
_Tt_db_results
deleteFileProperty (const _Tt_string &file,
const _Tt_db_property_ptr &property,
int &cache_level);
// Gets the values of the file property with the specified name.
_Tt_db_results getFileProperty (const _Tt_string &file,
const _Tt_string &name,
int &cache_level,
_Tt_db_property_ptr &property);
// Gets a list of all of the file properties.
_Tt_db_results
getFileProperties (const _Tt_string &file,
int &cache_level,
_Tt_db_property_list_ptr &properties);
// Returns a list of all of the object IDs for the specified file.
_Tt_db_results getFileObjects (const _Tt_string &file,
int &cache_level,
_Tt_string_list_ptr &objids);
// Sets and gets the access mode of the specified file.
_Tt_db_results setFileAccess (const _Tt_string &file,
const _Tt_db_access_ptr &access);
_Tt_db_results getFileAccess (const _Tt_string &file,
_Tt_db_access_ptr &access);
// Writes the specified object property to the database. All values of the
// the object property with the same name are overwritten. If the value of
// the property is NULL, this deletes all properties with the same name
// from the database. If the cache level in the database is higher then
// the cache level passed in, the write is not done and the values of all
// properties in the database are returned through the properties argument.
// The latest cache level is always returned.
_Tt_db_results setObjectProperty (const _Tt_string &objid,
const _Tt_db_property_ptr &property,
_Tt_db_property_list_ptr &properties,
int &cache_level);
// Writes the specified object properties to the database. All values of
// the object properties with the same names are overwritten. If the value
// of some of the properties are NULL, this deletes all properties with the
// same name from the database. If the cache level in the database is
// higher then the cache level passed in, the write is not done and
// all of the object properties in the database are returned through the
// out_properties argument. The latest cache level is always returned.
_Tt_db_results
setObjectProperties (const _Tt_string &objid,
const _Tt_db_property_list_ptr &in_properties,
_Tt_db_property_list_ptr &out_properties,
int &cache_level);
// Adds an object property to the list of values of the object property
// with the same name. If the property does not already exist, then
// the property is created. If the "unique" argument is TRUE, then
// the property name and value combination is guaranteed to be unique
// and will not be added to the list of values if the combination already
// exists. If the cache level in the database is higher then the cache
// level passed in, the write is not done and the values of all the properties
// in the database are returned through the properties argument.
// The latest cache level is always returned.
_Tt_db_results addObjectProperty (const _Tt_string &objid,
const _Tt_db_property_ptr &property,
bool_t unique,
_Tt_db_property_list_ptr &properties,
int &cache_level);
// Deletes the object property values with the same name and values. If
// the value list is empty, then all values of the property are deleted.
// If the cache level in the database is higher then the cache level passed
// in, the write is not done and the values of all the properties
// in the database are returned through the properties argument.
// The latest cache level is always returned.
_Tt_db_results
deleteObjectProperty (const _Tt_string &objid,
const _Tt_db_property_ptr &property,
_Tt_db_property_list_ptr &properties,
int &cache_level);
// Gets the values of the object property with the specified name.
_Tt_db_results getObjectProperty (const _Tt_string &objid,
const _Tt_string &name,
int &cache_level,
_Tt_db_property_ptr &property);
// Gets a list of all of the object properties.
_Tt_db_results
getObjectProperties (const _Tt_string &objid,
int &cache_level,
_Tt_db_property_list_ptr &property);
// Sets and gets the otype of the specified object.
_Tt_db_results setObjectType (const _Tt_string &objid,
const _Tt_string &otype);
_Tt_db_results getObjectType (const _Tt_string &objid,
_Tt_string &otype);
// Sets the file of the object. This should only be used to support
// a same partition move of an object.
_Tt_db_results setObjectFile (const _Tt_string &objid,
const _Tt_string &file);
// Gets the file of the object.
_Tt_db_results getObjectFile (const _Tt_string &objid,
_Tt_string &file);
// Sets and gets the access mode of the specified object.
_Tt_db_results setObjectAccess (const _Tt_string &objid,
const _Tt_db_access_ptr &access);
_Tt_db_results getObjectAccess (const _Tt_string &objid,
_Tt_db_access_ptr &access);
_Tt_db_results
isFileInDatabase (const _Tt_string &file,
bool_t &directory_flag);
_Tt_db_results
isObjectInDatabase (const _Tt_string &objid,
_Tt_string &forward_pointer);
// For the specified file, queues the message and the list of ptypes
// that the message is addressed to.
_Tt_db_results queueMessage (const _Tt_string &file,
const _Tt_string_list_ptr &ptypes,
const _Tt_message_ptr &message);
// For the specified file, returns a list of messages that are addressed
// to the specified ptypes. If there are no other ptypes that this message
// is addressed to, the message is deleteed from the database.
_Tt_db_results dequeueMessages (const _Tt_string &file,
const _Tt_string_list_ptr &ptypes,
_Tt_message_list_ptr &messages);
// Gets the remote ends' idea of what the netfile version of the specified
// file is.
_Tt_db_results file_netfile (const _Tt_string &file, _Tt_string &netfile);
// Gets the remote ends' idea of what the file version of the specified
// netfile is.
_Tt_db_results netfile_file (const _Tt_string &netfile, _Tt_string &file);
// Return a list of all of the sessions known to the dbserver.
_Tt_string_list * get_all_sessions();
// Tell the dbserver to perform garbage collection.
_Tt_db_results garbage_collect_in_server();
// Delete the named session.
_Tt_db_results delete_session(_Tt_string session);
// ********** Old DB Server Compatibility Members **********
// The following members are used to provide compatibility
// with old DB servers. All of the member functions map directly
// to an old DB server RPC call. The names of these member functions
// have been kept the same as the base name of the corresponding
// RPC call.
_Tt_string mfs (const _Tt_string &path);
_Tt_db_results addsession (const _Tt_string &file,
const _Tt_string &session);
_Tt_db_results delsession (const _Tt_string &file,
const _Tt_string &session);
_Tt_db_results gettype (const _Tt_string &objid,
_Tt_string &type);
int isaddindex (int, struct keydesc*);
int isbuild (char*, int, struct keydesc*, int);
int isclose (int);
int iscntl (int, int, char*);
int isdelrec (int, long, char*);
int iserase (char*);
int isopen (char*, int);
int isread (int, char*, int);
int isrewrec (int, long, char*);
int isstart (int, struct keydesc*, int, char*, int);
int iswrite (int, char*);
// Data members used by the old DB server compatibility member
// functions.
int iserrno;
long isrecnum;
int isreclen;
// ********** Old DB Server Compatibility Members **********
private:
_Tt_db_access_ptr dbAccess;
int dbAuthLevel;
_Tt_db_results dbConnectionResults;
_Tt_string dbHostname;
CLIENT *dbServer;
_Tt_string dbServerNetName;
#if !defined(OPT_TLI)
sockaddr_in dbSocket;
#endif
int dbVersion;
void createAuth ();
void setTtDBDefaults ();
_Tt_db_results connectToDB (const _Tt_string&);
void SetError(enum clnt_stat cf_stat);
// ********** Old DB Server Compatibility Members **********
// Helper functions for old DB server function compatibility
_Tt_db_results oldDBToNewDBResults (_Tt_old_db_results old_db_results);
// ********** Old DB Server Compatibility Members **********
};
#endif // _TT_DB_H

View 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_client_consts.h /main/3 1995/10/23 10:01:21 rswiston $ */
/*
* tt_db_client_consts.h - Declares constants that are used by the
* client-side DB server classes.
*
* Copyright (c) 1992 by Sun Microsystems, Inc.
*
*/
#ifndef _TT_DB_CLIENT_CONSTS_H
#define _TT_DB_CLIENT_CONSTS_H
#define TT_DB_SESSION_PROPERTY "_TT_SESSIONS"
#endif /* _TT_DB_CLIENT_CONSTS_H */

View 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_client_utils.C /main/3 1995/10/23 10:01:30 rswiston $
/*
* tt_db_client_utils.cc - Defines the _Tt_db utilities.
*
* Copyright (c) 1992 by Sun Microsystems, Inc.
*/
#include "db/tt_db_client_utils.h"
implement_list_of(_Tt_db_client)
implement_table_of(_Tt_db_client)

View 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_client_utils.h /main/3 1995/10/23 10:01:38 rswiston $ */
/*
* tt_db_utils.h - Declare the _Tt_db utilities.
*
* Copyright (c) 1992 by Sun Microsystems, Inc.
*/
#ifndef _TT_DB_CLIENT_UTILS_H
#define _TT_DB_CLIENT_UTILS_H
#include "util/tt_table.h"
#include "db/tt_db_client.h"
declare_list_of(_Tt_db_client)
declare_table_of(_Tt_db_client)
#endif // _TT_DB_CLIENT_UTILS_H

View File

@@ -0,0 +1,24 @@
//%% (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_create_objid.C /main/3 1995/10/23 10:01:45 rswiston $
/*
* tt_db_create_objid.cc - Defines a routine for constructing an objid.
*
* Copyright (c) 1992 by Sun Microsystems, Inc.
*/
#include "db/tt_db_create_objid.h"
_Tt_string _tt_db_create_objid (const _Tt_db_key_ptr &object_key,
const _Tt_string &file_system_type,
const _Tt_string &hostname,
const _Tt_string &partition)
{
_Tt_string objid = object_key->string();
objid = objid.cat(":").cat(file_system_type);
objid = objid.cat(":").cat(hostname);
objid = objid.cat(":").cat(partition);
return objid;
}

View File

@@ -0,0 +1,18 @@
/*%% (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_create_objid.h /main/3 1995/10/23 10:01:52 rswiston $ */
/*
* tt_db_create_objid.h - Defines a routine for constructing an objid.
*
* Copyright (c) 1992 by Sun Microsystems, Inc.
*/
#include "util/tt_string.h"
#include "db/tt_db_key_utils.h"
extern _Tt_string _tt_db_create_objid (const _Tt_db_key_ptr&,
const _Tt_string&,
const _Tt_string&,
const _Tt_string&);

View File

@@ -0,0 +1,629 @@
//%% (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_file.C /main/3 1995/10/23 10:01:59 rswiston $
/*
* tt_db_file.cc - Implement the TT DB server file class.
*
* Copyright (c) 1992 by Sun Microsystems, Inc.
*
* NOTE: Caching is not implemented. Therefore all of the cache levels
* are always set to -1 to force a full read from the database.
*/
#include "util/tt_path.h"
#include "db/tt_db_client_consts.h"
#include "db/tt_db_file_utils.h"
#include "db/tt_db_network_path.h"
#include "db/tt_db_object_utils.h"
#include "db/tt_db_access.h"
#include "db/tt_db_property.h"
_Tt_db_file::
_Tt_db_file()
{
}
_Tt_db_file::_Tt_db_file (const _Tt_string &file)
{
if (!file.len()) {
dbResults = TT_DB_ERR_ILLEGAL_FILE;
}
else {
_Tt_db_property_list_ptr properties;
_Tt_db_access_ptr access;
dbResults = setTtDBFileDefaults(file, properties, access);
}
}
_Tt_db_file::_Tt_db_file (const _Tt_string &file,
const _Tt_db_property_list_ptr &properties,
const _Tt_db_access_ptr &access)
{
if (!file.len()) {
dbResults = TT_DB_ERR_ILLEGAL_FILE;
}
else {
dbResults = setTtDBFileDefaults(file, properties, access);
}
}
_Tt_db_results
_Tt_db_file::setTtDBFileDefaults (const _Tt_string &file,
const _Tt_db_property_list_ptr &properties,
const _Tt_db_access_ptr &access)
{
checkedDatabase = FALSE;
directoryFlag = FALSE;
dbFileCurrentAccess = new _Tt_db_access;
dbFileObjects = new _Tt_string_list;
dbFileObjectsCacheLevel = -1;
dbFilePropertiesCacheLevel = -1;
dbFilePtypes = new _Tt_string_list;
dbResults = TT_DB_OK;
if (access.is_null()) {
dbFileAccess = new _Tt_db_access;
}
else {
dbFileAccess = access;
}
if (properties.is_null()) {
dbFileProperties = new _Tt_db_property_list;
}
else {
dbFileProperties = properties;
}
if (file.len()) {
_Tt_string local_path;
if (_tt_is_network_path(file)) {
dbFile = _tt_network_path_to_local_path(file);
dbFileNetworkPath = file;
(void)dbFileNetworkPath.split(':', dbFileHostname);
}
else {
// Get the absoulte network information for the path
_Tt_string temp_string;
dbResults = _tt_db_network_path (file,
dbFile,
dbFileHostname,
dbFilePartition,
dbFileNetworkPath);
}
if ((dbResults == TT_DB_OK)) {
if (!isFileInDatabase()) {
if (dbResults != TT_DB_ERR_DB_OPEN_FAILED) {
dbResults = createDBFile();
}
}
}
}
return dbResults;
}
_Tt_db_file::~_Tt_db_file ()
{
}
void _Tt_db_file::setCurrentAccess (const _Tt_db_access_ptr &access)
{
dbFileCurrentAccess = access;
}
_Tt_db_access_ptr _Tt_db_file::getCurrentAccess () const
{
return dbFileCurrentAccess;
}
_Tt_db_results _Tt_db_file::remove ()
{
if (dbFileNetworkPath.len()) {
setCurrentDBAccess ();
dbResults = dbFileDatabase->removeFile(dbFileNetworkPath);
if (dbResults == TT_DB_OK) {
dbFile = (char *)NULL;
dbFileNetworkPath = (char *)NULL;
dbFileProperties = (_Tt_db_property_list *)NULL;
dbFileAccess = (_Tt_db_access *)NULL;
}
}
else {
dbResults = TT_DB_ERR_ILLEGAL_FILE;
}
return processDBResults();
}
_Tt_db_results _Tt_db_file::copy (const _Tt_string &new_file)
{
if (!new_file.len()) {
return (dbResults = TT_DB_ERR_ILLEGAL_FILE);
}
if (isFileInDatabase()) {
_Tt_string new_local_path;
_Tt_string new_hostname;
_Tt_string new_partition;
_Tt_string new_network_path;
dbResults = _tt_db_network_path(new_file,
new_local_path,
new_hostname,
new_partition,
new_network_path);
if (dbResults == TT_DB_OK) {
// If we're not copying to the exact same file
if (dbFileNetworkPath != new_network_path) {
setCurrentDBAccess();
_Tt_db_property_list_ptr properties = getProperties();
_Tt_db_access_ptr access = getAccess ();
_Tt_string_list_ptr objids = getObjects();
if (dbResults == TT_DB_OK) {
_Tt_db_file_ptr new_db_file = new _Tt_db_file(new_network_path,
properties,
access);
_Tt_string_list_cursor objids_cursor(objids);
while (objids_cursor.next()) {
_Tt_db_object_ptr object = new _Tt_db_object(*objids_cursor);
(void)object->copy(new_file);
}
}
}
else {
dbResults = TT_DB_ERR_SAME_FILE;
}
}
}
else {
dbResults = TT_DB_ERR_ILLEGAL_FILE;
}
return dbResults;
}
_Tt_db_results _Tt_db_file::move (const _Tt_string &new_file)
{
if (!new_file.len()) {
return (dbResults = TT_DB_ERR_ILLEGAL_FILE);
}
if (isFileInDatabase()) {
// Get the hostname and remote path of the new file
_Tt_string new_local_path;
_Tt_string new_hostname;
_Tt_string new_partition;
_Tt_string new_network_path;
dbResults = _tt_db_network_path(new_file,
new_local_path,
new_hostname,
new_partition,
new_network_path);
if (dbResults == TT_DB_OK) {
// If we're not moving to the exact same file
if (dbFileNetworkPath != new_network_path) {
setCurrentDBAccess();
if (dbResults == TT_DB_OK) {
// If is the new file is on the same machine...
if (dbFileHostname == new_hostname) {
// We're not allowed to move directories across partitions
if (directoryFlag && (dbFilePartition != new_partition)) {
dbResults = TT_DB_ERR_ILLEGAL_FILE;
}
else {
dbResults = dbFileDatabase->moveFile(dbFileNetworkPath,
new_network_path);
if (dbResults == TT_DB_OK) {
// Change the official file of this object
_Tt_db_property_list_ptr properties;
_Tt_db_access_ptr access;
dbResults = setTtDBFileDefaults(new_network_path,
properties,
access);
}
}
}
// Else, the move is between different hosts...
else {
// We're not allowed to move directories across machines
if (directoryFlag) {
dbResults = TT_DB_ERR_ILLEGAL_FILE;
}
// Not a directory, move it...
else {
_Tt_db_property_list_ptr properties = getProperties();
_Tt_db_access_ptr access = getAccess ();
_Tt_string_list_ptr objids = getObjects();
if (dbResults == TT_DB_OK) {
_Tt_db_file_ptr new_db_file = new _Tt_db_file(new_network_path,
properties,
access);
_Tt_string_list_cursor objids_cursor(objids);
while (objids_cursor.next()) {
_Tt_db_object_ptr object = new _Tt_db_object(*objids_cursor);
(void)object->move(new_network_path);
}
}
}
if (dbResults == TT_DB_OK) {
dbResults = dbFileDatabase->removeFile(dbFileNetworkPath);
}
if (dbResults == TT_DB_OK) {
// Change the official file of this object
_Tt_db_property_list_ptr properties;
_Tt_db_access_ptr access;
dbResults = setTtDBFileDefaults(new_network_path,
properties,
access);
}
}
}
}
else {
dbResults = TT_DB_ERR_SAME_FILE;
}
}
}
else {
dbResults = TT_DB_ERR_ILLEGAL_FILE;
}
return dbResults;
}
_Tt_string _Tt_db_file::getHostname ()
{
return dbFileHostname;
}
_Tt_db_results
_Tt_db_file::setProperty (const _Tt_db_property_ptr &property)
{
if (isFileInDatabase()) {
setCurrentDBAccess();
dbResults = dbFileDatabase->setFileProperty(dbFileNetworkPath,
property,
dbFilePropertiesCacheLevel);
}
else {
dbResults = TT_DB_ERR_ILLEGAL_FILE;
}
return processDBResults();
}
_Tt_db_results
_Tt_db_file::setProperties (const _Tt_db_property_list_ptr &properties)
{
if (isFileInDatabase()) {
setCurrentDBAccess();
dbResults =
dbFileDatabase->setFileProperties(dbFileNetworkPath,
properties,
dbFilePropertiesCacheLevel);
}
else {
dbResults = TT_DB_ERR_ILLEGAL_FILE;
}
return processDBResults();
}
_Tt_db_results
_Tt_db_file::addProperty (const _Tt_db_property_ptr &property,
bool_t unique)
{
if (isFileInDatabase()) {
setCurrentDBAccess();
dbResults = dbFileDatabase->addFileProperty(dbFileNetworkPath,
property,
unique,
dbFilePropertiesCacheLevel);
}
else {
dbResults = TT_DB_ERR_ILLEGAL_FILE;
}
return processDBResults();
}
_Tt_db_results
_Tt_db_file::deleteProperty (const _Tt_db_property_ptr &property)
{
if (isFileInDatabase()) {
setCurrentDBAccess();
dbResults =
dbFileDatabase->deleteFileProperty(dbFileNetworkPath,
property,
dbFilePropertiesCacheLevel);
}
else {
dbResults = TT_DB_ERR_ILLEGAL_FILE;
}
return processDBResults();
}
_Tt_db_property_ptr _Tt_db_file::getProperty (const _Tt_string &name)
{
_Tt_db_property_ptr property;
if (isFileInDatabase()) {
setCurrentDBAccess();
dbFilePropertiesCacheLevel = -1;
dbResults = dbFileDatabase->getFileProperty(dbFileNetworkPath,
name,
dbFilePropertiesCacheLevel,
property);
}
else {
dbResults = TT_DB_ERR_ILLEGAL_FILE;
}
dbResults = processDBResults();
return property;
}
_Tt_db_property_list_ptr _Tt_db_file::getProperties ()
{
_Tt_db_property_list_ptr properties;
if (isFileInDatabase()) {
setCurrentDBAccess();
dbFilePropertiesCacheLevel = -1;
dbResults = dbFileDatabase->getFileProperties(dbFileNetworkPath,
dbFilePropertiesCacheLevel,
properties);
}
else {
dbResults = TT_DB_ERR_ILLEGAL_FILE;
}
dbResults = processDBResults();
return properties;
}
_Tt_string_list_ptr _Tt_db_file::getObjects ()
{
_Tt_string_list_ptr objids;
if (isFileInDatabase()) {
setCurrentDBAccess();
dbFileObjectsCacheLevel = -1;
dbResults = dbFileDatabase->getFileObjects(dbFileNetworkPath,
dbFileObjectsCacheLevel,
objids);
}
else {
dbResults = TT_DB_ERR_ILLEGAL_FILE;
}
dbResults = processDBResults();
return objids;
}
_Tt_db_results _Tt_db_file::setAccess (const _Tt_db_access_ptr &access)
{
if (isFileInDatabase()) {
setCurrentDBAccess();
dbResults = dbFileDatabase->setFileAccess(dbFileNetworkPath, access);
}
else {
dbResults = TT_DB_ERR_ILLEGAL_FILE;
}
return processDBResults();
}
_Tt_db_access_ptr _Tt_db_file::getAccess ()
{
_Tt_db_access_ptr access;
if (isFileInDatabase()) {
setCurrentDBAccess();
dbResults = dbFileDatabase->getFileAccess(dbFileNetworkPath, access);
}
else {
dbResults = TT_DB_ERR_ILLEGAL_FILE;
}
dbResults = processDBResults();
return access;
}
_Tt_db_results _Tt_db_file::addSession (const _Tt_string &session)
{
_Tt_db_property_ptr property = new _Tt_db_property;
property->name = TT_DB_SESSION_PROPERTY;
_Tt_string value = session;
(void)property->values->append(value);
return addProperty(property, TRUE);
}
_Tt_db_results _Tt_db_file::deleteSession (const _Tt_string &session)
{
_Tt_db_property_ptr property = new _Tt_db_property;
property->name = TT_DB_SESSION_PROPERTY;
_Tt_string value = session;
property->values->append(value);
return deleteProperty(property);
}
_Tt_string_list_ptr _Tt_db_file::getSessions ()
{
_Tt_db_property_ptr property;
_Tt_string_list_ptr sessions;
if (isFileInDatabase()) {
_Tt_string name(TT_DB_SESSION_PROPERTY);
property = getProperty(name);
if (dbResults == TT_DB_ERR_NO_SUCH_PROPERTY) {
dbResults = TT_DB_OK;
}
if (!property.is_null()) {
if (!property->is_empty()) {
sessions = new _Tt_string_list;
_Tt_string_list_cursor values_cursor(property->values);
while (values_cursor.next()) {
sessions->append(*values_cursor);
}
}
}
}
return sessions;
}
_Tt_db_results
_Tt_db_file::queueMessage (const _Tt_string_list_ptr &ptypes,
const _Tt_message_ptr &message)
{
if (isFileInDatabase()) {
dbResults = dbFileDatabase->queueMessage(dbFileNetworkPath,
ptypes,
message);
}
else {
dbResults = TT_DB_ERR_ILLEGAL_FILE;
}
return dbResults;
}
_Tt_db_results
_Tt_db_file::dequeueMessages (const _Tt_string_list_ptr &ptypes,
_Tt_message_list_ptr &messages)
{
if (isFileInDatabase()) {
dbResults = dbFileDatabase->dequeueMessages(dbFileNetworkPath,
ptypes,
messages);
}
else {
dbResults = TT_DB_ERR_ILLEGAL_FILE;
}
return dbResults;
}
_Tt_string _Tt_db_file::getNetworkPath (const _Tt_string &file)
{
_Tt_string network_path;
if (file.len()) {
if (_tt_is_network_path(file)) {
network_path = file;
}
else {
_Tt_string local_path;
_Tt_string hostname;
_Tt_string partition;
_Tt_db_results results = _tt_db_network_path(file,
local_path,
hostname,
partition,
network_path);
}
}
return network_path;
}
_Tt_db_results _Tt_db_file::createDBFile ()
{
if (!isFileInDatabase()) {
dbFileDatabase = dbHostnameGlobalMapRef.getDB(dbFileHostname,
dbFileHostname,
dbResults);
if (dbFileDatabase.is_null()) {
return dbResults;
}
int cache_level = -1;
setCurrentDBAccess ();
dbResults = dbFileDatabase->createFile(dbFileNetworkPath,
dbFileProperties,
dbFileAccess,
cache_level);
dbFileObjectsCacheLevel = cache_level;
dbFilePropertiesCacheLevel = cache_level;
}
else {
dbResults = TT_DB_ERR_FILE_EXISTS;
}
return processDBResults();
}
bool_t _Tt_db_file::isFileInDatabase ()
{
// Property caching is not currently implemented in _Tt_db_file,
// so this function does not read the properties from the database
// if the file exists. If caching is added, this is where the
// cache should be initially filled from.
if (!checkedDatabase) {
checkedDatabase = TRUE;
dbFileDatabase = dbHostnameGlobalMapRef.getDB(dbFileHostname,
dbFileHostname,
dbResults);
if (dbFileDatabase.is_null() || dbResults != TT_DB_OK) {
return FALSE;
}
_Tt_db_access_ptr access;
dbResults = dbFileDatabase->isFileInDatabase(dbFileNetworkPath,
directoryFlag);
if (dbResults != TT_DB_OK) {
dbHostnameGlobalMapRef.removeDB(dbFileHostname);
dbFileDatabase = (_Tt_db_client *)NULL;
}
}
return (dbFileDatabase.is_null() ? FALSE : TRUE);
}
_Tt_db_results _Tt_db_file::processDBResults ()
{
// If an RPC fails, assume the DB server went down and attempt to
// reconnect to it
if ((dbResults == TT_DB_ERR_DB_CONNECTION_FAILED) ||
(dbResults == TT_DB_ERR_RPC_CONNECTION_FAILED) ||
(dbResults == TT_DB_ERR_RPC_FAILED) ||
(dbResults == TT_DB_ERR_DB_OPEN_FAILED)) {
if (!dbFileDatabase.is_null()) {
dbHostnameGlobalMapRef.removeDB(dbFileHostname);
dbFileDatabase = dbHostnameGlobalMapRef.getDB(dbFileHostname,
dbFileHostname,
dbResults);
}
}
return dbResults;
}

View File

@@ -0,0 +1,193 @@
/*%% (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_file.h /main/3 1995/10/23 10:02:07 rswiston $ */
/*
* tt_db_file.h - Declare the TT DB server file class. This class defines the
* file properties interface to the DB server.
*
* Copyright (c) 1992 by Sun Microsystems, Inc.
*/
#ifndef _TT_DB_FILE_H
#define _TT_DB_FILE_H
#include "util/tt_object.h"
#include "util/tt_string.h"
#include "db/tt_db_hostname_global_map_ref.h"
#include "db/tt_db_access_utils.h"
#include "db/tt_db_property_utils.h"
#if defined(OPT_BUG_HPUX) || defined(OPT_BUG_AIX) || defined(__osf__)
# undef copy
#endif
class _Tt_db_file : public _Tt_object {
public:
_Tt_db_file ();
// If the file already exists in the DB on its partition, then
// the DB is connected to when it needs to be. If the file
// does not exist on the database, the file entry is created
// on the database.
_Tt_db_file (const _Tt_string &file);
_Tt_db_file (const _Tt_string &file,
const _Tt_db_property_list_ptr &properties,
const _Tt_db_access_ptr &access);
~_Tt_db_file ();
// Sets and gets the access mode of this file.
void setCurrentAccess (const _Tt_db_access_ptr &access);
_Tt_db_access_ptr getCurrentAccess () const;
// Removes the file and all of its objects from the database. Once this is
// called this particular object instantiation is useless until "setFile" has
// been called.
_Tt_db_results remove ();
// Copies the file to the new file name
_Tt_db_results copy (const _Tt_string &new_file);
// Moves the file to the new file name
_Tt_db_results move (const _Tt_string &new_file);
// Gets the local path of the file. Regardless of what path was specified
// in the object constructor, getLocalPath always returns the real path
// (the result of _tt_realpath).
const _Tt_string& getLocalPath () const
{
return dbFile;
}
// Gets the network absolute path of the file. The path is in the
// form:
//
// hostname:/path
//
const _Tt_string& getNetworkPath () const
{
return dbFileNetworkPath;
}
// Gets the network absolute path of the file argument. The path
// is in the form:
//
// hostname:/path
//
static _Tt_string getNetworkPath (const _Tt_string &file);
// Returns the hostname of the machine the file is located on.
_Tt_string getHostname ();
// Writes the specified file property to the database. All values of the
// the file property with the same name are overwritten. If the value of
// the property is NULL, this deletes all properties with the same name
// from the database.
_Tt_db_results setProperty (const _Tt_db_property_ptr &property);
// Writes the specified file properties to the database. All values of the
// the file properties with the same names are overwritten. If the value of
// some of the properties are NULL, this deletes all properties with the same
// name from the database.
_Tt_db_results setProperties (const _Tt_db_property_list_ptr &properties);
// Adds a file property to the list of values of the file property
// with the same name. If the property does not already exist, then
// the property is created. If the "unique" argument is TRUE, then
// the property name and value combination is guaranteed to be unique
// and will not be added to the list of values if the combination already
// exists.
_Tt_db_results addProperty (const _Tt_db_property_ptr &property,
bool_t unique=FALSE);
// Deletes the file property value with the same name and value. If
// the value is left empty, then all values of the property are deleted.
_Tt_db_results deleteProperty (const _Tt_db_property_ptr &property);
// Gets the values of the file property with the specified name.
_Tt_db_property_ptr getProperty (const _Tt_string &name);
// Gets a list of all of the file properties.
_Tt_db_property_list_ptr getProperties ();
// Returns a list of all of the object IDs for the specified file.
_Tt_string_list_ptr getObjects ();
// Sets and gets the access mode of the specified file.
_Tt_db_results setAccess (const _Tt_db_access_ptr &access);
_Tt_db_access_ptr getAccess ();
// Add a session to the file
_Tt_db_results addSession (const _Tt_string &session);
// Delete a session from the file
_Tt_db_results deleteSession (const _Tt_string &session);
// Get a list of sessions that have joined this file
_Tt_string_list_ptr getSessions ();
// For this file, queues the message and the list of ptypes
// that the message is addressed to.
_Tt_db_results queueMessage (const _Tt_string_list_ptr &ptypes,
const _Tt_message_ptr &message);
// For this file, returns a list of messages that are addressed
// the specified ptypes. If there are no other ptypes that this message
// is addressed to, the message is deleted from the database.
_Tt_db_results dequeueMessages (const _Tt_string_list_ptr &ptypes,
_Tt_message_list_ptr &messages);
// Gets the results of the last database operation made with this object.
_Tt_db_results getDBResults () const
{
return dbResults;
}
private:
bool_t checkedDatabase;
bool_t directoryFlag;
_Tt_string dbFile;
_Tt_db_access_ptr dbFileAccess;
_Tt_db_access_ptr dbFileCurrentAccess;
_Tt_db_client_ptr dbFileDatabase;
_Tt_string dbFileHostname;
_Tt_string dbFileNetworkPath;
_Tt_string_list_ptr dbFileObjects;
int dbFileObjectsCacheLevel;
_Tt_string dbFilePartition;
_Tt_db_property_list_ptr dbFileProperties;
int dbFilePropertiesCacheLevel;
_Tt_string_list_ptr dbFilePtypes;
_Tt_db_hostname_global_map_ref dbHostnameGlobalMapRef;
_Tt_db_results dbResults;
// Sets the file in the database that the object is operating on.
// If the file already exists in the DB on its partition, then
// the DB is connected to when it needs to be. If the file
// does not exist on the database, the file entry is created
// on the database.
_Tt_db_results setTtDBFileDefaults (const _Tt_string&,
const _Tt_db_property_list_ptr&,
const _Tt_db_access_ptr&);
_Tt_db_results createDBFile ();
bool_t isFileInDatabase ();
//
// Does some special results processing for any public member functions
// that do some database server operations. It should be used to get
// the final results for all such member functions. Member functions
// that are not public or that only work on the memory copy of the
// object should not call processDBResults.
//
_Tt_db_results processDBResults ();
void setCurrentDBAccess ()
{
if (!dbFileDatabase.is_null()) {
dbFileDatabase->setCurrentAccess(dbFileCurrentAccess);
}
}
};
#endif // _TT_DB_FILE_H

View 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_file_utils.C /main/3 1995/10/23 10:02:14 rswiston $
/*
* tt_db_file_utils.cc - Defines the _Tt_db_file utilities.
*
* Copyright (c) 1992 by Sun Microsystems, Inc.
*/
#include "db/tt_db_file_utils.h"
implement_ptr_to(_Tt_db_file)

View 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_db_file_utils.h /main/3 1995/10/23 10:02:22 rswiston $ */
/*
* tt_db_file_utils.h - Declare the _Tt_db_file utilities.
*
* Copyright (c) 1992 by Sun Microsystems, Inc.
*/
#ifndef _TT_DB_FILE_UTILS_H
#define _TT_DB_FILE_UTILS_H
#include "util/tt_table.h"
#include "db/tt_db_file.h"
declare_ptr_to(_Tt_db_file)
#endif // _TT_DB_FILE_UTILS_H

View File

@@ -0,0 +1,86 @@
//%% (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_hostname_global_map_ref.C /main/3 1995/10/23 10:02:29 rswiston $
/*
* tt_db_hostname_global_map_ref.cc - Define the TT DB client hostname global
* map ref class. This class contains a global map
* that provides a hostname to DB connection mapping.
* This way only one RPC connection per machine is
* created.
*
* Copyright (c) 1992 by Sun Microsystems, Inc.
*/
#include "db/tt_db_hostname_global_map_ref.h"
#include "util/tt_global_env.h"
_Tt_db_client_table_ptr*
_Tt_db_hostname_global_map_ref::dbHostnameMap = (_Tt_db_client_table_ptr *)NULL;
_Tt_db_hostname_global_map_ref::_Tt_db_hostname_global_map_ref ()
{
if (!dbHostnameMap) {
dbHostnameMap = new _Tt_db_client_table_ptr;
*dbHostnameMap = new _Tt_db_client_table
((_Tt_object_table_keyfn)
&_Tt_db_hostname_global_map_ref::dbHostnameMapKey);
}
}
_Tt_db_hostname_global_map_ref::~_Tt_db_hostname_global_map_ref ()
{
// The static table is freed up when the application dies or when
// _Tt_db_hostname_global_map_ref::flush() is called.
}
void _Tt_db_hostname_global_map_ref::addDB (_Tt_db_client_ptr &db)
{
(*dbHostnameMap)->insert(db);
}
void _Tt_db_hostname_global_map_ref::removeDB (const _Tt_string &hostname)
{
(*dbHostnameMap)->remove(hostname);
}
_Tt_db_client_ptr
_Tt_db_hostname_global_map_ref::getDB (const _Tt_string &hostname,
_Tt_string &real_hostname,
_Tt_db_results &results)
{
_Tt_string temp_hostname = _tt_global->db_hr_map.findEntry(hostname);
if (temp_hostname.is_null() || !temp_hostname.len()) {
temp_hostname = hostname;
}
real_hostname = temp_hostname;
_Tt_db_client_ptr db_ptr = (*dbHostnameMap)->lookup(real_hostname);
if (db_ptr.is_null()) {
db_ptr = new _Tt_db_client(real_hostname, results);
if (results != TT_DB_OK) { /* Can't happen ??? */
db_ptr = (_Tt_db_client *)0;
return db_ptr;
}
addDB(db_ptr);
}
else {
results = TT_DB_OK;
}
return db_ptr;
}
_Tt_string _Tt_db_hostname_global_map_ref::dbHostnameMapKey (_Tt_object_ptr &db)
{
return (((_Tt_db_client *)db.c_pointer())->getHostname());
}
void _Tt_db_hostname_global_map_ref::flush ()
{
if (dbHostnameMap) {
delete dbHostnameMap;
}
dbHostnameMap = (_Tt_db_client_table_ptr *)NULL;
}

View File

@@ -0,0 +1,43 @@
/*%% (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_hostname_global_map_ref.h /main/3 1995/10/23 10:02:37 rswiston $ */
/*
* tt_db_hostname_global_map_ref.h - Declare the TT DB server hostname
* global map ref class. This class
* contains a global map that provides
* a hostname to DB connection mapping.
* This way only one RPC connection per
* machine is created.
*
* Copyright (c) 1992 by Sun Microsystems, Inc.
*/
#ifndef _TT_DB_HOSTNAME_GLOBAL_MAP_REF_H
#define _TT_DB_HOSTNAME_GLOBAL_MAP_REF_H
#include "util/tt_new.h"
#include "util/tt_string.h"
#include "db/tt_db_client_utils.h"
class _Tt_db_hostname_global_map_ref : public _Tt_allocated {
public:
_Tt_db_hostname_global_map_ref ();
~_Tt_db_hostname_global_map_ref ();
void addDB (_Tt_db_client_ptr &db);
void removeDB (const _Tt_string &hostname);
_Tt_db_client_ptr getDB (const _Tt_string &hostname,
_Tt_string &real_hostname,
_Tt_db_results &dbResults);
static void flush ();
static _Tt_string dbHostnameMapKey (_Tt_object_ptr &db);
private:
static _Tt_db_client_table_ptr *dbHostnameMap;
};
#endif // _TT_DB_HOSTNAME_GLOBAL_MAP_REF_H

View File

@@ -0,0 +1,50 @@
//%% (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_hostname_redirection_map.C /main/3 1995/10/23 10:02:44 rswiston $
/*
* Tool Talk Utility - tt_hostname_redirection_map.cc
*
* Copyright (c) 1990 by Sun Microsystems, Inc.
*
* Defines a hostname redirection map. A global version
* of this object is in _tt_global.
*/
#include "db/tt_db_hostname_redirection_map.h"
#include "util/tt_path.h"
static const char hr_map_file[] = "hostname_map";
static const char hr_map_env[] = "_SUN_TT_HOSTNAME_MAP";
static const char hr_cde_map_env[] = "TT_HOSTNAME_MAP";
_Tt_db_hostname_redirection_map::
_Tt_db_hostname_redirection_map ()
{
map = new _Tt_string_map((_Tt_object_table_keyfn)
&_Tt_map_entry::getAddress);
}
_Tt_db_hostname_redirection_map::
~_Tt_db_hostname_redirection_map ()
{
}
_Tt_string _Tt_db_hostname_redirection_map::
findEntry(const _Tt_string &address)
{
return map->findEntry(address);
}
void _Tt_db_hostname_redirection_map::
refresh ()
{
// give preference to the cde named setting
const char *hr_map_env_to_use = (getenv(hr_cde_map_env) ? hr_cde_map_env : hr_map_env);
_Tt_string path = _tt_user_path (hr_map_file, hr_map_env_to_use, FALSE);
if (path.len()>0) {
map->loadFile(path);
}
}

View File

@@ -0,0 +1,35 @@
/*%% (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_hostname_redirection_map.h /main/3 1995/10/23 10:02:51 rswiston $ */
/* @(#)tt_db_hostname_redirection_map.h 1.5 @(#)
* Tool Talk Utility - tt_hostname_redirection_map.h
*
* Copyright (c) 1990 by Sun Microsystems, Inc.
*
* Declares a hostname redirection map. A global version
* of this object is in _tt_global.
*/
#ifndef _TT_HOSTNAME_REDIRECTION_MAP_H
#define _TT_HOSTNAME_REDIRECTION_MAP_H
#include "util/tt_object.h"
#include "util/tt_string_map_utils.h"
#include "util/tt_string_map.h"
#include "util/tt_map_entry.h"
class _Tt_db_hostname_redirection_map : public _Tt_object {
public:
_Tt_db_hostname_redirection_map ();
~_Tt_db_hostname_redirection_map ();
void refresh ();
_Tt_string findEntry(const _Tt_string &address);
private:
_Tt_string_map_ptr map;
};
#endif /* _TT_HOSTNAME_REDIRECTION_MAP_H */

View File

@@ -0,0 +1,105 @@
//%% (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_key.C /main/3 1995/10/23 10:02:59 rswiston $
/*
* @(#)tt_db_key.C 1.10 93/09/07
+ Implements the TT db server key class.
*
* Copyright (c) 1992 by Sun Microsystems, Inc.
*/
#include <util/tt_base64.h>
#include <sys/types.h>
#include <time.h>
#include <sys/time.h>
#include <unistd.h>
#include "util/tt_base64.h"
#include "util/tt_port.h"
#include "db/tt_db_key.h"
_Tt_db_key::_Tt_db_key (short version_number)
{
static long last_time_sec = 0;
static long counter = 0;
key.version = version_number;
key.padding = 0;
key.hostid = _tt_gethostid();
key.time_sec = time ((time_t *) NULL);
if (key.time_sec != last_time_sec) {
last_time_sec = key.time_sec;
counter = getpid() * 10000;
}
key.counter = counter++;
}
_Tt_db_key::_Tt_db_key (const _Tt_string &string)
{
// If this is an actual key...
if ((string.len() == TT_DB_KEY_LENGTH) && (string[0] < '0')) {
(void)memcpy((char *)&key, (char *)string, TT_DB_KEY_LENGTH);
}
// Else, assume this is an objid...
else {
_Tt_string key_string = (char *)string;
_Tt_string temp_string;
// Get the version number
key_string = key_string.split('|', temp_string);
key.version = (unsigned short)_tt_base64_decode(temp_string);
// In the future, if the key format changes, it may be necessary
// to check the version here and decode according to the version
// number.
// Set the padding to 2 bytes of 0
key.padding = (unsigned short)0;
// Get the host ID
key_string = key_string.split('|', temp_string);
key.hostid = _tt_base64_decode(temp_string);
// Get the first time component
key_string = key_string.split('|', temp_string);
key.time_sec = _tt_base64_decode(temp_string);
// Get the last time component
if (key_string.index(':') == -1) {
key.counter = _tt_base64_decode(key_string);
}
else {
key_string = key_string.split(':', temp_string);
key.counter = _tt_base64_decode(temp_string);
}
}
}
_Tt_db_key::~_Tt_db_key ()
{
}
_Tt_string _Tt_db_key::string () const
{
_Tt_string result(_tt_base64_encode(key.version));
result = result.cat("|");
result = result.cat(_tt_base64_encode(key.hostid)).cat("|");
result = result.cat(_tt_base64_encode(key.time_sec)).cat("|");
result = result.cat(_tt_base64_encode(key.counter));
return result;
}
int _Tt_db_key::
operator== (const _Tt_db_key &otherkey) const
{
// Very minor optimization:: compare the most likely differences
// first
return (key.time_sec==otherkey.key.time_sec &&
key.counter==otherkey.key.counter &&
key.version==otherkey.key.version &&
key.padding==otherkey.key.padding &&
key.hostid==otherkey.key.hostid);
}

View File

@@ -0,0 +1,66 @@
/*%% (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_key.h /main/4 1996/07/30 17:41:16 barstow $ */
/*
* tt_db_key.h - Defines the TT db server key class. This class is used to
* create unique object keys and object IDs. The key layout
* is:
*
* <00> <zero pad:2> <host id:4> <time sec:4> <counter:4>
*
* The padding goes before the host id to align the host id on an int boundary.
*
* Copyright (c) 1992 by Sun Microsystems, Inc.
*/
#ifndef _TT_DB_KEY_H
#define _TT_DB_KEY_H
#include "util/tt_object.h"
#include "util/tt_string.h"
struct _Tt_key_data {
unsigned short version;
unsigned short padding;
#ifdef __osf__
/* These fields need to be: <host id:4> <time sec:4> <counter:4> */
unsigned int hostid;
unsigned int time_sec;
unsigned int counter;
#else
unsigned long hostid;
unsigned long time_sec;
unsigned long counter;
#endif /* __osf__ */
};
const int TT_DB_KEY_LENGTH = sizeof(_Tt_key_data);
class _Tt_db_key : public _Tt_object {
public:
_Tt_db_key (short version_number=0);
_Tt_db_key (const _Tt_string&);
~_Tt_db_key ();
_Tt_string string () const;
_Tt_string binary () const
{
_Tt_string binary_string(TT_DB_KEY_LENGTH);
memcpy((char *)binary_string, (char *)&key, TT_DB_KEY_LENGTH);
return binary_string;
}
int operator==(const _Tt_db_key &otherkey) const;
int operator!=(const _Tt_db_key &otherkey) const
{ return ! operator==(otherkey);}
void print(FILE *fs) const
{ fprintf(fs, "%s", (char *)(this->string())); }
private:
_Tt_key_data key;
};
#endif /* _TT_DB_KEY_H */

View 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_key_utils.C /main/3 1995/10/23 10:03:14 rswiston $
/*
* tt_db_key_utils.cc - Defines the _Tt_db_key utilities.
*
* Copyright (c) 1992 by Sun Microsystems, Inc.
*/
#include "db/tt_db_key_utils.h"
implement_ptr_to(_Tt_db_key)

View 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_key_utils.h /main/3 1995/10/23 10:03:22 rswiston $ */
/*
* tt_db_key_utils.h - Declares the _Tt_db_key utilities.
*
* Copyright (c) 1992 by Sun Microsystems, Inc.
*/
#ifndef _TT_DB_KEY_UTILS_H
#define _TT_DB_KEY_UTILS_H
#include "db/tt_db_key.h"
declare_ptr_to(_Tt_db_key)
#endif // _TT_DB_KEY_UTILS_H

View 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_network_path.C /main/3 1995/10/23 10:03:29 rswiston $
/*
* tt_db_network_path.cc - Defines a function that takes a local
* path and returns the real local path, hostname, partition
* and real remote path of the file. The partition and real
* remote path are for the file on its native host.
*
* Copyright (c) 1990 by Sun Microsystems, Inc.
*
* Implementation for filepath utility functions
*
*/
#include "util/tt_path.h"
#include "util/tt_file_system.h"
#include "util/tt_file_system_entry.h"
#include "db/tt_db_hostname_global_map_ref.h"
_Tt_db_results _tt_db_network_path (const _Tt_string &path,
_Tt_string &local_path,
_Tt_string &hostname,
_Tt_string &partition,
_Tt_string &network_path)
{
_Tt_db_results results = TT_DB_OK;
if (_tt_is_network_path(path)) {
local_path = _tt_network_path_to_local_path(path);
} else {
local_path = _tt_realpath(path);
}
_Tt_file_system file_system;
_Tt_file_system_entry_ptr file_system_entry =
file_system.bestMatchToPath(local_path);
hostname = file_system_entry->getHostname();
if (file_system_entry->isLocal()) {
partition = file_system_entry->getMountPoint();
_Tt_string loop_back_mount_point =
file_system_entry->getLoopBackMountPoint();
if (loop_back_mount_point.len ()) {
// Get the path info after the mount point path
local_path = local_path.right(local_path.len() -
loop_back_mount_point.len());
// Replace the mount point path with
// the exported partition path.
if (partition != "/") {
local_path = loop_back_mount_point.cat(local_path);
}
}
network_path = hostname.cat(":").cat(local_path);
} else {
_Tt_db_hostname_global_map_ref map_ref;
_Tt_db_client_ptr database =
map_ref.getDB(hostname, hostname, results);
if (!database.is_null()) {
_Tt_string temp_string;
_Tt_string local_network_path;
if (_tt_is_network_path(path)) {
local_network_path = path;
} else {
local_network_path =
_tt_local_network_path(path);
}
results = database->getFilePartition(local_network_path,
partition,
network_path);
}
if ((results == TT_DB_ERR_DB_CONNECTION_FAILED) ||
(results == TT_DB_ERR_RPC_CONNECTION_FAILED) ||
(results == TT_DB_ERR_RPC_FAILED) ||
(results == TT_DB_ERR_DB_OPEN_FAILED)) {
map_ref.removeDB (hostname);
}
}
return results;
}

View File

@@ -0,0 +1,27 @@
/*%% (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_network_path.h /main/3 1995/10/23 10:03:37 rswiston $ */
/*
* Tool Talk Utility - tt_db_network_path.h
*
* Copyright (c) 1990 by Sun Microsystems, Inc.
*
* Extern declarations for filepath utility functions
*
*/
#ifndef _TT_DB_NETWORK_PATH_H
#define _TT_DB_NETWORK_PATH_H
#include <util/tt_string.h>
#include <db/tt_db_results.h>
extern _Tt_db_results _tt_db_network_path(const _Tt_string &path,
_Tt_string &local_path,
_Tt_string &hostname,
_Tt_string &partition,
_Tt_string &network_path);
#endif /* _TT_DB_NETWORK_PATH_H */

View File

@@ -0,0 +1,804 @@
//%% (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_object.C /main/3 1995/10/23 10:03:44 rswiston $
/*
* tt_db_object.cc - Implement the TT DB server object class.
*
* Copyright (c) 1992 by Sun Microsystems, Inc.
*
*/
#include "db/tt_db_create_objid.h"
#include "db/tt_db_key_utils.h"
#include "db/tt_db_network_path.h"
#include "db/tt_db_object_utils.h"
#include "db/tt_db_objid_to_key.h"
#include "db/tt_db_access.h"
#include "db/tt_db_property.h"
#define TT_DB_PROPS_CACHE_LEVEL_PROPERTY "_MODIFICATION_DATE"
_Tt_db_object::_Tt_db_object ()
{
setTtDBObjectDefaults();
}
_Tt_db_object::_Tt_db_object (const _Tt_string &objid)
{
setTtDBObjectDefaults();
dbObjectID = objid;
getDBObjectHostnameFromID ();
if (isObjectInDatabase()) {
dbObjectPropertiesCacheLevel = -1;
setCurrentDBAccess ();
dbResults =
dbObjectDatabase->getObjectProperties(dbObjectID,
dbObjectPropertiesCacheLevel,
dbObjectProperties);
memoryObjectCreated = TRUE;
if ((dbResults == TT_DB_ERR_DB_CONNECTION_FAILED) ||
(dbResults == TT_DB_ERR_RPC_CONNECTION_FAILED)) {
dbHostnameGlobalMapRef.removeDB (dbObjectHostname);
}
}
else {
dbResults = TT_DB_ERR_NO_SUCH_OBJECT;
}
}
void _Tt_db_object::setTtDBObjectDefaults ()
{
checkedDatabase = FALSE;
dbObjectAccess = new _Tt_db_access;
dbObjectCurrentAccess = new _Tt_db_access;
dbObjectProperties = new _Tt_db_property_list;
dbObjectPropertiesCacheLevel = -1;
dbResults = TT_DB_OK;
forwardPointerFlag = FALSE;
memoryObjectCreated = FALSE;
}
_Tt_db_object::~_Tt_db_object ()
{
}
void _Tt_db_object::setCurrentAccess (const _Tt_db_access_ptr &access)
{
dbObjectCurrentAccess = access;
}
_Tt_db_access_ptr _Tt_db_object::getCurrentAccess () const
{
return dbObjectCurrentAccess;
}
_Tt_string _Tt_db_object::create (const _Tt_string &file)
{
_Tt_string empty;
return create(file, empty);
}
_Tt_string _Tt_db_object::create (const _Tt_string &file,
const _Tt_string &key)
{
if (!memoryObjectCreated) {
if (!file.len()) {
dbResults = TT_DB_ERR_ILLEGAL_FILE;
}
else {
dbResults = createMemoryObject(file, key);
if (dbResults == TT_DB_OK) {
memoryObjectCreated = TRUE;
}
}
}
else {
dbResults = TT_DB_ERR_OBJECT_EXISTS;
}
return dbObjectID;
}
_Tt_db_results _Tt_db_object::write ()
{
if (!isObjectInDatabase()) {
dbResults = createDBObject();
}
else {
_Tt_db_property_list_ptr properties_in_db;
// Find the cache level property and make sure it is up to date
// with the actual cache level
// XXX - This needs to be done with 4/93 DB servers. 10/93 DB servers
// will protect the cache level property on the DB server side.
_Tt_db_property_list_cursor properties_cursor (dbObjectProperties);
_Tt_string cache_level_bytes (sizeof (int));
while (properties_cursor.next ()) {
if (properties_cursor->name == TT_DB_PROPS_CACHE_LEVEL_PROPERTY) {
memcpy ((char *)cache_level_bytes,
&dbObjectPropertiesCacheLevel,
sizeof (int));
properties_cursor->values->flush ();
properties_cursor->values->append (cache_level_bytes);
}
}
setCurrentDBAccess ();
dbResults =
dbObjectDatabase->setObjectProperties(dbObjectID,
dbObjectProperties,
properties_in_db,
dbObjectPropertiesCacheLevel);
// If there was an update conflict, that means someone else wrote
// new props to the DB since this object had read its cached props.
// The _Tt_db_client object returns the properties currently in the
// database when this type of conflict occurs.
if (dbResults == TT_DB_ERR_UPDATE_CONFLICT) {
dbObjectProperties = properties_in_db;
}
}
return processDBResults();
}
_Tt_db_results _Tt_db_object::refresh ()
{
// Check if it is in the database and force it to find the object
// if it has been moved.
if (isObjectInDatabase(TRUE)) {
int cache_level = dbObjectPropertiesCacheLevel;
_Tt_db_property_list_ptr properties;
setCurrentDBAccess ();
dbResults = dbObjectDatabase->getObjectProperties(dbObjectID,
cache_level,
properties);
// Update the cache if the _Tt_db_client has new property data
if (cache_level > dbObjectPropertiesCacheLevel) {
dbObjectPropertiesCacheLevel = cache_level;
dbObjectProperties = properties;
}
}
else {
dbResults = TT_DB_OK;
}
return processDBResults();
}
_Tt_db_results _Tt_db_object::remove ()
{
if (isObjectInDatabase()) {
setCurrentDBAccess ();
dbResults = dbObjectDatabase->removeObject(dbObjectID,
_Tt_string((char *)NULL));
if (dbResults == TT_DB_OK) {
setTtDBObjectDefaults();
}
}
else {
dbResults = TT_DB_ERR_NO_SUCH_OBJECT;
}
return processDBResults();
}
_Tt_db_results _Tt_db_object::remove (const _Tt_string &forward_pointer)
{
if (isObjectInDatabase()) {
setCurrentDBAccess ();
dbResults = dbObjectDatabase->removeObject(dbObjectID, forward_pointer);
if (dbResults == TT_DB_OK) {
setTtDBObjectDefaults();
}
}
else {
dbResults = TT_DB_ERR_NO_SUCH_OBJECT;
}
return processDBResults();
}
_Tt_string _Tt_db_object::copy (const _Tt_string &new_file)
{
_Tt_string new_objid;
if (!new_file.len()) {
dbResults = TT_DB_ERR_ILLEGAL_FILE;
return new_objid;
}
if (isObjectInDatabase()) {
dbObjectFile = getFile();
_Tt_string new_local_file;
_Tt_string new_hostname;
_Tt_string new_partition;
_Tt_string new_file_network_path;
dbResults = _tt_db_network_path(new_file,
new_local_file,
new_hostname,
new_partition,
new_file_network_path);
if (dbResults == TT_DB_OK) {
// If we're not copying to the exact same file
if (dbObjectFile != new_file_network_path) {
_Tt_db_object_ptr new_object = new _Tt_db_object;
new_objid = new_object->create(new_file_network_path);
dbResults = new_object->getDBResults();
if ((dbResults == TT_DB_OK) && new_objid.len()) {
// Refresh the current object's info
dbResults = internalRefresh();
if (dbResults == TT_DB_OK) {
(void)new_object->setAccess(dbObjectAccess);
(void)new_object->setProperties(dbObjectProperties);
(void)new_object->setType(dbObjectType);
dbResults = new_object->write();
}
}
}
else {
dbResults = TT_DB_ERR_SAME_OBJECT;
}
}
}
else {
dbResults = TT_DB_ERR_NO_SUCH_OBJECT;
}
dbResults = processDBResults();
return new_objid;
}
_Tt_string _Tt_db_object::move (const _Tt_string &new_file)
{
_Tt_string new_objid;
if (!new_file.len()) {
dbResults = TT_DB_ERR_ILLEGAL_FILE;
return new_objid;
}
if (isObjectInDatabase()) {
dbObjectFile = getFile();
_Tt_string new_local_file;
_Tt_string new_hostname;
_Tt_string new_partition;
_Tt_string new_file_network_path;
dbResults = _tt_db_network_path(new_file,
new_local_file,
new_hostname,
new_partition,
new_file_network_path);
// If we're not moving to the exact same file
if (dbObjectFile != new_file_network_path) {
new_objid = makeEquivalentObjectID(new_hostname, new_partition);
if ((dbResults == TT_DB_OK) && new_objid.len()) {
// If the objids are still the same, we only need to change the
// object's file in the database...
if (dbObjectID == new_objid) {
dbResults = dbObjectDatabase->setObjectFile(dbObjectID,
new_file_network_path);
if (dbResults == TT_DB_OK) {
dbResults = TT_DB_WRN_SAME_OBJECT_ID;
}
}
// Different objids and therefore different partitions or hosts
else {
_Tt_db_object_ptr new_object = new _Tt_db_object;
dbResults = new_object->setObjectID(new_objid);
// The new object should not exist, yet...
if (dbResults == TT_DB_ERR_NO_SUCH_OBJECT) {
new_object->dbObjectHostname = new_hostname;
new_object->dbObjectFile = new_file_network_path;
// Refresh the current object's info
dbResults = internalRefresh();
if (dbResults == TT_DB_OK) {
(void)new_object->setAccess(dbObjectAccess);
(void)new_object->setProperties(dbObjectProperties);
(void)new_object->setType(dbObjectType);
dbResults = new_object->write();
}
}
// If the new object already exists, then there is something
// weird going on...
else if (dbResults == TT_DB_OK) {
dbResults = TT_DB_ERR_CORRUPT_DB;
}
if (dbResults == TT_DB_OK) {
// Remove current object from the DB and specify the new objid
// as the forward pointer.
dbResults = remove(new_objid);
if (dbResults == TT_DB_OK) {
setTtDBObjectDefaults();
dbResults = setObjectID(new_objid);
}
}
}
}
else {
if (dbResults == TT_DB_OK) {
dbResults = TT_DB_ERR_ILLEGAL_OBJECT;
}
}
}
else {
dbResults = TT_DB_ERR_SAME_OBJECT;
}
}
else {
dbResults = TT_DB_ERR_NO_SUCH_OBJECT;
}
dbResults = processDBResults();
return new_objid;
}
_Tt_db_results
_Tt_db_object::setProperty (const _Tt_db_property_ptr &property)
{
if (property->name.len()) {
// See if a property with the same name exists...
bool_t found = FALSE;
_Tt_db_property_list_cursor properties_cursor(dbObjectProperties);
while (properties_cursor.next()) {
if (properties_cursor->name == property->name) {
found = TRUE;
break;
}
}
// If a property with the same name exists...
if (found) {
// If the new property has no values specified, then just
// delete the old property...
if (property->is_empty()) {
properties_cursor.remove();
}
// Else, we actually want to set some values...
else {
*properties_cursor = property;
}
}
// Else, no property with same name exists, just append the new
// property (if it's not empty)
else { if (!property->is_empty())
dbObjectProperties->append(property);
}
dbResults = TT_DB_OK;
}
else {
dbResults = TT_DB_ERR_ILLEGAL_PROPERTY;
}
return dbResults;
}
_Tt_db_results
_Tt_db_object::setProperties (const _Tt_db_property_list_ptr &properties)
{
// Replace the old properties with the new list
dbObjectProperties = properties;
return dbResults;
}
_Tt_db_results
_Tt_db_object::addProperty (const _Tt_db_property_ptr &property,
bool_t unique)
{
if (property->name.len()) {
bool_t found = FALSE;
// See if a property with the same name exists in the cache
_Tt_db_property_list_cursor properties_cursor(dbObjectProperties);
while (properties_cursor.next()) {
if (properties_cursor->name == property->name) {
found = TRUE;
break;
}
}
// If a property with the same name exists...
if (found) {
_Tt_string_list_cursor values_cursor(property->values);
// If a unique property name-value combinations are to be added...
if (unique) {
_Tt_string_list_cursor cache_values_cursor(properties_cursor->values);
// Loop through the values to be added
while (values_cursor.next()) {
cache_values_cursor.reset();
// Compare versus values already in the cache
bool_t is_unique = TRUE;
while (cache_values_cursor.next()) {
if (*cache_values_cursor == *values_cursor) {
is_unique = FALSE;
}
}
// If unique, append the value to the cache values
if (is_unique) {
properties_cursor->values->append(*values_cursor);
}
}
}
// Else uniqueness is not a requirement...
else {
while (values_cursor.next()) {
properties_cursor->values->append(*values_cursor);
}
}
dbResults = TT_DB_OK;
}
else {
dbObjectProperties->append(property);
dbResults = TT_DB_OK;
}
}
else {
dbResults = TT_DB_ERR_ILLEGAL_PROPERTY;
}
return dbResults;
}
_Tt_db_results
_Tt_db_object::deleteProperty (const _Tt_db_property_ptr &property)
{
if (isObjectInDatabase()) {
setCurrentDBAccess();
// Delete the property on the database immediately and refresh
// the cache with the latest and greatest. If the cache level
// here is not as high as the cache level in the DB, then the
// delete will fail.
dbResults =
dbObjectDatabase->deleteObjectProperty(dbObjectID,
property,
dbObjectProperties,
dbObjectPropertiesCacheLevel);
}
else {
dbResults = TT_DB_ERR_NO_SUCH_OBJECT;
}
return processDBResults();
}
_Tt_db_property_ptr _Tt_db_object::getProperty (const _Tt_string &name)
{
_Tt_db_property_ptr property;
if (name.len()) {
bool_t found = FALSE;
_Tt_db_property_list_cursor properties_cursor(dbObjectProperties);
// See if a property matches the specified name
while (properties_cursor.next()) {
if (properties_cursor->name == name) {
found = TRUE;
break;
}
}
if (found) {
property = *properties_cursor;
dbResults = TT_DB_OK;
}
else {
dbResults = TT_DB_ERR_NO_SUCH_PROPERTY;
}
}
else {
dbResults = TT_DB_ERR_ILLEGAL_PROPERTY;
}
return property;
}
_Tt_db_property_list_ptr _Tt_db_object::getProperties ()
{
dbResults = TT_DB_OK;
return dbObjectProperties;
}
_Tt_db_results _Tt_db_object::setType (const _Tt_string &type)
{
if (!isObjectInDatabase()) {
dbObjectType = type;
dbResults = TT_DB_OK;
}
else {
dbResults = TT_DB_ERR_OTYPE_ALREADY_SET;
}
return dbResults;
}
_Tt_string _Tt_db_object::getType ()
{
if (!dbObjectType.len() && isObjectInDatabase()) {
setCurrentDBAccess();
dbResults = dbObjectDatabase->getObjectType(dbObjectID, dbObjectType);
}
else {
dbResults = TT_DB_OK;
}
dbResults = processDBResults();
return dbObjectType;
}
_Tt_string _Tt_db_object::getFile ()
{
if (isObjectInDatabase()) {
setCurrentDBAccess();
dbResults = dbObjectDatabase->getObjectFile(dbObjectID, dbObjectFile);
}
else {
dbResults = TT_DB_OK;
}
dbResults = processDBResults();
return dbObjectFile;
}
_Tt_db_results _Tt_db_object::setAccess (const _Tt_db_access_ptr &access)
{
dbObjectAccess = access;
if (isObjectInDatabase()) {
setCurrentDBAccess();
dbResults = dbObjectDatabase->setObjectAccess(dbObjectID, dbObjectAccess);
}
else {
dbResults = TT_DB_OK;
}
return processDBResults();
}
_Tt_db_access_ptr _Tt_db_object::getAccess ()
{
if (isObjectInDatabase()) {
setCurrentDBAccess();
dbResults = dbObjectDatabase->getObjectAccess(dbObjectID, dbObjectAccess);
}
else {
dbResults = TT_DB_OK;
}
dbResults = processDBResults();
return dbObjectAccess;
}
_Tt_string _Tt_db_object::getObjectKey () const
{
_Tt_string key_string;
if (dbObjectID.len()) {
key_string = _tt_db_objid_to_key(dbObjectID);
}
return key_string;
}
_Tt_db_results
_Tt_db_object::createMemoryObject (const _Tt_string &file,
const _Tt_string& keystr)
{
_Tt_string local_file;
_Tt_string partition;
dbObjectID = (char *)NULL;
dbResults = _tt_db_network_path(file,
local_file,
dbObjectHostname,
partition,
dbObjectFile);
if (dbResults == TT_DB_OK) {
// Create a key for the new object,
// or use the passed-in one if present
_Tt_db_key_ptr key;
if (keystr.len()) {
key = new _Tt_db_key(keystr);
}
else {
key = new _Tt_db_key();
}
dbObjectID = _tt_db_create_objid(key, "NFS",
dbObjectHostname, partition);
}
return dbResults;
}
void _Tt_db_object::getDBObjectHostnameFromID ()
{
if (dbObjectID.len()) {
_Tt_string objid_string = dbObjectID;
_Tt_string temp_string;
// Get rid of the file system type
objid_string = objid_string.split(':', temp_string);
if (objid_string.len() && temp_string.len()) {
objid_string = objid_string.split(':', temp_string);
}
// Get the hostname
if (objid_string.len() && temp_string.len()) {
objid_string = objid_string.split(':', dbObjectHostname);
}
}
}
_Tt_db_results _Tt_db_object::createDBObject ()
{
if (dbObjectID.len()) {
if (dbObjectType.len()) {
dbObjectDatabase = dbHostnameGlobalMapRef.getDB(dbObjectHostname,
dbObjectHostname,
dbResults);
if (!dbObjectDatabase.is_null()) {
setCurrentDBAccess();
dbResults =
dbObjectDatabase->createObject (dbObjectFile,
dbObjectID,
dbObjectType,
dbObjectProperties,
dbObjectAccess,
dbObjectPropertiesCacheLevel);
dbObjectPropertiesCacheLevel = -1;
if (dbResults == TT_DB_OK) {
dbResults = internalRefresh ();
}
}
}
else {
dbResults = TT_DB_ERR_NO_OTYPE;
}
}
else {
dbResults = TT_DB_ERR_ILLEGAL_OBJECT;
}
return dbResults;
}
_Tt_db_results _Tt_db_object::setObjectID (const _Tt_string &new_objid)
{
dbObjectID = new_objid;
getDBObjectHostnameFromID();
dbResults = (isObjectInDatabase(TRUE) ? TT_DB_OK :
TT_DB_ERR_NO_SUCH_OBJECT);
return dbResults;
}
_Tt_string
_Tt_db_object::makeEquivalentObjectID (const _Tt_string &hostname,
const _Tt_string &partition)
{
_Tt_string new_objid = _tt_db_objid_to_key(dbObjectID);
new_objid = new_objid.cat(":NFS");
new_objid = new_objid.cat(":").cat(hostname);
new_objid = new_objid.cat(":").cat(partition);
return new_objid;
}
bool_t _Tt_db_object::isObjectInDatabase (bool_t force)
{
_Tt_string forward_pointer;
if ((!checkedDatabase || force) && dbObjectHostname.len()) {
// Get the DB connection for this objects DB host
dbObjectDatabase = dbHostnameGlobalMapRef.getDB(dbObjectHostname,
dbObjectHostname,
dbResults);
if (!dbObjectDatabase.is_null()) {
setCurrentDBAccess();
// See if the object is in the actual database and also check for
// a forward pointer
_Tt_string forward_pointer;
dbResults = dbObjectDatabase->isObjectInDatabase(dbObjectID,
forward_pointer);
}
// Either a failure or a forward pointer...
if (dbResults != TT_DB_OK) {
if (dbResults == TT_DB_ERR_NO_SUCH_OBJECT) {
dbHostnameGlobalMapRef.removeDB(dbObjectHostname);
dbObjectDatabase = (_Tt_db_client *)NULL;
dbResults = TT_DB_OK;
}
else if (dbResults == TT_DB_WRN_FORWARD_POINTER) {
// Change this objects ID to the forward pointer. The "setObjectID"
// member function will call "isObjectInDatabase" again and the
// forward pointer chain will eventually resolve to the final
// resting place of the object.
dbResults = setObjectID(forward_pointer);
forwardPointerFlag = TRUE;
}
}
checkedDatabase = TRUE;
}
return (dbObjectDatabase.is_null() ? FALSE : TRUE);
}
_Tt_db_results _Tt_db_object::internalRefresh ()
{
setCurrentDBAccess ();
dbResults =
dbObjectDatabase->getObjectProperties(dbObjectID,
dbObjectPropertiesCacheLevel,
dbObjectProperties);
if (dbResults == TT_DB_OK) {
dbResults = dbObjectDatabase->getObjectAccess(dbObjectID, dbObjectAccess);
}
if (dbResults == TT_DB_OK) {
dbResults = dbObjectDatabase->getObjectType(dbObjectID, dbObjectType);
}
return dbResults;
}
_Tt_db_results _Tt_db_object::processDBResults ()
{
// If an RPC fails, assume the DB server went down and attemp to
// reconnect to it
if ((dbResults == TT_DB_ERR_DB_CONNECTION_FAILED) ||
(dbResults == TT_DB_ERR_RPC_CONNECTION_FAILED)) {
if (!dbObjectDatabase.is_null()) {
dbHostnameGlobalMapRef.removeDB(dbObjectHostname);
dbObjectDatabase = dbHostnameGlobalMapRef.getDB(dbObjectHostname,
dbObjectHostname,
dbResults);
}
}
// Else if the results were OK, but the forward pointer flag was set,
// return TT_WRN_FORWARD_POINTER
else if ((dbResults == TT_DB_OK) && forwardPointerFlag) {
forwardPointerFlag = FALSE;
dbResults = TT_DB_WRN_FORWARD_POINTER;
}
return dbResults;
}

View File

@@ -0,0 +1,177 @@
/*%% (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_object.h /main/3 1995/10/23 10:03:53 rswiston $ */
/*
* tt_db_object.h - Declare the TT DB server object class. This class defines the
* object properties interface to the DB server.
*
* Copyright (c) 1992 by Sun Microsystems, Inc.
*/
#ifndef _TT_DB_OBJECT_H
#define _TT_DB_OBJECT_H
#include "util/tt_object.h"
#include "util/tt_string.h"
#include "db/tt_db_file.h"
#include "db/tt_db_hostname_global_map_ref.h"
#include "db/tt_db_access_utils.h"
#include "db/tt_db_property_utils.h"
class _Tt_db_object : public _Tt_object {
public:
// Instantiates a _Tt_object without any connection to an existing
// spec or the database.
_Tt_db_object ();
// If the specified ID is an existing spec in the database, then
// the database is connected to and the spec is loaded into memory.
_Tt_db_object (const _Tt_string &objid);
~_Tt_db_object ();
// Sets and gets the access mode of this object spec.
void setCurrentAccess (const _Tt_db_access_ptr &access);
_Tt_db_access_ptr getCurrentAccess () const;
// Creates the in memory version of the object spec and returns the
// new object ID.
_Tt_string create (const _Tt_string &file);
_Tt_string create (const _Tt_string &file, const _Tt_string &key);
// Writes the spec to the database.
_Tt_db_results write ();
// Refreshes the properties in memory with whatever is currently out
// in the database.
_Tt_db_results refresh ();
// Removes the spec from the database and/or memory and leaves the specified
// forward pointer in its place.
_Tt_db_results remove ();
_Tt_db_results remove (const _Tt_string &forward_pointer);
// Copys the object spec to the new file
_Tt_string copy (const _Tt_string &new_file);
// Moves the object spec to the new file. After the move is done,
// this object actually contains the information of the new location.
// However, to prevent any weird race conditions due to someone else
// doing a move shortly after this move, it is best to just instantiate
// a new _Tt_db_object with the new objid.
_Tt_string move (const _Tt_string &new_file);
// Writes the specified object property to memory. All values of the
// the object property with the same name are overwritten. If the value of
// the property is empty, this deletes all properties with the same name
// from the database.
_Tt_db_results setProperty (const _Tt_db_property_ptr &property);
// Writes the specified object properties to memory. All values of
// the object properties with the same names are overwritten. If the value
// of some of the properties are empty, this deletes all properties with the
// same name from the database.
_Tt_db_results setProperties (const _Tt_db_property_list_ptr &properties);
// Adds an object property to the list of values of the object property
// with the same name in memory. If the property does not already exist,
// then the property is created. If the "unique" argument is TRUE, then
// the property name and value combination is guaranteed to be unique
// and will not be added to the list of values if the combination already
// exists.
_Tt_db_results addProperty (const _Tt_db_property_ptr &property,
bool_t unique=FALSE);
// Deletes the object property value with the same name and value from the
// DB. If the value is left empty, then all values of the property are
// deleted. The deletion is not cached. The deletion is immediately
// executed on disk.
_Tt_db_results deleteProperty (const _Tt_db_property_ptr &property);
// Gets the values of the object property with the specified name from the
// memory cache. If the property does not exist in memory, then the value
// is obtained from the DB.
_Tt_db_property_ptr getProperty (const _Tt_string &name);
// Gets a list of all of the object properties currently written to the DB.
// If the object has never been written to the DB, then an error is returned.
_Tt_db_property_list_ptr getProperties ();
// Sets and gets the otype of the specified object.
_Tt_db_results setType (const _Tt_string &otype);
_Tt_string getType ();
// Gets the file of the object.
_Tt_string getFile ();
// Sets and gets the access mode of the specified object.
_Tt_db_results setAccess (const _Tt_db_access_ptr &access);
_Tt_db_access_ptr getAccess ();
// Returns the object ID of this object.
const _Tt_string& getObjectID () const
{
return dbObjectID;
}
// Returns the key porition of this object's object ID.
_Tt_string getObjectKey () const;
// Gets the results of the last database operation made with this object.
_Tt_db_results getDBResults () const
{
return dbResults;
}
private:
bool_t checkedDatabase;
_Tt_db_hostname_global_map_ref dbHostnameGlobalMapRef;
_Tt_db_access_ptr dbObjectAccess;
_Tt_db_access_ptr dbObjectCurrentAccess;
_Tt_db_client_ptr dbObjectDatabase;
_Tt_string dbObjectFile;
_Tt_string dbObjectHostname;
_Tt_string dbObjectID;
_Tt_db_property_list_ptr dbObjectProperties;
int dbObjectPropertiesCacheLevel;
_Tt_string dbObjectType;
_Tt_db_results dbResults;
bool_t forwardPointerFlag;
bool_t memoryObjectCreated;
void setTtDBObjectDefaults ();
_Tt_db_results createMemoryObject (const _Tt_string&, const _Tt_string&);
void getDBObjectHostnameFromID ();
_Tt_db_results createDBObject ();
//
// Sets the internal object ID to a new ID and checks to see if the
// object is in the database.
//
_Tt_db_results setObjectID (const _Tt_string&);
_Tt_string makeEquivalentObjectID (const _Tt_string&,
const _Tt_string&);
bool_t isObjectInDatabase (bool_t force = FALSE);
_Tt_db_results internalRefresh ();
//
// Does some special results processing for any public member functions
// that do some database server operations. It should be used to get
// the final results for all such member functions. Member functions
// that are not public or that only work on the memory copy of the
// object should not call processDBResults.
//
_Tt_db_results processDBResults ();
void setCurrentDBAccess ()
{
if (!dbObjectDatabase.is_null()) {
dbObjectDatabase->setCurrentAccess(dbObjectCurrentAccess);
}
}
};
#endif // _TT_DB_OBJECT_H

View 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_object_utils.C /main/3 1995/10/23 10:04:00 rswiston $
/*
* tt_db_object_utils.cc - Defines the _Tt_db_object utilities.
*
* Copyright (c) 1992 by Sun Microsystems, Inc.
*/
#include "db/tt_db_object_utils.h"
implement_list_of(_Tt_db_object)
implement_table_of(_Tt_db_object)

View 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_object_utils.h /main/3 1995/10/23 10:04:07 rswiston $ */
/*
* tt_db_object_utils.h - Declare the _Tt_db_object utilities.
*
* Copyright (c) 1992 by Sun Microsystems, Inc.
*/
#ifndef _TT_DB_OBJECT_UTILS_H
#define _TT_DB_OBJECT_UTILS_H
#include "util/tt_table.h"
#include "db/tt_db_object.h"
declare_list_of(_Tt_db_object)
declare_table_of(_Tt_db_object)
#endif // _TT_DB_OBJECT_UTILS_H

View File

@@ -0,0 +1,24 @@
//%% (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_objid_to_key.C /main/3 1995/10/23 10:04:15 rswiston $
/*
* Tool Talk Utility - tt_db_objid_to_key.cc
*
* Copyright (c) 1990 by Sun Microsystems, Inc.
*
* Object ID to object key conversion routine.
*
*/
#include "db/tt_db_objid_to_key.h"
_Tt_string _tt_db_objid_to_key (const _Tt_string &objid)
{
_Tt_string key;
_Tt_string temp = objid;
(void)temp.split(':', key);
return key;
}

View 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_objid_to_key.h /main/3 1995/10/23 10:04:22 rswiston $ */
/*
* Tool Talk Utility - tt_db_objid_to_key.h
*
* Copyright (c) 1990 by Sun Microsystems, Inc*
*
* Extern declarations for object ID to key conversion routine.
*
*/
#ifndef _TT_DB_OBJID_TO_KEY_H
#define _TT_DB_OBJID_TO_KEY_H
#include <util/tt_string.h>
extern _Tt_string _tt_db_objid_to_key (const _Tt_string &objid);
#endif /* _TT_DB_OBJID_TO_KEY */

View File

@@ -0,0 +1,45 @@
//%% (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_property.C /main/3 1995/10/23 10:04:30 rswiston $
/*
* tt_db_property.cc - Implement the _Tt_db_property class
*
* Copyright (c) 1992 by Sun Microsystems, Inc.
*/
#include "db/tt_db_property.h"
// Constructors and destructors
_Tt_db_property::
_Tt_db_property ()
{
values = new _Tt_string_list;
}
_Tt_db_property::
~_Tt_db_property ()
{
}
// whether a property is empty
int _Tt_db_property::
is_empty() const
// consider a property to be empty if it's values list is empty, or if all
// entries in the values list are NULL content member tt_strings.
{
if (values->is_empty()) return TRUE; // empty values list case
// check the list for all NULL content member tt_strings
_Tt_string_list_cursor values_cursor(values);
while (values_cursor.next()) if (*values_cursor != (char*)NULL) return FALSE;
return TRUE;
}

View 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: tt_db_property.h /main/3 1995/10/23 10:04:37 rswiston $ */
/*
* tt_db_property.h - Defines the TT DB server property class.
*
* Copyright (c) 1992 by Sun Microsystems, Inc.
*/
#ifndef _TT_DB_PROPERTY_H
#define _TT_DB_PROPERTY_H
#include "util/tt_object.h"
#include "util/tt_string.h"
class _Tt_db_property : public _Tt_object {
public:
_Tt_db_property ();
~_Tt_db_property ();
int is_empty() const;
_Tt_string name;
_Tt_string_list_ptr values;
void print (FILE *file=stdout)
{
fprintf(file, "Property Name: %s\n", ((char *)name ?
(char *)name : "(NULL)"));
if (!values.is_null()) {
fprintf(file, "Number of Values: %d\n", values->count());
int i = 0;
_Tt_string_list_cursor values_cursor(values);
while (values_cursor.next()) {
if (*values_cursor != (char*)NULL)
fprintf(file, "Property Value #%d: %s\n", i, (char *)*values_cursor);
else fprintf(file, "Property Value #%d: NULL\n", i);
i++;
}
}
}
};
#endif // _TT_DB_PROPERTY_H

View File

@@ -0,0 +1,18 @@
//%% (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_property_utils.C /main/3 1995/10/23 10:04:44 rswiston $
/* @(#)tt_db_property_utils.C 1.6 @(#)
* tt_db_property_utils.cc - Defines the _Tt_db_property utilities.
*
* Copyright (c) 1992 by Sun Microsystems, Inc.
*/
#include "db/tt_db_property.h"
#include "db/tt_db_property_utils.h"
implement_list_of(_Tt_db_property)

View 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_db_property_utils.h /main/3 1995/10/23 10:04:53 rswiston $ */
/* @(#)tt_db_property_utils.h 1.5 @(#)
* tt_db_property_utils.h - Declares the _Tt_db_property class utilities.
*
* Copyright (c) 1992 by Sun Microsystems, Inc.
*/
#ifndef _TT_DB_PROPERTY_UTILS_H
#define _TT_DB_PROPERTY_UTILS_H
#include "util/tt_list.h"
class _Tt_db_property;
declare_list_of(_Tt_db_property)
#endif // _TT_DB_PROPERTY_UTILS_H

View File

@@ -0,0 +1,59 @@
/*%% (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_results.h /main/3 1995/10/23 10:05:01 rswiston $ */
/*
* tt_db_results.h - Defines the result values that may be returned by
* a TT DB server operation.
*
* Copyright (c) 1992 by Sun Microsystems, Inc.
*/
#ifndef _TT_DB_RESULTS_H
#define _TT_DB_RESULTS_H
enum _Tt_db_results {
TT_DB_OK = 0,
TT_DB_WRN_FORWARD_POINTER = 1,
TT_DB_WRN_SAME_OBJECT_ID = 2,
TT_DB_ERR_DB_CONNECTION_FAILED = 3,
TT_DB_ERR_DB_OPEN_FAILED = 4,
TT_DB_ERR_DB_LOCKED = 5,
TT_DB_ERR_RPC_CONNECTION_FAILED = 6,
TT_DB_ERR_RPC_FAILED = 7,
TT_DB_ERR_CORRUPT_DB = 8,
TT_DB_ERR_DISK_FULL = 9,
TT_DB_ERR_ILLEGAL_FILE = 10,
TT_DB_ERR_ILLEGAL_OBJECT = 11,
TT_DB_ERR_ILLEGAL_PROPERTY = 12,
TT_DB_ERR_ILLEGAL_MESSAGE = 13,
TT_DB_ERR_SAME_FILE = 14,
TT_DB_ERR_SAME_OBJECT = 15,
TT_DB_ERR_FILE_EXISTS = 16,
TT_DB_ERR_OBJECT_EXISTS = 17,
TT_DB_ERR_NO_SUCH_FILE = 18,
TT_DB_ERR_NO_SUCH_OBJECT = 19,
TT_DB_ERR_NO_SUCH_PROPERTY = 20,
TT_DB_ERR_ACCESS_DENIED = 21,
TT_DB_ERR_NO_ACCESS_INFO = 22,
TT_DB_ERR_NO_OTYPE = 23,
TT_DB_ERR_OTYPE_ALREADY_SET = 24,
TT_DB_ERR_UPDATE_CONFLICT = 25,
TT_DB_ERR_PROPS_CACHE_ERROR = 26,
// new for filename mapping. We get this
// if there is a mild version
// mismatch, e.g. a libtt talking to
// a dbserver which doesn't support filename
// mapping, and one of the new
// API calls is used. This is relatively
// benign, just let the user know that
// his call is unimplemented in the system
// he/she tried to contact, so the user can
// differentiate this from the case where the
// RPC call failed due to the server not running, etc.
TT_DB_ERR_RPC_UNIMP = 27
};
#endif // _TT_DB_RESULTS_H

View File

@@ -0,0 +1,104 @@
//%% (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_rpc_message_routines.C /main/3 1995/10/23 10:05:09 rswiston $
/* @(#)tt_db_rpc_message_routines.C 1.10 94/11/17
* tt_db_rpc_message_routines.cc - Defines routines for converting TT
* message classes to RPC arguments.
*
* Copyright (c) 1992 by Sun Microsystems, Inc.
*/
#include "mp/mp_message.h"
#include "util/tt_string.h"
#include "util/tt_xdr_utils.h"
#include "db/tt_db_rpc_message_routines.h"
// If this file is being compiled with -g, then DEFINE_NEW_AND_DELETE
// must be defined in order to prevent a dependency on the libC library.
// The dependency is due to the fact that cfront generates an extern
// reference to vec_new and vec_delete if it sees any access to arrays
// of calsses or structures. In the case of this file, tt_message_list
// contains a pointer to a structure that causes the references to be
// generated.
#ifdef DEFINE_NEW_AND_DELETE
extern "C" {
void *__vec_new (void *, int , int , void *)
{ return (void *)NULL; }
void __vec_delete (void *, int , int , void *, int , int )
{}
}
#endif
void
_tt_get_rpc_message (const _tt_message &rpc_message,
_Tt_message_ptr &message)
{
message = (_Tt_message *)NULL;
if (rpc_message.body.body_len) {
XDR xdrs;
xdrmem_create(&xdrs,
rpc_message.body.body_val,
(u_int)rpc_message.body.body_len,
XDR_DECODE);
message = new _Tt_message;
(void)message->xdr(&xdrs);
}
}
void
_tt_get_rpc_messages (const _tt_message_list &rpc_messages,
_Tt_message_list_ptr &messages)
{
messages = (_Tt_message_list *)NULL;
if (rpc_messages.messages_len) {
messages = new _Tt_message_list;
for (int i=0; i < rpc_messages.messages_len; i++) {
_Tt_message_ptr message_ptr;
_tt_get_rpc_message(rpc_messages.messages_val [i],
message_ptr);
(void)messages->append(message_ptr);
}
}
}
_Tt_db_results
_tt_set_rpc_message (const _Tt_message_ptr &message,
_tt_message &rpc_message)
{
if (message.is_null()) {
rpc_message.body.body_val = (char *)NULL;
rpc_message.body.body_len = 0;
} else {
XDR xdrs;
_Tt_xdr_size_stream xdrsz;
u_int length;
if (!message->xdr((XDR *)xdrsz)) {
return TT_DB_ERR_ILLEGAL_MESSAGE;
} else {
length = (u_int)xdrsz.getsize();
}
_Tt_string temp_string((int)length);
xdrmem_create(&xdrs, (char *)temp_string, length, XDR_ENCODE);
if (!message->xdr(&xdrs)) {
return TT_DB_ERR_ILLEGAL_MESSAGE;
}
rpc_message.body.body_val = (char *)malloc(length+1);
(void)memcpy(rpc_message.body.body_val, (char *)temp_string, length);
rpc_message.body.body_val[length] = '\0';
rpc_message.body.body_len = length;
}
return TT_DB_OK;
}

View File

@@ -0,0 +1,25 @@
/*%% (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_rpc_message_routines.h /main/3 1995/10/23 10:05:17 rswiston $ */
/*
* tt_db_rpc_message_routines.h - Declares routines for converting TT
* message classes to RPC arguments.
*
* Copyright (c) 1992 by Sun Microsystems, Inc.
*/
#ifndef _TT_DB_RPC_MESSAGE_ROUTINES_H
#define _TT_DB_RPC_MESSAGE_ROUTINES_H
#include "mp/mp_message_utils.h"
#include "db/db_server.h"
extern void _tt_get_rpc_message (const _tt_message&, _Tt_message_ptr&);
extern void _tt_get_rpc_messages (const _tt_message_list&,
_Tt_message_list_ptr&);
extern _Tt_db_results _tt_set_rpc_message (const _Tt_message_ptr&,
_tt_message&);
#endif /* _TT_DB_RPC_MESSAGE_ROUTINES_H */

View File

@@ -0,0 +1,260 @@
//%% (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_rpc_routines.C /main/3 1995/10/23 10:05:24 rswiston $
/* %W @(#)
* tt_db_rpc_routines.cc - Defines routines for converting TT DB classes to
* RPC arguments.
*
* Copyright (c) 1992 by Sun Microsystems, Inc.
*/
#include <string.h>
#include "util/tt_string.h"
#include "util/tt_xdr_utils.h"
#include "db/tt_db_rpc_routines.h"
#include "db/tt_db_access.h"
#include "db/tt_db_property.h"
// If this file is being compiled with -g, then DEFINE_NEW_AND_DELETE
// must be defined in order to prevent a dependency on the libC library.
// The dependency is due to the fact that cfront generates an extern
// reference to vec_new and vec_delete if it sees any access to arrays
// of calsses or structures. In the case of this file, tt_message_list
// contains a pointer to a structure that causes the references to be
// generated.
#ifdef DEFINE_NEW_AND_DELETE
extern "C" {
void *__nw__FUi (unsigned int)
{ return (void *)NULL; }
void __dl__FPv (void *)
{}
void *__vec_new (void *, int, int, void *)
{ return (void *)NULL; }
void __vec_delete (void *, int, int, void *, int, int)
{}
}
#endif
void _tt_free_rpc_message (const _tt_message &rpc_message)
{
if (rpc_message.body.body_val) {
free(rpc_message.body.body_val);
}
}
void _tt_free_rpc_messages (const _tt_message_list &rpc_messages)
{
if (rpc_messages.messages_val) {
for (int i=0; i < rpc_messages.messages_len; i++) {
_tt_free_rpc_message(rpc_messages.messages_val [i]);
}
free((MALLOCTYPE *)rpc_messages.messages_val);
}
}
void _tt_free_rpc_strings (const _tt_string_list &rpc_strings)
{
if (rpc_strings.values_val) {
for (int i=0; i < rpc_strings.values_len; i++) {
if (rpc_strings.values_val [i].value) {
free(rpc_strings.values_val [i].value);
}
}
free((MALLOCTYPE *)rpc_strings.values_val);
}
}
void _tt_free_rpc_property (const _tt_property &rpc_prop)
{
if (rpc_prop.name) {
free(rpc_prop.name);
}
if (rpc_prop.values.values_val) {
for (int i=0; i < rpc_prop.values.values_len; i++) {
if (rpc_prop.values.values_val [i].value.value_val) {
free(rpc_prop.values.values_val [i].value.value_val);
}
}
free((MALLOCTYPE *)rpc_prop.values.values_val);
}
}
void _tt_free_rpc_properties (const _tt_property_list &rpc_props)
{
if (rpc_props.properties_val) {
for (int i=0; i < rpc_props.properties_len; i++) {
_tt_free_rpc_property(rpc_props.properties_val [i]);
}
free((MALLOCTYPE *)rpc_props.properties_val);
}
}
void _tt_get_rpc_access (const _tt_access &rpc_access,
_Tt_db_access_ptr &access)
{
access = new _Tt_db_access;
access->user = rpc_access.user;
access->group = rpc_access.group;
access->mode = rpc_access.mode;
}
void _tt_get_rpc_strings (const _tt_string_list &rpc_strings,
_Tt_string_list_ptr &strings)
{
strings = new _Tt_string_list;
if (rpc_strings.values_len) {
for (int i=0; i < rpc_strings.values_len; i++) {
(void)strings->append(_Tt_string(rpc_strings.values_val [i].value));
}
}
}
void _tt_get_rpc_property (const _tt_property &rpc_prop,
_Tt_db_property_ptr &prop)
{
prop = new _Tt_db_property;
if (rpc_prop.name) {
prop->name = rpc_prop.name;
for (int i=0; i < rpc_prop.values.values_len; i++) {
int prop_value_length = rpc_prop.values.values_val [i].value.value_len;
if (prop_value_length) {
_Tt_string prop_value(prop_value_length);
memcpy((char *)prop_value,
rpc_prop.values.values_val [i].value.value_val,
prop_value_length);
(void)prop->values->append(prop_value);
}
}
}
}
void _tt_get_rpc_properties (const _tt_property_list &rpc_props,
_Tt_db_property_list_ptr &props)
{
props = new _Tt_db_property_list;
if (rpc_props.properties_len) {
for (int i=0; i < rpc_props.properties_len; i++) {
_Tt_db_property_ptr prop;
_tt_get_rpc_property (rpc_props.properties_val [i], prop);
if (prop->name.len()) {
(void)props->append(prop);
}
}
}
}
void _tt_set_rpc_access (const _Tt_db_access_ptr &access,
_tt_access &rpc_access)
{
if (access.is_null()) {
rpc_access.user = (uid_t)-1;
rpc_access.group = (gid_t)-1;
rpc_access.mode = (mode_t)-1;
}
else {
rpc_access.user = access->user;
rpc_access.group = access->group;
rpc_access.mode = access->mode;
}
}
void _tt_set_rpc_strings (const _Tt_string_list_ptr &strings,
_tt_string_list &rpc_strings)
{
if (strings.is_null()) {
rpc_strings.values_val = (_tt_string *)NULL;
rpc_strings.values_len = 0;
}
else {
int strings_count = strings->count ();
rpc_strings.values_val = (_tt_string *)
malloc(sizeof(_tt_string) * strings_count);
rpc_strings.values_len = strings_count;
int i = 0;
_Tt_string_list_cursor strings_cursor(strings);
while (strings_cursor.next()) {
rpc_strings.values_val [i].value = strdup((char *)*strings_cursor);
i++;
}
}
}
void _tt_set_rpc_property (const _Tt_db_property_ptr &prop,
_tt_property &rpc_prop)
{
if (prop.is_null()) {
rpc_prop.name = (char *)NULL;
rpc_prop.values.values_len = 0;
rpc_prop.values.values_val = (_tt_property_value *)NULL;
}
else {
int prop_values_count = prop->values->count ();
rpc_prop.name = strdup((char *)prop->name);
rpc_prop.values.values_len = prop_values_count;
rpc_prop.values.values_val = (_tt_property_value *)
malloc (sizeof(_tt_property_value) *
prop_values_count);
int i = 0;
_Tt_string_list_cursor values_cursor(prop->values);
while (values_cursor.next()) {
_tt_property_value *temp_value = rpc_prop.values.values_val + i;
int temp_value_length = (*values_cursor).len();
temp_value->value.value_val = (char *)malloc(temp_value_length+1);
temp_value->value.value_len = temp_value_length;
(void)memcpy (temp_value->value.value_val,
(char *)*values_cursor,
temp_value_length);
temp_value->value.value_val[temp_value_length] = '\0';
i++;
}
}
}
void _tt_set_rpc_properties (const _Tt_db_property_list_ptr &props,
_tt_property_list &rpc_props)
{
if (props.is_null()) {
rpc_props.properties_len = 0;
rpc_props.properties_val = (_tt_property *)NULL;
}
else {
int props_count = rpc_props.properties_len = props->count();
if (!props_count) {
rpc_props.properties_val = (_tt_property *)NULL;
}
else {
rpc_props.properties_val = (_tt_property *)
malloc(sizeof(_tt_property) * props_count);
int i = 0;
_Tt_db_property_list_cursor props_cursor(props);
while (props_cursor.next()) {
_tt_set_rpc_property (*props_cursor, rpc_props.properties_val [i]);
i++;
}
}
}
}

View File

@@ -0,0 +1,38 @@
/*%% (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_rpc_routines.h /main/3 1995/10/23 10:05:32 rswiston $ */
/*
* tt_db_rpc_routines.h - Declares routines for converting TT DB classes to
* RPC arguments.
*
* Copyright (c) 1992 by Sun Microsystems, Inc.
*/
#ifndef _TT_DB_RPC_ROUTINES_H
#define _TT_DB_RPC_ROUTINES_H
#include "util/tt_string.h"
#include "db/db_server.h"
#include "db/tt_db_property_utils.h"
#include "db/tt_db_access_utils.h"
#include "db/tt_db_results.h"
extern void _tt_free_rpc_message (const _tt_message&);
extern void _tt_free_rpc_messages (const _tt_message_list&);
extern void _tt_free_rpc_strings (const _tt_string_list&);
extern void _tt_free_rpc_property (const _tt_property&);
extern void _tt_free_rpc_properties (const _tt_property_list&);
extern void _tt_get_rpc_access (const _tt_access&, _Tt_db_access_ptr&);
extern void _tt_get_rpc_strings (const _tt_string_list&, _Tt_string_list_ptr&);
extern void _tt_get_rpc_property (const _tt_property&, _Tt_db_property_ptr&);
extern void _tt_get_rpc_properties (const _tt_property_list&,
_Tt_db_property_list_ptr&);
extern void _tt_set_rpc_access (const _Tt_db_access_ptr&, _tt_access&);
extern void _tt_set_rpc_strings (const _Tt_string_list_ptr&, _tt_string_list&);
extern void _tt_set_rpc_property (const _Tt_db_property_ptr&, _tt_property&);
extern void _tt_set_rpc_properties (const _Tt_db_property_list_ptr&,
_tt_property_list&);
#endif /* _TT_DB_RPC_ROUTINES_H */

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,318 @@
/*%% (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_old_db.h /main/3 1995/10/23 10:05:54 rswiston $ */
/*
*
* @(#)tt_old_db.h 1.4 30 Jul 1993
*
* Copyright (c) 1992 by Sun Microsystems, Inc.
*/
/*
* tt_old_db.h - Defines the old TT DB server database. This class
* represents the actual data model used to store
* ToolTalk databse information in the old DB server.
* This is used purely for compatibility with the
* old DB server.
*
* The actual database schema is the following:
*
* Table Fields Length Description
* ----- ------ ------ -----------
* docoid_path 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
* ----- ------ ------ -----------
* oid_container Contains all of the
* 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
* ----- ------ ------ -----------
* oid_prop Contains all of the
* 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
* ----- ------ ------ -----------
* oid_access 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_SHORT_SIZE The user ID of the owner
* of the object or file.
*
* Group ID XDR_SHORT_SIZE The group ID of the
* object or file.
*
* Mode XDR_SHORT_SIZE The access mode of the
* object or file.
*
* Copyright (c) 1992 by Sun Microsystems, Inc.
*/
#ifndef _TT_OLD_DB_H
#define _TT_OLD_DB_H
#include "util/tt_object.h"
#include "util/tt_string.h"
#include "db/tt_client_isam_file_utils.h"
#include "db/tt_db_access_utils.h"
#include "db/tt_db_client_utils.h"
#include "db/tt_db_key_utils.h"
#include "db/tt_db_property_utils.h"
#include "db/tt_db_results.h"
class _Tt_old_db : public _Tt_object {
public:
// Empty constructor for _utils
_Tt_old_db ();
_Tt_old_db (const _Tt_string&,
const _Tt_db_client_ptr&);
~_Tt_old_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 &current_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 &current_access);
_Tt_db_results getDBResults () const
{
return dbResults;
}
const _Tt_string &getLastFileAccessed () const
{
return dbLastFileAccessed;
}
// Needed by addsession and delsession in _Tt_db_client
_Tt_db_results getFileKey (const _Tt_string&, _Tt_string&);
// Needed by addsession, delsession and gettype in _Tt_db_client
int propertyTableFD;
// Some of the keys are needed by _Tt_db_client for the addsession,
// delsession and gettype functions. All of the keys have been made
// public in case similar needs arise later.
_Tt_client_isam_key_descriptor_ptr fileTableFileKey;
_Tt_client_isam_key_descriptor_ptr fileTableFilePathKey;
_Tt_client_isam_key_descriptor_ptr fileObjectMapFileKey;
_Tt_client_isam_key_descriptor_ptr fileObjectMapObjectKey;
_Tt_client_isam_key_descriptor_ptr propertyTablePropertyKey;
_Tt_client_isam_key_descriptor_ptr accessTableKey;
private:
_Tt_client_isam_file_ptr fileTable;
_Tt_client_isam_file_ptr fileObjectMap;
_Tt_client_isam_file_ptr propertyTable;
_Tt_client_isam_file_ptr accessTable;
_Tt_string dbHostname;
_Tt_string dbPartition;
_Tt_db_results dbResults;
_Tt_string dbLastFileAccessed;
void connectToDB (const _Tt_string&, const _Tt_db_client_ptr&);
_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_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_OLD_DB_H */

View File

@@ -0,0 +1,62 @@
/*%% (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_old_db_consts.h /main/3 1995/10/23 10:06:02 rswiston $ */
/*
* tt_old_db_consts.h - Declares constants that are used by the
* _Tt_old_db class that may useful in other
* parts of the old DB compatibility code.
*
* Copyright (c) 1992 by Sun Microsystems, Inc.
*
*/
#ifndef _TT_OLD_DB_CONSTS_H
#define _TT_OLD_DB_CONSTS_H
#include "db/tt_db_key.h"
#include <limits.h>
#ifndef LONG_BIT
#define LONG_BIT 32
#endif
#define TT_OLD_DB_VERSION "0001"
#define TT_OLD_DB_FILE_TABLE_FILE "docoid_path"
#define TT_OLD_DB_FILE_OBJECT_MAP_FILE "oid_container"
#define TT_OLD_DB_PROPERTY_TABLE_FILE "oid_prop"
#define TT_OLD_DB_ACCESS_TABLE_FILE "oid_access"
#define TT_OLD_DB_PROPS_CACHE_LEVEL_PROPERTY "_MODIFICATION_DATE"
#define TT_OLD_DB_FORWARD_POINTER_PROPERTY "_NEW_OIDKEY"
#define TT_OLD_DB_OBJECT_TYPE_PROPERTY "_NODE_TYPE"
#define TT_OLD_DB_MESSAGE_PROPERTY "_TT_MSG_%d_%d"
#define TT_OLD_DB_MESSAGE_INFO_PROPERTY "_TT_QUEUED_MSGS"
// The ':' in front of the file name is for old DB server compatibility.
// The old DB server protocol expects a colon in every file path to
// delimit the hostname.
#define TT_OLD_DB_FORWARD_POINTER_FILE ":.TT_OLD_DB_FORWARD_POINTER_FILE"
const int TT_OLD_MAX_RECORD_LENGTH = 8192;
const int TT_OLD_DB_MAX_KEY_LENGTH = 120;
const int TT_OLD_DB_MAX_PROPERTY_NAME_LENGTH = 64;
const int TT_OLD_DB_LONG_SIZE = LONG_BIT/8;
const int TT_OLD_DB_SHORT_SIZE = 2;
const int TT_OLD_DB_KEY_LENGTH = TT_DB_KEY_LENGTH;
const int TT_OLD_DB_FIRST_KEY_OFFSET = 0;
const int TT_OLD_DB_SECOND_KEY_OFFSET = TT_OLD_DB_KEY_LENGTH;
const int TT_OLD_DB_FILE_PATH_OFFSET = TT_OLD_DB_KEY_LENGTH;
const int TT_OLD_DB_PROPERTY_NAME_OFFSET = TT_OLD_DB_KEY_LENGTH;
const int TT_OLD_DB_PROPERTY_VALUE_OFFSET = TT_OLD_DB_KEY_LENGTH+
TT_OLD_DB_MAX_PROPERTY_NAME_LENGTH;
const int TT_OLD_DB_ACCESS_USER_OFFSET = TT_OLD_DB_KEY_LENGTH;
const int TT_OLD_DB_ACCESS_GROUP_OFFSET = TT_OLD_DB_KEY_LENGTH+TT_OLD_DB_SHORT_SIZE;
const int TT_OLD_DB_ACCESS_MODE_OFFSET = TT_OLD_DB_KEY_LENGTH+2*TT_OLD_DB_SHORT_SIZE;
#endif /* _TT_OLD_DB_CONSTS_H */

View File

@@ -0,0 +1,70 @@
//%% (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_old_db_message_info.C /main/3 1995/10/23 10:06:11 rswiston $
/*
*
* @(#)tt_old_db_message_info.C 1.3 30 Jul 1993
*
* Copyright (c) 1992 by Sun Microsystems, Inc.
*/
#include "db/tt_old_db_message_info.h"
_Tt_old_db_message_info::
_Tt_old_db_message_info ()
{
}
_Tt_old_db_message_info::
~_Tt_old_db_message_info ()
{
}
bool_t _Tt_old_db_message_info::
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;
}

View File

@@ -0,0 +1,43 @@
/*%% (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_old_db_message_info.h /main/3 1995/10/23 10:06:18 rswiston $ */
/*
*
* @(#)tt_old_db_message_info.h 1.6 07 Sep 1993
*
* Copyright (c) 1992 by Sun Microsystems, Inc.
*/
/*
* tt_old_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_OLD_DB_MESSAGE_INFO_H
#define _TT_OLD_DB_MESSAGE_INFO_H
#include "util/tt_object.h"
#include "util/tt_string.h"
#include "util/tt_xdr_version.h"
class _Tt_old_db_message_info : public _Tt_object {
public:
_Tt_old_db_message_info ();
~_Tt_old_db_message_info ();
int messageID;
int numParts;
int messageSize;
_Tt_string_list_ptr ptypes;
bool_t xdr (XDR *xdrs);
};
#endif /* _TT_OLD_DB_MESSAGE_INFO_H */

View 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_old_db_message_info_utils.C /main/3 1995/10/23 10:06:26 rswiston $
/*
* tt_old_db_message_info.cc - Defines the _Tt_old_db_message_info utilities.
*
* Copyright (c) 1992 by Sun Microsystems, Inc.
*/
#include "tt_old_db_message_info_utils.h"
implement_ptr_to(_Tt_old_db_message_info)

View 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_old_db_message_info_utils.h /main/3 1995/10/23 10:06:34 rswiston $ */
/*
* tt_old_db_message_info_utils.h - Declare the _Tt_old_db_message_info utilities.
*
* Copyright (c) 1992 by Sun Microsystems, Inc.
*/
#ifndef _TT_OLD_DB_MESSAGE_INFO_UTILS_H
#define _TT_OLD_DB_MESSAGE_INFO_UTILS_H
#include "tt_old_db_message_info.h"
declare_ptr_to(_Tt_old_db_message_info)
#endif // _TT_OLD_DB_MESSAGE_INFO_UTILS_H

View File

@@ -0,0 +1,84 @@
//%% (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_old_db_partition_map_ref.C /main/3 1995/10/23 10:06:41 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 "util/tt_port.h"
#include "util/tt_gettext.h"
#include "db/tt_old_db_partition_map_ref.h"
_Tt_old_db_table_ptr*
_Tt_old_db_partition_map_ref::dbPartitionMap = (_Tt_old_db_table_ptr *)
NULL;
_Tt_old_db_partition_map_ref::_Tt_old_db_partition_map_ref ()
{
if (!dbPartitionMap) {
dbPartitionMap = new _Tt_old_db_table_ptr;
*dbPartitionMap = new _Tt_old_db_table ((_Tt_object_table_keyfn)
&dbPartitionMapKey);
}
}
_Tt_old_db_partition_map_ref::~_Tt_old_db_partition_map_ref ()
{
// The static table is freed up when the application dies or when
// _Tt_old_db_partition_map_ref::flush() is called.
}
void _Tt_old_db_partition_map_ref::addDB (_Tt_old_db_ptr &db)
{
(*dbPartitionMap)->insert(db);
}
void _Tt_old_db_partition_map_ref::removeDB (const _Tt_string &partition)
{
(*dbPartitionMap)->remove(partition);
}
_Tt_old_db_ptr
_Tt_old_db_partition_map_ref::getDB (const _Tt_string &partition,
const _Tt_db_client_ptr &db_conn)
{
_Tt_old_db_ptr db_ptr = (*dbPartitionMap)->lookup(partition);
if (db_ptr.is_null()) {
db_ptr = new _Tt_old_db(partition, db_conn);
_Tt_db_results results = db_ptr->getDBResults();
if (results != TT_DB_OK) {
_tt_syslog(0, LOG_ERR,
catgets(_ttcatd, 1, 7,
"Attempt to open database table %s:%s failed"),
(char *)db_conn->getHostname(),
(char *)db_ptr->getLastFileAccessed());
db_ptr = (_Tt_old_db *)NULL;
}
else {
addDB(db_ptr);
}
}
return db_ptr;
}
_Tt_string
_Tt_old_db_partition_map_ref::dbPartitionMapKey (_Tt_object_ptr &db)
{
return (((_Tt_old_db *)db.c_pointer())->getPartition());
}
void _Tt_old_db_partition_map_ref::flush ()
{
if (dbPartitionMap) {
delete dbPartitionMap;
}
dbPartitionMap = (_Tt_old_db_table_ptr *)NULL;
}

View 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: tt_old_db_partition_map_ref.h /main/3 1995/10/23 10:06:49 rswiston $ */
/*
* tt_old_db_partition__map_ref.h - Declare the old TT DB server partition
* global map ref class. This class contains
* a global map that provides a partition to
* old DB server DB mapping. This way only one set
* of ISAM file connections is made per partition
* from a particular client.
*
* Copyright (c) 1992 by Sun Microsystems, Inc.
*/
#ifndef _TT_OLD_DB_PARTITION_MAP_REF_H
#define _TT_OLD_DB_PARTITION_MAP_REF_H
#include "util/tt_new.h"
#include "util/tt_string.h"
#include "db/tt_old_db_utils.h"
class _Tt_old_db_partition_map_ref : public _Tt_allocated {
public:
_Tt_old_db_partition_map_ref ();
~_Tt_old_db_partition_map_ref ();
void addDB (_Tt_old_db_ptr &db);
void removeDB (const _Tt_string &partition);
_Tt_old_db_ptr getDB (const _Tt_string &partition,
const _Tt_db_client_ptr &db_conn);
static void flush ();
static _Tt_string dbPartitionMapKey (_Tt_object_ptr &db);
private:
static _Tt_old_db_table_ptr *dbPartitionMap;
bool_t checkForOldDB (const _Tt_string&);
bool_t checkForOldDBTable (const _Tt_string&,
const _Tt_string&,
const _Tt_string&);
};
#endif // _TT_OLD_DB_PARTITION_MAP_REF_H

View File

@@ -0,0 +1,45 @@
/*%% (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_old_db_results.h /main/3 1995/10/23 10:06:56 rswiston $ */
/* @(#)tt_old_db_results.h 1.3 93/07/30
*
* tt_old_db_results.h - Defines the result values that may be
* returned by an old TT DB server operation.
*
* Copyright (c) 1992 by Sun Microsystems, Inc.
*/
#ifndef _TT_OLD_DB_RESULTS_H
#define _TT_OLD_DB_RESULTS_H
// Status values that may be returned by an old DB server.
enum _Tt_old_db_results {
TT_OLD_DB_OK = TT_OK,
TT_OLD_DB_ERROR = TT_STATUS_LAST+1,
TT_OLD_DB_INIT_FAILED,
TT_OLD_DB_DBDESC_EXISTS,
TT_OLD_DB_DB_EXISTS,
TT_OLD_DB_CREATE_FAILED,
TT_OLD_DB_OPEN_FAILED,
TT_OLD_DB_NO_RECORD,
TT_OLD_DB_READ_FAILED,
TT_OLD_DB_WRITE_FAILED,
TT_OLD_DB_DELETE_FAILED,
TT_OLD_DB_CLOSE_FAILED,
TT_OLD_DB_UNKNOWN_DBTABLE,
TT_OLD_DB_UNKNOWN_INDEX,
TT_OLD_DB_INVALID_VERSION_NUMBER,
TT_OLD_DB_PATHMAP_FAILED,
TT_OLD_DB_UPDATE_MFS_INFO_FAILED,
TT_OLD_DB_CLEAR_LOCKS_FAILED,
TT_OLD_DB_RECORD_LOCKED,
TT_OLD_DB_NO_MFS,
TT_OLD_DB_UNKNOWN_FS,
TT_OLD_DB_CONVERSION_ERROR,
TT_OLD_DB_RECORD_SET,
TT_OLD_DB_ACCESS_DENIED
};
#endif /* _TT_OLD_DB_RESULTS_H */

View 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_old_db_utils.C /main/3 1995/10/23 10:07:03 rswiston $
/*
* tt_old_db_utils.cc - Defines the _Tt_old_db utilities.
*
* Copyright (c) 1992 by Sun Microsystems, Inc.
*/
#include "db/tt_old_db_utils.h"
implement_list_of(_Tt_old_db)
implement_table_of(_Tt_old_db)

View 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_old_db_utils.h /main/3 1995/10/23 10:07:10 rswiston $ */
/*
* tt_old_db_utils.h - Declare the _Tt_old_db utilities.
*
* Copyright (c) 1992 by Sun Microsystems, Inc.
*/
#ifndef _TT_OLD_DB_UTILS_H
#define _TT_OLD_DB_UTILS_H
#include "util/tt_list.h"
#include "util/tt_table.h"
#include "db/tt_old_db.h"
declare_list_of(_Tt_old_db)
declare_table_of(_Tt_old_db)
#endif // _TT_OLD_DB_UTILS_H