/[public]/psiconv/trunk/program/psiconv/gen_html.c
ViewVC logotype

Diff of /psiconv/trunk/program/psiconv/gen_html.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 34 Revision 67
19 19
20#include "config.h" 20#include "config.h"
21#include <stdio.h> 21#include <stdio.h>
22#include <string.h> 22#include <string.h>
23#include <stdlib.h> 23#include <stdlib.h>
24#include "data.h" 24#include "psiconv/data.h"
25#include "list.h" 25#include "psiconv/list.h"
26#include "gen.h" 26#include "gen.h"
27#include "psiconv.h" 27#include "psiconv.h"
28 28
29/* This determines for each character how it is displayed */ 29/* This determines for each character how it is displayed */
30static const char *char_table[0x100] = 30static const char *char_table[0x100] =
91 This one is specific for the base point of HTML */ 91 This one is specific for the base point of HTML */
92psiconv_character_layout gen_base_char(const psiconv_font font, 92psiconv_character_layout gen_base_char(const psiconv_font font,
93 const psiconv_color color, 93 const psiconv_color color,
94 const psiconv_color back_color) 94 const psiconv_color back_color)
95{ 95{
96 struct psiconv_character_layout base_char_struct = 96 struct psiconv_character_layout_s base_char_struct =
97 { 97 {
98 NULL, /* color */ 98 NULL, /* color */
99 NULL, /* back_color */ 99 NULL, /* back_color */
100 13.0, /* font_size */ 100 13.0, /* font_size */
101 psiconv_bool_false, /* italic */ 101 psiconv_bool_false, /* italic */
102 psiconv_bool_false, /* bold */ 102 psiconv_bool_false, /* bold */
103 psiconv_normalscript, /* super_sub */ 103 psiconv_normalscript, /* super_sub */
104 psiconv_bool_false, /* underline */ 104 psiconv_bool_false, /* underline */
105 psiconv_bool_false, /* strike_out */ 105 psiconv_bool_false, /* strikethrough */
106 NULL, /* font */ 106 NULL, /* font */
107 }; 107 };
108 base_char_struct.color = color; 108 base_char_struct.color = color;
109 base_char_struct.back_color = back_color; 109 base_char_struct.back_color = back_color;
110 base_char_struct.font = font; 110 base_char_struct.font = font;
131 fputs("</I>",of); 131 fputs("</I>",of);
132 if (old->bold) 132 if (old->bold)
133 fputs("</B>",of); 133 fputs("</B>",of);
134 if (old->underline) 134 if (old->underline)
135 fputs("</U>",of); 135 fputs("</U>",of);
136 if (old->strike_out) 136 if (old->strikethrough)
137 fputs("</STRIKE>",of); 137 fputs("</STRIKE>",of);
138 if (old->super_sub == psiconv_superscript) 138 if (old->super_sub == psiconv_superscript)
139 fputs("</SUP>",of); 139 fputs("</SUP>",of);
140 if (old->super_sub == psiconv_subscript) 140 if (old->super_sub == psiconv_subscript)
141 fputs("</SUB>",of); 141 fputs("</SUB>",of);
173 fputs("<I>",of); 173 fputs("<I>",of);
174 if (new->bold) 174 if (new->bold)
175 fputs("<B>",of); 175 fputs("<B>",of);
176 if (new->underline) 176 if (new->underline)
177 fputs("<U>",of); 177 fputs("<U>",of);
178 if (new->strike_out) 178 if (new->strikethrough)
179 fputs("<STRIKE>",of); 179 fputs("<STRIKE>",of);
180 if (new->super_sub == psiconv_superscript) 180 if (new->super_sub == psiconv_superscript)
181 fputs("<SUP>",of); 181 fputs("<SUP>",of);
182 if (new->super_sub == psiconv_subscript) 182 if (new->super_sub == psiconv_subscript)
183 fputs("<SUB>",of); 183 fputs("<SUB>",of);
198 if (old->underline) 198 if (old->underline)
199 fputs("</U>",of); 199 fputs("</U>",of);
200 else 200 else
201 fputs("<U>",of); 201 fputs("<U>",of);
202 } 202 }
203 if (old->strike_out != new->strike_out) { 203 if (old->strikethrough != new->strikethrough) {
204 if (old->strike_out) 204 if (old->strikethrough)
205 fputs("</STRIKE>",of); 205 fputs("</STRIKE>",of);
206 else 206 else
207 fputs("<STRIKE>",of); 207 fputs("<STRIKE>",of);
208 } 208 }
209 if (old->super_sub != new->super_sub) { 209 if (old->super_sub != new->super_sub) {
277 fputs("</UL>",of); 277 fputs("</UL>",of);
278 278
279 fputs("</P>\n",of); 279 fputs("</P>\n",of);
280} 280}
281 281
282int psiconv_gen_html(FILE *of,const psiconv_file file, const char *dest) 282int psiconv_gen_html(const char * filename,const psiconv_file file,
283 const char *dest)
283{ 284{
285 FILE *of = fopen(filename,"w");
286 if (! of)
287 return -1;
288
284 if (file->type == psiconv_word_file) { 289 if (file->type == psiconv_word_file) {
285 psiconv_gen_html_word(of,(psiconv_word_f) file->file); 290 psiconv_gen_html_word(of,(psiconv_word_f) file->file);
286 return 0;
287 } else if (file->type == psiconv_texted_file) { 291 } else if (file->type == psiconv_texted_file) {
288 psiconv_gen_html_texted(of,(psiconv_texted_f) file->file); 292 psiconv_gen_html_texted(of,(psiconv_texted_f) file->file);
289 return 0;
290 } else 293 } else {
294 fclose(of);
291 return -1; 295 return -1;
296 }
297 return fclose(of);
292} 298}
293 299
294void psiconv_gen_html_texted(FILE *of,psiconv_texted_f tf) 300void psiconv_gen_html_texted(FILE *of,psiconv_texted_f tf)
295{ 301{
296 psiconv_character_layout base_char; 302 psiconv_character_layout base_char;
347 } 353 }
348 fputs("</BODY>\n</HTML>\n",of); 354 fputs("</BODY>\n</HTML>\n",of);
349 psiconv_free_character_layout(base_char); 355 psiconv_free_character_layout(base_char);
350} 356}
351 357
352static struct psiconv_fileformat ff = 358static struct psiconv_fileformat_s ff =
353 { 359 {
354 "HTML3", 360 "HTML3",
355 "HTML 3.2, not verified so probably not completely compliant", 361 "HTML 3.2, not verified so probably not completely compliant",
356 &psiconv_gen_html 362 &psiconv_gen_html
357 }; 363 };

Legend:
Removed from v.34  
changed lines
  Added in v.67

frodo@frodo.looijaard.name
ViewVC Help
Powered by ViewVC 1.1.26