summaryrefslogtreecommitdiff
path: root/components/help/converters/gnome-db2html2
diff options
context:
space:
mode:
authorJonathan Blandford <jrb@redhat.com>2000-02-03 02:19:02 +0000
committerJonathan Blandford <jrb@src.gnome.org>2000-02-03 02:19:02 +0000
commit1373b6a72a436fb83cb9d9b5f66938c39a3331cf (patch)
tree16224a5e0a3025d269a27951ad93853d1d6e0406 /components/help/converters/gnome-db2html2
parent4ce74ec207cb343f50a1c1860944eb7d6a223a00 (diff)
downloadnautilus-1373b6a72a436fb83cb9d9b5f66938c39a3331cf.tar.gz
Added new converter to list. Does rough on-the-fly docbook to html
2000-02-03 Jonathan Blandford <jrb@redhat.com> * gnome-db2html2/Makefile.am: Added new converter to list. Does rough on-the-fly docbook to html conversion. Not perfect yet (never will be) but good enough (tm) until we can get a better solution for jade. 2000-02-03 Jonathan Blandford <jrb@redhat.com> * configure.in: added components/help/converters/gnome-db2html2/Makefile to the list.
Diffstat (limited to 'components/help/converters/gnome-db2html2')
-rw-r--r--components/help/converters/gnome-db2html2/.cvsignore5
-rw-r--r--components/help/converters/gnome-db2html2/Makefile.am19
-rw-r--r--components/help/converters/gnome-db2html2/gdb3html.c273
-rw-r--r--components/help/converters/gnome-db2html2/gdb3html.h103
-rw-r--r--components/help/converters/gnome-db2html2/sect-elements.c546
-rw-r--r--components/help/converters/gnome-db2html2/sect-elements.h10
-rw-r--r--components/help/converters/gnome-db2html2/toc-elements.c403
-rw-r--r--components/help/converters/gnome-db2html2/toc-elements.h10
8 files changed, 1369 insertions, 0 deletions
diff --git a/components/help/converters/gnome-db2html2/.cvsignore b/components/help/converters/gnome-db2html2/.cvsignore
new file mode 100644
index 000000000..da5622757
--- /dev/null
+++ b/components/help/converters/gnome-db2html2/.cvsignore
@@ -0,0 +1,5 @@
+Makefile.in
+Makefile
+.deps
+.libs
+gnome-db2html2
diff --git a/components/help/converters/gnome-db2html2/Makefile.am b/components/help/converters/gnome-db2html2/Makefile.am
new file mode 100644
index 000000000..db2140eb1
--- /dev/null
+++ b/components/help/converters/gnome-db2html2/Makefile.am
@@ -0,0 +1,19 @@
+## Process this file with automake to produce Makefile.in.
+
+INCLUDES = \
+ -I$(includedir) \
+ -I$(top_srcdir)/intl -I$(top_builddir)/intl \
+ $(GNOME_CFLAGS) $(XML_CFLAGS)
+
+LDADD = \
+ $(GNOME_LIBS) $(XML_LIBS)
+
+bin_PROGRAMS = gnome-db2html2
+
+gnome_db2html2_SOURCES = \
+ gdb3html.c \
+ gdb3html.h \
+ sect-elements.c \
+ sect-elements.h \
+ toc-elements.c \
+ toc-elements.h
diff --git a/components/help/converters/gnome-db2html2/gdb3html.c b/components/help/converters/gnome-db2html2/gdb3html.c
new file mode 100644
index 000000000..ff034960a
--- /dev/null
+++ b/components/help/converters/gnome-db2html2/gdb3html.c
@@ -0,0 +1,273 @@
+#include "gdb3html.h"
+#include "toc-elements.h"
+#include "sect-elements.h"
+
+/* Generic functions. Used by both elements and toc_elements */
+void
+article_start_element (Context *context, const gchar *name, const xmlChar **atrs)
+{
+ g_print ("<HTML>\n");
+}
+
+void
+article_end_element (Context *context, const gchar *name)
+{
+ g_print ("</BODY>\n</HTML>\n");
+}
+
+void
+artheader_start_element (Context *context, const gchar *name, const xmlChar **atrs)
+{
+ g_print ("<HEAD>\n");
+}
+
+void
+write_characters (Context *context,
+ const gchar *chars,
+ int len)
+{
+ char *temp;
+
+ temp = g_strndup (chars, len);
+ g_print ("chars:%s:\n", temp);
+ g_free (temp);
+
+}
+
+StackElement *
+find_first_element (Context *context, GSList *args)
+{
+ GList *ptr;
+ GSList *element_ptr;
+
+ for (ptr = context->stack; ptr; ptr = ptr->next) {
+ for (element_ptr = args; element_ptr; element_ptr = element_ptr->next) {
+ if (((StackElement*) ptr->data)->info->index == GPOINTER_TO_INT (element_ptr->data))
+ return (StackElement *) ptr->data;
+ }
+ }
+ return NULL;
+}
+
+ElementIndex
+find_first_parent (Context *context, GSList *args)
+{
+ StackElement *stack_el;
+
+ stack_el = find_first_element (context, args);
+ if (stack_el == NULL)
+ return UNDEFINED;
+ else
+ return stack_el->info->index;
+
+}
+
+
+/* helper functions */
+
+static ElementInfo *
+find_element_info (ElementInfo *elements,
+ const gchar *name)
+{
+ while (elements->name != NULL) {
+ if (!g_strcasecmp (elements->name, name))
+ return elements;
+ elements++;
+ }
+
+ return NULL;
+}
+
+/* our callbacks for the xmlSAXHandler */
+
+static xmlEntityPtr
+get_entity (Context *context, const gchar *name)
+{
+#ifdef ERROR_OUTPUT
+ g_print ("in getEntity:%s\n", name);
+#endif
+ return xmlGetPredefinedEntity (name);
+}
+
+static void
+start_document (Context *context)
+{
+}
+
+static void
+end_document (Context *context)
+{
+
+}
+
+static void
+start_element(Context *context,
+ const gchar *name,
+ const xmlChar **attrs)
+{
+ ElementInfo *element;
+ StackElement *stack_el = g_new0 (StackElement, 1);
+
+ element = find_element_info (context->elements, name);
+
+ stack_el->info = element;
+ context->stack = g_list_prepend (context->stack, stack_el);
+
+ if (element && element->start_element_func)
+ (* element->start_element_func) (context, name, attrs);
+}
+
+static void
+end_element (Context *context,
+ const gchar *name)
+{
+ ElementInfo *element;
+ StackElement *stack_el;
+ gchar **atrs_ptr;
+
+ element = find_element_info (context->elements, name);
+ stack_el = (StackElement *) context->stack->data;
+ g_assert (stack_el->info == element);
+ if (element && element->end_element_func)
+ (* element->end_element_func) (context, name);
+
+ context->stack = g_list_remove_link (context->stack, context->stack);
+
+ atrs_ptr = stack_el->atrs;
+ while (atrs_ptr && *atrs_ptr) {
+ g_free (*atrs_ptr);
+ atrs_ptr++;
+ };
+ g_free (stack_el->atrs);
+ g_free (stack_el);
+}
+
+static void
+characters (Context *context,
+ const gchar *chars,
+ int len)
+{
+ ElementInfo *element;
+
+
+ element = ((StackElement *)context->stack->data)->info;
+
+ if (element && element->characters_func)
+ (* element->characters_func) (context, chars, len);
+}
+
+static void
+comment (Context *context, const char *msg)
+{
+#ifdef ERROR_OUTPUT
+ g_log("XML", G_LOG_LEVEL_MESSAGE, "%s", msg);
+#endif
+}
+
+static void
+warning (Context *context, const char *msg, ...)
+{
+ va_list args;
+
+ va_start(args, msg);
+#ifdef ERROR_OUTPUT
+ g_logv("XML", G_LOG_LEVEL_WARNING, msg, args);
+#endif
+ va_end(args);
+}
+
+static void
+error (Context *context, const char *msg, ...)
+{
+ va_list args;
+
+ va_start(args, msg);
+#ifdef ERROR_OUTPUT
+ g_logv("XML", G_LOG_LEVEL_CRITICAL, msg, args);
+#endif
+ va_end(args);
+}
+
+static void
+fatal_error (Context *context, const char *msg, ...)
+{
+ va_list args;
+
+ va_start(args, msg);
+#ifdef ERROR_OUTPUT
+ g_logv("XML", G_LOG_LEVEL_ERROR, msg, args);
+#endif
+ va_end(args);
+}
+
+
+static xmlSAXHandler parser = {
+ NULL, /* internalSubset */
+ NULL, /* isStandalone */
+ NULL, /* hasInternalSubset */
+ NULL, /* hasExternalSubset */
+ NULL, /* resolveEntity */
+ (getEntitySAXFunc) get_entity, /* getEntity */
+ NULL, /* entityDecl */
+ NULL, /* notationDecl */
+ NULL, /* attributeDecl */
+ NULL, /* elementDecl */
+ NULL, /* unparsedEntityDecl */
+ NULL, /* setDocumentLocator */
+ (startDocumentSAXFunc) start_document, /* startDocument */
+ (endDocumentSAXFunc) end_document, /* endDocument */
+ (startElementSAXFunc) start_element, /* startElement */
+ (endElementSAXFunc) end_element, /* endElement */
+ NULL, /* reference */
+ (charactersSAXFunc) characters, /* characters */
+ NULL, /* ignorableWhitespace */
+ NULL, /* processingInstruction */
+ (commentSAXFunc) comment, /* comment */
+ (warningSAXFunc) warning, /* warning */
+ (errorSAXFunc) error, /* error */
+ (fatalErrorSAXFunc) fatal_error /* fatalError */
+};
+
+static void
+parse_file (gchar *filename, gchar *section)
+{
+ Context *context = g_new0 (Context, 1);
+
+ if (section) {
+ context->target_section = g_strdup (section);
+ context->elements = sect_elements;
+ context->data = sect_init_data ();
+ context->base_file = g_strdup (filename);
+ } else {
+ context->elements = toc_elements;
+ context->data = toc_init_data ();
+ context->base_file = g_strdup (filename);
+ }
+ if (xmlSAXUserParseFile (&parser, context, context->base_file) < 0) {
+ g_print ("error\n");
+ };
+}
+
+int
+main (int argc, char *argv[])
+{
+ gchar *section = NULL;
+ gchar *ptr;
+
+ if (argc != 2) {
+ g_print ("Usage: gdb2html FILE[#SECTIONID]\n\n");
+ return 0;
+ }
+
+ for (ptr = argv[1]; *ptr; ptr++){
+ if (*ptr == '#') {
+ *ptr = '\000';
+ if (*(ptr + 1))
+ section = ptr + 1;
+ break;
+ }
+ }
+ parse_file (argv[1], section);
+
+ return 0;
+}
diff --git a/components/help/converters/gnome-db2html2/gdb3html.h b/components/help/converters/gnome-db2html2/gdb3html.h
new file mode 100644
index 000000000..2684ab6fe
--- /dev/null
+++ b/components/help/converters/gnome-db2html2/gdb3html.h
@@ -0,0 +1,103 @@
+#ifndef __GDB3HTML_H__
+#define __GDB3HTML_H__
+
+#include <parser.h>
+#include <parserInternals.h>
+#include <glib.h>
+#include <string.h>
+
+typedef enum ElementIndex {
+ ARTICLE = 0,
+ BOOK,
+ SECTION,
+ SECT1,
+ SECT2,
+ SECT3, /* 5 */
+ SECT4,
+ SECT5,
+ PARA,
+ FORMALPARA,
+ ARTHEADER, /* 10 */
+ AUTHORGROUP,
+ AUTHOR,
+ FIRSTNAME,
+ OTHERNAME,
+ SURNAME, /* 15 */
+ AFFILIATION,
+ EMAIL,
+ ORGNAME,
+ ADDRESS,
+ COPYRIGHT, /* 20 */
+ YEAR,
+ HOLDER,
+ TITLE,
+ SUBTITLE,
+ ULINK, /* 25 */
+ XREF,
+ FOOTNOTE,
+ FIGURE,
+ GRAPHIC,
+ UNDEFINED /* 30 */
+} ElementIndex;
+
+typedef struct _ElementInfo ElementInfo;
+struct _ElementInfo {
+ ElementIndex index;
+ gchar *name;
+ startElementSAXFunc start_element_func;
+ endElementSAXFunc end_element_func;
+ charactersSAXFunc characters_func;
+};
+
+typedef struct _StackElement StackElement;
+struct _StackElement {
+ ElementInfo *info;
+ gchar **atrs;
+};
+
+
+typedef struct _Context Context;
+struct _Context {
+ ElementInfo *elements;
+ gchar *base_file;
+ gchar *target_section;
+ GList *stack;
+ gpointer data;
+
+ /* determine the "depth" that the current section is on.
+ * only applies to section */
+ gint sect1;
+ gint sect2;
+ gint sect3;
+ gint sect4;
+ gint sect5;
+};
+
+/* useful structs */
+typedef struct AuthorInfo {
+ gchar *firstname;
+ gchar *othername;
+ gchar *surname;
+ gchar *email;
+ gchar *orgname;
+} AuthorInfo;
+
+
+typedef struct HeaderInfo {
+ gchar *title;
+ gchar *subtitle;
+ gchar *copyright_year;
+ gchar *copyright_holder;
+ GSList *authors;
+} HeaderInfo;
+
+void article_start_element (Context *context, const gchar *name, const xmlChar **atrs);
+void article_end_element (Context *context, const gchar *name);
+void artheader_start_element (Context *context, const gchar *name, const xmlChar **atrs);
+void para_start_element (Context *context, const gchar *name, const xmlChar **atrs);
+void para_end_element (Context *context, const gchar *name);
+void write_characters (Context *context, const gchar *chars, int len);
+StackElement *find_first_element (Context *context, GSList *args);
+ElementIndex find_first_parent (Context *context, GSList *args);
+
+#endif
diff --git a/components/help/converters/gnome-db2html2/sect-elements.c b/components/help/converters/gnome-db2html2/sect-elements.c
new file mode 100644
index 000000000..750d57905
--- /dev/null
+++ b/components/help/converters/gnome-db2html2/sect-elements.c
@@ -0,0 +1,546 @@
+
+#include "sect-elements.h"
+
+#define IS_IN_SECT(context) (((SectContext *)context->data)->state == IN_SECT)
+typedef enum SectContextState {
+ LOOKING_FOR_SECT,
+ LOOKING_FOR_SECT_TITLE,
+ IN_SECT,
+ LOOKING_FOR_POST_SECT,
+ DONE_WITH_SECT
+} SectContextState;
+
+typedef struct _SectContext SectContext;
+struct _SectContext {
+ HeaderInfo *header;
+ gchar *prev;
+ gchar *previd;
+ gchar *top;
+ gchar *topid;
+ SectContextState state;
+ /* A list full of GStrings. */
+ GList *footnotes;
+};
+
+static void sect_sect_start_element (Context *context, const gchar *name, const xmlChar **atrs);
+static void sect_sect_end_element (Context *context, const gchar *name);
+static void sect_para_start_element (Context *context, const gchar *name, const xmlChar **atrs);
+static void sect_para_end_element (Context *context, const gchar *name);
+static void sect_para_characters (Context *context, const gchar *name, gint len);
+static void sect_formalpara_start_element (Context *context, const gchar *name, const xmlChar **atrs);
+static void sect_formalpara_end_element (Context *context, const gchar *name);
+static void sect_author_start_element (Context *context, const gchar *name, const xmlChar **atrs);
+static void sect_author_characters (Context *context, const gchar *chars, int len);
+static void sect_copyright_characters (Context *context, const gchar *chars, int len);
+static void sect_title_start_element (Context *context, const gchar *name, const xmlChar **atrs);
+static void sect_title_end_element (Context *context, const gchar *name);
+static void sect_title_characters (Context *context, const gchar *chars, int len);
+
+ElementInfo sect_elements[] = {
+ { ARTICLE, "article", (startElementSAXFunc) article_start_element, (endElementSAXFunc) article_end_element, NULL},
+ { BOOK, "book", NULL, NULL, NULL},
+ { SECTION, "section", (startElementSAXFunc) sect_sect_start_element, (endElementSAXFunc) sect_sect_end_element, NULL},
+ { SECT1, "sect1", (startElementSAXFunc) sect_sect_start_element, (endElementSAXFunc) sect_sect_end_element, NULL},
+ { SECT2, "sect2", (startElementSAXFunc) sect_sect_start_element, (endElementSAXFunc) sect_sect_end_element, NULL},
+ { SECT3, "sect3", (startElementSAXFunc) sect_sect_start_element, (endElementSAXFunc) sect_sect_end_element, NULL},
+ { SECT4, "sect4", (startElementSAXFunc) sect_sect_start_element, (endElementSAXFunc) sect_sect_end_element, NULL},
+ { SECT5, "sect5", (startElementSAXFunc) sect_sect_start_element, (endElementSAXFunc) sect_sect_end_element, NULL},
+ { PARA, "para", (startElementSAXFunc) sect_para_start_element, (endElementSAXFunc) sect_para_end_element, (charactersSAXFunc) sect_para_characters},
+ { FORMALPARA, "formalpara", (startElementSAXFunc) sect_formalpara_start_element, (endElementSAXFunc) sect_formalpara_end_element, NULL },
+ { ARTHEADER, "artheader", NULL, NULL, NULL}, //(startElementSAXFunc) artheader_start_element, (endElementSAXFunc) sect_artheader_end_element, NULL},
+ { AUTHORGROUP, "authorgroup", NULL, NULL, NULL},
+ { AUTHOR, "author", (startElementSAXFunc) sect_author_start_element, NULL, NULL},
+ { FIRSTNAME, "firstname", NULL, NULL, (charactersSAXFunc) sect_author_characters },
+ { OTHERNAME, "othername", NULL, NULL, (charactersSAXFunc) sect_author_characters },
+ { SURNAME, "surname", NULL, NULL, (charactersSAXFunc) sect_author_characters },
+ { AFFILIATION, "affiliation", NULL, NULL, NULL},
+ { EMAIL, "email", NULL, NULL, (charactersSAXFunc) sect_author_characters },
+ { ORGNAME, "orgname", NULL, NULL, (charactersSAXFunc) sect_author_characters },
+ { ADDRESS, "address", NULL, NULL, NULL},
+ { COPYRIGHT, "copyright", NULL, NULL, NULL},
+ { YEAR, "year", NULL, NULL, (charactersSAXFunc) sect_copyright_characters},
+ { HOLDER, "holder", NULL, NULL, (charactersSAXFunc) sect_copyright_characters},
+ { TITLE, "title", (startElementSAXFunc) sect_title_start_element, (endElementSAXFunc) sect_title_end_element, (charactersSAXFunc) sect_title_characters },
+ { SUBTITLE, "subtitle", (startElementSAXFunc) sect_title_start_element, (endElementSAXFunc) sect_title_end_element, (charactersSAXFunc) sect_title_characters },
+ { ULINK, "ulink", NULL, NULL, NULL},
+ { XREF, "xref", NULL, NULL, NULL},
+ { FOOTNOTE, "footnote", NULL, NULL, NULL},
+ { FIGURE, "figure", NULL, NULL, NULL},
+ { GRAPHIC, "graphic", NULL, NULL, NULL},
+ { UNDEFINED, NULL, NULL, NULL, NULL}
+};
+
+
+
+gpointer
+sect_init_data (void)
+{
+ SectContext *retval = g_new0 (SectContext, 1);
+ retval->header = g_new0 (HeaderInfo, 1);
+ retval->state = LOOKING_FOR_SECT;
+ return (gpointer) retval;
+}
+
+static void
+sect_para_start_element (Context *context, const gchar *name, const xmlChar **atrs)
+{
+ GSList *element_list = NULL;
+ StackElement *stack_el;
+
+ if (!IS_IN_SECT (context))
+ return;
+
+ element_list = g_slist_prepend (element_list, GINT_TO_POINTER (SECT1));
+ element_list = g_slist_prepend (element_list, GINT_TO_POINTER (SECT2));
+ element_list = g_slist_prepend (element_list, GINT_TO_POINTER (SECT3));
+ element_list = g_slist_prepend (element_list, GINT_TO_POINTER (SECT4));
+ element_list = g_slist_prepend (element_list, GINT_TO_POINTER (SECT5));
+ element_list = g_slist_prepend (element_list, GINT_TO_POINTER (SECTION));
+ element_list = g_slist_prepend (element_list, GINT_TO_POINTER (FIGURE));
+ element_list = g_slist_prepend (element_list, GINT_TO_POINTER (FOOTNOTE));
+ element_list = g_slist_prepend (element_list, GINT_TO_POINTER (FORMALPARA));
+ stack_el = find_first_element (context, element_list);
+
+ g_slist_free (element_list);
+ if (stack_el == NULL)
+ return;
+
+ switch (stack_el->info->index) {
+ case SECT1:
+ case SECT2:
+ case SECT3:
+ case SECT4:
+ case SECT5:
+ case SECTION:
+ g_print ("<P>\n");
+ break;
+ case FORMALPARA:
+ default:
+ break;
+ };
+}
+
+static void
+sect_para_end_element (Context *context, const gchar *name)
+{
+ GSList *element_list = NULL;
+ StackElement *stack_el;
+
+ if (!IS_IN_SECT (context))
+ return;
+
+ element_list = g_slist_prepend (element_list, GINT_TO_POINTER (SECT1));
+ element_list = g_slist_prepend (element_list, GINT_TO_POINTER (SECT2));
+ element_list = g_slist_prepend (element_list, GINT_TO_POINTER (SECT3));
+ element_list = g_slist_prepend (element_list, GINT_TO_POINTER (SECT4));
+ element_list = g_slist_prepend (element_list, GINT_TO_POINTER (SECT5));
+ element_list = g_slist_prepend (element_list, GINT_TO_POINTER (SECTION));
+ element_list = g_slist_prepend (element_list, GINT_TO_POINTER (FIGURE));
+ element_list = g_slist_prepend (element_list, GINT_TO_POINTER (FOOTNOTE));
+ element_list = g_slist_prepend (element_list, GINT_TO_POINTER (FORMALPARA));
+ stack_el = find_first_element (context, element_list);
+
+ g_slist_free (element_list);
+ if (stack_el == NULL)
+ return;
+
+ switch (stack_el->info->index) {
+ case SECT1:
+ case SECT2:
+ case SECT3:
+ case SECT4:
+ case SECT5:
+ case SECTION:
+ g_print ("</P>\n");
+ break;
+ case FORMALPARA:
+ default:
+ break;
+ };
+}
+
+static void
+sect_para_characters (Context *context,
+ const gchar *chars,
+ int len)
+{
+ if (IS_IN_SECT (context)) {
+ gchar *temp;
+ temp = g_strndup (chars, len);
+ g_print ("%s", temp);
+ g_free (temp);
+ }
+}
+
+
+static void
+sect_formalpara_start_element (Context *context, const gchar *name, const xmlChar **atrs)
+{
+ if (!IS_IN_SECT (context))
+ return;
+
+ g_print ("<P>");
+}
+
+static void
+sect_formalpara_end_element (Context *context, const gchar *name)
+{
+ if (!IS_IN_SECT (context))
+ return;
+
+ g_print ("</P>");
+}
+
+
+static void
+sect_sect_start_element (Context *context,
+ const gchar *name,
+ const xmlChar **atrs)
+{
+ gchar **atrs_ptr;
+ SectContext *sect_context = (SectContext *)context->data;
+
+ g_return_if_fail (strlen (name) >= 5);
+
+ atrs_ptr = (gchar **) atrs;
+ while (atrs_ptr && *atrs_ptr) {
+ if (!strcasecmp (*atrs_ptr, "id")) {
+ atrs_ptr++;
+ ((StackElement *)context->stack->data)->atrs = g_new0 (gchar *, 3);
+ ((StackElement *)context->stack->data)->atrs[0] = g_strdup ("id");
+ ((StackElement *)context->stack->data)->atrs[1] = g_strdup (*atrs_ptr);
+ if (!strcmp (*atrs_ptr, context->target_section))
+ sect_context->state = LOOKING_FOR_SECT_TITLE;
+ break;
+ }
+ atrs_ptr += 2;
+ }
+
+ switch (name[4]) {
+ case '1':
+ if (sect_context->state != LOOKING_FOR_SECT_TITLE) {
+ g_free (sect_context->prev);
+ g_free (sect_context->previd);
+ }
+ context->sect1++;
+ break;
+ case '2':
+ context->sect2++;
+ break;
+ case '3':
+ context->sect3++;
+ break;
+ case '4':
+ context->sect4++;
+ break;
+ case '5':
+ context->sect4++;
+ break;
+ default:
+ break;
+ }
+}
+
+static void
+sect_sect_end_element (Context *context,
+ const gchar *name)
+{
+ gchar **atrs_ptr;
+
+ g_return_if_fail (strlen (name) >= 5);
+
+ switch (name[4]) {
+ case '1':
+ context->sect2 = 0;
+ case '2':
+ context->sect3 = 0;
+ case '3':
+ context->sect4 = 0;
+ case '4':
+ context->sect5 = 0;
+ default:
+ break;
+ }
+ atrs_ptr = ((StackElement *) context->stack->data)->atrs;
+
+ while (atrs_ptr && *atrs_ptr) {
+ if (!strcasecmp (*atrs_ptr, "id")) {
+ atrs_ptr++;
+ if (!strcmp (*atrs_ptr, context->target_section)) {
+ ((SectContext *)context->data)->state = LOOKING_FOR_POST_SECT;
+ }
+ break;
+ }
+ atrs_ptr += 2;
+ }
+}
+
+
+static void
+sect_author_start_element (Context *context,
+ const gchar *name,
+ const xmlChar **atrs)
+{
+ GSList *element_list = NULL;
+ AuthorInfo *author;
+ ElementIndex index;
+
+ element_list = g_slist_prepend (element_list, GINT_TO_POINTER (ARTHEADER));
+ index = find_first_parent (context, element_list);
+ g_slist_free (element_list);
+
+ switch (index) {
+ case ARTHEADER:
+ break;
+ default:
+ return;
+ };
+ author = g_new0 (AuthorInfo, 1);
+ ((SectContext *) context->data)->header->authors = g_slist_prepend (((SectContext *) context->data)->header->authors, author);
+}
+
+static void
+sect_author_characters (Context *context, const gchar *chars, int len)
+{
+ GSList *element_list = NULL;
+ AuthorInfo *author;
+ ElementIndex index;
+ char *temp;
+
+ element_list = g_slist_prepend (element_list, GINT_TO_POINTER (ARTHEADER));
+ index = find_first_parent (context, element_list);
+ g_slist_free (element_list);
+
+ switch (index) {
+ case ARTHEADER:
+ break;
+ default:
+ return;
+ };
+
+ author = (AuthorInfo *) ((SectContext *) context->data)->header->authors->data;
+ g_return_if_fail (author != NULL);
+ temp = g_strndup (chars, len);
+ if (((StackElement *) context->stack->data)->info->index == FIRSTNAME)
+ author->firstname = temp;
+ else if (((StackElement *) context->stack->data)->info->index == OTHERNAME)
+ author->othername = temp;
+ else if (((StackElement *) context->stack->data)->info->index == SURNAME)
+ author->surname = temp;
+ else if (((StackElement *) context->stack->data)->info->index == EMAIL) {
+ author->email = temp;
+ } else if (((StackElement *) context->stack->data)->info->index == ORGNAME)
+ author->orgname = temp;
+ else
+ g_free (temp);
+}
+
+static void
+sect_copyright_characters (Context *context,
+ const gchar *chars,
+ int len)
+{
+ GSList *element_list = NULL;
+ ElementIndex index;
+ gchar *temp;
+
+ element_list = g_slist_prepend (element_list, GINT_TO_POINTER (COPYRIGHT));
+ index = find_first_parent (context, element_list);
+ g_slist_free (element_list);
+
+ temp = g_strndup (chars, len);
+
+ switch (index) {
+ case COPYRIGHT:
+ if (((StackElement *) context->stack->data)->info->index == YEAR)
+ ((SectContext *)context->data)->header->copyright_year = temp;
+ else if (((StackElement *) context->stack->data)->info->index == HOLDER)
+ ((SectContext *)context->data)->header->copyright_holder = temp;
+ break;
+ default:
+ g_free (temp);
+ break;
+ };
+}
+
+static void
+sect_title_start_element (Context *context,
+ const gchar *name,
+ const xmlChar **atrs)
+{
+ GSList *element_list = NULL;
+ StackElement *stack_el;
+ gchar **atrs_ptr;
+
+ if (!IS_IN_SECT (context))
+ return;
+
+ element_list = g_slist_prepend (element_list, GINT_TO_POINTER (SECT1));
+ element_list = g_slist_prepend (element_list, GINT_TO_POINTER (SECT2));
+ element_list = g_slist_prepend (element_list, GINT_TO_POINTER (SECT3));
+ element_list = g_slist_prepend (element_list, GINT_TO_POINTER (SECT4));
+ element_list = g_slist_prepend (element_list, GINT_TO_POINTER (SECT5));
+ element_list = g_slist_prepend (element_list, GINT_TO_POINTER (SECTION));
+ element_list = g_slist_prepend (element_list, GINT_TO_POINTER (FIGURE));
+ element_list = g_slist_prepend (element_list, GINT_TO_POINTER (FORMALPARA));
+ stack_el = find_first_element (context, element_list);
+
+ g_slist_free (element_list);
+ if (stack_el == NULL)
+ return;
+
+
+ switch (stack_el->info->index) {
+ case SECT1:
+ case SECT2:
+ case SECT3:
+ case SECT4:
+ case SECT5:
+ case SECTION:
+ if (context->sect2 == 0)
+ g_print ("<H2>");
+ else
+ g_print ("<H3>");
+ g_print ("<A name=\"");
+
+ atrs_ptr = (stack_el->atrs);
+ while (atrs_ptr && *atrs_ptr) {
+ if (!strcasecmp (*atrs_ptr, "id")) {
+ atrs_ptr++;
+ g_print ("%s", *atrs_ptr);
+ break;
+ }
+ atrs_ptr += 2;
+ }
+ g_print ("\">Section ");
+ if (context->sect1 > 0) g_print ("%d", context->sect1);
+ if (context->sect2 > 0) g_print (".%d", context->sect2);
+ if (context->sect3 > 0) g_print (".%d", context->sect3);
+ if (context->sect4 > 0) g_print (".%d", context->sect4);
+ if (context->sect5 > 0) g_print (".%d", context->sect5);
+ g_print (".&nbsp;&nbsp;</A><BR>");
+ break;
+ case FORMALPARA:
+ g_print ("<B>");
+ break;
+ default:
+ break;
+ };
+
+}
+
+static void
+sect_title_end_element (Context *context,
+ const gchar *name)
+{
+ GSList *element_list = NULL;
+ ElementIndex index;
+
+ if (!IS_IN_SECT (context))
+ return;
+
+ element_list = g_slist_prepend (element_list, GINT_TO_POINTER (SECT1));
+ element_list = g_slist_prepend (element_list, GINT_TO_POINTER (SECT2));
+ element_list = g_slist_prepend (element_list, GINT_TO_POINTER (SECT3));
+ element_list = g_slist_prepend (element_list, GINT_TO_POINTER (SECT4));
+ element_list = g_slist_prepend (element_list, GINT_TO_POINTER (SECT5));
+ element_list = g_slist_prepend (element_list, GINT_TO_POINTER (SECTION));
+ element_list = g_slist_prepend (element_list, GINT_TO_POINTER (FIGURE));
+ element_list = g_slist_prepend (element_list, GINT_TO_POINTER (FORMALPARA));
+
+ index = find_first_parent (context, element_list);
+
+ switch (index) {
+ case SECT1:
+ case SECTION:
+ g_print ("</A></H2>\n");
+ break;
+ case SECT2:
+ case SECT3:
+ case SECT4:
+ case SECT5:
+ g_print ("</A></H3>\n");
+ break;
+ case FORMALPARA:
+ g_print (".</B>");
+ break;
+ default:
+ break;
+ };
+
+ g_slist_free (element_list);
+
+}
+
+static void
+sect_title_characters (Context *context,
+ const gchar *chars,
+ int len)
+{
+ GSList *element_list = NULL;
+ ElementIndex index;
+ char *temp;
+
+
+ if (((SectContext *)context->data)->state == LOOKING_FOR_SECT_TITLE) {
+ SectContext *sect_context = (SectContext *)context->data;
+ temp = g_strndup (chars, len);
+
+ g_print ("<TITLE>%s</TITLE>\n</HEAD>\n", temp);
+ g_print ("<BODY BGCOLOR=\"#FFFFFF\" TEXT=\"#000000\" LINK=\"#0000FF\" VLINK=\"#840084\" ALINK=\"#0000FF\">\n");
+ if (sect_context->top == NULL)
+ g_print ("<A href=\"%s\"><font size=3>Up to Table of Contents</font></A><BR>\n",
+ context->base_file);
+ else
+ g_print ("<A href=\"%s#%s\"><font size=3>Up to %s</font></A><BR>\n",
+ context->base_file,
+ sect_context->topid,
+ sect_context->top);
+ g_print ("<H1>%s</H1>\n", temp);
+ ((SectContext *)context->data)->state = IN_SECT;
+ g_free (temp);
+ return;
+ }
+
+ if (!IS_IN_SECT (context))
+ return;
+
+ temp = g_strndup (chars, len);
+
+
+ element_list = g_slist_prepend (element_list, GINT_TO_POINTER (SECT1));
+ element_list = g_slist_prepend (element_list, GINT_TO_POINTER (SECT2));
+ element_list = g_slist_prepend (element_list, GINT_TO_POINTER (SECT3));
+ element_list = g_slist_prepend (element_list, GINT_TO_POINTER (SECT4));
+ element_list = g_slist_prepend (element_list, GINT_TO_POINTER (SECT5));
+ element_list = g_slist_prepend (element_list, GINT_TO_POINTER (SECTION));
+ element_list = g_slist_prepend (element_list, GINT_TO_POINTER (ARTHEADER));
+ element_list = g_slist_prepend (element_list, GINT_TO_POINTER (FIGURE));
+ element_list = g_slist_prepend (element_list, GINT_TO_POINTER (FORMALPARA));
+
+ index = find_first_parent (context, element_list);
+
+ switch (index) {
+ case SECT1:
+ case SECT2:
+ case SECT3:
+ case SECT4:
+ case SECT5:
+ case SECTION:
+ case FORMALPARA:
+ g_print (temp);
+ g_free (temp);
+ break;
+ case ARTHEADER:
+ if (((StackElement *)context->stack->data)->info->index == TITLE)
+ ((SectContext *) context->data)->header->title = temp;
+ else if (((StackElement *)context->stack->data)->info->index == SUBTITLE)
+ ((SectContext *) context->data)->header->subtitle = temp;
+ break;
+ default:
+ g_free (temp);
+ break;
+ };
+
+ g_slist_free (element_list);
+}
diff --git a/components/help/converters/gnome-db2html2/sect-elements.h b/components/help/converters/gnome-db2html2/sect-elements.h
new file mode 100644
index 000000000..0e39e7c61
--- /dev/null
+++ b/components/help/converters/gnome-db2html2/sect-elements.h
@@ -0,0 +1,10 @@
+#ifndef __SECT_ELEMENTS_H__
+#define __SECT_ELEMENTS_H__
+
+#include "gdb3html.h"
+
+extern ElementInfo sect_elements[];
+
+gpointer sect_init_data (void);
+
+#endif
diff --git a/components/help/converters/gnome-db2html2/toc-elements.c b/components/help/converters/gnome-db2html2/toc-elements.c
new file mode 100644
index 000000000..68751728d
--- /dev/null
+++ b/components/help/converters/gnome-db2html2/toc-elements.c
@@ -0,0 +1,403 @@
+
+#include "toc-elements.h"
+
+
+typedef struct _TocContext TocContext;
+struct _TocContext {
+ HeaderInfo *header;
+};
+
+static void toc_sect_start_element (Context *context, const gchar *name, const xmlChar **atrs);
+static void toc_sect_end_element (Context *context, const gchar *name);
+static void toc_artheader_end_element (Context *context, const gchar *name);
+static void toc_author_start_element (Context *context, const gchar *name, const xmlChar **atrs);
+static void toc_author_characters (Context *context, const gchar *chars, int len);
+static void toc_copyright_characters (Context *context, const gchar *chars, int len);
+static void toc_title_start_element (Context *context, const gchar *name, const xmlChar **atrs);
+static void toc_title_end_element (Context *context, const gchar *name);
+static void toc_title_characters (Context *context, const gchar *chars, int len);
+
+
+ElementInfo toc_elements[] = {
+ { ARTICLE, "article", (startElementSAXFunc) article_start_element, (endElementSAXFunc) article_end_element, NULL},
+ { BOOK, "book", NULL, NULL, NULL},
+ { SECTION, "section", (startElementSAXFunc) toc_sect_start_element, (endElementSAXFunc) toc_sect_end_element, NULL},
+ { SECT1, "sect1", (startElementSAXFunc) toc_sect_start_element, (endElementSAXFunc) toc_sect_end_element, NULL},
+ { SECT2, "sect2", (startElementSAXFunc) toc_sect_start_element, (endElementSAXFunc) toc_sect_end_element, NULL},
+ { SECT3, "sect3", (startElementSAXFunc) toc_sect_start_element, (endElementSAXFunc) toc_sect_end_element, NULL},
+ { SECT4, "sect4", (startElementSAXFunc) toc_sect_start_element, (endElementSAXFunc) toc_sect_end_element, NULL},
+ { SECT5, "sect5", (startElementSAXFunc) toc_sect_start_element, (endElementSAXFunc) toc_sect_end_element, NULL},
+ { PARA, "para", NULL, NULL, NULL},
+ { FORMALPARA, "formalpara", NULL, NULL, NULL},
+ { ARTHEADER, "artheader", (startElementSAXFunc) artheader_start_element, (endElementSAXFunc) toc_artheader_end_element, NULL},
+ { AUTHORGROUP, "authorgroup", NULL, NULL, NULL},
+ { AUTHOR, "author", (startElementSAXFunc) toc_author_start_element, NULL, NULL},
+ { FIRSTNAME, "firstname", NULL, NULL, (charactersSAXFunc) toc_author_characters },
+ { OTHERNAME, "othername", NULL, NULL, (charactersSAXFunc) toc_author_characters },
+ { SURNAME, "surname", NULL, NULL, (charactersSAXFunc) toc_author_characters },
+ { AFFILIATION, "affiliation", NULL, NULL, NULL},
+ { EMAIL, "email", NULL, NULL, (charactersSAXFunc) toc_author_characters },
+ { ORGNAME, "orgname", NULL, NULL, (charactersSAXFunc) toc_author_characters },
+ { ADDRESS, "address", NULL, NULL, NULL},
+ { COPYRIGHT, "copyright", NULL, NULL, NULL},
+ { YEAR, "year", NULL, NULL, (charactersSAXFunc) toc_copyright_characters},
+ { HOLDER, "holder", NULL, NULL, (charactersSAXFunc) toc_copyright_characters},
+ { TITLE, "title", (startElementSAXFunc) toc_title_start_element, (endElementSAXFunc) toc_title_end_element, (charactersSAXFunc) toc_title_characters },
+ { SUBTITLE, "subtitle", (startElementSAXFunc) toc_title_start_element, (endElementSAXFunc) toc_title_end_element, (charactersSAXFunc) toc_title_characters },
+ { ULINK, "ulink", NULL, NULL, NULL},
+ { XREF, "xref", NULL, NULL, NULL},
+ { FOOTNOTE, "footnote", NULL, NULL, NULL},
+ { FIGURE, "figure", NULL, NULL, NULL},
+ { GRAPHIC, "graphic", NULL, NULL, NULL},
+ { UNDEFINED, NULL, NULL, NULL, NULL}
+};
+
+
+
+gpointer
+toc_init_data (void)
+{
+ TocContext *retval = g_new0 (TocContext, 1);
+ retval->header = g_new0 (HeaderInfo, 1);
+
+ return (gpointer) retval;
+}
+
+
+
+static void
+toc_sect_start_element (Context *context,
+ const gchar *name,
+ const xmlChar **atrs)
+{
+ gchar **atrs_ptr;
+
+ g_return_if_fail (strlen (name) >= 5);
+
+ switch (name[4]) {
+ case '1':
+ context->sect1++;
+ break;
+ case '2':
+ context->sect2++;
+ break;
+ case '3':
+ context->sect3++;
+ break;
+ case '4':
+ context->sect4++;
+ break;
+ case '5':
+ context->sect4++;
+ break;
+ default:
+ break;
+ }
+
+ atrs_ptr = (gchar **) atrs;
+ while (atrs_ptr && *atrs_ptr) {
+ if (!strcasecmp (*atrs_ptr, "id")) {
+ atrs_ptr++;
+ ((StackElement *)context->stack->data)->atrs = g_new0 (gchar *, 3);
+ ((StackElement *)context->stack->data)->atrs[0] = g_strdup ("id");
+ ((StackElement *)context->stack->data)->atrs[1] = g_strdup (*atrs_ptr);
+ break;
+ }
+ atrs_ptr += 2;
+ }
+}
+
+static void
+toc_sect_end_element (Context *context,
+ const gchar *name)
+{
+ g_return_if_fail (strlen (name) >= 5);
+
+ switch (name[4]) {
+ case '1':
+ context->sect2 = 0;
+ case '2':
+ context->sect3 = 0;
+ case '3':
+ context->sect4 = 0;
+ case '4':
+ context->sect5 = 0;
+ default:
+ break;
+ }
+}
+
+static void
+toc_artheader_end_element (Context *context, const gchar *name)
+{
+ GSList *ptr;
+ AuthorInfo *author;
+ HeaderInfo *header = ((TocContext *) context->data)->header;
+
+ if (header->title)
+ g_print ("<TITLE>%s</TITLE>\n</HEAD>\n", header->title);
+ else
+ g_print ("<TITLE>GNOME Documentation</TITLE>\n</HEAD>\n");
+
+ g_print ("<BODY BGCOLOR=\"#FFFFFF\" TEXT=\"#000000\" LINK=\"#0000FF\" VLINK=\"#840084\" ALINK=\"#0000FF\">\n");
+ g_print ("<TABLE><TR><TD VALIGN=\"TOP\">\n");
+ g_print ("<IMG SRC=\"/usr/share/pixmaps/gnome-logo-icon.png\" BORDER=\"0\" ALT=\"GNOME\">\n");
+ g_print ("</TD><TD VALIGN=\"BOTTOM\">\n");
+ if (header->title)
+ g_print ("<H1>%s</H1>\n", header->title);
+ g_print ("</TD></TABLE><BR>\n");
+ if (header->subtitle)
+ g_print ("<H2>%s</H2>\n", header->subtitle);
+
+ for (ptr = header->authors; ptr; ptr = ptr->next) {
+ g_print ("<H3> by ");
+ author = (AuthorInfo *) ptr->data;
+ if (author->firstname)
+ g_print ("%s ", author->firstname);
+ if (author->othername)
+ g_print ("%s ", author->othername);
+ if (author->surname)
+ g_print ("%s", author->surname);
+ g_print ("</H3>\n");
+ if (author->orgname)
+ g_print ("%s<BR>", author->orgname);
+ if (author->email)
+ g_print ("<tt>&lt;%s&gt;</tt>\n", author->email);
+ g_print ("<BR>");
+ }
+ g_print ("<P>");
+ if ((header->copyright_holder) && (header->copyright_year))
+ g_print ("Copyright &copy; %s by %s", header->copyright_year, header->copyright_holder);
+ g_print ("<HR>\n<H1>Table of Contents</H1>\n\n");
+ g_print ("<P>\n");
+}
+
+static void
+toc_author_start_element (Context *context,
+ const gchar *name,
+ const xmlChar **atrs)
+{
+ GSList *element_list = NULL;
+ AuthorInfo *author;
+ ElementIndex index;
+
+ element_list = g_slist_prepend (element_list, GINT_TO_POINTER (ARTHEADER));
+ index = find_first_parent (context, element_list);
+ g_slist_free (element_list);
+
+ switch (index) {
+ case ARTHEADER:
+ break;
+ default:
+ return;
+ };
+ author = g_new0 (AuthorInfo, 1);
+ ((TocContext *) context->data)->header->authors = g_slist_prepend (((TocContext *) context->data)->header->authors, author);
+}
+
+static void
+toc_author_characters (Context *context, const gchar *chars, int len)
+{
+ GSList *element_list = NULL;
+ AuthorInfo *author;
+ ElementIndex index;
+ char *temp;
+
+ element_list = g_slist_prepend (element_list, GINT_TO_POINTER (ARTHEADER));
+ index = find_first_parent (context, element_list);
+ g_slist_free (element_list);
+
+ switch (index) {
+ case ARTHEADER:
+ break;
+ default:
+ return;
+ };
+
+ author = (AuthorInfo *) ((TocContext *) context->data)->header->authors->data;
+ g_return_if_fail (author != NULL);
+ temp = g_strndup (chars, len);
+ if (((StackElement *) context->stack->data)->info->index == FIRSTNAME)
+ author->firstname = temp;
+ else if (((StackElement *) context->stack->data)->info->index == OTHERNAME)
+ author->othername = temp;
+ else if (((StackElement *) context->stack->data)->info->index == SURNAME)
+ author->surname = temp;
+ else if (((StackElement *) context->stack->data)->info->index == EMAIL) {
+ author->email = temp;
+ } else if (((StackElement *) context->stack->data)->info->index == ORGNAME)
+ author->orgname = temp;
+ else
+ g_free (temp);
+}
+
+static void
+toc_copyright_characters (Context *context,
+ const gchar *chars,
+ int len)
+{
+ GSList *element_list = NULL;
+ ElementIndex index;
+ gchar *temp;
+
+ element_list = g_slist_prepend (element_list, GINT_TO_POINTER (COPYRIGHT));
+ index = find_first_parent (context, element_list);
+ g_slist_free (element_list);
+
+ temp = g_strndup (chars, len);
+
+ switch (index) {
+ case COPYRIGHT:
+ if (((StackElement *) context->stack->data)->info->index == YEAR)
+ ((TocContext *)context->data)->header->copyright_year = temp;
+ else if (((StackElement *) context->stack->data)->info->index == HOLDER)
+ ((TocContext *)context->data)->header->copyright_holder = temp;
+ break;
+ default:
+ g_free (temp);
+ break;
+ };
+}
+
+static void
+toc_title_start_element (Context *context,
+ const gchar *name,
+ const xmlChar **atrs)
+{
+ GSList *element_list = NULL;
+ StackElement *stack_el;
+ gchar **atrs_ptr;
+
+ element_list = g_slist_prepend (element_list, GINT_TO_POINTER (SECT1));
+ element_list = g_slist_prepend (element_list, GINT_TO_POINTER (SECT2));
+ element_list = g_slist_prepend (element_list, GINT_TO_POINTER (SECT3));
+ element_list = g_slist_prepend (element_list, GINT_TO_POINTER (SECT4));
+ element_list = g_slist_prepend (element_list, GINT_TO_POINTER (SECT5));
+ element_list = g_slist_prepend (element_list, GINT_TO_POINTER (SECTION));
+ element_list = g_slist_prepend (element_list, GINT_TO_POINTER (FIGURE));
+ element_list = g_slist_prepend (element_list, GINT_TO_POINTER (FORMALPARA));
+ stack_el = find_first_element (context, element_list);
+
+ g_slist_free (element_list);
+ if (stack_el == NULL)
+ return;
+
+ switch (stack_el->info->index) {
+ case SECT1:
+ case SECT2:
+ case SECT3:
+ case SECT4:
+ case SECT5:
+ case SECTION:
+ if (context->sect2 == 0)
+ g_print ("<H2>");
+ else
+ g_print ("<H3>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
+ if (context->sect1 > 0) g_print ("%d", context->sect1);
+ if (context->sect2 > 0) g_print (".%d", context->sect2);
+ if (context->sect3 > 0) g_print (".%d", context->sect3);
+ if (context->sect4 > 0) g_print (".%d", context->sect4);
+ if (context->sect5 > 0) g_print (".%d", context->sect5);
+ g_print (".&nbsp;&nbsp;");
+ g_print ("<A href=\"%s#", context->base_file);
+
+ atrs_ptr = (stack_el->atrs);
+ while (atrs_ptr && *atrs_ptr) {
+ if (!strcasecmp (*atrs_ptr, "id")) {
+ atrs_ptr++;
+ g_print ("%s", *atrs_ptr);
+ break;
+ }
+ atrs_ptr += 2;
+ }
+ g_print ("\">");
+ break;
+ case FORMALPARA:
+ default:
+ break;
+ };
+
+}
+
+static void
+toc_title_end_element (Context *context,
+ const gchar *name)
+{
+ GSList *element_list = NULL;
+ ElementIndex index;
+
+ element_list = g_slist_prepend (element_list, GINT_TO_POINTER (SECT1));
+ element_list = g_slist_prepend (element_list, GINT_TO_POINTER (SECT2));
+ element_list = g_slist_prepend (element_list, GINT_TO_POINTER (SECT3));
+ element_list = g_slist_prepend (element_list, GINT_TO_POINTER (SECT4));
+ element_list = g_slist_prepend (element_list, GINT_TO_POINTER (SECT5));
+ element_list = g_slist_prepend (element_list, GINT_TO_POINTER (SECTION));
+ element_list = g_slist_prepend (element_list, GINT_TO_POINTER (FIGURE));
+ element_list = g_slist_prepend (element_list, GINT_TO_POINTER (FORMALPARA));
+
+ index = find_first_parent (context, element_list);
+
+ switch (index) {
+ case SECT1:
+ case SECTION:
+ g_print ("</A></H2>\n");
+ break;
+ case SECT2:
+ case SECT3:
+ case SECT4:
+ case SECT5:
+ g_print ("</A></H3>\n");
+ break;
+ case FORMALPARA:
+ break;
+ default:
+ break;
+ };
+
+ g_slist_free (element_list);
+}
+
+static void
+toc_title_characters (Context *context, const gchar *chars, int len)
+{
+ GSList *element_list = NULL;
+ ElementIndex index;
+ char *temp;
+
+ element_list = g_slist_prepend (element_list, GINT_TO_POINTER (SECT1));
+ element_list = g_slist_prepend (element_list, GINT_TO_POINTER (SECT2));
+ element_list = g_slist_prepend (element_list, GINT_TO_POINTER (SECT3));
+ element_list = g_slist_prepend (element_list, GINT_TO_POINTER (SECT4));
+ element_list = g_slist_prepend (element_list, GINT_TO_POINTER (SECT5));
+ element_list = g_slist_prepend (element_list, GINT_TO_POINTER (SECTION));
+ element_list = g_slist_prepend (element_list, GINT_TO_POINTER (ARTHEADER));
+ element_list = g_slist_prepend (element_list, GINT_TO_POINTER (FIGURE));
+ element_list = g_slist_prepend (element_list, GINT_TO_POINTER (FORMALPARA));
+
+ index = find_first_parent (context, element_list);
+
+ temp = g_strndup (chars, len);
+
+ switch (index) {
+ case SECT1:
+ case SECT2:
+ case SECT3:
+ case SECT4:
+ case SECT5:
+ case SECTION:
+ g_print (temp);
+ g_free (temp);
+ break;
+ case ARTHEADER:
+ if (((StackElement *)context->stack->data)->info->index == TITLE)
+ ((TocContext *) context->data)->header->title = temp;
+ else if (((StackElement *)context->stack->data)->info->index == SUBTITLE)
+ ((TocContext *) context->data)->header->subtitle = temp;
+ break;
+ default:
+ g_free (temp);
+ break;
+ };
+
+ g_slist_free (element_list);
+}
diff --git a/components/help/converters/gnome-db2html2/toc-elements.h b/components/help/converters/gnome-db2html2/toc-elements.h
new file mode 100644
index 000000000..329e5a4b9
--- /dev/null
+++ b/components/help/converters/gnome-db2html2/toc-elements.h
@@ -0,0 +1,10 @@
+#ifndef __TOC_ELEMENTS_H__
+#define __TOC_ELEMENTS_H__
+
+#include "gdb3html.h"
+
+extern ElementInfo toc_elements[];
+
+gpointer toc_init_data (void);
+
+#endif