DtMmdb: move to lib directory as a standalone library.
This commit is contained in:
305
cde/lib/DtMmdb/oliasdb/DtMmdb.h
Normal file
305
cde/lib/DtMmdb/oliasdb/DtMmdb.h
Normal file
@@ -0,0 +1,305 @@
|
||||
/*
|
||||
* CDE - Common Desktop Environment
|
||||
*
|
||||
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
|
||||
*
|
||||
* These libraries and programs are free software; you can
|
||||
* redistribute them and/or modify them under the terms of the GNU
|
||||
* Lesser General Public License as published by the Free Software
|
||||
* Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* These libraries and programs are distributed in the hope that
|
||||
* they will be useful, but WITHOUT ANY WARRANTY; without even the
|
||||
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU Lesser General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with these libraries and programs; if not, write
|
||||
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
|
||||
* Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
/* $XConsortium: Mmdb.h /main/4 1996/05/29 13:01:24 rcs $ */
|
||||
/*
|
||||
* (c) Copyright 1996 Digital Equipment Corporation.
|
||||
* (c) Copyright 1996 Hewlett-Packard Company.
|
||||
* (c) Copyright 1996 International Business Machines Corp.
|
||||
* (c) Copyright 1996 Sun Microsystems, Inc.
|
||||
* (c) Copyright 1996 Novell, Inc.
|
||||
* (c) Copyright 1994, 1995, 1996 FUJITSU LIMITED.
|
||||
* (c) Copyright 1996 Hitachi.
|
||||
*/
|
||||
|
||||
#ifndef _MMDB_C_API_H
|
||||
#define _MMDB_C_API_H
|
||||
|
||||
|
||||
|
||||
#define DtMmdb_PROTO1(x) (x)
|
||||
#define DtMmdb_PROTO2(x,y) (x,y)
|
||||
#define DtMmdb_PROTO3(x,y,z) (x,y,z)
|
||||
|
||||
#undef _not_defined
|
||||
#ifdef _not_defined
|
||||
#ifdef __cplusplus
|
||||
#else
|
||||
#define DtMmdb_PROTO1(x) ()
|
||||
#define DtMmdb_PROTO2(x,y) ()
|
||||
#define DtMmdb_PROTO3(x,y,z) ()
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef unsigned int DtMmdbBool;
|
||||
#define DtMmdbTrue 1
|
||||
#define DtMmdbFalse 0
|
||||
|
||||
/*****************************************************/
|
||||
/* info lib structure */
|
||||
/*****************************************************/
|
||||
typedef struct _DtMmdbInfoLibInfo
|
||||
{
|
||||
const char* path;
|
||||
const char* name;
|
||||
unsigned int num_bookcases;
|
||||
} DtMmdbInfoLibInfo;
|
||||
|
||||
/*****************************************************/
|
||||
/* basecase structure */
|
||||
/*****************************************************/
|
||||
typedef struct _DtMmdbBookCaseInfo
|
||||
{
|
||||
const char* name;
|
||||
unsigned int num_books;
|
||||
} DtMmdbBookCaseInfo;
|
||||
|
||||
/*****************************************************/
|
||||
/* oid handler structure */
|
||||
/*****************************************************/
|
||||
typedef struct _DtMmdbObjectId
|
||||
{
|
||||
void* oid_ptr;
|
||||
} DtMmdbHandle;
|
||||
|
||||
extern DtMmdbHandle* DtMmdbGroundId;
|
||||
|
||||
/*****************************************************/
|
||||
/* info request structure */
|
||||
/*****************************************************/
|
||||
typedef struct _DtMmdbInfoRequest
|
||||
{
|
||||
int bookcase_descriptor;
|
||||
char* locator_ptr;
|
||||
DtMmdbHandle* primary_oid;
|
||||
DtMmdbHandle* secondary_oid;
|
||||
int sequence_num;
|
||||
} DtMmdbInfoRequest ;
|
||||
|
||||
|
||||
/*****************************************************/
|
||||
/* graphic info structure */
|
||||
/*****************************************************/
|
||||
typedef struct _DtMmdbGraphicInfo
|
||||
{
|
||||
unsigned short type;
|
||||
unsigned short width;
|
||||
unsigned short height;
|
||||
unsigned int llx, lly ;
|
||||
unsigned int urx, ury ;
|
||||
char* version;
|
||||
} DtMmdbGraphicInfo;
|
||||
|
||||
|
||||
/*****************************************************/
|
||||
/* mmdb */
|
||||
/*****************************************************/
|
||||
void DtMmdbInit();
|
||||
void DtMmdbQuit();
|
||||
|
||||
/*****************************************************/
|
||||
/* Handle space release*/
|
||||
/*****************************************************/
|
||||
void DtMmdbFreeHandle(DtMmdbHandle*);
|
||||
void DtMmdbFreeHandleList(DtMmdbHandle**);
|
||||
|
||||
/*****************************************************/
|
||||
/* infolib */
|
||||
/*****************************************************/
|
||||
int DtMmdbOpenInfoLib DtMmdb_PROTO3(
|
||||
const char* infolib_path,
|
||||
const char* selected_base_name,
|
||||
DtMmdbBool delayed_infolib_init
|
||||
);
|
||||
|
||||
void DtMmdbCloseInfoLib DtMmdb_PROTO1(int infolib_descriptor);
|
||||
|
||||
DtMmdbInfoLibInfo* DtMmdbInfoLibGetInfo DtMmdb_PROTO1(int infolib_descriptor);
|
||||
|
||||
void DtMmdbInfoLibFreeInfo DtMmdb_PROTO1(DtMmdbInfoLibInfo*);
|
||||
|
||||
|
||||
/*****************************************************/
|
||||
/* bookcase */
|
||||
/*****************************************************/
|
||||
int
|
||||
DtMmdbGetBookCaseByName
|
||||
DtMmdb_PROTO2(int infolib_descriptor, const char* name);
|
||||
|
||||
int
|
||||
DtMmdbGetBookCaseByIndex DtMmdb_PROTO2(int infolib_descriptor, int index);
|
||||
|
||||
int
|
||||
DtMmdbGetBookCaseByLoc DtMmdb_PROTO2(
|
||||
int infolib_descriptor,
|
||||
const char* locator
|
||||
);
|
||||
|
||||
int*
|
||||
DtMmdbGetBookCaseByLocs DtMmdb_PROTO2(
|
||||
int infolib_descriptor,
|
||||
const char** locators
|
||||
);
|
||||
|
||||
DtMmdbBookCaseInfo* DtMmdbBookCaseGetInfo DtMmdb_PROTO1(int bookcase_descriptor);
|
||||
void DtMmdbBookCaseFreeInfo DtMmdb_PROTO1(DtMmdbBookCaseInfo*);
|
||||
|
||||
/*****************************************************/
|
||||
/* section */
|
||||
/*****************************************************/
|
||||
const char* DtMmdbSectionGetLoc DtMmdb_PROTO1(DtMmdbInfoRequest* request);
|
||||
|
||||
const char*
|
||||
DtMmdbSectionGetLongTitle DtMmdb_PROTO2(
|
||||
DtMmdbInfoRequest* request,
|
||||
unsigned int* title_length
|
||||
);
|
||||
|
||||
const char*
|
||||
DtMmdbSectionGetShortTitle DtMmdb_PROTO2(
|
||||
DtMmdbInfoRequest* request,
|
||||
unsigned int* title_length
|
||||
);
|
||||
|
||||
const char*
|
||||
DtMmdbSectionGetData DtMmdb_PROTO2(
|
||||
DtMmdbInfoRequest* request,
|
||||
unsigned int* data_length
|
||||
);
|
||||
|
||||
int DtMmdbSectionGetDataSize DtMmdb_PROTO1(DtMmdbInfoRequest* request);
|
||||
|
||||
const char* DtMmdbSectionGetTocLoc DtMmdb_PROTO1( DtMmdbInfoRequest* request);
|
||||
|
||||
DtMmdbHandle*
|
||||
DtMmdbSectionGetBookId DtMmdb_PROTO1( DtMmdbInfoRequest* request);
|
||||
|
||||
DtMmdbHandle*
|
||||
DtMmdbSectionGetStyleSheetId DtMmdb_PROTO1(DtMmdbInfoRequest* request);
|
||||
|
||||
/*****************************************************/
|
||||
/* TOC */
|
||||
/*****************************************************/
|
||||
DtMmdbHandle*
|
||||
DtMmdbTocGetParentId DtMmdb_PROTO1(DtMmdbInfoRequest* request);
|
||||
|
||||
DtMmdbHandle**
|
||||
DtMmdbTocGetChildIds DtMmdb_PROTO2(
|
||||
DtMmdbInfoRequest* request,
|
||||
unsigned int* list_length
|
||||
);
|
||||
|
||||
int DtMmdbTocGetNumOfChildren DtMmdb_PROTO1( DtMmdbInfoRequest* request);
|
||||
|
||||
/*****************************************************/
|
||||
/* Locator */
|
||||
/*****************************************************/
|
||||
const char*
|
||||
DtMmdbLocatorGetSectionLoc DtMmdb_PROTO1(DtMmdbInfoRequest* request);
|
||||
|
||||
DtMmdbHandle*
|
||||
DtMmdbLocatorGetSectionObjectId DtMmdb_PROTO1(DtMmdbInfoRequest* request);
|
||||
|
||||
/*****************************************************/
|
||||
/* Graphic */
|
||||
/*****************************************************/
|
||||
const char*
|
||||
DtMmdbGraphicGetData DtMmdb_PROTO2(
|
||||
DtMmdbInfoRequest* request,
|
||||
unsigned int* data_length
|
||||
);
|
||||
|
||||
DtMmdbGraphicInfo*
|
||||
DtMmdbGraphicGetInfo DtMmdb_PROTO1(DtMmdbInfoRequest* request);
|
||||
void DtMmdbFreeGraphicInfo(DtMmdbGraphicInfo*);
|
||||
|
||||
|
||||
/*****************************************************/
|
||||
/* Stylesheet */
|
||||
/*****************************************************/
|
||||
const char*
|
||||
DtMmdbStylesheetGetName DtMmdb_PROTO1(DtMmdbInfoRequest* request);
|
||||
|
||||
const char*
|
||||
DtMmdbStylesheetGetata DtMmdb_PROTO2(
|
||||
DtMmdbInfoRequest* request,
|
||||
unsigned int* data_length
|
||||
);
|
||||
|
||||
/*****************************************************/
|
||||
/* BOOk */
|
||||
/*****************************************************/
|
||||
DtMmdbHandle*
|
||||
DtMmdbBookGetTocObjectId DtMmdb_PROTO1(DtMmdbInfoRequest* request);
|
||||
|
||||
const char*
|
||||
DtMmdbBookGetShortTitle DtMmdb_PROTO2(
|
||||
DtMmdbInfoRequest* request,
|
||||
unsigned int* length
|
||||
);
|
||||
|
||||
const char*
|
||||
DtMmdbBookGetLongTitle DtMmdb_PROTO2(
|
||||
DtMmdbInfoRequest* request,
|
||||
unsigned int* length
|
||||
);
|
||||
|
||||
int DtMmdbBookGetSeqNum DtMmdb_PROTO1(DtMmdbInfoRequest* request);
|
||||
|
||||
const char*
|
||||
DtMmdbBookGetSeqLIcense DtMmdb_PROTO2(
|
||||
DtMmdbInfoRequest* request,
|
||||
unsigned int* length
|
||||
);
|
||||
|
||||
DtMmdbHandle** DtMmdbBookGetTabList DtMmdb_PROTO2(
|
||||
DtMmdbInfoRequest* request, unsigned int* length
|
||||
);
|
||||
|
||||
/*****************************************************/
|
||||
/* DLP */
|
||||
/*****************************************************/
|
||||
DtMmdbHandle*
|
||||
DtMmdbDlpGetPrevSectionId DtMmdb_PROTO1(DtMmdbInfoRequest* request);
|
||||
|
||||
DtMmdbHandle*
|
||||
DtMmdbDlpGetNextSectionId DtMmdb_PROTO1(DtMmdbInfoRequest* request);
|
||||
|
||||
DtMmdbInfoRequest* newDtMmdbInfoRequestWithLoc(int bc_id, char* loc);
|
||||
DtMmdbInfoRequest* newDtMmdbInfoRequestWithPrimaryOid(int bc_id, char* oid_str);
|
||||
DtMmdbInfoRequest* newDtMmdbInfoRequestWithSecondaryOid(int bc_id, char* oid_str);
|
||||
DtMmdbInfoRequest* newDtMmdbInfoRequestWithSeqnum(int bc_id, char* oid_str);
|
||||
char* DtMmdbHandleToString(DtMmdbHandle* x);
|
||||
void DtMmdbFreeInfoRequest(DtMmdbInfoRequest*);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
20
cde/lib/DtMmdb/oliasdb/Makefile.am
Normal file
20
cde/lib/DtMmdb/oliasdb/Makefile.am
Normal file
@@ -0,0 +1,20 @@
|
||||
MAINTAINERCLEANFILES = Makefile.in
|
||||
|
||||
noinst_LTLIBRARIES = liboliasdb.la
|
||||
|
||||
liboliasdb_la_CXXFLAGS = -DNO_DB_LOCK -I..
|
||||
|
||||
liboliasdb_la_SOURCES = asciiIn_filters.C \
|
||||
collectionIterator.C \
|
||||
dlp_hd.C \
|
||||
doc_hd.C \
|
||||
graphic_hd.C \
|
||||
locator_hd.C \
|
||||
mark.C \
|
||||
mark_base.C \
|
||||
mmdb.C \
|
||||
node_hd.C \
|
||||
olias_funcs.C \
|
||||
stylesheet_hd.C \
|
||||
toc_hd.C \
|
||||
user_base.C
|
||||
93
cde/lib/DtMmdb/oliasdb/asciiIn_filters.C
Normal file
93
cde/lib/DtMmdb/oliasdb/asciiIn_filters.C
Normal file
@@ -0,0 +1,93 @@
|
||||
/*
|
||||
* CDE - Common Desktop Environment
|
||||
*
|
||||
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
|
||||
*
|
||||
* These libraries and programs are free software; you can
|
||||
* redistribute them and/or modify them under the terms of the GNU
|
||||
* Lesser General Public License as published by the Free Software
|
||||
* Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* These libraries and programs are distributed in the hope that
|
||||
* they will be useful, but WITHOUT ANY WARRANTY; without even the
|
||||
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU Lesser General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with these libraries and programs; if not, write
|
||||
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
|
||||
* Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
/*
|
||||
* $XConsortium: asciiIn_filters.cc /main/4 1996/06/11 17:26:22 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 "oliasdb/asciiIn_filters.h"
|
||||
#include "oliasdb/node_hd.h"
|
||||
|
||||
|
||||
static char oid_in_string_buf[BUFSIZ];
|
||||
|
||||
char* get_oid(info_lib* infolib_ptr, char* base_str, char* locator_line)
|
||||
{
|
||||
char* locator = strchr(locator_line, '\t') + 1;
|
||||
|
||||
if ( strcmp(locator, " 0000000000000000000000") == 0 ||
|
||||
strcmp(locator, "0") == 0 )
|
||||
{
|
||||
return (char*)"0.0";
|
||||
}
|
||||
|
||||
return get_oid_2(infolib_ptr, base_str, locator);
|
||||
}
|
||||
|
||||
char* get_oid_2(info_lib* infolib_ptr, char* base_str, char* locator)
|
||||
{
|
||||
node_smart_ptr x(infolib_ptr, base_str, locator);
|
||||
|
||||
const char *this_node_locator = x.locator();
|
||||
|
||||
if ( strcmp( this_node_locator, locator) == 0 ) {
|
||||
memset(oid_in_string_buf, 0, BUFSIZ);
|
||||
ostringstream strout(oid_in_string_buf, ios::out);
|
||||
x.its_oid().asciiOut(strout);
|
||||
int len = strout.str().size();
|
||||
*((char *) memcpy(oid_in_string_buf,
|
||||
strout.str().c_str(), len) + len) = '\0';
|
||||
} else {
|
||||
cerr << "dangling locator " << locator << "\n"
|
||||
<< "mismatches with " << this_node_locator << "\n"
|
||||
<< "of node " << x.its_oid().asciiOut(cerr) << "\n";
|
||||
throw(stringException("dangling locator"));
|
||||
}
|
||||
|
||||
return oid_in_string_buf;
|
||||
}
|
||||
|
||||
35
cde/lib/DtMmdb/oliasdb/asciiIn_filters.h
Normal file
35
cde/lib/DtMmdb/oliasdb/asciiIn_filters.h
Normal file
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* CDE - Common Desktop Environment
|
||||
*
|
||||
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
|
||||
*
|
||||
* These libraries and programs are free software; you can
|
||||
* redistribute them and/or modify them under the terms of the GNU
|
||||
* Lesser General Public License as published by the Free Software
|
||||
* Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* These libraries and programs are distributed in the hope that
|
||||
* they will be useful, but WITHOUT ANY WARRANTY; without even the
|
||||
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU Lesser General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with these libraries and programs; if not, write
|
||||
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
|
||||
* Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
/* $XConsortium: asciiIn_filters.h /main/4 1996/06/11 17:26:27 cde-hal $ */
|
||||
|
||||
#ifndef _filters_h
|
||||
#define _filters_h 1
|
||||
|
||||
#include "utility/funcs.h"
|
||||
#include "api/info_lib.h"
|
||||
|
||||
char* get_oid(info_lib*, char* base_nm, char* locator_line); // with byte count and \t
|
||||
char* get_oid_2(info_lib*, char* base_str, char* locator); // without byte count and \t
|
||||
|
||||
|
||||
#endif
|
||||
142
cde/lib/DtMmdb/oliasdb/c_api.C
Normal file
142
cde/lib/DtMmdb/oliasdb/c_api.C
Normal file
@@ -0,0 +1,142 @@
|
||||
/*
|
||||
* CDE - Common Desktop Environment
|
||||
*
|
||||
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
|
||||
*
|
||||
* These libraries and programs are free software; you can
|
||||
* redistribute them and/or modify them under the terms of the GNU
|
||||
* Lesser General Public License as published by the Free Software
|
||||
* Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* These libraries and programs are distributed in the hope that
|
||||
* they will be useful, but WITHOUT ANY WARRANTY; without even the
|
||||
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU Lesser General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with these libraries and programs; if not, write
|
||||
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
|
||||
* Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
/* $XConsortium: c_api.C /main/4 1996/08/21 15:52:45 drk $ */
|
||||
|
||||
#include "oliasdb/DtMmdb.h"
|
||||
#include <stdio.h>
|
||||
|
||||
#if ( ARCH == hpux)
|
||||
extern "C"
|
||||
char __pure_virtual_called()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef DEBUG
|
||||
|
||||
extern "C"
|
||||
void usage(int argc, char** argv)
|
||||
{
|
||||
fprintf(stderr, "Usage:\n");
|
||||
fprintf(stderr, " %s 0 libpath [bookcaseName]\n", argv[0]);
|
||||
fprintf(stderr, " %s 1 libpath bookcaseName locator (show bookcase)\n", argv[0]);
|
||||
fprintf(stderr, " %s 2 libpath bookcaseName locator (show section)\n", argv[0]);
|
||||
fprintf(stderr, " %s 3 libpath bookcaseName mmdboid (show section)\n", argv[0]);
|
||||
fprintf(stderr, " %s 4 libpath bookcaseName mmdboid (show TOC)\n", argv[0]);
|
||||
fprintf(stderr, " %s 5 libpath bookcaseName loc (show LOC)\n", argv[0]);
|
||||
fprintf(stderr, " %s 6 libpath bookcaseName mmdboid (show LOC)\n", argv[0]);
|
||||
fprintf(stderr, " %s 7 libpath bookcaseName loc (show graphic)\n", argv[0]);
|
||||
fprintf(stderr, " %s 8 libpath bookcaseName mmdboid (show graphic)\n", argv[0]);
|
||||
fprintf(stderr, " %s 9 libpath bookcaseName loc (show stylesheet)\n", argv[0]);
|
||||
fprintf(stderr, " %s 10 libpath bookcaseName mmdboid (show stylesheet)\n", argv[0]);
|
||||
fprintf(stderr, " %s 11 libpath bookcaseName mmdboid (show dlp)\n", argv[0]);
|
||||
fprintf(stderr, " %s 12 libpath bookcaseName TOC_section_mmdboid (show book)\n", argv[0]);
|
||||
fprintf(stderr, " %s 13 libpath bookcaseName book_mmdboid (show book)\n", argv[0]);
|
||||
fprintf(stderr, " %s 14 libpath bookcaseName book_seq_num (show book)\n", argv[0]);
|
||||
}
|
||||
|
||||
extern "C" int test0(int argc, char** argv);
|
||||
extern "C" int test1(int argc, char** argv);
|
||||
extern "C" int test2(int argc, char** argv);
|
||||
extern "C" int test3(int argc, char** argv);
|
||||
extern "C" int test4(int argc, char** argv);
|
||||
extern "C" int test_loc1(int argc, char** argv);
|
||||
extern "C" int test_loc2(int argc, char** argv);
|
||||
extern "C" int test_graphic1(int argc, char** argv);
|
||||
extern "C" int test_graphic2(int argc, char** argv);
|
||||
extern "C" int test_ss1(int argc, char** argv);
|
||||
extern "C" int test_ss2(int argc, char** argv);
|
||||
extern "C" int test_dlp(int argc, char** argv);
|
||||
extern "C" int test_book1(int argc, char** argv);
|
||||
extern "C" int test_book2(int argc, char** argv);
|
||||
extern "C" int test_book3(int argc, char** argv);
|
||||
#endif
|
||||
|
||||
extern "C"
|
||||
main( int argc, char** argv )
|
||||
{
|
||||
DtMmdbInit();
|
||||
|
||||
|
||||
#ifdef DEBUG
|
||||
if ( argc == 1 || 0==isdigit(argv[1][0]) ) {
|
||||
usage(argc, argv);
|
||||
} else
|
||||
switch ( atoi(argv[1]) ) {
|
||||
case 0:
|
||||
test0(argc, argv);
|
||||
break;
|
||||
case 1:
|
||||
test1(argc, argv);
|
||||
break;
|
||||
case 2:
|
||||
test2(argc, argv);
|
||||
break;
|
||||
case 3:
|
||||
test3(argc, argv);
|
||||
break;
|
||||
case 4:
|
||||
test4(argc, argv);
|
||||
break;
|
||||
case 5:
|
||||
test_loc1(argc, argv);
|
||||
break;
|
||||
case 6:
|
||||
test_loc2(argc, argv);
|
||||
break;
|
||||
case 7:
|
||||
test_graphic1(argc, argv);
|
||||
break;
|
||||
case 8:
|
||||
test_graphic2(argc, argv);
|
||||
break;
|
||||
case 9:
|
||||
test_ss1(argc, argv);
|
||||
break;
|
||||
case 10:
|
||||
test_ss2(argc, argv);
|
||||
break;
|
||||
case 11:
|
||||
test_dlp(argc, argv);
|
||||
break;
|
||||
case 12:
|
||||
test_book1(argc, argv);
|
||||
break;
|
||||
case 13:
|
||||
test_book2(argc, argv);
|
||||
break;
|
||||
case 14:
|
||||
test_book3(argc, argv);
|
||||
break;
|
||||
default:
|
||||
usage(argc, argv);
|
||||
}
|
||||
#endif
|
||||
|
||||
DtMmdbQuit();
|
||||
|
||||
exit(0);
|
||||
}
|
||||
|
||||
222
cde/lib/DtMmdb/oliasdb/c_api_book.C
Normal file
222
cde/lib/DtMmdb/oliasdb/c_api_book.C
Normal file
@@ -0,0 +1,222 @@
|
||||
/*
|
||||
* CDE - Common Desktop Environment
|
||||
*
|
||||
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
|
||||
*
|
||||
* These libraries and programs are free software; you can
|
||||
* redistribute them and/or modify them under the terms of the GNU
|
||||
* Lesser General Public License as published by the Free Software
|
||||
* Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* These libraries and programs are distributed in the hope that
|
||||
* they will be useful, but WITHOUT ANY WARRANTY; without even the
|
||||
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU Lesser General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with these libraries and programs; if not, write
|
||||
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
|
||||
* Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
// $XConsortium: c_api_book.cc /main/4 1996/06/11 17:26:37 cde-hal $
|
||||
|
||||
#include "oliasdb/c_api_common.h"
|
||||
|
||||
static doc_smart_ptr*
|
||||
getDocUsingPrOrSecOrSeq(DtMmdbInfoRequest* request)
|
||||
{
|
||||
mtry {
|
||||
info_base* x = getBookCase(request -> bookcase_descriptor);
|
||||
if ( x == 0 ) return 0;
|
||||
|
||||
oid_t * id = getPrimiaryOid(request);
|
||||
|
||||
if ( id ) {
|
||||
return new doc_smart_ptr(x, *id);
|
||||
}
|
||||
|
||||
id = getSecondaryOid(request); // book id
|
||||
|
||||
if ( id ) {
|
||||
return new doc_smart_ptr(*id, x);
|
||||
}
|
||||
|
||||
int seq = getSeqNum(request); // seq number
|
||||
|
||||
if ( seq == -1 ) return 0;
|
||||
|
||||
// bookcase is treated 1 based internally. But 0-based externally.
|
||||
return new doc_smart_ptr(x, seq+1);
|
||||
}
|
||||
|
||||
mcatch (mmdbException &,e)
|
||||
{
|
||||
return 0;
|
||||
} end_try;
|
||||
return 0;
|
||||
}
|
||||
|
||||
DtMmdbHandle*
|
||||
DtMmdbBookGetTocObjectId(DtMmdbInfoRequest* request)
|
||||
{
|
||||
mtry {
|
||||
doc_smart_ptr* x = getDocUsingPrOrSecOrSeq(request);
|
||||
if ( x == 0 ) return 0;
|
||||
|
||||
DtMmdbHandle *z = newDtMmdbHandle(x -> locator_id());
|
||||
|
||||
delete x;
|
||||
return z;
|
||||
}
|
||||
|
||||
mcatch (mmdbException &,e)
|
||||
{
|
||||
return 0;
|
||||
} end_try;
|
||||
return 0;
|
||||
}
|
||||
|
||||
const char*
|
||||
DtMmdbBookGetShortTitle(DtMmdbInfoRequest* request, unsigned int* length)
|
||||
{
|
||||
mtry {
|
||||
doc_smart_ptr* x = getDocUsingPrOrSecOrSeq(request);
|
||||
if ( x == 0 ) return 0;
|
||||
|
||||
const char* z = x -> short_title();
|
||||
|
||||
if ( length ) *length = strlen(z);
|
||||
|
||||
delete x;
|
||||
return z;
|
||||
}
|
||||
|
||||
mcatch (mmdbException &,e)
|
||||
{
|
||||
return 0;
|
||||
} end_try;
|
||||
return 0;
|
||||
}
|
||||
|
||||
const char*
|
||||
DtMmdbBookGetLongTitle(DtMmdbInfoRequest* request, unsigned int* length)
|
||||
{
|
||||
mtry {
|
||||
doc_smart_ptr* x = getDocUsingPrOrSecOrSeq(request);
|
||||
if ( x == 0 ) return 0;
|
||||
|
||||
const char* z = x -> long_title();
|
||||
|
||||
if ( length ) *length = strlen(z);
|
||||
|
||||
delete x;
|
||||
return z;
|
||||
}
|
||||
|
||||
mcatch (mmdbException &,e)
|
||||
{
|
||||
return 0;
|
||||
} end_try;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int DtMmdbBookGetSeqNum(DtMmdbInfoRequest* request)
|
||||
{
|
||||
mtry {
|
||||
doc_smart_ptr* x = getDocUsingPrOrSecOrSeq(request);
|
||||
if ( x == 0 ) return 0;
|
||||
|
||||
int z = x -> seq_num();
|
||||
|
||||
delete x;
|
||||
return z;
|
||||
}
|
||||
|
||||
mcatch (mmdbException &,e)
|
||||
{
|
||||
return 0;
|
||||
} end_try;
|
||||
return 0;
|
||||
}
|
||||
|
||||
const char*
|
||||
DtMmdbBookGetSeqLIcense(DtMmdbInfoRequest* request, unsigned int* length)
|
||||
{
|
||||
mtry {
|
||||
doc_smart_ptr* x = getDocUsingPrOrSecOrSeq(request);
|
||||
if ( x == 0 ) return 0;
|
||||
|
||||
const char* z = x -> license_terms();
|
||||
if ( length )
|
||||
*length = x -> license_terms_size();
|
||||
|
||||
delete x;
|
||||
return z;
|
||||
}
|
||||
|
||||
mcatch (mmdbException &,e)
|
||||
{
|
||||
return 0;
|
||||
} end_try;
|
||||
return 0;
|
||||
}
|
||||
|
||||
DtMmdbHandle** DtMmdbBookGetTabList(DtMmdbInfoRequest* request, unsigned int* length)
|
||||
{
|
||||
mtry {
|
||||
doc_smart_ptr* x = getDocUsingPrOrSecOrSeq(request);
|
||||
if ( x == 0 ) return 0;
|
||||
|
||||
short_list_handler* z = x -> tab_list();
|
||||
|
||||
if ( z == 0 ) return 0;
|
||||
|
||||
int count = (*z) -> count();
|
||||
|
||||
DtMmdbHandle** u = (DtMmdbHandle**)malloc(sizeof(DtMmdbHandle*)* (count+1));
|
||||
|
||||
if ( u == 0 ) return 0;
|
||||
|
||||
const char* desc = 0;
|
||||
pstring_handler *p = 0;
|
||||
|
||||
int i;
|
||||
for (i=0; i<count; i++) {
|
||||
p = (pstring_handler *)((*z)->get_component (i+1));
|
||||
|
||||
// The format is the title, a tab char, then the section oid.
|
||||
desc = (*p)->get();
|
||||
|
||||
while (*desc != '\0' && *desc != '\t') desc++;
|
||||
|
||||
if (*desc != '\t') {
|
||||
free(u);
|
||||
return 0;
|
||||
}
|
||||
|
||||
desc++;
|
||||
|
||||
oid_t w((char*)desc, true, false);
|
||||
u[i] = newDtMmdbHandle(w);
|
||||
|
||||
delete p;
|
||||
|
||||
}
|
||||
|
||||
u[i] = 0;
|
||||
|
||||
if ( length ) *length = count;
|
||||
|
||||
delete z;
|
||||
delete x;
|
||||
return u;
|
||||
}
|
||||
|
||||
mcatch (mmdbException &,e)
|
||||
{
|
||||
return 0;
|
||||
} end_try;
|
||||
return 0;
|
||||
}
|
||||
156
cde/lib/DtMmdb/oliasdb/c_api_book_test.C
Normal file
156
cde/lib/DtMmdb/oliasdb/c_api_book_test.C
Normal file
@@ -0,0 +1,156 @@
|
||||
/*
|
||||
* CDE - Common Desktop Environment
|
||||
*
|
||||
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
|
||||
*
|
||||
* These libraries and programs are free software; you can
|
||||
* redistribute them and/or modify them under the terms of the GNU
|
||||
* Lesser General Public License as published by the Free Software
|
||||
* Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* These libraries and programs are distributed in the hope that
|
||||
* they will be useful, but WITHOUT ANY WARRANTY; without even the
|
||||
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU Lesser General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with these libraries and programs; if not, write
|
||||
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
|
||||
* Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
/* $XConsortium: c_api_book_test.C /main/5 1996/08/21 15:52:51 drk $ */
|
||||
|
||||
#include "oliasdb/DtMmdb.h"
|
||||
#include <stdio.h>
|
||||
|
||||
extern "C"
|
||||
void showBook(DtMmdbInfoRequest* req)
|
||||
{
|
||||
const char* str = 0;
|
||||
DtMmdbHandle* id = 0;
|
||||
unsigned int l;
|
||||
int x ;
|
||||
DtMmdbHandle** ids;
|
||||
|
||||
if ( req == 0 ) return ;
|
||||
|
||||
str = DtMmdbBookGetShortTitle(req, &l);
|
||||
if ( str )
|
||||
fprintf(stderr, " bookInfo: shortTitle=%s\n", str);
|
||||
|
||||
str = DtMmdbBookGetLongTitle(req, &l);
|
||||
if ( str )
|
||||
fprintf(stderr, " bookInfo: longTitle=%s\n", str);
|
||||
|
||||
id = DtMmdbBookGetTocObjectId(req);
|
||||
if ( id )
|
||||
fprintf(stderr, " bookInfo: TOC section id=%s\n", DtMmdbHandleToString(id));
|
||||
DtMmdbFreeHandle(id);
|
||||
|
||||
x = DtMmdbBookGetSeqNum(req);
|
||||
fprintf(stderr, " bookInfo: seqnum =%d\n", x);
|
||||
|
||||
str =DtMmdbBookGetSeqLIcense(req, &l);
|
||||
if ( str )
|
||||
fprintf(stderr, " bookInfo: license term=%s\n", str);
|
||||
|
||||
ids = DtMmdbBookGetTabList(req, &l);
|
||||
if (ids) {
|
||||
for ( x=0; x<(int)l; x++ )
|
||||
fprintf(stderr, " bookInfo: tab section id=%s\n", DtMmdbHandleToString(ids[x]));
|
||||
}
|
||||
DtMmdbFreeHandleList(ids);
|
||||
}
|
||||
|
||||
/* TOC section's oid ask key */
|
||||
extern "C"
|
||||
int test_book1(int argc, char** argv)
|
||||
{
|
||||
int j = 0;
|
||||
int i = -1;
|
||||
DtMmdbInfoRequest* req = 0;
|
||||
|
||||
switch ( argc ) {
|
||||
case 5:
|
||||
{
|
||||
i = DtMmdbOpenInfoLib(argv[2], argv[3], DtMmdbFalse);
|
||||
j = DtMmdbGetBookCaseByName(i, argv[3]);
|
||||
|
||||
req = newDtMmdbInfoRequestWithPrimaryOid(j, argv[4]);
|
||||
showBook(req);
|
||||
|
||||
DtMmdbFreeInfoRequest(req);
|
||||
DtMmdbCloseInfoLib(i);
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
fprintf(stderr, "invalid arguments\n");
|
||||
}
|
||||
|
||||
fprintf(stderr, "infolib desc=%d\n", i);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* book's oid as key */
|
||||
extern "C"
|
||||
int test_book2(int argc, char** argv)
|
||||
{
|
||||
int j = 0;
|
||||
int i = -1;
|
||||
DtMmdbInfoRequest* req = 0;
|
||||
|
||||
switch ( argc ) {
|
||||
case 5:
|
||||
{
|
||||
i = DtMmdbOpenInfoLib(argv[2], argv[3], DtMmdbFalse);
|
||||
j = DtMmdbGetBookCaseByName(i, argv[3]);
|
||||
|
||||
req = newDtMmdbInfoRequestWithSecondaryOid(j, argv[4]);
|
||||
showBook(req);
|
||||
|
||||
DtMmdbFreeInfoRequest(req);
|
||||
DtMmdbCloseInfoLib(i);
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
fprintf(stderr, "invalid arguments\n");
|
||||
}
|
||||
|
||||
fprintf(stderr, "infolib desc=%d\n", i);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* book's seq number as key */
|
||||
extern "C"
|
||||
int test_book3(int argc, char** argv)
|
||||
{
|
||||
int j = 0;
|
||||
int i = -1;
|
||||
DtMmdbInfoRequest* req = 0;
|
||||
|
||||
switch ( argc ) {
|
||||
case 5:
|
||||
{
|
||||
i = DtMmdbOpenInfoLib(argv[2], argv[3], DtMmdbFalse);
|
||||
j = DtMmdbGetBookCaseByName(i, argv[3]);
|
||||
|
||||
req = newDtMmdbInfoRequestWithSeqnum(j, argv[4]);
|
||||
showBook(req);
|
||||
|
||||
DtMmdbFreeInfoRequest(req);
|
||||
DtMmdbCloseInfoLib(i);
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
fprintf(stderr, "invalid arguments\n");
|
||||
}
|
||||
|
||||
fprintf(stderr, "infolib desc=%d\n", i);
|
||||
return 0;
|
||||
}
|
||||
|
||||
190
cde/lib/DtMmdb/oliasdb/c_api_bookcase.C
Normal file
190
cde/lib/DtMmdb/oliasdb/c_api_bookcase.C
Normal file
@@ -0,0 +1,190 @@
|
||||
/*
|
||||
* CDE - Common Desktop Environment
|
||||
*
|
||||
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
|
||||
*
|
||||
* These libraries and programs are free software; you can
|
||||
* redistribute them and/or modify them under the terms of the GNU
|
||||
* Lesser General Public License as published by the Free Software
|
||||
* Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* These libraries and programs are distributed in the hope that
|
||||
* they will be useful, but WITHOUT ANY WARRANTY; without even the
|
||||
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU Lesser General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with these libraries and programs; if not, write
|
||||
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
|
||||
* Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
/* $XConsortium: c_api_bookcase.cc /main/5 1996/07/18 16:00:51 drk $ */
|
||||
|
||||
#include "oliasdb/c_api_common.h"
|
||||
|
||||
//extern void_ptr_array* infolib_array;
|
||||
extern void_ptr_array* bookcase_array;
|
||||
//extern olias_server* oserver_ptr;
|
||||
extern OLIAS_DB* mmdb_ptr;
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////
|
||||
|
||||
int
|
||||
DtMmdbGetBookCaseByName(int infolib_descriptor, const char* name)
|
||||
{
|
||||
mtry {
|
||||
info_lib* x = mmdb_ptr -> getInfoLib(infolib_descriptor);
|
||||
|
||||
if ( x == 0 ) return -1;
|
||||
|
||||
info_base* base = x -> get_info_base(name);
|
||||
|
||||
if ( base == 0 )
|
||||
return -1;
|
||||
else
|
||||
return base -> index_id();
|
||||
}
|
||||
|
||||
mcatch (mmdbException &,e)
|
||||
{
|
||||
return -1;
|
||||
} end_try;
|
||||
return -1;
|
||||
}
|
||||
|
||||
int
|
||||
DtMmdbGetBookCaseByIndex(int infolib_descriptor, int index)
|
||||
{
|
||||
mtry {
|
||||
info_lib* x = mmdb_ptr -> getInfoLib(infolib_descriptor);
|
||||
|
||||
if ( x == 0 ) return -1;
|
||||
|
||||
if ( 0 <= index && index < x -> num_of_bases() ) {
|
||||
|
||||
info_base* base;
|
||||
|
||||
long ind = x -> first();
|
||||
for ( int i=0; i<index; i++ )
|
||||
x -> next(ind);
|
||||
|
||||
base = (*x)(ind);
|
||||
|
||||
if ( base == 0 )
|
||||
return -1;
|
||||
else
|
||||
return base -> index_id();
|
||||
|
||||
} else
|
||||
return -1;
|
||||
}
|
||||
mcatch (mmdbException &,e)
|
||||
{
|
||||
return -1;
|
||||
} end_try;
|
||||
return -1;
|
||||
}
|
||||
|
||||
int
|
||||
DtMmdbGetBookCaseByLoc(int infolib_descriptor, const char* locator)
|
||||
{
|
||||
mtry {
|
||||
info_lib* x = mmdb_ptr -> getInfoLib(infolib_descriptor);
|
||||
|
||||
if ( x == 0 ) return -1;
|
||||
|
||||
//info_base* base = oserver_ptr -> get_infobase(locator, olias_server::LOC);
|
||||
info_base* base = x -> getInfobaseByComponent(locator, info_lib::LOC);
|
||||
|
||||
if ( base == 0 )
|
||||
return -1;
|
||||
else
|
||||
return base -> index_id();
|
||||
|
||||
}
|
||||
mcatch (mmdbException &,e)
|
||||
{
|
||||
return -1;
|
||||
} end_try;
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
int*
|
||||
DtMmdbGetBookCaseByLocs(int infolib_descriptor, const char** locators,
|
||||
int* count_ptr)
|
||||
{
|
||||
|
||||
mtry {
|
||||
info_lib* x = mmdb_ptr -> getInfoLib(infolib_descriptor);
|
||||
|
||||
if ( x == 0 ) return 0;
|
||||
|
||||
int count = 0;
|
||||
while ( locators[count] )
|
||||
count++;
|
||||
|
||||
info_base** bases =
|
||||
x -> getInfobasesByComponent((char**)locators, count, info_lib::LOC);
|
||||
|
||||
count = 0;
|
||||
while ( bases[count] )
|
||||
count++;
|
||||
|
||||
int* ds = (int*) malloc(sizeof(int)*(count+1));
|
||||
|
||||
for ( int i=0; i<count; i++ )
|
||||
ds[i] = bases[i] -> index_id();
|
||||
|
||||
delete [] bases;
|
||||
|
||||
if (count_ptr) *count_ptr = count;
|
||||
|
||||
return ds;
|
||||
|
||||
}
|
||||
mcatch (mmdbException &,e)
|
||||
{
|
||||
if (count_ptr) *count_ptr = 0;
|
||||
return 0;
|
||||
} end_try;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
DtMmdbBookCaseInfo*
|
||||
DtMmdbBookCaseGetInfo(int bookcase_descriptor)
|
||||
{
|
||||
mtry {
|
||||
info_base* x = getBookCase(bookcase_descriptor);
|
||||
|
||||
if ( x == 0 ) return 0;
|
||||
|
||||
DtMmdbBookCaseInfo *y =
|
||||
(DtMmdbBookCaseInfo*)malloc(sizeof(DtMmdbBookCaseInfo));
|
||||
|
||||
if ( y == 0 ) return 0;
|
||||
|
||||
y -> name = x -> get_base_name();
|
||||
y -> num_books = x -> num_of_docs();
|
||||
|
||||
return y;
|
||||
|
||||
}
|
||||
mcatch (mmdbException &,e)
|
||||
{
|
||||
return 0;
|
||||
} end_try;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void DtMmdbBookCaseFreeInfo(DtMmdbBookCaseInfo* x)
|
||||
{
|
||||
free((void*)x);
|
||||
}
|
||||
|
||||
45
cde/lib/DtMmdb/oliasdb/c_api_bookcase_test.C
Normal file
45
cde/lib/DtMmdb/oliasdb/c_api_bookcase_test.C
Normal file
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* CDE - Common Desktop Environment
|
||||
*
|
||||
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
|
||||
*
|
||||
* These libraries and programs are free software; you can
|
||||
* redistribute them and/or modify them under the terms of the GNU
|
||||
* Lesser General Public License as published by the Free Software
|
||||
* Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* These libraries and programs are distributed in the hope that
|
||||
* they will be useful, but WITHOUT ANY WARRANTY; without even the
|
||||
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU Lesser General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with these libraries and programs; if not, write
|
||||
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
|
||||
* Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
/* $XConsortium: c_api_bookcase_test.C /main/5 1996/08/21 15:52:55 drk $ */
|
||||
|
||||
#include "oliasdb/DtMmdb.h"
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
extern "C"
|
||||
void showBookCaseInfo(int i)
|
||||
{
|
||||
if ( i <= -1 ) {
|
||||
fprintf(stderr, "bad bookcase descriptor %d\n", i);
|
||||
} else {
|
||||
DtMmdbBookCaseInfo* info = DtMmdbBookCaseGetInfo(i);
|
||||
if ( info ) {
|
||||
if ( info -> name )
|
||||
fprintf(stderr, " bookcaseInfo: name= %s\n", info -> name);
|
||||
fprintf(stderr, " bookcaseInfo: num_bookcases= %d\n", info -> num_books);
|
||||
DtMmdbBookCaseFreeInfo(info);
|
||||
} else
|
||||
fprintf(stderr, "no bookcase info\n");
|
||||
}
|
||||
}
|
||||
|
||||
357
cde/lib/DtMmdb/oliasdb/c_api_common.C
Normal file
357
cde/lib/DtMmdb/oliasdb/c_api_common.C
Normal file
@@ -0,0 +1,357 @@
|
||||
/*
|
||||
* CDE - Common Desktop Environment
|
||||
*
|
||||
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
|
||||
*
|
||||
* These libraries and programs are free software; you can
|
||||
* redistribute them and/or modify them under the terms of the GNU
|
||||
* Lesser General Public License as published by the Free Software
|
||||
* Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* These libraries and programs are distributed in the hope that
|
||||
* they will be useful, but WITHOUT ANY WARRANTY; without even the
|
||||
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU Lesser General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with these libraries and programs; if not, write
|
||||
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
|
||||
* Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
/* $XConsortium: c_api_common.cc /main/5 1996/07/18 16:01:11 drk $ */
|
||||
|
||||
#include "dstr/void_ptr_array.h"
|
||||
#include "storage/page_storage.h"
|
||||
#include "api/info_lib.h"
|
||||
#include <stdlib.h>
|
||||
#include <limits.h>
|
||||
#include "schema/store_desc.h"
|
||||
#include "dynhash/data_t.h"
|
||||
#include "index/index.h"
|
||||
#include "object/compressed_pstring.h"
|
||||
#include "object/pstring.h"
|
||||
|
||||
#include "oliasdb/DtMmdb.h"
|
||||
#include "oliasdb/olias_funcs.h"
|
||||
#include "oliasdb/c_api_common.h"
|
||||
#include "oliasdb/graphic_hd.h"
|
||||
|
||||
#include "exception_init.h"
|
||||
|
||||
void_ptr_array* infolib_array = 0;
|
||||
void_ptr_array* bookcase_array = 0;
|
||||
OLIAS_DB *mmdb_ptr = 0;
|
||||
|
||||
DtMmdbHandle* DtMmdbGroundId;
|
||||
|
||||
void initialize_MMDB()
|
||||
{
|
||||
initialize_exception();
|
||||
|
||||
INIT_EXCEPTIONS();
|
||||
|
||||
cin_ptr = new fstream(0);
|
||||
cout_ptr = new fstream(1);
|
||||
cerr_ptr = new fstream(2);
|
||||
|
||||
g_memory_pool_ptr = new memory_pool;
|
||||
|
||||
page_storage::f_global_pcache_ptr = new page_cache_global_part;
|
||||
|
||||
ostring::input_buf = new char[LBUFSIZ];
|
||||
|
||||
data_t::larson_convertor_ptr = new atoi_larson;
|
||||
data_t::pearson_convertor_ptr = new atoi_pearson(SHRT_MAX, 256);
|
||||
|
||||
ground_ptr = new oid_t(c_code_t(0), i_code_t(0));
|
||||
|
||||
//root::io_info_buffer_ptr = new struct persis_t;
|
||||
|
||||
pstring::v_io_buf_ptr = new buffer(LBUFSIZ);
|
||||
graphic_smart_ptr::local_graphic_buffer_ptr = new buffer(LBUFSIZ);
|
||||
|
||||
compressed_pstring::working_buffer_ptr = new buffer(LBUFSIZ);
|
||||
compressed_pstring::v_cp_io_buf_ptr = new buffer(LBUFSIZ);
|
||||
|
||||
store_desc::v_unixf_pool_ptr =
|
||||
new lru(ACTIVE_UNIXF_SZ, INACTIVE_UNIXF_SZ, false);
|
||||
|
||||
c_index::v_static_key_ptr = new key_type(LBUFSIZ);
|
||||
|
||||
infolib_array = new void_ptr_array(10);
|
||||
bookcase_array = new void_ptr_array(10);
|
||||
}
|
||||
|
||||
void quit_MMDB()
|
||||
{
|
||||
delete c_index::v_static_key_ptr;
|
||||
|
||||
delete store_desc::v_unixf_pool_ptr;
|
||||
|
||||
delete compressed_pstring::working_buffer_ptr;
|
||||
delete compressed_pstring::v_cp_io_buf_ptr;
|
||||
|
||||
delete pstring::v_io_buf_ptr;
|
||||
delete graphic_smart_ptr::local_graphic_buffer_ptr;
|
||||
|
||||
//delete root::io_info_buffer_ptr;
|
||||
|
||||
delete ground_ptr;
|
||||
|
||||
delete data_t::larson_convertor_ptr;
|
||||
delete data_t::pearson_convertor_ptr;
|
||||
|
||||
delete ostring::input_buf;
|
||||
|
||||
delete page_storage::f_global_pcache_ptr;
|
||||
|
||||
delete g_memory_pool_ptr;
|
||||
|
||||
delete cin_ptr ;
|
||||
delete cout_ptr ;
|
||||
delete cerr_ptr ;
|
||||
|
||||
delete infolib_array;
|
||||
delete bookcase_array;
|
||||
|
||||
quit_exception();
|
||||
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
extern "C" {
|
||||
void DtMmdbInit()
|
||||
{
|
||||
initialize_MMDB();
|
||||
}
|
||||
|
||||
void DtMmdbQuit()
|
||||
{
|
||||
quit_MMDB();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#if __cplusplus < 201103L
|
||||
void* operator new( size_t sz ) throw(std::bad_alloc)
|
||||
#else
|
||||
void* operator new( size_t sz )
|
||||
#endif
|
||||
{
|
||||
void* p = (void*)malloc(sz);
|
||||
//printf("a::operator new called(). sz= %d, allo=%x\n", sz, p);
|
||||
return p;
|
||||
}
|
||||
|
||||
void operator delete( void* p ) throw()
|
||||
{
|
||||
//printf("a::operator free called(). alloc= %x\n", p);
|
||||
if ( p )
|
||||
free((char*)p);
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
extern "C" {
|
||||
void* centerline_new(int n, char*, int)
|
||||
{
|
||||
return :: operator new(n);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
info_lib* getInfoLib(int infolib_descriptor)
|
||||
{
|
||||
if ( 0 <= infolib_descriptor && infolib_array &&
|
||||
infolib_descriptor < infolib_array -> no_elmts()
|
||||
)
|
||||
{
|
||||
return (info_lib*)(*infolib_array)[infolib_descriptor];
|
||||
} else
|
||||
return 0;
|
||||
}
|
||||
*/
|
||||
|
||||
info_base* getBookCase(int bookcase_descriptor)
|
||||
{
|
||||
if ( 0 <= bookcase_descriptor && bookcase_array &&
|
||||
bookcase_descriptor < bookcase_array -> no_elmts()
|
||||
) {
|
||||
return (info_base*)(*bookcase_array)[bookcase_descriptor];
|
||||
} else
|
||||
return 0;
|
||||
}
|
||||
|
||||
oid_t* getPrimiaryOid(DtMmdbInfoRequest* x)
|
||||
{
|
||||
if ( x == 0 ) return 0;
|
||||
|
||||
if ( x -> primary_oid == 0 ) return 0;
|
||||
|
||||
return (oid_t*)(x -> primary_oid -> oid_ptr);
|
||||
}
|
||||
|
||||
oid_t* getSecondaryOid(DtMmdbInfoRequest* x)
|
||||
{
|
||||
if ( x == 0 ) return 0;
|
||||
|
||||
if ( x -> secondary_oid == 0 ) return 0;
|
||||
|
||||
return (oid_t*)(x -> secondary_oid -> oid_ptr);
|
||||
}
|
||||
|
||||
int getSeqNum(DtMmdbInfoRequest* x)
|
||||
{
|
||||
if ( x == 0 ) return -1;
|
||||
return x -> sequence_num;
|
||||
}
|
||||
|
||||
const char* getLocator(DtMmdbInfoRequest* x)
|
||||
{
|
||||
if ( x == 0 ) return 0;
|
||||
|
||||
return x -> locator_ptr;
|
||||
}
|
||||
|
||||
DtMmdbHandle* newDtMmdbHandle(const oid_t& x)
|
||||
{
|
||||
oid_t* y = new oid_t(x);
|
||||
DtMmdbHandle *z = (DtMmdbHandle*)malloc(sizeof(DtMmdbHandle));
|
||||
z -> oid_ptr = (void*)y;
|
||||
return z;
|
||||
}
|
||||
|
||||
DtMmdbGraphicInfo* newDtMmdbGraphicInfo()
|
||||
{
|
||||
DtMmdbGraphicInfo *z =
|
||||
(DtMmdbGraphicInfo*)malloc(sizeof(DtMmdbGraphicInfo));
|
||||
return z;
|
||||
}
|
||||
|
||||
void DtMmdbFreeHandle(DtMmdbHandle* x)
|
||||
{
|
||||
if ( x ) {
|
||||
// delete x -> oid_ptr;
|
||||
free((void*)x);
|
||||
}
|
||||
}
|
||||
|
||||
void DtMmdbFreeHandleList(DtMmdbHandle** list)
|
||||
{
|
||||
if ( list ) {
|
||||
int i = 0;
|
||||
while ( list[i] ) {
|
||||
DtMmdbFreeHandle(list[i]);
|
||||
i++;
|
||||
}
|
||||
free((void*)list);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef REGRESSION_TEST
|
||||
extern int auto_test(int argc, char** argv, OLIAS_DB& db);
|
||||
#endif
|
||||
|
||||
extern "C" {
|
||||
int auto_test_c_api(int argc, char** argv)
|
||||
{
|
||||
mtry
|
||||
{
|
||||
#ifdef REGRESSION_TEST
|
||||
OLIAS_DB db;
|
||||
return auto_test(argc, argv, db);
|
||||
#else
|
||||
return -1;
|
||||
#endif
|
||||
}
|
||||
|
||||
mcatch (mmdbException &,e)
|
||||
{
|
||||
cerr << "Exception msg: " << e << "\n";
|
||||
return -1;
|
||||
}
|
||||
end_try;
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
DtMmdbInfoRequest* newDtMmdbInfoRequestWithLoc(int bc_id, char* loc)
|
||||
{
|
||||
DtMmdbInfoRequest* x =
|
||||
(DtMmdbInfoRequest*) malloc(sizeof(DtMmdbInfoRequest));
|
||||
|
||||
|
||||
x -> bookcase_descriptor = bc_id ;
|
||||
x -> primary_oid = 0;
|
||||
x -> secondary_oid = 0;
|
||||
x -> locator_ptr = loc;
|
||||
return x;
|
||||
}
|
||||
|
||||
DtMmdbInfoRequest* newDtMmdbInfoRequestWithPrimaryOid(int bc_id, char* oid_str)
|
||||
{
|
||||
DtMmdbInfoRequest* x =
|
||||
(DtMmdbInfoRequest*) malloc(sizeof(DtMmdbInfoRequest));
|
||||
|
||||
|
||||
x -> bookcase_descriptor = bc_id ;
|
||||
x -> locator_ptr = 0;
|
||||
x -> primary_oid = newDtMmdbHandle(oid_t(oid_str, true, false));
|
||||
x -> secondary_oid = 0;
|
||||
return x;
|
||||
}
|
||||
|
||||
DtMmdbInfoRequest* newDtMmdbInfoRequestWithSecondaryOid(int bc_id, char* oid_str)
|
||||
{
|
||||
DtMmdbInfoRequest* x =
|
||||
(DtMmdbInfoRequest*) malloc(sizeof(DtMmdbInfoRequest));
|
||||
|
||||
|
||||
x -> bookcase_descriptor = bc_id ;
|
||||
x -> locator_ptr = 0;
|
||||
x -> primary_oid = 0;
|
||||
x -> secondary_oid = newDtMmdbHandle(oid_t(oid_str, true, false));
|
||||
return x;
|
||||
}
|
||||
|
||||
DtMmdbInfoRequest* newDtMmdbInfoRequestWithSeqnum(int bc_id, char* str)
|
||||
{
|
||||
DtMmdbInfoRequest* x =
|
||||
(DtMmdbInfoRequest*) malloc(sizeof(DtMmdbInfoRequest));
|
||||
|
||||
|
||||
x -> bookcase_descriptor = bc_id ;
|
||||
x -> locator_ptr = 0;
|
||||
x -> primary_oid = 0;
|
||||
x -> secondary_oid = 0;
|
||||
x -> sequence_num = atoi(str);
|
||||
return x;
|
||||
}
|
||||
|
||||
char* DtMmdbHandleToString(DtMmdbHandle* x)
|
||||
{
|
||||
static char buf[100];
|
||||
if ( x -> oid_ptr) {
|
||||
oid_t *z = (oid_t*)(x -> oid_ptr);
|
||||
snprintf(buf, sizeof(buf), "%d.%d", z -> ccode(), (int)z -> icode());
|
||||
} else
|
||||
buf[0] = 0;
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
void DtMmdbFreeInfoRequest(DtMmdbInfoRequest* x)
|
||||
{
|
||||
if ( x ) {
|
||||
DtMmdbFreeHandle(x-> primary_oid);
|
||||
DtMmdbFreeHandle(x-> secondary_oid);
|
||||
free(x);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
41
cde/lib/DtMmdb/oliasdb/c_api_common.h
Normal file
41
cde/lib/DtMmdb/oliasdb/c_api_common.h
Normal file
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* CDE - Common Desktop Environment
|
||||
*
|
||||
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
|
||||
*
|
||||
* These libraries and programs are free software; you can
|
||||
* redistribute them and/or modify them under the terms of the GNU
|
||||
* Lesser General Public License as published by the Free Software
|
||||
* Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* These libraries and programs are distributed in the hope that
|
||||
* they will be useful, but WITHOUT ANY WARRANTY; without even the
|
||||
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU Lesser General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with these libraries and programs; if not, write
|
||||
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
|
||||
* Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
/* $XConsortium: c_api_common.h /main/4 1996/06/11 17:27:02 cde-hal $ */
|
||||
|
||||
#ifndef cc_api_common_h
|
||||
#define cc_api_common_h
|
||||
|
||||
#include "oliasdb/mmdb.h"
|
||||
#include "oliasdb/DtMmdb.h"
|
||||
|
||||
extern OLIAS_DB* mmdb_ptr;
|
||||
extern info_base* getBookCase(int);
|
||||
extern oid_t* getPrimiaryOid(DtMmdbInfoRequest* x);
|
||||
extern oid_t* getSecondaryOid(DtMmdbInfoRequest* x);
|
||||
extern int getSeqNum(DtMmdbInfoRequest* x);
|
||||
extern const char* getLocator(DtMmdbInfoRequest* x);
|
||||
extern DtMmdbHandle* newDtMmdbHandle(const oid_t& x);
|
||||
extern DtMmdbGraphicInfo* newDtMmdbGraphicInfo();
|
||||
|
||||
|
||||
#endif
|
||||
98
cde/lib/DtMmdb/oliasdb/c_api_dlp.C
Normal file
98
cde/lib/DtMmdb/oliasdb/c_api_dlp.C
Normal file
@@ -0,0 +1,98 @@
|
||||
/*
|
||||
* CDE - Common Desktop Environment
|
||||
*
|
||||
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
|
||||
*
|
||||
* These libraries and programs are free software; you can
|
||||
* redistribute them and/or modify them under the terms of the GNU
|
||||
* Lesser General Public License as published by the Free Software
|
||||
* Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* These libraries and programs are distributed in the hope that
|
||||
* they will be useful, but WITHOUT ANY WARRANTY; without even the
|
||||
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU Lesser General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with these libraries and programs; if not, write
|
||||
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
|
||||
* Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
// $XConsortium: c_api_dlp.cc /main/4 1996/06/11 17:27:07 cde-hal $
|
||||
|
||||
#include "oliasdb/c_api_common.h"
|
||||
|
||||
static dlp_smart_ptr*
|
||||
getDlpUsingProid(DtMmdbInfoRequest* request)
|
||||
{
|
||||
mtry {
|
||||
info_base* x = getBookCase(request -> bookcase_descriptor);
|
||||
if ( x == 0 ) return 0;
|
||||
|
||||
oid_t * id = getPrimiaryOid(request);
|
||||
|
||||
if ( id ) {
|
||||
return new dlp_smart_ptr(x, *id);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
mcatch (mmdbException &,e)
|
||||
{
|
||||
return 0;
|
||||
} end_try;
|
||||
return 0;
|
||||
}
|
||||
|
||||
DtMmdbHandle*
|
||||
DtMmdbDlpGetPrevSectionId(DtMmdbInfoRequest* request)
|
||||
{
|
||||
mtry {
|
||||
dlp_smart_ptr* x = getDlpUsingProid(request);
|
||||
if ( x == 0 ) return 0;
|
||||
DtMmdbHandle *z = 0;
|
||||
|
||||
if ( x -> prev_node_oid() == ground )
|
||||
z = DtMmdbGroundId;
|
||||
else
|
||||
z = newDtMmdbHandle(x -> prev_node_oid());
|
||||
|
||||
delete x;
|
||||
return z;
|
||||
}
|
||||
|
||||
mcatch (mmdbException &,e)
|
||||
{
|
||||
return 0;
|
||||
} end_try;
|
||||
return 0;
|
||||
}
|
||||
|
||||
DtMmdbHandle*
|
||||
DtMmdbDlpGetNextSectionId(DtMmdbInfoRequest* request)
|
||||
{
|
||||
mtry {
|
||||
dlp_smart_ptr* x = getDlpUsingProid(request);
|
||||
if ( x == 0 ) return 0;
|
||||
|
||||
DtMmdbHandle *z = 0;
|
||||
|
||||
if ( x -> next_node_oid() == ground)
|
||||
z = DtMmdbGroundId;
|
||||
else
|
||||
z = newDtMmdbHandle(x -> next_node_oid());
|
||||
|
||||
delete x;
|
||||
return z;
|
||||
}
|
||||
|
||||
mcatch (mmdbException &,e)
|
||||
{
|
||||
return 0;
|
||||
} end_try;
|
||||
return 0;
|
||||
}
|
||||
|
||||
77
cde/lib/DtMmdb/oliasdb/c_api_dlp_test.C
Normal file
77
cde/lib/DtMmdb/oliasdb/c_api_dlp_test.C
Normal file
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
* CDE - Common Desktop Environment
|
||||
*
|
||||
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
|
||||
*
|
||||
* These libraries and programs are free software; you can
|
||||
* redistribute them and/or modify them under the terms of the GNU
|
||||
* Lesser General Public License as published by the Free Software
|
||||
* Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* These libraries and programs are distributed in the hope that
|
||||
* they will be useful, but WITHOUT ANY WARRANTY; without even the
|
||||
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU Lesser General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with these libraries and programs; if not, write
|
||||
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
|
||||
* Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
/* $XConsortium: c_api_dlp_test.C /main/5 1996/08/21 15:53:00 drk $ */
|
||||
|
||||
#include "oliasdb/DtMmdb.h"
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
extern "C"
|
||||
void showDLPCell(DtMmdbInfoRequest* req)
|
||||
{
|
||||
DtMmdbHandle* id ;
|
||||
|
||||
if ( req == 0 ) return ;
|
||||
|
||||
id = DtMmdbDlpGetPrevSectionId(req);
|
||||
if ( id )
|
||||
fprintf(stderr, " DLP: prevSectionId=%s\n", DtMmdbHandleToString(id));
|
||||
DtMmdbFreeHandle(id);
|
||||
|
||||
id = DtMmdbDlpGetNextSectionId(req);
|
||||
if ( id )
|
||||
fprintf(stderr, " DLP: nextSectionId=%s\n", DtMmdbHandleToString(id));
|
||||
DtMmdbFreeHandle(id);
|
||||
}
|
||||
|
||||
extern "C"
|
||||
int test_dlp(int argc, char** argv)
|
||||
{
|
||||
int j = 0;
|
||||
int i = 0;
|
||||
DtMmdbInfoRequest* req ;
|
||||
|
||||
switch ( argc ) {
|
||||
case 5:
|
||||
{
|
||||
i = DtMmdbOpenInfoLib(argv[2], argv[3], DtMmdbFalse);
|
||||
j = DtMmdbGetBookCaseByName(i, argv[3]);
|
||||
|
||||
req = newDtMmdbInfoRequestWithPrimaryOid(j, argv[4]);
|
||||
showDLPCell(req);
|
||||
|
||||
DtMmdbFreeInfoRequest(req);
|
||||
DtMmdbCloseInfoLib(i);
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
fprintf(stderr, "invalid arguments\n");
|
||||
}
|
||||
|
||||
fprintf(stderr, "infolib desc=%d\n", i);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
140
cde/lib/DtMmdb/oliasdb/c_api_graphic.C
Normal file
140
cde/lib/DtMmdb/oliasdb/c_api_graphic.C
Normal file
@@ -0,0 +1,140 @@
|
||||
/*
|
||||
* CDE - Common Desktop Environment
|
||||
*
|
||||
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
|
||||
*
|
||||
* These libraries and programs are free software; you can
|
||||
* redistribute them and/or modify them under the terms of the GNU
|
||||
* Lesser General Public License as published by the Free Software
|
||||
* Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* These libraries and programs are distributed in the hope that
|
||||
* they will be useful, but WITHOUT ANY WARRANTY; without even the
|
||||
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU Lesser General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with these libraries and programs; if not, write
|
||||
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
|
||||
* Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
// $XConsortium: c_api_graphic.cc /main/3 1996/06/11 17:27:16 cde-hal $
|
||||
|
||||
#include "oliasdb/c_api_common.h"
|
||||
|
||||
static graphic_smart_ptr*
|
||||
getGraphicUsingLocAndProid(DtMmdbInfoRequest* request, Boolean checkLocOnly = false)
|
||||
{
|
||||
mtry {
|
||||
info_base* x = getBookCase(request -> bookcase_descriptor);
|
||||
if ( x == 0 ) return 0;
|
||||
|
||||
const char* str = getLocator(request);
|
||||
|
||||
if ( str ) {
|
||||
return new graphic_smart_ptr(x, str);
|
||||
}
|
||||
|
||||
if ( checkLocOnly == true ) return 0;
|
||||
|
||||
oid_t * id = getPrimiaryOid(request);
|
||||
|
||||
if ( id == 0 ) return 0;
|
||||
|
||||
return new graphic_smart_ptr(x, *id);
|
||||
}
|
||||
|
||||
mcatch (mmdbException &,e)
|
||||
{
|
||||
return 0;
|
||||
} end_try;
|
||||
return 0;
|
||||
}
|
||||
|
||||
const char*
|
||||
DtMmdbGraphicGetData(DtMmdbInfoRequest* request, unsigned int* data_length)
|
||||
{
|
||||
mtry {
|
||||
graphic_smart_ptr* x = getGraphicUsingLocAndProid(request, true);
|
||||
|
||||
if ( x == 0 ) return 0;
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, " graphicInfo: mmdb_oid = %d.%d\n", (int)(*x).its_oid().ccode(), (int)(*x).its_oid().icode());
|
||||
#endif
|
||||
|
||||
const char* y = x -> data();
|
||||
if ( data_length ) *data_length = x -> data_size();
|
||||
|
||||
delete x;
|
||||
return y;
|
||||
}
|
||||
|
||||
mcatch (mmdbException &,e)
|
||||
{
|
||||
return 0;
|
||||
} end_try;
|
||||
return 0;
|
||||
}
|
||||
|
||||
DtMmdbGraphicInfo*
|
||||
DtMmdbGraphicGetInfo(DtMmdbInfoRequest* request)
|
||||
{
|
||||
|
||||
mtry {
|
||||
graphic_smart_ptr* x = getGraphicUsingLocAndProid(request, true);
|
||||
|
||||
if ( x == 0 ) return 0;
|
||||
|
||||
|
||||
|
||||
DtMmdbGraphicInfo* z = newDtMmdbGraphicInfo();
|
||||
|
||||
if ( z == 0 ) return 0;
|
||||
|
||||
z -> type = x -> coding();
|
||||
z -> width = x -> width();
|
||||
z -> height = x -> height();
|
||||
z -> llx = x -> llx();
|
||||
z -> lly = x -> lly();
|
||||
z -> urx = x -> urx();
|
||||
z -> ury = x -> ury();
|
||||
|
||||
delete x;
|
||||
|
||||
return z;
|
||||
}
|
||||
|
||||
mcatch (mmdbException &,e)
|
||||
{
|
||||
return 0;
|
||||
} end_try;
|
||||
return 0;
|
||||
}
|
||||
|
||||
const char* DtMmdbGraphicGetLoc(DtMmdbInfoRequest* request)
|
||||
{
|
||||
mtry {
|
||||
graphic_smart_ptr* x = getGraphicUsingLocAndProid(request, true);
|
||||
|
||||
if ( x == 0 ) return 0;
|
||||
|
||||
const char* y = x -> locator();
|
||||
|
||||
delete x;
|
||||
return y;
|
||||
}
|
||||
|
||||
mcatch (mmdbException &,e)
|
||||
{
|
||||
return 0;
|
||||
} end_try;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void DtMmdbFreeGraphicInfo(DtMmdbGraphicInfo* x)
|
||||
{
|
||||
free((void*)x);
|
||||
}
|
||||
123
cde/lib/DtMmdb/oliasdb/c_api_graphic_test.C
Normal file
123
cde/lib/DtMmdb/oliasdb/c_api_graphic_test.C
Normal file
@@ -0,0 +1,123 @@
|
||||
/*
|
||||
* CDE - Common Desktop Environment
|
||||
*
|
||||
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
|
||||
*
|
||||
* These libraries and programs are free software; you can
|
||||
* redistribute them and/or modify them under the terms of the GNU
|
||||
* Lesser General Public License as published by the Free Software
|
||||
* Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* These libraries and programs are distributed in the hope that
|
||||
* they will be useful, but WITHOUT ANY WARRANTY; without even the
|
||||
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU Lesser General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with these libraries and programs; if not, write
|
||||
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
|
||||
* Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
/* $XConsortium: c_api_graphic_test.C /main/5 1996/08/21 15:53:03 drk $ */
|
||||
|
||||
|
||||
#include "oliasdb/DtMmdb.h"
|
||||
#include <stdio.h>
|
||||
|
||||
extern "C"
|
||||
void showGraphic(DtMmdbInfoRequest* req)
|
||||
{
|
||||
const char* str;
|
||||
unsigned int l;
|
||||
unsigned int i;
|
||||
DtMmdbGraphicInfo* info ;
|
||||
|
||||
if ( req == 0 ) return ;
|
||||
|
||||
str = DtMmdbGraphicGetData( req, &l);
|
||||
if ( str ) {
|
||||
fprintf(stderr, " GraphicInfo: data=");
|
||||
for (i=0; i<l; i++ )
|
||||
fprintf(stderr, "%c", str[i]);
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
|
||||
info = DtMmdbGraphicGetInfo(req);
|
||||
if ( info ) {
|
||||
fprintf(stderr, " GraphicInfo: type=%d\n", info -> type);
|
||||
fprintf(stderr, " GraphicInfo: width=%d\n", info -> width);
|
||||
fprintf(stderr, " GraphicInfo: height=%d\n", info -> height);
|
||||
fprintf(stderr, " GraphicInfo: llx=%d\n", info -> llx);
|
||||
fprintf(stderr, " GraphicInfo: lly=%d\n", info -> lly);
|
||||
fprintf(stderr, " GraphicInfo: urx=%d\n", info -> urx);
|
||||
fprintf(stderr, " GraphicInfo: ury=%d\n", info -> ury);
|
||||
DtMmdbFreeGraphicInfo(info);
|
||||
}
|
||||
|
||||
/*
|
||||
str = DtMmdbGraphicGetLoc(req);
|
||||
fprintf(stderr, " GraphicInfo: graphic's locator=%s\n", str);
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
extern "C"
|
||||
int test_graphic1(int argc, char** argv)
|
||||
{
|
||||
int j = 0;
|
||||
int i = 0;
|
||||
DtMmdbInfoRequest* req;
|
||||
|
||||
switch ( argc ) {
|
||||
case 5:
|
||||
{
|
||||
i = DtMmdbOpenInfoLib(argv[2], argv[3], DtMmdbFalse);
|
||||
j = DtMmdbGetBookCaseByName(i, argv[3]);
|
||||
|
||||
req = newDtMmdbInfoRequestWithLoc(j, argv[4]);
|
||||
showGraphic(req);
|
||||
|
||||
DtMmdbFreeInfoRequest(req);
|
||||
DtMmdbCloseInfoLib(i);
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
fprintf(stderr, "invalid arguments\n");
|
||||
}
|
||||
|
||||
fprintf(stderr, "infolib desc=%d\n", i);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
extern "C"
|
||||
int test_graphic2(int argc, char** argv)
|
||||
{
|
||||
int j = 0;
|
||||
int i = 0;
|
||||
DtMmdbInfoRequest* req;
|
||||
|
||||
switch ( argc ) {
|
||||
case 5:
|
||||
{
|
||||
i = DtMmdbOpenInfoLib(argv[2], argv[3], DtMmdbFalse);
|
||||
j = DtMmdbGetBookCaseByName(i, argv[3]);
|
||||
|
||||
req = newDtMmdbInfoRequestWithPrimaryOid(j, argv[4]);
|
||||
showGraphic(req);
|
||||
|
||||
DtMmdbFreeInfoRequest(req);
|
||||
DtMmdbCloseInfoLib(i);
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
fprintf(stderr, "invalid arguments\n");
|
||||
}
|
||||
|
||||
fprintf(stderr, "infolib desc=%d\n", i);
|
||||
return 0;
|
||||
}
|
||||
125
cde/lib/DtMmdb/oliasdb/c_api_infolib.C
Normal file
125
cde/lib/DtMmdb/oliasdb/c_api_infolib.C
Normal file
@@ -0,0 +1,125 @@
|
||||
/*
|
||||
* CDE - Common Desktop Environment
|
||||
*
|
||||
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
|
||||
*
|
||||
* These libraries and programs are free software; you can
|
||||
* redistribute them and/or modify them under the terms of the GNU
|
||||
* Lesser General Public License as published by the Free Software
|
||||
* Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* These libraries and programs are distributed in the hope that
|
||||
* they will be useful, but WITHOUT ANY WARRANTY; without even the
|
||||
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU Lesser General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with these libraries and programs; if not, write
|
||||
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
|
||||
* Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
/* $XConsortium: c_api_infolib.cc /main/5 1996/07/18 16:01:28 drk $ */
|
||||
|
||||
#include "oliasdb/c_api_common.h"
|
||||
|
||||
//extern void_ptr_array* infolib_array;
|
||||
extern void_ptr_array* bookcase_array;
|
||||
extern OLIAS_DB* mmdb_ptr;
|
||||
|
||||
//extern olias_server* oserver_ptr;
|
||||
|
||||
void _assign_bookcase_index_id(info_lib* x)
|
||||
{
|
||||
long ind = x -> first();
|
||||
info_base* base;
|
||||
while (ind) {
|
||||
base = (*x)(ind);
|
||||
|
||||
// no duplication check yet
|
||||
int i = bookcase_array -> no_elmts();
|
||||
bookcase_array -> insert(base, i);
|
||||
bookcase_array -> reset_elmts(i+1);
|
||||
|
||||
base -> set_index_id(i);
|
||||
x -> next(ind);
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
DtMmdbOpenInfoLib(
|
||||
const char* infolib_path,
|
||||
const char* selected_base_name,
|
||||
DtMmdbBool delayed_infolib_init
|
||||
)
|
||||
{
|
||||
mtry {
|
||||
|
||||
mmdb_ptr = new OLIAS_DB;
|
||||
info_lib* x = mmdb_ptr -> openInfoLib(infolib_path, selected_base_name);
|
||||
|
||||
|
||||
int i = x -> descriptor();
|
||||
/*
|
||||
int i = infolib_array -> no_elmts();
|
||||
infolib_array -> insert(x, i);
|
||||
infolib_array -> reset_elmts(i+1);
|
||||
*/
|
||||
|
||||
_assign_bookcase_index_id(x);
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
mcatch (mmdbException &,e)
|
||||
{
|
||||
return -1;
|
||||
} end_try;
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
void DtMmdbCloseInfoLib(int infolib_descriptor)
|
||||
{
|
||||
delete mmdb_ptr;
|
||||
mmdb_ptr = 0;
|
||||
|
||||
//infolib_array -> reset_vptr(0);
|
||||
}
|
||||
|
||||
|
||||
DtMmdbInfoLibInfo*
|
||||
DtMmdbInfoLibGetInfo(int infolib_descriptor)
|
||||
{
|
||||
mtry {
|
||||
info_lib* x = mmdb_ptr -> getInfoLib(infolib_descriptor);
|
||||
|
||||
if ( x == 0 ) return 0;
|
||||
|
||||
DtMmdbInfoLibInfo *y =
|
||||
(DtMmdbInfoLibInfo*)malloc(sizeof(DtMmdbInfoLibInfo));
|
||||
|
||||
if ( y == 0 ) return 0;
|
||||
|
||||
y -> path = x -> get_info_lib_path();
|
||||
y -> name = x -> get_info_lib_name();
|
||||
y -> num_bookcases = x -> num_of_bases();
|
||||
|
||||
return y;
|
||||
|
||||
}
|
||||
mcatch (mmdbException &,e)
|
||||
{
|
||||
return 0;
|
||||
} end_try;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void DtMmdbInfoLibFreeInfo(DtMmdbInfoLibInfo* x)
|
||||
{
|
||||
free((void*)x);
|
||||
}
|
||||
|
||||
|
||||
100
cde/lib/DtMmdb/oliasdb/c_api_infolib_test.C
Normal file
100
cde/lib/DtMmdb/oliasdb/c_api_infolib_test.C
Normal file
@@ -0,0 +1,100 @@
|
||||
/*
|
||||
* CDE - Common Desktop Environment
|
||||
*
|
||||
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
|
||||
*
|
||||
* These libraries and programs are free software; you can
|
||||
* redistribute them and/or modify them under the terms of the GNU
|
||||
* Lesser General Public License as published by the Free Software
|
||||
* Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* These libraries and programs are distributed in the hope that
|
||||
* they will be useful, but WITHOUT ANY WARRANTY; without even the
|
||||
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU Lesser General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with these libraries and programs; if not, write
|
||||
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
|
||||
* Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
/* $XConsortium: c_api_infolib_test.C /main/5 1996/08/21 15:53:07 drk $ */
|
||||
|
||||
#include "oliasdb/DtMmdb.h"
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
extern "C" void showBookCaseInfo(int i);
|
||||
|
||||
extern "C"
|
||||
int showInfoLibInfo(int i)
|
||||
{
|
||||
int n = 0;
|
||||
DtMmdbInfoLibInfo* info = DtMmdbInfoLibGetInfo(i);
|
||||
if ( info ) {
|
||||
if ( info -> path )
|
||||
fprintf(stderr, "infolibInfo: path= %s\n", info -> path);
|
||||
if ( info -> name )
|
||||
fprintf(stderr, "infolibInfo: name= %s\n", info -> name);
|
||||
fprintf(stderr, "infolibInfo: num_bookcases= %d\n", info -> num_bookcases);
|
||||
|
||||
n = info -> num_bookcases;
|
||||
|
||||
DtMmdbInfoLibFreeInfo(info);
|
||||
} else
|
||||
fprintf(stderr, "no infolibInfo\n");
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
extern "C"
|
||||
int test0(int argc, char** argv)
|
||||
{
|
||||
int j = 0;
|
||||
int n = 0;
|
||||
int i = -1;
|
||||
switch ( argc ) {
|
||||
case 4:
|
||||
i = DtMmdbOpenInfoLib(argv[2], argv[3], DtMmdbFalse);
|
||||
n = showInfoLibInfo(i);
|
||||
for ( j=0; j<n; j++ )
|
||||
showBookCaseInfo(DtMmdbGetBookCaseByIndex(i, j));
|
||||
break;
|
||||
case 3:
|
||||
i = DtMmdbOpenInfoLib(argv[2], 0, DtMmdbFalse);
|
||||
showInfoLibInfo(i);
|
||||
n = showInfoLibInfo(i);
|
||||
for ( j=0; j<n; j++ )
|
||||
showBookCaseInfo(DtMmdbGetBookCaseByIndex(i, j));
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "bad argument list\n");
|
||||
}
|
||||
|
||||
fprintf(stderr, "infolib desc=%d\n", i);
|
||||
return 0;
|
||||
}
|
||||
|
||||
extern "C"
|
||||
int test1(int argc, char** argv)
|
||||
{
|
||||
int j = 0;
|
||||
int n = 0;
|
||||
int i = -1;
|
||||
switch ( argc ) {
|
||||
case 5:
|
||||
i = DtMmdbOpenInfoLib(argv[2], argv[3], DtMmdbFalse);
|
||||
n = showInfoLibInfo(i);
|
||||
for ( j=0; j<n; j++ )
|
||||
showBookCaseInfo(DtMmdbGetBookCaseByLoc(i, argv[4]));
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "bad argument list\n");
|
||||
}
|
||||
|
||||
fprintf(stderr, "infolib desc=%d\n", i);
|
||||
return 0;
|
||||
}
|
||||
|
||||
95
cde/lib/DtMmdb/oliasdb/c_api_locator.C
Normal file
95
cde/lib/DtMmdb/oliasdb/c_api_locator.C
Normal file
@@ -0,0 +1,95 @@
|
||||
/*
|
||||
* CDE - Common Desktop Environment
|
||||
*
|
||||
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
|
||||
*
|
||||
* These libraries and programs are free software; you can
|
||||
* redistribute them and/or modify them under the terms of the GNU
|
||||
* Lesser General Public License as published by the Free Software
|
||||
* Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* These libraries and programs are distributed in the hope that
|
||||
* they will be useful, but WITHOUT ANY WARRANTY; without even the
|
||||
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU Lesser General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with these libraries and programs; if not, write
|
||||
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
|
||||
* Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
// $XConsortium: c_api_locator.cc /main/3 1996/06/11 17:27:38 cde-hal $
|
||||
|
||||
#include "oliasdb/c_api_common.h"
|
||||
|
||||
static locator_smart_ptr*
|
||||
getLocatorUsingLocAndProid(DtMmdbInfoRequest* request, Boolean checkLocOnly = false)
|
||||
{
|
||||
mtry {
|
||||
info_base* x = getBookCase(request -> bookcase_descriptor);
|
||||
if ( x == 0 ) return 0;
|
||||
|
||||
const char* str = getLocator(request);
|
||||
|
||||
if ( str ) {
|
||||
return new locator_smart_ptr(x, str);
|
||||
} else
|
||||
return 0;
|
||||
|
||||
/*
|
||||
if ( checkLocOnly == true ) return 0;
|
||||
|
||||
oid_t * id = getPrimiaryOid(request);
|
||||
|
||||
if ( id == 0 ) return 0;
|
||||
|
||||
return new locator_smart_ptr(x, *id);
|
||||
*/
|
||||
}
|
||||
|
||||
mcatch (mmdbException &,e)
|
||||
{
|
||||
return 0;
|
||||
} end_try;
|
||||
return 0;
|
||||
}
|
||||
|
||||
const char*
|
||||
DtMmdbLocatorGetSectionLoc(DtMmdbInfoRequest* request)
|
||||
{
|
||||
mtry {
|
||||
locator_smart_ptr* x = getLocatorUsingLocAndProid(request, false);
|
||||
|
||||
if ( x == 0 ) return 0;
|
||||
const char* y = x -> inside_node_locator_str();
|
||||
delete x;
|
||||
return y;
|
||||
}
|
||||
|
||||
mcatch (mmdbException &,e)
|
||||
{
|
||||
return 0;
|
||||
} end_try;
|
||||
return 0;
|
||||
}
|
||||
|
||||
DtMmdbHandle*
|
||||
DtMmdbLocatorGetSectionObjectId(DtMmdbInfoRequest* request)
|
||||
{
|
||||
mtry {
|
||||
locator_smart_ptr* x = getLocatorUsingLocAndProid(request, true);
|
||||
if ( x == 0 ) return 0;
|
||||
DtMmdbHandle *z = newDtMmdbHandle(x -> node_id());
|
||||
delete x;
|
||||
return z;
|
||||
}
|
||||
|
||||
mcatch (mmdbException &,e)
|
||||
{
|
||||
return 0;
|
||||
} end_try;
|
||||
return 0;
|
||||
}
|
||||
|
||||
105
cde/lib/DtMmdb/oliasdb/c_api_locator_test.C
Normal file
105
cde/lib/DtMmdb/oliasdb/c_api_locator_test.C
Normal file
@@ -0,0 +1,105 @@
|
||||
/*
|
||||
* CDE - Common Desktop Environment
|
||||
*
|
||||
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
|
||||
*
|
||||
* These libraries and programs are free software; you can
|
||||
* redistribute them and/or modify them under the terms of the GNU
|
||||
* Lesser General Public License as published by the Free Software
|
||||
* Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* These libraries and programs are distributed in the hope that
|
||||
* they will be useful, but WITHOUT ANY WARRANTY; without even the
|
||||
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU Lesser General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with these libraries and programs; if not, write
|
||||
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
|
||||
* Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
/* $XConsortium: c_api_locator_test.C /main/5 1996/08/21 15:53:11 drk $ */
|
||||
|
||||
#include "oliasdb/DtMmdb.h"
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
extern "C"
|
||||
void showLocator(DtMmdbInfoRequest* req)
|
||||
{
|
||||
DtMmdbHandle* id = 0;
|
||||
const char* str = 0;
|
||||
|
||||
if ( req == 0 ) return ;
|
||||
|
||||
str = DtMmdbLocatorGetSectionLoc(req);
|
||||
if ( str )
|
||||
fprintf(stderr, " LOC: sectionLoc=%s\n", str);
|
||||
|
||||
id = DtMmdbLocatorGetSectionObjectId(req);
|
||||
if ( id )
|
||||
fprintf(stderr, " LOC: sectionId=%s\n", DtMmdbHandleToString(id));
|
||||
DtMmdbFreeHandle(id);
|
||||
}
|
||||
|
||||
extern "C"
|
||||
int test_loc1(int argc, char** argv)
|
||||
{
|
||||
int j = 0;
|
||||
int i = 0;
|
||||
DtMmdbInfoRequest* req;
|
||||
|
||||
switch ( argc ) {
|
||||
case 5:
|
||||
{
|
||||
i = DtMmdbOpenInfoLib(argv[2], argv[3], DtMmdbFalse);
|
||||
j = DtMmdbGetBookCaseByName(i, argv[3]);
|
||||
|
||||
req = newDtMmdbInfoRequestWithLoc(j, argv[4]);
|
||||
showLocator(req);
|
||||
|
||||
DtMmdbFreeInfoRequest(req);
|
||||
DtMmdbCloseInfoLib(i);
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
fprintf(stderr, "invalid arguments\n");
|
||||
}
|
||||
|
||||
fprintf(stderr, "infolib desc=%d\n", i);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
extern "C"
|
||||
int test_loc2(int argc, char** argv)
|
||||
{
|
||||
int j = 0;
|
||||
int i = 0;
|
||||
DtMmdbInfoRequest* req ;
|
||||
|
||||
switch ( argc ) {
|
||||
case 5:
|
||||
{
|
||||
i = DtMmdbOpenInfoLib(argv[2], argv[3], DtMmdbFalse);
|
||||
j = DtMmdbGetBookCaseByName(i, argv[3]);
|
||||
|
||||
req = newDtMmdbInfoRequestWithPrimaryOid(j, argv[4]);
|
||||
showLocator(req);
|
||||
|
||||
DtMmdbFreeInfoRequest(req);
|
||||
DtMmdbCloseInfoLib(i);
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
fprintf(stderr, "invalid arguments\n");
|
||||
}
|
||||
|
||||
fprintf(stderr, "infolib desc=%d\n", i);
|
||||
return 0;
|
||||
}
|
||||
|
||||
64
cde/lib/DtMmdb/oliasdb/c_api_pure_virtual.C
Normal file
64
cde/lib/DtMmdb/oliasdb/c_api_pure_virtual.C
Normal file
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* CDE - Common Desktop Environment
|
||||
*
|
||||
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
|
||||
*
|
||||
* These libraries and programs are free software; you can
|
||||
* redistribute them and/or modify them under the terms of the GNU
|
||||
* Lesser General Public License as published by the Free Software
|
||||
* Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* These libraries and programs are distributed in the hope that
|
||||
* they will be useful, but WITHOUT ANY WARRANTY; without even the
|
||||
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU Lesser General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with these libraries and programs; if not, write
|
||||
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
|
||||
* Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
/* $XConsortium: c_api_pure_virtual.cc /main/5 1996/07/18 16:01:43 drk $ */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
extern "C" {
|
||||
|
||||
#if defined(hpux)
|
||||
char __pure_virtual_called()
|
||||
{
|
||||
fprintf(stderr, "DtMmdb: pure virtual called\n");
|
||||
exit (-1);
|
||||
return 0;
|
||||
}
|
||||
#else
|
||||
#if defined(SVR4) && defined(SC3)
|
||||
void _pure_error_()
|
||||
{
|
||||
fprintf(stderr, "DtMmdb: pure virtual called\n");
|
||||
exit (-1);
|
||||
}
|
||||
#else
|
||||
#ifdef _AIX
|
||||
void __PureVirtualCalled()
|
||||
{
|
||||
fprintf(stderr, "DtMmdb: pure virtual called\n");
|
||||
exit (-1);
|
||||
}
|
||||
#else
|
||||
|
||||
void __pure_virtual_called()
|
||||
{
|
||||
fprintf(stderr, "DtMmdb: pure virtual called\n");
|
||||
exit (-1);
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
}
|
||||
239
cde/lib/DtMmdb/oliasdb/c_api_section.C
Normal file
239
cde/lib/DtMmdb/oliasdb/c_api_section.C
Normal file
@@ -0,0 +1,239 @@
|
||||
/*
|
||||
* CDE - Common Desktop Environment
|
||||
*
|
||||
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
|
||||
*
|
||||
* These libraries and programs are free software; you can
|
||||
* redistribute them and/or modify them under the terms of the GNU
|
||||
* Lesser General Public License as published by the Free Software
|
||||
* Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* These libraries and programs are distributed in the hope that
|
||||
* they will be useful, but WITHOUT ANY WARRANTY; without even the
|
||||
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU Lesser General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with these libraries and programs; if not, write
|
||||
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
|
||||
* Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
// $XConsortium: c_api_section.cc /main/3 1996/06/11 17:27:53 cde-hal $
|
||||
|
||||
#include "oliasdb/c_api_common.h"
|
||||
|
||||
const char*
|
||||
DtMmdbSectionGetLoc(DtMmdbInfoRequest* request)
|
||||
{
|
||||
mtry {
|
||||
info_base* x = getBookCase(request -> bookcase_descriptor);
|
||||
if ( x == 0 ) return 0;
|
||||
|
||||
oid_t * id = getPrimiaryOid(request);
|
||||
|
||||
if ( id == 0 ) return 0;
|
||||
|
||||
node_smart_ptr y(x, *id);
|
||||
|
||||
return y.locator();
|
||||
}
|
||||
|
||||
mcatch (mmdbException &,e)
|
||||
{
|
||||
return 0;
|
||||
} end_try;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static node_smart_ptr*
|
||||
getSectionUsingLocAndProid(DtMmdbInfoRequest* request)
|
||||
{
|
||||
mtry {
|
||||
info_base* x = getBookCase(request -> bookcase_descriptor);
|
||||
if ( x == 0 ) return 0;
|
||||
|
||||
const char* str = getLocator(request);
|
||||
|
||||
if ( str ) {
|
||||
return new node_smart_ptr(x, str);
|
||||
}
|
||||
|
||||
oid_t * id = getPrimiaryOid(request);
|
||||
|
||||
if ( id == 0 ) return 0;
|
||||
|
||||
return new node_smart_ptr(x, *id);
|
||||
}
|
||||
|
||||
mcatch (mmdbException &,e)
|
||||
{
|
||||
return 0;
|
||||
} end_try;
|
||||
return 0;
|
||||
}
|
||||
|
||||
const char*
|
||||
DtMmdbSectionGetLongTitle(
|
||||
DtMmdbInfoRequest* request,
|
||||
unsigned int* title_length
|
||||
)
|
||||
{
|
||||
mtry {
|
||||
node_smart_ptr* x = getSectionUsingLocAndProid(request);
|
||||
|
||||
if ( x == 0 ) return 0;
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, " mmdb_oid = ");
|
||||
(*x).its_oid().asciiOut(cerr); cerr << "\n";
|
||||
cerr.flush();
|
||||
#endif
|
||||
|
||||
const char* y = x -> long_title();
|
||||
|
||||
if ( title_length ) *title_length = strlen(y);
|
||||
delete x;
|
||||
return y;
|
||||
}
|
||||
|
||||
mcatch (mmdbException &,e)
|
||||
{
|
||||
return 0;
|
||||
} end_try;
|
||||
return 0;
|
||||
}
|
||||
|
||||
const char*
|
||||
DtMmdbSectionGetShortTitle(
|
||||
DtMmdbInfoRequest* request,
|
||||
unsigned int* title_length
|
||||
)
|
||||
{
|
||||
mtry {
|
||||
node_smart_ptr* x = getSectionUsingLocAndProid(request);
|
||||
|
||||
if ( x == 0 ) return 0;
|
||||
const char* y = x -> short_title();
|
||||
|
||||
if ( title_length ) *title_length = strlen(y);
|
||||
delete x;
|
||||
return y;
|
||||
}
|
||||
|
||||
mcatch (mmdbException &,e)
|
||||
{
|
||||
return 0;
|
||||
} end_try;
|
||||
return 0;
|
||||
}
|
||||
|
||||
const char*
|
||||
DtMmdbSectionGetData
|
||||
(
|
||||
DtMmdbInfoRequest* request,
|
||||
unsigned int* data_length
|
||||
)
|
||||
{
|
||||
mtry {
|
||||
node_smart_ptr* x = getSectionUsingLocAndProid(request);
|
||||
|
||||
if ( x == 0 ) return 0;
|
||||
const char* y = x -> data();
|
||||
|
||||
if ( data_length ) *data_length = strlen(y);
|
||||
delete x;
|
||||
return y;
|
||||
}
|
||||
|
||||
mcatch (mmdbException &,e)
|
||||
{
|
||||
return 0;
|
||||
} end_try;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int DtMmdbSectionGetDataSize(DtMmdbInfoRequest* request)
|
||||
{
|
||||
mtry {
|
||||
node_smart_ptr* x = getSectionUsingLocAndProid(request);
|
||||
|
||||
if ( x == 0 ) return -1;
|
||||
|
||||
int y = x -> data_size();
|
||||
|
||||
delete x;
|
||||
return y;
|
||||
}
|
||||
|
||||
mcatch (mmdbException &,e)
|
||||
{
|
||||
return -1;
|
||||
} end_try;
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
const char* DtMmdbSectionGetTocLoc(DtMmdbInfoRequest* request)
|
||||
{
|
||||
mtry {
|
||||
node_smart_ptr* x = getSectionUsingLocAndProid(request);
|
||||
|
||||
if ( x == 0 ) return 0;
|
||||
const char* y = x -> toc_node_loc();
|
||||
|
||||
delete x;
|
||||
return y;
|
||||
}
|
||||
|
||||
mcatch (mmdbException &,e)
|
||||
{
|
||||
return 0;
|
||||
} end_try;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
DtMmdbHandle*
|
||||
DtMmdbSectionGetBookId(DtMmdbInfoRequest* request)
|
||||
{
|
||||
mtry {
|
||||
node_smart_ptr* x = getSectionUsingLocAndProid(request);
|
||||
|
||||
if ( x == 0 ) return 0;
|
||||
|
||||
DtMmdbHandle *z = newDtMmdbHandle(x -> doc_id());
|
||||
|
||||
delete x;
|
||||
return z;
|
||||
}
|
||||
|
||||
mcatch (mmdbException &,e)
|
||||
{
|
||||
return 0;
|
||||
} end_try;
|
||||
return 0;
|
||||
}
|
||||
|
||||
DtMmdbHandle*
|
||||
DtMmdbSectionGetStyleSheetId(DtMmdbInfoRequest* request)
|
||||
{
|
||||
mtry {
|
||||
node_smart_ptr* x = getSectionUsingLocAndProid(request);
|
||||
|
||||
if ( x == 0 ) return 0;
|
||||
|
||||
DtMmdbHandle *z = newDtMmdbHandle(x -> stylesheet_id());
|
||||
|
||||
delete x;
|
||||
return z;
|
||||
}
|
||||
|
||||
mcatch (mmdbException &,e)
|
||||
{
|
||||
return 0;
|
||||
} end_try;
|
||||
return 0;
|
||||
}
|
||||
|
||||
130
cde/lib/DtMmdb/oliasdb/c_api_section_test.C
Normal file
130
cde/lib/DtMmdb/oliasdb/c_api_section_test.C
Normal file
@@ -0,0 +1,130 @@
|
||||
/*
|
||||
* CDE - Common Desktop Environment
|
||||
*
|
||||
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
|
||||
*
|
||||
* These libraries and programs are free software; you can
|
||||
* redistribute them and/or modify them under the terms of the GNU
|
||||
* Lesser General Public License as published by the Free Software
|
||||
* Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* These libraries and programs are distributed in the hope that
|
||||
* they will be useful, but WITHOUT ANY WARRANTY; without even the
|
||||
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU Lesser General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with these libraries and programs; if not, write
|
||||
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
|
||||
* Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
/* $XConsortium: c_api_section_test.C /main/5 1996/08/21 15:53:20 drk $ */
|
||||
|
||||
#include "oliasdb/DtMmdb.h"
|
||||
#include <stdio.h>
|
||||
|
||||
extern "C"
|
||||
void showSection(DtMmdbInfoRequest* req)
|
||||
{
|
||||
const char* str = 0;
|
||||
int size = 0;
|
||||
DtMmdbHandle* id = 0;
|
||||
|
||||
if ( req == 0 ) return ;
|
||||
|
||||
str = DtMmdbSectionGetLongTitle(req, 0);
|
||||
if (str) {
|
||||
fprintf(stderr, " SectionInfo: LongTitle=%s\n", str);
|
||||
}
|
||||
|
||||
str = DtMmdbSectionGetShortTitle(req, 0);
|
||||
if (str) {
|
||||
fprintf(stderr, " SectionInfo: ShortTitle=%s\n", str);
|
||||
}
|
||||
|
||||
str = DtMmdbSectionGetData(req, 0);
|
||||
if (str) {
|
||||
fprintf(stderr, " SectionInfo: data=%s\n", str);
|
||||
}
|
||||
|
||||
size = DtMmdbSectionGetDataSize(req);
|
||||
fprintf(stderr, " SectionInfo: dataSize=%d\n", size);
|
||||
|
||||
|
||||
str = DtMmdbSectionGetTocLoc(req);
|
||||
if (str) {
|
||||
fprintf(stderr, " SectionInfo: TocLoc=%s\n", str);
|
||||
}
|
||||
|
||||
id = DtMmdbSectionGetBookId(req);
|
||||
if (id) {
|
||||
fprintf(stderr, " SectionInfo: BookId=%s\n", DtMmdbHandleToString(id));
|
||||
}
|
||||
DtMmdbFreeHandle(id);
|
||||
|
||||
id = DtMmdbSectionGetStyleSheetId(req);
|
||||
if (id) {
|
||||
fprintf(stderr, " SectionInfo: StyleSheetId=%s\n", DtMmdbHandleToString(id));
|
||||
}
|
||||
DtMmdbFreeHandle(id);
|
||||
}
|
||||
|
||||
extern "C"
|
||||
int test2(int argc, char** argv)
|
||||
{
|
||||
int j = 0;
|
||||
int i = -1;
|
||||
DtMmdbInfoRequest* req = 0;
|
||||
|
||||
switch ( argc ) {
|
||||
case 5:
|
||||
{
|
||||
i = DtMmdbOpenInfoLib(argv[2], argv[3], DtMmdbFalse);
|
||||
j = DtMmdbGetBookCaseByLoc(i, argv[4]);
|
||||
|
||||
req = newDtMmdbInfoRequestWithLoc(j, argv[4]);
|
||||
showSection(req);
|
||||
|
||||
DtMmdbFreeInfoRequest(req);
|
||||
DtMmdbCloseInfoLib(i);
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
fprintf(stderr, "invalid arguments\n");
|
||||
}
|
||||
|
||||
fprintf(stderr, "infolib desc=%d\n", i);
|
||||
return 0;
|
||||
}
|
||||
|
||||
extern "C"
|
||||
int test3(int argc, char** argv)
|
||||
{
|
||||
int j = 0;
|
||||
int i = -1;
|
||||
DtMmdbInfoRequest* req = 0;
|
||||
|
||||
switch ( argc ) {
|
||||
case 5:
|
||||
{
|
||||
i = DtMmdbOpenInfoLib(argv[2], argv[3], DtMmdbFalse);
|
||||
j = DtMmdbGetBookCaseByName(i, argv[3]);
|
||||
|
||||
req = newDtMmdbInfoRequestWithPrimaryOid(j, argv[4]);
|
||||
showSection(req);
|
||||
|
||||
DtMmdbFreeInfoRequest(req);
|
||||
DtMmdbCloseInfoLib(i);
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
fprintf(stderr, "invalid arguments\n");
|
||||
}
|
||||
|
||||
fprintf(stderr, "infolib desc=%d\n", i);
|
||||
return 0;
|
||||
}
|
||||
104
cde/lib/DtMmdb/oliasdb/c_api_stylesheet.C
Normal file
104
cde/lib/DtMmdb/oliasdb/c_api_stylesheet.C
Normal file
@@ -0,0 +1,104 @@
|
||||
/*
|
||||
* CDE - Common Desktop Environment
|
||||
*
|
||||
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
|
||||
*
|
||||
* These libraries and programs are free software; you can
|
||||
* redistribute them and/or modify them under the terms of the GNU
|
||||
* Lesser General Public License as published by the Free Software
|
||||
* Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* These libraries and programs are distributed in the hope that
|
||||
* they will be useful, but WITHOUT ANY WARRANTY; without even the
|
||||
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU Lesser General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with these libraries and programs; if not, write
|
||||
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
|
||||
* Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
// $XConsortium: c_api_stylesheet.cc /main/3 1996/06/11 17:28:03 cde-hal $
|
||||
|
||||
#include "oliasdb/c_api_common.h"
|
||||
|
||||
static stylesheet_smart_ptr*
|
||||
getStylesheetUsingLocAndProid(DtMmdbInfoRequest* request, Boolean checkPIDOnly = false)
|
||||
{
|
||||
mtry {
|
||||
info_base* x = getBookCase(request -> bookcase_descriptor);
|
||||
if ( x == 0 ) return 0;
|
||||
|
||||
oid_t * id = getPrimiaryOid(request);
|
||||
|
||||
if ( id )
|
||||
return new stylesheet_smart_ptr(x, *id);
|
||||
|
||||
if ( checkPIDOnly == true ) return 0;
|
||||
|
||||
const char* str = getLocator(request);
|
||||
|
||||
if ( str ) {
|
||||
return new stylesheet_smart_ptr(x, str);
|
||||
} else
|
||||
return 0;
|
||||
|
||||
|
||||
}
|
||||
|
||||
mcatch (mmdbException &,e)
|
||||
{
|
||||
return 0;
|
||||
} end_try;
|
||||
return 0;
|
||||
}
|
||||
|
||||
const char*
|
||||
DtMmdbStylesheetGetName(DtMmdbInfoRequest* request)
|
||||
{
|
||||
mtry {
|
||||
stylesheet_smart_ptr* x = getStylesheetUsingLocAndProid(request, true);
|
||||
|
||||
if ( x == 0 ) return 0;
|
||||
const char* y = x -> name();
|
||||
delete x;
|
||||
return y;
|
||||
}
|
||||
|
||||
mcatch (mmdbException &,e)
|
||||
{
|
||||
return 0;
|
||||
} end_try;
|
||||
return 0;
|
||||
}
|
||||
|
||||
const char*
|
||||
DtMmdbStylesheetGetata(DtMmdbInfoRequest* request, unsigned int* data_length)
|
||||
{
|
||||
mtry {
|
||||
stylesheet_smart_ptr* x = getStylesheetUsingLocAndProid(request, false);
|
||||
|
||||
if ( x == 0 ) return 0;
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, " stylesheetInfo: mmdb_oid = %d.%d\n", (int)(*x).its_oid().ccode()
|
||||
, (int)(*x).its_oid().icode());
|
||||
#endif
|
||||
|
||||
const char* y = x -> online_data();
|
||||
|
||||
if ( data_length ) *data_length = strlen(y);
|
||||
|
||||
delete x;
|
||||
return y;
|
||||
}
|
||||
|
||||
mcatch (mmdbException &,e)
|
||||
{
|
||||
return 0;
|
||||
} end_try;
|
||||
return 0;
|
||||
}
|
||||
|
||||
107
cde/lib/DtMmdb/oliasdb/c_api_stylesheet_test.C
Normal file
107
cde/lib/DtMmdb/oliasdb/c_api_stylesheet_test.C
Normal file
@@ -0,0 +1,107 @@
|
||||
/*
|
||||
* CDE - Common Desktop Environment
|
||||
*
|
||||
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
|
||||
*
|
||||
* These libraries and programs are free software; you can
|
||||
* redistribute them and/or modify them under the terms of the GNU
|
||||
* Lesser General Public License as published by the Free Software
|
||||
* Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* These libraries and programs are distributed in the hope that
|
||||
* they will be useful, but WITHOUT ANY WARRANTY; without even the
|
||||
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU Lesser General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with these libraries and programs; if not, write
|
||||
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
|
||||
* Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
/* $XConsortium: c_api_stylesheet_test.C /main/5 1996/08/21 15:53:25 drk $ */
|
||||
|
||||
#include "oliasdb/DtMmdb.h"
|
||||
#include <stdio.h>
|
||||
|
||||
extern "C"
|
||||
void showStyleSheet(DtMmdbInfoRequest* req)
|
||||
{
|
||||
const char* str ;
|
||||
unsigned int l;
|
||||
|
||||
if ( req == 0 ) return ;
|
||||
|
||||
str = DtMmdbStylesheetGetName(req);
|
||||
if ( str )
|
||||
fprintf(stderr, " StylesheetInfo: name =%s\n", str);
|
||||
|
||||
str = DtMmdbStylesheetGetata(req, &l);
|
||||
if ( str ) {
|
||||
fprintf(stderr, " StylesheetInfo: data =%s\n", str);
|
||||
fprintf(stderr, " StylesheetInfo: length =%d\n", l);
|
||||
}
|
||||
}
|
||||
|
||||
extern "C"
|
||||
int test_ss1(int argc, char** argv)
|
||||
{
|
||||
int j = 0;
|
||||
int i = 0;
|
||||
DtMmdbInfoRequest* req ;
|
||||
|
||||
switch ( argc ) {
|
||||
case 5:
|
||||
{
|
||||
i = DtMmdbOpenInfoLib(argv[2], argv[3], DtMmdbFalse);
|
||||
j = DtMmdbGetBookCaseByName(i, argv[3]);
|
||||
|
||||
req = newDtMmdbInfoRequestWithLoc(j, argv[4]);
|
||||
showStyleSheet(req);
|
||||
|
||||
DtMmdbFreeInfoRequest(req);
|
||||
DtMmdbCloseInfoLib(i);
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
fprintf(stderr, "invalid arguments\n");
|
||||
}
|
||||
|
||||
fprintf(stderr, "infolib desc=%d\n", i);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
extern "C"
|
||||
int test_ss2(int argc, char** argv)
|
||||
{
|
||||
int j = 0;
|
||||
int i = 0;
|
||||
DtMmdbInfoRequest* req ;
|
||||
|
||||
switch ( argc ) {
|
||||
case 5:
|
||||
{
|
||||
i = DtMmdbOpenInfoLib(argv[2], argv[3], DtMmdbFalse);
|
||||
j = DtMmdbGetBookCaseByName(i, argv[3]);
|
||||
|
||||
req = newDtMmdbInfoRequestWithPrimaryOid(j, argv[4]);
|
||||
showStyleSheet(req);
|
||||
|
||||
DtMmdbFreeInfoRequest(req);
|
||||
DtMmdbCloseInfoLib(i);
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
fprintf(stderr, "invalid arguments\n");
|
||||
}
|
||||
|
||||
fprintf(stderr, "infolib desc=%d\n", i);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
302
cde/lib/DtMmdb/oliasdb/c_api_test.C
Normal file
302
cde/lib/DtMmdb/oliasdb/c_api_test.C
Normal file
@@ -0,0 +1,302 @@
|
||||
/*
|
||||
* CDE - Common Desktop Environment
|
||||
*
|
||||
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
|
||||
*
|
||||
* These libraries and programs are free software; you can
|
||||
* redistribute them and/or modify them under the terms of the GNU
|
||||
* Lesser General Public License as published by the Free Software
|
||||
* Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* These libraries and programs are distributed in the hope that
|
||||
* they will be useful, but WITHOUT ANY WARRANTY; without even the
|
||||
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU Lesser General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with these libraries and programs; if not, write
|
||||
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
|
||||
* Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
// $XConsortium: c_api_test.cc /main/4 1996/06/11 17:28:13 cde-hal $
|
||||
|
||||
#include "oliasdb/DtMmdb.h"
|
||||
#include "oliasdb/mmdb.h"
|
||||
#include "oliasdb/c_api_common.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
void showBookCaseInfo(int i);
|
||||
|
||||
int showInfoLibInfo(int i)
|
||||
{
|
||||
int n = 0;
|
||||
int j;
|
||||
DtMmdbInfoLibInfo* info = DtMmdbInfoLibGetInfo(i);
|
||||
if ( info ) {
|
||||
if ( info -> path )
|
||||
fprintf(stderr, "infolibInfo: path= %s\n", info -> path);
|
||||
if ( info -> name )
|
||||
fprintf(stderr, "infolibInfo: name= %s\n", info -> name);
|
||||
fprintf(stderr, "infolibInfo: num_bookcases= %d\n", info -> num_bookcases);
|
||||
|
||||
n = info -> num_bookcases;
|
||||
|
||||
DtMmdbInfoLibFreeInfo(info);
|
||||
} else
|
||||
fprintf(stderr, "no infolibInfo\n");
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
void showBookCaseInfo(int i)
|
||||
{
|
||||
if ( i <= -1 ) {
|
||||
fprintf(stderr, "bad bookcase descriptor %d\n", i);
|
||||
} else {
|
||||
DtMmdbBookCaseInfo* info = DtMmdbBookCaseGetInfo(i);
|
||||
if ( info ) {
|
||||
if ( info -> name )
|
||||
fprintf(stderr, " bookcaseInfo: name= %s\n", info -> name);
|
||||
fprintf(stderr, " bookcaseInfo: num_bookcases= %d\n", info -> num_books);
|
||||
DtMmdbBookCaseFreeInfo(info);
|
||||
} else
|
||||
fprintf(stderr, "no bookcase info\n");
|
||||
}
|
||||
}
|
||||
|
||||
// automatica test cases
|
||||
|
||||
extern int auto_test(int argc, char** argv, OLIAS_DB& db);
|
||||
|
||||
extern "C"
|
||||
int auto_test_c_api(int argc, char** argv)
|
||||
{
|
||||
OLIAS_DB db;
|
||||
return auto_test(argc, argv, db);
|
||||
}
|
||||
|
||||
// test cases that require manual inspection
|
||||
extern "C"
|
||||
int test0(int argc, char** argv)
|
||||
{
|
||||
int j = 0;
|
||||
int n = 0;
|
||||
int i = -1;
|
||||
switch ( argc ) {
|
||||
case 4:
|
||||
i = DtMmdbOpenInfoLib(argv[2], argv[3], DtMmdbFalse);
|
||||
n = showInfoLibInfo(i);
|
||||
for ( j=0; j<n; j++ )
|
||||
showBookCaseInfo(DtMmdbGetBookCaseByIndex(i, j));
|
||||
break;
|
||||
case 3:
|
||||
i = DtMmdbOpenInfoLib(argv[2], 0, DtMmdbFalse);
|
||||
showInfoLibInfo(i);
|
||||
n = showInfoLibInfo(i);
|
||||
for ( j=0; j<n; j++ )
|
||||
showBookCaseInfo(DtMmdbGetBookCaseByIndex(i, j));
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "bad argument list\n");
|
||||
}
|
||||
|
||||
fprintf(stderr, "infolib desc=%d\n", i);
|
||||
return 0;
|
||||
}
|
||||
|
||||
extern "C"
|
||||
int test1(int argc, char** argv)
|
||||
{
|
||||
int j = 0;
|
||||
int n = 0;
|
||||
int i = -1;
|
||||
switch ( argc ) {
|
||||
case 5:
|
||||
i = DtMmdbOpenInfoLib(argv[2], argv[3], DtMmdbFalse);
|
||||
n = showInfoLibInfo(i);
|
||||
for ( j=0; j<n; j++ )
|
||||
showBookCaseInfo(DtMmdbGetBookCaseByLoc(i, argv[4]));
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "bad argument list\n");
|
||||
}
|
||||
|
||||
fprintf(stderr, "infolib desc=%d\n", i);
|
||||
return 0;
|
||||
}
|
||||
|
||||
DtMmdbInfoRequest* newDtMmdbInfoRequestWithLoc(int bc_id, char* loc)
|
||||
{
|
||||
DtMmdbInfoRequest* x =
|
||||
(DtMmdbInfoRequest*) malloc(sizeof(DtMmdbInfoRequest));
|
||||
|
||||
|
||||
x -> bookcase_descriptor = bc_id ;
|
||||
x -> locator_ptr = loc;
|
||||
return x;
|
||||
}
|
||||
|
||||
DtMmdbInfoRequest* newDtMmdbInfoRequestWithPrimaryOid(int bc_id, char* oid_str)
|
||||
{
|
||||
DtMmdbInfoRequest* x =
|
||||
(DtMmdbInfoRequest*) malloc(sizeof(DtMmdbInfoRequest));
|
||||
|
||||
|
||||
x -> bookcase_descriptor = bc_id ;
|
||||
x -> primary_oid = newDtMmdbHandle(oid_t(oid_str, true, false));
|
||||
return x;
|
||||
}
|
||||
|
||||
char* DtMmdbHandleToString(DtMmdbHandle* x)
|
||||
{
|
||||
static char buf[100];
|
||||
if ( x -> oid_ptr) {
|
||||
oid_t *z = (oid_t*)(x -> oid_ptr);
|
||||
snprintf(buf, sizeof(buf), "%d.%d", z -> ccode(), z -> icode());
|
||||
} else
|
||||
buf[0] = 0;
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
void showSection(DtMmdbInfoRequest* req)
|
||||
{
|
||||
if ( req == 0 ) return ;
|
||||
|
||||
const char* str = DtMmdbSectionGetLongTitle(req, 0);
|
||||
if (str) {
|
||||
fprintf(stderr, " SectionInfo: LongTitle=%s\n", str);
|
||||
}
|
||||
|
||||
str = DtMmdbSectionGetShortTitle(req, 0);
|
||||
if (str) {
|
||||
fprintf(stderr, " SectionInfo: ShortTitle=%s\n", str);
|
||||
}
|
||||
|
||||
str = DtMmdbSectionGetData(req, 0);
|
||||
if (str) {
|
||||
fprintf(stderr, " SectionInfo: data=%s\n", str);
|
||||
}
|
||||
|
||||
int size = DtMmdbSectionGetDataSize(req);
|
||||
fprintf(stderr, " SectionInfo: dataSize=%d\n", size);
|
||||
|
||||
|
||||
str = DtMmdbSectionGetTocLoc(req);
|
||||
if (str) {
|
||||
fprintf(stderr, " SectionInfo: TocLoc=%s\n", str);
|
||||
}
|
||||
|
||||
DtMmdbHandle* id = DtMmdbSectionGetBookId(req);
|
||||
if (id) {
|
||||
fprintf(stderr, " SectionInfo: BookId=%s\n", DtMmdbHandleToString(id));
|
||||
}
|
||||
|
||||
id = DtMmdbSectionGetStyleSheetId(req);
|
||||
if (id) {
|
||||
fprintf(stderr, " SectionInfo: StyleSheetId=%s\n", DtMmdbHandleToString(id));
|
||||
}
|
||||
}
|
||||
|
||||
void showTOC(DtMmdbInfoRequest* req)
|
||||
{
|
||||
if ( req == 0 ) return ;
|
||||
|
||||
DtMmdbHandle* id = DtMmdbTocGetParentId(req);
|
||||
if (id)
|
||||
fprintf(stderr, " TOC: parentId=%s\n", DtMmdbHandleToString(id));
|
||||
|
||||
|
||||
unsigned int ct = 0;
|
||||
DtMmdbHandle** ids = DtMmdbTocGetChildIds(req, &ct);
|
||||
if ( ids ) {
|
||||
fprintf(stderr, "ct=%d\n", ct);
|
||||
for ( int i=0; i<ct; i++ )
|
||||
fprintf(stderr, " TOC: childid[%d]=%s\n", i, DtMmdbHandleToString(ids[i]));
|
||||
}
|
||||
|
||||
int i = DtMmdbTocGetNumOfChildren(req);
|
||||
fprintf(stderr, " TOC: NumOfChildren=%d\n", i);
|
||||
}
|
||||
|
||||
extern "C"
|
||||
int test2(int argc, char** argv)
|
||||
{
|
||||
int j = 0;
|
||||
int n = 0;
|
||||
int i = -1;
|
||||
const char* str;
|
||||
switch ( argc ) {
|
||||
case 5:
|
||||
{
|
||||
i = DtMmdbOpenInfoLib(argv[2], argv[3], DtMmdbFalse);
|
||||
j = DtMmdbGetBookCaseByLoc(i, argv[4]);
|
||||
|
||||
DtMmdbInfoRequest* req = newDtMmdbInfoRequestWithLoc(j, argv[4]);
|
||||
showSection(req);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
fprintf(stderr, "invalid arguments\n");
|
||||
}
|
||||
|
||||
fprintf(stderr, "infolib desc=%d\n", i);
|
||||
return 0;
|
||||
}
|
||||
|
||||
extern "C"
|
||||
int test3(int argc, char** argv)
|
||||
{
|
||||
int j = 0;
|
||||
int n = 0;
|
||||
int i = -1;
|
||||
const char* str;
|
||||
switch ( argc ) {
|
||||
case 5:
|
||||
{
|
||||
i = DtMmdbOpenInfoLib(argv[2], argv[3], DtMmdbFalse);
|
||||
j = DtMmdbGetBookCaseByName(i, argv[3]);
|
||||
|
||||
DtMmdbInfoRequest* req = newDtMmdbInfoRequestWithPrimaryOid(j, argv[4]);
|
||||
showSection(req);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
fprintf(stderr, "invalid arguments\n");
|
||||
}
|
||||
|
||||
fprintf(stderr, "infolib desc=%d\n", i);
|
||||
return 0;
|
||||
}
|
||||
|
||||
extern "C"
|
||||
int test4(int argc, char** argv)
|
||||
{
|
||||
int j = 0;
|
||||
int i = 0;
|
||||
const char* str;
|
||||
switch ( argc ) {
|
||||
case 5:
|
||||
{
|
||||
i = DtMmdbOpenInfoLib(argv[2], argv[3], DtMmdbFalse);
|
||||
j = DtMmdbGetBookCaseByName(i, argv[3]);
|
||||
|
||||
DtMmdbInfoRequest* req = newDtMmdbInfoRequestWithPrimaryOid(j, argv[4]);
|
||||
showTOC(req);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
fprintf(stderr, "invalid arguments\n");
|
||||
}
|
||||
|
||||
fprintf(stderr, "infolib desc=%d\n", i);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
134
cde/lib/DtMmdb/oliasdb/c_api_toc.C
Normal file
134
cde/lib/DtMmdb/oliasdb/c_api_toc.C
Normal file
@@ -0,0 +1,134 @@
|
||||
/*
|
||||
* CDE - Common Desktop Environment
|
||||
*
|
||||
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
|
||||
*
|
||||
* These libraries and programs are free software; you can
|
||||
* redistribute them and/or modify them under the terms of the GNU
|
||||
* Lesser General Public License as published by the Free Software
|
||||
* Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* These libraries and programs are distributed in the hope that
|
||||
* they will be useful, but WITHOUT ANY WARRANTY; without even the
|
||||
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU Lesser General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with these libraries and programs; if not, write
|
||||
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
|
||||
* Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
// $XConsortium: c_api_toc.cc /main/4 1996/06/11 17:28:18 cde-hal $
|
||||
|
||||
#include "oliasdb/c_api_common.h"
|
||||
|
||||
static toc_smart_ptr*
|
||||
getTocUsingProid(DtMmdbInfoRequest* request)
|
||||
{
|
||||
mtry {
|
||||
info_base* x = getBookCase(request -> bookcase_descriptor);
|
||||
if ( x == 0 ) return 0;
|
||||
|
||||
oid_t * id = getPrimiaryOid(request);
|
||||
|
||||
if ( id == 0 ) return 0;
|
||||
|
||||
return new toc_smart_ptr(x, *id);
|
||||
}
|
||||
|
||||
mcatch (mmdbException &,e)
|
||||
{
|
||||
return 0;
|
||||
} end_try;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
DtMmdbHandle*
|
||||
DtMmdbTocGetParentId(DtMmdbInfoRequest* request)
|
||||
{
|
||||
mtry {
|
||||
toc_smart_ptr* x = getTocUsingProid(request);
|
||||
if ( x == 0 ) return 0;
|
||||
|
||||
DtMmdbHandle *z = 0;
|
||||
|
||||
if ( x -> parent() == ground )
|
||||
z = DtMmdbGroundId;
|
||||
else
|
||||
z = newDtMmdbHandle(x -> parent());
|
||||
|
||||
delete x;
|
||||
return z;
|
||||
}
|
||||
|
||||
mcatch (mmdbException &,e)
|
||||
{
|
||||
return 0;
|
||||
} end_try;
|
||||
return 0;
|
||||
}
|
||||
|
||||
DtMmdbHandle**
|
||||
DtMmdbTocGetChildIds(
|
||||
DtMmdbInfoRequest* request,
|
||||
unsigned int* list_length
|
||||
)
|
||||
{
|
||||
mtry {
|
||||
toc_smart_ptr* x = getTocUsingProid(request);
|
||||
if ( x == 0 ) return 0;
|
||||
|
||||
oid_list_handler* y = x -> children();
|
||||
if ( y == 0 ) return 0;
|
||||
|
||||
int count = (*y) -> count();
|
||||
//fprintf(stderr, "count=%d\n", count);
|
||||
|
||||
DtMmdbHandle** z = (DtMmdbHandle**)malloc(sizeof(DtMmdbHandle*) * (count+1));
|
||||
|
||||
//fprintf(stderr, "z=%x\n", (void*)z);
|
||||
if ( z == 0 ) return 0;
|
||||
|
||||
int i;
|
||||
for (i=0; i<count; i++) {
|
||||
z[i] = newDtMmdbHandle(oid_t(OLIAS_NODE_CODE, ((*y) -> operator()(i+1)).icode()));
|
||||
}
|
||||
|
||||
z[i] = 0;
|
||||
|
||||
delete y;
|
||||
delete x;
|
||||
|
||||
if ( list_length )
|
||||
*list_length = count;
|
||||
|
||||
return z;
|
||||
}
|
||||
|
||||
mcatch (mmdbException &,e)
|
||||
{
|
||||
return 0;
|
||||
} end_try;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int DtMmdbTocGetNumOfChildren( DtMmdbInfoRequest* request)
|
||||
{
|
||||
mtry {
|
||||
toc_smart_ptr* x = getTocUsingProid(request);
|
||||
if ( x == 0 ) return -1;
|
||||
int y = x -> subtree_size();
|
||||
delete x;
|
||||
return y;
|
||||
}
|
||||
|
||||
mcatch (mmdbException &,e)
|
||||
{
|
||||
return -1;
|
||||
} end_try;
|
||||
return -1;
|
||||
}
|
||||
|
||||
86
cde/lib/DtMmdb/oliasdb/c_api_toc_test.C
Normal file
86
cde/lib/DtMmdb/oliasdb/c_api_toc_test.C
Normal file
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
* CDE - Common Desktop Environment
|
||||
*
|
||||
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
|
||||
*
|
||||
* These libraries and programs are free software; you can
|
||||
* redistribute them and/or modify them under the terms of the GNU
|
||||
* Lesser General Public License as published by the Free Software
|
||||
* Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* These libraries and programs are distributed in the hope that
|
||||
* they will be useful, but WITHOUT ANY WARRANTY; without even the
|
||||
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU Lesser General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with these libraries and programs; if not, write
|
||||
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
|
||||
* Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
/* $XConsortium: c_api_toc_test.C /main/5 1996/08/21 15:53:29 drk $ */
|
||||
|
||||
#include "oliasdb/DtMmdb.h"
|
||||
#include <stdio.h>
|
||||
|
||||
extern "C"
|
||||
void showTOC(DtMmdbInfoRequest* req)
|
||||
{
|
||||
DtMmdbHandle* id = 0;
|
||||
unsigned int ct = 0;
|
||||
unsigned int i = 0;
|
||||
DtMmdbHandle** ids = 0;
|
||||
|
||||
if ( req == 0 ) return ;
|
||||
|
||||
id = DtMmdbTocGetParentId(req);
|
||||
if (id)
|
||||
fprintf(stderr, " TOC: parentId=%s\n", DtMmdbHandleToString(id));
|
||||
DtMmdbFreeHandle(id);
|
||||
|
||||
|
||||
ids = DtMmdbTocGetChildIds(req, &ct);
|
||||
if ( ids ) {
|
||||
fprintf(stderr, "ct=%d\n", ct);
|
||||
for ( i=0; i<ct; i++ )
|
||||
fprintf(stderr, " TOC: childid[%d]=%s\n", i, DtMmdbHandleToString(ids[i]
|
||||
));
|
||||
}
|
||||
DtMmdbFreeHandleList(ids);
|
||||
|
||||
i = DtMmdbTocGetNumOfChildren(req);
|
||||
fprintf(stderr, " TOC: NumOfChildren=%d\n", i);
|
||||
}
|
||||
|
||||
extern "C"
|
||||
int test4(int argc, char** argv)
|
||||
{
|
||||
int j = 0;
|
||||
int i = 0;
|
||||
DtMmdbInfoRequest* req = 0;
|
||||
|
||||
switch ( argc ) {
|
||||
case 5:
|
||||
{
|
||||
i = DtMmdbOpenInfoLib(argv[2], argv[3], DtMmdbFalse);
|
||||
j = DtMmdbGetBookCaseByName(i, argv[3]);
|
||||
|
||||
req = newDtMmdbInfoRequestWithPrimaryOid(j, argv[4]);
|
||||
showTOC(req);
|
||||
|
||||
DtMmdbFreeInfoRequest(req);
|
||||
DtMmdbCloseInfoLib(i);
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
fprintf(stderr, "invalid arguments\n");
|
||||
}
|
||||
|
||||
fprintf(stderr, "infolib desc=%d\n", i);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
141
cde/lib/DtMmdb/oliasdb/collectionIterator.C
Normal file
141
cde/lib/DtMmdb/oliasdb/collectionIterator.C
Normal file
@@ -0,0 +1,141 @@
|
||||
/*
|
||||
* CDE - Common Desktop Environment
|
||||
*
|
||||
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
|
||||
*
|
||||
* These libraries and programs are free software; you can
|
||||
* redistribute them and/or modify them under the terms of the GNU
|
||||
* Lesser General Public License as published by the Free Software
|
||||
* Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* These libraries and programs are distributed in the hope that
|
||||
* they will be useful, but WITHOUT ANY WARRANTY; without even the
|
||||
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU Lesser General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with these libraries and programs; if not, write
|
||||
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
|
||||
* Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
// $XConsortium: collectionIterator.cc /main/4 1996/06/11 17:28:28 cde-hal $
|
||||
|
||||
#include "oliasdb/collectionIterator.h"
|
||||
#include "oliasdb/olias_consts.h"
|
||||
#include "oliasdb/node_hd.h"
|
||||
#include "oliasdb/stylesheet_hd.h"
|
||||
#include "oliasdb/graphic_hd.h"
|
||||
#include "oliasdb/locator_hd.h"
|
||||
|
||||
collectionIterator::collectionIterator(info_base* base, int position) :
|
||||
f_set_ptr(base -> get_set(position)), f_base(base), f_index(-1)
|
||||
{
|
||||
if ( f_set_ptr == 0 )
|
||||
throw(stringException("can't find set"));
|
||||
}
|
||||
|
||||
collectionIterator::~collectionIterator()
|
||||
{
|
||||
}
|
||||
|
||||
unsigned int collectionIterator::operator++()
|
||||
{
|
||||
if ( f_index == -1 ) {
|
||||
f_index = 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if ( f_index == -2 ) {
|
||||
MESSAGE(cerr, "can't advance iterator any more");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ( (*f_set_ptr) -> count() - 1 == f_index ) {
|
||||
f_index = -2;
|
||||
return 0;
|
||||
} else {
|
||||
f_index++;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
oid_t collectionIterator::get_oid(int index)
|
||||
{
|
||||
c_index_handler* x = (*f_set_ptr) -> get_index_ptr(index);
|
||||
|
||||
if ( x == 0 )
|
||||
throw(stringException("bad internal index"));
|
||||
|
||||
return (*x) -> first_of_invlist(f_index);
|
||||
}
|
||||
|
||||
nodeCollectionIterator::nodeCollectionIterator(info_base* base) :
|
||||
collectionIterator(base, NODE_SET_POS)
|
||||
{
|
||||
}
|
||||
|
||||
nodeCollectionIterator::~nodeCollectionIterator()
|
||||
{
|
||||
}
|
||||
|
||||
const char* nodeCollectionIterator::get_locator()
|
||||
{
|
||||
oid_t id = get_oid(1);
|
||||
node_smart_ptr node(f_base, id);
|
||||
return node.locator();
|
||||
}
|
||||
|
||||
stylesheetCollectionIterator::stylesheetCollectionIterator(info_base* base) :
|
||||
collectionIterator(base, STYLESHEET_SET_POS)
|
||||
{
|
||||
}
|
||||
|
||||
stylesheetCollectionIterator::~stylesheetCollectionIterator()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
const char* stylesheetCollectionIterator::get_locator()
|
||||
{
|
||||
oid_t id = get_oid(1);
|
||||
stylesheet_smart_ptr ss(f_base, id);
|
||||
return ss.name();
|
||||
}
|
||||
|
||||
graphicCollectionIterator::graphicCollectionIterator(info_base* base) :
|
||||
collectionIterator(base, GRAPHIC_SET_POS)
|
||||
{
|
||||
}
|
||||
|
||||
graphicCollectionIterator::~graphicCollectionIterator()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
const char* graphicCollectionIterator::get_locator()
|
||||
{
|
||||
oid_t id = get_oid(1);
|
||||
graphic_smart_ptr gr(f_base, id);
|
||||
return gr.locator();
|
||||
}
|
||||
|
||||
locatorCollectionIterator::locatorCollectionIterator(info_base* base) :
|
||||
collectionIterator(base, LOCATOR_SET_POS)
|
||||
{
|
||||
}
|
||||
|
||||
locatorCollectionIterator::~locatorCollectionIterator()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
const char* locatorCollectionIterator::get_locator()
|
||||
{
|
||||
oid_t id = get_oid(1);
|
||||
locator_smart_ptr lc(f_base, id);
|
||||
return lc.inside_node_locator_str();
|
||||
}
|
||||
|
||||
|
||||
101
cde/lib/DtMmdb/oliasdb/collectionIterator.h
Normal file
101
cde/lib/DtMmdb/oliasdb/collectionIterator.h
Normal file
@@ -0,0 +1,101 @@
|
||||
/*
|
||||
* CDE - Common Desktop Environment
|
||||
*
|
||||
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
|
||||
*
|
||||
* These libraries and programs are free software; you can
|
||||
* redistribute them and/or modify them under the terms of the GNU
|
||||
* Lesser General Public License as published by the Free Software
|
||||
* Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* These libraries and programs are distributed in the hope that
|
||||
* they will be useful, but WITHOUT ANY WARRANTY; without even the
|
||||
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU Lesser General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with these libraries and programs; if not, write
|
||||
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
|
||||
* Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
/* $XConsortium: collectionIterator.h /main/3 1996/06/11 17:28:33 cde-hal $ */
|
||||
|
||||
#ifndef _collection_iterator_h
|
||||
#define _collection_iterator_h 1
|
||||
|
||||
#include "api/info_base.h"
|
||||
#include "object/cset.h"
|
||||
|
||||
// collectionIterator iterates over MMDB's cset objects through
|
||||
// index.
|
||||
|
||||
class collectionIterator
|
||||
{
|
||||
public:
|
||||
collectionIterator(info_base*, int set_position);
|
||||
virtual ~collectionIterator();
|
||||
|
||||
// advance the iterator to the next position.
|
||||
// A newly constructed iterator's position is
|
||||
// undefined. This operator must be called to
|
||||
// advance to the 1st position.
|
||||
|
||||
// return 1 if advance successful and 0 otherwize.
|
||||
virtual unsigned int operator++() ;
|
||||
|
||||
protected:
|
||||
oid_t get_oid(int index);
|
||||
|
||||
protected:
|
||||
cset_handler* f_set_ptr;
|
||||
info_base* f_base;
|
||||
int f_index;
|
||||
};
|
||||
|
||||
// iterator over node set
|
||||
class nodeCollectionIterator : public collectionIterator
|
||||
{
|
||||
|
||||
public:
|
||||
nodeCollectionIterator(info_base*);
|
||||
~nodeCollectionIterator();
|
||||
|
||||
const char* get_locator();
|
||||
};
|
||||
|
||||
// iterator over graphic set
|
||||
class graphicCollectionIterator : public collectionIterator
|
||||
{
|
||||
|
||||
public:
|
||||
graphicCollectionIterator(info_base*);
|
||||
~graphicCollectionIterator();
|
||||
|
||||
const char* get_locator();
|
||||
};
|
||||
|
||||
// iterator over stylesheet set
|
||||
class stylesheetCollectionIterator : public collectionIterator
|
||||
{
|
||||
|
||||
public:
|
||||
stylesheetCollectionIterator(info_base*);
|
||||
~stylesheetCollectionIterator();
|
||||
|
||||
const char* get_locator();
|
||||
};
|
||||
|
||||
// iterator over locator set
|
||||
class locatorCollectionIterator : public collectionIterator
|
||||
{
|
||||
|
||||
public:
|
||||
locatorCollectionIterator(info_base*);
|
||||
~locatorCollectionIterator();
|
||||
|
||||
const char* get_locator();
|
||||
};
|
||||
|
||||
#endif
|
||||
292
cde/lib/DtMmdb/oliasdb/dlp_hd.C
Normal file
292
cde/lib/DtMmdb/oliasdb/dlp_hd.C
Normal file
@@ -0,0 +1,292 @@
|
||||
/*
|
||||
* CDE - Common Desktop Environment
|
||||
*
|
||||
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
|
||||
*
|
||||
* These libraries and programs are free software; you can
|
||||
* redistribute them and/or modify them under the terms of the GNU
|
||||
* Lesser General Public License as published by the Free Software
|
||||
* Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* These libraries and programs are distributed in the hope that
|
||||
* they will be useful, but WITHOUT ANY WARRANTY; without even the
|
||||
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU Lesser General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with these libraries and programs; if not, write
|
||||
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
|
||||
* Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
/*
|
||||
* $XConsortium: dlp_hd.cc /main/4 1996/06/11 17:28:37 cde-hal $
|
||||
*
|
||||
* Copyright (c) 1992 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 "oliasdb/dlp_hd.h"
|
||||
|
||||
handler* dlp::get_component(int index)
|
||||
{
|
||||
if ( index != 1 )
|
||||
throw(boundaryException(1, 1, index));
|
||||
|
||||
return new handler(/*c,*/ f_oid, storage_ptr);
|
||||
}
|
||||
|
||||
io_status dlp::asciiOut(ostream& out)
|
||||
{
|
||||
//////////////////////////////////////////////
|
||||
// qfc: cause dlp trouble to find end nodes.
|
||||
//////////////////////////////////////////////
|
||||
/*
|
||||
if ( BIT_TEST(pos_status, BEG) )
|
||||
out << '+';
|
||||
*/
|
||||
|
||||
io_status ok = node_oid.asciiOut(out);
|
||||
|
||||
/*
|
||||
if ( BIT_TEST(pos_status, TERM) )
|
||||
out << '-';
|
||||
*/
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
// format for a book section:
|
||||
// 1004 \n
|
||||
// +x.x \n
|
||||
// ...
|
||||
// 1004 \n
|
||||
// x.x \n
|
||||
// - \n
|
||||
//
|
||||
// a dlp stream is (book_section)+
|
||||
|
||||
io_status dlp::asciiIn(istream& in)
|
||||
{
|
||||
set_mode(UPDATE, true);
|
||||
|
||||
pos_status = NOT_BEG_TERM;
|
||||
|
||||
int plus = in.get();
|
||||
|
||||
if ( plus == '+' ) {
|
||||
pos_status |= BEG;
|
||||
} else
|
||||
in.putback(char(plus));
|
||||
|
||||
io_status ok = node_oid.asciiIn(in);
|
||||
|
||||
int minus = in.get();
|
||||
|
||||
if ( minus == '-' ) {
|
||||
pos_status |= TERM;
|
||||
if ( in.get() != '\n' )
|
||||
throw(stringException("should be a newline"));
|
||||
} else
|
||||
in.putback(char(minus));
|
||||
|
||||
//debug(cerr, int(BEG));
|
||||
//debug(cerr, int(TERM));
|
||||
//debug(cerr, int(pos_status));
|
||||
//debug(cerr, node_oid);
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
int dlp::cdr_sizeof()
|
||||
{
|
||||
return dl_list_cell::cdr_sizeof() + node_oid.cdr_sizeof() + sizeof(pos_status);
|
||||
}
|
||||
|
||||
io_status dlp::cdrOut(buffer& buf)
|
||||
{
|
||||
dl_list_cell::cdrOut(buf);
|
||||
node_oid.cdrOut(buf);
|
||||
buf.put(pos_status);
|
||||
return done;
|
||||
}
|
||||
|
||||
io_status dlp::cdrIn(buffer& buf)
|
||||
{
|
||||
dl_list_cell::cdrIn(buf);
|
||||
node_oid.cdrIn(buf, OLIAS_NODE_CODE);
|
||||
buf.get(pos_status);
|
||||
return done;
|
||||
}
|
||||
|
||||
|
||||
MMDB_BODIES(dlp)
|
||||
|
||||
///////////////////////////////////
|
||||
//
|
||||
///////////////////////////////////
|
||||
|
||||
dlp_smart_ptr::
|
||||
dlp_smart_ptr(info_lib* lib_ptr,
|
||||
const char* info_base_name, const oid_t& id):
|
||||
smart_ptr(lib_ptr, info_base_name, DLP_LIST_POS,
|
||||
managers::query_mgr -> form_oid_handler(
|
||||
oid_t(OLIAS_NODE_CODE, id.icode())
|
||||
),
|
||||
////////////////////////////////////////////////////////////
|
||||
// to keep backward compatibility
|
||||
// up to 2.2: position is specified by BASE_COMPONENT_INDEX
|
||||
// 2.3 and higher: position is specified by THIS
|
||||
////////////////////////////////////////////////////////////
|
||||
(lib_ptr->get_info_base(info_base_name)->
|
||||
get_list(DLP_LIST_POS)->its_store()->
|
||||
get_db_version() < mm_version(2,3)) ? BASE_COMPONENT_INDEX : THIS,
|
||||
smart_ptr::LIST
|
||||
)
|
||||
{
|
||||
}
|
||||
|
||||
dlp_smart_ptr::
|
||||
dlp_smart_ptr(info_base* bs_ptr, const oid_t& id) :
|
||||
smart_ptr(bs_ptr, DLP_LIST_POS,
|
||||
managers::query_mgr -> form_oid_handler(
|
||||
oid_t(OLIAS_NODE_CODE, id.icode())
|
||||
),
|
||||
////////////////////////////////////////////////////////////
|
||||
// to keep backward compatibility
|
||||
// up to 2.2: position is specified by BASE_COMPONENT_INDEX
|
||||
// 2.3 and higher: position is specified by THIS
|
||||
////////////////////////////////////////////////////////////
|
||||
(bs_ptr-> get_list(DLP_LIST_POS)->its_store()->
|
||||
get_db_version() < mm_version(2,3)) ? BASE_COMPONENT_INDEX : THIS,
|
||||
smart_ptr::LIST
|
||||
)
|
||||
{
|
||||
}
|
||||
|
||||
dlp_smart_ptr::
|
||||
dlp_smart_ptr(dlp_smart_ptr& dsp, const oid_t& dlp_id)
|
||||
{
|
||||
smart_ptr::_init(dlp_id, dsp.its_store());
|
||||
}
|
||||
|
||||
///////////////////////////////////
|
||||
//
|
||||
///////////////////////////////////
|
||||
const oid_t dlp_smart_ptr::node_id()
|
||||
{
|
||||
dlp* x = (dlp*)(handler::operator->());
|
||||
return oid_t( x -> node_oid );
|
||||
}
|
||||
|
||||
dlp_smart_ptr* dlp_smart_ptr::prev()
|
||||
{
|
||||
oid_t back_cell_oid(prev_dlp_oid());
|
||||
|
||||
if ( back_cell_oid.icode() == 0 )
|
||||
return 0;
|
||||
else {
|
||||
|
||||
dl_list_cell_handler* cell_hd = (dl_list_cell_handler*)this;
|
||||
|
||||
dlp_smart_ptr* back_cell_hd = (dlp_smart_ptr*)
|
||||
new smart_ptr(cell_hd->its_store(), back_cell_oid);
|
||||
|
||||
if ( back_cell_hd -> node_id().icode() == 0 ) {
|
||||
delete back_cell_hd;
|
||||
return 0;
|
||||
} else
|
||||
return back_cell_hd;
|
||||
}
|
||||
}
|
||||
|
||||
dlp_smart_ptr* dlp_smart_ptr::next()
|
||||
{
|
||||
oid_t next_cell_oid(next_dlp_oid());
|
||||
|
||||
if ( next_cell_oid.icode() == 0 )
|
||||
return 0;
|
||||
else {
|
||||
|
||||
dl_list_cell_handler* cell_hd = (dl_list_cell_handler*)this;
|
||||
|
||||
dlp_smart_ptr* next_cell_hd = (dlp_smart_ptr*)
|
||||
new smart_ptr(cell_hd->its_store(), next_cell_oid);
|
||||
|
||||
if ( next_cell_hd -> node_id().icode() == 0 ) {
|
||||
delete next_cell_hd;
|
||||
return 0;
|
||||
} else
|
||||
return next_cell_hd;
|
||||
}
|
||||
}
|
||||
|
||||
oid_t dlp_smart_ptr::next_node_oid()
|
||||
{
|
||||
dlp_smart_ptr* x = next();
|
||||
|
||||
if ( x ) {
|
||||
//return oid_t(x -> node_id());
|
||||
oid_t z(x -> node_id());
|
||||
delete x;
|
||||
return z;
|
||||
} else {
|
||||
return ground;
|
||||
}
|
||||
}
|
||||
|
||||
oid_t dlp_smart_ptr::prev_node_oid()
|
||||
{
|
||||
dlp_smart_ptr* x = prev();
|
||||
|
||||
if (x) {
|
||||
oid_t z(x -> node_id());
|
||||
delete x;
|
||||
return z;
|
||||
} else {
|
||||
return ground;
|
||||
}
|
||||
}
|
||||
|
||||
oid_t dlp_smart_ptr::prev_dlp_oid()
|
||||
{
|
||||
if ( BIT_TEST(((dlp*)(handler::operator->())) -> pos_status, dlp::BEG) ) {
|
||||
return ground;
|
||||
} else {
|
||||
dl_list_cell_handler* cell_hd = (dl_list_cell_handler*)this;
|
||||
return oid_t((*cell_hd) -> get_backward_ptr());
|
||||
}
|
||||
}
|
||||
|
||||
oid_t dlp_smart_ptr::next_dlp_oid()
|
||||
{
|
||||
//debug(cerr, *((dlp*)(handler::operator->())));
|
||||
if ( BIT_TEST(((dlp*)(handler::operator->())) -> pos_status, dlp::TERM) )
|
||||
return ground;
|
||||
else {
|
||||
dl_list_cell_handler* cell_hd = (dl_list_cell_handler*)this;
|
||||
return oid_t((*cell_hd) -> get_forward_ptr());
|
||||
}
|
||||
}
|
||||
127
cde/lib/DtMmdb/oliasdb/dlp_hd.h
Normal file
127
cde/lib/DtMmdb/oliasdb/dlp_hd.h
Normal file
@@ -0,0 +1,127 @@
|
||||
/*
|
||||
* CDE - Common Desktop Environment
|
||||
*
|
||||
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
|
||||
*
|
||||
* These libraries and programs are free software; you can
|
||||
* redistribute them and/or modify them under the terms of the GNU
|
||||
* Lesser General Public License as published by the Free Software
|
||||
* Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* These libraries and programs are distributed in the hope that
|
||||
* they will be useful, but WITHOUT ANY WARRANTY; without even the
|
||||
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU Lesser General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with these libraries and programs; if not, write
|
||||
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
|
||||
* Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
/*
|
||||
* $XConsortium: dlp_hd.h /main/4 1996/06/11 17:28:42 cde-hal $
|
||||
*
|
||||
* Copyright (c) 1992 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 _dlp_hd_h
|
||||
#define _dlp_hd_h 1
|
||||
|
||||
#include "object/oid_t.h"
|
||||
#include "object/dl_list_cell.h"
|
||||
#include "oliasdb/olias_consts.h"
|
||||
#include "api/smart_ptr.h"
|
||||
|
||||
/*************************************/
|
||||
// The dlp class
|
||||
/*************************************/
|
||||
|
||||
class dlp : public dl_list_cell
|
||||
{
|
||||
public:
|
||||
dlp() : dl_list_cell(DLP_CODE), pos_status(NOT_BEG_TERM) {};
|
||||
virtual ~dlp() {};
|
||||
|
||||
MMDB_SIGNATURES(dlp);
|
||||
|
||||
handler* get_component(int) ;
|
||||
|
||||
// in/out functions
|
||||
io_status asciiOut(ostream&);
|
||||
io_status asciiIn(istream&);
|
||||
|
||||
virtual int cdr_sizeof();
|
||||
virtual io_status cdrOut(buffer&);
|
||||
virtual io_status cdrIn(buffer&);
|
||||
|
||||
protected:
|
||||
enum POS_STATUS { BEG=1, TERM=2, NOT_BEG_TERM=0 };
|
||||
|
||||
oid_t node_oid;
|
||||
char pos_status; // 1: beginning cell
|
||||
// 2: terminating cell
|
||||
// 3: both beginning and terminating cell
|
||||
// 0: neither beginning nor terminating cell
|
||||
|
||||
friend class dlp_smart_ptr;
|
||||
};
|
||||
|
||||
typedef dlp* dlpPtr;
|
||||
|
||||
|
||||
|
||||
|
||||
class dlp_smart_ptr : public smart_ptr
|
||||
{
|
||||
public:
|
||||
// x_id is not the oid of the dlp_hd, rather it is the
|
||||
// content of the dlp_hd.
|
||||
dlp_smart_ptr(info_lib* lib_ptr, const char* ibase_name, const oid_t& node_id);
|
||||
dlp_smart_ptr(info_base* ibase_ptr, const oid_t& node_id);
|
||||
|
||||
dlp_smart_ptr(dlp_smart_ptr&, const oid_t& dlp_id);
|
||||
|
||||
virtual ~dlp_smart_ptr() {};
|
||||
|
||||
|
||||
// id of the node that this dlp represents
|
||||
const oid_t node_id();
|
||||
|
||||
// the prev and next dlp of this dlp
|
||||
dlp_smart_ptr* prev();
|
||||
dlp_smart_ptr* next();
|
||||
|
||||
oid_t prev_node_oid();
|
||||
oid_t next_node_oid();
|
||||
|
||||
oid_t prev_dlp_oid();
|
||||
oid_t next_dlp_oid();
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
60
cde/lib/DtMmdb/oliasdb/dlp_test.C
Normal file
60
cde/lib/DtMmdb/oliasdb/dlp_test.C
Normal file
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* CDE - Common Desktop Environment
|
||||
*
|
||||
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
|
||||
*
|
||||
* These libraries and programs are free software; you can
|
||||
* redistribute them and/or modify them under the terms of the GNU
|
||||
* Lesser General Public License as published by the Free Software
|
||||
* Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* These libraries and programs are distributed in the hope that
|
||||
* they will be useful, but WITHOUT ANY WARRANTY; without even the
|
||||
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU Lesser General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with these libraries and programs; if not, write
|
||||
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
|
||||
* Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
/* $XConsortium: dlp_test.cc /main/4 1996/07/18 16:02:00 drk $ */
|
||||
|
||||
#ifdef REGRESSION_TEST
|
||||
|
||||
#include "oliasdb/dlp_test.h"
|
||||
|
||||
int dlp_test( info_lib* infolib_ptr, const char* base_name, const char* oid_str )
|
||||
{
|
||||
oid_t id((char*)oid_str, true, false);
|
||||
|
||||
dlp_smart_ptr* y = new dlp_smart_ptr( infolib_ptr, base_name, id );
|
||||
|
||||
dlp_smart_ptr* z;
|
||||
cerr << form("run backward from %s:\n", oid_str);
|
||||
|
||||
do {
|
||||
y -> node_id().asciiOut(cerr); cerr << "\n";
|
||||
z = y->prev();
|
||||
delete y;
|
||||
y = z;
|
||||
} while ( y );
|
||||
|
||||
|
||||
cerr << form("run forward from %s:\n", oid_str);
|
||||
|
||||
y = new dlp_smart_ptr( infolib_ptr, base_name, id );
|
||||
|
||||
do {
|
||||
y -> node_id().asciiOut(cerr); cerr << "\n";
|
||||
z = y->prev();
|
||||
delete y;
|
||||
y = z;
|
||||
} while ( z );
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
30
cde/lib/DtMmdb/oliasdb/dlp_test.h
Normal file
30
cde/lib/DtMmdb/oliasdb/dlp_test.h
Normal file
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* CDE - Common Desktop Environment
|
||||
*
|
||||
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
|
||||
*
|
||||
* These libraries and programs are free software; you can
|
||||
* redistribute them and/or modify them under the terms of the GNU
|
||||
* Lesser General Public License as published by the Free Software
|
||||
* Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* These libraries and programs are distributed in the hope that
|
||||
* they will be useful, but WITHOUT ANY WARRANTY; without even the
|
||||
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU Lesser General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with these libraries and programs; if not, write
|
||||
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
|
||||
* Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
/* $XConsortium: dlp_test.h /main/3 1996/06/11 17:42:51 cde-hal $ */
|
||||
|
||||
#ifndef _dlp_test_h
|
||||
#define _dlp_test_h
|
||||
|
||||
#include "oliasdb/dlp_hd.h"
|
||||
|
||||
#endif
|
||||
159
cde/lib/DtMmdb/oliasdb/doc_hd.C
Normal file
159
cde/lib/DtMmdb/oliasdb/doc_hd.C
Normal file
@@ -0,0 +1,159 @@
|
||||
/*
|
||||
* CDE - Common Desktop Environment
|
||||
*
|
||||
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
|
||||
*
|
||||
* These libraries and programs are free software; you can
|
||||
* redistribute them and/or modify them under the terms of the GNU
|
||||
* Lesser General Public License as published by the Free Software
|
||||
* Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* These libraries and programs are distributed in the hope that
|
||||
* they will be useful, but WITHOUT ANY WARRANTY; without even the
|
||||
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU Lesser General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with these libraries and programs; if not, write
|
||||
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
|
||||
* Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
/*
|
||||
* $XConsortium: doc_hd.cc /main/4 1996/06/11 17:28:47 cde-hal $
|
||||
*
|
||||
* Copyright (c) 1992 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 "oliasdb/doc_hd.h"
|
||||
|
||||
|
||||
MMDB_BODIES(doc)
|
||||
|
||||
doc_smart_ptr::
|
||||
doc_smart_ptr(info_lib* lib_ptr, const char* info_base_name, const int seq_num) :
|
||||
smart_ptr(lib_ptr, info_base_name,
|
||||
DOC_SET_POS,
|
||||
managers::query_mgr -> form_integer_handler(seq_num),
|
||||
BASE_COMPONENT_INDEX +3,
|
||||
smart_ptr::SET
|
||||
)
|
||||
{
|
||||
if ( seq_num < 1 )
|
||||
throw(boundaryException(1, MAXINT, seq_num));
|
||||
}
|
||||
|
||||
doc_smart_ptr::
|
||||
doc_smart_ptr(info_base* base_ptr, const int seq_num) :
|
||||
smart_ptr(base_ptr, DOC_SET_POS,
|
||||
managers::query_mgr -> form_integer_handler(seq_num),
|
||||
BASE_COMPONENT_INDEX + 3, smart_ptr::SET)
|
||||
{
|
||||
if ( seq_num < 1 )
|
||||
throw(boundaryException(1, MAXINT, seq_num));
|
||||
}
|
||||
|
||||
doc_smart_ptr::
|
||||
doc_smart_ptr(info_lib* lib_ptr, const char* base_name, const oid_t& x_id) :
|
||||
smart_ptr(lib_ptr, base_name, DOC_SET_POS,
|
||||
managers::query_mgr -> form_oid_handler(x_id),
|
||||
BASE_COMPONENT_INDEX,
|
||||
smart_ptr::SET
|
||||
)
|
||||
{
|
||||
}
|
||||
|
||||
doc_smart_ptr::
|
||||
doc_smart_ptr(info_base* base_ptr, const oid_t& x_id) :
|
||||
smart_ptr(base_ptr, DOC_SET_POS,
|
||||
managers::query_mgr -> form_oid_handler(x_id),
|
||||
BASE_COMPONENT_INDEX,
|
||||
smart_ptr::SET
|
||||
)
|
||||
{
|
||||
}
|
||||
|
||||
doc_smart_ptr::
|
||||
doc_smart_ptr(const oid_t& doc_id,
|
||||
info_lib* lib_ptr, const char* base_name
|
||||
) :
|
||||
smart_ptr(
|
||||
lib_ptr->get_info_base(base_name)->get_set(DOC_SET_POS) ->
|
||||
its_store(),
|
||||
doc_id
|
||||
)
|
||||
{
|
||||
}
|
||||
|
||||
doc_smart_ptr::
|
||||
doc_smart_ptr(const oid_t& doc_id, info_base* base_ptr) :
|
||||
smart_ptr(
|
||||
base_ptr -> get_set(DOC_SET_POS) -> its_store(),
|
||||
doc_id
|
||||
)
|
||||
{
|
||||
}
|
||||
|
||||
oid_t doc_smart_ptr::locator_id()
|
||||
{
|
||||
return get_oid(BASE_COMPONENT_INDEX);
|
||||
}
|
||||
|
||||
const char* doc_smart_ptr::short_title()
|
||||
{
|
||||
return get_string(BASE_COMPONENT_INDEX+1);
|
||||
}
|
||||
|
||||
const char* doc_smart_ptr::long_title()
|
||||
{
|
||||
return get_string(BASE_COMPONENT_INDEX+2);
|
||||
}
|
||||
|
||||
int doc_smart_ptr::seq_num()
|
||||
{
|
||||
return get_int(BASE_COMPONENT_INDEX+3);
|
||||
}
|
||||
|
||||
short_list_handler* doc_smart_ptr::tab_list()
|
||||
{
|
||||
short_list_handler* y = (short_list_handler*)
|
||||
get_handler( BASE_COMPONENT_INDEX + 4,
|
||||
SHORT_LIST_CODE
|
||||
);
|
||||
|
||||
return y;
|
||||
}
|
||||
|
||||
const char* doc_smart_ptr::license_terms()
|
||||
{
|
||||
return get_string(BASE_COMPONENT_INDEX+5);
|
||||
}
|
||||
|
||||
unsigned int doc_smart_ptr::license_terms_size()
|
||||
{
|
||||
return get_string_size(BASE_COMPONENT_INDEX+5);
|
||||
}
|
||||
|
||||
113
cde/lib/DtMmdb/oliasdb/doc_hd.h
Normal file
113
cde/lib/DtMmdb/oliasdb/doc_hd.h
Normal file
@@ -0,0 +1,113 @@
|
||||
/*
|
||||
* CDE - Common Desktop Environment
|
||||
*
|
||||
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
|
||||
*
|
||||
* These libraries and programs are free software; you can
|
||||
* redistribute them and/or modify them under the terms of the GNU
|
||||
* Lesser General Public License as published by the Free Software
|
||||
* Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* These libraries and programs are distributed in the hope that
|
||||
* they will be useful, but WITHOUT ANY WARRANTY; without even the
|
||||
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU Lesser General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with these libraries and programs; if not, write
|
||||
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
|
||||
* Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
/*
|
||||
* $XConsortium: doc_hd.h /main/4 1996/06/11 17:28:52 cde-hal $
|
||||
*
|
||||
* Copyright (c) 1992 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 _doc_hd_h
|
||||
#define _doc_hd_h 1
|
||||
|
||||
#include "object/tuple.h"
|
||||
#include "object/short_list.h"
|
||||
#include "object/pstring.h"
|
||||
#include "object/oid.h"
|
||||
#include "object/integer.h"
|
||||
#include "oliasdb/olias_consts.h"
|
||||
#include "api/smart_ptr.h"
|
||||
|
||||
#ifdef A16_BROWSER
|
||||
#define long_title title
|
||||
#endif
|
||||
|
||||
/*************************************/
|
||||
// The doc class
|
||||
/*************************************/
|
||||
|
||||
class doc : public mmdb_tuple
|
||||
{
|
||||
public:
|
||||
doc() : mmdb_tuple(NUM_DOC_FIELDS, DOC_CODE) {};
|
||||
virtual ~doc() {};
|
||||
|
||||
MMDB_SIGNATURES(doc);
|
||||
|
||||
protected:
|
||||
friend class doc_smart_ptr;
|
||||
};
|
||||
|
||||
typedef doc* docPtr;
|
||||
|
||||
/*************************************/
|
||||
/*************************************/
|
||||
|
||||
|
||||
class doc_smart_ptr : public smart_ptr
|
||||
{
|
||||
public:
|
||||
doc_smart_ptr(info_lib*, const char* base_name, const int seq_num);
|
||||
doc_smart_ptr(info_base* base_ptr, const int seq_num);
|
||||
|
||||
doc_smart_ptr(info_lib*, const char* ibase_name, const oid_t& toc_node_id);
|
||||
doc_smart_ptr(info_base* ibase_ptr, const oid_t& toc_node_id);
|
||||
|
||||
doc_smart_ptr(const oid_t& doc_id, info_lib*, const char* ibase_name);
|
||||
doc_smart_ptr(const oid_t& doc_id, info_base*);
|
||||
|
||||
virtual ~doc_smart_ptr() {};
|
||||
|
||||
oid_t locator_id();
|
||||
const char* short_title();
|
||||
const char* long_title();
|
||||
short_list_handler* tab_list();
|
||||
int seq_num(); // seq number for Fulcrum.
|
||||
const char* license_terms();
|
||||
unsigned int license_terms_size();
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
126
cde/lib/DtMmdb/oliasdb/doc_test.C
Normal file
126
cde/lib/DtMmdb/oliasdb/doc_test.C
Normal file
@@ -0,0 +1,126 @@
|
||||
/*
|
||||
* CDE - Common Desktop Environment
|
||||
*
|
||||
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
|
||||
*
|
||||
* These libraries and programs are free software; you can
|
||||
* redistribute them and/or modify them under the terms of the GNU
|
||||
* Lesser General Public License as published by the Free Software
|
||||
* Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* These libraries and programs are distributed in the hope that
|
||||
* they will be useful, but WITHOUT ANY WARRANTY; without even the
|
||||
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU Lesser General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with these libraries and programs; if not, write
|
||||
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
|
||||
* Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
/* $XConsortium: doc_test.cc /main/4 1996/07/18 16:02:13 drk $ */
|
||||
|
||||
#ifdef REGRESSION_TEST
|
||||
|
||||
#include "oliasdb/doc_test.h"
|
||||
|
||||
#define LARGE_BUFSIZ 2048
|
||||
|
||||
|
||||
void print_doc(doc_smart_ptr& x, ostream& out, Boolean out_it_oid, Boolean out_tag_list)
|
||||
{
|
||||
if ( out_it_oid == true )
|
||||
out << "its_oid=" << x.its_oid();
|
||||
|
||||
out << "short_title=" << x.short_title();
|
||||
out << "long_title=" << x.long_title();
|
||||
out << "seq_num=" << x.seq_num();
|
||||
|
||||
|
||||
if ( x.license_terms()) {
|
||||
const char* w = x.license_terms();
|
||||
int u = x.license_terms_size();
|
||||
for (int i=0; i<u; i++ )
|
||||
out << w[i];
|
||||
out << "\n";
|
||||
}
|
||||
|
||||
out << "license_terms_size=" << x.license_terms_size();
|
||||
|
||||
if ( out_tag_list == true ) {
|
||||
cerr << "tag list of the doc";
|
||||
short_list_handler* z = x.tab_list();
|
||||
(*z) -> asciiOut(cerr); cerr << "\n";
|
||||
delete z;
|
||||
}
|
||||
}
|
||||
|
||||
int compare_doc(doc_smart_ptr& pattern, info_base* base_ptr)
|
||||
{
|
||||
char pattern_buf[LARGE_BUFSIZ];
|
||||
ostringstream pattern_out(pattern_buf, LARGE_BUFSIZ, ios::out);
|
||||
print_doc(pattern, pattern_out, false, false);
|
||||
|
||||
doc_smart_ptr x( base_ptr, pattern.seq_num());
|
||||
char db_buf[LARGE_BUFSIZ];
|
||||
ostringstream db_out(db_buf, LARGE_BUFSIZ, ios::out);
|
||||
print_doc(x, db_out, false, false);
|
||||
|
||||
return compare_stream(pattern_out, db_out);
|
||||
}
|
||||
|
||||
int doc_test_oid( info_lib* infolib_ptr, const char* base_name, const char* oid_str )
|
||||
{
|
||||
oid_t id((char*)oid_str, true, false);
|
||||
doc_smart_ptr x( infolib_ptr, base_name, id);
|
||||
print_doc(x, cerr, true, true);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int doc_test_doc_oid( info_lib* infolib_ptr, const char* base_name, const char* oid_str )
|
||||
{
|
||||
oid_t id((char*)oid_str, true, false);
|
||||
doc_smart_ptr x(id, infolib_ptr, base_name);
|
||||
print_doc(x, cerr, true, true);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
doc_test_int(info_lib* infolib_ptr,
|
||||
const char* base_name,
|
||||
const char* seq_num_str)
|
||||
{
|
||||
|
||||
doc_smart_ptr x( infolib_ptr, base_name, atoi(seq_num_str));
|
||||
print_doc(x, cerr, true, true);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void generate_doc_instance(random_gen& x, ostream& out, int seq_num, int min_tabs, int max_tabs)
|
||||
{
|
||||
out << "1000\n";
|
||||
out << "6\n";
|
||||
x.random_oid(out, 1001, 0); // id
|
||||
x.random_string(out, 10, 20); // title
|
||||
x.random_string(out, 10, 40); // title
|
||||
x.random_integer(out, seq_num); // seq number
|
||||
|
||||
out << "105\n";
|
||||
out << "#\n";
|
||||
|
||||
int tabs = x.pick_a_value(min_tabs, max_tabs);
|
||||
|
||||
for ( int i=0; i<tabs; i++ )
|
||||
x.random_string(out, 10, 40); // tab node locator
|
||||
|
||||
out << "#\n";
|
||||
|
||||
x.random_string(out, 10, 100); // license term
|
||||
}
|
||||
|
||||
#endif
|
||||
42
cde/lib/DtMmdb/oliasdb/doc_test.h
Normal file
42
cde/lib/DtMmdb/oliasdb/doc_test.h
Normal file
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* CDE - Common Desktop Environment
|
||||
*
|
||||
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
|
||||
*
|
||||
* These libraries and programs are free software; you can
|
||||
* redistribute them and/or modify them under the terms of the GNU
|
||||
* Lesser General Public License as published by the Free Software
|
||||
* Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* These libraries and programs are distributed in the hope that
|
||||
* they will be useful, but WITHOUT ANY WARRANTY; without even the
|
||||
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU Lesser General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with these libraries and programs; if not, write
|
||||
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
|
||||
* Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
/* $XConsortium: doc_test.h /main/4 1996/07/18 16:32:48 drk $ */
|
||||
|
||||
#ifndef _doc_test_h
|
||||
#define _doc_test_h
|
||||
|
||||
#ifdef REGRESSION_TEST
|
||||
|
||||
#include "oliasdb/doc_hd.h"
|
||||
#include "object/random_gen.h"
|
||||
|
||||
void print_doc(doc_smart_ptr& x, ostream& out, Boolean out_it_oid,
|
||||
Boolean out_tag_list);
|
||||
|
||||
int compare_doc(doc_smart_ptr& pattern, info_base* base_ptr);
|
||||
|
||||
void generate_doc_instance(random_gen&, ostream& out, int seq_num, int min_tabs = 1, int max_tabs = 20);
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
256
cde/lib/DtMmdb/oliasdb/graphic_hd.C
Normal file
256
cde/lib/DtMmdb/oliasdb/graphic_hd.C
Normal file
@@ -0,0 +1,256 @@
|
||||
/*
|
||||
* CDE - Common Desktop Environment
|
||||
*
|
||||
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
|
||||
*
|
||||
* These libraries and programs are free software; you can
|
||||
* redistribute them and/or modify them under the terms of the GNU
|
||||
* Lesser General Public License as published by the Free Software
|
||||
* Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* These libraries and programs are distributed in the hope that
|
||||
* they will be useful, but WITHOUT ANY WARRANTY; without even the
|
||||
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU Lesser General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with these libraries and programs; if not, write
|
||||
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
|
||||
* Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
/*
|
||||
* $XConsortium: graphic_hd.cc /main/4 1996/06/11 17:28:57 cde-hal $
|
||||
* $XConsortium: graphic_hd.cc /main/4 1996/06/11 17:28:57 cde-hal $
|
||||
*
|
||||
* Copyright (c) 1992 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 "oliasdb/graphic_hd.h"
|
||||
|
||||
#ifdef C_API
|
||||
buffer* graphic_smart_ptr::local_graphic_buffer_ptr = 0;
|
||||
#endif
|
||||
|
||||
MMDB_BODIES(graphic)
|
||||
|
||||
void
|
||||
graphic_smart_ptr::init () {
|
||||
f_type = 0;
|
||||
f_width = 0;
|
||||
f_height = 0;
|
||||
f_coding = 0;
|
||||
f_llx = 0;
|
||||
f_lly = 0;
|
||||
f_urx = 0;
|
||||
f_ury = 0;
|
||||
}
|
||||
|
||||
graphic_smart_ptr::
|
||||
graphic_smart_ptr(info_lib* lib_ptr, const char* ibase_name, const char* locator) :
|
||||
smart_ptr(lib_ptr, ibase_name, GRAPHIC_SET_POS,
|
||||
managers::query_mgr -> form_pstring_handler(locator),
|
||||
BASE_COMPONENT_INDEX, smart_ptr::SET
|
||||
),
|
||||
_converted(false)
|
||||
{
|
||||
init ();
|
||||
}
|
||||
|
||||
graphic_smart_ptr::
|
||||
graphic_smart_ptr(info_base* base_ptr, const char* locator)
|
||||
: smart_ptr(base_ptr, GRAPHIC_SET_POS,
|
||||
managers::query_mgr -> form_pstring_handler(locator),
|
||||
BASE_COMPONENT_INDEX, smart_ptr::SET
|
||||
),
|
||||
_converted(false)
|
||||
{
|
||||
//debug(cerr, locator);
|
||||
init ();
|
||||
}
|
||||
|
||||
graphic_smart_ptr::
|
||||
graphic_smart_ptr(info_base* base_ptr, const oid_t& id)
|
||||
: smart_ptr(base_ptr -> get_set(GRAPHIC_SET_POS) -> its_store(), id),
|
||||
_converted(false)
|
||||
{
|
||||
init ();
|
||||
}
|
||||
|
||||
///////////////////////////////
|
||||
//
|
||||
///////////////////////////////
|
||||
|
||||
const char* graphic_smart_ptr::locator()
|
||||
{
|
||||
return get_string(BASE_COMPONENT_INDEX);
|
||||
}
|
||||
|
||||
const char* graphic_smart_ptr::file_name()
|
||||
{
|
||||
return get_string(BASE_COMPONENT_INDEX+1);
|
||||
}
|
||||
|
||||
const char* graphic_smart_ptr::version()
|
||||
{
|
||||
return get_string(BASE_COMPONENT_INDEX+2);
|
||||
}
|
||||
|
||||
Boolean graphic_smart_ptr::_convert_to_ints()
|
||||
{
|
||||
pstring_handler* x = (pstring_handler*)get_handler(BASE_COMPONENT_INDEX+3, STRING_CODE);
|
||||
|
||||
char* y = (*x)->get();
|
||||
int ct = (*x) -> size();
|
||||
|
||||
int dots = 0;
|
||||
for ( int i=0; i<ct; i++ )
|
||||
if ( y[i] == '.' )
|
||||
dots++;
|
||||
|
||||
switch (dots) {
|
||||
case 3:
|
||||
sscanf(y, "%d.%hu.%hu.%hu", &f_type, &f_coding, &f_width, &f_height);
|
||||
break;
|
||||
|
||||
case 5:
|
||||
sscanf(y, "%d.%hu.%u.%u.%u.%u",
|
||||
&f_type, &f_coding, &f_llx, &f_lly, &f_urx, &f_ury);
|
||||
//debug(cerr, f_llx);
|
||||
//debug(cerr, f_lly);
|
||||
//debug(cerr, f_urx);
|
||||
//debug(cerr, f_ury);
|
||||
break;
|
||||
|
||||
default:
|
||||
throw(stringException("wrong number of dots"));
|
||||
}
|
||||
|
||||
_converted = true;
|
||||
|
||||
delete x;
|
||||
return true;
|
||||
}
|
||||
|
||||
#ifdef C_API
|
||||
#define local_graphic_buffer (*local_graphic_buffer_ptr)
|
||||
#else
|
||||
static buffer local_graphic_buffer(LBUFSIZ);
|
||||
#endif
|
||||
|
||||
|
||||
const char* graphic_smart_ptr::data()
|
||||
{
|
||||
return get_string(BASE_COMPONENT_INDEX+4, local_graphic_buffer);
|
||||
}
|
||||
|
||||
int graphic_smart_ptr::data_size()
|
||||
{
|
||||
return get_string_size(BASE_COMPONENT_INDEX+4);
|
||||
}
|
||||
|
||||
const char* graphic_smart_ptr::title()
|
||||
{
|
||||
mtry
|
||||
{
|
||||
return get_string(BASE_COMPONENT_INDEX+5);
|
||||
}
|
||||
|
||||
mcatch (mmdbException&,e)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
end_try;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int graphic_smart_ptr::type() const
|
||||
{
|
||||
if ( _converted == false )
|
||||
// cast away to achieve logical constness
|
||||
((graphic_smart_ptr*)this)->_convert_to_ints();
|
||||
|
||||
return f_type;
|
||||
}
|
||||
|
||||
unsigned short graphic_smart_ptr::coding()
|
||||
{
|
||||
if ( _converted == false )
|
||||
_convert_to_ints();
|
||||
|
||||
return f_coding;
|
||||
}
|
||||
|
||||
unsigned short graphic_smart_ptr::width()
|
||||
{
|
||||
if ( _converted == false )
|
||||
_convert_to_ints();
|
||||
|
||||
return f_width;
|
||||
}
|
||||
|
||||
unsigned short graphic_smart_ptr::height()
|
||||
{
|
||||
if ( _converted == false )
|
||||
_convert_to_ints();
|
||||
|
||||
return f_height;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////
|
||||
unsigned int graphic_smart_ptr::llx()
|
||||
{
|
||||
if ( _converted == false )
|
||||
_convert_to_ints();
|
||||
|
||||
return f_llx;
|
||||
}
|
||||
|
||||
unsigned int graphic_smart_ptr::lly()
|
||||
{
|
||||
if ( _converted == false )
|
||||
_convert_to_ints();
|
||||
|
||||
return f_lly;
|
||||
}
|
||||
|
||||
unsigned int graphic_smart_ptr::urx()
|
||||
{
|
||||
if ( _converted == false )
|
||||
_convert_to_ints();
|
||||
|
||||
return f_urx;
|
||||
}
|
||||
|
||||
unsigned int graphic_smart_ptr::ury()
|
||||
{
|
||||
if ( _converted == false )
|
||||
_convert_to_ints();
|
||||
|
||||
return f_ury;
|
||||
}
|
||||
|
||||
129
cde/lib/DtMmdb/oliasdb/graphic_hd.h
Normal file
129
cde/lib/DtMmdb/oliasdb/graphic_hd.h
Normal file
@@ -0,0 +1,129 @@
|
||||
/*
|
||||
* CDE - Common Desktop Environment
|
||||
*
|
||||
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
|
||||
*
|
||||
* These libraries and programs are free software; you can
|
||||
* redistribute them and/or modify them under the terms of the GNU
|
||||
* Lesser General Public License as published by the Free Software
|
||||
* Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* These libraries and programs are distributed in the hope that
|
||||
* they will be useful, but WITHOUT ANY WARRANTY; without even the
|
||||
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU Lesser General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with these libraries and programs; if not, write
|
||||
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
|
||||
* Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
/*
|
||||
* $XConsortium: graphic_hd.h /main/5 1996/06/11 17:29:02 cde-hal $
|
||||
* $XConsortium: graphic_hd.h /main/5 1996/06/11 17:29:02 cde-hal $
|
||||
*
|
||||
* Copyright (c) 1992 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 _graphic_hd_h
|
||||
#define _graphic_hd_h 1
|
||||
|
||||
#include "object/tuple.h"
|
||||
#include "object/pstring.h"
|
||||
#include "object/compressed_pstring.h"
|
||||
#include "oliasdb/olias_consts.h"
|
||||
#include "api/smart_ptr.h"
|
||||
|
||||
/*************************************/
|
||||
// The graphic class
|
||||
/*************************************/
|
||||
|
||||
class graphic : public mmdb_tuple
|
||||
{
|
||||
|
||||
public:
|
||||
graphic() : mmdb_tuple(NUM_GRAPHIC_FIELDS, GRAPHIC_CODE) {};
|
||||
virtual ~graphic() {};
|
||||
|
||||
MMDB_SIGNATURES(graphic);
|
||||
|
||||
protected:
|
||||
};
|
||||
|
||||
typedef graphic* graphicPtr;
|
||||
|
||||
/*************************************/
|
||||
// The graphic_smart_ptr class
|
||||
/*************************************/
|
||||
class graphic_smart_ptr : public smart_ptr
|
||||
{
|
||||
public:
|
||||
|
||||
graphic_smart_ptr(info_lib* lib_ptr, const char* ibase_name, const char* locator);
|
||||
graphic_smart_ptr(info_base* ibase_ptr, const char* locator);
|
||||
graphic_smart_ptr(info_base* ibase_ptr, const oid_t& id);
|
||||
virtual ~graphic_smart_ptr() {};
|
||||
|
||||
const char* locator();
|
||||
const char* file_name();
|
||||
const char* version();
|
||||
|
||||
int type() const;
|
||||
unsigned short coding();
|
||||
unsigned short width();
|
||||
unsigned short height();
|
||||
int data_size();
|
||||
const char* data();
|
||||
const char* title();
|
||||
|
||||
unsigned int llx() ;
|
||||
unsigned int lly() ;
|
||||
unsigned int urx() ;
|
||||
unsigned int ury() ;
|
||||
|
||||
protected:
|
||||
|
||||
int f_type;
|
||||
unsigned short f_width, f_height, f_coding;
|
||||
unsigned int f_llx, f_lly, f_urx, f_ury;
|
||||
Boolean _converted;
|
||||
|
||||
Boolean _convert_to_ints();
|
||||
|
||||
void init ();
|
||||
|
||||
#ifdef C_API
|
||||
static buffer* local_graphic_buffer_ptr;
|
||||
friend void initialize_MMDB();
|
||||
friend void quit_MMDB();
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
typedef graphic_smart_ptr* graphic_smart_ptrPtr;
|
||||
|
||||
#endif
|
||||
110
cde/lib/DtMmdb/oliasdb/graphic_test.C
Normal file
110
cde/lib/DtMmdb/oliasdb/graphic_test.C
Normal file
@@ -0,0 +1,110 @@
|
||||
/*
|
||||
* CDE - Common Desktop Environment
|
||||
*
|
||||
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
|
||||
*
|
||||
* These libraries and programs are free software; you can
|
||||
* redistribute them and/or modify them under the terms of the GNU
|
||||
* Lesser General Public License as published by the Free Software
|
||||
* Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* These libraries and programs are distributed in the hope that
|
||||
* they will be useful, but WITHOUT ANY WARRANTY; without even the
|
||||
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU Lesser General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with these libraries and programs; if not, write
|
||||
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
|
||||
* Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
/* $XConsortium: graphic_test.cc /main/4 1996/07/18 16:02:34 drk $ */
|
||||
|
||||
#ifdef REGRESSION_TEST
|
||||
|
||||
#include "oliasdb/graphic_test.h"
|
||||
|
||||
#define LARGE_BUFSIZ 2048
|
||||
|
||||
|
||||
void print_graphic(graphic_smart_ptr& x, ostream& out, Boolean out_misc)
|
||||
{
|
||||
out << "locator=" << x.locator() << "\n";
|
||||
out << "filename=" << x.file_name() << "\n";
|
||||
out << "version=" << x.version() << "\n";
|
||||
|
||||
const char* title = x.title();
|
||||
if ( title )
|
||||
out << "title=" << x.title() << "\n";
|
||||
else
|
||||
out << "no title" << "\n";
|
||||
|
||||
out << "data_size=" << x.data_size() << "\n";
|
||||
|
||||
int l = x.data_size();
|
||||
const char* str = x.data();
|
||||
|
||||
for ( int i=0; i<l; i++ )
|
||||
out << str[i];
|
||||
|
||||
out << "\n";
|
||||
|
||||
if ( out_misc == true ) {
|
||||
out << "type=" << x.type() << "\n";
|
||||
out << "coding=" << x.coding() << "\n";
|
||||
out << "width=" << x.width() << "\n";
|
||||
out << "height=" << x.height() << "\n";
|
||||
|
||||
out << "llx=" << x.llx() << "\n";
|
||||
out << "lly=" << x.lly() << "\n";
|
||||
out << "urx=" << x.urx() << "\n";
|
||||
out << "ury=" << x.ury() << "\n";
|
||||
}
|
||||
}
|
||||
|
||||
int compare_graphic(graphic_smart_ptr& pattern, info_base* base_ptr)
|
||||
{
|
||||
char pattern_buf[LARGE_BUFSIZ];
|
||||
ostringstream pattern_out(pattern_buf, LARGE_BUFSIZ, ios::out);
|
||||
print_graphic(pattern, pattern_out, false);
|
||||
|
||||
char loc[BUFSIZ];
|
||||
int len = MIN(strlen(pattern.locator()), BUFSIZ -1);
|
||||
*((char *) memcpy(loc, pattern.locator(), len) + len) = '\0';
|
||||
|
||||
graphic_smart_ptr x( base_ptr, loc );
|
||||
char db_buf[LARGE_BUFSIZ];
|
||||
ostringstream db_out(db_buf, LARGE_BUFSIZ, ios::out);
|
||||
print_graphic(x, db_out, false);
|
||||
|
||||
return compare_stream(pattern_out, db_out);
|
||||
}
|
||||
|
||||
int graphic_test(info_lib* infolib_ptr, const char* base_name, const char* node_id_str )
|
||||
{
|
||||
graphic_smart_ptr x( infolib_ptr, base_name, node_id_str );
|
||||
cerr << form("info. about graphic %s:\n", node_id_str);
|
||||
print_graphic(x, cerr, true);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void generate_graphic_instance(info_base* b_ptr, random_gen& x, ostream& out, int min_len, int max_len)
|
||||
{
|
||||
|
||||
out << "1009\n";
|
||||
out << "6\n";
|
||||
x.random_string(out, 15, 15); // locator
|
||||
x.random_string(out, 0, 0); //
|
||||
x.random_string(out, 2, 2); // version
|
||||
x.random_string(out, 10, 30); // misc info
|
||||
|
||||
handler * y = (b_ptr -> get_obj_dict()).get_handler(
|
||||
form("%s.%s", b_ptr -> get_base_name(), "sgml.dict")
|
||||
);
|
||||
x.random_string_to_be_compressed(out, min_len, max_len, y -> its_oid()); // graphic
|
||||
x.random_string(out, 10, 30); // title
|
||||
}
|
||||
|
||||
#endif
|
||||
41
cde/lib/DtMmdb/oliasdb/graphic_test.h
Normal file
41
cde/lib/DtMmdb/oliasdb/graphic_test.h
Normal file
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* CDE - Common Desktop Environment
|
||||
*
|
||||
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
|
||||
*
|
||||
* These libraries and programs are free software; you can
|
||||
* redistribute them and/or modify them under the terms of the GNU
|
||||
* Lesser General Public License as published by the Free Software
|
||||
* Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* These libraries and programs are distributed in the hope that
|
||||
* they will be useful, but WITHOUT ANY WARRANTY; without even the
|
||||
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU Lesser General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with these libraries and programs; if not, write
|
||||
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
|
||||
* Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
/* $XConsortium: graphic_test.h /main/4 1996/07/18 16:33:04 drk $ */
|
||||
|
||||
#ifdef REGRESSION_TEST
|
||||
|
||||
#ifndef _graphic_test_h
|
||||
#define _graphic_test_h
|
||||
|
||||
|
||||
#include "oliasdb/graphic_hd.h"
|
||||
#include "object/random_gen.h"
|
||||
|
||||
void print_graphic(graphic_smart_ptr& x, ostream& out);
|
||||
|
||||
int compare_graphic(graphic_smart_ptr& pattern, info_base* base_ptr);
|
||||
void generate_graphic_instance(info_base*, random_gen&, ostream& out, int min_len, int max_len);
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
68
cde/lib/DtMmdb/oliasdb/loc_test.C
Normal file
68
cde/lib/DtMmdb/oliasdb/loc_test.C
Normal file
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* CDE - Common Desktop Environment
|
||||
*
|
||||
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
|
||||
*
|
||||
* These libraries and programs are free software; you can
|
||||
* redistribute them and/or modify them under the terms of the GNU
|
||||
* Lesser General Public License as published by the Free Software
|
||||
* Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* These libraries and programs are distributed in the hope that
|
||||
* they will be useful, but WITHOUT ANY WARRANTY; without even the
|
||||
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU Lesser General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with these libraries and programs; if not, write
|
||||
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
|
||||
* Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
/* $XConsortium: loc_test.C /main/5 1996/10/26 18:19:23 cde-hal $ */
|
||||
|
||||
#ifdef REGRESSION_TEST
|
||||
|
||||
#include "oliasdb/loc_test.h"
|
||||
|
||||
#define LARGE_BUFSIZ 2048
|
||||
|
||||
|
||||
void print_loc(locator_smart_ptr& x, ostream& out)
|
||||
{
|
||||
out << x.inside_node_locator_str();
|
||||
x.node_id().asciiOut(out); out << "\n";
|
||||
}
|
||||
|
||||
int compare_locator(locator_smart_ptr& pattern, info_base* base_ptr)
|
||||
{
|
||||
char pattern_buf[LARGE_BUFSIZ];
|
||||
ostringstream pattern_out(pattern_buf, LARGE_BUFSIZ, ios::out);
|
||||
print_loc(pattern, pattern_out);
|
||||
|
||||
locator_smart_ptr x( base_ptr, pattern.inside_node_locator_str());
|
||||
char db_buf[LARGE_BUFSIZ];
|
||||
ostringstream db_out(db_buf, LARGE_BUFSIZ, ios::out);
|
||||
print_loc(x, db_out);
|
||||
|
||||
return compare_stream(pattern_out, db_out);
|
||||
}
|
||||
|
||||
int loc_test( info_lib* infolib_ptr, const char* base_name, const char* loc )
|
||||
{
|
||||
locator_smart_ptr x( infolib_ptr, base_name, loc );
|
||||
print_loc(x, cerr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void generate_loc_instance(random_gen& x, ostream& out)
|
||||
{
|
||||
out << "1002\n";
|
||||
out << "3\n";
|
||||
x.random_string(out, 15, 15); // locator
|
||||
x.random_oid(out, 1001, 0); // id
|
||||
x.random_string(out, 8, 255); // label
|
||||
}
|
||||
|
||||
#endif
|
||||
39
cde/lib/DtMmdb/oliasdb/loc_test.h
Normal file
39
cde/lib/DtMmdb/oliasdb/loc_test.h
Normal file
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* CDE - Common Desktop Environment
|
||||
*
|
||||
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
|
||||
*
|
||||
* These libraries and programs are free software; you can
|
||||
* redistribute them and/or modify them under the terms of the GNU
|
||||
* Lesser General Public License as published by the Free Software
|
||||
* Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* These libraries and programs are distributed in the hope that
|
||||
* they will be useful, but WITHOUT ANY WARRANTY; without even the
|
||||
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU Lesser General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with these libraries and programs; if not, write
|
||||
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
|
||||
* Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
/* $XConsortium: loc_test.h /main/4 1996/07/18 16:33:21 drk $ */
|
||||
#ifdef REGRESSION_TEST
|
||||
|
||||
#ifndef _loc_test_h
|
||||
#define _loc_test_h
|
||||
|
||||
#include "oliasdb/locator_hd.h"
|
||||
#include "object/random_gen.h"
|
||||
|
||||
|
||||
int compare_locator(locator_smart_ptr& pattern, info_base* base_ptr);
|
||||
int loc_test(info_lib* infolib_ptr, const char* base_name, const char* loc );
|
||||
void generate_loc_instance(random_gen&, ostream& out);
|
||||
|
||||
|
||||
#endif
|
||||
#endif
|
||||
116
cde/lib/DtMmdb/oliasdb/locator_hd.C
Normal file
116
cde/lib/DtMmdb/oliasdb/locator_hd.C
Normal file
@@ -0,0 +1,116 @@
|
||||
/*
|
||||
* CDE - Common Desktop Environment
|
||||
*
|
||||
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
|
||||
*
|
||||
* These libraries and programs are free software; you can
|
||||
* redistribute them and/or modify them under the terms of the GNU
|
||||
* Lesser General Public License as published by the Free Software
|
||||
* Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* These libraries and programs are distributed in the hope that
|
||||
* they will be useful, but WITHOUT ANY WARRANTY; without even the
|
||||
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU Lesser General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with these libraries and programs; if not, write
|
||||
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
|
||||
* Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
/*
|
||||
* $XConsortium: locator_hd.C /main/5 1996/10/26 18:18:44 cde-hal $
|
||||
*
|
||||
* Copyright (c) 1992 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 "oliasdb/locator_hd.h"
|
||||
|
||||
MMDB_BODIES(olias_locator)
|
||||
|
||||
olias_locator::olias_locator() : mmdb_tuple(2, LOCATOR_CODE)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// components:
|
||||
// this_oid (ostring) parent (ostring), prev (ostring),
|
||||
// next (ostring), children (list)
|
||||
|
||||
locator_smart_ptr::
|
||||
locator_smart_ptr(info_lib* lib_ptr,
|
||||
const char* info_base_name, const char* locator) :
|
||||
smart_ptr(lib_ptr, info_base_name, LOCATOR_SET_POS,
|
||||
managers::query_mgr -> form_pstring_handler(locator),
|
||||
BASE_COMPONENT_INDEX, smart_ptr::SET
|
||||
)
|
||||
{
|
||||
}
|
||||
|
||||
locator_smart_ptr::
|
||||
locator_smart_ptr(info_base* base_ptr, const char* locator) :
|
||||
smart_ptr(base_ptr, LOCATOR_SET_POS,
|
||||
managers::query_mgr -> form_pstring_handler(locator),
|
||||
BASE_COMPONENT_INDEX, smart_ptr::SET
|
||||
)
|
||||
{
|
||||
}
|
||||
|
||||
locator_smart_ptr::
|
||||
locator_smart_ptr(info_base* base_ptr, const oid_t& id) :
|
||||
smart_ptr(base_ptr -> get_set(LOCATOR_SET_POS) -> its_store(), id)
|
||||
{
|
||||
}
|
||||
|
||||
const char* locator_smart_ptr::inside_node_locator_str()
|
||||
{
|
||||
return get_string(BASE_COMPONENT_INDEX);
|
||||
}
|
||||
|
||||
oid_t locator_smart_ptr::node_id()
|
||||
{
|
||||
return get_oid(BASE_COMPONENT_INDEX+1);
|
||||
}
|
||||
|
||||
const char* locator_smart_ptr::label()
|
||||
{
|
||||
const char* rval;
|
||||
|
||||
mtry
|
||||
{
|
||||
rval = get_string(BASE_COMPONENT_INDEX+2);
|
||||
}
|
||||
mcatch_any()
|
||||
{
|
||||
// catch exceptions to ensure backwards compatibility
|
||||
rval = 0;
|
||||
}
|
||||
end_try;
|
||||
|
||||
return rval;
|
||||
}
|
||||
|
||||
101
cde/lib/DtMmdb/oliasdb/locator_hd.h
Normal file
101
cde/lib/DtMmdb/oliasdb/locator_hd.h
Normal file
@@ -0,0 +1,101 @@
|
||||
/*
|
||||
* CDE - Common Desktop Environment
|
||||
*
|
||||
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
|
||||
*
|
||||
* These libraries and programs are free software; you can
|
||||
* redistribute them and/or modify them under the terms of the GNU
|
||||
* Lesser General Public License as published by the Free Software
|
||||
* Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* These libraries and programs are distributed in the hope that
|
||||
* they will be useful, but WITHOUT ANY WARRANTY; without even the
|
||||
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU Lesser General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with these libraries and programs; if not, write
|
||||
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
|
||||
* Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
/*
|
||||
* $XConsortium: locator_hd.h /main/5 1996/10/26 18:18:57 cde-hal $
|
||||
*
|
||||
* Copyright (c) 1992 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 _locator_hd_h
|
||||
#define _locator_hd_h 1
|
||||
|
||||
#include "object/short_list.h"
|
||||
#include "object/tuple.h"
|
||||
#include "object/oid.h"
|
||||
#include "object/pstring.h"
|
||||
#include "object/integer.h"
|
||||
#include "oliasdb/olias_consts.h"
|
||||
#include "api/smart_ptr.h"
|
||||
|
||||
/*************************************/
|
||||
// The locator class
|
||||
/*************************************/
|
||||
|
||||
class olias_locator : public mmdb_tuple
|
||||
{
|
||||
|
||||
public:
|
||||
olias_locator();
|
||||
virtual ~olias_locator() {};
|
||||
|
||||
MMDB_SIGNATURES(olias_locator);
|
||||
|
||||
protected:
|
||||
};
|
||||
|
||||
typedef olias_locator* locatorPtr;
|
||||
|
||||
class locator_smart_ptr : public smart_ptr
|
||||
{
|
||||
public:
|
||||
locator_smart_ptr(info_lib* lib_ptr,
|
||||
const char* info_base_name, const char* locator);
|
||||
locator_smart_ptr(info_base* base_ptr, const char* locator);
|
||||
locator_smart_ptr(info_base* base_ptr, const oid_t& id);
|
||||
|
||||
virtual ~locator_smart_ptr() {};
|
||||
|
||||
|
||||
const char* inside_node_locator_str();
|
||||
oid_t node_id();
|
||||
const char* label();
|
||||
//int vcc_num();
|
||||
};
|
||||
|
||||
typedef locator_smart_ptr* locator_smart_ptrPtr;
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
270
cde/lib/DtMmdb/oliasdb/mark.C
Normal file
270
cde/lib/DtMmdb/oliasdb/mark.C
Normal file
@@ -0,0 +1,270 @@
|
||||
/*
|
||||
* CDE - Common Desktop Environment
|
||||
*
|
||||
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
|
||||
*
|
||||
* These libraries and programs are free software; you can
|
||||
* redistribute them and/or modify them under the terms of the GNU
|
||||
* Lesser General Public License as published by the Free Software
|
||||
* Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* These libraries and programs are distributed in the hope that
|
||||
* they will be useful, but WITHOUT ANY WARRANTY; without even the
|
||||
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU Lesser General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with these libraries and programs; if not, write
|
||||
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
|
||||
* Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
/*
|
||||
* $XConsortium: mark.cc /main/6 1996/07/18 14:47:10 drk $
|
||||
*
|
||||
* Copyright (c) 1992 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 "oliasdb/mark.h"
|
||||
|
||||
umark::umark() : mmdb_tuple(2, USER_MARK_CODE), mark_set_hd_ptr(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
MMDB_BODIES(umark)
|
||||
|
||||
mark_smart_ptr::
|
||||
mark_smart_ptr(mark_base* uptr, const char* node_locator) :
|
||||
mbase(uptr),
|
||||
v_loct_hd(0), v_mark_hd(0)
|
||||
{
|
||||
#ifdef INTERCEPT_MARK_CALLS
|
||||
MESSAGE(cerr, "mark_smart_ptr::cstr (1)");
|
||||
debug(cerr, uptr -> get_base_name());
|
||||
debug(cerr, node_locator);
|
||||
#endif
|
||||
|
||||
mark_set_hd_ptr = uptr->mark_set_hd;
|
||||
|
||||
mtry {
|
||||
mbase -> trans().begin();
|
||||
|
||||
abs_storage* marks_store = mark_set_hd_ptr -> its_store();
|
||||
|
||||
/////////////////////
|
||||
// init tuple part
|
||||
/////////////////////
|
||||
|
||||
mmdb_tuple_handler* x = (mmdb_tuple_handler*)
|
||||
(new handler(USER_MARK_CODE, marks_store));
|
||||
|
||||
|
||||
v_loct_hd =
|
||||
new pstring_handler(node_locator, strlen(node_locator), marks_store);
|
||||
|
||||
//(v_loct_hd->operator->())->asciiOut(cerr);
|
||||
|
||||
v_mark_hd =
|
||||
new pstring_handler("", 0, marks_store);
|
||||
/*
|
||||
debug(cerr, v_loct_hd -> its_oid());
|
||||
debug(cerr, *v_loct_hd);
|
||||
debug(cerr, int(v_loct_hd));
|
||||
debug(cerr, v_mark_hd -> its_oid());
|
||||
debug(cerr, *v_mark_hd);
|
||||
debug(cerr, int(v_mark_hd));
|
||||
*/
|
||||
|
||||
(*x) -> pinned_insert(BASE_COMPONENT_INDEX, v_loct_hd -> its_oid());
|
||||
(*x) -> pinned_insert(BASE_COMPONENT_INDEX+1, v_mark_hd -> its_oid());
|
||||
|
||||
x -> commit();
|
||||
/////////////////////
|
||||
// init smart_ptr
|
||||
/////////////////////
|
||||
|
||||
smart_ptr::_init(x->its_oid(), marks_store);
|
||||
|
||||
////////////////////////
|
||||
// insert into mark set
|
||||
////////////////////////
|
||||
v_loct_hd -> commit(); // commit it so that the locator
|
||||
// can be seen inside insert_object().
|
||||
(*mark_set_hd_ptr) -> insert_object( *x );
|
||||
|
||||
mark_set_hd_ptr -> commit();
|
||||
|
||||
//debug(cerr, x -> its_oid());
|
||||
|
||||
delete x;
|
||||
|
||||
mbase -> trans().end();
|
||||
}
|
||||
|
||||
mcatch (beginTransException&, e)
|
||||
{
|
||||
smart_ptr::_init(ground, 0); // mark the mark obsolete
|
||||
rethrow;
|
||||
}
|
||||
mcatch (commitTransException&, e)
|
||||
{
|
||||
smart_ptr::_init(ground, 0); // mark the mark obsolete
|
||||
rethrow;
|
||||
}
|
||||
mcatch (mmdbException&, e)
|
||||
{
|
||||
smart_ptr::_init(ground, 0); // mark the mark obsolete
|
||||
mbase -> trans().rollback();
|
||||
rethrow;
|
||||
}
|
||||
end_try;
|
||||
}
|
||||
|
||||
mark_smart_ptr::
|
||||
mark_smart_ptr(mark_base* uptr, const oid_t& mark_id) :
|
||||
smart_ptr(uptr->mark_set_hd->its_store(), mark_id),
|
||||
mbase(uptr), mark_set_hd_ptr(uptr -> mark_set_hd)
|
||||
{
|
||||
#ifdef INTERCEPT_MARK_CALLS
|
||||
MESSAGE(cerr, "mark_smart_ptr::cstr (2)");
|
||||
debug(cerr, uptr -> get_base_name());
|
||||
debug(cerr, mark_id);
|
||||
#endif
|
||||
|
||||
mtry
|
||||
{
|
||||
v_loct_hd = (pstring_handler*)
|
||||
get_handler(BASE_COMPONENT_INDEX, STRING_CODE);
|
||||
v_mark_hd = (pstring_handler*)
|
||||
get_handler(BASE_COMPONENT_INDEX+1, STRING_CODE);
|
||||
}
|
||||
|
||||
mcatch (mmdbException&, e)
|
||||
{
|
||||
smart_ptr::_init(ground, 0); // mark the mark obsolete
|
||||
rethrow;
|
||||
}
|
||||
end_try;
|
||||
|
||||
}
|
||||
|
||||
mark_smart_ptr::~mark_smart_ptr()
|
||||
{
|
||||
delete v_loct_hd;
|
||||
delete v_mark_hd;
|
||||
}
|
||||
|
||||
void mark_smart_ptr::update_usermark(const pstring& new_mark)
|
||||
{
|
||||
update_usermark(((pstring&)new_mark).get(), ((pstring&)new_mark).size());
|
||||
}
|
||||
|
||||
void mark_smart_ptr::update_usermark(const char* new_mark_str,
|
||||
int new_mark_str_sz)
|
||||
{
|
||||
mtry {
|
||||
mbase -> trans().begin();
|
||||
|
||||
(*v_mark_hd) -> update(new_mark_str, new_mark_str_sz);
|
||||
v_mark_hd -> commit();
|
||||
|
||||
mbase -> trans().end();
|
||||
}
|
||||
|
||||
mcatch (beginTransException&, e)
|
||||
{
|
||||
rethrow;
|
||||
}
|
||||
mcatch (commitTransException&, e)
|
||||
{
|
||||
rethrow;
|
||||
}
|
||||
mcatch (mmdbException&, e)
|
||||
{
|
||||
mbase -> trans().rollback();
|
||||
rethrow;
|
||||
}
|
||||
end_try;
|
||||
}
|
||||
|
||||
void mark_smart_ptr::remove_from_db()
|
||||
{
|
||||
mtry {
|
||||
mbase -> trans().begin();
|
||||
|
||||
(*mark_set_hd_ptr) -> remove_component(its_oid());
|
||||
mark_set_hd_ptr -> commit();
|
||||
|
||||
mbase -> trans().end();
|
||||
}
|
||||
|
||||
mcatch (beginTransException&, e)
|
||||
{
|
||||
rethrow;
|
||||
}
|
||||
mcatch (commitTransException&, e)
|
||||
{
|
||||
rethrow;
|
||||
}
|
||||
mcatch (mmdbException&, e)
|
||||
{
|
||||
mbase -> trans().rollback();
|
||||
rethrow;
|
||||
}
|
||||
end_try;
|
||||
}
|
||||
|
||||
const char* mark_smart_ptr::node_locator()
|
||||
{
|
||||
return (*v_loct_hd) -> get();
|
||||
}
|
||||
|
||||
pstring* mark_smart_ptr::mark_value()
|
||||
{
|
||||
/*
|
||||
pstring *z = v_mark_hd -> operator->();
|
||||
debug(cerr, z -> size());
|
||||
*/
|
||||
|
||||
return v_mark_hd -> operator->();
|
||||
}
|
||||
|
||||
ostream& operator <<(ostream& out, mark_smart_ptr& umark)
|
||||
{
|
||||
const char* x = umark.node_locator();
|
||||
if ( x )
|
||||
out << "node_locator: " << x << "\n";
|
||||
|
||||
out << "mark_value: ";
|
||||
|
||||
umark.mark_value() -> asciiOut(out);
|
||||
|
||||
// out << "\n";
|
||||
|
||||
return out;
|
||||
}
|
||||
108
cde/lib/DtMmdb/oliasdb/mark.h
Normal file
108
cde/lib/DtMmdb/oliasdb/mark.h
Normal file
@@ -0,0 +1,108 @@
|
||||
/*
|
||||
* CDE - Common Desktop Environment
|
||||
*
|
||||
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
|
||||
*
|
||||
* These libraries and programs are free software; you can
|
||||
* redistribute them and/or modify them under the terms of the GNU
|
||||
* Lesser General Public License as published by the Free Software
|
||||
* Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* These libraries and programs are distributed in the hope that
|
||||
* they will be useful, but WITHOUT ANY WARRANTY; without even the
|
||||
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU Lesser General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with these libraries and programs; if not, write
|
||||
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
|
||||
* Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
/*
|
||||
* $XConsortium: mark.h /main/4 1996/06/11 17:29:36 cde-hal $
|
||||
*
|
||||
* Copyright (c) 1992 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 _mark_h
|
||||
#define _mark_h 1
|
||||
|
||||
#include "object/tuple.h"
|
||||
#include "object/pstring.h"
|
||||
#include "object/oid.h"
|
||||
#include "oliasdb/olias_consts.h"
|
||||
#include "oliasdb/mark_base.h"
|
||||
#include "api/smart_ptr.h"
|
||||
|
||||
#define mark_smart_ptr user_mark_smart_ptr
|
||||
#define umark user_mark
|
||||
|
||||
class umark : public mmdb_tuple
|
||||
{
|
||||
|
||||
public:
|
||||
umark();
|
||||
virtual ~umark() {};
|
||||
|
||||
MMDB_SIGNATURES(umark);
|
||||
|
||||
friend class mark_smart_ptr;
|
||||
|
||||
protected:
|
||||
cset_handler* mark_set_hd_ptr;
|
||||
|
||||
};
|
||||
|
||||
class mark_smart_ptr : public smart_ptr
|
||||
{
|
||||
public:
|
||||
mark_smart_ptr(mark_base*, const char* node_locator);
|
||||
mark_smart_ptr(mark_base*, const oid_t& mark_oid);
|
||||
virtual ~mark_smart_ptr();
|
||||
|
||||
void update_usermark(const pstring& new_um);
|
||||
void update_usermark(const char* mark, int mark_sz);
|
||||
|
||||
void remove_from_db();
|
||||
|
||||
const char* node_locator();
|
||||
pstring* mark_value();
|
||||
|
||||
friend ostream& operator <<(ostream&, mark_smart_ptr&);
|
||||
|
||||
protected:
|
||||
|
||||
protected:
|
||||
mark_base* mbase;
|
||||
cset_handler* mark_set_hd_ptr;
|
||||
|
||||
pstring_handler* v_loct_hd;
|
||||
pstring_handler* v_mark_hd;
|
||||
};
|
||||
|
||||
#endif
|
||||
158
cde/lib/DtMmdb/oliasdb/mark_base.C
Normal file
158
cde/lib/DtMmdb/oliasdb/mark_base.C
Normal file
@@ -0,0 +1,158 @@
|
||||
/*
|
||||
* CDE - Common Desktop Environment
|
||||
*
|
||||
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
|
||||
*
|
||||
* These libraries and programs are free software; you can
|
||||
* redistribute them and/or modify them under the terms of the GNU
|
||||
* Lesser General Public License as published by the Free Software
|
||||
* Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* These libraries and programs are distributed in the hope that
|
||||
* they will be useful, but WITHOUT ANY WARRANTY; without even the
|
||||
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU Lesser General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with these libraries and programs; if not, write
|
||||
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
|
||||
* Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
/*
|
||||
* $XConsortium: mark_base.cc /main/7 1996/07/18 14:47:29 drk $
|
||||
*
|
||||
* Copyright (c) 1992 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 "oliasdb/mark_base.h"
|
||||
#include "oliasdb/mark.h"
|
||||
#include "utility/debug.h"
|
||||
#include "misc/unique_id.h"
|
||||
|
||||
mark_base::mark_base(user_base::rw_flag_t rw) :
|
||||
user_base(MARK_SPEC, rw)
|
||||
{
|
||||
mark_set_hd = NULL;
|
||||
}
|
||||
|
||||
|
||||
mark_base::mark_base( const char* base_dir,
|
||||
const char* base_nm,
|
||||
const char* base_ds,
|
||||
user_base::rw_flag_t rw
|
||||
) :
|
||||
user_base(base_dir, base_nm, base_ds, MARK_SPEC, rw)
|
||||
{
|
||||
if ( checking_status != SUCC ) {
|
||||
mark_set_hd = NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
desc* ptr = first_desc_ptr;
|
||||
|
||||
if ( ptr == 0 )
|
||||
throw(stringException("empty mark specification"));
|
||||
|
||||
while ( ptr ) {
|
||||
if ( strcmp( ptr -> get_type(), "container set") == 0 ) {
|
||||
mark_set_hd = (cset_handler*)
|
||||
(f_obj_dict -> get_handler(ptr -> get_nm()));
|
||||
return;
|
||||
}
|
||||
ptr = ptr -> get_next_desc();
|
||||
}
|
||||
|
||||
throw(stringException("can't find mark set description record"));
|
||||
}
|
||||
|
||||
mark_base::~mark_base()
|
||||
{
|
||||
}
|
||||
|
||||
oid_list_handler* mark_base::get_mark_list(const char* node_locator)
|
||||
{
|
||||
#ifdef INTERCEPT_MARK_BASE_CALLS
|
||||
MESSAGE(cerr, "mark_base::get_mark_list()");
|
||||
debug(cerr, node_locator);
|
||||
#endif
|
||||
|
||||
pstring* x = new pstring(node_locator, strlen(node_locator));
|
||||
handler y(x, 0);
|
||||
|
||||
oid_list_handler*z = (*mark_set_hd) -> get_locs(y, 1);
|
||||
|
||||
#ifdef INTERCEPT_MARK_BASE_CALLS
|
||||
if (z)
|
||||
debug(cerr, (*z) -> asciiOut(cerr));
|
||||
#endif
|
||||
|
||||
return z;
|
||||
}
|
||||
|
||||
mmdb_pos_t mark_base::first()
|
||||
{
|
||||
page_storage *s = (page_storage*)((*mark_set_hd) -> get_store());
|
||||
|
||||
mmdb_pos_t ind = s -> first_loc();
|
||||
|
||||
if ( managers::template_mgr -> peek_slot(s, ind) != USER_MARK_CODE ) {
|
||||
this -> next(ind);
|
||||
}
|
||||
|
||||
return ind;
|
||||
}
|
||||
|
||||
oid_t mark_base::get_mark_oid(mmdb_pos_t& ind)
|
||||
{
|
||||
page_storage *s = (page_storage*)((*mark_set_hd) -> get_store());
|
||||
|
||||
root *r = 0;
|
||||
managers::template_mgr -> init_obj(s, ind, r);
|
||||
|
||||
if (r==0)
|
||||
throw(stringException("null root object pointer"));
|
||||
|
||||
oid_t x = r -> my_oid();
|
||||
delete r;
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
void mark_base::next(mmdb_pos_t& ind)
|
||||
{
|
||||
page_storage *s = (page_storage*)((*mark_set_hd) -> get_store());
|
||||
|
||||
while ( s -> seek_loc( ind, positive, spointer_t::IS_OBJECT ) == true ) {
|
||||
if ( managers::template_mgr -> peek_slot(s, ind) == USER_MARK_CODE ) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
ind = 0;
|
||||
}
|
||||
|
||||
95
cde/lib/DtMmdb/oliasdb/mark_base.h
Normal file
95
cde/lib/DtMmdb/oliasdb/mark_base.h
Normal file
@@ -0,0 +1,95 @@
|
||||
/*
|
||||
* CDE - Common Desktop Environment
|
||||
*
|
||||
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
|
||||
*
|
||||
* These libraries and programs are free software; you can
|
||||
* redistribute them and/or modify them under the terms of the GNU
|
||||
* Lesser General Public License as published by the Free Software
|
||||
* Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* These libraries and programs are distributed in the hope that
|
||||
* they will be useful, but WITHOUT ANY WARRANTY; without even the
|
||||
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU Lesser General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with these libraries and programs; if not, write
|
||||
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
|
||||
* Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
/*
|
||||
* $XConsortium: mark_base.h /main/4 1996/07/18 14:47:51 drk $
|
||||
*
|
||||
* Copyright (c) 1992 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 _mark_base_h
|
||||
#define _mark_base_h 1
|
||||
|
||||
#include "oliasdb/user_base.h"
|
||||
|
||||
/*************************************/
|
||||
// The mark class
|
||||
/*************************************/
|
||||
|
||||
class mark_base : public user_base
|
||||
{
|
||||
|
||||
public:
|
||||
mark_base(const char* base_dir,
|
||||
const char* base_name,
|
||||
const char* base_desc,
|
||||
user_base::rw_flag_t = user_base::READ
|
||||
);
|
||||
mark_base(user_base::rw_flag_t = user_base::READ);
|
||||
virtual ~mark_base();
|
||||
|
||||
// return user marks associated with a node locator
|
||||
oid_list_handler* get_mark_list(const char* node_locator);
|
||||
|
||||
// iterate over all user marks
|
||||
mmdb_pos_t first();
|
||||
oid_t get_mark_oid(mmdb_pos_t& ind);
|
||||
void next(mmdb_pos_t& ind);
|
||||
|
||||
protected:
|
||||
|
||||
protected:
|
||||
cset_handler* mark_set_hd;
|
||||
|
||||
//a16 back compatible
|
||||
friend class user_mark_smart_ptr;
|
||||
|
||||
friend class mark_smart_ptr;
|
||||
friend class mark_hd;
|
||||
};
|
||||
|
||||
typedef mark_base* mark_basePtr;
|
||||
|
||||
|
||||
#endif
|
||||
563
cde/lib/DtMmdb/oliasdb/mark_test.C
Normal file
563
cde/lib/DtMmdb/oliasdb/mark_test.C
Normal file
@@ -0,0 +1,563 @@
|
||||
/*
|
||||
* CDE - Common Desktop Environment
|
||||
*
|
||||
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
|
||||
*
|
||||
* These libraries and programs are free software; you can
|
||||
* redistribute them and/or modify them under the terms of the GNU
|
||||
* Lesser General Public License as published by the Free Software
|
||||
* Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* These libraries and programs are distributed in the hope that
|
||||
* they will be useful, but WITHOUT ANY WARRANTY; without even the
|
||||
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU Lesser General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with these libraries and programs; if not, write
|
||||
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
|
||||
* Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
/* $XConsortium: mark_test.cc /main/5 1996/07/18 16:03:09 drk $ */
|
||||
|
||||
#ifdef REGRESSION_TEST
|
||||
|
||||
#include "mark_test.h"
|
||||
|
||||
void print_mark_list(mark_base* bptr, char* locator)
|
||||
{
|
||||
oid_list_handler* x = bptr -> get_mark_list(locator);
|
||||
|
||||
if ( x == 0 ) {
|
||||
MESSAGE(cerr, "empty oid_list");
|
||||
return ;
|
||||
}
|
||||
|
||||
int ind = (*x) -> first();
|
||||
|
||||
while (ind) {
|
||||
|
||||
oid_t id = (*x) -> operator()(ind);
|
||||
|
||||
if ( id.eq(ground) == false ) {
|
||||
mark_smart_ptr y(bptr, id);
|
||||
debug(cerr, y);
|
||||
}
|
||||
|
||||
(*x) -> next(ind);
|
||||
}
|
||||
}
|
||||
|
||||
mark_base* get_mark_base(char* path, char* name)
|
||||
{
|
||||
mark_base* ub = 0;
|
||||
|
||||
try {
|
||||
ub = new mark_base(
|
||||
path,
|
||||
name,
|
||||
"this marks",
|
||||
user_base::WRITE
|
||||
);
|
||||
}
|
||||
|
||||
catch (MMDBeXCEPtion &,e)
|
||||
{
|
||||
return 0;
|
||||
} end_try;
|
||||
|
||||
|
||||
if ( ub -> open_status() != user_base::SUCC ) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return ub;
|
||||
}
|
||||
|
||||
|
||||
void _get_id(istream& in, oid_t& x)
|
||||
{
|
||||
static char buf[LBUFSIZ];
|
||||
in.getline(buf, LBUFSIZ);
|
||||
|
||||
if ( buf[0] != 'k' || buf[1] != '\t' ) {
|
||||
debug(cerr, buf);
|
||||
throw(stringException("_get_id(): missing k\t"));
|
||||
}
|
||||
|
||||
char* key = buf+2;
|
||||
|
||||
oid_t id(key, true, false);
|
||||
|
||||
x = id;
|
||||
}
|
||||
|
||||
void _get_key(istream& in, char*& key)
|
||||
{
|
||||
static char buf[LBUFSIZ];
|
||||
in.getline(buf, LBUFSIZ);
|
||||
|
||||
if ( buf[0] != 'k' || buf[1] != '\t' ) {
|
||||
debug(cerr, buf);
|
||||
throw(stringException("_get_key(): missing k\t"));
|
||||
}
|
||||
|
||||
key = buf + 2;
|
||||
}
|
||||
|
||||
void _get_data(istream& in, char*& data)
|
||||
{
|
||||
static char buf[LBUFSIZ];
|
||||
in.getline(buf, LBUFSIZ);
|
||||
|
||||
if ( buf[0] != 'd' || buf[1] != '\t' ) {
|
||||
debug(cerr, buf);
|
||||
throw(stringException("_get_data(): missing d\t"));
|
||||
}
|
||||
|
||||
data = buf + 2;
|
||||
}
|
||||
|
||||
void _get_key_pos(istream& in, char*& key, int& n)
|
||||
{
|
||||
static char buf[LBUFSIZ];
|
||||
in.getline(buf, LBUFSIZ);
|
||||
|
||||
if ( buf[0] != 'k' || buf[1] != '\t' ) {
|
||||
debug(cerr, buf);
|
||||
throw(stringException("_get_key_pos(): missing k\t"));
|
||||
}
|
||||
|
||||
key = buf + 2;
|
||||
|
||||
char* nextToken = strchr(key, '\t');
|
||||
|
||||
if ( nextToken == 0 )
|
||||
throw(stringException("can't find position (integer)."));
|
||||
|
||||
*nextToken = 0;
|
||||
|
||||
n = atoi(nextToken+1);
|
||||
}
|
||||
|
||||
|
||||
oid_t get_nth_mark_id(mark_base* ub, char* key, int n)
|
||||
{
|
||||
oid_list_handler* handle = ub -> get_mark_list(key);
|
||||
|
||||
if ( handle == 0 ) {
|
||||
throw(stringException("empty mark list"));
|
||||
}
|
||||
|
||||
int ind = (*handle) -> first();
|
||||
|
||||
int i = 0;
|
||||
|
||||
while (ind) {
|
||||
|
||||
if ( n == i ) {
|
||||
oid_t id = (*handle) -> operator()(ind);
|
||||
delete handle;
|
||||
return id;
|
||||
}
|
||||
|
||||
(*handle) -> next(ind);
|
||||
i++;
|
||||
}
|
||||
|
||||
int count = (*handle)->count();
|
||||
delete handle;
|
||||
throw(boundaryException(0, count, i));
|
||||
}
|
||||
|
||||
|
||||
//////////////
|
||||
// create
|
||||
// k \t locator
|
||||
// d \t data
|
||||
//////////////
|
||||
int _create_subtest(char* buf, istream& in, mark_base* ub)
|
||||
{
|
||||
char* key, *data;
|
||||
mark_smart_ptr* x = 0;
|
||||
|
||||
if ( strcmp(buf, "create") == 0 ) {
|
||||
|
||||
cout << ">>> create:" << endl;
|
||||
|
||||
_get_key(in, key);
|
||||
_get_data(in, data);
|
||||
|
||||
cout << "---- new mark smtart_ptr ..." << endl;
|
||||
x = new mark_smart_ptr(ub, key);
|
||||
|
||||
cout << "---- updating ..." << endl;
|
||||
x -> update_usermark(data, strlen(data));
|
||||
delete x;
|
||||
cout << "<<< create:" << endl;
|
||||
} else
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
//////////////
|
||||
// get_by_key
|
||||
// k \t locator \t n
|
||||
//////////////
|
||||
_get_by_key_subtest(char* buf, istream& in, mark_base* ub)
|
||||
{
|
||||
char* key;
|
||||
int n;
|
||||
mark_smart_ptr* x = 0;
|
||||
|
||||
if ( strcmp(buf, "get_by_key") == 0 ) {
|
||||
cout << ">>> get_by_key:" << endl;
|
||||
|
||||
_get_key_pos(in, key, n);
|
||||
|
||||
oid_t id = get_nth_mark_id(ub, key, n);
|
||||
|
||||
x = new mark_smart_ptr(ub, id);
|
||||
|
||||
cout << x->node_locator();
|
||||
cout << "\n";
|
||||
cout << *(x->mark_value());
|
||||
cout << "\n";
|
||||
|
||||
delete x;
|
||||
|
||||
cout << "<<< get_by_key:" << endl;
|
||||
} else return 1;
|
||||
}
|
||||
|
||||
//////////////
|
||||
// get_by_oid
|
||||
// k \t oidInAscii
|
||||
//////////////
|
||||
_get_by_oid_subtest(char* buf, istream& in, mark_base* ub)
|
||||
{
|
||||
char* key;
|
||||
mark_smart_ptr* x = 0;
|
||||
if ( strcmp(buf, "get_by_oid") == 0 ) {
|
||||
|
||||
_get_key(in, key);
|
||||
|
||||
oid_t id(key, true, false);
|
||||
|
||||
x = new mark_smart_ptr(ub, id);
|
||||
|
||||
cout << x->node_locator();
|
||||
cout << "\n";
|
||||
cout << *(x->mark_value());
|
||||
cout << "\n";
|
||||
|
||||
delete x;
|
||||
|
||||
} else
|
||||
return 1;
|
||||
}
|
||||
|
||||
//////////////
|
||||
// show_for_a_locator
|
||||
// k \t locator
|
||||
//////////////
|
||||
_show_for_a_locator_subtest(char* buf, istream& in, mark_base* ub)
|
||||
{
|
||||
char* key;
|
||||
if ( strcmp(buf, "show_for_a_locator") == 0 ) {
|
||||
|
||||
cout << ">>> show_for_a_locator:" << endl;
|
||||
|
||||
_get_key(in, key);
|
||||
|
||||
oid_list_handler* z = ub-> get_mark_list(key);
|
||||
|
||||
if ( z == 0 )
|
||||
throw(stringException("empty oid_list"));
|
||||
|
||||
|
||||
int ind = (*z) -> first();
|
||||
|
||||
while (ind) {
|
||||
|
||||
oid_t id = (*z) -> operator()(ind);
|
||||
|
||||
|
||||
if ( id.eq(ground) == false ) {
|
||||
|
||||
mark_smart_ptr y(ub, id);
|
||||
cout << y.its_oid();
|
||||
cout << "\n";
|
||||
cout << y.node_locator();
|
||||
cout << "\n";
|
||||
cout << *(y.mark_value());
|
||||
cout << "\n";
|
||||
|
||||
}
|
||||
|
||||
(*z) -> next(ind);
|
||||
}
|
||||
|
||||
delete z;
|
||||
|
||||
cout << "<<< show_for_a_locator" << endl;
|
||||
|
||||
} else return 1;
|
||||
}
|
||||
|
||||
//////////////
|
||||
//show_all_marks_subtest
|
||||
//////////////
|
||||
_show_all_marks_subtest(char* buf, istream& in, mark_base* ub)
|
||||
{
|
||||
if ( strcmp(buf, "show_all_marks") == 0 ) {
|
||||
cout << ">>> show_all_marks" << endl;
|
||||
|
||||
mmdb_pos_t ind = ub -> first();
|
||||
while (ind) {
|
||||
oid_t id = ub -> get_mark_oid(ind);
|
||||
|
||||
if ( id.eq(ground) == false ) {
|
||||
|
||||
mark_smart_ptr y(ub, id);
|
||||
cout << y.its_oid();
|
||||
cout << "\n";
|
||||
cout << y.node_locator();
|
||||
cout << "\n";
|
||||
cout << *(y.mark_value());
|
||||
cout << "\n";
|
||||
|
||||
}
|
||||
|
||||
ub -> next(ind);
|
||||
}
|
||||
cout << "<<< show_all_marks." << endl;
|
||||
} else
|
||||
return 1;
|
||||
}
|
||||
|
||||
//////////////////////////////////////
|
||||
//////////////////////////////////////
|
||||
int _update_by_id_subtest(istream& in, oid_t id, mark_base* ub)
|
||||
{
|
||||
char* data;
|
||||
mark_smart_ptr* x = 0;
|
||||
_get_data(in, data);
|
||||
|
||||
x = new mark_smart_ptr(ub, id);
|
||||
|
||||
cout << x -> its_oid() << "\n";
|
||||
|
||||
x -> update_usermark(data, strlen(data));
|
||||
delete x;
|
||||
|
||||
x = new mark_smart_ptr(ub, id);
|
||||
|
||||
pstring* y = x->mark_value();
|
||||
|
||||
if ( y -> size() != strlen(data) || strcmp(y -> get(), data) != 0 )
|
||||
{
|
||||
debug(cerr, y->size());
|
||||
debug(cerr, (long)strlen(data));
|
||||
debug(cerr, y -> get());
|
||||
debug(cerr, data);
|
||||
throw(stringException("improperly updated mark"));
|
||||
|
||||
}
|
||||
|
||||
delete x;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//////////////
|
||||
// update_by_key
|
||||
// k \t locator \t n
|
||||
// d \t data
|
||||
//////////////
|
||||
_update_by_key_subtest(char* buf, istream& in, mark_base* ub)
|
||||
{
|
||||
char* key;
|
||||
int n;
|
||||
|
||||
if ( strcmp(buf, "update_by_key") == 0 ) {
|
||||
|
||||
cout << ">>> update_by_key" << endl;
|
||||
|
||||
_get_key_pos(in, key, n);
|
||||
|
||||
oid_t id = get_nth_mark_id(ub, key, n);
|
||||
|
||||
_update_by_id_subtest(in, id, ub);
|
||||
|
||||
cout << "<<< update_by_key" << endl;
|
||||
return 0;
|
||||
|
||||
} else
|
||||
return 1;
|
||||
}
|
||||
|
||||
////////////////////
|
||||
// update_by_id
|
||||
// k \t oid_tInAscii
|
||||
// d \t data
|
||||
////////////////////
|
||||
|
||||
_update_by_id_subtest(char* buf, istream& in, mark_base* ub)
|
||||
{
|
||||
if ( strcmp(buf, "update_by_id") == 0 ) {
|
||||
|
||||
cout << ">>> _update_by_id_subtest" << endl;
|
||||
|
||||
oid_t id;
|
||||
|
||||
_get_id(in, id);
|
||||
|
||||
_update_by_id_subtest(in, id, ub);
|
||||
|
||||
cout << "<<< _update_by_id_subtest" << endl;
|
||||
return 0;
|
||||
|
||||
} else
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
//////////////
|
||||
// delete_by_key
|
||||
// k \t locator \t n
|
||||
//////////////
|
||||
_delete_by_key_subtest(char* buf, istream& in, mark_base* ub)
|
||||
{
|
||||
mark_smart_ptr* x = 0;
|
||||
char* key; int n;
|
||||
if ( strcmp(buf, "delete_by_key") == 0 ) {
|
||||
|
||||
cout << ">>> _delete_by_key_subtest" << endl;
|
||||
|
||||
_get_key_pos(in, key, n);
|
||||
|
||||
oid_t id = get_nth_mark_id(ub, key, n);
|
||||
|
||||
x = new mark_smart_ptr(ub, id);
|
||||
|
||||
x -> remove_from_db();
|
||||
|
||||
delete x;
|
||||
|
||||
cout << "<<< _delete_by_key_subtest" << endl;
|
||||
|
||||
} else return 1;
|
||||
}
|
||||
|
||||
//////////////
|
||||
// delete_by_oid
|
||||
// k \t oidInAscii
|
||||
//////////////
|
||||
_delete_by_oid_subtest(char* buf, istream& in, mark_base* ub)
|
||||
{
|
||||
mark_smart_ptr* x = 0;
|
||||
if ( strcmp(buf, "delete_by_oid") == 0 ) {
|
||||
oid_t id;
|
||||
_get_id(in, id);
|
||||
|
||||
x = new mark_smart_ptr(ub, id);
|
||||
|
||||
x -> remove_from_db();
|
||||
|
||||
delete x;
|
||||
|
||||
} else return 1;
|
||||
}
|
||||
|
||||
int mark_test(int argc, char** argv)
|
||||
{
|
||||
int ok = 2;
|
||||
|
||||
if ( strcmp(argv[1], "create_mark_base") == 0 ) {
|
||||
if ( argc != 4 ) {
|
||||
MESSAGE(cerr, "args: create_mark_base path name");
|
||||
ok = -1;
|
||||
} else {
|
||||
|
||||
mark_base* ub = get_mark_base(argv[2], argv[3]);
|
||||
|
||||
if ( ub == 0 || ub -> open_status() != user_base::SUCC ) {
|
||||
ok = -1;
|
||||
} else {
|
||||
delete ub;
|
||||
ok = 0;
|
||||
}
|
||||
}
|
||||
} else
|
||||
|
||||
if ( strcmp(argv[1], "mark_comprehensive") == 0 ) {
|
||||
if ( argc != 5 ) {
|
||||
MESSAGE(cerr,
|
||||
"mark_comprehensive args: mark_comprehensive test_file path name");
|
||||
ok = -1;
|
||||
} else {
|
||||
|
||||
mark_base* ub = get_mark_base(argv[3], argv[4]);
|
||||
|
||||
if ( ub == 0 || ub -> open_status() != user_base::SUCC ) {
|
||||
ok = -1;
|
||||
} else {
|
||||
|
||||
|
||||
fstream in(argv[2], ios::in);
|
||||
|
||||
int i=1;
|
||||
char buf[LBUFSIZ];
|
||||
|
||||
while ( in.getline(buf, LBUFSIZ) ) {
|
||||
|
||||
if ( buf[0] == '#' )
|
||||
continue;
|
||||
|
||||
if ( _create_subtest(buf, in, ub) != 1 )
|
||||
continue;
|
||||
|
||||
if ( _get_by_key_subtest(buf, in, ub) != 1 )
|
||||
continue;
|
||||
|
||||
if ( _get_by_oid_subtest(buf, in, ub) != 1 )
|
||||
continue;
|
||||
|
||||
if ( _show_for_a_locator_subtest(buf, in, ub) != 1 )
|
||||
continue;
|
||||
|
||||
if ( _show_all_marks_subtest(buf, in, ub) != 1 )
|
||||
continue;
|
||||
|
||||
if ( _update_by_key_subtest(buf, in, ub) != 1 )
|
||||
continue;
|
||||
|
||||
if ( _update_by_id_subtest(buf, in, ub) != 1 )
|
||||
continue;
|
||||
|
||||
if ( _delete_by_key_subtest(buf, in, ub) != 1 )
|
||||
continue;
|
||||
|
||||
if ( _delete_by_oid_subtest(buf, in, ub) != 1 ) {
|
||||
debug(cerr, buf);
|
||||
throw(stringException("bad subtest command"));
|
||||
}
|
||||
|
||||
if ( i % 50 == 0 )
|
||||
MESSAGE(cerr, form("%d processed", i));
|
||||
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
delete ub;
|
||||
ok = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return ok;
|
||||
}
|
||||
#endif
|
||||
36
cde/lib/DtMmdb/oliasdb/mark_test.h
Normal file
36
cde/lib/DtMmdb/oliasdb/mark_test.h
Normal file
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* CDE - Common Desktop Environment
|
||||
*
|
||||
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
|
||||
*
|
||||
* These libraries and programs are free software; you can
|
||||
* redistribute them and/or modify them under the terms of the GNU
|
||||
* Lesser General Public License as published by the Free Software
|
||||
* Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* These libraries and programs are distributed in the hope that
|
||||
* they will be useful, but WITHOUT ANY WARRANTY; without even the
|
||||
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU Lesser General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with these libraries and programs; if not, write
|
||||
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
|
||||
* Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
/* $XConsortium: mark_test.h /main/5 1996/07/18 16:33:39 drk $ */
|
||||
|
||||
#ifdef REGRESSION_TEST
|
||||
|
||||
#ifndef _mark_test_h
|
||||
#define _mark_test_h
|
||||
|
||||
#include "oliasdb/mark.h"
|
||||
#include "oliasdb/mark_base.h"
|
||||
|
||||
int mark_test(int argc, char** argv);
|
||||
|
||||
#endif
|
||||
#endif
|
||||
266
cde/lib/DtMmdb/oliasdb/mmdb.C
Normal file
266
cde/lib/DtMmdb/oliasdb/mmdb.C
Normal file
@@ -0,0 +1,266 @@
|
||||
/*
|
||||
* CDE - Common Desktop Environment
|
||||
*
|
||||
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
|
||||
*
|
||||
* These libraries and programs are free software; you can
|
||||
* redistribute them and/or modify them under the terms of the GNU
|
||||
* Lesser General Public License as published by the Free Software
|
||||
* Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* These libraries and programs are distributed in the hope that
|
||||
* they will be useful, but WITHOUT ANY WARRANTY; without even the
|
||||
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU Lesser General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with these libraries and programs; if not, write
|
||||
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
|
||||
* Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
// $XConsortium: mmdb.C /main/7 1996/10/26 18:19:36 cde-hal $
|
||||
|
||||
#include "api/utility.h"
|
||||
#include "utility/db_version.h"
|
||||
#include "misc/unique_id.h"
|
||||
#include "oliasdb/olias_funcs.h"
|
||||
#include "oliasdb/collectionIterator.h"
|
||||
#include "oliasdb/mmdb.h"
|
||||
#include "mgrs/managers.h"
|
||||
#include "api/base.h" // for UIDSIZ define
|
||||
|
||||
OLIAS_DB::OLIAS_DB() : infolib_array(20)
|
||||
{
|
||||
//fprintf(stderr, "OLIAS_DB::OLIAS_DB()");
|
||||
managers::template_mgr -> insert_template(&dlp_template);
|
||||
managers::template_mgr -> insert_template(&doc_template);
|
||||
managers::template_mgr -> insert_template(&graphic_template);
|
||||
managers::template_mgr -> insert_template(&locator_template);
|
||||
managers::template_mgr -> insert_template(&node_template);
|
||||
managers::template_mgr -> insert_template(&toc_template);
|
||||
managers::template_mgr -> insert_template(&mark_template);
|
||||
//managers::template_mgr -> insert_template(&pref_template);
|
||||
managers::template_mgr -> insert_template(&stylesheet_template);
|
||||
|
||||
///////////////////////////////
|
||||
//
|
||||
///////////////////////////////
|
||||
|
||||
info_base_set_names = new charPtr[7];
|
||||
|
||||
info_base_set_names[0] = NODE_SET_NAME;
|
||||
info_base_set_names[1] = TOC_SET_NAME;
|
||||
info_base_set_names[2] = LOCATOR_SET_NAME;
|
||||
info_base_set_names[3] = GRAPHIC_SET_NAME,
|
||||
info_base_set_names[4] = DOC_SET_NAME;
|
||||
info_base_set_names[5] = STYLESHEET_SET_NAME;
|
||||
info_base_set_names[6] = 0;
|
||||
|
||||
info_base_list_names = new charPtr[2];
|
||||
info_base_list_names[0] = DLP_LIST_NAME;
|
||||
info_base_list_names[1] = 0;
|
||||
}
|
||||
|
||||
OLIAS_DB::~OLIAS_DB()
|
||||
{
|
||||
info_lib* x = 0;
|
||||
|
||||
for ( int i=0; i<infolib_array.no_elmts(); i++ ) {
|
||||
x = (info_lib*)(infolib_array)[i];
|
||||
delete x;
|
||||
}
|
||||
|
||||
delete [] info_base_set_names;
|
||||
delete [] info_base_list_names;
|
||||
}
|
||||
|
||||
int OLIAS_DB::validInfoLibPath(const char* path)
|
||||
{
|
||||
mtry
|
||||
{
|
||||
if ( exist_dir(path) == false )
|
||||
return 0;
|
||||
|
||||
if ( exist_file(MAP_FILE, path) == true )
|
||||
return 1;
|
||||
|
||||
if ( exist_file(MAP_FILE_8_3, path) == true )
|
||||
return 1;
|
||||
|
||||
}
|
||||
|
||||
mcatch (mmdbException &,e)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
end_try;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
info_lib*
|
||||
OLIAS_DB::openInfoLib(const char* infoLibPath, const char* selectedBaseName,
|
||||
const char* infoLibName)
|
||||
{
|
||||
int i;
|
||||
for ( i=0; i<infolib_array.no_elmts(); i++ ) {
|
||||
if ( infolib_array[i] == 0 )
|
||||
break;
|
||||
}
|
||||
|
||||
info_lib* x = new info_lib(
|
||||
info_base_set_names, info_base_list_names,
|
||||
(char*)infoLibPath, (char*)selectedBaseName,
|
||||
(char*)infoLibName, i
|
||||
);
|
||||
|
||||
|
||||
// see if infolib already exists in mmdb, if it does, just
|
||||
// return a pointer to it.
|
||||
int idx = 0;
|
||||
info_lib* y;
|
||||
|
||||
y = getInfoLib(x->get_info_lib_uid(), idx);
|
||||
if (y)
|
||||
{
|
||||
delete x;
|
||||
return y;
|
||||
}
|
||||
|
||||
infolib_array.insert(x, i);
|
||||
infolib_array.reset_elmts(i+1);
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
void OLIAS_DB::closeInfoLib(const char* infoLibUid)
|
||||
{
|
||||
int i = 0;
|
||||
info_lib* x = getInfoLib(infoLibUid, i);
|
||||
|
||||
if ( x ) {
|
||||
infolib_array.insert(0, i);
|
||||
delete x;
|
||||
}
|
||||
}
|
||||
|
||||
info_lib* OLIAS_DB::getInfoLib(int i)
|
||||
{
|
||||
if ( 0 <= i && i < infolib_array.no_elmts() )
|
||||
{
|
||||
return (info_lib*)infolib_array[i];
|
||||
} else
|
||||
return 0;
|
||||
}
|
||||
|
||||
info_lib* OLIAS_DB::getInfoLib(const char* infoLibUid, int& i)
|
||||
{
|
||||
info_lib* x = 0;
|
||||
for ( i=0; i<infolib_array.no_elmts(); i++ ) {
|
||||
x = (info_lib*)(infolib_array)[i];
|
||||
//if ( x && strcmp(x -> get_info_lib_name(), infoLibName) == 0 )
|
||||
if ( x && strcmp(x -> get_info_lib_uid(), infoLibUid) == 0 )
|
||||
return x;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
char* OLIAS_DB::getInfoLibUid(char* infoLibPath)
|
||||
{
|
||||
static char info_lib_uid[UIDSIZ];
|
||||
char info_lib_name[PATHSIZ];
|
||||
|
||||
if ( exist_file(MAP_FILE_8_3, infoLibPath) == true ) {
|
||||
fstream map_in(form("%s/%s", infoLibPath, MAP_FILE_8_3), ios::in);
|
||||
|
||||
if ( !map_in.getline(info_lib_name, PATHSIZ, '\t') ||
|
||||
!map_in.getline(info_lib_uid, UIDSIZ, '\n') )
|
||||
return 0;
|
||||
|
||||
return info_lib_uid;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Boolean
|
||||
OLIAS_DB::real_destroy_info_base(const char* info_lib_path, const char* base_name)
|
||||
{
|
||||
if ( unlink(form("%s/%s/%s.%s", info_lib_path, base_name, base_name, DATA_FILE_SUFFIX)) != 0 )
|
||||
return false;
|
||||
|
||||
if ( unlink(form("%s/%s/%s.%s", info_lib_path, base_name, base_name, INDEX_FILE_SUFFIX)) != 0 )
|
||||
return false;
|
||||
|
||||
if ( unlink(form("%s/%s/%s.%s", info_lib_path, base_name, base_name, SCHEMA_FILE_SUFFIX)) != 0 )
|
||||
return false;
|
||||
|
||||
if ( rmdir(form("%s/%s", info_lib_path, base_name)) != 0 )
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Boolean OLIAS_DB::real_destroy(const char* infoLibPath, const char* infoLibName)
|
||||
{
|
||||
// remove all infobases in the dir
|
||||
|
||||
char base_name[PATHSIZ];
|
||||
char base_desc[PATHSIZ];
|
||||
char buf[PATHSIZ];
|
||||
|
||||
int major_mm_version = 0;
|
||||
int minor_mm_version = 0;
|
||||
|
||||
snprintf(buf, sizeof(buf), "%s/%s", infoLibPath, MAP_FILE_8_3);
|
||||
fstream in(buf, ios::in);
|
||||
|
||||
while ( in.getline(base_name, PATHSIZ, '\t') ) {
|
||||
|
||||
in.getline(base_desc, PATHSIZ, '\t');
|
||||
|
||||
in >> major_mm_version >> minor_mm_version;
|
||||
|
||||
in.get();
|
||||
|
||||
if ( real_destroy_info_base(infoLibPath, base_name) != true )
|
||||
return false;
|
||||
}
|
||||
|
||||
// remove map file
|
||||
if ( unlink(buf) != 0 )
|
||||
return false;
|
||||
else
|
||||
return true;
|
||||
}
|
||||
|
||||
Boolean OLIAS_DB::destroy(const char* infoLibPath, const char* infoLibName)
|
||||
{
|
||||
int i = 0;
|
||||
if ( getInfoLib(infoLibName, i) ) {
|
||||
if ( infolib_array[i] )
|
||||
return false;
|
||||
|
||||
return real_destroy(infoLibPath, infoLibName);
|
||||
}
|
||||
|
||||
return real_destroy(infoLibPath, infoLibName);
|
||||
}
|
||||
|
||||
int OLIAS_DB::major_code_version()
|
||||
{
|
||||
return MAJOR;
|
||||
}
|
||||
|
||||
int OLIAS_DB::minor_code_version()
|
||||
{
|
||||
return MINOR;
|
||||
}
|
||||
|
||||
mm_version OLIAS_DB::code_version()
|
||||
{
|
||||
return mm_version(MAJOR, MINOR);
|
||||
}
|
||||
|
||||
100
cde/lib/DtMmdb/oliasdb/mmdb.h
Normal file
100
cde/lib/DtMmdb/oliasdb/mmdb.h
Normal file
@@ -0,0 +1,100 @@
|
||||
/*
|
||||
* CDE - Common Desktop Environment
|
||||
*
|
||||
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
|
||||
*
|
||||
* These libraries and programs are free software; you can
|
||||
* redistribute them and/or modify them under the terms of the GNU
|
||||
* Lesser General Public License as published by the Free Software
|
||||
* Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* These libraries and programs are distributed in the hope that
|
||||
* they will be useful, but WITHOUT ANY WARRANTY; without even the
|
||||
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU Lesser General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with these libraries and programs; if not, write
|
||||
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
|
||||
* Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
/* $XConsortium: mmdb.h /main/5 1996/10/26 18:19:50 cde-hal $ */
|
||||
|
||||
#ifndef _x_mmdb_h
|
||||
#define _x_mmdb_h
|
||||
|
||||
#include "api/info_lib.h"
|
||||
#include "mgrs/managers.h"
|
||||
#include "dstr/void_ptr_array.h"
|
||||
|
||||
#include "oliasdb/olias_consts.h"
|
||||
#include "oliasdb/node_hd.h"
|
||||
#include "oliasdb/graphic_hd.h"
|
||||
#include "oliasdb/toc_hd.h"
|
||||
#include "oliasdb/locator_hd.h"
|
||||
#include "oliasdb/doc_hd.h"
|
||||
#include "oliasdb/stylesheet_hd.h"
|
||||
#include "oliasdb/dlp_hd.h"
|
||||
#include "oliasdb/mark.h"
|
||||
|
||||
|
||||
class OLIAS_DB {
|
||||
|
||||
protected:
|
||||
char** info_base_set_names;
|
||||
char** info_base_list_names;
|
||||
|
||||
managers internal_managers; // this should be constructed before
|
||||
// the following objects!!!
|
||||
|
||||
dlp dlp_template;
|
||||
doc doc_template;
|
||||
graphic graphic_template;
|
||||
olias_locator locator_template;
|
||||
olias_node node_template;
|
||||
toc toc_template;
|
||||
umark mark_template;
|
||||
stylesheet stylesheet_template;
|
||||
|
||||
void_ptr_array infolib_array;
|
||||
|
||||
protected:
|
||||
Boolean
|
||||
real_destroy_info_base(const char* infoLibPath, const char* base_name);
|
||||
|
||||
Boolean real_destroy(const char* infoLibPath, const char* infoLibName);
|
||||
info_lib* getInfoLib(const char* infoLibUid, int& i);
|
||||
|
||||
public:
|
||||
OLIAS_DB();
|
||||
virtual ~OLIAS_DB();
|
||||
|
||||
info_lib* openInfoLib(const char* path = getenv("MMDB_PATH"),
|
||||
const char* selectedBookCaseName = 0,
|
||||
const char* infoLibName = "InfoLibrary"
|
||||
);
|
||||
// NOTE: default argument ("InfoLibrary") needs to be abandoned.
|
||||
void closeInfoLib(const char* infoLibUid = "InfoLibrary");
|
||||
info_lib* getInfoLib(int descriptor);
|
||||
|
||||
// complete remove file dir structure for the infolib
|
||||
// The action will be taken when the infolib is in closed state
|
||||
Boolean destroy(const char* infoLibPath, const char* infoLibName = "InfoLibrary");
|
||||
|
||||
// return 1 if path is a valid dir path and the directory contains
|
||||
// names.mmdb or bookcase.map file.
|
||||
int validInfoLibPath(const char* path);
|
||||
|
||||
int major_code_version();
|
||||
int minor_code_version();
|
||||
mm_version code_version();
|
||||
|
||||
int numItems() { return infolib_array.no_elmts(); }
|
||||
char* getInfoLibUid(char*);
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
153
cde/lib/DtMmdb/oliasdb/node_hd.C
Normal file
153
cde/lib/DtMmdb/oliasdb/node_hd.C
Normal file
@@ -0,0 +1,153 @@
|
||||
/*
|
||||
* CDE - Common Desktop Environment
|
||||
*
|
||||
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
|
||||
*
|
||||
* These libraries and programs are free software; you can
|
||||
* redistribute them and/or modify them under the terms of the GNU
|
||||
* Lesser General Public License as published by the Free Software
|
||||
* Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* These libraries and programs are distributed in the hope that
|
||||
* they will be useful, but WITHOUT ANY WARRANTY; without even the
|
||||
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU Lesser General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with these libraries and programs; if not, write
|
||||
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
|
||||
* Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
/*
|
||||
* $XConsortium: node_hd.C /main/5 1996/08/21 15:53:33 drk $
|
||||
*
|
||||
* Copyright (c) 1992 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 "oliasdb/node_hd.h"
|
||||
|
||||
#ifdef C_API
|
||||
#include "utility/c_stringstream.h"
|
||||
#else
|
||||
#include <sstream>
|
||||
using namespace std;
|
||||
#endif
|
||||
|
||||
MMDB_BODIES(olias_node)
|
||||
|
||||
node_smart_ptr::node_smart_ptr(info_lib* lib_ptr,
|
||||
const char* base_name,
|
||||
const char* locator) :
|
||||
smart_ptr(lib_ptr, base_name, NODE_SET_POS,
|
||||
managers::query_mgr -> form_pstring_handler(locator),
|
||||
BASE_COMPONENT_INDEX, smart_ptr::SET
|
||||
)
|
||||
{
|
||||
}
|
||||
|
||||
node_smart_ptr::node_smart_ptr(info_base* base_ptr,
|
||||
const char* locator) :
|
||||
smart_ptr(base_ptr, NODE_SET_POS,
|
||||
managers::query_mgr -> form_pstring_handler(locator),
|
||||
BASE_COMPONENT_INDEX, smart_ptr::SET
|
||||
)
|
||||
{
|
||||
}
|
||||
|
||||
node_smart_ptr::node_smart_ptr(info_lib* lib_ptr,
|
||||
const char* base_name, const oid_t& x):
|
||||
smart_ptr(
|
||||
lib_ptr -> get_info_base(base_name) -> get_set(NODE_SET_POS) -> its_store(),
|
||||
x
|
||||
)
|
||||
{
|
||||
}
|
||||
|
||||
node_smart_ptr::node_smart_ptr(info_base* base_ptr,
|
||||
const oid_t& x):
|
||||
smart_ptr(
|
||||
base_ptr -> get_set(NODE_SET_POS) -> its_store(),
|
||||
x
|
||||
)
|
||||
{
|
||||
}
|
||||
|
||||
/////////////////////////////////////////
|
||||
//
|
||||
//
|
||||
/////////////////////////////////////////
|
||||
const char* node_smart_ptr::locator()
|
||||
{
|
||||
return get_string(BASE_COMPONENT_INDEX);
|
||||
}
|
||||
|
||||
const char* node_smart_ptr::long_title()
|
||||
{
|
||||
return get_string(BASE_COMPONENT_INDEX+1);
|
||||
}
|
||||
|
||||
const char* node_smart_ptr::short_title()
|
||||
{
|
||||
return get_string(BASE_COMPONENT_INDEX+2);
|
||||
}
|
||||
|
||||
const char* node_smart_ptr::data()
|
||||
{
|
||||
return get_string(BASE_COMPONENT_INDEX+3);
|
||||
}
|
||||
|
||||
int node_smart_ptr::data_size()
|
||||
{
|
||||
return get_string_size(BASE_COMPONENT_INDEX+3);
|
||||
}
|
||||
|
||||
const char* node_smart_ptr::toc_node_loc()
|
||||
{
|
||||
return get_string(BASE_COMPONENT_INDEX+4);
|
||||
}
|
||||
|
||||
oid_t node_smart_ptr::doc_id()
|
||||
{
|
||||
return get_oid(BASE_COMPONENT_INDEX+5);
|
||||
}
|
||||
|
||||
oid_t node_smart_ptr::stylesheet_id()
|
||||
{
|
||||
return get_oid(BASE_COMPONENT_INDEX+6);
|
||||
}
|
||||
|
||||
|
||||
void node_smart_ptr::update_doc_id(const oid_t& x)
|
||||
{
|
||||
update_oid(BASE_COMPONENT_INDEX+5, x);
|
||||
}
|
||||
|
||||
Boolean node_smart_ptr::update_data(istream& in)
|
||||
{
|
||||
update_string(BASE_COMPONENT_INDEX+3, in);
|
||||
return true;
|
||||
}
|
||||
123
cde/lib/DtMmdb/oliasdb/node_hd.h
Normal file
123
cde/lib/DtMmdb/oliasdb/node_hd.h
Normal file
@@ -0,0 +1,123 @@
|
||||
/*
|
||||
* CDE - Common Desktop Environment
|
||||
*
|
||||
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
|
||||
*
|
||||
* These libraries and programs are free software; you can
|
||||
* redistribute them and/or modify them under the terms of the GNU
|
||||
* Lesser General Public License as published by the Free Software
|
||||
* Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* These libraries and programs are distributed in the hope that
|
||||
* they will be useful, but WITHOUT ANY WARRANTY; without even the
|
||||
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU Lesser General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with these libraries and programs; if not, write
|
||||
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
|
||||
* Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
/*
|
||||
* $XConsortium: node_hd.h /main/4 1996/06/11 17:29:56 cde-hal $
|
||||
*
|
||||
* Copyright (c) 1992 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 _node_hd_h
|
||||
#define _node_hd_h 1
|
||||
|
||||
#include "object/tuple.h"
|
||||
#include "object/pstring.h"
|
||||
#include "object/compressed_pstring.h"
|
||||
#include "object/oid.h"
|
||||
#include "oliasdb/olias_consts.h"
|
||||
#include "api/smart_ptr.h"
|
||||
|
||||
// A16 back compatible
|
||||
#ifdef A16_BROWSER
|
||||
#define long_title title
|
||||
#endif
|
||||
|
||||
/*************************************/
|
||||
// The node class
|
||||
/*************************************/
|
||||
|
||||
class olias_node : public mmdb_tuple
|
||||
{
|
||||
|
||||
public:
|
||||
olias_node() : mmdb_tuple(NUM_OLIAS_NODE_FIELDS, OLIAS_NODE_CODE) {};
|
||||
virtual ~olias_node() {};
|
||||
|
||||
MMDB_SIGNATURES(olias_node);
|
||||
|
||||
protected:
|
||||
};
|
||||
|
||||
typedef olias_node* nodePtr;
|
||||
|
||||
|
||||
|
||||
class node_smart_ptr : public smart_ptr
|
||||
{
|
||||
public:
|
||||
node_smart_ptr(info_lib* lib_ptr, const char* info_base_name, const char* locator);
|
||||
node_smart_ptr(info_base* base_ptr, const char* locator);
|
||||
|
||||
node_smart_ptr(info_lib* lib_ptr, const char* ibase_name, const oid_t& node_id);
|
||||
node_smart_ptr(info_base* ibase_ptr, const oid_t& node_id);
|
||||
virtual ~node_smart_ptr() {};
|
||||
|
||||
const char* locator();
|
||||
const char* long_title();
|
||||
const char* short_title();
|
||||
const char* data();
|
||||
int data_size();
|
||||
const char* toc_node_loc();
|
||||
oid_t doc_id();
|
||||
|
||||
oid_t stylesheet_id();
|
||||
//const char* stylesheet_name();
|
||||
|
||||
/////////////////////////////////////////////////////////////
|
||||
// this function (update_data()) is for clustering SGML data
|
||||
// portion to a set of centeralized pages
|
||||
/////////////////////////////////////////////////////////////
|
||||
Boolean update_data(istream&);
|
||||
|
||||
/////////////////////////////////////////////////////////////
|
||||
// this function is for update the doc id field so that
|
||||
// the node object can be loaded earlier than the doc object.
|
||||
/////////////////////////////////////////////////////////////
|
||||
void update_doc_id(const oid_t& doc_id);
|
||||
};
|
||||
|
||||
|
||||
typedef node_smart_ptr* node_smart_ptrPtr;
|
||||
|
||||
#endif
|
||||
207
cde/lib/DtMmdb/oliasdb/node_test.C
Normal file
207
cde/lib/DtMmdb/oliasdb/node_test.C
Normal file
@@ -0,0 +1,207 @@
|
||||
/*
|
||||
* CDE - Common Desktop Environment
|
||||
*
|
||||
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
|
||||
*
|
||||
* These libraries and programs are free software; you can
|
||||
* redistribute them and/or modify them under the terms of the GNU
|
||||
* Lesser General Public License as published by the Free Software
|
||||
* Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* These libraries and programs are distributed in the hope that
|
||||
* they will be useful, but WITHOUT ANY WARRANTY; without even the
|
||||
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU Lesser General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with these libraries and programs; if not, write
|
||||
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
|
||||
* Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
/* $XConsortium: node_test.cc /main/4 1996/07/18 16:03:28 drk $ */
|
||||
|
||||
#ifdef REGRESSION_TEST
|
||||
|
||||
#include "oliasdb/node_test.h"
|
||||
|
||||
#define LARGE_BUFSIZ 2048
|
||||
|
||||
void print_node(node_smart_ptr& x, ostream& out, Boolean get_data, Boolean get_doc_id)
|
||||
{
|
||||
out << "locator=" << x.locator() << "\n";
|
||||
out << "long_title=" << x.long_title() << "\n";
|
||||
out << "short_title=" << x.short_title() << "\n";
|
||||
|
||||
if ( get_data == true ) {
|
||||
out << "data_size=" << x.data_size() << "\n";
|
||||
out << "data=" << x.data() << "\n";
|
||||
}
|
||||
|
||||
out << "toc_node_loc=" << x.toc_node_loc() << "\n";
|
||||
|
||||
if ( get_data == true ) {
|
||||
out << "doc_id=" << x.doc_id() << "\n";
|
||||
}
|
||||
|
||||
out << "stylesheet_id=" << x.stylesheet_id() << "\n";
|
||||
}
|
||||
|
||||
int compare_node(node_smart_ptr& pattern, info_base* base_ptr)
|
||||
{
|
||||
char pattern_buf[LARGE_BUFSIZ];
|
||||
ostringstream pattern_out(pattern_buf, LARGE_BUFSIZ, ios::out);
|
||||
print_node(pattern, pattern_out, false, false);
|
||||
|
||||
char loc[BUFSIZ];
|
||||
int len = MIN(strlen(pattern.locator()), BUFSIZ - 1);
|
||||
*((char *) memcpy(loc, pattern.locator(), len) + len) = '\0';
|
||||
|
||||
node_smart_ptr x( base_ptr, loc );
|
||||
char db_buf[LARGE_BUFSIZ];
|
||||
ostringstream db_out(db_buf, LARGE_BUFSIZ, ios::out);
|
||||
print_node(x, db_out, false, false);
|
||||
|
||||
return compare_stream(pattern_out, db_out);
|
||||
}
|
||||
|
||||
|
||||
int compare_SGML_content(istream& in, info_base* base_ptr, Boolean doingTest)
|
||||
{
|
||||
int ok = 0;
|
||||
|
||||
int loc_size;
|
||||
char loc[BUFSIZ];
|
||||
in >> loc_size; in.get();
|
||||
|
||||
for ( int i=0; i<loc_size; i++ )
|
||||
loc[i] = (char)in.get();
|
||||
|
||||
loc[i] = 0;
|
||||
/*
|
||||
MESSAGE(cerr, "compare_SGML_content():");
|
||||
debug(cerr, loc);
|
||||
debug(cerr, loc_size);
|
||||
*/
|
||||
|
||||
in.get();
|
||||
|
||||
char* db_buf;
|
||||
int data_size ;
|
||||
ostringstream* db_out;
|
||||
|
||||
if ( doingTest ) {
|
||||
node_smart_ptr x( base_ptr, loc );
|
||||
data_size = x.data_size();
|
||||
|
||||
db_buf = new char[data_size+1];
|
||||
db_out = new ostringstream(db_buf, data_size+1, ios::out);
|
||||
|
||||
const char* z = x.data();
|
||||
for ( int i=0; i<data_size; i++ )
|
||||
db_out -> put(z[i]);
|
||||
}
|
||||
|
||||
in >> data_size; in.get();
|
||||
|
||||
char* pattern_buf = new char[data_size+1];
|
||||
ostringstream pattern_out(pattern_buf, data_size+1, ios::out);
|
||||
|
||||
for ( i=0; i<data_size; i++ )
|
||||
pattern_out.put((char)in.get());
|
||||
|
||||
in.get();
|
||||
|
||||
if ( doingTest ) {
|
||||
ok = compare_stream(pattern_out, *db_out);
|
||||
delete db_out;
|
||||
delete db_buf;
|
||||
}
|
||||
|
||||
delete pattern_buf;
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
int node_test_loc( info_lib* infolib_ptr, const char* base_name, const char* loc )
|
||||
{
|
||||
node_smart_ptr x( infolib_ptr, base_name, loc );
|
||||
|
||||
cerr << form("info of node with loc %s:\n", loc);
|
||||
x.its_oid().asciiOut(cerr); cerr << "\n";
|
||||
print_node(x, cerr, true, true);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int node_test_oid( info_lib* infolib_ptr, const char* base_name, const char* oid_str)
|
||||
{
|
||||
oid_t id((char*)oid_str, true, false);
|
||||
node_smart_ptr x( infolib_ptr, base_name, id );
|
||||
|
||||
cerr << form("info of node with oid string %s:\n", oid_str);
|
||||
print_node(x, cerr, true, true);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
1001
|
||||
7
|
||||
6
|
||||
15 y3THnmB0oYn87oL
|
||||
6
|
||||
19 Component Test Book
|
||||
6
|
||||
19 Component Test Book
|
||||
11
|
||||
503.16387
|
||||
0
|
||||
6
|
||||
15 y3THnmB0oYn87oL
|
||||
7
|
||||
0.0
|
||||
7
|
||||
1011.212994
|
||||
*/
|
||||
|
||||
void generate_node_instance(info_base* b_ptr, random_gen& x, ostream& out,
|
||||
ostream& mixed_out, int min_len, int max_len)
|
||||
{
|
||||
out << "1001\n";
|
||||
out << "7\n";
|
||||
|
||||
const char* loc = x.get_random_string(15, 15); // locator
|
||||
|
||||
out << "6\n15\t" << loc << "\n";
|
||||
|
||||
x.random_string(out, 10, 50); // short title
|
||||
x.random_string(out, 10, 100); // long title
|
||||
|
||||
//fprintf(stderr, "%d\n", (void*)(b_ptr -> get_base_name()));
|
||||
|
||||
handler * y = (b_ptr -> get_obj_dict()).get_handler(
|
||||
form("%s.%s", b_ptr -> get_base_name(), "sgml.dict")
|
||||
);
|
||||
|
||||
x.random_string_to_be_compressed(out, 0, 0, y -> its_oid()); // content
|
||||
x.random_string(out, 15, 15); // locator
|
||||
x.random_oid(out);
|
||||
x.random_oid(out);
|
||||
|
||||
mixed_out << "1010\n";
|
||||
mixed_out << "15\t" << loc << "\n"; // locator
|
||||
|
||||
x.random_string(mixed_out, min_len, max_len, false); // content
|
||||
}
|
||||
|
||||
/*
|
||||
void generate_sgml_instance(random_gen& x, ostream& out, int min_len, int max_len)
|
||||
{
|
||||
out << "1010\n";
|
||||
x.random_string(out, 15, 15); // locator
|
||||
x.random_string(out, min_len, max_len); // content
|
||||
}
|
||||
*/
|
||||
#endif
|
||||
44
cde/lib/DtMmdb/oliasdb/node_test.h
Normal file
44
cde/lib/DtMmdb/oliasdb/node_test.h
Normal file
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* CDE - Common Desktop Environment
|
||||
*
|
||||
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
|
||||
*
|
||||
* These libraries and programs are free software; you can
|
||||
* redistribute them and/or modify them under the terms of the GNU
|
||||
* Lesser General Public License as published by the Free Software
|
||||
* Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* These libraries and programs are distributed in the hope that
|
||||
* they will be useful, but WITHOUT ANY WARRANTY; without even the
|
||||
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU Lesser General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with these libraries and programs; if not, write
|
||||
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
|
||||
* Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
/* $XConsortium: node_test.h /main/4 1996/07/18 16:34:00 drk $ */
|
||||
|
||||
#ifdef REGRESSION_TEST
|
||||
|
||||
#ifndef _node_test_h
|
||||
#define _node_test_h
|
||||
|
||||
#include "oliasdb/node_hd.h"
|
||||
#include "object/random_gen.h"
|
||||
|
||||
|
||||
void print_node(node_smart_ptr& x, ostream& out, Boolean get_data, Boolean get_doc_id);
|
||||
|
||||
int compare_node(node_smart_ptr& pattern, info_base* base_ptr);
|
||||
int compare_SGML_content(istream& in, info_base* base_ptr, Boolean doing_test);
|
||||
void generate_node_instance(info_base*, random_gen&, ostream& out,
|
||||
ostream& mixed_out, int min_len, int max_len);
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
#endif
|
||||
115
cde/lib/DtMmdb/oliasdb/olias_consts.h
Normal file
115
cde/lib/DtMmdb/oliasdb/olias_consts.h
Normal file
@@ -0,0 +1,115 @@
|
||||
/*
|
||||
* CDE - Common Desktop Environment
|
||||
*
|
||||
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
|
||||
*
|
||||
* These libraries and programs are free software; you can
|
||||
* redistribute them and/or modify them under the terms of the GNU
|
||||
* Lesser General Public License as published by the Free Software
|
||||
* Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* These libraries and programs are distributed in the hope that
|
||||
* they will be useful, but WITHOUT ANY WARRANTY; without even the
|
||||
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU Lesser General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with these libraries and programs; if not, write
|
||||
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
|
||||
* Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
/*
|
||||
* $XConsortium: olias_consts.h /main/6 1996/10/26 18:19:11 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 _DTMMDB_OLIAS_CONSTS_HH_
|
||||
#define _DTMMDB_OLIAS_CONSTS_HH_
|
||||
|
||||
#define DOC_CODE 1000
|
||||
#define OLIAS_NODE_CODE 1001
|
||||
#define LOCATOR_CODE 1002
|
||||
#define TOC_CODE 1003
|
||||
#define DLP_CODE 1004
|
||||
#define GRAPHIC_CODE 1009
|
||||
#define SGML_CONTENT_CODE 1010
|
||||
#define STYLESHEET_CODE 1011
|
||||
#define XREF_CODE 1012
|
||||
|
||||
#define NUM_DOC_FIELDS 7
|
||||
#define NUM_OLIAS_NODE_FIELDS 7
|
||||
#define NUM_LOCATOR_FIELDS 3
|
||||
#define NUM_TOC_FIELDS 4
|
||||
#define NUM_GRAPHIC_FIELDS 6
|
||||
#define NUM_STYLESHEET_FIELDS 3
|
||||
|
||||
#define USER_MARK_CODE 1006
|
||||
#define USER_CONFIG_CODE 1007
|
||||
|
||||
#define DOC_SET_NAME (char*)"doc"
|
||||
#define NODE_SET_NAME (char*)"node"
|
||||
#define TOC_SET_NAME (char*)"toc"
|
||||
#define LOCATOR_SET_NAME (char*)"loc"
|
||||
#define GRAPHIC_SET_NAME (char*)"graphic"
|
||||
#define STYLESHEET_SET_NAME (char*)"stylesheet"
|
||||
|
||||
#define DLP_LIST_NAME (char*)"dlp"
|
||||
|
||||
#define USER_MARK_SET_NAME (char*)"mark"
|
||||
#define USER_CONFIG_SET_NAME (char*)"config"
|
||||
|
||||
#define MARK_SPEC (char*)"mmdb.mark.spec"
|
||||
#define PREF_SPEC (char*)"mmdb.pref.spec"
|
||||
|
||||
#define NODE_SET_POS 0
|
||||
#define TOC_SET_POS 1
|
||||
#define LOCATOR_SET_POS 2
|
||||
#define GRAPHIC_SET_POS 3
|
||||
#define DOC_SET_POS 4
|
||||
#define STYLESHEET_SET_POS 5
|
||||
|
||||
#define DLP_LIST_POS 0
|
||||
|
||||
#ifndef GRAPHIC_TYPE_ENUM
|
||||
#define GRAPHIC_TYPE_ENUM
|
||||
typedef enum {
|
||||
GR_TYPE_UNKNOWN,
|
||||
GR_TYPE_CGM,
|
||||
GR_TYPE_GIF,
|
||||
GR_TYPE_JPEG,
|
||||
GR_TYPE_PBM,
|
||||
GR_TYPE_PGM,
|
||||
GR_TYPE_POSTSCRIPT,
|
||||
GR_TYPE_PPM,
|
||||
GR_TYPE_TIFF,
|
||||
GR_TYPE_XBM,
|
||||
GR_TYPE_XPM,
|
||||
GR_TYPE_XWD
|
||||
} GR_TYPE;
|
||||
#endif
|
||||
|
||||
#endif
|
||||
306
cde/lib/DtMmdb/oliasdb/olias_funcs.C
Normal file
306
cde/lib/DtMmdb/oliasdb/olias_funcs.C
Normal file
@@ -0,0 +1,306 @@
|
||||
/*
|
||||
* CDE - Common Desktop Environment
|
||||
*
|
||||
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
|
||||
*
|
||||
* These libraries and programs are free software; you can
|
||||
* redistribute them and/or modify them under the terms of the GNU
|
||||
* Lesser General Public License as published by the Free Software
|
||||
* Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* These libraries and programs are distributed in the hope that
|
||||
* they will be useful, but WITHOUT ANY WARRANTY; without even the
|
||||
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU Lesser General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with these libraries and programs; if not, write
|
||||
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
|
||||
* Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
/*
|
||||
* $XConsortium: olias_funcs.cc /main/5 1996/07/18 14:48:42 drk $
|
||||
*
|
||||
* Copyright (c) 1992 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 "oliasdb/olias_funcs.h"
|
||||
#include "oliasdb/asciiIn_filters.h"
|
||||
#include "oliasdb/olias_consts.h"
|
||||
#include "oliasdb/node_hd.h"
|
||||
#include "oliasdb/doc_hd.h"
|
||||
#include "oliasdb/dlp_hd.h"
|
||||
|
||||
|
||||
/*
|
||||
#define BB_STRING "%%BoundingBox:"
|
||||
int bb_string_leng = strlen(BB_STRING);
|
||||
*/
|
||||
|
||||
|
||||
/////////////////////////////////////////////////
|
||||
// load sgml node data. This will cluster them.
|
||||
/////////////////////////////////////////////////
|
||||
|
||||
//extern char base_str[PATHSIZ];
|
||||
|
||||
struct map_record {
|
||||
char* col_name;
|
||||
c_code_t instance_class_code;
|
||||
handler* collection_hd;
|
||||
};
|
||||
|
||||
struct map_record set_map[]=
|
||||
{
|
||||
{(char*)"loc", LOCATOR_CODE, 0},
|
||||
{(char*)"toc", TOC_CODE, 0 },
|
||||
{(char*)"doc", DOC_CODE, 0 },
|
||||
{(char*)"graphic", GRAPHIC_CODE, 0 },
|
||||
// {(char*)"stylesheet", STYLESHEET_CODE, 0 },
|
||||
};
|
||||
|
||||
struct map_record list_map[]=
|
||||
{
|
||||
{(char*)"dlp", DLP_CODE, 0},
|
||||
};
|
||||
|
||||
//#define SET_MAP_SZ 5
|
||||
#define SET_MAP_SZ 4
|
||||
#define LIST_MAP_SZ 1
|
||||
|
||||
/////////////////////////////////////////////////
|
||||
// load mixed stream of infobase data from stdin.
|
||||
/////////////////////////////////////////////////
|
||||
void insert_to_collection(c_code_t ccode, istream& in)
|
||||
{
|
||||
enum coll_type { VOID, SET, LIST };
|
||||
|
||||
coll_type obj_type = VOID;
|
||||
|
||||
abs_storage* store = 0;
|
||||
// handler* hd = 0;
|
||||
|
||||
int i;
|
||||
for ( i = 0; i<SET_MAP_SZ ; i++ ) {
|
||||
if ( set_map[i].instance_class_code == ccode ) {
|
||||
obj_type = SET;
|
||||
store = set_map[i].collection_hd -> its_store();
|
||||
// hd = set_map[i].collection_hd;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ( obj_type == VOID )
|
||||
for ( i = 0; i<LIST_MAP_SZ ; i++ ) {
|
||||
if ( list_map[i].instance_class_code == ccode ) {
|
||||
obj_type = LIST;
|
||||
store = list_map[i].collection_hd -> its_store();
|
||||
// hd = set_map[i].collection_hd;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ( store == 0 ) {
|
||||
throw(stringException(form("unknown class code %d", ccode)));
|
||||
}
|
||||
|
||||
handler* root_hd_ptr = new handler(ccode, store);
|
||||
|
||||
(*root_hd_ptr) ->asciiIn(in);
|
||||
root_hd_ptr -> commit();
|
||||
|
||||
switch ( obj_type ) {
|
||||
case SET:
|
||||
(*(cset_handlerPtr)(set_map[i].collection_hd)) ->
|
||||
insert_object(*root_hd_ptr);
|
||||
break;
|
||||
case LIST:
|
||||
(*(dl_list_handlerPtr)(list_map[i].collection_hd)) ->
|
||||
insert_as_tail(*(dl_list_cell_handler*)root_hd_ptr);
|
||||
break;
|
||||
default:
|
||||
cerr << "bad ccode = " << ccode << "\n";
|
||||
throw(stringException("bad ccode"));
|
||||
}
|
||||
|
||||
delete root_hd_ptr;
|
||||
|
||||
}
|
||||
|
||||
static char locator[LBUFSIZ];
|
||||
|
||||
void sgml_content_load(info_base* x, istream& in)
|
||||
{
|
||||
in.getline(locator, LBUFSIZ);
|
||||
|
||||
char* locator_string = strchr(locator, '\t') + 1;
|
||||
if ( locator_string == (char*)1 )
|
||||
throw(formatException("bad sgml data format"));
|
||||
|
||||
node_smart_ptr y(x, locator_string);
|
||||
|
||||
if ( y.update_data(in) == false )
|
||||
throw(formatException("can't update sgml data"));
|
||||
|
||||
}
|
||||
|
||||
void _connectNodeToDoc(info_base* x_base);
|
||||
|
||||
int _load_mixed_objects_from_cin(info_base* base_ptr)
|
||||
{
|
||||
return _load_mixed_objects(base_ptr, cin);
|
||||
}
|
||||
|
||||
int _load_mixed_objects(info_base* base_ptr, istream& in)
|
||||
{
|
||||
int i;
|
||||
for ( i = 0; i<SET_MAP_SZ ; i++ ) {
|
||||
cset_handlerPtr x = base_ptr -> get_set(set_map[i].col_name);
|
||||
|
||||
if (x==0)
|
||||
throw(stringException("null cset_handler pointer"));
|
||||
|
||||
(*x) -> batch_index_begin();
|
||||
set_map[i].collection_hd = x;
|
||||
}
|
||||
|
||||
for ( i = 0; i<LIST_MAP_SZ ; i++ ) {
|
||||
dl_list_handlerPtr x = base_ptr -> get_list(list_map[i].col_name);
|
||||
|
||||
if (x==0)
|
||||
throw(stringException("null cset_handler pointer"));
|
||||
|
||||
(*x) -> batch_index_begin();
|
||||
list_map[i].collection_hd = x;
|
||||
}
|
||||
|
||||
|
||||
char ccode_buf[LBUFSIZ];
|
||||
int ccode;
|
||||
|
||||
while ( in.getline(ccode_buf, LBUFSIZ) ) {
|
||||
sscanf(ccode_buf, "%u", &ccode);
|
||||
//debug(cerr, ccode);
|
||||
|
||||
if ( ccode == SGML_CONTENT_CODE )
|
||||
sgml_content_load(base_ptr, in);
|
||||
else
|
||||
insert_to_collection(ccode, in);
|
||||
}
|
||||
|
||||
for ( i = 0; i<SET_MAP_SZ ; i++ ) {
|
||||
cset_handlerPtr x = (cset_handlerPtr)(set_map[i].collection_hd);
|
||||
(*x) -> batch_index_end();
|
||||
}
|
||||
|
||||
for ( i = 0; i<LIST_MAP_SZ ; i++ ) {
|
||||
dl_list_handlerPtr x = (dl_list_handlerPtr)(list_map[i].collection_hd);
|
||||
(*x) -> batch_index_end();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int load_mixed_objects_from_cin(info_base* base_ptr)
|
||||
{
|
||||
return load_mixed_objects(base_ptr, cin);
|
||||
}
|
||||
|
||||
int load_mixed_objects(info_base* base_ptr, istream& in)
|
||||
{
|
||||
_load_mixed_objects(base_ptr, in);
|
||||
_connectNodeToDoc(base_ptr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void _connectNodeToDoc(info_base* x_base)
|
||||
{
|
||||
int docs = x_base -> num_of_docs();
|
||||
|
||||
doc_smart_ptr* doc = 0;
|
||||
|
||||
node_smart_ptr* first_node = 0, *node = 0;
|
||||
dlp_smart_ptr* x = 0, *dlp_cell = 0;
|
||||
|
||||
for ( int i=0; i<docs; i++ ) {
|
||||
doc = new doc_smart_ptr(x_base, i+1);
|
||||
/*
|
||||
debug(cerr, doc -> its_oid());
|
||||
debug(cerr, doc -> long_title());
|
||||
*/
|
||||
|
||||
first_node = new node_smart_ptr(x_base, doc -> locator_id());
|
||||
|
||||
dlp_cell = new dlp_smart_ptr(x_base, first_node -> its_oid());
|
||||
|
||||
while ( dlp_cell ) {
|
||||
|
||||
|
||||
//debug(cerr, dlp_cell -> node_id());
|
||||
|
||||
node = new node_smart_ptr(x_base, dlp_cell -> node_id());
|
||||
//debug(cerr, node -> doc_id());
|
||||
node -> update_doc_id(doc -> its_oid());
|
||||
//debug(cerr, node -> doc_id());
|
||||
delete node;
|
||||
|
||||
x = dlp_cell -> next();
|
||||
|
||||
delete dlp_cell;
|
||||
|
||||
dlp_cell = x;
|
||||
}
|
||||
|
||||
delete doc;
|
||||
delete first_node;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void connectNodeToDoc(info_lib* x_lib)
|
||||
{
|
||||
if ( x_lib == 0 )
|
||||
throw(stringException("connectNodeToDoc: can't find infolib"));
|
||||
|
||||
info_base* x_base = 0;
|
||||
|
||||
long ind = x_lib -> first();
|
||||
|
||||
while ( ind ) {
|
||||
x_base = (*x_lib)(ind);
|
||||
|
||||
if ( x_base == 0 )
|
||||
throw(stringException("connectNodeToDoc: null base pointer"));
|
||||
|
||||
_connectNodeToDoc(x_base);
|
||||
|
||||
x_lib -> next(ind);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
66
cde/lib/DtMmdb/oliasdb/olias_funcs.h
Normal file
66
cde/lib/DtMmdb/oliasdb/olias_funcs.h
Normal file
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* CDE - Common Desktop Environment
|
||||
*
|
||||
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
|
||||
*
|
||||
* These libraries and programs are free software; you can
|
||||
* redistribute them and/or modify them under the terms of the GNU
|
||||
* Lesser General Public License as published by the Free Software
|
||||
* Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* These libraries and programs are distributed in the hope that
|
||||
* they will be useful, but WITHOUT ANY WARRANTY; without even the
|
||||
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU Lesser General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with these libraries and programs; if not, write
|
||||
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
|
||||
* Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
/*
|
||||
* $XConsortium: olias_funcs.h /main/4 1996/06/11 17:30:12 cde-hal $
|
||||
*
|
||||
* Copyright (c) 1992 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 _olias_funcs_h
|
||||
#define _olias_funcs_h 1
|
||||
|
||||
#include "api/info_lib.h"
|
||||
|
||||
// without calling connectNodeToDoc().
|
||||
int _load_mixed_objects_from_cin(info_base*);
|
||||
int _load_mixed_objects(info_base*, istream&);
|
||||
|
||||
// calling connectNodeToDoc().
|
||||
int load_mixed_objects_from_cin(info_base*);
|
||||
int load_mixed_objects(info_base*, istream&);
|
||||
|
||||
void connectNodeToDoc(info_lib*); // update doc id fields in all node objects
|
||||
|
||||
#endif
|
||||
275
cde/lib/DtMmdb/oliasdb/olias_server.C
Normal file
275
cde/lib/DtMmdb/oliasdb/olias_server.C
Normal file
@@ -0,0 +1,275 @@
|
||||
/*
|
||||
* CDE - Common Desktop Environment
|
||||
*
|
||||
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
|
||||
*
|
||||
* These libraries and programs are free software; you can
|
||||
* redistribute them and/or modify them under the terms of the GNU
|
||||
* Lesser General Public License as published by the Free Software
|
||||
* Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* These libraries and programs are distributed in the hope that
|
||||
* they will be useful, but WITHOUT ANY WARRANTY; without even the
|
||||
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU Lesser General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with these libraries and programs; if not, write
|
||||
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
|
||||
* Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
// $XConsortium: olias_server.cc /main/3 1996/06/11 17:30:16 cde-hal $
|
||||
/* Copyright (c) 1994 FUJITSU LIMITED */
|
||||
/* All Rights Reserved */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1992 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 "oliasdb/olias_server.h"
|
||||
|
||||
#ifdef DEMO_VERSION
|
||||
void demo_version_check(info_lib* infolibptr)
|
||||
{
|
||||
#if 1
|
||||
return;
|
||||
#else
|
||||
static char* demo_key = "DBzjcy94aK";
|
||||
static char* demo_short_title = "02192ec285a9349ae85e3cc7";
|
||||
static char* demo_long_title = "1e87fe1d9c927e9e24be85e3cc733598faeda88101ecb253";
|
||||
|
||||
if ( infolibptr == 0 )
|
||||
return;
|
||||
|
||||
info_base* x = 0;
|
||||
int i = infolibptr -> first();
|
||||
|
||||
while ( i != 0 ) {
|
||||
x = (*infolibptr)(i);
|
||||
|
||||
if ( x && (*(x -> get_set(NODE_SET_POS))) -> count() > 0 )
|
||||
{
|
||||
|
||||
node_smart_ptr n(x, demo_key);
|
||||
|
||||
if ( strcmp(n.locator(), demo_key) != 0 ||
|
||||
strcmp(n.short_title(), demo_short_title) != 0 ||
|
||||
strcmp(n.long_title(), demo_long_title) != 0
|
||||
) {
|
||||
debug(cerr, n.locator());
|
||||
debug(cerr, n.short_title());
|
||||
debug(cerr, n.long_title());
|
||||
throw(demoException(x -> get_base_path(), x -> get_base_name()));
|
||||
}
|
||||
}
|
||||
|
||||
infolibptr -> next(i);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
olias_server::olias_server(
|
||||
Boolean delayed_infolib_init,
|
||||
char* selected_base_name,
|
||||
char* x_info_lib_path
|
||||
) :
|
||||
server(x_info_lib_path)
|
||||
{
|
||||
managers::template_mgr -> insert_template(&dlp_template);
|
||||
managers::template_mgr -> insert_template(&doc_template);
|
||||
managers::template_mgr -> insert_template(&graphic_template);
|
||||
managers::template_mgr -> insert_template(&locator_template);
|
||||
managers::template_mgr -> insert_template(&node_template);
|
||||
managers::template_mgr -> insert_template(&toc_template);
|
||||
managers::template_mgr -> insert_template(&mark_template);
|
||||
managers::template_mgr -> insert_template(&pref_template);
|
||||
managers::template_mgr -> insert_template(&stylesheet_template);
|
||||
|
||||
///////////////////////////////
|
||||
//
|
||||
///////////////////////////////
|
||||
|
||||
info_base_set_names = new charPtr[7];
|
||||
|
||||
info_base_set_names[0] = NODE_SET_NAME;
|
||||
info_base_set_names[1] = TOC_SET_NAME;
|
||||
info_base_set_names[2] = LOCATOR_SET_NAME;
|
||||
info_base_set_names[3] = GRAPHIC_SET_NAME,
|
||||
info_base_set_names[4] = DOC_SET_NAME;
|
||||
info_base_set_names[5] = STYLESHEET_SET_NAME;
|
||||
info_base_set_names[6] = 0;
|
||||
|
||||
info_base_list_names = new charPtr[2];
|
||||
info_base_list_names[0] = DLP_LIST_NAME;
|
||||
info_base_list_names[1] = 0;
|
||||
|
||||
if ( delayed_infolib_init == false ) {
|
||||
infolibptr = new info_lib(
|
||||
info_base_set_names, info_base_list_names,
|
||||
info_lib_dir, selected_base_name
|
||||
);
|
||||
|
||||
#ifdef DEMO_VERSION
|
||||
demo_version_check(infolibptr);
|
||||
#endif
|
||||
|
||||
} else
|
||||
infolibptr = 0;
|
||||
|
||||
}
|
||||
|
||||
olias_server::~olias_server()
|
||||
{
|
||||
}
|
||||
|
||||
void olias_server::init_infolib()
|
||||
{
|
||||
if ( infolibptr == 0 ) {
|
||||
infolibptr = new info_lib(
|
||||
info_base_set_names, info_base_list_names,
|
||||
info_lib_dir, 0);
|
||||
|
||||
#ifdef DEMO_VERSION
|
||||
demo_version_check(infolibptr);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
info_base* olias_server::get_infobase(const char *locator_string, enum TestSelector sel)
|
||||
{
|
||||
|
||||
if ( locator_string == 0 )
|
||||
return 0;
|
||||
|
||||
|
||||
info_base* ib = 0;
|
||||
|
||||
int ind = infolibptr -> first();
|
||||
|
||||
while ( ind ) {
|
||||
|
||||
ib = (*infolibptr)(ind);
|
||||
|
||||
if (ib==0)
|
||||
throw(stringException("null info_base ptr"));
|
||||
|
||||
try { // since an infobase may not have any graphics, we catch
|
||||
// any exceptions there and try next infobase.
|
||||
|
||||
switch (sel) {
|
||||
case LOC:
|
||||
{
|
||||
locator_smart_ptr loc(ib, locator_string);
|
||||
|
||||
//fprintf(stderr, "inside-loc-string=%s\n", loc.inside_node_locator_str());
|
||||
//fprintf(stderr, "loc-string=%s\n", locator_string);
|
||||
if ( strcmp( loc.inside_node_locator_str(), locator_string) == 0 ) {
|
||||
return ib;
|
||||
}
|
||||
|
||||
}
|
||||
case GRA:
|
||||
{
|
||||
graphic_smart_ptr graphic(ib, locator_string);
|
||||
|
||||
if ( strcmp( graphic.locator(), locator_string) == 0 ) {
|
||||
return ib;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
catch (mmdbException &,e)
|
||||
{
|
||||
} end_try;
|
||||
|
||||
|
||||
infolibptr -> next(ind);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
info_base** olias_server::get_infobases(char **locator_strings, int count, enum TestSelector sel)
|
||||
{
|
||||
info_base** ibs = new info_basePtr[count];
|
||||
for ( int i=0; i<count; ibs[i++] = 0 );
|
||||
|
||||
info_base* ib = 0;
|
||||
|
||||
int ind = infolibptr -> first();
|
||||
|
||||
while ( ind ) {
|
||||
|
||||
ib = (*infolibptr)(ind);
|
||||
|
||||
if (ib == 0)
|
||||
throw(stringException("null info_base ptr"));
|
||||
|
||||
for ( i=0; i<count; i++ ) {
|
||||
|
||||
try {
|
||||
|
||||
if ( locator_strings[i] && ibs[i] == 0 ) {
|
||||
switch (sel) {
|
||||
case LOC:
|
||||
{
|
||||
locator_smart_ptr loc(ib, locator_strings[i]);
|
||||
|
||||
if ( strcmp( loc.inside_node_locator_str(),
|
||||
locator_strings[i]) == 0
|
||||
)
|
||||
ibs[i] = ib;
|
||||
}
|
||||
break;
|
||||
|
||||
case GRA:
|
||||
{
|
||||
graphic_smart_ptr graphic(ib, locator_strings[i]);
|
||||
|
||||
if ( strcmp( graphic.locator(),
|
||||
locator_strings[i]) == 0
|
||||
)
|
||||
ibs[i] = ib;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
catch (mmdbException &,e)
|
||||
{
|
||||
} end_try;
|
||||
|
||||
}
|
||||
|
||||
infolibptr -> next(ind);
|
||||
}
|
||||
|
||||
return ibs;
|
||||
}
|
||||
|
||||
102
cde/lib/DtMmdb/oliasdb/olias_server.h
Normal file
102
cde/lib/DtMmdb/oliasdb/olias_server.h
Normal file
@@ -0,0 +1,102 @@
|
||||
/*
|
||||
* CDE - Common Desktop Environment
|
||||
*
|
||||
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
|
||||
*
|
||||
* These libraries and programs are free software; you can
|
||||
* redistribute them and/or modify them under the terms of the GNU
|
||||
* Lesser General Public License as published by the Free Software
|
||||
* Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* These libraries and programs are distributed in the hope that
|
||||
* they will be useful, but WITHOUT ANY WARRANTY; without even the
|
||||
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU Lesser General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with these libraries and programs; if not, write
|
||||
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
|
||||
* Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
/*
|
||||
* $XConsortium: olias_server.h /main/3 1996/06/11 17:30:21 cde-hal $
|
||||
*
|
||||
* Copyright (c) 1992 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 _olias_server_h
|
||||
#define _olias_server_h 1
|
||||
|
||||
#include "oliasdb/dlp_hd.h"
|
||||
#include "oliasdb/doc_hd.h"
|
||||
#include "oliasdb/graphic_hd.h"
|
||||
#include "oliasdb/locator_hd.h"
|
||||
#include "oliasdb/node_hd.h"
|
||||
#include "oliasdb/toc_hd.h"
|
||||
#include "oliasdb/stylesheet_hd.h"
|
||||
#include "api/info_lib.h"
|
||||
#include "api/info_base.h"
|
||||
#include "api/server.h"
|
||||
|
||||
#include "oliasdb/user_base.h"
|
||||
#include "oliasdb/mark.h"
|
||||
#include "oliasdb/pref.h"
|
||||
|
||||
|
||||
class olias_server : public server
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
enum TestSelector { LOC, GRA };
|
||||
olias_server(
|
||||
Boolean delayed_infolib_init = false,
|
||||
char* selected_base_name = 0,
|
||||
char* x_info_lib_path = getenv("MMDB_PATH")
|
||||
);
|
||||
~olias_server();
|
||||
|
||||
void init_infolib();
|
||||
|
||||
info_base* get_infobase(const char *locator_string, enum TestSelector = LOC);
|
||||
info_base** get_infobases(char **locator_strings, int count, enum TestSelector = LOC);
|
||||
|
||||
protected:
|
||||
dlp dlp_template;
|
||||
doc doc_template;
|
||||
graphic graphic_template;
|
||||
olias_locator locator_template;
|
||||
olias_node node_template;
|
||||
toc toc_template;
|
||||
umark mark_template;
|
||||
pref pref_template;
|
||||
stylesheet stylesheet_template;
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
755
cde/lib/DtMmdb/oliasdb/olias_test.C
Normal file
755
cde/lib/DtMmdb/oliasdb/olias_test.C
Normal file
@@ -0,0 +1,755 @@
|
||||
/*
|
||||
* CDE - Common Desktop Environment
|
||||
*
|
||||
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
|
||||
*
|
||||
* These libraries and programs are free software; you can
|
||||
* redistribute them and/or modify them under the terms of the GNU
|
||||
* Lesser General Public License as published by the Free Software
|
||||
* Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* These libraries and programs are distributed in the hope that
|
||||
* they will be useful, but WITHOUT ANY WARRANTY; without even the
|
||||
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU Lesser General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with these libraries and programs; if not, write
|
||||
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
|
||||
* Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
/*
|
||||
* $XConsortium: olias_test.C /main/8 1996/10/26 18:20:03 cde-hal $
|
||||
*
|
||||
* Copyright (c) 1992 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 "oliasdb/olias_test.h"
|
||||
#include "api/utility.h"
|
||||
#include "utility/pm_random.h"
|
||||
#include "misc/unique_id.h"
|
||||
#include "storage/vm_storage.h"
|
||||
#include "dstr/dstr_test.h"
|
||||
#include "storage/store_test.h"
|
||||
#include "oliasdb/olias_funcs.h"
|
||||
|
||||
#include "object/random_gen.h"
|
||||
|
||||
#ifdef REGRESSION_TEST
|
||||
|
||||
#include "oliasdb/graphic_test.h"
|
||||
#include "oliasdb/loc_test.h"
|
||||
#include "oliasdb/stylesheet_test.h"
|
||||
#include "oliasdb/dlp_test.h"
|
||||
#include "oliasdb/mark_test.h"
|
||||
#include "oliasdb/toc_test.h"
|
||||
#include "oliasdb/doc_test.h"
|
||||
#include "oliasdb/node_test.h"
|
||||
|
||||
#endif
|
||||
|
||||
#include "oliasdb/collectionIterator.h"
|
||||
#include "oliasdb/mmdb.h"
|
||||
|
||||
|
||||
#ifdef NODEBUG
|
||||
void test_collector_iterator(info_base* base)
|
||||
{
|
||||
MESSAGE(cerr, "node locators:");
|
||||
nodeCollectionIterator x(base);
|
||||
|
||||
while ( ++x ) {
|
||||
debug(cerr, x.get_locator());
|
||||
}
|
||||
|
||||
MESSAGE(cerr, "stylesheet locators:");
|
||||
|
||||
stylesheetCollectionIterator y(base);
|
||||
|
||||
while ( ++y ) {
|
||||
debug(cerr, y.get_locator());
|
||||
}
|
||||
|
||||
MESSAGE(cerr, "locator set locators:");
|
||||
|
||||
locatorCollectionIterator z(base);
|
||||
|
||||
while ( ++z ) {
|
||||
debug(cerr, z.get_locator());
|
||||
}
|
||||
}
|
||||
|
||||
int dump_instances(info_base* base_ptr, char* col_nm, c_code_t ins_code)
|
||||
{
|
||||
if ( base_ptr == 0 )
|
||||
throw(stringException("null base ptr"));
|
||||
|
||||
Iterator *it = base_ptr -> first(col_nm, ins_code);
|
||||
|
||||
if (it==0)
|
||||
throw(stringException("null iterator pointer"));
|
||||
|
||||
int i = 0;
|
||||
|
||||
while ( *it ) {
|
||||
oid_t id = base_ptr -> get_oid(*it);
|
||||
|
||||
if ( strcmp(col_nm, NODE_SET_NAME) == 0 ) {
|
||||
i++;
|
||||
node_smart_ptr x(base_ptr, id);
|
||||
cout << x.data();
|
||||
//debug(cerr, x.long_title());
|
||||
} else
|
||||
if ( strcmp(col_nm, LOCATOR_SET_NAME) == 0 ) {
|
||||
i++;
|
||||
locator_smart_ptr x(base_ptr, id);
|
||||
cout << x.inside_node_locator_str() << "\n";
|
||||
}
|
||||
if ( strcmp(col_nm, GRAPHIC_SET_NAME) == 0 ) {
|
||||
i++;
|
||||
graphic_smart_ptr x(base_ptr, id);
|
||||
|
||||
if ( x.type() == 3 ) {
|
||||
const char* ps_str = x.data();
|
||||
cout << "\n";
|
||||
cout << "\n";
|
||||
cout << x.data_size() << "\t";
|
||||
for ( int j=0; j<x.data_size(); j++ )
|
||||
cout << ps_str[j];
|
||||
|
||||
cout << "\n";
|
||||
}
|
||||
}
|
||||
|
||||
base_ptr -> next(*it);
|
||||
}
|
||||
debug(cerr, i);
|
||||
|
||||
delete it;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int cache_test( info_lib* infolib_ptr, const char* base_name, int argc, char** argv )
|
||||
{
|
||||
locator_smart_ptrPtr* ptr_array = new locator_smart_ptrPtr[argc];
|
||||
debug(cerr, argc);
|
||||
|
||||
int i;
|
||||
for ( i=0; i<argc; i++ ) {
|
||||
ptr_array[i] = new locator_smart_ptr(infolib_ptr, base_name, argv[i]);
|
||||
|
||||
cerr << form("node_id of locator %s:\n", argv[i]);
|
||||
ptr_array[i] -> node_id().asciiOut(cerr); cerr << "\n";
|
||||
//debug(cerr, ptr_array[i] -> vcc_num());
|
||||
cerr << "\n";
|
||||
}
|
||||
|
||||
for ( i=0; i<argc; i++ ) {
|
||||
delete ptr_array[i];
|
||||
}
|
||||
delete ptr_array;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void dump_node_ids(info_base* x_base)
|
||||
{
|
||||
if ( x_base == 0 )
|
||||
return;
|
||||
|
||||
int docs = x_base -> num_of_docs();
|
||||
|
||||
doc_smart_ptr* doc = 0;
|
||||
|
||||
node_smart_ptr* first_node = 0, *node = 0;
|
||||
dlp_smart_ptr* x = 0, *dlp_cell = 0;
|
||||
|
||||
for ( int i=0; i<docs; i++ ) {
|
||||
doc = new doc_smart_ptr(x_base, i+1);
|
||||
|
||||
debug(cerr, doc -> long_title());
|
||||
|
||||
first_node = new node_smart_ptr(x_base, doc -> locator_id());
|
||||
|
||||
dlp_cell = new dlp_smart_ptr(x_base, first_node -> its_oid());
|
||||
|
||||
while ( dlp_cell ) {
|
||||
|
||||
debug(cerr, dlp_cell -> node_id());
|
||||
|
||||
x = dlp_cell -> next();
|
||||
|
||||
delete dlp_cell;
|
||||
|
||||
dlp_cell = x;
|
||||
}
|
||||
|
||||
delete doc;
|
||||
delete first_node;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef REGRESSION_TEST
|
||||
|
||||
#define TEST_STY_FILE "test.sty"
|
||||
#define TEST_SEC_FILE "test.sec"
|
||||
#define TEST_MIX_FILE "test.mix"
|
||||
|
||||
int generate_stream(info_base* b_ptr, char* path, int num_sections, int min, int max)
|
||||
{
|
||||
random_gen x;
|
||||
|
||||
if ( check_and_create_dir(path) == false )
|
||||
return -1;
|
||||
|
||||
// generate stylesheet stream
|
||||
|
||||
cerr << " stylesheets ..." << endl;
|
||||
int stylesheets = x.pick_a_value(5, 20); // assume [5, 20] is the range
|
||||
|
||||
char buf[BUFSIZ];
|
||||
snprintf(buf, sizeof(buf), "%s/%s", path, TEST_STY_FILE);
|
||||
fstream stylesheet_stream(buf, ios::out);
|
||||
|
||||
if ( !stylesheet_stream )
|
||||
return -1;
|
||||
|
||||
int i;
|
||||
for (i=0; i<stylesheets; i++ ) {
|
||||
// assume the stylesheet and section are of approx. length
|
||||
generate_stylesheet_instance(x, stylesheet_stream, min, max);
|
||||
}
|
||||
|
||||
// generate section stream
|
||||
|
||||
cerr << " sections ..." << endl;
|
||||
|
||||
snprintf(buf, sizeof(buf), "%s/%s", path, TEST_SEC_FILE);
|
||||
fstream section_stream(buf, ios::out);
|
||||
|
||||
if ( !section_stream ) return -1;
|
||||
|
||||
|
||||
// prepare mixed stream
|
||||
snprintf(buf, sizeof(buf), "%s/%s", path, TEST_MIX_FILE);
|
||||
fstream mix_stream(buf, ios::out);
|
||||
|
||||
if ( !mix_stream ) return -1;
|
||||
|
||||
for (i=0; i<num_sections; i++ )
|
||||
generate_node_instance(b_ptr, x, section_stream, mix_stream, min, max);
|
||||
|
||||
// generate mixed stream
|
||||
cerr << " docs ..." << endl;
|
||||
|
||||
// doc
|
||||
int docs = x.pick_a_value(num_sections/4, num_sections/2);
|
||||
for (i=0; i<docs; i++ ) {
|
||||
// [docs/10, docs] is for the number of tab sections
|
||||
//generate_doc_instance(x, mix_stream, i+1, docs/10, docs);
|
||||
generate_doc_instance(x, mix_stream, i+1, 1, 10);
|
||||
}
|
||||
|
||||
// toc
|
||||
cerr << " tocs ..." << endl;
|
||||
int tocs = docs;
|
||||
for (i=0; i<tocs; i++ ) {
|
||||
// [0, num_sections/10] is for the branch factor
|
||||
generate_toc_instance(x, mix_stream, i, 0, num_sections/10);
|
||||
}
|
||||
|
||||
// sgml
|
||||
|
||||
// graphic
|
||||
cerr << " graphics ..." << endl;
|
||||
int graphics = x.pick_a_value(num_sections/2, 2*num_sections);
|
||||
for (i=0; i<graphics; i++ )
|
||||
generate_graphic_instance(b_ptr, x, mix_stream, min, max);
|
||||
|
||||
// locators
|
||||
cerr << " locators ..." << endl;
|
||||
int locs = x.pick_a_value(num_sections, num_sections*5);
|
||||
for (i=0; i<locs; i++ )
|
||||
generate_loc_instance(x, mix_stream);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int destroy_stream(char* path)
|
||||
{
|
||||
mtry {
|
||||
del_file(TEST_STY_FILE, path);
|
||||
del_file(TEST_SEC_FILE, path);
|
||||
del_file(TEST_MIX_FILE, path);
|
||||
}
|
||||
mcatch_any()
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
end_try;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int extract_and_compare_objects(istream& in, info_base* base_ptr, int code)
|
||||
{
|
||||
int ok = 0;
|
||||
|
||||
handler* root_hd_ptr = 0;
|
||||
|
||||
vm_storage st((char*)"", (char*)"");
|
||||
|
||||
char ccode_buf[LBUFSIZ];
|
||||
int c;
|
||||
while ( (c = in.get()) != EOF ) {
|
||||
in.putback(c);
|
||||
|
||||
in.getline(ccode_buf, LBUFSIZ);
|
||||
|
||||
sscanf(ccode_buf, "%u", &c);
|
||||
//debug(cerr, c);
|
||||
//fprintf(stderr, "code = %d\n", c);
|
||||
|
||||
if ( c == SGML_CONTENT_CODE ) {
|
||||
if ( code == c || code == 0 )
|
||||
ok |= compare_SGML_content(in, base_ptr, (Boolean)true);
|
||||
else
|
||||
compare_SGML_content(in, base_ptr, (Boolean)false);
|
||||
} else {
|
||||
|
||||
root_hd_ptr = new handler(c, &st);
|
||||
|
||||
(*root_hd_ptr) -> asciiIn(in);
|
||||
|
||||
if ( code == c || code == 0 ) {
|
||||
switch ( c ) {
|
||||
case OLIAS_NODE_CODE :
|
||||
ok |= compare_node(*(node_smart_ptr*)root_hd_ptr, base_ptr);
|
||||
break;
|
||||
case STYLESHEET_CODE :
|
||||
ok |= compare_stylesheet(*(stylesheet_smart_ptr*)root_hd_ptr, base_ptr);
|
||||
break;
|
||||
case DOC_CODE :
|
||||
ok |= compare_doc(*(doc_smart_ptr*)root_hd_ptr, base_ptr);
|
||||
break;
|
||||
case GRAPHIC_CODE :
|
||||
ok |= compare_graphic(*(graphic_smart_ptr*)root_hd_ptr, base_ptr);
|
||||
break;
|
||||
case TOC_CODE :
|
||||
ok |= compare_toc(*(toc_smart_ptr*)root_hd_ptr, base_ptr);
|
||||
break;
|
||||
case LOCATOR_CODE :
|
||||
ok |= compare_locator(*(locator_smart_ptr*)root_hd_ptr, base_ptr);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
delete root_hd_ptr;
|
||||
}
|
||||
st.remove();
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
struct {
|
||||
char* name;
|
||||
c_code_t code;
|
||||
} auto_test_spec[] =
|
||||
{
|
||||
{(char*)"auto_node_test", OLIAS_NODE_CODE},
|
||||
{(char*)"auto_SGML_content_test", SGML_CONTENT_CODE},
|
||||
{(char*)"auto_stylesheet_test", STYLESHEET_CODE},
|
||||
{(char*)"auto_graphic_test", GRAPHIC_CODE},
|
||||
{(char*)"auto_doc_test", DOC_CODE},
|
||||
{(char*)"auto_toc_test", TOC_CODE},
|
||||
{(char*)"auto_loc_test", LOCATOR_CODE},
|
||||
};
|
||||
|
||||
#define NUM_OF_AUTO_TESTS 7
|
||||
|
||||
int auto_test(int argc, char** argv, OLIAS_DB& db)
|
||||
{
|
||||
int ok = 0;
|
||||
|
||||
info_lib* infolib_ptr = db.openInfoLib(argv[2]);
|
||||
|
||||
// define
|
||||
if ( infolib_ptr == 0 ||
|
||||
infolib_ptr->define_info_base(argv[4],argv[4],argv[3]) == false
|
||||
) {
|
||||
STDERR_MESSAGE("creating test database failed\n");
|
||||
return -1;
|
||||
} else
|
||||
STDERR_MESSAGE("creating test database done\n");
|
||||
|
||||
db.closeInfoLib(infolib_ptr->get_info_lib_uid());
|
||||
|
||||
// randomly generate raw stream
|
||||
infolib_ptr = db.openInfoLib(argv[2]);
|
||||
info_base* base_ptr = infolib_ptr -> get_info_base(argv[4]);
|
||||
ok = generate_stream(base_ptr, argv[2],
|
||||
atoi(argv[5]), atoi(argv[6]), atoi(argv[7])
|
||||
);
|
||||
if ( ok != 0 ) {
|
||||
STDERR_MESSAGE("generating test data failed\n");
|
||||
return -1;
|
||||
} else
|
||||
STDERR_MESSAGE("generating test data done\n");
|
||||
|
||||
db.closeInfoLib(infolib_ptr->get_info_lib_uid());
|
||||
|
||||
// load style sheet
|
||||
cerr << " loading stylesheets ..." << endl;
|
||||
char buf[256];
|
||||
char file_name[256];
|
||||
snprintf(buf, sizeof(buf), "%s.stylesheet", argv[4]);
|
||||
snprintf(file_name, sizeof(file_name), "%s/%s", argv[2], TEST_STY_FILE);
|
||||
|
||||
infolib_ptr = db.openInfoLib(argv[2]);
|
||||
base_ptr = infolib_ptr -> get_info_base(argv[4]);
|
||||
ok = load( base_ptr, buf, file_name );
|
||||
|
||||
if ( ok != 0 ) {
|
||||
STDERR_MESSAGE("loading test stylesheet data failed\n");
|
||||
return -1;
|
||||
} else
|
||||
STDERR_MESSAGE("loading test stylesheet data done\n");
|
||||
|
||||
db.closeInfoLib(infolib_ptr->get_info_lib_uid());
|
||||
|
||||
|
||||
// load sections (small component)
|
||||
cerr << " loading sections ..." << endl;
|
||||
snprintf(buf, sizeof(buf), "%s.node", argv[4]);
|
||||
snprintf(file_name, sizeof(file_name), "%s/%s", argv[2], TEST_SEC_FILE);
|
||||
|
||||
infolib_ptr = db.openInfoLib(argv[2]);
|
||||
base_ptr = infolib_ptr -> get_info_base(argv[4]);
|
||||
ok = load( base_ptr, buf, file_name );
|
||||
|
||||
if ( ok != 0 ) {
|
||||
STDERR_MESSAGE("loading test section data failed\n");
|
||||
return -1;
|
||||
} else
|
||||
STDERR_MESSAGE("loading test section data done\n");
|
||||
|
||||
db.closeInfoLib(infolib_ptr->get_info_lib_uid());
|
||||
|
||||
// load all other objects
|
||||
cerr << " loading all other objects ..." << endl;
|
||||
snprintf(file_name, sizeof(file_name), "%s/%s", argv[2], TEST_MIX_FILE);
|
||||
fstream in(file_name, ios::in);
|
||||
|
||||
if ( !in ) return -1;
|
||||
|
||||
infolib_ptr = db.openInfoLib(argv[2]);
|
||||
base_ptr = infolib_ptr -> get_info_base(argv[4]);
|
||||
ok = _load_mixed_objects(base_ptr, in);
|
||||
|
||||
if ( ok != 0 ) {
|
||||
STDERR_MESSAGE("loading all other test data failed\n");
|
||||
return -1;
|
||||
} else
|
||||
STDERR_MESSAGE("loading all other test data done\n");
|
||||
|
||||
db.closeInfoLib(infolib_ptr->get_info_lib_uid());
|
||||
|
||||
// test
|
||||
|
||||
infolib_ptr = db.openInfoLib(argv[2]);
|
||||
base_ptr = infolib_ptr -> get_info_base(argv[4]);
|
||||
|
||||
// stylesheet
|
||||
snprintf(file_name, sizeof(file_name), "%s/%s", argv[2], TEST_STY_FILE);
|
||||
fstream ss_in(file_name, ios::in);
|
||||
|
||||
if ( !ss_in ) return -1;
|
||||
|
||||
ok = extract_and_compare_objects(ss_in, base_ptr, 0);
|
||||
|
||||
if ( ok != 0 ) {
|
||||
STDERR_MESSAGE("testing stylesheet data failed\n");
|
||||
return -1;
|
||||
} else
|
||||
STDERR_MESSAGE("testing stylesheet data done\n");
|
||||
|
||||
// node
|
||||
snprintf(file_name, sizeof(file_name), "%s/%s", argv[2], TEST_SEC_FILE);
|
||||
fstream nd_in(file_name, ios::in);
|
||||
if ( !nd_in ) return -1;
|
||||
|
||||
ok = extract_and_compare_objects(nd_in, base_ptr, 0);
|
||||
|
||||
if ( ok != 0 ) {
|
||||
STDERR_MESSAGE("testing section failed\n");
|
||||
return -1;
|
||||
} else
|
||||
STDERR_MESSAGE("testing section done\n");
|
||||
|
||||
// all other
|
||||
snprintf(file_name, sizeof(file_name), "%s/%s", argv[2], TEST_MIX_FILE);
|
||||
fstream all_in(file_name, ios::in);
|
||||
if ( !all_in ) return -1;
|
||||
|
||||
ok = extract_and_compare_objects(all_in, base_ptr, 0);
|
||||
|
||||
if ( ok != 0 ) {
|
||||
STDERR_MESSAGE("testing all other data failed\n");
|
||||
return -1;
|
||||
} else
|
||||
STDERR_MESSAGE("testing all other data done\n");
|
||||
|
||||
db.closeInfoLib(infolib_ptr->get_info_lib_uid());
|
||||
|
||||
if ( argc == 8 ||
|
||||
( argc == 9 && strcmp(argv[8], "true") == 0 ) )
|
||||
{
|
||||
db.destroy(argv[2]);
|
||||
destroy_stream(argv[2]);
|
||||
}
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
int select_debug_routine(int argc, char** argv, OLIAS_DB& db)
|
||||
{
|
||||
int ok = 2;
|
||||
|
||||
#ifdef REGRESSION_TEST
|
||||
if ( strcmp(argv[1], "auto_test") == 0 ) {
|
||||
|
||||
if (argc != 8 && argc != 9 ) {
|
||||
// 1 2 3 4 5
|
||||
cerr << "usage: auto_test info_lib_path info_base_spec base_name number_of_sections max_section_size, min_section_size [true|false]\n";
|
||||
return 1;
|
||||
} else
|
||||
return auto_test(argc, argv, db);
|
||||
|
||||
}
|
||||
|
||||
ok =store_test(argc, argv);
|
||||
|
||||
if ( ok != 2 ) {
|
||||
return ok;
|
||||
}
|
||||
|
||||
ok =dstr_test(argc, argv);
|
||||
|
||||
if ( ok != 2 ) {
|
||||
return ok;
|
||||
}
|
||||
|
||||
ok =mark_test(argc, argv);
|
||||
#ifdef NODEBUG
|
||||
if (ok < 0) {
|
||||
cerr << "mark_test failed." << endl;
|
||||
return ok;
|
||||
}
|
||||
else
|
||||
cerr << "mark_test done." << endl;
|
||||
#else
|
||||
if ( ok != 2 ) {
|
||||
return ok;
|
||||
}
|
||||
#endif
|
||||
|
||||
for ( int i=0; i<NUM_OF_AUTO_TESTS; i++ )
|
||||
|
||||
if ( strcmp(argv[1], auto_test_spec[i].name) == 0 ) {
|
||||
|
||||
if ( argc != 4 && argc != 3 ) {
|
||||
cerr << " args: " << auto_test_spec[i].name ;
|
||||
cerr << " base_name [stream_file_name]";
|
||||
return 1;
|
||||
}
|
||||
|
||||
info_base* base_ptr = db.openInfoLib() -> get_info_base(argv[2]);
|
||||
|
||||
if ( argc == 4 ) {
|
||||
fstream in(argv[3], ios::in);
|
||||
return extract_and_compare_objects(in, base_ptr, auto_test_spec[i].code);
|
||||
} else {
|
||||
return extract_and_compare_objects(cin, base_ptr, auto_test_spec[i].code);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef NODEBUG
|
||||
if ( strcmp(argv[1], "random_gen") == 0 ) {
|
||||
if ( argc != 7 ) {
|
||||
cerr << "random_gen args: " << "random_gen base_name path num_sections min_section_len max_sec_len\n";
|
||||
return 1;
|
||||
}
|
||||
info_base* base_ptr = db.openInfoLib() -> get_info_base(argv[2]);
|
||||
|
||||
return generate_stream(base_ptr, argv[3], atoi(argv[4]), atoi(argv[5]), atoi(argv[6]));
|
||||
} else
|
||||
|
||||
if ( strcmp(argv[1], "test_iterator") == 0 ) {
|
||||
info_base* base_ptr = db.openInfoLib() -> get_info_base(argv[2]);
|
||||
test_collector_iterator(base_ptr);
|
||||
ok = 0;
|
||||
} else
|
||||
|
||||
if ( strcmp(argv[1], "dump_node_ids") == 0 ) {
|
||||
if ( argc != 3 ) {
|
||||
MESSAGE(cerr, "dump_node_ids args: dump_node_ids base_nm");
|
||||
} else {
|
||||
info_base* base_ptr = db.openInfoLib() -> get_info_base(argv[2]);
|
||||
dump_node_ids(base_ptr);
|
||||
ok = 0;
|
||||
}
|
||||
} else
|
||||
|
||||
if ( strcmp(argv[1], "dump_instances") == 0 ) {
|
||||
if ( argc != 4 ) {
|
||||
MESSAGE(cerr, "load args: dump_all_instance base_nm type");
|
||||
} else {
|
||||
info_base* base_ptr = db.openInfoLib() -> get_info_base(argv[2]);
|
||||
|
||||
if ( strcmp(argv[3], "nodes") == 0 )
|
||||
ok = dump_instances(base_ptr, NODE_SET_NAME, OLIAS_NODE_CODE);
|
||||
else
|
||||
if ( strcmp(argv[3], "locators") == 0 )
|
||||
ok = dump_instances(base_ptr, LOCATOR_SET_NAME, LOCATOR_CODE);
|
||||
else
|
||||
if ( strcmp(argv[3], "graphics") == 0 )
|
||||
ok = dump_instances(base_ptr, GRAPHIC_SET_NAME, GRAPHIC_CODE);
|
||||
}
|
||||
} else
|
||||
|
||||
if ( strcmp(argv[1], "file_load") == 0 ) {
|
||||
if ( (argc-2) % 3 != 0 ) {
|
||||
MESSAGE(cerr,
|
||||
"load args: file_load [obj_type obj_name data_file]+");
|
||||
} else {
|
||||
info_base* base_ptr = db.openInfoLib() -> get_info_base(argv[2]);
|
||||
ok = load( base_ptr, argv+2, argc-2 );
|
||||
}
|
||||
|
||||
} else
|
||||
|
||||
if ( strcmp(argv[1], "loc_test") == 0 ) {
|
||||
if ( argc != 4 ) {
|
||||
MESSAGE(cerr,
|
||||
"loc_test args: loc_test base_name loc_value");
|
||||
} else {
|
||||
ok = loc_test( db.openInfoLib(), argv[2], argv[3] );
|
||||
}
|
||||
|
||||
} else
|
||||
if ( strcmp(argv[1], "toc_test") == 0 ) {
|
||||
if ( argc != 4 ) {
|
||||
MESSAGE(cerr,
|
||||
"toc_test args: toc_test base_name oid_str");
|
||||
} else {
|
||||
ok = toc_test( db.openInfoLib(), argv[2], argv[3] );
|
||||
}
|
||||
|
||||
} else
|
||||
if ( strcmp(argv[1], "graphic_test") == 0 ) {
|
||||
if ( argc != 4 ) {
|
||||
MESSAGE(cerr,
|
||||
"graphic_test args: graphic_test base_name oid_str");
|
||||
} else {
|
||||
ok = graphic_test( db.openInfoLib(), argv[2], argv[3] );
|
||||
}
|
||||
|
||||
} else
|
||||
if ( strcmp(argv[1], "stylesheet_test_loc") == 0 ) {
|
||||
if ( argc != 4 ) {
|
||||
MESSAGE(cerr,
|
||||
"stylesheet_test_loc args: stylesheet_test_loc base_name loc");
|
||||
} else {
|
||||
ok = stylesheet_test_loc( db.openInfoLib(), argv[2], argv[3] );
|
||||
}
|
||||
} else
|
||||
if ( strcmp(argv[1], "stylesheet_test_oid") == 0 ) {
|
||||
if ( argc != 4 ) {
|
||||
MESSAGE(cerr,
|
||||
"stylesheet_test_oid args: stylesheet_test_oid base_name oid");
|
||||
} else {
|
||||
ok = stylesheet_test_oid( db.openInfoLib(), argv[2], argv[3] );
|
||||
}
|
||||
} else
|
||||
if ( strcmp(argv[1], "node_test_loc") == 0 ) {
|
||||
if ( argc != 4 ) {
|
||||
MESSAGE(cerr,
|
||||
"node_test_loc args: node_test_loc base_name loc");
|
||||
} else {
|
||||
ok = node_test_loc( db.openInfoLib(), argv[2], argv[3] );
|
||||
}
|
||||
} else
|
||||
|
||||
if ( strcmp(argv[1], "node_test_oid") == 0 ) {
|
||||
if ( argc != 4 ) {
|
||||
MESSAGE(cerr,
|
||||
"node_test_oid args: node_test_oid base_name oid_str");
|
||||
} else {
|
||||
ok = node_test_oid( db.openInfoLib(), argv[2], argv[3] );
|
||||
}
|
||||
|
||||
} else
|
||||
if ( strcmp(argv[1], "dlp_test") == 0 ) {
|
||||
if ( argc != 4 ) {
|
||||
MESSAGE(cerr,
|
||||
"dlp_test args: dlp_test base_name oid_str");
|
||||
} else {
|
||||
ok = dlp_test( db.openInfoLib(), argv[2], argv[3] );
|
||||
}
|
||||
|
||||
} else
|
||||
if ( strcmp(argv[1], "doc_test_oid") == 0 ) {
|
||||
if ( argc != 4 ) {
|
||||
MESSAGE(cerr,
|
||||
"doc_test_oid args: doc_test_oid base_name oid_str");
|
||||
} else {
|
||||
ok = doc_test_oid( db.openInfoLib(), argv[2], argv[3] );
|
||||
}
|
||||
|
||||
} else
|
||||
if ( strcmp(argv[1], "doc_test_int") == 0 ) {
|
||||
if ( argc != 4 ) {
|
||||
MESSAGE(cerr,
|
||||
"doc_test_int args: doc_test_int base_name int_str");
|
||||
} else {
|
||||
ok = doc_test_int( db.openInfoLib(), argv[2], argv[3] );
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
return ok;
|
||||
}
|
||||
83
cde/lib/DtMmdb/oliasdb/olias_test.h
Normal file
83
cde/lib/DtMmdb/oliasdb/olias_test.h
Normal file
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* CDE - Common Desktop Environment
|
||||
*
|
||||
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
|
||||
*
|
||||
* These libraries and programs are free software; you can
|
||||
* redistribute them and/or modify them under the terms of the GNU
|
||||
* Lesser General Public License as published by the Free Software
|
||||
* Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* These libraries and programs are distributed in the hope that
|
||||
* they will be useful, but WITHOUT ANY WARRANTY; without even the
|
||||
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU Lesser General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with these libraries and programs; if not, write
|
||||
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
|
||||
* Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
/*
|
||||
* $XConsortium: olias_test.h /main/4 1996/07/18 14:49:25 drk $
|
||||
*
|
||||
* Copyright (c) 1992 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 _olias_test_h
|
||||
#define _olias_test_h 1
|
||||
|
||||
#include "oliasdb/mmdb.h"
|
||||
|
||||
int select_debug_routine(int argc, char** argv, OLIAS_DB&);
|
||||
|
||||
#ifdef DEBUG
|
||||
|
||||
int loc_test( info_lib*, const char* base_name, const char* loc );
|
||||
int toc_test( info_lib*, const char* base_name, const char* oid_id_str);
|
||||
int graphic_test( info_lib*, const char* base_name, const char* oid_str);
|
||||
|
||||
int node_test_loc( info_lib*, const char* base_name, const char* loc );
|
||||
int node_test_oid( info_lib*, const char* base_name, const char* oid_str );
|
||||
int dlp_test( info_lib*, const char* base_name, const char* oid_str );
|
||||
int doc_test_oid( info_lib*, const char* base_name, const char* oid_str );
|
||||
int doc_test_int( info_lib*, const char* base_name, const char* oid_str );
|
||||
int doc_test_doc_oid( info_lib*, const char* base_name, const char* oid_str );
|
||||
int stylesheet_test_loc( info_lib*, const char* base_name, const char* loc );
|
||||
int stylesheet_test_oid( info_lib*, const char* base_name, const char* oid_str);
|
||||
void update_stylesheet_test(char* filename, info_base* base_ptr, char* locator);
|
||||
int cache_test( info_lib*, const char* base_name, int argc, char** argv );
|
||||
void dump_node_ids(info_base*);
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef REGRESSION_TEST
|
||||
int generate_stream(info_base*, char* path, int num_sections, int min_section_len, int max_sec_len);
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
185
cde/lib/DtMmdb/oliasdb/pref.C
Normal file
185
cde/lib/DtMmdb/oliasdb/pref.C
Normal file
@@ -0,0 +1,185 @@
|
||||
/*
|
||||
* CDE - Common Desktop Environment
|
||||
*
|
||||
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
|
||||
*
|
||||
* These libraries and programs are free software; you can
|
||||
* redistribute them and/or modify them under the terms of the GNU
|
||||
* Lesser General Public License as published by the Free Software
|
||||
* Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* These libraries and programs are distributed in the hope that
|
||||
* they will be useful, but WITHOUT ANY WARRANTY; without even the
|
||||
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU Lesser General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with these libraries and programs; if not, write
|
||||
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
|
||||
* Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
/*
|
||||
* $XConsortium: pref.cc /main/4 1996/06/11 17:30:27 cde-hal $
|
||||
*
|
||||
* Copyright (c) 1992 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 "oliasdb/pref.h"
|
||||
|
||||
MMDB_BODIES(pref)
|
||||
|
||||
pref_smart_ptr::pref_smart_ptr(pref_base* uptr,
|
||||
const char* name) :
|
||||
pbase(uptr), pref_set_hd_ptr(uptr -> pref_set_hd),
|
||||
v_name_hd(0), v_cnfg_hd(0)
|
||||
{
|
||||
|
||||
abs_storage *pref_store = pref_set_hd_ptr -> its_store();
|
||||
|
||||
oid_list_handler* pref_list = (*pref_set_hd_ptr) ->
|
||||
get_locs(managers::query_mgr -> form_pstring_handler(name),
|
||||
BASE_COMPONENT_INDEX
|
||||
);
|
||||
|
||||
|
||||
if ( pref_list == 0 ) {
|
||||
|
||||
MESSAGE(cerr, "NEW RECORD");
|
||||
try {
|
||||
pbase -> trans().begin();
|
||||
|
||||
tuple_handler* w =
|
||||
new tuple_handler(oid_t(USER_CONFIG_CODE, 0), pref_store);
|
||||
|
||||
v_name_hd = new pstring_handler(name, strlen(name), pref_store);
|
||||
v_cnfg_hd = new pstring_handler("", 0, pref_store);
|
||||
|
||||
(*w) -> pinned_insert(BASE_COMPONENT_INDEX, v_name_hd -> its_oid());
|
||||
(*w) -> pinned_insert(BASE_COMPONENT_INDEX+1, v_cnfg_hd -> its_oid());
|
||||
|
||||
/////////////////////
|
||||
// init smart_ptr
|
||||
/////////////////////
|
||||
smart_ptr::_init(w->its_oid(), pref_store);
|
||||
|
||||
(*pref_set_hd_ptr) -> insert_object( *w );
|
||||
|
||||
pbase -> trans().end();
|
||||
}
|
||||
|
||||
catch (mmdbException&, e)
|
||||
{
|
||||
smart_ptr::_init(ground, 0); // mark the pref obsolete
|
||||
pbase -> trans().rollback();
|
||||
rethrow;
|
||||
}
|
||||
end_try;
|
||||
|
||||
|
||||
} else {
|
||||
MESSAGE(cerr, "OLD RECORD");
|
||||
|
||||
if ( (*pref_list) -> count() == 0 ) {
|
||||
throw(stringException("zero prefs in the list"));
|
||||
}
|
||||
|
||||
smart_ptr::_init((*pref_list) -> operator()(1), pref_store);
|
||||
|
||||
v_name_hd = (pstring_handler*)
|
||||
get_handler(BASE_COMPONENT_INDEX, STRING_CODE);
|
||||
v_cnfg_hd = (pstring_handler*)
|
||||
get_handler(BASE_COMPONENT_INDEX+1, STRING_CODE);;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
pref_smart_ptr::~pref_smart_ptr()
|
||||
{
|
||||
delete v_name_hd;
|
||||
delete v_cnfg_hd;
|
||||
}
|
||||
|
||||
Boolean pref_smart_ptr::update_value(const pstring& new_uc)
|
||||
{
|
||||
return update_value(((pstring&)new_uc).get(), ((pstring&)new_uc).size());
|
||||
}
|
||||
|
||||
Boolean pref_smart_ptr::update_value(const char* new_pref,
|
||||
int new_pref_sz)
|
||||
{
|
||||
try {
|
||||
pbase -> trans().begin();
|
||||
|
||||
(*v_cnfg_hd) -> update(new_pref, new_pref_sz);
|
||||
|
||||
pbase -> trans().end();
|
||||
}
|
||||
|
||||
catch (mmdbException&, e)
|
||||
{
|
||||
pbase -> trans().rollback();
|
||||
return false;
|
||||
}
|
||||
end_try;
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Boolean pref_smart_ptr::remove_from_db()
|
||||
{
|
||||
try {
|
||||
pbase -> trans().begin();
|
||||
|
||||
(*pref_set_hd_ptr) -> remove_component(its_oid());
|
||||
|
||||
pbase -> trans().end();
|
||||
}
|
||||
|
||||
catch (mmdbException&, e)
|
||||
{
|
||||
pbase -> trans().rollback();
|
||||
return false;
|
||||
}
|
||||
end_try;
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
char* pref_smart_ptr::name()
|
||||
{
|
||||
return (*v_name_hd) -> get();
|
||||
}
|
||||
|
||||
pstring* pref_smart_ptr::pref_value()
|
||||
{
|
||||
return v_cnfg_hd -> operator->();
|
||||
}
|
||||
|
||||
109
cde/lib/DtMmdb/oliasdb/pref.h
Normal file
109
cde/lib/DtMmdb/oliasdb/pref.h
Normal file
@@ -0,0 +1,109 @@
|
||||
/*
|
||||
* CDE - Common Desktop Environment
|
||||
*
|
||||
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
|
||||
*
|
||||
* These libraries and programs are free software; you can
|
||||
* redistribute them and/or modify them under the terms of the GNU
|
||||
* Lesser General Public License as published by the Free Software
|
||||
* Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* These libraries and programs are distributed in the hope that
|
||||
* they will be useful, but WITHOUT ANY WARRANTY; without even the
|
||||
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU Lesser General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with these libraries and programs; if not, write
|
||||
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
|
||||
* Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
/*
|
||||
* $XConsortium: pref.h /main/4 1996/06/11 17:30:32 cde-hal $
|
||||
*
|
||||
* Copyright (c) 1992 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 _pref_h
|
||||
#define _pref_h 1
|
||||
|
||||
#include "object/tuple.h"
|
||||
#include "object/pstring.h"
|
||||
#include "object/oid.h"
|
||||
|
||||
#include "oliasdb/olias_consts.h"
|
||||
#include "oliasdb/pref_base.h"
|
||||
#include "api/smart_ptr.h"
|
||||
|
||||
|
||||
#ifdef A16_BROWSER
|
||||
#define pref_smart_ptr user_config_smart_ptr
|
||||
#define pref_value config_value
|
||||
#endif
|
||||
|
||||
|
||||
class pref : public mmdb_tuple
|
||||
{
|
||||
public:
|
||||
pref() : mmdb_tuple(2, USER_CONFIG_CODE) {};
|
||||
virtual ~pref() {};
|
||||
|
||||
MMDB_SIGNATURES(pref);
|
||||
|
||||
friend class pref_smart_ptr;
|
||||
|
||||
protected:
|
||||
cset_handler* pref_set_hd_ptr;
|
||||
};
|
||||
|
||||
class pref_smart_ptr : public smart_ptr
|
||||
{
|
||||
|
||||
public:
|
||||
pref_smart_ptr(pref_base*, const char* name);
|
||||
virtual ~pref_smart_ptr();
|
||||
|
||||
Boolean update_value(const pstring& new_value);
|
||||
Boolean update_value(const char* new_value, int new_value_sz);
|
||||
|
||||
Boolean remove_from_db();
|
||||
|
||||
char* name();
|
||||
pstring* pref_value();
|
||||
|
||||
|
||||
protected:
|
||||
pref_base* pbase;
|
||||
cset_handler* pref_set_hd_ptr;
|
||||
|
||||
pstring_handler* v_name_hd;
|
||||
pstring_handler* v_cnfg_hd;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
92
cde/lib/DtMmdb/oliasdb/pref_base.C
Normal file
92
cde/lib/DtMmdb/oliasdb/pref_base.C
Normal file
@@ -0,0 +1,92 @@
|
||||
/*
|
||||
* CDE - Common Desktop Environment
|
||||
*
|
||||
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
|
||||
*
|
||||
* These libraries and programs are free software; you can
|
||||
* redistribute them and/or modify them under the terms of the GNU
|
||||
* Lesser General Public License as published by the Free Software
|
||||
* Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* These libraries and programs are distributed in the hope that
|
||||
* they will be useful, but WITHOUT ANY WARRANTY; without even the
|
||||
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU Lesser General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with these libraries and programs; if not, write
|
||||
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
|
||||
* Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
/*
|
||||
* $XConsortium: pref_base.cc /main/3 1996/06/11 17:30:37 cde-hal $
|
||||
*
|
||||
* Copyright (c) 1992 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 "oliasdb/pref_base.h"
|
||||
#include "utility/debug.h"
|
||||
#include "unique_id.h"
|
||||
|
||||
pref_base::pref_base(user_base::rw_flag_t rw) :
|
||||
user_base(PREF_SPEC, rw)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
pref_base::pref_base( const char* base_dir,
|
||||
const char* base_nm,
|
||||
const char* base_ds,
|
||||
user_base::rw_flag_t rw
|
||||
) :
|
||||
user_base(base_dir, base_nm, base_ds, PREF_SPEC, rw)
|
||||
{
|
||||
if ( checking_status != SUCC )
|
||||
return;
|
||||
|
||||
desc* ptr = first_desc_ptr;
|
||||
|
||||
if ( ptr == 0 )
|
||||
throw(stringException("empty pref base specification"));
|
||||
|
||||
while ( ptr ) {
|
||||
if ( strcmp( ptr -> get_type(), "container set") == 0 ) {
|
||||
pref_set_hd = (cset_handler*)
|
||||
(managers::obj_dict -> get_handler(ptr -> get_nm()));
|
||||
return;
|
||||
}
|
||||
ptr = ptr -> get_next_desc();
|
||||
}
|
||||
|
||||
throw(stringException("can't find pref set description record"));
|
||||
}
|
||||
|
||||
pref_base::~pref_base()
|
||||
{
|
||||
}
|
||||
|
||||
89
cde/lib/DtMmdb/oliasdb/pref_base.h
Normal file
89
cde/lib/DtMmdb/oliasdb/pref_base.h
Normal file
@@ -0,0 +1,89 @@
|
||||
/*
|
||||
* CDE - Common Desktop Environment
|
||||
*
|
||||
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
|
||||
*
|
||||
* These libraries and programs are free software; you can
|
||||
* redistribute them and/or modify them under the terms of the GNU
|
||||
* Lesser General Public License as published by the Free Software
|
||||
* Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* These libraries and programs are distributed in the hope that
|
||||
* they will be useful, but WITHOUT ANY WARRANTY; without even the
|
||||
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU Lesser General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with these libraries and programs; if not, write
|
||||
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
|
||||
* Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
/*
|
||||
* $XConsortium: pref_base.h /main/3 1996/06/11 17:30:42 cde-hal $
|
||||
*
|
||||
* Copyright (c) 1992 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 _pref_base_h
|
||||
#define _pref_base_h 1
|
||||
|
||||
#include "oliasdb/user_base.h"
|
||||
|
||||
|
||||
/*************************************/
|
||||
// The pref_base class
|
||||
/*************************************/
|
||||
|
||||
class pref_base : public user_base
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
pref_base(const char* base_dir,
|
||||
const char* base_name,
|
||||
const char* base_desc,
|
||||
user_base::rw_flag_t = pref_base::READ
|
||||
);
|
||||
pref_base(user_base::rw_flag_t = pref_base::READ);
|
||||
virtual ~pref_base();
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
cset_handler* pref_set_hd;
|
||||
|
||||
friend class user_config_smart_ptr;
|
||||
friend class pref_smart_ptr;
|
||||
friend class pref_hd;
|
||||
};
|
||||
|
||||
typedef pref_base* pref_basePtr;
|
||||
|
||||
|
||||
#endif
|
||||
198
cde/lib/DtMmdb/oliasdb/stylesheet_hd.C
Normal file
198
cde/lib/DtMmdb/oliasdb/stylesheet_hd.C
Normal file
@@ -0,0 +1,198 @@
|
||||
/*
|
||||
* CDE - Common Desktop Environment
|
||||
*
|
||||
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
|
||||
*
|
||||
* These libraries and programs are free software; you can
|
||||
* redistribute them and/or modify them under the terms of the GNU
|
||||
* Lesser General Public License as published by the Free Software
|
||||
* Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* These libraries and programs are distributed in the hope that
|
||||
* they will be useful, but WITHOUT ANY WARRANTY; without even the
|
||||
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU Lesser General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with these libraries and programs; if not, write
|
||||
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
|
||||
* Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
/*
|
||||
* $XConsortium: stylesheet_hd.cc /main/4 1996/06/11 17:30:47 cde-hal $
|
||||
*
|
||||
* Copyright (c) 1992 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 "oliasdb/stylesheet_hd.h"
|
||||
#include "api/transaction.h"
|
||||
|
||||
MMDB_BODIES(stylesheet)
|
||||
|
||||
stylesheet_smart_ptr::stylesheet_smart_ptr(info_lib* lib_ptr,
|
||||
const char* base_name,
|
||||
const char* locator) :
|
||||
smart_ptr(lib_ptr, base_name, STYLESHEET_SET_POS,
|
||||
managers::query_mgr -> form_pstring_handler(locator),
|
||||
BASE_COMPONENT_INDEX, smart_ptr::SET
|
||||
)
|
||||
{
|
||||
}
|
||||
|
||||
stylesheet_smart_ptr::stylesheet_smart_ptr(info_base* base_ptr,
|
||||
const char* locator) :
|
||||
smart_ptr(base_ptr, STYLESHEET_SET_POS,
|
||||
managers::query_mgr -> form_pstring_handler(locator),
|
||||
BASE_COMPONENT_INDEX, smart_ptr::SET
|
||||
)
|
||||
{
|
||||
}
|
||||
|
||||
stylesheet_smart_ptr::stylesheet_smart_ptr(info_lib* lib_ptr,
|
||||
const char* base_name, const oid_t& x):
|
||||
smart_ptr(
|
||||
lib_ptr -> get_info_base(base_name) -> get_set(STYLESHEET_SET_POS) -> its_store(),
|
||||
x
|
||||
)
|
||||
{
|
||||
}
|
||||
|
||||
stylesheet_smart_ptr::stylesheet_smart_ptr(info_base* base_ptr,
|
||||
const oid_t& x):
|
||||
smart_ptr(
|
||||
base_ptr -> get_set(STYLESHEET_SET_POS) -> its_store(),
|
||||
x
|
||||
)
|
||||
{
|
||||
}
|
||||
|
||||
/////////////////////////////////////////
|
||||
//
|
||||
//
|
||||
/////////////////////////////////////////
|
||||
const char* stylesheet_smart_ptr::name()
|
||||
{
|
||||
return get_string(BASE_COMPONENT_INDEX);
|
||||
}
|
||||
|
||||
const char* stylesheet_smart_ptr::online_data()
|
||||
{
|
||||
return get_string(BASE_COMPONENT_INDEX+1);
|
||||
}
|
||||
|
||||
const char* stylesheet_smart_ptr::hardcopy_data()
|
||||
{
|
||||
return get_string(BASE_COMPONENT_INDEX+2);
|
||||
}
|
||||
|
||||
int stylesheet_smart_ptr::online_data_size()
|
||||
{
|
||||
return get_string_size(BASE_COMPONENT_INDEX+1);
|
||||
}
|
||||
|
||||
int stylesheet_smart_ptr::hardcopy_data_size()
|
||||
{
|
||||
return get_string_size(BASE_COMPONENT_INDEX+2);
|
||||
}
|
||||
|
||||
void stylesheet_smart_ptr::update_online_data(istream& in)
|
||||
{
|
||||
update_data(in, BASE_COMPONENT_INDEX+1);
|
||||
}
|
||||
|
||||
void stylesheet_smart_ptr::update_hardcopy_data(istream& in)
|
||||
{
|
||||
update_data(in, BASE_COMPONENT_INDEX+2);
|
||||
}
|
||||
|
||||
void stylesheet_smart_ptr::update_data(istream& in, int index)
|
||||
{
|
||||
transaction trans ;
|
||||
mtry {
|
||||
trans.begin();
|
||||
|
||||
update_string(index, in);
|
||||
|
||||
trans.end();
|
||||
}
|
||||
|
||||
mcatch (beginTransException&, e)
|
||||
{
|
||||
rethrow;
|
||||
}
|
||||
mcatch (commitTransException&, e)
|
||||
{
|
||||
rethrow;
|
||||
}
|
||||
mcatch (mmdbException&, e)
|
||||
{
|
||||
trans.rollback();
|
||||
rethrow;
|
||||
}
|
||||
end_try;
|
||||
}
|
||||
|
||||
void
|
||||
stylesheet_smart_ptr::update_online_data(const char* buf, int size)
|
||||
{
|
||||
update_data(buf, size, BASE_COMPONENT_INDEX+1);
|
||||
}
|
||||
|
||||
void
|
||||
stylesheet_smart_ptr::update_hardcopy_data(const char* buf, int size)
|
||||
{
|
||||
update_data(buf, size, BASE_COMPONENT_INDEX+2);
|
||||
}
|
||||
|
||||
void
|
||||
stylesheet_smart_ptr::update_data(const char* buf, int size, int index)
|
||||
{
|
||||
transaction trans ;
|
||||
mtry {
|
||||
trans.begin();
|
||||
|
||||
update_string(index, buf, size);
|
||||
|
||||
trans.end();
|
||||
}
|
||||
|
||||
mcatch (beginTransException&, e)
|
||||
{
|
||||
rethrow;
|
||||
}
|
||||
mcatch (commitTransException&, e)
|
||||
{
|
||||
rethrow;
|
||||
}
|
||||
mcatch (mmdbException&, e)
|
||||
{
|
||||
trans.rollback();
|
||||
rethrow;
|
||||
}
|
||||
end_try;
|
||||
}
|
||||
|
||||
117
cde/lib/DtMmdb/oliasdb/stylesheet_hd.h
Normal file
117
cde/lib/DtMmdb/oliasdb/stylesheet_hd.h
Normal file
@@ -0,0 +1,117 @@
|
||||
/*
|
||||
* CDE - Common Desktop Environment
|
||||
*
|
||||
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
|
||||
*
|
||||
* These libraries and programs are free software; you can
|
||||
* redistribute them and/or modify them under the terms of the GNU
|
||||
* Lesser General Public License as published by the Free Software
|
||||
* Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* These libraries and programs are distributed in the hope that
|
||||
* they will be useful, but WITHOUT ANY WARRANTY; without even the
|
||||
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU Lesser General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with these libraries and programs; if not, write
|
||||
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
|
||||
* Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
/*
|
||||
* $XConsortium: stylesheet_hd.h /main/4 1996/06/11 17:30:53 cde-hal $
|
||||
*
|
||||
* Copyright (c) 1992 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 _stylesheet_hd_h
|
||||
#define _stylesheet_hd_h 1
|
||||
|
||||
#include "object/tuple.h"
|
||||
#include "object/pstring.h"
|
||||
#include "object/compressed_pstring.h"
|
||||
#include "object/oid.h"
|
||||
#include "oliasdb/olias_consts.h"
|
||||
#include "api/smart_ptr.h"
|
||||
|
||||
/*************************************/
|
||||
// The stylesheet class
|
||||
/*************************************/
|
||||
|
||||
class stylesheet : public mmdb_tuple
|
||||
{
|
||||
|
||||
public:
|
||||
stylesheet() : mmdb_tuple(NUM_STYLESHEET_FIELDS, STYLESHEET_CODE) {};
|
||||
virtual ~stylesheet() {};
|
||||
|
||||
MMDB_SIGNATURES(stylesheet);
|
||||
|
||||
protected:
|
||||
};
|
||||
|
||||
typedef stylesheet* stylesheetPtr;
|
||||
|
||||
|
||||
|
||||
class stylesheet_smart_ptr : public smart_ptr
|
||||
{
|
||||
private:
|
||||
char* get_data(int index);
|
||||
int get_data_size(int index);
|
||||
|
||||
// transaction guarded version
|
||||
void update_data(istream& in, int index);
|
||||
void update_data(const char* buf, int size, int index);
|
||||
|
||||
public:
|
||||
stylesheet_smart_ptr(info_lib* lib_ptr, const char* info_base_name, const char* locator);
|
||||
stylesheet_smart_ptr(info_base* base_ptr, const char* locator);
|
||||
|
||||
stylesheet_smart_ptr(info_lib* lib_ptr, const char* ibase_name, const oid_t& stylesheet_id);
|
||||
stylesheet_smart_ptr(info_base* ibase_ptr, const oid_t& stylesheet_id);
|
||||
virtual ~stylesheet_smart_ptr() {};
|
||||
|
||||
const char* name();
|
||||
|
||||
const char* online_data(); // online style sheet
|
||||
int online_data_size();
|
||||
|
||||
const char* hardcopy_data(); // hardcopy style sheet
|
||||
int hardcopy_data_size();
|
||||
|
||||
void update_hardcopy_data(istream& in);
|
||||
void update_online_data(istream& in);
|
||||
|
||||
void update_hardcopy_data(const char* buf, int size) ;
|
||||
void update_online_data(const char* buf, int size);
|
||||
};
|
||||
|
||||
|
||||
typedef stylesheet_smart_ptr* stylesheet_smart_ptrPtr;
|
||||
|
||||
#endif
|
||||
108
cde/lib/DtMmdb/oliasdb/stylesheet_test.C
Normal file
108
cde/lib/DtMmdb/oliasdb/stylesheet_test.C
Normal file
@@ -0,0 +1,108 @@
|
||||
/*
|
||||
* CDE - Common Desktop Environment
|
||||
*
|
||||
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
|
||||
*
|
||||
* These libraries and programs are free software; you can
|
||||
* redistribute them and/or modify them under the terms of the GNU
|
||||
* Lesser General Public License as published by the Free Software
|
||||
* Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* These libraries and programs are distributed in the hope that
|
||||
* they will be useful, but WITHOUT ANY WARRANTY; without even the
|
||||
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU Lesser General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with these libraries and programs; if not, write
|
||||
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
|
||||
* Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
/* $XConsortium: stylesheet_test.cc /main/4 1996/07/18 16:03:49 drk $ */
|
||||
|
||||
#ifdef REGRESSION_TEST
|
||||
|
||||
#include "oliasdb/stylesheet_test.h"
|
||||
|
||||
#define LARGE_BUFSIZ 2048
|
||||
|
||||
void print_stylesheet(stylesheet_smart_ptr& x, ostream& out)
|
||||
{
|
||||
out << "name=" << x.name();
|
||||
out << "online_data_size=" << x.online_data_size();
|
||||
out << "online_data=" << x.online_data();
|
||||
out << "hardcopy_data_size=" << x.hardcopy_data_size();
|
||||
out << "hardcopy_data_size=" << x.hardcopy_data();
|
||||
}
|
||||
|
||||
int compare_stylesheet(stylesheet_smart_ptr& pattern, info_base* base_ptr)
|
||||
{
|
||||
char pattern_buf[LARGE_BUFSIZ];
|
||||
ostringstream pattern_out(pattern_buf, LARGE_BUFSIZ, ios::out);
|
||||
print_stylesheet(pattern, pattern_out);
|
||||
|
||||
char loc[BUFSIZ];
|
||||
int len = MIN(strlen(pattern.name()), BUFSIZ - 1);
|
||||
*((char *) memcpy(loc, pattern.name(), len) + len) = '\0';
|
||||
|
||||
stylesheet_smart_ptr x( base_ptr, loc );
|
||||
char db_buf[LARGE_BUFSIZ];
|
||||
ostringstream db_out(db_buf, LARGE_BUFSIZ, ios::out);
|
||||
print_stylesheet(x, db_out);
|
||||
|
||||
return compare_stream(pattern_out, db_out);
|
||||
}
|
||||
|
||||
void update_stylesheet_test(char* filename, info_base* base_ptr, char* locator)
|
||||
{
|
||||
char buf[LBUFSIZ];
|
||||
char st_buf[LBUFSIZ];
|
||||
fstream in(filename, ios::in);
|
||||
while (in) {
|
||||
in.getline(buf, LBUFSIZ);
|
||||
int slen = strlen(st_buf);
|
||||
int len = MIN(strlen(buf), LBUFSIZ - 1 - slen);
|
||||
*((char *) memcpy(st_buf + slen, buf, len) + len) = '\0';
|
||||
}
|
||||
stylesheet_smart_ptr st(base_ptr, locator);
|
||||
st.update_online_data(st_buf, strlen(st_buf));
|
||||
}
|
||||
|
||||
int stylesheet_test_loc( info_lib* infolib_ptr, const char* base_name, const char* loc )
|
||||
{
|
||||
stylesheet_smart_ptr x( infolib_ptr, base_name, loc );
|
||||
cerr << form("info of stylesheet object with loc %s:\n", loc);
|
||||
print_stylesheet(x, cerr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int stylesheet_test_oid( info_lib* infolib_ptr, const char* base_name, const char* oid_str)
|
||||
{
|
||||
oid_t id((char*)oid_str, true, false);
|
||||
stylesheet_smart_ptr x( infolib_ptr, base_name, id );
|
||||
|
||||
cerr << form("info of stylesheet object with id : ");
|
||||
debug(cerr, id);
|
||||
debug(cerr, x.name());
|
||||
debug(cerr, x.online_data_size());
|
||||
debug(cerr, x.online_data());
|
||||
debug(cerr, x.hardcopy_data_size());
|
||||
debug(cerr, x.hardcopy_data());
|
||||
|
||||
x.its_oid().asciiOut(cerr); cerr << "\n";
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void generate_stylesheet_instance(random_gen& x, ostream& out, int min_len, int max_len)
|
||||
{
|
||||
out << "1011\n";
|
||||
out << "3\n";
|
||||
x.random_string(out, 15, 15); // name
|
||||
x.random_string(out, min_len, max_len); // sheet1
|
||||
x.random_string(out, min_len, max_len); // sheet2
|
||||
}
|
||||
|
||||
#endif
|
||||
41
cde/lib/DtMmdb/oliasdb/stylesheet_test.h
Normal file
41
cde/lib/DtMmdb/oliasdb/stylesheet_test.h
Normal file
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* CDE - Common Desktop Environment
|
||||
*
|
||||
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
|
||||
*
|
||||
* These libraries and programs are free software; you can
|
||||
* redistribute them and/or modify them under the terms of the GNU
|
||||
* Lesser General Public License as published by the Free Software
|
||||
* Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* These libraries and programs are distributed in the hope that
|
||||
* they will be useful, but WITHOUT ANY WARRANTY; without even the
|
||||
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU Lesser General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with these libraries and programs; if not, write
|
||||
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
|
||||
* Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
/* $XConsortium: stylesheet_test.h /main/4 1996/07/18 16:34:23 drk $ */
|
||||
|
||||
#ifdef REGRESSION_TEST
|
||||
|
||||
#ifndef _stylesheet_test_h
|
||||
#define _stylesheet_test_h
|
||||
|
||||
#include "oliasdb/stylesheet_hd.h"
|
||||
#include "object/random_gen.h"
|
||||
|
||||
void print_stylesheet(stylesheet_smart_ptr& x, ostream& out);
|
||||
|
||||
int compare_stylesheet(stylesheet_smart_ptr& pattern, info_base* base_ptr);
|
||||
|
||||
void generate_stylesheet_instance(random_gen&, ostream& out, int min_len=500, int max_len=5000);
|
||||
|
||||
|
||||
#endif
|
||||
#endif
|
||||
109
cde/lib/DtMmdb/oliasdb/toc_hd.C
Normal file
109
cde/lib/DtMmdb/oliasdb/toc_hd.C
Normal file
@@ -0,0 +1,109 @@
|
||||
/*
|
||||
* CDE - Common Desktop Environment
|
||||
*
|
||||
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
|
||||
*
|
||||
* These libraries and programs are free software; you can
|
||||
* redistribute them and/or modify them under the terms of the GNU
|
||||
* Lesser General Public License as published by the Free Software
|
||||
* Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* These libraries and programs are distributed in the hope that
|
||||
* they will be useful, but WITHOUT ANY WARRANTY; without even the
|
||||
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU Lesser General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with these libraries and programs; if not, write
|
||||
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
|
||||
* Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
/*
|
||||
* $XConsortium: toc_hd.cc /main/4 1996/06/11 17:30:57 cde-hal $
|
||||
*
|
||||
* Copyright (c) 1992 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 "oliasdb/toc_hd.h"
|
||||
|
||||
MMDB_BODIES(toc)
|
||||
|
||||
toc_smart_ptr::toc_smart_ptr(info_lib* lib_ptr,
|
||||
const char* info_base_name,
|
||||
const oid_t& node_id
|
||||
) :
|
||||
smart_ptr(lib_ptr, info_base_name, TOC_SET_POS,
|
||||
managers::query_mgr ->
|
||||
form_oid_handler(
|
||||
/*
|
||||
( node_id.ccode() == OLIAS_NODE_CODE ) ?
|
||||
node_id : oid_t(OLIAS_NODE_CODE, node_id.icode())
|
||||
*/
|
||||
oid_t(OLIAS_NODE_CODE, node_id.icode())
|
||||
),
|
||||
BASE_COMPONENT_INDEX, smart_ptr::SET
|
||||
)
|
||||
{
|
||||
}
|
||||
|
||||
toc_smart_ptr::toc_smart_ptr(info_base* base_ptr,
|
||||
const oid_t& node_id) :
|
||||
smart_ptr(base_ptr, TOC_SET_POS,
|
||||
managers::query_mgr ->
|
||||
form_oid_handler(
|
||||
/*
|
||||
( node_id.ccode() == OLIAS_NODE_CODE ) ?
|
||||
node_id : oid_t(OLIAS_NODE_CODE, node_id.icode())
|
||||
*/
|
||||
oid_t(OLIAS_NODE_CODE, node_id.icode())
|
||||
),
|
||||
BASE_COMPONENT_INDEX, smart_ptr::SET
|
||||
)
|
||||
{
|
||||
}
|
||||
|
||||
oid_t toc_smart_ptr::toc_node_oid()
|
||||
{
|
||||
return get_oid(BASE_COMPONENT_INDEX);
|
||||
}
|
||||
|
||||
oid_t toc_smart_ptr::parent()
|
||||
{
|
||||
return get_oid(BASE_COMPONENT_INDEX+1);
|
||||
}
|
||||
|
||||
oid_list_handler* toc_smart_ptr::children()
|
||||
{
|
||||
return (oid_list_handler*)
|
||||
get_handler(BASE_COMPONENT_INDEX+3, OID_LIST_CODE);
|
||||
}
|
||||
|
||||
int toc_smart_ptr::subtree_size()
|
||||
{
|
||||
return get_int(BASE_COMPONENT_INDEX+2);
|
||||
}
|
||||
|
||||
98
cde/lib/DtMmdb/oliasdb/toc_hd.h
Normal file
98
cde/lib/DtMmdb/oliasdb/toc_hd.h
Normal file
@@ -0,0 +1,98 @@
|
||||
/*
|
||||
* CDE - Common Desktop Environment
|
||||
*
|
||||
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
|
||||
*
|
||||
* These libraries and programs are free software; you can
|
||||
* redistribute them and/or modify them under the terms of the GNU
|
||||
* Lesser General Public License as published by the Free Software
|
||||
* Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* These libraries and programs are distributed in the hope that
|
||||
* they will be useful, but WITHOUT ANY WARRANTY; without even the
|
||||
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU Lesser General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with these libraries and programs; if not, write
|
||||
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
|
||||
* Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
/*
|
||||
* $XConsortium: toc_hd.h /main/4 1996/06/11 17:31:03 cde-hal $
|
||||
*
|
||||
* Copyright (c) 1992 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 _toc_hd_h
|
||||
#define _toc_hd_h 1
|
||||
|
||||
#include "object/oid_list.h"
|
||||
#include "object/oid.h"
|
||||
#include "object/integer.h"
|
||||
#include "object/tuple.h"
|
||||
#include "object/oid_t.h"
|
||||
#include "oliasdb/olias_consts.h"
|
||||
#include "api/smart_ptr.h"
|
||||
|
||||
/*************************************/
|
||||
// The toc class
|
||||
/*************************************/
|
||||
|
||||
class toc : public mmdb_tuple
|
||||
{
|
||||
|
||||
public:
|
||||
toc() : mmdb_tuple(NUM_TOC_FIELDS, TOC_CODE) {};
|
||||
virtual ~toc() {};
|
||||
|
||||
MMDB_SIGNATURES(toc);
|
||||
|
||||
protected:
|
||||
};
|
||||
|
||||
typedef toc* tocPtr;
|
||||
|
||||
|
||||
class toc_smart_ptr : public smart_ptr
|
||||
{
|
||||
public:
|
||||
toc_smart_ptr(info_lib* lib_ptr,
|
||||
const char* ibase_name, const oid_t& node_id);
|
||||
toc_smart_ptr(info_base* ibase_ptr, const oid_t& node_id);
|
||||
virtual ~toc_smart_ptr() {};
|
||||
|
||||
oid_t toc_node_oid();
|
||||
oid_t parent();
|
||||
oid_list_handler* children();
|
||||
int subtree_size();
|
||||
};
|
||||
|
||||
|
||||
typedef toc_smart_ptr* toc_smart_ptrPtr;
|
||||
|
||||
#endif
|
||||
89
cde/lib/DtMmdb/oliasdb/toc_test.C
Normal file
89
cde/lib/DtMmdb/oliasdb/toc_test.C
Normal file
@@ -0,0 +1,89 @@
|
||||
/*
|
||||
* CDE - Common Desktop Environment
|
||||
*
|
||||
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
|
||||
*
|
||||
* These libraries and programs are free software; you can
|
||||
* redistribute them and/or modify them under the terms of the GNU
|
||||
* Lesser General Public License as published by the Free Software
|
||||
* Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* These libraries and programs are distributed in the hope that
|
||||
* they will be useful, but WITHOUT ANY WARRANTY; without even the
|
||||
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU Lesser General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with these libraries and programs; if not, write
|
||||
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
|
||||
* Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
/* $XConsortium: toc_test.cc /main/4 1996/07/18 16:04:09 drk $ */
|
||||
|
||||
#ifdef REGRESSION_TEST
|
||||
|
||||
#include "oliasdb/toc_test.h"
|
||||
|
||||
#define LARGE_BUFSIZ 2048
|
||||
|
||||
|
||||
void print_toc(toc_smart_ptr& x, ostream& out)
|
||||
{
|
||||
x.toc_node_oid().asciiOut(out); out << "\n";
|
||||
x.parent().asciiOut(out); out << "\n";
|
||||
|
||||
out << "children of the toc: ";
|
||||
oid_list_handler* y = x.children();
|
||||
(*y) -> asciiOut(out); out << "\n";
|
||||
|
||||
delete y;
|
||||
|
||||
out << "subtree node count: ";
|
||||
out << x.subtree_size() << "\n";
|
||||
}
|
||||
|
||||
int compare_toc(toc_smart_ptr& pattern, info_base* base_ptr)
|
||||
{
|
||||
char pattern_buf[LARGE_BUFSIZ];
|
||||
ostringstream pattern_out(pattern_buf, LARGE_BUFSIZ, ios::out);
|
||||
print_toc(pattern, pattern_out);
|
||||
|
||||
toc_smart_ptr x(base_ptr, pattern.toc_node_oid());
|
||||
char db_buf[LARGE_BUFSIZ];
|
||||
ostringstream db_out(db_buf, LARGE_BUFSIZ, ios::out);
|
||||
print_toc(x, db_out);
|
||||
|
||||
return compare_stream(pattern_out, db_out);
|
||||
}
|
||||
|
||||
int
|
||||
toc_test(info_lib* infolib_ptr, const char* base_name, const char* node_id_str )
|
||||
{
|
||||
oid_t id((char*)node_id_str, true, false);
|
||||
toc_smart_ptr x( infolib_ptr, base_name, id );
|
||||
print_toc(x, cerr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void generate_toc_instance(random_gen& x, ostream& out, int instance_num, int min_nodes, int max_nodes)
|
||||
{
|
||||
out << "1003\n";
|
||||
out << "4\n";
|
||||
x.random_oid(out, 1001, instance_num); // toc node id
|
||||
x.random_oid(out, 1001, 0); // parent node id
|
||||
x.random_integer(out); //
|
||||
|
||||
out << "106\n";
|
||||
out << "#\n";
|
||||
|
||||
int nodes = x.pick_a_value(min_nodes, max_nodes);
|
||||
|
||||
for ( int i=0; i<nodes; i++ )
|
||||
x.random_oid(out, 1001, 0); // id
|
||||
|
||||
out << "#\n";
|
||||
}
|
||||
|
||||
#endif
|
||||
39
cde/lib/DtMmdb/oliasdb/toc_test.h
Normal file
39
cde/lib/DtMmdb/oliasdb/toc_test.h
Normal file
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* CDE - Common Desktop Environment
|
||||
*
|
||||
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
|
||||
*
|
||||
* These libraries and programs are free software; you can
|
||||
* redistribute them and/or modify them under the terms of the GNU
|
||||
* Lesser General Public License as published by the Free Software
|
||||
* Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* These libraries and programs are distributed in the hope that
|
||||
* they will be useful, but WITHOUT ANY WARRANTY; without even the
|
||||
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU Lesser General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with these libraries and programs; if not, write
|
||||
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
|
||||
* Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
/* $XConsortium: toc_test.h /main/4 1996/07/18 16:34:47 drk $ */
|
||||
|
||||
#ifdef REGRESSION_TEST
|
||||
|
||||
#ifndef _toc_test_h
|
||||
#define _toc_test_h
|
||||
|
||||
#include "oliasdb/toc_hd.h"
|
||||
#include "object/random_gen.h"
|
||||
|
||||
|
||||
int compare_toc(toc_smart_ptr& pattern, info_base* base_ptr);
|
||||
void generate_toc_instance(random_gen&, ostream& out, int instance_num, int min_nodes = 1, int max_nodes = 20);
|
||||
|
||||
|
||||
#endif
|
||||
#endif
|
||||
451
cde/lib/DtMmdb/oliasdb/user_base.C
Normal file
451
cde/lib/DtMmdb/oliasdb/user_base.C
Normal file
@@ -0,0 +1,451 @@
|
||||
/*
|
||||
* CDE - Common Desktop Environment
|
||||
*
|
||||
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
|
||||
*
|
||||
* These libraries and programs are free software; you can
|
||||
* redistribute them and/or modify them under the terms of the GNU
|
||||
* Lesser General Public License as published by the Free Software
|
||||
* Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* These libraries and programs are distributed in the hope that
|
||||
* they will be useful, but WITHOUT ANY WARRANTY; without even the
|
||||
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU Lesser General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with these libraries and programs; if not, write
|
||||
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
|
||||
* Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
/*
|
||||
* $XConsortium: user_base.cc /main/8 1996/08/15 14:13:12 cde-hal $
|
||||
*
|
||||
* Copyright (c) 1992 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 "oliasdb/user_base.h"
|
||||
#include "oliasdb/mark.h"
|
||||
#include "utility/debug.h"
|
||||
#include "misc/unique_id.h"
|
||||
|
||||
#define LOCK_DIR "lock"
|
||||
#define AT_LOCK "at_lock"
|
||||
#define W_LOCK "w_lock"
|
||||
#define ACCESS_INFO "access_info"
|
||||
|
||||
extern void_ptr_array g_store_array;
|
||||
extern Boolean g_transaction_on;
|
||||
|
||||
extern int g_mode_8_3;
|
||||
|
||||
user_base::user_base( const char* spec_path, rw_flag_t rw) :
|
||||
base(0), backup_file(0), rw_flag(rw), first_desc_ptr(0),
|
||||
spec_name(spec_path)
|
||||
{
|
||||
g_mode_8_3 = 1;
|
||||
int len;
|
||||
|
||||
f_obj_dict = new object_dict;
|
||||
|
||||
char* path = getenv("DTINFO_USER_DB") ;
|
||||
|
||||
if ( path == 0 ) {
|
||||
char* home = getenv("HOME");
|
||||
char* lang = getenv("LANG");
|
||||
|
||||
if ( home == 0 )
|
||||
throw(stringException("HOME unspecified"));
|
||||
if ( lang == 0 )
|
||||
throw(stringException("LANG unknown"));
|
||||
|
||||
path = form("%s/.dt/dtinfo/%s", home, lang);
|
||||
}
|
||||
|
||||
char* name = getenv("USER");
|
||||
|
||||
if ( name == 0 )
|
||||
name = (char*)"";
|
||||
|
||||
len = MIN(strlen(path), PATHSIZ - 1);
|
||||
*((char *) memcpy(base_path, path, len) + len) = '\0';
|
||||
len = MIN(strlen(name), PATHSIZ - 1);
|
||||
*((char *) memcpy(base_name, name, len) + len) = '\0';
|
||||
len = MIN(strlen(""), PATHSIZ - 1);
|
||||
*((char *) memcpy(base_desc, "", len) + len) = '\0';
|
||||
|
||||
_init();
|
||||
|
||||
}
|
||||
|
||||
|
||||
user_base::user_base( const char* base_dir,
|
||||
const char* base_nm,
|
||||
const char* base_ds,
|
||||
const char* spec_path,
|
||||
rw_flag_t rw
|
||||
) :
|
||||
base(0, 0, 0, base_dir, base_nm, base_ds, ""), backup_file(0),
|
||||
rw_flag(rw), checking_status(SUCC), first_desc_ptr(0),
|
||||
spec_name(spec_path)
|
||||
{
|
||||
g_mode_8_3 = 1;
|
||||
|
||||
f_obj_dict = new object_dict;
|
||||
|
||||
_init();
|
||||
}
|
||||
|
||||
user_base::checking_status_t user_base::check_mode()
|
||||
{
|
||||
mtry {
|
||||
|
||||
switch ( rw_flag ) {
|
||||
case user_base::READ:
|
||||
{
|
||||
if ( exist_dir(base_path) == false ) {
|
||||
return user_base::FAIL;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case user_base::WRITE:
|
||||
{
|
||||
if ( check_and_create_dir(base_path) == false ) {
|
||||
return user_base::FAIL;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mcatch (systemException&, e)
|
||||
{
|
||||
return user_base::FAIL;
|
||||
}
|
||||
end_try;
|
||||
|
||||
if ( exist_file(SCHEMA_FILE, base_path) == true )
|
||||
return user_base::SUCC;
|
||||
|
||||
if ( exist_file(form("%s.%s", base_name, SCHEMA_FILE_SUFFIX), base_path) == true )
|
||||
return user_base::SUCC;
|
||||
|
||||
return user_base::NO_BASE;
|
||||
}
|
||||
|
||||
user_base::checking_status_t user_base::check_lock()
|
||||
{
|
||||
char lock_dir[PATHSIZ+5];
|
||||
int len;
|
||||
|
||||
snprintf(lock_dir, sizeof(lock_dir), "%s/%s", base_path, LOCK_DIR);
|
||||
|
||||
if ( check_and_create_dir(lock_dir) == false ) {
|
||||
MESSAGE(cerr, form("no write permission to %s", lock_dir));
|
||||
return user_base::CREATE_LOCKFILE_FAIL;
|
||||
}
|
||||
|
||||
len = MIN(strlen(atomic_lock_path), strlen(lock_dir) + strlen(AT_LOCK) + 1);
|
||||
*((char *) memcpy(atomic_lock_path,
|
||||
form("%s/%s", lock_dir, AT_LOCK), len) + len) = '\0';
|
||||
len = MIN(strlen(write_lock_path), strlen(lock_dir) + strlen(W_LOCK) + 1);
|
||||
*((char *) memcpy(write_lock_path,
|
||||
form("%s/%s", lock_dir, W_LOCK), len) + len) = '\0';
|
||||
len = MIN(strlen(ai_path), strlen(lock_dir) + strlen(ACCESS_INFO) + 1);
|
||||
*((char *) memcpy(ai_path,
|
||||
form("%s/%s", lock_dir, ACCESS_INFO), len) + len) = '\0';
|
||||
|
||||
char* ai_info = 0;
|
||||
|
||||
switch (rw_flag) {
|
||||
case user_base::READ:
|
||||
|
||||
if (
|
||||
read_lock(atomic_lock_path, write_lock_path,
|
||||
ai_path, access_info((char*)"read"), offset, ai_info
|
||||
) == false
|
||||
) {
|
||||
if ( ai_info ) {
|
||||
debug(cerr, ai_info);
|
||||
delete [] ai_info;
|
||||
}
|
||||
return user_base::RLOCK_FAIL;
|
||||
} else
|
||||
return user_base::SUCC;
|
||||
break;
|
||||
|
||||
case user_base::WRITE:
|
||||
|
||||
if (
|
||||
write_lock(atomic_lock_path, write_lock_path,
|
||||
ai_path, access_info((char*)"write"), ai_info
|
||||
) == false
|
||||
) {
|
||||
if ( ai_info ) {
|
||||
debug(cerr, ai_info);
|
||||
|
||||
//
|
||||
// int x = strlen(ai_info);
|
||||
// if ( x >= 5 && strncmp(ai_info + x - 5, "read", 4) == 0 )
|
||||
// {
|
||||
// rw_flag = user_base::READ;
|
||||
// MESSAGE(cerr, "write locking failed, try read mode");
|
||||
// int ok = check_lock();
|
||||
// delete ai_info;
|
||||
// return ok;
|
||||
// }
|
||||
|
||||
delete [] ai_info;
|
||||
}
|
||||
return user_base::WLOCK_FAIL;
|
||||
} else {
|
||||
return user_base::SUCC;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
abort();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void user_base::_init()
|
||||
{
|
||||
set_mode(HEALTH, true);
|
||||
|
||||
checking_status = check_mode();
|
||||
|
||||
MESSAGE(cerr, "Initial mode");
|
||||
debug(cerr, checking_status);
|
||||
|
||||
first_desc_ptr = 0;
|
||||
|
||||
switch ( checking_status ) {
|
||||
|
||||
case user_base::NO_BASE:
|
||||
|
||||
if ( disk_space(base_path) < 10*KB ) {
|
||||
checking_status = user_base::FAIL;
|
||||
break;
|
||||
}
|
||||
|
||||
mtry
|
||||
{
|
||||
ubase_trans.begin();
|
||||
|
||||
define();
|
||||
|
||||
ubase_trans.sync();
|
||||
ubase_trans.end();
|
||||
|
||||
}
|
||||
|
||||
mcatch (beginTransException &,e)
|
||||
{
|
||||
// cases: can't open log or write size info to log
|
||||
checking_status = user_base::FAIL;
|
||||
clean_up();
|
||||
break;
|
||||
}
|
||||
mcatch (commitTransException &,e)
|
||||
{
|
||||
// cases: bad log file, can't write to store, etc.
|
||||
checking_status = user_base::FAIL;
|
||||
clean_up();
|
||||
break;
|
||||
}
|
||||
// cases: can't do define()
|
||||
mcatch (mmdbException &,e)
|
||||
{
|
||||
checking_status = user_base::FAIL;
|
||||
ubase_trans.rollback();
|
||||
ubase_trans.abort();
|
||||
clean_up();
|
||||
break;
|
||||
|
||||
}
|
||||
end_try;
|
||||
|
||||
checking_status = check_mode();
|
||||
break;
|
||||
|
||||
case user_base::SUCC:
|
||||
|
||||
mtry {
|
||||
ubase_trans.begin();
|
||||
|
||||
first_desc_ptr = f_obj_dict -> init_a_base(base_path, base_name);
|
||||
|
||||
ubase_trans.end();
|
||||
}
|
||||
|
||||
mcatch (mmdbException &,e) {
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "mmdbException caught @ %s line:%d.\n",
|
||||
__FILE__, __LINE__);
|
||||
#endif
|
||||
ubase_trans.abort();
|
||||
|
||||
set_mode(HEALTH, false);
|
||||
checking_status = user_base::FAIL;
|
||||
break;
|
||||
} end_try;
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
set_mode(HEALTH, false);
|
||||
break;
|
||||
}
|
||||
|
||||
#ifndef NO_DB_LOCK
|
||||
if ( checking_status == user_base::SUCC ) {
|
||||
checking_status = check_lock();
|
||||
debug(cerr, checking_status);
|
||||
if ( checking_status != user_base::SUCC ) {
|
||||
set_mode(HEALTH, false);
|
||||
return;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
MESSAGE(cerr, "Final mode"); debug(cerr, checking_status);
|
||||
|
||||
switch ( checking_status ) {
|
||||
|
||||
case user_base::SUCC:
|
||||
set_mode(HEALTH, true);
|
||||
MESSAGE(cerr, form("userbase \"%s\" available", base_name));
|
||||
break;
|
||||
|
||||
default:
|
||||
set_mode(HEALTH, false);
|
||||
break;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
user_base::~user_base()
|
||||
{
|
||||
if ( checking_status == user_base::SUCC &&
|
||||
exist_dir(form("%s/%s", base_path, LOCK_DIR)) == true )
|
||||
{
|
||||
|
||||
#ifndef NO_DB_LOCK
|
||||
switch (rw_flag) {
|
||||
case user_base::READ:
|
||||
read_unlock(atomic_lock_path, ai_path, offset);
|
||||
break;
|
||||
case user_base::WRITE:
|
||||
write_unlock(atomic_lock_path, write_lock_path, ai_path);
|
||||
);
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
delete f_obj_dict;
|
||||
}
|
||||
|
||||
void user_base::clean_up()
|
||||
{
|
||||
abs_storage* store_ptr = 0;
|
||||
desc* desc_ptr = first_desc_ptr;
|
||||
|
||||
while ( desc_ptr ) {
|
||||
store_ptr = desc_ptr -> get_store();
|
||||
|
||||
if ( store_ptr ) {
|
||||
mtry {
|
||||
/*
|
||||
MESSAGE(cerr, "removing: ");
|
||||
MESSAGE(cerr, store_ptr -> my_name());
|
||||
*/
|
||||
store_ptr->remove();
|
||||
}
|
||||
mcatch (mmdbException &,e)
|
||||
{
|
||||
} end_try;
|
||||
}
|
||||
desc_ptr = desc_ptr -> get_next_desc();
|
||||
}
|
||||
|
||||
if ( exist_file(SCHEMA_FILE, base_path) == true )
|
||||
del_file(SCHEMA_FILE, base_path);
|
||||
}
|
||||
|
||||
Boolean user_base::define()
|
||||
{
|
||||
int len;
|
||||
|
||||
if ( check_and_create_dir(base_path) == false ) {
|
||||
throw(stringException(form("can't create %s", base_path)));
|
||||
}
|
||||
|
||||
char spec_file_path[PATHSIZ];
|
||||
|
||||
//char* x = getenv("DTINFO_LIB");
|
||||
char* x = getenv("DTINFO_MARKSPECPATH");
|
||||
|
||||
if ( x == 0 ) {
|
||||
len = MIN(strlen(spec_name), PATHSIZ - 1);
|
||||
*((char *) memcpy(spec_file_path, spec_name, len) + len) = '\0';
|
||||
}
|
||||
else {
|
||||
len = MIN(strlen(x) + strlen(spec_name) + 1, PATHSIZ - 1);
|
||||
*((char *) memcpy(spec_file_path,
|
||||
form("%s/%s", x, spec_name), len) + len) = '\0';
|
||||
}
|
||||
|
||||
if (exist_file(spec_file_path) == false) {
|
||||
|
||||
debug(cerr, spec_file_path);
|
||||
|
||||
throw(stringException(
|
||||
form("missing %s. can't define user_base", spec_file_path)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/*
|
||||
char unique_nm[PATHSIZ];
|
||||
const char* uid;
|
||||
uid = unique_id();
|
||||
len = MIN(strlen(base_name) + strlen(uid) + 1, PATHSIZ - 1);
|
||||
*((char *) memcpy(unique_nm,
|
||||
form("%s.%s", base_name, uid), len) + len) = '\0';
|
||||
*/
|
||||
|
||||
first_desc_ptr =
|
||||
f_obj_dict -> init_a_base(spec_file_path, base_path, base_name);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
130
cde/lib/DtMmdb/oliasdb/user_base.h
Normal file
130
cde/lib/DtMmdb/oliasdb/user_base.h
Normal file
@@ -0,0 +1,130 @@
|
||||
/*
|
||||
* CDE - Common Desktop Environment
|
||||
*
|
||||
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
|
||||
*
|
||||
* These libraries and programs are free software; you can
|
||||
* redistribute them and/or modify them under the terms of the GNU
|
||||
* Lesser General Public License as published by the Free Software
|
||||
* Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* These libraries and programs are distributed in the hope that
|
||||
* they will be useful, but WITHOUT ANY WARRANTY; without even the
|
||||
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU Lesser General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with these libraries and programs; if not, write
|
||||
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
|
||||
* Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
/*
|
||||
* $XConsortium: user_base.h /main/4 1996/06/11 17:31:14 cde-hal $
|
||||
*
|
||||
* Copyright (c) 1992 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 _user_base_h
|
||||
#define _user_base_h 1
|
||||
|
||||
#include "utility/funcs.h"
|
||||
#include "utility/rw_lock.h"
|
||||
#include "api/utility.h"
|
||||
#include "api/base.h"
|
||||
#include "api/transaction.h"
|
||||
#include "object/oid_list.h"
|
||||
#include "oliasdb/olias_consts.h"
|
||||
|
||||
/*************************************/
|
||||
// The user_base class
|
||||
/*************************************/
|
||||
|
||||
class user_base : public base
|
||||
{
|
||||
|
||||
public:
|
||||
enum rw_flag_t { READ, WRITE };
|
||||
enum checking_status_t { SUCC,
|
||||
NO_BASE,
|
||||
FAIL,
|
||||
/*
|
||||
NO_READ_PERMISSION,
|
||||
NO_WRITE_PERMISSION,
|
||||
*/
|
||||
CREATE_LOCKFILE_FAIL,
|
||||
RLOCK_FAIL,
|
||||
WLOCK_FAIL
|
||||
};
|
||||
|
||||
checking_status_t open_status() { return checking_status ; }
|
||||
|
||||
user_base( const char* base_dir,
|
||||
const char* base_name,
|
||||
const char* base_desc,
|
||||
const char* spec_path,
|
||||
rw_flag_t = user_base::READ
|
||||
);
|
||||
user_base(const char* spec_path, rw_flag_t = user_base::READ);
|
||||
virtual ~user_base();
|
||||
|
||||
Boolean define();
|
||||
rw_flag_t rw_mode() { return rw_flag; };
|
||||
|
||||
transaction& trans() { return ubase_trans; };
|
||||
|
||||
protected:
|
||||
void _init();
|
||||
|
||||
user_base::checking_status_t check_mode();
|
||||
user_base::checking_status_t check_lock();
|
||||
|
||||
void clean_up();
|
||||
|
||||
|
||||
protected:
|
||||
ostream* backup_file;
|
||||
rw_flag_t rw_flag;
|
||||
checking_status_t checking_status;
|
||||
|
||||
char atomic_lock_path[PATHSIZ];
|
||||
char write_lock_path[PATHSIZ];
|
||||
char ai_path[PATHSIZ];
|
||||
int offset;
|
||||
|
||||
desc* first_desc_ptr;
|
||||
const char* spec_name;
|
||||
|
||||
transaction ubase_trans;
|
||||
|
||||
object_dict *f_obj_dict;
|
||||
};
|
||||
|
||||
typedef user_base* user_basePtr;
|
||||
|
||||
extern user_basePtr default_user_base;
|
||||
|
||||
#endif
|
||||
31
cde/lib/DtMmdb/oliasdb/user_config.h
Normal file
31
cde/lib/DtMmdb/oliasdb/user_config.h
Normal file
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* CDE - Common Desktop Environment
|
||||
*
|
||||
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
|
||||
*
|
||||
* These libraries and programs are free software; you can
|
||||
* redistribute them and/or modify them under the terms of the GNU
|
||||
* Lesser General Public License as published by the Free Software
|
||||
* Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* These libraries and programs are distributed in the hope that
|
||||
* they will be useful, but WITHOUT ANY WARRANTY; without even the
|
||||
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU Lesser General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with these libraries and programs; if not, write
|
||||
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
|
||||
* Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
/* $XConsortium: user_config.h /main/3 1996/06/11 17:31:19 cde-hal $ */
|
||||
|
||||
#ifndef _user_config_h
|
||||
#define _user_config_h 1
|
||||
|
||||
#include "oliasdb/pref.h"
|
||||
|
||||
#endif
|
||||
|
||||
31
cde/lib/DtMmdb/oliasdb/user_mark.h
Normal file
31
cde/lib/DtMmdb/oliasdb/user_mark.h
Normal file
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* CDE - Common Desktop Environment
|
||||
*
|
||||
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
|
||||
*
|
||||
* These libraries and programs are free software; you can
|
||||
* redistribute them and/or modify them under the terms of the GNU
|
||||
* Lesser General Public License as published by the Free Software
|
||||
* Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* These libraries and programs are distributed in the hope that
|
||||
* they will be useful, but WITHOUT ANY WARRANTY; without even the
|
||||
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU Lesser General Public License for more
|
||||
* details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with these libraries and programs; if not, write
|
||||
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
|
||||
* Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
/* $XConsortium: user_mark.h /main/3 1996/06/11 17:31:24 cde-hal $ */
|
||||
|
||||
#ifndef _user_mark_h
|
||||
#define _user_mark_h 1
|
||||
|
||||
#include "oliasdb/mark.h"
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user