~ubuntu-branches/ubuntu/natty/bluefish/natty-proposed

« back to all changes in this revision

Viewing changes to src/parsedtd.h

  • Committer: Bazaar Package Importer
  • Author(s): Davide Puricelli (evo)
  • Date: 2005-04-23 17:05:18 UTC
  • mto: (1.1.5 upstream) (5.1.2 sid)
  • mto: This revision was merged to the branch mainline in revision 3.
  • Revision ID: james.westby@ubuntu.com-20050423170518-izh2k25xve7ui1jx
Tags: upstream-1.0
ImportĀ upstreamĀ versionĀ 1.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* Bluefish HTML Editor
2
 
 * parsedtd.h - Parse a DTD file with definition of HTML
3
 
 *
4
 
 * Copyright (C) 2000 Santiago Capel Torres
5
 
 *
6
 
 * This program is free software; you can redistribute it and/or modify
7
 
 * it under the terms of the GNU General Public License as published by
8
 
 * the Free Software Foundation; either version 2 of the License, or
9
 
 * (at your option) any later version.
10
 
 *
11
 
 * This program is distributed in the hope that it will be useful,
12
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 
 * GNU General Public License for more details.
15
 
 *
16
 
 * You should have received a copy of the GNU General Public License
17
 
 * along with this program; if not, write to the Free Software
18
 
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19
 
 */
20
 
 
21
 
 
22
 
 
23
 
#ifndef _PARSEDTD_H_
24
 
#define _PARSEDTD_H_
25
 
 
26
 
#include <glib.h>
27
 
 
28
 
/*
29
 
  SGML Basic Types.
30
 
  www.w3.org/TR/html401/types.html
31
 
*/
32
 
 
33
 
#define SGML_BT_FIRST          0
34
 
 
35
 
#define SGML_BT_CDATA          0
36
 
#define SGML_BT_ID             1
37
 
#define SGML_BT_NAME           2
38
 
#define SGML_BT_IDREF          3
39
 
#define SGML_BT_IDREFS         4
40
 
#define SGML_BT_NUMBER         5
41
 
#define SGML_BT_BOOLEAN        6
42
 
 
43
 
#define SGML_BT_LAST           6
44
 
 
45
 
 
46
 
/*
47
 
  HTML Attrib Types
48
 
  www.w3.org/TR/html401/types.html
49
 
*/
50
 
 
51
 
#define HTML_AT_FIRST         100
52
 
 
53
 
#define HTML_AT_TEXT          100
54
 
#define HTML_AT_URI           101
55
 
#define HTML_AT_COLOR         102
56
 
#define HTML_AT_LENGTH        103
57
 
#define HTML_AT_PIXELS        104
58
 
#define HTML_AT_MULTILENGTH   105
59
 
#define HTML_AT_CONTENTYPE    106
60
 
#define HTML_AT_CONTENTYPES   107
61
 
#define HTML_AT_LANGUAGECODE  108
62
 
#define HTML_AT_CHARSET       109
63
 
#define HTML_AT_CHARSETS      110
64
 
#define HTML_AT_CHARACTER     111
65
 
#define HTML_AT_DATETIME      112
66
 
#define HTML_AT_LYNKTYPES     113
67
 
#define HTML_AT_MEDIADESC     114
68
 
#define HTML_AT_SCRIPT        115
69
 
#define HTML_AT_STYLESHEET    116
70
 
#define HTML_AT_FRAMETARGET   117
71
 
 
72
 
#define HTML_AT_LAST          117
73
 
 
74
 
/* First ID for the elements */
75
 
#define HTML_EL_FIRST           0
76
 
 
77
 
/* Properties of the elements */
78
 
#define HTML_STARTTAG_OPTIONAL (1 << 0)
79
 
#define HTML_ENDTAG_OPTIONAL   (1 << 1)
80
 
 
81
 
/* Default values of the attributes */
82
 
#define HTML_DEFVALUE_LITERAL  0
83
 
#define HTML_DEFVALUE_IMPLIED  1
84
 
#define HTML_DEFVALUE_REQUIRED 2
85
 
#define HTML_DEFVALUE_FIXED    3
86
 
 
87
 
 
88
 
/*
89
 
  Structs for the internal representation of the DTDs
90
 
*/
91
 
 
92
 
/* Representation of an attribute */
93
 
typedef struct {
94
 
        char *name;                                     /* Name of the attribute */
95
 
        int basictype;                          /* SGML basic type (see above) */
96
 
        int attrtype;                           /* HTML attribute type (see above) */
97
 
        char *othertype;                        /* Other type, if different from basictype and attrtype */
98
 
        int defaultvaluetype;           /* Type of default value:  #IMPLIED, #REQUIRED, #FIXED */
99
 
        char *defaultvalue;                     /* Default value of the attribute if not of above types */
100
 
} SGML_attrinfo;
101
 
 
102
 
typedef struct {
103
 
        int id;                                         /* Automatic incremental id of the element */
104
 
        char *name;                                     /* Name of the element (=HTML tag) */
105
 
        int flags;                                      /* Properties of the element */
106
 
        char *content;                          /* contents of the element */
107
 
        GList *attrs;                           /* List of all attributes (SGML_attrinfo) of this element */
108
 
        int clonedattrs;                        /* The list of attrs is cloned from other element */
109
 
} SGML_elementinfo;
110
 
 
111
 
typedef struct {
112
 
        const char *doctype;            /* <!DOCTYPE ...> */
113
 
        char *filename;                         /* path of the DTD file */
114
 
        int reserved;
115
 
        GList *elements;                        /* Parsed DTD */
116
 
        int ref;                                        /* reference count to the GList */
117
 
} SGML_doctype;
118
 
 
119
 
/* Supported Doctype's names */
120
 
#define DTD_HTML_L_0  "!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML Level 0//EN\""
121
 
#define DTD_HTML_L_0S "!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML Strict Level 0//EN\""
122
 
#define DTD_HTML_L_1  "!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML Level 1//EN\""
123
 
#define DTD_HTML_L_1S "!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML Strict Level 1//EN\""
124
 
#define DTD_HTML_2_0  "!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\""
125
 
#define DTD_HTML_2_0S "!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML Strict//EN\""
126
 
#define DTD_HTML_2_1E "!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.1E//EN\""
127
 
#define DTD_HTML_3_0  "!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 3.0//EN//\""
128
 
#define DTD_HTML_3_0S "!DOCTYPE HTML PUBLIC \"-//W3O//DTD W3 HTML Strict 3.0//EN//\""
129
 
#define DTD_HTML_3_2  "!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 3.2//EN\""
130
 
#define DTD_HTML_4_0S "!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Strict//EN\""
131
 
#define DTD_HTML_4_0F "!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Frameset//EN\""
132
 
#define DTD_HTML_4_0T "!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\""
133
 
#define DTD_HTML_4_01S "!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Strict//EN\""
134
 
#define DTD_HTML_4_01F "!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Frameset//EN\""
135
 
#define DTD_HTML_4_01T "!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\""
136
 
#define DTD_XHTML_1_0 "!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0//EN\""
137
 
#define DTD_XHTML_1_0S "!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"DTD/xhtml1-strict.dtd\""
138
 
#define DTD_XHTML_1_0F "!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Frameset//EN\"
139
 
\"DTD/xhtml1-frameset.dtd\""
140
 
#define DTD_XHTML_1_0T "!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"
141
 
\"DTD/xhtml1-transitional.dtd\""
142
 
#define DTD_XHTML_1_1 "!DOCTYPE html PUBLIC \"-//IETF//DTD XHTML 1.1//EN\""
143
 
 
144
 
extern SGML_doctype HTML_doctypes[];
145
 
#define DOCTYPE_DEFAULT (15)
146
 
#define RET_DTD_LOADED  (0)
147
 
 
148
 
SGML_elementinfo *get_element_byname(GList * elements, const char *name);
149
 
gint get_doctype_from_text(gchar * text, gchar * doctype, int maxlen);
150
 
gint find_dtd_index(const gchar * doctype);
151
 
gint find_a_loaded_dtd();
152
 
gint load_DTD(int index);
153
 
gint unload_DTD(int index);
154
 
gint filetoDTD(GList ** elementsptr, const gchar * filename);
155
 
gint getDTDTagList(GList * elements, gchar * buffer, gchar * sep,
156
 
                   int maxlen);
157
 
gint getDTDAttList(GList * elements, gchar * buffer, gchar * sep,
158
 
                   int maxlen);
159
 
GList *get_attr_othervalues(SGML_attrinfo *ai);
160
 
 
161
 
#endif