40 |
#include "som.h" |
#include "som.h" |
41 |
#include "tab.h" |
#include "tab.h" |
42 |
#include "version.h" |
#include "version.h" |
43 |
|
#include "mkfile.h" |
44 |
|
|
45 |
/* Prototypes. */ |
/* Prototypes. */ |
46 |
static int postopen (struct file_ext *); |
static int postopen (struct file_ext *); |
123 |
return 1; |
return 1; |
124 |
} |
} |
125 |
|
|
126 |
|
|
127 |
|
/* Link the image contained in FILENAME to the |
128 |
|
HTML stream in file F. */ |
129 |
|
static int |
130 |
|
link_image (struct file_ext *f, char *filename) |
131 |
|
{ |
132 |
|
fprintf (f->file, |
133 |
|
"<IMG SRC=\"%s\"/>", filename); |
134 |
|
|
135 |
|
if (ferror (f->file)) |
136 |
|
return 0; |
137 |
|
|
138 |
|
return 1; |
139 |
|
} |
140 |
|
|
141 |
|
|
142 |
/* Generic option types. */ |
/* Generic option types. */ |
143 |
enum |
enum |
144 |
{ |
{ |
409 |
static void output_tab_table (struct outp_driver *, struct tab_table *); |
static void output_tab_table (struct outp_driver *, struct tab_table *); |
410 |
|
|
411 |
static void |
static void |
412 |
html_submit (struct outp_driver *this, struct som_table *s) |
html_submit (struct outp_driver *this, struct som_entity *s) |
413 |
{ |
{ |
414 |
extern struct som_table_class tab_table_class; |
extern struct som_table_class tab_table_class; |
415 |
struct html_driver_ext *x = this->ext; |
struct html_driver_ext *x = this->ext; |
421 |
return; |
return; |
422 |
} |
} |
423 |
|
|
424 |
if (s->class == &tab_table_class) |
assert ( s->class == &tab_table_class ) ; |
425 |
output_tab_table (this, (struct tab_table *) s->ext); |
|
426 |
else |
switch (s->type) |
427 |
assert (0); |
{ |
428 |
|
case SOM_TABLE: |
429 |
|
output_tab_table ( this, (struct tab_table *) s->ext); |
430 |
|
break; |
431 |
|
case SOM_CHART: |
432 |
|
link_image( &x->file, ((struct chart *)s->ext)->filename); |
433 |
|
break; |
434 |
|
default: |
435 |
|
assert(0); |
436 |
|
break; |
437 |
|
} |
438 |
|
|
439 |
} |
} |
440 |
|
|
441 |
/* Write string S of length LEN to file F, escaping characters as |
/* Write string S of length LEN to file F, escaping characters as |
582 |
fputs ("</TABLE>\n\n", x->file.file); |
fputs ("</TABLE>\n\n", x->file.file); |
583 |
} |
} |
584 |
|
|
585 |
|
|
586 |
|
void html_initialise_chart(struct outp_class *c, struct chart *ch); |
587 |
|
void html_finalise_chart(struct outp_class *c, struct chart *ch); |
588 |
|
|
589 |
|
|
590 |
|
void |
591 |
|
html_initialise_chart(struct outp_class *c UNUSED, struct chart *ch) |
592 |
|
{ |
593 |
|
|
594 |
|
FILE *fp; |
595 |
|
|
596 |
|
make_unique_file_stream(&fp, &ch->filename); |
597 |
|
|
598 |
|
#ifdef NO_CHARTS |
599 |
|
ch->lp = 0; |
600 |
|
#else |
601 |
|
ch->pl_params = pl_newplparams(); |
602 |
|
ch->lp = pl_newpl_r ("png", 0, fp, stderr, ch->pl_params); |
603 |
|
#endif |
604 |
|
|
605 |
|
} |
606 |
|
|
607 |
|
void |
608 |
|
html_finalise_chart(struct outp_class *c UNUSED, struct chart *ch) |
609 |
|
{ |
610 |
|
free(ch->filename); |
611 |
|
} |
612 |
|
|
613 |
|
|
614 |
|
|
615 |
/* HTML driver class. */ |
/* HTML driver class. */ |
616 |
struct outp_class html_class = |
struct outp_class html_class = |
617 |
{ |
{ |
651 |
NULL, |
NULL, |
652 |
NULL, |
NULL, |
653 |
NULL, |
NULL, |
654 |
|
|
655 |
|
html_initialise_chart, |
656 |
|
html_finalise_chart |
657 |
|
|
658 |
}; |
}; |
659 |
|
|
660 |
#endif /* !NO_HTML */ |
#endif /* !NO_HTML */ |