1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
|
/*
* html.c:
*
* Copyright (c) 2008 James McKenzie <james@fishsoup.dhs.org>,
* All rights reserved.
*
*/
static char rcsid[] = "$Id$";
/*
* $Log$
* Revision 1.2 2008/02/04 02:05:06 james
* *** empty log message ***
*
* Revision 1.1 2008/02/03 23:31:25 james
* *** empty log message ***
*
*/
#include "project.h"
void
html_entity (FILE * f, int c)
{
switch (c)
{
case 32:
fprintf (f, " ");
break;
case 38:
fprintf (f, "&");
break;
case 60:
fprintf (f, "<");
break;
case 62:
fprintf (f, ">");
break;
default:
fputc (c, f);
}
}
void
html_render (FILE * f, CRT_CA c)
{
if (c.attr & CRT_ATTR_REVERSE)
{
fprintf (f, "<td bgcolor='#000000'><font color='#ffffff'>");
}
else
{
fprintf (f, "<td>");
}
if (c.attr & CRT_ATTR_UNDERLINE)
fprintf (f, "<ul>");
if (c.attr & CRT_ATTR_BOLD)
fprintf (f, "<b>");
if (c.chr < 32)
c.chr = 32;
if (c.chr > 126)
c.chr = 32;
html_entity (f, c.chr);
if (c.attr & CRT_ATTR_BOLD)
fprintf (f, "</b>");
if (c.attr & CRT_ATTR_UNDERLINE)
fprintf (f, "</ul>");
if (c.attr & CRT_ATTR_REVERSE)
{
fprintf (f, "</font>");
}
fprintf (f, "</td>");
}
void
html_draw (FILE * f, CRT * c)
{
CRT_Pos p;
int o;
fprintf (f, "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\n");
for (p.y = 0; p.y < CRT_ROWS; ++p.y)
{
o = CRT_ADDR (p.y, 0);
fprintf (f, "<tr>");
for (p.x = 0; p.x < CRT_ROWS; ++p.x, ++o)
{
html_render (f, c->screen[o]);
}
fprintf (f, "</tr>\n");
}
fprintf (f, "</table>\n");
}
|