RastEventHandler.cxx revision 7c478bd95313f5f23a4c958a745db2134aa03244
// Copyright (c) 1994,1995 James Clark
// See the file COPYING for copying permission.
#pragma ident "%Z%%M% %I% %E% SMI"
#ifdef __GNUG__
#pragma implementation
#endif
#include "config.h"
#include "RastEventHandler.h"
#include "SgmlParser.h"
#include "ParserOptions.h"
#include "Entity.h"
#include "Notation.h"
#include "Attribute.h"
#include "Vector.h"
#include "Vector.h"
#include "MessageArg.h"
#include "RastEventHandlerMessages.h"
#include <stdlib.h>
#include <string.h>
#ifdef SP_NAMESPACE
namespace SP_NAMESPACE {
#endif
class EventHandlerMessenger : public Messenger {
public:
}
}
private:
};
#if 0
const
#endif
{
static const char s[] =
" !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~";
size_t i;
for (i = 0; i < sizeof(v_); i++)
v_[i] = 0;
for (i = 0; s[i] != '\0'; i++)
v_[(unsigned char)s[i]] = 32 + i;
}
// inline
{
if (lineLength_ > 0) {
lineLength_ = 0;
}
}
{
init(0, 0);
}
{
}
{
hadActiveLpdOrDtd_ = 0;
hadDocumentElement_ = 0;
haveLinkProcess_ = 0;
for (int i = 0; i < nAttributeType; i++)
attributeSortOrder_[i].clear();
}
{
{
}
{
}
{
}
for (int i = 0; i < nAttributeType; i++)
}
: lineLength_(0),
os_(0),
piErrorCount_(0),
RastSubdocState(parser, this),
{
}
void RastEventHandler::end()
{
if (errorCount() != 0) {
os() << (piErrorCount_ != 0
? "#RAST-PI-ERROR"
: "#ERROR")
<< nl;
}
}
void RastEventHandler::truncateOutput()
{
// This must be handled by derived classes to get conforming output.
}
{
delete event;
}
{
if (!hadDocumentElement_) {
if (activeLinkTypes_.size() > 0) {
activeLinks();
}
hadDocumentElement_ = 1;
}
hadNewline = 1;
}
else
hadNewline = 0;
if (haveLinkProcess_) {
const AttributeList *linkAttributes;
const ResultElementSpec *resultElementSpec;
EventHandlerMessenger messenger(this);
event->attributes(),
if (linkProcess_.nImpliedLinkRules() > 0) {
if (!hadNewline) {
hadNewline = 1;
}
}
if (linkAttributes) {
if (!hadNewline) {
hadNewline = 1;
}
if (linkProcess_.isExplicit()) {
os() << "#RESULT=";
}
else
}
}
else
hadNewline = 0;
}
delete event;
}
void RastEventHandler::activeLinks()
{
found = 1;
if (linkProcess_.nImpliedLinkRules() > 0) {
}
}
if (!found) {
if (endPrologEvent_) {
found = 1;
break;
}
}
if (!found) {
}
}
}
}
void RastEventHandler::simpleLinkInfo()
{
if (!endPrologEvent_)
return;
if (name == activeLinkTypes_[i]) {
break;
}
}
}
}
{
size_t i;
for (i = 0; i < n; i++)
sortOrder[i] = i;
for (i = 1; i < n; i++) {
size_t j;
for (j = i; j > 0; j--) {
name) <= 0)
break;
}
}
for (i = 0; i < n; i++) {
const ResultElementSpec &result
}
}
}
{
if (haveLinkProcess_)
}
delete event;
}
{
delete event;
}
{
os() << "[?";
if (dataLength > 0) {
if (dataLength >= 4
4*sizeof(Char)) == 0
}
}
delete event;
}
inline
{
&& (n1 == 0
}
// Is s2 a prefix of s1 of length n1?
inline
{
&& (n1 == 0
}
{
queueParseSubdoc(0);
return 1;
}
queueParseSubdoc(1);
return 1;
}
if (hadActiveLpdOrDtd_)
return 1;
hadActiveLpdOrDtd_ = 1;
for (;;) {
if (n == 0 || *p == ',') {
return 0;
if (name == activeLinkTypes_[i]) {
}
if (n == 0)
break;
}
else
name += *p;
p++;
n--;
}
return 1;
}
LinkRulePi *p = new LinkRulePi;
linkRuleQueue_.append(p);
return 1;
}
return 0;
}
{
delete event;
}
{
if (!entity)
return;
delete event;
}
{
char c;
c = 'C';
break;
c = 'S';
break;
c = 'N';
break;
default:
return;
}
: dtdAttribute));
}
{
if (!entity)
return;
delete event;
}
{
if (parseNextSubdoc()) {
// FIXME subdocuments in entity attributes shouldn't count against
// SUBDOC quantity limit.
oldSubdocState.swap(*this);
}
}
{
}
{
if (parseSubdocQueue_.size() == 0)
return 0;
}
return result;
}
{
if (publicId) {
else {
}
}
if (!systemId)
else {
}
}
}
{
delete event;
}
{
// This needs to be fast.
while (length != 0) {
if (printable(*p)) {
switch (lineLength_) {
case maxLineLength:
lineLength_ = 0;
// fall through
case 0:
lim = maxLineLength;
break;
default:
break;
}
for (;;) {
p++;
if (--n == 0)
break;
if (!printable(*p)) {
lim -= n;
break;
}
}
lineLength_ += lim;
}
else {
// *p is an unprintable character print it
switch (*p) {
case RS:
break;
case RE:
break;
case TAB:
break;
default:
break;
}
p++;
length--;
}
}
}
{
for (;;) {
if (n1 == 0)
return n2 == 0 ? 0 : -1;
if (n2 == 0)
return 1;
// printable characters precede non-printable characters;
// printable characters are in ASCII order
// non-printable characters are in document character set order
if (a1 == 0) {
if (a2 == 0)
else
return 1;
}
else if (a2 == 0)
return -1;
else
}
p1++;
p2++;
n1--;
n2--;
}
}
{
if (length == 0)
return;
|| attributeType == simpleAttribute) {
size_t i;
for (i = 0; i < length; i++)
sortOrder[i] = i;
// insertion sort
for (i = 1; i < length; i++) {
size_t j;
for (j = i; j > 0; j--) {
break;
}
}
}
// Don't use sortOrder because attributeSortOrder_ may be grown
// because of data attributes.
if (value) {
case AttributeValue::implied:
break;
case AttributeValue::tokenized:
break;
case AttributeValue::cdata:
{
const Char *p;
switch (type) {
break;
break;
break;
default:
break;
}
}
break;
}
}
if (semantics) {
= entity->asExternalDataEntity();
if (externalDataEntity)
: dtdAttribute));
else {
if (subdocEntity) {
->tokenLocation(i));
}
else {
if (internalEntity)
}
}
}
}
}
}
}
{
if (!entity)
return;
os() << '#'
<< "DATA-INTERNAL" << nl;
}
{
haveLinkProcess_ = 1;
}
else
delete event;
}
{
}
delete event;
}
{
}
{
if (!cancelled()) {
}
}
: rast_(0)
{
}
{
}
// Always return 1. 0 means not ready.
{
selected = 0;
}
else {
if (linkAttributes.size() > 0) {
}
selected = 0;
}
return 1;
}
// Return zero for failure (RAST-PI-ERROR).
{
Boolean haveSelection = 0;
size_t i;
for (i = 0; i < linkAttributes.size(); i++) {
const AttributeList &a = *linkAttributes[i];
Boolean matchValue = 0;
case AttributeValue::cdata:
// What if it contains SDATA entities?
matchValue = 1;
break;
case AttributeValue::tokenized:
matchValue = 1;
break;
default:
break;
}
if (matchValue)
break;
}
if (matchValue) {
if (haveSelection) {
return 0;
}
haveSelection = 1;
selected = i;
}
}
if (!haveSelection) {
return 0;
}
return 1;
}
{
}
#ifdef SP_NAMESPACE
}
#endif