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

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

View File

@@ -0,0 +1,56 @@
/* $XConsortium: AttributeData.cc /main/2 1996/07/18 16:07:35 drk $ */
/* exported interfaces */
#include "AttributeData.h"
/* imported interfaces */
#include "SGMLName.h"
#include "Token.h"
#include "Dispatch.h"
//-------------------------------------------------------------------------
AttributeData::AttributeData( const Token &t,
int attr_name,
ActionType mode ):BaseData(t, mode)
{
const char *str;
if ( str = attribute_value( t, attr_name ) ) {
data_complete = 1;
ValueBuffer.writeStr( str );
}
else {
data_avail = 0;
}
}
//-------------------------------------------------------------------------
const char *
AttributeData::attribute_value( const Token &t, int attributeName )
{
const AttributeRec *tmp;
int att_type;
tmp = t.LookupAttr( attributeName );
if ( !tmp ) {
return 0;
}
att_type = tmp->getAttrType();
if ( att_type == SGMLName::ENTITY ) {
SGMLDefn *sgml_defn = Dispatch::entity_ref( tmp->getAttrValueString() );
if ( !sgml_defn ) {
throw(Unexpected("no entity declaration for this entity"));
}
/*
* Use the file name
*/
return ( sgml_defn->getFileName() );
}
else if ( att_type == SGMLName::CDATA ||
att_type == SGMLName::TOKEN ){
return ( tmp->getAttrValueString() );
}
}

View File

@@ -0,0 +1,23 @@
/* $XConsortium: AttributeData.h /main/2 1996/07/18 16:36:49 drk $ */
#ifndef __attr_Data__
#define __attr_Data__
#include "BaseDataCollect.h"
class Token;
class AttributeData : public BaseData {
friend class FirstOf;
friend class OL_Data;
friend class Concat;
private:
const char *attribute_value( const Token &t, int attr_name );
protected:
AttributeData( const Token &t, int attr_name, ActionType mode );
};
#endif

View File

@@ -0,0 +1,115 @@
/* $XConsortium: AttributeList.C /main/3 1996/08/21 15:45:57 drk $
*
* (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.
*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <iostream.h>
#include <assert.h>
#include "AttributeRec.h"
#include "AttributeList.h"
// Debugging macro
#ifdef DEBUG
#define DBG(level) if ( dbgLevel >= level)
#else
#define DBG(level) if (0)
#endif
static int dbgLevel;
//---------------------------------------------------------
// ValList : Constructor
OL_AttributeList::OL_AttributeList()
{
DBG(10) cerr << "(DEBUG) Invoking OL_AttributeList::OL_AttributeList()\n";
dbgLevel=-1;
char *dbgStr;
head = NULL;
tail = NULL;
dbgStr = getenv("OL_DEBUG");
dbgLevel = ( dbgStr ? atoi(dbgStr):0);
}
//---------------------------------------------------------
// OL_AttributeList::OL_AttributeList
OL_AttributeList::~OL_AttributeList()
{
AttributeRec *pt = head;
while ( pt ) {
AttributeRec *tmp = pt;
pt = pt->next;
delete tmp;
}
}
//---------------------------------------------------------
// OL_AttributeList:lookup
AttributeRec *OL_AttributeList::lookup( int attName ) const
{
DBG(10) cerr << "(DEBUG) Invoking OL_AttributeList::lookup()\n";
DBG(10) cerr << " with attName = " << attName << endl;
AttributeRec *pt = head;
while ( pt ) {
if ( pt->attName == attName ) {
return ( pt );
}
pt = pt->next;
}
return ( NULL );
}
//---------------------------------------------------------
// OL_AttributeList::add
void OL_AttributeList::insert ( AttributeRec *entry )
{
if ( !tail ) {
head = tail = entry;
}
else {
tail->next = entry;
tail = entry;
}
}
//---------------------------------------------------------
const AttributeRec *OL_AttributeList::GetFirstAttr() const
{
return( head );
}
//---------------------------------------------------------
const AttributeRec *
OL_AttributeList::GetNextAttr( const AttributeRec *attRec) const
{
assert( attRec != NULL );
return( attRec->next );
}

View File

@@ -0,0 +1,32 @@
/* $XConsortium: AttributeList.h /main/3 1996/08/21 15:46:01 drk $ */
//---------------------------------------------------------
// AttributeList.h
#ifndef ATT_LIST_HDR
#define ATT_LIST_HDR
#include <stdio.h>
#include "AttributeRec.h"
class OL_AttributeList {
friend class Token;
protected:
AttributeRec *head;
AttributeRec *tail;
AttributeRec *lookup ( int ) const;
void insert(AttributeRec * );
const AttributeRec *GetFirstAttr() const;
const AttributeRec *GetNextAttr( const AttributeRec *) const;
OL_AttributeList();
~OL_AttributeList();
};
#endif

View File

@@ -0,0 +1,65 @@
/* $XConsortium: AttributeRec.cc /main/4 1996/07/18 16:08:22 drk $ */
#include <string.h>
#include <stdlib.h>
#include <iostream.h>
#include <assert.h>
#include "SGMLDefn.h"
#include "SGMLName.h"
#include "AttributeRec.h"
#ifdef FISH_DEBUG
#include <dbug.h>
#endif
//---------------------------------------------------------------------
AttributeRec::AttributeRec( const char *name,
const char *value,
int type )
{
#ifdef FISH_DEBUG
DBUG_PRINT("AttributeRec", ("name = %s\n"
"value = %s\n"
"type = %d", name, value, type));
#endif
next=NULL;
attName = SGMLName::intern( name );
switch(attType = type){
case SGMLName::TOKEN:
case SGMLName::NOTATION:
case SGMLName::ENTITY:
attValue = SGMLName::intern( value );
attValueString = SGMLName::lookup(attValue);
copy = NULL;
#ifdef FISH_DEBUG
DBUG_PRINT("AttributeRec", ("attValue after the intern: %d", attValue));
#endif
break;
case SGMLName::CDATA:
attValue = -1;
attValueString = copy = new char[ strlen(value) + 1 ];
strcpy( copy, value );
break;
default:
abort();
}
}
//---------------------------------------------------------------------
AttributeRec::~AttributeRec()
{
delete copy;
}
//---------------------------------------------------------------------
int
AttributeRec::getAttrName() const
{
return(attName);
}

View File

@@ -0,0 +1,48 @@
/* $XConsortium: AttributeRec.h /main/3 1996/08/21 15:46:05 drk $ */
//----------------------------------------------
// AttributeRec.h
#ifndef ATT_REC_HDR
#define ATT_REC_HDR
#include "SGMLName.h"
class SGMLDefn;
class AttributeRec {
friend class OL_AttributeList;
friend class Token;
private:
int attName;
int attType;
const char *attValueString;
char *copy;
int attValue;
AttributeRec *next;
protected:
AttributeRec( const char * name, const char *value,
int type );
~AttributeRec();
public:
int getAttrName() const;
/* use this for CDATA attributes */
const char *getAttrValueString() const { return(attValueString); }
/* use this for NAME, NOTATION, ENTITY attributes */
int getAttValue() const { return(attValue); }
int getAttrType() const { return(attType); }
int operator== ( AttributeRec & s ) {
return ( attName == s.attName );
}
};
#endif

View File

@@ -0,0 +1,111 @@
/* $XConsortium: AttributeStore.C /main/3 1996/08/21 15:46:08 drk $ */
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <iostream.h>
#include "List.h"
#include "AttributeRec.h"
#include "AttributeStore.h"
#include "HashBucketEntry.h"
// Debugging macro
#ifdef DEBUG
#define DBG(level) if ( dbgLevel >= level)
#else
#define DBG(level) if (0)
#endif
//---------------------------------------------------------
// AttributeStore : Constructor
AttributeStore::AttributeStore( int sz ):NumBuckets(sz)
{
char *dbgStr;
dbgStr = getenv("OL_DEBUG");
dbgLevel = ( dbgStr ? atoi(dbgStr):0);
HashTable = new HashBucketEntry * [ NumBuckets ];
if ( !HashTable ) {
cerr << "(ERROR) Unable to allocate memory for HashTable\n";
exit(1);
}
for ( int i=0; i < sz; i++) {
HashTable[i] = NULL;
}
}
//---------------------------------------------------------
// AttributeStore : Destructor
AttributeStore::~AttributeStore()
{
for ( int i=0; i < NumBuckets; i++ ) {
delete HashTable[i];
}
}
//---------------------------------------------------------
// AttributeStore::hash()
int AttributeStore::hash( char *HashKeyStr )
{
DBG(10) cerr << "(DEBUG) Invoking hash function with HashKeyStr = "
<< HashKeyStr << endl;
int sum=0;
// This is a simple hash function
for ( char *ptr=HashKeyStr; *ptr; ptr++ ) {
sum += *ptr;
}
sum = sum % NumBuckets;
DBG(10) cerr << "(DEBUG) returning value for hash function = "
<< sum << endl;
return ( sum );
}
//---------------------------------------------------------
// AttributeStore::lookup
char *AttributeStore::lookup( Token *ThisToken, char *aName )
{
int HashValue;
AttributeRec *aRecPtr;
HashValue=hash( aName );
aRecPtr = HashTable[ HashValue ]->lookup( aName );
return ( aRecPtr->GetAttributeValue( ThisToken ) );
}
//---------------------------------------------------------
// AttributeStore::add
int AttributeStore::insert ( AttributeRec *att )
{
int HashValue;
HashBucketEntry *BucketEntry;
HashValue = hash ( att->name );
BucketEntry = HashTable [ HashValue ];
if ( BucketEntry->lookup ( att->name ) ) {
return(0);
}
else {
BucketEntry->insert( att );
return(1);
}
}

View File

@@ -0,0 +1,34 @@
/* $XConsortium: AttributeStore.h /main/2 1996/07/18 16:38:25 drk $ */
//---------------------------------------------------------
// AttributeSore.h
#ifndef ATT_STORE
#define ATT_STORE
#include "AttributeRec.h"
class AttributeStore {
private:
AttributeRec *head;
AttributeRec *current;
public:
char *lookup ( char * );
int add ( AttributeRec * );
AttributeRec *getNext() {
AttributeRec *ptr;
if ( current ) {
ptr = current;
current = current->next;
return (ptr );
}
else {
return ( NULL );
}
}
AttributeStore();
~AttributeStore();
};
#endif

View File

@@ -0,0 +1,242 @@
/* $XConsortium: AusText.C /main/3 1996/09/10 16:04:23 cde-hal $
*
* (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.
*/
/* imported interfaces */
#include "OL-Data.h"
#include "Task.h"
#include "FlexBuffer.h"
#include "Token.h"
#include "OLAF.h"
#include "BookCaseDB.h"
#include "BookTasks.h"
#include "NodeData.h"
#include "NodeTask.h"
#include "GraphicsTask.h"
#include "BookTasks.h"
#include "Dispatch.h"
#include "SGMLName.h"
#include "DataRepository.h"
#include "AusTextStorage.h"
/* exported interfaces */
#include "AusText.h"
const unsigned char WORD_SEP = ' ';
// charater strings
const int OLIAS_SCOPE_TITLE = OLAF::Title;
const int OLIAS_SCOPE_EXAMPLE = OLAF::Example;
const int OLIAS_SCOPE_INDEX = OLAF::Index;
const int OLIAS_SCOPE_TABLE = OLAF::Table;
const int OLIAS_SCOPE_GRAPHIC = OLAF::Graphic;
//-----------------------------------------------------------------------
AusText::AusText(NodeData *f_node, const Token &t):SearchEngine(f_node, t)
{
store = new DataRepository;
f_search_store = NULL;
// NOTE: We need to activate default zone here because AusText::markup
// is not being called for the top element in the section.
// Do not forget to deactivate it on the other end!
store->ActivateZone ( DataRepository::Default, t.level() );
}
//-----------------------------------------------------------------------
AusText::~AusText()
{
store->deActivateZone ( f_base );
if ( store ) { delete store; }
if ( f_search_store ) { delete f_search_store; }
}
//-----------------------------------------------------------------------
void
AusText::write_start_tag ( const Token &t)
{
const AttributeRec *a;
int level = t.level();
if ( a = t.LookupAttr( OLAF::OL_scope ) ) {
switch ( a->getAttValue() ) {
case OLIAS_SCOPE_EXAMPLE :
store->ActivateZone( DataRepository::Example, level );
break;
case OLIAS_SCOPE_GRAPHIC :
store->ActivateZone( DataRepository::Graphic, level );
break;
case OLIAS_SCOPE_INDEX :
store->ActivateZone( DataRepository::Index, level );
break;
case OLIAS_SCOPE_TABLE :
store->ActivateZone( DataRepository::Table, level );
break;
case OLIAS_SCOPE_TITLE :
store->ActivateZone( DataRepository::Head, level );
break;
default : throw(Unexpected("Not a valid zone"));
}
}
#if 0
else {
store->ActivateZone ( DataRepository::Default, level );
}
#endif
store->put( WORD_SEP );
}
//------------------------------------------------------------------------
void
AusText::write_end_tag( const Token & t)
{
store->deActivateZone( t.level() );
store->put( WORD_SEP );
}
//------------------------------------------------------------------------
void
AusText::write_terms( FlexBuffer *termsbuf )
{
int bufsize = termsbuf->GetSize();
const char *buffer = termsbuf->GetBuffer();
store->write( buffer, bufsize );
termsBuffer = termsbuf;
}
//------------------------------------------------------------------------
void
AusText::write_buffer()
{
BookCaseTask *f_bc = f_parent->node()->book()->bookcase();
const char *BookCaseName = f_bc->bookcasename();
const char *pathname = f_bc->database()->path();
f_search_store = new AusTextStore( pathname, BookCaseName );
assert(f_search_store != NULL);
const char *book_short_title = f_parent->node()->book()->book_short_title();
const char *book_id = f_parent->node()->book()->locator();
const char *nodelocator = f_parent->node()->locator();
const char *node_title = f_parent->node()->title();
f_search_store->insert(book_short_title,
book_id,
nodelocator,
node_title,
store
);
}
//------------------------------------------------------------------------
void
AusText::markup( const Token & t )
{
if ( f_base > 0 ) {
ComplexTask::markup(t);
if ( t.type() == START ) {
if ( Dispatch::OutsideIgnoreScope() ) {
if ( t.LookupAttr( OLAF::OL_Graphic ) ) {
CollectObject = t.level();
f_graphics = new GraphicsTask ( this, t );
assert ( f_graphics != NULL );
addSubTask( f_graphics );
}
#if TABLES
else if( t.LookupAttr( OLAF::OL_Table ) ) {
CollectObject = t.level();
addSubTask(new SearchableTableTask(this, t));
}
#endif
write_start_tag ( t );
}
}
else if ( t.type() == END ) {
if ( Dispatch::OutsideIgnoreScope() ) {
if ( CollectObject >= 0 ) {
if ( CollectObject == t.level() ) {
CollectObject = -1;
if ( f_graphics ) {
if ( f_graphics->HasSearchTerms() ) {
hasTerms = 1;
FlexBuffer *buf = (FlexBuffer *)f_graphics->GetTerms();
write_terms ( buf );
}
KILLSUBTASK( f_graphics );
}
}
}
write_end_tag( t );
if ( f_base == t.level() ) {
f_base = -1;
write_buffer();
}
} /* OutsideIgnoreScope */
} /* if ( t.type() == END ) */
} /* if ( f_base > 0 ) */
}
//---------------------------------------------------------------------
void
AusText::data ( const char *str, size_t sz )
{
if ( f_base > 0 ) {
ComplexTask::data( str, sz );
if ( Dispatch::OutsideIgnoreScope() ) {
/* @@ for tables, this isn't quite right... */
if ( CollectObject < 0 ) {
if ( sz == 0 ) { return; }
store->write( str, sz );
}
}
}
}

View File

@@ -0,0 +1,36 @@
/* $XConsortium: AusText.h /main/2 1996/07/18 16:38:54 drk $ */
// AusText.h - Specific implementation for AusText search engine
#ifndef AUSTEXT_HEADER
#define AUSTEXT_HEADER
#include "SearchEng.h"
class Token;
class AusTextStore;
class NodeData;
class DataRepository;
class AusText : public SearchEngine {
private:
DataRepository *store;
AusTextStore *f_search_store;
protected:
void write_start_tag ( const Token &);
void write_end_tag ( const Token & );
void write_terms ( FlexBuffer *termsbuf );
void write_buffer();
public:
void markup( const Token & );
void data( const char *, size_t );
public:
AusText(NodeData *, const Token &);
~AusText();
};
#endif

View File

@@ -0,0 +1,343 @@
/* $XConsortium: AusTextStorage.cc /main/5 1996/07/23 18:08:29 cde-hal $
*
* (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.
*/
#include <stdio.h>
#include <stddef.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <assert.h>
#include <stream.h>
/* imported interfaces */
#include <misc/unique_id.h>
#include "FlexBuffer.h"
#include "Task.h"
#include "DataBase.h"
#include "DataRepository.h"
/* exported interfaces */
#include "AusTextStorage.h"
#ifdef DTSR_USE_CNTR_L
const char CNTR_L = '\014'; /* This is for ascii system only */
#endif
// If NodeParser ever gets setup to run on all bookcases at one time, we
// will need a reset() function for this member.
unsigned long AusTextStore::f_recordcount = 0;
#ifdef DTSR_LIKES_FGETS
const int LINE_SIZE = 80; /* this is the line size allowed for data in
* the *.fzk file
*/
/* Most of the non-alphanumeric character in ascii code set */
const char *DELIMITER_SET = "\t\n !@#$%^&*()_-=+\\|~[]{};:,.<>/?";
enum EucCodeSet {
CodeSetInv = -1,
CodeSet0 = 0,
CodeSet1 = 1,
CodeSet2 = 2,
CodeSet3 = 3
};
/*
* charcspn determines if ch is found in the set
* returns 1 if so, 0 if otherwise
*/
/*
* @@ charset is expensive, alternative approach is to use a
* static array
* static char char_tab[] = { 0, 0, 0, 1,...... }
* where 1 indicates the character is in the delimiter character set
* however, this might not be portable for character set other than
* ascii , so this has to be done carefully
* If the format of the fzk is changed, all this will no longer be
* required. So, I am not going to do anything at this point
*/
//-----------------------------------------------------------------
static int charset ( const char ch, const char *set)
{
for ( const char *ptr = set;
*ptr != '\0';
ptr++ ) {
if ( ch == *ptr ) return 1;
}
return 0;
}
/*
* getline returns the no. of bytes that should be read as a line.
* Normally it should read line_size, but if there is a token that
* spans 2 lines, getline need to determine the line size such that
* at the end of the line, no token should be spanning the next line.
*/
/*
* start_ptr is the start of the buffer and end_ptr is the end of the buffer
* it is similar to fread except that end_ptr is supplied as the bounding
* condition as opposed to the EOF in fread. Besides, no actual character
* is read , only the number of characters that should be read as a line.
*/
//--------------------------------------------------------------------------
static unsigned int DefaultGetLine ( const char *start_ptr,
const char *end_ptr,
int line_size )
{
if ( start_ptr > end_ptr ) { return 0; }
if ( start_ptr + line_size - 1 <= end_ptr ) { // not @ the end yet
/*
* FIrst see if there is a token that spans multiple lines
*/
const char *ptr = start_ptr + line_size - 1;
if ( ptr == end_ptr ) { return line_size; }
if ( charset( *(ptr+1), DELIMITER_SET ) || charset ( *ptr, DELIMITER_SET ) ) {
return ( line_size );
}
/* That means found a token that spans 2 lines */
/* So now loop back until *ptr is not in DELIMITER_SET */
const char *new_end_ptr;
for ( new_end_ptr = ptr;
new_end_ptr > start_ptr && !charset( *new_end_ptr , DELIMITER_SET );
new_end_ptr-- );
return( new_end_ptr - start_ptr + 1 );
}
else {
// last chunk of line
return ( end_ptr - start_ptr + 1 );
}
}
inline EucCodeSet JpEucCodeSet(const unsigned char* text)
{
EucCodeSet codeset;
if (text == NULL)
codeset = CodeSetInv;
else if (*text < 0x80)
codeset = CodeSet0;
else if (*text == 0x8E)
codeset = CodeSet2;
else if (*text == 0x8F)
codeset = CodeSet3;
else {
assert( *text > 0xA0 && *text < 0xFF);
codeset = CodeSet1;
}
return codeset;
}
static unsigned int JpGetLine ( const char *start_ptr,
const char *end_ptr,
int line_size )
{
if (start_ptr > end_ptr)
return 0;
if (end_ptr - start_ptr + 1 <= line_size)
return (end_ptr - start_ptr + 1);
// reference limit
const char* limit = start_ptr + line_size;
EucCodeSet codeset = JpEucCodeSet((const unsigned char*)start_ptr);
int len;
const char* p;
for (p = start_ptr; p < limit; p += len) {
if (JpEucCodeSet((const unsigned char*)p) != codeset)
break;
if (codeset == CodeSet0)
len = 1;
else if ((codeset == CodeSet1) || (codeset == CodeSet2))
len = 2;
else if (codeset == CodeSet3)
len = 3;
else
len = 0;
if ((len == 0) || (p + len - 1 > end_ptr))
break;
}
return (p - start_ptr);
}
#endif // DTSR_LIKES_FGETS
//-----------------------------------------------------------------------
static int isdir(const char* filename)
{
int ret = 0;
struct stat sb;
if(stat(filename, &sb) == 0){
if(S_ISDIR(sb.st_mode)){
ret = 1;
}
}
return ret;
}
//-----------------------------------------------------------------------
static void makedir(const char *path) /* throw(PosixError) */
{
if(mkdir((char*)path, 0775) != 0){
throw(PosixError(errno, path));
}
}
//-----------------------------------------------------------------------
AusTextStore::AusTextStore( const char *path, const char *name )
{
if ( !isdir(path) ) {
makedir(path);
}
austext_path = new char [ strlen(path) + 1 + strlen("dtsearch") + 1 ];
/*
* throw(ResourceExhausted)
*
*/
assert ( austext_path != NULL );
sprintf( austext_path, "%s/dtsearch", path );
if ( !isdir(austext_path) ) {
makedir(austext_path);
}
char *fzk = form("%s/%s.fzk", austext_path, name );
/* Use append instead because this fzk file is going to be appended
* all the time
*/
afp = fopen ( fzk, "a" );
if ( !afp ) {
throw(PosixError(errno, form("unable to open fzk file %s\n", fzk) ) );
}
}
//-----------------------------------------------------------------------
void
AusTextStore::insert( const char *BookShortTitle,
const char *BookID,
const char *SectionID,
const char *SectionTitle,
DataRepository *store
)
{
/* write the abstract and record stuff in the fzk file */
if ( afp ) {
f_recordcount++;
/* Record type ie for all the zone content */
FlexBuffer **table = store->tabbuf();
for ( int pos=store->Default;
pos < store->Total;
pos++ ) {
if ( table[pos] ) {
if ( table[pos]->GetSize() > 0 ) {
fprintf(afp, " 0,2\n");
/* abstract includes SectionID\tBookShortTitle\tSectionTitle */
fprintf(afp, "ABSTRACT: %s\t%s\t%s\n", SectionID,
BookShortTitle,
SectionTitle );
// first the record type
// The following was unique, but there is a limit to the size of
// the key, so let's just use a simple counter.
// fprintf(afp, "%s%s%s\n", store->get_zone_name(pos), BookID, SectionID);
fprintf(afp, "%s%d\n", store->get_zone_name(pos), f_recordcount);
fprintf(afp, "0/0/0~0:0\n"); // null date
// Now the actual buffer
const char *start_ptr = table[pos]->GetBuffer();
const char *end_ptr = start_ptr + table[pos]->GetSize() - 1;
#ifdef DTSR_LIKES_FGETS
unsigned int (*getline)(const char *, const char *, int);
const char* lang = getenv("LANG");
if (lang && !strncmp(lang, "ja", strlen("ja")))
getline = JpGetLine;
else
getline = DefaultGetLine;
int num_byte;
while ( num_byte = getline(start_ptr, end_ptr, LINE_SIZE) ) {
if ( !fwrite(start_ptr, num_byte, 1, afp ) )
{
throw(PosixError(errno, "unable to write to fzk file\n" ) );
}
fputc('\n', afp );
start_ptr += num_byte;
}
// for current section and book level scopes, place the book and
// section ids into the indexed data.
fprintf(afp, "\n%s\n%s\n", BookID, SectionID);
#else
char *ptr = (char*)start_ptr;
for (; ptr <= end_ptr; ptr++) {
if (*ptr == '\n')
*ptr = ' ';
}
if (fwrite(start_ptr, table[pos]->GetSize(), 1, afp) == 0)
throw(PosixError(errno, "unable to write to fzk file\n"));
// for current section and book level scopes, place the book and
// section ids into the indexed data.
fprintf(afp, "\t%s\t%s", BookID, SectionID);
#endif
#ifdef DTSR_USE_CNTR_L
// Then the ^L character at the end
fprintf(afp, "\n%c\n", CNTR_L );
#else
fprintf(afp, "\n");
#endif
}
}
}
}
}
//-----------------------------------------------------------------------
AusTextStore::~AusTextStore()
{
if ( afp ) { fclose(afp); }
if ( austext_path ) { delete [] austext_path; }
}

View File

@@ -0,0 +1,37 @@
/* $XConsortium: AusTextStorage.h /main/3 1996/07/18 16:39:21 drk $ */
#ifndef AUSTEXT_STOR_HDR
#define AUSTEXT_STOR_HDR
class DataRepository;
class AusTextStore {
private:
FILE *afp;
char *austext_path;
static unsigned long f_recordcount;
public:
AusTextStore( const char *BookCasePath, const char *BookCaseName );
/*
* insert ( "This Book Case Name", 2,
* "XmyLcfhalklkoop",
* "This is the text that the indexing machine will see",
* 51 );
*
*/
void insert( const char *BookShortTitle,
const char *BookID,
const char *SectionID,
const char *SectionTitle,
DataRepository *store
);
~AusTextStore();
};
#endif

View File

@@ -0,0 +1,28 @@
/* $XConsortium: BTCollectable.cc /main/2 1996/07/18 16:09:37 drk $ */
#include <string.h>
// exported interfaces
#include "BTCollectable.h"
//--------------------------------------------------------------------
BTCollectable::BTCollectable():f_name(0), line_num(0), value(0)
{
}
//--------------------------------------------------------------------
BTCollectable::BTCollectable(
const char *filename, int line_no, const char *val
)
{
f_name = strdup( filename );
line_num = line_no;
value = strdup( val );
}
//--------------------------------------------------------------------
BTCollectable::~BTCollectable()
{
delete f_name;
delete value;
}

View File

@@ -0,0 +1,26 @@
/* $XConsortium: BTCollectable.h /main/2 1996/07/18 16:39:46 drk $ */
#ifndef BT_COLLECT
#define BT_COLLECT
class BTCollectable
{
public:
BTCollectable();
BTCollectable( const char *filename, int line_no, const char *val=NULL );
~BTCollectable();
char *filename() { return(f_name); }
int linenum() { return(line_num); }
char *get_value() { return( value ); }
private:
char *f_name;
int line_num;
char *value;
};
#endif

View File

@@ -0,0 +1,42 @@
/* $XConsortium: BaseDataCollect.h /main/2 1996/07/18 16:40:12 drk $ */
#ifndef __BaseDataCollect_h
#define __BaseDataCollect_h
#include "Task.h"
#include "Token.h"
#include "FlexBuffer.h"
enum ActionType {
DEFAULT_ACTION=0,
IGNORE_ON=1,
REMOVE_SPACES=2,
GENERATE_ID=4
};
class BaseData : public ComplexTask {
protected:
int f_base;
FlexBuffer ValueBuffer;
int data_avail;
int data_complete;
int ignore_status;
protected:
BaseData( const Token &t, ActionType istat) {
f_base = t.level();
data_avail = 1;
data_complete = 0;
ignore_status = istat & IGNORE_ON;
}
public:
int ContentIsEmpty() { return ( ValueBuffer.GetSize() == 0 ); }
const char *content() { return( ValueBuffer.GetBuffer() ); }
int content_size() { return( ValueBuffer.GetSize() ); }
int DataWillBeAvailable() { return( data_avail ); }
int DataIsComplete() { return( data_complete ); }
};
#endif

View File

@@ -0,0 +1,81 @@
/* $XConsortium: BookCaseDB.C /main/4 1996/10/26 18:17:13 cde-hal $ */
#include "BookCaseDB.h"
#include <assert.h>
/*--------------------------------------------------------------------
*
* The BookCase is represented as a database (a directory) containing
* several tables (files).
*
* As the tables are shared by many tasks within the bookcase task,
* they are accessed through the bookcase, and created here...
*
*--------------------------------------------------------------------*/
/* This will be placed in a global .h file eventually */
#define LINK_CODE 1333
BookCaseDB::BookCaseDB(const char *dir)
: DB(dir)
{
for(int i = 0; i < TableQty; i++){
f_tables[i] = NULL;
}
}
//--------------------------------------------------------------------
struct Schema{
int id;
const char *name;
int code;
int cols;
};
#define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0]))
//--------------------------------------------------------------------
DBTable*
BookCaseDB::table(int tid, int a)
{
static Schema schema[] = {
{ BookMeta, "BookMeta", DOC_CODE, 6 },
{ NodeMeta, "NodeMeta", NODE_CODE, 8 },
{ NodeSGML, "NodeSGML", SGML_CONTENT_CODE, 3 },
{ Link, "Link", LINK_CODE, 3 },
{ Locator, "Locator", LOCATOR_CODE, 5 },
{ TOCTree, "ContentsTree", TOC_CODE, 5 },
{ TOCPath, "ContentsPath", DLP_CODE, 4 },
{ Graphics, "Graphics", GRAPHIC_CODE, 7 },
{ StyleSheet, "StyleSheet", NODE_CODE, 3 },
{ XRef, "XRef", XREF_CODE, 4 },
};
assert(tid >= 0 && tid < TableQty);
assert(schema[tid].id == tid); /* just be sure the code doesn't get out
* of sync.
*/
if(!f_tables[tid]){
f_tables[tid] = DB::table(schema[tid].name,
schema[tid].code,
schema[tid].cols,
a);
}
return f_tables[tid];
}
BookCaseDB::~BookCaseDB()
{
for( int i = 0; i < TableQty; i++ ) {
if ( f_tables[i] ) {
delete f_tables[i]; f_tables[i] = 0;
}
}
}

View File

@@ -0,0 +1,32 @@
/* $XConsortium: BookCaseDB.h /main/3 1996/09/23 22:23:30 cde-hal $ -*- c++ -*- */
#ifndef __BookCaseDB_h
#define __BookCaseDB_h
#include "DataBase.h"
class BookCaseDB : public DB{
public:
BookCaseDB(const char *dir);
~BookCaseDB();
/*
* Enumeration of tables...
*/
typedef enum {
BookMeta,
NodeMeta, NodeSGML, Link, Locator,
TOCTree, TOCPath,
Graphics,
StyleSheet,
XRef,
TableQty
}TableID;
DBTable *table(int, int access = DB::CREATE);
DBTable *f_tables[TableQty];
};
#endif /* __BookCaseDB_h */

View File

@@ -0,0 +1,652 @@
/* $XConsortium: BookTasks.cc /main/5 1996/05/29 12:36:58 rcs $
*
* (c) Copyright 1996 Digital Equipment Corporation.
* (c) Copyright 1996 Hewlett-Packard Company.
* (c) Copyright 1996 International Business Machines Corp.
* (c) Copyright 1996 Sun Microsystems, Inc.
* (c) Copyright 1996 Novell, Inc.
* (c) Copyright 1996 FUJITSU LIMITED.
* (c) Copyright 1996 Hitachi.
*/
#include <stream.h>
/* import... */
#include <assert.h>
#include <string.h>
#include "Dispatch.h"
#include "Token.h"
#include "OLAF.h"
#include "NodeTask.h"
#include "TOCTask.h"
#include "BookCaseDB.h"
#include "OL-Data.h"
#include "StringList.h"
#include "StyleTask.h"
/* export... */
#include "BookTasks.h"
#ifdef LICENSE_MANAGEMENT
#include "cryptlib/lterms.h"
#endif
#ifdef FISH_DEBUG
#include "dbug.h" /* ala Fred Fish's dbug package from uunet */
#endif
const int A_FEATURE = OLAF::Feature;
const int A_VEN_CODE = OLAF::VenCode;
const int A_VERSION = OLAF::Version;
const int A_GROUPING = OLAF::Grouping;
const int A_DEMO_TERMS = OLAF::DemoTerms;
const int A_DEFAULT_SECTION = OLAF::DefaultSection;
/***********************************
*
* BookCaseTask
*
***********************************/
BookCaseTask::BookCaseTask(const char *infolib)
{
library = new char[strlen(infolib)+1];
strcpy(library, infolib);
f_base = -1;
bookCaseName = NULL;
bookCaseDesc = NULL;
f_db = NULL;
if ( !Dispatch::RunTocGenOnly() ) {
style = new StyleTaskDB(this);
addSubTask(style);
}
book = new BookTask(this);
addSubTask(book);
f_style = NULL;
}
//--------------------------------------------------------------------
BookCaseDB*
BookCaseTask::database()
{
if(!f_db){
f_db = new BookCaseDB(library);
}
return f_db;
}
//--------------------------------------------------------------------
DBTable *
BookCaseTask::table(int tid)
{
return database()->table(tid);
}
//--------------------------------------------------------------------
const char *
BookCaseTask::bookcasename()
{
if ( !bookCaseName ) {
throw(Unexpected("BookCase name not available yet."));
}
return ( bookCaseName->content() );
}
/*
//--------------------------------------------------------------------
void
BookCaseTask::write_full_text_record( const char *str,
int sz,
const char *nodelocator,
const char *node_title
)
{
const char *BookCaseName = bookcasename();
if ( !f_search_storage ) {
const char *pathname = database()->path();
f_search_storage = new FulcrumStore( pathname , BookCaseName);
assert ( f_search_storage );
}
const int BookNum = book->sequencenum();
const char *BookShortTitle = book->book_short_title();
f_search_storage->insert( BookCaseName,
BookNum,
BookShortTitle,
nodelocator,
node_title,
str,
sz );
}
*/
/*
//--------------------------------------------------------------------
void
BookCaseTask::write_full_text_record(DataRepository *store,
const char *nodelocator,
const char *node_title
)
{
const char *BookCaseName = bookcasename();
if ( !f_search_storage ) {
const char *pathname = database()->path();
f_search_storage = new AusTextStore( pathname, BookCaseName );
assert( f_search_storage );
}
const char *BookShortTitle = book->book_short_title();
f_search_storage->insert( BookShortTitle,
nodelocator,
node_title,
store
);
}
*/
//--------------------------------------------------------------------
void BookCaseTask::markup(const Token &t)
{
ComplexTask::markup(t);
if (t.type() == START){
if(t.olaf() == OLAF::Bookcase){
if(f_base >= 0){
throw(Unexpected("second (illegal) BookCase element found"));
}
f_base = t.level();
}
if(f_base >= 0){
switch(t.olaf()){
case OLAF::BcName:
if(bookCaseName){
throw(Unexpected("second (illegal) bookcase name element found"));
}
bookCaseName = new OL_Data(t, OLAF::OL_data);
addSubTask(bookCaseName);
break;
case OLAF::BcDesc:
if(bookCaseDesc){
throw(Unexpected("second (illegal) bookcase description element found"));
}
bookCaseDesc = new OL_Data(t, OLAF::OL_data);
addSubTask(bookCaseDesc);
break;
}
if(!f_style && t.LookupAttr(OLAF::OL_style)){
OL_Data *tmp_style = new OL_Data(t, OLAF::OL_style);
if ( tmp_style->DataWillBeAvailable() ) {
f_style = tmp_style;
addSubTask(f_style);
}
else {
delete tmp_style;
}
}
}
}
else if(t.type() == END){
if(t.level() == f_base){
const char *name;
const char *desc;
if(bookCaseName){
name = bookCaseName->content();
}else{
throw(Unexpected("No bookcase name element in Bookcase element."));
}
if(bookCaseDesc){
desc = bookCaseDesc->content();
}else{
desc = "";
}
printf("BookCase name: `%s' desc: `%s'\n", name, desc);
}
/* @# warn if no bookcase ever found? */
}
}
const char *
BookCaseTask::styleName()
{
const char *ret;
if ( Dispatch::RunTocGenOnly() ) {
return("");
}
if(!f_style) {
throw(Unexpected ("No style architectural form defined for bookcase."));
}
ret = f_style->content();
#ifdef FISH_DEBUG
DBUG_PRINT("Style", ("bookcase style is: %s", ret));
#endif
if(!style->exist(ret)){
#ifdef FISH_DEBUG
DBUG_PRINT("Error", ("style `%s' not found", ret));
#endif
Token::signalError(Token::User, Token::Fatal, NULL, 0,
"An undeclared style sheet name `%s' was found in the bookcase specification.\n", ret);
}
return ret;
}
/*****************
*
* BookTask
*
*****************/
BookTask::BookTask(BookCaseTask *bc)
{
f_base = 0;
f_seq_no = 1;
f_toc = NULL;
f_bookcase = bc;
tocLocator = NULL;
shortTitle = NULL;
title = NULL;
tabName = NULL;
tabLocator = NULL;
tabNames = new StringList();
tabLocators = new StringList();
tabLines = new StringList();
tabFiles = new StringList();
f_node = new NodeTask(this, NULL);
addSubTask(f_node);
f_style = NULL;
e_string = NULL;
e_len = 0;
}
BookTask::~BookTask()
{
KILLSUBTASK(f_node);
delete tabLocators;
KILLSUBTASK(title);
KILLSUBTASK(shortTitle);
KILLSUBTASK(tabName);
KILLSUBTASK(tabLocator);
}
//------------------------------------------------------------------
void
BookTask::encrypt( const Token &t )
{
/*
* Grab all the strings that are required by the encryption API
*/
char buf[ 256 ];
#ifdef LICENSE_MANAGEMENT
LTerms lt;
char *a_val;
for ( const AttributeRec *arec = t.GetFirstAttr();
arec;
arec = t.GetNextAttr( arec ) ) {
a_val = ( char * )arec->getAttrValueString();
#ifdef FISH_DEBUG
DBUG_PRINT("BookTasks", ("access attribute value %s", a_val) );
#endif
switch ( arec->getAttrName() ) {
case A_FEATURE :
if ( lt.add_feature( a_val ) != 0 ) {
throw(Unexpected("invalid access feature syntax"));
}
break;
case A_VEN_CODE :
if ( lt.add_ven_code( a_val ) != 0 ) {
throw(Unexpected("invalid access ven_code syntax") );
}
break;
case A_VERSION :
if ( lt.add_version( a_val ) != 0 ) {
throw(Unexpected("invalid access version syntax"));
}
break;
case A_GROUPING :
if ( lt.add_grouping( a_val ) != 0 ) {
throw(Unexpected("invalid access grouping syntax"));
}
break;
case A_DEMO_TERMS :
if ( lt.add_demo_terms( a_val ) != 0 ) {
throw(Unexpected("invalid access demo_terms syntax"));
}
break;
case A_DEFAULT_SECTION :
if ( lt.add_noaccess_locator( a_val ) != 0 ) {
throw(Unexpected("invalid default section ID syntax"));
}
break;
}
}
if ( lt.pack( buf, 256 ) ) {
throw(Unexpected("Unable to pack the string for encryption"));
}
int len = 256;
if ( e_terms( &lt, buf, len ) ) {
throw(Unexpected("Unable to encrypt string for access control"));
}
#else
int len = 256;
(void) memset(buf, '\0', len);
#endif
e_string = (char *)malloc(len);
(void)memcpy(e_string, buf, len); // Cannot use strdup - embedded NULs
e_len = len;
}
//----------------------------------------------------------------------
void BookTask::markup(const Token &t)
{
ComplexTask::markup(t);
if(t.type() == START){
if(t.olaf() == OLAF::Book){
if(f_base > 0){
throw(Unexpected("illegal nested BOOK architectural form"));
}
f_base = t.level();
}
if(f_base >= 0){
switch(t.olaf()){
case OLAF::BkSTitle:
if(shortTitle){
throw(Unexpected("BkSTitle already found"));
}
shortTitle = new OL_Data(t, OLAF::OL_data);
addSubTask(shortTitle);
break;
case OLAF::BkTitle:
if(title){
throw(Unexpected("BkTitle already found"));
}
title = new OL_Data(t, OLAF::OL_data);
addSubTask(title);
break;
case OLAF::Tab:
if(tabName){
tabNames->append(tabName->content());
tabLocators->append(tabLocator->content());
tabLines->append( form("%d", tabLocator->line_no()) );
tabFiles->append( tabLocator->filename() );
KILLSUBTASK(tabName);
KILLSUBTASK(tabLocator);
}
tabName = new OL_Data(t, OLAF::OL_data);
tabLocator = new OL_Data(t, OLAF::OL_idref, REMOVE_SPACES);
addSubTask(tabName);
addSubTask(tabLocator);
break;
case OLAF::BookAccess:
encrypt( t );
break;
}
if ( t.LookupAttr( OLAF::OL_ToC ) ) {
if ( f_toc ) {
throw(Unexpected("An illegal TOC was found.\n"));
}
f_toc = new TOCTask(t, this);
addSubTask(f_toc);
}
if(f_base >= 0 && !f_style && t.LookupAttr(OLAF::OL_style)){
OL_Data *tmp_style = new OL_Data(t, OLAF::OL_style);
if ( tmp_style->DataWillBeAvailable() ) {
f_style = tmp_style;
addSubTask(f_style);
}
else {
delete tmp_style;
}
}
}
}
else if(t.type() == END){
if(t.level() == f_base){ /* found end of book... write out CCF data */
if ( !Dispatch::RunTocGenOnly() ) {
write_record();
}
reset();
}
}
}
//----------------------------------------------------------------------
void BookTask::write_record(void)
{
StringList tablines;
/* finish any pending tab */
if(tabName){
tabNames->append(tabName->content());
tabLocators->append(tabLocator->content());
tabLines->append( form("%d", tabLocator->line_no()) );
tabFiles->append(tabLocator->filename());
}
for(int i = 0; i < tabNames->qty(); i++){
const char *name = tabNames->item(i);
const char *loc = tabLocators->item(i);
const char *line = tabLines->item(i);
const char *file = tabFiles->item(i);
char *p = new char [strlen(name) + 1 + strlen(loc) + 1
+ strlen(line) + 1 + strlen(file) + 1];
sprintf(p, "%s\t%s\t%s\t%s", name, loc, line, file);
tablines.append(p);
delete p;
}
const char *bk_title;
if(title){
bk_title = title->content();
}else{
throw(Unexpected("Required Title form missing from Book"));
}
const char *bk_stitle = bk_title;
if ( shortTitle ) {
bk_stitle = shortTitle->content();
}
DBTable *tbl = bookcase()->table(BookCaseDB::BookMeta);
tbl->insert(STRING_CODE, locator(),
STRING_CODE, bk_stitle,
STRING_CODE, bk_title,
INTEGER_CODE, f_seq_no,
SHORT_LIST_CODE, tablines.qty(), STRING_CODE, tablines.array(),
-STRING_CODE, e_string , e_len,
NULL);
#ifdef FISH_DEBUG
DBUG_PRINT("Book", ("Book... title: `%s' short title: `%s'\n",
bk_title,
bk_stitle));
#endif
}
void BookTask::reset()
{
KILLSUBTASK(shortTitle);
KILLSUBTASK(title);
KILLSUBTASK(f_toc);
KILLSUBTASK(f_style);
delete tabNames; tabNames = new StringList();
delete tabLocators; tabLocators = new StringList();
tabName = tabLocator = NULL;
delete tabLines; tabLines = new StringList();
delete tabFiles; tabFiles = new StringList();
delete tocLocator; tocLocator = NULL;
f_seq_no ++;
f_base = 0;
}
const char *BookTask::locator()
{
if ( Dispatch::RunTocGenOnly() ) {
return ("");
}
if(!tocLocator){
/* this is the first time anybody asked for the book's locator...
* it must be the TOC node asking for the book locator, which
* is the TOC node locator!
*/
const char *l = f_node->locator();
tocLocator = new char[strlen(l) + 1];
strcpy(tocLocator, l);
}
return tocLocator;
}
const char *
BookTask::styleName()
{
if ( Dispatch::RunTocGenOnly() ) {
return("");
}
const char *ret;
if(f_style){
ret = f_style->content();
if(f_bookcase->styleTask()->exist(ret)){
#ifdef FISH_DEBUG
DBUG_PRINT("Style", ("book style is: %s", ret));
#endif
}else{
Token::signalError(Token::User, Token::Continuable, NULL, 0,
"no such style `%s'\n", ret);
ret = f_bookcase->styleName();
}
}else{
ret = f_bookcase->styleName();
}
return ret;
}
//--------------------------------------------------------------
const char *
BookTask::book_title()
{
if ( !title ) {
throw(Unexpected("Book title is not available yet"));
}
return( title->content() );
}
//--------------------------------------------------------------
const char *
BookTask::book_short_title()
{
if ( !shortTitle ) {
return( book_title() );
}
return( shortTitle->content() );
}

View File

@@ -0,0 +1,113 @@
/* $XConsortium: BookTasks.h /main/3 1996/07/18 15:15:19 drk $ */
#ifndef __BookTasks_h
#define __BookTasks_h
#include "Task.h"
class BookTask;
class NodeTask;
class StyleTask;
class OL_Data;
class DBTable;
class DB;
class SearchStorage;
class BookCaseDB;
class BookCaseTask : public ComplexTask{
public:
BookCaseTask(const char* infolib);
void markup(const Token&);
BookCaseDB *database(); /* throw(Unexpected) */
DBTable *table(int); /* throw(Unexpected) */
const char *bookcasename(); /* throw(Unexpected) */
void write_full_text_record( const char *str,
int sz,
const char *nodelocator,
const char *node_title
);
const char *styleName(); /* throw(Unexpected) */
StyleTask *styleTask() { return style; };
private:
char *library;
int f_base;
BookCaseDB *f_db;
StyleTask *style;
BookTask *book;
SearchStorage *f_search_storage;
OL_Data *bookCaseName;
OL_Data *bookCaseDesc;
OL_Data *f_style;
};
class BookTask : public ComplexTask{
public:
BookTask(BookCaseTask *);
~BookTask();
void reset(void);
void markup(const Token&);
BookCaseTask *bookcase() { return f_bookcase; };
int sequencenum() const { return f_seq_no; }
const char *locator(); /* Locator for this book, i.e.
* for the TOC node for this book
*/
const char *styleName(); /* throw(Unexpected) */
const char *book_short_title(); /* throw(Unexpected) */
const char *book_title(); /* throw(Unexpected) */
protected:
void write_record(void);
private:
int f_base; /* tag nesting level of <BOOK> elt */
int f_seq_no; /* fulltext index document sequence number */
BookCaseTask *f_bookcase; /* 'parent' bookcase object */
OL_Data *shortTitle; /* short title collection task */
OL_Data *title; /* title collection task */
char *tocLocator; /* locator of TOC node */
OL_Data *tabName;
OL_Data *tabLocator;
class StringList *tabNames;
class StringList *tabLocators;
class StringList *tabLines;
class StringList *tabFiles;
NodeTask *f_node;
Task *f_toc;
OL_Data *f_style;
void encrypt( const Token & );
char *e_string; /*
* The encrypted string that is associated
* with the access permission for this book
*/
int e_len;
};
#endif /* __BookTasks_h */

View File

@@ -0,0 +1,63 @@
/* $XConsortium: ConcatTask.C /main/3 1996/08/21 15:46:12 drk $ */
/* exported interfaces */
#include "ConcatTask.h"
/* imported interfaces */
#include "Expression.h"
#include "ExprList.h"
#include "Token.h"
#include "AttributeData.h"
#include "Content.h"
#include "FirstOf.h"
#include "GenericId.h"
#include "Literal.h"
Concat::Concat( const Token &t,
ExprList *elist,
ActionType mode):OL_Data(t, mode)
{
for ( OL_Expression *eptr = elist->first();
eptr;
eptr = elist->next(eptr) ) {
switch ( eptr->type() ) {
case REFERENCE:
addSubTask( new AttributeData( t, eptr->name(), mode ));
break;
case CONTENT:
addSubTask( new Content(t,mode) );
break;
case CONCAT:
addSubTask( new Concat( t,
(ExprList *)eptr->data_list(),
mode) );
break;
case FIRSTOF:
addSubTask( new FirstOf( t,
(ExprList *)eptr->data_list(),
mode) );
break;
case GENERIC_ID:
addSubTask( new GenericId( t,
eptr->name(),
mode) );
break;
case LITERAL:
addSubTask( new Literal( t,
( const char *)eptr->data_list(),
mode) );
break;
default:
abort();
}
}
}

View File

@@ -0,0 +1,23 @@
/* $XConsortium: ConcatTask.h /main/2 1996/07/18 16:40:43 drk $ */
#ifndef __Concat_h__
#define __Concat_h__
#include "Task.h"
#include "OL-Data.h"
class ExprList;
class Token;
class Concat : public OL_Data {
friend class FirstOf;
friend class OL_Data;
protected:
Concat( const Token &t, ExprList *elist, ActionType mode );
void markup( const Token &t ) { OL_Data::markup(t); }
void data( const char *str, size_t sz ) { OL_Data::data(str, sz); }
};
#endif

View File

@@ -0,0 +1,55 @@
/* $XConsortium: Content.cc /main/2 1996/07/18 16:10:34 drk $ */
/* exported interfaces */
#include "Content.h"
/* imported interfaces */
#include "Dispatch.h"
#include "OL-Data.h"
#include "Token.h"
#include "SGMLName.h"
void
Content::markup( const Token &t )
{
if ( ignore_status && !Dispatch::OutsideIgnoreScope() ) {
return;
}
if ( f_base > 0 ) {
if ( t.type() == END ) {
if ( f_base == t.level() ) {
f_base = -1;
data_complete=1;
}
}
else if ( t.type() == EXTERNAL_ENTITY ) {
data_avail = 1;
ValueBuffer.writeStr( t.getEntityFileName() );
}
else if ( t.type() == INTERNAL_ENTITY ) {
data_avail = 1;
ValueBuffer.put( '&' );
ValueBuffer.writeStr( SGMLName::lookup( t.getEntityName() ) );
ValueBuffer.put( ';' );
}
}
}
void
Content::data( const char *str, size_t sz )
{
if ( ignore_status && !Dispatch::OutsideIgnoreScope() ) {
return;
}
if ( f_base > 0 ) {
ValueBuffer.write ( str, sz );
}
}

View File

@@ -0,0 +1,24 @@
/* $XConsortium: Content.h /main/2 1996/07/18 16:41:08 drk $ */
#ifndef __Cont_h__
#define __Cont_h__
#include "BaseDataCollect.h"
class Token;
class Content : public BaseData {
friend class FirstOf;
friend class OL_Data;
friend class Concat;
protected:
Content( const Token &t , ActionType mode);
void markup( const Token &t );
void data( const char *str, size_t sz );
};
inline
Content::Content( const Token &t, ActionType mode ):BaseData(t, mode) {}
#endif

View File

@@ -0,0 +1,34 @@
/* $XConsortium: ContentRec.h /main/2 1996/07/18 16:41:34 drk $ */
#ifndef __CRec_hdr__
#define __CRec_hdr__
#include "VarElementList.h"
class ContentRec {
friend class OL_Data;
friend int ol_dataparse();
friend class ContentType;
private:
int data_type;
int attr_name;
VarElementList var_list;
ContentRec *next;
public:
void Init ( int dtype, int aname=0, VarElement *vList=0 );
ContentRec() { attr_name = -1; data_type=-1, next = 0; }
};
/*--------------------------------------------------------*/
inline
void
ContentRec::Init( int dtype, int aname, VarElement *vlist )
{
data_type = dtype;
attr_name = aname;
var_list.insert ( vlist );
}
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,28 @@
/* $XConsortium: ContentType.h /main/3 1996/08/21 15:46:16 drk $ */
#ifndef __Content_Type_h__
#define __Content_Type_h__
#include <assert.h>
class OL_Expression;
class ContentType {
friend class OL_Data;
private:
OL_Expression *exprlist;
protected:
void Parse( char *str );
ContentType();
~ContentType();
public:
void init ( OL_Expression *elist ); // Construct a ExprList object
};
#endif

View File

@@ -0,0 +1,208 @@
%{
/* $XConsortium: ContentType.l /main/2 1996/11/19 16:54:22 drk $ */
#include <iostream.h>
#include <stream.h>
#include <stdio.h>
#include <memory.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include "Exceptions.hh"
#include "Task.h"
#include "SGMLName.h"
#include "ExprList.h"
#include "Expression.h"
#include "OL_DataExpr.tab.h"
#include "ContentType.h"
/* CurrentContentPtr is used as the communication media between
* yyparse and ContentType::Parse()
*/
ContentType *CurrentContentPtr;
/*
* Forward declaration for my_input
*/
static int my_input ( char *, int );
extern int yyparse();
#undef YY_INPUT
#define YY_INPUT(b, r, ms ) ( r=my_input( ( char *)b,ms) )
static char *myinput;
static char *myinputptr;
static char *myinputlim;
// Debugging macro
#ifdef DEBUG
#define DBG(level) if ( dbgLevel >= level)
#else
#define DBG(level) if (0)
#endif
static int dbgLevel = -1;
%}
%%
"@"[a-zA-Z0-9]+ {
yylval.name = SGMLName::intern((const char *)yytext+1 ,1);
return( Reference );
}
["][^"]*["] {
if ( *(yytext + 1) != '"' ) {
// get rid of the 2 quotes
int len = strlen(( const char *)yytext)-2;
char *lit_str = new char [ len + 1 ];
strncpy ( lit_str,
(const char *)yytext + 1,
len );
*(lit_str + len) = '\0';
yylval.string = lit_str;
}
else {
yylval.string = 0;
}
DBG(50) cerr << "(DEBUG) literal \"string\" = "
<< yylval.string << endl;
return( Literal );
}
['][^']*['] {
if ( *(yytext + 1) != '\'' ) {
// get rid of the 2 quotes
int len = strlen(( const char *)yytext)-2;
char *lit_str = new char [ len + 1 ];
strncpy ( lit_str,
(const char *)yytext + 1,
len );
*(lit_str + len) = '\0';
yylval.string = lit_str;
}
else {
yylval.string = 0;
}
DBG(50) cerr << "(DEBUG) literal 'string' = "
<< yylval.string << endl;
return( Literal );
}
[Aa][Tt][Tt][Rr] { return( Attr ); }
[Cc][Oo][Nn][Cc][Aa][Tt] { return( Concat ); }
[Ff][Ii][Rr][Ss][Tt][Oo][Ff] { return( FirstOf); }
"#"[Cc][Oo][Nn][Tt][Ee][Nn][Tt] { return( Content ); }
[^(,)\n\t ]+ {
yylval.name = SGMLName::intern((const char *)yytext,1);
DBG(10) cerr << "(DEBUG) matches"
<< (char *)SGMLName::lookup(yylval.name)
<< endl;
return ( Id );
}
[(,)] {
DBG(10) cerr << "(DEBUG) matches"
<< (char *)yytext
<< endl;
return ( yytext[0] );
}
[\n\t ]+ ;
. {
throw(Unexpected(
"Syntax error in value expression"));
}
%%
static int
my_input ( char *buf, int max_size )
{
int remain = myinputlim - myinputptr;
int n = ( max_size > remain ? remain : max_size );
if ( n > 0 ) {
memcpy ( buf, myinputptr, n );
myinputptr += n;
}
return n;
}
//--------------------------------------------------------------
void
ol_dataerror(char *str)
{
throw(Unexpected(form("Syntax error in %s", myinput)));
}
//--------------------------------------------------------------
ContentType::ContentType()
{
char *dbgStr;
dbgStr = getenv ("OL_DEBUG");
dbgLevel = ( dbgStr ? atoi ( dbgStr ) : 0 );
exprlist = 0;
}
//--------------------------------------------------------------
ContentType::~ContentType()
{
Expression *eptr = exprlist;
while ( eptr ) {
Expression *tmp = eptr;
eptr = eptr->next;
delete tmp;
}
}
//--------------------------------------------------------------
void
ContentType::Parse( char *str )
{
DBG(10) cerr << "(DEBUG) ContentType::Parse() str = " << str << endl;
myinput = str;
myinputptr = str;
myinputlim = str + strlen(str);
CurrentContentPtr = this;
yyparse();
BEGIN INITIAL;
yyrestart(NULL);
}
//--------------------------------------------------------------
void
ContentType::init( Expression *expr )
{
assert(expr);
if ( expr->next ) {
/*
* The same as CONCAT
*/
ExprList *elist = new ExprList( expr );
Expression *new_expr = new Expression ( CONCAT, -1, elist );
assert(new_expr);
exprlist = new_expr;
}
else {
exprlist = expr;
}
}

View File

@@ -0,0 +1,635 @@
/* $TOG: DataBase.C /main/5 1998/04/17 11:43:17 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.
*/
/* imported interfaces... */
#include <string.h>
#include <stdarg.h>
#include <assert.h>
#include <unistd.h>
#include <errno.h>
#include <sys/stat.h>
#include <sys/types.h>
#include "StringList.h"
#include "Token.h"
/* exported interfaces... */
#include "DataBase.h"
#define FRIENDLY_ASSERT(e) \
if(!(e)) Token::signalError(Token::Internal, Token::Fatal, \
__FILE__, __LINE__, \
"assertion failed: " #e);
DB::DB(const char *name)
{
f_name = new char[strlen(name)+1];
strcpy(f_name, name);
}
static int isdir(const char* filename)
{
int ret = 0;
struct stat sb;
if(stat(filename, &sb) == 0){
if(S_ISDIR(sb.st_mode)){
ret = 1;
}
}
return ret;
}
static void makedir(const char *path) /* throw(PosixError) */
{
if(mkdir((char*)path, DATABASE_DIRECTORY_MODE) != 0){
throw(PosixError(errno, path));
}
}
DBTable *DB::table(const char *tname, int scode, int cols,
int access)
/* throw(PosixError); */
{
DBTable *ret = 0; /* keep compiler happy */
switch(access){
case CREATE:
if(!isdir(f_name)){
makedir(f_name);
}
ret = new DBTable(this, scode, cols, tname);
break;
case READ:
ret = new DBTable(this, scode, cols, tname);
ret->file(DB::READ);
break;
default:
abort();
}
return ret;
}
DBTable::DBTable(DB *database, int schema_code, int cols, const char *name)
{
f_database = database;
f_schema_code = schema_code;
f_cols = cols;
f_name = new char[strlen(name)+1];
strcpy(f_name, name);
f_file = NULL;
f_start = 0;
}
DBTable::~DBTable()
{
if(f_file && strcmp(f_name, DATABASE_STDIO) != 0) fclose(f_file);
delete f_name;
}
FILE *
DBTable::file(DB::Access access)
{
if(!f_file){
if(strcmp(f_name, DATABASE_STDIO) == 0){
f_file = access == DB::CREATE ? stdout : stdin;
}else{
const char *p = f_database->path();
char *path = new char[strlen(p) + 1 + strlen(f_name) + 1];
sprintf(path, "%s/%s", p, f_name);
f_file = fopen(path, access == DB::CREATE ? "w" : "r");
if(!f_file){
throw(PosixError(errno, path));
}
delete path;
}
}
return f_file;
}
//----------------------------------------------------------
void DBTable::insert(int typecode, ...)
{
FILE *out = file(DB::CREATE);
va_list ap;
va_start(ap, typecode);
fprintf(out, "%d\n%d\n", f_schema_code, f_cols);
int cols_found = 0;
while(typecode != 0){
switch(typecode){
case STRING_CODE:
{
const char *str = va_arg(ap, const char*);
fprintf(out, "%d\n%ld\t%s\n", STRING_CODE, (long)strlen(str), str);
}
break;
case -STRING_CODE:
{
const char *str = va_arg(ap, const char*);
size_t len = va_arg(ap, size_t);
fprintf(out, "%d\n%ld\t", STRING_CODE, (long)len );
fwrite ( str, len, 1, out );
fputc( '\n', out);
}
break;
case COMPRESSED_STRING_CODE:
{
const char *comp_agent = va_arg(ap, const char* );
const char *str = va_arg(ap, const char* );
fprintf(out, "%d\n%s\n%ld\t%s\n", COMPRESSED_STRING_CODE,comp_agent,
(long)strlen(str), str );
}
break;
case -COMPRESSED_STRING_CODE:
{
const char *comp_agent = va_arg(ap, const char* );
const char *str = va_arg(ap, const char* );
size_t len = va_arg(ap, size_t );
fprintf(out, "%d\n%s\n%ld\t", COMPRESSED_STRING_CODE,
comp_agent,
(long)len
);
fwrite( str, len, 1, out );
fputc('\n', out);
}
break;
case OID_CODE:
{
const char *oid = va_arg(ap, const char*);
fprintf(out, "%d\n%s\n", OID_CODE, oid);
}
break;
case INTEGER_CODE:
{
int x = va_arg(ap, int);
fprintf(out, "%d\n%d\n", INTEGER_CODE, x);
}
break;
case SHORT_LIST_CODE:
{
int qty = va_arg(ap, int);
int code = va_arg(ap, int);
fprintf(out, "%d\n#\n", SHORT_LIST_CODE);
switch(code){
case INTEGER_CODE:
{
int *items = va_arg(ap, int*);
for(int i = 0; i < qty; i++){
fprintf(out, "%d\n%d\n", code, items[i]);
}
}
break;
case STRING_CODE:
{
const char **items = va_arg(ap, const char**);
for(int i = 0; i < qty; i++){
fprintf(out, "%d\n%ld\t%s\n",
code, (long)strlen(items[i]), items[i]);
}
}
break;
case OID_CODE:
{
const char **items = va_arg(ap, const char**);
for(int i = 0; i < qty; i++){
fprintf(out, "%d\n%s\n",
code, items[i]);
}
}
break;
default:
fprintf(stderr, "Internal error: unknown database type code: %d\n",
code);
abort();
}
fprintf(out, "#\n");
break;
}
case OID_LIST_CODE:
{
int qty = va_arg(ap, int);
fprintf(out, "%d\n#\n", OID_LIST_CODE);
const char **items = va_arg(ap, const char**);
for(int i = 0; i < qty; i++){
fprintf(out, "%s\n", items[i]);
}
fprintf(out, "#\n");
break;
}
default:
fprintf(stderr, "Internal error: unknown database type code: %d\n",
typecode);
abort();
}
cols_found++;
typecode = va_arg(ap, int);
}
va_end(ap);
fflush(out); /* @# some routines are sloppy and don't
* close their tables!
*/
assert(cols_found == f_cols);
}
//----------------------------------------------------------
void DBTable::insert_untagged(int typecode, ...)
{
FILE *out = file(DB::CREATE);
va_list ap;
va_start(ap, typecode);
fprintf(out, "%d\n", f_schema_code);
if(f_start){
fprintf(out, "+");
f_start = 0;
}
int cols_found = 0;
while(typecode != 0){
switch(typecode){
case STRING_CODE:
{
const char *str = va_arg(ap, const char*);
fprintf(out, "%ld\t%s\n", (long)strlen(str), str);
}
break;
case -STRING_CODE:
{
const char *str = va_arg(ap, const char*);
size_t len = va_arg(ap, size_t);
fprintf(out, "%ld\t", (long)len );
fwrite ( str, len, 1, out );
fputc( '\n', out);
}
break;
case OID_CODE:
{
const char *oid = va_arg(ap, const char*);
fprintf(out, "%s\n", oid);
}
break;
case INTEGER_CODE:
{
int x = va_arg(ap, int);
fprintf(out, "%d\n", x);
}
break;
default:
fprintf(stderr, "Internal error: unknown database type code: %d\n",
typecode);
abort();
}
cols_found++;
typecode = va_arg(ap, int);
}
va_end(ap);
fflush(out); /* @# some routines are sloppy and don't
* close their tables!
*/
assert(cols_found == f_cols);
}
//----------------------------------------------------------
void DBTable::start_list()
{
this->f_start = 1;
}
//----------------------------------------------------------
void DBTable::end_list()
{
fprintf(file(DB::CREATE), "-\n");
f_start = 0;
}
//----------------------------------------------------------
DBCursor::DBCursor(DBTable &t)
{
f_table = &t;
f_start = -1;
f_fields = new StringList();
f_list = NULL;
}
//----------------------------------------------------------
DBCursor::~DBCursor()
{
// this is for the last record
delete f_fields;
if ( f_list ) delete f_list;
}
//----------------------------------------------------------
void DBCursor::string_field(FILE *fp, char **out, int *lenOut)
{
int len = 0;
int io;
/* fscanf is wierd, so we do it ourselves... */
while(isdigit(io = fgetc(fp))){
len = len * 10 + (io - '0');
}
FRIENDLY_ASSERT(io == '\t');
char *str = new char[len + 1];
io = fread(str, sizeof(str[0]), len+1, fp); /* read \n also */
FRIENDLY_ASSERT(io == len+1);
str[len] = 0; /* replace \n with 0 (just in case...) */
if(out){
f_fields->add(str);
*out = str;
if(lenOut) *lenOut = len;
}else{
delete str;
}
}
void DBCursor::int_field(FILE *fp, int *out)
{
int an_int;
int io;
io = fscanf(fp, "%d\n", &an_int);
FRIENDLY_ASSERT(io == 1);
if(out) *out = an_int;
}
void DBCursor::short_list(FILE *fp, int *qout, int ltype, void *out)
{
int c;
c = fgetc(fp);
FRIENDLY_ASSERT(c == '#');
c = fgetc(fp);
FRIENDLY_ASSERT(c == '\n');
switch(ltype){
case STRING_CODE:
{
typedef const char** ccpp;
ccpp *cpout = (ccpp*)out;
assert(f_list == NULL); /* only one SHORT_LIST per record supported */
f_list = new StringList;
while((c = fgetc(fp)) != '#'){
char *item;
int ftype;
ungetc(c, fp);
fscanf(fp, "%d\n", &ftype);
FRIENDLY_ASSERT(ftype == STRING_CODE);
string_field(fp, &item, NULL);
f_list->append(item);
}
*cpout = f_list->array();
*qout = f_list->qty();
}
break;
default:
abort(); /* only strings supported */
}
c = fgetc(fp);
FRIENDLY_ASSERT(c == '\n');
}
int DBCursor::next(int typeCode, ...)
{
int ret = 1;
FILE *fp = f_table->file(DB::READ);
int io;
int recordClass;
if(f_start < 0){ /* on first call to next(), reset the file */
rewind(fp);
}
f_start = ftell(fp);
io = fscanf(fp, "%d\n", &recordClass); /* get record code */
if(io != EOF){ /* got any data? */
FRIENDLY_ASSERT(io == 1);
// clean up previous fields first if they exist
f_fields->reset();
delete f_list; f_list = NULL;
va_list ap;
va_start(ap, typeCode);
int fieldQty;
io = fscanf(fp, "%d\n", &fieldQty); /* get field count */
FRIENDLY_ASSERT(io == 1);
/* iterate over fields in the input stream... */
while(fieldQty--){
int fieldCode;
io = fscanf(fp, "%d\n", &fieldCode); /* get field type */
FRIENDLY_ASSERT(io == 1);
assert(typeCode); /* make sure caller didn't give too few args */
switch(fieldCode){
case STRING_CODE:
{
char **data = NULL;
int *len = NULL;
if (fieldCode == typeCode || (fieldCode + typeCode) == 0) {
data = va_arg(ap, char**);
if (fieldCode != typeCode) {
len = va_arg(ap, int*);
}
}
string_field(fp, data, len);
}
break;
case INTEGER_CODE:
int_field(fp, fieldCode == typeCode ? va_arg(ap, int*) : 0);
break;
case SHORT_LIST_CODE:
{
int *qout = va_arg(ap, int *);
int ltype = va_arg(ap, int);
void *out = va_arg(ap, void*);
short_list(fp, qout, ltype, out);
}
break;
default:
abort();
}
typeCode = va_arg(ap, int);
}
assert(typeCode == 0); /* check for end marker */
va_end(ap);
}else{
ret = 0; /* EOF found... no record */
}
return ret;
}
void DBCursor::undoNext()
{
FILE *fp = f_table->file(DB::READ);
if(f_start >= 0){
if(fseek(fp, f_start, 0) < 0){
throw(PosixError(errno, f_table->name()));
}
}else{
abort(); /* @# throw("no next to undo!") */
}
}
//----------------------------------------------------------------
void DBCursor::local_rewind()
{
f_start = -1;
}
//----------------------------------------------------------------
int DBCursor::tell()
{
if ( f_start == -1 ) {
return(0);
}
else {
return f_start;
}
}
//----------------------------------------------------------------
void DBCursor::seekToRec( int pos )
{
FILE *fp = f_table->file(DB::READ);
if ( pos >= 0 ){
if (fseek(fp, pos, 0) < 0 ) {
throw(PosixError(errno, f_table->name()));
}
}
else{
abort();
}
}

View File

@@ -0,0 +1,162 @@
/* $XConsortium: DataBase.h /main/6 1996/10/26 18:17:26 cde-hal $ -*- c++ -*- */
#ifndef __DataBase_h
#define __DataBase_h
#include "Exceptions.hh"
#include "object/c_codes.h" /* mmdb codes */
#include "oliasdb/olias_consts.h"
#include <errno.h>
#include <stdio.h>
#include <string.h>
class PosixError : public Exception{
public:
enum { MAXMSG = 200 };
PosixError(int error_no, const char *msg)
{ f_errno = error_no; strncpy(f_msg, msg, MAXMSG+1); };
const char *msg(void) const { return f_msg; };
int error_no(void) const { return f_errno; };
DECLARE_EXCEPTION(PosixError, Exception);
private:
char f_msg[MAXMSG+1];
int f_errno;
};
#define DATABASE_DIRECTORY_MODE 0775
#define DATABASE_STDIO "-"
class DBTable;
class DB{
public:
/*
* USE: const char *dir = "/some/dir/for/all/the/tables";
* DB *db = DB(dir);
* assert(strcmp(db->path(), dir) == 0);
*/
DB(const char *name); /* a directory, for now */
~DB() { if ( f_name ) delete f_name; }
const char *path(void) { return f_name; };
typedef enum { READ, CREATE
#if DB_UPDATE
, UPDATE
#endif
} Access;
/*
* USE: DBTable *t = db->table("NodeMeta", NODE_CODE, 4, CREATE);
* where NODE_CODE is an MMDB object code, and 4
* is the number of "columns" in the table, i.e. the
* number of items you're going to pass to each call to
* insert()
*
* CREATE creates a file named "NodeMeta" in db's directory.
* READ opens a file named "NodeMeta" in db's directory.
*/
DBTable *table(const char *name,
int schema_code, int cols,
int a = READ); /* throw PosixError */
private:
char *f_name;
};
#define BT_NUM_DOC_FIELDS 6
#define BT_NUM_LOCATOR_FIELDS 3
#define BT_NUM_GRAPHIC_FIELDS 6
#define BT_NUM_STYLESHEET_FIELDS 3
#define BT_NUM_OLIAS_NODE_FIELDS 7
class DBTable{
friend class DB;
friend class DBCursor;
public:
~DBTable();
/*
* USE: int intlist = 4;
* table->insert(INTEGER_CODE, 4,
* STRING_CODE, "xyz",
* -STRING_CODE, "abcd", 4,
* SHORT_LIST_CODE, 1, INTEGER_CODE, &intlist,
* NULL);
*/
void insert(int typecode, ...);
void insert_untagged(int typecode, ...);
const char *name() { return f_name; };
void start_list();
void end_list();
protected:
DBTable(DB* database, int schema_code, int cols, const char *name);
FILE *file(DB::Access);
private:
FILE *f_file;
DB *f_database;
int f_schema_code;
int f_cols;
char *f_name;
int f_start; /* at start of linked list */
};
class DBCursor{
public:
DBCursor(DBTable &t);
~DBCursor();
/*
* USE: DBTable t(...);
* DBCurcor c(t);
* const char *f1;
* int f2
*
* while(c.next(STRING_CODE, &f1,
* INTEGER_CODE, &f2,
* NULL)){
* ...use f1, f2...
* }
*/
int next(int code, ...);
void undoNext(); /* seek back to the beginning of the last record read
* throw(PosixError) on unseekable device
*/
void local_rewind(); /* restart at the beginning of the table file */
int tell(); /* current position of the file */
void seekToRec( int pos ); /* seek directly to pos */
protected:
void string_field(FILE *, char **, int *);
void int_field(FILE *, int *);
void short_list(FILE *, int *, int, void*);
private:
DBTable *f_table;
class StringList *f_fields;
class StringList *f_list;
long f_start;
};
#endif /* __DataBase_h */

View File

@@ -0,0 +1,105 @@
/* $XConsortium: DataRepository.C /main/3 1996/08/21 15:46:21 drk $ */
#include "dti_cc/CC_Stack.h"
#include "dti_cc/CC_Slist.h"
/* Imported Interfaces */
#include "Task.h"
#include "FlexBuffer.h"
#include "DataRepository.h"
//-------------Initializer for the zone_name mapping ----------------
static char *zone_name[] = {
"D",
"H",
"G",
"E",
"I",
"T"
};
//------------------------------------------------------------------
DataRepository::DataRepository()
{
for ( int i = 0; i < Total; i++ ) {
table[i] = NULL;
}
zone_stack = new Stack<Rec>;
current_buf = NULL;
}
//------------------------------------------------------------------
DataRepository::~DataRepository()
{
delete zone_stack;
// destroy the table
for ( int i = 0; i < Total; i++ ) {
delete table[i];
}
}
//------------------------------------------------------------------
void
DataRepository::ActivateZone( int zt, int level )
{
if ( !table[zt] ) {
table[zt] = new FlexBuffer;
}
// prepare a buffer to be written
Rec rec( level, table[zt] );
zone_stack->push ( rec );
current_buf = table[zt];
}
//------------------------------------------------------------------
void
DataRepository::deActivateZone( int level )
{
if ( zone_stack->empty() ) {
return;
}
if ( zone_stack->top().level != level ) {
return;
}
Rec ZoneRec = zone_stack->pop();
// update the current_buf
if ( !zone_stack->empty() ) {
current_buf = zone_stack->top().Buf;
}
}
//------------------------------------------------------------------
void
DataRepository::put(char ch)
{
if ( current_buf ) {
current_buf->put( ch );
}
}
//------------------------------------------------------------------
void
DataRepository::write( const char *str, size_t n )
{
current_buf->write( str, n );
}
//-------------------------------------------------------------------
const char *
DataRepository::get_zone_name( int zt )
{
if ( zt >= Total ) {
return NULL;
}
return ( zone_name[zt] );
}

View File

@@ -0,0 +1,73 @@
/* $XConsortium: DataRepository.h /main/2 1996/07/18 16:42:32 drk $ */
// DataRepository.h -- used to store all the full-text content
#ifndef DataRP_HEADER
#define DataRP_HEADER
#include <stddef.h>
/* Forward declaration */
class FlexBuffer;
template <class T> class Stack;
template <class T> class CC_TPtrSlist;
class Rec {
friend class DataRepository;
private:
int level;
FlexBuffer *Buf;
public:
Rec(int l, FlexBuffer *buf):level(l),Buf(buf){}
Rec():level(-1),Buf(NULL){}
Rec( const Rec &t ) {
if ( this != &t ) {
this->level = t.level;
this->Buf = t.Buf;
}
}
Rec & operator=( Rec &t ) {
if ( this != &t ) {
this->level = t.level;
this->Buf = t.Buf;
}
return *this;
}
};
class DataRepository {
public:
typedef enum
{ Default=0, Head, Graphic, Example, Index, Table, Total} ZoneType;
private:
FlexBuffer *table[Total]; // zone buffer
Stack<Rec> *zone_stack;
FlexBuffer *current_buf;
public:
DataRepository();
~DataRepository();
void ActivateZone( int zone_type, int level ); // throw Exception
void deActivateZone( int level ); // throw Exception
void put( char );
void write ( const char *, size_t );
FlexBuffer **tabbuf() { return ( table ); }
const char *get_zone_name( int zone_type );
};
#endif

View File

@@ -0,0 +1,45 @@
/* $XConsortium: DataTask.C /main/3 1996/08/21 15:46:25 drk $ */
/* exported interfaces... */
#include "DataTask.h"
/* imported interfaces... */
#include "Token.h"
DataTask::DataTask(const Token&) : buf()
{
level = 1;
}
void DataTask::markup(const Token &t)
{
switch(t.type()){
case START:
/*
* be careful not to start collecting again after the relavent
* element is done!
*/
if(level > 0) level++;
break;
case END:
if(level > 0) level--;
}
}
void DataTask::data(const char *chars, size_t len)
{
if(level > 0){
buf.write(chars, len);
}
}
const char * DataTask::content(size_t *len)
{
if(len) *len = buf.GetSize();
return buf.GetBuffer();
}

View File

@@ -0,0 +1,40 @@
/* $XConsortium: DataTask.h /main/2 1996/07/18 16:42:57 drk $ */
/* $Id: DataTask.h /main/2 1996/07/18 16:42:57 drk $ */
#ifndef __DataTask_h
#define __DataTask_h
#include <stddef.h>
#include "Task.h"
#include "FlexBuffer.h"
class DataTask : public Task{
/*
* A DataTask collects all the data for an element.
*
* USE:
* if(t.type() == START && t.attrMatch(OLAF::OLIAS, OLAF::Title)){
* titleTask = addSubTask(new DataTask());
*
* ... (more markup(), data() calls) ...
*
* const char *title = titleTask.content()
*/
public:
DataTask(const Token& t);
virtual void markup(const Token& t) /* throw(Unexpected) */;
virtual void data(const char *chars,
size_t len) /* throw(ResourcesExhausted) */;
const char *content(size_t *length_return = NULL);
private:
int level; /* how far nested are we? */
FlexBuffer buf;
};
#endif /* __DataTask_h */

View File

@@ -0,0 +1,193 @@
/* $XConsortium: Dispatch.cc /main/2 1996/06/11 16:49:03 cde-hal $
*
* (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.
*/
/* exported interfaces... */
#include "Dispatch.h"
/* imported interfaces... */
#include <assert.h>
#include <string.h>
#include "SGMLName.h"
#include "EntityScope.h"
#include "Token.h"
#include "FlexBuffer.h"
#include "SGMLDefn.h"
#include "SearchPath.h"
#include "OLAF.h"
Task *Dispatch::TaskObject = NULL;
Stack<int> *Dispatch::IgnoreStack = NULL;
int Dispatch::level = 0;
static EntityScope entity_stack;
Token* Dispatch::tok = new Token();
char* Dispatch::f_file = NULL;
int Dispatch::f_line = 0;
const char *Dispatch::tmpdir = NULL;
const char *Dispatch::srcdir = NULL;
SearchPath *Dispatch::search_path_table = NULL;
int Dispatch::tocgen_only = 0;
//---------------------------------------------------------------------
void
Dispatch::token(TOKEN_TYPE tokType, unsigned char *Name )
{
tok->setFileLine(f_file, f_line);
switch(tokType){
case START:
level++;
tok->StoreStartTag( Name, level );
if ( tok->LookupAttr( OLAF::OL_Ignore )
|| tok->LookupAttr( OLAF::OL_ShortTitle ) ) {
IgnoreStack->push ( level );
}
break;
case END:
tok->StoreEndTag ( Name, level );
level--;
break;
case INTERNAL_ENTITY:
tok->StoreEntity( Name , INTERNAL_ENTITY);
break;
case EXTERNAL_ENTITY:
tok->StoreEntity( Name , EXTERNAL_ENTITY);
SGMLDefn *sgml_rec;
sgml_rec = entity_stack.LookupEntity( SGMLName::intern((char*)Name) );
if(sgml_rec){
tok->SetEntityValue( sgml_rec );
}else{
tok->reportError(Token::Internal, Token::Fatal,
"Unable to find entity definition for %.50s", Name);
}
break;
}
TaskObject->markup( *tok );
if ( tokType == END ) {
if ( !IgnoreStack->empty() ) {
int topelement = IgnoreStack->top();
if ( topelement == tok->level() ) {
topelement = IgnoreStack->pop();
}
}
}
delete tok;
tok = new Token();
}
//---------------------------------------------------------------------
void Dispatch::setRoot( Task *t, Stack<int> *istack)
{
assert(TaskObject == NULL);
TaskObject = t;
assert(IgnoreStack == NULL);
IgnoreStack = istack;
}
//---------------------------------------------------------------------
SGMLDefn *
Dispatch::entity_ref( const char *ent_name )
{
int ent_num;
ent_num = SGMLName::intern(ent_name);
SGMLDefn *sgml_rec = entity_stack.LookupEntity( ent_num );
return sgml_rec;
}
//---------------------------------------------------------------------
void
Dispatch::entity_decl( SGMLDefn *defn )
{
EntityList *escope = entity_stack.GetTopEntities();
assert(escope != NULL);
/*
* first clone up an SGMLDefn record for storage purposes
*/
SGMLDefn *sgmlRec = new SGMLDefn();
*sgmlRec = *defn;
escope->insert( sgmlRec );
}
//---------------------------------------------------------------------
void
Dispatch::file(const char *f)
{
delete f_file;
f_file = new char[strlen(f)+1];
strcpy(f_file, f);
/*
* put directory of f_file into the search path also
*/
if(search_path_table){
// perform dirname first
char *dirname = strdup( f_file );
char *p = strrchr( dirname, '/' );
if ( p ) {
*p = '\0';
}
else {
strcpy( dirname,"." );
}
search_path_table->replace_file_scope( dirname );
delete dirname;
}
}
//---------------------------------------------------------------------
void
Dispatch::subdoc_start()
{
EntityList *newrec = new EntityList();
entity_stack.push ( newrec );
}
//---------------------------------------------------------------------
void
Dispatch::subdoc_end()
{
EntityList *rec = entity_stack.pop();
if ( !rec ) {
throw(Unexpected("SUBDOC end tag is not matched"));
}
delete rec;
}

View File

@@ -0,0 +1,76 @@
/* $XConsortium: Dispatch.h /main/3 1996/08/21 15:46:29 drk $ -*- c++ -*- */
/* $XConsortium: Dispatch.h /main/3 1996/08/21 15:46:29 drk $ -*- c++ -*- */
//---------------------------------------------------------------------
// Dispatch Functions
//---------------------------------------------------------------------
#ifndef DISPATCH_HEADER
#define DISPATCH_HEADER
#include "Token.h"
#include "Task.h"
#include "FlexBuffer.h"
#include "dti_cc/CC_Stack.h"
class SGMLDefn;
class SearchPath;
class Dispatch {
friend int yylex();
friend int main(int argc, char **argv);
protected:
static Token *tok;
static const char *tmpdir;
static const char *srcdir;
static SearchPath *search_path_table;
static int tocgen_only;
static void token ( TOKEN_TYPE, unsigned char * );
static void subdoc_start();
static void subdoc_end();
static void data ( FlexBuffer * );
static void setRoot( Task *t, Stack<int> *istack);
static void setTempDir ( const char *tmpdir );
static void setSrcDir ( const char *srcdir );
static void entity_decl( SGMLDefn *);
static void file(const char *);
static void line(int l) { f_line = l; };
static void newline() { f_line++; };
private:
static Task *TaskObject;
static int level;
static Stack<int> *IgnoreStack;
static char *f_file;
static int f_line;
public:
static SGMLDefn *entity_ref ( const char *ename );
static int OutsideIgnoreScope() { return IgnoreStack->empty(); }
static int RunTocGenOnly() { return(tocgen_only); }
#ifdef SC3
static const char *GetTmpDir() { return( tmpdir ); }
static const char *GetSrcDir() { return( srcdir ); }
static SearchPath *GetSearchPath() { return ( search_path_table ); }
#else
static const char *GetTmpDir() { return( tmpdir ); }
static const char *GetSrcDir() { return( srcdir ); }
static SearchPath *GetSearchPath() { return ( search_path_table ); }
#endif
};
inline
void
Dispatch::data( FlexBuffer *buf )
{
TaskObject->data( (const char *)( buf->GetBuffer() ),
buf->GetSize() );
}
#endif

View File

@@ -0,0 +1,64 @@
/* $XConsortium: EntityList.cc /main/2 1996/07/18 16:11:54 drk $ */
/* exported interfaces */
#include "EntityList.h"
/* imported interfaces */
#include <stdio.h>
#include "SGMLName.h"
#include "SGMLDefn.h"
//---------------------------------------------------------
EntityList::EntityList()
{
head = NULL;
tail = NULL;
next = NULL;
}
//---------------------------------------------------------
EntityList::~EntityList()
{
SGMLDefn *pt = head;
while ( pt ) {
SGMLDefn *tmp = pt;
pt = pt->next;
delete tmp;
}
}
//---------------------------------------------------------
// EntityList:lookup
SGMLDefn *
EntityList::lookup(int ename ) const
{
SGMLDefn *pt = head;
while ( pt ) {
if ( pt->getName() == ename ) {
return ( pt );
}
pt = pt->next;
}
return ( NULL );
}
//---------------------------------------------------------
// EntityList::add
void
EntityList::insert( SGMLDefn *entry )
{
if ( !tail ) {
head = tail = entry;
}
else {
tail->next = entry;
tail = entry;
}
}

View File

@@ -0,0 +1,29 @@
/* $XConsortium: EntityList.h /main/2 1996/07/18 16:43:25 drk $ */
#ifndef ENT_LIST_HDR
#define ENT_LIST_HDR
#include "SGMLDefn.h"
class EntityList {
friend class EntityScope;
friend class Dispatch;
protected:
SGMLDefn *head;
SGMLDefn *tail;
EntityList *next;
SGMLDefn *lookup( int ) const;
void insert ( SGMLDefn * );
// SGMLDefn *GetFirstAttr() const;
// SGMLDefn *GetNextAttr( const SGMLDefn *) const;
EntityList();
~EntityList();
};
#endif

View File

@@ -0,0 +1,66 @@
/* $XConsortium: EntityScope.h /main/2 1996/07/18 16:43:47 drk $ */
#ifndef ENT_SCOPE_HDR
#define ENT_SCOPE_HDR
#include "EntityList.h"
class EntityScope {
private:
EntityList *currentEntityScope;
public:
void push ( EntityList *escope ) {
escope->next = currentEntityScope;
currentEntityScope = escope;
}
EntityList *pop();
EntityList *GetTopEntities() const { return(currentEntityScope); }
SGMLDefn *LookupEntity( int ename );
/*
* Constructor EntityScope creates a topmost entitylist
* so the stack will contain an element after it is constructed
*/
EntityScope() { currentEntityScope = new EntityList(); }
~EntityScope();
};
//----------------------------------------------------------------
inline
SGMLDefn *
EntityScope::LookupEntity( int ename )
{
return ( currentEntityScope->lookup( ename ) );
}
//-----------------------------------------------------------------
inline
EntityList *
EntityScope::pop()
{
EntityList *ptr;
ptr = currentEntityScope;
currentEntityScope = ptr->next;
return ( ptr );
}
//-----------------------------------------------------------------
inline
EntityScope::~EntityScope()
{
EntityList *pt = currentEntityScope;
while( pt ) {
EntityList *tmp = pt;
pt = pt->next;
delete tmp;
}
}
#endif

View File

@@ -0,0 +1,44 @@
/* $XConsortium: ExprList.C /main/3 1996/08/21 15:46:33 drk $ */
/* imported interfaces */
/* exported interfaces */
#include "Expression.h"
#include "ExprList.h"
//------------------------------------------------------------------
ExprList::ExprList()
{
head = 0;
}
//------------------------------------------------------------------
ExprList::ExprList( OL_Expression *elist )
{
head = elist;
}
//------------------------------------------------------------------
ExprList::~ExprList()
{
OL_Expression *ptr = head;
while ( ptr ) {
OL_Expression *tmp = ptr;
ptr = ptr->next;
delete tmp;
}
}
//------------------------------------------------------------------
OL_Expression *
ExprList::first()
{
return ( head );
}
//------------------------------------------------------------------
OL_Expression *
ExprList::next( OL_Expression *ptr )
{
if ( ptr ) { return(ptr->next); }
else { return 0; }
}

View File

@@ -0,0 +1,22 @@
/* $XConsortium: ExprList.h /main/3 1996/08/21 15:46:37 drk $ */
#ifndef __ExprList__
#define __ExprList__
class OL_Expression;
class ExprList {
private:
OL_Expression *head;
public:
ExprList();
ExprList( OL_Expression *elist);
~ExprList();
OL_Expression *first();
OL_Expression *next( OL_Expression *elem );
};
#endif

View File

@@ -0,0 +1,20 @@
/* $XConsortium: Expression.C /main/3 1996/08/21 15:46:40 drk $ */
/* imported interfaces */
#include "Expression.h"
#include "ExprList.h"
OL_Expression::~OL_Expression()
{
/* This is a hack right now to eliminate the memory leak
*/
if ( data_type == CONCAT || data_type == FIRSTOF ) {
ExprList *vlist = ( ExprList * )value_list;
delete vlist;
}
else if ( data_type == LITERAL ) {
char *vlist = (char *)value_list;
delete vlist;
}
}

View File

@@ -0,0 +1,45 @@
/* $XConsortium: Expression.h /main/3 1996/08/21 15:46:44 drk $ */
#ifndef __CRec_hdr__
#define __CRec_hdr__
enum OL_DATA_TYPE {
INVALID_OL_TYPE,
CONTENT,
CONCAT,
FIRSTOF,
GENERIC_ID,
LITERAL,
REFERENCE
};
class OL_Expression {
friend class OL_Data;
friend class FirstOf;
friend class Concat;
friend int ol_dataparse();
friend class ContentType;
friend class ExprList;
private:
OL_DATA_TYPE data_type;
int ename;
void *value_list;
OL_Expression *next;
public:
OL_Expression( OL_DATA_TYPE dtype=INVALID_OL_TYPE,
int dname=-1,
void *vlist=0) {
data_type = dtype; ename = dname; value_list = vlist; next = 0;
}
~OL_Expression();
OL_DATA_TYPE type() const { return data_type; }
int name() const { return ename; }
void *data_list() const { return value_list; }
};
#endif

View File

@@ -0,0 +1,115 @@
/* $XConsortium: FirstOf.C /main/3 1996/08/21 15:46:47 drk $ */
/* exported interfaces */
#include "FirstOf.h"
/* imported interfaces */
#include "Dispatch.h"
#include "OLAF.h"
#include "ExprList.h"
#include "Expression.h"
#include "Token.h"
#include "OL-Data.h"
#include "ConcatTask.h"
#include "Content.h"
#include "AttributeData.h"
#include "GenericId.h"
#include "Literal.h"
//---------------------------------------------------------------------
FirstOf::FirstOf( const Token &t,
ExprList *el,
ActionType mode ):BaseData(t,mode)
{
f_base = t.level();
for ( OL_Expression *local_list = el->first();
local_list;
local_list = el->next(local_list) ) {
switch ( local_list->type() ) {
case CONTENT :
addSubTask( new Content( t,mode) );
break;
case CONCAT :
addSubTask( new Concat ( t,
(ExprList *) local_list->data_list(),
mode) );
break;
case FIRSTOF :
addSubTask( new FirstOf( t,
(ExprList *)local_list->data_list(),
mode) );
break;
case GENERIC_ID :
addSubTask( new GenericId(t,
local_list->name(),
mode) );
break;
case LITERAL :
addSubTask( new Literal( t,
(const char *)local_list->data_list(),
mode) );
break;
case REFERENCE :
addSubTask( new AttributeData( t,
local_list->name(),
mode ));
break;
default:
abort();
}
}
}
//--------------------------------------------------------------------------
void
FirstOf::markup( const Token &t )
{
if ( ignore_status && !Dispatch::OutsideIgnoreScope() ) {
return;
}
if ( f_base > 0 ) {
ComplexTask::markup( t );
if ( t.type() == END ) {
if ( t.level() == f_base ) {
data_complete = 1;
for ( int i = 0; i < ComplexTask::used; i++ ) {
BaseData *task = ( BaseData *)ComplexTask::subtask(i);
if ( task->DataIsComplete() ) {
ValueBuffer.writeStr( task->content() );
break;
}
}
f_base = -1;
ComplexTask::removeAllSubTasks();
}
}
}
}

View File

@@ -0,0 +1,27 @@
/* $XConsortium: FirstOf.h /main/3 1996/08/21 15:46:51 drk $ */
#ifndef __FirstOfHdr__
#define __FirstOfHdr__
#include "Task.h"
#include "BaseDataCollect.h"
class Token;
class OL_Expression;
class ExprList;
class FirstOf : public BaseData {
friend class OL_Data;
friend class Concat;
private:
OL_Expression *elist;
protected:
FirstOf( const Token &t, ExprList *el,ActionType mode );
void markup( const Token &t );
void data( const char *str, size_t sz ) { ComplexTask::data( str, sz ); }
};
#endif

View File

@@ -0,0 +1,73 @@
/* $XConsortium: FlexBuffer.cc /main/2 1996/07/18 16:13:49 drk $ */
#include <iostream.h>
#include <memory.h>
#include <string.h>
#include "FlexBuffer.h"
//---------------------------------------------------------
FlexBuffer::FlexBuffer()
{
HeadPtr = 0;
maxSize = pos = 0;
}
//---------------------------------------------------------
//FlexBuffer::~FlexBuffer()
//{
// delete HeadPtr;
//}
//---------------------------------------------------------
void
FlexBuffer::grow(size_t needed)
{
if(needed + 1 > maxSize){
char *born = new char[maxSize = needed * 3 / 2 + 10];
if(pos){
memcpy(born, HeadPtr, pos);
delete [] HeadPtr;
}
HeadPtr = born;
}
}
//---------------------------------------------------------
void
FlexBuffer::write(const char *d, size_t n)
{
grow(pos + n);
memcpy(HeadPtr + pos, d, n);
pos += n;
}
//---------------------------------------------------------
void
FlexBuffer::writeStr(const char *str )
{
int n = strlen(str);
grow( pos + n );
memcpy ( HeadPtr + pos, str, n );
pos += n;
}
//---------------------------------------------------------
FlexBuffer &
FlexBuffer::operator+( FlexBuffer & fb )
{
grow( pos + fb.GetSize() );
memcpy(HeadPtr + pos , fb.HeadPtr, fb.GetSize() );
pos += fb.GetSize();
return ( *this );
}
//---------------------------------------------------------
ostream &
operator<< ( ostream &os, FlexBuffer &fb )
{
os << fb.GetBuffer();
return os;
}

View File

@@ -0,0 +1,43 @@
/* $XConsortium: FlexBuffer.h /main/2 1996/07/18 16:45:28 drk $ */
#ifndef FLEX_BFR_HDR
#define FLEX_BFR_HDR
#include <stddef.h>
#include <iostream.h>
class FlexBuffer {
friend ostream &operator<< ( ostream &s, FlexBuffer &);
private:
int pos;
int maxSize;
char *HeadPtr;
void grow(size_t);
public:
void write( const char *ch, size_t n );
void writeStr ( const char *ch );
void put( char );
void reset() { pos = 0; };
int GetSize() { return( pos ); }
const char *GetBuffer() { grow(pos); HeadPtr[pos] = 0; return(HeadPtr); }
FlexBuffer();
~FlexBuffer() { delete [] HeadPtr; }
FlexBuffer &operator+ ( FlexBuffer & );
};
inline void FlexBuffer::put( char c )
{
grow( pos + 1 );
*(HeadPtr + pos) = c;
pos += 1;
}
#endif

View File

@@ -0,0 +1,95 @@
/* $XConsortium: GenericId.cc /main/5 1996/07/18 16:14:18 drk $ */
/* exported interfaces */
#include "GenericId.h"
/* imported interfaces */
#include "Dispatch.h"
#include "SGMLName.h"
#include "OLAF.h"
#include "OL-Data.h"
#include "Token.h"
#ifdef FISH_DEBUG
#include "dbug.h"
#endif
//-------------------------------------------------------------------------
GenericId::GenericId( const Token &t,
int name,
ActionType mode ):BaseData(t,mode)
{
#ifdef FISH_DEBUG
DBUG_PRINT("GenericId", (" name = %s", SGMLName::lookup(name)) );
#endif
giname = name;
f_data = NULL;
done = 0;
f_base = -1;
}
//-------------------------------------------------------------------------
void
GenericId::markup( const Token &t )
{
#ifdef FISH_DEBUG
DBUG_PRINT( "GenericId", (" token t = %s",SGMLName::lookup(t.Gi()) ) );
#endif
if ( ignore_status && !Dispatch::OutsideIgnoreScope() ) {
return;
}
if ( f_data ) {
f_data->markup( t );
}
if ( t.type() == START ) {
/* first time we see the GI */
if ( t.Gi() == giname && f_base < 0 && !done ) {
/* fork off the OL_Data class for this GI */
f_data = new OL_Data ( t, OLAF::OL_data, (ActionType)ignore_status );
assert ( f_data != NULL );
f_base = t.level();
}
}
else if ( t.type() == END ) {
if ( f_base == t.level() && !done ) {
if ( data_complete = f_data->DataIsComplete() ) {
ValueBuffer.writeStr( f_data->content() );
}
delete f_data; f_data = NULL;
done = 1;
}
}
}
//-------------------------------------------------------------------------
void
GenericId::data( const char *str, size_t sz )
{
if ( ignore_status && !Dispatch::OutsideIgnoreScope() ) {
return;
}
if ( f_base > 0 ) {
if ( f_data ) {
f_data->data( str, sz );
}
}
}

View File

@@ -0,0 +1,29 @@
/* $XConsortium: GenericId.h /main/2 1996/07/18 16:45:48 drk $ */
#ifndef __gen_Id__
#define __gen_Id__
#include "BaseDataCollect.h"
class Token;
class OL_Data;
class GenericId : public BaseData {
friend class FirstOf;
friend class OL_Data;
friend class Concat;
private:
int giname;
int done;
OL_Data *f_data;
protected:
GenericId( const Token &t, int giname,ActionType mode);
void markup( const Token &t );
void data( const char *str, size_t sz );
};
#endif

View File

@@ -0,0 +1,287 @@
/* $XConsortium: GraphicsTask.cc /main/8 1996/08/14 16:59:38 rcs $ */
#include <assert.h>
#include <stream.h>
#include <iostream.h>
#include <sys/types.h>
#include <netinet/in.h>
#include "GraphicsTask.h"
#include "Dispatch.h"
#include "FlexBuffer.h"
#include "OLAF.h"
#include "OL-Data.h"
#include "Token.h"
#include "SearchEng.h"
#include "BookTasks.h"
#include "NodeData.h"
#include "NodeTask.h"
#include "DataBase.h"
#include "BookCaseDB.h"
#ifndef DtinfoClient
#include "PostScript.h"
#endif
#include "SearchPath.h"
#include "utility/funcs.h"
#include <X11/XWDFile.h>
GR_TYPE gtype;
extern FILE *graphics_taskin;
extern void get_type ();
const int GR_ENCODING_TEXT = 1;
//-------------------------------------------------------------------------
GR_TYPE
GraphicsTask::graphics_type( const char *gname )
{
gtype = GR_TYPE_UNKNOWN;
if ( !(graphics_taskin = fopen( gname, "r" )) ) {
throw(PosixError( errno, form("cannot open graphics file %s\n", gname)));
}
get_type();
if (gtype == GR_TYPE_UNKNOWN) {
if ((strstr(gname, ".cgm") != NULL) ||
(strstr(gname, ".CGM") != NULL))
{
gtype = GR_TYPE_CGM;
}
}
fclose(graphics_taskin);
// If the file is not cgm and if the lexer couldn't detect the graphics type,
// see if the graphic is an XWD file.
if (gtype == GR_TYPE_UNKNOWN) {
// Create header container
CARD32 header[sz_XWDheader];
XWDFileHeader *hdrptr;
FILE *fp;
if ( !(fp = fopen( gname, "r" )) ) {
throw(PosixError( errno,
form("cannot reopen graphics file %s\n", gname)));
}
hdrptr = (XWDFileHeader *)header;
// Initialize the structure
for (CARD32 ndx = 0; ndx < sz_XWDheader; ndx++) {
header[ndx] = (CARD32) 0;
}
if ( fread( &header[0], sizeof(*hdrptr), 1, fp ) == 1 ) {
// Normal fields into host byte-order
hdrptr->file_version = ntohl(hdrptr->file_version);
hdrptr->header_size = ntohl(hdrptr->header_size);
hdrptr->pixmap_width = ntohl(hdrptr->pixmap_width);
hdrptr->pixmap_height = ntohl(hdrptr->pixmap_height);
// Check some of the structure members to confirm the file type.
if ((hdrptr->file_version == XWD_FILE_VERSION) &&
(hdrptr->header_size > 0) &&
(hdrptr->pixmap_width > 0) &&
(hdrptr->pixmap_height > 0)) {
gtype = GR_TYPE_XWD;
}
}
fclose( fp );
}
return ( gtype );
}
//-------------------------------------------------------------------------
GraphicsTask::GraphicsTask( SearchEngine *parent, const Token &t )
{
f_base = t.level();
graphics_data = NULL;
f_parent = parent;
termsbuf = NULL;
f_title = 0;
if ( Dispatch::OutsideIgnoreScope() ) {
graphics_data = new OL_Data ( t, OLAF::OL_Graphic );
addSubTask( graphics_data );
if ( t.LookupAttr( OLAF::OL_Title ) ) {
f_title = new OL_Data(t, OLAF::OL_Title, IGNORE_ON );
if ( !f_title->DataWillBeAvailable() ) {
delete f_title;
f_title = 0;
}
else {
addSubTask(f_title);
}
}
}
}
//-------------------------------------------------------------------------
void
GraphicsTask::markup( const Token &t )
{
if ( f_base > 0 ) {
ComplexTask::markup( t );
if ( t.type() == START && !f_title ) {
if ( t.LookupAttr( OLAF::OL_Title ) ) {
f_title = new OL_Data(t, OLAF::OL_Title, IGNORE_ON );
if ( !f_title->DataWillBeAvailable() ) {
delete f_title;
f_title = 0;
}
else {
addSubTask(f_title);
}
}
}
if ( t.type() == END ) {
if ( Dispatch::OutsideIgnoreScope() ) {
if ( f_base == t.level() ) {
write_record( t );
KILLSUBTASK( graphics_data );
f_base = -1;
}
}
}
}
}
//-------------------------------------------------------------------------
void
GraphicsTask::write_record( const Token &t )
{
/*
* It is up to the client of graphics_data to determine how to
* interpret the content() , which will be treated as file name
*/
SearchPath *spath = Dispatch::GetSearchPath();
const char *file_name = graphics_data->content();
const char *grFileName = spath->get_real_path( file_name );
const char *bounding_box = "0.0.0.0";
GR_TYPE gr_type = GR_TYPE_UNKNOWN;
/*
* assuming that grFileName is actually corresponding to the
* final file where the graphical content is stored
*/
FlexBuffer graphics_buffer;
const char *size_info;
int graphics_available=0;
FILE *gp;
if ( grFileName ) {
gp = fopen ( grFileName, "r" );
if ( gp ) {
graphics_available=1;
int c;
while ( ( c=getc(gp) ) != EOF ) {
graphics_buffer.put(c);
}
fclose(gp);
switch ( (gr_type = graphics_type( grFileName )) ) {
case GR_TYPE_UNKNOWN :
{
cerr << "(WARNING) Unsupported graphics type found in "
<< grFileName << endl
<< " It is included in file " << t.file() << endl
<< " at line " << t.line() << endl;
}
break;
case GR_TYPE_POSTSCRIPT :
{
#ifndef DtinfoClient
PostScript *ps_store = new PostScript( grFileName );
bounding_box = ps_store->GetBoundingBox();
if ( ps_store->HasSearchTerms() ) {
termsbuf = ps_store->GetTermsBuffer();
}
delete ps_store;
#else
cerr << "(WARNING) Unsupported PostScript graphic found in "
<< grFileName << endl
<< " It is included in file " << t.file() << endl
<< " at line " << t.line() << endl;
#endif
}
break;
}
size_info = form("%d.%d.%s",
gr_type,
GR_ENCODING_TEXT,
bounding_box );
}
}
else {
cerr << "(WARNING) graphical file = " << file_name << endl
<< " included in file = " << t.file() << endl
<< " at line = " << t.line() << endl
<< " is not found, a zero length graphical data is used\n\n";
}
/* dump the graphics record */
NodeData *nodeData = f_parent->node_data();
const char *gid = nodeData->graphics_id();
BookTask *book = nodeData->node()->book();
const char *bookLocator = book->locator();
DBTable *gtab = book->bookcase()->table(BookCaseDB::Graphics);
gtab->insert( STRING_CODE, bookLocator,
STRING_CODE, gid,
STRING_CODE, "",
STRING_CODE, "v0",
STRING_CODE, graphics_available?size_info : "0.0.0.0.0.0",
-STRING_CODE, graphics_buffer.GetBuffer(),
graphics_buffer.GetSize(),
STRING_CODE, f_title?f_title->content():"",
NULL);
/*
if ( compress ) {
gtab->insert(STRING_CODE, gid,
STRING_CODE, "@@ graphcis name",
STRING_CODE, "v0",
STRING_CODE, "@@ type info",
COMPRESSED_STRING_CODE, "@@ CompressedAgent",
-STRING_CODE, graphics_buffer.GetBuffer(), graphics_buffer.GetBSize(),
STRING_CODE, "@@ graphics title" );
}
*/
}

View File

@@ -0,0 +1,53 @@
/* $XConsortium: GraphicsTask.h /main/3 1996/07/18 16:46:09 drk $ */
#ifndef GRAPHICS_TASK_HDR
#define GRAPHICS_TASK_HDR
#include "Task.h"
#include "FlexBuffer.h"
#include "oliasdb/olias_consts.h"
class Token;
class SearchEngine;
class OL_Data;
class GraphicsTask : public ComplexTask {
private:
int f_base;
SearchEngine *f_parent;
const FlexBuffer *termsbuf;
OL_Data *graphics_data;
OL_Data *f_title;
void write_record( const Token & );
GR_TYPE graphics_type( const char * );
public:
int IsDone() { return( f_base == -1 ); }
int HasSearchTerms() const;
const FlexBuffer *GetTerms() { return(termsbuf); }
public:
void markup ( const Token & );
GraphicsTask( SearchEngine *parent, const Token &t);
};
inline
int
GraphicsTask::HasSearchTerms() const
{
if ( !termsbuf ) {
return 0;
}
else {
FlexBuffer *tmpBuffer = ( FlexBuffer *)termsbuf;
return( tmpBuffer->GetSize() );
}
}
#endif

View File

@@ -0,0 +1,10 @@
/* $XConsortium: Handler.cc /main/2 1996/07/18 16:15:12 drk $ */
#include <stdio.h>
#include <stdlib.h>
//---------------------------------------------------------------------
void FreeStoreException()
{
fprintf(stderr,"(ERROR) Memory exhausted\n");
exit(1);
}

View File

@@ -0,0 +1,8 @@
/* $XConsortium: Handler.h /main/2 1996/07/18 16:46:29 drk $ */
#ifndef __HandlerH__
#define __HandlerH__
#include <new.h>
extern void FreeStoreException();
#endif

View File

@@ -0,0 +1,374 @@
XCOMM $TOG: Imakefile /main/27 1997/09/05 11:29:30 samborn $
DEPEND_DEFINES = $(CXXDEPENDINCLUDES)
#ifdef RegenParserFiles
XCOMM lex flags
LFLAGS=-Cf -L -8 -s
YFLAGS=-d
#endif
#ifdef DoLicenseManagement
LIC_FLAGS=-DLICENSE_MANAGEMENT
LIC_INCLUDES=$(LICENSE_L_INCLUDES) $(LICENSE_F_INCLUDES)
LIC_LIBS=$(LICENSE_L_LIBS)
#endif
#ifdef UseRWClasses
XCOMM make rogue into a defined item in site.def
INCLUDES=-I/VOB/olias/control/rogue
ROGUE_LIBS=$(RW_LIBDIR) $(RW_LIB)
#endif
INCLUDES=$(MMDB_INCLUDES) $(EXCEPTIONS_INCLUDES) \
$(MISC_INCLUDES) $(GLOBAL_INCLUDES) $(DBUG_INCLUDES) \
$(COMMON_CLASS_INCLUDES) $(LIC_INCLUDES)
MMDB_DIR=../../../mmdb
#ifdef AIXArchitecture
API_OBJS = \
$(MMDB_DIR)/api/base.o $(MMDB_DIR)/api/info_base.o \
$(MMDB_DIR)/api/info_lib.o $(MMDB_DIR)/api/smart_ptr.o \
$(MMDB_DIR)/api/transaction.o $(MMDB_DIR)/api/utility.o
BTREE_OBJS = \
$(MMDB_DIR)/btree/mmdb_btree.o
#if !defined(AIXArchitecture)
EXTRA_BTREE_BERKELEY_OBJS = $(MMDB_DIR)/btree_berkeley/memmove.o
#endif
BTREE_BERKELEY_OBJS = \
$(MMDB_DIR)/btree_berkeley/bt_close.o $(MMDB_DIR)/btree_berkeley/bt_conv.o \
$(MMDB_DIR)/btree_berkeley/bt_debug.o $(MMDB_DIR)/btree_berkeley/bt_delete.o \
$(MMDB_DIR)/btree_berkeley/bt_get.o $(MMDB_DIR)/btree_berkeley/bt_open.o \
$(MMDB_DIR)/btree_berkeley/bt_overflow.o $(MMDB_DIR)/btree_berkeley/bt_page.o \
$(MMDB_DIR)/btree_berkeley/bt_put.o $(MMDB_DIR)/btree_berkeley/bt_search.o \
$(MMDB_DIR)/btree_berkeley/bt_seq.o $(MMDB_DIR)/btree_berkeley/bt_split.o \
$(MMDB_DIR)/btree_berkeley/bt_stack.o $(MMDB_DIR)/btree_berkeley/bt_utils.o \
$(MMDB_DIR)/btree_berkeley/mktemp.o $(MMDB_DIR)/btree_berkeley/realloc.o \
$(MMDB_DIR)/btree_berkeley/snprintf.o $(EXTRA_BTREE_BERKELEY_OBJS) \
$(MMDB_DIR)/btree_berkeley/mpool.o $(MMDB_DIR)/btree_berkeley/db.o
COMPRESSION_OBJS = \
$(MMDB_DIR)/compression/abs_agent.o $(MMDB_DIR)/compression/zip.o \
$(MMDB_DIR)/compression/huffman.o $(MMDB_DIR)/compression/trie.o \
$(MMDB_DIR)/compression/code.o $(MMDB_DIR)/compression/lzss.o \
$(MMDB_DIR)/compression/sgml.o $(MMDB_DIR)/compression/ps.o
DISKHASH_OBJS = \
$(MMDB_DIR)/diskhash/disk_bucket.o $(MMDB_DIR)/diskhash/bucket_array.o \
$(MMDB_DIR)/diskhash/disk_hash.o
DSTR_OBJS = \
$(MMDB_DIR)/dstr/set.o $(MMDB_DIR)/dstr/bset.o \
$(MMDB_DIR)/dstr/slist.o $(MMDB_DIR)/dstr/dlist_cell.o \
$(MMDB_DIR)/dstr/dlist.o $(MMDB_DIR)/dstr/heap.o \
$(MMDB_DIR)/dstr/void_ptr_array.o $(MMDB_DIR)/dstr/void_ptr_stack.o \
$(MMDB_DIR)/dstr/memory_pool.o $(MMDB_DIR)/dstr/dstr_test.o \
$(MMDB_DIR)/dstr/index_agent.o $(MMDB_DIR)/dstr/token_stack.o \
$(MMDB_DIR)/dstr/slist_char_ptr_cell.o
DTI_EXCS_OBJS = \
$(MMDB_DIR)/dti_excs/Jump_Environment.o $(MMDB_DIR)/dti_excs/Exceptions.o \
$(MMDB_DIR)/dti_excs/Exception.o $(MMDB_DIR)/dti_excs/Destructable.o \
$(MMDB_DIR)/dti_excs/terminate.o
DYNHASH_OBJS = \
$(MMDB_DIR)/dynhash/data_t.o $(MMDB_DIR)/dynhash/imp_bucket.o \
$(MMDB_DIR)/dynhash/imp_die.o
HMPHF_OBJS = \
$(MMDB_DIR)/hmphf/buckets.o $(MMDB_DIR)/hmphf/mphf_funcs.o \
$(MMDB_DIR)/hmphf/mphf_hash_table.o $(MMDB_DIR)/hmphf/params.o \
$(MMDB_DIR)/hmphf/pattern.o $(MMDB_DIR)/hmphf/sorter.o
INDEX_OBJS = \
$(MMDB_DIR)/index/btree_index.o $(MMDB_DIR)/index/dyn_disk_index.o \
$(MMDB_DIR)/index/dyn_index.o $(MMDB_DIR)/index/dyn_memory_index.o \
$(MMDB_DIR)/index/fast_mphf.o $(MMDB_DIR)/index/hash.o \
$(MMDB_DIR)/index/index.o $(MMDB_DIR)/index/inv_lists.o \
$(MMDB_DIR)/index/mphf_index.o
MGRS_OBJS = \
$(MMDB_DIR)/mgrs/managers.o $(MMDB_DIR)/mgrs/misc.o \
$(MMDB_DIR)/mgrs/query_mgr.o $(MMDB_DIR)/mgrs/template_mgr.o
MISC_OBJS = \
$(MMDB_DIR)/misc/unique_id.o
OBJECT_OBJS = \
$(MMDB_DIR)/object/composite.o $(MMDB_DIR)/object/compressed_pstring.o \
$(MMDB_DIR)/object/cset.o $(MMDB_DIR)/object/dl_list.o \
$(MMDB_DIR)/object/dl_list_cell.o $(MMDB_DIR)/object/handler.o \
$(MMDB_DIR)/object/integer.o $(MMDB_DIR)/object/long_pstring.o \
$(MMDB_DIR)/object/oid.o $(MMDB_DIR)/object/oid_list.o \
$(MMDB_DIR)/object/oid_t.o $(MMDB_DIR)/object/primitive.o \
$(MMDB_DIR)/object/pstring.o $(MMDB_DIR)/object/random_gen.o \
$(MMDB_DIR)/object/root.o $(MMDB_DIR)/object/short_list.o \
$(MMDB_DIR)/object/tuple.o
OLIASDB_OBJS = \
$(MMDB_DIR)/oliasdb/asciiIn_filters.o $(MMDB_DIR)/oliasdb/collectionIterator.o \
$(MMDB_DIR)/oliasdb/dlp_hd.o $(MMDB_DIR)/oliasdb/dlp_test.o \
$(MMDB_DIR)/oliasdb/doc_hd.o $(MMDB_DIR)/oliasdb/doc_test.o \
$(MMDB_DIR)/oliasdb/graphic_hd.o $(MMDB_DIR)/oliasdb/graphic_test.o \
$(MMDB_DIR)/oliasdb/loc_test.o $(MMDB_DIR)/oliasdb/locator_hd.o \
$(MMDB_DIR)/oliasdb/mark.o $(MMDB_DIR)/oliasdb/mark_base.o \
$(MMDB_DIR)/oliasdb/mark_test.o $(MMDB_DIR)/oliasdb/mmdb.o \
$(MMDB_DIR)/oliasdb/node_hd.o $(MMDB_DIR)/oliasdb/node_test.o \
$(MMDB_DIR)/oliasdb/olias_funcs.o $(MMDB_DIR)/oliasdb/olias_test.o \
$(MMDB_DIR)/oliasdb/stylesheet_hd.o $(MMDB_DIR)/oliasdb/stylesheet_test.o \
$(MMDB_DIR)/oliasdb/toc_hd.o $(MMDB_DIR)/oliasdb/toc_test.o \
$(MMDB_DIR)/oliasdb/user_base.o
SCHEMA_OBJS = \
$(MMDB_DIR)/schema/desc.o $(MMDB_DIR)/schema/store_desc.o \
$(MMDB_DIR)/schema/object_dict.o $(MMDB_DIR)/schema/stored_object_desc.o \
$(MMDB_DIR)/schema/index_desc.o $(MMDB_DIR)/schema/inv_desc.o \
$(MMDB_DIR)/schema/agent_desc.o $(MMDB_DIR)/schema/container_desc.o \
$(MMDB_DIR)/schema/sheet.o $(MMDB_DIR)/schema/token.o
STORAGE_OBJS = \
$(MMDB_DIR)/storage/abs_storage.o $(MMDB_DIR)/storage/chunks_index.o \
$(MMDB_DIR)/storage/heap_comp_funcs.o $(MMDB_DIR)/storage/lru.o \
$(MMDB_DIR)/storage/page.o $(MMDB_DIR)/storage/page_cache.o \
$(MMDB_DIR)/storage/page_rep.o $(MMDB_DIR)/storage/page_storage.o \
$(MMDB_DIR)/storage/rep_cell.o $(MMDB_DIR)/storage/rep_policy.o \
$(MMDB_DIR)/storage/store_test.o $(MMDB_DIR)/storage/unixf_storage.o \
$(MMDB_DIR)/storage/version.o $(MMDB_DIR)/storage/vm_storage.o
UTILITY_OBJS = \
$(MMDB_DIR)/utility/funcs.o $(MMDB_DIR)/utility/ostring.o \
$(MMDB_DIR)/utility/pm_random.o $(MMDB_DIR)/utility/atoi_pearson.o \
$(MMDB_DIR)/utility/xtime.o $(MMDB_DIR)/utility/buffer.o \
$(MMDB_DIR)/utility/atoi_larson.o $(MMDB_DIR)/utility/atomic_lock.o \
$(MMDB_DIR)/utility/rw_lock.o $(MMDB_DIR)/utility/atoi_fast.o \
$(MMDB_DIR)/utility/filter.o $(MMDB_DIR)/utility/mmdb_exception.o \
$(MMDB_DIR)/utility/randomize.o
DTI_CC_OBJS = \
$(MMDB_DIR)/dti_cc/CC_Listbase.o $(MMDB_DIR)/dti_cc/cc_exceptions.o \
$(MMDB_DIR)/dti_cc/CC_String.o $(MMDB_DIR)/dti_cc/CC_Tokenizer.o \
$(MMDB_DIR)/dti_cc/CC_Stack.o $(MMDB_DIR)/dti_cc/CC_Slist.o
#if defined(HPArchitecture) || !defined(CplusplusCompilerMajorVersion) || (CplusplusCompilerMajorVersion != 4)
EXTRA_HARDCOPY_OBJS = $(MMDB_DIR)/HardCopy/TemplatesAutoNumber.o
#endif
HARDCOPY_OBJS = \
$(MMDB_DIR)/HardCopy/FPset.o $(MMDB_DIR)/HardCopy/HardCopyFP.o \
$(MMDB_DIR)/HardCopy/autoNumber.o $(MMDB_DIR)/HardCopy/autoNumberFP.o \
$(EXTRA_HARDCOPY_OBJS)
#if defined(HPArchitecture) || !defined(CplusplusCompilerMajorVersion) || (CplusplusCompilerMajorVersion != 4)
EXTRA_STYLESHEET_OBJS = $(MMDB_DIR)/StyleSheet/SSTemplates.o
#endif
STYLESHEET_OBJS = \
$(MMDB_DIR)/StyleSheet/Attribute.o $(MMDB_DIR)/StyleSheet/AttributeList.o \
$(MMDB_DIR)/StyleSheet/BitVector.o $(MMDB_DIR)/StyleSheet/DocParser.o \
$(MMDB_DIR)/StyleSheet/Element.o $(MMDB_DIR)/StyleSheet/Expression.o \
$(MMDB_DIR)/StyleSheet/Feature.o $(MMDB_DIR)/StyleSheet/FeatureDefDictionary.o \
$(MMDB_DIR)/StyleSheet/FeatureSet.o $(MMDB_DIR)/StyleSheet/FeatureValue.o \
$(MMDB_DIR)/StyleSheet/PathQualifier.o $(MMDB_DIR)/StyleSheet/PathTable.o \
$(MMDB_DIR)/StyleSheet/Resolver.o $(MMDB_DIR)/StyleSheet/ResolverStack.o \
$(MMDB_DIR)/StyleSheet/SSPath.o $(MMDB_DIR)/StyleSheet/StyleSheet.o \
$(MMDB_DIR)/StyleSheet/StyleSheetExceptions.o \
$(MMDB_DIR)/StyleSheet/SymTab.o $(MMDB_DIR)/StyleSheet/VariableTable.o \
$(MMDB_DIR)/StyleSheet/defParser.o $(MMDB_DIR)/StyleSheet/defToken.o \
$(MMDB_DIR)/StyleSheet/style.o $(MMDB_DIR)/StyleSheet/tokenStyle.o \
$(MMDB_DIR)/StyleSheet/RendererHCV.o $(EXTRA_STYLESHEET_OBJS)
MMDB_OBJS = $(HARDCOPY_OBJS) $(STYLESHEET_OBJS) $(DTI_CC_OBJS)
ALL_MMDB_OBJS = $(API_OBJS) $(BTREE_OBJS) \
$(BTREE_BERKELEY_OBJS) $(COMPRESSION_OBJS) \
$(DISKHASH_OBJS) $(DSTR_OBJS) \
$(DTI_EXCS_OBJS) $(DYNHASH_OBJS) \
$(HMPHF_OBJS) $(INDEX_OBJS) \
$(MGRS_OBJS) $(MISC_OBJS) \
$(OBJECT_OBJS) $(OLIASDB_OBJS) \
$(SCHEMA_OBJS) $(STORAGE_OBJS) \
$(UTILITY_OBJS) $(MMDB_OBJS)
#endif
#ifdef AIXArchitecture
Libs = $(LINKLIBS) $(ALL_MMDB_OBJS) $(LIC_LIBS) $(DBUG_LIBS) $(DTSVCLIB) $(TTLIB) $(MATH_LIB)
#else
Libs = $(LINKLIBS) $(MMDB_LIBS) $(LIC_LIBS) $(DBUG_LIBS) $(MATH_LIB)
#endif
#ifdef UseQSearch
SEARCHENG=QSearch
#else
#ifdef UseDtSearch
SEARCHENG=AusText
#endif
#endif
#ifdef UseDtSearch
SEARCH_SRCS=$(SEARCHENG).C $(SEARCHENG)Storage.C
SEARCH_OBJS=$(SEARCHENG).o $(SEARCHENG)Storage.o
#else
SEARCH_OBJS=$(SEARCHENG)
#endif
NORMAL_SRCS = \
AttributeData.C \
AttributeList.C \
AttributeRec.C \
BookCaseDB.C \
BookTasks.C \
BTCollectable.C \
ConcatTask.C \
Content.C \
OL_DataExpr.C \
ContentType.C \
DataBase.C \
DataTask.C \
DataRepository.C \
Dispatch.C \
EntityList.C \
Expression.C \
ExprList.C \
FirstOf.C \
FlexBuffer.C \
GenericId.C \
gr_type.C \
GraphicsTask.C \
Handler.C \
LcfTask.C \
NodeData.C \
NodeTask.C \
OL-Data.C \
OLAF.C \
ReplaceIdIdref.C \
SGMLDefn.C \
SGMLName.C \
SearchEng.C \
SearchPath.C \
SearchStorage.C \
StringList.C \
StyleTask.C \
StyleTaskDB.C \
StyleValidate.C \
TOCTask.C \
Task.C \
Token.C \
lex.C
NORMAL_OBJS = $(NORMAL_SRCS:.C=.o) $(SEARCH_OBJS)
SRCS=$(NORMAL_SRCS) $(SEARCH_SRCS)
#ifndef DtinfoClient
OBJS=$(NORMAL_OBJS) PostScript.o
#else
OBJS=$(NORMAL_OBJS)
#endif
CMD_SRCS = NodeParser.C \
NCFGen.C \
MixedGen.C \
RemoteId.C \
StyleUpdate.C
CMD_OBJS = $(CMD_SRCS:.C=.o)
XCOMM #######################################
XCOMM Template handling
XCOMM #######################################
#if defined(SunArchitecture) && CplusplusCompilerMajorVersion > 3
all::$(CMD_OBJS)
SimpleLibraryT(OLAFParse,$(OBJS),$(LIBDIR))
SimpleCPlusPlusProgram(NodeParser, NodeParser.o libOLAFParse.a libOLAFParseT.a,$(Libs))
SimpleCPlusPlusProgram(NCFGen, NCFGen.o libOLAFParse.a libOLAFParseT.a,$(Libs) $(DTSVCLIB) $(TTLIB))
SimpleCPlusPlusProgram(MixedGen, MixedGen.o RemoteId.o libOLAFParse.a libOLAFParseT.a,$(Libs) $(DTSVCLIB) $(TTLIB))
SimpleCPlusPlusProgram(StyleUpdate, StyleUpdate.o libOLAFParse.a libOLAFParseT.a,$(Libs) $(DTSVCLIB) $(TTLIB))
#else
TEMPLATE_OBJS = TKTemplate.o
RealLibrary(OLAFParse,$(OBJS),$(LIBDIR))
SimpleCPlusPlusProgram(NodeParser, NodeParser.o $(TEMPLATE_OBJS) libOLAFParse.a,$(Libs))
SimpleCPlusPlusProgram(NCFGen, NCFGen.o $(TEMPLATE_OBJS) libOLAFParse.a,$(Libs) $(DTSVCLIB) $(TTLIB))
SimpleCPlusPlusProgram(MixedGen, MixedGen.o RemoteId.o $(TEMPLATE_OBJS) libOLAFParse.a,$(Libs) $(DTSVCLIB) $(TTLIB))
SimpleCPlusPlusProgram(StyleUpdate, StyleUpdate.o $(TEMPLATE_OBJS) libOLAFParse.a,$(Libs) $(DTSVCLIB) $(TTLIB))
#ifdef HPArchitecture
SpecialCPlusPlusObjectRule($(TEMPLATE_OBJS),,+pti all_tmpls)
#else
#if defined(UXPArchitecture) || (defined(SunArchitecture) && CplusplusCompilerMajorVersion < 4)
SpecialCPlusPlusObjectRule($(TEMPLATE_OBJS),,+Tall_tmpls)
#endif
#endif
#endif
XCOMM lex.C gr_type.C ReplaceIdIdref.C ContentType.C RemoteId.C
XCOMM and OL_DataExpr.C are generated from flex and byacc files
#ifdef RegenParserFiles
SimpleCPlusPlusLexTarget(lex)
LexTarget (gr_type,graphics_task)
LexTarget (ReplaceIdIdref,nodedata)
LexTarget (ContentType,ol_data)
LexTarget (RemoteId,remote)
YaccTarget(OL_DataExpr,ol_data)
#else
OL_DataExpr.o : OL_DataExpr.C
CplusObjectCompile($(_NOOP_))
ContentType.o : ContentType.C
CplusObjectCompile($(_NOOP_))
gr_type.o : gr_type.C
CplusObjectCompile($(_NOOP_))
ReplaceIdIdref.o : ReplaceIdIdref.C
CplusObjectCompile($(_NOOP_))
lex.o : lex.C
CplusObjectCompile($(_NOOP_))
RemoteId.o : RemoteId.C
CplusObjectCompile($(_NOOP_))
#endif
XCOMM This passes BookTasks.C the necessary flag to compile-in licensing
SpecialCPlusPlusObjectRule(BookTasks.o,,$(LIC_FLAGS))
InstallBuildToolsBinary(NodeParser)
InstallBuildToolsBinary(NCFGen)
InstallBuildToolsBinary(MixedGen)
InstallBuildToolsBinary(StyleUpdate)
InstallBuildToolsScript(dtinfogen)
InstallBuildToolsBinary(dtinfogen_worker)
#ifndef DtinfoClient
InstallMultipleDest(install_buildtools,psbox.ps,$(INSTALL_ETC_DIR))
#endif
XCOMM symlinks used by dtinfogen when run from the build tree
LinkSourceFile(hardcopy.feature.spec,$(CDELIBSRC)/DtMmdb/StyleSheet)
LinkSourceFile(online.feature.spec,$(CDELIBSRC)/DtMmdb/StyleSheet)
LinkSourceFile(mmdb.infolib.spec,$(CDELIBSRC)/DtMmdb/oliasdb)
LinkSourceFile(dtsr,$(PROGRAMSRC))
LinkFile(C.ISO-8859-1,$(PROGRAMSRC)/localized/C)
LinkFile(de_DE.ISO-8859-1,$(PROGRAMSRC)/localized/de_DE.ISO8859-1)
LinkFile(es_ES.ISO-8859-1,$(PROGRAMSRC)/localized/es_ES.ISO8859-1)
LinkFile(fr_FR.ISO-8859-1,$(PROGRAMSRC)/localized/fr_FR.ISO8859-1)
LinkFile(it_IT.ISO-8859-1,$(PROGRAMSRC)/localized/it_IT.ISO8859-1)
LinkFile(ja_JP.EUC-JP,$(PROGRAMSRC)/localized/ja_JP.dt-eucJP)
LinkFile(C,C.ISO-8859-1)
#if defined(SunArchitecture)
SYS_LIBRARIES = -lgen
#endif
DEPLIBS2 = $(DEPDTSVCLIB) $(DEPTTLIB) /* $(DEPXMLIB) $(DEPXTOOLLIB) $(DEPXLIB) */
LOCAL_LIBRARIES2 = $(DTSVCLIB) $(TTLIB) $(XMLIB) $(XTOOLLIB) $(XLIB)
SRCS2 = dtinfogen_worker.c
OBJS2 = dtinfogen_worker.o
AllTarget(dtinfogen_worker)
ComplexProgramTarget_2(dtinfogen_worker,$(LOCAL_LIBRARIES2),NullParameter)
clean::
RemoveFiles(dtinfogen_worker)
DependTarget3($(NORMAL_SRCS),$(CMD_SRCS),$(SRCS2))

View File

@@ -0,0 +1,114 @@
/* $XConsortium: LcfTask.C /main/3 1996/10/26 18:17:58 cde-hal $
*
* (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.
*/
/* exported interfaces */
#include "LcfTask.h"
/* imported interfaces */
#include <assert.h>
#include "Token.h"
#include "NodeTask.h"
#include "DataBase.h"
#include "OL-Data.h"
#include "OLAF.h"
#include "BookTasks.h"
#include "BookCaseDB.h"
//--------------------------------------------------------------------
LcfTask::LcfTask( NodeTask *f_parent, const Token &t )
{
assert( f_parent != NULL );
f_node = f_parent;
f_base = t.level();
}
//--------------------------------------------------------------------
void
LcfTask::markup( const Token &t )
{
ComplexTask::markup(t);
if ( t.type() == START ) {
if ( t.LookupAttr( OLAF::OL_id ) ) {
OL_Data *LocData = new OL_Data ( t, OLAF::OL_id, REMOVE_SPACES );
/*
* Add subtask only if I know Data will be available
*/
if ( LocData->DataWillBeAvailable() ) {
addSubTask( LocData );
OL_Data *RefData = new OL_Data(t, OLAF::OL_XRefLabel, IGNORE_ON);
addSubTask( RefData );
}
else { delete LocData; }
}
}
else if ( t.type() == END ) {
/* only write out all the locator if I am at the end f_node */
if ( t.level() == f_base ) {
write_record();
reset();
}
}
}
//--------------------------------------------------------------------
void
LcfTask::reset()
{
ComplexTask::removeAllSubTasks();
}
//--------------------------------------------------------------------
void
LcfTask::write_record()
{
const char *NodeLocator = f_node->locator();
#if 0
for ( int i = 0; i < ComplexTask::used; i++ ) {
OL_Data *task = (OL_Data * )subtask(i);
if ( !task->ContentIsEmpty() ) {
DBTable *tbl = f_node->book()->bookcase()->table(BookCaseDB::Locator);
tbl->insert( STRING_CODE, task->content(),
STRING_CODE, NodeLocator,
STRING_CODE, task->filename(),
INTEGER_CODE, task->line_no(),
NULL);
}
}
#else
for ( int i = 0; i < ComplexTask::used; i+=2 ) {
OL_Data* task = (OL_Data * )subtask(i);
OL_Data* reftask = (OL_Data * )subtask(i+1);
if ( !task->ContentIsEmpty() ) {
DBTable *tbl = f_node->book()->bookcase()->table(BookCaseDB::Locator);
const char* reflabel = "";
if ( !reftask->ContentIsEmpty() ) {
const char* content = reftask->content();
if (strlen(content) < 256)
reflabel = content;
}
tbl->insert( STRING_CODE, task->content(),
STRING_CODE, NodeLocator,
STRING_CODE, reflabel,
STRING_CODE, task->filename(),
INTEGER_CODE, task->line_no(),
NULL);
}
}
#endif
}

View File

@@ -0,0 +1,27 @@
/* $XConsortium: LcfTask.h /main/2 1996/07/18 16:46:47 drk $ */
#ifndef LCF_TASK_H
#define LCF_TASK_H
#include "Task.h"
class NodeTask;
class LcfTask : public ComplexTask{
friend class NodeTask;
public:
LcfTask( NodeTask *f_parent , const Token &t );
void markup(const Token& t);
protected:
void reset();
void write_record();
// void setNode(NodeTask *n) { f_node = n; }
private:
NodeTask *f_node;
int f_base;
};
#endif /* LcfTask.h */

View File

@@ -0,0 +1,32 @@
/* $XConsortium: Literal.h /main/2 1996/07/18 16:47:09 drk $ */
#ifndef __Lithdr__
#define __Lithdr__
#include "BaseDataCollect.h"
#include "FlexBuffer.h"
class Token;
class Literal : public BaseData {
friend class FirstOf;
friend class OL_Data;
friend class Concat;
protected:
Literal( const Token &t, const char *str, ActionType mode );
};
inline
Literal::Literal( const Token &t,
const char *str,
ActionType mode ):BaseData(t, mode)
{
data_complete = 1;
if ( str ) {
ValueBuffer.writeStr( str );
}
}
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,344 @@
/* $XConsortium: NCFGen.C /main/9 1996/08/21 15:47:02 drk $ */
#include <stdio.h>
#include <stdlib.h>
#if !defined(__uxp__) && !defined(USL)
#include <strings.h>
#endif
#include <strstream.h>
#include "Exceptions.hh"
#include "DataBase.h"
#include "BookCaseDB.h"
#include "Task.h"
#include "Handler.h"
#include "StyleValidate.h"
#include "Token.h"
/* MMDB interfaces */
#include "oliasdb/mmdb.h"
#include "oliasdb/asciiIn_filters.h"
#include "oliasdb/olias_consts.h"
#include "oliasdb/stylesheet_hd.h"
/* Hash table interfaces */
#include "dti_cc/CC_String.h"
#include "dti_cc/cc_hdict.h"
#include "BTCollectable.h"
#ifdef FISH_DEBUG
#include "dbug.h"
#endif
#define SKIP_CODE -1
static unsigned hash_func(const CC_String &str)
{
return str.hash();
}
//-------------------------------------------------------------------------
static void
writeStyleSheets(BookCaseDB& db)
{
DBTable *out = db.DB::table(DATABASE_STDIO,
STYLESHEET_CODE, BT_NUM_STYLESHEET_FIELDS,
DB::CREATE);
DBTable *in = db.table(BookCaseDB::StyleSheet, DB::READ);
DBCursor cursor(*in);
const char *name;
const char *online;
int len_o;
const char *print;
int len_p;
int statusO = 0;
int statusP = 0;
while(cursor.next(STRING_CODE, &name,
-STRING_CODE, &online, &len_o,
-STRING_CODE, &print, &len_p,
NULL)){
if( statusO=validate_stylesheet( online, len_o, ONLINE )){
Token::signalError(Token::User, Token::Continuable, 0, 0,
"Online style sheet for `%s' is invalid.", name);
}
if( statusP=validate_stylesheet( print, len_p, PRINT )){
Token::signalError(Token::User, Token::Continuable, 0, 0,
"Print style sheet for `%s' is invalid.", name);
}
if ( statusO || statusP ) {
throw(Unexpected("Style sheet validation failed\n"));
}
out->insert(STRING_CODE, name,
-STRING_CODE, online, len_o,
-STRING_CODE, print, len_p,
NULL);
}
delete out;
}
//-------------------------------------------------------------------------
static void
buildNCF(BookCaseDB& db, const char *base_name, int compressed)
{
DBTable *ncf = db.DB::table(DATABASE_STDIO,
OLIAS_NODE_CODE, BT_NUM_OLIAS_NODE_FIELDS,
DB::CREATE);
DBTable *nodeMeta = db.table(BookCaseDB::NodeMeta, DB::READ);
DBCursor cursor(*nodeMeta);
const char *bookLocator;
const char *nodeLocator;
const char *filename;
int line_num;
const char *title;
const char *stitle;
const char *style;
int dupID = 0;
OLIAS_DB mmdb_handle;
info_lib *mmdb =
mmdb_handle.openInfoLib(getenv("MMDB_PATH"), (char*)base_name);
info_base *base_ptr = mmdb->get_info_base(base_name);
const int BUFSIZE=30;
hashTable<CC_String,BTCollectable> node_dict(hash_func); // Hash table...
if ( compressed ) {
// 30 will be enough for now.
const int COMPRESSED_AGENT_SIZE=30;
char comp_agent[COMPRESSED_AGENT_SIZE];
// was bzero before, but unable to find bzero on solaris
for ( int i = 0; i < COMPRESSED_AGENT_SIZE; i++ ) {
comp_agent[i] = 0;
}
ostrstream str_buf( comp_agent,COMPRESSED_AGENT_SIZE);
handler *x = (base_ptr->get_obj_dict()).get_handler(
form("%s.%s", base_name, "sgml.dict"));
x->its_oid().asciiOut(str_buf);
while(cursor.next(STRING_CODE, &bookLocator,
STRING_CODE, &nodeLocator,
STRING_CODE, &filename,
INTEGER_CODE, &line_num,
SKIP_CODE, /* TOC num */
STRING_CODE, &title,
STRING_CODE, &stitle,
STRING_CODE, &style,
NULL)){
CC_String *key = new CC_String(nodeLocator);
// check for duplicate node locator
BTCollectable *val = node_dict.findValue( key );
if ( val ) {
delete key;
dupID++;
cerr << "(ERROR) Duplicate section ID = " << nodeLocator << endl
<< " found in file = " << filename << endl
<< " at line = " << line_num << endl
<< " is in conflict with " << endl
<< " section ID = " << nodeLocator << endl
<< " in file = " << val->filename() << endl
<< " at line = " << val->linenum() << "\n\n";
}
else {
BTCollectable *val = new BTCollectable( filename,
line_num,
bookLocator);
node_dict.insertKeyAndValue( key, val );
}
stylesheet_smart_ptr sheet(base_ptr, style);
char oid_buf[BUFSIZE];
ostrstream strout(oid_buf,BUFSIZE,ios::out);
sheet.its_oid().asciiOut(strout);
oid_buf[strout.pcount()] = NULL;
ncf->insert(STRING_CODE, nodeLocator,
STRING_CODE, title,
STRING_CODE, stitle,
COMPRESSED_STRING_CODE, comp_agent, "",
STRING_CODE, bookLocator,
OID_CODE, "0.0", /* pointer to Book/CCF/DOC object */
OID_CODE, oid_buf,
NULL);
}
}
else {
while(cursor.next(STRING_CODE, &bookLocator,
STRING_CODE, &nodeLocator,
STRING_CODE, &filename,
INTEGER_CODE, &line_num,
SKIP_CODE, /* TOC num */
STRING_CODE, &title,
STRING_CODE, &stitle,
STRING_CODE, &style,
NULL)){
CC_String *key = new CC_String(nodeLocator);
// check for duplicate node locator
BTCollectable *val = node_dict.findValue( key );
if ( val ) {
delete key;
dupID++;
cerr << "(ERROR) Duplicate section ID = " << nodeLocator << endl
<< " found in file = " << filename << endl
<< " at line = " << line_num << endl
<< " is in conflict with " << endl
<< " section ID = " << nodeLocator << endl
<< " in file = " << val->filename() << endl
<< " at line = " << val->linenum() << "\n\n";
}
else {
BTCollectable *val = new BTCollectable( filename,
line_num,
bookLocator );
node_dict.insertKeyAndValue( key , val );
}
stylesheet_smart_ptr sheet(base_ptr, style);
char oid_buf[BUFSIZE];
ostrstream strout(oid_buf,BUFSIZE,ios::out);
sheet.its_oid().asciiOut(strout);
oid_buf[strout.pcount()] = NULL;
ncf->insert(STRING_CODE, nodeLocator,
STRING_CODE, title,
STRING_CODE, stitle,
STRING_CODE, "",
STRING_CODE, bookLocator,
OID_CODE, "0.0", /* pointer to Book/CCF/DOC object */
OID_CODE, oid_buf,
NULL);
}
}
if ( dupID ) {
throw(Unexpected(
form("Number of duplicated section ID found = %d", dupID)
));
}
delete ncf;
node_dict.clearAndDestroy();
}
//-------------------------------------------------------------------------
static void
usage(const char *progname)
{
fprintf(stderr, "usage: %s [-compressed] [-load-style] <bookcasename> <bookcasedir>\n", progname);
exit(1);
}
//-------------------------------------------------------------------------
main(int argc, char **argv)
{
INIT_EXCEPTIONS();
set_new_handler( FreeStoreException );
int ret = 1;
const char *progname = argv[0];
int compressed = 0;
int load_style_only = 0;
#ifdef FISH_DEBUG
DBUG_PROCESS(argv[0]);
if(getenv("FISH_DBUG")) DBUG_PUSH(getenv("FISH_DBUG"));
#endif
argv++;
argc--;
while(argc > 0 && argv[0][0] == '-'){
const char *opt = argv[0];
argv++;
argc--;
if(strcmp(opt, "-compressed") == 0){
compressed = 1;
}
else if ( strcmp(opt, "-load-style") == 0 ) {
load_style_only = 1;
}
else {
usage(progname);
}
}
if(argc == 2){
const char *base_name = argv[0];
const char *bookcaseDir = argv[1];
try{
BookCaseDB db(bookcaseDir);
if ( load_style_only ) {
writeStyleSheets(db);
}
else {
buildNCF(db, base_name, compressed);
}
ret = 0;
}
catch(PosixError&, pe){
fprintf(stderr, "%s: error on %s: %s\n",
progname, bookcaseDir, pe.msg());
}
catch(Unexpected&, pe) {
fprintf(stderr, "(ERROR) %s\n\n", pe.msg() );
}
catch(mmdbException&, e) {
cerr << e;
}
catch_any() {
fprintf(stderr, "*** Internal Error ***: unexpected exception\n");
abort();
}end_try;
}else{
usage(progname);
}
return ret;
}

View File

@@ -0,0 +1,436 @@
/* $XConsortium: NodeData.C /main/4 1996/09/24 16:55:25 cde-hal $
*
* (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.
*/
/* exported interfaces... */
#include "NodeData.h"
/* imported interfaces... */
#include <iostream.h>
#include <stream.h>
#include <stdlib.h>
#include <stdio.h>
#include <assert.h>
#include "Token.h"
#include "FlexBuffer.h"
#include "NodeTask.h"
#include "SearchEng.h"
#include "OLAF.h"
#include "SGMLName.h"
#include "OL-Data.h"
#include "BookTasks.h"
#include "DataBase.h"
#include "BookCaseDB.h"
#include "GraphicsTask.h"
#include "Dispatch.h"
#ifdef UseQSearch
#include "QSearch.h"
#else
#ifdef FULCRUM
#include "Fulcrum.h"
#else
#ifdef DTSEARCH
#include "AusText.h"
#endif
#endif
#endif
// Debugging macro
#ifdef DEBUG
#define DBG(level) if ( dbgLevel >= level)
#else
#define DBG(level) if (0)
#endif
static int dbgLevel=-1;
extern void ReplaceIdIdRef( NodeData *, char *, int );
//----------------------------------------------------------------
void
replace_entity( FlexBuffer *buf , const char *str)
{
int len = strlen( str );
int i;
const char *ptr;
for ( i = 0, ptr = str;
i < len;
i++, ptr++ ) {
switch ( *ptr )
{
case '\n':
buf->writeStr("&lnfeed;");
break;
case '&':
buf->writeStr("&amp;");
break;
case '\240':
buf->writeStr("&nbsp;");
break;
case '<':
buf->writeStr("&lt;");
break;
default:
buf->put( *ptr );
}
}
}
//--------------------------------------------------------------------
void
NodeData::write_start_tag( const Token &t, FlexBuffer *buffer )
{
const AttributeRec *LinkRec = t.LookupAttr( OLAF::OL_idref );
const AttributeRec *IdRec = t.LookupAttr( OLAF::OL_id );
const AttributeRec *XRefRec = t.LookupAttr( OLAF::OL_XRef );
const AttributeRec *GraphicExist = t.LookupAttr( OLAF::OL_Graphic );
if ( t.LookupAttr( OLAF::OL_Ignore ) ) {
if ( IdRec ) {
buffer->writeStr("<%BOGUS><#><#OL-ID>");
char *str = form("%d", seq_no );
buffer->writeStr( str );
buffer->writeStr( "</#OL-ID><#LAST>0</#LAST></#></%BOGUS>" );
seq_no++;
addSubTask( new OL_Data ( t, OLAF::OL_id, REMOVE_SPACES ) );
return;
}
}
if ( Dispatch::OutsideIgnoreScope() ) {
/* write the start tag */
char *str = form("<%s>", t.giName() );
buffer->writeStr( str );
/* write out all the attribute name and value */
// if ( t.GetFirstAttr() || LinkRec || IdRec || GraphicExist ) {
// Always output the attribute tag container because we'll always have
// position data.
buffer->writeStr ( "<#>" );
// }
for ( const AttributeRec *a = t.GetFirstAttr();
a;
a = t.GetNextAttr(a) ) {
/* write the start tag */
const char *attName = SGMLName::lookup( a->getAttrName() );
/* write the attribute start tag */
char *start_tag = form("<%s>",attName);
buffer->writeStr( start_tag );
/* write the attribute value */
replace_entity ( buffer, a->getAttrValueString() );
/* write the attribute end tag */
char *end_tag = form("</%s>", attName );
buffer->writeStr( end_tag );
}
if ( LinkRec ) {
char *str = form ( "<#OL-IDREF>%d</#OL-IDREF>", seq_no );
buffer->writeStr(str);
seq_no++;
addSubTask( new OL_Data ( t, OLAF::OL_idref, REMOVE_SPACES ) );
}
if ( GraphicExist ) {
char *str = form("<#GRAPHIC>%d</#GRAPHIC>", seq_no );
buffer->writeStr( str );
seq_no++;
current_graphics_id = new OL_Data(t, OLAF::OL_id, GENERATE_ID);
addSubTask( current_graphics_id );
}
if ( IdRec ) {
char *str = form("<#OL-ID>%d</#OL-ID>", seq_no );
buffer->writeStr( str );
seq_no++;
addSubTask( new OL_Data ( t, OLAF::OL_id, REMOVE_SPACES ) );
}
if ( XRefRec ) {
char *str = form("<#OL-XREF>%d</#OL-XREF>", seq_no );
buffer->writeStr( str );
seq_no++;
addSubTask( new OL_Data ( t, OLAF::OL_XRef, REMOVE_SPACES ) );
}
if ( GraphicExist ) {
/*
* delay the writing of </#> until potential search terms are generated
*/
return;
}
// if ( t.GetFirstAttr() || LinkRec || IdRec ) {
buffer->writeStr("<#LAST>0</#LAST></#>");
// }
}
}
//---------------------------------------------------------------------
static void
write_end_tag( const Token &t, FlexBuffer *buffer)
{
if ( Dispatch::OutsideIgnoreScope() ) {
char *str = form("</%s>", t.giName() );
buffer->writeStr( str );
}
}
//---------------------------------------------------------------------
NodeData::NodeData( NodeTask *parent, const Token &t)
{
char *dbgStr;
dbgStr = getenv ( "OL_DEBUG");
dbgLevel = ( dbgStr ? atoi(dbgStr) : 0 );
f_node = parent;
f_base = t.level();
CollectObject = -1;
NodeBuffer = new FlexBuffer();
DbBuffer = new FlexBuffer();
seq_no = 0;
current_graphics_id = NULL;
/* f_search is managed explicitly */
/* This probably has to be #ifdef FULCRUM */
#ifdef FULCRUM
f_search = new Fulcrum ( this, t );
#else
#ifdef UseQSearch
f_search = new QSearch ( this, t );
#else
#ifdef DTSEARCH
f_search = new AusText( this, t );
#endif
#endif
#endif
write_start_tag ( t, NodeBuffer );
}
//---------------------------------------------------------------------
NodeData::~NodeData()
{
assert(f_base < 0); /* for debugging NodeTask/NodeData interaction */
reset();
delete NodeBuffer;
delete DbBuffer;
}
//---------------------------------------------------------------------
void
NodeData::markup( const Token &t )
{
if ( f_base > 0 ) {
ComplexTask::markup(t);
if ( f_search ) {
f_search->markup( t );
}
if ( t.type() == START ) {
if ( CollectObject >= 0 ) {
write_start_tag ( t, internal_buffer );
}
else {
if ( t.LookupAttr( OLAF::OL_Graphic ) ) {
CollectObject = t.level();
internal_buffer = new FlexBuffer();
assert(internal_buffer != NULL);
}
write_start_tag ( t, NodeBuffer );
}
}
else if ( t.type() == END ) {
if ( Dispatch::OutsideIgnoreScope() ) {
if ( CollectObject >= 0 ) {
if ( t.level() == CollectObject ) {
if ( f_search->HasSearchTerms() ) {
FlexBuffer *buffer = (FlexBuffer *)
f_search->DumpSearchTerms();
/*
* write out the searchable terms in attribute format
*/
NodeBuffer->writeStr("<#TERMS>");
NodeBuffer->write ( buffer->GetBuffer(),
buffer->GetSize() );
NodeBuffer->writeStr("</#TERMS>");
}
NodeBuffer->writeStr("<#LAST>0</#LAST></#>");
/* write out all the other data/tags that are found within the
* graphic tags
*/
*NodeBuffer = *NodeBuffer + *internal_buffer;
write_end_tag ( t, NodeBuffer );
current_graphics_id = NULL;
CollectObject = -1;
delete internal_buffer;
}
else {
write_end_tag ( t, internal_buffer );
}
}
else { /* ie not collecting oject */
write_end_tag( t , NodeBuffer);
}
if ( f_base == t.level() ) {
write_record();
reset();
}
}
} /* if ( t.type() == END ) */
} /* if ( f_base > 0 ) */
}
//---------------------------------------------------------------------
void
NodeData::reset()
{
f_base = -1;
NodeBuffer->reset();
DbBuffer->reset();
if ( f_search ) {
delete f_search;
f_search = NULL;
}
ComplexTask::removeAllSubTasks();
}
//---------------------------------------------------------------------
void
NodeData::data ( const char *str, size_t t )
{
if ( f_base > 0 ) {
ComplexTask::data( str, t );
if ( f_search ) {
f_search->data( str, t );
}
if ( Dispatch::OutsideIgnoreScope() ) {
if (CollectObject < 0) {
replace_entity( NodeBuffer, str );
}
else {
replace_entity( internal_buffer, str );
}
}
}
}
//---------------------------------------------------------------------
void
NodeData::write_record()
{
DBG(20) printf("Node Before replacement is %s\n", NodeBuffer->GetBuffer());
ReplaceIdIdRef( this, (char *)NodeBuffer->GetBuffer(),
NodeBuffer->GetSize() );
/*
* write out the whole record
*/
const char *TocLocator = f_node->book()->locator();
const char *NodeLocator = f_node->locator();
DBTable *tbl = f_node->book()->bookcase()->table(BookCaseDB::NodeSGML);
tbl->insert(STRING_CODE, TocLocator,
STRING_CODE, NodeLocator,
-STRING_CODE, DbBuffer->GetBuffer(), DbBuffer->GetSize(),
NULL);
/*
DBTable *ltab = f_node->book()->bookcase()->table(BookCaseDB::Link);
for ( int i = 0; i < ComplexTask::used; i++ ) {
OL_Data *Task = ( OL_Data * )ComplexTask::subtask(i);
ltab->insert( STRING_CODE, NodeLocator,
INTEGER_CODE, StartingSeqNo + i,
STRING_CODE, Task->content(),
NULL
);
}
*/
}
//---------------------------------------------------------------------
const char *
NodeData::graphics_id()
{
if ( !current_graphics_id ) {
throw(Unexpected("Graphics ID not available"));
}
if ( current_graphics_id->ContentIsEmpty() ) {
throw(Unexpected("An ID could not be found for the graphical object"));
}
return ( current_graphics_id->content() );
}

View File

@@ -0,0 +1,46 @@
/* $XConsortium: NodeData.h /main/2 1996/07/18 16:47:34 drk $ */
// NodeData.h
#ifndef NODEDATA_HEADER
#define NODEDATA_HEADER
#include "Task.h"
class Token;
class FlexBuffer;
class NodeTask;
class SearchEngine;
class OL_Data;
class NodeData : public ComplexTask {
friend int nodedatalex();
public:
NodeData( NodeTask *, const Token & );
~NodeData();
void markup( const Token & );
void data(const char *, size_t );
NodeTask *node() const { return f_node; }
const char *graphics_id();
protected:
NodeTask *f_node;
FlexBuffer *NodeBuffer;
int CollectObject;
int f_base;
SearchEngine *f_search;
void write_record();
void reset();
private:
int seq_no;
FlexBuffer *DbBuffer;
FlexBuffer *internal_buffer;
OL_Data *current_graphics_id;
void write_start_tag( const Token &t, FlexBuffer *buf );
};
#endif

View File

@@ -0,0 +1,111 @@
/* $XConsortium: NodeParser.C /main/6 1996/08/21 15:47:06 drk $ */
#include <stdio.h>
#include "dti_cc/CC_Stack.h"
#include "Exceptions.hh"
#include "DataBase.h"
#include "Dispatch.h"
#include "SearchPath.h"
#include "Task.h"
#include "BookTasks.h"
#include "OLAF.h"
#ifdef FISH_DEBUG
#include "dbug.h" /* Fred Fish's dbug.h */
#endif
#include "Handler.h"
//---------------------------------------------------------------------
int main(int argc, char **argv)
{
INIT_EXCEPTIONS();
/* can't seem to get C++ initialization stuff to do this... */
OLAF::init();
set_new_handler( FreeStoreException );
int ret = 1;
#ifdef FISH_DEBUG
DBUG_PROCESS(argv[0]);
if(getenv("FISH_DBUG")) DBUG_PUSH(getenv("FISH_DBUG"));
#endif
if(argc == 4){
const char *toc_option = argv[1];
const char *infolib = argv[2];
const char *srcdir = argv[3];
Dispatch::tmpdir = infolib;
Dispatch::srcdir = srcdir;
if ( !strcmp(toc_option, "toc") ) {
Dispatch::tocgen_only = 1;
}
else if ( !strcmp(toc_option, "all") ) {
Dispatch::tocgen_only = 0;
}
else {
fprintf(stderr, "usage: NodeParse [ tocgen_only | all ] <database-dir> <source-dir>\n");
exit(1);
}
/*
* Add the . directory as a default if the file is not found in scrdir
*/
SearchPath *sptable = new SearchPath( srcdir, ".", 0 );
Dispatch::search_path_table = sptable;
Task *t = new BookCaseTask( infolib );
Stack<int> *istack = new Stack<int>;
Dispatch::setRoot(t, istack);
try{
extern int yylex();
yylex();
ret = 0;
}
catch(Unexpected&, u)
{
try {
Dispatch::tok->reportError(Token::User, Token::Fatal,
"markup error: %s", u.msg());
}
catch(ErrorReported&, e)
{
if ( e.f_severity == Token::Fatal ) {
exit(1);
}
}end_try;
}
catch(PosixError&, pe)
{
fprintf(stderr, "(ERROR) %s\n", pe.msg() );
exit(1);
}
catch(ErrorReported&, e)
{
if ( e.f_severity == Token::Fatal ) {
exit(1);
}
}end_try;
}else{
fprintf(stderr, "usage: NodeParse [ tocgen_only | all ] <database-dir> <source-dir>\n");
}
return ret;
}

View File

@@ -0,0 +1,471 @@
/* $XConsortium: NodeTask.C /main/6 1996/10/26 18:18:31 cde-hal $ */
/* $Id */
#include <stream.h>
/* exported interfaces... */
#include "NodeTask.h"
/* imported interfaces... */
#include <assert.h>
#include <assert.h>
#include <ctype.h>
#include "Dispatch.h"
#include "Token.h"
#include "LcfTask.h"
#include "OLAF.h"
#include "BookTasks.h"
#include "BookCaseDB.h"
#include "DataBase.h"
#include "OL-Data.h"
#include "NodeData.h"
#include "StyleTask.h"
#ifdef FISH_DEBUG
#include "dbug.h" /* Fred Fish's dbug.h */
#endif
#define NUM_FIELDS 5
#define NULLTOEMPTY(x) ((x) ? (x) : "")
static int findDigits( int num )
{
char str[NUM_FIELDS+1];
sprintf( str, "%d", num );
return( strlen(str) );
}
//--------------------------------------------------------------------
NodeTask::NodeTask(BookTask *book, NodeTask *parent)
{
f_book = book;
f_parent = parent;
f_base = -1;
section_element_name = NULL;
ord = 1;
f_title = NULL;
f_shortTitle = NULL;
f_locator = NULL;
/* LCF task is managed explicitly instead of being pushed on the ComplexTask
* list. It is to ensure that f_locator is available whenever f_lcf needs
* it.
*/
f_lcf = NULL;
subnode_pending = 0;
f_subnode = NULL;
f_data = NULL;
f_style = NULL;
}
//--------------------------------------------------------------------
NodeTask::~NodeTask()
{
KILLSUBTASK(f_title);
KILLSUBTASK(f_shortTitle);
KILLSUBTASK(f_locator);
if ( f_lcf ) {
delete f_lcf;
f_lcf = 0;
}
ComplexTask::removeAllSubTasks();
}
int NodeTask::checkNodeAF(const Token& t)
{
int ret = 0;
if(t.LookupAttr( OLAF::OL_Section )
|| t.LookupAttr( OLAF::OL_ToC ) ){
#ifdef FISH_DEBUG
DBUG_PRINT("NodeTask", ("%lx <SECTION> found", this));
#endif
ret = 1;
if(f_base <= 0){ /* are we "idle"? */
f_base = t.level();
section_element_name = strdup(t.giName()); /*@# could be NULL! */
if ( !Dispatch::RunTocGenOnly() ) {
f_lcf = new LcfTask( this , t );
}
/*
* first time we see OL-ID="...", spawn an OL_Data to collect the id
*/
if(f_base > 0 && f_locator == NULL
&& t.LookupAttr(OLAF::OL_id) ){
f_locator = new OL_Data(t, OLAF::OL_id, REMOVE_SPACES);
if ( f_locator->DataWillBeAvailable() ) {
addSubTask( f_locator );
}
else {
delete f_locator;
f_locator = NULL;
}
}
if ( t.LookupAttr( OLAF::OL_Title ) && f_title == NULL ) {
f_title = new OL_Data(t, OLAF::OL_Title, IGNORE_ON );
if ( f_title->DataWillBeAvailable() ) {
addSubTask( f_title );
}
else {
delete f_title;
f_title = 0;
}
}
if ( !Dispatch::RunTocGenOnly() ) {
addSubTask ( f_data = new NodeData ( this, t ) );
}
}else{ /* not idle... must be in the middle of a node */
if(!f_subnode){
f_subnode = new NodeTask(f_book, this);
#ifdef FISH_DEBUG
DBUG_PRINT("NodeTask", ("%lx spawned subnode %lx\n",
this, f_subnode));
#endif
}
subnode_pending = 1;
f_subnode->markup(t);
}
}
return ret;
}
//--------------------------------------------------------------------
void NodeTask::markup(const Token& t)
{
if(subnode_pending){
f_subnode->markup(t);
}else{
ComplexTask::markup(t);
if(t.type() == START){
/*
* Process Node element start tags...
*/
if(checkNodeAF(t)){
/* work done in above routine */
}
/*
* Process Node title start tags...
*/
else {
if ( t.LookupAttr( OLAF::OL_ShortTitle ) ) {
if(f_base > 0 && f_shortTitle == NULL){
f_shortTitle = new OL_Data(t, OLAF::OL_ShortTitle, IGNORE_ON );
if ( !f_shortTitle->DataWillBeAvailable() ) {
delete f_shortTitle;
f_shortTitle = 0;
}
else {
addSubTask(f_shortTitle);
}
}
}
if ( t.LookupAttr( OLAF::OL_Title ) ) {
/* only grab the first title in a node */
if(f_base > 0 && f_title == NULL){
f_title = new OL_Data(t, OLAF::OL_Title, IGNORE_ON );
if ( !f_title->DataWillBeAvailable() ) {
delete f_title;
f_title = 0;
}
else {
addSubTask(f_title);
}
}
}
}
if(f_base >= 0 && !f_style && t.LookupAttr(OLAF::OL_style)
&& !subnode_pending ){
OL_Data *tmp_style = new OL_Data(t, OLAF::OL_style, IGNORE_ON);
if ( tmp_style->DataWillBeAvailable() ) {
f_style = tmp_style;
addSubTask(f_style);
}
else {
delete tmp_style;
}
}
/*
* first time we see OL-ID="...", spawn an OL_Data to collect the id
*/
if(f_base > 0 && f_locator == NULL
&& t.LookupAttr( OLAF::OL_id ) && !subnode_pending ){
f_locator = new OL_Data(t, OLAF::OL_id, REMOVE_SPACES);
if ( f_locator->DataWillBeAvailable() ) {
addSubTask( f_locator );
}
else {
delete f_locator;
f_locator = NULL;
}
}
}
/*
* Let LCF task do its thing
*/
if ( f_base > 0 && !subnode_pending && !Dispatch::RunTocGenOnly() ) {
f_lcf->markup(t);
}
/*
* End Tags... track nesting level, ...
*/
if(t.type() == END){
if(f_base > 0){
if(t.level() == f_base){ /* found end of node...
* write out node meta data */
write_record();
reset();
if(f_parent){
f_parent->endSubNode(t);
}
}
}
}
}
}
void NodeTask::endSubNode(const Token& t)
{
// f_lcf->setNode(this);
subnode_pending = 0;
markup(t);
}
int NodeTask::formatOrd(char * buf, int max)
{
int ret;
int ord_len = findDigits( ord );
if ( ord_len > NUM_FIELDS ) {
throw(Unexpected(form("No. of sections = %d have exceeded the maximum number of sections allowed at one level\n", ord )));
}
if(f_parent == NULL){
int buflen = strlen(buf);
assert( buflen + NUM_FIELDS < max );
sprintf(buf, "%05d", ord); /* we assume max is
* big enough to format one int
*/
ret = buflen + NUM_FIELDS;
}else{
ret = f_parent->formatOrd(buf, max);
int buflen = ret;
assert ( buflen + NUM_FIELDS + 1< max );
sprintf(buf + buflen, ".%05d", ord);
ret = buflen + NUM_FIELDS + 1;
}
return ret;
}
void NodeTask::write_record()
{
if(f_title){
const char *title = f_title->content();
const char *stitle = title;
char num[1024]; num[0]='\0';
const char *style = styleName();
if(f_shortTitle){
stitle = f_shortTitle->content();
}
formatOrd(num, sizeof(num));
#ifdef FISH_DEBUG
DBUG_PRINT("NodeTask", ("%lx loc=%s ord=%s title=`%s'\n",
this, locator(), num, title));
#endif
DBTable *tbl = f_book->bookcase()->table(BookCaseDB::NodeMeta);
tbl->insert(STRING_CODE, f_book->locator(),
STRING_CODE, locator(),
STRING_CODE, f_locator->filename(),
INTEGER_CODE, f_locator->line_no(),
STRING_CODE, num,
STRING_CODE, title,
STRING_CODE, stitle,
STRING_CODE, style,
NULL);
}else{
throw(Unexpected(form(
"No section title available for the section element [%s]\n",
NULLTOEMPTY(section_element_name))));
}
}
void NodeTask::reset()
{
f_base = -1;
delete section_element_name;
ord++;
KILLSUBTASK(f_title);
KILLSUBTASK(f_locator);
KILLSUBTASK(f_shortTitle);
KILLSUBTASK(f_data);
KILLSUBTASK(f_style);
if ( f_lcf ) {
delete f_lcf;
f_lcf = 0;
}
if(f_subnode) f_subnode->ord = 1;
}
void NodeTask::data( const char *str, size_t sz)
{
if(subnode_pending){
f_subnode->data(str, sz);
}else{
ComplexTask::data(str, sz);
if ( f_base > 0 && !Dispatch::RunTocGenOnly() ) {
f_lcf->data(str, sz);
}
}
}
const char *NodeTask::locator()
{
if(!f_locator) throw(Unexpected(form(
"No ID available for the section element [%s]\n",
NULLTOEMPTY(section_element_name)
)));
if ( !f_locator->DataIsComplete() ) {
throw(Unexpected(form(
"ID collection is not done yet for the section element [%s]\n",
NULLTOEMPTY(section_element_name)
)));
}
return ( f_locator->content() );
}
const char *
NodeTask::styleName()
{
if ( Dispatch::RunTocGenOnly() ) {
return("");
}
const char *ret;
if(f_style){
ret = f_style->content();
/* This is a hack to get the name of the style sheet right
* Because sgmls can change the case sensitivity of the actual
* style sheet name, I am going to use the case sensitive version
* of the string first, if it doesn't exist, I will try the case
* insensitive one, i.e. all uppercase
*/
if(f_book->bookcase()->styleTask()->exist(ret)){
#ifdef FISH_DEBUG
DBUG_PRINT("Style", ("node style is: %s", ret));
#endif
}
else {
char *local_str = (char *)ret;
for ( char *ptr = local_str; *ptr != '\0'; ptr++ ) {
*ptr = toupper( *ptr );
}
/* try again */
if ( f_book->bookcase()->styleTask()->exist(ret) ) {
#ifdef FISH_DEBUG
DBUG_PRINT("Style", ("node style is: %s", ret));
#endif
}
else{
Token::signalError(Token::User, Token::Continuable,
f_style->filename(), f_style->line_no(),
form("Style `%s' not available\n", ret) );
if ( f_parent ) { ret = f_parent->styleName(); }
else { ret = f_book->styleName(); }
}
}
}
else{
if ( f_parent ) { ret = f_parent->styleName(); }
else { ret = f_book->styleName(); }
}
return ret;
}
//------------------------------------------------------------
const char *
NodeTask::title()
{
if (!f_title) {
throw(Unexpected(
form(
"No section title available for the section element [%s]\n",
NULLTOEMPTY(section_element_name )
)
));
}
return( f_title->content() );
}

View File

@@ -0,0 +1,77 @@
/* $XConsortium: NodeTask.h /main/3 1996/07/18 15:16:53 drk $ */
#ifndef __NodeTask_h
#define __NodeTask_h
#include "Task.h"
class LcfTask;
class SearchStorage;
class BookCaseTask;
class BookTask;
class OL_Data;
class NodeData;
class NodeTask : public ComplexTask{
/*
* The NodeTask builds the NodeMeta table:
*
* Table name: NodeMeta
* Fields:
* STRING node contents ("balanced tag" string) -- "" on first pass
* STRING book/toc locator
* STRING node locator
* STRING node "ordinal", e.g. 2.3.1
* STRING node title
* STRING node stitle
*/
public:
NodeTask(BookTask *book, class NodeTask *parent);
~NodeTask();
void markup(const Token& t);
void data( const char *, size_t);
const char *locator(); /* throw(Unexpected) if no locator yet */
BookTask *book() { return ( f_book ); }
const char *styleName();
const char *title(); /* throw(Unexpected) if no title available yet */
int start_node_level() const { return(f_base); }
protected:
void write_record();
void reset();
void endSubNode(const Token& t);
int checkNodeAF(const Token& t);
int formatOrd(char * buf, int max); /* for TOC gen, debugging */
private:
int f_base;
char *section_element_name;
int ord; /* for TOC gen, debugging */
BookTask *f_book;
LcfTask *f_lcf;
OL_Data *f_shortTitle;
OL_Data *f_title;
OL_Data *f_locator;
int subnode_pending;
NodeTask *f_subnode;
NodeTask *f_parent;
NodeData *f_data;
OL_Data *f_style;
};
#endif /* __NodeTask_h */

View File

@@ -0,0 +1,248 @@
/* $XConsortium: OL-Data.C /main/4 1996/08/21 15:47:10 drk $
*
* (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.
*/
/* exported interfaces */
#include "OL-Data.h"
/* imported interfaces */
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <misc/unique_id.h>
#include "Expression.h"
#include "AttributeRec.h"
#include "OLAF.h"
#include "SGMLName.h"
#include "Token.h"
#include "Task.h"
#include "Dispatch.h"
#include "SGMLDefn.h"
#include "AttributeData.h"
#include "Content.h"
#include "FirstOf.h"
#include "GenericId.h"
#include "Literal.h"
#include "ConcatTask.h"
// Debugging macro
#ifdef DEBUG
#define DBG(level) if ( dbgLevel >= level)
#else
#define DBG(level) if (0)
#endif
static int dbgLevel=-1;
//---------------------------------------------------------------------------
static char *
FilteredSpaces( const char *str )
{
char *head;
char *tail = (char *)str + strlen( str ) - 1;
char *ptr = (char *)str;
while (1) {
if ( *ptr != ' ' && *ptr != '\n' && *ptr != '\t' ) {
head = ptr;
break;
}
else {
ptr++;
}
}
while (1) {
if ( *tail != ' ' && *tail != '\n' && *tail != '\t' ) {
*(tail + 1) = '\0';
break;
}
else { tail--; }
}
return ( head );
}
//-------------------------------------------------------------------------
OL_Data::OL_Data( const Token &t,
int DataType,
ActionType mode ):BaseData(t,mode)
{
char *dbgStr;
dbgStr = getenv("OL_DEBUG");
dbgLevel = ( dbgStr ? atoi ( dbgStr ) : 0 );
/* first generate grep all the mode info */
istat = mode & IGNORE_ON;
removeSpaces = mode & REMOVE_SPACES;
f_name = strdup( t.file() );
line_num = t.line();
if ( istat && !Dispatch::OutsideIgnoreScope() ) {
data_avail = 0;
return;
}
const AttributeRec *attRec;
if ( !(attRec = t.LookupAttr( DataType )) ) {
if ( mode & GENERATE_ID ) {
const char *str = unique_id();
ValueBuffer.writeStr( str );
data_avail = 1;
data_complete = 1;
}
else {
/*
* The default rule kicks in, i.e use #CONTENT
*/
addSubTask( new Content( t, mode) );
}
return;
}
tokContent.Parse( ( char *)attRec->getAttrValueString() );
const OL_Expression *eptr = tokContent.exprlist;
assert(eptr != NULL);
switch ( eptr->type() ) {
case REFERENCE:
{
BaseData *sub_data = new AttributeData(t, eptr->name(), mode );
if ( sub_data ) {
if ( data_avail= sub_data->DataWillBeAvailable() ) {
ValueBuffer.write( sub_data->content(),
sub_data->content_size() );
data_complete = 1;
}
delete sub_data;
}
}
break;
case CONTENT:
addSubTask( new Content(t, mode) );
break;
case CONCAT:
addSubTask( new Concat( t,
(ExprList *)eptr->data_list(),
mode) );
break;
case FIRSTOF:
addSubTask( new FirstOf( t,
(ExprList *)eptr->data_list(),
mode) );
break;
case GENERIC_ID:
addSubTask( new GenericId( t,
eptr->name(),
mode) );
break;
case LITERAL:
data_avail = 1;
data_complete = 1;
ValueBuffer.writeStr( ( const char *)eptr->data_list() );
break;
default:
abort();
}
}
//-------------------------------------------------------------------------
void
OL_Data::markup( const Token &t )
{
DBG(80) cerr << "(DEBUG) OL_Data::markup() " << endl;
DBG(80) cerr << " t.giName() = " << t.giName() << endl;
if ( istat && !Dispatch::OutsideIgnoreScope() ) {
return;
}
if ( f_base > 0 ) {
ComplexTask::markup( t );
if ( t.type() == END ) {
if ( f_base == t.level() ) {
data_complete = 1;
for ( int i=0; i < ComplexTask::used; i++ ) {
BaseData *task = ( BaseData *)ComplexTask::subtask(i);
ValueBuffer.write( task->content(), task->content_size() );
}
if ( removeSpaces && ValueBuffer.GetSize() > 0 ) {
const char *filtered_string = FilteredSpaces( ValueBuffer.GetBuffer() );
/* rewrite ValueBuffer with the filtered string */
ValueBuffer.reset();
ValueBuffer.writeStr( filtered_string );
}
DBG(10) printf("Data for <%s> = %s\n", t.giName(),
ValueBuffer.GetBuffer() );
reset();
}
}
} /* if level > 0 */
}
//-------------------------------------------------------------------------
void
OL_Data::data( const char *str, size_t t )
{
if ( istat && !Dispatch::OutsideIgnoreScope() ) {
return;
}
if ( f_base > 0 ) {
ComplexTask::data( str, t );
}
}
//-------------------------------------------------------------------------
void
OL_Data::reset()
{
f_base = -1;
istat = removeSpaces = 0;
removeAllSubTasks();
}

View File

@@ -0,0 +1,64 @@
/* $XConsortium: OL-Data.h /main/2 1996/07/18 16:47:56 drk $ */
#ifndef OL_DATA_H
#define OL_DATA_H
#include <string.h>
#include "ContentType.h"
#include "Token.h"
#include "BaseDataCollect.h"
class OL_Data : public BaseData {
friend class FirstOf;
private:
ContentType tokContent;
char *f_name;
int line_num;
int istat; /* These are status info */
int removeSpaces;
void reset();
protected:
/*
* This constructor is used by the derived class of OL_Data only
*/
OL_Data( const Token &t, ActionType ignore=DEFAULT_ACTION );
public:
/*
* istat is controlled by the invoker to determine if OL_Data should really
* ignore the OLIAS IGNORE attribute. The reason that such action is
* controlled by the invoker of the class is that the corresponding
* behavior of IGNORE is controlled by the invoker, not by the OL_Data class
*/
OL_Data( const Token &t,
int aType,
ActionType mode=DEFAULT_ACTION);
/* no action takes place by default */
~OL_Data() { delete f_name; }
public:
void markup( const Token & );
void data( const char *, size_t );
char *filename() { return ( f_name ); }
int line_no() { return ( line_num ); }
};
inline
OL_Data::OL_Data(const Token &t, ActionType mode):BaseData(t,mode)
{
istat = mode & IGNORE_ON;
removeSpaces = mode & REMOVE_SPACES;
f_name = strdup( t.file() );
line_num = t.line();
}
#endif

View File

@@ -0,0 +1,96 @@
/* $XConsortium: OLAF.C /main/4 1996/09/24 16:55:40 cde-hal $
*
* OLAF -- OLIAS Architectural Forms
*/
#include <assert.h>
#include "OLAF.h"
#include "SGMLName.h"
static int init = OLAF::init();
const int NAMECASE = 1; /* Only one SGML Decl. supported */
int
OLAF::init()
{
static int done = 0;
if(done) return 0;
done = 1;
#define INTERN(n) SGMLName::intern(#n, NAMECASE);
SGMLName::init();
/* The order of calls to SGMLName::intern _MUST_ match the
* enumeration in OLAF.h
*/
INTERN(OLIAS);
INTERN(OLIAS.Value);
INTERN(OLIAS.ID);
INTERN(OLIAS.IDREF);
INTERN(OLIAS.Scope);
INTERN(OLIAS.Style);
INTERN(OLIAS.Choice);
INTERN(OLIAS.TOC);
INTERN(OLIAS.TOCEntry);
INTERN(OLIAS.TOClevel);
INTERN(OLIAS.Section);
INTERN(OLIAS.Title);
INTERN(OLIAS.ShortTitle);
INTERN(OLIAS.Ignore);
INTERN(OLIAS.Graphic);
INTERN(OLIAS.Table);
INTERN(OLIAS.XRefLabel);
INTERN(OLIAS.XRef);
INTERN(Example);
INTERN(Graphic);
INTERN(Index);
INTERN(Table);
INTERN(Title);
INTERN(BookcaseDesc);
INTERN(BookcaseName);
INTERN(BookShortTitle);
INTERN(BookTitle);
INTERN(Book);
INTERN(Bookcase);
INTERN(Style);
INTERN(Stylesheet);
INTERN(BookTab);
INTERN(Feature);
INTERN(Online);
INTERN(Print);
INTERN(Path);
INTERN(Select);
INTERN(FeatureSet);
INTERN(FeatureText);
INTERN(AutoNumber);
INTERN(AutoRef);
INTERN(BookAccess);
assert(SGMLName::intern("Feature", NAMECASE) == OLAF::Feature);
SGMLName::intern("lnfeed");
SGMLName::intern("nbsp");
SGMLName::intern("amp");
SGMLName::intern("lt");
assert(SGMLName::intern("lnfeed") == OLAF::lnfeed);
INTERN(VenCode);
INTERN(Version);
INTERN(Grouping);
INTERN(DemoTerms);
INTERN(DefaultSection);
assert( SGMLName::intern("Grouping", NAMECASE) == OLAF::Grouping );
return 0;
}

View File

@@ -0,0 +1,87 @@
/* $XConsortium: OLAF.h /main/4 1996/09/24 16:55:57 cde-hal $
*
* OLAF -- OLIAS Architectural Forms
*/
#ifndef __OLAF_h
#define __OLAF_h
#include "SGMLName.h"
class OLAF{
public:
/* you can call this whenever you like. Only the first call has
* any effect.
*/
static int init();
enum {
/* Architectural form namespaces... */
OLIAS = SGMLName::qty,
OL_data,
OL_id,
OL_idref,
OL_scope,
OL_style,
OL_Choice,
OL_ToC,
OL_ToCEntry,
OL_TOClevel,
OL_Section,
OL_Title,
OL_ShortTitle,
OL_Ignore,
OL_Graphic,
OL_Table,
OL_XRefLabel,
OL_XRef,
Example,
Graphic,
Index,
Table,
Title,
BcDesc,
BcName,
BkSTitle,
BkTitle,
Book,
Bookcase,
Style,
Stylesheet,
Tab,
Feature,
Online,
Print,
Path,
Select,
FeatureSet,
FeatureText,
AutoNumber,
AutoRef,
BookAccess,
/*
* The following names are for entities , shouldn't be inside OLAF
* namespace. But ...
*/
lnfeed,
nbsp,
amp,
lt,
/*
* The following are attribute names used in the access control element
*/
VenCode,
Version,
Grouping,
DemoTerms,
DefaultSection
};
};
#endif /* __OLAF_h */

View File

@@ -0,0 +1,410 @@
/* $TOG: OL_DataExpr.C /main/4 1997/12/23 11:38:27 bill $ */
#ifndef lint
static char ol_datasccsid[] = "@(#)yaccpar 1.8 (Berkeley) 01/20/90";
#endif
#define ol_dataBYACC 1
#line 2 "OL_DataExpr.y"
#include <stdio.h>
#include "ExprList.h"
#include "Expression.h"
#include "ContentType.h"
extern int ol_datalex();
extern void ol_dataerror( char *str );
extern ContentType *CurrentContentPtr;
#line 14 "OL_DataExpr.y"
typedef union {
int name;
char *string;
OL_Expression *eptr;
} ol_dataSTYPE;
#line 23 "y.tab.c"
#define Reference 257
#define Id 258
#define Literal 259
#define Content 260
#define Concat 261
#define Attr 262
#define FirstOf 263
#define ol_dataERRCODE 256
short ol_datalhs[] = { -1,
0, 2, 2, 1, 1, 1, 1, 1, 1, 1,
};
short ol_datalen[] = { 2,
1, 1, 3, 1, 1, 4, 4, 4, 1, 1,
};
short ol_datadefred[] = { 0,
10, 4, 9, 5, 0, 0, 0, 0, 0, 1,
0, 0, 0, 0, 0, 0, 0, 3, 6, 7,
8,
};
short ol_datadgoto[] = { 8,
9, 10,
};
short ol_datasindex[] = { -255,
0, 0, 0, 0, -40, -30, -27, 0, -29, 0,
-255, -244, -255, -255, -25, -24, -23, 0, 0, 0,
0,
};
short ol_datarindex[] = { 0,
0, 0, 0, 0, 0, 0, 0, 0, 1, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0,
};
short ol_datagindex[] = { 0,
0, -2,
};
#define ol_dataTABLESIZE 42
short ol_datatable[] = { 11,
2, 1, 2, 3, 4, 5, 6, 7, 15, 12,
17, 18, 13, 16, 14, 19, 20, 21, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 2,
};
short ol_datacheck[] = { 40,
0, 257, 258, 259, 260, 261, 262, 263, 11, 40,
13, 14, 40, 258, 44, 41, 41, 41, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, 41,
};
#define ol_dataFINAL 8
#ifndef ol_dataDEBUG
#define ol_dataDEBUG 0
#endif
#define ol_dataMAXTOKEN 263
#if ol_dataDEBUG
char *ol_dataname[] = {
"end-of-file",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,"'('","')'",0,0,"','",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"Reference","Id",
"Literal","Content","Concat","Attr","FirstOf",
};
char *ol_datarule[] = {
"$accept : ValList",
"ValList : ExprList",
"ExprList : Expr",
"ExprList : Expr ',' ExprList",
"Expr : Id",
"Expr : Content",
"Expr : Concat '(' ExprList ')'",
"Expr : Attr '(' Id ')'",
"Expr : FirstOf '(' ExprList ')'",
"Expr : Literal",
"Expr : Reference",
};
#endif
#define ol_dataclearin (ol_datachar=(-1))
#define ol_dataerrok (ol_dataerrflag=0)
#ifdef ol_dataSTACKSIZE
#ifndef ol_dataMAXDEPTH
#define ol_dataMAXDEPTH ol_dataSTACKSIZE
#endif
#else
#ifdef ol_dataMAXDEPTH
#define ol_dataSTACKSIZE ol_dataMAXDEPTH
#else
#define ol_dataSTACKSIZE 500
#define ol_dataMAXDEPTH 500
#endif
#endif
int ol_datadebug;
int ol_datanerrs;
int ol_dataerrflag;
int ol_datachar;
short *ol_datassp;
ol_dataSTYPE *ol_datavsp;
ol_dataSTYPE ol_dataval;
ol_dataSTYPE ol_datalval;
short ol_datass[ol_dataSTACKSIZE];
ol_dataSTYPE ol_datavs[ol_dataSTACKSIZE];
#define ol_datastacksize ol_dataSTACKSIZE
#line 97 "OL_DataExpr.y"
#line 136 "y.tab.c"
#define ol_dataABORT goto ol_dataabort
#define ol_dataACCEPT goto ol_dataaccept
#define ol_dataERROR goto ol_dataerrlab
#if ol_dataDEBUG
#ifndef __cplusplus
extern char *getenv(const char *);
#endif
#endif
int
ol_dataparse()
{
register int ol_datam, ol_datan, ol_datastate;
#if ol_dataDEBUG
register char *ol_datas;
if (ol_datas = getenv("ol_dataDEBUG"))
{
ol_datan = *ol_datas;
if (ol_datan >= '0' && ol_datan <= '9')
ol_datadebug = ol_datan - '0';
}
#endif
ol_datanerrs = 0;
ol_dataerrflag = 0;
ol_datachar = (-1);
ol_datassp = ol_datass;
ol_datavsp = ol_datavs;
*ol_datassp = ol_datastate = 0;
ol_dataloop:
if (ol_datan = ol_datadefred[ol_datastate]) goto ol_datareduce;
if (ol_datachar < 0)
{
if ((ol_datachar = ol_datalex()) < 0) ol_datachar = 0;
#if ol_dataDEBUG
if (ol_datadebug)
{
ol_datas = 0;
if (ol_datachar <= ol_dataMAXTOKEN) ol_datas = ol_dataname[ol_datachar];
if (!ol_datas) ol_datas = "illegal-symbol";
printf("ol_datadebug: state %d, reading %d (%s)\n", ol_datastate,
ol_datachar, ol_datas);
}
#endif
}
if ((ol_datan = ol_datasindex[ol_datastate]) && (ol_datan += ol_datachar) >= 0 &&
ol_datan <= ol_dataTABLESIZE && ol_datacheck[ol_datan] == ol_datachar)
{
#if ol_dataDEBUG
if (ol_datadebug)
printf("ol_datadebug: state %d, shifting to state %d\n",
ol_datastate, ol_datatable[ol_datan]);
#endif
if (ol_datassp >= ol_datass + ol_datastacksize - 1)
{
goto ol_dataoverflow;
}
*++ol_datassp = ol_datastate = ol_datatable[ol_datan];
*++ol_datavsp = ol_datalval;
ol_datachar = (-1);
if (ol_dataerrflag > 0) --ol_dataerrflag;
goto ol_dataloop;
}
if ((ol_datan = ol_datarindex[ol_datastate]) && (ol_datan += ol_datachar) >= 0 &&
ol_datan <= ol_dataTABLESIZE && ol_datacheck[ol_datan] == ol_datachar)
{
ol_datan = ol_datatable[ol_datan];
goto ol_datareduce;
}
if (ol_dataerrflag) goto ol_datainrecovery;
#if 0 // Disable for now
#ifdef lint
goto ol_datanewerror;
#endif
ol_datanewerror:
#endif /* 0 */
ol_dataerror("syntax error");
#if 0 // Disable for now
#ifdef lint
goto ol_dataerrlab;
#endif
ol_dataerrlab:
#endif /* 0 */
++ol_datanerrs;
ol_datainrecovery:
if (ol_dataerrflag < 3)
{
ol_dataerrflag = 3;
for (;;)
{
if ((ol_datan = ol_datasindex[*ol_datassp]) && (ol_datan += ol_dataERRCODE) >= 0 &&
ol_datan <= ol_dataTABLESIZE && ol_datacheck[ol_datan] == ol_dataERRCODE)
{
#if ol_dataDEBUG
if (ol_datadebug)
printf("ol_datadebug: state %d, error recovery shifting\
to state %d\n", *ol_datassp, ol_datatable[ol_datan]);
#endif
if (ol_datassp >= ol_datass + ol_datastacksize - 1)
{
goto ol_dataoverflow;
}
*++ol_datassp = ol_datastate = ol_datatable[ol_datan];
*++ol_datavsp = ol_datalval;
goto ol_dataloop;
}
else
{
#if ol_dataDEBUG
if (ol_datadebug)
printf("ol_datadebug: error recovery discarding state %d\n",
*ol_datassp);
#endif
if (ol_datassp <= ol_datass) goto ol_dataabort;
--ol_datassp;
--ol_datavsp;
}
}
}
else
{
if (ol_datachar == 0) goto ol_dataabort;
#if ol_dataDEBUG
if (ol_datadebug)
{
ol_datas = 0;
if (ol_datachar <= ol_dataMAXTOKEN) ol_datas = ol_dataname[ol_datachar];
if (!ol_datas) ol_datas = "illegal-symbol";
printf("ol_datadebug: state %d, error recovery discards token %d (%s)\n",
ol_datastate, ol_datachar, ol_datas);
}
#endif
ol_datachar = (-1);
goto ol_dataloop;
}
ol_datareduce:
#if ol_dataDEBUG
if (ol_datadebug)
printf("ol_datadebug: state %d, reducing by rule %d (%s)\n",
ol_datastate, ol_datan, ol_datarule[ol_datan]);
#endif
ol_datam = ol_datalen[ol_datan];
ol_dataval = ol_datavsp[1-ol_datam];
switch (ol_datan)
{
case 1:
#line 36 "OL_DataExpr.y"
{
CurrentContentPtr->init(ol_datavsp[0].eptr);
}
break;
case 2:
#line 42 "OL_DataExpr.y"
{
ol_dataval.eptr = ol_datavsp[0].eptr;
}
break;
case 3:
#line 46 "OL_DataExpr.y"
{
ol_datavsp[-2].eptr->next = ol_datavsp[0].eptr;
ol_dataval.eptr = ol_datavsp[-2].eptr;
}
break;
case 4:
#line 53 "OL_DataExpr.y"
{
OL_Expression *expr = new OL_Expression( GENERIC_ID, ol_datavsp[0].name);
ol_dataval.eptr = expr;
}
break;
case 5:
#line 59 "OL_DataExpr.y"
{
OL_Expression *expr = new OL_Expression( CONTENT );
ol_dataval.eptr = expr;
}
break;
case 6:
#line 65 "OL_DataExpr.y"
{
ExprList *elist = new ExprList( ol_datavsp[-1].eptr );
OL_Expression *expr = new OL_Expression( CONCAT, -1, elist);
ol_dataval.eptr = expr;
}
break;
case 7:
#line 71 "OL_DataExpr.y"
{
OL_Expression *expr = new OL_Expression( REFERENCE, ol_datavsp[-1].name);
ol_dataval.eptr = expr;
}
break;
case 8:
#line 76 "OL_DataExpr.y"
{
ExprList *elist = new ExprList ( ol_datavsp[-1].eptr );
OL_Expression *expr = new OL_Expression( FIRSTOF, -1, elist );
ol_dataval.eptr = expr;
}
break;
case 9:
#line 83 "OL_DataExpr.y"
{
OL_Expression *expr = new OL_Expression( LITERAL, -1, ol_datavsp[0].string );
ol_dataval.eptr = expr;
}
break;
case 10:
#line 89 "OL_DataExpr.y"
{
OL_Expression *expr = new OL_Expression( REFERENCE, ol_datavsp[0].name );
ol_dataval.eptr = expr;
}
break;
#line 350 "y.tab.c"
}
ol_datassp -= ol_datam;
ol_datastate = *ol_datassp;
ol_datavsp -= ol_datam;
ol_datam = ol_datalhs[ol_datan];
if (ol_datastate == 0 && ol_datam == 0)
{
#if ol_dataDEBUG
if (ol_datadebug)
printf("ol_datadebug: after reduction, shifting from state 0 to\
state %d\n", ol_dataFINAL);
#endif
ol_datastate = ol_dataFINAL;
*++ol_datassp = ol_dataFINAL;
*++ol_datavsp = ol_dataval;
if (ol_datachar < 0)
{
if ((ol_datachar = ol_datalex()) < 0) ol_datachar = 0;
#if ol_dataDEBUG
if (ol_datadebug)
{
ol_datas = 0;
if (ol_datachar <= ol_dataMAXTOKEN) ol_datas = ol_dataname[ol_datachar];
if (!ol_datas) ol_datas = "illegal-symbol";
printf("ol_datadebug: state %d, reading %d (%s)\n",
ol_dataFINAL, ol_datachar, ol_datas);
}
#endif
}
if (ol_datachar == 0) goto ol_dataaccept;
goto ol_dataloop;
}
if ((ol_datan = ol_datagindex[ol_datam]) && (ol_datan += ol_datastate) >= 0 &&
ol_datan <= ol_dataTABLESIZE && ol_datacheck[ol_datan] == ol_datastate)
ol_datastate = ol_datatable[ol_datan];
else
ol_datastate = ol_datadgoto[ol_datam];
#if ol_dataDEBUG
if (ol_datadebug)
printf("ol_datadebug: after reduction, shifting from state %d \
to state %d\n", *ol_datassp, ol_datastate);
#endif
if (ol_datassp >= ol_datass + ol_datastacksize - 1)
{
goto ol_dataoverflow;
}
*++ol_datassp = ol_datastate;
*++ol_datavsp = ol_dataval;
goto ol_dataloop;
ol_dataoverflow:
ol_dataerror("yacc stack overflow");
ol_dataabort:
return (1);
ol_dataaccept:
return (0);
}

View File

@@ -0,0 +1,14 @@
/* $XConsortium: OL_DataExpr.tab.h /main/3 1996/08/21 15:57:56 drk $ */
#define Reference 257
#define Id 258
#define Literal 259
#define Content 260
#define Concat 261
#define Attr 262
#define FirstOf 263
typedef union {
int name;
char *string;
OL_Expression *eptr;
} YYSTYPE;
extern YYSTYPE ol_datalval;

View File

@@ -0,0 +1,103 @@
/* $XConsortium: OL_DataExpr.y /main/2 1996/11/11 11:51:54 drk $ */
%{
#include <stdio.h>
#include "ExprList.h"
#include "Expression.h"
#include "ContentType.h"
extern int yylex();
extern void yyerror( char *str );
extern ContentType *CurrentContentPtr;
%}
%union {
int name;
char *string;
Expression *eptr;
}
%token <name> Reference
%token <name> Id
%token <string> Literal
%token Content
%token Concat
%token Attr
%token FirstOf
%type <eptr> Expr
%type <eptr> ExprList
%start ValList
%%
ValList : ExprList
{
CurrentContentPtr->init($1);
}
;
ExprList : Expr
{
$$ = $1;
}
| Expr ',' ExprList
{
$1->next = $3;
$$ = $1;
}
;
Expr : Id
{
Expression *expr = new Expression( GENERIC_ID, $1);
$$ = expr;
}
| Content
{
Expression *expr = new Expression( CONTENT );
$$ = expr;
}
| Concat '(' ExprList ')'
{
ExprList *elist = new ExprList( $3 );
Expression *expr = new Expression( CONCAT, -1, elist);
$$ = expr;
}
| Attr '(' Id ')'
{
Expression *expr = new Expression( REFERENCE, $3);
$$ = expr;
}
| FirstOf '(' ExprList ')'
{
ExprList *elist = new ExprList ( $3 );
Expression *expr = new Expression( FIRSTOF, -1, elist );
$$ = expr;
}
| Literal
{
Expression *expr = new Expression( LITERAL, -1, $1 );
$$ = expr;
}
| Reference
{
Expression *expr = new Expression( REFERENCE, $1 );
$$ = expr;
}
;
%%

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,155 @@
%{
/* $XConsortium: RemoteId.l /main/3 1996/11/19 16:54:33 drk $ */
/* imported interfaces */
#include "FlexBuffer.h"
#include "BTCollectable.h"
#include "dti_cc/CC_String.h"
#include "dti_cc/cc_hdict.h"
static int my_input ( char *, int );
#undef YY_INPUT
#define YY_INPUT(b, r, ms ) ( r=my_input( ( char *)b,ms) )
static char *myinput;
static char *myinputptr;
static char *myinputlim;
static FlexBuffer *NodeBuffer;
static FlexBuffer *idref_buffer;
static hashTable<CC_String,BTCollectable> *hd;
static int NeedRemote = 0;
static int current_line_num = 0;
static char *current_file_name;
%}
%x OLIDREF OLIDREF_LINE OLIDREF_FILE
%%
"<#OL-IDREF>" {
BEGIN( OLIDREF );
NodeBuffer->writeStr("<#OL-IDREF>");
}
<OLIDREF>"<#L>" {
BEGIN(OLIDREF_LINE);
}
<OLIDREF_LINE>[^<]+ {
const char *line = (const char *)yytext;
current_line_num = atoi( line );
}
<OLIDREF_LINE>"</#L>" {
BEGIN( OLIDREF );
}
<OLIDREF>"<#F>" {
BEGIN ( OLIDREF_FILE );
}
<OLIDREF_FILE>[^<]+ {
current_file_name = strdup( (const char *)yytext);
}
<OLIDREF_FILE>"</#F>" {
BEGIN ( OLIDREF );
}
<OLIDREF>"&lt;" {
// Perform the entity resolution
idref_buffer->put('<');
NodeBuffer->writeStr( "&lt;" );
}
<OLIDREF>"&amp;" {
idref_buffer->put('&');
NodeBuffer->writeStr( "&amp;" );
}
<OLIDREF>"</#OL-IDREF>" {
/*
* test if the link value found in
* #OL-IDREF is resolved in the bookcase
*/
CC_String key( (const char *)idref_buffer->GetBuffer() );
CC_String *val = (CC_String *)hd->findValue( &key );
if ( !val ) {
NeedRemote = 1;
cerr << "(WARNING) Unresolved link = " << (const char *)key << endl
<< " file = " << current_file_name << endl
<< " line no. = " << current_line_num << "\n\n";
}
// cleanup and reset
delete current_file_name; current_file_name = 0;
idref_buffer->reset();
NodeBuffer->writeStr("</#OL-IDREF>");
if ( NeedRemote ) {
NodeBuffer->writeStr("<#REMOTE></#REMOTE>");
NeedRemote = 0;
}
BEGIN ( 0 );
}
<OLIDREF>[^&<]+ {
const char *str = (const char *)yytext;
idref_buffer->writeStr( str );
NodeBuffer->writeStr( str );
}
. |
\n {
NodeBuffer->put( yytext[0] );
}
%%
static int
my_input ( char *buf, int max_size )
{
int remain = myinputlim - myinputptr;
int n = ( max_size > remain ? remain : max_size );
if ( n > 0 ) {
memcpy ( buf, myinputptr, n );
myinputptr += n;
}
return n;
}
//------------------------------------------------------------
void insert_remotelink( hashTable<CC_String,BTCollectable> *dictionary,
char *data,
size_t datalen,
FlexBuffer *result_buf)
{
myinput = data;
myinputptr = data;
myinputlim = data + datalen;
NodeBuffer = result_buf;
hd = dictionary;
idref_buffer = new FlexBuffer();
yylex();
delete idref_buffer;
BEGIN INITIAL;
yyrestart(NULL);
}
void bogus(int)
{
cout << "bogus\n";
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,190 @@
%{ /* -*- c++ -*- */
/* $XConsortium: ReplaceIdIdref.l /main/3 1996/11/19 16:54:45 drk $ */
/* exported interfaces... */
#include "NodeData.h"
/* imported interfaces... */
#include <iostream.h>
#include <stream.h>
#include <stdlib.h>
#include <stdio.h>
#include <assert.h>
#include "misc/unique_id.h"
#include "Token.h"
#include "FlexBuffer.h"
#include "NodeTask.h"
#include "SearchEng.h"
#include "OLAF.h"
#include "SGMLName.h"
#include "OL-Data.h"
#include "BookTasks.h"
#include "DataBase.h"
#include "BookCaseDB.h"
#include "GraphicsTask.h"
#include "Dispatch.h"
// Debugging macro
#ifdef DEBUG
#define DBG(level) if ( dbgLevel >= level)
#else
#define DBG(level) if (0)
#endif
static int dbgLevel=-1;
/*
* Forward declaration for my_input
*/
static int my_input ( char *, int );
#undef YY_INPUT
#define YY_INPUT(b, r, ms ) ( r=my_input( ( char *)b,ms) )
static char *myinput;
static char *myinputptr;
static char *myinputlim;
NodeData *CurrentNodeData;
extern void replace_entity ( FlexBuffer *, const char *);
%}
%x OLID OLIDREF GRAPHIC XREF
%%
"<#OL-XREF>" {
BEGIN ( XREF );
}
<XREF>[0-9]+ {
const char *str = ( const char *)yytext;
OL_Data *idref =
(OL_Data *)CurrentNodeData->subtask( atoi(str) );
if ( !idref->ContentIsEmpty() ) {
const char *idrefval = idref->content();
FlexBuffer *db_buf = CurrentNodeData->DbBuffer;
db_buf->writeStr("<#OL-XREF>");
replace_entity ( db_buf, idrefval );
db_buf->writeStr("</#OL-XREF>");
}
}
<XREF>"</#OL-XREF>" {
BEGIN ( 0 );
}
"<#OL-ID>" {
BEGIN ( OLID );
}
<OLID>[0-9]+ {
/*
* query the array for the real no.
*/
const char *str = ( const char *)yytext;
OL_Data *id =
(OL_Data *)CurrentNodeData->subtask( atoi(str) );
if ( !id->ContentIsEmpty() ) {
const char *idval = id->content();
FlexBuffer *db_buf = CurrentNodeData->DbBuffer;
db_buf->writeStr("<#OL-ID>");
replace_entity( db_buf, idval );
db_buf->writeStr("</#OL-ID>");
}
}
<OLID>"</#OL-ID>" {
BEGIN ( 0 );
}
"<#OL-IDREF>" {
BEGIN( OLIDREF );
}
<OLIDREF>[0-9]+ {
const char *str = (const char *)yytext;
OL_Data *idref =
(OL_Data *)CurrentNodeData->subtask(atoi(str));
if ( !idref->ContentIsEmpty() ) {
const char *idrefval = idref->content();
int line_num = idref->line_no();
const char *filename = idref->filename();
FlexBuffer *db_buf = CurrentNodeData->DbBuffer;
db_buf->writeStr("<#OL-IDREF>");
db_buf->writeStr(form("<#L>%d</#L>", line_num));
db_buf->writeStr(form("<#F>%s</#F>", filename));
replace_entity ( db_buf, idrefval );
db_buf->writeStr("</#OL-IDREF>");
}
}
<OLIDREF>"</#OL-IDREF>" {
BEGIN( 0 );
}
"<#GRAPHIC>" {
BEGIN( GRAPHIC );
}
<GRAPHIC>[0-9]+ {
const char *str = (const char *)yytext;
OL_Data *graphic_id =
(OL_Data *)CurrentNodeData->subtask(atoi(str));
if ( !graphic_id->ContentIsEmpty() ) {
const char *graphic_id_val =
graphic_id->content();
CurrentNodeData->DbBuffer->writeStr("<#GRAPHIC>");
replace_entity (CurrentNodeData->DbBuffer,
graphic_id_val);
CurrentNodeData->DbBuffer->writeStr("</#GRAPHIC>");
}
}
<GRAPHIC>"</#GRAPHIC>" {
BEGIN(0);
}
. |
\n {
CurrentNodeData->DbBuffer->put( yytext[0] );
}
%%
//-----------------------------------------------------------------------
static int
my_input ( char *buf, int max_size )
{
int remain = myinputlim - myinputptr;
int n = ( max_size > remain ? remain : max_size );
if ( n > 0 ) {
memcpy ( buf, myinputptr, n );
myinputptr += n;
}
return n;
}
//----------------------------------------------------------------------
void ReplaceIdIdRef( NodeData *nd , char *buffer, int sz )
{
CurrentNodeData = nd;
myinput = buffer;
myinputptr = buffer;
myinputlim = buffer + sz;
yylex();
BEGIN INITIAL;
yyrestart(NULL);
}

View File

@@ -0,0 +1,101 @@
/* $XConsortium: SGMLDefn.cc /main/2 1996/06/04 16:44:32 rcs $
*
* (c) Copyright 1996 Digital Equipment Corporation.
* (c) Copyright 1996 Hewlett-Packard Company.
* (c) Copyright 1996 International Business Machines Corp.
* (c) Copyright 1996 Sun Microsystems, Inc.
* (c) Copyright 1996 Novell, Inc.
* (c) Copyright 1996 FUJITSU LIMITED.
* (c) Copyright 1996 Hitachi.
*/
#include <assert.h>
#include <string.h>
#include "SGMLName.h"
#include "SGMLDefn.h"
SGMLDefn::SGMLDefn()
{
sys_id = NULL;
pub_id = NULL;
file_name = NULL;
name = -1;
next = NULL;
type = INVALID;
}
SGMLDefn::~SGMLDefn()
{
delete sys_id;
delete pub_id;
delete file_name;
}
void
SGMLDefn::store_sys_id( char *sid )
{
if ( sid ) {
delete sys_id;
sys_id = new char [ strlen(sid) + 1 ];
assert(sys_id != NULL);
strcpy ( sys_id , sid );
}
}
void
SGMLDefn::store_pub_id( char *pid )
{
if ( pid ) {
delete pub_id;
pub_id = new char [ strlen(pid) + 1 ];
assert(pub_id != NULL);
strcpy ( pub_id, pid );
}
}
void
SGMLDefn::store_defn( DEFN_TYPE dt, char *defnStr )
{
if ( dt == ENTITY_TYPE ) {
type = dt;
char *tmp = strtok( defnStr, "\n\t ");
name = SGMLName::intern(tmp);
}
}
void
SGMLDefn::store_file_name( char *fname )
{
if ( fname ) {
delete file_name;
file_name = new char [ strlen(fname) + 1 ];
assert(file_name != NULL);
strcpy( file_name, fname );
}
}
SGMLDefn &
SGMLDefn::operator=( SGMLDefn &defn )
{
store_sys_id( defn.sys_id );
store_pub_id( defn.pub_id );
store_file_name( defn.file_name );
type = defn.type;
name = defn.name;
next = NULL;
return (*this);
}

View File

@@ -0,0 +1,48 @@
/* $XConsortium: SGMLDefn.h /main/2 1996/07/18 16:48:35 drk $ */
#ifndef SGML_DEFN_HDR
#define SGML_DEFN_HDR
enum DEFN_TYPE {
INVALID=-1,
ENTITY_TYPE,
NOTATION_TYPE,
SUBDOC_TYPE
};
class SGMLDefn {
friend int yylex();
friend class Dispatch;
friend class EntityList;
private:
char *sys_id;
char *pub_id;
char *file_name;
int name;
DEFN_TYPE type;
SGMLDefn *next;
protected:
void store_sys_id( char *sid );
void store_pub_id( char *pid );
void store_defn( DEFN_TYPE, char * );
void store_file_name( char *file_name );
SGMLDefn &operator=( SGMLDefn & );
public:
int getName() const { return(name); }
char *getFileName() const { return(file_name); }
SGMLDefn();
~SGMLDefn();
};
#endif

View File

@@ -0,0 +1,217 @@
/* $TOG: SGMLName.C /main/3 1998/04/17 11:23:18 mgreess $ */
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include "SGMLName.h"
/****** private interface *******/
typedef struct {
char *string;
int code;
}Item;
class StringToInt{
public:
StringToInt();
int intern(const char* name);
const char* lookup(int);
protected:
void grow(size_t);
private:
Item *items;
size_t used;
size_t total;
};
static int
whichString (const char * target,
const Item * table,
int qty);
/****** implementation *******/
static StringToInt *theTable = NULL;
int
SGMLName::intern(const char *name, int upcase)
{
static char *buf = 0;
static size_t buflen = 0;
const char *n;
if(!theTable) theTable = new StringToInt();
if(upcase){
size_t nlen = strlen(name);
if(buflen < nlen + 1){
delete buf;
buf = new char[buflen = nlen * 3 / 2 + 10];
}
const char *src;
char *dest;
for(src = name, dest=buf; *src; src++, dest++){
*dest = toupper(*src);
}
*dest = 0;
n = buf;
}else{
n = name;
}
return theTable->intern(n);
}
const char*
SGMLName::lookup(int indx)
{
return theTable->lookup(indx);
}
StringToInt::StringToInt()
{
items = 0;
total = used = 0;
}
StringToInt::intern(const char *name)
{
int indx;
if( (indx = whichString(name, items, used)) < 0){
grow(used + 1);
char *p = new char[strlen(name)+1];
strcpy(p, name);
indx = used;
while(indx > 0 && strcmp(name, items[indx-1].string) < 0){
items[indx] = items[indx-1];
indx--;
}
items[indx].string = p;
items[indx].code = used;
used++;
}
return items[indx].code;
}
void StringToInt::grow(size_t needed)
{
if(total < needed){
Item *born = new Item[total = needed * 3 / 2 + 10];
if(used){
memcpy(born, items, sizeof(Item) * used);
delete items;
}
items = born;
}
}
const char* StringToInt::lookup(int indx)
{
int i;
for(i = 0; i < used; i++){
if (items[i].code == indx) return items[i].string;
}
abort();
return NULL; /* avoid compiler warning */
}
/*
** Binary search for an array of strings for a given string.
** return index into the table, or -1 if not found.
*/
static int
whichString (const char * target,
const Item * table,
int qty)
{
int low = 0;
int high = qty;
int i, diff;
while(high > 0){
i = (high + low)/2;
diff = strcmp(table[i].string, target);
if(diff == 0) { /* success: found it */
return i;
}else if(low + 1 >= high) break;
else if(diff > 0) high = i;
else low = i;
}
return -1;
}
const int NAMECASE = 1; /* Only one SGML Decl. supported */
void SGMLName::init()
{
#define INTERN(n) intern(#n, NAMECASE);
INTERN(IMPLIED);
INTERN(CDATA);
INTERN(NOTATION);
INTERN(TOKEN);
INTERN(ENTITY);
}
#ifdef TEST
#include <stdio.h>
int
main(int argc, char **)
{
char buf[100];
int upcase = 0;
if(argc > 1) upcase = 1;
while(fgets(buf, sizeof(buf)-1, stdin) != NULL){
int indx;
printf("intern: %d\n", indx = SGMLName::intern(buf, upcase));
printf("lookup: %s\n", SGMLName::lookup(indx));
}
}
#endif

View File

@@ -0,0 +1,18 @@
/* $XConsortium: SGMLName.h /main/2 1996/07/18 15:19:02 drk $ */
#ifndef __SGMLName_h
#define __SGMLName_h
class SGMLName{
public:
static int intern(const char*, int upcase = 0);
static const char *lookup(int) /* throw(KeyError) */;
enum DeclaredValue { IMPLIED, CDATA, NOTATION, TOKEN, ENTITY, qty };
static void init();
};
#endif

View File

@@ -0,0 +1,45 @@
/* $XConsortium: SearchEng.C /main/3 1996/08/21 15:47:17 drk $ */
/* imported interfaces */
#include "dti_cc/CC_Stack.h"
#include "OL-Data.h"
#include "Task.h"
#include "FlexBuffer.h"
#include "Token.h"
#include "OLAF.h"
#include "NodeData.h"
#include "NodeTask.h"
#include "GraphicsTask.h"
#include "BookTasks.h"
#include "Dispatch.h"
#include "SGMLName.h"
// exported interfaces
#include "SearchEng.h"
//---------------------------------------------------------------------
SearchEngine::SearchEngine( NodeData *parent , const Token & t )
{
f_base = t.level();
f_graphics = 0;
CollectObject = -1;
hasTerms = 0;
f_parent = parent;
termsBuffer = NULL;
}
//---------------------------------------------------------------------
int
SearchEngine::GraphicsIsDone() const
{
if ( f_graphics ) { return ( f_graphics->IsDone() ); }
else {
return 0;
}
}

View File

@@ -0,0 +1,86 @@
/* $XConsortium: SearchEng.h /main/2 1996/07/18 16:48:56 drk $ */
// SearchEngine.h - This serves as a base class for different search engine
#ifndef SRH_ENG_HEADER
#define SRH_ENG_HEADER
#include "FlexBuffer.h"
template <class Type> class Stack;
class ComplexTask;
class Token;
class NodeData;
class GraphicsTask;
class SearchEngine : public ComplexTask {
protected:
const FlexBuffer *termsBuffer;
int f_base;
int hasTerms;
int CollectObject;
NodeData *f_parent;
GraphicsTask *f_graphics;
protected:
virtual void write_start_tag ( const Token & ) = 0;
virtual void write_end_tag ( const Token & ) = 0;
virtual void write_terms ( FlexBuffer *termsbuf ) = 0;
virtual void write_buffer() = 0; /*
* This corresponds to the
* write_fulcrum_buffer, write_qsearch_buffer
*/
public:
/* The following 2 are pure virtual, so that each derived class has to
* redefine them
*/
virtual void markup( const Token &) = 0;
virtual void data ( const char *, size_t ) = 0;
/* default will be used if not redefined by the derived class
*/
virtual int HasSearchTerms() const;
virtual const FlexBuffer *DumpSearchTerms();
virtual int GraphicsIsDone() const;
virtual NodeData *node_data() { return f_parent; }
protected:
SearchEngine( NodeData *, const Token &); /* This is not intended to be
* used as a constructor for
* instantiation an object
* but used as a common point
* of initialization of all the
* base classes for SearchEng
*/
public:
virtual ~SearchEngine() {}
};
inline
int
SearchEngine::HasSearchTerms() const
{
return( hasTerms );
}
//---------------------------------------------------------------------
inline
const FlexBuffer *
SearchEngine::DumpSearchTerms()
{
hasTerms = 0;
return ( termsBuffer );
}
#endif

View File

@@ -0,0 +1,153 @@
/* $XConsortium: SearchPath.C /main/7 1996/08/21 15:47:21 drk $ */
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#if !defined(__uxp__) && !defined(USL)
#include <strings.h>
#endif
#include <sys/stat.h>
#include <sys/types.h>
#include <stream.h>
#include "Exceptions.hh"
#include "Task.h"
/* exported interface */
#include "SearchPath.h"
#ifdef NEED_STRCASECMP
#include <ctype.h>
/*
* In case strcasecmp and strncasecmp are not provided by the system
* here are ones which do the trick.
*/
int
strcasecmp(register const char *s1,
register const char *s2)
{
register int c1, c2;
while (*s1 && *s2) {
c1 = isupper(*s1) ? tolower(*s1) : *s1;
c2 = isupper(*s2) ? tolower(*s2) : *s2;
if (c1 != c2)
return (c1 - c2);
s1++;
s2++;
}
return (int) (*s1 - *s2);
}
int
strncasecmp(register const char *s1,
register const char *s2,
register size_t count)
{
register int c1, c2;
if (!count)
return 0;
while (*s1 && *s2) {
c1 = isupper(*s1) ? tolower(*s1) : *s1;
c2 = isupper(*s2) ? tolower(*s2) : *s2;
if ((c1 != c2) || (! --count))
return (c1 - c2);
s1++;
s2++;
}
return (int) (*s1 - *s2);
}
#endif
//--------------------------------------------------------------------
static int isdir(char* filename)
{
int ret = 0;
struct stat sb;
if(stat(filename, &sb) == 0){
if(S_ISDIR(sb.st_mode)){
ret = 1;
}
}
return ret;
}
//-------------------------------------------------------------------
SearchPath::SearchPath( const char *path, ... )
{
search_path_table = new CC_TPtrSlist<CC_String>;
new_path = 0;
va_list ap;
va_start ( ap , path);
const char *spath = path;
while ( spath ) {
CC_String *key = new CC_String(spath);
search_path_table->append( key );
spath = va_arg ( ap, const char * );
}
va_end ( ap );
}
//-------------------------------------------------------------------
char *
SearchPath::get_real_path( const char *file_name )
{
CC_TPtrSlistIterator<CC_String> path_it( *search_path_table );
FILE *fp;
if (file_name == NULL || *file_name == '\0')
return NULL;
// remove storage object specifier
if (strncasecmp(file_name, "<OSFILE", 7) == 0) {
if (file_name = strchr(file_name, '>'))
file_name++;
else
return NULL;
}
while ( path_it() ) {
const char *path = (const char *)*path_it.key();
char *full_path_name = form( "%s/%s", path, file_name );
if (( fp = fopen( full_path_name , "r" )) && !isdir(full_path_name) ) {
fclose( fp );
return ( full_path_name );
}
fclose( fp );
}
return NULL;
}
//-------------------------------------------------------------------
void
SearchPath::replace_file_scope( const char *f_path )
{
if ( new_path ) {
if ( !search_path_table->remove( new_path ) ) {
throw(Unexpected("Cannot replace file scope\n"));
}
delete new_path; new_path = 0;
}
new_path = new CC_String(f_path);
search_path_table->prepend( new_path );
}

View File

@@ -0,0 +1,50 @@
/* $XConsortium: SearchPath.h /main/3 1996/08/21 15:47:25 drk $ */
// SearchPath.h
#ifndef SRH_PATH_HDR
#define SRH_PATH_HDR
#include <stdarg.h>
#include "dti_cc/CC_Slist.h"
#include "dti_cc/CC_String.h"
class SearchPath {
private:
CC_TPtrSlist<CC_String> *search_path_table;
CC_String *new_path;
public:
/* the search path order is significant because they are searched in that
* order
*/
/*
* Usage :: SearchPath *ptr = new SearchPath ( "dir1", "dir2", "dir3" );
* and later on when I invoked ptr->get_real_path( "file_name" );
* dir1, dir2 and dir3 will be searched in order to determine if file_name
* exists in any one of the directories.
*
* The first directory which contains "file_name" will be returned by
* get_real_path( "file_name" );
*
*/
SearchPath(const char *path, ... );
/*
* Usage: replace_file_scope checks if we are in a file that is outside the
* the build directory and the source directory, if so , it will
* get rid of that directory, and prepend the new one at the front
* of the search path table list. This is primarily tied to the
* the ESIS format for the display of current file name and line
* number.
*
*/
void replace_file_scope( const char *path );
char *get_real_path( const char *file_name );
~SearchPath() { if ( search_path_table ) delete search_path_table; }
};
#endif

View File

@@ -0,0 +1,171 @@
/* $XConsortium: SearchStorage.cc /main/4 1996/07/23 18:10:39 cde-hal $
*
* (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.
*/
#include <stdio.h>
#include <stddef.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <assert.h>
#include <stream.h>
/* imported interfaces */
#include <misc/unique_id.h>
#include "FlexBuffer.h"
#include "Task.h"
#include "DataBase.h"
/* exported interfaces */
#include "SearchStorage.h"
//-----------------------------------------------------------------------
static int isdir(const char* filename)
{
int ret = 0;
struct stat sb;
if(stat(filename, &sb) == 0){
if(S_ISDIR(sb.st_mode)){
ret = 1;
}
}
return ret;
}
//-----------------------------------------------------------------------
static void makedir(const char *path) /* throw(PosixError) */
{
if(mkdir((char*)path, 0775) != 0){
throw(PosixError(errno, path));
}
}
//-----------------------------------------------------------------------
static const char *FilteredString( FlexBuffer &f_buf, const char *str )
{
for ( const char *ptr = str; *ptr != 0; ptr++ ) {
if ( *ptr == '\"' ) {
f_buf.writeStr ( "\\\"" );
}
else if ( *ptr == '\\' ) {
f_buf.writeStr ( "\\\\" );
}
else {
f_buf.put ( *ptr );
}
}
return ( f_buf.GetBuffer() );
}
//-----------------------------------------------------------------------
SearchStorage::SearchStorage( const char *path, const char *name )
{
if ( !isdir(path) ) {
makedir(path);
}
filteredPath = new char [ strlen(path) + 1 + strlen("filtered") + 1 ];
/*
* throw(ResourceExhausted)
*
*/
assert ( filteredPath != NULL );
sprintf( filteredPath, "%s/filtered", path );
if ( !isdir(filteredPath) ) {
makedir(filteredPath);
}
/* construct the fulcrum path */
char *fulcrumpath = form("%s/fulcrum", path );
if ( !isdir(fulcrumpath) ) {
makedir(fulcrumpath);
}
char *catalogname = form("%s/%s.cin", fulcrumpath, name );
catalogfile = fopen ( catalogname, "w" );
if ( !catalogfile ) {
throw(PosixError(errno, form("unable to open catalog %s\n", catalogname) ) );
}
}
//-----------------------------------------------------------------------
void
SearchStorage::insert( const char *BookCaseName,
const int BookNum,
const char *BookShortTitle,
const char *SectionID,
const char *SectionTitle,
const char *buffer,
int size
)
{
// write the search buffer to a file with name "NodeLocator" under
// fulcrumpath
// we use a unique_id() as the file name, in order to avoid spaces, /
// and stuffs like that.....
const char *filtered_file_name = unique_id();
char *filename = form("%s/%s", filteredPath, filtered_file_name );
FILE *fp = fopen( filename, "w" );
if ( !fp ) {
throw(PosixError(errno, form("Unable to open %s", filename) ) );
}
if ( !fwrite ( buffer, size, 1, fp ) ) {
throw(PosixError(errno, "unable to write to buffer\n" ) );
}
fclose(fp);
FlexBuffer new_section_id;
FlexBuffer new_book_short_title;
FlexBuffer new_section_title;
FlexBuffer new_book_case_name;
// append to the catalog file
if ( catalogfile ) {
fprintf( catalogfile, "{\ns %s s 32 1;\n", filtered_file_name );
fprintf( catalogfile, "f 100 \"%s\" ;\n",
FilteredString( new_section_id, SectionID ) );
fprintf( catalogfile, "f 127 \"%s\" ;\n" ,
FilteredString( new_book_short_title, BookShortTitle ) );
fprintf( catalogfile, "f 128 \"%s\" ;\n",
FilteredString( new_section_title, SectionTitle ) );
fprintf( catalogfile, "f 130 \"%d\";\n", BookNum );
fprintf( catalogfile, "f 131 \"%s\";\n",
FilteredString( new_book_case_name, BookCaseName) );
fprintf( catalogfile, "}\n");
}
}
//-----------------------------------------------------------------------
SearchStorage::~SearchStorage()
{
if ( catalogfile ) { fclose(catalogfile); }
if ( filteredPath ) { delete [] filteredPath; }
}

View File

@@ -0,0 +1,38 @@
/* $XConsortium: SearchStorage.h /main/3 1996/07/18 16:49:38 drk $ */
#ifndef SRCH_STOR_HDR
#define SCRH_STOR_HDR
#include <stdio.h>
class SearchStorage {
private:
FILE *catalogfile;
char *filteredPath;
public:
SearchStorage( const char *BookCasePath, const char *BookCaseName );
/*
* insert ( "This Book Case Name", 2,
* "XmyLcfhalklkoop",
* "This is the text that the indexing machine will see",
* 51 );
*
*/
void insert( const char *BookCaseName,
const int BookNum,
const char *BookShortTitle,
const char *SectionID,
const char *SectionTitle,
const char *buffer,
int size
);
~SearchStorage();
};
#endif

View File

@@ -0,0 +1,58 @@
/* $XConsortium: Stack.h /main/2 1996/07/18 16:49:58 drk $ */
#ifndef STACK_HEADRER
#define STACK_HEADER
//-----------------------------------------------------------------------
class Element{
friend class Stack;
friend class SearchEngine;
protected:
int name;
Element *next;
Element( int aName, Element *v=0) { name = aName; next = v; }
int GetName() const { return name; }
};
class Stack {
private:
Element *currentToken;
public:
void push( Element *tok ) { tok->next = currentToken; currentToken = tok; }
Element *pop() {
Element *ptr;
if ( currentToken ) {
ptr = currentToken;
currentToken = ptr->next;
return ( ptr );
}
else {
return ( NULL );
}
}
Element *GetTopToken() { return ( currentToken ); }
Stack() { currentToken = NULL; }
~Stack();
};
inline
Stack::~Stack()
{
Element *pt = currentToken;
while ( pt ) {
Element *tmp = pt;
pt = pt->next;
delete tmp;
}
}
#endif

View File

@@ -0,0 +1,65 @@
/* $XConsortium: StringList.cc /main/2 1996/07/18 15:19:21 drk $ */
/* exported interfaces... */
#include "StringList.h"
/* imported interfaces... */
#include <string.h>
StringList::StringList()
{
used = alloc = 0;
items = NULL;
}
StringList::~StringList()
{
reset();
delete items;
}
void StringList::grow(size_t total)
{
if(total + 1 > alloc){
char **born = new char*[alloc = total * 3 / 2 + 1];
if(used > 0){
memcpy(born, items, used *sizeof(items[0]));
delete items;
}
items = born;
}
}
const char * StringList::append(const char *str)
{
char *p = new char[strlen(str)+1];
strcpy(p, str);
grow(used);
items[used++] = p;
return p;
}
void StringList::add(char *str)
{
grow(used);
items[used++] = str;
}
void StringList::reset()
{
for(size_t i = 0; i < used; i++){
delete items[i];
items[i] = 0; /* This is to prevent the item[i] from being deleted
* again, ie free memory freed.
*/
}
used = 0;
}

View File

@@ -0,0 +1,41 @@
/* $XConsortium: StringList.h /main/2 1996/07/18 15:19:39 drk $ -*- c++ -*- */
#ifndef __StringList_h
#define __StringList_h
#include <stddef.h> /* for size_t */
/***********************************
*
* StringList
*
***********************************/
class StringList{
public:
StringList(void);
~StringList();
const char * append(const char*); /* returns a copy, owned by this obj. */
void add(char*); /* caller relinquishes ownership */
size_t qty() { return used; };
const char *item(size_t indx) { return items[indx]; };
const char **array() { return (const char **)items; };
void reset();
protected:
char **items;
size_t used;
private:
void grow(size_t n);
size_t alloc;
};
#endif /* __StringList_h */

View File

@@ -0,0 +1,564 @@
/* $XConsortium: StyleTask.cc /main/7 1996/07/18 15:20:02 drk $ */
/* $XConsortium: StyleTask.cc /main/7 1996/07/18 15:20:02 drk $ */
/* $XConsortium: StyleTask.cc /main/7 1996/07/18 15:20:02 drk $ */
/* $XConsortium: StyleTask.cc /main/7 1996/07/18 15:20:02 drk $ */
/* $XConsortium: StyleTask.cc /main/7 1996/07/18 15:20:02 drk $ */
/* $XConsortium: StyleTask.cc /main/7 1996/07/18 15:20:02 drk $ */
/* $XConsortium: StyleTask.cc /main/7 1996/07/18 15:20:02 drk $ */
/* export... */
#include "StyleTask.h"
/* import... */
#include <assert.h>
#include "AttributeRec.h"
#include "DataBase.h"
#include "FlexBuffer.h"
#include "OLAF.h"
#include "OL-Data.h"
#include "SGMLName.h"
#include "StringList.h"
#include "Token.h"
#ifdef FISH_DEBUG
#include "dbug.h" /* Fred Fish's dbug.h */
#endif
/*****************
*
* StyleTask
*
*****************/
static unsigned hash_func(const CC_String &str)
{
return str.hash();
}
inline
static
void write_tabs( FlexBuffer *buf, Stack<int> *fstack, char ch )
{
int num_ch = fstack->entries() + 1;
for ( int i=0; i < num_ch; i++ ) {
buf->put(ch);
}
}
StyleTask::StyleTask()
{
f_base = f_select = -1;
onlineSS = new FlexBuffer();
printSS = new FlexBuffer();
viewset = new hashTable<CC_String,int>(hash_func);
f_buffer = NULL;
f_pathbuf = NULL;
f_locator = NULL;
feature_depth = new Stack<int>;
}
StyleTask::~StyleTask()
{
delete viewset;
delete f_pathbuf;
delete onlineSS;
delete printSS;
delete feature_depth;
KILLSUBTASK(f_locator);
ComplexTask::removeAllSubTasks();
}
void StyleTask::reset()
{
f_base = f_select = -1;
delete f_pathbuf; f_pathbuf = NULL;
delete onlineSS; onlineSS = new FlexBuffer();
delete printSS; printSS = new FlexBuffer();
delete feature_depth;
feature_depth = new Stack<int>;
f_buffer = NULL;
KILLSUBTASK( f_locator );
ComplexTask::removeAllSubTasks();
}
static void
report_position(FlexBuffer *buffer, const char *file, int line)
{
char info[200]; //MAGIC
sprintf(info, "#file: %.150s line: %d\n", file, line);
buffer->writeStr(info);
}
static void
write_array(FlexBuffer *buffer, const char *tokens, int quotes)
{
buffer->put('[');
char *str = strdup ( tokens );
if(str){
char * token = strtok ( str, " \n\t");
if ( token ) {
if (quotes) buffer->put( '\"' );
buffer->writeStr( token );
if (quotes) buffer->put( '\"' );
while ( token = strtok ( NULL, " \n\t" ) ) {
buffer->put(',');
if (quotes) buffer->put( '\"' );
buffer->writeStr( token );
if (quotes) buffer->put( '\"' );
}
}
delete str;
} /*@# else out of memory... */
buffer->put(']');
}
static void
autonumber(FlexBuffer *buffer, const Token& t)
{
const AttributeRec *id = t.LookupAttr(SGMLName::intern("ID", 1));
const AttributeRec *type = t.LookupAttr(SGMLName::intern("Type", 1));
const AttributeRec *initial = t.LookupAttr(SGMLName::intern("Initial", 1));
const AttributeRec *delta = t.LookupAttr(SGMLName::intern("Delta", 1));
const AttributeRec *reset = t.LookupAttr(SGMLName::intern("Reset", 1));
const AttributeRec *counter = t.LookupAttr(SGMLName::intern("Counter", 1));
if(!id) throw(Unexpected("Autonumber: missing ID attribute"));
if(!type) throw(Unexpected("Autonumber: missing Type attribute"));
if(!initial) throw(Unexpected("Autonumber: missing Initial attribute"));
if(!delta) throw(Unexpected("Autonumber: missing Delta attribute"));
if(!reset) throw(Unexpected("Autonumber: missing Reset attribute"));
if(!counter) throw(Unexpected("Autonumber: missing Counter attribute"));
buffer->writeStr(id->getAttrValueString());
buffer->writeStr(" = autonumber[\"");
buffer->writeStr(type->getAttrValueString());
buffer->writeStr("\", \"");
buffer->writeStr(initial->getAttrValueString());
buffer->writeStr("\", \"");
buffer->writeStr(delta->getAttrValueString());
buffer->writeStr("\", ");
write_array(buffer, counter->getAttrValueString(), 1);
buffer->writeStr(", ");
write_array(buffer, reset->getAttrValueString(), 1);
buffer->writeStr("]\n\n");
}
static void
write_attr(FlexBuffer *f_buffer, const AttributeRec *arec)
{
f_buffer->writeStr( SGMLName::lookup( arec->getAttrName() ) );
f_buffer->writeStr( ":\t" );
const char *val = arec->getAttrValueString();
/* NAMES, NUMBERS convert to arrays for stylesheet lang. */
if(arec->getAttrType() == SGMLName::TOKEN
&& strchr(val, ' ')){
write_array(f_buffer, val, 0);
}else{
/* NASTY HACK!
* The stylesheet internal language requires some feature
* values to be quoted, and some not. It _seems_ that
* quoting anything that doesn't start with a digit will
* satisfy the constraints. This is highly artificial!
*
* Now for the exception that proves the hack!
* TRUE and FALSE...
*
* One more to add to the heap,
* if an attribute value is being referenced
*/
int quotes = !isdigit(val[0])
&& strcmp(val, "TRUE") != 0
&& strcmp(val, "FALSE") != 0
&& val[0] != '@';
if(quotes) f_buffer->writeStr( "\"" );
f_buffer->writeStr( val );
if(quotes) f_buffer->writeStr( "\"" );
}
}
void
StyleTask::markup( const Token &t )
{
ComplexTask::markup(t);
if (t.type() == START) {
/*
* Process Stylesheet start tags...
*/
switch(t.olaf()){
case OLAF::Stylesheet:
if (f_base >= 0) {
throw
(Unexpected
("illegal nested STYLESHEET architectural form"));
}
f_base = t.level();
#ifdef FISH_DEBUG
DBUG_PRINT("Style", ("Style level=`%d'\n", f_base));
#endif
break;
case OLAF::Path:
if ( f_pathbuf != NULL ) {
delete f_pathbuf;
}
f_pathbuf = new FlexBuffer();
f_buffer = f_pathbuf;
f_dataMode = inPath;
break;
case OLAF::Select:
f_buffer->writeStr( "[" );
f_select = t.level();
break;
case OLAF::Online:
f_buffer = onlineSS;
// feature_depth->clear();
if ( f_pathbuf == NULL ) {
throw(Unexpected("no path available for online feature."));
}
report_position(f_buffer, t.file(), t.line());
f_buffer->writeStr( f_pathbuf->GetBuffer() );
f_buffer->writeStr( "\n" );
write_tabs( f_buffer, feature_depth, '\t');
f_buffer->writeStr( "{\n" );
feature_depth->push(t.level());
break;
case OLAF::Print:
f_buffer = printSS;
// feature_depth->clear();
if ( f_pathbuf == NULL ) {
throw(Unexpected("no path available for print feature."));
}
report_position(f_buffer, t.file(), t.line());
f_buffer->writeStr( f_pathbuf->GetBuffer() );
f_buffer->writeStr( "\n" );
write_tabs( f_buffer, feature_depth, '\t');
f_buffer->writeStr( "{\n" );
feature_depth->push( t.level() );
break;
case OLAF::AutoNumber:
report_position(onlineSS, t.file(), t.line());
autonumber(onlineSS, t);
report_position(printSS, t.file(), t.line());
autonumber(printSS, t);
break;
case OLAF::FeatureText:
report_position(f_buffer, t.file(), t.line());
write_tabs( f_buffer, feature_depth, '\t');
f_buffer->writeStr( t.giName() );
f_buffer->writeStr( ": " );
f_dataMode = startContent;
break;
case OLAF::AutoRef:
{
const AttributeRec *arec;
int id = SGMLName::intern("ID");
if(arec = t.LookupAttr(id)){
if(f_dataMode == inContent){
f_buffer->writeStr(" + ");
}
f_buffer->writeStr(arec->getAttrValueString());
f_dataMode = inContent;
} /* else document is not conforming... sgmls will report error */
}
break;
case OLAF::Feature:
report_position(f_buffer, t.file(), t.line());
write_tabs( f_buffer, feature_depth, '\t');
f_buffer->writeStr( t.giName() );
f_buffer->writeStr( ": " );
const AttributeRec *arec;
/*
* Is it an enumeration feature?
*/
if(arec = t.LookupAttr(OLAF::OL_Choice)){
/* OL_Choice can only be applied to NAME attributes, hence
we don't neet to worryabout "'s in the attribute value.
*/
/* except TRUE and FALSE....*/
const char *val = arec->getAttrValueString();
int quotes = !isdigit(val[0])
&& strcmp(val, "TRUE") != 0
&& strcmp(val, "FALSE") != 0
&& val[0] != '@';
if (quotes) f_buffer->writeStr("\"");
f_buffer->writeStr(val);
if (quotes) f_buffer->writeStr("\" ");
}else{
f_buffer->writeStr( " {\n" );
for (arec = t.GetFirstAttr();
arec != NULL;
arec = t.GetNextAttr( arec )) {
if (( arec->getAttrValueString() != NULL ) &&
( arec->getAttrName() != OLAF::OLIAS )) {
write_tabs( f_buffer, feature_depth, '\t');
f_buffer->put('\t');
write_attr(f_buffer, arec);
f_buffer->writeStr( ",\n" );
}
}
feature_depth->push(t.level());
}
break;
}
/*
* first time we see OL-ID="...", spawn an OL_Data to collect the id
*/
if ((f_base >= 0) && (f_locator == NULL) &&
(t.LookupAttr(OLAF::OL_id))) {
#ifdef FISH_DEBUG
DBUG_PRINT("Style", ("spawning locator collection subtask\n"));
#endif
f_locator = new OL_Data(t, OLAF::OL_id, REMOVE_SPACES);
addSubTask( f_locator );
}
}
else if (t.type() == END) {
if (f_base > 0) {
int topelement;
if ( !feature_depth->empty() ) {
if ( topelement = feature_depth->top() ) {
if ( topelement == t.level() ) {
topelement = feature_depth->pop();
write_tabs( f_buffer, feature_depth, '\t');
if(feature_depth->empty()){
f_buffer->writeStr("}\n");
}
else {
f_buffer->writeStr("},\n");
}
}else if ( topelement + 1 == t.level() ) {
/* need a new-line at end of FeatureText data */
f_buffer->writeStr(",\n");
}
}
}
if (t.level() == f_base) {
/* found end of stylesheet... write out StyleSheet data */
#ifdef FISH_DEBUG
DBUG_PRINT("Style", ("found end of stylesheet write out StyleSheet data\n"));
#endif
write_record();
}
else if(t.level() == f_select){
f_buffer->writeStr( "]" );
f_select = -1;
}
}
}
}
void StyleTask::data ( const char *str, size_t t )
{
if ( f_base > 0 ) {
ComplexTask::data( str, t );
if (f_buffer != NULL) {
switch(f_dataMode){
case inPath:
f_buffer->write ( str, t );
break;
case inContent:
f_buffer->write ( " + ", 3 );
/* fall through */
case startContent:
f_buffer->write ( "\"", 1 );
f_dataMode = inContent;
const char *p;
for(p = str; *p; p++){
if(*p == '"' || *p == '\\')
f_buffer->put('\\');
f_buffer->put(*p);
}
f_buffer->write ( "\"", 1 );
break;
}
}
}
}
const char *
StyleTask::locator()
{
const char *ret = 0;
if (f_locator){
ret = f_locator->content();
}
if (!(ret && *ret)){
throw(Unexpected ("No name given to stylesheet."));
}
return ret;
}
void StyleTask::write_record( void )
{
const char
*localstr = locator();
#ifdef FISH_DEBUG
DBUG_PRINT("Style",
("Style Sheet: \nview=`%s'\nonlineSS=`%s'\n\nprintSS=`%s'\n",
localstr,
onlineSS->GetBuffer(),
printSS->GetBuffer() ));
DBUG_PRINT("Style", ("View id...\n"));
DBUG_PRINT("Style", ("\tis: `%s'\n", localstr ));
#endif
CC_String *str = new CC_String( localstr );
int *bogus = new int(0);
if ( !viewset->contains( str ) ) {
viewset->insertKeyAndValue( str,bogus );
}
else {
Token::signalError(Token::User, Token::Continuable, 0, 0,
"Duplicate stylesheet id `%s'", localstr);
return;
}
int online_bufsize=onlineSS->GetSize();
const char *online_buf = onlineSS->GetBuffer();
int print_bufsize= printSS->GetSize();
const char *print_buf = printSS->GetBuffer();
done(localstr,
online_buf, online_bufsize,
print_buf, print_bufsize);
}
int StyleTask::exist( const char * str )
{
CC_String tmp(str);
return( viewset->contains( &tmp ) );
}
const char *
StyleTask::print()
{
const char *ret = 0;
if(printSS) ret = printSS->GetBuffer();
return ret;
}
int
StyleTask::print_data_size()
{
if (printSS) return ( printSS->GetSize() );
else return 0;
}
const char *
StyleTask::online()
{
return onlineSS->GetBuffer();
}
int
StyleTask::online_data_size()
{
if ( onlineSS ) return ( onlineSS->GetSize() );
else return 0;
}

View File

@@ -0,0 +1,118 @@
/* $XConsortium: StyleTask.h /main/3 1996/08/21 15:47:29 drk $ */
/* $XConsortium: StyleTask.h /main/3 1996/08/21 15:47:29 drk $ */
#ifndef __StyleTasks_h
#define __StyleTasks_h
#include "Task.h"
#include "FlexBuffer.h"
#include "dti_cc/CC_String.h"
#include "dti_cc/cc_hdict.h"
#include "dti_cc/CC_Stack.h"
class BookCaseTask;
class DataTask;
class DB;
class DBTable;
class FlexBuffer;
class OL_Data;
class imp_die;
class StyleTask : public ComplexTask{
public:
StyleTask();
~StyleTask();
/*
* USE:
* StyleTask t;
* t.markup(...); ... t.data(...); ...
* const char *l = t.locator();
*/
const char * locator() /* throw(Unexpected) */;
void reset(void);
void markup(const Token&);
void data(const char *, size_t );
int exist( const char * view ); /*
* Given a view determine if it exists?
*/
/*
* USE:
* StyleTask st(...);
* st.markup(...); st.data(...); ... // feed stylesheet to the task
* const char *p = st.print();
* const char *o = st.online();
*/
const char *print();
int print_data_size();
const char *online();
int online_data_size();
protected:
void write_record( void );
/* comments below to avoid compiler warnings... */
virtual void done(const char * /*name*/,
const char * /*online*/, int /*online_len*/,
const char * /*print*/, int /*print_len*/) {};
private:
int
f_base; /* tag nesting level of <STYLESHEET> elt */
int f_select;
enum { inPath, startContent, inContent } f_dataMode;
FlexBuffer
*f_buffer,
*f_pathbuf,
*onlineSS,
*printSS; /*
* The style sheet data proper.
* Need to determine if it gets transformed
* or not.
*/
OL_Data
*f_locator;
hashTable<CC_String,int>
*viewset; /*
* List of views,
* Must be a unique set of names.
*/
Stack<int> *feature_depth;
};
class StyleTaskDB : public StyleTask{
public:
StyleTaskDB(BookCaseTask *);
BookCaseTask *bookcase() { return f_bookcase; };
protected:
virtual void done(const char * name,
const char * online, int online_len,
const char * print, int print_len);
private:
BookCaseTask
*f_bookcase; /* 'parent' bookcase object */
};
#endif /* __StyleTasks_h */

View File

@@ -0,0 +1,38 @@
/* $XConsortium: StyleTaskDB.cc /main/2 1996/07/18 15:20:49 drk $ */
/* export... */
#include "StyleTask.h"
/* import... */
#include <assert.h>
#include "BookCaseDB.h"
#include "BookTasks.h"
#include "DataBase.h"
//---------------------------------------------------------------------
StyleTaskDB::StyleTaskDB(BookCaseTask *bc)
: StyleTask()
{
f_bookcase = bc;
}
void StyleTaskDB::done(const char * name,
const char * online, int online_len,
const char * print, int print_len)
{
/*
* Use -STRING_CODE instead of STRING_CODE to handle 8-bit clean
* data
*/
DBTable *tbl = f_bookcase->table(BookCaseDB::StyleSheet);
tbl->insert(STRING_CODE, name,
-STRING_CODE, online, online_len,
-STRING_CODE, print, print_len,
NULL);
reset();
}

View File

@@ -0,0 +1,118 @@
/* $XConsortium: StyleUpdate.C /main/7 1996/08/21 15:47:33 drk $ */
#include <stdio.h>
#include <iostream.h>
#include "Exceptions.hh"
#include "dti_cc/CC_Stack.h"
#include "DataBase.h"
#include "SearchPath.h"
#include "Dispatch.h"
#include "Task.h"
#include "StyleTask.h"
#include "OLAF.h"
#include "Handler.h"
#include "StyleValidate.h"
#include "oliasdb/mmdb.h"
#include "oliasdb/stylesheet_hd.h"
#include "utility/mmdb_exception.h"
#ifdef FISH_DEBUG
#include "dbug.h" /* Fred Fish's dbug.h */
#endif
//---------------------------------------------------------------------
int main(int argc, char **argv)
{
INIT_EXCEPTIONS();
/* can't seem to get C++ initialization stuff to do this... */
OLAF::init();
set_new_handler( FreeStoreException );
int ret = 1;
#ifdef FISH_DEBUG
DBUG_PROCESS(argv[0]);
if(getenv("FISH_DBUG")) DBUG_PUSH(getenv("FISH_DBUG"));
#endif
if(argc == 3){
char *infolibDir = argv[1];
char *bcname = argv[2];
OLIAS_DB mmdb_handle;
info_lib *mmdb = mmdb_handle.openInfoLib(infolibDir, bcname);
info_base* ibase = mmdb->get_info_base(bcname);
SearchPath *sptable = new SearchPath( ".", NULL );
Dispatch::search_path_table = sptable;
StyleTask *styleTask = new StyleTask( );
Stack<int> *istack = new Stack<int>;
Dispatch::setRoot(styleTask, istack);
try{
try{
extern int yylex();
yylex();
const char *styleName = styleTask->locator();
stylesheet_smart_ptr sty(ibase, styleName);
const char *ps = styleTask->print();
int ps_size = styleTask->print_data_size();
const char *os = styleTask->online();
int os_size = styleTask->online_data_size();
if(!ps) ps = "";
if( validate_stylesheet( ps, ps_size, PRINT ) ){
Token::signalError(Token::User, Token::Fatal, 0, 0,
"Print style sheet is invalid; update aborted.");
}
if(!os) os = "";
if( validate_stylesheet( os, os_size, ONLINE ) ){
Token::signalError(Token::User, Token::Fatal, 0, 0,
"Online style sheet is invalid; update aborted.");
}
sty.update_hardcopy_data(ps, ps_size );
sty.update_online_data(os, os_size );
ret = 0;
}catch(Unexpected&, u){
Dispatch::tok->reportError(Token::User, Token::Fatal,
"markup error: %s", u.msg());
}
catch(PosixError&, p){
Token::signalError(Token::Internal, Token::Fatal, 0, 0,
"%s", p.msg() );
}end_try;
}catch(ErrorReported&, e){
/* error is already reported. */
}catch(mmdbException&, e){
cerr << e;
}
catch_any() {
fprintf(stderr, "*** Internal Error ***: unexpected exception\n");
abort();
}end_try;
}else{
fprintf(stderr,
"usage: sgmls styleheet | StyleUpdate <infolib> <bookcase>\n");
}
return ret;
}

View File

@@ -0,0 +1,48 @@
/* $XConsortium: StyleValidate.cc /main/2 1996/07/18 16:18:13 drk $ */
#include <stdio.h>
#include <iostream.h>
#include <stream.h>
#include <unistd.h>
#include <sys/wait.h>
#include "DataBase.h"
#include "StyleValidate.h"
//---------------------------------------------------------------------
int
validate_stylesheet( const char *buf, int buf_size, enum RENDERER_ENGINE_T t )
{
char *styleFile = form( "/usr/tmp/style_sheet.%d", getpid() );
FILE *fp = fopen( styleFile, "w" );
if ( !fp ) {
throw( PosixError(1, "Unable to open style_sheet\n") );
}
fwrite( (char *)buf, buf_size, 1, fp );
fclose( fp );
char* renderer = 0;
switch ( t ) {
case ONLINE:
renderer = "online";
break;
case PRINT:
renderer = "hardcopy";
break;
default:
throw( PosixError(1, "Unknown renderer engine\n") );
}
char *cmd = form("validator %s %s", renderer, styleFile);
int status = system(cmd);
int exit_status = WEXITSTATUS(status);
unlink( styleFile );
return (exit_status);
}

View File

@@ -0,0 +1,10 @@
/* $XConsortium: StyleValidate.h /main/2 1996/07/18 16:50:17 drk $ */
// Usage :
// int status = validate_stylesheet( style_sheet, style_sheet_size );
// if (status) { fprintf(stderr, "failed"); }
enum RENDERER_ENGINE_T { ONLINE, PRINT };
extern int validate_stylesheet( const char *buf,int buf_size, enum RENDERER_ENGINE_T );

View File

@@ -0,0 +1,86 @@
/* $TOG: TKTemplate.C /main/6 1998/04/17 11:43:37 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.
*/
#include "dti_cc/CC_Stack.h"
#include "dti_cc/CC_Stack.C"
#include "dti_cc/CC_Slist.h"
#include "dti_cc/CC_Slist.C"
#include "dti_cc/cc_pvect.h"
#include "dti_cc/cc_pvect.C"
#include "dti_cc/cc_hdict.h"
#include "dti_cc/cc_hdict.C"
#include "BTCollectable.h"
#include "DataRepository.h"
#include "dti_cc/CC_String.h"
#ifdef _IBMR2
#pragma define (Stack<int>)
#pragma define (CC_TPtrSlist<CC_String>)
#pragma define (hashTable<CC_String, BTCollectable>)
#pragma define (hashTable<CC_String, int>)
#pragma define (hashTableIterator<CC_String, BTCollectable>)
#pragma define (hashTableIterator<CC_String, int>)
#pragma define (Stack<Rec>)
#endif
#ifdef __osf__
#pragma define_template Stack<int>
#pragma define_template CC_TPtrSlist<CC_String>
#pragma define_template hashTable<CC_String, BTCollectable>
#pragma define_template hashTable<CC_String, int>
#pragma define_template hashTableIterator<CC_String, BTCollectable>
#pragma define_template hashTableIterator<CC_String, int>
#pragma define_template Stack<Rec>
#pragma define_template CC_TValSlist<int>
#pragma define_template CC_TPtrSlist<kv_pair<CC_String, BTCollectable> >
#pragma define_template CC_TPtrSlist<kv_pair<CC_String, int> >
#pragma define_template CC_TValSlist<Rec>
#pragma define_template CC_TValSlistIterator<int>
#pragma define_template CC_TValSlistIterator<Rec>
#pragma define_template kv_pair<CC_String, BTCollectable>
#pragma define_template pointer_vector<CC_TPtrSlist<kv_pair<CC_String, BTCollectable> > >
#pragma define_template kv_pair<CC_String, int>
#pragma define_template pointer_vector<CC_TPtrSlist<kv_pair<CC_String, int> > >
CC_Boolean kv_pair<CC_String, BTCollectable>::f_needRemove = FALSE;
CC_Boolean kv_pair<CC_String, int>::f_needRemove = FALSE;
#endif
#ifdef USL
#pragma instantiate Stack<int>
#pragma instantiate CC_TPtrSlist<CC_String>
#pragma instantiate hashTable<CC_String, BTCollectable>
#pragma instantiate hashTable<CC_String, int>
#pragma instantiate hashTableIterator<CC_String, BTCollectable>
#pragma instantiate hashTableIterator<CC_String, int>
#pragma instantiate Stack<Rec>
#pragma instantiate CC_TValSlist<int>
#pragma instantiate CC_TPtrSlist<kv_pair<CC_String, BTCollectable> >
#pragma instantiate CC_TPtrSlist<kv_pair<CC_String, int> >
#pragma instantiate CC_TValSlist<Rec>
#pragma instantiate CC_TValSlistIterator<int>
#pragma instantiate CC_TValSlistIterator<Rec>
#pragma instantiate kv_pair<CC_String, BTCollectable>
#pragma instantiate pointer_vector<CC_TPtrSlist<kv_pair<CC_String, BTCollectable> > >
#pragma instantiate kv_pair<CC_String, int>
#pragma instantiate pointer_vector<CC_TPtrSlist<kv_pair<CC_String, int> > >
#endif
#if !defined(__osf__) && !defined(IBMR2)
typedef Stack<int> _f1_;
typedef CC_TPtrSlist<CC_String> _f2_;
typedef hashTable<CC_String, BTCollectable> _f3_;
typedef hashTable<CC_String, int> _f4_;
typedef hashTableIterator<CC_String, BTCollectable> _f5_;
typedef hashTableIterator<CC_String, int> _f6_;
typedef Stack<Rec> _f7_;
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,163 @@
/* $XConsortium: TOCTask.cc /main/2 1996/07/18 15:21:32 drk $ */
/* exported interfaces... */
#include "TOCTask.h"
/* imported interfaces... */
#include "Token.h"
#include "AttributeRec.h"
#include "OLAF.h"
#include "SGMLName.h"
#include "OL-Data.h"
#include "BookTasks.h"
#include "DataBase.h"
#include "BookCaseDB.h"
/*
* TOCTask
*/
TOCTask::TOCTask(const Token& t, BookTask *book, TOCTask *parent, int sibindx)
{
f_book = book;
f_parent = parent;
f_sibling_index = sibindx;
f_base = t.level();
f_locator = NULL;
markup(t);
}
int toc_depth(const Token& t)
{
int ret = -1;
const AttributeRec *a;
if( t.LookupAttr( OLAF::OL_ToC ) ){
ret = 0;
}
else if(a = t.LookupAttr( OLAF::OL_ToCEntry )){
const char *val;
if(val = a->getAttrValueString()){
ret = atoi(val);
}
}
return ret;
}
void TOCTask::markup(const Token& t)
{
if(f_base >= 0){
if(f_locator) f_locator->markup(t);
if(used > 0) subtasks[used-1]->markup(t);
if(t.type() == START){
if(f_locator == NULL){
/* locator for root node, TOC, is an OL_id.
* others are OL_idref
*/
if(f_parent == NULL && t.LookupAttr(OLAF::OL_id)){
f_locator = new OL_Data(t, OLAF::OL_id, REMOVE_SPACES);
}
else if(f_parent != NULL && t.LookupAttr(OLAF::OL_idref)){
f_locator = new OL_Data(t, OLAF::OL_idref, REMOVE_SPACES);
}
}
if (t.level() == f_base + 1
&& t.LookupAttr( OLAF::OL_ToCEntry ) ){
TOCTask *child = new TOCTask(t, f_book, this, used + 1);
addSubTask(child);
}
}
else if(t.type() == END){
if(t.level() == f_base){
if(f_parent == 0){ /* is this the root node? */
/* tree is now complete. write it out. */
BookCaseTask *bc = f_book->bookcase();
write_tree(bc->table(BookCaseDB::TOCTree));
/* write out path too */
write_path(bc->table(BookCaseDB::TOCPath));
}
f_base = -1;
}
}
}
}
void TOCTask::data(const char *chars, size_t len)
{
if(f_locator) f_locator->data(chars, len);
if(used) subtasks[used-1]->data(chars,len);
}
const char *TOCTask::locator()
{
if (!f_locator){
throw(Unexpected("No locator for TOC entry"));
}
return f_locator->content();
}
void TOCTask::write_path(DBTable *tbl)
{
tbl->insert(STRING_CODE, f_book->locator(),
STRING_CODE, locator(),
INTEGER_CODE, f_locator->line_no(),
STRING_CODE, f_locator->filename(),
NULL);
for(int i = 0; i < used; i++){
((TOCTask*)subtasks[i])->write_path(tbl);
}
}
int TOCTask::write_tree(DBTable *tbl)
{
const char **children = NULL;
int qty = 1;
if(used){
children = (const char **)new char*[used];
for(int i = 0; i < used; i++){
TOCTask *ch = (TOCTask*)subtasks[i];
children[i] = ch->locator();
qty += ((TOCTask*)subtasks[i])->write_tree(tbl);
}
}
tbl->insert(STRING_CODE, f_book->locator(),
STRING_CODE, locator(),
STRING_CODE, f_parent ? f_parent->locator() : "",
SHORT_LIST_CODE,
used, STRING_CODE, children,
INTEGER_CODE, qty,
NULL);
delete children;
return qty;
}

View File

@@ -0,0 +1,79 @@
/* $XConsortium: TOCTask.h /main/2 1996/07/18 15:21:52 drk $ */
#ifndef __TOCTask_h
#define __TOCTask_h
#include "Task.h"
#include "OL-Data.h"
class DBTable;
class BookTask;
class TOCTask : public ComplexTask{
/*
* TOCTask is used to build two tables:
*
* Table name: ContentsTree
* Fields:
* STRING_CODE book/toc locator
* STRING_CODE node locator
* STRING_CODE parent node locator
* SHORT_LIST_CODE of STRING_CODE child node locator
*
* Table name: ContentsPath
* Fields:
* STRING_CODE book/toc locator
* STRING_CODE node locator
*
* Each TOCTask maintains:
* a subtask to gather the locator of the node it refers to
* (or, in the case of the root TOC node, the locator of the TOC)
* a "current" child subtask
* it also uses the subtasks[] array to hold tasks that are no longer
* "active" (i.e. receiving markup() and data()).
*
* The TOCTask determines when to create a new "current" subtask
* in its markup() method.
*
* When the root TOC node completes, it uses the write_tree() and write_path()
* methods to walk the whole tree of TOCTasks twice to build the tables.
*/
public:
TOCTask(const Token& t, BookTask *book,
TOCTask *parent = NULL, int sibling_index = 0);
~TOCTask() { delete f_locator; }
void markup(const Token& t); /* throw Unexpected */
void data(const char *chars, size_t len);
const char *locator(); /* throw Unexpected */
protected:
TOCTask *parent() { return f_parent; };
TOCTask *left() { return f_parent && f_sibling_index > 0 ?
(TOCTask*)f_parent->subtask(f_sibling_index - 1) : NULL;
};
TOCTask *right() { return f_parent &&
f_sibling_index + 1 < f_parent->used ?
(TOCTask*)f_parent->subtask(f_sibling_index + 1) : NULL;
};
void write_path(DBTable *tbl);
int write_tree(DBTable *tbl); /* return size of subtree */
private:
int f_base;
BookTask *f_book;
TOCTask *f_parent;
int f_sibling_index;
OL_Data *f_locator;
};
#endif

View File

@@ -0,0 +1,315 @@
/* $XConsortium: TableTask.C /main/3 1996/08/21 15:47:46 drk $ */
/* exported interfaces... */
#include "TableTask.h"
/* imported interfaces... */
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
#include "FlexBuffer.h"
#include "Token.h"
#include "SGMLName.h"
#include "dbug.h"
#define NAMECASE 1
int TableTask::TGroup;
int TableTask::ColSpec;
int TableTask::Row;
int TableTask::TBody;
int TableTask::Entry;
TableTask::TableTask(const Token& t)
{
static int inited = 0;
if(!inited){
TGroup = SGMLName::intern("TGroup", NAMECASE);
ColSpec = SGMLName::intern("ColSpec", NAMECASE);
Row = SGMLName::intern("Row", NAMECASE);
TBody = SGMLName::intern("TBody", NAMECASE);
Entry = SGMLName::intern("Entry", NAMECASE);
inited = 1;
}
f_base = t.level();
f_buf = new FlexBuffer();
state = Start;
markup(t);
}
TableTask::~TableTask()
{
delete f_buf;
}
void
TableTask::markup(const Token& t)
{
int again = 0;
if(t.type() == END && t.level() == f_base){
write_record();
delete this; /* this object deletes itself when it's done. */
return;
}
do{
switch(state){
case Start:
if(t.type() == START && t.Gi() == TGroup){
// @@ attributes?
/*
* _@Tab
* @Fmta {_
*/
puts("@Tab\n"
" @Fmta {");
f_cols = 0;
state = Fmt_;
}
else{
expected("TGROUP", t);
}
case Fmt_:
if(t.Gi() == ColSpec){
// @@ attributes?
if(f_cols < 26){
/*
* @Tab
* @Fmta_ { @Col A_
*/
if(f_cols > 0) puts(" ! ");
puts(" @Col ");
putC('A' + f_cols);
f_cols++;
}else{
error("Too many columns. Maximum is 26.");
}
}
else if(t.Gi() == Row){
/*
* @Tab
* @Fmta { @Col A ! @Col B ! ..._ }
* {
* _
*/
puts(" }\n"
"{\n");
state = _Row;
}
else{
error("Expected <COLSPEC> or <ROW>; found <%s%s>",
t.type() == END ? "/" : "", t.giName());
}
break;
case _Row:
if(t.type() == START && t.Gi() == Row){
// @@ attributes?
/*
* @Tab
* @Fmta { @Col A ! @Col B ! ..._ }
* {
* _ @Rowa _
*/
puts(" @Rowa ");
f_col = 0;
state = _Entry;
}
else if(t.type() == END && t.Gi() == TBody){
/*
* @Tab
* @Fmta { @Col A ! @Col B ! ... }
* {
* @Rowa A { abc } B { def }
* _}
* _
*/
puts("}\n");
state = End;
}
else{
expected("ROW", t); /*@@ or </TBODY> */
}
break;
case _Entry:
if(t.type() == START && t.Gi() == Entry){
// @@ attributes?
if(f_col < f_cols){
/*
* @Tab
* @Fmta { @Col A ! @Col B ! ... }
* {
* @Rowa _A { _
*/
putC('A' + f_col);
f_col ++;
puts(" { ");
f_entryBase = t.level();
state = Object;
}else{
error("Too many entries in row: only %s columns specified",
f_cols);
}
}
if(t.type() == END && t.Gi() == Row){
/*
* @Tab
* @Fmta { @Col A ! @Col B ! ... }
* {
* @Rowa A { abc } B { def } _
* _
*/
puts("\n");
f_col = 0;
state = _Row;
}
else{
expected("ENTRY", t);
}
break;
case Object:
if(t.type() == END && t.level() == f_entryBase){
/*
* @Tab
* @Fmta { @Col A ! @Col B ! ... }
* {
* @Rowa A { object } _
*/
puts(" } ");
state = _Entry;
}
else{
putC(' '); /* @# put whitespace in for markup to make
* "a<tag>b" come out as "a b" in stead of "ab"
*/
/* @@ markup within an entry ignored ?!!? */
}
break;
case End:
break;
default:
abort();
}
}while(again);
}
void
TableTask::expected(const char *right, const Token& wrong)
{
error("Expected <%s>; found <%s%s>",
right, wrong.type() == END ? "/" : "", wrong.giName());
}
void
TableTask::error(const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
/* @# more info here? */
vfprintf(stderr, fmt, ap);
va_end(ap);
}
void
TableTask::putC(char c)
{
f_buf->put(c);
}
void
TableTask::puts(const char *s)
{
f_buf->writeStr(s);
}
void
TableTask::write(const char *buf, size_t len)
{
f_buf->write(buf, len);
}
void
TableTask::data(const char *chars, size_t len)
{
while(len--){
char c = *chars++;
switch(c){
case '/':
case '|':
case '&':
case '{':
case '}':
case '#':
case '@':
case '^':
case '"':
case '\\':
putC('\\');
putC(c);
break;
default:
putC(c);
}
}
}
SearchableTableTask::SearchableTableTask(SearchEngine *s, const Token& t)
: TableTask(t)
{
f_search = s;
}
void
SearchableTableTask::write_record()
{
DBUG_PRINT("Table", ("Lout table: `%s'", f_buf->GetBuffer()));
/*@@ write to BookCaseDB? Convert to PS? */
}

View File

@@ -0,0 +1,61 @@
/* TableTask.h -*- c++ -*-
* $XConsortium: TableTask.h /main/2 1996/07/18 15:22:35 drk $
*/
#ifndef __TableTask_h
#define __TableTask_h
#include "Task.h"
class FlexBuffer;
class TableTask : public Task{
public:
TableTask(const Token& t);
~TableTask();
void markup(const Token& t);
void data (const char *chars, size_t len);
protected:
void putC(char c);
void puts(const char *);
void write(const char *, size_t);
enum { Start, Fmt_, _Row, _Entry, Object, End } state;
static int TGroup, ColSpec, Entry, Row, TBody;
void error(const char *fmt, ...);
void expected(const char *right, const Token& wrong);
virtual void write_record() = 0;
FlexBuffer *f_buf; /* output buffer */
private:
int f_base; /* level of <TGROUP> token */
int f_entryBase; /* level of <ENTRY> token */
int f_cols; /* total number of colums in the table */
int f_col; /* current column (in Row_ state) */
};
class SearchEngine;
class SearchableTableTask : public TableTask{
public:
SearchableTableTask(SearchEngine *se, const Token& t);
protected:
void write_record();
private:
SearchEngine *f_search;
};
#endif /* __TableTask_h */

View File

@@ -0,0 +1,196 @@
/* $XConsortium: Task.cc /main/2 1996/07/18 15:22:57 drk $ */
/* $XConsortium: Task.cc /main/2 1996/07/18 15:22:57 drk $ */
/* exported interfaces... */
#include "Task.h"
/* imported interfaces... */
#include <string.h>
#include <stdlib.h>
#include <stdarg.h>
#include "SGMLName.h"
#include "Token.h"
#include "AttributeRec.h"
ComplexTask::ComplexTask()
{
used = alloc = 0;
subtasks = NULL;
}
ComplexTask::~ComplexTask()
{
int i;
for(i = 0; i < used; i++){
delete subtasks[i];
}
if ( subtasks ) delete subtasks;
}
void ComplexTask::removeAllSubTasks()
{
for ( int i = 0; i < used; i++ ) {
delete subtasks[i];
}
if ( subtasks ) { delete subtasks; subtasks = 0; }
used = alloc = 0;
}
void ComplexTask::addSubTask(Task *t)
{
grow(used + 1);
subtasks[used++] = t;
}
void ComplexTask::stopSubTask(Task *t)
{
for(int i = 0; i < used; i++){
if(subtasks[i] == t){
while(i + 1 < used){
subtasks[i] = subtasks[i+1];
i++;
}
used--;
return;
}
}
fprintf(stderr, "Internal errnor: stop unknown task.");
abort();
}
void
ComplexTask::grow(int needed)
{
if(needed + 1 > alloc){
Task **born = new Task*[alloc = needed * 3 / 2 + 10];
if(used){
memcpy(born, subtasks, sizeof(Task*) * used);
delete subtasks; subtasks = 0;
}
subtasks = born;
}
}
void ComplexTask::markup(const Token& t)
{
int i;
for(i = 0; i < used; i++){
subtasks[i]->markup(t);
}
}
void ComplexTask::data(const char *d, size_t len)
{
int i;
for(i = 0; i < used; i++){
subtasks[i]->data(d, len);
}
}
#if TEST_TASK
#include <stdio.h>
void TestTask::markup(const Token &t)
{
switch(t.type()){
case START:
printf("\nStart Element: %s\n", t.giName());
const AttributeRec *a;
for(a = t.GetFirstAttr(); a ; a = t.GetNextAttr(a)){
const char *ty = SGMLName::lookup(a->getAttrType());
printf("Attribute: %s = [%s]`%s'\n",
SGMLName::lookup(a->getAttrName()), ty, a->getAttrValueString());
}
break;
case END:
printf("End Element: %s\n", t.giName());
break;
default:
printf("Unknown Token Type: %d\n", t.type());
abort();
break;
}
}
void TestTask::data(const char *data, size_t)
{
printf("data: `%s'\n", data);
}
/*
* TestTask 2 is for OL-Data testing
*/
#include <stdio.h>
#include "OLAF.h"
#include "OL-Data.h"
TestTask2::TestTask2()
{
f_base = -1;
}
void TestTask2::markup(const Token &t)
{
ComplexTask::markup( t );
switch(t.type()){
case START:
/*
* See if any OLIAS Architecture Form exists
*/
if ( t.AttributeMatch( OLAF::OLIAS, OLAF::Graphic ) ) {
f_base = t.level();
if ( t.LookupAttr( OLAF::OL_data ) )
ComplexTask::addSubTask( new OL_Data ( t, OLAF::OL_data ) );
}
break;
case END:
if ( f_base == t.level() ) {
for ( int i=0; i < ComplexTask::used; i++ ) {
OL_Data *t = ( OL_Data *) subtask(i);
cout << "OL_Data found = " << t->content() << endl;
}
}
break;
default :
break;
}
}
void TestTask2::data(const char *data, size_t t)
{
ComplexTask::data( data, t );
}
#endif

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