void init_entity()
- initializes this module
void debug_entity(b)
- sets the debug-flag for this module to b
Bool b;
void print_entity(file, gen, entity_name, text, ex_id, type, not_name)
- prints entity, for debugging
FILE *file;
String gen;
String entity_name;
String text;
P_Extern_id ex_id;
int type;
String not_name;
These functions are straight forward.
void define_parameter_entity(entity_name, text, extern_id, type, not_name)
- defines a parameter entity
String entity_name;
String text;
P_Extern_id extern_id;
int type;
String not_name;
void define_general_entity(entity_name, text, extern_id, type, not_name)
- defines a general entity
String entity_name;
String text;
P_Extern_id extern_id;
int type;
String not_name;
void define_entity(str, entities, entity_name, text, ex_id, type, not_name)
- defines a general or parameter entity
String str;
EntityTable entities;
String entity_name;
String text;
P_Extern_id ex_id;
int type;
String not_name;
Entities are stored in hash tables. One hashtable for general entities,
one for parameter entities.
The first two functions are used to define entities.
The third is a local function called by the others,
to actually define the entity.
The str parameter is one of { "general", "parameter" }.
Some of the parameters can be empty if they are not needed for the
specified type of the entity.
The type can be one of { LITERAL, STARTTAG, ENDTAG, MS, MD, CDATA, SDATA, PI,
EXTERNAL, SUBDOC, NDATA }.
LITERAL means that the entity consists only of a parameter literal.
EXTERNAL means that the entity is an external entity, that is not a SUBDOC or
NDATA.
The other types correspond to the keywords used in sections
10.5.3, 10.5.4, 10.5.5 on page 38-39 of the Standard.
Note that SUBDOC and NDATA entities are not allowed in basic SGML.
void switch_to_par_entity(ent_name)
- gets input from parameter entity ent_name
String ent_name;
void switch_to_gen_entity(ent_name)
- gets input from general entity ent_name
String ent_name;
void switch_to_entity(type, entity_table, ent_name)
- gets input from entity ent_name from entity_table
String type;
EntityTable entity_table;
String ent_name;
void leave_entity(ent_name)
- end of entity is reached
String ent_name;
Bool recursive_entity(info)
- checks whether entity info is already open
Entity *info;
The functions switch_to_par_entity() and switch_to_gen_entity()
perform a switch, to get input from the named parameter/general entity.
If the entity does not exist, is already open, or the number of
open entities is too big,
an error report will follow, and the switch will be ignored.
They call switch_to_entity() to perform the actual switch.
The parameter type is one of {``general'', ``parameter''} and is only used
in error-reports.
The entity_table is the hash table in which the entity ent_name must be found.
For general entities entity_table equals gen_table, for parameter
entities par_table.
recursive_entity() checks whether the entity is already open.
leave_entity() is called by the input manager (see ``in.c''), when the end of
an entity is reached.
int entity_type (entity_name)
- returns the type of a general entity
String ent_name;
This function returns the type of the named entity.
The entity must be a general entity.
This is only used in norm_val_length() in the file att_chk.c
to count the proper quantity for a CDATA entity.
P_Extern_id new_extern_id(type, pub_str, sys_str)
- creates a new extern identifier
int type;
String pub_str;
String sys_str;
String extern_id_system(ex_id)
- returns the system-string of ex_id
P_Extern_id ex_id;
String extern_id_public(ex_id)
- returns the public-string of ex_id
P_Extern_id ex_id;
int extern_id_type(ex_id)
- returns the type of ex_id
P_Extern_id ex_id;
void print_extern_id(file, ex_id)
- prints ex_id, used for debugging
FILE* file;
P_Extern_id ex_id;
These functions define the type P_Extern_id, used to act as
extern identifier (see Standard 10.1.6, page 35).
The function new_extern_id() creates an extern identifier.
The next three functions return values of the different fields of
an extern identifier.
void switch_to_extern_id(ex_id)
- gets input from extern identifier
P_Extern_id ex_id;
This function tries to open a file with the name of the system identifier
of ex_id or with the name of the public identifier of ex_id.
If this succeeds, input is taken from this file and TRUE is returned,
otherwise an error is reported and FALSE is returned.
void generate_entities(file)
- generates C code for all entities on file
FILE *file;
void generate_gen_entities()
- generate C code for all general entities
void generate_par_entities()
- generate C code for all parameter entities
The entities that are defined in the DTD must be known in the document parser.
The function generate_entities() generates C code for all entities.
It calls the other two functions to generate code for the general-
and the parameter entities.
These functions use hash_generator() with do_extern() and do_entity() as
parameters.
These functions are only used in the DTD-parser.
void do_entity(key, entity)
- generates C code for entity entity
String key;
Entity *entity;
void do_extern(key, entity)
- generates C code for extern identifier of entity
String key;
Entity *entity;
void generate_extern_id(file, id, var_name)
- print id in C structure
FILE* file;
P_Extern_id id;
String var_name;
These functions are only needed in the DTD-parser.
do_entity() generates code for an entity declaration.
do_extern() calls generate_extern_id() if entity is an extern entity.
The function generate_extern_id()
writes on a file the extern identifier in a C structure.
var_name is the variable name of the C-structure.
This file is to be included in the document parser.
void entity_notation(key, entity)
- checks whether entity is NDATA entity
String key;
Entity *entity;
void check_entity_notation()
- checks whether notations names of NDATA entities are defined
Every notation name of a NDATA entity must be defined as notation
in the same DTD.
entity.c entity.h