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

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

140
cde/lib/DtSearch/Imakefile Normal file
View File

@@ -0,0 +1,140 @@
XCOMM $XConsortium: Imakefile /main/13 1996/08/20 15:21:22 rws $
#define IHaveSubdirs
#define PassCDebugFlags /**/
SUBDIRS = raima
EXTRALIBRARYDEPS = raima/DONE
#ifdef AlphaArchitecture
EXTRA_DEFINES = -DBYTE_SWAP -D_OSF_SOURCE
#endif
#ifdef USLArchitecture
EXTRA_DEFINES = -DBYTE_SWAP
#endif
MakeSubdirs($(SUBDIRS))
ForceSubdirs($(SUBDIRS))
DependSubdirs($(SUBDIRS))
#define DoNormalLib NormalLibDtSearch
#define DoSharedLib SharedLibDtSearch
#define DoDebugLib DebugLibDtSearch
#define DoProfileLib ProfileLibDtSearch
#define LibName DtSearch
#define SoRev SODTSEARCHREV
#define IncSubdir Dt
#ifndef DtSearchDefines
# define DtSearchDefines -DI18N_MSG -DXK_MISCELLANY -DMULTIBYTE
#endif
DEFINES = DtSearchDefines
INCLUDES = -I. -I./raima
YFLAGS = -d
#ifdef SharedDtSearchReqs
REQUIREDLIBS = SharedDtSearchReqs
#endif
HEADERS = \
Search.h \
SearchE.h \
SearchP.h \
boolpars.h \
boolyac.h \
dberr.h \
dproto.h
SRCS = \
apndext.c ausdopen.c ausexit.c \
bmstrstr.c boolpars.c boolsrch.c \
boolyac.c cuslang.c dbchange.c \
dberr.c delspace.c dtoe.c \
dtoeinit.c dtsrapi.c dtsrdbrec.c \
dtsrjoint.c dtsrswab.c \
dtsrutil.c dtsrve.c \
endslash.c fileman.c globals.c \
hdecode.c hencode.c hilite.c \
iscompat.c isduprec.c jpn.c \
lang.c langmap.c msgs.c \
msgutil.c objdate.c ocf.c \
opendblk.c ophuf.c readchar.c \
strupr.c userint.c vedelete.c \
vestatis.c vstfunct.c
OBJS1 = \
apndext.o ausdopen.o ausexit.o \
bmstrstr.o boolpars.o boolsrch.o \
boolyac.o cuslang.o dbchange.o \
dberr.o delspace.o dtoe.o \
dtoeinit.o dtsrapi.o dtsrdbrec.o \
dtsrjoint.o dtsrswab.o \
dtsrutil.o dtsrve.o \
endslash.o fileman.o globals.o \
hdecode.o hencode.o hilite.o \
iscompat.o isduprec.o jpn.o \
lang.o langmap.o msgs.o \
msgutil.o objdate.o ocf.o \
opendblk.o ophuf.o readchar.o \
strupr.o userint.o vedelete.o \
vestatis.o vstfunct.o
RAIMA_OBJS = \
raima/alloc.o raima/cmstat.o \
raima/cmtype.o raima/connect.o \
raima/costat.o raima/cotype.o \
raima/crget.o raima/crread.o \
raima/crset.o raima/crstat.o \
raima/crtype.o raima/crwrite.o \
raima/csmget.o raima/csmread.o \
raima/csmset.o raima/csmwrite.o \
raima/csoget.o raima/csoread.o \
raima/csoset.o raima/csowrite.o \
raima/csstat.o raima/ctscm.o \
raima/ctsco.o raima/ctscr.o \
raima/dbacode.o raima/dbdpath.o \
raima/dbfpath.o raima/dblfcns.o \
raima/dbswab.o \
raima/dbuserid.o raima/delete.o \
raima/destroy.o raima/dio.o \
raima/discon.o raima/disdel.o \
raima/fillnew.o raima/findco.o \
raima/findfm.o raima/findlm.o \
raima/findnm.o raima/findpm.o \
raima/gtscm.o raima/gtsco.o \
raima/gtscr.o raima/gtscs.o \
raima/initial.o raima/inittab.o \
raima/ismember.o raima/isowner.o \
raima/keydel.o raima/keyexist.o \
raima/keyfcns.o raima/keyfind.o \
raima/keyfrst.o raima/keylast.o \
raima/keynext.o raima/keyprev.o \
raima/keystore.o raima/libfcns.o \
raima/makenew.o raima/mapchar.o \
raima/members.o raima/netunix.o \
raima/oflag.o raima/opens.o \
raima/options.o raima/pathfcns.o \
raima/recfcns.o raima/recfrst.o \
raima/reclast.o raima/recnext.o \
raima/recprev.o raima/recread.o \
raima/recset.o raima/recstat.o \
raima/recwrite.o raima/renfile.o \
raima/rwcurr.o raima/setdb.o \
raima/setmm.o raima/setmo.o \
raima/setmr.o raima/setom.o \
raima/setoo.o raima/setor.o \
raima/setrm.o raima/setro.o \
raima/startup.o raima/stscm.o \
raima/stsco.o raima/stscr.o \
raima/stscs.o raima/utscm.o \
raima/utsco.o raima/utscr.o \
raima/utscs.o
OBJS = $(OBJS1) $(RAIMA_OBJS)
YaccFile(boolyac,$(YFLAGS))
#include <Library.tmpl>
DependTarget()

263
cde/lib/DtSearch/Search.h Normal file
View File

@@ -0,0 +1,263 @@
/* $TOG: Search.h /main/12 1998/04/03 17:10:35 mgreess $
*
* (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 1996 FUJITSU LIMITED.
* (c) Copyright 1996 Hitachi.
*/
/*
* COMPONENT_NAME: austext
*
* FUNCTIONS: none
*
* ORIGINS: 27
*
*
* (C) COPYRIGHT International Business Machines Corp. 1994,1995
* All Rights Reserved
* Licensed Materials - Property of IBM
* US Government Users Restricted Rights - Use, duplication or
* disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
*/
#ifndef _Search_h
#define _Search_h
/********************** Search.h ***********************
* $TOG: Search.h /main/12 1998/04/03 17:10:35 mgreess $
* Jan 1994.
* Public header file for DtSearch/AusText API.
* Formerly named ausapi.h. Externals renamed
* from ausapi_... or aa_... to DtSearch conventions.
* Documentation in dtsearch.doc.
*
*/
#ifndef _XOPEN_SOURCE
#define _XOPEN_SOURCE 1
#endif
#include <time.h>
#include <stdio.h>
#include <string.h>
#if defined(linux)
# define __SVR4_I386_ABI_L1__
#endif
#include <limits.h>
#if defined(linux)
# undef __SVR4_I386_ABI_L1__
# ifndef WORD_BIT
# define WORD_BIT 32
# endif
# ifndef LONG_BIT
# define LONG_BIT 32
# endif
#endif
#define DtSrVERSION "0.6"
#define DtSrMAXHITS 20
#define DtSrMAX_KTNAME 13
#define DtSrMAX_DB_KEYSIZE 32
#define DtSrMAXWIDTH_HWORD 134
#define DtSrMAX_STEMCOUNT 8
/****************************************/
/* */
/* RETURN CODES */
/* */
/****************************************/
#define DtSrOK 0 /* normal, successful response */
#define DtSrPASSWD 1 /* failed communications authentication */
#define DtSrNOTAVAIL 2 /* no hits on search, no such rec, etc */
#define DtSrFAIL 3 /* misc unsuccessful engine returns */
#define DtSrREINIT 4 /* engine reinitialized, request canceled */
#define DtSrERROR 5 /* fatal caller (client) program error */
#define DtSrABORT 6 /* fatal engine failure, caller must abort */
#define DtSrCOMM 7 /* fatal communications failure */
/* In order to share databases among heterogenous machines,
* certain integer types must be defined that are invariably
* 2 and 4 bytes on all architectures.
* Note WORD_BIT == 32 does not guarantee short == 16.
*/
#if (WORD_BIT == 16)
typedef int DtSrINT16;
typedef unsigned int DtSrUINT16;
#elif (WORD_BIT == 32)
typedef short DtSrINT16;
typedef unsigned short DtSrUINT16;
#else
#error Unable to typedef DtSrINT16 and DtSrUINT16
#endif
#if (WORD_BIT == 32)
typedef int DtSrINT32;
typedef unsigned int DtSrUINT32;
#elif (LONG_BIT == 32)
typedef long DtSrINT32;
typedef unsigned long DtSrUINT32;
#else
#error Unable to typedef DtSrINT32 and DtSrUINT32
#endif
#ifndef DB_ADDR
typedef DtSrINT32 DB_ADDR; /* vista.h: must be 4 bytes */
#endif
#ifndef TRUE
#define TRUE 1
#endif
#ifndef FALSE
#define FALSE 0
#endif
typedef DtSrUINT32 DtSrObjdate;
/****************************************/
/* */
/* DtSrKeytype */
/* */
/****************************************/
typedef struct {
char is_selected; /* TRUE: user has selected this keytype */
char ktchar; /* first char of opera record key */
char name [DtSrMAX_KTNAME+1]; /* label string used in UI */
} DtSrKeytype;
/****************************************/
/* */
/* DtSrResult */
/* */
/****************************************/
/* DtSrResult ormerly DITTO. DtSrObj types formerly ORT_. */
typedef struct _DtSrResult {
struct _DtSrResult *link; /* ptr to next list node */
DtSrUINT32 flags; /* (reserved) */
DtSrINT32 objflags; /* flags from object record */
#define DtSrFlDELETE (1<<0) /* (reserved) */
#define DtSrFlOLDNOTES (1<<1) /* (reserved) */
#define DtSrFlNOTAVAIL (1<<2) /* object not retrievable from engine */
DtSrUINT32 objuflags; /* user flags from database rec */
DtSrINT32 objsize; /* in uncompressed bytes */
DtSrObjdate objdate; /* zero means object 'undated' */
DtSrINT16 objtype; /* from database record */
#define DtSrObjUNKNOWN 0 /* object type unknown or not applicable */
#define DtSrObjTEXT 1 /* generic, unformatted flat text */
#define DtSrObjBINARY 2 /* generic binary object */
#define DtSrObjSGML 3 /* generic SGML formatted document */
#define DtSrObjHTML 4 /* HTML formatted document */
#define DtSrObjPOSTSCR 6 /* Postscript document */
#define DtSrObjINTERLF 7 /* Interleaf document */
#define DtSrObjDTINFO 8 /* DtInfo document */
DtSrINT16 objcost; /* (reserved) */
int dbn; /* dbnamesv index */
DB_ADDR dba; /* data base addr within database */
DtSrINT16 language; /* language of the database */
#define DtSrLaENG 0 /* English, ASCII char set (default) */
#define DtSrLaENG2 1 /* English, ISO Latin-1 char set */
#define DtSrLaESP 2 /* Spanish, ISO Latin-1 char set */
#define DtSrLaFRA 3 /* French, ISO Latin-1 char set */
#define DtSrLaITA 4 /* Italian, ISO Latin-1 char set */
#define DtSrLaDEU 5 /* German, ISO Latin-1 char set */
#define DtSrLaJPN 6 /* Japanese, EUC, auto kanji compounds */
#define DtSrLaJPN2 7 /* Japanese, EUC, listed kanji compounds */
#define DtSrLaLAST 7 /* Last supported DtSrLa constant */
char reckey [DtSrMAX_DB_KEYSIZE]; /* object's db key */
int proximity; /* 'distance' of object from query */
char *abstractp; /* object's abstract from db*/
} DtSrResult;
/****************************************/
/* */
/* DtSrHitword */
/* */
/****************************************/
typedef struct {
long offset; /* word location in cleartext */
long length; /* length of word */
} DtSrHitword;
/************************************************/
/* */
/* Functions */
/* */
/************************************************/
extern void DtSearchAddMessage (char *msg);
extern int DtSearchHasMessages (void);
extern char *DtSearchGetMessages (void);
extern void DtSearchFreeMessages (void);
extern int DtSearchGetMaxResults (void);
extern void DtSearchSetMaxResults (int new_max_results);
extern char *DtSearchFormatObjdate (DtSrObjdate objdate);
extern void DtSearchExit (int return_code);
extern void DtSearchAddUserExit (void (*user_exit)(int));
extern void DtSearchRemoveUserExit (void);
extern int DtSearchSortResults (DtSrResult **list, int sort_type);
#define DtSrSORT_PROX 1 /* sort on proximity */
#define DtSrSORT_DATE 2 /* sort on objdate */
extern int DtSearchMergeResults (DtSrResult **targ, DtSrResult **src);
extern int DtSearchFreeResults (DtSrResult **list);
extern DtSrObjdate
DtSearchValidDateString (char *date_string);
extern int DtSearchInit (
char *argv0,
char *userid,
long switches,
char *config_file,
FILE *err_file,
char ***dbnames,
int *dbcount);
/* Bit values valid for switches argument: */
#define DtSrInNOLOCALE 0x0001L /* do not exec setlocale() */
#define DtSrInSIGNAL 0x0002L /* register abort signal handlers */
#define DtSrInUSEROCF 0x0004L /* (reserved) */
#define DtSrInENAB_NOHUP 0x0008L /* enab nohup for backgnd progms */
#define DtSrInIDEBUG 0x0010L /* set initialization debugging */
#define DtSrInSDEBUG 0x0020L /* set search debugging */
#define DtSrInRDEBUG 0x0040L /* set retrieval debugging */
#define DtSrInCDEBUG 0x0080L /* set communications debugging */
#define DtSrInANY_DEBUG \
(DtSrInIDEBUG | DtSrInSDEBUG | DtSrInRDEBUG | DtSrInCDEBUG)
#define DtSrInRDWR 0x0100L /* open db files for read and write */
extern int DtSearchReinit (
char ***dbnames,
int *dbcount);
extern int DtSearchGetKeytypes (
char *dbname,
int *ktcount,
DtSrKeytype **keytypes);
extern int DtSearchQuery (
void *qry,
char *dbname,
int search_type,
char *date1,
char *date2,
DtSrResult **results,
long *resultscount,
char *stems,
int *stemcount);
extern int DtSearchRetrieve (
char *dbname,
DB_ADDR dba,
char **cleartext,
long *clearlen,
int *fzkeyi);
extern int DtSearchHighlight (
char *dbname,
char *cleartext,
DtSrHitword **hitwptr,
long *hitwcount,
int search_type,
char *stems,
int stemcount);
/********************** Search.h ***********************/
#endif /* _Search_h */

617
cde/lib/DtSearch/SearchE.h Normal file
View File

@@ -0,0 +1,617 @@
/*
* COMPONENT_NAME: austext
*
* FUNCTIONS: none
*
* ORIGINS: 27
*
*
* (C) COPYRIGHT International Business Machines Corp. 1991,1995
* All Rights Reserved
* Licensed Materials - Property of IBM
* US Government Users Restricted Rights - Use, duplication or
* disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
*/
#ifndef _SearchE_h
#define _SearchE_h
/***************************** SearchE.h ******************************
* $XConsortium: SearchE.h /main/5 1996/08/12 13:16:47 cde-ibm $
* August 1991.
* Header file for online DtSearch Engine (OE.C etc).
* SearchE.h was formerly called oe.h (Opera Engine).
* The old OE engine is pretty much invisible now, having
* been surrounded by the ausapi/DtSearch interface.
*
* The main data structure for passing and receiving arguments
* between the callers and the engine is USRBLK which is
* the only argument in the Opera_Engine() call.
* The actual input and output arguments in the USRBLK for each
* function are described below with the function description.
*
* All OE_functions pass a return code
* to the caller. OE_OK = successful completion,
* anything else may be partial completion/success or failure.
* Return code mnemonics are also defined below.
*
* $Log$
* Revision 2.7 1996/03/20 19:11:21 miker
* Changed prototype of hilite_cleartext().
*
* Revision 2.6 1996/03/13 22:34:53 miker
* Changed char to UCHAR several places.
*
* Revision 2.5 1996/03/05 19:17:50 miker
* oe_unblob no longer converts to uppercase.
*
* Revision 2.4 1996/03/05 15:54:06 miker
* Minor changes to support yacc-based boolean search.
*
* Revision 2.3 1996/02/01 16:14:38 miker
* Obsoleted requests OE_DITTO2KWIC, OE_VALIDATE_PWD, OE_CHANGE_PWD,
* OE_FINDSTR_REC, OE_FINDSTR_HITL, OE_ASSIST, OE_KILL.
* Restored OE_PING as the official "null" function.
* Added USRDBG_HILITE and USRDBG_PARSE.
* Replaced STRKIND, OE_kind_of_stems, and oe_stems_to_hitwords
* with hilite_cleartext. Deleted oe_ditto2kwic, oe_findstr_hitl.
* Deleted usrblk.kwiclen.
*
* Revision 2.2 1995/10/25 22:35:45 miker
* Added prolog.
*
* Revision 2.1 1995/09/22 22:39:39 miker
* Freeze DtSearch 0.1, AusText 2.1.8
*
* Revision 1.1 1995/08/31 20:42:33 miker
* Initial revision
*
* The DtSearch return codes wrap around the OE return codes.
*/
#include "SearchP.h"
#define AUDIT_FORMAT "UID=%-8s TIME=%s ELAP=%-3ld DB=%-8s HITS=%-5ld "
#define AUDIT_WHOWHEN "UID=%-8s TIME=%s"
#define DISCARD_FORMAT "%s\t\"%s\"\t%s\t%s\n"
#define HARDCOPY_SCRIPT "opprt.bat"
#define MAX_HITWCOUNT 200 /* max number hitwords that can be hilited */
#define WORDS_HITLIMIT 300000L
/*-------------------- Request Codes ------------------------
* All Engine requests, in addition to input below, require valid
* usrblk.userid
* usrblk.request.
* All Engine requests, in addition to output below,
* may return ausapi_msglist.
* There is no zero request code.
* See list of return codes for the ones that are marked 'common retncodes'.
*/
#define OE_INITIALIZE 1
/* does lotsa stuff--see the function.
* input:
* .query = AUSAPI_VERSION of UI code
* .dblist = data from user config file
* .dblk = data from user config file
* output:
* .dblist = modified after load of site config file
* .dblk = modified after load of site config file
* .retncode = OE_OK, OE_NOTAVAIL, OE_ABORT
*/
#define OE_TEXT2FZKEY 2
/* converts problem description text to fzkey.
* input:
* .query = problem description text
* .dblk = desired database and db parameters
* output:
* .fzkey = inference from query text analysis
* .retncode = common retncodes + OE_BAD_QUERY
*/
#define OE_SRCH_FZKEY 3
/* Converts fzkey to hitlist of dba's.
* Not available for databases without semantic dictionaries.
* input:
* .fzkey = database search vector
* .dblk = desired database and db parameters
* output:
* .workproc = function to be called until !OE_SEARCHING
* .dittolist = hitlist sorted by proximity
* .dittocount = # of nodes on dittolist
* .retncode = common retncodes + OE_SEARCHING, OE_NOTAVAIL,
* OE_USER_STOP, OE_SYSTEM_STOP, OE_BAD_QUERY
*/
#define OE_SRCH_STEMS 4
/* converts string of wordstems and booleans to
* hitlist of dba's and stems array.
* input:
* .query = text string of wordstems and booleans
* .dblk = desired database and db parameters
* output:
* .fzkey = (value undefined)
* .workproc = function to be called until !OE_SEARCHING
* .dittolist = hitlist
* .dittocount = # of nodes on dittolist
* .stems = array of stems for hiliting in text of hits
* .stemcount = size of 'stems' array
* .retncode = common retncodes + OE_BAD_QUERY, OE_SEARCHING,
* OE_NOTAVAIL, OE_USER_STOP
*/
#define OE_SRCH_WORDS 5
/* converts string of exact words and booleans to
* hitlist of dba's and stems array.
* input:
* .query = text string of exact words and booleans
* .dblk = desired database and db parameters
* output:
* .fzkey = (value undefined)
* .workproc = function to be called until !OE_SEARCHING
* .dittolist = hitlist
* .dittocount = # of nodes on dittolist
* .stems = array of words for hiliting in text of hits
* .stemcount = size of 'stems' array
* .retncode = common retncodes + OE_BAD_QUERY, OE_SEARCHING,
* OE_NOTAVAIL, OE_USER_STOP
*/
#define OE_STOP_SRCH 6
/* sets global switch to cancel search work procedure.
* workproc actually cancels itself after reading switch.
* input: .request = OE_STOP_SEARCH
* output: .retncode = 'common retncodes' only
*/
#define OE_APPEND_NOTES 7
/* appends user's notes to record at current dba.
* input:
* .query = freeform text of append
* .dba = address of record to append
* .dblk = desired database and db parameters
* output:
* .retncode = common retncodes + OE_TIMEOUT, OE_DISABLED
*/
#define OE_GETREC 8
/* retrieves record, cleartext, and notes for specified dba.
* Clears hitwords array, does not use or change stems array.
* input:
* .dba = address of record to retrieve
* .dblk = desired database and db parameters
* output:
* .objrec = austext record itself, as is from vista
* .cleartext = NULL or uncompressed text string
* .clearlen = 0 or size of cleartext
* .hitwords = array pointer cleared to NULL
* .hitwcount = size of hitwords array set to 0
* .notes = NULL, or list of notes records, as is
* .retncode = common retncodes + OE_NOTAVAIL
*/
#define OE_GETREC_STEMS 9
/* retrieves record, cleartext, notes, and hitwords
* array for specified dba and stems (from OE_SRCH_STEMS).
* If no text in repository, equivalent to OE_GETREC.
* input:
* .dba = address of record to retrieve
* .stems = array of word stems to hilite
* .stemcount = size of stems array
* .dblk = desired database and db parameters
* output:
* .objrec = austext record itself, as is from vista
* .cleartext = NULL or uncompressed text string
* .clearlen = 0 or size of cleartext
* .hitwords = NULL or array of words in cleartext to hilite
* .hitwcount = 0 or size of hitwords array
* .notes = NULL, or list of notes records, as is
* .retncode = common retncodes + OE_NOTAVAIL
*/
#define OE_GETREC_WORDS 10
/* retrieves record, cleartext, notes, and hitwords
* array for specified dba and stems array (from OE_SRCH_WORDS).
* If no text in repository, equivalent to OE_GETREC.
* input:
* .dba = address of record to retrieve
* .stems = array of exact words to hilite
* .stemcount = size of stems array
* .dblk = desired database and db parameters
* output:
* .objrec = austext record itself, as is from vista
* .cleartext = NULL or uncompressed text string
* .clearlen = 0 or size of cleartext
* .hitwords = NULL or array of words in cleartext to hilite
* .hitwcount = 0 or size of hitwords array
* .notes = NULL, or list of notes records, as is
* .retncode = common retncodes + OE_NOTAVAIL
*/
#define OE_NEXT_DBA 11
/* advances dba to next valid b-tree address. Wraps if necessary.
* input:
* .dba = current address of record
* .dblk = desired database and db parameters
* output:
* .dba = address of next record in b-tree
* .retncode = common retncodes + OE_WRAPPED
*/
#define OE_PREV_DBA 12
/* retreats dba to previous valid b-tree address.
* Wraps if necessary.
* input:
* .dba = current address of record
* .dblk = desired database and db parameters
* output:
* .dba = address of previous record in b-tree
* .retncode = common retncodes + OE_WRAPPED
*/
#define OE_RECKEY2DBA 13
/* converts an austext record key into a dba. Wraps if not found.
* input:
* .query = desired record key
* .dblk = desired database and db parameters
* output:
* .dba = address of record found,
* or next avail address if not found
* .retncode = common retncodes + OE_WRAPPED
*/
#define OE_MARK_DELETION 14
/* writes record id to an external file for
* possible later deletion by external program.
* input:
* .query = record key to be marked for deletion
* .dblk = database where record is located
* output:
* .retncode = common retncodes + OE_NOTAVAIL, OE_DISABLED
*/
#define OE_GETREC_DIC 15
/* THIS FUNCTION IS NO LONGER SUPPORTED.
* IF RECEIVED BY ENGINE, IT IS TREATED EXACTLY AS OE_GETREC.
* Retrieves record, cleartext, notes, and hitwords
* array for specified dba. Hitwords are not derived from the
* stems array; they are all the cleartext words that are in
* the dictionary. (Compare to OE_GETREC_WORDS and OE_GETREC_STEMS).
* If no text in repository, equivalent to OE_GETREC.
* input:
* .dba = address of record to retrieve
* .dblk = desired database and db parameters
* output:
* .objrec = austext record itself, as is from vista
* .cleartext = NULL or uncompressed text string
* .clearlen = 0 or size of cleartext
* .hitwords = NULL or array of words in cleartext to hilite
* .hitwcount = 0 or size of hitwords array
* .notes = NULL, or list of notes records, as is
* .retncode = common retncodes + OE_NOTAVAIL
*/
#define OE_DITTO2KWIC 16
#define OE_VALIDATE_PWD 17
#define OE_CHANGE_PWD 18
/* (These functions are obsolete) */
#define OE_DELETE_RECID 19
/* Deletes header record, all text, user notes,
* and word/stems references for specified record.
* Currently can only be called from offline program
* when all online austext users have been logged off.
* THIS FUNCTION IS <<<VERY>>> SLOW (about 15 min on large dbase)!
* input:
* .query = desired record key
* .dblk = desired database and db parameters
* output:
* .dba = address of record deleted
* THIS ADDRESS IS NO LONGER VALID!
* .dbatab = (undefined)
* .dbacount = 1
* .retncode = common retncodes + OE_NOTAVAIL
*/
#define OE_DELETE_BATCH 20
/* Deletes header records, all text, user notes,
* and word/stems references for all records in a
* datbase address table. Currently can only be called
* from offline program when all online austext users
* have been logged off. This function is the preferred
* deletion method because it is faster than deleting
* single records at a time. Addresses not found are ignored.
* input:
* .dblk = desired database and db parameters
* .dbatab = table of valid addresses to be deleted
* .dbacount = number of addresses on the table
* output:
* .retncode = common retncodes only
*/
#define OE_ASSIST 21
#define OE_FINDSTR_REC 22
#define OE_FINDSTR_HITL 23
/* (These functions are obsolete) */
#define OE_SRCH_STATISTICAL 24
/* Converts string of natural language text to
* hitlist of dba's and stems array. Uses stems only,
* no booleans, all words are ORed together. Hitlist sorted
* based on statistics of included word stems.
* input:
* .query = natural language text string
* .dblk = desired database and db parameters
* output:
* .stems = array of stems for hiliting in text of hits
* .stemcount = size of 'stems' array (up to max allowed)
* .workproc = function to be called until !OE_SEARCHING
* .dittolist = hitlist
* .dittocount = # of nodes on dittolist
* .retncode = common retncodes + OE_BAD_QUERY, OE_SEARCHING,
* OE_NOTAVAIL, OE_USER_STOP
*/
#define OE_HILITE_STEMS 25
/* Creates a hitwords array for hiliting using the text
* in cleartext (however it may have been obtained),
* and the stems array from the last search.
* input:
* .cleartext = text to be hilited
* .clearlen = size of cleartext
* .stems = array of words or stems to hilite
* .stemcount = size of stems array
* .search_type = 'W', 'P' or 'S', indicating type of
* search that generated stems array.
* output:
* .hitwords = array of words in cleartext to hilite
* .hitwcount = size of hitwords array
* .retncode = common retncodes + OE_NOTAVAIL, OE_BAD_QUERY
*/
#define OE_GET_EXPIRE 26
/* Returns in 'dba' field the expiration date of OE as a timestamp.
* Zero means no expiration date. Overlays previous value in dba.
* input: .request = OE_GET_EXPIRE
* output: .dba = unix timestamp of expiration date or 0
* .retncode = common retncodes only
*/
#define OE_KILL 9997
#define OE_PING 9998
#define OE_SHUTDOWN 9999
/* (These functions are obsolete) */
/*-------------------- Return Codes ------------------------
* The return codes marked 'common retncodes' are OE_OK, OE_NOOP, OE_REINIT,
* and OE_ABORT, and can be returned by almost all functions.
* OE_BAD_QUERY will be returned for any unknown function request.
* There is no zero return code.
*/
#define OE_OK 1 /* normal successful completion */
#define OE_REINIT 2 /* request canceled: OE reinitialized
* databases so UI's dba's may be bad */
#define OE_SEARCHING 3 /* keep calling workproc */
#define OE_BAD_DBLK 4
#define OE_BAD_REQUEST 5 /* invalid request field */
#define OE_BAD_QUERY 6 /* invalid query or other input fld */
#define OE_NOTAVAIL 7 /* no record, hits, function disabled */
#define OE_TIMEOUT 8
#define OE_WRAPPED 9 /* got next item instead of reqstd item */
#define OE_SYSTEM_STOP 10 /* error: search canceled by OE */
#define OE_BAD_PASSWD 11 /* invalid password */
#define OE_BAD_HITLIST 12 /* invalid hitlist */
#define OE_DISABLED 13 /* requested function disabled at this site */
#define OE_USER_STOP 14 /* search canceled by user */
#define OE_BAD_COMM 15 /* request canceled by comm layer */
#define OE_NOOP 888 /* No Operation, nothing done */
#define OE_ABORT 999 /* fatal OE error, OE permanently disabled */
/****************************************/
/* */
/* OEFTAB */
/* */
/****************************************/
/* Table used in load_ocf() oe_uninitialize() to allow overriding default
* locations of various files. Complete discussion in .ocf documentation.
*/
typedef struct
{
char *id; /* keyword identifier */
char **OEFptr; /* addr of variable to change */
char previously_specified; /* bool ensures only one spec */
} OEFTAB;
/****************************************/
/* */
/* USRBLK */
/* */
/****************************************/
typedef struct
{
char userid [10]; /* 1 - 8 alphanumeric char */
int search_type; /* single char = curr search type.
* 'T' = Semantic Text search
* 'W' = Exact Words search
* 'S' = Stems search
* 'Z' = Fzkey search
* 'N' = Navigator string (unpacked fzk) srch
* 'P' = Statistical (Probabilistic) search
*/
long flags; /* bit switches... */
#define USR_BIT_1 0x0001L /* (reserved) */
#define USR_NO_ITERATE 0x0002L /* override iterations in workprocs */
#define USR_STOPSRCH 0x0004L /* the "stop" button, cancels workproc */
#define USR_MAXMIN 0x0008L /* symdif() algorithm = fuzzy max min */
#define USR_OBJDATES 0x0010L /* restrict hitlists to objdate ranges */
#define USR_KWIC_ABSTR 0x0020L /* retn KeyWord In Context for abstract */
#define USR_NO_INFOMSGS 0x0040L /* do not retn information-only msgs to UI */
#define USR_MAXHITS_MSG 0x0080L /* show # hits each keytype if sum > maxhits */
#define USR_SORT_WHITL 0x0100L /* sort word/stem hitlists by semantics */
long debug; /* Nonproduction bit switches */
#define USRDBG_RARE 0x0001L /* 1 Misc initialzatn trace msgs */
#define USRDBG_SRCHCMPL 0x0002L /* 2 trace ui search_completed functions */
#define USRDBG_RETRVL 0x0004L /* 4 trace record retrieval funcs */
#define USRDBG_ITERATE 0x0008L /* 8 forces iteration on all iterable cmds */
#define USRDBG_UTIL 0x0010L /* 16 trace misc utility functions */
#define USRDBG_MEDPRMPT 0x0020L /* 32 Prints prompt of medley sockets cmds */
#define USRDBG_HITLIST 0x0040L /* 64 print hitlists after searches */
#define USRDBG_SYMP 0x0080L /* 128 trace symptom search funcs */
#define USRDBG_DELETE 0x0100L /* 256 trace record deletion functions */
#define USRDBG_RPC 0x0200L /* 512 trace RPC communications funcs */
#define USRDBG_VERBOSE 0x0400L /* 1024 verbose debugging: iterative details */
#define USRDBG_HILITE 0x0800L /* 2048 trace hiliting functions */
#define USRDBG_PARSE 0x1000L /* 4096 trace linguistic parse/stem funcs */
#define USRDBG_BOOL 0x2000L /* 8192 trace boolean parse funcs */
int request;
int retncode;
char *query; /* input data for text searches */
DtSrObjdate objdate1; /* only retn hit objects >= (after) date1 */
DtSrObjdate objdate2; /* only retn hit objects <= (before) date2 */
DB_ADDR dba; /* for direct dba reads */
DB_ADDR *dbatab; /* array of dba's for batch deletes */
int dbacount; /* # of dba's in dbatab */
void (*workproc) (void);
/* (1) If single tasking (iterative), OE places ptr to work
procedure. (2) If multitasking (no iterations), UI places
ptr of func to call when OE's spawned subtask is done. */
DBLK *dblist; /* linked list of all databases */
DBLK *dblk; /* users curr database selection */
DtSrResult *dittolist; /* hitlist retnd from various searches */
long dittocount; /* # of items on hitlist */
int stemcount; /* # of wordstems in 'stems' array */
char stems [DtSrMAX_STEMCOUNT] [DtSrMAXWIDTH_HWORD];
/* for hiliting words in text records */
struct or_objrec objrec; /* austext record buffer */
char *abstrbuf; /* buf to hold abstracts */
int abstrbufsz; /* maximum abstract size all databases */
char *cleartext; /* decompressed austext record text */
long clearlen; /* size of cleartext in bytes */
LLIST *notes; /* uncompressed, right out of vista */
DtSrHitword *hitwords; /* array of hit words inside cleartext */
long hitwcount; /* number of elements in hitwords array */
} USRBLK;
/****************************************/
/* */
/* SAVEUSR */
/* */
/****************************************/
/* The following data is saved between calls of the workprocs.
* In a future msg passing protocol where there may be multiple UIs
* per OE, this data would be maintained in a list of structures,
* one for each currently active search (UI only passes user id name
* in iterative calls, OE searches list to match curr status).
* But for now, this will have to do.
*/
typedef struct
{
time_t start_time;
int iterations;
int vistano;
DtSrResult *dittolist;
long dittocount;
int stemcount;
char stems [DtSrMAX_STEMCOUNT] [DtSrMAXWIDTH_HWORD];
char ktchars [MAX_KTCOUNT + 2];
char *lastqry;
long ktsum [MAX_KTCOUNT + 1];
} SAVEUSR;
/*--------------- GLOBALS in oe.c, loadocf.c -------------------*/
extern char **ausapi_dbnamesv;
extern int ausapi_dbnamesc;
extern USRBLK usrblk;
extern char *global_memory_ptr;
extern OEFTAB oef_table[];
extern SAVEUSR saveusr; /* (only one for now) */
extern int shm_id;
extern int OE_bmhtab_strlen [DtSrMAX_STEMCOUNT];
extern size_t OE_bmhtables [DtSrMAX_STEMCOUNT] [MAX_BMHTAB];
extern int OE_dbn;
extern int OE_enable_markdel;
extern int OE_enable_usernotes;
extern time_t *OE_expiration;
extern int OE_fastdecode;
extern char *OE_fileio;
extern long OE_flags;
#define OE_AUDIT 1L /* enables audit file logging */
#define OE_INITOK (1L<<1) /* ensures first reqst was INITIALIZE */
#define OE_PERMERR (1L<<2) /* disables engine on fatal errors */
#define OE_NO_ITERATE (1L<<3) /* override iterations in workprocs */
extern char *OE_inittab_dir; /* local dir of server daemon */
extern long OE_objsize;
extern char *OE_prodname;
extern int OE_search_type;
extern char *OE_server_dir; /* local dir of server daemon */
extern char *OE_sitecnfg_fname;
extern time_t OE_sitecnfg_mtime;
extern int OE_uppercase_keys;
extern long OE_words_hitlimit;
/* Global pointers to formerly hardcoded path/file names.
* The comment names the #define constant under which the
* filename is/was specified in either fuzzy.h or oe.h.
*/
extern char *OEF_audit; /* FNAME_AUDIT */
extern char *OEF_discard; /* FNAME_DISCARD_DATA */
extern char *OEF_news; /* FNAME_SITENEWS */
extern char *OEF_notesnot; /* FNAME_NOTES_BAC */
extern char *OEF_notessem; /* FNAME_NOTES_SEM */
extern char *OEF_readme; /* FNAME_README */
/*---------------- FUNCTION PROTOTYPES ----------------------*/
extern char *calloe_getrec (char *dbname, DB_ADDR dba,
LLIST **global_msglist);
extern long calloe_hilite (char *cleartext, DtSrHitword *hitwords,
LLIST **global_msglist);
extern DtSrResult
*calloe_search (char *qry, char *dbname,
int search_type, LLIST **global_msglist);
extern int call_output_script (char *shellcmd, char *text);
extern void clear_hitwords (void);
extern void clear_usrblk_record (void);
extern void dummy_workproc (void);
extern char *ensure_end_slash (char *charbuf);
extern void fasthuf (UCHAR *input_bitstring, UCHAR *output_charbuf,
int outbuf_size, time_t encode_id);
extern char *get_hitlist_text (int maxlen);
extern long hilite_cleartext (int parse_type, char *stems, int stemcount);
extern int load_ocf (void);
extern char *nowstring (time_t *now);
extern void oe_initialize (void);
extern int oe_unblob (LLIST *bloblist);
extern void oe_write_audit_rec (long numhits);
extern void Opera_Engine (void);
extern void print_dittolist (DtSrResult *dittolist, char *label);
extern void print_stems (int stemcount, void *stems, char *locstr);
extern void print_usrblk_record (char *label);
extern void release_shm_mem (void);
extern char *retncode_str (int num);
extern void symptom_search (void);
extern int ve_append_notes (void);
extern void ve_browse_dba (int direction);
extern LLIST *ve_getblobs (DtSrINT32 dba, int vistano);
extern int ve_getrec_dba (LLIST **bloblist);
extern int ve_initialize (void);
extern void ve_ditto (void);
extern DtSrINT32 ve_reckey2dba (void);
extern void ve_statistical (void);
extern void ve_stem_search (void);
extern void ve_word_search (void);
extern void ve_shutdown (void);
/***************************** SearchE.h ******************************/
#endif /* _SearchE_h */

863
cde/lib/DtSearch/SearchP.h Normal file
View File

@@ -0,0 +1,863 @@
/*
* COMPONENT_NAME: austext
*
* FUNCTIONS:
*
* ORIGINS: 27
*
*
* (C) COPYRIGHT International Business Machines Corp. 1990,1995
* All Rights Reserved
* Licensed Materials - Property of IBM
* US Government Users Restricted Rights - Use, duplication or
* disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
*/
#ifndef _SearchP_h
#define _SearchP_h
/************************ SearchP.h ********************************
* $XConsortium: SearchP.h /main/9 1996/10/12 16:10:00 cde-ibm $
* June 1990.
* Private header file for DtSearch/AusText used by
* both build tools and search engine.
* Derived from original IBM fuzzy.h.
*
* Hierarchies of DtSearch/AusText Search*.h #includes:
* Search.h is Dt/Aus public header, defines _XOPEN_SOURCE.
* SearchP.h is private Dt/Aus, includes Search.h.
* semantic.h is private Aus only, defines _ALL_SOURCE,
* includes SearchP.h.
* (Should be specified in place of SearchP.h).
* SearchE.h is private engine header Dt/Aus. Invokes either
* SearchP.h or semantic.h depending on whether DTSEARCH defined.
* Only one of the above should be specified. They should always
* be first include to get the _SOURCE defines right.
* DTSEARCH should be defined on compiler cmd line.
*
* $Log$
* Revision 2.11 1996/04/10 19:44:43 miker
* AusText 2.1.13, DtSearch 0.5. Documentation cleanup.
*
* Revision 2.10 1996/03/13 22:35:14 miker
* Added UCHAR definition. Changed char to UCHAR several places.
*
* Revision 2.9 1996/03/05 16:48:56 miker
* Add COMMENT_CHARS from lang.c.
*
* Revision 2.8 1996/03/05 15:58:57 miker
* Replace vewords with yacc-based boolean search.
*
* Revision 2.7 1996/02/01 16:26:06 miker
* AUSAPI_VERSION 2.1.11, DtSearch 0.3:
* Changed parsers to use character reading cofunctions.
*
* Revision 2.6 1995/12/27 15:51:36 miker
* Version 2.1.10: First GA release of AusBuild.
*
* Revision 2.5 1995/12/07 23:24:38 miker
* Version 2.1.9e: Freezing AusBuild version with
* everything except multiple source files dialog box.
*
* Revision 2.4 1995/10/25 22:29:29 miker
* Added prolog.
*
* Revision 2.3 1995/10/19 19:07:42 miker
* Changed AUSAPI_VERSION to 2.1.9 (but not yet released).
*
* Revision 2.2 1995/10/03 21:36:13 miker
* Added 'const' to strdup prototype for greater portability.
*
* Revision 2.1 1995/09/22 22:39:41 miker
* Freeze DtSearch 0.1, AusText 2.1.8
*
* Revision 1.3 1995/09/19 21:38:59 miker
* Removed debugging #defines.
*/
#include "Search.h" /* the "public" header file */
#include <nl_types.h> /* for nl_catd below and all cat...() funcs */
#include <sys/types.h>
#include <netinet/in.h>
#define AUSAPI_VERSION "2.1.13"
/* Format: "v.r.m", where v,r,m are integer substrings
* meaning version, revision, and mod respectively.
* Complete new version austomatically sets revision=1, mod=0.
* New revision within a version just sets mod=0.
* When mod=0, full string may be abbreviated to "v.r".
* Full string will contain no whitespace.
* AUSAPI_VERSION is compared to current versions of database
* schemas and client/server protocols by ausapi_init().
* By convention, AusText programs display AUSAPI_VERSION
* at the top of the main gui window and in usage statements.
*/
#define SCHEMA_VERSION "2.0"
/* Identifies when schema last changed.
* Same format as AUSAPI_VERSION, except only "v.r" substring used.
* To ensure compatibility, database programs must have v.r integers
* within the range between SCHEMA_VERSION and AUSAPI_VERSION.
* The 3rd integer, the 'mod' number, never matters.
*/
#define PROTOCOL_VERSION "2.1"
/* Identifies when protocol between ui and engine/ausapi
* last changed. Typical changes would be changes to major
* structures like usrblk, dblk, and socblk, or changes to
* the arguments for either ausapi or Opera_Engine calls.
* Only meaningful for client/server systems.
* Same format as AUSAPI_VERSION, except only "v.r" substring used.
* To ensure compatibility, clients must have v.r integers
* within the range between PROTOCOL_VERSION and AUSAPI_VERSION
* of the engine. The 3rd integer, the 'mod' number, never matters.
*/
/*------------- #define Compiler and related #defines ------------------
* #define TURBO_COMPILER...
* #define PS2AIX_COMPILER...
* #define AIX370_COMPILER...
* #define HP_COMPILER...
* #define _AIX...
* ... define one of the above at top of Search.h to provide
* structures and functions that are compiler dependent.
* Since the compiler definition must precede all other headers,
* the #include for Search.h must be the first statement of all source
* files.
*
* UCHAR corrects for compilers whose default char is signed.
*/
#define UCHAR unsigned char
#ifdef TURBO_COMPILER
#define LINT_ARGS /* establishes strong prototyping in vista */
#define ANSI /* allow multiple databases in vista */
#else
#define SINGLE_USER /* eliminate vista lockmgr */
#define UNIX /* used in vista.h and elsewhere */
#endif
#ifdef HP_COMPILER
#define _INCLUDE_HPUX_SOURCE
#define _INCLUDE_POSIX_SOURCE
#define _INCLUDE_XOPEN_SOURCE
#endif
/*----------------------- AUSTEXT.H ---------------------
* DBMS record/key structure and constant declarations.
* These represent the database schema formerly in austext.h
* and derived from austext.sch.
*/
typedef struct or_dbrec {
DtSrUINT32 or_dbflags;
DtSrUINT32 or_dbuflags;
DtSrINT32 or_reccount;
DtSrINT32 or_maxdba;
DtSrINT32 or_availd99;
DtSrINT32 or_unavaild99;
DtSrINT32 or_hufid;
DtSrINT32 or_dbsecmask;
char or_version[8];
char or_dbfill[50];
DtSrINT16 or_dbotype;
DtSrINT16 or_compflags;
DtSrINT16 or_dbaccess;
DtSrINT16 or_minwordsz;
DtSrINT16 or_maxwordsz;
DtSrINT16 or_recslots;
DtSrINT16 or_fzkeysz;
DtSrINT16 or_abstrsz;
DtSrINT16 or_language;
} DBREC;
struct or_dbmiscrec {
DtSrINT16 or_dbmisctype;
char or_dbmisc[1][106];
};
struct or_objrec {
DtSrUINT32 or_objflags;
DtSrUINT32 or_objuflags;
DtSrINT32 or_objsize;
DtSrINT32 or_objdate;
DtSrINT32 or_objsecmask;
char or_objkey[32];
char or_objfill[34];
DtSrINT16 or_objaccess;
DtSrINT16 or_objtype;
DtSrINT16 or_objcost;
DtSrINT16 or_objhdroffset;
DtSrINT16 or_objeureka;
};
struct or_miscrec {
DtSrINT16 or_misctype;
char or_misc[1][105];
};
struct or_blobrec {
DtSrINT16 or_bloblen;
char or_blob[234][1];
};
struct or_swordrec {
char or_swordkey[16];
DtSrINT32 or_swoffset;
DtSrINT32 or_swfree;
DtSrINT32 or_swaddrs;
};
struct or_lwordrec {
char or_lwordkey[40];
DtSrINT32 or_lwoffset;
DtSrINT32 or_lwfree;
DtSrINT32 or_lwaddrs;
};
struct or_hwordrec {
char or_hwordkey[134];
DtSrINT32 or_hwoffset;
DtSrINT32 or_hwfree;
DtSrINT32 or_hwaddrs;
};
/* File Id Constants */
#define OR_D00 0
#define OR_D01 1
#define OR_D21 2
#define OR_D22 3
#define OR_D23 4
#define OR_K00 5
#define OR_K01 6
#define OR_K21 7
#define OR_K22 8
#define OR_K23 9
/* Record Name Constants */
#define OR_DBREC 10000
#define OR_DBMISCREC 10001
#define OR_OBJREC 10002
#define OR_MISCREC 10003
#define OR_BLOBREC 10004
#define OR_SWORDREC 10005
#define OR_LWORDREC 10006
#define OR_HWORDREC 10007
/* Field Name Constants */
#define OR_DBFLAGS 0L
#define OR_DBUFLAGS 1L
#define OR_RECCOUNT 2L
#define OR_MAXDBA 3L
#define OR_AVAILD99 4L
#define OR_UNAVAILD99 5L
#define OR_HUFID 6L
#define OR_DBSECMASK 7L
#define OR_VERSION 8L
#define OR_DBFILL 9L
#define OR_DBOTYPE 10L
#define OR_COMPFLAGS 11L
#define OR_DBACCESS 12L
#define OR_MINWORDSZ 13L
#define OR_MAXWORDSZ 14L
#define OR_RECSLOTS 15L
#define OR_FZKEYSZ 16L
#define OR_ABSTRSZ 17L
#define OR_LANGUAGE 18L
#define OR_DBMISCTYPE 1000L
#define OR_DBMISC 1001L
#define OR_OBJFLAGS 2000L
#define OR_OBJUFLAGS 2001L
#define OR_OBJSIZE 2002L
#define OR_OBJDATE 2003L
#define OR_OBJSECMASK 2004L
#define OR_OBJKEY 2005L
#define OR_OBJFILL 2006L
#define OR_OBJACCESS 2007L
#define OR_OBJTYPE 2008L
#define OR_OBJCOST 2009L
#define OR_OBJHDROFFSET 2010L
#define OR_OBJEUREKA 2011L
#define OR_MISCTYPE 3000L
#define OR_MISC 3001L
#define OR_BLOBLEN 4000L
#define OR_BLOB 4001L
#define OR_SWORDKEY 5000L
#define OR_SWOFFSET 5001L
#define OR_SWFREE 5002L
#define OR_SWADDRS 5003L
#define OR_LWORDKEY 6000L
#define OR_LWOFFSET 6001L
#define OR_LWFREE 6002L
#define OR_LWADDRS 6003L
#define OR_HWORDKEY 7000L
#define OR_HWOFFSET 7001L
#define OR_HWFREE 7002L
#define OR_HWADDRS 7003L
/* Set Name Constants */
#define OR_DB_MISCS 20000
#define OR_OBJ_BLOBS 20001
#define OR_OBJ_MISCS 20002
/*----------------------- end AUSTEXT.H ---------------------*/
/*------------- DMACROS.H -------------------
* The following were formerly in dmacros.h.
* They provide macro enhancements to the
* DBMS function prototypes in vista.h.
* Each DBMS function is coded in a macro which includes
* a location string (usually module name + line number).
* The location string is printed whenever there is
* a user or system failure.
* Warning: These should not be coded naked within 'if-else' statements
* because the 'if' in the macros will interfere with the outside else.
*/
#define CMSTAT(s,a,b) if(d_cmstat(a,b) < S_OKAY) vista_abort(s)
#define CMTYPE(s,a,b,c) if(d_cmtype(a,b,c) < S_OKAY) vista_abort(s)
#define CONNECT(s,a,b) if(d_connect(a,b) < S_OKAY) vista_abort(s)
#define COSTAT(s,a,b) if(d_costat(a,b) < S_OKAY) vista_abort(s)
#define COTYPE(s,a,b,c) if(d_cotype(a,b,c) < S_OKAY) vista_abort(s)
#define CRGET(s,a,b) if(d_crget(a,b) < S_OKAY) vista_abort(s)
#define CRREAD(s,a,b,c) if(d_crread(a,b,c) < S_OKAY) vista_abort(s)
#define CRSET(s,a,b) if(d_crset(a,b) < S_OKAY) vista_abort(s)
#define CRSTAT(s,a) if(d_crstat(a) < S_OKAY) vista_abort(s)
#define CRTYPE(s,a,b) if(d_crtype(a,b) < S_OKAY) vista_abort(s)
#define CRWRITE(s,a,b,c) if(d_crwrite(a,b,c) < S_OKAY) vista_abort(s)
#define CSMGET(s,a,b,c) if(d_csmget(a,b,c) < S_OKAY) vista_abort(s)
#define CSMREAD(s,a,b,c,d) if(d_csmread(a,b,c,d) < S_OKAY) vista_abort(s)
#define CSMSET(s,a,b,c) if(d_csmset(a,b,c) < S_OKAY) vista_abort(s)
#define CSMWRITE(s,a,b,c,d) if(d_csmwrite(a,b,c,d) < S_OKAY) vista_abort(s)
#define CSOGET(s,a,b,c) if(d_csoget(a,b,c) < S_OKAY) vista_abort(s)
#define CSOREAD(s,a,b,c,d) if(d_csoread(a,b,c,d) < S_OKAY) vista_abort(s)
#define CSOSET(s,a,b,c) if(d_csoset(a,b,c) < S_OKAY) vista_abort(s)
#define CSOWRITE(s,a,b,c,d) if(d_csowrite(a,b,c,d) < S_OKAY) vista_abort(s)
#define CSSTAT(s,a,b) if(d_csstat(a,b) < S_OKAY) vista_abort(s)
#define CTBPATH(s,a) if(d_ctbpath(a) < S_OKAY) vista_abort(s)
#define CTSCM(s,a,b,c) if(d_ctscm(a,b,c) < S_OKAY) vista_abort(s)
#define CTSCO(s,a,b,c) if(d_ctsco(a,b,c) < S_OKAY) vista_abort(s)
#define CTSCR(s,a,b) if(d_ctscr(a,b) < S_OKAY) vista_abort(s)
#define DBDPATH(s,a) if(d_dbdpath(a) < S_OKAY) vista_abort(s)
#define DBFPATH(s,a) if(d_dbfpath(a) < S_OKAY) vista_abort(s)
#define DBLOG(s,a) if(d_dblog(a) < S_OKAY) vista_abort(s)
#define DBTAF(s,a) if(d_dbtaf(a) < S_OKAY) vista_abort(s)
#define DBUSERID(s,a) if(d_dbuserid(a) < S_OKAY) vista_abort(s)
#define DECODE_DBA(s,a,b,c) if(d_decode_dba(a,b,c) < S_OKAY) vista_abort(s)
#define DELETE(s,a) if(d_delete(a) < S_OKAY) vista_abort(s)
#define DESTROY(s,a) if(d_desoy(a) < S_OKAY) vista_abort(s)
#define DISCON(s,a,b) if(d_discon(a,b) < S_OKAY) vista_abort(s)
#define DISDEL(s,a) if(d_disdel(a) < S_OKAY) vista_abort(s)
#define ENCODE_DBA(s,a,b,c) if(d_encode_dba(a,b,c) < S_OKAY) vista_abort(s)
#define FILLNEW(s,a,b,c) if(d_fillnew(a,b,c) < S_OKAY) vista_abort(s)
#define FINDCO(s,a,b) if(d_findco(a,b) < S_OKAY) vista_abort(s)
#define FINDFM(s,a,b) if(d_findfm(a,b) < S_OKAY) vista_abort(s)
#define FINDLM(s,a,b) if(d_findlm(a,b) < S_OKAY) vista_abort(s)
#define FINDNM(s,a,b) if(d_findnm(a,b) < S_OKAY) vista_abort(s)
#define FINDPM(s,a,b) if(d_findpm(a,b) < S_OKAY) vista_abort(s)
#define FREEALL(s) if(d_freeall() < S_OKAY) vista_abort(s)
#define GTSCM(s,a,b,c) if(d_gtscm(a,b,c) < S_OKAY) vista_abort(s)
#define GTSCO(s,a,b,c) if(d_gtsco(a,b,c) < S_OKAY) vista_abort(s)
#define GTSCR(s,a,b) if(d_gtscr(a,b) < S_OKAY) vista_abort(s)
#define GTSCS(s,a,b,c) if(d_gtscs(a,b,c) < S_OKAY) vista_abort(s)
#define INITFILE(s,a,b) if(d_initfile(a,b) < S_OKAY) vista_abort(s)
#define INITIALIZE(s,a) if(d_initialize(a) < S_OKAY) vista_abort(s)
#define ISMEMBER(s,a,b) if(d_ismember(a,b) < S_OKAY) vista_abort(s)
#define ISOWNER(s,a,b) if(d_isowner(a,b) < S_OKAY) vista_abort(s)
#define KEYDEL(s,a,b) if(d_keydel(a,b) < S_OKAY) vista_abort(s)
#define KEYEXIST(s,a,b) if(d_keyexist(a,b) < S_OKAY) vista_abort(s)
#define KEYFIND(s,a,b,c) if(d_keyfind(a,b,c) < S_OKAY) vista_abort(s)
#define KEYFREE(s,a,b) if(d_keyfree(a,b) < S_OKAY) vista_abort(s)
#define KEYFRST(s,a,b) if(d_keyfrst(a,b) < S_OKAY) vista_abort(s)
#define KEYLAST(s,a,b) if(d_keylast(a,b) < S_OKAY) vista_abort(s)
#define KEYLOCK(s,a,b,c) if(d_keylock(a,b,c) < S_OKAY) vista_abort(s)
#define KEYLSTAT(s,a,b,c) if(d_keylstat(a,b,c) < S_OKAY) vista_abort(s)
#define KEYNEXT(s,a,b) if(d_keynext(a,b) < S_OKAY) vista_abort(s)
#define KEYPREV(s,a,b) if(d_keyprev(a,b) < S_OKAY) vista_abort(s)
#define KEYREAD(s,a) if(d_keyread(a) < S_OKAY) vista_abort(s)
#define KEYSTORE(s,a,b) if(d_keystore(a,b) < S_OKAY) vista_abort(s)
#define LOCK(s,a,b,c) if(d_lock(a,b,c) < S_OKAY) vista_abort(s)
#define MAKENEW(s,a,b) if(d_makenew(a,b) < S_OKAY) vista_abort(s)
#define MAPCHAR(s,a,b,c,d) if(d_mapchar(a,b,c,d) < S_OKAY) vista_abort(s)
#define MEMBERS(s,a,b,c) if(d_members(a,b,c) < S_OKAY) vista_abort(s)
#define OFF_OPT(s,a) if(d_off_opt(a) < S_OKAY) vista_abort(s)
#define ON_OPT(s,a) if(d_on_opt(a) < S_OKAY) vista_abort(s)
#define OPEN(s,a,b) if(d_open(a,b) < S_OKAY) vista_abort(s)
#define RDCURR(s,a,b) if(d_rdcurr(a,b) < S_OKAY) vista_abort(s)
#define RECFREE(s,a,b) if(d_recfree(a,b) < S_OKAY) vista_abort(s)
#define RECFRST(s,a,b) if(d_recfrst(a,b) < S_OKAY) vista_abort(s)
#define RECLAST(s,a,b) if(d_reclast(a,b) < S_OKAY) vista_abort(s)
#define RECLOCK(s,a,b,c) if(d_reclock(a,b,c) < S_OKAY) vista_abort(s)
#define RECLSTAT(s,a,b,c) if(d_reclstat(a,b,c) < S_OKAY) vista_abort(s)
#define RECNEXT(s,a) if(d_recnext(a) < S_OKAY) vista_abort(s)
#define RECOVER(s,a) if(d_recover(a) < S_OKAY) vista_abort(s)
#define RECPREV(s,a) if(d_recprev(a) < S_OKAY) vista_abort(s)
#define RECREAD(s,a,b) if(d_recread(a,b) < S_OKAY) vista_abort(s)
#define RECSET(s,a,b) if(d_recset(a,b) < S_OKAY) vista_abort(s)
#define RECSTAT(s,a,b,c) if(d_recstat(a,b,c) < S_OKAY) vista_abort(s)
#define RECWRITE(s,a,b) if(d_recwrite(a,b) < S_OKAY) vista_abort(s)
#define RENFILE(s,a,b,c) if(d_renfile(a,b,c) < S_OKAY) vista_abort(s)
#define RLBCLR(s,a) if(d_rlbclr(a) < S_OKAY) vista_abort(s)
#define RLBSET(s,a) if(d_rlbset(a) < S_OKAY) vista_abort(s)
#define RLBTST(s,a) if(d_rlbtst(a) < S_OKAY) vista_abort(s)
#define SETDB(s,a) if(d_setdb(a) < S_OKAY) vista_abort(s)
#define SETFILES(s,a) if(d_setfiles(a) < S_OKAY) vista_abort(s)
#define SETFREE(s,a,b) if(d_setfree(a,b) < S_OKAY) vista_abort(s)
#define SETLOCK(s,a,b,c) if(d_setlock(a,b,c) < S_OKAY) vista_abort(s)
#define SETLSTAT(s,a,b,c) if(d_setlstat(a,b,c) < S_OKAY) vista_abort(s)
#define SETMM(s,a,b,c) if(d_setmm(a,b,c) < S_OKAY) vista_abort(s)
#define SETMO(s,a,b,c) if(d_setmo(a,b,c) < S_OKAY) vista_abort(s)
#define SETMR(s,a,b) if(d_setmr(a,b) < S_OKAY) vista_abort(s)
#define SETOM(s,a,b,c) if(d_setom(a,b,c) < S_OKAY) vista_abort(s)
#define SETOO(s,a,b,c) if(d_setoo(a,b,c) < S_OKAY) vista_abort(s)
#define SETOR(s,a,b) if(d_setor(a,b) < S_OKAY) vista_abort(s)
#define SETPAGES(s,a,b) if(d_setpages(a,b) < S_OKAY) vista_abort(s)
#define SETRM(s,a,b) if(d_setrm(a,b) < S_OKAY) vista_abort(s)
#define SETRO(s,a,b) if(d_setro(a,b) < S_OKAY) vista_abort(s)
#define STSCM(s,a,b,c) if(d_stscm(a,b,c) < S_OKAY) vista_abort(s)
#define STSCO(s,a,b,c) if(d_stsco(a,b,c) < S_OKAY) vista_abort(s)
#define STSCR(s,a,b) if(d_stscr(a,b) < S_OKAY) vista_abort(s)
#define STSCS(s,a,b,c) if(d_stscs(a,b,c) < S_OKAY) vista_abort(s)
#define TIMEOUT(s,a) if(d_timeout(a) < S_OKAY) vista_abort(s)
#define TRABORT(s) if(d_trabort() < S_OKAY) vista_abort(s)
#define TRBEGIN(s,a) if(d_trbegin(a) < S_OKAY) vista_abort(s)
#define TREND(s) if(d_trend() < S_OKAY) vista_abort(s)
#define UTSCM(s,a,b,c) if(d_utscm(a,b,c) < S_OKAY) vista_abort(s)
#define UTSCO(s,a,b,c) if(d_utsco(a,b,c) < S_OKAY) vista_abort(s)
#define UTSCR(s,a,b) if(d_utscr(a,b) < S_OKAY) vista_abort(s)
#define UTSCS(s,a,b,c) if(d_utscs(a,b,c) < S_OKAY) vista_abort(s)
#define WRCURR(s,a) if(d_wrcurr(a) < S_OKAY) vista_abort(s)
/*------------- end DMACROS.H -------------------*/
/*------------- COMPILER DEPENDENT CONSTANTS -------------------*/
#ifdef TURBO_COMPILER
#define FNAME_NULL "nul"
#define LOCAL_SLASH 92 /* ascii back slash char (\) */
#endif
#ifdef UNIX
#define FNAME_NULL "/dev/null"
#define LOCAL_SLASH 47 /* ascii forward slash char (/) */
#endif
/*------------ COMPILER INDEPENDENT CONSTANTS -------------------*/
#define CACHE_SIZE 64 /* used in vista d_setpages() function */
#define COMMENT_CHARS "#*$!\n" /* identify comment lines in AusText files */
#define CTRL_Z 26
#define DIT_FINDSTR 1L /* DITTO.flags: retained aft FINDSTR srch */
#define DIT_STOP 2L /* DITTO.flags: node where user pushed stop */
#define END_RETAIN_PAGE 11 /* VT = marks end of RETAIN page */
/***#define END_RETAIN_REC '\f'****/
#define EXT_CHARTYPE ".chr" /* user definable wildcards (from LOADCHR) */
#define EXT_CANDI ".can" /* candidate dictionary words format */
#define EXT_CONFIG ".ocf" /* standard opera configuration file */
#define EXT_DTBS ".d99" /* inverted index file for dbase addrs */
#define EXT_FZKEY ".fzk" /* output of all opera text anal pgms */
#define EXT_HANDEL ".han" /* standard handel profile file format */
#define EXT_HUFFCODE ".huf" /* huffman encode tree (from HUFFCODE) */
#define EXT_HDECODE ".c" /* huffman decode tree (from HUFFCODE) */
#define EXT_INCLIST ".inc" /* "include" list file name extension */
#define EXT_LIST ".lst" /* standard wordlist format: 1 word/line */
#define EXT_SCHEMA ".sch" /* vista database schema format */
#define EXT_STOPLIST ".stp" /* standard stop list format */
#define EXT_SURVEY ".sur" /* standard survey file format */
#define EXT_TEMP ".tmp" /* any kind of temporary file */
#define EXT_TEXT ".txt" /* freeform ascii text format */
#define EXT_USRNOTES ".not" /* user notes flatfile format */
#define ETXDELIM "\f\n" /* default end-of-text (ETX) delim str */
#define FNAME_AUDIT "opaudit.lst"
#define FNAME_AUSCAT "austools.cat" /* Austools msgs catalog */
#define FNAME_AUSTEXT_TUTORIAL "austext.tut"
#define FNAME_CONFIRM_LIST "todscrd.lst" /* Shankar/Tomita files */
#define FNAME_DISCARD_DATA "shdscrd.lst" /* OEF_discard */
#define FNAME_DTSRCAT "dtsearch" /* DtSearch msgs catalog */
#define FNAME_HUFFCODE_TAB "ophuf.huf" /* huffman encode table */
#define FNAME_MUIRES "mui.res" /* motif class resources file */
#define FNAME_NOTES_BAC "usrnotes.not"
#define FNAME_NOTES_SEM "usrnotes.sem"
#define FNAME_ORIGSTOP "orig.stp"
#define FNAME_README "readme.txt"
#define FNAME_SITECONFIG "dtsearch.ocf"
#define FNAME_SITENEWS "sitenews.txt"
#define MINWIDTH_TOKEN 2 /* default smallest word/stem allowed */
#define MAX_BMHTAB 256 /* max alphabet size in bmstrstr tables */
#define MAX_ETXDELIM 100 /* max size of ETX delim string */
#define MAX_KTCOUNT 64 /* max number of keytypes */
#define MAXWIDTH_LWORD 40 /* = sizeof(or_lwordrec.or_lwordkey) */
#define MAXWIDTH_SWORD 16 /* = sizeof(or_swordrec.or_swordkey) */
#define NULLDATESTR "0/0/0~0:0"
#define NUM_HOLES 256 /* array size for defragmentation */
#define OBJDATESTR "%02d/%02d/%02d~%02d:%02d"
#define PRODNAME "DtSearch"
#define PWDMASKSZ 20
#define SCREEN_WIDTH 80 /* max len text line in online OPERA pgms */
#define STEM_CH 15 /* Ctrl-O stemmed word prefix character */
/*--------------- BYTE SWAP DECLARATIONS ------------
* The default database record format is the data ordering
* for big endian machines (most significant byte first),
* also known as "network" order. For non big_endian platforms,
* all compiles should include the BYTE_SWAP define.
* SWABDIR is direction of io to indicate correct byte swap function.
* HTON is host to network, internal memory to external database file.
* NTOH is network to host, file to memory.
* Actual host_to_network functions defined in <netinit/in.h>
* which is not yet standardized.
*/
typedef enum {HTON=1, NTOH} SWABDIR;
extern void swab_dbrec (struct or_dbrec *rec, SWABDIR direction);
extern void swab_objrec (struct or_objrec *rec, SWABDIR direction);
#ifdef BYTE_SWAP /* ie (BYTE_ORDER != BIG_ENDIAN) */
#define HTONL(x) x = htonl(x)
#define HTONS(x) x = htons(x)
#define NTOHL(x) x = ntohl(x)
#define NTOHS(x) x = ntohs(x)
#else /* !BYTE_SWAP, ie (BYTE_ORDER == BIG_ENDIAN) */
#define HTONL(x)
#define HTONS(x)
#define NTOHL(x)
#define NTOHS(x)
#endif /* BYTE_SWAP */
/*--------------- TESKEY PARSE CHARACTER TYPES ------------
* Used in langmap.c for linguistic parsing modules.
* Low order byte reserved for uppercase image of character
* as locale independent replacement for toupper() and strupr().
*/
#define CONCORDABLE 0x4000 /* alpha, numeric: inside word */
#define OPT_CONCORD 0x2000 /* "./-": maybe inside word, maybe outside */
#define NON_CONCORD 0x1000 /* space, punctuation, etc: outside word */
#define VOWEL 0x0800 /* concordable subtype: aeiou */
#define CONSONANT 0x0400 /* concordable subtype: all alpha - vowels */
#define NUMERAL 0x0200 /* concordable subtype: 0-9 */
#define WHITESPACE 0x0100 /* locale indep replacement for isspace() */
/*--------------- SCHEMA CONSTANTS ----------------
* Associated with fields in database schema (austext.h)
* and in DITTO structures.
* Values 20000 - 29999 reserved for custom user applic in all cardinal ints.
* ORA_ retrieval access location cardinal integers in or_access.
* ORC_ compression id bit switches in or_compflags.
* ORD_ bit switches in or_dbflags.
* (ORO_ bit switches in or_objflags
* renamed to DtSrFlxxx and moved to Search.h)
* ORM_ type cardinal integers in or_misctype.
* (ORT_ object type (or_objtype, or_dbotype, DITTO)
* renamed to DtSrObj... and moved to Search.h)
* (ORL_ language id cardinal integers in or_language
* renamed to DtSrLa... and moved to Search.h)
*/
#define ORA_VARIES 0 /* object accessibility unspec at curr lvl */
#define ORA_NOTAVAIL 1 /* obj not directly accessible from engine */
#define ORA_BLOB 2 /* obj stored in blob recs */
#define ORA_REFBLOB 3 /* svr ref (filename of object) in blob */
#define ORA_REFKEY 4 /* svr ref in or_objkey */
#define ORA_REFHUGEKEY 5 /* svr ref in 'huge' key (misc) rec */
#define ORA_REFABSTR 6 /* svr ref in abstract (misc rec) */
#define ORA_CREFBLOB 13 /* clt ref (filename of object) in blob */
#define ORA_CREFKEY 14 /* clt ref in or_objkey */
#define ORA_CREFABSTR 16 /* clt ref in abstract (misc rec) */
#define ORC_COMPBLOB (1<<0) /* blobs are compressed */
#define ORC_COMPABSTR (1<<1) /* abstracts are compressed */
#define ORD_XWORDS (1L<<0) /* inverted index includes exact words */
#define ORD_XSTEMS (1L<<1) /* inverted index includes word stems */
#define ORD_USEHUGEKEYS (1L<<4) /* all direct user access via huge keys */
#define ORD_NOMARKDEL (1L<<8) /* permanently disables mark-for-deletion */
#define ORD_NONOTES (1L<<9) /* permanently disables user notes */
#define ORD_WIDECHAR (1L<<10) /* text is multibyte or wide chars */
#define ORO_DELETE (1L<<0) /* obj is marked for deletion */
#define ORO_OLDNOTES (1L<<1) /* obj has old style usernotes in misc rec */
#define ORM_FZKABS 1 /* fzkey[fzkeysz] + abstract[abstrsz] */
#define ORM_HUGEKEY 2 /* optional 'huge' key */
#define ORM_OLDNOTES 3 /* old style user notes */
#define ORM_KEYTYPE 4 /* database keytype rec (KEYTYPE struct) */
/*------------------------- MACROS ---------------------------*/
/* (Use offsetof() in stddef.h to replace my old OFFSET macro) */
#define NULLORSTR(str) ((str)?str:catgets(dtsearch_catd,1,1,"<null>"))
#define NUMARRAY(arr) ((sizeof(arr) / sizeof(arr[0])))
/****************************************/
/* */
/* LLIST */
/* */
/****************************************/
typedef struct llist_tag {
struct llist_tag *link;
void *data;
} LLIST;
/****************************************/
/* */
/* FREE_SPACE_STR */
/* */
/****************************************/
/* 'holes' structure used for dynamic defragmentation */
typedef struct holes_str {
DtSrINT32 hole_size;
DtSrINT32 offset;
} FREE_SPACE_STR;
/****************************************/
/* */
/* FILE_HEADER */
/* */
/****************************************/
/* 'holes' structure used for dynamic defragmentation */
typedef struct fl_head {
DtSrINT32 hole_count [2];
FREE_SPACE_STR hole_array [2] [NUM_HOLES];
} FILE_HEADER;
/****************************************/
/* */
/* CMPLL, sort_llist, compare_llist */
/* */
/****************************************/
/* Generic LLIST structure typically used for 'lines' of text,
* as in ausapi.msglist and usrblk.msgs, and binary blobs.
* See structure typedef below for blob list structure.
* LLISTs can be sorted by calling sort_llist().
* The compare function is stored in global pointer 'compare_llist'
* prior to calling the sort function.
*/
typedef int (*CMPLL) (LLIST *left, LLIST *right);
/****************************************/
/* */
/* READCFP */
/* */
/****************************************/
/* Pointer to a function that takes a void
* pointer and returns a C char (1 octet).
* Used by linguistic parsers as a character reading cofunction.
* When parser is reading from a file stream as in dtsrindex,
* usual cofunction is readchar_ftext(). When parser is reading
* from a text string as in queries, the usual cofunction
* is readchar_string() which just accesses next char in string.
*/
typedef UCHAR (*READCFP) (void *);
/********************************************************/
/* */
/* WORDTREE */
/* */
/********************************************************/
/* A generic structure for creating binary trees of words
* from stoplists, include-lists, etc.
*/
typedef struct _bintree_tag {
struct _bintree_tag *rlink; /* ptr to right node */
struct _bintree_tag *llink; /* ptr to left node */
int len; /* length of word */
void *word;
} WORDTREE;
/************************************************/
/* */
/* PARG */
/* */
/************************************************/
/* Single argument for first parser call for a text block */
typedef struct {
void *dblk; /* dblk is (DBLK *) */
FILE *ftext; /* Text file being parsed in dtsrindex */
void *string; /* Query or other string being parsed */
void *etxdelim; /* End of text (ETX) delimiter string */
long *offsetp; /* where parser stores word offset */
long flags;
#define PA_INDEXING 0x0001 /* parse for indexing purposes (dtsrindex) */
#define PA_HILITING 0x0002 /* parse for hiliting purposes */
#define PA_MSGS 0x0004 /* explain parse failures with msgs */
void *extra; /* reserved for generic use by parsers */
} PARG;
/********************************************************/
/* */
/* DBLK */
/* */
/********************************************************/
/* One element of a linked list of universal information
* about all databases accessible,
* to an online search engine instance, chained off of
* the global OE_dblist. It is also used individually
* by offline build tools to store database data.
* It contains pointers to linguistic processors and data structures,
* data derived from the site configuration file,
* data derived and used by the DBMS,
* and some fields reflecting recommended initial user choices.
* Changes here should also be reflected in initblks.c,
* austext.sch, initausd.c, and in oeinit.c.
*/
typedef struct dblk_tag
{
struct dblk_tag *link; /* ptr to next dblk in list */
char name [11]; /* 1 - 8 char dictionary name */
char is_selected; /* bool: initial gui selection status */
char *label; /* database description/label string for UI */
long flags;
char *path; /* where to find all database files */
FILE *syofile; /* symptom offset (ranges) d97 file */
FILE *syifile; /* symptom index d98 file */
void *ranges; /* contents of syofile read into ram */
FILE *iifile; /* inverted words index d99 file */
time_t iimtime; /* last time d99 was modified */
int vistano; /* vista database number */
int ktcount; /* number of nodes in keytypes array */
DtSrKeytype *keytypes; /* record types in this database */
DBREC dbrec; /* copy of database's dbrec record */
void *zblk; /* used only for semantic processing */
/*----- Huffman Compression -----*/
time_t hufid; /* tree identification atom */
int hufroot; /* index to inverted tree root (array bottom) */
int *huftree; /* beginning of huffman tree array */
/*----- Language Fields -----*/
char *fname_stp; /* name of stoplist file */
char *fname_inc; /* name of include-list file */
char *fname_sfx; /* name of suffixes file */
int *charmap; /* parse/stem table for char set */
WORDTREE *stoplist; /* root of stoplist tree */
WORDTREE *inclist; /* root of include-list tree */
char *(*lstrupr) (char *string, struct dblk_tag *dblk);
char *(*parser) (PARG *parg);
void *parse_extra; /* eg additional word trees */
char *(*stemmer) (char *wordin, struct dblk_tag *dblk);
long stem_flags; /* stemmer options */
void *stem_extra; /* eg suffix tables */
void *lang_extra; /* additional language dependent data */
long lang_flags; /* language dependent switches */
#define LF_DUP_STP 0x0001 /* duplicate stop list */
#define LF_DUP_INC 0x0002 /* duplicate include list */
#define LF_DUP_SFX 0x0004 /* duplicate suffixes list */
/*----- User Search Parameters -----*/
int maxhits; /* max # hits to be returned from searches */
void *resuser; /* reserved for private use by users */
} DBLK;
/*------------------------- GLOBALS -------------------------*/
/* DtSearchExit (austext_exit) and DtSearchExitUser (austext_exit_user)
* are in ausexit.c too but are "public" in DtSearch (defined in Search.h).
*/
extern char *aa_argv0; /* globals.c */
extern int aa_maxhits; /* aajoint.c */
extern FILE *aa_stderr; /* globals.c */
extern int ascii_charmap[]; /* langmap.c */
extern LLIST *ausapi_msglist; /* globals.c */
extern void (*austext_exit_first) (int); /* ausexit.c */
extern void (*austext_exit_dbms) (int); /* ausexit.c */
extern void (*austext_exit_comm) (int); /* ausexit.c */
extern void (*austext_exit_endwin) (int); /* ausexit.c */
extern void (*austext_exit_mem) (int); /* ausexit.c */
extern void (*austext_exit_last) (int); /* ausexit.c */
extern void (*austext_exit_user) (int); /* ausexit.c */
extern nl_catd austools_catd; /* globals.c */
extern CMPLL compare_llist;
extern nl_catd dtsearch_catd; /* globals.c */
extern unsigned long
duprec_hashsize; /* isduprec.c */
extern int latin_charmap[]; /* langmap.c */
/*------------------------ FUNCTION PROTOTYPES ------------------------*/
extern void add_free_space(FREE_SPACE_STR *del_rec, FILE_HEADER *flh);
extern void append_ext (char *buffer, int buflen,
char *fname, char *fext);
extern int austext_dopen (
char *dbname,
char *dbpath,
char *d2xpath,
int cache_size,
DBREC *bufptr);
extern void *austext_malloc (size_t size, char *location, void *ignored);
extern char *bmhcore (
UCHAR *text,
size_t txtlen,
UCHAR *pattern,
size_t patlen,
size_t *bmhtable);
extern void bmhtable_build (
UCHAR *pattern,
size_t patlen,
size_t *bmhtable);
extern char *bmstrstr (
UCHAR *text,
size_t txtlen,
UCHAR *pattern,
size_t patlen);
extern int clean_wrap (char *string, int linelen);
extern LLIST *cutnode_llist (LLIST *node, LLIST **llistp);
extern void (*dberr_exit)(int exitcode); /* defaults to exit() */
extern void delete_whitespace (char *linebuf);
extern void discard_to_ETX (PARG *parg);
extern int endstroke (int c);
extern void put_new_word(struct or_hwordrec *recbuf, int vistano);
extern FREE_SPACE_STR
*find_free_space (DtSrINT32 req_size, FILE_HEADER *flh);
extern void free_llist (LLIST **llhead);
extern int fread_d99_header (FILE_HEADER *flh, FILE *fp);
extern int fwrite_d99_header (FILE_HEADER *flh, FILE *fp);
extern char *get_email_addr (void);
extern char *getnews (char *fname, int use_copyr);
extern void hc_decode (UCHAR *input_bitstring, UCHAR *output_charbuf,
int outbuf_size, time_t encode_id);
extern int hc_encode (struct or_blobrec *targ, UCHAR *src,
int srclen, int force_flush);
extern void init_header (FILE *fp, FILE_HEADER *flh);
extern int is_compatible_version (char *callers_vers, char *local_vers);
extern int is_concordable (char *word, int *charmap);
extern int is_duprec (char *recid);
extern int is_objdatestr (char *string, DtSrObjdate *objdptr);
extern int is_objdatetm (struct tm *objdatetm);
extern void join_llists (LLIST **mainlist, LLIST **sublist);
extern char *jpn_parser (PARG *parg);
extern int load_custom_language (DBLK *dblk, DBLK *dblist);
extern int load_jpn_language (DBLK *dblk, DBLK *dblist);
extern int load_language (DBLK *dblk, DBLK *dblist);
extern int load_wordtree (
WORDTREE **treetop,
DBLK *dblk,
char *fname,
int do_teskey_test);
extern char *null_stemmer (char *word, DBLK *dblk);
extern char *null_lstrupr (char *string, DBLK *dblk);
extern char *objdate2fzkstr (DtSrObjdate objdate);
extern struct tm
*objdate2tm (DtSrObjdate objdate);
extern int objdate_in_range (DtSrObjdate recdate,
DtSrObjdate date1, DtSrObjdate date2);
extern int offline_kbhit (void);
extern int open_dblk (DBLK **dblist, int numpages, int debugging);
extern LLIST *pop_llist (LLIST **llistp);
extern void print_dbrec (char *dbname, struct or_dbrec *dbrec);
extern int quit_escape(void);
extern UCHAR readchar_ftext (PARG *parg);
extern UCHAR readchar_string (UCHAR *string);
extern char *remove_spaces (char *string);
extern void replace_ext (char *buffer, int buflen,
char *fname, char *fext);
extern LLIST *sort_llist (LLIST *list_header);
extern char *teskey_parser (PARG *parg);
extern DtSrObjdate
tm2objdate (struct tm *tmptr);
#ifndef _ALL_SOURCE
extern char *strdup (const char *s);
#endif
extern void toggle_insert (void);
extern void unload_custom_language (DBLK *dblk);
extern void unload_language (DBLK *dblk);
extern void vista_abort (char *location);
extern char *vista_msg (char *location);
/************************ SearchP.h ********************************/
#endif /* _SearchP_h */

106
cde/lib/DtSearch/apndext.c Normal file
View File

@@ -0,0 +1,106 @@
/*
* COMPONENT_NAME: austext
*
* FUNCTIONS: append_ext
* replace_ext
*
* ORIGINS: 27
*
*
* (C) COPYRIGHT International Business Machines Corp. 1990,1995
* All Rights Reserved
* Licensed Materials - Property of IBM
* US Government Users Restricted Rights - Use, duplication or
* disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
*/
/*************************** APNDEXT.C *************************
* $XConsortium: apndext.c /main/5 1996/05/07 13:24:29 drk $
* append_ext:
* 1. Concatenates a file extension to a passed filename,
* unless an extension is already provided in the name.
* Moves the concatenated string to the passed buffer.
* 2. Checks for filename buffer overflow.
*
* replace_ext:
* Same thing, except that if a dotted extension is already
* provided, it REPLACES the last extension with the passed one.
*
* $Log$
* Revision 2.2 1995/10/25 22:25:29 miker
* Added prolog.
*
* Revision 2.1 1995/09/22 18:08:26 miker
* Freeze DtSearch 0.1, AusText 2.1.8
*/
#include "SearchP.h"
#include <string.h>
/********************************************************/
/* */
/* append_ext */
/* */
/********************************************************/
void append_ext(char *buffer, /* output assy area */
int buflen, /* length of buffer */
char *fname, /* input prefix (file name) */
char *fext) /* input suffix (file ext .XXX) */
{
char *endptr, *slashptr, *dotptr;
strncpy (buffer, fname, buflen);
*(buffer + buflen - 5) = '\0'; /* room for ".xxx" at end */
/* Look for FINAL dot and FINAL slash (directory delim) */
dotptr = slashptr = NULL;
for (endptr = buffer; *endptr != 0; endptr++) {
if (*endptr == LOCAL_SLASH)
slashptr = endptr;
else if (*endptr == '.')
dotptr = endptr;
}
/* If extension already exists (ie there's a dot in the name),
* and its past any dir delim, if any,
* return immediately: the dot is a valid extension marker.
*/
if (dotptr) { /* extension already exists */
if (slashptr == NULL)
return;
else if (slashptr < dotptr)
return;
}
/* Extension does not exist or its in earlier dir name */
strcpy (endptr, fext);
return;
} /* append_ext() */
/********************************************************/
/* */
/* replace_ext */
/* */
/********************************************************/
void replace_ext (char *buffer, /* output assy area */
int buflen, /* length of buffer */
char *fname, /* input prefix (file name) */
char *fext) /* input suffix (file ext .XXX) */
{
int fnamelen;
char *targ;
strncpy(buffer, fname, buflen - 1);
*(buffer + buflen - 1) = '\0'; /* just in case */
fnamelen = strlen(buffer);
if ((targ = strrchr(buffer, '.')) == NULL) {
strncpy (buffer + fnamelen, fext, buflen - fnamelen - 1);
*(buffer + buflen - 1) = '\0'; /* again just in case */
}
else {
while (*targ != 0 && *fext != 0) *targ++ = *fext++;
if (*fext == 0) *targ = 0;
}
return;
} /* replace_ext() */
/*************************** APNDEXT.C ****************************/

186
cde/lib/DtSearch/ausdopen.c Normal file
View File

@@ -0,0 +1,186 @@
/*
* COMPONENT_NAME: austext
*
* FUNCTIONS: austext_dopen
*
* ORIGINS: 27
*
*
* (C) COPYRIGHT International Business Machines Corp. 1994,1995
* All Rights Reserved
* Licensed Materials - Property of IBM
* US Government Users Restricted Rights - Use, duplication or
* disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
*/
/*************************** AUSDOPEN.C **************************
* $XConsortium: ausdopen.c /main/6 1996/08/12 13:17:32 cde-ibm $
* April 1994.
* Austext_dopen() performs vista d_open() for an AusText database.
* Optionally sets vista page cache size, renames the files,
* opens the database, and optionally reads the dbrec.
* Intended to be used by offline programs like cravel, cborodin,
* and various utilities. Similar to opendblk.c.
*
* $Log$
* Revision 2.3 1995/10/25 22:22:45 miker
* Added prolog.
*
* Revision 2.2 1995/10/19 20:20:51 miker
* Deleted all RENFILE calls--database files no longer have to be renamed.
*
* Revision 2.1 1995/09/22 19:04:52 miker
* Freeze DtSearch 0.1, AusText 2.1.8
*
* Revision 1.5 1995/08/31 21:53:28 miker
* Minor changes for DtSearch.
*
* Revision 1.4 1995/05/30 18:19:21 miker
* write all err msgs to aa_stderr (write_msg) rather than stdout.
*/
#include "SearchP.h"
#include "vista.h"
#define PROGNAME "AUSDOPEN"
/****************************************/
/* */
/* austext_dopen */
/* */
/****************************************/
/* dbname: 1 - 8 char database name.
* path: Optional path prefix for .dbd file.
* If NULL is passed, default is vista
* default (current working directory).
* d2xpath: Used only for mrclean; should be NULL for all other callers.
* Specifies path prefix for rename of d2x files only.
* cache: Optional vista paging size.
* If zero is passed, default is global CACHE_SIZE.
* If < 16 specified, silently adjusted up to minimum 16.
* If cache specified is not a power of 2,
* cache adjusted upward to nearest power of 2.
* dbrec: If NULL is passed, dbrec is not read. Otherwise
* database's dbrec is read into passed buffer.
*
* RETURNS: TRUE if all went well.
* FALSE and writes error msg to ausapi_msglist if could not open.
* (vista abort prints out its own error messages).
*/
int austext_dopen (
char *dbname,
char *path,
char *d2xpath,
int cache,
DBREC *dbrec)
{
char dbdbuf[2048];
char d2xbuf[2048];
int i;
char sprintbuf[2048];
char *d2xptr, *ptr, *src;
/* Test dbname */
if (dbname == NULL) {
INVALID_DBNAME:
sprintf (sprintbuf, catgets (dtsearch_catd, 13, 348,
"%s Invalid database name '%s'."),
PROGNAME"348", NULLORSTR(dbname));
DtSearchAddMessage (sprintbuf);
return FALSE;
}
i = strlen (dbname);
if (i < 1 || i > 8)
goto INVALID_DBNAME;
/* Test cache, silently rounding up to nearest power of 2.
* 2^4 = 16 = minimum cache. 2^12 = 4096 = maximum cache.
*/
if (cache == 0)
cache = CACHE_SIZE;
else {
for (i = 4; i < 12; i++)
if (1 << i >= cache)
break;
cache = 1 << i;
}
/* If mrclean needs special d2x renames, build them now.
* (d2xptr is where the ".d2x" extensions will be copied.)
*/
if (d2xpath) {
d2xptr = d2xbuf;
for (i = 0; i < sizeof (d2xbuf) - 14; i++) {
if (d2xpath[i] == 0)
break;
*d2xptr++ = d2xpath[i];
}
if (i > 0 && *(d2xptr - 1) != LOCAL_SLASH)
*d2xptr++ = LOCAL_SLASH;
src = dbname;
while (*src != 0)
*d2xptr++ = *src++;
}
/* Copy path, if any, to name buffer leaving room for the slash
* which the caller may not have originally specified,
* the 8 char database name, the 3 char file name extensions,
* and the terminating \0. Then set 'ptr' to the place
* where the dbdname should be appended.
*/
ptr = dbdbuf;
if (path != NULL) {
for (i = 0; i < sizeof (dbdbuf) - 14; i++) {
if (path[i] == 0)
break;
*ptr++ = path[i];
}
if (i > 0 && *(ptr - 1) != LOCAL_SLASH)
*ptr++ = LOCAL_SLASH;
}
/* Now concatenate the dbname and set ptr to where
* the file name extensions should go.
*/
src = dbname;
while (*src != 0)
*ptr++ = *src++;
/* Specify the cache size and open the database.
* I use the original d_open() call so I can print
* a good error msg if it fails.
*/
*ptr = 0; /* no extension used for .dbd file in OPEN */
SETPAGES (PROGNAME "283", cache, 4);
d_open (dbdbuf, "o");
if (db_status != S_OKAY) {
sprintf (sprintbuf, catgets (dtsearch_catd, 13, 379,
"%s Could not open database '%s':\n %s."),
PROGNAME"379", dbdbuf, vista_msg (PROGNAME"379"));
DtSearchAddMessage (sprintbuf);
return FALSE;
}
/* From here on, emergency exits MUST close the database. */
austext_exit_dbms = (void (*) (int)) d_close;
/* If requested, read the dbrec into caller's buffer. */
if (dbrec != NULL) {
RECFRST (PROGNAME "285", OR_DBREC, 0); /* seqtl retrieval */
if (db_status != S_OKAY) {
NO_DBREC:
sprintf (sprintbuf,
PROGNAME "289 Database '%s' has not been initialized.",
dbname);
DtSearchAddMessage (sprintbuf);
return FALSE;
}
RECREAD (PROGNAME "302", dbrec, 0);
if (db_status != S_OKAY)
goto NO_DBREC;
swab_dbrec (dbrec, NTOH);
}
return TRUE;
} /* austext_dopen() */
/*************************** AUSDOPEN.C **************************/

127
cde/lib/DtSearch/ausexit.c Normal file
View File

@@ -0,0 +1,127 @@
/*
* COMPONENT_NAME: austext
*
* FUNCTIONS: DtSearchExit
* DtSearchAddUserExit
* DtSearchRemoveUserExit
*
* ORIGINS: 27
*
*
* (C) COPYRIGHT International Business Machines Corp. 1993,1996
* All Rights Reserved
* Licensed Materials - Property of IBM
* US Government Users Restricted Rights - Use, duplication or
* disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
*/
/********************* AUSEXIT.C ************************
* $XConsortium: ausexit.c /main/6 1996/06/23 16:47:24 cde-ibm $
* August 1993.
* Performs generic exit function for AusText system ensuring
* graceful shutdown for vista database, curses lib, etc.
* Declares several global function pointers.
* Austext_exit has been renamed to DtSearchExit to support
* it's public visibility in DtSearch.
*
* Replaces both exitop.c and exitopv.c and changes the name
* of the function from opera_exit() to austext_exit().
* The name change ensures that the linker will catch all
* the places we have to set global 'austext_exit_dbms' to d_close().
* These were the former exitopV.c links; the plain exitop.c
* links were non-vista programs so only the name has to be changed.
*
* If austext_exit_endwin is not NULL, then a windows-oriented UI
* is executing and austext_exit_endwin should be called before
* shutting down to ensure restoration of normal terminal mode.
* For curses, austext_exit_endwin is set to the curses endwin()
* function immediately after curses initialization (initscr() call).
*
* If austext_exit_dbms is not NULL, then current process
* is linked to database api and function should be called
* to flush and close databases. For vista, austext_exit_dbms
* is set to d_close() at beginning of vista-using program.
*
* If austext_exit_mem is not NULL, then current process
* is using shared memory and function should be called
* to release it to the system.
*
* If austext_exit_comm is not NULL, then current process
* is communicating to a remote process over a network.
* The function is in a local communications package and
* should be called to gracefully shutdown local child/parent
* processes and daemons and allow a message to be sent to
* the remote process to do the same.
*
* Austext_exit_first and last are miscellaneous private
* exits which get called first and last respectively.
* Austext_exit_user is called just before 'last',
* but 'user' is public, ie known to customer developers
* using the DtSearch/ausapi interface, whereas 'first' and 'last'
* are private, reserved for the ausapi developers themselves.
*
* $Log$
* Revision 2.3 1996/04/10 19:45:58 miker
* Added DtSearchAddUserExit and DtSearchRemoveUserExit.
*
* Revision 2.2 1995/10/25 22:20:53 miker
* Added prolog.
*
* Revision 2.1 1995/09/22 18:51:11 miker
* Freeze DtSearch 0.1, AusText 2.1.8
*
* Revision 1.4 1995/08/31 21:54:23 miker
* Rename austext_exit() to DtSearchExit().
*/
#include "Search.h"
void (*austext_exit_first) (int) = NULL;
void (*austext_exit_dbms) (int) = NULL;
void (*austext_exit_comm) (int) = NULL;
void (*austext_exit_endwin) (int) = NULL;
void (*austext_exit_mem) (int) = NULL;
void (*austext_exit_user) (int) = NULL;
void (*austext_exit_last) (int) = NULL;
/****************************************/
/* */
/* DtSearchExit */
/* */
/****************************************/
void DtSearchExit (int return_code)
{
if (austext_exit_first != NULL)
austext_exit_first (return_code);
if (austext_exit_dbms != NULL)
austext_exit_dbms (return_code);
if (austext_exit_comm != NULL)
austext_exit_comm (return_code);
if (austext_exit_endwin != NULL)
austext_exit_endwin (return_code);
if (austext_exit_mem != NULL)
austext_exit_mem (return_code);
if (austext_exit_user != NULL)
austext_exit_user (return_code);
if (austext_exit_last != NULL)
austext_exit_last (return_code);
exit (return_code);
}
/****************************************/
/* */
/* DtSearchAddUserExit */
/* */
/****************************************/
void DtSearchAddUserExit (void (*user_exit)(int))
{ austext_exit_user = user_exit; }
/****************************************/
/* */
/* DtSearchRemoveUserExit */
/* */
/****************************************/
void DtSearchRemoveUserExit (void)
{ austext_exit_user = NULL; }
/********************* AUSEXIT.C ************************/

229
cde/lib/DtSearch/bmstrstr.c Normal file
View File

@@ -0,0 +1,229 @@
/*
* COMPONENT_NAME: austext
*
* FUNCTIONS: bmhcore
* bmhtable_build
* bmstrstr
* main
*
* ORIGINS: 27
*
*
* (C) COPYRIGHT International Business Machines Corp. 1992,1995
* All Rights Reserved
* Licensed Materials - Property of IBM
* US Government Users Restricted Rights - Use, duplication or
* disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
*/
/************************* BMSTRSTR.C ****************************
* $TOG: bmstrstr.c /main/6 1998/04/17 11:25:23 mgreess $
* Original module named fastsearch.c
* and included colocation string search functions.
* Modification of Boyer-Moore-Horspool algorithm,
* Sec 10.5.2 of Information Retrieval, Frakes and Baeza-Yates, editors.
* Provides a generalized boyer-moore
* strstr() function. The table used in the BMH algorithm is
* generated in a separate function to improve efficiency when
* looking for the same substring pattern in multiple text strings.
* The 'length' arguments can be passed if known, or passed as
* strlen(xxx) if not known. HOWEVER the string arrays MUST be at
* least 1 char larger then strlen() says ('cause we insert a \0).
* This whole thing has been coded for SPEED!
*
* $Log$
* Revision 2.2 1995/10/26 15:37:42 miker
* Added prolog.
*
* Revision 2.1 1995/09/22 19:10:39 miker
* Freeze DtSearch 0.1, AusText 2.1.8
*
* Revision 1.2 1995/08/31 22:12:05 miker
* Minor changes for DtSearch.
*/
#include "SearchP.h"
#include <stdio.h>
#include <string.h>
#include <sys/param.h>
#ifndef _AIX
#define __strcmp strcmp
#endif
/*********#define TEST_BMSTRSTR**************/
/****************************************/
/* */
/* bmhtable_build */
/* */
/****************************************/
/* Builds the table for search substring 'pattern'
* used by the BMH core search algorithm.
* 'patlen' is the string length of 'pattern'.
* The caller defines and passes 'bmhtable',
* an array of long integers (size_t) of size MAX_BMHTAB.
* This function initializes bmhtable for later search call.
*/
void bmhtable_build (
unsigned char *pattern,
size_t patlen,
size_t * bmhtable)
{
int k;
for (k = 0; k < MAX_BMHTAB; k++)
bmhtable[k] = patlen;
patlen--;
for (k = 0; k < patlen; k++)
bmhtable[pattern[k]] = (patlen - k);
return;
} /* bmhtable_build() */
/****************************************/
/* */
/* bmhcore */
/* */
/****************************************/
/* Performs 'core' BMH search after bmhtable is built.
* Returns ptr to first occurrence of pattern in text or NULL.
* WARNING! IF EITHER txtlen OR patlen <= 0, THIS FUNCTION WILL CRASH!!!
* Pattern and patlen MUST BE identical with those used to build
* bmhtable.
*/
char *bmhcore (
unsigned char *text,
size_t txtlen,
unsigned char *pattern,
size_t patlen,
size_t *bmhtable)
{
register unsigned char
lastchar = pattern[patlen - 1];
register unsigned char
textchar;
register unsigned char
*cp;
register unsigned char
*last;
int savechar;
int savechar2;
unsigned char
*result = NULL;
/* Terminate pattern with a char we KNOW is not in text.
* Note that this requires string to have room for \0 at end.
*/
savechar = pattern[patlen];
pattern[patlen] = '\0';
last = text + txtlen;
for (cp = text + patlen - 1; cp < last; cp += bmhtable[textchar]) {
/*
* Check if last character matches. If it doesn't, no need
* to check any further.
*/
if ((textchar = *cp) != lastchar)
continue;
savechar2 = cp[1];
cp[1] = '\0';
if (!__strcmp ((char *) (cp + 1 - patlen), (char *) pattern))
result = cp + 1 - patlen;
cp[1] = savechar2;
if (result)
break;
}
pattern[patlen] = savechar; /* restore last char */
return (char *) result;
} /* bmhcore() */
/****************************************/
/* */
/* bmstrstr */
/* */
/****************************************/
/* Search in text [1..txtlen] for pattern [1..patlen].
* Returns ptr to first occurrence of pattern, or NULL.
*/
char *bmstrstr (
unsigned char *text,
size_t txtlen,
unsigned char *pattern,
size_t patlen)
{
size_t bmhtable[MAX_BMHTAB];
bmhtable_build (pattern, patlen, bmhtable);
return bmhcore (text, txtlen, pattern, patlen, bmhtable);
} /* bmstrstr() */
#ifdef TEST_BMSTRSTR /* for test only */
#include <sys/stat.h>
/****************************************/
/* */
/* main */
/* */
/****************************************/
/* tests bmstrstr() against standard strstr() on a specified file */
main ()
{
FILE *f;
struct stat statbuf;
size_t fsize = 0L;
char fname[BUFSIZ+1];
char pattern[MAXPATHLEN+1];
char *readbuf = NULL;
char *ptr;
MAIN_LOOP:
printf ("\nEnter a filename (Ctrl-C quits) > ");
*fname = '\0';
fgets (fname, sizeof(fname), stdin);
if (strlen(fname) && fname[strlen(fname)-1] == '\n')
fname[strlen(fname)-1] = '\0';
if ((f = fopen (fname, "r")) == NULL) {
printf ("Can't open '%s': %s\n", fname, strerror (errno));
goto MAIN_LOOP;
}
fstat (fileno (f), &statbuf);
if (fsize > statbuf.st_size) {
free (readbuf);
readbuf = NULL;
}
fsize = statbuf.st_size;
if (readbuf == NULL)
readbuf = malloc (fsize + 64L);
fread (readbuf, fsize, 1L, f);
fclose (f);
printf ("Enter a search pattern > ");
*pattern = '\0';
fgets (pattern, sizeof(pattern), stdin);
if (strlen(pattern) && pattern[strlen(pattern)-1] == '\n')
pattern[strlen(pattern)-1] = '\0';
ptr = bmstrstr (readbuf, fsize, pattern, strlen (pattern));
if (ptr == NULL)
puts ("bmstrstr: Pattern not found.");
else
printf ("bmstrstr: Pattern found at offset %ld.\n", ptr - readbuf);
ptr = strstr (readbuf, pattern);
if (ptr == NULL)
puts ("strstr: Pattern not found.");
else
printf ("strstr: Pattern found at offset %ld.\n", ptr - readbuf);
goto MAIN_LOOP;
} /* main() test program */
#endif
/************************* BMSTRSTR.C ****************************/

1102
cde/lib/DtSearch/boolpars.c Normal file

File diff suppressed because it is too large Load Diff

115
cde/lib/DtSearch/boolpars.h Normal file
View File

@@ -0,0 +1,115 @@
/* $XConsortium: boolpars.h /main/1 1996/03/29 17:03:47 cde-ibm $
*
* (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 1996 FUJITSU LIMITED.
* (c) Copyright 1996 Hitachi.
*/
/*
* COMPONENT_NAME: austext
*
* FUNCTIONS: none
*
* ORIGINS: 27
*
*
* (C) COPYRIGHT International Business Machines Corp. 1996
* All Rights Reserved
* Licensed Materials - Property of IBM
* US Government Users Restricted Rights - Use, duplication or
* disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
*/
#ifndef _boolpars_h
#define _boolpars_h
/******************** BOOLPARS.H ********************
* $Id: boolpars.h /main/1 1996/03/29 17:03:47 cde-ibm $
* February 1996.
* Header for boolpars.c AusText/DtSearch yacc-based boolean query parser.
*
* FORMAT OF TRUTH TABLE:
* Pointer to TRUTHTAB struct is main yacc stack value.
* Represents 256 unsigned chars, every possible permutation of 8 (max)
* query stems. The unsigned chars ("permutes") are bit vectors.
* Bit #0 (lowest order) is for first word in stemsarray stems[0],
* bit #1 is stems[1], etc.
* Example: truthtab for query consisting of a single word,
* call it 'A' (assigned bit #0), is the 128 chars 1, 3, 5, 7, ...,
* ie all bitvector permutations with low order bit turned on.
* B: (bit #1) is the 128 chars 2, 3, 6, 7, ..., ie all permutations
* with 2nd bit turned on.
* A & B: Intersection of truth tables: the 64 chars 3, 7, ...,
* all the bit vector permutations they have in common.
* A | B: Union of truth tables: the 192 permutes 1,2,3, 5,6,7, 9,10,11...
* ~B: Complement of truth table, U - B: the 128 chars 0, 1, 4, 5, ...,
* ie every bitvector permutation NOT in B.
*
* The zero permute (all bits zero) refers to the entire
* balance of the database containing none of the query stems.
* Needless to say searches with the zero permute in their
* truth table will take an incredibly long time!
*
* The 'universal set' U is all 256 possible permutes.
* The 'empty set' is indicated by truthtab.pmsz == 0;
*
* The permutes in a truth table are maintained in
* ascending order for ease of comparisons.
*
* Truth table manipulations require and depend on
* DtSrMAX_STEMCOUNT being defined only as 8.
*
* Newly allocated truth tables are maintained on the 'ttlist'
* using the 'next' field. This is to ensure they are eventually
* freed to prevent memory leaks.
*
* If 'stemno' >= 0 it points to the word in usrblk.stems to which
* it applies. Stemno == -1 means truth table is not directly
* associated with a word in usrblk.stems.
*
* $Log$
* Revision 1.1 1996/03/05 15:52:06 miker
* Initial revision
*
*/
#define COLLOC_STEM_FORMAT "@%02d%02d%d"
/****************************************/
/* */
/* TRUTHTAB */
/* */
/****************************************/
/* Truth table returned from boolean_parse() */
typedef struct tttag {
struct tttag *next;
int stemno; /* -1 means not assoc with stems[] array */
int pmsz; /* number of bytes in permutes array */
unsigned char *permutes; /* array of bit vector permutations */
} TRUTHTAB;
/****************************************/
/* */
/* Globals */
/* */
/****************************************/
extern int qry_has_no_NOTs;
extern int qry_is_all_ANDs;
extern int parser_invalid_wordcount;
extern TRUTHTAB final_truthtab;
/****************************************/
/* */
/* Function Prototypes */
/* */
/****************************************/
extern void add_syntax_errmsg (int msgno);
extern TRUTHTAB *boolyac_AND (TRUTHTAB *tt1, TRUTHTAB *tt2);
extern TRUTHTAB *boolyac_COLLOC (TRUTHTAB *tt1, int colval, TRUTHTAB *tt2);
extern TRUTHTAB *boolyac_NOT (TRUTHTAB *tt1);
extern TRUTHTAB *boolyac_OR (TRUTHTAB *tt1, TRUTHTAB *tt2);
extern TRUTHTAB *copy_final_truthtab (TRUTHTAB *tt);
/******************** BOOLPARS.H *********************/
#endif /* _boolpars_h */

1572
cde/lib/DtSearch/boolsrch.c Normal file

File diff suppressed because it is too large Load Diff

134
cde/lib/DtSearch/boolyac.y Normal file
View File

@@ -0,0 +1,134 @@
%{
/* $XConsortium: boolyac.y /main/1 1996/03/29 17:04:13 cde-ibm $
*
* (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 1996 FUJITSU LIMITED.
* (c) Copyright 1996 Hitachi.
*/
/*
* COMPONENT_NAME: austext
*
* FUNCTIONS: expr
* yyparse
*
* ORIGINS: 27
*
*
* (C) COPYRIGHT International Business Machines Corp. 1996,1996
* All Rights Reserved
* Licensed Materials - Property of IBM
* US Government Users Restricted Rights - Use, duplication or
* disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
*/
/********************* BOOLYAC.Y ********************
* $Id: boolyac.y /main/1 1996/03/29 17:04:13 cde-ibm $
* February 1996.
* AusText/DtSearch yacc-based boolean query parser.
* Converts boolean query into stems array and truth table
* for subsequent search. This is the yacc source.
* After processing by yacc, it becomes boolyac.c and boolyac.h.
* Boolpars.c contains all the related C source code: yylex,
* action functions, and the main driver function, boolean_parse.
*
* $Log$
* Revision 1.1 1996/03/05 15:52:05 miker
* Initial revision
*
*/
#include <stddef.h>
#include "boolpars.h"
%}
%union {
TRUTHTAB *truthtab;
int int_val;
}
%token <truthtab> WORD_TOKEN
%left '|' /* left associative, lowest precedence */
%left '&' /* left associative, higher precedence */
%right '~' /* right associative */
%token <int_val> COLLOC_TOKEN
%token ERROR_TOKEN /* highest precedence */
%type <truthtab> expr query
%%
/*********** Top Level Start Rule ****************/
query: /* nothing */
{
if (parser_invalid_wordcount > 0)
add_syntax_errmsg(6);
else
add_syntax_errmsg(1);
YYABORT;
}
| expr
{ $$ = copy_final_truthtab ($1); }
| '&' expr
{ add_syntax_errmsg(2); YYABORT; }
| expr '&'
{
if (qry_is_all_ANDs)
$$ = copy_final_truthtab ($1);
else {
add_syntax_errmsg(2);
YYABORT;
}
}
| '|' expr
{ add_syntax_errmsg(2); YYABORT; }
| expr '|'
{ add_syntax_errmsg(2); YYABORT; }
| '(' ')'
{ add_syntax_errmsg(3); YYABORT; }
| expr '~'
{ add_syntax_errmsg(4); YYABORT; }
| COLLOC_TOKEN expr
{ add_syntax_errmsg(5); YYABORT; }
| ')' COLLOC_TOKEN
{ add_syntax_errmsg(5); YYABORT; }
| ERROR_TOKEN { YYABORT; }
;
/*********** Valid Expressions ************/
expr: WORD_TOKEN
{ $$ = $1; }
| expr '&' expr
{ $$ = boolyac_AND ($1, $3); }
| expr '|' expr
{ $$ = boolyac_OR ($1, $3); }
| '(' expr ')'
{ $$ = $2; }
| '~' expr
{ $$ = boolyac_NOT ($2); }
| WORD_TOKEN COLLOC_TOKEN WORD_TOKEN %prec COLLOC_TOKEN
{
$$ = boolyac_COLLOC ($1, $2, $3);
if ($$ == NULL)
YYABORT;
}
;
%%
/********************* BOOLYAC.Y ********************/

View File

@@ -0,0 +1,51 @@
/*
* COMPONENT_NAME: austext
*
* FUNCTIONS: load_custom_language
* unload_custom_language
*
* ORIGINS: 27
*
*
* (C) COPYRIGHT International Business Machines Corp. 1995
* All Rights Reserved
* Licensed Materials - Property of IBM
* US Government Users Restricted Rights - Use, duplication or
* disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
*/
/************ CUSLANG.C **********
* $XConsortium: cuslang.c /main/4 1996/05/07 13:26:29 drk $
* August 1995.
* Dummy load_custom_language() and unload_custom_language().
* Can be overridden by user's own custom language functions
* by linking in a module with these functions prior to
* linking in this module.
* Both are referenced in loadlang.c.
*
* $Log$
* Revision 2.2 1995/10/26 15:33:30 miker
* Added prolog.
*
* Revision 2.1 1995/09/22 19:13:59 miker
* Freeze DtSearch 0.1, AusText 2.1.8
*/
#include "SearchP.h"
int load_custom_language (DBLK *dblk, DBLK *dblist)
{
char msgbuf [1024];
sprintf (msgbuf,
"CUSLANG01 Database '%s': Language number %d\n"
" is unsupported and user has not provided a\n"
" load_custom_language() function to handle it.",
dblk->name, dblk->dbrec.or_language);
DtSearchAddMessage (msgbuf);
return FALSE;
}
void unload_custom_language (DBLK *dblk)
/* If user provides load() but not unload(),
* then this dummy will almost certainly cause
* memory leaks at REINIT.
*/
{ return; }

128
cde/lib/DtSearch/dbchange.c Normal file
View File

@@ -0,0 +1,128 @@
/*
* COMPONENT_NAME: austext
*
* FUNCTIONS: database_has_changed
* file_has_changed
*
* ORIGINS: 27
*
*
* (C) COPYRIGHT International Business Machines Corp. 1995
* All Rights Reserved
* Licensed Materials - Property of IBM
* US Government Users Restricted Rights - Use, duplication or
* disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
*/
/******************************* DBCHANGE.C ********************************
* $XConsortium: dbchange.c /main/4 1996/05/07 13:26:54 drk $
* March 1995.
* Extracted from oe.c so it could also be called by server daemon.
* When called only in the engine it was only called by a child
* of the daemon, so the original daemon was never updated and
* every single engine call resulted in an engine reinitialization.
*
* $Log$
* Revision 2.2 1995/10/26 15:31:24 miker
* Added prolog.
*
* Revision 2.1 1995/09/22 19:47:12 miker
* Freeze DtSearch 0.1, AusText 2.1.8
*
* Revision 1.2 1995/08/31 22:18:48 miker
* Minor changes for DtSearch including msg catalogs and
* replacing socblk with usrblk for head of dblist.
*/
#include "SearchE.h"
#include <errno.h>
#include <sys/stat.h>
#define PROGNAME "DBCHANGE"
/************************************************/
/* */
/* file_has_changed */
/* */
/************************************************/
/* If site config file or any d99 file has changed
* since program initialization, close all databases and reinitialize.
* This usually happens when the administrator has updated
* a copy of one of the databases in a different directory.
* He then changes the PATH parameter for that database in the
* site config file. By closing databases and reinitializing,
* an administrator can swap databases without bringing the users down.
* The test for the d99 files is included because in some systems,
* like cose, a database may change without a corresponding
* change in the site config file.
* Databases cannot be swapped during an ongoing search.
* If the passed file's mod time is unaccessible or has changed,
* appends msg to msglist, reinitializes engine if necessary,
* sets up usrblk.retncode, and returns TRUE.
* Otherwise returns FALSE.
*/
static int file_has_changed (char *fname, time_t origtime)
{
struct stat statbuf;
char sprintbuf[1024];
if (stat (fname, &statbuf) == -1) {
sprintf (sprintbuf, catgets (dtsearch_catd, 10, 1300,
"%s Unable to comply with request; cannot access status\n"
" of database file '%s': %s"),
PROGNAME "1300", fname, strerror (errno));
DtSearchAddMessage (sprintbuf);
usrblk.retncode = OE_NOOP;
return TRUE;
}
if (origtime != statbuf.st_mtime) {
strcpy (sprintbuf, nowstring (&origtime));
fprintf (aa_stderr,
"%s %s reinitialized AusText engine:\n"
" changed file: %s\n"
" old file time: %s\n"
" current file time: %s.\n",
PROGNAME "1312", aa_argv0, fname,
sprintbuf, nowstring (&statbuf.st_mtime));
if (!(usrblk.flags & USR_NO_INFOMSGS)) {
sprintf (sprintbuf, catgets (dtsearch_catd, 10, 1313,
"%s *** REQUEST CANCELED *** %s Engine reinitialized\n"
" due to modification of file %s, probably caused by\n"
" update to one or more databases."),
PROGNAME "1313", OE_prodname, fname);
DtSearchAddMessage (sprintbuf);
}
oe_uninitialize ();
oe_initialize ();
usrblk.retncode = OE_REINIT;
return TRUE;
}
return FALSE;
} /* file_has_changed() */
/************************************************/
/* */
/* database_has_changed */
/* */
/************************************************/
/* Verify that none of the databases has changed since the last call.
* Don't check until after first initialize.
* Returns TRUE if any changes, else FALSE.
*/
int database_has_changed (void)
{
char fnamebuf[256];
DBLK *db;
if (OE_sitecnfg_mtime == 0L)
return FALSE;
if (file_has_changed (OE_sitecnfg_fname, OE_sitecnfg_mtime))
return TRUE;
for (db = usrblk.dblist; db != NULL; db = db->link) {
sprintf (fnamebuf, "%s%s" EXT_DTBS, db->path, db->name);
if (file_has_changed (fnamebuf, db->iimtime))
return TRUE;
}
return FALSE;
} /* database_has_changed() */
/******************************* DBCHANGE.C ********************************/

199
cde/lib/DtSearch/dberr.c Normal file
View File

@@ -0,0 +1,199 @@
/*
* COMPONENT_NAME: austext
*
* FUNCTIONS: dbautorec
* dberr
* vista_abort
* vista_msg
*
* ORIGINS: 27
*
* (C) COPYRIGHT International Business Machines Corp. 1993,1995
* All Rights Reserved
* US Government Users Restricted Rights - Use, duplication or
* disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
*/
/************************** DBERR.C *************************
* $XConsortium: dberr.c /main/6 1996/11/25 18:46:36 drk $
* November 1993.
* Extensive enhancement to original vista dberr() function.
* This module MUST be linked into a system before libvista.a
* so that this version of dberr() will be called rather than
* the default Raima version.
*
* $Log$
* Revision 2.2 1995/10/24 21:29:25 miker
* Add IBM prolog. Update NOFILE msg for enhanced vista.
*
* Revision 2.1 1995/09/22 19:26:52 miker
* Freeze DtSearch 0.1, AusText 2.1.8
*
* Revision 1.7 1995/08/31 22:23:39 miker
* Minor changes for DtSearch.
*
* Revision 1.6 1995/07/20 17:54:22 miker
* Changed dberr_exit to global function ptr--easier to use or ignore.
*
* Revision 1.5 1995/07/18 22:27:16 miker
* Delete msglist arg from vista_abort() function.
* Replace exit() with dberr_exit() so applications
* can clean up after database errors.
*/
#ifndef _XOPEN_SOURCE
#define _XOPEN_SOURCE 1 /* for nl_catd */
#endif
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
#include <string.h>
#include <nl_types.h> /* for nl_catd */
#include "vista.h"
#include "dberr.h" /* retained for default vista msgs */
#define MS_vista 13 /* message set number */
/*------------------- GLOBALS -------------------*/
static int vista_syserrno = 0;
static char vista_errmsg[1024];
void (*dberr_exit) (int) = exit;
extern nl_catd dtsearch_catd; /* non AusText user should #define to -1 */
extern FILE *aa_stderr; /* non AusText user should #define to stderr */
/****************************************/
/* */
/* dberr */
/* */
/****************************************/
/* Just set db_status and a new global called db_syserrno.
* This function is called by the vista runtime code itself
* so the prototype cannot be changed.
* Original Raima comment for dberr: "vpp -nOS2 -dUNIX -nBSD
* -nVANILLA_BSD -nVMS -nMEMLOCK -nWINDOWS -nFAR_ALLOC
* -f/usr/users/master/config/nonwin dberr.c".
*/
int dberr (int verrno)
{
vista_syserrno = errno;
db_status = (verrno == S_DEBUG) ? S_OKAY : verrno;
return db_status;
}
/****************************************/
/* */
/* dbautorec */
/* */
/****************************************/
/* Database auto-recovery notification function.
* Exact copy of original Raima function.
* Original Raima comments:
* This function is called by the db_VISTA runtime whenever
* a database recovery is about to occur. Any desired user
* interaction code (such as an "auto-recovery in process" message)
* should be included here.
*/
void dbautorec (void)
{
fputs (catgets (dtsearch_catd, MS_vista, 304,
"\n*** db_VISTA auto recovery in process...\n"),
aa_stderr);
db_status = S_RECOVERY;
return;
} /* dbautorec() */
/****************************************/
/* */
/* vista_msg */
/* */
/****************************************/
/* Assembles vista error message string corresponding
* to value in db_status. Unlike the original dberr(),
* vista_msg() generates a msg for ALL vista statuses
* including positive values (presumably programming errors
* since positive values are normal vista return codes).
* The passed variable will be prefixed to the string to
* identify the location (module name, line number) of the error.
* Returns a pointer to global buffer containing the msg string.
*/
char *vista_msg (char *location)
{
int i;
char *defaultmsg;
char *msgtarg;
/* Assemble standard Raima err msg */
if (location == NULL)
location = catgets (dtsearch_catd, MS_vista, 303,
"(unspecified location)");
sprintf (vista_errmsg, catgets (dtsearch_catd, MS_vista, 311,
"*** DB Error at %s, db_status = %d: %n"),
location, db_status, &i);
msgtarg = vista_errmsg + i;
if (db_status == S_UNAVAIL) { /* +5, usually at d_open() time */
strcpy (msgtarg, catgets (dtsearch_catd, MS_vista, 315,
"Database in use by other users."));
}
else if (db_status >= 0)
strcpy (msgtarg, catgets (dtsearch_catd, MS_vista, 312,
"Programming Error."));
else {
if (db_status < 0 && db_status > -100)
defaultmsg = user_error[-(db_status + 1)];
else if (db_status <= -900)
defaultmsg = system_error[-(db_status + 900)];
else
defaultmsg = catgets (dtsearch_catd, MS_vista, 313,
"Unknown Error.");
strcpy (msgtarg, catgets (dtsearch_catd, MS_vista, -db_status,
defaultmsg));
}
msgtarg += strlen (msgtarg);
/* Append system errno msg */
sprintf (msgtarg, catgets (dtsearch_catd, MS_vista, 301,
"\n*** System I/O errno %d = %s"),
vista_syserrno, strerror (vista_syserrno));
msgtarg += strlen (msgtarg);
/* Append additional information for common user error msgs */
if (db_status == S_NOFILE) {
strcpy (msgtarg, catgets (dtsearch_catd, MS_vista, 302,
"\n"
"*** The usual cause for this kind of error is a missing\n"
"*** or read-only database file, or some system limit\n"
"*** on the number of open files has been exceeded."));
}
msgtarg += strlen (msgtarg);
*msgtarg++ = '\n';
return vista_errmsg;
} /* vista_msg() */
/****************************************/
/* */
/* vista_abort */
/* */
/****************************************/
/* Writes out vista error message string
* corresponding to value in db_status to aa_stderr.
* Conceptually aa_stderr is stderr but it may
* have been vectored to a file by caller.
*
* Then exits using an global exit function pointer.
* The default is plain ol' exit() but users can map
* it to anything, like DtSearchExit() or auscur_exit().
*
* Called by every vista function macro in dmacros.h,
* so it exactly replaces former dboops() function.
*/
void vista_abort (char *location)
{
fputs (vista_msg (location), aa_stderr);
fflush (aa_stderr);
dberr_exit (93);
}
/************************** DBERR.C *************************/

95
cde/lib/DtSearch/dberr.h Normal file
View File

@@ -0,0 +1,95 @@
/* $XConsortium: dberr.h /main/5 1996/09/23 21:00:53 cde-ibm $ */
/*
* COMPONENT_NAME: austext
*
* FUNCTIONS: none
*
* ORIGINS: 27
*
* (C) COPYRIGHT International Business Machines Corp. 1995
* All Rights Reserved
* Licensed Materials - Property of IBM
* US Government Users Restricted Rights - Use, duplication or
* disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
*/
/* $Log$
* Revision 2.2 1995/10/24 21:37:15 miker
* Add prolog.
* */
/* dberr error/status codes */
static char *user_error[] = {
"database not opened",
"invalid set",
"invalid record",
"invalid database",
"invalid field name",
"invalid db_address",
"no current record",
"set has no current owner",
"set has no current member",
"key value required",
"invalid lock value",
"record is owner of non-empty set(s)",
"record is member of set(s)",
"member already owned",
"field is a compound key",
"record not connected to set",
"field is not a valid key",
"record not legal owner of set",
"record not legal member of set",
"error in d_setpages (database open or bad param)",
"incompatible dictionary file",
"illegal attempt to delete system record",
"illegal attempt to lock locked set/record",
"attempt to access unlocked set/record",
"transaction id not supplied",
"transaction already active",
"transaction not active",
"transaction cannot begin due to locked files",
"cannot free locks within a transaction",
"too many changed database pages",
"cannot update database outside a transaction",
"exclusive access required",
"write locks not allowed on static files",
"unspecified or duplicate user id",
"database, path or file name too long",
"invalid file number was passed to d_renfile",
"field is not an optional key field",
"field is not defined in current record type",
"record/field has/in a compound key",
"invalid record or set number",
"record/set not timestamped",
"bad DBUSERID (contains non-alphanumeric)",
"NetBIOS has not been installed on machine",
"wrong number of elements in DBDPATH",
"wrong number of elements in DBFPATH",
"no current record type",
"invalid country table sort string",
"database not closed"
};
static char *system_error[] = {
"no more space on file",
"system error",
"page fault",
"no working file in dio",
"unable to allocate sufficient memory",
"error opening file",
"unable to get access to database taf file",
"database taf/log file error",
"inconsistent database locks",
"file record limit exceeded",
"key file inconsistency",
"maximum concurrent user limit exceeded",
"error seeking in database file",
"invalid file specified",
"error reading from a database/overflow file",
"lock manager synchronization error",
"debug check interrupt",
"network communications error",
"auto-recovery in process",
"error writing to a database/overflow file",
"no lock manager is installed",
"DBUSERID is already being used",
"the lock manager is busy"
};
/* vpp -nOS2 -dUNIX -nBSD -nVANILLA_BSD -nVMS -nMEMLOCK -nWINDOWS -nFAR_ALLOC -f/usr/users/master/config/nonwin dberr.h */

View File

@@ -0,0 +1,69 @@
/*
* COMPONENT_NAME: austext
*
* FUNCTIONS: delete_whitespace
*
* ORIGINS: 27
*
*
* (C) COPYRIGHT International Business Machines Corp. 1990,1995
* All Rights Reserved
* Licensed Materials - Property of IBM
* US Government Users Restricted Rights - Use, duplication or
* disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
*/
/***************************** DELSPACE.C *****************************
* $XConsortium: delspace.c /main/5 1996/05/07 13:28:17 drk $
* Removes trailing whitespace from a character buffer
* (such as a line read in with fgets).
* If the last char in the original buffer was \n,
* then the last char in the resulting string will be \n.
* Replaces all internal control and extended graphics
* characters (except the last \n) with a blank.
* Does nothing to empty strings ("\0") and strings
* beginning with a form feed ("\f....").
* All Conversions are done inplace, i.e. within
* the same buffer passed to the function.
*
* $Log$
* Revision 2.3 1995/12/01 16:05:37 miker
* No longer overlays tabs with a space char.
*
* Revision 2.2 1995/10/25 22:06:36 miker
* Added prolog.
*
* Revision 2.1 1995/09/22 19:46:16 miker
* Freeze DtSearch 0.1, AusText 2.1.8
*
* Revision 1.2 1995/08/31 22:27:03 miker
* Minor changes for DtSearch.
*/
#include "SearchP.h"
#include <ctype.h>
void delete_whitespace (char *linebuf)
{
static char *ptr, *endptr;
static int has_linefeed;
/* do nothing if empty or ff string */
if (*linebuf == '\0' || *linebuf == '\f')
return;
ptr = linebuf + strlen (linebuf) - 1;
has_linefeed = (*ptr == '\n');
while (!isgraph (*ptr) && ptr >= linebuf)
ptr--;
endptr = ptr + 1; /* endptr = just past last char */
for (ptr = linebuf; ptr < endptr; ptr++)
if (!isprint(*ptr) && *ptr != '\t')
*ptr = ' ';
if (has_linefeed)
*endptr++ = '\n';
*endptr = 0;
return;
}
/***************************** DELSPACE.C *****************************/

187
cde/lib/DtSearch/dproto.h Normal file
View File

@@ -0,0 +1,187 @@
/* $XConsortium: dproto.h /main/2 1996/05/09 03:55:20 drk $ */
/*----------------------------------------------------------------------------
dproto.h: db_VISTA (user) function declaration header file
(C) Copyright 1988 by Raima Corporation.
----------------------------------------------------------------------------*/
/* ********************** EDIT HISTORY *******************************
SCR DATE INI DESCRIPTION
----- --------- --- -----------------------------------------------------
571 31-Jan-89 RSC Placed ctbpath inside NO_COUNTRY, not NO_TIMESTAMP
*/
int d_setfiles(P1(int)); /* dio.c */
int d_setpages(P1(int) Pi(int)); /* dio.c */
int d_trbound(P0); /* trlog.c */
int d_trlog(P1(int) Pi(int) Pi(CONST char FAR *) Pi(int));
/* trlog.c */
int d_trmark(P0); /* trlog.c */
int d_tron(P0); /* trlog.c */
int d_troff(P0); /* trlog.c */
int d_decode_dba(P1(DB_ADDR) Pi(int FAR *) Pi(long FAR *));
/* dbacode.c */
int d_encode_dba(P1(int) Pi(long) Pi(DB_ADDR FAR *));
/* dbacode.c */
#define d_memlock(p) /**/
#define d_memlock_group(lg) S_OKAY
#define d_memunlock(p) /**/
#define d_memunlock_group(lg) /**/
char FAR * d_alloc(P1(unsigned)); /* alloc.c */
char FAR * d_calloc(P1(unsigned) Pi(unsigned)); /* alloc.c */
void d_free(P1(CHAR_P FAR *)); /* alloc.c */
#ifndef MULTI_TASK /* MULTI_TASK */
#define dt_opentask(a) S_OKAY
#define dt_closetask(a) S_OKAY
int d_close(P0); /* dblfcns.c */
int d_cmstat(P1(int) DBN_Dn); /* cmstat.c */
int d_cmtype(P1(int) Pi(int FAR *) DBN_Dn); /* cmtype.c */
int d_connect(P1(int) DBN_Dn); /* connect.c */
#ifndef NO_TIMESTAMP /* NO_TIMESTAMP */
int d_costat(P1(int) DBN_Dn); /* costat.c */
#endif /* NO_TIMESTAMP */
int d_cotype(P1(int) Pi(int FAR *) DBN_Dn); /* cotype.c */
int d_crget(P1(DB_ADDR FAR *) DBN_Dn); /* crget.c */
int d_crread(P1(long) Pi(char FAR *) DBN_Dn); /* crread.c */
int d_crset(P1(DB_ADDR FAR *) DBN_Dn); /* crset.c */
#ifndef NO_TIMESTAMP /* NO_TIMESTAMP */
int d_crstat(P0); /* crstat.c */
#endif /* NO_TIMESTAMP */
int d_crtype(P1(int FAR *) DBN_Dn); /* crtype.c */
int d_crwrite(P1(long) Pi(char FAR *) DBN_Dn); /* crwrite.c */
int d_csmget(P1(int) Pi(DB_ADDR FAR *) DBN_Dn); /* csmget.c */
int d_csmread(P1(int) Pi(long) Pi(char FAR *) DBN_Dn);
/* csmread.c */
int d_csmset(P1(int) Pi(DB_ADDR FAR *) DBN_Dn); /* csmset.c */
int d_csmwrite(P1(int) Pi(long) Pi(CONST char FAR *) DBN_Dn);
/* csmwrite.c */
int d_csoget(P1(int) Pi(DB_ADDR FAR *) DBN_Dn); /* csoget.c */
int d_csoread(P1(int) Pi(long) Pi(char FAR *) DBN_Dn);
/* csoread.c */
int d_csoset(P1(int) Pi(DB_ADDR FAR *) DBN_Dn); /* csoset.c */
int d_csowrite(P1(int) Pi(long) Pi(CONST char FAR *) DBN_Dn);
/* csowrite.c */
#ifndef NO_TIMESTAMP /* NO_TIMESTAMP */
int d_csstat(P1(int) DBN_Dn); /* csstat.c */
int d_ctscm(P1(int) Pi(ULONG FAR *) DBN_Dn); /* ctscm.c */
int d_ctsco(P1(int) Pi(ULONG FAR *) DBN_Dn); /* ctsco.c */
int d_ctscr(P1(ULONG FAR *)); /* ctscr.c */
#endif /* NO_TIMESTAMP */
#ifndef NO_COUNTRY
int d_ctbpath(P1(CONST char FAR *)); /* pathfcns.c */
#endif /* NO_COUNTRY */
int d_dbdpath(P1(CONST char FAR *)); /* dbdpath.c */
int d_dbfpath(P1(CONST char FAR *)); /* dbfpath.c */
int d_dblog(P1(CONST char FAR *)); /* dblog.c */
int d_dbtaf(P1(CONST char FAR *)); /* dbtaf.c */
int d_dbuserid(P1(CONST char FAR *)); /* dbuserid.c */
int d_delete(DBN_D1); /* delete.c */
int d_disdel(DBN_D1); /* disdel.c */
int d_recnext(DBN_D1); /* recnext.c */
int d_recprev(DBN_D1); /* recprev.c */
int d_destroy(P1(CONST char FAR *)); /* destroy.c */
int d_discon(P1(int) DBN_Dn); /* discon.c */
int d_fillnew(P1(int) Pi(CONST char FAR *) DBN_Dn); /* fillnew.c */
int d_findco(P1(int) DBN_Dn); /* findco.c */
int d_findfm(P1(int) DBN_Dn); /* findfm.c */
int d_findlm(P1(int) DBN_Dn); /* findlm.c */
int d_findnm(P1(int) DBN_Dn); /* findnm.c */
int d_findpm(P1(int) DBN_Dn); /* findpm.c */
int d_freeall(P0); /* dblfcns.c */
#ifndef NO_TIMESTAMP /* NO_TIMESTAMP */
int d_gtscm(P1(int) Pi(ULONG FAR *) DBN_Dn); /* gtscm.c */
int d_gtsco(P1(int) Pi(ULONG FAR *) DBN_Dn); /* gtsco.c */
int d_gtscr(P1(ULONG FAR *)); /* gtscr.c */
int d_gtscs(P1(int) Pi(ULONG FAR *) DBN_Dn); /* gtscs.c */
#endif /* NO_TIMESTAMP */
int d_initialize(DBN_D1); /* initial.c */
int d_initfile(P1(FILE_NO) DBN_Dn); /* initial.c */
int d_ismember(P1(int) DBN_Dn); /* ismember.c */
int d_isowner(P1(int) DBN_Dn); /* isowner.c */
int d_keydel(P1(long) DBN_Dn); /* keydel.c */
int d_keyexist(P1(long) DBN_Dn); /* keyexist.c */
int d_keyfind(P1(long) Pi(CONST char FAR *) DBN_Dn);
/* keyfind.c */
int d_keyfree(P1(long) DBN_Dn); /* dblfcns.c */
int d_keyfrst(P1(long) DBN_Dn); /* keyfrst.c */
int d_keylast(P1(long) DBN_Dn); /* keylast.c */
int d_keylock(P1(long) Pi(char FAR *) DBN_Dn); /* dblfcns.c */
int d_keylstat(P1(long) Pi(char FAR *) DBN_Dn); /* dblfcns.c */
int d_keynext(P1(long) DBN_Dn); /* keynext.c */
int d_keyprev(P1(long) DBN_Dn); /* keyprev.c */
int d_keyread(P1(char FAR *)); /* keyfcns.c */
int d_keystore(P1(long) DBN_Dn); /* keystore.c */
int d_lock(P1(int) Pi(LOCK_REQUEST FAR *) DBN_Dn); /* dblfcns.c */
int d_makenew(P1(int) DBN_Dn); /* makenew.c */
int d_mapchar(P1(unsigned char) Pi(unsigned char)
Pi(CONST char FAR *) Pi(unsigned char)); /* mapchar.c */
int d_members(P1(int) Pi(LONG FAR *) DBN_Dn); /* members.c */
int d_off_opt(P1(int)); /* options.c */
int d_on_opt(P1(int)); /* options.c */
int d_open(P1(CONST char FAR *) Pi(CONST char FAR *));
/* dblfcns.c */
int d_rerdcurr(P1(DB_ADDR FAR **)); /* rwcurr.c */
int d_rdcurr(P1(DB_ADDR FAR **) Pi(int FAR *)); /* rwcurr.c */
int d_wrcurr(P1(DB_ADDR FAR *)); /* rwcurr.c */
int d_recfree(P1(int) DBN_Dn); /* dblfcns.c */
int d_recfrst(P1(int) DBN_Dn); /* recfrst.c */
int d_reclast(P1(int) DBN_Dn); /* reclast.c */
int d_reclock(P1(int) Pi(char FAR *) DBN_Dn); /* dblfcns.c */
int d_reclstat(P1(int) Pi(char FAR *) DBN_Dn); /* dblfcns.c */
int d_recover(P1(CONST char FAR *)); /* recover.c */
int d_recread(P1(char FAR *) DBN_Dn); /* recread.c */
int d_recset(P1(int) DBN_Dn); /* recset.c */
#ifndef NO_TIMESTAMP /* NO_TIMESTAMP */
int d_recstat(P1(DB_ADDR) Pi(ULONG)); /* recstat.c */
#endif /* NO_TIMESTAMP */
int d_recwrite(P1(CONST char FAR *) DBN_Dn); /* recwrite.c */
int d_renfile(P1(CONST char FAR *) Pi(FILE_NO)
Pi(CONST char FAR *)); /* renfile.c */
int d_retries(P1(int)); /* dblfcns.c */
int d_rlbclr(P0); /* dblfcns.c */
int d_rlbset(P0); /* dblfcns.c */
int d_rlbtst(P0); /* dblfcns.c */
int d_set_dberr(P1(FARPROC)); /* dberr.c */
#ifndef ONE_DB /* ONE_DB */
int d_setdb(P1(int)); /* setdb.c */
#endif /* ONE_DB */
int d_setfree(P1(int) DBN_Dn); /* dblfcns.c */
int d_setkey(P1(long) Pi(CONST char FAR *) DBN_Dn); /* makenew.c */
int d_setlock(P1(int) Pi(char FAR *) DBN_Dn); /* dblfcns.c */
int d_setlstat(P1(int) Pi(char FAR *) DBN_Dn); /* dblfcns.c */
int d_setmm(P1(int) Pi(int) DBN_Dn); /* setmm.c */
int d_setmo(P1(int) Pi(int) DBN_Dn); /* setmo.c */
int d_setmr(P1(int) DBN_Dn); /* setmr.c */
int d_setom(P1(int) Pi(int) DBN_Dn); /* setom.c */
int d_setoo(P1(int) Pi(int) DBN_Dn); /* setoo.c */
int d_setor(P1(int) DBN_Dn); /* setor.c */
int d_setrm(P1(int) DBN_Dn); /* setrm.c */
int d_setro(P1(int) DBN_Dn); /* setro.c */
#ifndef NO_TIMESTAMP /* NO_TIMESTAMP */
int d_stscm(P1(int) Pi(ULONG) DBN_Dn); /* stscm.c */
int d_stsco(P1(int) Pi(ULONG) DBN_Dn); /* stsco.c */
int d_stscr(P1(ULONG)); /* stscr.c */
int d_stscs(P1(int) Pi(ULONG) DBN_Dn); /* stscs.c */
#endif /* NO_TIMESTAMP */
int d_timeout(P1(int)); /* dblfcns.c */
int d_trabort(P0); /* dblfcns.c */
int d_trbegin(P1(CONST char FAR *)); /* dblfcns.c */
int d_trend(P0); /* dblfcns.c */
#ifndef NO_TIMESTAMP /* NO_TIMESTAMP */
int d_utscm(P1(int) Pi(ULONG FAR *) DBN_Dn); /* utscm.c */
int d_utsco(P1(int) Pi(ULONG FAR *) DBN_Dn); /* utsco.c */
int d_utscr(P1(ULONG FAR *)); /* utscr.c */
int d_utscs(P1(int) Pi(ULONG FAR *) DBN_Dn); /* utscs.c */
#endif /* NO_TIMESTAMP */
#endif /* MULTI_TASK */
int dberr(P1(int)); /* dberr.c */
#define D_FUNCTIONS_H
/* vpp -nOS2 -dUNIX -nBSD -nVANILLA_BSD -nVMS -nMEMLOCK -nWINDOWS -nFAR_ALLOC -f/usr/users/master/config/nonwin dproto.h */

885
cde/lib/DtSearch/dtoe.c Normal file
View File

@@ -0,0 +1,885 @@
/*
* COMPONENT_NAME: austext
*
* FUNCTIONS: Opera_Engine
* alarm_signal_handler
* expired
* no_keytypes
* oe_unblob
* oe_write_audit_rec
* request_str
* retncode_str
* save_query
*
* ORIGINS: 27
*
*
* (C) COPYRIGHT International Business Machines Corp. 1991,1996
* All Rights Reserved
* Licensed Materials - Property of IBM
* US Government Users Restricted Rights - Use, duplication or
* disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
*/
/******************************* DTOE.C ********************************
* $XConsortium: dtoe.c /main/6 1996/11/25 18:52:51 drk $
* Sept 1991.
* Universal Opera Engine code.
* Additional functions in modules named OE...
* See comments in OE.H for Opera_Engine() function descriptions.
* References to 'socblk' have all been replaced by usrblk,
* which is now the universal data structure.
*
* $Log$
* Revision 2.8 1996/03/20 19:25:31 miker
* Use new hilite_cleartext() function call.
*
* Revision 2.7 1996/03/13 22:51:39 miker
* Changed char to UCHAR several places.
* Revision 2.6 1996/03/05 19:20:58 miker
* Replaced vewords with boolyac, boolpars, and boolsrch.
* oe_unblob no longer converts to uppercase.
* Revision 2.5 1996/02/01 17:15:18 miker
* 2.1.11: Changes to support parsers using readchar cofunctions.
* Changed hiliting calls to hilite_cleartext.
* Obsoleted OE_FINDSTR_REC, OE_DITTO2KWIC, OE_FINDSTR_HITL.
* Revision 2.4 1995/12/27 16:47:12 miker
* Prolog update.
* Revision 2.3 1995/10/24 22:31:32 miker
* Renamed from oe.c. Added prolog.
* Log: oe.c,v
* Revision 2.2 1995/10/03 21:44:24 miker
* Deleted unsigned attrib from misc variables for portability.
* Revision 2.1 1995/09/22 21:29:45 miker
* Freeze DtSearch 0.1, AusText 2.1.8
* Revision 1.19 1995/09/05 18:49:45 miker
* Changed all socblk refs to usrblk. Obsoleted several globals.
* Conflated all msglists to one ausapi_msglist. Numerous name changes.
* Added DTSEARCH define. Remove password processing.
* Made usrblk a universal global. ...All for DtSearch.
* Revision 1.18 1995/07/19 21:02:59 miker
* 2.1.6c: Removed OE_mail_feature and OE_print_server.
* Revision 1.17 1995/06/22 20:49:33 miker
* 2.1.6: Additional debugging messages.
* Revision 1.16 1995/05/30 19:20:51 miker
* Print a little more of msglist when debugging engine return.
*/
#include "SearchE.h"
#include <ctype.h>
#include <string.h>
#include <errno.h>
#include <signal.h>
#include <sys/stat.h>
#define PROGNAME "DTOE"
#define MAX_LASTQRY 64
#define QRYBUFSZ 1024
#define MS_misc 1
#define MS_oe 10
/*******#define DUMP_HITWORDS*******/
typedef struct {
int num;
char *str;
} NUMSTR;
/*------------------ OPERA ENGINE GLOBALS --------------------
* Default values set by init_globals() in oeinit.c
* (Some values preinitialized here by compiler because
* they may be used before the first call to init_globals()).
* Most can be overridden by site configuration file.
* Obviously any changes here should be reflected in init_globals().
* Other OE_... globals are located in loadocf.c
*/
extern int debugging_jpn;
extern int debugging_teskey;
char *global_memory_ptr = NULL; /* shared mem, dynam
* defrag */
int shm_id = 0; /* shared mem, dynam defrag */
int OE_bmhtab_strlen[DtSrMAX_STEMCOUNT] = { 0 };
size_t OE_bmhtables[DtSrMAX_STEMCOUNT][MAX_BMHTAB] = { 0 };
int OE_dbn = 0; /* dynamic */
int OE_enable_markdel = 0;
int OE_enable_usernotes = 0;
int OE_fastdecode = 0;
char *OE_fileio = NULL;
long OE_flags = 0L;
long OE_objsize = 0L;
char *OE_prodname = PRODNAME; /* reset only in main() */
float OE_prox_factor = 0.0;
int OE_search_type = 0;
char *OE_sitecnfg_fname = NULL;
time_t OE_sitecnfg_mtime = 0L; /* reset only in oeinitialize() */
int OE_uppercase_keys = 0;
long OE_words_hitlimit = 0L;
static time_t my_expiration = 0L;
time_t *OE_expiration = &my_expiration;
char *OEF_audit = NULL;
char *OEF_discard = NULL;
char *OEF_news = NULL;
char *OEF_notesnot = NULL;
char *OEF_notessem = NULL;
char *OEF_readme = NULL;
/*------------ OTHER GLOBALS -----------*/
SAVEUSR saveusr = { 0 };
static DtSrHitword
next_hitwords [DtSrMAX_STEMCOUNT];
/****************************************/
/* */
/* expired */
/* */
/****************************************/
/* This function permanently disables opera
* if the license to opera has expired.
*/
static void expired (char *sprintbuf)
{
sprintf (sprintbuf, catgets (dtsearch_catd, MS_oe, 71,
PROGNAME "71 %s has expired."),
OE_prodname);
DtSearchAddMessage (sprintbuf);
OE_flags |= OE_PERMERR;
usrblk.retncode = OE_ABORT;
return;
} /* expired() */
/************************************************/
/* */
/* alarm_signal_handler */
/* */
/************************************************/
/* Interrupt handler for SIGALRM */
static void alarm_signal_handler (int sig)
{
fprintf (aa_stderr, PROGNAME "32 "
"%s %s shutdown due to excessive user idle time.\n",
nowstring (NULL), aa_argv0);
DtSearchExit (100 + sig);
} /* alarm_signal_handler() */
/****************************************/
/* */
/* oe_unblob */
/* */
/****************************************/
/* Converts a list of compressed text blob records
* straight out of vista into a single string of clear text.
* input = OE_objsize, dblk.hufid, passed bloblist (freed after use!).
* output = usrblk.cleartext, usrblk.clearlen.
* Returns OE_OK if all goes well, else returns other appropriate retncode.
*/
int oe_unblob (LLIST *bloblist)
{
UCHAR *targ, *src, *stoploc;
short blobclearlen;
LLIST *lptr, *nextlptr;
long mallocsz;
struct or_blobrec
*bptr;
/* Free previous cleartext, if any, and allocate new buffer */
if (OE_objsize < 512)
mallocsz = 512L;
else
mallocsz = OE_objsize + 4L;
if (usrblk.cleartext != NULL)
free (usrblk.cleartext);
usrblk.cleartext = austext_malloc (mallocsz, PROGNAME "188", NULL);
usrblk.clearlen = OE_objsize;
/* Uncompress/decipher bloblist into cleartext,
* freeing the blobs as we go.
*/
targ = (UCHAR *) usrblk.cleartext;
stoploc = targ + OE_objsize;
lptr = bloblist;
while (lptr != NULL) {
/* Setup ptrs and counters for decoding */
bptr = (struct or_blobrec *) lptr->data;
src = (UCHAR *) bptr->or_blob;
blobclearlen = bptr->or_bloblen; /* len of cleartext in curr blob */
if (targ + blobclearlen > stoploc) {
DtSearchAddMessage (PROGNAME "242 Logical Error in database. "
"Object larger than stored size.");
free (usrblk.cleartext);
usrblk.clearlen = 0;
usrblk.retncode = OE_ABORT;
OE_flags |= OE_PERMERR;
return OE_ABORT;
}
/* Decode into clear text buffer */
hc_decode (src, targ, blobclearlen, usrblk.dblk->dbrec.or_hufid);
targ += blobclearlen;
/* free current blob, advance to next blob */
nextlptr = lptr->link; /* temp save next blob addr */
free (lptr);
lptr = nextlptr;
}
*targ = 0;
if (usrblk.debug & USRDBG_RETRVL)
fprintf (aa_stderr, PROGNAME "256 "
"oe_unblob: actual decompressed length = %ld.\n",
targ - (UCHAR *) usrblk.cleartext);
return OE_OK;
} /* oe_unblob() */
/************************************************/
/* */
/* save_query */
/* */
/************************************************/
/* If AUDIT switch is turned on, saves query and start_time in saveusr
* for later printing when search process has completed.
*/
static void save_query (char *prefix, time_t start_time)
{
char *src, *targ, *end;
if (saveusr.lastqry != NULL)
free (saveusr.lastqry);
saveusr.lastqry = austext_malloc (MAX_LASTQRY, PROGNAME "500", NULL);
/* First copy prefix and "=" */
targ = saveusr.lastqry;
src = prefix;
while (*src != 0)
*targ++ = *src++;
*targ++ = '=';
/* Copy query after '=', replacing any ctrl chars
* with a displayable funny character (tilde ~).
*/
if (usrblk.query == NULL)
strcpy (targ, catgets (dtsearch_catd, MS_misc, 1, "<null>"));
else {
end = saveusr.lastqry + MAX_LASTQRY - 2;
src = usrblk.query;
while (*src != 0 && targ < end) {
*targ = *src++;
if (*targ < 32)
*targ = '~';
targ++;
}
*targ = 0;
}
saveusr.start_time = start_time;
return;
} /* save_query() */
/************************************************/
/* */
/* oe_write_audit_rec */
/* */
/************************************************/
/* Writes out audit data after uninterrupted completion of a search.
* Caller checks if AUDIT flag is on.
* Argument is number of hits (may or may not = dittocount).
* By convention, numhits = -1 means search was canceled by user,
* numhits = -2 means system canceled search.
* Requires various saveusr and usrblk fields to be correct.
*/
void oe_write_audit_rec (long numhits)
{
char sprintbuf[1024];
time_t now_gmt;
FILE *stream;
if ((stream = fopen (OEF_audit, "a ")) == NULL)
/* the blank in "a " works around old aix bug */
{
sprintf (sprintbuf, catgets (dtsearch_catd, MS_misc, 1596,
PROGNAME "1596 Cannot open audit file %s: %s"),
OEF_audit, strerror (errno));
DtSearchAddMessage (sprintbuf);
OE_flags &= ~OE_AUDIT; /* don't try to audit anything else */
}
else {
time (&now_gmt);
fprintf (stream, AUDIT_FORMAT "%s\n",
usrblk.userid,
nowstring (&now_gmt),
now_gmt - saveusr.start_time, /* elapsed search time */
usrblk.dblk->name,
numhits,
(saveusr.lastqry == NULL) ? \
catgets (dtsearch_catd, MS_misc, 1, "<null>") : saveusr.lastqry);
if (saveusr.lastqry != NULL) {
free (saveusr.lastqry);
saveusr.lastqry = NULL;
}
fclose (stream);
}
return;
} /* oe_write_audit_rec() */
/************************************************/
/* */
/* no_keytypes */
/* */
/************************************************/
/* Returns FALSE if any keytype in usrblk.dblk is_selected.
* Otherwise appends an error msg, sets usrblk.retncode
* to OE_BAD_QUERY, and returns TRUE.
*/
static int no_keytypes (void)
{
int i = usrblk.dblk->ktcount;
char sprintbuf[256];
DtSrKeytype *keytypes = usrblk.dblk->keytypes;
while (--i >= 0)
if (keytypes[i].is_selected)
return FALSE;
sprintf (sprintbuf, catgets (dtsearch_catd, MS_oe, 440,
PROGNAME "440 No record keytypes were selected in database '%s'."),
usrblk.dblk->label);
DtSearchAddMessage (sprintbuf);
usrblk.retncode = OE_BAD_QUERY;
return TRUE;
} /* no_keytypes() */
/************************************************/
/* */
/* request_str */
/* */
/************************************************/
/* Returns string identifier for OE_... request numbers for debugging */
static char *request_str (int reqnum)
{
static NUMSTR numstr[] = {
{OE_INITIALIZE, "INITIALIZE"}, /* 1 */
{OE_TEXT2FZKEY, "TEXT2FZKEY"}, /* 2 */
{OE_SRCH_FZKEY, "SRCH_FZKEY"}, /* 3 */
{OE_SRCH_STEMS, "SRCH_STEMS"}, /* 4 */
{OE_SRCH_WORDS, "SRCH_WORDS"}, /* 5 */
{OE_STOP_SRCH, "STOP_SRCH"}, /* 6 */
{OE_APPEND_NOTES, "APPEND_NOTES"}, /* 7 */
{OE_GETREC, "GETREC"}, /* 8 */
{OE_GETREC_STEMS, "GETREC_STEMS"}, /* 9 */
{OE_GETREC_WORDS, "GETREC_WORDS"}, /* 10 */
{OE_NEXT_DBA, "NEXT_DBA"}, /* 11 */
{OE_PREV_DBA, "PREV_DBA"}, /* 12 */
{OE_RECKEY2DBA, "RECKEY2DBA"}, /* 13 */
{OE_MARK_DELETION, "MARK_DELETION"}, /* 14 */
{OE_GETREC_DIC, "GETREC_DIC"}, /* 15 */
{OE_DITTO2KWIC, "DITTO2KWIC"}, /* 16 */
{OE_VALIDATE_PWD, "VALIDATE_PWD"}, /* 17 */
{OE_CHANGE_PWD, "CHANGE_PWD"}, /* 18 */
{OE_DELETE_RECID, "DELETE_RECID"}, /* 19 */
{OE_DELETE_BATCH, "DELETE_BATCH"}, /* 20 */
{OE_ASSIST, "ASSIST"}, /* 21 */
{OE_FINDSTR_REC, "FINDSTR_REC"}, /* 22 */
{OE_FINDSTR_HITL, "FINDSTR_HITL"}, /* 23 */
{OE_SRCH_STATISTICAL, "SRCH_STATISTICAL"}, /* 24 */
{OE_HILITE_STEMS, "HILITE_STEMS"}, /* 25 */
{OE_GET_EXPIRE, "GET_EXPIRE"}, /* 26 */
{OE_KILL, "KILL"}, /* 9997 */
{OE_PING, "PING"}, /* 9998 */
{OE_SHUTDOWN, "SHUTDOWN"}, /* 9999 */
{0, "<unknown>"}
};
NUMSTR *ptr = numstr;
while (reqnum != ptr->num && ptr->num != 0)
ptr++;
return ptr->str;
} /* request_str() */
/************************************************/
/* */
/* retncode_str */
/* */
/************************************************/
/* Returns string identifier for OE_... retncode numbers for debugging */
char *retncode_str (int num)
{
static char buf [16];
static NUMSTR numstr[] = {
{OE_OK, "OE_OK"}, /* 1 */
{OE_REINIT, "OE_REINIT"}, /* 2 */
{OE_SEARCHING, "OE_SEARCHING"}, /* 3 */
{OE_BAD_DBLK, "OE_BAD_DBLK"}, /* 4 */
{OE_BAD_REQUEST,"OE_BAD_REQUEST"}, /* 5 */
{OE_BAD_QUERY, "OE_BAD_QUERY"}, /* 6 */
{OE_NOTAVAIL, "OE_NOTAVAIL"}, /* 7 */
{OE_TIMEOUT, "OE_TIMEOUT"}, /* 8 */
{OE_WRAPPED, "OE_WRAPPED"}, /* 9 */
{OE_SYSTEM_STOP,"OE_SYSTEM_STOP"}, /* 10 */
{OE_BAD_PASSWD, "OE_BAD_PASSWD"}, /* 11 */
{OE_BAD_HITLIST,"OE_BAD_HITLIST"}, /* 12 */
{OE_DISABLED, "OE_DISABLED"}, /* 13 */
{OE_USER_STOP, "OE_USER_STOP"}, /* 14 */
{OE_BAD_COMM, "OE_BAD_COMM"}, /* 15 */
{OE_NOOP, "OE_NOOP"}, /* 888 */
{OE_ABORT, "OE_ABORT"}, /* 999 */
{0, buf}
};
NUMSTR *ptr = numstr;
while (num != ptr->num && ptr->num != 0)
ptr++;
if (ptr->num == 0)
sprintf (buf, "%d(?)", num);
return ptr->str;
} /* retncode_str() */
/************************************************/
/* */
/* Opera_Engine */
/* */
/************************************************/
void Opera_Engine (void)
{
int i, len, ws_flag;
char sprintbuf [1024];
char *ptr, *ptr2;
LLIST *bloblist;
LLIST *llp;
FILE *stream;
DBLK *db;
PARG parg;
DB_ADDR dba;
static int first_idletime_call = TRUE;
static time_t
start_time = 0L;
extern int database_has_changed (void);
time (&start_time); /* time that current call began */
if (usrblk.debug != 0L) {
if ((usrblk.debug & USRDBG_PARSE) != 0) {
debugging_jpn = TRUE;
debugging_teskey = TRUE;
}
/*
* Place strings for 3 interesting time stamps at sprintbuf
* +0, +100, and +200.
*/
strcpy (sprintbuf, nowstring (&start_time));
if (*OE_expiration != 0L)
strcpy (sprintbuf + 100, nowstring (OE_expiration));
else
strcpy (sprintbuf + 100, "0");
if (OE_sitecnfg_mtime != 0)
strcpy (sprintbuf + 200, nowstring (&OE_sitecnfg_mtime));
else
strcpy (sprintbuf + 200, "0");
fprintf (aa_stderr,
"\n" PROGNAME "444 Opera_Engine Request %d (%s) at %s.\n"
" user='%s', usrblk.flags=%ld(x%04lx), usrblk.debug=%ld(x%04lx).\n"
" OE_flags=%ld(x%04lx), exp=%s, sitecnfg=%s.\n"
,usrblk.request, request_str (usrblk.request), sprintbuf
,usrblk.userid, usrblk.flags, usrblk.flags
,usrblk.debug, usrblk.debug
,OE_flags, OE_flags, sprintbuf + 100, sprintbuf + 200
);
i = 0;
for (db = usrblk.dblist; db != NULL; db = db->link) {
if (db == usrblk.dblk)
break;
i++;
}
if (db == NULL)
fprintf (aa_stderr, " dblk is %s\n",
(i) ? "INVALID!" : "null.");
else
fprintf (aa_stderr, " dblk #%d: name='%s', vistano=%d.\n"
,i, usrblk.dblk->name, usrblk.dblk->vistano
);
fflush (aa_stderr);
}
/* Check if this copy of opera has expired.
* If *OE_expiration == 0, expiration checking disabled.
* If current time < expiration time, permit request.
* Otherwise disable this and all further requests.
*/
if (*OE_expiration != 0L)
if (start_time > *OE_expiration)
expired (sprintbuf);
if (OE_flags & OE_PERMERR) {
sprintf (sprintbuf, catgets (dtsearch_catd, MS_oe, 490,
PROGNAME "490 %s Engine permanently disabled."), OE_prodname);
DtSearchAddMessage (sprintbuf);
usrblk.retncode = OE_ABORT;
goto ENGINE_RETURN;
}
/* Ensure that the first call is always an OE_INITIALIZE call */
if ((usrblk.request != OE_INITIALIZE) && !(OE_flags & OE_INITOK)) {
DtSearchAddMessage (catgets (dtsearch_catd, MS_oe, 523,
PROGNAME "523 Request Denied: First request must "
"be Engine Initialization."));
usrblk.retncode = OE_NOOP;
goto ENGINE_RETURN;
}
/* Verify that none of the databases has changed since the last call. */
if (database_has_changed ())
goto ENGINE_RETURN;
/* Make usrblk ready. Basically ensure client side
* has not destroyed usrblk. Set OE_dbn to match user's dblk.
* The make-ready activity is not called for OE_INITIALIZE
* because the site's config file has not yet been called
* to create the OE's dblks.
*/
if (usrblk.request != OE_INITIALIZE) {
/* Set OE_dbn to match selected dblk */
for ( db = usrblk.dblist, OE_dbn = 0;
db != NULL;
db = db->link, OE_dbn++)
if (strcmp (usrblk.dblk->name, db->name) == 0)
break;
if (db == NULL) {
sprintf (sprintbuf, catgets (dtsearch_catd, MS_oe, 48,
PROGNAME "48 Request Aborted: "
"'%s' database not available at this site."),
usrblk.dblk->name);
DtSearchAddMessage (sprintbuf);
usrblk.retncode = OE_ABORT;
OE_flags |= OE_PERMERR;
goto ENGINE_RETURN;
}
/* Override user switches if required by the engine */
if ((OE_flags & OE_NO_ITERATE) != 0)
usrblk.flags |= USR_NO_ITERATE;
}
/*----------------- BIG SWITCH ON REQUEST CODE ------------------*/
switch (usrblk.request) {
case OE_SRCH_STEMS:
case OE_SRCH_WORDS:
/*
* Builds dittolist from query of stems/words +
* booleans. Swap stoplists to fool search functions.
*/
if (no_keytypes ())
break;
usrblk.search_type =
(usrblk.request == OE_SRCH_WORDS)? 'W' : 'S';
if (OE_flags & OE_AUDIT)
save_query ("WORDS", start_time);
/****ve_word_search ();*****/
if (!boolean_parse()) {
usrblk.retncode = OE_BAD_QUERY;
break;
}
boolean_search();
if (usrblk.debug & USRDBG_SRCHCMPL)
print_stems (usrblk.stemcount, usrblk.stems, PROGNAME"637");
if (usrblk.debug & (USRDBG_SRCHCMPL | USRDBG_HITLIST))
print_dittolist (usrblk.dittolist, PROGNAME "657");
break;
case OE_SRCH_STATISTICAL:
/*
* Builds dittolist from query string of natural
* language text whose words cause statistical doc
* retrieval.
*/
if (no_keytypes ())
break;
if (OE_flags & OE_AUDIT)
save_query ("STAT", start_time);
ve_statistical ();
if (usrblk.debug & USRDBG_SRCHCMPL)
print_stems (usrblk.stemcount, usrblk.stems,
PROGNAME"770 SRCH_STATISTICAL:");
if (usrblk.debug & (USRDBG_SRCHCMPL | USRDBG_HITLIST))
print_dittolist (usrblk.dittolist, PROGNAME "772");
break;
case OE_HILITE_STEMS:
if (usrblk.debug & (USRDBG_RETRVL | USRDBG_HILITE)) {
fprintf (aa_stderr, PROGNAME "819 HILITE_STEMS: "
"srchtyp=%c clrln=%ld clrtxt='%.30s'\n",
usrblk.search_type, usrblk.clearlen,
NULLORSTR (usrblk.cleartext));
print_stems (usrblk.stemcount, usrblk.stems, " ");
}
if (usrblk.cleartext == NULL || usrblk.clearlen <= 0) {
NO_TEXT:
DtSearchAddMessage (
PROGNAME "839 Client Error: No Text to highlight.");
usrblk.retncode = OE_BAD_QUERY;
break;
}
if (usrblk.cleartext[0] == '\0')
goto NO_TEXT;
if (usrblk.stemcount <= 0) {
DtSearchAddMessage (PROGNAME "846 Client Error: "
"Cannot highlight words, stemcount is zero.");
usrblk.retncode = OE_BAD_QUERY;
break;
}
/* Subswitch: depending on request, load hitwords array */
switch (usrblk.search_type) {
case 'W':
i = 'W';
break;
case 'S':
case 'P':
i = 'S';
break;
default:
i = 0;
DtSearchAddMessage (
PROGNAME "708 Word Highlighting is not available "
"for semantic searches.");
usrblk.retncode = OE_BAD_QUERY;
break;
}
if (!i)
break;
hilite_cleartext (i, (char *) usrblk.stems, usrblk.stemcount);
if (OE_flags & OE_PERMERR)
usrblk.retncode = OE_ABORT;
else
usrblk.retncode = OE_OK;
if (usrblk.debug & USRDBG_RETRVL) {
fprintf (aa_stderr,
PROGNAME "820 HILITE_STEMS: hitwcount=%ld\n",
usrblk.hitwcount);
}
break; /* end OE_HILITE_STEMS */
case OE_STOP_SRCH:
/* interrupts long, ongoing search of database */
usrblk.flags |= USR_STOPSRCH;
usrblk.retncode = OE_OK;
break;
case OE_GETREC:
case OE_GETREC_WORDS:
case OE_GETREC_STEMS:
case OE_GETREC_DIC:
/*
* Retrieve database record, text blobs, notes, etc.
* Note that ve_getrec_dba() may return OE_OK even if
* there are no blobs. That will happen when it can
* return everything else about the record, but by
* design the text itself is not stored in the
* repository. In other words, no blobs is not an error
* so check if blobs were returned and adjust retncode
* accordingly.
*/
usrblk.retncode = ve_getrec_dba (&bloblist);
if (usrblk.retncode != OE_OK)
break;
/*
* If no text blobs, ensure cleartext and hitwords
* array are empty (which will cause OE_NOTAVAIL return
* below). Don't create a "no text" msg because many
* clients will want to retrieve the record text
* locally and they won't want an "error" msg
* cluttering up the msglist.
*/
if (bloblist == NULL) {
usrblk.clearlen = 0;
if (usrblk.cleartext != NULL) {
free (usrblk.cleartext);
usrblk.cleartext = NULL;
}
clear_hitwords ();
}
/*
* Otherwise if text blobs do exist, convert them into
* clear text and a hitwords array for hiliting.
*/
else {
usrblk.retncode = oe_unblob (bloblist);
if (usrblk.retncode != OE_OK)
break;
/* Subswitch: depending on request, load hitwords array */
switch (usrblk.request) {
case OE_GETREC_WORDS:
hilite_cleartext ('W',
(char*) usrblk.stems, usrblk.stemcount);
break;
case OE_GETREC_STEMS:
hilite_cleartext ('S',
(char*) usrblk.stems, usrblk.stemcount);
break;
case OE_GETREC_DIC:
DtSearchAddMessage (PROGNAME "783 "
"Dictionary word hiliting function "
"is no longer supported.");
clear_hitwords ();
break;
case OE_GETREC:
default:
clear_hitwords (); /* ensure no hiliting */
} /* end hitwords subswitch */
#ifdef DUMP_HITWORDS /* dump the stems and hitwords arrays */
print_stems (usrblk.stemcount, usrblk.stems, "\nSTEMS:");
fprintf (aa_stderr, "HITWORDS: hitwcount = %d\n",
usrblk.hitwcount);
for (i = 0; i < usrblk.hitwcount; i++)
fprintf (aa_stderr, "offset = %4ld, len=%2d, '%.10s...'\n",
usrblk.hitwords[i].offset,
usrblk.hitwords[i].length,
usrblk.cleartext + usrblk.hitwords[i].offset);
#endif
} /* end if where blobs exist */
if (OE_flags & OE_PERMERR)
usrblk.retncode = OE_ABORT;
else {
usrblk.retncode = ((usrblk.clearlen) ? OE_OK : OE_NOTAVAIL);
if (usrblk.debug & USRDBG_RETRVL)
print_usrblk_record (PROGNAME "957 final: ");
}
break; /* end cases OE_GETREC... */
case OE_NEXT_DBA:
/*
* increments dba address field (not associated with
* hitlist)
*/
ve_browse_dba (+1);
break;
case OE_PREV_DBA:
/*
* decrements dba address field (not associated with
* hitlist)
*/
ve_browse_dba (-1);
break;
case OE_APPEND_NOTES:
/* appends user notes to record at dba */
usrblk.retncode = ve_append_notes ();
break;
case OE_RECKEY2DBA:
/* converts vista record key to database address */
usrblk.dba = ve_reckey2dba ();
if ((usrblk.debug & USRDBG_DELETE) != 0L)
fprintf (aa_stderr, PROGNAME "1089 RECKEY2DBA: "
"retncode=%d, reckey='%s' ->\tdba=%ld:%ld\n",
usrblk.retncode, usrblk.query,
(usrblk.dba) >> 24, (usrblk.dba) & 0xffffff);
break;
case OE_DELETE_RECID:
/*
* First converts recid to a db address. Then deletes
* entire record: blobs, notes, and words. Presumes
* only 2 retncodes from reckey2dba are OK and WRAPPED.
* (bad presumption).
*/
dba = ve_reckey2dba ();
if (usrblk.retncode != OE_OK) {
usrblk.retncode = OE_NOTAVAIL;
break;
}
usrblk.dba = dba;
usrblk.dbatab = &usrblk.dba;
usrblk.dbacount = 1;
ve_delete ();
break;
case OE_DELETE_BATCH:
/* deletes all records in a table of dba's */
ve_delete ();
break;
case OE_INITIALIZE:
/*
* first call from UI. returns info used to build
* users screen
*/
oe_initialize ();
break;
case OE_GET_EXPIRE:
usrblk.dba = *OE_expiration;
usrblk.retncode = OE_OK;
break;
case OE_PING:
/* Null function. Just does REINIT checks etc. */
usrblk.retncode = OE_OK;
break;
case OE_SHUTDOWN:
case OE_KILL:
case OE_VALIDATE_PWD:
case OE_CHANGE_PWD:
/* These functions are obsolete and harmless */
usrblk.retncode = OE_OK;
break;
case OE_FINDSTR_REC:
case OE_FINDSTR_HITL:
case OE_DITTO2KWIC:
/* These functions are just obsolete */
sprintf (sprintbuf,
PROGNAME"1027: User Interface Error. "
"%d is obsolete request code.\n",
usrblk.request);
DtSearchAddMessage (sprintbuf);
usrblk.retncode = OE_BAD_REQUEST;
break;
default:
sprintf (sprintbuf, catgets (dtsearch_catd, MS_oe, 367,
PROGNAME "367: User Interface Error. "
"%d is invalid request code.\n"),
usrblk.request);
DtSearchAddMessage (sprintbuf);
usrblk.retncode = OE_BAD_REQUEST;
break;
} /* end switch */
ENGINE_RETURN:
if (usrblk.debug != 0L) {
if (!DtSearchHasMessages())
fprintf (aa_stderr, PROGNAME"998 Msglist is empty.\n");
else {
fprintf (aa_stderr,
"mmmmmmmmmm Msglist mmmmmmmmm\n%s\n"
"mmmmmmmmmmmmmmmmmmmmmmmmmmmm\n",
DtSearchGetMessages());
}
fprintf (aa_stderr, PROGNAME "999 usrblk.retncode = %d (%s).\n",
usrblk.retncode, retncode_str (usrblk.retncode));
fflush (aa_stderr);
}
return;
} /* Opera_Engine() */
/******************************* DTOE.C ********************************/

360
cde/lib/DtSearch/dtoeinit.c Normal file
View File

@@ -0,0 +1,360 @@
/*
* COMPONENT_NAME: austext
*
* FUNCTIONS: UNMALLOC
* dump_dblk
* oe_initialize
* oe_uninitialize
*
* ORIGINS: 27
*
*
* (C) COPYRIGHT International Business Machines Corp. 1991,1995
* All Rights Reserved
* Licensed Materials - Property of IBM
* US Government Users Restricted Rights - Use, duplication or
* disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
*/
/******************************* DTOEINIT.C ********************************
* $XConsortium: dtoeinit.c /main/6 1996/11/21 19:49:29 drk $
* Sept 1991.
* Contains oe_initialize() function from universal "Opera Engine" code.
* Has been separated out because it is the largest function and
* needs to be tested separately.
*
* $Log$
* Revision 2.4 1996/03/13 22:52:04 miker
* Enabled several language loading debug requests from API.
*
* Revision 2.3 1995/10/25 21:59:27 miker
* Renamed from oeinit.c. Added prolog.
*
* Log: oeinit.c,v
* Revision 2.2 1995/10/02 20:39:22 miker
* Added zbflags arg to load_semantic().
*
* Revision 2.1 1995/09/22 21:38:53 miker
* Freeze DtSearch 0.1, AusText 2.1.8
*
* Revision 1.14 1995/09/05 18:58:01 miker
* Changed all socblk refs to universal, global usrblk (no more merges).
* Deleted numerous globals. Added DTSEARCH define.
* Conflated all msglists to one ausapi_msglist. All for DtSearch...
*/
#include "SearchE.h"
#include <string.h>
#include <sys/stat.h>
#define XOS_USE_NO_LOCKING
#define X_INCLUDE_TIME_H
#include <X11/Xos_r.h>
#define PROGNAME "DTOEINIT"
#define MS_misc 1
#define MS_oeinit 9
extern int debugging_loadlang;
/************************************************/
/* */
/* UNMALLOC */
/* */
/************************************************/
/* macro to test and free any malloc'ed pointer */
#define UNMALLOC(ptr) if(ptr){free(ptr);ptr=NULL;}
/********************************/
/* */
/* dump_dblk */
/* */
/********************************/
/* Dumps values from passed dblk.
* Used only for debugging initialization.
*/
static void dump_dblk (char *msgprefix, DBLK *d)
{
int i;
fprintf (aa_stderr, "%s: DBLK v#%d name='%s' label='%s', path='%s'\n",
NULLORSTR (msgprefix), d->vistano, NULLORSTR (d->name),
NULLORSTR (d->label), NULLORSTR (d->path));
fprintf (aa_stderr, " mx=%d kt=", d->maxhits);
for (i = 0; i < d->ktcount; i++) {
fputc (' ', aa_stderr);
if (d->keytypes[i].is_selected)
fputc ('*', aa_stderr);
fputc (d->keytypes[i].ktchar, aa_stderr);
}
fputc ('\n', aa_stderr);
return;
} /* dump_dblk() */
/************************************************/
/* */
/* oe_initialize */
/* */
/************************************************/
/* - verify version number compatibilities.
* - initialize socblk and OE_... globals.
* - load site defaults ocf file and create database list.
* - load dictionaries.
* - merge site defaults into usrblk.
* - open database(s).
*/
void oe_initialize (void)
{
char *ptr;
int good_dblk_count = 0;
DBLK *db, *bad_db, **lastlink;
char sprintbuf[1024];
FILE *stream;
OEFTAB *oef;
if (usrblk.debug & USRDBG_RARE)
fprintf (aa_stderr, PROGNAME "555 Entered Engine Initialization.\n");
debugging_loadlang = (usrblk.debug & USRDBG_RARE);
/* Initialize most of the engine's globals.
* OE_bit_vector_size is set in ve_initialize().
* OE_bmhtab... are set by boyer-moore string searches only.
* OE_prodname is initialized by compiler and maybe changed by main().
* OE_expiration is initialized by compiler and never reset.
* OE_sitecnfg_fname is initialized by ausapi or loadocf and never reset.
* OE_sitecnfg_mtime is initialized by oe_initialize() and never reset.
*/
global_memory_ptr = NULL;
austext_exit_mem = (void (*) (int)) release_shm_mem;
OE_flags = 0L;
OE_objsize = 0L;
OE_search_type = 'P'; /* default is statistical searches */
OE_words_hitlimit = WORDS_HITLIMIT;
OE_enable_markdel = FALSE; /* former lvl2 default: TRUE */
OE_enable_usernotes = FALSE; /* former lvl2 default: TRUE */
OE_fastdecode = FALSE; /* former lvl2 default: TRUE */
OE_fileio = "-OFF"; /* former lvl2 default: "-ON" */
OE_uppercase_keys = FALSE; /* former lvl2 default: TRUE */
OEF_audit = FNAME_AUDIT;
OEF_discard = FNAME_DISCARD_DATA;
OEF_news = FNAME_SITENEWS;
OEF_notesnot = FNAME_NOTES_BAC;
OEF_notessem = FNAME_NOTES_SEM;
OEF_readme = FNAME_README;
for (oef = oef_table; oef->id != NULL; oef++)
oef->previously_specified = FALSE;
/* Verify version number compatibility between engine and UI.
* Only checked if request is OE_INITIALIZE, not on reinits.
*/
if (usrblk.request == OE_INITIALIZE) {
if (!is_compatible_version (usrblk.query, SCHEMA_VERSION) ||
!is_compatible_version (usrblk.query, PROTOCOL_VERSION)) {
if (usrblk.query != NULL)
ptr = usrblk.query;
else
ptr = catgets (dtsearch_catd, MS_misc, 6, "<unknown>");
sprintf (sprintbuf, catgets (dtsearch_catd, MS_oeinit, 137,
"%s User Interface version %s and Engine "
"version %s are incompatible."),
PROGNAME"137", ptr, AUSAPI_VERSION);
DtSearchAddMessage (sprintbuf);
usrblk.retncode = OE_NOTAVAIL;
return;
}
}
/* Load site configuration (ocf) file and create dblks list */
if (!load_ocf()) {
sprintf (sprintbuf, catgets (dtsearch_catd, MS_oeinit, 202,
"%s Initialization failed due to errors in configuration file."),
PROGNAME"202");
DtSearchAddMessage (sprintbuf);
usrblk.retncode = OE_NOTAVAIL;
return;
}
/* Had to wait to write audit file till after site config set the flags */
if (OE_flags & OE_AUDIT || usrblk.debug & USRDBG_RARE) {
sprintf (sprintbuf,
"ENGINEINIT='%s' UVER='%s' " AUDIT_WHOWHEN "\n",
AUSAPI_VERSION, usrblk.query, usrblk.userid,
nowstring (NULL));
if (usrblk.debug & USRDBG_RARE)
fprintf (aa_stderr, PROGNAME "362 %s", sprintbuf);
if (OE_flags & OE_AUDIT) {
if ((stream = fopen (OEF_audit, "a ")) != NULL)
/* the blank in "a " works around old aix bug */
{
fputs (sprintbuf, stream);
fclose (stream);
}
}
} /* endif to write to audit file */
/* ---- DATABASES PASSES #1 - #3 ------------------------------------
* Call vista to open databases and load system (dbrec) records.
* Where possible, this call will forgive errors by just
* unlinking the offending dblk from the dblist.
* However loss of all dblks equals a fatal error.
*/
if (!ve_initialize()) {
INIT_FAILED:
sprintf (sprintbuf, catgets (dtsearch_catd, MS_oeinit, 266,
"%s Initialization failed due to errors in database,\n"
" language, or related files."),
PROGNAME "266");
DtSearchAddMessage (sprintbuf);
usrblk.retncode = OE_NOTAVAIL;
return;
}
/* ---- DATABASES PASS #4 ------------------------------------
* Load each database's language and semantic files.
* If an error is discovered in any one dblk,
* it is unlinked from dblist.
* However loss of all dblks on dblist is fatal.
*/
good_dblk_count = 0;
db = usrblk.dblist; /* could already = NULL after ve_initialize() */
lastlink = &usrblk.dblist;
while (db != NULL) {
if (!load_language (db, usrblk.dblist))
goto DELETE_DB;
/*
* This dblk successfully loaded its language and and semantic
* files. If no gui label was provided, set it to the
* database name. Then increment pointers and continue.
*/
if (db->label == NULL)
db->label = strdup (db->name);
else if (db->label[0] == 0)
db->label = strdup (db->name);
good_dblk_count++;
lastlink = &db->link;
db = db->link;
continue;
DELETE_DB:
/*
* One or more language or semantic files could not be loaded for
* this dblk. Unlink it and don't increment pointers.
*/
bad_db = db; /* temp save */
*lastlink = db->link;
db = db->link;
free (bad_db);
} /* end loop that loads all database files */
/* Abort if fatal dictionary load errors */
if (good_dblk_count <= 0) {
sprintf (sprintbuf, catgets (dtsearch_catd, MS_misc, 8,
"%s No valid databases remain."),
PROGNAME"265");
DtSearchAddMessage (sprintbuf);
goto INIT_FAILED;
}
memset (&saveusr, 0, sizeof (SAVEUSR));
OE_flags |= OE_INITOK;
if (usrblk.debug & USRDBG_RARE) {
struct tm *time_ptr;
_Xltimeparams localtime_buf;
if (*OE_expiration != 0)
{
time_ptr = _XLocaltime(OE_expiration, localtime_buf);
strftime (sprintbuf, 100, "%x", time_ptr);
}
else
strcpy (sprintbuf, "0");
if (OE_sitecnfg_mtime != 0)
{
time_ptr = _XLocaltime(&OE_sitecnfg_mtime, localtime_buf);
strftime (sprintbuf + 100, 100, "%x,%X", time_ptr);
}
else
strcpy (sprintbuf + 100, "0");
fprintf (aa_stderr, PROGNAME "666 Engine Initialization Completed.\n"
" usrblk.flags=%ld(x%04lx), usrblk.debug=%ld(x%04lx).\n"
" OE_flags=%ld(x%04lx), expiration=%s, sitecnfg=%s.\n"
,usrblk.flags, usrblk.flags, usrblk.debug, usrblk.debug
,OE_flags, OE_flags, sprintbuf, sprintbuf + 100
);
}
usrblk.retncode = OE_OK;
return;
} /* oe_initialize() */
/************************************************/
/* */
/* oe_uninitialize */
/* */
/************************************************/
/* Called by Opera_Engine() whenever the site config file
* has been altered. Closes databases, frees all allocated storage,
* and resets everything so oe_initialize() can be re-called.
* Allows administrator to swap to newer, updated databases
* without forcing users to shutdown by changing PATH value
* in site config file.
*/
void oe_uninitialize (void)
{
DBLK *db, *nextdb;
OEFTAB *oef;
ve_shutdown (); /* close all databases */
UNMALLOC (usrblk.abstrbuf);
/* release shared memory, suffixes array, etc, if any */
release_shm_mem ();
/* Free allocated storage in oef table and reset the default filenames. */
for (oef = oef_table; oef->id != NULL; oef++) {
if (oef->previously_specified) {
oef->previously_specified = FALSE;
free (*(oef->OEFptr));
}
}
db = usrblk.dblist;
while (db != NULL) {
/* Save next dblk so we'll know where to go after freeing this one */
nextdb = db->link;
UNMALLOC (db->path);
UNMALLOC (db->keytypes);
if (db->iifile != NULL) {
fclose (db->iifile);
db->iifile = NULL;
}
if (db->syofile != NULL) {
fclose (db->syofile);
db->syofile = NULL;
}
if (db->syifile != NULL) {
fclose (db->syifile);
db->syifile = NULL;
}
unload_language (db);
free (db);
db = nextdb;
}
usrblk.dblist = NULL;
usrblk.dblk = NULL;
return;
} /* oe_uninitialize() */
/******************************* DTOEINIT.C ********************************/

File diff suppressed because it is too large Load Diff

851
cde/lib/DtSearch/dtsrapi.c Normal file
View File

@@ -0,0 +1,851 @@
/*
* COMPONENT_NAME: austext
*
* FUNCTIONS: DtSearchGetKeytypes
* DtSearchHighlight
* DtSearchInit
* DtSearchQuery
* DtSearchRetrieve
* aa_categories
* aa_is_semantic_db
* aa_netrc
* aa_reinit
* ausapi_get_hirec
* ausapi_getexpire
* ausapi_getnews
* both_valid_dates
* build_dbnames_array
* pack_navstr
* signal_abort
* valid_dbname
*
* ORIGINS: 27
*
*
* (C) COPYRIGHT International Business Machines Corp. 1993,1995
* All Rights Reserved
* Licensed Materials - Property of IBM
* US Government Users Restricted Rights - Use, duplication or
* disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
*/
/**************************** DTSRAPI.C *************************
* $XConsortium: dtsrapi.c /main/9 1996/11/25 18:54:18 drk $
* Nov 1993. Originally called "calloe".
* Implements a simple DtSearch/AusText API at a higher level than OE calls.
* Substantially isolates caller from knowledge of usrblks,
* hiding details of searches, possible return codes, etc.
* Does its own mallocs and frees and controls the usrblk.
*
* Function descriptions (ie documentation) is in dtsearch.doc
* and Search.h.
*
* Revision 2.8 1996/03/14 22:54:41 miker
* Pass backdoor usrblk.debug into DtSearch.
*
* Revision 2.7 1996/02/01 18:09:24 miker
* Deleted ausapi_kwic, ausapi_ping, ausapi_shutdown, signal(SIGUSR1).
* DtSearchInit: usrblk.debug = high order 16 bits of init_switches arg.
*
* Revision 2.6 1995/12/27 16:08:22 miker
* Added DtSearchReinit().
*
* Revision 2.5 1995/10/26 17:34:52 miker
* Fixed duplicate messages catalog open.
*
* Revision 2.4 1995/10/25 21:39:45 miker
* Renamed from ausapi.c. Added prolog.
*
* Log: ausapi.c,v
* Revision 2.3 1995/10/19 20:19:34 miker
* Databases opened read-only unless DtSrInRDWR is specified.
*
* Revision 2.2 1995/10/02 20:51:32 miker
* Bug: Tried to free unmalloced version string after Init (Takuki Kamiya).
* Added symbolic msg catalog set numbers.
* Fixed erroneous dbnames assignment.
*
* Revision 2.1 1995/09/22 18:48:45 miker
* Freeze DtSearch 0.1, AusText 2.1.8
*
* Revision 1.20 1995/09/19 21:43:46 miker
* Fixed minor bug in debugging statements only.
*
* Revision 1.19 1995/08/31 21:36:39 miker
* Added #define to block out code not to be delivered to DtSearch.
* Changed all msgslists to one global one at ausapi_msglist.
* Moved function documentation to dtsearch.doc
* Public functions renamed to match DtSearch conventions.
* Rearranged some function args to eliminate public global variables.
* Broke messages catalog in two so DtSearch can have its own.
* Minor changes to accommodate portability.
* Reenabled user to change name of site config file.
*
* Revision 1.18 1995/07/18 22:05:10 miker
* Set OE_sitecnfg_fname to arg passed to ausapi_init().
*/
#include "SearchE.h"
#include <ctype.h>
#include <signal.h>
#include <locale.h>
#include <string.h>
#include <fcntl.h>
#define PROGNAME "DTSRAPI"
#define SPRINTBUFSZ 1024
#define MS_misc 1
#define MS_ausapi 2
/*------------------- PRIVATE GLOBALS ---------------------*/
/* Usrblk should not be visible to user interface code,
* but must be visible to real engine... */
USRBLK usrblk = { 0 };
static int save_search_type = '$';
static char *sprintbuf = NULL;
/*------------------- EXTERNS (aajoint.c) ---------------------*/
extern int aa_is_initialized;
extern void aa_check_initialization (void);
extern long save_init_switches;
#ifndef db_oflag
extern int db_oflag;
#endif
/************************************************/
/* */
/* signal_abort */
/* */
/************************************************/
/* Interrupt handler for all common 'abort' signals.
* Shuts down gracefully by ensuring database properly closed.
* The database close and write to the audit log occur in OE.
*/
static void signal_abort (int sig)
{
fputs (DtSearchGetMessages (), aa_stderr);
fprintf (aa_stderr, catgets (dtsearch_catd, MS_ausapi, 216,
"\n%s %s Caught signal %d.\n"),
PROGNAME"216",
(aa_argv0) ? aa_argv0 : OE_prodname,
sig);
fflush (aa_stderr);
DtSearchExit (100 + sig);
} /* signal_abort() */
/************************************************/
/* */
/* valid_dbname */
/* */
/************************************************/
/* Sets usrblk.dblk to passed dbname.
* Name must match dblk.label if it exists,
* otherwise it must match dblk.name (same
* algorithm that generates dbnamesv[]).
* If dbname == NULL, sets dblk to first dblist node.
* Returns TRUE on success.
* Returns FALSE and err msg if invalid dbname.
*/
static int valid_dbname (char *dbname)
{
DBLK *db;
aa_check_initialization ();
if (dbname == NULL) {
usrblk.dblk = usrblk.dblist;
return TRUE;
}
if (dbname[0] == 0) {
usrblk.dblk = usrblk.dblist;
return TRUE;
}
for (db = usrblk.dblist; db != NULL; db = db->link) {
if (db->label) {
if (strcmp (dbname, db->label) == 0)
break;
}
if (strcmp (dbname, db->name) == 0)
break;
}
if (db == NULL) {
sprintf (sprintbuf, catgets (dtsearch_catd, MS_ausapi, 1,
"%1$sInvalid or unavailable database '%2$s'."),
PROGNAME "48 ", dbname);
DtSearchAddMessage (sprintbuf);
if (DtSrInANY_DEBUG & save_init_switches) {
fputs (PROGNAME "49 Available Databases:\n", aa_stderr);
for (db = usrblk.dblist; db != NULL; db = db->link)
fprintf (aa_stderr, " name='%s'\tlabel='%s'\n",
db->name, db->label);
}
return FALSE;
}
else
usrblk.dblk = db;
return TRUE;
} /* valid_dbname() */
/************************************************/
/* */
/* build_dbnames_array */
/* */
/************************************************/
/* Builds array of database name string ptrs with same
* architecture as command line arguments argv and argc
* from the shell. Uses dblk.label if it exists,
* otherwise uses dblk.name.
* Called at initialization and reinitialization.
*/
static void build_dbnames_array (void)
{
char *targ, *src;
DBLK *db;
int i;
size_t mallocsz = 0L;
if (ausapi_dbnamesv)
free (ausapi_dbnamesv);
ausapi_dbnamesc = 0;
for (db = usrblk.dblist; db != NULL; db = db->link) {
ausapi_dbnamesc++;
mallocsz += ((db->label) ? strlen (db->label) : sizeof (db->name)) + 2L;
}
ausapi_dbnamesv = austext_malloc (
mallocsz + (sizeof (char *) * (2 + ausapi_dbnamesc)) + 4,
PROGNAME "106", NULL);
/* The first part of the malloc is the array of pointers.
* The strings start just after the array. Set 'targ' to
* the beginning of the strings, while 'i' indexes the ptrs.
*/
targ = (char *) ausapi_dbnamesv + (sizeof (char *) * (1 + ausapi_dbnamesc));
for (i = 0, db = usrblk.dblist; db != NULL; i++, db = db->link) {
ausapi_dbnamesv[i] = targ;
src = (db->label) ? db->label : db->name;
while (*src != 0)
*targ++ = *src++;
*targ++ = 0;
if (save_init_switches & DtSrInIDEBUG) {
fprintf (aa_stderr, PROGNAME "490 "
"dbnames[%d] = '%s': dname='%s', dlabel='%s'\n",
i, ausapi_dbnamesv[i], db->name, db->label);
fflush (aa_stderr);
}
}
ausapi_dbnamesv[i] = NULL; /* terminate the list this way too */
return;
} /* build_dbnames_array() */
/************************************************/
/* */
/* aa_reinit */
/* */
/************************************************/
/* Performs all reinitialization functions required by OE_REINIT.
* Always returns DtSrREINIT.
*/
static int aa_reinit (void)
{
clear_usrblk_record ();
clear_hitwords ();
usrblk.dba = 0;
DtSearchFreeResults (&usrblk.dittolist);
usrblk.dittocount = 0;
build_dbnames_array ();
return DtSrREINIT;
} /* aa_reinit() */
/************************************************/
/* */
/* DtSearchInit */
/* */
/************************************************/
/* Initializes ausapi and the AusText engine (performs OE_INIT).
* Must be first ausapi call. Must be called only once (reinit?).
* See dtsearch.doc for specs.
*/
int DtSearchInit (
char *argv0,
char *userid,
long switches,
char *config_file,
FILE *err_file,
char ***dbnames,
int *dbcount)
{
if (aa_is_initialized) {
sprintf (sprintbuf, catgets (dtsearch_catd, MS_ausapi, 621,
"%1$s %2%s has already been initialized."),
PROGNAME"621", PRODNAME);
DtSearchAddMessage (sprintbuf);
return DtSrFAIL;
}
aa_is_initialized = TRUE;
save_init_switches = switches;
if (argv0)
aa_argv0 = argv0;
if (err_file)
aa_stderr = err_file;
sprintbuf = austext_malloc (SPRINTBUFSZ, PROGNAME "135", NULL);
/* Open msgs and help text catalogs. */
if (switches & DtSrInNOLOCALE == 0) {
setlocale (LC_ALL, "");
dtsearch_catd = catopen (FNAME_DTSRCAT, 0);
}
/* Register AusText abort signal handlers.
* This ensures that if caller is killed,
* engine will shutdown gracefully.
*/
if (switches & DtSrInSIGNAL) {
if (!(switches & DtSrInENAB_NOHUP))
signal (SIGHUP, signal_abort); /* trap hangups */
signal (SIGINT, signal_abort); /* interrupt, ctrl-c */
signal (SIGQUIT, signal_abort); /* quit, ctrl-d */
signal (SIGKILL, signal_abort); /* (kill -9, cannot be trapped) */
signal (SIGTERM, signal_abort); /* kill [-15], sfwr terminate */
signal (SIGPWR, signal_abort); /* power failure imminent */
#ifdef _AIX
signal (SIGXCPU, signal_abort); /* cpu time limit exceeded */
signal (SIGDANGER, signal_abort); /* imminent paging space crash */
#endif
}
/* If user name was not passed, get it from LOGNAME environment var */
if (userid == NULL || *userid == 0)
if ((userid = (char *) getenv ("LOGNAME")) == NULL) {
sprintf (sprintbuf, catgets (dtsearch_catd, MS_ausapi, 187,
"%1$s Missing both userid and LOGNAME environment variable."),
PROGNAME "187 ");
DtSearchAddMessage (sprintbuf);
return DtSrFAIL;
}
/* initialize usrblk fields */
memset (&usrblk, 0, sizeof (USRBLK));
strncpy (usrblk.userid, userid, 8);
usrblk.userid[8] = 0;
usrblk.flags |= USR_NO_INFOMSGS; /* standard for ausapi */
usrblk.flags |= USR_SORT_WHITL; /* standard for ausapi */
usrblk.flags |= USR_NO_ITERATE; /* must ALWAYS be on in
* this api */
if (switches & DtSrInIDEBUG)
usrblk.debug |= USRDBG_RARE;
if (switches & DtSrInSDEBUG)
usrblk.debug |= USRDBG_SRCHCMPL;
if (switches & DtSrInRDEBUG)
usrblk.debug |= USRDBG_RETRVL;
/* Secret unadvertised feature. High order 2 bytes
* are direct settings of lower 2 bytes of usrblk.debug.
*/
usrblk.debug |= switches >> 16;
/* Set vista's db_oflag from DtSrInRDWR switch.
* Note the vista flag and the switch are inverses
* of each other (RDWR vs. RDONLY).
*/
if ((switches & DtSrInRDWR) == 0)
db_oflag = O_RDONLY;
/* Prespecify site config file to engine */
if (config_file)
OE_sitecnfg_fname = (char *) strdup (config_file);
/* initialize AusText Engine */
usrblk.request = OE_INITIALIZE;
usrblk.query = AUSAPI_VERSION;
Opera_Engine ();
usrblk.query = NULL; /* so we don't try to free it at query time */
if (usrblk.retncode != OE_OK)
return DtSrFAIL;
build_dbnames_array ();
if (dbnames) {
*dbnames = ausapi_dbnamesv;
if (!dbcount) {
sprintf (sprintbuf, catgets(dtsearch_catd, MS_ausapi, 7,
"%s dbnames specified but not dbcount."),
PROGNAME"304");
DtSearchAddMessage (sprintbuf);
return DtSrFAIL;
}
*dbcount = ausapi_dbnamesc;
}
return DtSrOK;
} /* DtSearchInit() */
/************************************************/
/* */
/* DtSearchReinit */
/* */
/************************************************/
/* Returns pointer to dbnames array.
* Used after database or config file changes to trigger
* engine reinitialization and to reaccess the database names.
*/
int DtSearchReinit (char ***dbnames, int *dbcount)
{
aa_check_initialization();
usrblk.request = OE_PING;
Opera_Engine();
switch (usrblk.retncode) {
case OE_REINIT:
if (save_init_switches & DtSrInANY_DEBUG) {
fputs (PROGNAME"755 "
"DtSearchReinit: Engine did return REINIT.\n",
aa_stderr);
fflush (aa_stderr);
}
aa_reinit();
/* fall thru to OK... */
case OE_OK:
*dbnames = ausapi_dbnamesv;
*dbcount = ausapi_dbnamesc;
return DtSrOK;
default:
return DtSrERROR;
}
} /* DtSearchReinit() */
/************************************************/
/* */
/* DtSearchGetKeytypes */
/* */
/************************************************/
/* Returns pointer to keytypes array of specified database.
* If dbname == NULL, returns keytypes of first dblist node.
* Caller may modify is_selected field but should
* not alter other keytypes fields or pointers.
*/
int DtSearchGetKeytypes (
char *dbname, /* 1 - 8 char database name */
int *ktcount, /* number entries in array */
DtSrKeytype **keytypes) /* array of database types */
{
if (!valid_dbname (dbname))
return DtSrREINIT;
*ktcount = usrblk.dblk->ktcount;
*keytypes = usrblk.dblk->keytypes;
return DtSrOK;
} /* DtSearchGetKeytypes() */
/************************************************/
/* */
/* both_valid_dates */
/* */
/************************************************/
/* Subroutine of DtSearchQuery().
* Sets usrblk.objdate1 and objdate2 from passed date strings.
* Returns TRUE on successful parse and conversion.
* Returns FALSE and err msg if either date string is invalid.
*/
static int both_valid_dates (char *date1, char *date2)
{
int convert_error = FALSE;
if ((usrblk.objdate1 = DtSearchValidDateString (date1)) == -1L)
convert_error = TRUE;
if ((usrblk.objdate2 = DtSearchValidDateString (date2)) == -1L)
convert_error = TRUE;
if (!convert_error &&
usrblk.objdate1 != 0L &&
usrblk.objdate2 != 0L &&
usrblk.objdate1 >= usrblk.objdate2) {
sprintf (sprintbuf, catgets (dtsearch_catd, MS_ausapi, 198,
"%s 'Before' date is equal to or after 'After' date.\n"
" No records would be returned."),
PROGNAME "198");
DtSearchAddMessage (sprintbuf);
convert_error = TRUE;
}
return !convert_error;
} /* both_valid_dates() */
/************************************************/
/* */
/* DtSearchQuery */
/* */
/************************************************/
/* Returns hitlist (dittolist) if search successful.
* If dbname is NULL, assumes name from first dblk on dblist.
* Will work correctly even if arg dittolist == &usrblk.dittolist.
* Only return hits 'after' date1 and 'before' date2.
* NULL in one date field means search not limited in that direction.
* NULL in both date fields means search not restricted by dates.
* NULL is also permitted in stems, but if stems is
* not NULL, the passed stems array MUST be defined:
* char stems [DtSrMAX_STEMCOUNT] [DtSrMAXWIDTH_HWORD].
* If query is fzkeyi, it must point to
* array of FZKEYSZ integers.
* DtSearchQuery() was formerly named ausapi_search().
*/
int DtSearchQuery (
void *qry, /* query, fzkeyi, nav string */
char *dbname, /* database name from dbnamesv */
int search_type, /* 'P', 'W', 'S', 'T', 'Z', or 'N' */
char *date1, /* "yyyy mm dd", 3 numeric tokens */
char *date2, /* date1 earlier than date2 */
DtSrResult
**dittolist, /* put hitlist here */
long *dittocount, /* put num items on returned hitlist */
char *stems, /* put stems array here */
int *stemcount) /* put size of stems array */
{
int final_request;
int i, maxbkt;
char *ptr;
DBLK *db;
LLIST *llp;
enum { TEXT, NAVSTRING, FZKEYI }
qryarg;
char date1str[24];
if (!valid_dbname (dbname))
return DtSrREINIT;
/* Verify valid search_type and set flag
* to tell us how to interpret 'qry' arg.
*/
switch (search_type) {
case 'P': /* statistical search */
qryarg = TEXT;
final_request = OE_SRCH_STATISTICAL;
break;
case 'W': /* exact words search */
qryarg = TEXT;
final_request = OE_SRCH_WORDS;
break;
case 'S': /* exact stems search */
qryarg = TEXT;
final_request = OE_SRCH_STEMS;
break;
default:
sprintf (sprintbuf, catgets (dtsearch_catd, MS_ausapi, 20,
"%1$s Invalid search_type '%2$c'."),
PROGNAME "172 ", search_type);
DtSearchAddMessage (sprintbuf);
return DtSrERROR;
} /* end switch on search_type */
/* Validate the 'qry' argument */
if (qry == NULL) {
QUERY_ERROR:
sprintf (sprintbuf, catgets (dtsearch_catd, MS_ausapi, 30,
"%s Null query. No search performed."),
PROGNAME"81");
DtSearchAddMessage (sprintbuf);
return DtSrFAIL;
}
/* If qry is a char string, it must be nonempty. */
if (qryarg != FZKEYI && ((char *) qry)[0] == 0)
goto QUERY_ERROR;
/* If qry is text to be sent as is to engine,
* copy it over now to userblk.
*/
if (qryarg == TEXT && qry != usrblk.query) {
if (usrblk.query != NULL)
free (usrblk.query);
usrblk.query = austext_malloc (strlen (qry) + 16, PROGNAME "102", NULL);
strcpy (usrblk.query, qry);
}
/* Validate the 'date' args and place them into usrblk. */
if (!both_valid_dates (date1, date2))
return DtSrFAIL;
/* Finish setup usrblk for final search */
usrblk.flags |= USR_NO_ITERATE; /* must ALWAYS be ON in this api */
usrblk.request = final_request;
db = usrblk.dblk;
db->maxhits = aa_maxhits;
if (qryarg == TEXT)
save_search_type = usrblk.search_type = search_type;
if (usrblk.debug & USRDBG_SRCHCMPL) {
ptr = sprintbuf;
for (i = 0; i < db->ktcount; i++) {
if (db->keytypes[i].is_selected)
*ptr++ = '*';
*ptr++ = db->keytypes[i].ktchar;
*ptr++ = ' ';
}
*(--ptr) = 0;
strcpy (date1str, objdate2fzkstr (usrblk.objdate1));
fprintf (aa_stderr,
PROGNAME "353 DtSearchQuery(): dbname='%s' srchtype='%c'\n"
" maxhits=%d keytypes='%s'\n"
" date1='%s' -> %s. date2='%s' -> %s.\n"
" query='%.60s'\n",
db->name, search_type, db->maxhits, sprintbuf,
NULLORSTR (date1), date1str,
NULLORSTR (date2), objdate2fzkstr (usrblk.objdate2),
NULLORSTR (usrblk.query));
fflush (aa_stderr);
}
/* Final engine call, the search itself... */
Opera_Engine ();
END_OF_SEARCH:
if (usrblk.debug & USRDBG_SRCHCMPL) {
/* count msgs */
i = 0;
for (llp = ausapi_msglist; llp != NULL; llp = llp->link)
i++;
fprintf (aa_stderr, PROGNAME "380 Return from Search: "
"retncode=%d hitcount=%ld srchmsgs=%d.\n",
usrblk.retncode, usrblk.dittocount, i);
fflush (aa_stderr);
}
/* Set this func's retn value based on engine's retncode, and return. */
switch (usrblk.retncode) {
case OE_OK:
/*
* Transfer usrblk.dittolist to user's own dittolist
* pointer. Also he MUST use DtSearchFreeResults()
* between calls. Otherwise the code below will cause a
* memory leak.
*/
*dittolist = usrblk.dittolist;
*dittocount = usrblk.dittocount;
usrblk.dittolist = NULL;
usrblk.dittocount = 0;
if (stems) {
*stemcount = usrblk.stemcount;
for (i = 0; i < *stemcount; i++) {
strcpy (stems, usrblk.stems[i]);
stems += DtSrMAXWIDTH_HWORD;
}
}
return DtSrOK;
case OE_NOTAVAIL:
return DtSrNOTAVAIL;
case OE_ABORT:
return DtSrABORT;
case OE_REINIT:
return aa_reinit ();
case OE_BAD_QUERY:
/* Query was invalid. Tell the user why. */
if (ausapi_msglist == NULL) {
sprintf (sprintbuf,
catgets (dtsearch_catd, MS_ausapi, 806,
"%s Query insufficient or search options "
"incompatible with database '%s' to commence search."),
PROGNAME "806", usrblk.dblk->name);
DtSearchAddMessage (sprintbuf);
}
return DtSrFAIL;
case OE_NOOP:
/* Search was unsuccessful. Msgs should say why. */
return DtSrFAIL;
default:
/*
* Includes OE_SEARCHING, OE_USER_STOP, etc. Probable
* program error. Msgs may or may not say why.
*/
return DtSrERROR;
} /* end switch */
} /* DtSearchQuery() */
/************************************************/
/* */
/* DtSearchRetrieve */
/* */
/************************************************/
/* Mallocs and returns cleartext of a record given database address (dba).
* fzkey integers start at bkt #2, just like categories.
* WARNING! USER SHOULD NEITHER MALLOC NOR FREE HIS CLEARTEXT POINTER!
*/
int DtSearchRetrieve (
char *dbname, /* 1 - 8 char database name */
DB_ADDR dba, /* database address from dittolist */
char **cleartext, /* cleartext put here (freed first) */
long *clearlen, /* length of returned cleartext */
int *fzkeyi) /* ptr to array of FZKEYSZ integers */
{
int i;
if (!valid_dbname (dbname))
return DtSrREINIT;
usrblk.dba = dba;
usrblk.request = OE_GETREC;
Opera_Engine ();
/* Set this func's retn value based on engine's retncode, and return. */
switch (usrblk.retncode) {
case OE_OK:
/*
* WARNING! USER SHOULD NEITHER MALLOC NOR FREE HIS
* CLEARTEXT POINTER.
*/
*cleartext = usrblk.cleartext; /* user MUST leave
* cleartext alone */
*clearlen = usrblk.clearlen;
return DtSrOK;
case OE_NOTAVAIL:
return DtSrNOTAVAIL;
case OE_ABORT:
return DtSrABORT;
case OE_REINIT:
return aa_reinit ();
case OE_NOOP:
return DtSrFAIL;
default:
/*
* Includes all unexpected return codes. Probable
* program error. Msgs may or may not say why.
*/
return DtSrERROR;
} /* end switch */
} /* DtSearchRetrieve() */
/************************************************/
/* */
/* DtSearchHighlight */
/* */
/************************************************/
/* Mallocs and returns hitwords array for passed text string
* using database and stems array from last search.
* The stems ptr may be NULL, but if specified
* the passed stems array MUST be defined:
* char stems [DtSrMAX_STEMCOUNT] [DtSrMAXWIDTH_HWORD].
*/
int DtSearchHighlight (
char *dbname, /* database name */
char *cleartext, /* text to be hilited */
DtSrHitword ** hitwords,
/* where to put hitwords array */
long *hitwcount, /* num items in hitwords array */
int search_type, /* [opt] override save_search_type */
char *stems, /* [opt] override last search stems */
int stemcount /* num stems in stems array */
)
{
int i;
char *cptr;
if (!valid_dbname (dbname))
return DtSrREINIT;
/* copy cleartext to usrblk if necessary */
if (cleartext == NULL || cleartext[0] == 0) {
sprintf (sprintbuf, catgets (dtsearch_catd, MS_ausapi, 40,
"%1$s Null cleartext. No highlighting performed."),
PROGNAME "349 ", dbname);
DtSearchAddMessage (sprintbuf);
return DtSrERROR;
}
if (cleartext != usrblk.cleartext) {
if (usrblk.cleartext != NULL)
free (usrblk.cleartext);
usrblk.clearlen = strlen (cleartext);
usrblk.cleartext = austext_malloc (usrblk.clearlen + 16,
PROGNAME "267", NULL);
strcpy (usrblk.cleartext, cleartext);
}
if (search_type)
usrblk.search_type = search_type;
else
usrblk.search_type = save_search_type;
if (stems) {
if (stemcount > DtSrMAX_STEMCOUNT) {
sprintf (sprintbuf, catgets (dtsearch_catd, MS_ausapi, 1072,
"%s Program Error: Stem count (%d) greater than maximum (%d)."),
PROGNAME"1072", stemcount, DtSrMAX_STEMCOUNT);
DtSearchAddMessage (sprintbuf);
return DtSrERROR;
}
usrblk.stemcount = stemcount;
cptr = stems;
for (i = 0; i < stemcount; i++) {
strcpy (usrblk.stems[i], cptr);
cptr += DtSrMAXWIDTH_HWORD;
}
}
usrblk.request = OE_HILITE_STEMS;
Opera_Engine ();
/* Set this func's retn value based on engine's retncode, and return. */
switch (usrblk.retncode) {
case OE_OK:
/*
* Note that the following assignment works even if the
* user's hitwords arg is in fact &usrblk.hitwords and
* hitwcount is in fact &usrblk.hitwcount.
*/
*hitwords = usrblk.hitwords;
*hitwcount = usrblk.hitwcount;
return DtSrOK;
case OE_ABORT:
return DtSrABORT;
case OE_REINIT:
return aa_reinit ();
case OE_NOOP:
case OE_NOTAVAIL:
return DtSrFAIL;
default:
/*
* Includes OE_BAD_QUERY and all unexpected return
* codes. Probable program error. Msgs may or may not
* say why. In case they don't, put OE's retncode on
* msglist.
*/
if (!ausapi_msglist) {
sprintf (sprintbuf, catgets (dtsearch_catd, MS_ausapi, 1342,
"%s Search Engine Error %d for highlight request for "
"database '%s', hit word count=%ld, search type='%c', text='%.30s'"),
PROGNAME "1342",
usrblk.retncode, dbname, *hitwcount, search_type,
NULLORSTR (cleartext));
DtSearchAddMessage (sprintbuf);
}
return DtSrERROR;
} /* end switch */
} /* DtSearchHighlight() */
/**************************** DTSRAPI.C *************************/

View File

@@ -0,0 +1,337 @@
/*
* COMPONENT_NAME: austext
*
* FUNCTIONS: main
* print_dbrec
*
* ORIGINS: 27
*
*
* (C) COPYRIGHT International Business Machines Corp. 1994,1995
* All Rights Reserved
* Licensed Materials - Property of IBM
* US Government Users Restricted Rights - Use, duplication or
* disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
*/
/************************* DTSRDBREC.C **************************
* $XConsortium: dtsrdbrec.c /main/8 1996/11/21 19:49:44 drk $
* January 1994.
* Prints out data in a dbrec system record in human readable form.
*
* $Log$
* Revision 2.4 1996/02/01 18:18:18 miker
* Added DtSrLaJPN2. Deleted BETA definition.
*
* Revision 2.3 1995/10/25 19:49:12 miker
* Renamed from dbrec.c. Added prolog.c.
*
* Log: dbrec.c,v
* Revision 2.2 1995/10/19 20:31:07 miker
* No longer necessary to rename d00 file.
* Database files may be read-only.
*
* Revision 2.1 1995/09/22 19:34:56 miker
* Freeze DtSearch 0.1, AusText 2.1.8
*
* Revision 1.12 1995/09/19 21:51:43 miker
* ifdef DTSEARCH, use DtSrVERSION instead of AUSAPI_VERSION in banner.
*
* Revision 1.11 1995/08/31 22:24:50 miker
* Added report of or_language and other minor changes for DtSearch.
* DtSearch executable (without semantic report) renamed dtsrdbrec.
*/
#include "SearchP.h"
#define XOS_USE_NO_LOCKING
#define X_INCLUDE_TIME_H
#include <X11/Xos_r.h>
#define PROGNAME "DTSRDBREC"
#define MS_misc 1
#define MS_dbrec 23
/**#define MAIN_PROGRAM ***/
/************************************************/
/* */
/* language_name */
/* */
/************************************************/
static char *language_name (int language_number)
{
switch (language_number) {
case DtSrLaENG: return "ENGLISH (ASCII)";
case DtSrLaENG2: return "ENGLISH (ISO Latin-1)";
case DtSrLaESP: return "SPANISH";
case DtSrLaFRA: return "FRENCH";
case DtSrLaITA: return "ITALIAN";
case DtSrLaDEU: return "GERMAN";
case DtSrLaJPN: return "JAPANESE (AUTO COMPOUNDS)";
case DtSrLaJPN2: return "JAPANESE (COMPOUNDS FROM LIST)";
default: return "USER DEFINED LANGUAGE";
}
}
/************************************************/
/* */
/* print_dbrec */
/* */
/************************************************/
void print_dbrec (char *dbname, struct or_dbrec * dbrec)
{
int i;
char *cptr;
int blobs_are_possible = FALSE;
printf (catgets (dtsearch_catd, MS_dbrec, 1,
"---------- System Values for Database '%s' ----------\n"),
dbname);
printf (catgets (dtsearch_catd, MS_dbrec, 2,
"Schema version number (version) is '%s'.\n"),
dbrec->or_version);
printf (catgets (dtsearch_catd, MS_dbrec, 3,
"Maximum object key size (sizeof(objkey)) is %ld bytes.\n"),
DtSrMAX_DB_KEYSIZE);
if (ORD_USEHUGEKEYS & dbrec->or_dbflags)
printf (catgets (dtsearch_catd, MS_dbrec, 4,
"Optional 'Huge' keys enabled.\n"));
printf (catgets (dtsearch_catd, MS_dbrec, 12,
"Maximum length of an abstract string (abstrsz) is %d.\n"),
dbrec->or_abstrsz);
if (dbrec->or_abstrsz == 0)
puts (catgets (dtsearch_catd, MS_dbrec, 14,
" (Abstracts are not used in this database)."));
else {
/*
* if they CAN be compressed, say whether or not they
* actually are
*/
if (dbrec->or_hufid != 0L)
printf (catgets (dtsearch_catd, MS_dbrec, 20,
"Abstracts are %scompressed.\n"),
(ORC_COMPABSTR & dbrec->or_compflags) ? "" : "not ");
}
printf (catgets (dtsearch_catd, MS_dbrec, 22,
"Parsing language is number %d, %s.\n"),
dbrec->or_language, language_name(dbrec->or_language));
printf (catgets (dtsearch_catd, MS_dbrec, 24,
"Minimum word length (minwordsz) is %d.\n"),
dbrec->or_minwordsz);
printf (catgets (dtsearch_catd, MS_dbrec, 26,
"Maximum word length (maxwordsz) is %d.\n"),
dbrec->or_maxwordsz);
printf (catgets (dtsearch_catd, MS_dbrec, 30,
"Number of .d00 slots per object (recslots) is %d.\n"),
dbrec->or_recslots);
printf (catgets (dtsearch_catd, MS_dbrec, 36,
" (Maximum number of database objects is %ld).\n"),
0xffffffL / (long) dbrec->or_recslots);
printf (catgets (dtsearch_catd, MS_dbrec, 40,
"Huffman compression table id (hufid) is %ld.\n"),
dbrec->or_hufid);
if (dbrec->or_hufid == 0L)
puts (catgets (dtsearch_catd, MS_dbrec, 42,
" (Compression is disabled in this database)."));
if (dbrec->or_hufid == -1L)
puts (catgets (dtsearch_catd, MS_dbrec, 44,
" (Specific compression table is not yet determined)."));
blobs_are_possible = FALSE;
switch (dbrec->or_dbaccess) {
case ORA_VARIES:
puts (catgets (dtsearch_catd, MS_dbrec, 50,
"Engine accessibility to data may vary from object to object."));
blobs_are_possible = TRUE;
break;
case ORA_NOTAVAIL:
puts (catgets (dtsearch_catd, MS_dbrec, 54,
"Data objects are not directly accessible from the engine."));
break;
case ORA_BLOB:
puts (catgets (dtsearch_catd, MS_dbrec, 56,
"Data objects are stored internally as blobs."));
blobs_are_possible = TRUE;
break;
case ORA_REFBLOB:
puts (catgets (dtsearch_catd, MS_dbrec, 60,
"Only server file references to objects are stored in the blobs."));
break;
case ORA_CREFBLOB:
puts (catgets (dtsearch_catd, MS_dbrec, 64,
"Only client file references to objects are stored in the blobs."));
break;
case ORA_REFKEY:
puts (catgets (dtsearch_catd, MS_dbrec, 68,
"Object keys are server file references to the objects."));
break;
case ORA_CREFKEY:
puts (catgets (dtsearch_catd, MS_dbrec, 72,
"Object keys are client file references to the objects."));
break;
case ORA_REFHUGEKEY:
puts (catgets (dtsearch_catd, MS_dbrec, 74,
"Server file references to objects are "
"stored in the 'huge' keys."));
break;
case ORA_REFABSTR:
puts (catgets (dtsearch_catd, MS_dbrec, 80,
"Server file references to objects are stored in the abstracts."));
break;
case ORA_CREFABSTR:
puts (catgets (dtsearch_catd, MS_dbrec, 86,
"Client file references to objects are stored in the abstracts."));
break;
default:
printf (catgets (dtsearch_catd, MS_dbrec, 90,
"Error: meaning of or_dbaccess value (%hd) is unknown.\n"),
dbrec->or_dbaccess);
blobs_are_possible = TRUE;
break;
} /* end or_dbaccess switch */
if (blobs_are_possible) {
/*
* if they CAN be compressed, say whether or not they
* actually are
*/
if (dbrec->or_hufid != 0L)
printf (catgets (dtsearch_catd, MS_dbrec, 100,
"Repository blobs are %scompressed.\n"),
(ORC_COMPBLOB & dbrec->or_compflags) ? "" : "not ");
}
else
puts (catgets (dtsearch_catd, MS_dbrec, 110,
"Repository blobs are not used in this database."));
printf (catgets (dtsearch_catd, MS_dbrec, 120,
"Database switches (dbflags) are 0x%lx:\n"),
dbrec->or_dbflags);
printf (catgets (dtsearch_catd, MS_dbrec, 130,
" Inverted index %s words exactly as parsed.\n"),
(ORD_XWORDS & dbrec->or_dbflags) ?
catgets (dtsearch_catd, MS_dbrec, 124, "INCLUDES") :
catgets (dtsearch_catd, MS_dbrec, 125, "EXCLUDES"));
printf (catgets (dtsearch_catd, MS_dbrec, 140,
" Inverted index %s word stems.\n"),
(ORD_XSTEMS & dbrec->or_dbflags) ?
catgets (dtsearch_catd, MS_dbrec, 124, "INCLUDES") :
catgets (dtsearch_catd, MS_dbrec, 125, "EXCLUDES"));
printf (catgets (dtsearch_catd, MS_dbrec, 160,
" Use of optional 'huge' keys is %s.\n"),
(ORD_USEHUGEKEYS & dbrec->or_dbflags) ?
catgets (dtsearch_catd, MS_dbrec, 126, "ENABLED") :
catgets (dtsearch_catd, MS_dbrec, 127, "DISABLED"));
printf (catgets (dtsearch_catd, MS_dbrec, 162,
" Mark-for-deletion is %s.\n"),
(ORD_NOMARKDEL & dbrec->or_dbflags) ?
catgets (dtsearch_catd, MS_dbrec, 127, "DISABLED") :
catgets (dtsearch_catd, MS_dbrec, 126, "ENABLED"));
printf (catgets (dtsearch_catd, MS_dbrec, 164,
" Appendable user notes are %s.\n"),
(ORD_NONOTES & dbrec->or_dbflags) ?
catgets (dtsearch_catd, MS_dbrec, 127, "DISABLED") :
catgets (dtsearch_catd, MS_dbrec, 126, "ENABLED"));
printf (catgets (dtsearch_catd, MS_dbrec, 170,
" Text characters are %s wide.\n"),
(ORD_WIDECHAR & dbrec->or_dbflags) ?
catgets (dtsearch_catd, MS_dbrec, 172, "MULTIPLE bytes") :
catgets (dtsearch_catd, MS_dbrec, 174, "a SINGLE byte"));
printf (catgets (dtsearch_catd, MS_dbrec, 200,
"Current number of database objects (reccount) is %ld.\n"),
dbrec->or_reccount);
printf (catgets (dtsearch_catd, MS_dbrec, 210,
"Last currently used slot number (maxdba) is %ld.\n"),
dbrec->or_maxdba);
for (i = 58; i > 0; i--)
putchar ('-');
putchar ('\n');
return;
} /* print_dbrec() */
#ifdef MAIN_PROGRAM
#include <locale.h>
#include <fcntl.h>
#include "vista.h"
/************************************************/
/* */
/* main */
/* */
/************************************************/
int main (int argc, char *argv[])
{
struct or_dbrec dbrec;
char renamebuf[256];
time_t now;
struct tm *time_ptr;
_Xltimeparams localtime_buf;
aa_argv0 = argv[0];
setlocale (LC_ALL, "");
dtsearch_catd = catopen (FNAME_DTSRCAT, 0);
austools_catd = catopen (FNAME_AUSCAT, 0);
time (&now);
time_ptr = _XLocaltime(&now, localtime_buf);
strftime (renamebuf, sizeof (renamebuf),
catgets (dtsearch_catd, MS_misc, 22, "%A, %b %d %Y, %I:%M %p"),
time_ptr);
printf (catgets (dtsearch_catd, MS_misc, 23,
"%s: Version %s. Run %s.\n"),
aa_argv0,
DtSrVERSION,
renamebuf);
if (argc < 2) {
printf (catgets (dtsearch_catd, MS_dbrec, 310,
"USAGE: %s <dbname>\n"), aa_argv0);
return 2;
}
sprintf (renamebuf, "%s.d00", argv[1]);
db_oflag = O_RDONLY; /* db files may be read-only */
d_open (argv[1], "o");
if (db_status != S_OKAY) {
printf (catgets (dtsearch_catd, MS_dbrec, 330,
"Could not open '%s' database.\n%s\n"),
argv[1], vista_msg(PROGNAME"293"));
return 3;
}
d_recfrst (OR_DBREC, 0);
if (db_status != S_OKAY) {
printf (catgets (dtsearch_catd, MS_dbrec, 340,
"No dbrec record in database '%s'.\n"),
argv[1]);
return 4;
}
d_recread (&dbrec, 0);
if (db_status != S_OKAY) {
printf (catgets (dtsearch_catd, MS_dbrec, 350,
"Can't read dbrec record in database '%s'.\n%s\n"),
argv[1], vista_msg(PROGNAME"306"));
return 5;
}
swab_dbrec (&dbrec, NTOH);
print_dbrec (argv[1], &dbrec);
return 0;
} /* main() */
#endif
/************************* DTSRDBREC.C **************************/

View File

@@ -0,0 +1,591 @@
/*
* COMPONENT_NAME: austext
*
* FUNCTIONS: DtSearchFormatObjdate
* DtSearchFreeResults
* DtSearchGetMaxResults
* DtSearchMergeResults
* DtSearchSetMaxResults
* DtSearchSortResults
* DtSearchValidDateString
* aa_check_initialization
* aa_envars
* aa_get_passwd
* ditto_pop
* ditto_sort
* ditto_split
* merge_by_date
* merge_by_prox
*
* ORIGINS: 27
*
*
* (C) COPYRIGHT International Business Machines Corp. 1995, 1996
* All Rights Reserved
* Licensed Materials - Property of IBM
* US Government Users Restricted Rights - Use, duplication or
* disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
*/
/**************************** DTSRJOINT.C *************************
* $XConsortium: dtsrjoint.c /main/5 1996/06/23 16:47:42 cde-ibm $
* February 1995.
* Split off of ausapi.c when I converted to client/server model.
* Ausclt.c is virtual copy of ausapi functions in RPC client stub.
* This module contains ausapi utilities that are common to both
* sides (ie do not result in RPC call to server or require
* access to real usrblk). My original version of this program
* was called "aacom" for "ausapi common" but I renamed it to avoid
* conflict with aacomm, the rpc/sockets communications module.
*
* $Log$
* Revision 2.5 1996/04/10 19:52:16 miker
* Added locale independent ISDIGIT macro. Changed function name
* from aa_merge_dittolists to DtSearchMergeResults.
*
* Revision 2.4 1995/12/27 16:11:54 miker
* Remove save_init_dbxxx globals for DtSearchReinit().
*
* Revision 2.3 1995/10/25 22:16:09 miker
* Renamed from aajoint.c. Added prolog.
*
* Log: aajoint.c,v
* Revision 2.2 1995/10/02 20:14:39 miker
* DtSearch function name changes.
* Added const to strdup() prototype for greater portability.
* Changed to more uniform output format in DtSearchFormatObjdate().
*
* Revision 2.1 1995/09/22 15:18:08 miker
* Freeze DtSearch 0.1, AusText 2.1.8
*
* Revision 1.3 1995/08/31 21:31:48 miker
* Renames and minor changes for DtSearch.
*
* Revision 1.2 1995/06/22 18:01:09 miker
* 2.1.6: RPC version no longer user specifiable. Removed aa_versnum etc.
* Added aa_sort_dittolist, date sorting of hitlists by any client.
*/
#include "SearchE.h"
#include <termios.h>
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
#ifndef strdup
extern char *strdup (const char *s);
#endif
#define PROGNAME "DTSRJOINT"
#define ISDIGIT(c) ((ascii_charmap [(unsigned int) (c)] & NUMERAL) != 0)
/*------------- GLOBALS VISIBLE TO CALLER -------------------*/
/* see also globals.c */
char **ausapi_dbnamesv = NULL; /* array of database names */
int ausapi_dbnamesc = 0; /* size of dbnames array */
int aa_maxhits = DtSrMAXHITS; /* num hits retnd after
* srch */
/*------------------- PRIVATE GLOBALS ---------------------*/
int aa_is_initialized = FALSE;
int aa_getnews_flag = 1;
long save_init_switches = 0L;
int ditsort_type = 0;
/************************************************/
/* */
/* aa_check_initialization */
/* */
/************************************************/
/* Confirms ausapi_init() was first function called. */
void aa_check_initialization (void)
{
if (aa_is_initialized)
return;
fprintf (aa_stderr,
catgets (dtsearch_catd, 2, 37,
"%s First API function call must be DtSearchInit().\n"),
PROGNAME"37");
DtSearchExit (37);
} /* aa_check_initialization() */
/************************************************/
/* */
/* DtSearchValidDateString */
/* */
/************************************************/
/* Subroutine of aa_both_valid_dates(), called once for each date string,
* or can be called from user interface to validate a date string.
* Converts passed date string into valid AusText DtSrObjdate.
* Date string format: "[yy]yy [mm [dd]]",
* 1, 2, or 3 numeric tokens separated by one
* or more nonnumeric chars (whitespace, slashes, etc).
* The first token is a complete year number integer yyyy
* in the range 1900 <= yyyy <= 5995. If the first token contains
* less than 4 digits it is presumed to be the number of years
* since 1900. The month number is the second token mm,
* in the range 1 - 12, and the third token dd is the day, 1 - 31.
* If only two tokens are in the string they are presumed to
* be year and month; the day is presumed to be to 1.
* If only one token is in the string it is presumed to
* be the year; the month is presumed to be 1 and the day
* is presumed to be 1. NULL and empty strings are always
* valid. They mean no date exclusion in the search
* and this function returns objdate 0 for them.
* Returns objdate on successful parse and conversion.
* Returns -1 and err msg if date string is invalid.
*/
DtSrObjdate DtSearchValidDateString (char *datestr)
{
DtSrObjdate objdate = 0L;
char parsebuf[64];
char *startp, *endp;
int yy, mm, dd;
int stop_parse = FALSE;
char msgbuf[256];
aa_check_initialization();
if (datestr == NULL) /* null string is valid */
return 0L;
if (datestr[0] == 0) /* empty string is valid */
return 0L;
strncpy (parsebuf, datestr, sizeof (parsebuf));
parsebuf[sizeof (parsebuf) - 1] = 0;
/* yyyy */
for (startp = parsebuf; *startp != 0 && !ISDIGIT(*startp); startp++);
if (*startp == 0) { /* no numeric digits in string */
#ifdef DEBUG_VALDATE
fprintf (aa_stderr, PROGNAME"269 No numeric digits in string\n");
#endif
INVALID_DATESTR:
sprintf (msgbuf,
catgets (dtsearch_catd, 2, 115,
"%s '%s' is invalid or incomplete date string.\n"
"The correct format is '[yy]yy [mm [dd]]'."),
PROGNAME"115", datestr);
DtSearchAddMessage (msgbuf);
#ifdef DEBUG_VALDATE
fprintf (aa_stderr, PROGNAME"278 Returning objdate -1\n");
fflush (aa_stderr);
#endif
return -1L;
}
for (endp = startp; ISDIGIT(*endp); endp++);
if (*endp == 0) { /* mm and dd both missing */
mm = 1;
dd = 1;
stop_parse = TRUE;
#ifdef DEBUG_VALDATE
fprintf (aa_stderr, PROGNAME"286 mm and dd both missing\n");
#endif
}
*endp = 0;
yy = atoi (startp);
#ifdef DEBUG_VALDATE
fprintf (aa_stderr, PROGNAME"293 yystr='%s' yy=%d\n", startp, yy);
#endif
if (strlen (startp) < 4)
yy += 1900;
if (yy < 1900 || yy > 5995)
goto INVALID_DATESTR;
if (stop_parse)
goto DATESTR_OK;
/* mm */
for (startp = ++endp; *startp != 0 && !ISDIGIT(*startp); startp++);
if (*startp == 0) { /* no mm in string */
mm = 1;
dd = 1;
#ifdef DEBUG_VALDATE
fprintf (aa_stderr, PROGNAME"309 No mm in string\n");
#endif
goto DATESTR_OK;
}
for (endp = startp; ISDIGIT(*endp); endp++);
if (*endp == 0) { /* no dd in string */
dd = 1;
stop_parse = TRUE;
#ifdef DEBUG_VALDATE
fprintf (aa_stderr, PROGNAME"318 No dd in string\n");
#endif
}
*endp = 0;
mm = atoi (startp);
#ifdef DEBUG_VALDATE
fprintf (aa_stderr, PROGNAME"293 mmstr='%s' mm=%d\n", startp, mm);
#endif
if (mm < 1 || mm > 12)
goto INVALID_DATESTR;
if (stop_parse)
goto DATESTR_OK;
/* dd */
for (startp = ++endp; *startp != 0 && !ISDIGIT(*startp); startp++);
if (*startp == 0) { /* no dd in string */
dd = 1;
#ifdef DEBUG_VALDATE
fprintf (aa_stderr, PROGNAME"336 No dd in string\n");
#endif
goto DATESTR_OK;
}
for (endp = startp; ISDIGIT(*endp); endp++);
*endp = 0;
dd = atoi (startp);
#ifdef DEBUG_VALDATE
fprintf (aa_stderr, PROGNAME"344 ddstr='%s' dd=%d\n", startp, dd);
#endif
if (dd < 1 || dd > 31)
goto INVALID_DATESTR;
DATESTR_OK:
objdate = (yy - 1900) << 20 | (mm-1) << 16 | dd << 11;
#ifdef DEBUG_VALDATE
fprintf (aa_stderr,
PROGNAME"352 Returning objdate %08lx, %d/%d/%d, %s\n",
objdate, yy, mm, dd, objdate2fzkstr(objdate));
fflush (aa_stderr);
#endif
return objdate;
} /* DtSearchValidDateString() */
/************************************************/
/* */
/* DtSearchFormatObjdate */
/* */
/************************************************/
/* Converts objdate in hitlist to displayable string */
char *DtSearchFormatObjdate (DtSrObjdate objdate)
{
static char datestr_buf[24];
if (objdate == 0L)
return "(undated)";
strftime (datestr_buf, sizeof(datestr_buf), "%Y.%m.%d",
objdate2tm (objdate));
return datestr_buf;
} /* DtSearchFormatObjdate() */
/************************************************/
/* */
/* DtSearchGetMaxResults */
/* DtSearchSetMaxResults */
/* */
/************************************************/
int DtSearchGetMaxResults (void)
{ return aa_maxhits; }
void DtSearchSetMaxResults (int newmax)
{ aa_maxhits = newmax; }
/************************************************/
/* */
/* DtSearchFreeResults */
/* */
/************************************************/
/* Frees storage allocated for the dittolist created
* by DtSearchQuery(), and sets dittolist pointer to NULL.
* Always returns DtSrOK.
*/
int DtSearchFreeResults (DtSrResult ** dittolist)
{
free_llist ((LLIST **) dittolist);
return DtSrOK;
} /* DtSearchFreeResults() */
/************************************************/
/* */
/* DtSearchMergeResults */
/* */
/************************************************/
/* Merges one dittolist into another using proximity
* for sort order. Sets 'src' dittolist pointer to NULL.
* Does not change dittocount of either list, user must do that.
* Returns DtSrOK on successful merge,
* else returns DtSrERROR for programming error.
* Formerly named aa_merge_dittolists.
*/
int DtSearchMergeResults (DtSrResult **targ_list, DtSrResult **src_list)
{
DtSrResult *targ, *src, *nextsrc, **prevtargl;
if (src_list == NULL || targ_list == NULL)
return DtSrERROR;
/* If there's no 'src' list, return with no changes.
* In other words, merge was successful before we started.
*/
if (*src_list == NULL)
return DtSrOK;
/* At this point we know there is a src_list.
* If there's no targ_list, just swap the pointers.
*/
if (*targ_list == NULL) {
*targ_list = *src_list;
*src_list = NULL;
return DtSrOK;
}
/* We have two nonempty lists. Now do a real merge.
* Insert src node into targ list only if it's
* proximity is smaller. Otherwise just
* advance to the next targ node.
*/
src = *src_list; /* curr src_list node to compare */
nextsrc = src->link; /* next src_list node to compare */
targ = *targ_list; /* curr targ_list node to compare */
prevtargl = targ_list; /* prev targ_list node link pointer */
while (src != NULL && targ != NULL) {
if (src->proximity < targ->proximity) {
/* Insert src node into targ list */
*prevtargl = src;
src->link = targ;
prevtargl = &src->link;
src = nextsrc;
if (src)
nextsrc = src->link;
}
else {
/* just advance to next targ node */
prevtargl = &targ->link;
targ = targ->link;
}
}
/* If there's any src_list left,
* just tack it onto the end of the targ_list.
*/
if (src) {
/* advance to end of targ_list */
while (targ) {
prevtargl = &targ->link;
targ = targ->link;
}
*prevtargl = src;
}
*src_list = NULL;
return DtSrOK;
} /* DtSearchMergeResults() */
/************************************************************
* Aa_sort_dittolist(): basically a copy of ditto_sort() from engine,
* but will sort on several different ditto fields
* (currently only date fields implemented),
* and is only used as convenience function on client/gui side.
* The proximity field is always the minor sort key.
* All functions with similar names to engine functions are static
* in this module so they won't collide with same function in engine.
* Performs a recursive split-merge sort on ditto lists.
************************************************************/
/************************************************/
/* */
/* ditto_pop */
/* */
/************************************************/
/* Subroutine of DtSearchSortResults().
* Detaches first node in a list and returns it...
* If *lst is empty return NULL, else set *lst to the link
* cell of the first DtSrResult node on *lst and return a pointer to
* the first DtSrResult node on *lst.
*/
static DtSrResult *ditto_pop (DtSrResult ** lst)
{
DtSrResult *first_node;
first_node = *lst;
if (first_node != NULL)
*lst = first_node->link;
return first_node;
} /* ditto_pop() */
/************************************************/
/* */
/* ditto_split */
/* */
/************************************************/
/* Subroutine of DtSearchSortResults().
* Find the middle node in lst. Set its 'next' pointer to NULL.
* Return the remainder of lst, i.e. a pointer to the
* next node after the middle node.
*/
static DtSrResult *ditto_split (DtSrResult * lst)
{
DtSrResult *tail = lst->link;
if (lst == NULL || tail == NULL)
return lst;
/*
* Advance 'tail' to end of list, and advance 'lst' only half
* as often
*/
while ((tail != NULL) && ((tail = tail->link) != NULL)) {
lst = lst->link;
tail = tail->link;
}
tail = lst->link;
lst->link = NULL;
return tail;
} /* ditto_split() */
/************************************************/
/* */
/* merge_by_prox */
/* */
/************************************************/
/* Subroutine of DtSearchSortResults().
* Merges two sorted DtSrResult lists together in proximity order.
*/
static DtSrResult *merge_by_prox (DtSrResult * l1, DtSrResult * l2)
{
DtSrResult *myqueue = NULL;
DtSrResult *myend = NULL;
DtSrResult *mynext;
while ((l1 != NULL) && (l2 != NULL)) {
/*
* Perform ENQUEUE function. Next item popped off a list is
* the next one in sorted order. It is added to END of
* myqueue to maintain order. THIS IS WHERE THE ACTUAL SORT
* COMPARE FUNCTION IS PERFORMED.
*/
mynext = (l1->proximity < l2->proximity) ?
ditto_pop (&l1) : ditto_pop (&l2);
mynext->link = NULL;
if (myqueue == NULL)
myqueue = mynext;
else
myend->link = mynext;
myend = mynext;
}
/*
* Perform JOIN QUEUE function. Append entire list to end of
* queue.
*/
if (l1 != NULL)
myend->link = l1;
if (l2 != NULL)
myend->link = l2;
return myqueue;
} /* merge_by_prox() */
/************************************************/
/* */
/* merge_by_date */
/* */
/************************************************/
/* Subroutine of DtSearchSortResults().
* Merges two sorted DtSrResult lists together in objdate order.
*/
static DtSrResult *merge_by_date (DtSrResult * l1, DtSrResult * l2)
{
DtSrResult *myqueue = NULL;
DtSrResult *myend = NULL;
DtSrResult *mynext;
while ((l1 != NULL) && (l2 != NULL)) {
/*
* Perform ENQUEUE function. Next item popped off a list is
* the next one in sorted order. It is added to END of
* myqueue to maintain order. THIS IS WHERE THE ACTUAL SORT
* COMPARE FUNCTION IS PERFORMED.
*/
if (l1->objdate == l2->objdate)
mynext = (l1->proximity < l2->proximity) ?
ditto_pop (&l1) : ditto_pop (&l2);
else
mynext = (l1->objdate > l2->objdate) ?
ditto_pop (&l1) : ditto_pop (&l2);
mynext->link = NULL;
if (myqueue == NULL)
myqueue = mynext;
else
myend->link = mynext;
myend = mynext;
}
/*
* Perform JOIN QUEUE function. Append entire list to end of
* queue.
*/
if (l1 != NULL)
myend->link = l1;
if (l2 != NULL)
myend->link = l2;
return myqueue;
} /* merge_by_date() */
/************************************************/
/* */
/* ditto_sort */
/* */
/************************************************/
/* Subroutine of DtSearchSortResults().
* Sorts a list of DtSrResult structures and returns ptr to sorted list.
* The basic idea is to sort by recursively splitting a list
* into two equal halves and sorting each of those. The recursion
* ends when there are only two small lists which are either
* already sorted or are swapped. This sort rarely runs out
* of stack space because each recursion cuts the list length in
* half so there are at most 1 + log-N-to-the-base-2 items on the stack.
* (e.g. 64,000 nodes = max stack depth of 16: 2**16 = 64K).
*/
static DtSrResult *ditto_sort (DtSrResult * lst)
{
DtSrResult *lst2;
if ((lst == NULL) || (lst->link == NULL))
return lst;
lst2 = ditto_split (lst);
switch (ditsort_type) {
case DtSrSORT_PROX:
return merge_by_prox (ditto_sort (lst), ditto_sort (lst2));
case DtSrSORT_DATE:
return merge_by_date (ditto_sort (lst), ditto_sort (lst2));
default:
fprintf (aa_stderr, PROGNAME "525 Invalid Sort Type %d.\n",
ditsort_type);
DtSearchExit (32);
}
} /* ditto_sort() */
/************************************************/
/* */
/* DtSearchSortResults */
/* */
/************************************************/
/* Only publicly visible sort function.
* DtSearchSortResults() was formerly named aa_sort_dittolist.
*/
int DtSearchSortResults (DtSrResult ** dittolist, int sort_type)
{
switch (sort_type) {
case DtSrSORT_PROX:
case DtSrSORT_DATE:
ditsort_type = sort_type;
*dittolist = ditto_sort (*dittolist); /* recursive call */
return DtSrOK;
default:
DtSearchAddMessage (PROGNAME "140 "
"Program Error: Invalid sort type.");
return DtSrERROR;
}
} /* DtSearchSortResults() */
/**************************** DTSRJOINT.C *************************/

131
cde/lib/DtSearch/dtsrswab.c Normal file
View File

@@ -0,0 +1,131 @@
/*
* COMPONENT_NAME: austext
*
* FUNCTIONS: swab_dbrec
* swab_objrec
*
* ORIGINS: 27
*
* (C) COPYRIGHT International Business Machines Corp. 1996
* All Rights Reserved
* Licensed Materials - Property of IBM
* US Government Users Restricted Rights - Use, duplication or
* disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
*/
/********************* DTSRSWAB.C **********************************
* $XConsortium: dtsrswab.c /main/2 1996/10/28 13:58:11 drk $
* July 1996.
* These functions byte swap and other manipulations on
* DtSearch or_... structures to ensure that database records
* are maintained in a canonical format no matter what machine
* they are used on.
* The functions use the standard htonl, htons, ntohl, and ntohs
* network conversion functions for byte order neutrality.
* They use the DtSrINT16 and DtSrINT32 typedefs in Search.h
* to control integer size.
* The external database records are in the canonical,
* big-endian "network" order.
* So that they can be defined as "null" macros on big endian machines,
* the functions (1) always byte swap in place and (2) always succeed.
*
* $Log$
*/
#include "SearchP.h"
/********************************/
/* */
/* swab_objrec */
/* */
/********************************/
void swab_objrec (struct or_objrec *rec, SWABDIR direction)
{
#ifndef BYTE_SWAP
return;
#else
if (direction == NTOH) {
NTOHL (rec->or_objflags);
NTOHL (rec->or_objuflags);
NTOHL (rec->or_objsize);
NTOHL (rec->or_objdate);
NTOHL (rec->or_objsecmask);
NTOHS (rec->or_objaccess);
NTOHS (rec->or_objtype);
NTOHS (rec->or_objcost);
NTOHS (rec->or_objhdroffset);
NTOHS (rec->or_objeureka);
}
else { /* going the other direction */
HTONL (rec->or_objflags);
HTONL (rec->or_objuflags);
HTONL (rec->or_objsize);
HTONL (rec->or_objdate);
HTONL (rec->or_objsecmask);
HTONS (rec->or_objaccess);
HTONS (rec->or_objtype);
HTONS (rec->or_objcost);
HTONS (rec->or_objhdroffset);
HTONS (rec->or_objeureka);
}
return;
#endif /* BYTE_SWAP */
} /* swab_objrec() */
/********************************/
/* */
/* swab_dbrec */
/* */
/********************************/
void swab_dbrec (struct or_dbrec *rec, SWABDIR direction)
{
#ifndef BYTE_SWAP
return;
#else
if (direction == NTOH) {
NTOHL (rec->or_dbflags);
NTOHL (rec->or_dbuflags);
NTOHL (rec->or_reccount);
NTOHL (rec->or_maxdba);
NTOHL (rec->or_availd99);
NTOHL (rec->or_unavaild99);
NTOHL (rec->or_hufid);
NTOHL (rec->or_dbsecmask);
NTOHS (rec->or_dbotype);
NTOHS (rec->or_compflags);
NTOHS (rec->or_dbaccess);
NTOHS (rec->or_minwordsz);
NTOHS (rec->or_maxwordsz);
NTOHS (rec->or_recslots);
NTOHS (rec->or_fzkeysz);
NTOHS (rec->or_abstrsz);
NTOHS (rec->or_language);
}
else { /* going the other direction */
HTONL (rec->or_dbflags);
HTONL (rec->or_dbuflags);
HTONL (rec->or_reccount);
HTONL (rec->or_maxdba);
HTONL (rec->or_availd99);
HTONL (rec->or_unavaild99);
HTONL (rec->or_hufid);
HTONL (rec->or_dbsecmask);
HTONS (rec->or_dbotype);
HTONS (rec->or_compflags);
HTONS (rec->or_dbaccess);
HTONS (rec->or_minwordsz);
HTONS (rec->or_maxwordsz);
HTONS (rec->or_recslots);
HTONS (rec->or_fzkeysz);
HTONS (rec->or_abstrsz);
HTONS (rec->or_language);
}
return;
#endif /* BYTE_SWAP */
} /* swab_dbrec() */
/********************* DTSRSWAB.C **********************************/

286
cde/lib/DtSearch/dtsrutil.c Normal file
View File

@@ -0,0 +1,286 @@
/*
* COMPONENT_NAME: austext
*
* FUNCTIONS: clear_hitwords
* clear_usrblk_record
* get_hitlist_text
* print_dittolist
* print_usrblk_record
*
* ORIGINS: 27
*
*
* (C) COPYRIGHT International Business Machines Corp. 1991,1995
* All Rights Reserved
* Licensed Materials - Property of IBM
* US Government Users Restricted Rights - Use, duplication or
* disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
*/
/*********************** DTSRUTIL.C ***********************
* $XConsortium: dtsrutil.c /main/5 1996/08/12 13:18:30 cde-ibm $
* October 1991.
* Set of utility functions for opera User Interfaces (UIs),
* although may also be used by Opera Engine (OE) itself.
* Function free_dittolist() replaced by macro call to free_llist().
* Ausapi wrapped aa_free_dittolist around free_llist().
* DtSearch renamed aa_free_dittolist to DtSearchFreeResults().
*
* $Log$
* Revision 2.4 1996/03/13 22:54:21 miker
* Changed char to UCHAR several places.
*
* Revision 2.3 1996/03/05 16:05:45 miker
* Added print_stems().
*
* Revision 2.2 1995/10/25 18:36:09 miker
* Renamed from uiutil.c. Added prolog.
*
* Log: uiutil.c,v
* Revision 2.1 1995/09/22 22:19:47 miker
* Freeze DtSearch 0.1, AusText 2.1.8
*
* Revision 1.13 1995/09/05 19:17:28 miker
* Minor name and function changes for DtSearch. Made usrblk global.
*/
#include "SearchE.h"
#include <string.h>
#include <sys/stat.h>
#define MS_misc 1
/********#define DEBUG_CLEARREC*********/
/**********#define DEBUG_FAX***********/
#define PROGNAME "DTSRUTIL"
/************************************************/
/* */
/* print_stems */
/* */
/************************************************/
/* For debugging. Prints passed stems array to aa_stderr. */
void print_stems (int stemcount, void *stems, char *prefix)
{
int i;
UCHAR *cptr;
if (stemcount <= 0) {
fprintf (aa_stderr, "%s Stems array is empty.\n", prefix);
fflush (aa_stderr);
return;
}
fprintf (aa_stderr, "%s stemct = %d:\n", prefix, stemcount);
for (i=0; i<stemcount; i++) {
cptr = (UCHAR *) stems + (i * DtSrMAXWIDTH_HWORD);
if (i == 3 || i == 6)
fputc ('\n', aa_stderr);
fprintf (aa_stderr, " #%d:'%c%s'",
i, (*cptr < 32) ? '~' : *cptr, cptr + 1);
}
fputc ('\n', aa_stderr);
fflush (aa_stderr);
return;
} /* print_stems() */
/************************************************/
/* */
/* print_dittolist */
/* */
/************************************************/
/* Only for debugging in oe. Dumps first 10 list nodes. */
void print_dittolist (DtSrResult * dittolist, char *prefix)
{
DtSrResult *dit;
char datebuf[48];
int maxcount = 10;
if (prefix == NULL)
prefix = "HITLIST";
if (dittolist == NULL) {
fprintf (aa_stderr, "%s Dittolist is empty.\n", prefix);
return;
}
fprintf (aa_stderr, "%s First %d hits on dittolist at %p:\n",
prefix, maxcount, dittolist);
for (dit = dittolist; dit != NULL && maxcount-- > 0; dit = dit->link) {
if (dit->objdate == 0)
strcpy (datebuf, "0");
else
strftime (datebuf, sizeof (datebuf), "%y/%m/%d",
objdate2tm (dit->objdate));
fprintf (aa_stderr,
" dbn=%d dba=%d:%ld prox=%d sz=%ld date=%s key='%s'\n",
dit->dbn, dit->dba >> 24, (long)dit->dba & 0xffffffL,
dit->proximity, (long)dit->objsize,
datebuf, dit->reckey);
if (dit->abstractp)
if (dit->abstractp[0] != 0)
fprintf (aa_stderr, " abstract='%.50s'\n", dit->abstractp);
}
return;
} /* print_dittolist() */
/************************************************/
/* */
/* get_hitlist_text */
/* */
/************************************************/
/* Converts dittolist into a single block of clean ascii text
* for use as a hitlist, or for printing out to hardcopy.
* Wraps lines intelligently to ensure no line is greater than maxlen.
* If maxlen == 0, no wrapping is performed.
* Returns static pointer to dynamically allocated buffer--
* if permanent copy is desired, caller must copy text
* to his own buffer before next call.
*/
char *get_hitlist_text (int maxlen)
{
static char *text = NULL;
int sofar;
char *src, *targ, *eol;
DtSrResult *dit;
char sprintbuf[80];
size_t mallocsz;
if (usrblk.dittocount <= 0L) {
sprintf (sprintbuf, catgets (dtsearch_catd, MS_misc, 96,
"%s Hitlist is empty."), PROGNAME"96");
DtSearchAddMessage (sprintbuf);
return NULL;
}
if (maxlen > 0 && maxlen < DtSrMAX_DB_KEYSIZE + 7) {
sprintf (sprintbuf, PROGNAME "97 maxlen = %d is too small.", maxlen);
DtSearchAddMessage (sprintbuf);
return NULL;
}
/* Allocate enough memory for each item in ditto list */
mallocsz = usrblk.dittocount *
(usrblk.abstrbufsz + DtSrMAX_DB_KEYSIZE + 80L);
if (text != NULL)
free (text);
text = austext_malloc (mallocsz, PROGNAME "103", NULL);
/* Loop thru ditto list, creating text out of hitlist */
targ = text;
for (dit = usrblk.dittolist; dit != NULL; dit = dit->link) {
if (maxlen == 0) {
sprintf (targ, "%5d %-*s %s\n%n",
dit->proximity,
DtSrMAX_DB_KEYSIZE,
dit->reckey,
dit->abstractp,
&sofar);
targ += sofar;
}
else /* (maxlen > 0) */
/*
* We may have more text than can fit on one line.
* Wrap lines to fit within maxlen.
*/
{
eol = targ + maxlen;
sprintf (targ, "%5d %-*s %n",
dit->proximity,
DtSrMAX_DB_KEYSIZE,
dit->reckey,
&sofar);
targ += sofar;
src = dit->abstractp;
for (;;) {
while (targ < eol && *src != 0)
*targ++ = *src++;
*targ++ = '\n';
if (*src == 0)
break;
eol = targ + maxlen;
strcpy (targ, " ");
targ += 9;
}
} /* end else (maxlen > 0) */
} /* end loop on dittolist */
*targ = 0; /* ...I don't know about you, but I always forget
* this */
if (usrblk.debug & USRDBG_UTIL)
fprintf (aa_stderr, PROGNAME "160 "
"get_hitlist_text(): mallocsz=%ld textlen=%ld\n",
mallocsz, strlen (text));
return text;
} /* get_hitlist_text() */
/****************************************/
/* */
/* print_usrblk_record */
/* */
/****************************************/
/* dumps out usrblk 'record' fields for debugging */
void print_usrblk_record (char *prefix)
{
fprintf (aa_stderr, "%s usrblk_record(): dba=%ld:%ld objkey='%s'\n"
" notesp=%p clearlen=%d cleartxt='%.30s'\n"
" #hitw=%d hitw=%p abstr='%.24s'\n",
prefix,
(long)usrblk.dba >> 24, (long)usrblk.dba & 0xffffffL,
usrblk.objrec.or_objkey,
usrblk.notes,
(int)usrblk.clearlen,
NULLORSTR (usrblk.cleartext),
(int)usrblk.hitwcount,
usrblk.hitwords,
NULLORSTR (usrblk.abstrbuf));
return;
} /* print_usrblk_record() */
/****************************************/
/* */
/* clear_usrblk_record */
/* */
/****************************************/
/* Clears and initializes all USRBLK fields that
* represent an opera record from vista, specifically
* objrec, notes, textblobs, clearlen, and cleartext.
* This function MUST NOT ALTER dba, hitwords, and hitwcount,
* because many callers require these things to remain untouched.
* If usrblk.objrec.or_objkey[0] == '\0',
* UI must presume that all record fields are invalid
* including usrblk.objfzkey and usrblk.abstract.
*/
void clear_usrblk_record (void)
{
usrblk.clearlen = 0;
if (usrblk.cleartext != NULL) {
free (usrblk.cleartext);
usrblk.cleartext = NULL;
}
free_llist (&usrblk.notes);
usrblk.objrec.or_objkey[0] = '\0';
if (usrblk.abstrbufsz > 0)
usrblk.abstrbuf[0] = 0;
if (usrblk.debug & USRDBG_RETRVL)
print_usrblk_record (PROGNAME "600 clear: ");
return;
} /* clear_usrblk_record() */
/************************************************/
/* */
/* clear_hitwords */
/* */
/************************************************/
/* clears hitwcount and array in usrblk */
void clear_hitwords (void)
{
usrblk.hitwcount = 0;
if (usrblk.hitwords != NULL) {
free (usrblk.hitwords);
usrblk.hitwords = NULL;
}
return;
} /* clear_hitwords() */
/*********************** DTSRUTIL.C ***********************/

1039
cde/lib/DtSearch/dtsrve.c Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,45 @@
/*
* COMPONENT_NAME: austext
*
* FUNCTIONS: ensure_end_slash
*
* ORIGINS: 27
*
*
* (C) COPYRIGHT International Business Machines Corp. 1995,1996
* All Rights Reserved
* Licensed Materials - Property of IBM
* US Government Users Restricted Rights - Use, duplication or
* disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
*/
/************** ENDSLASH.C ****************
* $XConsortium: endslash.c /main/4 1996/05/07 13:33:42 drk $
* If passed path name string does not end in a slash, adds a slash.
* There MUST BE ROOM for the extra slash in the passed string buffer!
* Does nothing if passed pathstr is completely empty
* to prevent a presumed 'root path' for files in curr work dir.
* Returns ptr to zero byte at end of string.
*
* $Log$
* Revision 2.2 1995/10/26 15:23:51 miker
* Added prolog.
*
* Revision 2.1 1995/09/22 19:52:53 miker
* Freeze DtSearch 0.1, AusText 2.1.8
*
* Revision 1.1 1995/07/18 22:41:43 miker
* Initial release as separate module.
*/
#include <string.h>
char *ensure_end_slash (char *pathstr)
{
char *cptr = pathstr + strlen(pathstr) - 1;
if (*pathstr == 0)
return pathstr;
if (*cptr++ != '/') {
*cptr++ = '/';
*cptr = 0;
}
return cptr;
}

292
cde/lib/DtSearch/fileman.c Normal file
View File

@@ -0,0 +1,292 @@
/*
* COMPONENT_NAME: austext
*
* FUNCTIONS: add_free_space
* find_free_space
* init_header
*
* ORIGINS: 27
*
* (C) COPYRIGHT International Business Machines Corp. 1993,1995
* All Rights Reserved
* US Government Users Restricted Rights - Use, duplication or
* disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
*/
/******************* FILEMAN.C **********************
* $XConsortium: fileman.c /main/8 1996/11/25 18:47:12 drk $
* September 1993.
* Garbage collection algorithm: Fileman maintains
* 2 tables at the front of the d99. They keep track of
* small sized 'holes' (unique words that appear only
* once in a record)and large holes of free space.
* Only the N largest holes in each table are saved,
* so some fragmentation still exists. This happens
* particularly when a huge database is built from scratch.
* As the size grows, more and more holes are discarded
* because they are too small to handle any words as
* the database grows. For this reason, mrclean should
* be run at least once after the database grows to a
* fairly good size, to recover the wasted space. Once the
* database reaches its nominal size, the 2 tables are very
* effective at recycling holes, so mrclean need not be
* run for compression purposes.
*
* $Log$
* Revision 2.2 1995/10/24 22:09:25 miker
* Add prolog.
*
* Revision 2.1 1995/09/22 20:05:50 miker
* Freeze DtSearch 0.1, AusText 2.1.8
*
* Revision 1.3 1995/09/05 17:27:37 miker
* Names changes for DtSearch.
*/
#include "SearchP.h"
#include <stdlib.h>
#include <errno.h>
#define PROGNAME "FILEMAN"
#define HOLE_SIZE_LIMIT 500
DtSrINT32 batch_size = 0;
/************************/
/* */
/* Init Header */
/* */
/************************/
/* Initialize file_header data, and write it at the beginning of a new file */
void init_header (FILE * fp, FILE_HEADER * flh)
{
memset (flh, 0, sizeof(FILE_HEADER));
fseek (fp, 0L, SEEK_SET);
fwrite (flh, sizeof(FILE_HEADER), (size_t)1, fp);
return;
} /* init_header() */
/********************************/
/* */
/* fread_d99_header */
/* */
/********************************/
/* Reads d99 header structure from front of passed d99 file.
* Performs byte swap as necessary IN PASSED BUFFER.
* Returns TRUE if successful, else FALSE.
*/
int fread_d99_header (FILE_HEADER *flh, FILE *fp)
{
int i;
errno = 0;
fseek (fp, 0L, SEEK_SET);
if (fread (flh, sizeof(FILE_HEADER), (size_t)1, fp) != 1L)
return FALSE;
NTOHL (flh->hole_count[0]);
NTOHL (flh->hole_count[1]);
for (i = 0; i < NUM_HOLES; i++) {
NTOHL (flh->hole_array[0][i].hole_size);
NTOHL (flh->hole_array[0][i].offset);
NTOHL (flh->hole_array[1][i].hole_size);
NTOHL (flh->hole_array[1][i].offset);
}
return TRUE;
} /* fread_d99_header() */
/********************************/
/* */
/* fwrite_d99_header */
/* */
/********************************/
/* Writes d99 header structure to front of passed d99 file.
* Performs byte swap as necessary IN PASSED BUFFER.
* Returns TRUE if successful, else FALSE.
*/
int fwrite_d99_header (FILE_HEADER *flh, FILE *fp)
{
int i;
HTONL (flh->hole_count[0]);
HTONL (flh->hole_count[1]);
for (i = 0; i < NUM_HOLES; i++) {
HTONL (flh->hole_array[0][i].hole_size);
HTONL (flh->hole_array[0][i].offset);
HTONL (flh->hole_array[1][i].hole_size);
HTONL (flh->hole_array[1][i].offset);
}
errno = 0;
fseek (fp, 0L, SEEK_SET);
if (fwrite (flh, sizeof(FILE_HEADER), (size_t)1, fp) == 1L)
return TRUE;
else
return FALSE;
} /* fwrite_d99_header() */
/************************/
/* */
/* Find Free Space */
/* */
/************************/
/* Find free space that is big enough to hold a new record.
On success - return pointer to the FREE_SPACE_STR.
On failure - return NULL.
*/
FREE_SPACE_STR *find_free_space (DtSrINT32 req_size, FILE_HEADER * flh)
{
static FREE_SPACE_STR space_found;
FREE_SPACE_STR del_rec;
int i, j, k;
DtSrINT32 hole_check_size;
float coeff;
j = -1;
if (req_size <= HOLE_SIZE_LIMIT) {
k = 0;
coeff = 1.1;
}
else {
k = 1;
coeff = 1.2;
}
for (i = 0; i < flh->hole_count[k]; i++) {
if (flh->hole_array[k][i].hole_size >= req_size) {
if (j < 0) {
j = i;
}
else { /** check if it's the smallest one of the
free space available ***/
if (flh->hole_array[k][i].hole_size <
flh->hole_array[k][j].hole_size) {
j = i;
}
}
}
}
/* if big enough free space not found, return NULL */
if (j < 0) {
return NULL;
}
if (flh->hole_array[k][j].hole_size == req_size) {
space_found.hole_size = flh->hole_array[k][j].hole_size;
space_found.offset = flh->hole_array[k][j].offset;
/* compact the hole_array */
if (j == NUM_HOLES - 1) {
(flh->hole_count[k])--;
flh->hole_array[k][j].hole_size = 0;
return &space_found;
}
for (i = j; i < (flh->hole_count[k] - 1); i++) {
flh->hole_array[k][i].hole_size =
flh->hole_array[k][i + 1].hole_size;
flh->hole_array[k][i].offset =
flh->hole_array[k][i + 1].offset;
}
(flh->hole_count[k])--;
}
else {
/* Hole size CAN NOT excede global batch_size in borodin */
hole_check_size = (req_size * coeff < batch_size) ?
req_size * coeff : batch_size;
if (hole_check_size >= flh->hole_array[k][j].hole_size) {
space_found.hole_size = flh->hole_array[k][j].hole_size;
space_found.offset = flh->hole_array[k][j].offset;
/* compact the hole_array */
if (j == NUM_HOLES - 1) {
flh->hole_array[k][j].hole_size = 0;
}
else {
for (i = j; i < (flh->hole_count[k] - 1); i++) {
flh->hole_array[k][i].hole_size =
flh->hole_array[k][i + 1].hole_size;
flh->hole_array[k][i].offset =
flh->hole_array[k][i + 1].offset;
}
}
(flh->hole_count[k])--;
}
else {
space_found.hole_size = req_size;
space_found.offset = flh->hole_array[k][j].offset;
flh->hole_array[k][j].hole_size -= req_size;
flh->hole_array[k][j].offset += req_size * sizeof(DtSrINT32);
if ((k == 1) &&
(flh->hole_array[k][j].hole_size <= HOLE_SIZE_LIMIT)) {
del_rec.hole_size = flh->hole_array[k][j].hole_size;
del_rec.offset = flh->hole_array[k][j].offset;
add_free_space (&del_rec, flh);
if (j == NUM_HOLES - 1) {
(flh->hole_count[k])--;
flh->hole_array[k][j].hole_size = 0;
return &space_found;
}
for (i = j; i < (flh->hole_count[k] - 1); i++) {
flh->hole_array[k][i].hole_size =
flh->hole_array[k][i + 1].hole_size;
flh->hole_array[k][i].offset =
flh->hole_array[k][i + 1].offset;
}
(flh->hole_count[k])--;
}
}
}
return &space_found;
}
/************ end of function find_free_space ******************/
/************************/
/* */
/* Add Free Space */
/* */
/************************/
/* Adds freed space to the hole_array.
If there'e no space left in the hole_array, checks if the new
space is greater, than the smallest space in the hole_array.
If yes - substitute it.
*/
void add_free_space (FREE_SPACE_STR * del_rec, FILE_HEADER * flh)
{
int i, j, k;
DtSrINT32 min_size;
if (del_rec->hole_size <= HOLE_SIZE_LIMIT) {
k = 0;
}
else {
k = 1;
}
j = flh->hole_count[k];
if (j < NUM_HOLES) {
flh->hole_array[k][j].hole_size = del_rec->hole_size;
flh->hole_array[k][j].offset = del_rec->offset;
(flh->hole_count[k])++;
}
else {
min_size = flh->hole_array[k][0].hole_size;
j = 0;
for (i = 1; i < NUM_HOLES; i++) {
if (flh->hole_array[k][i].hole_size < min_size) {
min_size = flh->hole_array[k][i].hole_size;
j = i;
}
}
if (del_rec->hole_size > flh->hole_array[k][j].hole_size) {
flh->hole_array[k][j].hole_size = del_rec->hole_size;
flh->hole_array[k][j].offset = del_rec->offset;
}
}
return;
}
/************ end of function add_free_space ******************/

View File

@@ -0,0 +1,45 @@
/*
* COMPONENT_NAME: austext
*
* FUNCTIONS: none
*
* ORIGINS: 27
*
*
* (C) COPYRIGHT International Business Machines Corp. 1995
* All Rights Reserved
* Licensed Materials - Property of IBM
* US Government Users Restricted Rights - Use, duplication or
* disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
*/
/**************************** GLOBALS.C *************************
* $XConsortium: globals.c /main/5 1996/05/07 13:34:49 drk $
* March 1995.
* Contains only the most global of DtSearch/AusText globals.
* Used by everybody, including offlines, so must be kept
* in a very small module, and reference as few headers as possible.
*
* $Log$
* Revision 2.3 1995/10/26 15:19:28 miker
* Added prolog.
*
* Revision 2.2 1995/10/02 20:32:00 miker
* Comments cleanup only.
*
* Revision 2.1 1995/09/22 20:11:33 miker
* Freeze DtSearch 0.1, AusText 2.1.8
*
* Revision 1.2 1995/09/05 17:53:52 miker
* Added dtsearch_catd and _XOPEN_SOURCE for DtSearch.
*/
#ifndef _XOPEN_SOURCE
#define _XOPEN_SOURCE
#endif
#include <stdio.h>
#include <nl_types.h>
FILE *aa_stderr = stderr;
char *aa_argv0 = "<argv0>";
nl_catd dtsearch_catd = (nl_catd) -1;
nl_catd austools_catd = (nl_catd) -1;
void *ausapi_msglist = NULL; /* really (LLIST *) */

291
cde/lib/DtSearch/hdecode.c Normal file
View File

@@ -0,0 +1,291 @@
/*
* COMPONENT_NAME: austext
*
* FUNCTIONS: hc_decode
* main
*
* ORIGINS: 27
*
*
* (C) COPYRIGHT International Business Machines Corp. 1990,1995
* All Rights Reserved
* Licensed Materials - Property of IBM
* US Government Users Restricted Rights - Use, duplication or
* disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
*/
/************************* HDECODE.C ***************************
* $XConsortium: hdecode.c /main/8 1996/11/21 19:50:15 drk $
* 1990.
* Decode function that reads in a Huffman Code bitstring and returns the
* original plaintext characters. Intended use of Huffman Code is
* both compression and encryption of text lines in Opera System.
* Decode (decryption) is optimized for high speed, online use.
*
* Global Arguments:
* 'hctree' is decode table in form of array of integers.
* Each integer pair forms a node in a huffman code tree.
* See huffcode.c for full discussion of its organization.
* If 'hctree' is NULL, the tree has not been linked into
* current object module, and this function must read the
* source file and create the tree at execution time.
* This flexibility allows internal use of decode function
* using different trees without having to recompile/relink.
* The linked-in version is more secure for external customer use.
* 'hctree_name' is filename prefix for both encode (.huf) and
* encode (.c) source files. If 'hctree' is NULL, this is
* the file from which the tree will be built.
* 'hctree_id' is unique unix timestamp indicating when hctree was
* create. It is compared with caller's (encoder's) passed stamp
* to ensure encode/decode compatibility.
* 'hctree_root' is the integer index of the root node in hctree.
* By luck, this is always the LAST node so it also gives an
* indication of the storage needed when the tree has to be
* allocated at execution time.
*
* Passed Arguments:
* 'bitstring' is the address of the huffman encoded cyphertext.
* It begins on byte boundary, but may end in middle of
* a byte depending on charcount.
* 'charbuf' is the output buffer where the plaintext characters
* will be assembled.
* 'charcount' is the number of plaintext bytes that were encoded into
* the passed bitstring, and will be assembled into charbuf.
*
* $Log$
* Revision 2.3 1996/03/13 22:56:26 miker
* Changed char to UCHAR several places.
*
* Revision 2.2 1995/10/25 17:51:46 miker
* Added prolog.
*
* Revision 2.1 1995/09/22 20:50:00 miker
* Freeze DtSearch 0.1, AusText 2.1.8
*
* Revision 1.3 1995/09/05 18:02:21 miker
* Name changes for DtSearch.
*/
#include "SearchP.h"
#include <errno.h>
#define X_INCLUDE_STRING_H
#define XOS_USE_NO_LOCKING
#include <X11/Xos_r.h>
#define HDEC_FBUFSZ 128
#define PROGNAME "HDECODE"
#define MS_huff 30 /* message catalog set number */
extern char *hctree_name;
extern time_t hctree_id;
extern int hctree_root;
extern int *hctree;
/*---------------- TREENODE structure ---------------------*/
typedef struct {
int branch0;
int branch1;
} TREENODE;
/************************************************/
/* */
/* HC Decode */
/* */
/************************************************/
void hc_decode (
UCHAR *bitstring, /* input: compressed data */
UCHAR *charbuf, /* output: uncompressed data */
int charcount, /* input: length uncompressed data */
time_t encode_id)
{ /* input: compression table to use */
#ifdef DEBUG_DECODE
static int first_time = TRUE;
#endif
register int bitreg;
int i;
int bitcount;
int tree_index;
TREENODE *tree_addr;
#ifdef EXTERNAL_TREE
char *ptr;
char *hdecode_filebuf;
FILE *hdecode_file;
_Xstrtokparams strtok_buf;
#endif
#ifdef EXTERNAL_TREE
/* Create hctree from external file? */
if (hctree == NULL) {
if ((hdecode_filebuf = malloc (HDEC_FBUFSZ)) == NULL) {
fprintf (aa_stderr, catgets(dtsearch_catd, MS_huff, 10,
"%s Out of Memory.\n"),
PROGNAME"076");
DtSearchExit (2);
}
if ((hdecode_file = fopen (hctree_name, "r")) == NULL) {
fprintf (aa_stderr, catgets(dtsearch_catd, MS_huff, 11,
"%s Cannot open tree file '%s': %s\n"),
PROGNAME"082", hctree_name, strerror (errno));
DtSearchExit (2);
}
/* read first few lines to load global variables */
for (i = 0; i < 3; i++)
fgets (hdecode_filebuf, HDEC_FBUFSZ, hdecode_file);
ptr = strchr (hdecode_filebuf, '=');
hctree_id = atol (ptr + 1);
fgets (hdecode_filebuf, HDEC_FBUFSZ, hdecode_file);
ptr = strchr (hdecode_filebuf, '=');
hctree_root = atoi (ptr + 1);
fgets (hdecode_filebuf, HDEC_FBUFSZ, hdecode_file); /* throwaway */
/* allocate space for the hctree and read in the values */
if ((hctree = (int *) malloc (
sizeof (int) * 2 * (hctree_root + 2))) == NULL) {
fprintf (aa_stderr, "\n" PROGNAME "100 Out of Memory.\7\n");
DtSearchExit (2);
}
for (i = 0; i <= hctree_root; i++) {
if ((fgets (hdecode_filebuf, HDEC_FBUFSZ, hdecode_file)) == NULL) {
fprintf (aa_stderr, catgets(dtsearch_catd, MS_huff, 12,
"%s Invalid format hctree '%s'.\n"),
PROGNAME"106", hctree_name);
DtSearchExit (2);
}
hctree[2 * i] = atoi (_XStrtok (hdecode_filebuf, " \t,", strtok_buf));
hctree[2 * i + 1] = atoi (_XStrtok (NULL, " \t,", strtok_buf));
}
free (hdecode_filebuf);
fclose (hdecode_file);
} /* endif where hctree created from external file */
#endif /* for EXTERNAL_TREE */
#ifdef DEBUG_DECODE
if (first_time) {
first_time = FALSE;
printf ("\n***** created hctree from '%s' ******\n"
"hctree_id = %ld\nhctree_root = %d\n",
hctree_name, hctree_id, hctree_root);
}
#endif
if (encode_id != hctree_id) {
fprintf (aa_stderr, catgets(dtsearch_catd, MS_huff, 13,
"%s Incompatible hctree_ids.\n"),
PROGNAME"118");
DtSearchExit (2);
}
tree_addr = (TREENODE *) hctree;
bitcount = 0;
while (charcount-- > 0) { /****** MAIN OUTPUT CHARACTER LOOP ******/
tree_index = hctree_root;
while (tree_index >= 0) { /****** TREE TRAVERSAL LOOP ******/
/* retrieve next bit */
if (bitcount <= 0) { /* read next input char? */
bitcount = 8;
bitreg = *bitstring++;
}
bitreg <<= 1;
bitcount--;
if (bitreg & 0x0100)
tree_index = tree_addr[tree_index].branch1;
else
tree_index = tree_addr[tree_index].branch0;
} /* end tree traversal loop */
/******** DECODE CHARACTER ********/
/* if literal code, retrieve next 8 bits as char itself */
if ((tree_index += 257) == 256) {
tree_index = 0;
for (i = 8; i > 0; i--) {
if (bitcount <= 0) { /* read next input char? */
bitcount = 8;
bitreg = *bitstring++;
}
bitreg <<= 1;
bitcount--;
tree_index <<= 1;
if (bitreg & 0x0100)
tree_index |= 1;
} /* end 8-bit for loop */
} /* endif to process literal coding */
*charbuf = tree_index;
charbuf++;
} /* end main output character loop */
return;
} /* end of function hc_decode */
#ifdef DEBUG_DECODE
/************************************************/
/* */
/* Main */
/* */
/************************************************/
void main (int argc, char *argv[])
{
#define BITSTR_BUFSIZE 140
FILE *instream;
FILE *aa_stderr = stderr;
char stringbuf[BITSTR_BUFSIZE + 2];
char charbuf[9 * BITSTR_BUFSIZE];
char fname_tree[80];
int mychar;
int oops;
int i;
union {
INT integer;
char chars[2];
} charcount;
if (argc <= 1) {
puts ("Usage: hdecode [hucfile] cypherfile");
return;
}
if (argc >= 3) {
hctree = NULL;
append_ext (fname_tree, sizeof (fname_tree), argv[1], EXT_HDECODE);
hctree_name = fname_tree;
argv++;
}
if ((instream = fopen (argv[1], "rb")) == NULL) {
fprintf (aa_stderr, "Cannot open cypherfile '%s'.\n", argv[1]);
exit (2);
}
MAINLOOP:
/**************/
if ((mychar = fgetc (instream)) == EOF)
return;
charcount.chars[0] = mychar;
if ((mychar = fgetc (instream)) == EOF)
return;
charcount.chars[1] = mychar;
if (charcount.integer > sizeof (charbuf) - 2) {
oops = TRUE;
charcount.integer = sizeof (charbuf) - 2;
}
else
oops = FALSE;
/* printf("\n\n***** charcount = %d %s*****\n",
charcount.integer, (oops) ? "(reduced)" : "");*/
for (i = 0; i < BITSTR_BUFSIZE; i++) {
if ((mychar = fgetc (instream)) == EOF) {
fprintf (aa_stderr, "\n" PROGNAME "202 Unexpected EOF '%s'.\n",
argv[1]);
exit (2);
}
stringbuf[i] = mychar;
}
hc_decode (stringbuf, charbuf, charcount.integer, hctree_id);
for (i = 0; i < charcount.integer; i++)
putchar (charbuf[i]);
goto MAINLOOP;
/************/
} /* end of function main */
#endif
/************************* HDECODE.C ***************************/

360
cde/lib/DtSearch/hencode.c Normal file
View File

@@ -0,0 +1,360 @@
/*
* COMPONENT_NAME: austext
*
* FUNCTIONS: convert_str_2_char
* gen_vec
* hc_encode
* main
* process_char
*
* ORIGINS: 27
*
*
* (C) COPYRIGHT International Business Machines Corp. 1990,1995
* All Rights Reserved
* Licensed Materials - Property of IBM
* US Government Users Restricted Rights - Use, duplication or
* disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
*/
/********************** HENCODE.C ***********************
* $XConsortium: hencode.c /main/9 1996/11/21 19:50:29 drk $
* Huffman encoder program.
*
* $Log$
* Revision 2.3 1996/03/13 22:56:39 miker
* Changed char to UCHAR several places.
*
* Revision 2.2 1995/10/26 15:11:42 miker
* Added prolog.
*
* Revision 2.1 1995/09/22 20:50:40 miker
* Freeze DtSearch 0.1, AusText 2.1.8
*
* Revision 1.3 1995/09/05 18:07:00 miker
* Name changes for DtSearch.
*/
#include "SearchP.h"
#include <errno.h>
#define X_INCLUDE_STRING_H
#define XOS_USE_NO_LOCKING
#include <X11/Xos_r.h>
#define PROGNAME "HENCODE"
#define MS_huff 30 /* message catalog set number */
#define DELIMITERS "\t\n"
#define LAST_BIT '-'
#define LITERAL_NUM 256
#define NO_SPACE 0
/*------------------------ GLOBALS ---------------------------*/
long gen_vec_hufid = 0L;
static struct or_blobrec blobrec;
static char *huff_code[257];
static int code_length[257];
static char coded_bits_str[9];
static char bit_pos = 0;
static char bits_left;
static int total_num_chars = 0;
static int num_char_coded = 0;
static char zero_str[] = "00000000";
#define MAX_NUM_CHAR (sizeof(blobrec.or_blob) - 1)
#define MAX_NUM_BITS (8 * MAX_NUM_CHAR)
/****************************************/
/* */
/* GENERATE VECTORS */
/* */
/****************************************/
void gen_vec (char *fname_huffcode_tab)
{
char temp[40];
int i, j;
char tab_filebuf[128];
unsigned char ch;
FILE *tab_stream;
_Xstrtokparams strtok_buf;
if ((tab_stream = fopen (fname_huffcode_tab, "r")) == NULL) {
printf (catgets(dtsearch_catd, MS_huff, 1,
"%s: Cannot open huffman encode file '%s':\n"
" %s\n Exit Code = 2\n"),
PROGNAME"222", fname_huffcode_tab, strerror (errno));
DtSearchExit (2);
}
memset (huff_code, 0, sizeof(huff_code));
memset (code_length, 0, sizeof(code_length));
/*
* First line in the file contains time stamp. We have to read
* it separately. First token on first line is hufid. Save it
* in a global for optional use by caller.
*/
fgets (tab_filebuf, sizeof (tab_filebuf) - 1, tab_stream);
gen_vec_hufid = atol (tab_filebuf);
/*-------------- READ IN HUFFMAN FILE ------------*/
/*
* We are only interested in the character itself (index) and
* its Huffman Code
*/
while (fgets (tab_filebuf, sizeof (tab_filebuf) - 1, tab_stream)
!= NULL) {
i = atoi (_XStrtok (tab_filebuf, DELIMITERS, strtok_buf)); /* char */
/* read current huff code */
strcpy (temp, _XStrtok (NULL, DELIMITERS, strtok_buf));
if (temp[0] == ' ') {
/* Empty huffcode associated with LITERAL CODE.
* Either this is literal char itself and literal
* encodeing has been turned off, or this char is
* so rare that it is coded using the literal char.
*/
if (i == 256)
continue;
/* current character has LITERAL CODE */
strcpy (temp, huff_code[LITERAL_NUM]);
*(code_length + i) = *(code_length + LITERAL_NUM) + 8;
ch = (unsigned char) i;
for (j = 0; j < 8; j++) {
if (ch & 0x80) {
temp[*(code_length + LITERAL_NUM) + j] =
'1';
}
else {
temp[*(code_length + LITERAL_NUM) + j] =
'0';
}
ch = ch << 1;
}
temp[*(code_length + LITERAL_NUM) + 8] = '\0';
huff_code[i] =
(char *) malloc (*(code_length + i) + 1);
strcpy (huff_code[i], temp);
}
else {
/* regular HUFFMAN code */
*(code_length + i) = strlen (temp);
huff_code[i] =
(char *) malloc (*(code_length + i) + 1);
strcpy (huff_code[i], temp);
}
}
fclose (tab_stream);
} /* end of function gen_vec */
/********************************************************/
/* */
/* Convert Coded String to Coded Character */
/* */
/********************************************************/
void convert_str_2_char (char *code)
{
int i, j;
*code = 0;
j = 1;
for (i = 0; i < 8; i++) {
if (*(coded_bits_str + (7 - i)) == '1') {
*code += j;
}
j = j * 2;
}
total_num_chars++;
return;
}
/****************************************/
/* */
/* Process Current Character */
/* */
/****************************************/
int process_char (UCHAR ch, char *bitstr)
{
char temp_code[40];
char coded_char;
int i, j;
int num_of_bits_in_code;
i = (int) ch;
num_of_bits_in_code = *(code_length + i);
if ((MAX_NUM_BITS - total_num_chars * 8 - bit_pos) <
num_of_bits_in_code) {
return NO_SPACE;
}
strcpy (temp_code, huff_code[i]);
while (TRUE) {
/* fill new character with Huffman Code */
if (bit_pos == 0) {
if (num_of_bits_in_code == 8) {
strcpy (coded_bits_str, temp_code);
convert_str_2_char (&coded_char);
bitstr[total_num_chars - 1] = coded_char;
return TRUE;
}
if (num_of_bits_in_code < 8) {
strcpy (coded_bits_str, temp_code);
bit_pos = num_of_bits_in_code;
bits_left = 8 - bit_pos;
return TRUE;
}
if (num_of_bits_in_code > 8) {
strncpy (coded_bits_str, temp_code, 8);
coded_bits_str[8] = '\0';
convert_str_2_char (&coded_char);
bitstr[total_num_chars - 1] = coded_char;
num_of_bits_in_code -= 8;
strcpy (temp_code, &temp_code[8]);
}
} /* end of bit_pos == 0 loop */
else {
j = bit_pos + num_of_bits_in_code;
if (j == 8) {
bit_pos = 0;
strcat (coded_bits_str, temp_code);
convert_str_2_char (&coded_char);
bitstr[total_num_chars - 1] = coded_char;
return TRUE;
}
if (j < 8) {
strcat (coded_bits_str, temp_code);
bit_pos = j;
bits_left = 8 - bit_pos;
return TRUE;
}
if (j > 8) {
strncat (coded_bits_str, temp_code,
(size_t) bits_left);
convert_str_2_char (&coded_char);
bitstr[total_num_chars - 1] = coded_char;
num_of_bits_in_code -= bits_left;
strcpy (temp_code, &huff_code[i][bits_left]);
bit_pos = 0;
}
} /* end of else loop */
} /* end of while(TRUE) loop */
}
/************************************************/
/* */
/* HC Encode */
/* */
/************************************************/
int hc_encode (struct or_blobrec * targblobrec,
UCHAR *charbuf,
int charcount,
int file_pos)
{
/********** replaced by blobrec above...
union charint
{
char ch[2];
INT orig_char_count;
} un1;
static char temp1 [MAX_NUM_CHAR+1]; ...repl by blobrec;
************/
char *ptr, *targ, *src;
int i, j;
char temp;
char ret_code = TRUE;
char write = FALSE;
char last_call = FALSE;
if (charcount == 0) {
last_call = TRUE;
charcount = 1;
}
for (i = 0; i < charcount; i++) {
if (!last_call) {
ret_code = process_char (charbuf[i], (char *) blobrec.or_blob);
}
if ((ret_code == NO_SPACE) ||
(file_pos && (i == (charcount - 1)))) {
if (!last_call) {
if (file_pos && (i == (charcount - 1))) {
num_char_coded++;
}
}
if (bit_pos) {
strncat (coded_bits_str, zero_str,
(size_t) bits_left);
convert_str_2_char (&temp);
blobrec.or_blob[total_num_chars - 1][0] = temp;
}
write = TRUE;
/**********
un1.orig_char_count = num_char_coded;
bitstring[0] = un1.ch[0];
bitstring[1] = un1.ch[1];
for (j = 0; j <= total_num_chars; j++) {
*(bitstring + j + 2) = *(temp1 + j);
};
**************/
targblobrec->or_bloblen = num_char_coded;
targ = (char *) targblobrec->or_blob;
src = (char *) blobrec.or_blob;
for (j = 0; j < total_num_chars; j++)
*targ++ = *src++;
num_char_coded = 0;
bit_pos = 0;
total_num_chars = 0;
if (file_pos && (i == (charcount - 1))) {
return write;
}
i--;
}
else {
num_char_coded++;
}
}
return write;
}
#ifdef DEBUG_HENCODE
/****************************************/
/* */
/* Main */
/* */
/****************************************/
main (int argc, char *argv[])
{
FILE *stream;
char bitstring[MAX_NUM_CHAR + 2];
char charbuf[MAX_NUM_CHAR + 1];
int charcount = 0;
int mychar;
if (argc < 2) {
fprintf (stderr, "Usage: try filename\n");
exit (1);
}
if ((stream = fopen (argv[1], "rb")) == NULL) {
fprintf (stderr, "Could not open input file '%s'\n", argv[1]);
exit (2);
}
fp = fopen ("codefile.dat", "wb");
gen_vec ();
while ((mychar = getc (stream)) != EOF) {
charbuf[charcount] = mychar;
charcount++;
if (charcount == MAX_NUM_CHAR) {
hc_encode (bitstring, charbuf, charcount, 0);
/*
* for (j = 0; j < charcount; j++) {
* fputc(bitstring[j], fp); }
*/
charcount = 0;
}
}
hc_encode (bitstring, charbuf, charcount, 1);
printf ("Total Number of Characters = %ld\n", total_num_chars);
fclose (fp);
fclose (stream);
return;
}
#endif
/********************** HENCODE.C ***********************/

160
cde/lib/DtSearch/hilite.c Normal file
View File

@@ -0,0 +1,160 @@
/*
* COMPONENT_NAME: austext
*
* FUNCTIONS: hilite_cleartext
*
* ORIGINS: 27
*
*
* (C) COPYRIGHT International Business Machines Corp. 1992,1996
* All Rights Reserved
* Licensed Materials - Property of IBM
* US Government Users Restricted Rights - Use, duplication or
* disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
*/
/******************************* HILITE.C ********************************
* $XConsortium: hilite.c /main/5 1996/05/07 13:36:46 drk $
* January 1992.
* Opera Engine (OE) functions that create the usrblk.hitwords
* array in response to several user requests.
* The hitwords array identifies the offset and
* length of words or substrings in cleartext to be hilited
* by the User Interface (UI).
* Formerly the hilite.c module was named oehitw.c
*
* $Log$
* Revision 2.4 1996/03/20 19:33:36 miker
* Changed hilite_cleartext() usage to pass in stems array
* so code could be reused for collocations searches.
*
* Revision 2.3 1996/02/01 19:06:53 miker
* AusText 2.1.11, DtSearch 0.3: Major rewrite for new parsers.
* Replaced oe_stems_to_hitwords with hilite_cleartext.
*
* Revision 2.2 1995/10/24 22:03:53 miker
* Add prolog.
*
* Revision 2.1 1995/09/22 20:53:52 miker
* Freeze DtSearch 0.1, AusText 2.1.8
*
* Revision 1.1 1995/08/31 21:02:32 miker
* Initial revision
*/
#include "SearchE.h"
#include <stdlib.h>
#include <string.h>
#define PROGNAME "HILITE"
/****************************************/
/* */
/* hilite_cleartext */
/* */
/****************************************/
/* Builds usrblk.hitwords array from usrblk.cleartext
* and passed stems array. Arg parse_type must
* contain 'W' or 'S' to correctly indicate whether
* the stems array is loaded with parsed words or stems.
* Stems array must be same format at usrblk.stems (double
* indexed array with max DtSrMAXWIDTH_HWORD columns per row).
* (Formerly this function was named 'build_hitwords',
* then 'oe_stems_to_hitwords').
* Returns new value of usrblk.hitwords.
* If zero hitwords, returns NULL in usrblk.hitwords.
*/
long hilite_cleartext (int parse_type, char *stems, int stemcount)
{
int i;
char *textp, *stemp;
DBLK *dblk = usrblk.dblk;
PARG parg;
char * (*parser)() = usrblk.dblk->parser;
char * (*stemmer)() = usrblk.dblk->stemmer;
DtSrHitword *hitwords;
size_t hitwords_size = 0;
long hitwcount = 0;
long offset;
int wordlen;
int debugging_hilite = (usrblk.debug & USRDBG_HILITE);
/* Ensure current usrblk.hitwords values are clear */
clear_hitwords ();
memset (&parg, 0, sizeof(PARG));
parg.dblk = dblk;
parg.string = usrblk.cleartext;
parg.offsetp = &offset;
parg.flags |= PA_HILITING;
/* OUTER LOOP: Parse/stem each word in cleartext */
for ( textp = parser (&parg);
textp;
textp = parser (NULL)) {
wordlen = strlen (textp);
if (parse_type == 'S')
textp = stemmer (textp, dblk);
if (debugging_hilite) {
fprintf (aa_stderr,
PROGNAME"127 offs:%5ld '%s' %n",
offset, textp, &i);
while (i++ < 35)
fputc (' ', aa_stderr);
}
/* INNER LOOP: Search for word in stems array */
stemp = stems;
for (i=stemcount; i; i--) {
if (strcmp (textp, stemp) == 0)
break;
stemp += DtSrMAXWIDTH_HWORD;
}
/* Miss. If text word is not in
* stems array, go parse next word.
*/
if (i == 0) {
if (debugging_hilite)
fprintf (aa_stderr, "miss.\n");
continue;
}
/* HIT! Add to hitwords table. */
if (hitwcount >= hitwords_size) {
if (hitwords_size == 0) {
hitwords_size = 200;
hitwords = malloc (
hitwords_size * sizeof(DtSrHitword) + 16);
}
else {
hitwords_size += hitwords_size >> 1; /* 1.5 times */
if (debugging_hilite || (usrblk.debug & USRDBG_RETRVL))
fprintf (aa_stderr,
PROGNAME"098 realloc for %ld hitwords.\n",
hitwords_size);
hitwords = realloc (hitwords,
hitwords_size * sizeof(DtSrHitword) + 16);
}
if (!hitwords) {
fputs (PROGNAME"091 Out of Memory!\n", aa_stderr);
DtSearchExit (91);
}
}
hitwords[hitwcount].offset = offset;
hitwords[hitwcount].length = wordlen;
hitwcount++;
if (debugging_hilite)
fprintf (aa_stderr, "HIT! hwct=%ld.\n", hitwcount);
} /* end OUTER parse loop */
usrblk.hitwcount = hitwcount;
usrblk.hitwords = (hitwcount)? hitwords : NULL;
if (debugging_hilite || (usrblk.debug & USRDBG_RETRVL))
fprintf (aa_stderr,
PROGNAME"138 parstyp='%c' stemct=%d hitwcount=%ld\n",
parse_type, stemcount, usrblk.hitwcount);
return hitwcount;
} /* hilite_cleartext() */
/******************************* HILITE.C ********************************/

120
cde/lib/DtSearch/iscompat.c Normal file
View File

@@ -0,0 +1,120 @@
/*
* COMPONENT_NAME: austext
*
* FUNCTIONS: false
* is_compatible_version
*
* ORIGINS: 27
*
*
* (C) COPYRIGHT International Business Machines Corp. 1993,1995
* All Rights Reserved
* Licensed Materials - Property of IBM
* US Government Users Restricted Rights - Use, duplication or
* disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
*/
/*********************** ISCOMPAT.C ************************
* $XConsortium: iscompat.c /main/7 1996/11/21 19:50:44 drk $
* November 1993.
* Verifies version number compatibility between caller and this program.
*
* $Log$
* Revision 2.2 1995/10/25 17:46:54 miker
* Added prolog.
*
* Revision 2.1 1995/09/22 20:55:37 miker
* Freeze DtSearch 0.1, AusText 2.1.8
*
* Revision 1.4 1995/09/05 18:10:55 miker
* Name changes for DtSearch.
*/
#include "SearchP.h"
#define X_INCLUDE_STRING_H
#define XOS_USE_NO_LOCKING
#include <X11/Xos_r.h>
/****#define DEBUG_ISCOMPAT****/
#ifdef DEBUG_ISCOMPAT
static int false (int n) { printf("iscompat=%d\n",n); return FALSE; }
#else
#define false(n) FALSE
#endif
/************************************************/
/* */
/* is_compatible_version */
/* */
/************************************************/
/* Returns TRUE if the caller's 'version' and 'revision' numbers,
* ie the first two numbers of a standard "v.r.m" or "v.r"
* version string, are between VERSCONST and the version
* compiled for this program, ie the constant AUSAPI_VERSION.
* VERSCONST is also expected to be a #define constant,
* either SCHEMA_VERSION, when the last schema change occurred,
* or PROTOCOL_VERSION, when the protocol between the ui and
* the engine changed.
* Returns FALSE if caller's version is not within that range.
* Uses strtok()!
*/
int is_compatible_version (char *callers_version, char *VERSCONST)
{
char safebuf [24];
char *ptr;
int fuzzy_v, fuzzy_r, his_v, his_r, my_v, my_r;
_Xstrtokparams strtok_buf;
if (callers_version == NULL)
return false(1);
if (*callers_version == '\0')
return false(2);
strncpy (safebuf, callers_version, sizeof(safebuf));
safebuf[sizeof(safebuf) - 1] = 0;
if ((ptr = _XStrtok (safebuf, ".", strtok_buf)) == NULL)
return false(3);
if ((his_v = atoi (ptr)) == 0)
if (*ptr != '0')
return false(4);
if ((ptr = _XStrtok (NULL, ".", strtok_buf)) == NULL)
return false(5);
if ((his_r = atoi (ptr)) == 0)
if (*ptr != '0')
return false(6);
strncpy (safebuf, VERSCONST, sizeof(safebuf));
safebuf[sizeof(safebuf) - 1] = 0;
if ((ptr = _XStrtok (safebuf, ".", strtok_buf)) == NULL)
return false(7);
if ((my_v = atoi (ptr)) == 0)
if (*ptr != '0')
return false(8);
if ((ptr = _XStrtok (NULL, ".", strtok_buf)) == NULL)
return false(9);
if ((my_r = atoi (ptr)) == 0)
if (*ptr != '0')
return false(10);
strncpy (safebuf, AUSAPI_VERSION, sizeof(safebuf));
safebuf[sizeof(safebuf) - 1] = 0;
if ((ptr = _XStrtok (safebuf, ".", strtok_buf)) == NULL)
return false(11);
if ((fuzzy_v = atoi (ptr)) == 0)
if (*ptr != '0')
return false(12);
if ((ptr = _XStrtok (NULL, ".", strtok_buf)) == NULL)
return false(13);
if ((fuzzy_r = atoi (ptr)) == 0)
if (*ptr != '0')
return false(14);
if (his_v < my_v || fuzzy_v < his_v)
return false(15);
if (his_v == my_v && his_r < my_r)
return false(16);
if (fuzzy_v == his_v && fuzzy_r < his_r)
return false(17);
return TRUE;
} /* is_compatible_version() */
/*********************** ISCOMPAT.C ************************/

252
cde/lib/DtSearch/isduprec.c Normal file
View File

@@ -0,0 +1,252 @@
/*
* COMPONENT_NAME: austext
*
* FUNCTIONS: dump_hashtab
* is_duprec
* main
*
* ORIGINS: 27
*
*
* (C) COPYRIGHT International Business Machines Corp. 1993,1995
* All Rights Reserved
* Licensed Materials - Property of IBM
* US Government Users Restricted Rights - Use, duplication or
* disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
*/
/******************* ISDUPREC.C *******************
* $XConsortium: isduprec.c /main/5 1996/05/07 13:37:35 drk $
* June 1993.
* Is_duprec() returns 0 (FALSE) for every record id it is passed
* unless one is passed that duplicates a previous one,
* in which case it returns 1 (TRUE).
* It ensures that duplicate record ids in an .fzk file
* are not processed by either ravel or borodin.
* It does it by storing each recid into a hash table and
* searching the table before storing a new recid.
* Returns 2 on errors (malloc out of space, etc);
*
* Global 'duprec_hashsize' can be changed to any rational value
* for a hash table size (say 1000 to 30,000) prior to the first call
* of is_duprec(). It should be roughly => to the total number of
* different record ids expected to be passed to is_duprec().
* If initialized to 0 before the first call, that will disable
* duplicate checking, i.e. is_duprec() will allocate no memory
* and always return 0.
*
* $Log$
* Revision 2.2 1995/10/25 17:22:48 miker
* Added prolog.
*
* Revision 2.1 1995/09/22 20:56:44 miker
* Freeze DtSearch 0.1, AusText 2.1.8
*
* Revision 1.3 1995/09/05 18:11:45 miker
* Minor changes so ansi c compilers won't whine.
*/
#include <stdlib.h>
#include <string.h>
#ifdef TEST
#include <stdio.h>
#include <errno.h>
#endif
#define PROGNAME "ISDUPREC"
#define HASHSIZE 3000L
#define NOT_A_DUP 0
#define IS_A_DUP 1
#define OUT_OF_MEM 2
unsigned long duprec_hashsize = HASHSIZE;
/************************************************/
/* */
/* HASHNODE */
/* */
/************************************************/
/* The hash table is a HASHSIZE array of pointers to these structures.
* Each pointer is initialized to NULL.
* Additions are handled by filling in a HASHNODE pointed to
* by the table pointer. The 'recid' is NOT a char array of length
* 1, but a string whose length varies depending on the actual
* length of the passed record id. Each hashnode is malloced
* for exactly the right length. Collisions are handled by linking
* additional nodes off of the original one.
*/
typedef struct hash_tag {
struct hash_tag *link;
char recid[2]; /* actual array size varies */
} HASHNODE;
#ifdef TEST
/************************************************/
/* */
/* dump_hashtab() */
/* */
/************************************************/
/* For debugging, prints out all recids in hashtab, skipping empty bkts */
static void dump_hashtab (HASHNODE ** hashtab)
{
HASHNODE *hp, **hpp;
int i;
printf (PROGNAME "67 dump_hashtab(%p):\n", hashtab);
for (i = 0, hpp = hashtab; i < duprec_hashsize; i++, hpp++) {
if (*hpp) {
printf (" %4d:", i);
fflush (stdout);
for (hp = *hpp; hp != NULL; hp = hp->link)
printf (" '%s'", hp->recid);
putchar ('\n');
fflush (stdout);
}
}
return;
} /* dump_hashtab() */
#endif /* TEST */
/************************************************/
/* */
/* is_duprec() */
/* */
/************************************************/
/* Normal return is 0 indicating that passed record id is unique.
* Also immediately returns 0 if duplicate checking has been
* turned off by setting global 'duprec_hashsize' to zero.
* Returns 1 if record id is a duplicate.
* Returns 2 if out of memory.
* First call uses 'duprec_hashsize' to create hash table.
*/
int is_duprec (char *recid)
{
static HASHNODE **hashtab = NULL;
static unsigned long primes[10] =
{1013, 1511, 2203, 3511, 5003, 10007, 15013, 20011, 25013, 30001};
unsigned long i;
char *cp;
unsigned long sum;
HASHNODE *hp, **hpp;
if (duprec_hashsize == 0UL)
return NOT_A_DUP;
/* Generate hash table at first call only */
if (hashtab == NULL) {
/*
* adjust table size upward to nearest preordained prime
* number
*/
for (i = 0; i < 9 && primes[i] < duprec_hashsize; i++);
duprec_hashsize = primes[i];
#ifdef TEST
printf (PROGNAME "117 Create hash table, duprec_hashsize set = %ld.\n",
duprec_hashsize);
#endif
hashtab = malloc ((duprec_hashsize + 2L) * sizeof (HASHNODE **));
if (hashtab == NULL)
return OUT_OF_MEM;
/* init table to all NULL pointers. */
hpp = hashtab;
for (i = duprec_hashsize + 2L; i > 0L; i--)
*hpp++ = NULL;
}
/*****dump_hashtab(hashtab);******/
/* HASH FUNCTION: H(recid) = (SUM(i*recid[i])) mod M,
* where M is table size (prime), and SUM is calculated
* for i=1 to end of recid. Multiplying the position by the character
* value at that position minimizes the influence of identical
* characters at the beginnings and ends of recids,
* and also usually yields a number larger than M.
* Not skipping over the first position (the keytype char) helps
* efficiently catch recids that are blank after the keytype.
*/
sum = 0UL;
i = 1;
cp = recid;
while (*cp != 0)
sum += i++ * (*cp++);
hpp = &(hashtab[sum % duprec_hashsize]); /* hpp = head of linked
* list */
#ifdef TEST
printf (PROGNAME "150 is_duprec('%s')=hashtab[%lu]=%p: ",
recid, sum % duprec_hashsize, *hpp);
fflush (stdout);
i = 0;
#endif
/* Search linked list (if any) for hashnode containing recid */
for (hp = *hpp; hp != NULL; hp = hp->link) {
#ifdef TEST
i++;
#endif
if (strcmp (hp->recid, recid) == 0) {
#ifdef TEST
printf ("DUP!@listpos=%d\n", i);
#endif
return IS_A_DUP;
}
hpp = &hp->link; /* now hpp = tail of linked list */
}
#ifdef TEST
printf ("miss@listlen=%d\n", i);
#endif
/* Not a duplicate. Add current recid to hash table. */
if ((hp = malloc (sizeof (HASHNODE) + strlen (recid) + 2)) == NULL)
return OUT_OF_MEM;
strcpy (hp->recid, recid);
hp->link = NULL;
/*****hp->link = *hpp;******/
*hpp = hp;
return NOT_A_DUP;
} /* is_duprec() */
#ifdef MAIN
/************************************************/
/* */
/* main() */
/* */
/************************************************/
main (int argc, char *argv[])
{
int i;
FILE *f;
char buf[2048];
if (argc < 2) {
printf ("USAGE: %s <file> [n]\n"
"where file contains list of char strings\n"
"and optional n changes hash table size.\n",
argv[0]);
return;
}
if ((f = fopen (argv[1], "r")) == NULL) {
printf ("Can't open %s: %s\n", argv[1], strerror (errno));
return;
}
if (argc >= 3)
duprec_hashsize = atol (argv[2]);
while (fgets (buf, sizeof (buf), f) != NULL) {
buf[sizeof (buf) - 1] = 0;
i = is_duprec (buf);
printf ("%s", buf); /* each buf should end in \n */
if (i > 1)
break;
}
return;
}
#endif
/******************* ISDUPREC.C *******************/

1300
cde/lib/DtSearch/jpn.c Normal file

File diff suppressed because it is too large Load Diff

1666
cde/lib/DtSearch/lang.c Normal file

File diff suppressed because it is too large Load Diff

636
cde/lib/DtSearch/langmap.c Normal file
View File

@@ -0,0 +1,636 @@
/*
* COMPONENT_NAME: austext
*
* FUNCTIONS: none
*
* ORIGINS: 27
*
*
* (C) COPYRIGHT International Business Machines Corp. 1996
* All Rights Reserved
* Licensed Materials - Property of IBM
* US Government Users Restricted Rights - Use, duplication or
* disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
*/
/******************** LANGMAP.C ********************
* $XConsortium: langmap.c /main/3 1996/05/07 13:38:58 drk $
* January 1996.
* Contains European single byte character maps for
* teskey parser and Paice/Porter stemmers.
* Formerly coded in lang.c.
*
* Contains two code pages: ascii and iso-latin-1.
* From F. N. Teskey (Principles of Text Processing, Elis Horwood Ltd,
* 1982), a word is "a finite sequence of concordable and optionally
* concordable characters delimited by either a nonconcordable character or an
* optionally concordable character adjacent to a nonconcordable or optionally
* concordable one." Optionally concordable characters are symbols like
* "./-" which may or may not occur within words (TCP/IP, file.dos, co-op).
* Concordable characters are alphas and numbers.
* Nonconcordables are whitespace, punctuation, control chars, etc.
*
* Lowest order byte = 'uppercase' of indexing char.
* Next higher order byte = mask for teskey parse bits.
*
* $Log$
* Revision 1.3 1996/03/13 22:58:28 miker
* Added prolog.
*
* Revision 1.2 1996/03/05 16:35:04 miker
* Changed usage of WHITESPACE to replace isspace() function calls.
*
* Revision 1.1 1996/02/01 19:15:52 miker
* Initial revision
*/
#include "SearchP.h"
/************************************************/
/* */
/* latin_charmap */
/* */
/************************************************/
/* Teskey character map for iso-latin-1 character set. */
int latin_charmap [] = {
NON_CONCORD | 0 /* NULL, Teskey EOT char */
,NON_CONCORD | 1 /* CTRL-A */
,NON_CONCORD | 2 /* CTRL-B */
,NON_CONCORD | 3 /* CTRL-C */
,NON_CONCORD | 4 /* CTRL-D */
,NON_CONCORD | 5 /* CTRL-E */
,NON_CONCORD | 6 /* CTRL-F */
,NON_CONCORD | 7 /* BEL \a */
,NON_CONCORD | 8 /* BS \b */
,NON_CONCORD | WHITESPACE | 9 /* TAB \t */
,NON_CONCORD | WHITESPACE | 10 /* LF \n */
,NON_CONCORD | WHITESPACE | 11 /* VT \v */
,NON_CONCORD | WHITESPACE | 12 /* FF \f */
,NON_CONCORD | WHITESPACE | 13 /* CR \r */
,NON_CONCORD | 14 /* CTRL-N */
,NON_CONCORD | 15 /* CTRL-O */
,NON_CONCORD | 16 /* CTRL-P */
,NON_CONCORD | 17 /* CTRL-Q */
,NON_CONCORD | 18 /* CTRL-R */
,NON_CONCORD | 19 /* CTRL-S */
,NON_CONCORD | 20 /* CTRL-T */
,NON_CONCORD | 21 /* CTRL-U */
,NON_CONCORD | 22 /* CTRL-V */
,NON_CONCORD | 23 /* CTRL-W */
,NON_CONCORD | 24 /* CTRL-X */
,NON_CONCORD | 25 /* CTRL-Y */
,NON_CONCORD | 26 /* CTRL-Z (EOF) */
,NON_CONCORD | 27 /* ESC */
,NON_CONCORD | 28
,NON_CONCORD | 29
,NON_CONCORD | 30
,NON_CONCORD | 31
,NON_CONCORD | WHITESPACE | 32 /* SPACE (blank) */
,NON_CONCORD | 33 /* ! */
,NON_CONCORD | 34 /* " */
,NON_CONCORD | 35 /* # */
,NON_CONCORD | 36 /* $ */
,NON_CONCORD | 37 /* % */
,NON_CONCORD | 38 /* & */
,NON_CONCORD | 39 /* ' (apostrophe) */
,NON_CONCORD | 40 /* ( */
,NON_CONCORD | 41 /* ) */
,NON_CONCORD | 42 /* * */
,NON_CONCORD | 43 /* + */
,NON_CONCORD | 44 /* , (comma) */
,OPT_CONCORD | 45 /* - (dash) */
,OPT_CONCORD | 46 /* . (period) */
,OPT_CONCORD | 47 /* / (slash) */
,CONCORDABLE | NUMERAL | 48 /* 0 */
,CONCORDABLE | NUMERAL | 49 /* 1 */
,CONCORDABLE | NUMERAL | 50 /* 2 */
,CONCORDABLE | NUMERAL | 51 /* 3 */
,CONCORDABLE | NUMERAL | 52 /* 4 */
,CONCORDABLE | NUMERAL | 53 /* 5 */
,CONCORDABLE | NUMERAL | 54 /* 6 */
,CONCORDABLE | NUMERAL | 55 /* 7 */
,CONCORDABLE | NUMERAL | 56 /* 8 */
,CONCORDABLE | NUMERAL | 57 /* 9 */
,NON_CONCORD | 58 /* : */
,NON_CONCORD | 59 /* ; */
,NON_CONCORD | 60 /* < */
,NON_CONCORD | 61 /* = */
,NON_CONCORD | 62 /* > */
,NON_CONCORD | 63 /* ? */
,NON_CONCORD | 64 /* @ */
,CONCORDABLE | VOWEL | 65 /* A */
,CONCORDABLE | CONSONANT | 66 /* B */
,CONCORDABLE | CONSONANT | 67 /* C */
,CONCORDABLE | CONSONANT | 68 /* D */
,CONCORDABLE | VOWEL | 69 /* E */
,CONCORDABLE | CONSONANT | 70 /* F */
,CONCORDABLE | CONSONANT | 71 /* G */
,CONCORDABLE | CONSONANT | 72 /* H */
,CONCORDABLE | VOWEL | 73 /* I */
,CONCORDABLE | CONSONANT | 74 /* J */
,CONCORDABLE | CONSONANT | 75 /* K */
,CONCORDABLE | CONSONANT | 76 /* L */
,CONCORDABLE | CONSONANT | 77 /* M */
,CONCORDABLE | CONSONANT | 78 /* N */
,CONCORDABLE | VOWEL | 79 /* O */
,CONCORDABLE | CONSONANT | 80 /* P */
,CONCORDABLE | CONSONANT | 81 /* Q */
,CONCORDABLE | CONSONANT | 82 /* R */
,CONCORDABLE | CONSONANT | 83 /* S */
,CONCORDABLE | CONSONANT | 84 /* T */
,CONCORDABLE | VOWEL | 85 /* U */
,CONCORDABLE | CONSONANT | 86 /* V */
,CONCORDABLE | CONSONANT | 87 /* W */
,CONCORDABLE | CONSONANT | 88 /* X */
,CONCORDABLE | CONSONANT | 89 /* Y */
,CONCORDABLE | CONSONANT | 90 /* Z */
,NON_CONCORD | 91 /* [ */
,NON_CONCORD | 92 /* \ (backslash) */
,NON_CONCORD | 93 /* ] */
,NON_CONCORD | 94 /* ^ */
,OPT_CONCORD | 95 /* _ (underscore) */
,NON_CONCORD | 96 /* ` (grave accent) */
,CONCORDABLE | VOWEL | 'A' /* 97 = lowercase a */
,CONCORDABLE | CONSONANT | 'B' /* 98 = lowercase b */
,CONCORDABLE | CONSONANT | 'C' /* 99 = lowercase c */
,CONCORDABLE | CONSONANT | 'D' /* 100 = lowercase d */
,CONCORDABLE | VOWEL | 'E' /* 101 = lowercase e */
,CONCORDABLE | CONSONANT | 'F' /* 102 = lowercase f */
,CONCORDABLE | CONSONANT | 'G' /* 103 = lowercase g */
,CONCORDABLE | CONSONANT | 'H' /* 104 = lowercase h */
,CONCORDABLE | VOWEL | 'I' /* 105 = lowercase i */
,CONCORDABLE | CONSONANT | 'J' /* 106 = lowercase j */
,CONCORDABLE | CONSONANT | 'K' /* 107 = lowercase k */
,CONCORDABLE | CONSONANT | 'L' /* 108 = lowercase l */
,CONCORDABLE | CONSONANT | 'M' /* 109 = lowercase m */
,CONCORDABLE | CONSONANT | 'N' /* 110 = lowercase n */
,CONCORDABLE | VOWEL | 'O' /* 111 = lowercase o */
,CONCORDABLE | CONSONANT | 'P' /* 112 = lowercase p */
,CONCORDABLE | CONSONANT | 'Q' /* 113 = lowercase q */
,CONCORDABLE | CONSONANT | 'R' /* 114 = lowercase r */
,CONCORDABLE | CONSONANT | 'S' /* 115 = lowercase s */
,CONCORDABLE | CONSONANT | 'T' /* 116 = lowercase t */
,CONCORDABLE | VOWEL | 'U' /* 117 = lowercase u */
,CONCORDABLE | CONSONANT | 'V' /* 118 = lowercase v */
,CONCORDABLE | CONSONANT | 'W' /* 119 = lowercase w */
,CONCORDABLE | CONSONANT | 'X' /* 120 = lowercase x */
,CONCORDABLE | CONSONANT | 'Y' /* 121 = lowercase y */
,CONCORDABLE | CONSONANT | 'Z' /* 122 = lowercase z */
,NON_CONCORD | 123 /* { */
,NON_CONCORD | 124 /* | (virgule, vertical line) */
,NON_CONCORD | 125 /* } */
,NON_CONCORD | 126 /* ~ */
,NON_CONCORD | 127 /* DEL */
,NON_CONCORD | 128
,NON_CONCORD | 129
,NON_CONCORD | 130
,NON_CONCORD | 131
,NON_CONCORD | 132
,NON_CONCORD | 133
,NON_CONCORD | 134
,NON_CONCORD | 135
,NON_CONCORD | 136
,NON_CONCORD | 137
,NON_CONCORD | 138
,NON_CONCORD | 139
,NON_CONCORD | 140
,NON_CONCORD | 141
,NON_CONCORD | 142
,NON_CONCORD | 143
,NON_CONCORD | 144
,NON_CONCORD | 145
,NON_CONCORD | 146
,NON_CONCORD | 147
,NON_CONCORD | 148
,NON_CONCORD | 149
,NON_CONCORD | 150
,NON_CONCORD | 151
,NON_CONCORD | 152
,NON_CONCORD | 153
,NON_CONCORD | 154
,NON_CONCORD | 155
,NON_CONCORD | 156
,NON_CONCORD | 157
,NON_CONCORD | 158
,NON_CONCORD | 159
,CONCORDABLE | 160 /* RSP, 'Reqd SPace' (nonbreak?) */
,NON_CONCORD | 161 /* inverted exclamation point */
,NON_CONCORD | 162 /* cent sign, C slash */
,NON_CONCORD | 163 /* pounds sterling */
,NON_CONCORD | 164 /* generic international currency */
,NON_CONCORD | 165 /* yen */
,NON_CONCORD | 166 /* broken vertical line */
,NON_CONCORD | 167 /* section/paragraph symbol */
,NON_CONCORD | 168 /* diaeresis-umlaut */
,NON_CONCORD | 169 /* copyright symbol, c circle */
,NON_CONCORD | 170 /* 'a' small superscript, feminine */
,NON_CONCORD | 171 /* left angle quotes */
,NON_CONCORD | 172 /* logical not, eol */
,CONCORDABLE | 173 /* SHY, 'Syllable HYphen' (nonbreak?) */
,NON_CONCORD | 174 /* registered trademark, r circle */
,NON_CONCORD | 175 /* overline */
,NON_CONCORD | 176 /* degree symbol, xB0 */
,NON_CONCORD | 177 /* plus-minus symbol */
,NON_CONCORD | 178 /* squared, '2' superscript */
,NON_CONCORD | 179 /* cubed, '3' superscript */
,NON_CONCORD | 180 /* acute accent */
,NON_CONCORD | 181 /* micro symbol (greek mu) */
,NON_CONCORD | 182 /* paragraph symbol */
,NON_CONCORD | 183 /* middle dot */
,NON_CONCORD | 184 /* cedilla */
,NON_CONCORD | 185 /* '1' superscript */
,NON_CONCORD | 186 /* 'o' small superscript, masculine */
,NON_CONCORD | 187 /* right angle quotes */
,NON_CONCORD | 188 /* one fourth */
,NON_CONCORD | 189 /* one half */
,NON_CONCORD | 190 /* three fourths */
,NON_CONCORD | 191 /* inverted question mark */
,CONCORDABLE | VOWEL | 192 /* uppercase 'A' grave accent, xC0 */
,CONCORDABLE | VOWEL | 193 /* uppercase 'A' acute accent */
,CONCORDABLE | VOWEL | 194 /* uppercase 'A' circumflex */
,CONCORDABLE | VOWEL | 195 /* uppercase 'A' tilde */
,CONCORDABLE | VOWEL | 196 /* uppercase 'A' diaeresis-umlaut */
,CONCORDABLE | VOWEL | 197 /* uppercase 'A' overcircle */
,CONCORDABLE | VOWEL | 198 /* uppercase 'AE' diphthong */
,CONCORDABLE | CONSONANT | 199 /* uppercase 'C' cedilla */
,CONCORDABLE | VOWEL | 200 /* uppercase 'E' grave accent */
,CONCORDABLE | VOWEL | 201 /* uppercase 'E' acute accent */
,CONCORDABLE | VOWEL | 202 /* uppercase 'E' circumflex */
,CONCORDABLE | VOWEL | 203 /* uppercase 'E' diaeresis-umlaut */
,CONCORDABLE | VOWEL | 204 /* uppercase 'I' grave accent */
,CONCORDABLE | VOWEL | 205 /* uppercase 'I' acute accent */
,CONCORDABLE | VOWEL | 206 /* uppercase 'I' circumflex */
,CONCORDABLE | VOWEL | 207 /* uppercase 'I' diaeresis-umlaut */
,CONCORDABLE | CONSONANT | 208 /* uppercase 'D' stroke (eth), xD0 */
,CONCORDABLE | CONSONANT | 209 /* uppercase 'N' tilde */
,CONCORDABLE | VOWEL | 210 /* uppercase 'O' grave accent */
,CONCORDABLE | VOWEL | 211 /* uppercase 'O' acute accent */
,CONCORDABLE | VOWEL | 212 /* uppercase 'O' circumflex */
,CONCORDABLE | VOWEL | 213 /* uppercase 'O' tilde */
,CONCORDABLE | VOWEL | 214 /* uppercase 'O' diaeresis-umlaut */
,NON_CONCORD | 215 /* multiply sign 'x' */
,CONCORDABLE | VOWEL | 216 /* uppercase 'O' slash */
,CONCORDABLE | VOWEL | 217 /* uppercase 'U' grave accent */
,CONCORDABLE | VOWEL | 218 /* uppercase 'U' acute accent */
,CONCORDABLE | VOWEL | 219 /* uppercase 'U' circumflex */
,CONCORDABLE | VOWEL | 220 /* uppercase 'U' diaeresis-umlaut */
,CONCORDABLE | VOWEL | 221 /* uppercase 'Y' acute accent */
,CONCORDABLE | CONSONANT | 222 /* uppercase Thorn (Iceland) */
,CONCORDABLE | CONSONANT | 223 /* lowercase s sharp (German ss) */
,CONCORDABLE | VOWEL | 192 /* 224, lcase 'a' grave accent, xE0 */
,CONCORDABLE | VOWEL | 193 /* lowercase 'a' acute accent */
,CONCORDABLE | VOWEL | 194 /* lowercase 'a' circumflex */
,CONCORDABLE | VOWEL | 195 /* lowercase 'a' tilde */
,CONCORDABLE | VOWEL | 196 /* lowercase 'a' diaeresis-umlaut */
,CONCORDABLE | VOWEL | 197 /* lowercase 'a' overcircle */
,CONCORDABLE | VOWEL | 198 /* lowercase 'ae' diphthong */
,CONCORDABLE | CONSONANT | 199 /* lowercase 'c' cedilla */
,CONCORDABLE | VOWEL | 200 /* 232, lowercase 'e' grave accent */
,CONCORDABLE | VOWEL | 201 /* lowercase 'e' acute accent */
,CONCORDABLE | VOWEL | 202 /* lowercase 'e' circumflex */
,CONCORDABLE | VOWEL | 203 /* lowercase 'e' diaeresis-umlaut */
,CONCORDABLE | VOWEL | 204 /* lowercase 'i' grave accent */
,CONCORDABLE | VOWEL | 205 /* lowercase 'i' acute accent */
,CONCORDABLE | VOWEL | 206 /* lowercase 'i' circumflex */
,CONCORDABLE | VOWEL | 207 /* lowercase 'i' diaeresis-umlaut */
,CONCORDABLE | CONSONANT | 208 /* 240, lcase 'd' stroke (eth), xF0 */
,CONCORDABLE | CONSONANT | 209 /* lowercase 'n' tilde */
,CONCORDABLE | VOWEL | 210 /* lowercase 'o' grave accent */
,CONCORDABLE | VOWEL | 211 /* lowercase 'o' acute accent */
,CONCORDABLE | VOWEL | 212 /* lowercase 'o' circumflex */
,CONCORDABLE | VOWEL | 213 /* lowercase 'o' tilde */
,CONCORDABLE | VOWEL | 214 /* lowercase 'o' diaeresis-umlaut */
,NON_CONCORD | 247 /* divide sign */
,CONCORDABLE | VOWEL | 216 /* 248, lowercase 'o' slash */
,CONCORDABLE | VOWEL | 217 /* lowercase 'u' grave accent */
,CONCORDABLE | VOWEL | 218 /* lowercase 'u' acute accent */
,CONCORDABLE | VOWEL | 219 /* lowercase 'u' circumflex */
,CONCORDABLE | VOWEL | 220 /* lowercase 'u' diaeresis-umlaut */
,CONCORDABLE | VOWEL | 221 /* lowercase 'y' acute accent */
,CONCORDABLE | CONSONANT | 222 /* lowercase thorn (Icelandic) */
,CONCORDABLE | CONSONANT | 255 /* lowercase 'y' diaeresis-umlaut */
,NON_CONCORD /* 256, an extra one... */
}; /* latin_charmap[] */
/************************************************/
/* */
/* ascii_charmap */
/* */
/************************************************/
/* Teskey character map for 7-bit ascii
* character set in 8-bit octets.
* Also accessed in packed EUC parsing in jpn.c.
*/
int ascii_charmap [] = {
NON_CONCORD | 0 /* NULL, Teskey EOT char */
,NON_CONCORD | 1 /* CTRL-A */
,NON_CONCORD | 2 /* CTRL-B */
,NON_CONCORD | 3 /* CTRL-C */
,NON_CONCORD | 4 /* CTRL-D */
,NON_CONCORD | 5 /* CTRL-E */
,NON_CONCORD | 6 /* CTRL-F */
,NON_CONCORD | 7 /* BEL \a */
,NON_CONCORD | 8 /* BS \b */
,NON_CONCORD | WHITESPACE | 9 /* TAB \t */
,NON_CONCORD | WHITESPACE | 10 /* LF \n */
,NON_CONCORD | WHITESPACE | 11 /* VT \v */
,NON_CONCORD | WHITESPACE | 12 /* FF \f */
,NON_CONCORD | WHITESPACE | 13 /* CR \r */
,NON_CONCORD | 14 /* CTRL-N */
,NON_CONCORD | 15 /* CTRL-O */
,NON_CONCORD | 16 /* CTRL-P */
,NON_CONCORD | 17 /* CTRL-Q */
,NON_CONCORD | 18 /* CTRL-R */
,NON_CONCORD | 19 /* CTRL-S */
,NON_CONCORD | 20 /* CTRL-T */
,NON_CONCORD | 21 /* CTRL-U */
,NON_CONCORD | 22 /* CTRL-V */
,NON_CONCORD | 23 /* CTRL-W */
,NON_CONCORD | 24 /* CTRL-X */
,NON_CONCORD | 25 /* CTRL-Y */
,NON_CONCORD | 26 /* CTRL-Z (EOF) */
,NON_CONCORD | 27 /* ESC */
,NON_CONCORD | 28
,NON_CONCORD | 29
,NON_CONCORD | 30
,NON_CONCORD | 31
,NON_CONCORD | WHITESPACE | 32 /* SPACE (blank) */
,NON_CONCORD | 33 /* ! */
,NON_CONCORD | 34 /* " */
,NON_CONCORD | 35 /* # */
,NON_CONCORD | 36 /* $ */
,NON_CONCORD | 37 /* % */
,NON_CONCORD | 38 /* & */
,NON_CONCORD | 39 /* ' (apostrophe) */
,NON_CONCORD | 40 /* ( */
,NON_CONCORD | 41 /* ) */
,NON_CONCORD | 42 /* * */
,NON_CONCORD | 43 /* + */
,NON_CONCORD | 44 /* , (comma) */
,OPT_CONCORD | 45 /* - (dash) */
,OPT_CONCORD | 46 /* . (period) */
,OPT_CONCORD | 47 /* / (slash) */
,CONCORDABLE | NUMERAL | 48 /* 0 */
,CONCORDABLE | NUMERAL | 49 /* 1 */
,CONCORDABLE | NUMERAL | 50 /* 2 */
,CONCORDABLE | NUMERAL | 51 /* 3 */
,CONCORDABLE | NUMERAL | 52 /* 4 */
,CONCORDABLE | NUMERAL | 53 /* 5 */
,CONCORDABLE | NUMERAL | 54 /* 6 */
,CONCORDABLE | NUMERAL | 55 /* 7 */
,CONCORDABLE | NUMERAL | 56 /* 8 */
,CONCORDABLE | NUMERAL | 57 /* 9 */
,NON_CONCORD | 58 /* : */
,NON_CONCORD | 59 /* ; */
,NON_CONCORD | 60 /* < */
,NON_CONCORD | 61 /* = */
,NON_CONCORD | 62 /* > */
,NON_CONCORD | 63 /* ? */
,NON_CONCORD | 64 /* @ */
,CONCORDABLE | VOWEL | 65 /* A */
,CONCORDABLE | CONSONANT | 66 /* B */
,CONCORDABLE | CONSONANT | 67 /* C */
,CONCORDABLE | CONSONANT | 68 /* D */
,CONCORDABLE | VOWEL | 69 /* E */
,CONCORDABLE | CONSONANT | 70 /* F */
,CONCORDABLE | CONSONANT | 71 /* G */
,CONCORDABLE | CONSONANT | 72 /* H */
,CONCORDABLE | VOWEL | 73 /* I */
,CONCORDABLE | CONSONANT | 74 /* J */
,CONCORDABLE | CONSONANT | 75 /* K */
,CONCORDABLE | CONSONANT | 76 /* L */
,CONCORDABLE | CONSONANT | 77 /* M */
,CONCORDABLE | CONSONANT | 78 /* N */
,CONCORDABLE | VOWEL | 79 /* O */
,CONCORDABLE | CONSONANT | 80 /* P */
,CONCORDABLE | CONSONANT | 81 /* Q */
,CONCORDABLE | CONSONANT | 82 /* R */
,CONCORDABLE | CONSONANT | 83 /* S */
,CONCORDABLE | CONSONANT | 84 /* T */
,CONCORDABLE | VOWEL | 85 /* U */
,CONCORDABLE | CONSONANT | 86 /* V */
,CONCORDABLE | CONSONANT | 87 /* W */
,CONCORDABLE | CONSONANT | 88 /* X */
,CONCORDABLE | CONSONANT | 89 /* Y */
,CONCORDABLE | CONSONANT | 90 /* Z */
,NON_CONCORD | 91 /* [ */
,NON_CONCORD | 92 /* \ (backslash) */
,NON_CONCORD | 93 /* ] */
,NON_CONCORD | 94 /* ^ */
,OPT_CONCORD | 95 /* _ (underscore) */
,NON_CONCORD | 96 /* ` (grave accent) */
,CONCORDABLE | VOWEL | 'A' /* 97 = lowercase a */
,CONCORDABLE | CONSONANT | 'B' /* 98 = lowercase b */
,CONCORDABLE | CONSONANT | 'C' /* 99 = lowercase c */
,CONCORDABLE | CONSONANT | 'D' /* 100 = lowercase d */
,CONCORDABLE | VOWEL | 'E' /* 101 = lowercase e */
,CONCORDABLE | CONSONANT | 'F' /* 102 = lowercase f */
,CONCORDABLE | CONSONANT | 'G' /* 103 = lowercase g */
,CONCORDABLE | CONSONANT | 'H' /* 104 = lowercase h */
,CONCORDABLE | VOWEL | 'I' /* 105 = lowercase i */
,CONCORDABLE | CONSONANT | 'J' /* 106 = lowercase j */
,CONCORDABLE | CONSONANT | 'K' /* 107 = lowercase k */
,CONCORDABLE | CONSONANT | 'L' /* 108 = lowercase l */
,CONCORDABLE | CONSONANT | 'M' /* 109 = lowercase m */
,CONCORDABLE | CONSONANT | 'N' /* 110 = lowercase n */
,CONCORDABLE | VOWEL | 'O' /* 111 = lowercase o */
,CONCORDABLE | CONSONANT | 'P' /* 112 = lowercase p */
,CONCORDABLE | CONSONANT | 'Q' /* 113 = lowercase q */
,CONCORDABLE | CONSONANT | 'R' /* 114 = lowercase r */
,CONCORDABLE | CONSONANT | 'S' /* 115 = lowercase s */
,CONCORDABLE | CONSONANT | 'T' /* 116 = lowercase t */
,CONCORDABLE | VOWEL | 'U' /* 117 = lowercase u */
,CONCORDABLE | CONSONANT | 'V' /* 118 = lowercase v */
,CONCORDABLE | CONSONANT | 'W' /* 119 = lowercase w */
,CONCORDABLE | CONSONANT | 'X' /* 120 = lowercase x */
,CONCORDABLE | CONSONANT | 'Y' /* 121 = lowercase y */
,CONCORDABLE | CONSONANT | 'Z' /* 122 = lowercase z */
,NON_CONCORD | 123 /* { */
,NON_CONCORD | 124 /* | (virgule, vertical line) */
,NON_CONCORD | 125 /* } */
,NON_CONCORD | 126 /* ~ */
,NON_CONCORD | 127 /* DEL */
,NON_CONCORD | 128
,NON_CONCORD | 129
,NON_CONCORD | 130
,NON_CONCORD | 131
,NON_CONCORD | 132
,NON_CONCORD | 133
,NON_CONCORD | 134
,NON_CONCORD | 135
,NON_CONCORD | 136
,NON_CONCORD | 137
,NON_CONCORD | 138
,NON_CONCORD | 139
,NON_CONCORD | 140
,NON_CONCORD | 141
,NON_CONCORD | 142
,NON_CONCORD | 143
,NON_CONCORD | 144
,NON_CONCORD | 145
,NON_CONCORD | 146
,NON_CONCORD | 147
,NON_CONCORD | 148
,NON_CONCORD | 149
,NON_CONCORD | 150
,NON_CONCORD | 151
,NON_CONCORD | 152
,NON_CONCORD | 153
,NON_CONCORD | 154
,NON_CONCORD | 155
,NON_CONCORD | 156
,NON_CONCORD | 157
,NON_CONCORD | 158
,NON_CONCORD | 159
,NON_CONCORD | 160
,NON_CONCORD | 161
,NON_CONCORD | 162
,NON_CONCORD | 163
,NON_CONCORD | 164
,NON_CONCORD | 165
,NON_CONCORD | 166
,NON_CONCORD | 167
,NON_CONCORD | 168
,NON_CONCORD | 169
,NON_CONCORD | 170
,NON_CONCORD | 171
,NON_CONCORD | 172
,NON_CONCORD | 173
,NON_CONCORD | 174
,NON_CONCORD | 175
,NON_CONCORD | 176
,NON_CONCORD | 177
,NON_CONCORD | 178
,NON_CONCORD | 179
,NON_CONCORD | 180
,NON_CONCORD | 181
,NON_CONCORD | 182
,NON_CONCORD | 183
,NON_CONCORD | 184
,NON_CONCORD | 185
,NON_CONCORD | 186
,NON_CONCORD | 187
,NON_CONCORD | 188
,NON_CONCORD | 189
,NON_CONCORD | 190
,NON_CONCORD | 191
,NON_CONCORD | 192
,NON_CONCORD | 193
,NON_CONCORD | 194
,NON_CONCORD | 195
,NON_CONCORD | 196
,NON_CONCORD | 197
,NON_CONCORD | 198
,NON_CONCORD | 199
,NON_CONCORD | 200
,NON_CONCORD | 201
,NON_CONCORD | 202
,NON_CONCORD | 203
,NON_CONCORD | 204
,NON_CONCORD | 205
,NON_CONCORD | 206
,NON_CONCORD | 207
,NON_CONCORD | 208
,NON_CONCORD | 209
,NON_CONCORD | 210
,NON_CONCORD | 211
,NON_CONCORD | 212
,NON_CONCORD | 213
,NON_CONCORD | 214
,NON_CONCORD | 215
,NON_CONCORD | 216
,NON_CONCORD | 217
,NON_CONCORD | 218
,NON_CONCORD | 219
,NON_CONCORD | 220
,NON_CONCORD | 221
,NON_CONCORD | 222
,NON_CONCORD | 223
,NON_CONCORD | 224
,NON_CONCORD | 225
,NON_CONCORD | 226
,NON_CONCORD | 227
,NON_CONCORD | 228
,NON_CONCORD | 229
,NON_CONCORD | 230
,NON_CONCORD | 231
,NON_CONCORD | 232
,NON_CONCORD | 233
,NON_CONCORD | 234
,NON_CONCORD | 235
,NON_CONCORD | 236
,NON_CONCORD | 237
,NON_CONCORD | 238
,NON_CONCORD | 239
,NON_CONCORD | 240
,NON_CONCORD | 241
,NON_CONCORD | 242
,NON_CONCORD | 243
,NON_CONCORD | 244
,NON_CONCORD | 245
,NON_CONCORD | 246
,NON_CONCORD | 247
,NON_CONCORD | 248
,NON_CONCORD | 249
,NON_CONCORD | 250
,NON_CONCORD | 251
,NON_CONCORD | 252
,NON_CONCORD | 253
,NON_CONCORD | 254
,NON_CONCORD | 255
,NON_CONCORD /* 256 = an extra one... */
}; /* ascii_charmap[] */
/******************** LANGMAP.C ********************/

View File

@@ -0,0 +1,444 @@
/* $TOG: libDtSearch.elist /main/4 1999/10/14 14:12:00 mgreess $ */
/*************************************************************************
* Export list for libDtSearch
* This list *must* be updated whenever a change is made to the library API.
*
* The syntax for the symbol declarations in this list is as follows:
* public sym => Public C symbol, i.e., publicized API
* private sym => Private C symbol, i.e., unpublicized API
* internal sym => Internal C symbol, i.e., not part of API
*
**************************************************************************/
/********************************************************************
* Public symbols -- available to everyone
********************************************************************/
public DtSearchAddMessage
public DtSearchAddUserExit
public DtSearchExit
public DtSearchFormatObjdate
public DtSearchFreeMessages
public DtSearchFreeResults
public DtSearchGetKeytypes
public DtSearchGetMaxResults
public DtSearchGetMessages
public DtSearchHasMessages
public DtSearchHighlight
public DtSearchInit
public DtSearchMergeResults
public DtSearchQuery
public DtSearchReinit
public DtSearchRemoveUserExit
public DtSearchRetrieve
public DtSearchSetMaxResults
public DtSearchSortResults
public DtSearchValidDateString
/********************************************************************
* Private symbols -- Undocumented APIs that are exported for B.C.
* or because privileged applications may need used them.
********************************************************************/
private ADDRcmp
private INTcmp
private OEF_audit
private OEF_discard
private OEF_news
private OEF_notesnot
private OEF_notessem
private OEF_readme
private OE_bmhtab_strlen
private OE_bmhtables
private OE_dbn
private OE_enable_markdel
private OE_enable_usernotes
private OE_expiration
private OE_fastdecode
private OE_fileio
private OE_flags
private OE_inittab_dir
private OE_objsize
private OE_prodname
private OE_prox_factor
private OE_search_type
private OE_server_dir
private OE_sitecnfg_fname
private OE_sitecnfg_mtime
private OE_uppercase_keys
private OE_words_hitlimit
private Opera_Engine
private aa_argv0
private aa_maxhits
private aa_stderr
private add_free_space
private add_syntax_errmsg
private alloc_table
private append_ext
private ascii_charmap
private ausapi_dbnamesc
private ausapi_dbnamesv
private ausapi_msglist
private austext_dopen
private austext_exit_comm
private austext_exit_dbms
private austext_exit_endwin
private austext_exit_first
private austext_exit_last
private austext_exit_mem
private austext_exit_user
private austext_malloc
private austools_catd
private batch_size
private bmhcore
private bmhtable_build
private bmstrstr
private boolyac_AND
private boolyac_COLLOC
private boolyac_NOT
private boolyac_OR
private check_dba
private clean_wrap
private clear_hitwords
private clear_usrblk_record
private compare_llist
private compat_dbd
private con_dbd
private con_dbf
private copy_final_truthtab
private crloc
private ctb_init
private ctbl_alloc
private ctbl_free
private cutnode_llist
private d_alloc
private d_calloc
private d_close
private d_cmtype
private d_connect
private d_cotype
private d_crget
private d_crread
private d_crset
private d_crtype
private d_crwrite
private d_csmget
private d_csmread
private d_csmset
private d_csmwrite
private d_csoget
private d_csoread
private d_csoset
private d_csowrite
private d_ctbpath
private d_dbdpath
private d_dbfpath
private d_dbuserid
private d_decode_dba
private d_delete
private d_destroy
private d_discon
private d_disdel
private d_encode_dba
private d_fillnew
private d_findco
private d_findfm
private d_findlm
private d_findnm
private d_findpm
private d_free
private d_initfile
private d_initialize
private d_ismember
private d_isowner
private d_keydel
private d_keyexist
private d_keyfind
private d_keyfrst
private d_keylast
private d_keynext
private d_keyprev
private d_keyread
private d_keystore
private d_makenew
private d_mapchar
private d_members
private d_off_opt
private d_on_opt
private d_open
private d_rdcurr
private d_recfrst
private d_reclast
private d_recnext
private d_recprev
private d_recread
private d_recset
private d_recwrite
private d_renfile
private d_rerdcurr
private d_setdb
private d_setfiles
private d_setkey
private d_setmm
private d_setmo
private d_setmr
private d_setom
private d_setoo
private d_setor
private d_setpages
private d_setrm
private d_setro
private d_wrcurr
private db_glob_init
private db_global
private db_oflag
private db_pgtab_sz
private db_status
private db_txtest
private dbautorec
private dberr
private dberr_exit
private dbn_check
private delete_whitespace
private dio_clear
private dio_close
private dio_clrfile
private dio_findpg
private dio_flush
private dio_free
private dio_get
private dio_init
private dio_open
private dio_out
private dio_pzalloc
private dio_pzclr
private dio_pzdel
private dio_pznext
private dio_pzread
private dio_read
private dio_release
private dio_setdef
private dio_touch
private dio_write
private discard_to_ETX
private dtsearch_catd
private dummy_workproc
private duprec_hashsize
private ensure_end_slash
private fillnew_wordrec
private final_truthtab
private find_free_space
private find_keyword
private fldcmp
private fread_d99_header
private free_llist
private fwrite_d99_header
private gen_vec
private gen_vec_hufid
private get_element
private get_hitlist_text
private global_memory_ptr
private hc_decode
private hc_encode
private hilite_cleartext
private init_header
private init_user_interrupt
private initdbt
private inittab
private is_compatible_version
private is_concordable
private is_duprec
private is_objdatestr
private is_objdatetm
private join_llists
private jpn_parser
private key_bldcom
private key_boundary
private key_close
private key_cmpcpy
private key_delete
private key_init
private key_insert
private key_locpos
private key_open
private key_reset
private key_scan
private largest_page
private latin_charmap
private ll_access
private ll_append
private ll_first
private ll_free
private ll_next
private ll_prepend
private load_custom_language
private load_jpn_language
private load_language
private load_ocf
private load_wordtree
private nfld_check
private nowstring
private nrec_check
private nset_check
private null_dba
private null_lstrupr
private null_stemmer
private objdate2fzkstr
private objdate2tm
private objdate_in_range
private oe_initialize
private oe_unblob
private oe_write_audit_rec
private oef_table
private old_no_of_dbs
private old_size_fd
private old_size_ft
private old_size_kt
private old_size_mt
private old_size_rt
private old_size_srt
private old_size_st
private open_b
private open_dblk
private parser_invalid_wordcount
private pop_llist
private print_dbrec
private print_dittolist
private print_stems
private print_usrblk_record
private qry_has_no_NOTs
private qry_is_all_ANDs
private r_chkfld
private r_clropt
private r_delrec
private r_gfld
private r_gmem
private r_gset
private r_pfld
private r_pmem
private r_pset
private r_setopt
private r_smem
private r_tstopt
private read_wordstr
private readchar_ftext
private readchar_string
private release_shm_mem
private renfiles
private replace_ext
private retncode_str
private saveusr
private shm_id
private shutdown_now
private size_compat
private sk_free
private sort_llist
private startup
private strupr
private swab_dbrec
private swab_objrec
private swab_page
private taskinit
private termfree
private teskey_parser
private tm2objdate
private trcommit
private unload_custom_language
private unload_language
private usrblk
private ve_append_notes
private ve_browse_dba
private ve_getblobs
private ve_getrec_dba
private ve_initialize
private ve_reckey2dba
private ve_shutdown
private ve_statistical
private vista_abort
private vista_msg
private write_wordstr
/********************************************************************
* Internal symbols -- not to be used outside the library.
********************************************************************/
internal Db_lookup
internal Dbpg_table
internal Used_files
internal aa_check_initialization
internal aa_getnews_flag
internal aa_is_initialized
internal boolean_parse
internal boolean_search
internal cnt_open_files
internal comp_stat
internal convert_str_2_char
internal database_has_changed
internal debugging_boolsrch
internal debugging_dbswab
internal debugging_dio_close
internal debugging_dio_init
internal debugging_dopen
internal debugging_inittab
internal debugging_jpn
internal debugging_key_swabs
internal debugging_loadlang
internal debugging_loadword
internal debugging_paice
internal debugging_search_wordtree
internal debugging_teskey
internal ditsort_type
internal dump_init_tables
internal efim_qsort
internal get_next_memory_block
internal hctree
internal hctree_id
internal hctree_name
internal hctree_root
internal init_memory
internal load_ditto_str
internal max_open_files
internal oe_uninitialize
internal process_char
internal save_init_switches
internal unload_jpn_language
internal user_interrupt
internal ve_delete
internal yychar
internal yydebug
internal yyerror
internal yylex
internal yynerrs
internal yyparse
#if defined(hpux)
internal yymaxdepth
#endif
#if defined(sun)
internal yy_yys
internal yy_yyv
internal yyact
internal yychk
internal yydef
internal yyerrflag
internal yyexca
internal yylval
internal yypact
internal yypgo
internal yyps
internal yypv
internal yyr1
internal yyr2
internal yys
internal yystate
internal yytmp
internal yyv
internal yyval
#endif

1347
cde/lib/DtSearch/mrclean.c Normal file

File diff suppressed because it is too large Load Diff

138
cde/lib/DtSearch/msgs.c Normal file
View File

@@ -0,0 +1,138 @@
/*
* COMPONENT_NAME: austext
*
* FUNCTIONS: DtSearchAddMessage
* DtSearchFreeMessages
* DtSearchGetMessages
* DtSearchHasMessages
*
* ORIGINS: 27
*
*
* (C) COPYRIGHT International Business Machines Corp. 1995
* All Rights Reserved
* Licensed Materials - Property of IBM
* US Government Users Restricted Rights - Use, duplication or
* disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
*/
/********************** MSGS.C *****************************
* $XConsortium: msgs.c /main/4 1996/05/07 13:40:27 drk $
* August 1995.
* Handles access to global ausapi_msglist for DtSearch.
*
* $Log$
* Revision 2.2 1995/10/26 14:35:04 miker
* Added prolog.
*
* Revision 2.1 1995/09/22 21:19:23 miker
* Freeze DtSearch 0.1, AusText 2.1.8
*/
#include "SearchP.h"
#define PROGNAME "MSGS"
/****************************************/
/* */
/* DtSearchHasMessages */
/* */
/****************************************/
int DtSearchHasMessages (void)
{ return (ausapi_msglist != NULL); }
/****************************************/
/* */
/* DtSearchFreeMessages */
/* */
/****************************************/
void DtSearchFreeMessages (void)
{ free_llist (&ausapi_msglist); }
/****************************************/
/* */
/* DtSearchAddMessage */
/* */
/****************************************/
/* Mallocs space for new message and appends copy of passed msg
* to end of global msglist. This function allocates memory
* for the messages--THE CALLER MUST FREE THE MESSAGES,
* preferably using DtSearchFreeMessages() (free_llist()).
* DtSearchAddMessage() was formerly called append_msglist() in msgutil.c.
*/
void DtSearchAddMessage (char *msg)
{
LLIST *new;
LLIST **pp;
new = austext_malloc (strlen(msg) + sizeof(LLIST) + 2,
PROGNAME"47", NULL);
new->link = NULL;
new->data = new + 1; /* hop over exactly 1 LLIST structure */
strcpy (new->data, msg);
for ( pp = &ausapi_msglist; *pp != NULL; pp = &((*pp)->link) ) ;
*pp = new;
return;
} /* DtSearchAddMessage() */
/****************************************/
/* */
/* DtSearchGetMessages */
/* */
/****************************************/
/* July 1994,
* DtSearchGetMessages was formerly flatmessages().
* Copies all msgs in ausapi_msglist into single, flat text buffer.
*/
char *DtSearchGetMessages (void)
{
char *targ, *src;
size_t totlen = 0L;
LLIST *llptr;
static char *flatbuf = NULL;
static size_t flatbufsz = 0L;
/* Since function is often used as an arg in printf,
* be sure to return something safe when there are no msgs.
*/
if (ausapi_msglist == NULL)
return "";
/* First Pass: Get the total length.
* including room for inserted \n's.
*/
for (llptr = ausapi_msglist; llptr != NULL; llptr = llptr->link)
totlen += strlen(llptr->data) + 2;
if (totlen > flatbufsz) {
if (flatbuf)
free (flatbuf);
flatbuf = austext_malloc (totlen + 4, PROGNAME"73", NULL);
flatbufsz = totlen;
}
/* Second Pass: Copy the messages into the flat buffer.
* Make sure there are no less than 2 \n's at end of each msg--
* one to terminate msg (it may already be in the original
* msg string) and an added one to separate from the next msg.
*/
targ = flatbuf;
for (llptr = ausapi_msglist; llptr != NULL; llptr = llptr->link) {
src = (char *) llptr->data;
while (*src != 0)
*targ++ = *src++;
*targ++ = '\n';
if (*(--src) != '\n')
*targ++ = '\n';
}
/* Overlay the last two \n so the whole string won't end.
* This prevents ugly spacing problems when function
* is used directly in information dialog boxes. It also
* means regular writes to stdout etc will usually have to
* insert their own final \n.
*/
targ[-2] = 0;
return flatbuf;
} /* DtSearchGetMessages() */
/********************** MSGS.C *****************************/

397
cde/lib/DtSearch/msgutil.c Normal file
View File

@@ -0,0 +1,397 @@
/*
* COMPONENT_NAME: austext
*
* FUNCTIONS: austext_malloc
* clean_wrap
* cutnode_llist
* free_llist
* join_llists
* merge_llist
* nowstring
* pop_llist
* sort_llist
* split_llist
*
* ORIGINS: 27
*
*
* (C) COPYRIGHT International Business Machines Corp. 1991,1995
* All Rights Reserved
* Licensed Materials - Property of IBM
* US Government Users Restricted Rights - Use, duplication or
* disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
*/
/*************************** MSGUTIL.C *************************
* $XConsortium: msgutil.c /main/9 1996/11/25 18:47:48 drk $
* August 1991.
* Utilites for generic manipulation of linked lists and binary trees.
* All utilities require that the link fields be the first fields
* in each structure. Also includes an error message mechanism
* that is absolutely independent of user interface (UI)--
* not even stdio is used. The trick is to append all
* error/information messages to the end of a linked list that
* eventually will be returned to the UI to be displayed
* in whatever manner is appropriate. (However a generic stdio
* print facility for the linked msglists is also provided
* for dumping the list before crashing or when stdio is ok).
*
* With 2 exceptions, all messages should contain only
* printable ascii characters and the space character.
* Control characters and extended ascii graphics chars are verboten.
* The exceptions are \n and \r, which are always permitted.
*
* The most common fatal error in opera and other text analysis
* systems occurs when a memory allocation fails. Therefore
* this module contains a generic 'safe malloc' function
* which tests for failure and prints all outstanding messages
* before exiting if malloc fails. It also uses DtSearchExit()
* for the actual abort so other system dependent stuff can be
* performed before going down.
*
* $Log$
* Revision 2.4 1996/03/05 17:58:29 miker
* Replace isspace() with ref to locale independent ascii_charmap[].
*
* Revision 2.3 1995/10/25 16:46:00 miker
* Added prolog.
*
* Revision 2.2 1995/10/19 20:58:05 miker
* Fix segfault in cleanwrap() if text contains single word > wraplen.
*
* Revision 2.1 1995/09/22 21:20:35 miker
* Freeze DtSearch 0.1, AusText 2.1.8
*
* Revision 1.8 1995/09/05 18:21:23 miker
* For DtSearch, rename and move universal msglist functions to msgs.c.
*/
#include "SearchP.h"
/****#include <ctype.h>****/
#include <string.h>
#include <stdlib.h>
#define XOS_USE_NO_LOCKING
#define X_INCLUDE_TIME_H
#include <X11/Xos_r.h>
#define PROGNAME "MSGUTIL"
#define MAX_LINELEN 77
#define MS_misc 1
CMPLL compare_llist = NULL; /* global function pointer */
/************************************************/
/* */
/* nowstring */
/* */
/************************************************/
/* Returns ptr to static string where the current time
* is formatted in human readable form. Used in audit
* records, debugging logs, and error messages.
*/
char *nowstring (time_t * now)
{
static char buf[128];
time_t mynow;
struct tm * time_ptr;
_Xltimeparams localtime_buf;
if (now == NULL) {
now = &mynow;
time (now);
}
time_ptr = _XLocaltime(now, localtime_buf);
strftime (buf, sizeof (buf),
catgets (dtsearch_catd, MS_misc, 2, "%Y/%m/%d,%H:%M:%S"),
time_ptr);
return buf;
} /* nowstring() */
/************************************************/
/* */
/* free_llist */
/* */
/************************************************/
/* Frees storage for all items in an LLIST and
* sets it top-of-list pointer to NULL. This works only for lists
* created by append_msglist, append_textblobs, and other LLIST
* structures where the data and the node itself
* are allocated in one call to malloc().
*/
void free_llist (LLIST ** llhead)
{
LLIST *next;
LLIST *ll = *llhead;
while (ll != NULL) {
next = ll->link;
free (ll);
ll = next;
}
*llhead = NULL;
return;
} /* free_llist() */
/************************************************/
/* */
/* join_llists */
/* */
/************************************************/
/* Merges two list by appending sublist to end of mainlist,
* then setting sublist to NULL. Originally either list can be NULL.
* Mainlist is represented by ptr to ptr so it can be modified if NULL.
* Sublist is ptr to ptr so it can be SET to NULL after join.
* Method:
* Init pp = ptr to first 'link' field in list,
* i.e. the ptr to a ptr passed by the caller.
* Usually this will be the addr of the top of the list pointer.
* Then advance it to point to the last link in the list.
*
* Note that this function works for any LLIST including those
* whose 'data' pointer is not allocated concurrently with the node.
*/
void join_llists (LLIST ** mainlist, LLIST ** sublist)
{
LLIST **pp;
for (pp = mainlist; *pp != NULL; pp = &((*pp)->link));
*pp = *sublist;
*sublist = NULL;
return;
} /* join_llists() */
/************************************************/
/* */
/* pop_llist */
/* */
/************************************************/
/* Detaches first node in an llist and returns it.
* If *llistp is empty return NULL, else set *llistp to the link
* cell of the first LLIST node on *llistp and return a pointer to
* the first LLIST node on *llistp. Used mainly by merge_llist(),
* which is itself called by sort_llist(), but can be called by
* anyone needing to remove the first element of an llist.
*/
LLIST *pop_llist (LLIST ** llistp)
{
LLIST *first_node = *llistp;
if (first_node != NULL)
*llistp = first_node->link;
return first_node;
} /* pop_llist() */
/************************************************/
/* */
/* cutnode_llist */
/* */
/************************************************/
/* Detaches any specified node in an llist and rejoins the
* loose ends of the llist. *llistp may become NULL.
* Returns NULL if *llistp is initially NULL or if node is not on llist,
* else returns the detached node.
*/
LLIST *cutnode_llist (LLIST * node, LLIST ** llistp)
{
LLIST **pp; /* link addr pointing to current node */
for (pp = llistp; *pp != NULL; pp = &((*pp)->link)) {
if (*pp == node)
break;
}
if (*pp == NULL)
return NULL;
*pp = node->link; /* join the loose ends */
return node;
} /* cutnode_llist() */
/************************************************/
/* */
/* split_llist */
/* */
/************************************************/
/* Subroutine of sort_llist().
* Find the middle node in lst. Set its 'link' pointer to NULL.
* Return the remainder of lst, i.e. a pointer to the
* next node after the middle node.
*/
static LLIST *split_llist (LLIST * lst)
{
LLIST *tail = lst->link;
if (lst == NULL || tail == NULL)
return lst;
/* advance 'tail' to end of list, and advance 'lst' only half as often */
while ((tail != NULL) && ((tail = tail->link) != NULL)) {
lst = lst->link;
tail = tail->link;
}
tail = lst->link;
lst->link = NULL;
return tail;
} /* split_llist() */
/************************************************/
/* */
/* merge_llist */
/* */
/************************************************/
/* Subroutine of sort_llist(). Merges two sorted LLISTs together. */
static LLIST *merge_llist (LLIST * l1, LLIST * l2)
{
LLIST *myqueue = NULL;
LLIST *myend = NULL;
LLIST *mynext;
while ((l1 != NULL) && (l2 != NULL)) {
/*
* Perform ENQUEUE function. Next item popped off a list is
* the next one in sorted order. It is added to END of
* myqueue to maintain order. THIS IS WHERE THE ACTUAL SORT
* COMPARE FUNCTION IS PERFORMED.
*/
mynext = (compare_llist (l1, l2) < 0) ?
pop_llist (&l1) : pop_llist (&l2);
mynext->link = NULL;
if (myqueue == NULL)
myqueue = mynext;
else
myend->link = mynext;
myend = mynext;
}
/* attach the remainder of whichever list is left to the end of queue */
if (l1 != NULL)
myend->link = l1;
if (l2 != NULL)
myend->link = l2;
return myqueue;
} /* merge_llist() */
/************************************************/
/* */
/* sort_llist */
/* */
/************************************************/
/* Sorts a list of LLIST structures and returns ptr to sorted list.
* The basic idea is to sort by recursively splitting a list
* into two equal halves and sorting each of those. The recursion
* ends when there are only two small lists which are either
* already sorted or are swapped. This sort rarely runs out
* of stack space because each recursion cuts the list length in
* half so there are at most 1 + log-N-to-the-base-2 items on the stack.
* (e.g. 64,000 nodes = max stack depth of 16: 2**16 = 64K).
*
* The compare function accepts pointers to two LLIST structures.
* It returns <0, =0, or >0 based on whether the first structure (left)
* is <, =, or > the second (right) structure in sort order.
* For efficiency's sake, a pointer to the compare function is placed
* in the global variable 'compare_llist' before calling
* sort_llist the first time, rather than continually
* passing it to all these nested functions.
*/
LLIST *sort_llist (LLIST * lst)
{
LLIST *lst2;
if ((lst == NULL) || (lst->link == NULL))
return lst;
lst2 = split_llist (lst);
return merge_llist (sort_llist (lst), sort_llist (lst2));
} /* sort_llist() */
/************************************************/
/* */
/* austext_malloc */
/* */
/************************************************/
/* 'location' may be NULL. Last arg (formerly msglist) is isgnored.
* Renamed from safe_malloc() to force compile errors if args not changed.
*/
void *austext_malloc (size_t size, char *location, void *ignore)
{
static void *ptr;
char *outofmem_msg;
if ((ptr = malloc (size)) != NULL)
return ptr;
ptr = ((aa_argv0) ? aa_argv0 : "");
if (location == NULL)
location = catgets (dtsearch_catd, MS_misc, 1, "<null>");
outofmem_msg = catgets (dtsearch_catd, MS_misc, 3,
"*** %sOut of Memory at %s asking for %lu bytes! ***\n");
fprintf (aa_stderr, outofmem_msg, ptr, location, size);
fflush (aa_stderr);
if (ausapi_msglist)
fprintf (aa_stderr, "%s\n", DtSearchGetMessages ());
fflush (aa_stderr);
DtSearchExit (43);
return NULL;
} /* austext_malloc */
/************************************************/
/* */
/* clean_wrap */
/* */
/************************************************/
/* Utility which provides a way of breaking up long
* messages which contain no control characters into lines
* whose linefeed breaks occur at even word boundaries,
* and whose lengths are controlled by the caller.
* It should only be called when text itself may be
* modified and may safely contain a linefeed (ascii 0x0A).
* Converts a long text string into several lines by overlaying
* the whitespace char nearest to the end of every line with \n.
* Restarts length count if \n is found already within string.
* Does nothing if passed wrap length = 0.
* Does not append \n to end of string. Does not alter string length.
* Returns total number of lines (\n's + trailing piece of last line),
* or returns 0 if wraplen == 0.
*/
int clean_wrap (char *string, int wraplen)
{
char *nlptr, *breakptr;
int linecount = 0;
if (wraplen <= 0)
return 0;
while (strlen (string) > wraplen) {
breakptr = string + wraplen;
/* Look for \n within the next wraplen */
for (nlptr = string; nlptr < breakptr; nlptr++)
if (*nlptr == '\n')
break;
if (nlptr < breakptr) {
string = ++nlptr;
goto LINE_DONE;
}
/* Otherwise back up to the first whitespace before last word */
for (nlptr = breakptr - 1; nlptr > string; nlptr--)
if (ascii_charmap[*nlptr] & WHITESPACE) {
*nlptr = '\n';
string = ++nlptr;
goto LINE_DONE;
}
/* No whitespace at all in "text" before wraplen!
* No choice but to overlay the last char.
*/
*(--breakptr) = '\n';
string = ++breakptr;
LINE_DONE:
linecount++;
}
/* Done wrapping. now just count remaining lines in string. */
while (*string != 0)
if (*string++ == '\n')
linecount++;
if (*(string - 1) != '\n')
linecount++;
return linecount;
} /* clean_wrap() */
/********************** MSGUTIL.C *************************/

264
cde/lib/DtSearch/objdate.c Normal file
View File

@@ -0,0 +1,264 @@
/*
* COMPONENT_NAME: austext
*
* FUNCTIONS: is_objdatestr
* is_objdatetm
* objdate2fzkstr
* objdate2tm
* objdate_in_range
* tm2objdate
*
* ORIGINS: 27
*
*
* (C) COPYRIGHT International Business Machines Corp. 1994,1995
* All Rights Reserved
* Licensed Materials - Property of IBM
* US Government Users Restricted Rights - Use, duplication or
* disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
*/
/*************************** OBJDATE.C *************************
* $XConsortium: objdate.c /main/8 1996/11/21 19:51:44 drk $
* November 1994.
* Utilites for generic manipulation of austext objdates.
* Most of these functions were originally in msgutil.c
*
* $Log$
* Revision 2.5 1996/03/05 18:00:36 miker
* Replaced hardcoded strings with refs to NULLDATESTR.
*
* Revision 2.4 1996/02/13 16:44:40 miker
* Allow \n to terminate null date string in is_objdatestr.
*
* Revision 2.3 1995/10/25 16:38:10 miker
* Added prolog.
*
* Revision 2.2 1995/10/02 20:37:30 miker
* Cosmetic cleanup only.
*
* Revision 2.1 1995/09/22 21:25:35 miker
* Freeze DtSearch 0.1, AusText 2.1.8
*
* Revision 1.3 1995/09/05 18:24:09 miker
* Remove refs to usrblk so objdate can be used in offline programs.
* Name changes for DtSearch.
*/
#include "SearchP.h"
#define X_INCLUDE_STRING_H
#define XOS_USE_NO_LOCKING
#include <X11/Xos_r.h>
#define PROGNAME "OBJDATE"
/************************************************/
/* */
/* is_objdatestr */
/* */
/************************************************/
/* Converts OBJDATESTR formatted string as found in .fzk files
* to DtSrObjdate long integer if string is valid.
* Returns TRUE if passed string is correctly formatted
* and conversion successful. Returns FALSE and
* does not alter passed objdate if string is not valid.
* String format is: "yy/mm/dd~hh:mm[\n]" (see OBJDATESTR in SearchP.h).
* The slashes and tilde are mandatory, the final \n is optional.
* Each field maps to an objdate bitfield; bitfields map
* to struct tm fields (see fuzzy.h).
* Can be used merely to test for valid string format by
* passing NULL for objdate pointer.
*/
int is_objdatestr (char *string, DtSrObjdate *objdptr)
{
static char parsebuf[24];
int i;
char *token;
DtSrObjdate myobjdate = 0L;
_Xstrtokparams strtok_buf;
/* Test for "null" objdate (which is valid) */
if (strncmp (string, NULLDATESTR, 9) == 0) {
if (string[9] == 0 || string[9] == '\n') {
if (objdptr)
*objdptr = 0L;
return TRUE;
}
}
strncpy (parsebuf, string, sizeof (parsebuf));
parsebuf[sizeof (parsebuf) - 1] = '\0';
if ((token = _XStrtok(parsebuf, "/", strtok_buf)) == NULL)
return FALSE;
i = atoi (token);
if (i < 1 || i > 4095) /* yy */
return FALSE;
else
myobjdate |= (i << 20);
if ((token = _XStrtok(NULL, "/", strtok_buf)) == NULL)
return FALSE;
i = atoi (token);
if (i < 1 || i > 12) /* mm */
return FALSE;
else
myobjdate |= (--i << 16);
if ((token = _XStrtok(NULL, "~", strtok_buf)) == NULL)
return FALSE;
i = atoi (token);
if (i < 1 || i > 31) /* dd */
return FALSE;
else
myobjdate |= (i << 11);
if ((token = _XStrtok(NULL, ":", strtok_buf)) == NULL)
return FALSE;
i = atoi (token);
if (i < 0 || i > 23) /* hh */
return FALSE;
else
myobjdate |= (i << 6);
if ((token = _XStrtok(NULL, "\n", strtok_buf)) == NULL)
return FALSE;
i = atoi (token);
if (i < 0 || i > 59) /* mm */
return FALSE;
else
myobjdate |= i;
if (objdptr)
*objdptr = myobjdate;
return TRUE;
} /* is_objdatestr() */
/************************************************/
/* */
/* is_objdatetm */
/* */
/************************************************/
/* Returns TRUE if passed structure is correctly formatted
* for conversion to DtSrObjdate variable, else returns FALSE.
*/
int is_objdatetm (struct tm *objdatetm)
{
if (objdatetm->tm_year < 0)
return FALSE;
if (objdatetm->tm_year > 4095)
return FALSE;
if (objdatetm->tm_mon < 0)
return FALSE;
if (objdatetm->tm_mon > 11)
return FALSE;
if (objdatetm->tm_mday < 1)
return FALSE;
if (objdatetm->tm_mday > 31)
return FALSE;
if (objdatetm->tm_hour < 0)
return FALSE;
if (objdatetm->tm_hour > 23)
return FALSE;
if (objdatetm->tm_min < 0)
return FALSE;
if (objdatetm->tm_min > 59)
return FALSE;
return TRUE;
} /* is_objdatetm() */
/************************************************/
/* */
/* objdate2tm */
/* */
/************************************************/
/* Converts DtSrObjdate formatted long int and returns
* pointer to static, standard unix tm structure.
* Bitfields map to struct tm fields (see fuzzy.h).
* The output tm structure is suitable for mktime(),
* but may only work for some formats of strftime().
*/
struct tm *objdate2tm (DtSrObjdate objdate)
{
static struct tm mytm;
memset (&mytm, 0, sizeof (struct tm));
mytm.tm_year = objdate >> 20;
mytm.tm_mon = (objdate >> 16) & 0xf;
mytm.tm_mday = (objdate >> 11) & 0x1f;
mytm.tm_hour = (objdate >> 6) & 0x1f;
mytm.tm_min = objdate & 0x3f;
mytm.tm_isdst = -1;
return &mytm;
} /* objdate2tm() */
/************************************************/
/* */
/* objdate2fzkstr */
/* */
/************************************************/
/* Converts DtSrObjdate formatted long int and returns pointer
* to static date string in .fzk format for debugging.
*/
char *objdate2fzkstr (DtSrObjdate objdate)
{
struct tm *tmptr;
static char strbuf[36];
if (objdate == 0L)
return NULLDATESTR;
tmptr = objdate2tm (objdate);
sprintf (strbuf, OBJDATESTR,
tmptr->tm_year, tmptr->tm_mon + 1,
tmptr->tm_mday, tmptr->tm_hour, tmptr->tm_min);
return strbuf;
} /* objdate2fzkstr() */
/************************************************/
/* */
/* tm2objdate */
/* */
/************************************************/
/* Converts specific fields in a tm structure to
* an DtSrObjdate formatted long int and returns it.
* DtSrObjdate bitfields map to struct tm fields (see fuzzy.h).
* Does not validate tm fields (use is_objdate() to confirm).
*/
DtSrObjdate tm2objdate (struct tm *tmptr)
{
return ((tmptr->tm_year << 20) |
(tmptr->tm_mon << 16) |
(tmptr->tm_mday << 11) |
(tmptr->tm_hour << 6) |
tmptr->tm_min);
} /* tm2objdate() */
/************************************************/
/* */
/* objdate_in_range */
/* */
/************************************************/
/* Returns TRUE if passed record objdate (presumably read from
* an austext record) is within the objdate ranges specified
* in usrblk. Returns FALSE if record is in any way disqualified
* from inclusion on a hitlist because of date.
* Zero in any of the three dates is automatic "in range" qualification.
*/
int objdate_in_range (
DtSrObjdate recdate,
DtSrObjdate date1,
DtSrObjdate date2)
{
if (recdate == 0L) /* Null dated record always qualifies */
return TRUE;
if (date1 != 0L && date1 > recdate)
return FALSE;
if (date2 != 0L && date2 < recdate)
return FALSE;
return TRUE;
} /* objdate_in_range() */
/********************** OBJDATE.C *************************/

1165
cde/lib/DtSearch/ocf.c Normal file

File diff suppressed because it is too large Load Diff

619
cde/lib/DtSearch/oekwic.c Normal file
View File

@@ -0,0 +1,619 @@
/*
* COMPONENT_NAME: austext
*
* FUNCTIONS: findstr_workproc
* kwic_workproc
* make_one_kwic
* oe_ditto2kwic
* oe_findstr_hitl
* restore_findstr_hitl
*
* ORIGINS: 27
*
* IBM CONFIDENTIAL -- (IBM Confidential Restricted when
* combined with the aggregated modules for this product)
* OBJECT CODE ONLY SOURCE MATERIALS
*
* (C) COPYRIGHT International Business Machines Corp. 1992,1995
* All Rights Reserved
* US Government Users Restricted Rights - Use, duplication or
* disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
*/
/******************************* OEKWIC.C ********************************
* $XConsortium: oekwic.c /main/4 1996/05/07 13:42:36 drk $
* April 1992.
* Opera Engine (OE) functions that create KeyWord In Context (KWIC)
* abstracts to replace database abstract when requested by user.
* KWIC abstract is a string extracted
* from the cleartext where the first hitword appears.
* Also includes find-string functions which use similar logic.
* Also includes a few generic OE utilities.
*
* $Log$
* Revision 1.6 1995/09/05 19:02:02 miker
* Made usrblk universal global. Deleted refs to socblk.
* Other minor name and function changes for DtSearch.
*
*/
#include "SearchE.h"
#include <ctype.h>
/******#define DEBUG_KWIC*********/
/********#define DEBUG_FINDSTR_ITER***********/
/******#define DEBUG_FINDSTR********/
#define PROGNAME "OEKWIC"
#define START_KWIC_ITERATIONS 10
#define START_FINDSTR_ITERATIONS 10
#define MIN_KWIC_ITERATIONS 2
#define MIN_FINDSTR_ITERATIONS 2
#define MIN_KWIC_BUFSZ 20
static int found_one_substring = FALSE;
/************************************************/
/* */
/* make_one_kwic */
/* */
/************************************************/
/* Builds abstract for record in usrblk.cleartext to
* KWIC string where first word/substring in
* usrblk.hitwords array is in center of abstract string.
* Returns new abstract in passed buffer (in a ditto list).
* General format of new abstract is: "...text <<word>> text...".
*/
static void make_one_kwic (char *abstract)
{
char c;
int i;
long from; /* offset from beginning of cleartext */
int abstrsz;
char *to, *lastto;
abstrsz = usrblk.dblk->dbrec.or_abstrsz;
if (usrblk.kwiclen > 0 && usrblk.kwiclen < abstrsz)
abstrsz = usrblk.kwiclen;
to = abstract;
lastto = to + abstrsz - 2;
/* No hitwords to abstract */
if (usrblk.hitwcount <= 0L)
return;
/* Find beginning of 'from' string */
from = usrblk.hitwords[0].offset -
((abstrsz - usrblk.hitwords[0].length - 14) >> 1L);
if (from < 0L) from = 0L;
/* If abstract doesnt begin at start of cleartext, print ellipsis */
if (from != 0L) for (i=3; i>0; i--)
*to++ = '.';
/* Move text up to the start of the word.
* Replace cntrl chars with single space.
*/
while (from < usrblk.hitwords[0].offset)
{
c = usrblk.cleartext [from++];
*to++ = (iscntrl(c))? ' ' : c;
}
/* Move the word itself, hilited with angle brackets */
for (i=2; i>0; i--)
*to++ = '<';
for (i=0; i<usrblk.hitwords[0].length; i++)
*to++ = usrblk.cleartext [from++];
for (i=2; i>0; i--)
*to++ = '>';
/* Move text beyond the word until end of input or end of abstract buffer */
while (from < usrblk.clearlen && to < lastto - 4)
{
c = usrblk.cleartext [from++];
*to++ = (iscntrl(c))? ' ' : c;
}
/* If not end of input, print another ellipsis */
if (from < usrblk.clearlen) for (i=3; i>0; i--) *to++ = '.';
*to = '\0';
#ifdef DEBUG_KWIC
printf("%s\n", abstract);
#endif
return;
} /* make_one_kwic() */
/************************************************/
/* */
/* oe_ditto2kwic */
/* */
/************************************************/
/* Converts all abstracts in dittolist to KWIC strings */
void oe_ditto2kwic (void)
{
void kwic_workproc (void);
int search_type = usrblk.search_type;
/* First validate the input fields in usrblk */
if (usrblk.dittocount <= 0L || usrblk.stemcount <= 0)
{
usrblk.retncode = OE_BAD_QUERY;
return;
}
/* Set up various global variables for calls to oe_stems_to_hitwords().
* Only an exact words search (search_type == 'W') does not require
* stemming. Statistical, semantic and exact stems searches
* do require stemming.
*/
OE_kind_of_stems = (search_type == 'W') ? WORD_KIND : STEM_KIND;
/* Initialize where user loop status maintained between workproc calls */
saveusr.dittolist = usrblk.dittolist;
saveusr.iterations = START_KWIC_ITERATIONS;
/* Call the work procedure that traverses the entire dittolist.
* If NO_ITERATE is specified, it will run to completion.
* Otherwise it will run just its first set of iterations,
* move its own address into usrblk.workproc, then return.
* Until workproc/mainloop is done, the static variable 'saveusr.dittolist'
* will always indicate where the last execution of the loop ended.
*/
usrblk.flags &= ~USR_STOPSRCH; /* init stop button to OFF */
kwic_workproc(); /* work proc will set retncode */
return;
} /* oe_ditto2kwic() */
/************************************************/
/* */
/* kwic_workproc */
/* */
/************************************************/
/* called repeatedly to convert abstracts in dittolist to KWIC strings */
void kwic_workproc (void)
{
int iter;
int entire_list_done;
time_t start_time;
double time_dif;
DtSrResult *dit;
LLIST *bloblist;
char sprintbuf[256];
/* test whether user has pushed STOP button since last call */
if (usrblk.flags & USR_STOPSRCH)
{
usrblk.retncode = OE_USER_STOP;
return;
}
#ifdef DEBUG_KWIC
printf ("\nSTART ITERATIONS = %d\n", saveusr.iterations);
#endif
/* initialize the loop */
dit = saveusr.dittolist;
entire_list_done = FALSE;
time (&start_time);
/* Traverse entire dittolist. Unblob each record,
* create a hitword list, then use it to convert abstract.
*/
for (iter = saveusr.iterations; iter > 0; )
{
/* Set usrblk.dblk ptr to correct database for curr ditto node */
if (dbn_to_dblk (dit->dbn))
saveusr.vistano = usrblk.dblk->vistano;
else
{
usrblk.retncode = OE_NOTAVAIL;
return;
}
/* If this record's database has too small an
* abstract buffer, just skip the conversion.
*/
if (usrblk.dblk->dbrec.or_abstrsz < MIN_KWIC_BUFSZ)
goto NEXT_DIT;
/* Skip any records which do not have blobs. */
if (usrblk.dblk->dbrec.or_dbaccess != ORA_BLOB)
goto NEXT_DIT;
if ((bloblist = ve_getblobs (dit->dba, saveusr.vistano)) == NULL)
{
sprintf (sprintbuf, PROGNAME"149 "
"Corrupted database address on hitlist. "
"Erroneous record: '%s' in database '%s'.",
dit->reckey, usrblk.dblk->label);
DtSearchAddMessage (sprintbuf);
usrblk.retncode = OE_NOTAVAIL;
return;
}
usrblk.retncode = oe_unblob (bloblist, FALSE);
if (usrblk.retncode != OE_OK)
{
sprintf (sprintbuf, PROGNAME"213 "
"Erroneous record: '%s' in database '%s'.",
dit->reckey, usrblk.dblk->label);
DtSearchAddMessage (sprintbuf);
return;
}
if (!oe_stems_to_hitwords (1))
return;
make_one_kwic (dit->abstractp);
/* Increment ditto pointer. Check for end of dittolist. */
NEXT_DIT:
if ((dit = dit->link) == NULL)
{
entire_list_done = TRUE;
break;
}
/* Decrement iteration counter unless user said not to */
if (!(usrblk.flags & USR_NO_ITERATE))
iter--;
} /* end iteration loop */
if (usrblk.debug & (USRDBG_SRCHCMPL | USRDBG_HITLIST))
print_dittolist (saveusr.dittolist, PROGNAME"888");
/* End of current set of iterations.
* If main loop is not completed,
* adjust number of iterations to about 1 second,
* save current status, and return to caller.
*/
if (!entire_list_done)
{
time_dif = difftime (time(NULL), start_time);
if (time_dif < 1.)
saveusr.iterations = (float) saveusr.iterations * 1.5;
else if (time_dif > 1.)
saveusr.iterations = (double) saveusr.iterations / time_dif;
if (saveusr.iterations < MIN_KWIC_ITERATIONS)
saveusr.iterations = MIN_KWIC_ITERATIONS;
#ifdef DEBUG_KWIC
printf ("\nEND ITERATIONS = %d, time_dif = %lf\n",
saveusr.iterations, time_dif);
#endif
saveusr.dittolist = dit; /* temp save curr loc in usrblk.dittolist */
usrblk.workproc = kwic_workproc;
usrblk.retncode = OE_SEARCHING;
return;
} /* endif where we are still searching */
/* Unless user specified no_iterate, calling program should always
* reset workproc to NULL. Dummy_workproc just appends an
* error message to notify programmer of his problem.
*/
if (!(usrblk.flags & USR_NO_ITERATE))
usrblk.workproc = dummy_workproc;
usrblk.retncode = OE_OK;
return;
} /* kwic_workproc() */
/************************************************/
/* */
/* oe_findstr_hitl */
/* */
/************************************************/
/* Reduces dittolist to the subset of records that
* contain string in query, and converts their
* abstracts to a KWIC-like string.
*/
void oe_findstr_hitl (void)
{
void findstr_workproc (void);
char *ptr, *ptr2;
char msgbuf [256];
/* Validate input fields */
if (usrblk.query == NULL || usrblk.query[0] == '\0')
{
usrblk.retncode = OE_BAD_QUERY;
return;
}
if (strlen(usrblk.query) >= DtSrMAXWIDTH_HWORD)
{
sprintf (msgbuf, PROGNAME"516 "
"No more than %d characters are allowed in the search string.",
DtSrMAXWIDTH_HWORD - 1);
DtSearchAddMessage (msgbuf);
usrblk.retncode = OE_BAD_QUERY;
return;
}
if (usrblk.dittocount <= 0 || usrblk.dittolist == NULL)
{
DtSearchAddMessage (PROGNAME"317 Hitlist empty. Nothing to search.");
usrblk.retncode = OE_BAD_HITLIST;
return;
}
/* Save stems array so we can restore it later,
* then copy the query to it for use by oe_stems_to_hitwords call.
* Convert to uppercase as we copy.
*/
saveusr.stemcount = usrblk.stemcount;
memcpy (saveusr.stems, usrblk.stems,
(size_t) (usrblk.stemcount * DtSrMAXWIDTH_HWORD));
usrblk.stemcount = 1;
ptr = usrblk.stems[0]; /* target */
ptr2 = usrblk.query; /* source */
while (*ptr2 != 0)
*ptr++ = toupper(*ptr2++);
*ptr = 0;
OE_kind_of_stems = STRING_KIND;
/* initialize saveusr loop status stuff maintained between workproc calls */
saveusr.vistano = usrblk.dblk->vistano;
saveusr.iterations = START_FINDSTR_ITERATIONS;
saveusr.dittolist = usrblk.dittolist; /* curr start of each iteration */
saveusr.dittocount = 0; /* number of records containing substring */
/* Call the work procedure that traverses the entire dittolist.
* If NO_ITERATE is specified, it will run to completion.
* Otherwise it will run just its first set of iterations,
* move its own address into usrblk.workproc, then return.
* Until workproc/mainloop is done, the static variable 'saveusr.dittolist'
* will always indicate where the last execution of the loop ended.
* The ditto node for each record which is found to contain
* the string will be removed from dittolist and added to newditlist.
*/
usrblk.flags &= ~USR_STOPSRCH; /* init stop button to OFF */
found_one_substring = FALSE; /* init HIT indicator */
findstr_workproc(); /* work proc will set retncode */
return;
} /* oe_findstr_hitl() */
/************************************************/
/* */
/* restore_findstr_hitl */
/* */
/************************************************/
/* Each time the find-string workproc detected the search
* string in a ditto node, it converted its abstract.
* Other nodes were just marked for deletion.
* When the entire dittolist has been traversed,
* or if the user pushes the stop button to stop traversal,
* this cleanup function is called to delete those nodes that
* were marked for deletion. However if NO records were
* ever found containing the string, nothing is deleted and
* the hitlist is restored as it was prior to the beginning of the search.
* The hitwords array is always blown away but the stems
* array is always restored no matter what.
*/
static void restore_findstr_hitl (void)
{
DtSrResult *dit, *nextdit;
DtSrResult **lastlink;
long newdittocount = 0L;
/* If the string was ever found in any record,
* delete all nonhits up to the last successful find.
*/
#ifdef DEBUG_FINDSTR
printf ("\nRESTORE FINDSTR: totnumhits = %ld\n", saveusr.dittocount);
#endif
if (saveusr.dittocount > 0)
{
dit = usrblk.dittolist;
lastlink = &usrblk.dittolist;
while (dit != NULL)
{
/* On a hit, advance the pointers, advance new dittocount.
* Break the loop on the last hit.
*/
if (dit->flags & DIT_FINDSTR)
{
#ifdef DEBUG_FINDSTR
printf ("#%ld HIT %s, \"%s\"\n", newdittocount+1,
dit->reckey, dit->abstract);
#endif
lastlink = &dit->link;
dit = dit->link;
if (++newdittocount >= saveusr.dittocount)
break;
}
/* If this was NOT a hit, delete node,
* and link up loose ends.
*/
else
{
#ifdef DEBUG_FINDSTR
printf ("RESTORE DELETING %s\n", dit->reckey);
#endif
nextdit = dit->link;
free (dit);
*lastlink = nextdit;
dit = nextdit;
}
}
/* At this point, we've cleaned up the list
* down to the last hit, or to its end.
* Keep deleting until end of list, or user's stop point.
*/
while (dit != NULL)
{
if (!(usrblk.flags & USR_STOPSRCH) /* never stopped */
|| !(dit->flags & DIT_STOP)) /* stopped somewhere ahead */
{
#ifdef DEBUG_FINDSTR
printf ("PAST LAST HIT, DELETING %s\n", dit->reckey);
#endif
nextdit = dit->link;
free (dit);
*lastlink = nextdit;
dit = nextdit;
}
else
{
break; /* user stopped at this exact node */
}
}
/* If there's anything left on the list,
* its because user stopped the search here.
* Just count the remaining records for the final tally.
*/
while (dit != NULL)
{
newdittocount++;
#ifdef DEBUG_FINDSTR
printf ("#%ld SAVING AFTER STOP %s\n", newdittocount, dit->reckey);
#endif
dit = dit->link;
}
usrblk.dittocount = newdittocount;
} /* endif where at least one record had a string hit */
/* restore the original stems array */
usrblk.stemcount = saveusr.stemcount;
memcpy (usrblk.stems, saveusr.stems,
(size_t) (saveusr.stemcount * DtSrMAXWIDTH_HWORD));
#ifdef DEBUG_FINDSTR
printf ("LEAVING RESTORE now real dittocount = %ld, stemcount = %d\n"
" first stem = '%s'\n", usrblk.dittocount,
usrblk.stemcount, usrblk.stems[0]);
#endif
return;
} /* restore_findstr_hitl() */
/************************************************/
/* */
/* findstr_workproc */
/* */
/************************************************/
/* Called repeatedly to search for character substrings in records
* on the hitlist, and convert their abstracts to KWIC strings.
*/
void findstr_workproc (void)
{
int iter;
int entire_list_done;
time_t start_time;
double time_dif;
DtSrResult *dit, *cutdit;
LLIST *bloblist;
/* Test whether user has pushed STOP button since last call.
* The DIT_STOP marks where the search ended for restore_findstr_hitl().
*/
if (usrblk.flags & USR_STOPSRCH)
{
saveusr.dittolist->flags |= DIT_STOP;
usrblk.retncode = (found_one_substring)? OE_OK : OE_USER_STOP;
restore_findstr_hitl();
return;
}
#ifdef DEBUG_FINDSTR_ITER
printf ("\nSTART ITERATIONS = %d\n", saveusr.iterations);
#endif
/* initialize the loop */
dit = saveusr.dittolist;
entire_list_done = FALSE;
time (&start_time);
/* Traverse entire dittolist, starting where we last left off.
* Unblob each record and search for the query string.
* If found, mark it and convert its abstract.
* If not found, make sure it's not marked and then continue.
*/
for (iter = saveusr.iterations; iter > 0; )
{
/*****usrblk.dba = dit->dba;**** unnecessary?******/
if ((bloblist = ve_getblobs (dit->dba, saveusr.vistano)) == NULL)
{
DtSearchAddMessage (
PROGNAME"390 Corrupted database address on hitlist.");
restore_findstr_hitl();
usrblk.retncode = OE_BAD_HITLIST;
return;
}
usrblk.retncode = oe_unblob (bloblist, FALSE);
if (usrblk.retncode != OE_OK)
return;
if (!oe_stems_to_hitwords (1))
return;
if (usrblk.hitwcount > 0) /* string FOUND */
{
found_one_substring = TRUE;
saveusr.dittocount++;
#ifdef DEBUG_FINDSTR_ITER
printf ("<<--->> HIT numhits=%ld, reckey = %s\n",
saveusr.dittocount, dit->reckey);
#endif
make_one_kwic (dit->abstractp);
dit->flags |= DIT_FINDSTR;
}
else dit->flags = 0; /* string NOT found */
/* advance to next ditto node */
if ((dit = dit->link) == NULL)
{
entire_list_done = TRUE;
break;
}
/* decrement iteration counter unless user said not to */
if (!(usrblk.flags & USR_NO_ITERATE)) iter--;
} /* end iteration loop */
/* End of current set of iterations.
* If main loop is not completed,
* adjust number of iterations to about 1 second,
* save current status, and return to caller.
*/
if (!entire_list_done)
{
time_dif = difftime (time(NULL), start_time);
if (time_dif < 1.)
saveusr.iterations = (float) saveusr.iterations * 1.5;
else if (time_dif > 1.)
saveusr.iterations = (double) saveusr.iterations / time_dif;
if (saveusr.iterations < MIN_FINDSTR_ITERATIONS)
saveusr.iterations = MIN_FINDSTR_ITERATIONS;
#ifdef DEBUG_FINDSTR_ITER
printf ("\nEND ITERATIONS = %d, time_dif = %lf\n",
saveusr.iterations, time_dif);
#endif
saveusr.dittolist = dit; /* temp save curr loc in usrblk.dittolist */
usrblk.workproc = findstr_workproc;
usrblk.retncode = OE_SEARCHING;
return;
} /* endif where we are still searching */
/* Completely done! Unless user specified no_iterate,
* calling program should always reset workproc to NULL.
* In case he forgets, dummy_workproc just appends an
* error message to notify programmer of his problem.
*/
if (!(usrblk.flags & USR_NO_ITERATE))
usrblk.workproc = dummy_workproc;
if (saveusr.dittocount > 0)
usrblk.retncode = OE_OK;
else
usrblk.retncode = OE_NOTAVAIL;
restore_findstr_hitl();
return;
} /* findstr_workproc() */
/******************************* OEKWIC.C ********************************/

282
cde/lib/DtSearch/opendblk.c Normal file
View File

@@ -0,0 +1,282 @@
/*
* COMPONENT_NAME: austext
*
* FUNCTIONS: open_dblk
*
* ORIGINS: 27
*
* (C) COPYRIGHT International Business Machines Corp. 1993,1995
* All Rights Reserved
* US Government Users Restricted Rights - Use, duplication or
* disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
*/
/*********************** OPENDBLK.C ************************
* $XConsortium: opendblk.c /main/5 1996/05/07 13:43:01 drk $
* October 1993.
* Opens all vista and the d99 database files in a dblk list.
* Most errors are handled by disconnecting the offending
* dblk from the list. Of course loss of ALL dblks is fatal.
*
* The nonvista d99 files (words inverted index) are opened,
* mostly to test if they can be found. If not, we can return
* a complete error message for the single dblk and unlink it.
* Vista can only open all databases at once.
*
* Does not use dmacros.h for vista calls so error msgs can be
* constructed and added to global msglist (although hard vista
* errors will still first send a msg to stdout via dberr.c).
*
* Open_dblk() should be used to replace all OPEN() calls
* in systems using DBLK structures.
* (1) It does not open dictionary files because they are not
* always needed (in OE, these are opened in oeinit.c).
* (2) It does not read dbrec system records because the caller may
* want to initialize them (in OE, these are read and
* validated by ve_initialize() in ve.c).
* (3) It does not open the other d9x files because they
* may not be present, depending on values in dbrec record.
*
* INPUT:
* 'dblist' is linked list of dblks.
* Each dblk must have valid 'name' field,
* and 'path' field must be NULL or a valid path string.
* 'numpages' is the number of vista cache pages to be opened.
* Where speed is critical it should be 64--
* for normal operations it should be no less than 16.
* 'debugging' is a boolean. It is usually set to (usrblk.debug & USRDBG_RARE)
* and if TRUE, trace msgs are written to stdout.
*
* OUTPUT:
* Sets correct vistano, iifile, and iimtime fields in each surviving dblk.
* Places all err msgs on global msglist as they occur.
* Sets austext_exit_dbms to d_close() on success (retncode > 0).
* Returns TRUE if at least some of the databases were opened.
* Bad dblks are unlinked from dblist and freed.
* Returns FALSE if fatal errors.
*
* $Log$
* Revision 2.5 1996/02/01 19:19:41 miker
* Minor change to err msg.
*
* Revision 2.4 1995/10/25 15:26:16 miker
* Added prolog.
*
* Revision 2.3 1995/10/19 20:25:52 miker
* Renaming database files no longer required.
* Transaction logging disabled, no space needed for overflow files.
* Open mode of non-vista database files also tracks new vista db_oflag.
*
* Revision 2.2 1995/10/03 21:45:26 miker
* Cosmetic msg changes only.
*
* Revision 2.1 1995/09/22 21:38:03 miker
* Freeze DtSearch 0.1, AusText 2.1.8
*
* Revision 1.8 1995/09/05 19:04:40 miker
* Name and msgs changes for DtSearch. Made ausapi_msglist universal.
*/
#include "SearchE.h"
#include <string.h>
#include <errno.h>
#include <fcntl.h>
#include <sys/stat.h>
#include "vista.h"
#define PROGNAME "OPENDBLK"
#define MS_misc 1
#define MS_oeinit 9
#define MS_vista 13
/****************************************/
/* */
/* open_dblk */
/* */
/****************************************/
/* dblk.path may be NULL */
int open_dblk (DBLK ** dblist, int numpages, int debugging)
{
DBLK *db, *bad_db, **lastlink;
int i;
size_t totlen = 0L;
char *allnames;
int vistano = 0;
char *srcptr, *targptr;
char temp_file_name[1024];
char sprintbuf[1024];
struct stat statbuf;
char open_mode [8];
if (debugging)
fprintf (aa_stderr, PROGNAME"76 "
"Entering open_dblks(). db_oflag==%d.\n",
db_oflag);
if (dblist == NULL || numpages < 8) {
BAD_INPUT:
sprintf (sprintbuf, catgets (dtsearch_catd, MS_oeinit, 99,
"%s Programming Error: Invalid input to open_dblk()."),
PROGNAME "99");
DtSearchAddMessage (sprintbuf);
return FALSE;
}
if (*dblist == NULL) /* empty list of dblks */
goto BAD_INPUT;
if (debugging) {
fprintf (aa_stderr, PROGNAME "96 Current list of dblks:\n");
for (db = *dblist; db != NULL; db = db->link) {
targptr = sprintbuf;
for (i = 0; i < db->ktcount; i++) {
*targptr++ = db->keytypes[i].ktchar;
}
*targptr = 0;
fprintf (aa_stderr, "--> DBLK at %p link=%p name='%s' maxhits=%d\n"
" keytypes='%s', path='%s'\n",
db, db->link, db->name, db->maxhits,
sprintbuf, NULLORSTR (db->path));
}
}
/* By doing setpages first, we can trap previously opened databases.
* Overflow and transaction locking files are not required.
*/
d_setpages (numpages, 0);
if (db_status != S_OKAY) {
DtSearchAddMessage (vista_msg (PROGNAME "389"));
return FALSE;
}
/* ---- PASS #1 ------------------------------------------
* Open nonvista (d99) files. If error, unlink dblk from dblist.
* Add up the total string length of surviving paths and database names.
* This giant path/file string will be used in the single d_open()
* below to find the .dbd files.
* While we're at it, set vistano in each dblk.
* The open mode depends on the current setting of db_oflag.
*/
if (db_oflag == O_RDONLY)
strcpy (open_mode, "rb");
else
strcpy (open_mode, "r+b");
db = *dblist;
lastlink = dblist;
while (db != NULL) {
if (db->path == NULL)
db->path = strdup ("");
strcpy (temp_file_name, db->path);
strcat (temp_file_name, db->name);
strcat (temp_file_name, EXT_DTBS);
if ((db->iifile = fopen (temp_file_name, open_mode)) == NULL) {
if (debugging)
fprintf (aa_stderr, PROGNAME "129 UNLINK: cant open '%s'.\n",
temp_file_name);
sprintf (sprintbuf, catgets (dtsearch_catd, MS_oeinit, 317,
"%s Cannot open database file '%s'.\n"
" Errno %d = %s\n"
" %s is removing '%s' from list of available databases."),
PROGNAME "317", temp_file_name, errno, strerror (errno),
OE_prodname, db->name);
if (errno == ENOENT)
strcat (sprintbuf, catgets (dtsearch_catd, MS_oeinit, 318,
"\n This can usually be corrected by specifying a valid\n"
" database PATH in the site configuration file."));
DtSearchAddMessage (sprintbuf);
goto DELETE_DB;
}
/*
* Find and save the timestamp for when the d99 file was
* last modified. An engine reinit is forced if it changes
* while the engine is running.
*/
if (fstat (fileno (db->iifile), &statbuf) == -1) {
if (debugging)
fprintf (aa_stderr,
PROGNAME "149 UNLINK: cant get status '%s'.\n",
temp_file_name);
sprintf (sprintbuf, catgets (dtsearch_catd, MS_oeinit, 1404,
"%s Removing database '%s' from list of "
"available databases because status is "
"unavailable for file %s: %s"),
PROGNAME "1404", db->name, temp_file_name, strerror (errno));
DtSearchAddMessage (sprintbuf);
goto DELETE_DB;
}
db->iimtime = statbuf.st_mtime;
/*
* This dblk is ok so far. Increment pointers and
* continue.
*/
if (debugging)
fprintf (aa_stderr, PROGNAME "163 opened '%s'.\n", temp_file_name);
db->vistano = vistano++;
totlen += strlen (db->path) + strlen (db->name) + 16;
lastlink = &db->link;
db = db->link;
continue;
DELETE_DB:
/*
* This dblk failed in one or more ways. Unlink it and
* don't increment pointers. If all dblks unlinked, *dblist
* will = NULL.
*/
bad_db = db; /* temp save */
*lastlink = db->link;
db = db->link;
free (bad_db);
} /* end PASS #1 */
/* quit if no dblks remain */
if (vistano <= 0) {
sprintf (sprintbuf, catgets (dtsearch_catd, MS_misc, 8,
"%s No valid databases remain."), PROGNAME "265");
DtSearchAddMessage (sprintbuf);
return FALSE;
}
allnames = austext_malloc (totlen + 512, PROGNAME "66", NULL);
/* ---- PASS #2 ------------------------------------------
* Build string of accumulated path and database names.
*/
targptr = allnames;
for (db = *dblist; db != NULL; db = db->link) {
srcptr = db->path;
while (*srcptr != 0)
*targptr++ = *srcptr++;
srcptr = db->name;
while (*srcptr != 0)
*targptr++ = *srcptr++;
*targptr++ = ';';
}
*(--targptr) = 0; /* terminate string */
if (debugging)
fprintf (aa_stderr,
PROGNAME "150 vista opening databases '%s'\n", allnames);
d_open (allnames, "o"); /* replaces OPEN() call from dmacros.h */
if (db_status != S_OKAY) {
targptr = austext_malloc (totlen + 128, PROGNAME"239", NULL);
sprintf (targptr, catgets (dtsearch_catd, MS_vista, 378,
"%s Could not open following database name string:\n '%s'"),
PROGNAME"378", allnames);
DtSearchAddMessage (targptr);
DtSearchAddMessage (vista_msg (PROGNAME"379"));
free (allnames);
free (targptr);
return FALSE;
}
else if (debugging)
fprintf (aa_stderr, " --> vista open successful!\n");
/* From here on, emergency exits MUST close the databases */
austext_exit_dbms = (void (*) (int)) d_close;
free (allnames);
return TRUE;
} /* open_dblk() */
/*********************** OPENDBLK.C ************************/

277
cde/lib/DtSearch/ophuf.c Normal file
View File

@@ -0,0 +1,277 @@
/* $XConsortium: ophuf.c /main/3 1996/05/09 03:55:33 drk $ */
/*
* COMPONENT_NAME: austext
*
* FUNCTIONS:
*
* ORIGINS: 27
*
*
* (C) COPYRIGHT International Business Machines Corp. 1993,1996
* All Rights Reserved
* Licensed Materials - Property of IBM
* US Government Users Restricted Rights - Use, duplication or
* disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
*/
#include <time.h>
char *hctree_name = "neuthuf.c";
time_t hctree_id = 827251660L;
int hctree_root = 254;
static int hctree_array[] = {
-257, -256, /* 0 */
-255, -254, /* 1 */
-253, -252, /* 2 */
-251, -250, /* 3 */
-249, -248, /* 4 */
-247, -246, /* 5 */
-245, -244, /* 6 */
-243, -242, /* 7 */
-241, -240, /* 8 */
-239, -238, /* 9 */
-237, -236, /* 10 */
-235, -234, /* 11 */
-233, -232, /* 12 */
-231, -230, /* 13 */
-229, -228, /* 14 */
-227, -226, /* 15 */
-225, -224, /* 16 */
-223, -222, /* 17 */
-221, -220, /* 18 */
-219, -218, /* 19 */
-217, -216, /* 20 */
-215, -214, /* 21 */
-213, -212, /* 22 */
-211, -210, /* 23 */
-209, -208, /* 24 */
-207, -206, /* 25 */
-205, -204, /* 26 */
-203, -202, /* 27 */
-201, -200, /* 28 */
-199, -198, /* 29 */
-197, -196, /* 30 */
-195, -194, /* 31 */
-193, -192, /* 32 */
-191, -190, /* 33 */
-189, -188, /* 34 */
-187, -186, /* 35 */
-185, -184, /* 36 */
-183, -182, /* 37 */
-181, -180, /* 38 */
-179, -178, /* 39 */
-177, -176, /* 40 */
-175, -174, /* 41 */
-173, -172, /* 42 */
-171, -170, /* 43 */
-169, -168, /* 44 */
-167, -166, /* 45 */
-165, -164, /* 46 */
-163, -162, /* 47 */
-161, -160, /* 48 */
-159, -158, /* 49 */
-157, -156, /* 50 */
-155, -154, /* 51 */
-153, -152, /* 52 */
-151, -150, /* 53 */
-149, -148, /* 54 */
-147, -146, /* 55 */
-145, -144, /* 56 */
-143, -142, /* 57 */
-141, -140, /* 58 */
-139, -138, /* 59 */
-137, -136, /* 60 */
-135, -134, /* 61 */
-133, -132, /* 62 */
-131, -130, /* 63 */
-129, -128, /* 64 */
-127, -126, /* 65 */
-125, -124, /* 66 */
-123, -122, /* 67 */
-121, -120, /* 68 */
-119, -118, /* 69 */
-117, -116, /* 70 */
-115, -114, /* 71 */
-113, -112, /* 72 */
-111, -110, /* 73 */
-109, -108, /* 74 */
-107, -106, /* 75 */
-105, -104, /* 76 */
-103, -102, /* 77 */
-101, -100, /* 78 */
-99, -98, /* 79 */
-97, -96, /* 80 */
-95, -94, /* 81 */
-93, -92, /* 82 */
-91, -90, /* 83 */
-89, -88, /* 84 */
-87, -86, /* 85 */
-85, -84, /* 86 */
-83, -82, /* 87 */
-81, -80, /* 88 */
-79, -78, /* 89 */
-77, -76, /* 90 */
-75, -74, /* 91 */
-73, -72, /* 92 */
-71, -70, /* 93 */
-69, -68, /* 94 */
-67, -66, /* 95 */
-65, -64, /* 96 */
-63, -62, /* 97 */
-61, -60, /* 98 */
-59, -58, /* 99 */
-57, -56, /* 100 */
-55, -54, /* 101 */
-53, -52, /* 102 */
-51, -50, /* 103 */
-49, -48, /* 104 */
-47, -46, /* 105 */
-45, -44, /* 106 */
-43, -42, /* 107 */
-41, -40, /* 108 */
-39, -38, /* 109 */
-37, -36, /* 110 */
-35, -34, /* 111 */
-33, -32, /* 112 */
-31, -30, /* 113 */
-29, -28, /* 114 */
-27, -26, /* 115 */
-25, -24, /* 116 */
-23, -22, /* 117 */
-21, -20, /* 118 */
-19, -18, /* 119 */
-17, -16, /* 120 */
-15, -14, /* 121 */
-13, -12, /* 122 */
-11, -10, /* 123 */
-9, -8, /* 124 */
-7, -6, /* 125 */
-5, -4, /* 126 */
-3, -2, /* 127 */
0, 1, /* 128 */
2, 3, /* 129 */
4, 5, /* 130 */
6, 7, /* 131 */
8, 9, /* 132 */
10, 11, /* 133 */
12, 13, /* 134 */
14, 15, /* 135 */
16, 17, /* 136 */
18, 19, /* 137 */
20, 21, /* 138 */
22, 23, /* 139 */
24, 25, /* 140 */
26, 27, /* 141 */
28, 29, /* 142 */
30, 31, /* 143 */
32, 33, /* 144 */
34, 35, /* 145 */
36, 37, /* 146 */
38, 39, /* 147 */
40, 41, /* 148 */
42, 43, /* 149 */
44, 45, /* 150 */
46, 47, /* 151 */
48, 49, /* 152 */
50, 51, /* 153 */
52, 53, /* 154 */
54, 55, /* 155 */
56, 57, /* 156 */
58, 59, /* 157 */
60, 61, /* 158 */
62, 63, /* 159 */
64, 65, /* 160 */
66, 67, /* 161 */
68, 69, /* 162 */
70, 71, /* 163 */
72, 73, /* 164 */
74, 75, /* 165 */
76, 77, /* 166 */
78, 79, /* 167 */
80, 81, /* 168 */
82, 83, /* 169 */
84, 85, /* 170 */
86, 87, /* 171 */
88, 89, /* 172 */
90, 91, /* 173 */
92, 93, /* 174 */
94, 95, /* 175 */
96, 97, /* 176 */
98, 99, /* 177 */
100, 101, /* 178 */
102, 103, /* 179 */
104, 105, /* 180 */
106, 107, /* 181 */
108, 109, /* 182 */
110, 111, /* 183 */
112, 113, /* 184 */
114, 115, /* 185 */
116, 117, /* 186 */
118, 119, /* 187 */
120, 121, /* 188 */
122, 123, /* 189 */
124, 125, /* 190 */
126, 127, /* 191 */
128, 129, /* 192 */
130, 131, /* 193 */
132, 133, /* 194 */
134, 135, /* 195 */
136, 137, /* 196 */
138, 139, /* 197 */
140, 141, /* 198 */
142, 143, /* 199 */
144, 145, /* 200 */
146, 147, /* 201 */
148, 149, /* 202 */
150, 151, /* 203 */
152, 153, /* 204 */
154, 155, /* 205 */
156, 157, /* 206 */
158, 159, /* 207 */
160, 161, /* 208 */
162, 163, /* 209 */
164, 165, /* 210 */
166, 167, /* 211 */
168, 169, /* 212 */
170, 171, /* 213 */
172, 173, /* 214 */
174, 175, /* 215 */
176, 177, /* 216 */
178, 179, /* 217 */
180, 181, /* 218 */
182, 183, /* 219 */
184, 185, /* 220 */
186, 187, /* 221 */
188, 189, /* 222 */
190, 191, /* 223 */
192, 193, /* 224 */
194, 195, /* 225 */
196, 197, /* 226 */
198, 199, /* 227 */
200, 201, /* 228 */
202, 203, /* 229 */
204, 205, /* 230 */
206, 207, /* 231 */
208, 209, /* 232 */
210, 211, /* 233 */
212, 213, /* 234 */
214, 215, /* 235 */
216, 217, /* 236 */
218, 219, /* 237 */
220, 221, /* 238 */
222, 223, /* 239 */
224, 225, /* 240 */
226, 227, /* 241 */
228, 229, /* 242 */
230, 231, /* 243 */
232, 233, /* 244 */
234, 235, /* 245 */
236, 237, /* 246 */
238, 239, /* 247 */
240, 241, /* 248 */
242, 243, /* 249 */
244, 245, /* 250 */
246, 247, /* 251 */
248, 249, /* 252 */
250, 251, /* 253 */
252, 253 /* 254 */
};
int *hctree = hctree_array;

View File

@@ -0,0 +1,106 @@
# $XConsortium: Imakefile /main/10 1996/08/14 17:50:16 cde-ibm $
#
# (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 1996 FUJITSU LIMITED.
# (c) Copyright 1996 Hitachi.
#
REQUIREDLIBS = -lc -lm
#ifdef AlphaArchitecture
EXTRA_DEFINES = -DBYTE_SWAP -D_OSF_SOURCE -D_XOPEN_SOURCE
#endif
#ifdef USLArchitecture
EXTRA_DEFINES = -DBYTE_SWAP -D_XOPEN_SOURCE
#endif
#ifdef UXPArchitecture
EXTRA_DEFINES = -D_XOPEN_SOURCE
#endif
#define DoNormalLib NormalLibDtSearch
#define DoSharedLib SharedLibDtSearch
#define DoDebugLib DebugLibDtSearch
#define DoProfileLib ProfileLibDtSearch
#define LibName DtSearch
#define SoRev SODTSEARCHREV
#define IncSubdir Dt
#define LibCreate NO
#ifndef DtSvcDefines
# define DtSvcDefines -DXK_MISCELLANY -DMULTIBYTE
#endif
DEFINES = DtSvcDefines \
-DCDE_INSTALLATION_TOP=\"$(CDE_INSTALLATION_TOP)\" \
-DCDE_CONFIGURATION_TOP=\"$(CDE_CONFIGURATION_TOP)\" \
-DNO_TRANS -DUNIX -DNO_CONST -D_POSIX_SOURCE
INCLUDES = -I.
HEADERS = \
dbtype.h dproto.h inittab.h ncb.h task.h vista.h \
dblock.h dbxtrn.h dtcover.h ll.h proto.h trxlog.h
SRCS = \
alloc.c cmstat.c cmtype.c connect.c \
costat.c cotype.c crget.c crread.c crset.c \
crstat.c crtype.c crwrite.c csmget.c csmread.c \
csmset.c csmwrite.c csoget.c csoread.c csoset.c \
csowrite.c csstat.c ctscm.c ctsco.c ctscr.c \
dbacode.c dbdpath.c dbfpath.c dblfcns.c \
dbswab.c dbuserid.c \
delete.c destroy.c dio.c discon.c disdel.c \
fillnew.c findco.c findfm.c findlm.c findnm.c \
findpm.c gtscm.c gtsco.c gtscr.c gtscs.c \
initial.c inittab.c ismember.c \
isowner.c keydel.c keyexist.c keyfcns.c \
keyfind.c keyfrst.c keylast.c keynext.c keyprev.c \
keystore.c libfcns.c makenew.c mapchar.c \
members.c netunix.c oflag.c opens.c options.c \
pathfcns.c recfcns.c recfrst.c reclast.c recnext.c \
recprev.c recread.c recset.c \
recstat.c recwrite.c renfile.c rwcurr.c setdb.c \
setmm.c setmo.c setmr.c setom.c setoo.c \
setor.c setrm.c setro.c startup.c stscm.c \
stsco.c stscr.c stscs.c \
utscm.c utsco.c utscr.c utscs.c
/* WARNING!!!!
* Any .o's added to this list need to be added to DTUTIL1_OBJS1
* and SHARED_DTUTIL1_OBJS1 in the DtSearch Imakefile.
*/
OBJS = \
alloc.o cmstat.o cmtype.o connect.o \
costat.o cotype.o crget.o crread.o crset.o \
crstat.o crtype.o crwrite.o csmget.o csmread.o \
csmset.o csmwrite.o csoget.o csoread.o csoset.o \
csowrite.o csstat.o ctscm.o ctsco.o ctscr.o \
dbacode.o dbdpath.o dbfpath.o dblfcns.o \
dbswab.o dbuserid.o \
delete.o destroy.o dio.o discon.o disdel.o \
fillnew.o findco.o findfm.o findlm.o findnm.o \
findpm.o gtscm.o gtsco.o gtscr.o gtscs.o \
initial.o inittab.o ismember.o \
isowner.o keydel.o keyexist.o keyfcns.o \
keyfind.o keyfrst.o keylast.o keynext.o keyprev.o \
keystore.o libfcns.o makenew.o mapchar.o \
members.o netunix.o opens.o options.o oflag.o \
pathfcns.o recfcns.o recfrst.o reclast.o recnext.o \
recprev.o recread.o recset.o \
recstat.o recwrite.o renfile.o rwcurr.o setdb.o \
setmm.o setmo.o setmr.o setom.o setoo.o \
setor.o setrm.o setro.o startup.o stscm.o \
stsco.o stscr.o stscs.o \
utscm.o utsco.o utscr.o utscs.o
#include <Library.tmpl>
SubdirLibraryRule($(OBJS))
DependTarget()

View File

@@ -0,0 +1,244 @@
/* $XConsortium: alloc.c /main/2 1996/05/09 03:55:49 drk $ */
/*
* COMPONENT_NAME: austext
*
* FUNCTIONS: CurrLock
* CurrUnlock
* I_CALLOC
* I_FREE
* I_MALLOC
* Memlock
* Memunlock
* NewInit
* calloc
* d_alloc
* d_calloc
* d_free
* ll_access
* ll_append
* ll_first
* ll_free
* ll_next
* ll_prepend
* malloc
* memlock
* memunlock
*
* ORIGINS: 157
*
* OBJECT CODE ONLY SOURCE MATERIALS
*/
/*-----------------------------------------------------------------------
alloc.c -- db_VISTA dynamic memory allocation module.
(C) Copyright 1986,1987 by Raima Corporation.
-----------------------------------------------------------------------*/
/* ********************** EDIT HISTORY *******************************
SCR DATE INI DESCRIPTION
----- --------- --- -----------------------------------------------------
420 15-Aug-88 RTK Lock level wasn't incremented when stack had overflowed
420 27-Sep-88 RSC there was unreachable code in ll_free (repl 'return' w/
'break' inside loop)
550 10-Jan-88 RSC ll_free was referencing a segment that was free'd
420 13-Feb-89 WLW Removed unnecessary FAR's, modified d_lockpop
550 14-Feb-89 RTK Better fix to ll_free problem (windows compatible)
*/
#include <stdio.h>
#include "vista.h"
#include "dbtype.h"
char *malloc(P1(unsigned));
char *calloc(P1(unsigned) Pi(unsigned));
#define memlock(p) (p)
#define memunlock(p) 1
#define Memlock(cp) /**/
#define Memunlock(cp) /**/
#define I_CALLOC(cp, i, s) calloc(i, s)
#define I_MALLOC(cp, b) malloc(b)
#define I_FREE(cp) free((cp)->ptr)
#define CurrUnlock(ll) /**/
#define CurrLock(ll) /**/
/*-----------------------------------------------------------------------
Uninstrumented dynamic memory allocation functions
-----------------------------------------------------------------------*/
/* Allocate and clear i*s bytes of memory
*/
char FAR * d_calloc(i, s)
unsigned i, s;
{
return (I_CALLOC(cp, i, s));
}
/* Allocate b bytes of memory
*/
char FAR * d_alloc(b)
unsigned b;
{
return (I_MALLOC(cp, b));
}
/* Free memory
*/
void d_free(p)
CHAR_P FAR *p;
{
if ((p != NULL) && (p->ptr != NULL)) {
I_FREE(p);
p->ptr = NULL;
}
}
static int NewInit(P1(LL_P FAR *));
/* Resets pointer to current element and checks for an empty list
*/
BOOLEAN ll_access(ll)
llist FAR *ll;
{
ll->curr = NULL;
return( ll->head.ptr != NULL && ll->tail.ptr != NULL );
}
/* Appends item to list
*/
int ll_append(ll, data)
llist FAR *ll;
CHAR_P FAR *data;
{
LL_P item;
LL_P hold;
if ( NewInit(&item) != S_OKAY ) {
return( db_status );
}
if ( ll->head.ptr == NULL ) {
/* Empty list */
ll->head = ll->tail = item;
ll->curr = (LL_P FAR *)&ll->head;
CurrLock(ll);
}
else {
CurrUnlock(ll);
ll->curr = (LL_P FAR *)&ll->tail;
CurrLock(ll);
hold = item;
MEM_LOCK(&item);
ll->curr->ptr->next = item;
CurrUnlock(ll);
ll->curr = (LL_P FAR *)&ll->tail;
*ll->curr = hold;
CurrLock(ll);
}
ll->curr->ptr->data = *data;
return( db_status );
}
/* Finds the first element of a list and returns its data
*/
CHAR_P FAR *ll_first(ll)
llist FAR *ll;
{
if ( ll->head.ptr == NULL ) {
return( NULL );
}
CurrUnlock(ll);
ll->curr = (LL_P FAR *)&ll->head;
CurrLock(ll);
return( (CHAR_P FAR *)&ll->curr->ptr->data );
}
/* Frees a list
*/
void ll_free(ll)
llist FAR *ll;
{
LL_P FAR *curr, next, free;
curr = (LL_P FAR *)&ll->head;
while ( TRUE ) {
MEM_LOCK(curr);
if ( curr->ptr == NULL )
break;
bytecpy(&next, &curr->ptr->next, sizeof(LL_P));
if ( curr != NULL )
d_free((CHAR_P FAR *)curr);
bytecpy(&free, &next, sizeof(LL_P));
curr = &free;
}
byteset(&ll->head, '\0', sizeof(LL_P));
byteset(&ll->tail, '\0', sizeof(LL_P));
}
/* Finds the next element and returns its data
*/
CHAR_P FAR *ll_next(ll)
llist FAR *ll;
{
LL_P FAR *next;
if ( ll->curr == NULL ) {
return( ll_first(ll) );
}
if ( ll->curr->ptr->next.ptr == NULL ) {
return( NULL );
}
next = &ll->curr->ptr->next;
CurrUnlock(ll);
ll->curr = next;
CurrLock(ll);
return( (CHAR_P FAR *)&ll->curr->ptr->data );
}
/* Prepends (stacks) item
*/
int ll_prepend(ll, data)
llist FAR *ll;
CHAR_P FAR *data;
{
LL_P item;
if ( NewInit(&item) != S_OKAY ) {
return( db_status );
}
if ( ll->head.ptr == NULL ) {
/* Empty list */
ll->head = ll->tail = item;
ll->curr = (LL_P FAR *)&ll->head;
CurrLock(ll);
}
else {
CurrUnlock(ll);
MEM_LOCK(&item);
item.ptr->next = ll->head;
MEM_UNLOCK(&item);
ll->curr = (LL_P FAR *)&ll->head;
*ll->curr = item;
CurrLock(ll);
}
ll->curr->ptr->data = *data;
return( db_status );
}
/* Allocates and initializes a new list element
*/
static int NewInit(new)
LL_P FAR *new;
{
new->ptr = (ll_elem FAR *)ALLOC(new, sizeof(ll_elem), "new");
if ( new->ptr == NULL )
return( dberr(S_NOMEMORY) );
byteset(new->ptr, '\0', sizeof(ll_elem));
MEM_UNLOCK(new);
return( db_status );
}
/* vpp -nOS2 -dUNIX -nBSD -nVANILLA_BSD -nVMS -nMEMLOCK -nWINDOWS -nFAR_ALLOC -f/usr/users/master/config/nonwin alloc.c */

View File

@@ -0,0 +1,58 @@
/* $XConsortium: cmstat.c /main/2 1996/05/09 03:56:07 drk $ */
/*
* COMPONENT_NAME: austext
*
* FUNCTIONS: d_cmstat
*
* ORIGINS: 157
*
* OBJECT CODE ONLY SOURCE MATERIALS
*/
/*-----------------------------------------------------------------------
cmstat.c -- db_VISTA member timestamp status check module.
(C) Copyright 1987 by Raima Corporation.
-----------------------------------------------------------------------*/
/* ********************** EDIT HISTORY *******************************
SCR DATE INI DESCRIPTION
----- --------- --- -----------------------------------------------------
04-Aug-88 RTK MULTI_TASK changes
*/
#include <stdio.h>
#include "vista.h"
#include "dbtype.h"
#ifndef NO_TIMESTAMP
/* Test timestamp status of current member
*/
d_cmstat(set TASK_PARM DBN_PARM)
int set;
TASK_DECL
DBN_DECL
{
ULONG cts, uts;
ULONG cmts;
DB_ENTER(DB_ID TASK_ID LOCK_SET(SET_IO));
if ( d_ctscm(set, &cts TASK_PARM DBN_PARM) == S_OKAY ) {
if ( cts ) {
cmts = cm_time[NUM2INT(set - SETMARK, st_offset)];
if ( cts > cmts )
db_status = S_DELETED;
else {
d_utscm(set, &uts TASK_PARM DBN_PARM);
if ( uts > cmts )
db_status = S_UPDATED;
}
}
else
dberr(S_TIMESTAMP);
}
RETURN( db_status );
}
#endif
/* vpp -nOS2 -dUNIX -nBSD -nVANILLA_BSD -nVMS -nMEMLOCK -nWINDOWS -nFAR_ALLOC -f/usr/users/master/config/nonwin cmstat.c */

View File

@@ -0,0 +1,76 @@
/* $XConsortium: cmtype.c /main/2 1996/05/09 03:56:24 drk $ */
/*
* COMPONENT_NAME: austext
*
* FUNCTIONS: d_cmtype
*
* ORIGINS: 157
*
* OBJECT CODE ONLY SOURCE MATERIALS
*/
/*-----------------------------------------------------------------------
cmtype.c -- db_VISTA member type module.
(C) Copyright 1987 by Raima Corporation.
-----------------------------------------------------------------------*/
/* ********************** EDIT HISTORY *******************************
SCR DATE INI DESCRIPTION
----- --------- --- -----------------------------------------------------
103 24-Jun-88 RSC Improve generation of single-user version
04-Aug-88 RTK MULTI_TASK changes
*/
#include <stdio.h>
#include "vista.h"
#include "dbtype.h"
/* Get current member type
*/
d_cmtype(set, cmtype TASK_PARM DBN_PARM)
int set;
int FAR *cmtype;
TASK_DECL
DBN_DECL
{
char FAR *mrec;
INT crt;
SET_ENTRY FAR *set_ptr;
#ifndef SINGLE_USER
int dbopen_sv;
#endif
DB_ENTER(DB_ID TASK_ID LOCK_SET(SET_IO));
if (nset_check(set, &set, (SET_ENTRY FAR * FAR *)&set_ptr) != S_OKAY)
RETURN( db_status );
if ( ! curr_mem[set] )
RETURN( dberr( S_NOCM ) );
#ifndef SINGLE_USER
/* set up to allow unlocked read */
dbopen_sv = dbopen;
dbopen = 2;
#endif
/* Read current member */
dio_read(curr_mem[set], (char FAR * FAR *)&mrec, NOPGHOLD);
#ifndef SINGLE_USER
dbopen = dbopen_sv;
#endif
if (db_status != S_OKAY)
RETURN( db_status );
/* Fetch record type from record header */
bytecpy(&crt, mrec, sizeof(INT));
#ifndef SINGLE_USER
crt &= ~RLBMASK; /* mask off rlb */
#endif
*cmtype = (int)crt + RECMARK;
RETURN( db_status );
}
/* vpp -nOS2 -dUNIX -nBSD -nVANILLA_BSD -nVMS -nMEMLOCK -nWINDOWS -nFAR_ALLOC -f/usr/users/master/config/nonwin cmtype.c */

View File

@@ -0,0 +1,345 @@
/* $XConsortium: connect.c /main/2 1996/05/09 03:56:41 drk $ */
/*
* COMPONENT_NAME: austext
*
* FUNCTIONS: Pi
* d_connect
* sortcmp
*
* ORIGINS: 157
*
* OBJECT CODE ONLY SOURCE MATERIALS
*/
/*-----------------------------------------------------------------------
connect.c -- db_VISTA set connection module
(C) Copyright 1985, 1986, 1987 by Raima Corp.
-----------------------------------------------------------------------*/
/* ********************** EDIT HISTORY *******************************
SCR DATE INI DESCRIPTION
----- --------- --- -----------------------------------------------------
04-Aug-88 RTK MULTI_TASK changes
*/
#include <stdio.h>
#include "vista.h"
#include "dbtype.h"
/* Internal function Prototypes */
static int sortcmp(P1(SET_ENTRY FAR *) Pi(char FAR *)
Pi(char FAR *));
/* set pointer structure definition */
typedef struct {
LONG total; /* total number of members in set */
DB_ADDR first; /* database address of first member in set */
DB_ADDR last; /* database address of last member in set */
#ifndef NO_TIMESTAMP
ULONG timestamp; /* set update timestamp - if used */
#endif
} SET_PTR;
/* member pointer structure definition */
typedef struct {
DB_ADDR owner; /* database address of owner record */
DB_ADDR prev; /* database address of previous member in set */
DB_ADDR next; /* database address of next member in set */
} MEM_PTR;
/* Connect the current record as member of set
*/
d_connect(set TASK_PARM DBN_PARM)
int set; /* Set constant */
TASK_DECL
DBN_DECL /* Database number */
{
MEM_PTR crmp; /* current record's member pointer */
SET_PTR cosp; /* current owner's set pointer */
MEM_PTR cmmp; /* current member's member pointer */
MEM_PTR nmmp; /* next member's member pointer */
char FAR *crec; /* ptr to current record contents in cache */
char FAR *orec; /* ptr to current owner record contents in cache */
char FAR *mrec; /* ptr to current member record contents in cache */
char FAR *nrec; /* ptr to next member record contents in cache */
DB_ADDR mdba; /* db address of current member record */
DB_ADDR ndba; /* db address of next member record */
INT ordering; /* set order control variable */
int stat, compare; /* status code & sort comparison result */
#ifndef NO_TIMESTAMP
FILE_NO file;
#endif
SET_ENTRY FAR *set_ptr;
DB_ADDR FAR *co_ptr;
DB_ADDR FAR *cm_ptr;
DB_ENTER(DB_ID TASK_ID LOCK_SET(SET_IO));
if (nset_check(set, &set, (SET_ENTRY FAR * FAR *)&set_ptr) != S_OKAY)
RETURN( db_status );
/* make sure we have a current record */
if ( curr_rec == NULL_DBA )
RETURN( dberr(S_NOCR) );
/* make sure we have a current owner */
if ( *(co_ptr = &curr_own[set]) == NULL_DBA )
RETURN( dberr(S_NOCO) );
crec = orec = mrec = nrec = NULL;
/* read current record */
if ( dio_read( curr_rec, (char FAR * FAR *)&crec, PGHOLD ) != S_OKAY )
RETURN( db_status );
/* read owner record */
if ( (stat = dio_read(*co_ptr, (char FAR * FAR *)&orec, PGHOLD)) != S_OKAY ) {
dio_release( curr_rec );
RETURN( stat );
}
/* get copy of current record's member ptr for set */
if ( (stat = r_gmem(set, crec, (char FAR *)&crmp)) != S_OKAY )
goto quit;
/* ensure record not already connected to set */
if ( ! crmp.owner == NULL_DBA ) {
stat = dberr(S_ISOWNED);
goto quit;
}
/* get set pointer from owner */
if ( r_gset(set, orec, (char FAR *)&cosp) != S_OKAY ) {
stat = db_status == S_INVOWN ? dberr(S_SYSERR) : db_status;
goto quit;
}
/* set current record's owner to current owner of set */
crmp.owner = *co_ptr;
cm_ptr = &curr_mem[set];
/* make insertion based on set order specfication */
if (cosp.first == NULL_DBA) {
/* set is empty */
/* set current owner's first and last to current record */
cosp.first = cosp.last = curr_rec;
/* set current record's next and previous to null */
crmp.next = crmp.prev = NULL_DBA;
goto inserted;
}
/* order is as specified in DDL */
ordering = set_ptr->st_order;
while (TRUE) switch (ordering) {
case ASCENDING:
case DESCENDING:
/* perform a linked insertion sort on set -
position the current member to the proper place and then
switch to order NEXT */
for (mdba = cosp.first; TRUE; mdba = cmmp.next) {
/* read member record and get member pointer from member
record */
if (((stat = dio_read(mdba, (char FAR * FAR *)&mrec, NOPGHOLD)) != S_OKAY) ||
((stat = r_gmem(set, mrec, (char FAR *)&cmmp)) != S_OKAY))
goto quit;
/* compare sort fields of current record with member record */
compare = sortcmp(set_ptr, crec, mrec);
if ((ordering == ASCENDING) ? (compare < 0) : (compare > 0)) {
/* found insertion position -
make previous member the current member of set and
switch to next order processing */
*cm_ptr = cmmp.prev;
ordering = NEXT;
break;
}
if ( cmmp.next == NULL_DBA ) {
/* connect at end of list */
*cm_ptr = mdba;
ordering = NEXT;
break;
}
}
break;
case FIRST:
crmp.next = cosp.first;
/* read current owner's first member and get first member's
member pointer
*/
mdba = cosp.first;
if (((stat = dio_read(mdba, (char FAR * FAR *)&mrec, PGHOLD)) != S_OKAY) ||
((stat = r_gmem(set, mrec, (char FAR *)&cmmp)) != S_OKAY))
goto quit;
/* set current member's previous, and current owner's first, to
current record */
cmmp.prev = cosp.first = curr_rec;
goto inserted;
case NEXT:
if (!*cm_ptr) {
/* if no current member, next is same as first */
ordering = FIRST;
break;
}
/* insert record after current member */
mdba = *cm_ptr;
/* read current member record and get member pointer from
current member
*/
if (((stat = dio_read(mdba, (char FAR * FAR *)&mrec, PGHOLD)) != S_OKAY) ||
((stat = r_gmem(set, mrec, (char FAR *)&cmmp)) != S_OKAY))
goto quit;
/* set current record's next to current member's next */
crmp.next = cmmp.next;
/* set current record's prev to current member */
crmp.prev = mdba;
/* set current member's next ro current record */
cmmp.next = curr_rec;
if (crmp.next == NULL_DBA) {
/* current record at end of list -
update set pointer's last member */
cosp.last = curr_rec;
goto inserted;
}
/* read next member record and member pointer from next member */
ndba = crmp.next;
if (((stat = dio_read(ndba, (char FAR * FAR *)&nrec, PGHOLD)) != S_OKAY) ||
((stat = r_gmem(set, nrec, (char FAR *)&nmmp)) != S_OKAY))
goto quit;
/* set previous pointer in next member to current record */
nmmp.prev = curr_rec;
goto inserted;
case LAST:
/* set current member to owner's last pointer */
*cm_ptr = cosp.last;
/* switch to order next */
ordering = NEXT;
break;
default:
/* there are no other possible orderings! */
RETURN( dberr(S_SYSERR) );
} /* while switch */
inserted:
/* increment total members in set */
++cosp.total;
#ifndef NO_TIMESTAMP
/* check for timestamp */
if ( set_ptr->st_flags & TIMESTAMPED ) {
file = NUM2INT((FILE_NO)((*co_ptr >> FILESHIFT) & FILEMASK), ft_offset);
cosp.timestamp = dio_pzgetts(file);
}
#endif
if ( mrec ) {
/* put member pointer back into member record and mark member
record as modified
*/
if (((stat = r_pmem(set, mrec, (char FAR *)&cmmp)) != S_OKAY) ||
((stat = dio_write(mdba, NULL, PGFREE)) != S_OKAY))
goto quit;
}
if ( nrec ) {
/* put member pointer back into next record and mark next record
as modified
*/
if (((stat = r_pmem(set, nrec, (char FAR *)&nmmp)) != S_OKAY) ||
((stat = dio_write(ndba, NULL, PGFREE)) != S_OKAY))
goto quit;
}
/* put set pointer back into owner record and mark owner record as
modified; put member pointer back into current record mark current
record as modified */
if (((stat = r_pset(set, orec, (char FAR *)&cosp)) != S_OKAY) ||
((stat = dio_write(*co_ptr, NULL, PGFREE)) != S_OKAY) ||
((stat = r_pmem(set, crec, (char FAR *)&crmp)) != S_OKAY) ||
((stat = dio_write(curr_rec, NULL, PGFREE)) != S_OKAY))
goto quit;
/* set current member to current record */
*cm_ptr = curr_rec;
#ifndef NO_TIMESTAMP
/* check and fetch timestamps */
if ( db_tsrecs )
d_utscr(&cm_time[set] TASK_PARM);
if ( db_tssets )
cs_time[set] = cosp.timestamp;
#endif
RETURN( db_status );
/* error return */
quit:
if ( crec ) dio_release( curr_rec );
if ( orec ) dio_release( *co_ptr );
if ( mrec ) dio_release( mdba );
if ( nrec ) dio_release( ndba );
RETURN( db_status = stat );
}
/* Compare two sort fields
*/
static int sortcmp(set_ptr, mem1, mem2)
SET_ENTRY FAR *set_ptr; /* set table entry */
char FAR *mem1; /* member record 1 */
char FAR *mem2; /* member record 2 */
{
INT rn1, rn2; /* record numbers for mem1 & mem2 */
MEMBER_ENTRY FAR *mt1, FAR *mt2;
register MEMBER_ENTRY FAR *mt;
int mem, memtot;
int cmp; /* fldcmp result */
register int maxflds;
register SORT_ENTRY FAR *srt1_ptr, FAR *srt2_ptr;
FIELD_ENTRY FAR *fld_ptr;
/* extract record numbers from record header */
bytecpy(&rn1, mem1, sizeof(INT));
rn1 &= ~RLBMASK; /* mask off rlb */
bytecpy(&rn2, mem2, sizeof(INT));
rn2 &= ~RLBMASK; /* mask off rlb */
#ifndef ONE_DB
rn1 += curr_db_table->rt_offset;
rn2 += curr_db_table->rt_offset;
#endif
/* locate member_table entries for these record types */
mt2 = mt1 = NULL;
for (mem = set_ptr->st_members, memtot = mem + set_ptr->st_memtot,
mt = &member_table[mem];
mem < memtot;
++mem, ++mt) {
if ( mt->mt_record == rn1 ) {
mt1 = mt;
if (mt2 != NULL)
break;
}
if ( mt->mt_record == rn2 ) {
mt2 = mt;
if (mt1 != NULL)
break;
}
}
/* set maxflds to number of sort fields in set (min(mt1,mt2)) */
maxflds = (mt1->mt_totsf <= mt2->mt_totsf) ? mt1->mt_totsf : mt2->mt_totsf;
/* do comparison for each field */
for (srt1_ptr = &sort_table[mt1->mt_sort_fld],
srt2_ptr = &sort_table[mt2->mt_sort_fld];
maxflds--;
++srt1_ptr, ++srt2_ptr) {
/* compare the two fields */
/* computation is pointer to next sort field in member record */
fld_ptr = &field_table[srt1_ptr->se_fld];
if (cmp = fldcmp(fld_ptr, mem1 + fld_ptr->fd_ptr,
mem2 + field_table[srt2_ptr->se_fld].fd_ptr))
return (cmp); /* return at first unequal fields */
}
/* fields match */
return (0);
}
/* vpp -nOS2 -dUNIX -nBSD -nVANILLA_BSD -nVMS -nMEMLOCK -nWINDOWS -nFAR_ALLOC -f/usr/users/master/config/nonwin connect.c */

View File

@@ -0,0 +1,59 @@
/* $XConsortium: costat.c /main/2 1996/05/09 03:56:57 drk $ */
/*
* COMPONENT_NAME: austext
*
* FUNCTIONS: d_costat
*
* ORIGINS: 157
*
* OBJECT CODE ONLY SOURCE MATERIALS
*/
/*-----------------------------------------------------------------------
costat.c -- db_VISTA owner timestamp status check module.
(C) Copyright 1987 by Raima Corporation.
-----------------------------------------------------------------------*/
/* ********************** EDIT HISTORY *******************************
SCR DATE INI DESCRIPTION
----- --------- --- -----------------------------------------------------
04-Aug-88 RTK MULTI_TASK changes
*/
#include <stdio.h>
#include "vista.h"
#include "dbtype.h"
#ifndef NO_TIMESTAMP
/* Test timestamp status of current owner
*/
d_costat(set TASK_PARM DBN_PARM)
int set;
TASK_DECL
DBN_DECL
{
ULONG cts, uts;
ULONG cots;
DB_ENTER(DB_ID TASK_ID LOCK_SET(SET_IO));
if ( d_ctsco(set, &cts TASK_PARM DBN_PARM) == S_OKAY ) {
if ( cts ) {
cots = co_time[NUM2INT(set - SETMARK, st_offset)];
if ( cts > cots )
db_status = S_DELETED;
else {
d_utsco(set, &uts TASK_PARM DBN_PARM);
if ( uts > cots )
db_status = S_UPDATED;
}
}
else
dberr(S_TIMESTAMP);
}
RETURN( db_status );
}
#endif
/* vpp -nOS2 -dUNIX -nBSD -nVANILLA_BSD -nVMS -nMEMLOCK -nWINDOWS -nFAR_ALLOC -f/usr/users/master/config/nonwin costat.c */

View File

@@ -0,0 +1,73 @@
/* $XConsortium: cotype.c /main/2 1996/05/09 03:57:15 drk $ */
/*
* COMPONENT_NAME: austext
*
* FUNCTIONS: d_cotype
*
* ORIGINS: 157
*
* OBJECT CODE ONLY SOURCE MATERIALS
*/
/*-----------------------------------------------------------------------
cotype.c -- db_VISTA owner type module.
(C) Copyright 1987 by Raima Corporation.
-----------------------------------------------------------------------*/
/* ********************** EDIT HISTORY *******************************
SCR DATE INI DESCRIPTION
----- --------- --- -----------------------------------------------------
04-Aug-88 RTK MULTI_TASK changes
*/
#include <stdio.h>
#include "vista.h"
#include "dbtype.h"
/* Get current owner type
*/
d_cotype(set, cotype TASK_PARM DBN_PARM)
int set;
int FAR *cotype;
TASK_DECL
DBN_DECL
{
char FAR *orec;
INT crt;
#ifndef SINGLE_USER
int dbopen_sv;
#endif
SET_ENTRY FAR *set_ptr;
DB_ENTER(DB_ID TASK_ID LOCK_SET(SET_IO));
if (nset_check(set, &set, (SET_ENTRY FAR * FAR *)&set_ptr) != S_OKAY)
RETURN( db_status );
if ( ! curr_own[set] )
RETURN( dberr( S_NOCO ) );
/* set up to allow unlocked read */
#ifndef SINGLE_USER
dbopen_sv = dbopen;
dbopen = 2;
#endif
/* Read current owner */
dio_read(curr_own[set], (char FAR * FAR *)&orec, NOPGHOLD);
#ifndef SINGLE_USER
dbopen = dbopen_sv;
#endif
if (db_status != S_OKAY)
RETURN( db_status );
/* Fetch record type from record header */
bytecpy(&crt, orec, sizeof(INT));
crt &= ~RLBMASK; /* mask off rlb */
*cotype = (int)crt + RECMARK;
RETURN( db_status );
}
/* vpp -nOS2 -dUNIX -nBSD -nVANILLA_BSD -nVMS -nMEMLOCK -nWINDOWS -nFAR_ALLOC -f/usr/users/master/config/nonwin cotype.c */

View File

@@ -0,0 +1,46 @@
/* $XConsortium: crget.c /main/2 1996/05/09 03:57:29 drk $ */
/*
* COMPONENT_NAME: austext
*
* FUNCTIONS: d_crget
*
* ORIGINS: 157
*
* OBJECT CODE ONLY SOURCE MATERIALS
*/
/*-----------------------------------------------------------------------
crget.c -- db_VISTA current record database address get module.
(C) Copyright 1987 by Raima Corporation.
-----------------------------------------------------------------------*/
/* ********************** EDIT HISTORY *******************************
SCR DATE INI DESCRIPTION
----- --------- --- -----------------------------------------------------
04-Aug-88 RTK MULTI_TASK changes
*/
#include <stdio.h>
#include "vista.h"
#include "dbtype.h"
/* Get current record
*/
d_crget(dba TASK_PARM DBN_PARM)
DB_ADDR FAR *dba; /* db address of record to become current */
TASK_DECL
DBN_DECL
{
DB_ENTER(DB_ID TASK_ID LOCK_SET(RECORD_NOIO));
if ( ! dbopen ) RETURN( dberr(S_DBOPEN) );
if ( *dba = curr_rec )
db_status = S_OKAY;
else
db_status = S_NOCR;
RETURN( db_status );
}
/* vpp -nOS2 -dUNIX -nBSD -nVANILLA_BSD -nVMS -nMEMLOCK -nWINDOWS -nFAR_ALLOC -f/usr/users/master/config/nonwin crget.c */

View File

@@ -0,0 +1,70 @@
/* $XConsortium: crread.c /main/2 1996/05/09 03:57:43 drk $ */
/*
* COMPONENT_NAME: austext
*
* FUNCTIONS: d_crread
*
* ORIGINS: 157
*
* OBJECT CODE ONLY SOURCE MATERIALS
*/
/*-----------------------------------------------------------------------
crread.c -- db_VISTA current record field read module.
(C) Copyright 1987 by Raima Corporation.
-----------------------------------------------------------------------*/
/* ********************** EDIT HISTORY *******************************
SCR DATE INI DESCRIPTION
----- --------- --- -----------------------------------------------------
04-Aug-88 RTK MULTI_TASK changes
*/
#include <stdio.h>
#include "vista.h"
#include "dbtype.h"
/* Read data from field of current record
*/
d_crread(field, data TASK_PARM DBN_PARM)
long field; /* Field constant */
char FAR *data; /* Data area to contain field contents */
TASK_DECL
DBN_DECL /* database number */
{
int fld, rec;
#ifndef SINGLE_USER
int dbopen_sv;
#endif
RECORD_ENTRY FAR *rec_ptr;
FIELD_ENTRY FAR *fld_ptr;
DB_ENTER(DB_ID TASK_ID LOCK_SET(RECORD_IO));
if (nfld_check(field, &rec, &fld, (RECORD_ENTRY FAR * FAR *)&rec_ptr, (FIELD_ENTRY FAR * FAR *)&fld_ptr) != S_OKAY)
RETURN( db_status );
/* Make sure we have a current record */
if ( ! curr_rec )
RETURN( dberr(S_NOCR) );
/* set up to allow unlocked read */
#ifndef SINGLE_USER
dbopen_sv = dbopen;
dbopen = 2;
#endif
/* Read current record */
dio_read( curr_rec, (char FAR * FAR *)&crloc , NOPGHOLD);
#ifndef SINGLE_USER
dbopen = dbopen_sv;
#endif
if (db_status != S_OKAY)
RETURN( db_status );
/* Get data from record and return */
RETURN( r_gfld(fld_ptr, crloc, data) );
}
/* vpp -nOS2 -dUNIX -nBSD -nVANILLA_BSD -nVMS -nMEMLOCK -nWINDOWS -nFAR_ALLOC -f/usr/users/master/config/nonwin crread.c */

View File

@@ -0,0 +1,48 @@
/* $XConsortium: crset.c /main/2 1996/05/09 03:57:56 drk $ */
/*
* COMPONENT_NAME: austext
*
* FUNCTIONS: d_crset
*
* ORIGINS: 157
*
* OBJECT CODE ONLY SOURCE MATERIALS
*/
/*-----------------------------------------------------------------------
crset.c -- db_VISTA current record database address set module.
(C) Copyright 1987 by Raima Corporation.
-----------------------------------------------------------------------*/
/* ********************** EDIT HISTORY *******************************
SCR DATE INI DESCRIPTION
----- --------- --- -----------------------------------------------------
04-Aug-88 RTK MULTI_TASK changes
*/
#include <stdio.h>
#include "vista.h"
#include "dbtype.h"
/* Set current record
*/
d_crset(dba TASK_PARM DBN_PARM)
DB_ADDR FAR *dba; /* db address of record to become current */
TASK_DECL
DBN_DECL
{
DB_ENTER(DB_ID TASK_ID LOCK_SET(RECORD_IO));
if ( ! dbopen ) RETURN( dberr(S_DBOPEN) );
if ( dba == NULL ) {
curr_rec = NULL_DBA;
db_status = S_OKAY;
}
else if ( check_dba(*dba) == S_OKAY )
curr_rec = *dba;
RETURN( db_status );
}
/* vpp -nOS2 -dUNIX -nBSD -nVANILLA_BSD -nVMS -nMEMLOCK -nWINDOWS -nFAR_ALLOC -f/usr/users/master/config/nonwin crset.c */

View File

@@ -0,0 +1,53 @@
/* $XConsortium: crstat.c /main/2 1996/05/09 03:58:12 drk $ */
/*
* COMPONENT_NAME: austext
*
* FUNCTIONS: d_crstat
*
* ORIGINS: 157
*
* OBJECT CODE ONLY SOURCE MATERIALS
*/
/*-----------------------------------------------------------------------
crstat.c -- db_VISTA current record timestamp status check module.
(C) Copyright 1987 by Raima Corporation.
-----------------------------------------------------------------------*/
/* ********************** EDIT HISTORY *******************************
SCR DATE INI DESCRIPTION
----- --------- --- -----------------------------------------------------
04-Aug-88 RTK MULTI_TASK changes
*/
#include <stdio.h>
#include "vista.h"
#include "dbtype.h"
#ifndef NO_TIMESTAMP
/* Test timestamp status of current record
*/
d_crstat(TASK_ONLY)
TASK_DECL
{
ULONG cts, uts;
DB_ENTER(NO_DB_ID TASK_ID LOCK_SET(RECORD_IO));
if ( d_ctscr(&cts TASK_PARM) == S_OKAY ) {
if ( cts ) {
d_utscr(&uts TASK_PARM);
if ( cts > cr_time )
db_status = S_DELETED;
else if ( uts > cr_time )
db_status = S_UPDATED;
}
else
dberr(S_TIMESTAMP);
}
RETURN( db_status );
}
#endif
/* vpp -nOS2 -dUNIX -nBSD -nVANILLA_BSD -nVMS -nMEMLOCK -nWINDOWS -nFAR_ALLOC -f/usr/users/master/config/nonwin crstat.c */

View File

@@ -0,0 +1,68 @@
/* $XConsortium: crtype.c /main/2 1996/05/09 03:58:25 drk $ */
/*
* COMPONENT_NAME: austext
*
* FUNCTIONS: d_crtype
*
* ORIGINS: 157
*
* OBJECT CODE ONLY SOURCE MATERIALS
*/
/*-----------------------------------------------------------------------
crtype.c -- db_VISTA current record type module.
(C) Copyright 1987 by Raima Corporation.
-----------------------------------------------------------------------*/
/* ********************** EDIT HISTORY *******************************
SCR DATE INI DESCRIPTION
----- --------- --- -----------------------------------------------------
04-Aug-88 RTK MULTI_TASK changes
*/
#include <stdio.h>
#include "vista.h"
#include "dbtype.h"
/* Get current record type
*/
d_crtype(crtype TASK_PARM DBN_PARM)
int FAR *crtype;
TASK_DECL
DBN_DECL
{
INT crt;
#ifndef SINGLE_USER
int dbopen_sv;
#endif
DB_ENTER(DB_ID TASK_ID LOCK_SET(RECORD_IO));
if ( ! dbopen ) RETURN( dberr(S_DBOPEN) );
if ( ! curr_rec )
RETURN( dberr( S_NOCR ) );
/* set up to allow unlocked read */
#ifndef SINGLE_USER
dbopen_sv = dbopen;
dbopen = 2;
#endif
/* Read current record */
dio_read(curr_rec, (char FAR * FAR *)&crloc, NOPGHOLD);
#ifndef SINGLE_USER
dbopen = dbopen_sv;
#endif
if (db_status != S_OKAY)
RETURN( db_status );
/* Fetch record type from record header */
bytecpy(&crt, crloc, sizeof(INT));
crt &= ~RLBMASK; /* mask off rlb */
*crtype = (int)crt + RECMARK;
RETURN( db_status = S_OKAY );
}
/* vpp -nOS2 -dUNIX -nBSD -nVANILLA_BSD -nVMS -nMEMLOCK -nWINDOWS -nFAR_ALLOC -f/usr/users/master/config/nonwin crtype.c */

View File

@@ -0,0 +1,87 @@
/* $XConsortium: crwrite.c /main/2 1996/05/09 03:58:39 drk $ */
/*
* COMPONENT_NAME: austext
*
* FUNCTIONS: d_crwrite
*
* ORIGINS: 157
*
* OBJECT CODE ONLY SOURCE MATERIALS
*/
/*-----------------------------------------------------------------------
crwrite.c -- db_VISTA current record field write module.
(C) Copyright 1987 by Raima Corporation.
-----------------------------------------------------------------------*/
/* ********************** EDIT HISTORY *******************************
SCR DATE INI DESCRIPTION
----- --------- --- -----------------------------------------------------
04-Aug-88 RTK MULTI_TASK changes
*/
#include <stdio.h>
#include "vista.h"
#include "dbtype.h"
/* Write data to a field in the current record
*/
d_crwrite(field, data TASK_PARM DBN_PARM)
long field; /* field constant */
char FAR *data; /* data area to contain field contents */
TASK_DECL
DBN_DECL /* database number */
{
#ifndef NO_TIMESTAMP
ULONG timestamp;
#endif
int stat, fld, rec;
RECORD_ENTRY FAR *rec_ptr;
FIELD_ENTRY FAR *fld_ptr;
DB_ENTER(DB_ID TASK_ID LOCK_SET(SET_IO));
if (nfld_check(field, &rec, &fld, (RECORD_ENTRY FAR * FAR *)&rec_ptr, (FIELD_ENTRY FAR * FAR *)&fld_ptr) != S_OKAY)
RETURN( db_status );
/* compound keys cannot be updated directly */
if ( fld_ptr->fd_type == COMKEY )
RETURN( dberr(S_ISCOMKEY) );
/* field used in compound keys cannot be updated directly */
if ( fld_ptr->fd_flags & COMKEYED )
RETURN( dberr(S_COMKEY) );
/* Make sure we have a current record */
if ( ! curr_rec )
RETURN( dberr(S_NOCR) );
/* Read current record */
if ( dio_read( curr_rec, (char FAR * FAR *)&crloc , PGHOLD) != S_OKAY )
RETURN( db_status );
/* check out the field */
if ( (stat = r_chkfld(fld, fld_ptr, crloc, data)) != S_OKAY ) {
dio_release(curr_rec);
RETURN( db_status = stat );
}
/* put data into record and return */
if ( r_pfld(fld, fld_ptr, crloc, data, &curr_rec) != S_OKAY )
RETURN( db_status );
#ifndef NO_TIMESTAMP
/* check for timestamp */
if ( rec_ptr->rt_flags & TIMESTAMPED ) {
timestamp = dio_pzgetts(rec_ptr->rt_file);
bytecpy( crloc + RECUPTIME, &timestamp, sizeof(LONG));
}
#endif
dio_write(curr_rec, NULL, PGFREE);
#ifndef NO_TIMESTAMP
if (( db_status == S_OKAY ) && ( rec_ptr->rt_flags & TIMESTAMPED ))
cr_time = timestamp;
#endif
RETURN( db_status );
}
/* vpp -nOS2 -dUNIX -nBSD -nVANILLA_BSD -nVMS -nMEMLOCK -nWINDOWS -nFAR_ALLOC -f/usr/users/master/config/nonwin crwrite.c */

View File

@@ -0,0 +1,48 @@
/* $XConsortium: csmget.c /main/2 1996/05/09 03:58:53 drk $ */
/*
* COMPONENT_NAME: austext
*
* FUNCTIONS: d_csmget
*
* ORIGINS: 157
*
* OBJECT CODE ONLY SOURCE MATERIALS
*/
/*-----------------------------------------------------------------------
csmget.c -- db_VISTA current set member database address get module.
(C) Copyright 1987 by Raima Corporation.
-----------------------------------------------------------------------*/
/* ********************** EDIT HISTORY *******************************
SCR DATE INI DESCRIPTION
----- --------- --- -----------------------------------------------------
04-Aug-88 RTK MULTI_TASK changes
*/
#include <stdio.h>
#include "vista.h"
#include "dbtype.h"
/* Get current set member
*/
d_csmget(set, dba TASK_PARM DBN_PARM)
int set; /* Set table entry */
DB_ADDR FAR *dba; /* db address of record to become current */
TASK_DECL
DBN_DECL /* database number */
{
SET_ENTRY FAR *set_ptr;
DB_ENTER(DB_ID TASK_ID LOCK_SET(SET_NOIO));
if (nset_check(set, &set, (SET_ENTRY FAR * FAR *)&set_ptr) != S_OKAY)
RETURN( db_status );
if ( ! (*dba = curr_mem[set]) )
db_status = S_NOCM;
RETURN( db_status );
}
/* vpp -nOS2 -dUNIX -nBSD -nVANILLA_BSD -nVMS -nMEMLOCK -nWINDOWS -nFAR_ALLOC -f/usr/users/master/config/nonwin csmget.c */

View File

@@ -0,0 +1,74 @@
/* $XConsortium: csmread.c /main/2 1996/05/09 03:59:07 drk $ */
/*
* COMPONENT_NAME: austext
*
* FUNCTIONS: d_csmread
*
* ORIGINS: 157
*
* OBJECT CODE ONLY SOURCE MATERIALS
*/
/*-----------------------------------------------------------------------
csmread.c -- db_VISTA current set member field read module.
(C) Copyright 1987 by Raima Corporation.
-----------------------------------------------------------------------*/
/* ********************** EDIT HISTORY *******************************
SCR DATE INI DESCRIPTION
----- --------- --- -----------------------------------------------------
04-Aug-88 RTK MULTI_TASK changes
*/
#include <stdio.h>
#include "vista.h"
#include "dbtype.h"
/* Read data from field of current set member
*/
d_csmread(set, field, data TASK_PARM DBN_PARM)
int set; /* Set constant */
long field; /* Field constant */
char FAR *data; /* Data area to contain field contents */
TASK_DECL
DBN_DECL /* database number */
{
int fld, rec;
#ifndef SINGLE_USER
int dbopen_sv;
#endif
char FAR *recp;
SET_ENTRY FAR *set_ptr;
RECORD_ENTRY FAR *rec_ptr;
FIELD_ENTRY FAR *fld_ptr;
DB_ENTER(DB_ID TASK_ID LOCK_SET(SET_IO));
if ((nset_check(set, &set, (SET_ENTRY FAR * FAR *)&set_ptr) != S_OKAY) ||
(nfld_check(field, &rec, &fld, (RECORD_ENTRY FAR * FAR *)&rec_ptr, (FIELD_ENTRY FAR * FAR *)&fld_ptr) != S_OKAY))
RETURN( db_status );
/* Make sure we have a current member */
if ( ! curr_mem[set] )
RETURN( dberr(S_NOCM) );
/* set up to allow unlocked read */
#ifndef SINGLE_USER
dbopen_sv = dbopen;
dbopen = 2;
#endif
/* Read current member */
dio_read( curr_mem[set], (char FAR * FAR *)&recp , NOPGHOLD);
#ifndef SINGLE_USER
dbopen = dbopen_sv;
#endif
if (db_status != S_OKAY)
RETURN( db_status );
/* Get data from record and return */
RETURN( r_gfld(fld_ptr, recp, data) );
}
/* vpp -nOS2 -dUNIX -nBSD -nVANILLA_BSD -nVMS -nMEMLOCK -nWINDOWS -nFAR_ALLOC -f/usr/users/master/config/nonwin csmread.c */

View File

@@ -0,0 +1,70 @@
/* $XConsortium: csmset.c /main/2 1996/05/09 03:59:23 drk $ */
/*
* COMPONENT_NAME: austext
*
* FUNCTIONS: d_csmset
*
* ORIGINS: 157
*
* OBJECT CODE ONLY SOURCE MATERIALS
*/
/*-----------------------------------------------------------------------
csmset.c -- db_VISTA current set member database address set module.
(C) Copyright 1987 by Raima Corporation.
-----------------------------------------------------------------------*/
/* ********************** EDIT HISTORY *******************************
SCR DATE INI DESCRIPTION
----- --------- --- -----------------------------------------------------
04-Aug-88 RTK MULTI_TASK changes
*/
#include <stdio.h>
#include "vista.h"
#include "dbtype.h"
/* Set current set member
*/
d_csmset(set, dba TASK_PARM DBN_PARM)
int set; /* Set table entry */
DB_ADDR FAR *dba; /* db address of record to become current */
TASK_DECL
DBN_DECL /* database number */
{
INT type;
char FAR *ptr;
SET_ENTRY FAR *set_ptr;
MEMBER_ENTRY FAR *mem_ptr;
int mem, memtot;
DB_ENTER(DB_ID TASK_ID LOCK_SET(SET_IO));
if (nset_check(set, &set, (SET_ENTRY FAR * FAR *)&set_ptr) != S_OKAY)
RETURN( db_status );
if ( dba == NULL ) {
curr_mem[set] = NULL_DBA;
}
else if ( check_dba(*dba) == S_OKAY ) {
/* get the record type */
if ( dio_read( *dba, (char FAR * FAR *)&ptr, NOPGHOLD ) ) RETURN( db_status );
bytecpy( &type, ptr, sizeof(INT) );
type &= ~RLBMASK;
#ifndef ONE_DB
type += curr_db_table->rt_offset;
#endif
for (mem = set_ptr->st_members, memtot = mem + set_ptr->st_memtot,
mem_ptr = &member_table[mem];
mem < memtot;
++mem, ++mem_ptr) {
if (mem_ptr->mt_record == type)
RETURN( r_smem(dba, set) );
}
dberr( S_INVMEM );
}
RETURN( db_status );
}
/* vpp -nOS2 -dUNIX -nBSD -nVANILLA_BSD -nVMS -nMEMLOCK -nWINDOWS -nFAR_ALLOC -f/usr/users/master/config/nonwin csmset.c */

View File

@@ -0,0 +1,92 @@
/* $XConsortium: csmwrite.c /main/2 1996/05/09 03:59:37 drk $ */
/*
* COMPONENT_NAME: austext
*
* FUNCTIONS: d_csmwrite
*
* ORIGINS: 157
*
* OBJECT CODE ONLY SOURCE MATERIALS
*/
/*-----------------------------------------------------------------------
csmwrite.c -- db_VISTA current set member field write module.
(C) Copyright 1987 by Raima Corporation.
-----------------------------------------------------------------------*/
/* ********************** EDIT HISTORY *******************************
SCR DATE INI DESCRIPTION
----- --------- --- -----------------------------------------------------
04-Aug-88 RTK MULTI_TASK changes
*/
#include <stdio.h>
#include "vista.h"
#include "dbtype.h"
/* Write data to a field in the current set member
*/
d_csmwrite(set, field, data TASK_PARM DBN_PARM)
int set; /* Set constant */
long field; /* Field constant */
CONST char FAR *data; /* Data area to contain field contents */
TASK_DECL
DBN_DECL /* database number */
{
#ifndef NO_TIMESTAMP
ULONG timestamp;
#endif
int stat, fld, rec;
char FAR *recp;
SET_ENTRY FAR *set_ptr;
RECORD_ENTRY FAR *rec_ptr;
FIELD_ENTRY FAR *fld_ptr;
DB_ADDR FAR *cm_ptr;
DB_ENTER(DB_ID TASK_ID LOCK_SET(SET_IO));
if ((nset_check(set, &set, (SET_ENTRY FAR * FAR *)&set_ptr) != S_OKAY) ||
(nfld_check(field, &rec, &fld, (RECORD_ENTRY FAR * FAR *)&rec_ptr, (FIELD_ENTRY FAR * FAR *)&fld_ptr) != S_OKAY))
RETURN( db_status );
/* compound keys cannot be updated directly */
if ( fld_ptr->fd_type == COMKEY )
RETURN( dberr(S_ISCOMKEY) );
/* field used in compound keys cannot be updated directly */
if ( fld_ptr->fd_flags & COMKEYED )
RETURN( dberr(S_COMKEY) );
/* Make sure we have a current member */
if ( ! *(cm_ptr = &curr_mem[set]) )
RETURN( dberr(S_NOCM) );
/* Read current member */
if ( dio_read( *cm_ptr, (char FAR * FAR *)&recp , PGHOLD) != S_OKAY )
RETURN( db_status );
/* check out the field */
if ( (stat = r_chkfld(fld, fld_ptr, recp, data)) != S_OKAY ) {
dio_release(*cm_ptr);
RETURN( db_status = stat );
}
/* Put data into record */
if ( r_pfld(fld, fld_ptr, recp, data, cm_ptr) != S_OKAY )
RETURN( db_status );
#ifndef NO_TIMESTAMP
/* check for timestamp */
if ( rec_ptr->rt_flags & TIMESTAMPED ) {
timestamp = dio_pzgetts(rec_ptr->rt_file);
bytecpy( recp + RECUPTIME, &timestamp, sizeof(LONG));
}
#endif
dio_write(*cm_ptr, NULL, PGFREE);
#ifndef NO_TIMESTAMP
if (( db_status == S_OKAY ) && ( rec_ptr->rt_flags & TIMESTAMPED ))
cm_time[set] = timestamp;
#endif
RETURN( db_status );
}
/* vpp -nOS2 -dUNIX -nBSD -nVANILLA_BSD -nVMS -nMEMLOCK -nWINDOWS -nFAR_ALLOC -f/usr/users/master/config/nonwin csmwrite.c */

View File

@@ -0,0 +1,49 @@
/* $XConsortium: csoget.c /main/2 1996/05/09 03:59:50 drk $ */
/*
* COMPONENT_NAME: austext
*
* FUNCTIONS: d_csoget
*
* ORIGINS: 157
*
* OBJECT CODE ONLY SOURCE MATERIALS
*/
/*-----------------------------------------------------------------------
csoget.c -- db_VISTA current set owner database address get module.
(C) Copyright 1987 by Raima Corporation.
-----------------------------------------------------------------------*/
/* ********************** EDIT HISTORY *******************************
SCR DATE INI DESCRIPTION
----- --------- --- -----------------------------------------------------
04-Aug-88 RTK MULTI_TASK changes
*/
#include <stdio.h>
#include "vista.h"
#include "dbtype.h"
/* Get current set owner
*/
d_csoget(set, dba TASK_PARM DBN_PARM)
int set; /* Set table entry */
DB_ADDR FAR *dba; /* db address of record to become current */
TASK_DECL
DBN_DECL /* database number */
{
SET_ENTRY FAR *set_ptr;
DB_ENTER(DB_ID TASK_ID LOCK_SET(SET_NOIO));
if (nset_check(set, &set, (SET_ENTRY FAR * FAR *)&set_ptr) != S_OKAY)
RETURN( db_status );
if ( ! (*dba = curr_own[set]) )
db_status = S_NOCO;
RETURN( db_status );
}
/* vpp -nOS2 -dUNIX -nBSD -nVANILLA_BSD -nVMS -nMEMLOCK -nWINDOWS -nFAR_ALLOC -f/usr/users/master/config/nonwin csoget.c */

View File

@@ -0,0 +1,74 @@
/* $XConsortium: csoread.c /main/2 1996/05/09 04:00:07 drk $ */
/*
* COMPONENT_NAME: austext
*
* FUNCTIONS: d_csoread
*
* ORIGINS: 157
*
* OBJECT CODE ONLY SOURCE MATERIALS
*/
/*-----------------------------------------------------------------------
csoread.c -- db_VISTA current set owner field read module.
(C) Copyright 1987 by Raima Corporation.
-----------------------------------------------------------------------*/
/* ********************** EDIT HISTORY *******************************
SCR DATE INI DESCRIPTION
----- --------- --- -----------------------------------------------------
04-Aug-88 RTK MULTI_TASK changes
*/
#include <stdio.h>
#include "vista.h"
#include "dbtype.h"
/* Read data from field of current set owner
*/
d_csoread(set, field, data TASK_PARM DBN_PARM)
int set; /* Set constant */
long field; /* Field constant */
char FAR *data; /* Data area to contain field contents */
TASK_DECL
DBN_DECL /* database number */
{
int fld, rec;
#ifndef SINGLE_USER
int dbopen_sv;
#endif
char FAR *recp;
SET_ENTRY FAR *set_ptr;
RECORD_ENTRY FAR *rec_ptr;
FIELD_ENTRY FAR *fld_ptr;
DB_ENTER(DB_ID TASK_ID LOCK_SET(SET_IO));
if ((nset_check(set, &set, (SET_ENTRY FAR * FAR *)&set_ptr) != S_OKAY) ||
(nfld_check(field, &rec, &fld, (RECORD_ENTRY FAR * FAR *)&rec_ptr, (FIELD_ENTRY FAR * FAR *)&fld_ptr) != S_OKAY))
RETURN( db_status );
/* Make sure we have a current owner */
if ( ! curr_own[set] )
RETURN( dberr(S_NOCO) );
/* set up to allow unlocked read */
#ifndef SINGLE_USER
dbopen_sv = dbopen;
dbopen = 2;
#endif
/* Read current owner */
dio_read( curr_own[set], (char FAR * FAR *)&recp , NOPGHOLD);
#ifndef SINGLE_USER
dbopen = dbopen_sv;
#endif
if (db_status != S_OKAY)
RETURN( db_status );
/* Get data from record and return */
RETURN( r_gfld(fld_ptr, recp, data) );
}
/* vpp -nOS2 -dUNIX -nBSD -nVANILLA_BSD -nVMS -nMEMLOCK -nWINDOWS -nFAR_ALLOC -f/usr/users/master/config/nonwin csoread.c */

View File

@@ -0,0 +1,66 @@
/* $XConsortium: csoset.c /main/2 1996/05/09 04:00:24 drk $ */
/*
* COMPONENT_NAME: austext
*
* FUNCTIONS: d_csoset
*
* ORIGINS: 157
*
* OBJECT CODE ONLY SOURCE MATERIALS
*/
/*-----------------------------------------------------------------------
csoset.c -- db_VISTA current set owner database address set module.
(C) Copyright 1987 by Raima Corporation.
-----------------------------------------------------------------------*/
/* ********************** EDIT HISTORY *******************************
SCR DATE INI DESCRIPTION
----- --------- --- -----------------------------------------------------
04-Aug-88 RTK MULTI_TASK changes
*/
#include <stdio.h>
#include "vista.h"
#include "dbtype.h"
/* Set current set owner
*/
d_csoset(set, dba TASK_PARM DBN_PARM)
int set; /* Set table entry */
DB_ADDR FAR *dba; /* db address of record to become current */
TASK_DECL
DBN_DECL /* database number */
{
INT type;
char FAR *ptr;
SET_ENTRY FAR *set_ptr;
DB_ENTER(DB_ID TASK_ID LOCK_SET(SET_IO));
if (nset_check(set, &set, (SET_ENTRY FAR * FAR *)&set_ptr) != S_OKAY)
RETURN( db_status );
if ( dba == NULL ) {
curr_own[set] = curr_mem[set] = NULL_DBA;
}
else if ( check_dba(*dba) == S_OKAY ) {
/* get the record type */
if ( dio_read( *dba, (char FAR * FAR *)&ptr , NOPGHOLD) ) RETURN( db_status );
bytecpy( &type, ptr, sizeof(INT) );
type &= ~RLBMASK;
#ifndef ONE_DB
type += curr_db_table->rt_offset;
#endif
if (set_ptr->st_own_rt != type)
RETURN( dberr( S_INVOWN ) );
curr_own[set] = *dba;
curr_mem[set] = NULL_DBA;
}
RETURN( db_status );
}
/* vpp -nOS2 -dUNIX -nBSD -nVANILLA_BSD -nVMS -nMEMLOCK -nWINDOWS -nFAR_ALLOC -f/usr/users/master/config/nonwin csoset.c */

View File

@@ -0,0 +1,92 @@
/* $XConsortium: csowrite.c /main/2 1996/05/09 04:00:40 drk $ */
/*
* COMPONENT_NAME: austext
*
* FUNCTIONS: d_csowrite
*
* ORIGINS: 157
*
* OBJECT CODE ONLY SOURCE MATERIALS
*/
/*-----------------------------------------------------------------------
csowrite.c -- db_VISTA current set owner field write module.
(C) Copyright 1987 by Raima Corporation.
-----------------------------------------------------------------------*/
/* ********************** EDIT HISTORY *******************************
SCR DATE INI DESCRIPTION
----- --------- --- -----------------------------------------------------
04-Aug-88 RTK MULTI_TASK changes
*/
#include <stdio.h>
#include "vista.h"
#include "dbtype.h"
/* Write data to a field in the current set owner
*/
d_csowrite(set, field, data TASK_PARM DBN_PARM)
int set; /* Set constant */
long field; /* Field constant */
CONST char FAR *data; /* Data area to contain field contents */
TASK_DECL
DBN_DECL /* database number */
{
#ifndef NO_TIMESTAMP
ULONG timestamp;
#endif
int stat, fld, rec;
char FAR *recp;
SET_ENTRY FAR *set_ptr;
RECORD_ENTRY FAR *rec_ptr;
FIELD_ENTRY FAR *fld_ptr;
DB_ADDR FAR *co_ptr;
DB_ENTER(DB_ID TASK_ID LOCK_SET(SET_IO));
if ((nset_check(set, &set, (SET_ENTRY FAR * FAR *)&set_ptr) != S_OKAY) ||
(nfld_check(field, &rec, &fld, (RECORD_ENTRY FAR * FAR *)&rec_ptr, (FIELD_ENTRY FAR * FAR *)&fld_ptr) != S_OKAY))
RETURN( db_status );
/* compound keys cannot be updated directly */
if ( fld_ptr->fd_type == COMKEY )
RETURN( dberr(S_ISCOMKEY) );
/* field used in compound keys cannot be updated directly */
if ( fld_ptr->fd_flags & COMKEYED )
RETURN( dberr(S_COMKEY) );
/* Make sure we have a current owner */
if ( ! *(co_ptr = &curr_own[set]) )
RETURN( dberr(S_NOCO) );
/* Read current owner */
if ( dio_read( *co_ptr, (char FAR * FAR *)&recp , PGHOLD) != S_OKAY )
RETURN( db_status );
/* check out the field */
if ( (stat = r_chkfld(fld, fld_ptr, recp, data)) != S_OKAY ) {
dio_release(*co_ptr);
RETURN( db_status = stat );
}
/* Put data into record */
if ( r_pfld(fld, fld_ptr, recp, data, co_ptr) != S_OKAY )
RETURN( db_status );
#ifndef NO_TIMESTAMP
/* check for timestamp */
if ( rec_ptr->rt_flags & TIMESTAMPED ) {
timestamp = dio_pzgetts(rec_ptr->rt_file);
bytecpy( recp + RECUPTIME, &timestamp, sizeof(LONG));
}
#endif
dio_write(*co_ptr, (char FAR *)NULL, PGFREE);
#ifndef NO_TIMESTAMP
if (( db_status == S_OKAY ) && ( rec_ptr->rt_flags & TIMESTAMPED ))
co_time[set] = timestamp;
#endif
RETURN( db_status );
}
/* vpp -nOS2 -dUNIX -nBSD -nVANILLA_BSD -nVMS -nMEMLOCK -nWINDOWS -nFAR_ALLOC -f/usr/users/master/config/nonwin csowrite.c */

View File

@@ -0,0 +1,52 @@
/* $XConsortium: csstat.c /main/2 1996/05/09 04:00:57 drk $ */
/*
* COMPONENT_NAME: austext
*
* FUNCTIONS: d_csstat
*
* ORIGINS: 157
*
* OBJECT CODE ONLY SOURCE MATERIALS
*/
/*-----------------------------------------------------------------------
csstat.c -- db_VISTA current set timestamp status check module.
(C) Copyright 1987 by Raima Corporation.
-----------------------------------------------------------------------*/
/* ********************** EDIT HISTORY *******************************
SCR DATE INI DESCRIPTION
----- --------- --- -----------------------------------------------------
04-Aug-88 RTK MULTI_TASK changes
*/
#include <stdio.h>
#include "vista.h"
#include "dbtype.h"
#ifndef NO_TIMESTAMP
/* Test timestamp status of current set
*/
d_csstat(set TASK_PARM DBN_PARM)
int set;
TASK_DECL
DBN_DECL
{
ULONG uts;
DB_ENTER(DB_ID TASK_ID LOCK_SET(SET_IO));
if ( d_utscs(set, &uts TASK_PARM DBN_PARM) == S_OKAY ) {
if ( uts ) {
if ( uts > cs_time[NUM2INT(set - SETMARK, st_offset)] )
db_status = S_UPDATED;
}
else
dberr(S_TIMESTAMP);
}
RETURN( db_status );
}
#endif
/* vpp -nOS2 -dUNIX -nBSD -nVANILLA_BSD -nVMS -nMEMLOCK -nWINDOWS -nFAR_ALLOC -f/usr/users/master/config/nonwin csstat.c */

View File

@@ -0,0 +1,70 @@
/* $XConsortium: ctscm.c /main/2 1996/05/09 04:01:14 drk $ */
/*
* COMPONENT_NAME: austext
*
* FUNCTIONS: d_ctscm
*
* ORIGINS: 157
*
* OBJECT CODE ONLY SOURCE MATERIALS
*/
/*-----------------------------------------------------------------------
ctscm.c -- db_VISTA current member creation timestamp get module.
(C) Copyright 1987 by Raima Corporation.
-----------------------------------------------------------------------*/
/* ********************** EDIT HISTORY *******************************
SCR DATE INI DESCRIPTION
----- --------- --- -----------------------------------------------------
04-Aug-88 RTK MULTI_TASK changes
*/
#include <stdio.h>
#include "vista.h"
#include "dbtype.h"
#ifndef NO_TIMESTAMP
/* Get creation timestamp of current member
*/
d_ctscm(set, timestamp TASK_PARM DBN_PARM)
int set;
ULONG FAR *timestamp;
TASK_DECL
DBN_DECL
{
INT rec;
char FAR *rptr;
SET_ENTRY FAR *set_ptr;
DB_ENTER(DB_ID TASK_ID LOCK_SET(SET_IO));
if (nset_check(set, &set, (SET_ENTRY FAR * FAR *)&set_ptr) != S_OKAY)
RETURN( db_status );
/* make sure we have a current member */
if ( ! curr_mem[set] )
RETURN( dberr(S_NOCM) );
/* read current member */
if ( dio_read( curr_mem[set], (char FAR * FAR *)&rptr , NOPGHOLD) != S_OKAY )
RETURN( db_status );
/* get record id */
bytecpy(&rec, rptr, sizeof(INT));
if ( rec >= 0 ) {
rec &= ~RLBMASK; /* mask off rlb */
if (record_table[NUM2INT(rec, rt_offset)].rt_flags & TIMESTAMPED)
bytecpy(timestamp, rptr + RECCRTIME, sizeof(ULONG));
else
*timestamp = 0L;
}
else
db_status = S_DELETED;
RETURN( db_status );
}
#endif
/* vpp -nOS2 -dUNIX -nBSD -nVANILLA_BSD -nVMS -nMEMLOCK -nWINDOWS -nFAR_ALLOC -f/usr/users/master/config/nonwin ctscm.c */

View File

@@ -0,0 +1,70 @@
/* $XConsortium: ctsco.c /main/2 1996/05/09 04:01:31 drk $ */
/*
* COMPONENT_NAME: austext
*
* FUNCTIONS: d_ctsco
*
* ORIGINS: 157
*
* OBJECT CODE ONLY SOURCE MATERIALS
*/
/*-----------------------------------------------------------------------
ctsco.c -- db_VISTA current owner creation timestamp get module.
(C) Copyright 1987 by Raima Corporation.
-----------------------------------------------------------------------*/
/* ********************** EDIT HISTORY *******************************
SCR DATE INI DESCRIPTION
----- --------- --- -----------------------------------------------------
04-Aug-88 RTK MULTI_TASK changes
*/
#include <stdio.h>
#include "vista.h"
#include "dbtype.h"
#ifndef NO_TIMESTAMP
/* Get creation timestamp of current owner
*/
d_ctsco(set, timestamp TASK_PARM DBN_PARM)
int set;
ULONG FAR *timestamp;
TASK_DECL
DBN_DECL
{
INT rec;
char FAR *rptr;
SET_ENTRY FAR *set_ptr;
DB_ENTER(DB_ID TASK_ID LOCK_SET(SET_IO));
if (nset_check(set, &set, (SET_ENTRY FAR * FAR *)&set_ptr) != S_OKAY)
RETURN( db_status );
/* make sure we have a current owner */
if ( ! curr_own[set] )
RETURN( dberr(S_NOCO) );
/* read current owner */
if ( dio_read( curr_own[set], (char FAR * FAR *)&rptr , NOPGHOLD) != S_OKAY )
RETURN( db_status );
/* get record id */
bytecpy(&rec, rptr, sizeof(INT));
if ( rec >= 0 ) {
rec &= ~RLBMASK; /* mask off rlb */
if (record_table[NUM2INT(rec, rt_offset)].rt_flags & TIMESTAMPED)
bytecpy(timestamp, rptr + RECCRTIME, sizeof(ULONG));
else
*timestamp = 0L;
}
else
db_status = S_DELETED;
RETURN( db_status );
}
#endif
/* vpp -nOS2 -dUNIX -nBSD -nVANILLA_BSD -nVMS -nMEMLOCK -nWINDOWS -nFAR_ALLOC -f/usr/users/master/config/nonwin ctsco.c */

View File

@@ -0,0 +1,63 @@
/* $XConsortium: ctscr.c /main/2 1996/05/09 04:01:47 drk $ */
/*
* COMPONENT_NAME: austext
*
* FUNCTIONS: d_ctscr
*
* ORIGINS: 157
*
* OBJECT CODE ONLY SOURCE MATERIALS
*/
/*-----------------------------------------------------------------------
ctscr.c -- db_VISTA current record creation timestamp get module.
(C) Copyright 1987 by Raima Corporation.
-----------------------------------------------------------------------*/
/* ********************** EDIT HISTORY *******************************
SCR DATE INI DESCRIPTION
----- --------- --- -----------------------------------------------------
04-Aug-88 RTK MULTI_TASK changes
*/
#include <stdio.h>
#include "vista.h"
#include "dbtype.h"
#ifndef NO_TIMESTAMP
/* Get creation timestamp of current record
*/
d_ctscr(timestamp TASK_PARM)
ULONG FAR *timestamp;
TASK_DECL
{
INT rec;
DB_ENTER(NO_DB_ID TASK_ID LOCK_SET(RECORD_IO));
/* make sure we have a current record */
if ( ! curr_rec )
RETURN( dberr(S_NOCR) );
/* read current record */
if ( dio_read( curr_rec, (char FAR * FAR *)&crloc , NOPGHOLD) != S_OKAY )
RETURN( db_status );
/* get record id */
bytecpy(&rec, crloc, sizeof(INT));
if ( rec >= 0 ) {
rec &= ~RLBMASK; /* mask off rlb */
if (record_table[NUM2INT(rec, rt_offset)].rt_flags & TIMESTAMPED)
bytecpy(timestamp, crloc + RECCRTIME, sizeof(ULONG));
else
*timestamp = 0L;
}
else
db_status = S_DELETED;
RETURN( db_status );
}
#endif
/* vpp -nOS2 -dUNIX -nBSD -nVANILLA_BSD -nVMS -nMEMLOCK -nWINDOWS -nFAR_ALLOC -f/usr/users/master/config/nonwin ctscr.c */

View File

@@ -0,0 +1,46 @@
/* $XConsortium: dbacode.c /main/2 1996/05/09 04:02:05 drk $ */
/*
* COMPONENT_NAME: austext
*
* FUNCTIONS: d_decode_dba
* d_encode_dba
*
* ORIGINS: 157
*
* OBJECT CODE ONLY SOURCE MATERIALS
*/
/*-----------------------------------------------------------------------
dbacode.c -- Module for encoding and decoding database addresses
(C) Copyright 1987 by Raima Corporation.
-----------------------------------------------------------------------*/
#include <stdio.h>
#include "vista.h"
#include "dbtype.h"
/* Decode file and slot number from a database address
*/
d_decode_dba(dba, file, slot)
DB_ADDR dba; /* database address */
int FAR *file; /* returned file number */
long FAR *slot; /* returned slot number */
{
*file = (int)(FILEMASK & (dba >> FILESHIFT));
*slot = ADDRMASK & dba;
return ( db_status = S_OKAY );
}
/* Encode database address from file and slot number
*/
d_encode_dba(file, slot, dba)
int file; /* returned file number */
long slot; /* returned slot number */
DB_ADDR FAR *dba; /* database address */
{
*dba = ((FILEMASK & file) << FILESHIFT) | slot;
return ( db_status = S_OKAY );
}
/* vpp -nOS2 -dUNIX -nBSD -nVANILLA_BSD -nVMS -nMEMLOCK -nWINDOWS -nFAR_ALLOC -f/usr/users/master/config/nonwin dbacode.c */

View File

@@ -0,0 +1,46 @@
/* $XConsortium: dbdpath.c /main/2 1996/05/09 04:02:22 drk $ */
/*
* COMPONENT_NAME: austext
*
* FUNCTIONS: d_dbdpath
*
* ORIGINS: 157
*
* OBJECT CODE ONLY SOURCE MATERIALS
*/
/*-----------------------------------------------------------------------
dbdpath.c -- db_VISTA dictionary path set module.
(C) Copyright 1987 by Raima Corporation.
-----------------------------------------------------------------------*/
/* ********************** EDIT HISTORY *******************************
SCR DATE INI DESCRIPTION
----- --------- --- -----------------------------------------------------
04-Aug-88 RTK MULTI_TASK changes
*/
#include <stdio.h>
#include "vista.h"
#include "dbtype.h"
/* Set Database Dictionary Path
*/
d_dbdpath(path TASK_PARM)
CONST char FAR *path;
TASK_DECL
{
DB_ENTER(NO_DB_ID TASK_ID LOCK_SET(LOCK_NONE));
if (dbopen)
dberr(S_DBOPEN);
else if (strlen(path) >= FILENMLEN - 4)
dberr(S_NAMELEN);
else {
strcpy(dbdpath, path);
db_status = S_OKAY;
}
RETURN( db_status );
}
/* vpp -nOS2 -dUNIX -nBSD -nVANILLA_BSD -nVMS -nMEMLOCK -nWINDOWS -nFAR_ALLOC -f/usr/users/master/config/nonwin dbdpath.c */

View File

@@ -0,0 +1,46 @@
/* $XConsortium: dbfpath.c /main/2 1996/05/09 04:02:40 drk $ */
/*
* COMPONENT_NAME: austext
*
* FUNCTIONS: d_dbfpath
*
* ORIGINS: 157
*
* OBJECT CODE ONLY SOURCE MATERIALS
*/
/*-----------------------------------------------------------------------
dbfpath.c -- db_VISTA files path set module.
(C) Copyright 1987 by Raima Corporation.
-----------------------------------------------------------------------*/
/* ********************** EDIT HISTORY *******************************
SCR DATE INI DESCRIPTION
----- --------- --- -----------------------------------------------------
04-Aug-88 RTK MULTI_TASK changes
*/
#include <stdio.h>
#include "vista.h"
#include "dbtype.h"
/* Set Database Files Path
*/
d_dbfpath(path TASK_PARM)
CONST char FAR *path;
TASK_DECL
{
DB_ENTER(NO_DB_ID TASK_ID LOCK_SET(LOCK_NONE));
if (dbopen)
dberr(S_DBOPEN);
else if (strlen(path) >= FILENMLEN - 1)
dberr(S_NAMELEN);
else {
strcpy(dbfpath, path);
db_status = S_OKAY;
}
RETURN( db_status );
}
/* vpp -nOS2 -dUNIX -nBSD -nVANILLA_BSD -nVMS -nMEMLOCK -nWINDOWS -nFAR_ALLOC -f/usr/users/master/config/nonwin dbfpath.c */

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,172 @@
/* $XConsortium: dblock.h /main/2 1996/05/09 04:02:57 drk $ */
/*
* COMPONENT_NAME: austext
*
* FUNCTIONS: FCNINIT
*
* ORIGINS: 157
*
*/
/* ********************** EDIT HISTORY *******************************
SCR DATE INI DESCRIPTION
----- --------- --- -----------------------------------------------------
368 28-Jul-88 RSC Integrate BSD changes into code
115 16-Aug-88 RSC Integrate VAX/VMS changes into source code
423 09-Sep-88 RSC Change variables to be compatible with MULTI_TASK
420 07-Oct-88 RSC Unoptimized use of fl_list (full of bugs)
441 09-Dec-88 RSC Modified defn of FCNPID for general lockmgr
*/
/* Lock Manager/Runtime function interaction */
/* Network Bios Status codes */
#define N_BUSY 0xff
#define N_OKAY 0x00
#define N_TIMEOUT 0x05
#define N_SESCLOSED 0x0a
#define N_DUPNAME 0x0d
#define N_TABFULL 0x11
#define N_OPENREJ 0x12
#define N_CALLNAME 0x14
#define N_NAMEUSED 0x16
#define N_NAMEDEL 0x17
#define N_SESABORT 0x18
#define N_INTFBUSY 0x21
#define N_COMMANDS 0x22
/* Function/Status codes */
#define L_RECOVER -5
#define L_QUEUEFULL -4
#define L_TIMEOUT -3
#define L_UNAVAIL -2
#define L_SYSERR -1
#define L_OKAY 0
#define L_DBOPEN 1
#define L_DBCLOSE 2
#define L_LOCK 3
#define L_FREE 4
#define L_TRCOMMIT 5
#define L_TREND 6
#define L_SETTIME 7
#define L_RECDONE 8
#define L_LOGIN 9
#define L_DELETE 10
#ifndef LOGFILELEN
#define LOGFILELEN 48
#endif
/* Macros for VMS mailbox usage */
typedef struct LM_LOCKREQ_S {
INT fref;
INT type;
} LM_LOCKREQ;
/* Message packets, Runtime to Lock Manager */
/* Some macro / typdefs to make this file much more readable */
#define PERMISSION 0666
#ifdef GENERAL
/* Defines for GENERAL LOCKMGR */
#define FCNPID INT fcn;
#define FCNDEF INT fcn;
#define FCNINIT() 0
typedef char LM_FILEID;
#else /* GENERAL */
/* Defines for UNIX SYS-V */
#define FCNPID LONG fcn;\
int pid;
#define FCNDEF LONG fcn;
#define FCNINIT() 0
/* Defines for both UNIX SYS-V and BSD */
typedef struct LM_FILEID_S {
ino_t inode;
dev_t device;
} LM_FILEID;
#endif /* GENERAL */
typedef struct LM_LOGIN_S {
FCNPID
char dbusrid[80];
} LM_LOGIN;
typedef struct LM_DBOPEN_S {
FCNPID
INT nfiles;
INT type;
LM_FILEID fnames[1];
} LM_DBOPEN;
typedef struct LM_DBCLOSE_S {
FCNPID
INT nfiles;
INT frefs[1];
} LM_DBCLOSE;
typedef struct LM_LOCK_S {
FCNPID
INT nfiles;
LM_LOCKREQ locks[1];
} LM_LOCK;
typedef struct LM_RECOVERED_S {
FCNPID
} LM_RECOVERED;
typedef struct LM_FREE_S {
FCNPID
INT nfiles;
INT frefs[1];
} LM_FREE;
typedef struct LM_TRCOMMIT_S {
FCNPID
char logfile[LOGFILELEN];
} LM_TRCOMMIT;
typedef struct LM_TREND_S {
FCNPID
} LM_TREND;
typedef struct LM_SETTIME_S {
FCNPID
INT secs;
} LM_SETTIME;
/* Message packets, Lock Manager to Runtime */
typedef struct LR_DBOPEN_S {
FCNDEF
INT status;
char logfile[LOGFILELEN];
INT nusers;
INT nfiles;
INT frefs[1];
} LR_DBOPEN;
typedef struct LR_LOCK_S {
FCNDEF
INT status;
char logfile[LOGFILELEN];
} LR_LOCK;
#define DBLOCK_H
/* vpp -nOS2 -dUNIX -nBSD -nVANILLA_BSD -nVMS -nMEMLOCK -nWINDOWS -nFAR_ALLOC -f/usr/users/master/config/nonwin dblock.h */

View File

@@ -0,0 +1,45 @@
/* $XConsortium: dblog.c /main/2 1996/05/09 04:03:14 drk $ */
/*
* COMPONENT_NAME: austext
*
* FUNCTIONS: d_dblog
*
* ORIGINS: 157
*
* OBJECT CODE ONLY SOURCE MATERIALS
*/
/*-----------------------------------------------------------------------
dblog.c -- db_VISTA database log filename/path set module.
(C) Copyright 1987 by Raima Corporation.
-----------------------------------------------------------------------*/
/* ********************** EDIT HISTORY *******************************
SCR DATE INI DESCRIPTION
----- --------- --- -----------------------------------------------------
04-Aug-88 RTK MULTI_TASK changes
*/
#include <stdio.h>
#include "vista.h"
#include "dbtype.h"
/* Set database log file name/path
*/
d_dblog(log TASK_PARM)
CONST char FAR *log;
TASK_DECL
{
DB_ENTER(NO_DB_ID TASK_ID LOCK_SET(LOCK_NONE));
if (dbopen)
dberr(S_DBOPEN);
else {
strncpy(dblog, log, FILENMLEN - 1);
dblog[FILENMLEN - 1] = '\0';
db_status = S_OKAY;
}
RETURN( db_status );
}
/* vpp -nOS2 -dUNIX -nBSD -nVANILLA_BSD -nVMS -nMEMLOCK -nWINDOWS -nFAR_ALLOC -f/usr/users/master/config/nonwin dblog.c */

View File

@@ -0,0 +1,240 @@
/*
* COMPONENT_NAME: austext
*
* FUNCTIONS: swab_page
*
* ORIGINS: 27
*
* (C) COPYRIGHT International Business Machines Corp. 1996
* All Rights Reserved
* Licensed Materials - Property of IBM
* US Government Users Restricted Rights - Use, duplication or
* disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
*/
/********************* DBSWAB.C **********************************
* $XConsortium: dbswab.c /main/3 1996/10/28 13:59:11 drk $
* July 1996.
* These functions do byte swap and other manipulations on
* vista cache pages to ensure that database files are
* maintained in a canonical format no matter what machine
* they are used on.
* The DtSearch data records are presumed already in external
* file format by code at the DtSearch level (dtsrswab.c).
* These functions use the standard htonl, htons, ntohl, and ntohs
* network conversion functions for byte order neutrality.
* They use the LONG and INT typedefs in vista.h
* to control integer size.
* The external database files are in the canonical,
* big-endian "network" order.
* So that they can be defined as "null" macros on big endian machines,
* the functions (1) always byte swap in place, and (2) always succeed.
*
* $Log$
*/
#include "vista.h"
#include "dbtype.h"
#include "dbswab.h"
#define DEBUG_DBSWAB
#ifdef DEBUG_DBSWAB
#include <stdio.h>
int debugging_dbswab = FALSE;
int debugging_key_swabs = FALSE;
#endif
/********************************/
/* */
/* swab_page */
/* */
/********************************/
/* Performs byte swap on all slots of any cache page except page 0.
* 4-byte timestamp page header already swapped by caller.
*
* WARNING! The algorithms will only work for the
* DtSearch schema. For data pages, they ignore the
* 1-byte optional key flags except for the OR_MISC record.
* The first 6 bytes of each slot (rectype, dba)
* are always byte swapped. Thereafter every 4-bytes
* is swapped as set or member ptrs until we reach
* the data offset. For OR_MISC records we presume
* exactly 1 byte of optional key flags before the
* set/member ptrs.
*/
void swab_page (char *pgbuf, FILE_ENTRY *file_ptr, SWABDIR direction)
{
#ifndef BYTE_SWAP
return;
#else
INT slotno;
char *slotptr;
char *cptr;
INT slsize = file_ptr->ft_slsize;
INT slots = file_ptr->ft_slots; /* # slots per page */
INT recno;
INT used_count;
INT key_prefix;
INT curr_offset, data_offset;
INT align_INT;
LONG align_LONG;
/*----------------- DATA PAGES --------------------
* If file is 'data' file, slots begin immediately after
* the page's timestamp. For each slot we have to swap
* the optional set and member tables as well as fixed
* slot header data.
*/
if (file_ptr->ft_type == DATA) {
#ifdef DEBUG_DBSWAB
if (debugging_dbswab) {
printf (__FILE__"073 %s DATA page '%s': slct=%d slsz=%d pgsz=%d\n",
(direction == HTON)? "WRITE" : "READ",
file_ptr->ft_name, (int)file_ptr->ft_slots,
(int)file_ptr->ft_slsize, (int)file_ptr->ft_pgsize);
fflush(stdout);
}
#endif
for ( slotno = 0, slotptr = pgbuf + 4; /* over timestamp */
slotno < slots;
slotno++, slotptr += slsize) {
/* record number (= record type)
* Save the correct host order value in 'recno'.
*/
memcpy (&align_INT, slotptr, sizeof(INT));
if (direction == HTON) {
recno = align_INT;
HTONS (align_INT);
}
else {
NTOHS (align_INT);
recno = align_INT;
}
memcpy (slotptr, &align_INT, sizeof(INT));
/* dba, or delete chain ptr */
memcpy (&align_LONG, slotptr + sizeof(INT), sizeof(LONG));
align_LONG = HTONL (align_LONG);
memcpy (slotptr + sizeof(INT), &align_LONG, sizeof(LONG));
/* If this is a deleted record, we're done */
if (recno & 0x8000)
continue;
/* Swap 4-byte set/member ptrs till we hit data */
recno &= 0x0fff; /* switch off delete and lock bits */
data_offset = record_table[recno].rt_data;
for ( curr_offset = (recno == MISCREC_RECNO)? 7 : 6;
curr_offset < data_offset;
curr_offset += sizeof(LONG)) {
memcpy (&align_LONG, slotptr + curr_offset, sizeof(LONG));
align_LONG = HTONL (align_LONG);
memcpy (slotptr + curr_offset, &align_LONG, sizeof(LONG));
}
} /* end loop on each slot */
} /* end if (data page) */
/*----------------- KEY PAGES --------------------
* DtSearch doesn't use anything but key and data files
* so this must be a key file. A b-tree node = one cache page.
* Before the slots begin in a key file page there is
* additional header data to be swapped after the timestamp:
* the used_slots count (2 bytes) and the orphan ptr (4 bytes).
* If used_slots == 0, then the page is not used and the
* orphan ptr is really a delete chain ptr for the entire node.
*/
else {
/* 'used_slots'
* Save the correct host order value in 'used_count'.
*/
memcpy (&align_INT, pgbuf + 4, sizeof(INT));
if (direction == HTON) {
used_count = align_INT;
HTONS (align_INT);
}
else {
NTOHS (align_INT);
used_count = align_INT;
}
memcpy (pgbuf + 4, &align_INT, sizeof(INT));
/* 'orphan' ptr or 'delete chain' ptr */
memcpy (&align_LONG, pgbuf + 6, sizeof(LONG));
align_LONG = HTONL (align_LONG);
memcpy (pgbuf + 6, &align_LONG, sizeof(LONG));
#ifdef DEBUG_DBSWAB
if (debugging_dbswab || debugging_key_swabs) {
printf (__FILE__
"124 %s KEY page '%s': slct=%d used=%d slsz=%d pgsz=%d\n",
(direction == HTON)? "WRITE" : "READ",
file_ptr->ft_name, (int)slots,
(int)used_count,
(int)slsize, (int)file_ptr->ft_pgsize);
fflush (stdout);
}
#endif
/* For each used slot we have to swap the key prefix
* at the beginning of the slot, then at the *end*
* of the key, the dba, followed by the child node ptr.
* (This is not the format raima published but it's true!)
* Slots start at pg offset 10: timestamp + used_slots + orphan ptr.
* Note that if used_count == 0, we won't process
* this deleted node any further.
*/
for ( slotno = 0, slotptr = pgbuf + 10;
slotno < used_count;
slotno++, slotptr += slsize) {
/* 'key prefix. Save host order value. */
memcpy (&align_INT, slotptr, sizeof(INT));
if (direction == HTON) {
key_prefix = align_INT;
HTONS (align_INT);
}
else {
NTOHS (align_INT);
key_prefix = align_INT;
}
memcpy (slotptr, &align_INT, sizeof(INT));
#ifdef DEBUG_DBSWAB
if (debugging_key_swabs)
printf (" slot #%02d: prefix=%d",
(int)slotno, (int)key_prefix);
#endif
/* database address.
* All DtSearch keys are unswapped char strings.
* The dba is just past the key, 8 bytes before
* of the end of the slot.
*/
cptr = slotptr + slsize - 8;
memcpy (&align_LONG, cptr, sizeof(LONG));
align_LONG = HTONL (align_LONG);
memcpy (cptr, &align_LONG, sizeof(LONG));
#ifdef DEBUG_DBSWAB
if (debugging_key_swabs) {
printf (" dba=x%08lx key='%s'\n", (direction == NTOH)?
(long)align_LONG : (long)ntohl(align_LONG),
slotptr + 2);
fflush (stdout);
}
#endif
/* 'child ptr'. after dba, 4 bytes before end of slot. */
cptr += 4;
memcpy (&align_LONG, cptr, sizeof(LONG));
align_LONG = HTONL (align_LONG);
memcpy (cptr, &align_LONG, sizeof(LONG));
} /* end loop on each slot */
} /* end if (key page) */
return;
#endif /* BYTE_SWAP */
} /* swab_page() */
/********************* DBSWAB.C **********************************/

View File

@@ -0,0 +1,82 @@
/*
* COMPONENT_NAME: austext
*
* FUNCTIONS: HTONL
* HTONS
* NTOHL
* NTOHS
* SWABDIR
* htonl
* htons
* ntohl
* ntohs
*
* ORIGINS: 27
*
*
* (C) COPYRIGHT International Business Machines Corp. 1996
* All Rights Reserved
* Licensed Materials - Property of IBM
* US Government Users Restricted Rights - Use, duplication or
* disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
*/
/********************* DBSWAB.H **********************************
* $XConsortium: dbswab.h /main/2 1996/10/28 14:00:06 drk $
* July 1996.
* Header file for all internal vista byte swap modifications.
* The mods byte swap vista cache pages, dbd tables, etc,
* to ensure that database files are maintained in a canonical
* format no matter what machine they are used on.
* The DtSearch data records are byte swapped in code at the
* DtSearch level (dtsrswab.c, defns in SearchP.h).
* Byte swap is performed with the standard htonl, htons, ntohl,
* and ntohs network conversion functions for byte order neutrality.
* Canonical integer length is enforced with the typedefs
* LONG and INT in vista.h
* The external database files are in big-endian ("network") order.
* So that they can be defined as "null" macros on big endian machines,
* new functions (1) always byte swap in place, and (2) always succeed.
*
* An #include "vista.h" and #include "dbtype.h" must precede this include.
*
* $Log$
*/
#ifndef _H_DBSWAB
#define _H_DBSWAB
#include <sys/types.h>
#include <netinet/in.h>
/* Record number for OR_MISCREC DtSearch record */
#define MISCREC_RECNO 3
/* Direction of io to indicate correct byte swap function.
* HTON is host to network, internal RAM to external database file.
* NTOH is network to host, file to RAM.
*/
typedef enum {HTON=1, NTOH} SWABDIR;
extern void swab_page (char *pgbuf, FILE_ENTRY *file_ptr, SWABDIR direction);
#ifdef BYTE_SWAP /* ie (BYTE_ORDER != BIG_ENDIAN) */
#define HTONL(x) x = htonl(x)
#define HTONS(x) x = htons(x)
#define NTOHL(x) x = ntohl(x)
#define NTOHS(x) x = ntohs(x)
#else /* !BYTE_SWAP, ie (BYTE_ORDER == BIG_ENDIAN) */
#define HTONL(x)
#define HTONS(x)
#define NTOHL(x)
#define NTOHS(x)
#endif /* BYTE_SWAP */
/******** debug stuff *******/
extern char *debug_keyslot_ptr;
extern void snap_dump (char *label, void *ptr, int len);
/********************* DBSWAB.H **********************************/
#endif /* _H_DBSWAB */

View File

@@ -0,0 +1,64 @@
/* $XConsortium: dbtaf.c /main/3 1996/05/09 04:03:32 drk $ */
/*
* COMPONENT_NAME: austext
*
* FUNCTIONS: d_dbtaf
*
* ORIGINS: 157
*
* OBJECT CODE ONLY SOURCE MATERIALS
*/
/*-----------------------------------------------------------------------
dbtaf.c -- db_VISTA transaction activity filename/path set module.
(C) Copyright 1987 by Raima Corporation.
-----------------------------------------------------------------------*/
/* ********************** EDIT HISTORY *******************************
SCR DATE INI DESCRIPTION
----- --------- --- -----------------------------------------------------
04-Aug-88 RTK MULTI_TASK changes
05-May-89 WLW Added TASK_PARM for multi-tasking
*/
#include <stdio.h>
#include "vista.h"
#include "dbtype.h"
static char VISTATAF[] = "vista.taf";
/* Set database transaction activity file name/path
*/
d_dbtaf(taf TASK_PARM)
CONST char FAR *taf;
TASK_DECL
{
char dbtaf[FILENMLEN];
int len;
DB_ENTER(NO_DB_ID TASK_ID LOCK_SET(LOCK_NONE));
if (dbopen)
dberr(S_DBOPEN);
else {
len = strlen(taf);
if (len > (FILENMLEN - 1)) {
strncpy(dbtaf, taf, FILENMLEN - 1);
dbtaf[FILENMLEN - 1] = '\0';
}
else if (taf[len - 1] == DIRCHAR) {
if (len > (FILENMLEN - sizeof(VISTATAF))) {
strncpy(dbtaf, taf, FILENMLEN - sizeof(VISTATAF) - 1);
dbtaf[(len = (FILENMLEN - sizeof(VISTATAF))) - 1] = DIRCHAR;
}
else
strcpy(dbtaf, taf);
strcpy(&dbtaf[len], VISTATAF);
}
else
strcpy(dbtaf, taf);
db_status = S_OKAY;
}
RETURN (db_status = S_OKAY);
}
/* vpp -nOS2 -dUNIX -nBSD -nVANILLA_BSD -nVMS -nMEMLOCK -nWINDOWS -nFAR_ALLOC -f/usr/users/master/config/nonwin dbtaf.c */

View File

@@ -0,0 +1,626 @@
/*
* COMPONENT_NAME: austext
*
* FUNCTIONS: ALLOC
* BITS
* CALLOC
* DB_ENTER
* DB_REF
* FREE
* LOCK_SET
* MEM_LOCK
* MEM_UNLOCK
* NUM2EXT
* NUM2INT
* ORIGIN
* RETURN
* RN_REF
* TABLE_SIZE
* arraysize
* bytecmp
* bytecpy
* byteset
*
* ORIGINS: 27,157
*
* (C) COPYRIGHT International Business Machines Corp. 1995, 1996
* All Rights Reserved
* US Government Users Restricted Rights - Use, duplication or
* disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
*/
/*----------------------------------------------------------------------------
$TOG: dbtype.h /main/6 1998/03/19 19:00:38 mgreess $
dbtype.h: Standard db_VISTA header file containing:
- DDL dictionary type definitions
- Machine dependent constant definitions
- Miscellaneous constants used by runtime functions
- Virtual memory page table type definitions
(An #include "vista.h" must precede this include)
(C) Copyright 1984, 1985, 1986 by Raima Corporation.
----------------------------------------------------------------------------*/
/* ********************** EDIT HISTORY *******************************
SCR DATE INI DESCRIPTION
----- --------- --- -----------------------------------------------------
101 21-Jun-88 RSC Added rn_type and rn_dba to database table
344 06-Jul-88 RSC LOGFILELEN also defined in dblock.h - add ifndef
115 18-Jul-88 RSC Integrate VAX VMS changes
21-Jul-88 RSC Fix bugaboo in VAX integration
368 28-Jul-88 RSC Integrate BSD changes into code
310 10-Aug-88 RSC Cleanup function prototype
19-Aug-88 RSC Moved rn_type,rn_dba to separate table for compatibility
with db_QUERY and db_REVISE
423 10-Sep-88 RSC Add dbpush names for netunix.c
423 22-Sep-88 RSC Modify/simplify DB_ENTER macro for Lattice compiler
368 23-Sep-88 RSC Change type of pid from INT to int and
corrected defn of MESSAGE
423 26-Sep-88 RSC Moved INIT_PAGE_P defn to initial.c
11-Oct-88 RSC Fix for ONE_DB compile
441 06-Dec-88 RSC Move defn of MESSAGE from netgen.h to here
532 06-Jan-89 RSC Fixed defn of DB_ID for ONE_DB
$Log$
* Revision 1.2 1995/10/13 18:29:38 miker
* Added #define DtSrFILENMLEN to expand max filename len.
* Changed FILENMLEN from 48 to DtSrFILENMLEN (240: 256 - 16).
*/
/* Compiler dependencies are handled with ifdef macros:
NOTE: One of these macros should be defined on the compile command,
for example
cc -c -DUNIX fillnew.c
Failure to do so will produce compilation errors.
UNIX = Unix C compiler
LAT = Lattice
MSC = Microsoft
AZ = Aztec
C86 = CI C86
DS = DeSmet
VMS = Vax/VMS
HHS = Harris H-series
*/
#ifdef NO_TRANS
#define SINGLE_USER
#endif
#ifdef SINGLE_USER
#define NO_TIMESTAMP
#endif
#define PGHOLD 1
#define NOPGHOLD 0
#define PGFREE 1
#define NOPGFREE 0
#define KEYFIND 0
#define KEYNEXT 1
#define KEYPREV 2
#define KEYFRST 3
#define KEYLAST 4
/* dictionary attribute flags */
#define SORTFLD 0x0001 /* field is a set sort field */
#define STRUCTFLD 0x0002 /* field is sub-field of struct */
#define UNSIGNEDFLD 0x0004 /* field is unsigned */
#define STATIC 0x0002 /* file/record is static */
#define LOCAL 0x0004 /* file/record is local */
#define COMKEYED 0x0010 /* record/field contains/included in compound key */
#define TIMESTAMPED 0x0001 /* record/set is timestamped */
#define TRUE 1
#define FALSE 0
#define YES 1
#define NO 0
#define BITS_PER_BYTE 8
/* Number of bits in a "type" */
#define BITS( type ) (BITS_PER_BYTE * sizeof( type ))
/* Number of elements in a vector */
#define arraysize(v) (sizeof(v)/sizeof(*(v)))
/* Number of bytes in a disk block */
#define D_BLKSZ 512
#define DBD_COMPAT_LEN 6
#define INT_SIZE sizeof(int)
#define SHORT_SIZE sizeof(short)
#define LONG_SIZE sizeof(long)
#ifndef NO_FLOAT
#define FLOAT_SIZE sizeof(float)
#define DOUBLE_SIZE sizeof(double)
#endif
#define CHAR_SIZE sizeof(char)
#define DB_ADDR_SIZE sizeof(LONG)
#define PGHDRSIZE 4
#define CTBNAME "vista.ctb"
#define RECHDRSIZE 6
#define NONE -1
/* FILEMASK, ADDRMASK, FILESHIFT always operate on 4-byte variables */
#define FILEMASK 0x000000FF
#define ADDRMASK 0x00FFFFFF
#define FILESHIFT 24
#define OPTKEYSHIFT 10
#define OPTKEYMASK 0xFC00
#define OPTKEYNDX 0x003F
#define OPTKEY_LIMIT 63
#define RLBMASK 0x4000
/* The following constants all depend on the size of INT and DB_ADDR */
/* creation timestamp in rec hdr = sizeof(INT) + DB_ADDR_SIZE */
#define RECCRTIME 6
/* update timestamp in rec hdr = RECCRTIME + sizeof(LONG) */
#define RECUPTIME 10
/* member count prior + next timestamp (opt) */
/* max size of set pointer = sizeof(LONG) + 2*DB_ADDR_SIZE + sizeof(ULONG) */
#define SETPSIZE 16
/* Offset to total members in set ptr */
#define SP_MEMBERS 0
/* Offset to first member ptr in set ptr */
#define SP_FIRST 4
/* Offset to last member ptr in set ptr = 2+DB_ADDR_SIZE */
#define SP_LAST 8
#ifndef NO_TIMESTAMP
/* Offset to timestamp in set ptr */
#define SP_UTIME 12
#endif
/* Size of member pointer = 3*DB_ADDR_SIZE */
#define MEMPSIZE 12
/* Offset to owner ptr in member ptr */
#define MP_OWNER 0
/* Offset to previous member ptr in member ptr = DB_ADDR_SIZE */
#define MP_PREV 4
/* Offset to next member ptr in member ptr = 2*DB_ADDR_SIZE */
#define MP_NEXT 8
/* maximum length of a database file name */
#define DtSrFILENMLEN 240 /* expand max filename len from 48 */
#ifndef FILENMLEN
#define FILENMLEN DtSrFILENMLEN
#endif
#ifndef LOGFILELEN
#define LOGFILELEN 48
#endif
/* maximum length of a database name */
#define DBNMLEN 12
/* maximum length of a database path */
#define PATHLEN FILENMLEN-15
#define MAXDIMS 3
#define OPEN 'o'
#define CLOSED 'c'
#define DATA 'd'
#define KEY 'k'
#define OVERFLOW 'o'
typedef struct FILE_ENTRY_S {
char ft_name[FILENMLEN]; /* name of file */
INT ft_desc; /* file descriptor */
char ft_status; /* 'o'=opened, 'c'=closed */
char ft_type; /* 'd'=data, 'k'=key, 'o'=overflow */
INT ft_slots; /* record slots per page */
INT ft_slsize; /* size of record slots in bytes */
INT ft_pgsize; /* size of page */
INT ft_flags; /* 0x0002 is set if file is static */
} FILE_ENTRY;
typedef struct RECORD_ENTRY_S {
INT rt_file; /* file table entry of file containing record */
INT rt_len; /* total length of record */
INT rt_data; /* offset to start of data in record */
INT rt_fields; /* first field def in field_table */
INT rt_fdtot; /* total number of fields in record */
INT rt_flags; /* 0x0001 is set if record is timestamped
0x0002 is set if record is static */
} RECORD_ENTRY;
#define FIRST 'f'
#define LAST 'l'
#define ASCENDING 'a'
#define DESCENDING 'd'
#define NOORDER 'n'
#define NEXT 'n'
typedef struct SET_ENTRY_S {
INT st_order; /* 'f'=first, 'l'=last, 'a'=ascending,
'd'=descending, 'n'=no order */
INT st_own_rt; /* record table entry of owner */
INT st_own_ptr; /* offset to set pointers in record */
INT st_members; /* index of first member record in member table */
INT st_memtot; /* total number of members of set */
INT st_flags; /* 0x0001 is set if record is timestamped */
} SET_ENTRY;
typedef struct MEMBER_ENTRY_S {
INT mt_record; /* record table entry for this member */
INT mt_mem_ptr; /* offset to member ptrs in record */
INT mt_sort_fld; /* sort table entry of first sort field */
INT mt_totsf; /* total number of sort fields */
} MEMBER_ENTRY;
typedef struct SORT_ENTRY_S {
INT se_fld; /* field table entry of sort field */
INT se_set; /* set table entry of sorted set */
} SORT_ENTRY;
#define NOKEY 'n'
#define DUPLICATES 'd'
#define UNIQUE 'u'
#define CHARACTER 'c'
#define SHORTINT 's'
#define REGINT 'i'
#define LONGINT 'l'
#ifndef NO_FLOAT
#define FLOAT 'f'
#define DOUBLE 'F'
#endif
#define DBADDR 'd'
#define GROUPED 'g'
#define COMKEY 'k'
typedef struct FIELD_ENTRY_S {
char fd_key; /* 'n'=none, 'd'=duplicates, 'u'=unique */
char fd_type; /* 'c'=char, 's'=short, 'i'=int, 'l'=long, 'd'=DB_ADDR,
'f' = float, 'D' = double, 'g'=grouped field,
'k' = compound key */
INT fd_len; /* length of field in bytes */
INT fd_dim[MAXDIMS]; /* size of each array dimension */
INT fd_keyfile; /* file_table entry for key file */
INT fd_keyno; /* key prefix number */
INT fd_ptr; /* offset to field in record or
1st compound key field in key_table */
INT fd_rec; /* record table entry of record containing field */
INT fd_flags; /* 0x0001 is set if field in "by" clause of set spec
0x0002 is set if field member of struct field
0x0004 is set if field is unsigned data type
0x0008 is set if field is an optional key */
} FIELD_ENTRY;
/* compound key table entry declaration */
typedef struct KEY_ENTRY_S {
INT kt_key; /* compound key field number */
INT kt_field; /* field number of included field */
INT kt_ptr; /* offset to start of field data in key */
INT kt_sort; /* 'a' = ascending, 'd' = descending */
} KEY_ENTRY;
#ifndef ONE_DB
/* database table entry declaration */
typedef struct DB_ENTRY_S {
char db_name[DBNMLEN]; /* name of this database */
char db_path[PATHLEN]; /* name of path to this database */
DB_ADDR sysdba; /* database address of system record */
DB_ADDR curr_dbt_rec;/* this db's current record */
INT Page_size; /* size of this db's page */
INT Size_ft; /* size of this db's file_table */
INT ft_offset; /* offset to start of this db's file_table entries */
INT Size_rt; /* size of this db's record_table */
INT rt_offset; /* offset to start of this db's record_table entries */
INT Size_fd; /* size of this db's field_table */
INT fd_offset; /* offset to start of this db's field_table entries */
INT Size_st; /* size of this db's set_table */
INT st_offset; /* offset to start of this db's set_table entries */
INT Size_mt; /* size of this db's member_table */
INT mt_offset; /* offset to start of this db's member_table entries */
INT Size_srt; /* size of this db's sort_table */
INT srt_offset; /* offset to start of this db's sort_table entries */
INT Size_kt; /* size of this db's key_table */
INT kt_offset; /* offset to strary of this db's key table entries */
INT key_offset; /* key prefix offset for this db */
} DB_ENTRY;
/* Structure containing current record type & address for recfrst/set/next..*/
typedef struct RN_ENTRY_S {
INT rn_type; /* Last record type supplied to recfrst/recset */
DB_ADDR rn_dba; /* Last db addr computed by recfrst/recset/recnext */
} RN_ENTRY;
#define DB_REF(item) (db_global.Curr_db_table->item)
#define RN_REF(item) (curr_rn_table->item)
#define NUM2INT(num, offset) ((num) + db_global.Curr_db_table->offset)
#define NUM2EXT(num, offset) ((num) - db_global.Curr_db_table->offset)
#define ORIGIN(offset) (curr_db_table->offset)
#ifndef NO_DBN
#define CURR_DB_PARM , curr_db
#define DBN_PARM , dbn
#define DBN_ONLY dbn
#define DBN_DECL int dbn;
#else
#define CURR_DB_PARM /**/
#define DBN_PARM /**/
#define DBN_ONLY /**/
#define DBN_DECL /**/
#endif
#else
#define DB_REF(item) (db_global.item)
#define RN_REF(item) (db_global.item)
#define NUM2INT(num, offset) (num)
#define NUM2EXT(num, offset) (num)
#define ORIGIN(offset) (0)
#define CURR_DB_PARM /**/
#define DBN_PARM /**/
#define DBN_ONLY /**/
#define DBN_DECL /**/
#endif
#define TABLE_SIZE(size) DB_REF(size)
/* DBN_PARM... and TASK_PARM... are used for function interfaces */
#ifdef MULTI_TASK
#define TASK_PARM , task
#define TASK_PARM_DBN task ,
#define TASK_ONLY task
#define TASK_DECL DB_TASK task;
#define TASK_PTR_DECL DB_TASK FAR *task;
#define TASK_DBN_ONLY task DBN_PARM
#else
#define TASK_PARM /**/
#define TASK_PARM_DBN /**/
#define TASK_ONLY /**/
#define TASK_DECL /**/
#define TASK_PTR_DECL /**/
#define TASK_DBN_ONLY DBN_ONLY
#endif
#ifndef NO_COUNTRY
/* Country code table definition */
typedef struct CNTRY_TBL_S {
unsigned char out_chr;
unsigned char sort_as1;
unsigned char sort_as2;
unsigned char sub_sort;
} CNTRY_TBL;
#endif
/* names lists structure declaration */
typedef struct OBJNAMES_S {
char **recs;
char **flds;
char **sets;
} OBJNAMES;
/* directory separator character:
MS-DOS: '\'
UNIX: '/'
*/
#ifdef HHS
#define DIRCHAR '*'
#else
#define DIRCHAR '/'
#endif
/* The following define aid in the use of a set of routines which use RMS
directly to do the i/o to database files. */
#define DB_OPEN open_b
#define DB_CLOSE close
#define DB_LSEEK lseek
#define DB_WRITE write
#define DB_READ read
typedef struct {FILE_NO FAR *ptr; LOCK_DESC} FILE_NO_P;
typedef struct {int FAR *ptr; LOCK_DESC} INT_P;
typedef struct {struct NODE_PATH_S FAR *ptr; LOCK_DESC} NODE_PATH_P;
#ifndef SINGLE_USER
typedef struct {struct lock_descr FAR *ptr; LOCK_DESC} LOCK_DESCR_P;
typedef struct {struct LM_LOCK_S FAR *ptr; LOCK_DESC} LM_LOCK_P;
typedef struct {struct LM_FREE_S FAR *ptr; LOCK_DESC} LM_FREE_P;
typedef struct {struct LM_DBOPEN_S FAR *ptr; LOCK_DESC} LM_DBOPEN_P;
typedef struct {struct LM_DBCLOSE_S FAR *ptr; LOCK_DESC} LM_DBCLOSE_P;
typedef struct {struct LR_DBOPEN_S FAR *ptr; LOCK_DESC} LR_DBOPEN_P;
#endif
typedef struct {struct KEY_INFO_S FAR *ptr; LOCK_DESC} KEY_INFO_P;
typedef struct {struct ren_entry FAR *ptr; LOCK_DESC} REN_ENTRY_P;
typedef struct {struct RN_ENTRY_S FAR *ptr; LOCK_DESC} RN_ENTRY_P;
typedef struct {struct LOOKUP_ENTRY_S FAR *ptr; LOCK_DESC} LOOKUP_ENTRY_P;
typedef struct {struct page_entry FAR *ptr; LOCK_DESC} PAGE_ENTRY_P;
typedef struct {struct DB_ENTRY_S FAR *ptr; LOCK_DESC} DB_ENTRY_P;
typedef struct {struct FILE_ENTRY_S FAR *ptr; LOCK_DESC} FILE_ENTRY_P;
typedef struct {struct RECORD_ENTRY_S FAR *ptr; LOCK_DESC} RECORD_ENTRY_P;
typedef struct {struct SET_ENTRY_S FAR *ptr; LOCK_DESC} SET_ENTRY_P;
typedef struct {struct MEMBER_ENTRY_S FAR *ptr; LOCK_DESC} MEMBER_ENTRY_P;
typedef struct {struct SORT_ENTRY_S FAR *ptr; LOCK_DESC} SORT_ENTRY_P;
typedef struct {struct FIELD_ENTRY_S FAR *ptr; LOCK_DESC} FIELD_ENTRY_P;
typedef struct {struct KEY_ENTRY_S FAR *ptr; LOCK_DESC} KEY_ENTRY_P;
typedef struct {struct PGZERO_S FAR *ptr; LOCK_DESC} PGZERO_P;
typedef struct {struct RI_ENTRY_S FAR *ptr; LOCK_DESC} RI_ENTRY_P;
typedef struct {ULONG FAR *ptr; LOCK_DESC} ULONG_P;
typedef struct {LONG FAR *ptr; LOCK_DESC} LONG_P;
#ifndef NO_COUNTRY
typedef struct {struct CNTRY_TBL_S FAR *ptr; LOCK_DESC} CNTRY_TBL_P;
#endif
static struct sk {
INT sk_fld;
CHAR_P sk_val;
} __SK__;
typedef struct { struct sk FAR *ptr; LOCK_DESC } SK_P;
/* node key search path stack entry: one per level per key field */
typedef struct NODE_PATH_S {
F_ADDR node; /* node (page) number */
INT slot; /* slot number of key */
} NODE_PATH;
/* index key information: one entry per key field */
typedef struct KEY_INFO_S {
NODE_PATH_P Node_path; /* stack of node #s in search path */
INT level; /* current level # in node path */
INT max_lvls; /* maximum possible levels for key */
INT lstat; /* last key function status */
INT fldno; /* field number of key */
FILE_NO keyfile; /* key file containing this key */
CHAR_P Keyval; /* ptr to last key value */
DB_ADDR dba; /* db address of last key */
} KEY_INFO;
#define node_path Node_path.ptr
#define keyval Keyval.ptr
/* key slot structure */
typedef struct key_slot {
F_ADDR child; /* child node pointer */
INT keyno; /* key number */
char data[1]; /* start of key data */
} KEY_SLOT;
typedef union key_type {
char kd[256];
struct key_slot ks;
} KEY_TYPE;
/* file rename table entry declarations */
typedef struct ren_entry {
CHAR_P Ren_db_name;
CHAR_P File_name;
FILE_NO file_no;
} REN_ENTRY;
#define bytecpy(s1, s2, n) memcpy((char *)(s1), (char *)(s2), (unsigned)(n))
#define bytecmp(s1, s2, n) memcmp((char *)(s1), (char *)(s2), (unsigned)(n))
#define byteset(s, c, n) memset((char *)(s), (char)(c), (unsigned)(n))
typedef struct MESSAGE_S {
#ifdef GENERAL
INT mtype;
char mtext[1];
#else /* GENERAL */
LONG mtype;
int pid;
char mtext[1];
#endif /* GENERAL */
} MESSAGE;
#ifdef ONE_DB
#define NO_DBN
#endif
#ifndef NO_DBN /* NO_DBN */
#ifdef COMMA /* COMMA */
#define DB_ID , dbn
#define NO_DB_ID , -1
#define DBN_PARAM , b
#else /* COMMA */
#define DB_ID dbn
#define NO_DB_ID -1
#define DBN_PARAM b
#define COMMA
#endif /* COMMA */
#else /* NO_DBN */
#define DBN_PARAM /**/
#define DB_ID /**/
#define DB_PARM /**/
#define NO_DB_ID /**/
#endif /* NO_DBN */
#ifdef MULTI_TASK
#ifdef COMMA
#define TASK_ID , &task
#define TASK_PTR_ID , task
#define NO_TASK_ID , NULL
#define TASK_PARAM , c
#else
#define TASK_ID &task
#define TASK_PTR_ID task
#define NO_TASK_ID NULL
#define TASK_PARAM c
#define COMMA
#endif
#else
#define TASK_PARAM /**/
#define TASK_ID /**/
#define TASK_PTR_ID /**/
#define NO_TASK_ID /**/
#endif
#define LOCK_PARAM /**/
#define LOCK_PARM /**/
#define LOCK_DECL /**/
#define LOCK_SET(a) /**/
#define TDTL_PARAM DBN_PARAM TASK_PARAM LOCK_PARAM
#define DB_ENTER(TDTL_PARAM) if ( startup(TDTL_PARAM) != S_OKAY ) { return( db_status ); } else
#define RETURN(x) return( x )
#define ALLOC(l, b, v) d_alloc(b)
#define CALLOC(l, i, s, v) d_calloc(i, s)
#define MEM_LOCK(cp) d_memlock((CHAR_P FAR *)(cp))
#define MEM_UNLOCK(cp) d_memunlock((CHAR_P FAR *)(cp))
#define FREE(cp) d_free((CHAR_P FAR *)(cp))
/* Lock sets are defined in dblfcns.c */
#define LOCK_NONE -1
#define LOCK_ALL 0
#define LOCK_IO 1
#define LOCK_NOIO 2
#define RECORD_IO 3
#define RECORD_NOIO 4
#define SET_IO 5
#define SET_NOIO 6
#ifdef GENERAL
#define TIMEOUT_DEF 20
#else
#define TIMEOUT_DEF 10
#endif
#include <sys/types.h>
#include <sys/stat.h>
#include "trxlog.h"
#include "dblock.h"
#include "ll.h"
#include "dbxtrn.h"
typedef struct LOOKUP_ENTRY_S {
#ifdef MULTI_TASK
TASK FAR *task; /* task pointer */
#endif
FILE_NO file; /* file table entry number (0..size_ft-1) */
F_ADDR pageno; /* database page number */
short pg_slot; /* page table slot pointing to this entry */
} LOOKUP_ENTRY;
/* virtual page table entry */
typedef struct page_entry {
BOOLEAN recently_used; /* LRU flag */
BOOLEAN modified; /* TRUE if page has been modified */
INT holdcnt; /* "hold-in-cache" counter */
short lu_slot; /* lookup table slot pointing to this entry */
#ifndef NO_TRANS
F_ADDR ovfl_addr; /* overflow file address of page */
#endif
CHAR_P Buff; /* page buffer pointer */
} PAGE_ENTRY;
#define buff Buff.ptr
#include "proto.h"
#ifdef MULTI_TASK
#ifdef NO_DT_COVER
#include "dtcover.h"
#endif
#endif
#ifndef SINGLE_USER
/* record/set lock descriptor */
struct lock_descr {
FILE_NO_P fl_list; /* array of files used by record/set */
int fl_cnt; /* Number of elements in fl_list */
BOOLEAN fl_kept; /* Is lock kept after transaction? */
char fl_type; /* lock type: 'r' = read, 'w' = write,
'x' = exclusive, 'f' = free */
char fl_prev; /* previous lock type */
};
#endif
/* vpp -nOS2 -dUNIX -nBSD -nVANILLA_BSD -nVMS -nMEMLOCK -nWINDOWS -nFAR_ALLOC dbtype.h */

View File

@@ -0,0 +1,58 @@
/* $XConsortium: dbuserid.c /main/2 1996/05/09 04:03:46 drk $ */
/*
* COMPONENT_NAME: austext
*
* FUNCTIONS: d_dbuserid
*
* ORIGINS: 157
*
* OBJECT CODE ONLY SOURCE MATERIALS
*/
/*-----------------------------------------------------------------------
dbuserid.c -- db_VISTA user identifier set module.
(C) Copyright 1987 by Raima Corporation.
-----------------------------------------------------------------------*/
/* ********************** EDIT HISTORY *******************************
SCR DATE INI DESCRIPTION
----- --------- --- -----------------------------------------------------
04-Aug-88 RTK MULTI_TASK changes
418 05-Oct-88 RSC also allow underscores in dbuserid
*/
#include <stdio.h>
#include <ctype.h>
#include "vista.h"
#include "dbtype.h"
/* Set Database User Identifier
*/
d_dbuserid(id TASK_PARM)
CONST char FAR *id;
TASK_DECL
{
CONST char FAR *chk_id;
DB_ENTER(NO_DB_ID TASK_ID LOCK_SET(LOCK_NONE));
for (chk_id = id; *chk_id; chk_id++) {
if (isascii(*chk_id)) {
if (!isalnum(*chk_id)) {
if (*chk_id != '_') RETURN ( dberr(S_BADUSERID));
}
}
else RETURN ( dberr(S_BADUSERID));
}
if (dbopen)
dberr(S_DBOPEN);
else {
strncpy(dbuserid, id, FILENMLEN - 1);
dbuserid[FILENMLEN - 1] = '\0';
db_status = S_OKAY;
}
RETURN( db_status );
}
/* vpp -nOS2 -dUNIX -nBSD -nVANILLA_BSD -nVMS -nMEMLOCK -nWINDOWS -nFAR_ALLOC -f/usr/users/master/config/nonwin dbuserid.c */

View File

@@ -0,0 +1,266 @@
/* $XConsortium: dbxtrn.h /main/2 1996/05/09 04:04:00 drk $ */
/*
* COMPONENT_NAME: austext
*
* FUNCTIONS: none
*
* ORIGINS: 157
*
*/
/*----------------------------------------------------------------------------
dbxtrn.h: db_VISTA external data header file
(This file is included by dbtype.h)
(C) Copyright 1984 by Raima Corporation.
----------------------------------------------------------------------------*/
/* ********************** EDIT HISTORY *******************************
SCR DATE INI DESCRIPTION
----- --------- --- -----------------------------------------------------
423 22-Sep-88 RSC Cleanup file to compile under Lattice
368 23-Sep-88 RSC Changed defn of Last_mtype to match dbtype.h
439 17-Nov-88 RSC Integrate 3.10 branch (w/o windows) into main
440 13-Dec-88 RSC LR_LOCK was removed from db_global for general LM
532 06-Jan-89 RSC Fixed defns of rn_dba/type,db_name for ONE_DB
05-May-89 WLW Changed TASK_P to DB_TASK for query multi-tasking
*/
/* Database Dictionary Tables */
extern INT largest_page;
#ifndef ONE_DB
extern INT old_size_ft;
extern INT old_size_fd;
extern INT old_size_st;
extern INT old_size_mt;
extern INT old_size_srt;
extern INT old_size_kt;
extern INT old_size_rt;
extern INT old_no_of_dbs;
#else
#define old_size_ft 0
#define old_size_fd 0
#define old_size_st 0
#define old_size_mt 0
#define old_size_srt 0
#define old_size_kt 0
#define old_size_rt 0
#define old_no_of_dbs 0
#endif
extern char FAR *crloc; /* location in page buffer of current record */
typedef struct TASK_S {
/* The following global variables came from dblfcns.c */
#ifndef SINGLE_USER
int Lock_tries; /* lock_tries = 5 */
int Dbwait_time; /* dbwait_time = 1 */
int Db_timeout; /* db_timeout = TIMEOUT_DEF */
#endif
int Dbopen; /* dbopen = 0 */
#ifndef SINGLE_USER
int Db_lockmgr; /* db_lockmgr = 1 */
#endif
char Dbuserid[FILENMLEN]; /* dbuserid = "" */
char Dbdpath[FILENMLEN*2]; /* dbdpath = "" */
char Dbfpath[FILENMLEN*2]; /* dbdpath = "" */
#ifndef SINGLE_USER
INT_P App_locks; /* app_locks = NULL */
INT_P Excl_locks; /* excl_locks = NULL */
INT_P Kept_locks; /* kept_locks = NULL */
#endif
CONST char FAR *Trans_id; /* trans_id = NULL */
char Dblog[FILENMLEN]; /* dblog = "" */
#ifndef SINGLE_USER
LOCK_DESCR_P Rec_locks; /* rec_locks = NULL */
LOCK_DESCR_P Set_locks; /* set_locks = NULL */
LOCK_DESCR_P Key_locks; /* key_locks = NULL */
int Keyl_cnt;
int Lp_size;
int Fp_size;
LM_LOCK_P Lock_pkt; /* lock_pkt = NULL */
LM_FREE_P Free_pkt; /* free_pkt = NULL */
FILE_NO_P File_refs;
int Lsn;
BOOLEAN Session_active; /* session_active = FALSE */
#endif
/* The following global variables came from dio.c */
BOOLEAN Cache_ovfl; /* cache_ovfl = FALSE */
PGZERO_P Pgzero; /* database file page 0 array */
/* The following global variables came from keyfcns.c */
int No_of_keys; /* no_of_keys = 0 */
KEY_INFO_P Key_info; /* key_info = NULL */
KEY_TYPE Key_type;
/* The following global variables came from netwdos.c */
int Net_status;
LONG Last_mtype;
/* The following global variables came from options.c */
int Dboptions; /* ifdef NO_TRANS: dboptions =
DCHAINUSE | TRLOGGING
else: dboptions = DCHAINUSE */
/* The following global variables came from ovfcns.c */
long Ov_initaddr; /* ov_initaddr = 0L */
long Ov_rootaddr; /* ov_rootaddr = 0L */
long Ov_nextaddr; /* ov_nextaddr = 0L */
RI_ENTRY_P Root_ix;
/* The following global variables came from renfiles.c */
llist Ren_list; /* Ren_list = LLIST_INIT() */
/* The following global variables came from inittab.h */
INT Page_size;
#ifndef ONE_DB
int Curr_db;
DB_ENTRY FAR *Curr_db_table;
#endif
DB_ADDR Curr_rec; /* current record address */
DB_ADDR_P Curr_own; /* current set owners array */
DB_ADDR_P Curr_mem; /* current set members array */
#ifndef NO_TIMESTAMP
ULONG Cr_time;
ULONG_P Co_time; /* co_time = NULL */
ULONG_P Cm_time; /* cm_time = NULL */
ULONG_P Cs_time; /* cs_time = NULL */
BOOLEAN Db_tsrecs;
BOOLEAN Db_tssets;
#endif
FILE_NO Ov_file;
#ifndef ONE_DB
BOOLEAN Setdb_on;
INT No_of_dbs;
RN_ENTRY_P Rn_table;
RN_ENTRY FAR *Curr_rn_table;
#else
DB_ADDR rn_dba; /* last computed dba by recfrst/recset/recnext */
INT rn_type; /* last record type supplied to recfrst/recset */
INT Ft_offset;
#endif
#ifndef ONE_DB
DB_ENTRY_P Db_table;
#else
char db_name[DBNMLEN]; /* name of this database */
char db_path[PATHLEN]; /* name of path to this database */
DB_ADDR sysdba; /* database address of system record */
#endif
FILE_ENTRY_P File_table;
INT Size_ft;
RECORD_ENTRY_P Record_table;
INT Size_rt;
SET_ENTRY_P Set_table;
INT Size_st;
MEMBER_ENTRY_P Member_table;
INT Size_mt;
SORT_ENTRY_P Sort_table;
INT Size_srt;
FIELD_ENTRY_P Field_table;
INT Size_fd;
KEY_ENTRY_P Key_table;
INT Size_kt;
int Lock_lvl;
#define LOCK_STACK_SIZE 10
int Lock_stack[LOCK_STACK_SIZE];
#ifndef NO_COUNTRY
CNTRY_TBL_P country_tbl;
int ctbl_activ;
char ctbpath[FILENMLEN];
#endif
llist Sk_list;
} TASK;
/* Dynamically allocated global variables */
#define app_locks db_global.App_locks.ptr
#define excl_locks db_global.Excl_locks.ptr
#define kept_locks db_global.Kept_locks.ptr
#define rec_locks db_global.Rec_locks.ptr
#define set_locks db_global.Set_locks.ptr
#define key_locks db_global.Key_locks.ptr
#define lock_pkt db_global.Lock_pkt.ptr
#define free_pkt db_global.Free_pkt.ptr
#define file_refs db_global.File_refs.ptr
#define key_info db_global.Key_info.ptr
#define curr_own db_global.Curr_own.ptr
#define curr_mem db_global.Curr_mem.ptr
#define rn_table db_global.Rn_table.ptr
#define db_table db_global.Db_table.ptr
#define file_table db_global.File_table.ptr
#define record_table db_global.Record_table.ptr
#define set_table db_global.Set_table.ptr
#define member_table db_global.Member_table.ptr
#define sort_table db_global.Sort_table.ptr
#define field_table db_global.Field_table.ptr
#define key_table db_global.Key_table.ptr
#define pgzero db_global.Pgzero.ptr
#define root_ix db_global.Root_ix.ptr
#ifndef NO_TIMESTAMP
#define co_time db_global.Co_time.ptr
#define cm_time db_global.Cm_time.ptr
#define cs_time db_global.Cs_time.ptr
#endif
/* Used in DIO.C and OVFCNS.C */
#define ixpg_table Ixpg_table.ptr
#define dbpgbuff Dbpgbuff.ptr
#define ix_lookup Ix_lookup.ptr
/* Non-dynamically allocated global variables */
#define lock_tries db_global.Lock_tries
#define dbwait_time db_global.Dbwait_time
#define db_timeout db_global.Db_timeout
#define dbopen db_global.Dbopen
#define db_lockmgr db_global.Db_lockmgr
#define dbuserid db_global.Dbuserid
#define dbdpath db_global.Dbdpath
#define dbfpath db_global.Dbfpath
#define trans_id db_global.Trans_id
#define dblog db_global.Dblog
#define keyl_cnt db_global.Keyl_cnt
#define lp_size db_global.Lp_size
#define fp_size db_global.Fp_size
#define session_active db_global.Session_active
#define cache_ovfl db_global.Cache_ovfl
#define no_of_keys db_global.No_of_keys
#define key_type db_global.Key_type
#define net_status db_global.Net_status
#define last_mtype db_global.Last_mtype
#define dboptions db_global.Dboptions
#define ov_initaddr db_global.Ov_initaddr
#define ov_rootaddr db_global.Ov_rootaddr
#define ov_nextaddr db_global.Ov_nextaddr
#define page_size db_global.Page_size
#define curr_db db_global.Curr_db
#define curr_db_table db_global.Curr_db_table
#define curr_rec db_global.Curr_rec
#ifndef NO_TIMESTAMP
#define cr_time db_global.Cr_time
#define db_tsrecs db_global.Db_tsrecs
#define db_tssets db_global.Db_tssets
#endif
#define ov_file db_global.Ov_file
#ifndef ONE_DB
#define setdb_on db_global.Setdb_on
#define no_of_dbs db_global.No_of_dbs
#define curr_rn_table db_global.Curr_rn_table
#endif
#define size_ft db_global.Size_ft
#define size_rt db_global.Size_rt
#define size_st db_global.Size_st
#define size_mt db_global.Size_mt
#define size_srt db_global.Size_srt
#define size_fd db_global.Size_fd
#define size_kt db_global.Size_kt
#define lock_lvl db_global.Lock_lvl
#define lock_stack db_global.Lock_stack
#define ren_list db_global.Ren_list
#define sk_list db_global.Sk_list
extern TASK db_global;
extern int db_glob_init;
#ifdef MULTI_TASK
extern DB_TASK Currtask;
#endif
#ifdef MULTI_TASK
extern int task_count;
#endif
/* vpp -nOS2 -dUNIX -nBSD -nVANILLA_BSD -nVMS -nMEMLOCK -nWINDOWS -nFAR_ALLOC -f/usr/users/master/config/nonwin dbxtrn.h */

View File

@@ -0,0 +1,116 @@
/* $XConsortium: delete.c /main/2 1996/05/09 04:04:16 drk $ */
/*
* COMPONENT_NAME: austext
*
* FUNCTIONS: d_delete
*
* ORIGINS: 157
*
* OBJECT CODE ONLY SOURCE MATERIALS
*/
/*-----------------------------------------------------------------------
delete.c -- db_VISTA record deletion module.
(C) Copyright 1987 by Raima Corporation.
-----------------------------------------------------------------------*/
/* ********************** EDIT HISTORY *******************************
SCR DATE INI DESCRIPTION
----- --------- --- -----------------------------------------------------
04-Aug-88 RTK MULTI_TASK changes
*/
#include <stdio.h>
#include "vista.h"
#include "dbtype.h"
static DB_ADDR zap_dba = NULL_DBA;
/* Delete the current record, with error checking
*/
d_delete(TASK_DBN_ONLY)
TASK_DECL
DBN_DECL
{
register int st_lc, mt_lc; /* loop control */
INT i, rt;
char FAR *ptr;
SET_ENTRY FAR *set_ptr;
MEMBER_ENTRY FAR *mem_ptr;
DB_ADDR FAR *co_ptr, FAR *cm_ptr;
#ifndef NO_TIMESTAMP
ULONG FAR *cots_ptr, FAR *cmts_ptr, FAR *sts_ptr;
#endif
DB_ENTER(DB_ID TASK_ID LOCK_SET(SET_IO));
if ( ! dbopen ) RETURN( dberr(S_DBOPEN) );
if ( ! curr_rec ) RETURN( dberr( S_NOCR ) );
/* get the record type of the current record */
if ( dio_read( curr_rec, (char FAR * FAR *)&ptr , NOPGHOLD) != S_OKAY )
RETURN( db_status );
bytecpy( &rt, ptr, sizeof(INT) );
if (rt < 0)
RETURN( dberr(S_INVADDR) );
rt &= ~RLBMASK; /* mask off rlb */
#ifndef ONE_DB
rt += curr_db_table->rt_offset;
#endif
/* make sure this is not the system record */
if ( record_table[rt].rt_fdtot == -1 )
RETURN( dberr( S_DELSYS ) );
/* scan the set list for sets that this record owns to confirm it is
empty
*/
for (st_lc = size_st, set_ptr = set_table; --st_lc >= 0; ++set_ptr) {
if ((set_ptr->st_own_rt == rt) &&
(bytecmp(ptr+set_ptr->st_own_ptr+SP_FIRST,&zap_dba,DB_ADDR_SIZE) != 0))
RETURN( dberr( S_HASMEM ) );
}
/* scan the member list for sets which own this record */
for (mt_lc = size_mt, mem_ptr = member_table; --mt_lc >= 0; ++mem_ptr) {
if ((mem_ptr->mt_record == rt) &&
(bytecmp(ptr+mem_ptr->mt_mem_ptr+MP_OWNER,&zap_dba,DB_ADDR_SIZE) != 0))
RETURN( dberr( S_ISMEM ) );
}
/* delete record */
if ( r_delrec( rt, curr_rec ) == S_OKAY ) {
/* nullify any currency containing deleted record */
#ifndef NO_TIMESTAMP
for (i = 0, co_ptr = curr_own, cm_ptr = curr_mem, cots_ptr = co_time,
cmts_ptr = cm_time, sts_ptr = cs_time;
i < size_st;
++i, ++co_ptr, ++cm_ptr, ++cots_ptr, ++cmts_ptr, ++sts_ptr) {
#else
for (i = 0, co_ptr = curr_own, cm_ptr = curr_mem;
i < size_st;
++i, ++co_ptr, ++cm_ptr) {
#endif
if ( ADDRcmp(&curr_rec, co_ptr) == 0 ) {
*co_ptr = NULL_DBA;
#ifndef NO_TIMESTAMP
if ( db_tsrecs ) *cots_ptr = 0L;
if ( db_tssets ) *sts_ptr = 0L;
#endif
}
if ( ADDRcmp(&curr_rec, cm_ptr) == 0 ) {
*cm_ptr = NULL_DBA;
#ifndef NO_TIMESTAMP
if ( db_tsrecs ) *cmts_ptr = 0L;
#endif
}
}
curr_rec = NULL_DBA;
#ifndef NO_TIMESTAMP
cr_time = 0L;
#endif
}
RETURN( db_status );
}
/* vpp -nOS2 -dUNIX -nBSD -nVANILLA_BSD -nVMS -nMEMLOCK -nWINDOWS -nFAR_ALLOC -f/usr/users/master/config/nonwin delete.c */

View File

@@ -0,0 +1,71 @@
/* $XConsortium: destroy.c /main/2 1996/05/09 04:04:29 drk $ */
/*
* COMPONENT_NAME: austext
*
* FUNCTIONS: d_destroy
*
* ORIGINS: 157
*
* OBJECT CODE ONLY SOURCE MATERIALS
*/
/*-----------------------------------------------------------------------
destroy.c -- db_VISTA database remove module.
(C) Copyright 1987 by Raima Corporation.
-----------------------------------------------------------------------*/
/* ********************** EDIT HISTORY *******************************
SCR DATE INI DESCRIPTION
----- --------- --- -----------------------------------------------------
04-Aug-88 RTK MULTI_TASK changes
17-Oct-88 RSC Changed return to RETURN
*/
#include <stdio.h>
#include "vista.h"
#include "dbtype.h"
/* Database remove function
*/
/* Warning: this function will destroy the entire contents
of the database
*/
d_destroy(dbname TASK_PARM)
CONST char FAR *dbname;
TASK_DECL
{
register int ft_lc; /* loop control */
register FILE_ENTRY FAR *file_ptr;
int ovfl_save;
DB_ENTER(NO_DB_ID TASK_ID LOCK_SET(LOCK_ALL));
/* database must be closed (might be multiple databases open) */
if ( dbopen ) d_close(TASK_ONLY);
#ifndef NO_TRANS
ovfl_save = use_ovfl;
use_ovfl = NO;
#endif
/* prepare for the inittab and read in the database tables */
if ((initdbt(dbname) != S_OKAY) || (inittab() != S_OKAY))
RETURN( db_status );
/* remove db files in file_table */
for (ft_lc = size_ft, file_ptr = file_table; --ft_lc >= 0; ++file_ptr) {
unlink(file_ptr->ft_name);
}
/* free all residual memory */
termfree();
#ifndef NO_TRANS
use_ovfl = ovfl_save;
#endif
RETURN( db_status );
}
/* vpp -nOS2 -dUNIX -nBSD -nVANILLA_BSD -nVMS -nMEMLOCK -nWINDOWS -nFAR_ALLOC -f/usr/users/master/config/nonwin destroy.c */

1901
cde/lib/DtSearch/raima/dio.c Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,176 @@
/* $XConsortium: discon.c /main/2 1996/05/09 04:04:43 drk $ */
/*
* COMPONENT_NAME: austext
*
* FUNCTIONS: d_discon
*
* ORIGINS: 157
*
* OBJECT CODE ONLY SOURCE MATERIALS
*/
/*-----------------------------------------------------------------------
discon.c -- db_VISTA set dicconnection module
(C) Copyright 1985, 1986, 1987 by Raima Corp.
-----------------------------------------------------------------------*/
/* ********************** EDIT HISTORY *******************************
SCR DATE INI DESCRIPTION
----- --------- --- -----------------------------------------------------
04-Aug-88 RTK MULTI_TASK changes
*/
#include <stdio.h>
#include "vista.h"
#include "dbtype.h"
/* set pointer structure definition */
typedef struct {
LONG total; /* total number of members in set */
DB_ADDR first; /* database address of first member in set */
DB_ADDR last; /* database address of last member in set */
#ifndef NO_TIMESTAMP
ULONG timestamp; /* set update timestamp - if used */
#endif
} SET_PTR;
/* member pointer structure definition */
typedef struct {
DB_ADDR owner; /* database address of owner record */
DB_ADDR prev; /* database address of previous member in set */
DB_ADDR next; /* database address of next member in set */
} MEM_PTR;
/* Disconnect the current member of set
*/
d_discon(nset TASK_PARM DBN_PARM)
int nset; /* set number */
TASK_DECL
DBN_DECL /* database number */
{
SET_PTR cosp; /* current owner's set pointer */
MEM_PTR cmmp; /* member's member pointer */
MEM_PTR npmp; /* next or previous member's member pointer */
char FAR *orec; /* ptr to current owner record contents in cache */
char FAR *mrec = NULL; /* ptr to member record contents in cache */
char FAR *nprec = NULL; /* ptr to next or prev record contents in cache */
DB_ADDR mdba; /* db address of member record */
DB_ADDR npdba; /* db address of next or previous member */
int set; /* set_table entry */
int stat; /* status code variable */
#ifndef NO_TIMESTAMP
FILE_NO file; /* file containing owner record */
#endif
SET_ENTRY FAR *set_ptr;
DB_ADDR FAR *co_ptr, FAR *cm_ptr;
DB_ENTER(DB_ID TASK_ID LOCK_SET(SET_IO));
if (nset_check(nset, &set, (SET_ENTRY FAR * FAR *)&set_ptr) != S_OKAY)
RETURN( db_status );
/* make sure we have a current owner */
if ( !*(co_ptr = &curr_own[set]) )
RETURN( dberr(S_NOCO) );
/* make sure we have a current member */
if ( !*(cm_ptr = &curr_mem[set]) )
RETURN( dberr(S_NOCM) );
/* read member record */
mdba = *cm_ptr;
if ( dio_read(mdba, (char FAR * FAR *)&mrec, PGHOLD) != S_OKAY )
RETURN( db_status );
/* ensure record is connected */
if ( (stat = r_gmem(set, mrec, (char FAR *)&cmmp)) != S_OKAY )
goto quit_b;
if ( cmmp.owner == NULL_DBA ) { /* checks owner pointer */
stat = S_NOTCON;
goto quit_b;
}
/* read owner record */
if ( (stat = dio_read(*co_ptr, (char FAR * FAR *)&orec, PGHOLD)) != S_OKAY )
goto quit_b;
/* get set pointer from owner */
if ( r_gset(set, orec, (char FAR *)&cosp) != S_OKAY )
goto quit_a;
if ( cmmp.next == NULL_DBA )
/* last record in set */
cosp.last = cmmp.prev;
else {
/* set next record's prev to current member's prev */
npdba = cmmp.next;
if ((dio_read(npdba, (char FAR * FAR *)&nprec, NOPGHOLD) != S_OKAY) ||
(r_gmem(set, nprec, (char FAR *)&npmp) != S_OKAY))
goto quit_a;
npmp.prev = cmmp.prev;
if ((r_pmem(set, nprec, (char FAR *)&npmp) != S_OKAY) ||
(dio_write(npdba, NULL, NOPGFREE) != S_OKAY))
goto quit_a;
}
if ( cmmp.prev == NULL_DBA )
/* first record in set */
cosp.first = cmmp.next;
else {
/* set previous record's next to current member's next */
npdba = cmmp.prev;
if ((dio_read(npdba, (char FAR * FAR *)&nprec, NOPGHOLD) != S_OKAY) ||
(r_gmem(set, nprec, (char FAR *)&npmp) != S_OKAY))
goto quit_a;
npmp.next = cmmp.next;
if ((r_pmem(set, nprec, (char FAR *)&npmp) != S_OKAY) ||
(dio_write(npdba, NULL, NOPGFREE) != S_OKAY))
goto quit_a;
}
#ifndef NO_TIMESTAMP
/* check for timestamp */
if ( set_ptr->st_flags & TIMESTAMPED ) {
file = NUM2INT((FILE_NO)((*co_ptr >> FILESHIFT) & FILEMASK), ft_offset);
cosp.timestamp = dio_pzgetts(file);
}
#endif
/* update membership count */
--cosp.total;
/* update owner record's set pointer */
if ((r_pset(set, orec, (char FAR *)&cosp) != S_OKAY) ||
(dio_write(*co_ptr, NULL, PGFREE) != S_OKAY))
RETURN( db_status );
/* update current record and current member */
curr_rec = mdba;
*cm_ptr = cmmp.next;
/* make member record's member pointer null */
cmmp.owner = cmmp.prev = cmmp.next = NULL_DBA;
/* update member record */
if ((r_pmem(set, mrec, (char FAR *)&cmmp) != S_OKAY) ||
(dio_write(mdba, NULL, PGFREE) != S_OKAY))
RETURN( db_status );
#ifndef NO_TIMESTAMP
/* note timestamps */
if ( db_tsrecs )
d_utscr( &cr_time TASK_PARM );
if ( db_tsrecs && *cm_ptr )
d_utscm(nset, &cm_time[set] TASK_PARM DBN_PARM);
/* check for timestamp */
if ( set_ptr->st_flags & TIMESTAMPED )
cs_time[set] = cosp.timestamp;
#endif
RETURN( db_status = *cm_ptr ? S_OKAY : S_EOS );
quit_a:
stat = db_status;
dio_write(mdba, NULL, PGFREE);
quit_b:
dio_write(*co_ptr, NULL, PGFREE);
RETURN( db_status = stat );
}
/* vpp -nOS2 -dUNIX -nBSD -nVANILLA_BSD -nVMS -nMEMLOCK -nWINDOWS -nFAR_ALLOC -f/usr/users/master/config/nonwin discon.c */

View File

@@ -0,0 +1,95 @@
/* $XConsortium: disdel.c /main/2 1996/05/09 04:04:57 drk $ */
/*
* COMPONENT_NAME: austext
*
* FUNCTIONS: d_disdel
*
* ORIGINS: 157
*
* OBJECT CODE ONLY SOURCE MATERIALS
*/
/*-----------------------------------------------------------------------
disdel.c -- db_VISTA set disconnection/deletion module
(C) Copyright 1985, 1986, 1987 by Raima Corp.
-----------------------------------------------------------------------*/
/* ********************** EDIT HISTORY *******************************
SCR DATE INI DESCRIPTION
----- --------- --- -----------------------------------------------------
04-Aug-88 RTK MULTI_TASK changes
518 06-Jan-89 RSC d_discon infinite loops (not checking d_discon status)
*/
#include <stdio.h>
#include "vista.h"
#include "dbtype.h"
/* Disconnect from all sets (owner and member) and delete record
*/
d_disdel(TASK_DBN_ONLY)
TASK_DECL
DBN_DECL
{
int rectype, nset, cset;
register int set, mem;
DB_ADDR dba, odba, mdba;
DB_ADDR FAR *co_ptr, FAR *cm_ptr;
register SET_ENTRY FAR *set_ptr;
register MEMBER_ENTRY FAR *mem_ptr;
int memtot;
DB_ENTER(DB_ID TASK_ID LOCK_SET(SET_IO));
if ( d_crtype(&rectype TASK_PARM DBN_PARM) != S_OKAY )
RETURN( db_status );
rectype += NUM2INT(-RECMARK, rt_offset);
d_crget(&dba TASK_PARM DBN_PARM);
for (set = 0, set_ptr = &set_table[ORIGIN(st_offset)];
set < TABLE_SIZE(Size_st);
++set, ++set_ptr) {
nset = set + SETMARK;
cset = set + ORIGIN(st_offset);
co_ptr = &curr_own[cset];
cm_ptr = &curr_mem[cset];
odba = *co_ptr;
mdba = *cm_ptr;
if (set_ptr->st_own_rt == rectype) {
/* disconnect all member records from set s */
d_setor(nset TASK_PARM DBN_PARM);
while (d_findfm(nset TASK_PARM DBN_PARM) == S_OKAY)
if (d_discon(nset TASK_PARM DBN_PARM) < S_OKAY)
RETURN (db_status);
d_setro(nset TASK_PARM DBN_PARM);
}
for (mem = set_ptr->st_members, memtot = mem + set_ptr->st_memtot,
mem_ptr = &member_table[mem];
mem < memtot;
++mem, ++mem_ptr) {
if (mem_ptr->mt_record == rectype) {
/* disconnect current record from set */
if (d_ismember(nset TASK_PARM DBN_PARM) == S_OKAY) {
d_csmset(nset, &dba TASK_PARM DBN_PARM);
if (d_discon(nset TASK_PARM DBN_PARM) < S_OKAY)
RETURN (db_status);
}
}
}
curr_rec = dba;
if ( dba == odba ) {
*co_ptr = NULL_DBA;
*cm_ptr = NULL_DBA;
}
else
*co_ptr = odba;
if ( dba == mdba )
*cm_ptr = NULL_DBA;
else
*cm_ptr = mdba;
}
RETURN( d_delete(TASK_DBN_ONLY) );
}
/* vpp -nOS2 -dUNIX -nBSD -nVANILLA_BSD -nVMS -nMEMLOCK -nWINDOWS -nFAR_ALLOC -f/usr/users/master/config/nonwin disdel.c */

View File

@@ -0,0 +1,311 @@
/* $XConsortium: dproto.h /main/2 1996/05/09 04:05:13 drk $ */
/*
* COMPONENT_NAME: austext
*
* FUNCTIONS: Pi
* d_alloc
* d_calloc
* d_cmstat
* d_cmtype
* d_connect
* d_costat
* d_cotype
* d_crget
* d_crread
* d_crset
* d_crtype
* d_crwrite
* d_csmget
* d_csmread
* d_csmset
* d_csmwrite
* d_csoget
* d_csoread
* d_csoset
* d_csowrite
* d_csstat
* d_ctbpath
* d_ctscm
* d_ctsco
* d_ctscr
* d_dbdpath
* d_dbfpath
* d_dblog
* d_dbtaf
* d_dbuserid
* d_decode_dba
* d_destroy
* d_discon
* d_encode_dba
* d_fillnew
* d_findco
* d_findfm
* d_findlm
* d_findnm
* d_findpm
* d_free
* d_gtscm
* d_gtsco
* d_gtscr
* d_gtscs
* d_initfile
* d_ismember
* d_isowner
* d_keydel
* d_keyexist
* d_keyfind
* d_keyfree
* d_keyfrst
* d_keylast
* d_keylock
* d_keylstat
* d_keynext
* d_keyprev
* d_keyread
* d_keystore
* d_lock
* d_makenew
* d_mapchar
* d_members
* d_memlock
* d_memlock_group
* d_memunlock
* d_memunlock_group
* d_off_opt
* d_on_opt
* d_open
* d_rdcurr
* d_recfree
* d_recfrst
* d_reclast
* d_reclock
* d_reclstat
* d_recover
* d_recread
* d_recset
* d_recstat
* d_recwrite
* d_renfile
* d_rerdcurr
* d_retries
* d_set_dberr
* d_setdb
* d_setfiles
* d_setfree
* d_setkey
* d_setlock
* d_setlstat
* d_setmm
* d_setmo
* d_setmr
* d_setom
* d_setoo
* d_setor
* d_setpages
* d_setrm
* d_setro
* d_stscm
* d_stsco
* d_stscr
* d_stscs
* d_timeout
* d_trbegin
* d_trlog
* d_utscm
* d_utsco
* d_utscr
* d_utscs
* d_wrcurr
* dberr
* dt_closetask
* dt_opentask
*
* ORIGINS: 157
*
*/
/*----------------------------------------------------------------------------
dproto.h: db_VISTA (user) function declaration header file
(C) Copyright 1988 by Raima Corporation.
----------------------------------------------------------------------------*/
/* ********************** EDIT HISTORY *******************************
SCR DATE INI DESCRIPTION
----- --------- --- -----------------------------------------------------
571 31-Jan-89 RSC Placed ctbpath inside NO_COUNTRY, not NO_TIMESTAMP
*/
int d_setfiles(P1(int)); /* dio.c */
int d_setpages(P1(int) Pi(int)); /* dio.c */
int d_trbound(P0); /* trlog.c */
int d_trlog(P1(int) Pi(int) Pi(CONST char FAR *) Pi(int));
/* trlog.c */
int d_trmark(P0); /* trlog.c */
int d_tron(P0); /* trlog.c */
int d_troff(P0); /* trlog.c */
int d_decode_dba(P1(DB_ADDR) Pi(int FAR *) Pi(long FAR *));
/* dbacode.c */
int d_encode_dba(P1(int) Pi(long) Pi(DB_ADDR FAR *));
/* dbacode.c */
#define d_memlock(p) /**/
#define d_memlock_group(lg) S_OKAY
#define d_memunlock(p) /**/
#define d_memunlock_group(lg) /**/
char FAR * d_alloc(P1(unsigned)); /* alloc.c */
char FAR * d_calloc(P1(unsigned) Pi(unsigned)); /* alloc.c */
void d_free(P1(CHAR_P FAR *)); /* alloc.c */
#ifndef MULTI_TASK /* MULTI_TASK */
#define dt_opentask(a) S_OKAY
#define dt_closetask(a) S_OKAY
int d_close(P0); /* dblfcns.c */
int d_cmstat(P1(int) DBN_Dn); /* cmstat.c */
int d_cmtype(P1(int) Pi(int FAR *) DBN_Dn); /* cmtype.c */
int d_connect(P1(int) DBN_Dn); /* connect.c */
#ifndef NO_TIMESTAMP /* NO_TIMESTAMP */
int d_costat(P1(int) DBN_Dn); /* costat.c */
#endif /* NO_TIMESTAMP */
int d_cotype(P1(int) Pi(int FAR *) DBN_Dn); /* cotype.c */
int d_crget(P1(DB_ADDR FAR *) DBN_Dn); /* crget.c */
int d_crread(P1(long) Pi(char FAR *) DBN_Dn); /* crread.c */
int d_crset(P1(DB_ADDR FAR *) DBN_Dn); /* crset.c */
#ifndef NO_TIMESTAMP /* NO_TIMESTAMP */
int d_crstat(P0); /* crstat.c */
#endif /* NO_TIMESTAMP */
int d_crtype(P1(int FAR *) DBN_Dn); /* crtype.c */
int d_crwrite(P1(long) Pi(char FAR *) DBN_Dn); /* crwrite.c */
int d_csmget(P1(int) Pi(DB_ADDR FAR *) DBN_Dn); /* csmget.c */
int d_csmread(P1(int) Pi(long) Pi(char FAR *) DBN_Dn);
/* csmread.c */
int d_csmset(P1(int) Pi(DB_ADDR FAR *) DBN_Dn); /* csmset.c */
int d_csmwrite(P1(int) Pi(long) Pi(CONST char FAR *) DBN_Dn);
/* csmwrite.c */
int d_csoget(P1(int) Pi(DB_ADDR FAR *) DBN_Dn); /* csoget.c */
int d_csoread(P1(int) Pi(long) Pi(char FAR *) DBN_Dn);
/* csoread.c */
int d_csoset(P1(int) Pi(DB_ADDR FAR *) DBN_Dn); /* csoset.c */
int d_csowrite(P1(int) Pi(long) Pi(CONST char FAR *) DBN_Dn);
/* csowrite.c */
#ifndef NO_TIMESTAMP /* NO_TIMESTAMP */
int d_csstat(P1(int) DBN_Dn); /* csstat.c */
int d_ctscm(P1(int) Pi(ULONG FAR *) DBN_Dn); /* ctscm.c */
int d_ctsco(P1(int) Pi(ULONG FAR *) DBN_Dn); /* ctsco.c */
int d_ctscr(P1(ULONG FAR *)); /* ctscr.c */
#endif /* NO_TIMESTAMP */
#ifndef NO_COUNTRY
int d_ctbpath(P1(CONST char FAR *)); /* pathfcns.c */
#endif /* NO_COUNTRY */
int d_dbdpath(P1(CONST char FAR *)); /* dbdpath.c */
int d_dbfpath(P1(CONST char FAR *)); /* dbfpath.c */
int d_dblog(P1(CONST char FAR *)); /* dblog.c */
int d_dbtaf(P1(CONST char FAR *)); /* dbtaf.c */
int d_dbuserid(P1(CONST char FAR *)); /* dbuserid.c */
int d_delete(DBN_D1); /* delete.c */
int d_disdel(DBN_D1); /* disdel.c */
int d_recnext(DBN_D1); /* recnext.c */
int d_recprev(DBN_D1); /* recprev.c */
int d_destroy(P1(CONST char FAR *)); /* destroy.c */
int d_discon(P1(int) DBN_Dn); /* discon.c */
int d_fillnew(P1(int) Pi(CONST char FAR *) DBN_Dn); /* fillnew.c */
int d_findco(P1(int) DBN_Dn); /* findco.c */
int d_findfm(P1(int) DBN_Dn); /* findfm.c */
int d_findlm(P1(int) DBN_Dn); /* findlm.c */
int d_findnm(P1(int) DBN_Dn); /* findnm.c */
int d_findpm(P1(int) DBN_Dn); /* findpm.c */
int d_freeall(P0); /* dblfcns.c */
#ifndef NO_TIMESTAMP /* NO_TIMESTAMP */
int d_gtscm(P1(int) Pi(ULONG FAR *) DBN_Dn); /* gtscm.c */
int d_gtsco(P1(int) Pi(ULONG FAR *) DBN_Dn); /* gtsco.c */
int d_gtscr(P1(ULONG FAR *)); /* gtscr.c */
int d_gtscs(P1(int) Pi(ULONG FAR *) DBN_Dn); /* gtscs.c */
#endif /* NO_TIMESTAMP */
int d_initialize(DBN_D1); /* initial.c */
int d_initfile(P1(FILE_NO) DBN_Dn); /* initial.c */
int d_ismember(P1(int) DBN_Dn); /* ismember.c */
int d_isowner(P1(int) DBN_Dn); /* isowner.c */
int d_keydel(P1(long) DBN_Dn); /* keydel.c */
int d_keyexist(P1(long) DBN_Dn); /* keyexist.c */
int d_keyfind(P1(long) Pi(CONST char FAR *) DBN_Dn);
/* keyfind.c */
int d_keyfree(P1(long) DBN_Dn); /* dblfcns.c */
int d_keyfrst(P1(long) DBN_Dn); /* keyfrst.c */
int d_keylast(P1(long) DBN_Dn); /* keylast.c */
int d_keylock(P1(long) Pi(char FAR *) DBN_Dn); /* dblfcns.c */
int d_keylstat(P1(long) Pi(char FAR *) DBN_Dn); /* dblfcns.c */
int d_keynext(P1(long) DBN_Dn); /* keynext.c */
int d_keyprev(P1(long) DBN_Dn); /* keyprev.c */
int d_keyread(P1(char FAR *)); /* keyfcns.c */
int d_keystore(P1(long) DBN_Dn); /* keystore.c */
int d_lock(P1(int) Pi(LOCK_REQUEST FAR *) DBN_Dn); /* dblfcns.c */
int d_makenew(P1(int) DBN_Dn); /* makenew.c */
int d_mapchar(P1(unsigned char) Pi(unsigned char)
Pi(CONST char FAR *) Pi(unsigned char)); /* mapchar.c */
int d_members(P1(int) Pi(LONG FAR *) DBN_Dn); /* members.c */
int d_off_opt(P1(int)); /* options.c */
int d_on_opt(P1(int)); /* options.c */
int d_open(P1(CONST char FAR *) Pi(CONST char FAR *));
/* dblfcns.c */
int d_rerdcurr(P1(DB_ADDR FAR **)); /* rwcurr.c */
int d_rdcurr(P1(DB_ADDR FAR **) Pi(int FAR *)); /* rwcurr.c */
int d_wrcurr(P1(DB_ADDR FAR *)); /* rwcurr.c */
int d_recfree(P1(int) DBN_Dn); /* dblfcns.c */
int d_recfrst(P1(int) DBN_Dn); /* recfrst.c */
int d_reclast(P1(int) DBN_Dn); /* reclast.c */
int d_reclock(P1(int) Pi(char FAR *) DBN_Dn); /* dblfcns.c */
int d_reclstat(P1(int) Pi(char FAR *) DBN_Dn); /* dblfcns.c */
int d_recover(P1(CONST char FAR *)); /* recover.c */
int d_recread(P1(char FAR *) DBN_Dn); /* recread.c */
int d_recset(P1(int) DBN_Dn); /* recset.c */
#ifndef NO_TIMESTAMP /* NO_TIMESTAMP */
int d_recstat(P1(DB_ADDR) Pi(ULONG)); /* recstat.c */
#endif /* NO_TIMESTAMP */
int d_recwrite(P1(CONST char FAR *) DBN_Dn); /* recwrite.c */
int d_renfile(P1(CONST char FAR *) Pi(FILE_NO)
Pi(CONST char FAR *)); /* renfile.c */
int d_retries(P1(int)); /* dblfcns.c */
int d_rlbclr(P0); /* dblfcns.c */
int d_rlbset(P0); /* dblfcns.c */
int d_rlbtst(P0); /* dblfcns.c */
int d_set_dberr(P1(FARPROC)); /* dberr.c */
#ifndef ONE_DB /* ONE_DB */
int d_setdb(P1(int)); /* setdb.c */
#endif /* ONE_DB */
int d_setfree(P1(int) DBN_Dn); /* dblfcns.c */
int d_setkey(P1(long) Pi(CONST char FAR *) DBN_Dn); /* makenew.c */
int d_setlock(P1(int) Pi(char FAR *) DBN_Dn); /* dblfcns.c */
int d_setlstat(P1(int) Pi(char FAR *) DBN_Dn); /* dblfcns.c */
int d_setmm(P1(int) Pi(int) DBN_Dn); /* setmm.c */
int d_setmo(P1(int) Pi(int) DBN_Dn); /* setmo.c */
int d_setmr(P1(int) DBN_Dn); /* setmr.c */
int d_setom(P1(int) Pi(int) DBN_Dn); /* setom.c */
int d_setoo(P1(int) Pi(int) DBN_Dn); /* setoo.c */
int d_setor(P1(int) DBN_Dn); /* setor.c */
int d_setrm(P1(int) DBN_Dn); /* setrm.c */
int d_setro(P1(int) DBN_Dn); /* setro.c */
#ifndef NO_TIMESTAMP /* NO_TIMESTAMP */
int d_stscm(P1(int) Pi(ULONG) DBN_Dn); /* stscm.c */
int d_stsco(P1(int) Pi(ULONG) DBN_Dn); /* stsco.c */
int d_stscr(P1(ULONG)); /* stscr.c */
int d_stscs(P1(int) Pi(ULONG) DBN_Dn); /* stscs.c */
#endif /* NO_TIMESTAMP */
int d_timeout(P1(int)); /* dblfcns.c */
int d_trabort(P0); /* dblfcns.c */
int d_trbegin(P1(CONST char FAR *)); /* dblfcns.c */
int d_trend(P0); /* dblfcns.c */
#ifndef NO_TIMESTAMP /* NO_TIMESTAMP */
int d_utscm(P1(int) Pi(ULONG FAR *) DBN_Dn); /* utscm.c */
int d_utsco(P1(int) Pi(ULONG FAR *) DBN_Dn); /* utsco.c */
int d_utscr(P1(ULONG FAR *)); /* utscr.c */
int d_utscs(P1(int) Pi(ULONG FAR *) DBN_Dn); /* utscs.c */
#endif /* NO_TIMESTAMP */
#endif /* MULTI_TASK */
int dberr(P1(int)); /* dberr.c */
#define D_FUNCTIONS_H
/* vpp -nOS2 -dUNIX -nBSD -nVANILLA_BSD -nVMS -nMEMLOCK -nWINDOWS -nFAR_ALLOC -f/usr/users/master/config/nonwin dproto.h */

View File

@@ -0,0 +1,153 @@
/* $XConsortium: dtcover.h /main/2 1996/05/09 04:05:27 drk $ */
/*
* COMPONENT_NAME: austext
*
* FUNCTIONS: none
*
* ORIGINS: 157
*
*/
/*----------------------------------------------------------------------------
dtcover.h: converts d_* calls to dt_* for MULTI_TASKing
(C) Copyright 1988 by Raima Corporation.
----------------------------------------------------------------------------*/
/* ********************** EDIT HISTORY *******************************
SCR DATE INI DESCRIPTION
----- --------- --- -----------------------------------------------------
571 31-Jan-89 RSC Placed ctbpath inside NO_COUNTRY, not NO_TIMESTAMP
*/
#define d_close dt_close
#define d_cmstat dt_cmstat
#define d_cmtype dt_cmtype
#define d_connect dt_connect
#ifndef NO_TIMESTAMP
#define d_costat dt_costat
#endif
#define d_cotype dt_cotype
#define d_crget dt_crget
#define d_crread dt_crread
#define d_crset dt_crset
#ifndef NO_TIMESTAMP
#define d_crstat dt_crstat
#endif
#define d_crtype dt_crtype
#define d_crwrite dt_crwrite
#define d_csmget dt_csmget
#define d_csmread dt_csmread
#define d_csmset dt_csmset
#define d_csmwrite dt_csmwrite
#define d_csoget dt_csoget
#define d_csoread dt_csoread
#define d_csoset dt_csoset
#define d_csowrite dt_csowrite
#ifndef NO_TIMESTAMP
#define d_csstat dt_csstat
#define d_ctscm dt_ctscm
#define d_ctsco dt_ctsco
#define d_ctscr dt_ctscr
#endif
#ifndef NO_COUNTRY
#define d_ctbpath dt_ctbpath
#endif
#define d_dbdpath dt_dbdpath
#define d_dbfpath dt_dbfpath
#define d_dblog dt_dblog
#define d_dbtaf dt_dbtaf
#define d_dbuserid dt_dbuserid
#define d_delete dt_delete
#define d_disdel dt_disdel
#define d_recnext dt_recnext
#define d_recprev dt_recprev
#define d_destroy dt_destroy
#define d_discon dt_discon
#define d_fillnew dt_fillnew
#define d_findco dt_findco
#define d_findfm dt_findfm
#define d_findlm dt_findlm
#define d_findnm dt_findnm
#define d_findpm dt_findpm
#define d_freeall dt_freeall
#ifndef NO_TIMESTAMP
#define d_gtscm dt_gtscm
#define d_gtsco dt_gtsco
#define d_gtscr dt_gtscr
#define d_gtscs dt_gtscs
#endif
#define d_initialize dt_initialize
#define d_initfile dt_initfile
#define d_ismember dt_ismember
#define d_isowner dt_isowner
#define d_keydel dt_keydel
#define d_keyexist dt_keyexist
#define d_keyfind dt_keyfind
#define d_keyfree dt_keyfree
#define d_keyfrst dt_keyfrst
#define d_keylast dt_keylast
#define d_keylock dt_keylock
#define d_keylstat dt_keylstat
#define d_keynext dt_keynext
#define d_keyprev dt_keyprev
#define d_keyread dt_keyread
#define d_keystore dt_keystore
#define d_lock dt_lock
#define d_makenew dt_makenew
#define d_mapchar dt_mapchar
#define d_members dt_members
#define d_off_opt dt_off_opt
#define d_on_opt dt_on_opt
#define d_open dt_open
#define d_rdcurr dt_rdcurr
#define d_rerdcurr dt_rerdcurr
#define d_recfree dt_recfree
#define d_recfrst dt_recfrst
#define d_reclast dt_reclast
#define d_reclock dt_reclock
#define d_reclstat dt_reclstat
#define d_recover dt_recover
#define d_recread dt_recread
#define d_recset dt_recset
#ifndef NO_TIMESTAMP
#define d_recstat dt_recstat
#endif
#define d_recwrite dt_recwrite
#define d_renfile dt_renfile
#define d_retries dt_retries
#define d_rlbclr dt_rlbclr
#define d_rlbset dt_rlbset
#define d_rlbtst dt_rlbtst
#define d_set_dberr dt_set_dberr
#define d_setdb dt_setdb
#define d_setfree dt_setfree
#define d_setkey dt_setkey
#define d_setlock dt_setlock
#define d_setlstat dt_setlstat
#define d_setmm dt_setmm
#define d_setmo dt_setmo
#define d_setmr dt_setmr
#define d_setom dt_setom
#define d_setoo dt_setoo
#define d_setor dt_setor
#define d_setrm dt_setrm
#define d_setro dt_setro
#ifndef NO_TIMESTAMP
#define d_stscm dt_stscm
#define d_stsco dt_stsco
#define d_stscr dt_stscr
#define d_stscs dt_stscs
#endif
#define d_timeout dt_timeout
#define d_trabort dt_trabort
#define d_trbegin dt_trbegin
#define d_trend dt_trend
#ifndef NO_TIMESTAMP
#define d_utscm dt_utscm
#define d_utsco dt_utsco
#define d_utscr dt_utscr
#define d_utscs dt_utscs
#endif
#define d_wrcurr dt_wrcurr
/* vpp -nOS2 -dUNIX -nBSD -nVANILLA_BSD -nVMS -nMEMLOCK -nWINDOWS -nFAR_ALLOC dtcover.h */

View File

@@ -0,0 +1,137 @@
/* $XConsortium: fillnew.c /main/3 1996/08/12 12:33:46 cde-ibm $ */
/*
* COMPONENT_NAME: austext
*
* FUNCTIONS: d_fillnew
*
* ORIGINS: 157
*
* OBJECT CODE ONLY SOURCE MATERIALS
*/
/*-----------------------------------------------------------------------
fillnew.c -- db_VISTA (filled) record creation module
(C) Copyright 1987 by Raima Corp.
-----------------------------------------------------------------------*/
/* ********************** EDIT HISTORY *******************************
SCR DATE INI DESCRIPTION
----- --------- --- -----------------------------------------------------
158 15-JUN-88 RSC inform key_bldcom NOT to complement compound keys
04-Aug-88 RTK MULTI_TASK changes
*/
#include <stdio.h>
#include "vista.h"
#include "dbtype.h"
#define FALSE 0
#define TRUE 1
/* Create and fill a new record
*/
d_fillnew( nrec, recval TASK_PARM DBN_PARM )
int nrec; /* record number */
CONST char FAR *recval; /* record value */
TASK_DECL
DBN_DECL /* database number */
{
#ifndef NO_TIMESTAMP
ULONG timestamp;
#endif
DB_ADDR db_addr;
INT recnum, stat;
FILE_NO file;
F_ADDR rec_addr;
char FAR *ptr;
char key[256];
RECORD_ENTRY FAR *rec_ptr;
FIELD_ENTRY FAR *fld_ptr;
int fld, fldtot;
DB_ENTER(DB_ID TASK_ID LOCK_SET(RECORD_IO));
if (nrec_check(nrec, &nrec, (RECORD_ENTRY FAR * FAR *)&rec_ptr) != S_OKAY)
RETURN( db_status );
recnum = NUM2EXT(nrec, rt_offset);
/* check for duplicate keys */
db_addr = curr_rec;
for (fld = rec_ptr->rt_fields, fldtot = fld + rec_ptr->rt_fdtot,
fld_ptr = &field_table[fld];
(fld < fldtot) || (fld_ptr->fd_type == COMKEY);
++fld, ++fld_ptr) {
if ((fld_ptr->fd_key == UNIQUE) && !(fld_ptr->fd_flags & OPTKEYMASK)) {
if (fld_ptr->fd_type != COMKEY)
ptr = (char FAR *)recval + fld_ptr->fd_ptr - rec_ptr->rt_data;
else
key_bldcom(fld, (char FAR *)recval, ptr = key, FALSE); /* Don't complement */
d_keyfind(FLDMARK*(long)recnum + (fld - rec_ptr->rt_fields), ptr
TASK_PARM DBN_PARM);
curr_rec = db_addr;
if ( db_status == S_OKAY )
RETURN( db_status = S_DUPLICATE );
}
}
/* pull out the file number */
file = rec_ptr->rt_file;
db_addr = (NUM2EXT(file, ft_offset) & FILEMASK) << FILESHIFT;
/* select a record pointer to use */
if ( dio_pzalloc(file, &rec_addr) != S_OKAY )
RETURN( db_status );
db_addr |= rec_addr;
/* read record */
if (dio_read(db_addr, (char FAR * FAR *)&ptr, PGHOLD) != S_OKAY)
RETURN( db_status );
/* zero fill the record */
byteset(ptr, 0, rec_ptr->rt_len);
/* place the record number and db_addr at the start of the record */
bytecpy( ptr, &recnum, sizeof(INT) );
bytecpy( ptr+sizeof(INT), &db_addr, DB_ADDR_SIZE );
#ifndef NO_TIMESTAMP
/* check for timestamp */
if ( rec_ptr->rt_flags & TIMESTAMPED ) {
timestamp = dio_pzgetts(file);
bytecpy( ptr + RECCRTIME, &timestamp, sizeof(LONG));
bytecpy( ptr + RECUPTIME, &timestamp, sizeof(LONG));
}
else timestamp = 0;
#endif
/* copy the record value into place */
bytecpy( ptr+rec_ptr->rt_data, recval, rec_ptr->rt_len-rec_ptr->rt_data );
/* for each keyed field, enter the key value into the key file */
for (fld = rec_ptr->rt_fields, fldtot = fld + rec_ptr->rt_fdtot,
fld_ptr = &field_table[fld];
(fld < fldtot) || (fld_ptr->fd_type == COMKEY);
++fld, ++fld_ptr) {
if ((fld_ptr->fd_key != 'n') && !(fld_ptr->fd_flags & OPTKEYMASK)) {
if ( fld_ptr->fd_type != COMKEY )
ptr = (char FAR *)recval + fld_ptr->fd_ptr - rec_ptr->rt_data;
else
key_bldcom(fld, (char FAR *)recval, ptr = key, TRUE);
if ((stat = key_insert(fld, ptr, db_addr)) != S_OKAY) {
r_delrec( nrec, db_addr );
dio_write(db_addr, NULL, PGFREE);
RETURN( db_status = stat );
}
}
}
/* 'touch' page, do page's update housekeeping */
if ( dio_write(db_addr, NULL, PGFREE) == S_OKAY ) {
curr_rec = db_addr;
#ifndef NO_TIMESTAMP
if ( db_tsrecs ) cr_time = timestamp;
#endif
}
RETURN( db_status );
}
/* vpp -nOS2 -dUNIX -nBSD -nVANILLA_BSD -nVMS -nMEMLOCK -nWINDOWS -nFAR_ALLOC -f/usr/users/master/config/nonwin fillnew.c */

View File

@@ -0,0 +1,78 @@
/* $XConsortium: findco.c /main/2 1996/05/09 04:06:00 drk $ */
/*
* COMPONENT_NAME: austext
*
* FUNCTIONS: d_findco
*
* ORIGINS: 157
*
* OBJECT CODE ONLY SOURCE MATERIALS
*/
/*-----------------------------------------------------------------------
findco.c -- db_VISTA find owner of current record module
(C) Copyright 1987 by Raima Corp.
-----------------------------------------------------------------------*/
/* ********************** EDIT HISTORY *******************************
SCR DATE INI DESCRIPTION
----- --------- --- -----------------------------------------------------
04-Aug-88 RTK MULTI_TASK changes
*/
#include <stdio.h>
#include "vista.h"
#include "dbtype.h"
/* Find owner of current record
*/
d_findco(nset TASK_PARM DBN_PARM)
int nset;
TASK_DECL
DBN_DECL
{
int set;
char mem[MEMPSIZE];
DB_ADDR own;
SET_ENTRY FAR *set_ptr;
DB_ENTER(DB_ID TASK_ID LOCK_SET(SET_IO));
if (nset_check(nset, &set, (SET_ENTRY FAR * FAR *)&set_ptr) != S_OKAY)
RETURN( db_status );
/* Make sure we have a current record */
if ( ! curr_rec )
RETURN( dberr(S_NOCR) );
/* Read current record */
if ( dio_read(curr_rec, (char FAR * FAR *)&crloc, NOPGHOLD) != S_OKAY )
RETURN( db_status );
/* Get the member ptr for this set */
if ( r_gmem(set, crloc, mem) != S_OKAY )
RETURN( db_status );
/* Extract the owner ptr from the member ptr */
bytecpy(&own, mem+MP_OWNER, DB_ADDR_SIZE);
if ( ! own ) /* Record not connected to set */
RETURN( dberr( S_NOTCON ) );
/* set the new current owner and member */
curr_own[set] = own;
curr_mem[set] = curr_rec;
curr_rec = own;
#ifndef NO_TIMESTAMP
/* set any timestamps */
if ( db_tsrecs ) {
d_utscr( &cr_time TASK_PARM );
d_utscm(nset, &cm_time[set] TASK_PARM DBN_PARM);
co_time[set] = cr_time;
}
if ( db_tssets )
d_utscs(nset, &cs_time[set] TASK_PARM DBN_PARM);
#endif
RETURN( db_status = S_OKAY );
}
/* vpp -nOS2 -dUNIX -nBSD -nVANILLA_BSD -nVMS -nMEMLOCK -nWINDOWS -nFAR_ALLOC -f/usr/users/master/config/nonwin findco.c */

View File

@@ -0,0 +1,80 @@
/* $XConsortium: findfm.c /main/2 1996/05/09 04:06:14 drk $ */
/*
* COMPONENT_NAME: austext
*
* FUNCTIONS: d_findfm
*
* ORIGINS: 157
*
* OBJECT CODE ONLY SOURCE MATERIALS
*/
/*-----------------------------------------------------------------------
findfm.c -- db_VISTA find first member module
(C) Copyright 1987 by Raima Corp.
-----------------------------------------------------------------------*/
/* ********************** EDIT HISTORY *******************************
SCR DATE INI DESCRIPTION
----- --------- --- -----------------------------------------------------
04-Aug-88 RTK MULTI_TASK changes
*/
#include <stdio.h>
#include "vista.h"
#include "dbtype.h"
/* Find first member of set
*/
d_findfm(nset TASK_PARM DBN_PARM)
int nset;
TASK_DECL
DBN_DECL
{
char setp[SETPSIZE];
DB_ADDR mem;
char FAR *recp;
int set;
SET_ENTRY FAR *set_ptr;
DB_ENTER(DB_ID TASK_ID LOCK_SET(SET_IO));
if (nset_check(nset, &set, (SET_ENTRY FAR * FAR *)&set_ptr) != S_OKAY)
RETURN( db_status );
/* make sure we have a current owner */
if ( ! curr_own[set] )
RETURN( dberr(S_NOCO) );
/* read current owner of set */
if ( dio_read(curr_own[set], (char FAR * FAR *)&recp, NOPGHOLD) != S_OKAY )
RETURN( db_status );
/* get set pointer from record */
if ( r_gset(set, recp, setp) != S_OKAY )
RETURN( db_status == S_INVOWN? dberr(S_SYSERR): db_status );
/* extract address of first member */
bytecpy(&mem, setp+SP_FIRST, DB_ADDR_SIZE);
/* set current record and member */
curr_mem[set] = mem;
if ( ! mem ) /* end of set if no first member */
RETURN( db_status = S_EOS );
curr_rec = mem;
#ifndef NO_TIMESTAMP
/* set timestamps */
if ( db_tsrecs ) {
d_utscr( &cr_time TASK_PARM );
cm_time[set] = cr_time;
}
if ( db_tssets )
/* only needed for system record support */
d_utscs(nset, &cs_time[set] TASK_PARM DBN_PARM);
#endif
RETURN( db_status = S_OKAY );
}
/* vpp -nOS2 -dUNIX -nBSD -nVANILLA_BSD -nVMS -nMEMLOCK -nWINDOWS -nFAR_ALLOC -f/usr/users/master/config/nonwin findfm.c */

View File

@@ -0,0 +1,80 @@
/* $XConsortium: findlm.c /main/2 1996/05/09 04:06:29 drk $ */
/*
* COMPONENT_NAME: austext
*
* FUNCTIONS: d_findlm
*
* ORIGINS: 157
*
* OBJECT CODE ONLY SOURCE MATERIALS
*/
/*-----------------------------------------------------------------------
findlm.c -- db_VISTA find last member module
(C) Copyright 1987 by Raima Corp.
-----------------------------------------------------------------------*/
/* ********************** EDIT HISTORY *******************************
SCR DATE INI DESCRIPTION
----- --------- --- -----------------------------------------------------
04-Aug-88 RTK MULTI_TASK changes
*/
#include <stdio.h>
#include "vista.h"
#include "dbtype.h"
/* Find last member of set
*/
d_findlm(nset TASK_PARM DBN_PARM)
int nset;
TASK_DECL
DBN_DECL
{
char setp[SETPSIZE];
DB_ADDR mem;
char FAR *recp;
int set;
SET_ENTRY FAR *set_ptr;
DB_ENTER(DB_ID TASK_ID LOCK_SET(SET_IO));
if (nset_check(nset, &set, (SET_ENTRY FAR * FAR *)&set_ptr) != S_OKAY)
RETURN( db_status );
/* make sure we have a current owner */
if ( ! curr_own[set] )
RETURN( dberr(S_NOCO) );
/* read current owner of set */
if ( dio_read(curr_own[set], (char FAR * FAR *)&recp, NOPGHOLD) != S_OKAY )
RETURN( db_status );
/* get set pointer from record */
if ( r_gset(set, recp, setp) != S_OKAY )
RETURN( (db_status == S_INVOWN) ? dberr(S_SYSERR) : db_status );
/* extract address of last member */
bytecpy(&mem, setp+SP_LAST, DB_ADDR_SIZE);
/* set current record and member */
curr_mem[set] = mem;
if ( ! mem ) /* end of set if no first member */
RETURN( db_status = S_EOS );
curr_rec = mem;
#ifndef NO_TIMESTAMP
/* set timestamps */
if ( db_tsrecs ) {
d_utscr( &cr_time TASK_PARM );
cm_time[set] = cr_time;
}
if ( db_tssets )
/* only needed for system record support */
d_utscs(nset, &cs_time[set] TASK_PARM DBN_PARM);
#endif
RETURN( db_status = S_OKAY );
}
/* vpp -nOS2 -dUNIX -nBSD -nVANILLA_BSD -nVMS -nMEMLOCK -nWINDOWS -nFAR_ALLOC -f/usr/users/master/config/nonwin findlm.c */

View File

@@ -0,0 +1,79 @@
/* $XConsortium: findnm.c /main/2 1996/05/09 04:06:45 drk $ */
/*
* COMPONENT_NAME: austext
*
* FUNCTIONS: d_findnm
*
* ORIGINS: 157
*
* OBJECT CODE ONLY SOURCE MATERIALS
*/
/*-----------------------------------------------------------------------
findnm.c -- db_VISTA find next member module
(C) Copyright 1987 by Raima Corp.
-----------------------------------------------------------------------*/
/* ********************** EDIT HISTORY *******************************
SCR DATE INI DESCRIPTION
----- --------- --- -----------------------------------------------------
04-Aug-88 RTK MULTI_TASK changes
*/
#include <stdio.h>
#include "vista.h"
#include "dbtype.h"
/* Find next member of set
*/
d_findnm(nset TASK_PARM DBN_PARM)
int nset;
TASK_DECL
DBN_DECL
{
int set;
char memp[MEMPSIZE];
DB_ADDR mem;
char FAR *recp;
DB_ADDR FAR *cm_ptr;
SET_ENTRY FAR *set_ptr;
DB_ENTER(DB_ID TASK_ID LOCK_SET(SET_IO));
if (nset_check(nset, &set, (SET_ENTRY FAR * FAR *)&set_ptr) != S_OKAY)
RETURN( db_status );
/* make sure we have a current owner */
if ( ! curr_own[set] )
RETURN( dberr(S_NOCO) );
/* find first member if no current member */
if ( !*(cm_ptr = &curr_mem[set]) )
RETURN( d_findfm(nset TASK_PARM DBN_PARM) );
/* read current member of set and get member pointer from record */
if ((dio_read(*cm_ptr, (char FAR * FAR *)&recp, NOPGHOLD) != S_OKAY) ||
(r_gmem(set, recp, memp) != S_OKAY))
RETURN( db_status );
/* extract address of next member */
bytecpy(&mem, memp+MP_NEXT, DB_ADDR_SIZE);
/* set current record and member */
*cm_ptr = mem;
if ( ! mem ) /* end of set */
RETURN( db_status = S_EOS );
curr_rec = mem;
#ifndef NO_TIMESTAMP
/* set timestamps */
if ( db_tsrecs ) {
d_utscr( &cr_time TASK_PARM );
cm_time[set] = cr_time;
}
#endif
RETURN( db_status = S_OKAY );
}
/* vpp -nOS2 -dUNIX -nBSD -nVANILLA_BSD -nVMS -nMEMLOCK -nWINDOWS -nFAR_ALLOC -f/usr/users/master/config/nonwin findnm.c */

View File

@@ -0,0 +1,79 @@
/* $XConsortium: findpm.c /main/2 1996/05/09 04:06:57 drk $ */
/*
* COMPONENT_NAME: austext
*
* FUNCTIONS: d_findpm
*
* ORIGINS: 157
*
* OBJECT CODE ONLY SOURCE MATERIALS
*/
/*-----------------------------------------------------------------------
findpm.c -- db_VISTA find previous member module
(C) Copyright 1987 by Raima Corp.
-----------------------------------------------------------------------*/
/* ********************** EDIT HISTORY *******************************
SCR DATE INI DESCRIPTION
----- --------- --- -----------------------------------------------------
04-Aug-88 RTK MULTI_TASK changes
*/
#include <stdio.h>
#include "vista.h"
#include "dbtype.h"
/* Find previous member of set
*/
d_findpm(nset TASK_PARM DBN_PARM)
int nset;
TASK_DECL
DBN_DECL
{
int set;
char memp[MEMPSIZE];
DB_ADDR mem;
char FAR *recp;
DB_ADDR FAR *cm_ptr;
SET_ENTRY FAR *set_ptr;
DB_ENTER(DB_ID TASK_ID LOCK_SET(SET_IO));
if (nset_check(nset, &set, (SET_ENTRY FAR * FAR *)&set_ptr) != S_OKAY)
RETURN( db_status );
/* make sure we have a current owner */
if ( ! curr_own[set] )
RETURN( dberr(S_NOCO) );
/* find last member if no current member */
if ( !*(cm_ptr = &curr_mem[set]) )
RETURN( d_findlm(nset TASK_PARM DBN_PARM) );
/* read current member of set and get member pointer from record */
if ((dio_read(*cm_ptr, (char FAR * FAR *)&recp, NOPGHOLD) != S_OKAY) ||
(r_gmem(set, recp, memp) != S_OKAY))
RETURN( db_status );
/* extract address of previous member */
bytecpy( &mem, memp+MP_PREV, DB_ADDR_SIZE);
/* set current record and member */
*cm_ptr = mem;
if ( ! mem ) /* end of set */
RETURN( db_status = S_EOS );
curr_rec = mem;
#ifndef NO_TIMESTAMP
/* set timestamps */
if ( db_tsrecs ) {
d_utscr( &cr_time TASK_PARM );
cm_time[set] = cr_time;
}
#endif
RETURN( db_status = S_OKAY );
}
/* vpp -nOS2 -dUNIX -nBSD -nVANILLA_BSD -nVMS -nMEMLOCK -nWINDOWS -nFAR_ALLOC -f/usr/users/master/config/nonwin findpm.c */

View File

@@ -0,0 +1,58 @@
/* $XConsortium: gtscm.c /main/2 1996/05/09 04:07:14 drk $ */
/*
* COMPONENT_NAME: austext
*
* FUNCTIONS: d_gtscm
*
* ORIGINS: 157
*
* OBJECT CODE ONLY SOURCE MATERIALS
*/
/*-----------------------------------------------------------------------
gtscm.c -- db_VISTA current member timestamp get module.
(C) Copyright 1987 by Raima Corporation.
-----------------------------------------------------------------------*/
/* ********************** EDIT HISTORY *******************************
SCR DATE INI DESCRIPTION
----- --------- --- -----------------------------------------------------
04-Aug-88 RTK MULTI_TASK changes
*/
#include <stdio.h>
#include "vista.h"
#include "dbtype.h"
#ifndef NO_TIMESTAMP
/* Get timestamp of current member
*/
d_gtscm(set, timestamp TASK_PARM DBN_PARM)
int set;
ULONG FAR *timestamp;
TASK_DECL
DBN_DECL
{
SET_ENTRY FAR *set_ptr;
DB_ENTER(DB_ID TASK_ID LOCK_SET(SET_NOIO));
if (nset_check(set, &set, (SET_ENTRY FAR * FAR *)&set_ptr) != S_OKAY)
RETURN( db_status );
/* make sure we have a current member */
if ( curr_mem[set] ) {
if ( db_tsrecs )
*timestamp = cm_time[set];
else
dberr(S_TIMESTAMP);
}
else
dberr(S_NOCM);
RETURN( db_status );
}
#endif
/* vpp -nOS2 -dUNIX -nBSD -nVANILLA_BSD -nVMS -nMEMLOCK -nWINDOWS -nFAR_ALLOC -f/usr/users/master/config/nonwin gtscm.c */

View File

@@ -0,0 +1,58 @@
/* $XConsortium: gtsco.c /main/2 1996/05/09 04:07:28 drk $ */
/*
* COMPONENT_NAME: austext
*
* FUNCTIONS: d_gtsco
*
* ORIGINS: 157
*
* OBJECT CODE ONLY SOURCE MATERIALS
*/
/*-----------------------------------------------------------------------
gtsco.c -- db_VISTA current owner timestamp get module.
(C) Copyright 1987 by Raima Corporation.
-----------------------------------------------------------------------*/
/* ********************** EDIT HISTORY *******************************
SCR DATE INI DESCRIPTION
----- --------- --- -----------------------------------------------------
04-Aug-88 RTK MULTI_TASK changes
*/
#include <stdio.h>
#include "vista.h"
#include "dbtype.h"
#ifndef NO_TIMESTAMP
/* Get timestamp of current owner
*/
d_gtsco(set, timestamp TASK_PARM DBN_PARM)
int set;
ULONG FAR *timestamp;
TASK_DECL
DBN_DECL
{
SET_ENTRY FAR *set_ptr;
DB_ENTER(DB_ID TASK_ID LOCK_SET(SET_NOIO));
if (nset_check(set, &set, (SET_ENTRY FAR * FAR *)&set_ptr) != S_OKAY)
RETURN( db_status );
/* make sure we have a current owner */
if ( curr_own[set] ) {
if ( db_tsrecs )
*timestamp = co_time[set];
else
dberr(S_TIMESTAMP);
}
else
dberr(S_NOCO);
RETURN( db_status );
}
#endif
/* vpp -nOS2 -dUNIX -nBSD -nVANILLA_BSD -nVMS -nMEMLOCK -nWINDOWS -nFAR_ALLOC -f/usr/users/master/config/nonwin gtsco.c */

View File

@@ -0,0 +1,53 @@
/* $XConsortium: gtscr.c /main/2 1996/05/09 04:07:42 drk $ */
/*
* COMPONENT_NAME: austext
*
* FUNCTIONS: d_gtscr
*
* ORIGINS: 157
*
* OBJECT CODE ONLY SOURCE MATERIALS
*/
/*-----------------------------------------------------------------------
gtscr.c -- db_VISTA current record timestamp get module.
(C) Copyright 1987 by Raima Corporation.
-----------------------------------------------------------------------*/
/* ********************** EDIT HISTORY *******************************
SCR DATE INI DESCRIPTION
----- --------- --- -----------------------------------------------------
04-Aug-88 RTK MULTI_TASK changes
*/
#include <stdio.h>
#include "vista.h"
#include "dbtype.h"
#ifndef NO_TIMESTAMP
/* Get timestamp of current record
*/
d_gtscr(timestamp TASK_PARM)
ULONG FAR *timestamp;
TASK_DECL
{
DB_ENTER(NO_DB_ID TASK_ID LOCK_SET(RECORD_NOIO));
db_status = S_OKAY;
/* make sure we have a current record */
if ( curr_rec ) {
if ( db_tsrecs )
*timestamp = cr_time;
else
dberr(S_TIMESTAMP);
}
else
dberr(S_NOCR);
RETURN( db_status );
}
#endif
/* vpp -nOS2 -dUNIX -nBSD -nVANILLA_BSD -nVMS -nMEMLOCK -nWINDOWS -nFAR_ALLOC -f/usr/users/master/config/nonwin gtscr.c */

Some files were not shown because too many files have changed in this diff Show More