/* ***************************************************************************** * * $RCSfile: fileutil.h,v $ * $Date: 1999/06/25 18:13:04 $ * $Source: /home/richard/Xml/RCS/fileutil.h,v $ * $Revision: 1.41 $ * $Author: richard $ * ***************************************************************************** * * Copyright 1998, Brown University and Richard Goerwitz * ***************************************************************************** * * Header file for fileutil.h, which contains (so far) just a single * routine, getline(), which reads in complete lines from a file * ("complete" meaning lines assembled by concatenating ones ending * in a backslash with their successors). * ***************************************************************************** */ #ifndef FILEUTIL_H_INCLUDED #define FILEUTIL_H_INCLUDED typedef struct xml_error xml_error; typedef struct xml_warning xml_warning; typedef struct xml_element xml_element; typedef struct xml_unparsed_entity xml_unparsed_entity; typedef struct xml_file xml_file; typedef struct xml_attribute xml_attribute; /* XML attribute flags; only one right now */ #define DEFINED_EXTERNALLY 1 #include "general.h" #include "parstree.h" #include "utfutil.h" /* if you use this macro, be sure to declare "int v" */ #define is_big_endian ((v = 1) && (! ((char *)&v)[0])) /* tests whether (xml_file *)xf holds a temporary file or not */ #define is_xml_tmpfile(xf) (((xf)->tmpfilename) ? 1 : 0) /* list of built-in entities (ones that don't have to be declared) */ extern const char *built_in_entity_list[]; struct xml_error { int num; /* the text that caused the problem */ my_wchar_t *text; int lineno; long offset; }; struct xml_warning { int num; /* the text that caused the problem */ my_wchar_t *text; int lineno; long offset; }; enum content_types { empty, Any, mixed, children, /* used if an ATTLIST is declared for as yet undeclared element */ dummy }; struct xml_element { my_wchar_t *name; enum content_types type; size_t ancestorlen; xml_element **ancestors; size_t parentlen; xml_element **parents; void *content_model; void *compiled_content_model; size_t attlistlen; xml_attribute **attlist; /* a cute little kludge suggested by SJD */ int times_open; size_t last_closed_at; int flags; }; enum attribute_types { cdata, id, idref, idrefs, entity, entities, nmtoken, nmtokens, notation, enumeration }; enum default_types { required, implied, defaulted, fixed }; struct xml_attribute { my_wchar_t *name; enum attribute_types type; size_t nmtoklen; my_wchar_t **nmtokens; enum default_types default_type; my_wchar_t *default_val; int flags; }; struct xml_unparsed_entity { my_wchar_t *notname; my_wchar_t *sysid; }; struct xml_file { /* Info on the file being read - name, handle, char-reading function... */ char *filename; char *tmpfilename; FILE *file; yesno standalone; int (*get_xml_char)(); int lineno; my_wchar_t lastchar; /* how many ? */ int cond_levels; yesno child; xml_file *parent; struct rg_htable *element_names; struct rg_htable *notation_names; struct rg_htable *parameter_entity_names; struct rg_htable *external_entity_names; struct rg_htable *unparsed_entity_names; struct rg_htable *entity_names; struct rg_htable *idrefs; struct rg_htable *ids; /* array of pointers to xml_error and warning structs */ size_t errlen; xml_error **xml_errors; size_t warnlen; xml_warning **xml_warnings; /* when done parsing, holds the tree (see parstree.c) */ xml_node *parstree; /* array of pointers to other xml_file sub-structures */ size_t filelen; xml_file **xml_files; }; /* to avoid duplicate error messages */ #define add_unique_error(xf,n,s) { size_t I;\ for (I = 0; I < xf->errlen; I++) \ if (xf->xml_errors[I]->num == n) \ break; \ if (I == xf->errlen) \ add_xml_error (xf, n, s); \ } extern char *getline (FILE *, char *, int *); extern my_wchar_t *read_entire_xml_file (xml_file *, xml_file *); extern xml_file *set_encoding (xml_file *, my_wchar_t *); extern size_t read_xml_file (xml_file *, my_wchar_t *, size_t); extern size_t add_xml_file_nomerge (xml_file *, xml_file *); extern size_t add_xml_file (xml_file *, xml_file *); extern xml_file *create_xml_file (char *); extern xml_file *create_xml_tmpfile (char *, char *); extern int rewind_xml_file (xml_file *); extern void free_xml_file (xml_file *); extern int remove_all_errors_and_warnings_except (xml_file *, ...); extern int report_all_errors_and_warnings (xml_file *, int *); extern xml_error *add_xml_error (xml_file *, int, my_wchar_t *); extern xml_warning *add_xml_warning (xml_file *, int, my_wchar_t *); extern int sort_xml_errors_and_warnings (xml_file *); extern xml_element *create_xml_element (xml_file *xf, my_wchar_t *, enum content_types, void *); extern xml_attribute *create_xml_attribute (xml_file *, my_wchar_t *, enum attribute_types, size_t, my_wchar_t **, enum default_types, my_wchar_t *); extern void free_xml_element (xml_element *); extern void free_xml_attribute (xml_attribute *); #endif /* FILEUTIL_H_INCLUDED */