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,39 @@
XCOMM $XConsortium: Imakefile /main/9 1996/08/21 15:51:27 drk $
XCOMM ** WARNING **
XCOMM
XCOMM The files named here may appear in many different Imakefiles.
XCOMM If you add or remove a file, be sure to update all locations.
XCOMM It's unfortunate, but all this redundancy serves a purpose.
XCOMM
XCOMM Other possible locations are:
XCOMM .../lib/DtMmdb/Imakefile
XCOMM .../lib/DtMmdb/<subdir>/Imakefile
XCOMM .../programs/dtinfo/mmdb/Imakefile
XCOMM .../programs/dtinfo/mmdb/<subdir>/Imakefile
#define DoNormalLib NormalLibDtMmdb
#define DoSharedLib SharedLibDtMmdb
#define DoDebugLib DebugLibDtMmdb
#define DoProfileLib ProfileLibDtMmdb
#define LibName DtMmdb
#define SoRev SODTMMDBREV
#define LibHeaders NO
#define LibCreate NO
#define LargePICTable YES
#define CplusplusSource YES
DEPEND_DEFINES = $(CXXDEPENDINCLUDES)
XCOMM In DtMmdb we compile as C_API sources.
DEFINES = -DC_API
INCLUDES = -I.. $(EXCEPTIONS_INCLUDES)
SRCS = mmdb_btree.C
OBJS = $(SRCS:.C=.o)
#include <Library.tmpl>
SubdirLibraryRule($(OBJS))
DependTarget()

View File

@@ -0,0 +1,161 @@
/*
* $XConsortium: mmdb_btree.cc /main/3 1996/06/11 17:14:32 cde-hal $
*
* Copyright (c) 1993 HAL Computer Systems International, Ltd.
* All rights reserved. Unpublished -- rights reserved under
* the Copyright Laws of the United States. USE OF A COPYRIGHT
* NOTICE IS PRECAUTIONARY ONLY AND DOES NOT IMPLY PUBLICATION
* OR DISCLOSURE.
*
* THIS SOFTWARE CONTAINS CONFIDENTIAL INFORMATION AND TRADE
* SECRETS OF HAL COMPUTER SYSTEMS INTERNATIONAL, LTD. USE,
* DISCLOSURE, OR REPRODUCTION IS PROHIBITED WITHOUT THE
* PRIOR EXPRESS WRITTEN PERMISSION OF HAL COMPUTER SYSTEMS
* INTERNATIONAL, LTD.
*
* RESTRICTED RIGHTS LEGEND
* Use, duplication, or disclosure by the Government is subject
* to the restrictions as set forth in subparagraph (c)(l)(ii)
* of the Rights in Technical Data and Computer Software clause
* at DFARS 252.227-7013.
*
* HAL COMPUTER SYSTEMS INTERNATIONAL, LTD.
* 1315 Dell Avenue
* Campbell, CA 95008
*
*/
#include "btree/mmdb_btree.h"
btree::btree(const char* store_name)
{
// let the package figure out all these parameters
btree_info.flags = 0;
btree_info.cachesize = 0;
btree_info.maxkeypage = 0;
btree_info.minkeypage = 0;
btree_info.psize = 0;
btree_info.compare = NULL;
btree_info.prefix = NULL;
btree_info.lorder = 0;
int mode = O_CREAT|O_RDWR;
//btree_DB = dbopen(store_name, mode, 0640, DB_BTREE, &btree_info);
btree_DB = dbopen(store_name, mode, 0640, DB_BTREE, NULL);
if ( btree_DB == 0 )
throw(stringException("btree dbopen failed"));
}
btree::~btree()
{
if ( btree_DB->sync(btree_DB, 0) == RET_ERROR )
throw(stringException("btree sync failed"));
if ( btree_DB->close(btree_DB) == RET_ERROR )
throw(stringException("btree close failed"));
}
void btree::clean()
{
throw(stringException("void btree::clean(): not implemented yet"));
}
void btree::data_t_2_DBT(data_t& w)
{
switch (w.flag) {
case data_t::INT:
key_DBT.data = &w.key.int_key;
key_DBT.size = sizeof(w.key.int_key);
break;
case data_t::STRING:
key_DBT.data = w.key.str_key;
key_DBT.size = strlen(w.key.str_key);
break;
case data_t::VOID:
throw(stringException("btree data_t_2_DBT: unknow key type"));
}
}
Boolean btree::insert(data_t& w)
{
data_t_2_DBT(w);
DBT data_DBT;
data_DBT.data = &w.dt;
data_DBT.size = sizeof(w.dt);
//int status = btree_DB->put(btree_DB, &key_DBT, &data_DBT, R_NOOVERWRITE);
int status = btree_DB->put(btree_DB, &key_DBT, &data_DBT, 0);
switch (status) {
case RET_ERROR:
throw(stringException("btree put failed"));
break;
case RET_SPECIAL:
throw(stringException("btree put: dup key"));
break;
case RET_SUCCESS:
return true;
}
}
Boolean btree::remove(data_t& w)
{
data_t_2_DBT(w);
int status = btree_DB->del(btree_DB, &key_DBT, 0);
switch (status) {
case RET_ERROR:
throw(stringException("btree delete failed"));
break;
case RET_SPECIAL:
case RET_SUCCESS:
return true;
}
}
Boolean btree::member(data_t& w)
{
data_t_2_DBT(w);
DBT data_DBT;
int status = btree_DB->get(btree_DB, &key_DBT, &data_DBT, 0);
switch (status) {
case RET_ERROR:
throw(stringException("btree get failed"));
break;
case RET_SPECIAL:
return false;
case RET_SUCCESS:
if ( data_DBT.size != sizeof(w.dt) )
throw(stringException("btree get: tree corrupted"));
memcpy((char*)&w.dt, data_DBT.data, data_DBT.size);
return true;
}
}
ostream& btree::asciiOut(ostream& out)
{
return out;
}
istream& btree::asciiIn(istream& in)
{
return in;
}

View File

@@ -0,0 +1,78 @@
/*
* $XConsortium: mmdb_btree.h /main/3 1996/06/11 17:14:37 cde-hal $
*
* Copyright (c) 1993 HAL Computer Systems International, Ltd.
* All rights reserved. Unpublished -- rights reserved under
* the Copyright Laws of the United States. USE OF A COPYRIGHT
* NOTICE IS PRECAUTIONARY ONLY AND DOES NOT IMPLY PUBLICATION
* OR DISCLOSURE.
*
* THIS SOFTWARE CONTAINS CONFIDENTIAL INFORMATION AND TRADE
* SECRETS OF HAL COMPUTER SYSTEMS INTERNATIONAL, LTD. USE,
* DISCLOSURE, OR REPRODUCTION IS PROHIBITED WITHOUT THE
* PRIOR EXPRESS WRITTEN PERMISSION OF HAL COMPUTER SYSTEMS
* INTERNATIONAL, LTD.
*
* RESTRICTED RIGHTS LEGEND
* Use, duplication, or disclosure by the Government is subject
* to the restrictions as set forth in subparagraph (c)(l)(ii)
* of the Rights in Technical Data and Computer Software clause
* at DFARS 252.227-7013.
*
* HAL COMPUTER SYSTEMS INTERNATIONAL, LTD.
* 1315 Dell Avenue
* Campbell, CA 95008
*
*/
#ifndef _btree_h
#define _btree_h 1
#include "storage/unixf_storage.h"
#include "dynhash/data_t.h"
#ifdef SVR4
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#else
#include <sys/file.h>
#include <sys/types.h>
#include <limits.h>
#endif
#include "dstr/index_agent.h"
#include "btree_berkeley/db.h"
class btree : public index_agent
{
public:
btree(const char* btree_file_name );
~btree();
void clean();
Boolean insert(data_t& w);
Boolean remove(data_t& w);
Boolean member(data_t& w);
ostream& asciiOut(ostream& out);
istream& asciiIn(istream& in);
protected:
DBT key_DBT;
DB* btree_DB;
BTREEINFO btree_info;
protected:
void data_t_2_DBT(data_t& w);
};
#endif