~ubuntu-branches/ubuntu/maverick/gettext/maverick

« back to all changes in this revision

Viewing changes to gettext-tools/gnulib-lib/html-styled-ostream.c

  • Committer: Colin Watson
  • Date: 2010-08-01 21:36:08 UTC
  • mfrom: (2.1.10 sid)
  • Revision ID: cjwatson@canonical.com-20100801213608-yy7vkm8lpatep3ci
merge from Debian 0.18.1.1-1

Show diffs side-by-side

added added

removed removed

Lines of Context:
62
62
 
63
63
static void
64
64
html_styled_ostream__write_mem (html_styled_ostream_t stream,
65
 
                                const void *data, size_t len)
 
65
                                const void *data, size_t len)
66
66
{
67
67
  html_ostream_write_mem (stream->html_destination, data, len);
68
68
}
85
85
 
86
86
static void
87
87
html_styled_ostream__begin_use_class (html_styled_ostream_t stream,
88
 
                                      const char *classname)
 
88
                                      const char *classname)
89
89
{
90
90
  html_ostream_begin_span (stream->html_destination, classname);
91
91
}
92
92
 
93
93
static void
94
94
html_styled_ostream__end_use_class (html_styled_ostream_t stream,
95
 
                                    const char *classname)
 
95
                                    const char *classname)
96
96
{
97
97
  html_ostream_end_span (stream->html_destination, classname);
98
98
}
121
121
       - special characters like < > & " are escaped in the <style> and
122
122
         <script> elements.  */
123
123
  ostream_write_str (stream->destination,
124
 
                     "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">\n");
 
124
                     "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">\n");
125
125
  ostream_write_str (stream->destination, "<html>\n");
126
126
  ostream_write_str (stream->destination, "<head>\n");
127
127
  if (css_filename != NULL)
128
128
    {
129
129
      ostream_write_str (stream->destination, "<style type=\"text/css\">\n"
130
 
                                              "<!--\n");
 
130
                                              "<!--\n");
131
131
 
132
132
      /* Include the contents of CSS_FILENAME literally.  */
133
133
      {
134
 
        int fd;
135
 
        char buf[4096];
136
 
 
137
 
        fd = open (css_filename, O_RDONLY | O_TEXT);
138
 
        if (fd < 0)
139
 
          error (EXIT_FAILURE, errno,
140
 
                 _("error while opening \"%s\" for reading"),
141
 
                 css_filename);
142
 
 
143
 
        for (;;)
144
 
          {
145
 
            size_t n_read = safe_read (fd, buf, sizeof (buf));
146
 
            if (n_read == SAFE_READ_ERROR)
147
 
              error (EXIT_FAILURE, errno, _("error reading \"%s\""),
148
 
                     css_filename);
149
 
            if (n_read == 0)
150
 
              break;
151
 
 
152
 
            ostream_write_mem (stream->destination, buf, n_read);
153
 
          }
154
 
 
155
 
        if (close (fd) < 0)
156
 
          error (EXIT_FAILURE, errno, _("error after reading \"%s\""),
157
 
                 css_filename);
 
134
        int fd;
 
135
        char buf[4096];
 
136
 
 
137
        fd = open (css_filename, O_RDONLY | O_TEXT);
 
138
        if (fd < 0)
 
139
          error (EXIT_FAILURE, errno,
 
140
                 _("error while opening \"%s\" for reading"),
 
141
                 css_filename);
 
142
 
 
143
        for (;;)
 
144
          {
 
145
            size_t n_read = safe_read (fd, buf, sizeof (buf));
 
146
            if (n_read == SAFE_READ_ERROR)
 
147
              error (EXIT_FAILURE, errno, _("error reading \"%s\""),
 
148
                     css_filename);
 
149
            if (n_read == 0)
 
150
              break;
 
151
 
 
152
            ostream_write_mem (stream->destination, buf, n_read);
 
153
          }
 
154
 
 
155
        if (close (fd) < 0)
 
156
          error (EXIT_FAILURE, errno, _("error after reading \"%s\""),
 
157
                 css_filename);
158
158
      }
159
159
 
160
160
      ostream_write_str (stream->destination, "-->\n"
161
 
                                              "</style>\n");
 
161
                                              "</style>\n");
162
162
    }
163
163
  ostream_write_str (stream->destination, "</head>\n");
164
164
  ostream_write_str (stream->destination, "<body>\n");