|
Packit Bot |
06c835 |
/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
|
|
Packit Bot |
06c835 |
|
|
Packit Bot |
06c835 |
#line 1 "html-styled-ostream.oo.c"
|
|
Packit Bot |
06c835 |
/* Output stream for CSS styled text, producing HTML output.
|
|
Packit Bot |
06c835 |
Copyright (C) 2006-2007, 2015 Free Software Foundation, Inc.
|
|
Packit Bot |
06c835 |
Written by Bruno Haible <bruno@clisp.org>, 2006.
|
|
Packit Bot |
06c835 |
|
|
Packit Bot |
06c835 |
This program is free software: you can redistribute it and/or modify
|
|
Packit Bot |
06c835 |
it under the terms of the GNU General Public License as published by
|
|
Packit Bot |
06c835 |
the Free Software Foundation; either version 3 of the License, or
|
|
Packit Bot |
06c835 |
(at your option) any later version.
|
|
Packit Bot |
06c835 |
|
|
Packit Bot |
06c835 |
This program is distributed in the hope that it will be useful,
|
|
Packit Bot |
06c835 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit Bot |
06c835 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
Packit Bot |
06c835 |
GNU General Public License for more details.
|
|
Packit Bot |
06c835 |
|
|
Packit Bot |
06c835 |
You should have received a copy of the GNU General Public License
|
|
Packit Bot |
06c835 |
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
|
Packit Bot |
06c835 |
|
|
Packit Bot |
06c835 |
#include <config.h>
|
|
Packit Bot |
06c835 |
|
|
Packit Bot |
06c835 |
/* Specification. */
|
|
Packit Bot |
06c835 |
#include "html-styled-ostream.h"
|
|
Packit Bot |
06c835 |
|
|
Packit Bot |
06c835 |
#include <errno.h>
|
|
Packit Bot |
06c835 |
#include <fcntl.h>
|
|
Packit Bot |
06c835 |
#include <stdlib.h>
|
|
Packit Bot |
06c835 |
#include <unistd.h>
|
|
Packit Bot |
06c835 |
|
|
Packit Bot |
06c835 |
#include "html-ostream.h"
|
|
Packit Bot |
06c835 |
|
|
Packit Bot |
06c835 |
#include "binary-io.h"
|
|
Packit Bot |
06c835 |
#ifndef O_TEXT
|
|
Packit Bot |
06c835 |
# define O_TEXT 0
|
|
Packit Bot |
06c835 |
#endif
|
|
Packit Bot |
06c835 |
|
|
Packit Bot |
06c835 |
#include "error.h"
|
|
Packit Bot |
06c835 |
#include "safe-read.h"
|
|
Packit Bot |
06c835 |
#include "xalloc.h"
|
|
Packit Bot |
06c835 |
#include "gettext.h"
|
|
Packit Bot |
06c835 |
|
|
Packit Bot |
06c835 |
#define _(str) gettext (str)
|
|
Packit Bot |
06c835 |
|
|
Packit Bot |
06c835 |
|
|
Packit Bot |
06c835 |
#line 47 "html-styled-ostream.c"
|
|
Packit Bot |
06c835 |
#if !IS_CPLUSPLUS
|
|
Packit Bot |
06c835 |
#define html_styled_ostream_representation any_ostream_representation
|
|
Packit Bot |
06c835 |
#endif
|
|
Packit Bot |
06c835 |
#include "html_styled_ostream.priv.h"
|
|
Packit Bot |
06c835 |
|
|
Packit Bot |
06c835 |
const typeinfo_t html_styled_ostream_typeinfo = { "html_styled_ostream" };
|
|
Packit Bot |
06c835 |
|
|
Packit Bot |
06c835 |
static const typeinfo_t * const html_styled_ostream_superclasses[] =
|
|
Packit Bot |
06c835 |
{ html_styled_ostream_SUPERCLASSES };
|
|
Packit Bot |
06c835 |
|
|
Packit Bot |
06c835 |
#define super styled_ostream_vtable
|
|
Packit Bot |
06c835 |
|
|
Packit Bot |
06c835 |
#line 51 "html-styled-ostream.oo.c"
|
|
Packit Bot |
06c835 |
|
|
Packit Bot |
06c835 |
/* Implementation of ostream_t methods. */
|
|
Packit Bot |
06c835 |
|
|
Packit Bot |
06c835 |
static void
|
|
Packit Bot |
06c835 |
html_styled_ostream__write_mem (html_styled_ostream_t stream,
|
|
Packit Bot |
06c835 |
const void *data, size_t len)
|
|
Packit Bot |
06c835 |
{
|
|
Packit Bot |
06c835 |
html_ostream_write_mem (stream->html_destination, data, len);
|
|
Packit Bot |
06c835 |
}
|
|
Packit Bot |
06c835 |
|
|
Packit Bot |
06c835 |
static void
|
|
Packit Bot |
06c835 |
html_styled_ostream__flush (html_styled_ostream_t stream)
|
|
Packit Bot |
06c835 |
{
|
|
Packit Bot |
06c835 |
html_ostream_flush (stream->html_destination);
|
|
Packit Bot |
06c835 |
}
|
|
Packit Bot |
06c835 |
|
|
Packit Bot |
06c835 |
static void
|
|
Packit Bot |
06c835 |
html_styled_ostream__free (html_styled_ostream_t stream)
|
|
Packit Bot |
06c835 |
{
|
|
Packit Bot |
06c835 |
html_ostream_free (stream->html_destination);
|
|
Packit Bot |
06c835 |
ostream_write_str (stream->destination, "</body>\n");
|
|
Packit Bot |
06c835 |
ostream_write_str (stream->destination, "</html>\n");
|
|
Packit Bot |
06c835 |
}
|
|
Packit Bot |
06c835 |
|
|
Packit Bot |
06c835 |
/* Implementation of styled_ostream_t methods. */
|
|
Packit Bot |
06c835 |
|
|
Packit Bot |
06c835 |
static void
|
|
Packit Bot |
06c835 |
html_styled_ostream__begin_use_class (html_styled_ostream_t stream,
|
|
Packit Bot |
06c835 |
const char *classname)
|
|
Packit Bot |
06c835 |
{
|
|
Packit Bot |
06c835 |
html_ostream_begin_span (stream->html_destination, classname);
|
|
Packit Bot |
06c835 |
}
|
|
Packit Bot |
06c835 |
|
|
Packit Bot |
06c835 |
static void
|
|
Packit Bot |
06c835 |
html_styled_ostream__end_use_class (html_styled_ostream_t stream,
|
|
Packit Bot |
06c835 |
const char *classname)
|
|
Packit Bot |
06c835 |
{
|
|
Packit Bot |
06c835 |
html_ostream_end_span (stream->html_destination, classname);
|
|
Packit Bot |
06c835 |
}
|
|
Packit Bot |
06c835 |
|
|
Packit Bot |
06c835 |
/* Constructor. */
|
|
Packit Bot |
06c835 |
|
|
Packit Bot |
06c835 |
html_styled_ostream_t
|
|
Packit Bot |
06c835 |
html_styled_ostream_create (ostream_t destination, const char *css_filename)
|
|
Packit Bot |
06c835 |
{
|
|
Packit Bot |
06c835 |
html_styled_ostream_t stream =
|
|
Packit Bot |
06c835 |
XMALLOC (struct html_styled_ostream_representation);
|
|
Packit Bot |
06c835 |
|
|
Packit Bot |
06c835 |
stream->base.base.vtable = &html_styled_ostream_vtable;
|
|
Packit Bot |
06c835 |
stream->destination = destination;
|
|
Packit Bot |
06c835 |
stream->html_destination = html_ostream_create (destination);
|
|
Packit Bot |
06c835 |
|
|
Packit Bot |
06c835 |
ostream_write_str (stream->destination, "\n");
|
|
Packit Bot |
06c835 |
/* HTML 4.01 or XHTML 1.0?
|
|
Packit Bot |
06c835 |
Use HTML 4.01. This is conservative. Before switching to XHTML 1.0,
|
|
Packit Bot |
06c835 |
verify that in the output
|
|
Packit Bot |
06c835 |
- all HTML element names are in lowercase,
|
|
Packit Bot |
06c835 |
- all empty elements are denoted like or ,
|
|
Packit Bot |
06c835 |
- every attribute specification is in assignment form, like
|
|
Packit Bot |
06c835 |
,
|
|
Packit Bot |
06c835 |
- every element also has an 'id' attribute,
|
|
Packit Bot |
06c835 |
- special characters like < > & " are escaped in the <style> and
|
|
Packit Bot |
06c835 |
<script> elements. */
|
|
Packit Bot |
06c835 |
ostream_write_str (stream->destination,
|
|
Packit Bot |
06c835 |
"\n");
|
|
Packit Bot |
06c835 |
ostream_write_str (stream->destination, "<html>\n");
|
|
Packit Bot |
06c835 |
ostream_write_str (stream->destination, "<head>\n");
|
|
Packit Bot |
06c835 |
if (css_filename != NULL)
|
|
Packit Bot |
06c835 |
{
|
|
Packit Bot |
06c835 |
ostream_write_str (stream->destination, "<style type=\"text/css\">\n"
|
|
Packit Bot |
06c835 |
"
|
|
Packit Bot |
06c835 |
|
|
Packit Bot |
06c835 |
/* Include the contents of CSS_FILENAME literally. */
|
|
Packit Bot |
06c835 |
{
|
|
Packit Bot |
06c835 |
int fd;
|
|
Packit Bot |
06c835 |
char buf[4096];
|
|
Packit Bot |
06c835 |
|
|
Packit Bot |
06c835 |
fd = open (css_filename, O_RDONLY | O_TEXT);
|
|
Packit Bot |
06c835 |
if (fd < 0)
|
|
Packit Bot |
06c835 |
error (EXIT_FAILURE, errno,
|
|
Packit Bot |
06c835 |
_("error while opening \"%s\" for reading"),
|
|
Packit Bot |
06c835 |
css_filename);
|
|
Packit Bot |
06c835 |
|
|
Packit Bot |
06c835 |
for (;;)
|
|
Packit Bot |
06c835 |
{
|
|
Packit Bot |
06c835 |
size_t n_read = safe_read (fd, buf, sizeof (buf));
|
|
Packit Bot |
06c835 |
if (n_read == SAFE_READ_ERROR)
|
|
Packit Bot |
06c835 |
error (EXIT_FAILURE, errno, _("error reading \"%s\""),
|
|
Packit Bot |
06c835 |
css_filename);
|
|
Packit Bot |
06c835 |
if (n_read == 0)
|
|
Packit Bot |
06c835 |
break;
|
|
Packit Bot |
06c835 |
|
|
Packit Bot |
06c835 |
ostream_write_mem (stream->destination, buf, n_read);
|
|
Packit Bot |
06c835 |
}
|
|
Packit Bot |
06c835 |
|
|
Packit Bot |
06c835 |
if (close (fd) < 0)
|
|
Packit Bot |
06c835 |
error (EXIT_FAILURE, errno, _("error after reading \"%s\""),
|
|
Packit Bot |
06c835 |
css_filename);
|
|
Packit Bot |
06c835 |
}
|
|
Packit Bot |
06c835 |
|
|
Packit Bot |
06c835 |
ostream_write_str (stream->destination, "-->\n"
|
|
Packit Bot |
06c835 |
"</style>\n");
|
|
Packit Bot |
06c835 |
}
|
|
Packit Bot |
06c835 |
ostream_write_str (stream->destination, "</head>\n");
|
|
Packit Bot |
06c835 |
ostream_write_str (stream->destination, "<body>\n");
|
|
Packit Bot |
06c835 |
|
|
Packit Bot |
06c835 |
return stream;
|
|
Packit Bot |
06c835 |
}
|
|
Packit Bot |
06c835 |
|
|
Packit Bot |
06c835 |
#line 170 "html-styled-ostream.c"
|
|
Packit Bot |
06c835 |
|
|
Packit Bot |
06c835 |
const struct html_styled_ostream_implementation html_styled_ostream_vtable =
|
|
Packit Bot |
06c835 |
{
|
|
Packit Bot |
06c835 |
html_styled_ostream_superclasses,
|
|
Packit Bot |
06c835 |
sizeof (html_styled_ostream_superclasses) / sizeof (html_styled_ostream_superclasses[0]),
|
|
Packit Bot |
06c835 |
sizeof (struct html_styled_ostream_representation),
|
|
Packit Bot |
06c835 |
html_styled_ostream__write_mem,
|
|
Packit Bot |
06c835 |
html_styled_ostream__flush,
|
|
Packit Bot |
06c835 |
html_styled_ostream__free,
|
|
Packit Bot |
06c835 |
html_styled_ostream__begin_use_class,
|
|
Packit Bot |
06c835 |
html_styled_ostream__end_use_class,
|
|
Packit Bot |
06c835 |
};
|
|
Packit Bot |
06c835 |
|
|
Packit Bot |
06c835 |
#if !HAVE_INLINE
|
|
Packit Bot |
06c835 |
|
|
Packit Bot |
06c835 |
/* Define the functions that invoke the methods. */
|
|
Packit Bot |
06c835 |
|
|
Packit Bot |
06c835 |
void
|
|
Packit Bot |
06c835 |
html_styled_ostream_write_mem (html_styled_ostream_t first_arg, const void *data, size_t len)
|
|
Packit Bot |
06c835 |
{
|
|
Packit Bot |
06c835 |
const struct html_styled_ostream_implementation *vtable =
|
|
Packit Bot |
06c835 |
((struct html_styled_ostream_representation_header *) (struct html_styled_ostream_representation *) first_arg)->vtable;
|
|
Packit Bot |
06c835 |
vtable->write_mem (first_arg,data,len);
|
|
Packit Bot |
06c835 |
}
|
|
Packit Bot |
06c835 |
|
|
Packit Bot |
06c835 |
void
|
|
Packit Bot |
06c835 |
html_styled_ostream_flush (html_styled_ostream_t first_arg)
|
|
Packit Bot |
06c835 |
{
|
|
Packit Bot |
06c835 |
const struct html_styled_ostream_implementation *vtable =
|
|
Packit Bot |
06c835 |
((struct html_styled_ostream_representation_header *) (struct html_styled_ostream_representation *) first_arg)->vtable;
|
|
Packit Bot |
06c835 |
vtable->flush (first_arg);
|
|
Packit Bot |
06c835 |
}
|
|
Packit Bot |
06c835 |
|
|
Packit Bot |
06c835 |
void
|
|
Packit Bot |
06c835 |
html_styled_ostream_free (html_styled_ostream_t first_arg)
|
|
Packit Bot |
06c835 |
{
|
|
Packit Bot |
06c835 |
const struct html_styled_ostream_implementation *vtable =
|
|
Packit Bot |
06c835 |
((struct html_styled_ostream_representation_header *) (struct html_styled_ostream_representation *) first_arg)->vtable;
|
|
Packit Bot |
06c835 |
vtable->free (first_arg);
|
|
Packit Bot |
06c835 |
}
|
|
Packit Bot |
06c835 |
|
|
Packit Bot |
06c835 |
void
|
|
Packit Bot |
06c835 |
html_styled_ostream_begin_use_class (html_styled_ostream_t first_arg, const char *classname)
|
|
Packit Bot |
06c835 |
{
|
|
Packit Bot |
06c835 |
const struct html_styled_ostream_implementation *vtable =
|
|
Packit Bot |
06c835 |
((struct html_styled_ostream_representation_header *) (struct html_styled_ostream_representation *) first_arg)->vtable;
|
|
Packit Bot |
06c835 |
vtable->begin_use_class (first_arg,classname);
|
|
Packit Bot |
06c835 |
}
|
|
Packit Bot |
06c835 |
|
|
Packit Bot |
06c835 |
void
|
|
Packit Bot |
06c835 |
html_styled_ostream_end_use_class (html_styled_ostream_t first_arg, const char *classname)
|
|
Packit Bot |
06c835 |
{
|
|
Packit Bot |
06c835 |
const struct html_styled_ostream_implementation *vtable =
|
|
Packit Bot |
06c835 |
((struct html_styled_ostream_representation_header *) (struct html_styled_ostream_representation *) first_arg)->vtable;
|
|
Packit Bot |
06c835 |
vtable->end_use_class (first_arg,classname);
|
|
Packit Bot |
06c835 |
}
|
|
Packit Bot |
06c835 |
|
|
Packit Bot |
06c835 |
#endif
|