2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
6 * These libraries and programs are free software; you can
7 * redistribute them and/or modify them under the terms of the GNU
8 * Lesser General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
12 * These libraries and programs are distributed in the hope that
13 * they will be useful, but WITHOUT ANY WARRANTY; without even the
14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these librararies and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
23 /* $XConsortium: Dispatch.cc /main/2 1996/06/11 16:49:03 cde-hal $
25 * (c) Copyright 1996 Digital Equipment Corporation.
26 * (c) Copyright 1996 Hewlett-Packard Company.
27 * (c) Copyright 1996 International Business Machines Corp.
28 * (c) Copyright 1996 Sun Microsystems, Inc.
29 * (c) Copyright 1996 Novell, Inc.
30 * (c) Copyright 1996 FUJITSU LIMITED.
31 * (c) Copyright 1996 Hitachi.
34 /* exported interfaces... */
37 /* imported interfaces... */
42 #include "EntityScope.h"
44 #include "FlexBuffer.h"
46 #include "SearchPath.h"
50 Task *Dispatch::TaskObject = NULL;
51 Stack<int> *Dispatch::IgnoreStack = NULL;
52 int Dispatch::level = 0;
53 static EntityScope entity_stack;
54 Token* Dispatch::tok = new Token();
56 char* Dispatch::f_file = NULL;
57 int Dispatch::f_line = 0;
59 const char *Dispatch::tmpdir = NULL;
60 const char *Dispatch::srcdir = NULL;
61 SearchPath *Dispatch::search_path_table = NULL;
63 int Dispatch::tocgen_only = 0;
65 //---------------------------------------------------------------------
67 Dispatch::token(TOKEN_TYPE tokType, unsigned char *Name )
70 tok->setFileLine(f_file, f_line);
75 tok->StoreStartTag( Name, level );
77 if ( tok->LookupAttr( OLAF::OL_Ignore )
78 || tok->LookupAttr( OLAF::OL_ShortTitle ) ) {
79 IgnoreStack->push ( level );
85 tok->StoreEndTag ( Name, level );
90 tok->StoreEntity( Name , INTERNAL_ENTITY);
94 tok->StoreEntity( Name , EXTERNAL_ENTITY);
97 sgml_rec = entity_stack.LookupEntity( SGMLName::intern((char*)Name) );
100 tok->SetEntityValue( sgml_rec );
102 tok->reportError(Token::Internal, Token::Fatal,
103 "Unable to find entity definition for %.50s", Name);
109 TaskObject->markup( *tok );
111 if ( tokType == END ) {
112 if ( !IgnoreStack->empty() ) {
114 int topelement = IgnoreStack->top();
115 if ( topelement == tok->level() ) {
116 topelement = IgnoreStack->pop();
127 //---------------------------------------------------------------------
128 void Dispatch::setRoot( Task *t, Stack<int> *istack)
130 assert(TaskObject == NULL);
133 assert(IgnoreStack == NULL);
134 IgnoreStack = istack;
138 //---------------------------------------------------------------------
140 Dispatch::entity_ref( const char *ent_name )
143 ent_num = SGMLName::intern(ent_name);
144 SGMLDefn *sgml_rec = entity_stack.LookupEntity( ent_num );
149 //---------------------------------------------------------------------
151 Dispatch::entity_decl( SGMLDefn *defn )
153 EntityList *escope = entity_stack.GetTopEntities();
155 assert(escope != NULL);
158 * first clone up an SGMLDefn record for storage purposes
161 SGMLDefn *sgmlRec = new SGMLDefn();
164 escope->insert( sgmlRec );
167 //---------------------------------------------------------------------
169 Dispatch::file(const char *f)
172 f_file = new char[strlen(f)+1];
177 * put directory of f_file into the search path also
179 if(search_path_table){
180 // perform dirname first
181 char *dirname = strdup( f_file );
182 char *p = strrchr( dirname, '/' );
187 strcpy( dirname,"." );
190 search_path_table->replace_file_scope( dirname );
195 //---------------------------------------------------------------------
197 Dispatch::subdoc_start()
199 EntityList *newrec = new EntityList();
200 entity_stack.push ( newrec );
203 //---------------------------------------------------------------------
205 Dispatch::subdoc_end()
207 EntityList *rec = entity_stack.pop();
210 throw(Unexpected("SUBDOC end tag is not matched"));