aboutsummaryrefslogtreecommitdiffstats
path: root/vbistuff
diff options
context:
space:
mode:
authorGerd Hoffmann <kraxel@redhat.com>2010-04-01 09:24:39 (GMT)
committerGerd Hoffmann <kraxel@redhat.com>2010-04-01 09:24:39 (GMT)
commitbc7f101b0c874e21473aca15d9b08de8bd164392 (patch)
tree878e2a671f9bd0b3401383406a513c8056f25e17 /vbistuff
parenta4a3e6b21da7d11e66364ab9ab67795a3f78020a (diff)
v3.75
Diffstat (limited to 'vbistuff')
-rw-r--r--vbistuff/Subdir.mk34
-rw-r--r--vbistuff/about.html.in374
-rw-r--r--vbistuff/alevt.css.in82
-rw-r--r--vbistuff/alevtd.c (renamed from vbistuff/main.c)123
-rw-r--r--vbistuff/bottom.html.in16
-rw-r--r--vbistuff/httpd.h6
-rw-r--r--vbistuff/page.c581
-rw-r--r--vbistuff/response.c3
8 files changed, 731 insertions, 488 deletions
diff --git a/vbistuff/Subdir.mk b/vbistuff/Subdir.mk
index d65684f..da3a9a7 100644
--- a/vbistuff/Subdir.mk
+++ b/vbistuff/Subdir.mk
@@ -1,30 +1,32 @@
-# variables
-TARGETS-vbistuff := vbistuff/alevtd vbistuff/ntsc-cc
+# targets to build
+TARGETS-vbistuff := \
+ vbistuff/ntsc-cc
+ifeq ($(FOUND_ZVBI),yes)
+TARGETS-vbistuff += \
+ vbistuff/alevtd
+endif
HTML-alevtd := \
vbistuff/alevt.css.h \
vbistuff/top.html.h \
vbistuff/bottom.html.h \
- vbistuff/about.html.h \
+ vbistuff/about.html.h
-OBJS-alevtd := \
- vbistuff/main.o \
+# objects for targets
+vbistuff/alevtd: \
+ vbistuff/alevtd.o \
vbistuff/request.o \
vbistuff/response.o \
vbistuff/page.o \
- libng/devices.o \
- libvbi/libvbi.a
-OBJS-ntsc-cc := \
- vbistuff/ntsc-cc.o
+ common/vbi-data.o \
+ libng/devices.o
-# local targets
-vbistuff/alevtd: $(OBJS-alevtd)
- $(CC) $(CFLAGS) -o $@ $(OBJS-alevtd)
-
-vbistuff/ntsc-cc: $(OBJS-ntsc-cc)
- $(CC) $(CFLAGS) -o $@ $(OBJS-ntsc-cc) $(ATHENA_LIBS)
+vbistuff/ntsc-cc: vbistuff/ntsc-cc.o
+# libraries to link
+vbistuff/alevtd : LDLIBS := $(VBI_LIBS)
+vbistuff/ntsc-cc : LDLIBS := $(ATHENA_LIBS)
# global targets
all:: $(TARGETS-vbistuff)
@@ -39,4 +41,4 @@ distclean::
rm -f $(TARGETS-vbistuff)
# special dependences
-vbistuff/main.o:: vbistuff/main.c $(HTML-alevtd)
+vbistuff/alevtd.o:: vbistuff/alevtd.c $(HTML-alevtd)
diff --git a/vbistuff/about.html.in b/vbistuff/about.html.in
index e09683d..1663ac6 100644
--- a/vbistuff/about.html.in
+++ b/vbistuff/about.html.in
@@ -4,27 +4,359 @@
<link rel="stylesheet" type="text/css" href="/alevt.css">
</head>
<body>
-<b>about the alevt http daemon</b>
-<p>
-This daemon serves videotext pages as HTML.&nbsp; The vbi decoder is
-taken from <a href="http://lecker.essen.de/~froese/">alevt
-1.6.0</a>.&nbsp; Source code of this deamon comes with <a
-href="http://bytesex.org/xawtv/">xawtv</a>.
-<p>
-&copy; 1999-2002 Gerd Knorr &lt;kraxel@goldbach.in-berlin.de&gt; [http server]
-<br>
-&copy; 1998-2000 Edgar Toernig &lt;froese@gmx.de&gt; [vbi decoding, alevt]
-<br>
-misc patches by several other hackers.
+<h2>About the alevt http daemon</h2>
+<p style="max-width: 40em">
+This daemon serves videotext pages as HTML.&nbsp; It uses
+the <a href="http://zapping.sf.net">zvbi</a> library to decode
+the vbi data. &nbsp; Source code of this daemon comes with
+<a href="http://bytesex.org/xawtv/">xawtv</a>.
+</p>
+&copy; 1999-2002 Gerd Knorr &lt;kraxel@bytesex.org&gt;
<hr noshade size=1>
-<a href="/100/">100</a> &nbsp;
-<a href="/200/">200</a> &nbsp;
-<a href="/300/">300</a> &nbsp;
-<a href="/400/">400</a> &nbsp;
-<a href="/500/">500</a> &nbsp;
-<a href="/600/">600</a> &nbsp;
-<a href="/700/">700</a> &nbsp;
-<a href="/800/">800</a> &nbsp;
-<a href="/about.html">about</a>
+<h2>Jump to page ...</h2>
+<a href="/100/00.html">100</a> &nbsp;
+<a href="/200/00.html">200</a> &nbsp;
+<a href="/300/00.html">300</a> &nbsp;
+<a href="/400/00.html">400</a> &nbsp;
+<a href="/500/00.html">500</a> &nbsp;
+<a href="/600/00.html">600</a> &nbsp;
+<a href="/700/00.html">700</a> &nbsp;
+<a href="/800/00.html">800</a> &nbsp;
+<hr noshade size=1>
+<h2>teletext characters</h2>
+<pre style="font-family: teletext; font-size: 20px">
+
+ETS 300 706 Table 36: Latin National Option Sub-sets
+
+# ů č ť ž ý í ř é á ě ú š
+£ $ @ ← ½ → ↑ # — ¼ ‖ ¾ ÷
+# õ Š Ä Ö Ž Ü Õ š ä ö ž ü
+é ï à ë ê ù î # è â ô û ç
+# $ § Ä Ö Ü ^ _ ° ä ö ü ß
+£ $ é ° ç → ↑ # ù à ò è ì
+# $ Š ė ȩ Ž č ū š ą ų ž į
+# ń ą Ƶ Ś Ł ć ó ę ż ś ł ź
+ç $ ¡ á é í ó ú ¿ ü ñ è à
+# ¤ Ţ Â Ş Ǎ Í ı ţ â ş ǎ î
+# Ë Č Ć Ž Ð Š ë č ć ž ð š
+# ¤ É Ä Ö Å Ü _ é ä ö å ü
+ ğ İ Ş Ö Ç Ü Ğ ı ş ö ç ü
+
+ETS 300 706 Table 35: Latin G0 Primary Set
+
+
+ 0 @ P ` p
+! 1 A Q a q
+" 2 B R b r
+# 3 C S c s
+¤ 4 D T d t
+% 5 E U e u
+& 6 F V f v
+' 7 G W g w
+( 8 H X h x
+) 9 I Y i y
+* : J Z j z
++ ; K [ k {
+, < L \ l ¦
+- = M ] m }
+. > N ^ n ~
+/ ? O _ o ■
+
+ETS 300 706 Table 37: Latin G2 Supplementary Set
+
+
+  ° — Ω ĸ
+¡ ± ˋ ¹ Æ æ
+¢ ² ˊ ® Ð đ
+£ ³ ˆ © ª ð
+$ × ˜ ™ Ħ ħ
+¥ µ ˉ ♪ ı
+# ¶ ˘ ₠ IJ ij
+§ · ˙ ‰ Ŀ ŀ
+¤ ÷ ¨ ɑ Ł ł
+‘ ’ . Ø ø
+“ ” ˚ Œ œ
+« » ˏ º ß
+← ¼ ˍ ⅛ Þ þ
+↑ ½ ˝ ⅜ Ŧ ŧ
+→ ¾ ˛ ⅝ Ŋ ŋ
+↓ ¿ ˇ ⅞ ʼn ■
+
+ETS 300 706 Table 38: Cyrillic G0 Primary Set - Option 1 - Serbian/Croatian
+
+
+ 0 Ч П ч п
+! 1 А Ќ а ќ
+" 2 Б Р б р
+# 3 Ц С ц с
+$ 4 Д Т д т
+% 5 Е У е у
+& 6 Ф В ф в
+' 7 Г Ѓ г ѓ
+( 8 Х Љ х љ
+) 9 И Њ и њ
+* : Ј З ј з
++ ; К Ћ к ћ
+, < Л Ж л ж
+- = М Ђ м ђ
+. > Н Ш н ш
+/ ? О Џ о ■
+
+ETS 300 706 Table 39: Cyrillic G0 Primary Set - Option 2 - Russian/Bulgarian
+
+
+ 0 Ю П ю п
+! 1 А Я а я
+" 2 Б Р б р
+# 3 Ц С ц с
+$ 4 Д Т д т
+% 5 Е У е у
+ы 6 Ф Ж ф ж
+' 7 Г В г в
+( 8 Х Ь х ь
+) 9 И Ъ и ъ
+* : Ѝ З ѝ з
++ ; К Ш к ш
+, < Л Э л э
+- = М Щ м щ
+. > Н Ч н ч
+/ ? О Ы о ■
+
+ETS 300 706 Table 40: Cyrillic G0 Primary Set - Option 3 - Ukrainian
+
+
+ 0 Ю П ю п
+! 1 А Я а я
+" 2 Б Р б р
+# 3 Ц С ц с
+$ 4 Д Т д т
+% 5 Е У е у
+ï 6 Ф Ж ф ж
+' 7 Г В г в
+( 8 Х Ь х ь
+) 9 И І и і
+* : Ѝ З ѝ з
++ ; К Ш к ш
+, < Л Є л є
+- = М Щ м щ
+. > Н Ч н ч
+/ ? О Ї о ■
+
+ETS 300 706 Table 41: Cyrillic G2 Supplementary Set
+
+
+  ° — D d
+¡ ± ˋ ¹ E e
+¢ ² ˊ ® F f
+£ ³ ˆ © G g
+ × ˜ ™ I i
+¥ µ ˉ ♪ J j
+# ¶ ˘ ₠ K k
+§ · ˙ ‰ L l
+ ÷ ¨ ɑ N n
+‘ ’ . Ł Q q
+“ ” ˚ ł R r
+« » ˏ ß S s
+← ¼ ˍ ⅛ U u
+↑ ½ ˝ ⅜ V v
+→ ¾ ˛ ⅝ W w
+↓ ¿ ˇ ⅞ Z z
+
+ETS 300 706 Table 42: Greek G0 Primary Set
+
+
+ 0 ΐ Π ΰ π
+! 1 Α Ρ α ρ
+" 2 Β ʹ β ς
+# 3 Γ Σ γ σ
+$ 4 Δ Τ δ τ
+% 5 Ε Υ ε υ
+& 6 Ζ Φ ζ φ
+' 7 Η Χ η χ
+( 8 Θ Ψ θ ψ
+) 9 Ι Ω ι ω
+* : Κ Ϊ κ ϊ
++ ; Λ Ϋ λ ϋ
+, « Μ ά μ ό
+- = Ν έ ν ύ
+. » Ξ ή ξ ώ
+/ ? Ο ί ο ■
+
+ETS 300 706 Table 43: Greek G2 Supplementary Set
+
+
+  ° ? C c
+a ± ˋ ¹ D d
+b ² ˊ ® F f
+£ ³ ˆ © G g
+e x ˜ ™ J j
+h m ˉ ♪ L l
+i n ˘ ₠ Q q
+§ p ˙ ‰ R r
+: ÷ ¨ ɑ S s
+‘ ’ . Ί U u
+“ ” ˚ Ύ V v
+k t ˏ Ώ W w
+← ¼ ˍ ⅛ Y y
+↑ ½ ˝ ⅜ Z z
+→ ¾ ˛ ⅝ Ά Έ
+↓ x ˇ ⅞ Ή ■
+
+ETS 300 706 Table 44: Arabic G0 Primary Set
+
+
+ 0    
+! 1    
+" 2    
+£ 3    
+$ 4    
+% 5    
+ 6    
+ 7    
+) 8    
+( 9    
+* :    
++ ؛    
+، >    
+- =    
+. <    
+/ ؟  #  ■
+
+ETS 300 706 Table 45: Arabic G2 Supplementary Set
+
+
+  à P é p
+  A Q a q
+  B R b r
+  C S c s
+  D T d t
+  E U e u
+  F V f v
+  G W g w
+  H X h x
+  I Y i y
+  J Z j z
+  K ë k â
+  L ê l ô
+  M ù m û
+  N î n ç
+  O  o
+
+ETS 300 706 Table 46: Hebrew G0 Primary Set
+
+
+ 0 @ P א נ
+! 1 A Q ב ס
+" 2 B R ג ע
+# 3 C S ד ף
+$ 4 D T ה פ
+% 5 E U ו ץ
+& 6 F V ז צ
+' 7 G W ח ק
+( 8 H X ט ר
+) 9 I Y י ש
+* : J Z ך ת
++ ; K ← כ ₪
+, < L ½ ל ‖
+- = M → ם ¾
+. > N ↑ מ ÷
+/ ? O # ן ■
+
+ETS 300 706 Table 47: G1 Block Mosaics Set
+
+   
+   
+   
+   
+   
+   
+   
+   
+   
+   
+   
+   
+   
+   
+   
+   
+
+ETS 300 706 Table 48: G3 Smooth Mosaics and Line Drawing Set
+
+
+     
+     
+     
+     
+     
+     
+     
+     
+     
+     
+     
+     
+     
+     
+     
+     
+
+Teletext composed glyphs
+
+ @ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_
+
+ @ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_
+ˋ -À---È---Ì-----Ò-----Ù----------
+ˊ -Á-Ć-É---Í--Ĺ-ŃÓ--ŔŚ-Ú---ÝŹ-----
+ˆ -Â-Ĉ-Ê-ĜĤÎĴ----Ô---Ŝ-Û-Ŵ-Ŷ------
+˜ -Ã-------Ĩ----ÑÕ-----Ũ----------
+ˉ -Ā---Ē---Ī-----Ō-----Ū----------
+˘ -Ă---Ĕ-Ğ-Ĭ-----Ŏ-----Ŭ----------
+˙ ---Ċ-Ė-Ġ-İ----------------Ż-----
+¨ -Ä---Ë---Ï-----Ö-----Ü---Ÿ------
+. --------------------------------
+˚ -Å-------------------Ů----------
+ˏ ---Ç---------------ŞŢ-----------
+ˍ --------------------------------
+˝ ---------------Ő-----Ű----------
+˛ -Ą---Ę---Į-----------Ų----------
+ˇ ---ČĎĚ------Ľ-Ň---ŘŠ------Ž-----
+
+Teletext composed glyphs
+
+ `abcdefghijklmnopqrstuvwxyz{¦}~■
+
+ `abcdefghijklmnopqrstuvwxyz{¦}~■
+ˋ -à---è---ì-----ò-----ù----------
+ˊ -á-ć-é---í----ńó--ŕś-ú---ýź-----
+ˆ -â-ĉ-ê-ĝĥîĵ----ô---ŝ-û-ŵ-ŷ------
+˜ -ã-------ĩ----ñõ-----ũ----------
+ˉ -ā---ē---ī-----ō-----ū----------
+˘ -ă---ĕ-ğ-ĭ-----ŏ-----ŭ----------
+˙ ---ċ-ė-ġ------------------ż-----
+¨ -ä---ë---ï-----ö-----ü---ÿ------
+. --------------------------------
+˚ -å-------------------ů----------
+ˏ ---ç---------------şţ-----------
+ˍ --------------------------------
+˝ ---------------ő-----ű----------
+˛ -ą---ę---į-----------ų----------
+ˇ ---čďě------ľ-ň---řš------ž-----
+
+EIA 608 Closed Captioning Basic Character Set
+
+ ( 0 8 @ H P X ú h p x
+! ) 1 9 A I Q Y a i q y
+" á 2 : B J R Z b j r z
+# + 3 ; C K S [ c k s ç
+$ , 4 < D L T é d l t ÷
+% - 5 = E M U ] e m u Ñ
+& . 6 > F N V í f n v ñ
+' / 7 ? G O W ó g o w ■
+
+EIA 608 Closed Captioning Special Characters
+
+®°½¿™¢£♪à èâêîôû
+</pre>
</body>
</html>
diff --git a/vbistuff/alevt.css.in b/vbistuff/alevt.css.in
index 08648b4..bd97f9b 100644
--- a/vbistuff/alevt.css.in
+++ b/vbistuff/alevt.css.in
@@ -3,15 +3,10 @@ body { background-color: white; color: black }
pre.vt { border: 1pt solid black; padding: 12pt }
pre.vt { background-color: #c0c0c0; width: auto; float: left }
pre.vt { white-space: pre }
+pre.vt { font-family: "teletext"; font-size: 20px; line-height: 20px }
div.quick { clear: both }
-/* please don't re-color my links (underline is fine) */
-/* it would be that simple in theory,
- but Mozilla/4 does not understand "inherit" *grumble*
-span a { color: inherit; background-color: inherit }
-*/
-
/* videotext colors */
span.c00 { color: #000000; background-color: #000000 }
span.c10 { color: #ff0000; background-color: #000000 }
@@ -85,75 +80,6 @@ span.c57 { color: #ff00ff; background-color: #ffffff }
span.c67 { color: #00ffff; background-color: #ffffff }
span.c77 { color: #ffffff; background-color: #ffffff }
-/* The same again for all the links... */
-span.c00 a { color: #000000; background-color: #000000 }
-span.c10 a { color: #ff0000; background-color: #000000 }
-span.c20 a { color: #00ff00; background-color: #000000 }
-span.c30 a { color: #ffff00; background-color: #000000 }
-span.c40 a { color: #0000ff; background-color: #000000 }
-span.c50 a { color: #ff00ff; background-color: #000000 }
-span.c60 a { color: #00ffff; background-color: #000000 }
-span.c70 a { color: #ffffff; background-color: #000000 }
-
-span.c01 a { color: #000000; background-color: #ff0000 }
-span.c11 a { color: #ff0000; background-color: #ff0000 }
-span.c21 a { color: #00ff00; background-color: #ff0000 }
-span.c31 a { color: #ffff00; background-color: #ff0000 }
-span.c41 a { color: #0000ff; background-color: #ff0000 }
-span.c51 a { color: #ff00ff; background-color: #ff0000 }
-span.c61 a { color: #00ffff; background-color: #ff0000 }
-span.c71 a { color: #ffffff; background-color: #ff0000 }
-
-span.c02 a { color: #000000; background-color: #00ff00 }
-span.c12 a { color: #ff0000; background-color: #00ff00 }
-span.c22 a { color: #00ff00; background-color: #00ff00 }
-span.c32 a { color: #ffff00; background-color: #00ff00 }
-span.c42 a { color: #0000ff; background-color: #00ff00 }
-span.c52 a { color: #ff00ff; background-color: #00ff00 }
-span.c62 a { color: #00ffff; background-color: #00ff00 }
-span.c72 a { color: #ffffff; background-color: #00ff00 }
-
-span.c03 a { color: #000000; background-color: #ffff00 }
-span.c13 a { color: #ff0000; background-color: #ffff00 }
-span.c23 a { color: #00ff00; background-color: #ffff00 }
-span.c33 a { color: #ffff00; background-color: #ffff00 }
-span.c43 a { color: #0000ff; background-color: #ffff00 }
-span.c53 a { color: #ff00ff; background-color: #ffff00 }
-span.c63 a { color: #00ffff; background-color: #ffff00 }
-span.c73 a { color: #ffffff; background-color: #ffff00 }
-
-span.c04 a { color: #000000; background-color: #0000ff }
-span.c14 a { color: #ff0000; background-color: #0000ff }
-span.c24 a { color: #00ff00; background-color: #0000ff }
-span.c34 a { color: #ffff00; background-color: #0000ff }
-span.c44 a { color: #0000ff; background-color: #0000ff }
-span.c54 a { color: #ff00ff; background-color: #0000ff }
-span.c64 a { color: #00ffff; background-color: #0000ff }
-span.c74 a { color: #ffffff; background-color: #0000ff }
-
-span.c05 a { color: #000000; background-color: #ff00ff }
-span.c15 a { color: #ff0000; background-color: #ff00ff }
-span.c25 a { color: #00ff00; background-color: #ff00ff }
-span.c35 a { color: #ffff00; background-color: #ff00ff }
-span.c45 a { color: #0000ff; background-color: #ff00ff }
-span.c55 a { color: #ff00ff; background-color: #ff00ff }
-span.c65 a { color: #00ffff; background-color: #ff00ff }
-span.c75 a { color: #ffffff; background-color: #ff00ff }
-
-span.c06 a { color: #000000; background-color: #00ffff }
-span.c16 a { color: #ff0000; background-color: #00ffff }
-span.c26 a { color: #00ff00; background-color: #00ffff }
-span.c36 a { color: #ffff00; background-color: #00ffff }
-span.c46 a { color: #0000ff; background-color: #00ffff }
-span.c56 a { color: #ff00ff; background-color: #00ffff }
-span.c66 a { color: #00ffff; background-color: #00ffff }
-span.c76 a { color: #ffffff; background-color: #00ffff }
-
-span.c07 a { color: #000000; background-color: #ffffff }
-span.c17 a { color: #ff0000; background-color: #ffffff }
-span.c27 a { color: #00ff00; background-color: #ffffff }
-span.c37 a { color: #ffff00; background-color: #ffffff }
-span.c47 a { color: #0000ff; background-color: #ffffff }
-span.c57 a { color: #ff00ff; background-color: #ffffff }
-span.c67 a { color: #00ffff; background-color: #ffffff }
-span.c77 a { color: #ffffff; background-color: #ffffff }
+/* please don't re-color my links (underline is fine) */
+span a { color: inherit; background-color: inherit; }
+span a { text-decoration: underline }
diff --git a/vbistuff/main.c b/vbistuff/alevtd.c
index 160bb1c..96d8b2f 100644
--- a/vbistuff/main.c
+++ b/vbistuff/alevtd.c
@@ -1,3 +1,5 @@
+#include "config.h"
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -26,20 +28,12 @@
#include "httpd.h"
#include "devices.h"
-
-/* libvbi */
-#include "vt.h"
-#include "misc.h"
-#include "fdset.h"
-#include "vbi.h"
-#include "lang.h"
-#include "dllist.h"
-#include "export.h"
+#include "vbi-data.h"
/* ---------------------------------------------------------------------- */
/* public variables - server configuration */
-char *server_name = "alevt/1.6.0";
+char *server_name = "alevtd/2.0";
int debug = 0;
int dontdetach = 0;
@@ -64,25 +58,7 @@ int cachereset = 0;
time_t now,start;
int slisten;
-struct vbi *vbi;
-struct export *fmt;
-void vbi_handler(struct vbi *vbi, int fd);
-
-static void
-dummy_client(struct dl_head *reqs, struct vt_event *ev)
-{
- struct vt_page *vtp;
-
- if (!debug)
- return;
-
- switch (ev->type) {
- case EV_PAGE:
- vtp = ev->p1;
- fprintf(stderr,"page %x.%02x \r", vtp->pgno, vtp->subno);
- break;
- }
-}
+struct vbi_state *vbi;
/* ---------------------------------------------------------------------- */
@@ -116,8 +92,6 @@ usage(char *name)
"Options:\n"
" -h print this text\n"
" -v dev vbi device [%s]\n"
- " -6 16 vbi lines (depending on the bttv version\n"
- " -9 19 vbi lines one of these two should work)\n"
" -d enable debug output [%s]\n"
" -F do not fork into background [%s]\n"
" -s enable syslog (start/stop/errors) [%s]\n"
@@ -129,9 +103,12 @@ usage(char *name)
" -i ip bind to IP-address >ip< [%s]\n"
" -l log write access log to file >log< [%s]\n"
" -L log same as above + flush every line\n"
+#if 0
" -r poll tv frequency and clear cache\n"
" on station changes [%s]\n"
- " -a use ascii art for block graphics [%s]\n",
+ " -a use ascii art for block graphics [%s]\n"
+#endif
+ "",
h ? h+1 : name,
ng_dev.vbi,
debug ? "on" : "off",
@@ -141,9 +118,12 @@ usage(char *name)
listen_port,
server_host,
listen_ip ? listen_ip : "any",
+ logfile ? logfile : "none");
+#if 0
logfile ? logfile : "none",
- cachereset ? "on" : "off",
- ascii_art ? "on" : "off");
+ cachereset ? "on" : "off",
+ ascii_art ? "on" : "off");
+#endif
if (getuid() == 0) {
pw = getpwuid(0);
gr = getgrgid(getgid());
@@ -320,7 +300,7 @@ mainloop(void)
struct REQUEST *req,*prev,*tmp;
struct timeval tv;
- int max,length,freq,lastfreq = 0;
+ int max,length;
fd_set rd,wr;
for (;!termsig;) {
@@ -334,12 +314,14 @@ mainloop(void)
}
got_sighup = 0;
}
+#if 0
if (got_sigusr1) {
if (debug)
fprintf(stderr,"got SIGUSR1, reset cached vbi pages\n");
vbi->cache->op->reset(vbi->cache);
got_sigusr1 = 0;
}
+#endif
FD_ZERO(&rd);
FD_ZERO(&wr);
@@ -379,7 +361,7 @@ mainloop(void)
/* vbi data? */
if (FD_ISSET(vbi->fd,&rd)) {
-#ifdef __linux__
+#if 0 /* def __linux__ */
if (cachereset) {
ioctl(vbi->fd, VIDIOCGFREQ, &freq);
if (lastfreq != freq) {
@@ -390,7 +372,7 @@ mainloop(void)
}
}
#endif
- vbi_handler(vbi,vbi->fd);
+ vbi_hasdata(vbi);
}
/* new connection ? */
@@ -548,8 +530,7 @@ main(int argc, char *argv[])
#else
struct sockaddr ss;
#endif
- int c, opt, rc, ss_len;
- int bttv = -1;
+ int c, opt, rc, ss_len, v4, v6, simulate;
char host[INET6_ADDRSTRLEN+1];
char serv[16];
@@ -563,19 +544,22 @@ main(int argc, char *argv[])
}
/* parse options */
+ v4 = 1; v6 = 1; simulate = 0;
for (;;) {
- if (-1 == (c = getopt(argc,argv,"69hasdFr"
+ if (-1 == (c = getopt(argc,argv,"hasdFr46S"
"p:N:n:i:t:c:u:g:l:L:v:")))
break;
switch (c) {
case 'h':
usage(argv[0]);
break;
- case '6':
- bttv = 0;
+ case '4':
+ v4 = 1;
+ v6 = 0;
break;
- case '9':
- bttv = 1;
+ case '6':
+ v4 = 0;
+ v6 = 1;
break;
case 'a':
ascii_art++;
@@ -583,6 +567,9 @@ main(int argc, char *argv[])
case 's':
usesyslog++;
break;
+ case 'S':
+ simulate++;
+ break;
case 'd':
debug++;
break;
@@ -633,18 +620,13 @@ main(int argc, char *argv[])
syslog_init();
/* open vbi device */
- fdset_init(fds);
- vbi = vbi_open(ng_dev.vbi, cache_open(), 0, bttv);
- if (vbi == 0) {
+ vbi = vbi_open(ng_dev.vbi,debug,simulate);
+ if (NULL == vbi) {
xperror(LOG_ERR,"cannot open vbi device",NULL);
exit(1);
}
- fmt = export_open("ascii");
- vbi_add_handler(vbi, dummy_client, NULL);
-#if 0
- if (vbi->cache)
- vbi->cache->op->mode(vbi->cache, CACHE_MODE_ERC, erc);
-#endif
+ if (debug)
+ vbi_event_handler_add(vbi->dec,~0,vbi_dump_event,vbi);
/* bind to socket */
slisten = -1;
@@ -655,30 +637,33 @@ main(int argc, char *argv[])
ask.ai_socktype = SOCK_STREAM;
/* try ipv6 first ... */
- ask.ai_family = PF_INET6;
- if (0 != (rc = getaddrinfo(listen_ip, listen_port, &ask, &res))) {
- if (debug)
- fprintf(stderr,"getaddrinfo (ipv6): %s\n",gai_strerror(rc));
- } else {
- if (-1 == (slisten = socket(res->ai_family, res->ai_socktype,
- res->ai_protocol)) && debug)
- xperror(LOG_ERR,"socket (ipv6)",NULL);
+ if (-1 == slisten && v6) {
+ ask.ai_family = PF_INET6;
+ if (0 != (rc = getaddrinfo(listen_ip, listen_port, &ask, &res))) {
+ if (debug)
+ fprintf(stderr,"getaddrinfo (ipv6): %s\n",gai_strerror(rc));
+ } else {
+ if (-1 == (slisten = socket(res->ai_family, res->ai_socktype,
+ res->ai_protocol)) && debug)
+ xperror(LOG_ERR,"socket (ipv6)",NULL);
+ }
}
-
+
/* ... failing that try ipv4 */
- if (-1 == slisten) {
+ if (-1 == slisten && v4) {
ask.ai_family = PF_INET;
if (0 != (rc = getaddrinfo(listen_ip, listen_port, &ask, &res))) {
fprintf(stderr,"getaddrinfo (ipv4): %s\n",gai_strerror(rc));
- exit(1);
- }
- if (-1 == (slisten = socket(res->ai_family, res->ai_socktype,
- res->ai_protocol))) {
- xperror(LOG_ERR,"socket (ipv4)",NULL);
- exit(1);
+ } else {
+ if (-1 == (slisten = socket(res->ai_family, res->ai_socktype,
+ res->ai_protocol)))
+ xperror(LOG_ERR,"socket (ipv4)",NULL);
}
}
+ if (-1 == slisten)
+ exit(1);
+
memcpy(&ss,res->ai_addr,res->ai_addrlen);
ss_len = res->ai_addrlen;
if (res->ai_canonname)
diff --git a/vbistuff/bottom.html.in b/vbistuff/bottom.html.in
index aed8480..c662824 100644
--- a/vbistuff/bottom.html.in
+++ b/vbistuff/bottom.html.in
@@ -1,11 +1,11 @@
-<a href="/100/">100</a> &nbsp;
-<a href="/200/">200</a> &nbsp;
-<a href="/300/">300</a> &nbsp;
-<a href="/400/">400</a> &nbsp;
-<a href="/500/">500</a> &nbsp;
-<a href="/600/">600</a> &nbsp;
-<a href="/700/">700</a> &nbsp;
-<a href="/800/">800</a> &nbsp;
+<a href="/100/00.html">100</a> &nbsp;
+<a href="/200/00.html">200</a> &nbsp;
+<a href="/300/00.html">300</a> &nbsp;
+<a href="/400/00.html">400</a> &nbsp;
+<a href="/500/00.html">500</a> &nbsp;
+<a href="/600/00.html">600</a> &nbsp;
+<a href="/700/00.html">700</a> &nbsp;
+<a href="/800/00.html">800</a> &nbsp;
<a href="/about.html">about</a>
</div>
<form name="goto" action="/goto/">
diff --git a/vbistuff/httpd.h b/vbistuff/httpd.h
index 9d4dbf2..78807f7 100644
--- a/vbistuff/httpd.h
+++ b/vbistuff/httpd.h
@@ -52,18 +52,16 @@ struct REQUEST {
struct REQUEST *next;
};
-/* --- main.c --------------------------------------------------- */
+/* --- alevtd.c ------------------------------------------------- */
extern int debug;
extern int tcp_port;
-extern int ascii_art;
extern char *server_name;
extern int canonicalhost;
extern char server_host[];
extern time_t now,start;
-extern struct vbi *vbi;
-extern struct export *fmt;
+extern struct vbi_state *vbi;
void xperror(int loglevel, char *txt, char *peerhost);
void xerror(int loglevel, char *txt, char *peerhost);
diff --git a/vbistuff/page.c b/vbistuff/page.c
index a608b96..0164848 100644
--- a/vbistuff/page.c
+++ b/vbistuff/page.c
@@ -1,26 +1,21 @@
+#include "config.h"
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <ctype.h>
+#include <wchar.h>
+#include <wctype.h>
+#include <iconv.h>
+#include <errno.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
+#include <libzvbi.h>
#include "httpd.h"
-
-/* libvbi */
-#include "vt.h"
-#include "misc.h"
-#include "fdset.h"
-#include "vbi.h"
-#include "lang.h"
-#include "dllist.h"
-#include "export.h"
-
-void fmt_page(struct export *e, struct fmt_page *pg, struct vt_page *vtp);
-
-#define BUFSIZE 4096
+#include "vbi-data.h"
/* ---------------------------------------------------------------------- */
@@ -32,287 +27,293 @@ static char page_about[] =
#include "about.html.h"
;
-static char page_top[] =
+static wchar_t page_top[] = L""
#include "top.html.h"
;
-static char page_bottom[] =
+static wchar_t page_bottom[] = L""
#include "bottom.html.h"
;
+#if 0
/* 01234567890123456789012345678901 */
static char graphic1[32] = " '-.:::.;;;.}/}./#";
/* 012345 6789 0123 456789012345678901 */
static char graphic2[32] = ".:::.\\{{.\\||.\\#_:::.[.||].###";
+#endif
-/* ---------------------------------------------------------------------- */
+enum mime_type {
+ TYPE_TEXT = 1,
+ TYPE_HTML = 2,
+};
-/* fix bcd issues ... */
-static int calc_page(int pagenr, int offset)
-{
- int result;
-
- result = pagenr + offset;
- if (offset < 0) {
- while ((result & 0x0f) > 0x09)
- result -= 0x01;
- while ((result & 0xf0) > 0x90)
- result -= 0x10;
- if (result < 0x100)
- result = 0x100;
- }
- if (offset > 0) {
- while ((result & 0x0f) > 0x09)
- result += 0x01;
- while ((result & 0xf0) > 0x90)
- result += 0x10;
- if (result > 0x899)
- result = 0x899;
- }
- return result;
-}
-
-static void vbipage(struct REQUEST *req, struct vt_page *page,
- int pagenr, int subnr, int html)
-{
- char *out;
- int size,len,x,y;
- int color,lcolor,link;
- struct fmt_page pg[1];
+#define CHARSET "utf-8"
+#define TXTBUF (25*41*8)
+#define HTMLBUF (25*1024)
- struct fmt_char l[W+2];
-#define L (l+1)
-
- fmt_page(fmt,pg,page);
- size = 2*BUFSIZE;
- out = malloc(size);
- len = 0;
+/* ---------------------------------------------------------------------- */
- if (html)
- len += sprintf(out+len,page_top,page->pgno,page->subno);
- for (y = 0; y < H; y++) {
- if (~pg->hid & (1 << y)) { /* !hidden */
- for (x = 0; x < W; ++x) {
- struct fmt_char c = pg->data[y][x];
- switch (c.ch) {
- case 0x00:
- case 0xa0:
- c.ch = ' ';
- break;
- case 0x7f:
- c.ch = '*';
- break;
- case BAD_CHAR:
- c.ch = '?';
- break;
- default:
- if (c.attr & EA_GRAPHIC) {
- if (ascii_art) {
- if (!(c.ch & 128))
- c.ch = graphic1[c.ch];
- else
- c.ch = graphic2[c.ch-128];
- } else {
- c.ch = '#';
- }
- }
- break;
+static int vbi_export_html(wchar_t *dest, int size,
+ struct vbi_state *vbi, struct vbi_page *pg,
+ int pagenr, int subnr)
+{
+ int x,y,i,link;
+ int fg,bg,len=0;
+ vbi_char *ch;
+ wchar_t wch,*obuf;
+ struct vbi_page dummy;
+
+ obuf = dest;
+ link = -1;
+ len = swprintf(obuf,size,page_top,pagenr,subnr);
+ obuf += len; size -= len;
+ for (y = 0; y < 25; y++) {
+ ch = pg->text + 41*y;
+ fg = -1;
+ bg = -1;
+ for (x = 0; x <= 40; x++) {
+ /* close link tags */
+ if (link >= 0) {
+ if (0 == link) {
+ len = swprintf(obuf,size,L"</a>");
+ obuf += len; size -= len;
}
- L[x] = c;
+ link--;
}
-
- /* delay fg and attr changes as far as possible */
- for (x = 0; x < W; ++x)
- if (L[x].ch == ' ') {
- L[x].fg = L[x-1].fg;
- L[x].attr = L[x-1].attr;
- }
-
- /* move fg and attr changes to prev bg change point */
- for (x = W-1; x >= 0; x--)
- if (L[x].ch == ' ' && L[x].bg == L[x+1].bg) {
- L[x].fg = L[x+1].fg;
- L[x].attr = L[x+1].attr;
- }
-
- /* now emit the whole line */
- lcolor = -1; link = -1;
- for (x = 0; x < W; ++x) {
- /* close link tags */
- if (html && link >= 0) {
- if (0 == link)
- len += sprintf(out+len,"</a>");
- link--;
- }
-
- /* color handling */
- color = (L[x].fg&0x0f) * 10 + (L[x].bg&0x0f);
- if (html && color != lcolor) {
- if (-1 != lcolor)
- len += sprintf(out+len,"</span>");
- len += sprintf(out+len,"<span class=\"c%02d\">",color);
- lcolor = color;
- }
-
- /* check for references to other pages */
- if (html && y > 0 && -1 == link && x < W-2 &&
- isdigit(L[x].ch) &&
- isdigit(L[x+1].ch) &&
- isdigit(L[x+2].ch) &&
- !isdigit(L[x+3].ch) &&
- !isdigit(L[x-1].ch)) {
- len += sprintf(out+len,"<a href=\"/%c%c%c/\">",
- L[x].ch, L[x+1].ch, L[x+2].ch);
- link = 2;
- }
- if (html && y > 0 && -1 == link && x < W-1 &&
- '>' == L[x].ch &&
- '>' == L[x+1].ch) {
- len += sprintf(out+len,"<a href=\"/%03x/\">",
- page->pgno+1);
- link = 1;
- }
- if (html && y > 0 && -1 == link && x < W-1 &&
- '<' == L[x].ch &&
- '<' == L[x+1].ch) {
- len += sprintf(out+len,"<a href=\"/%03x/\">",
- page->pgno-1);
- link = 1;
+
+ /* this char */
+ wch = ch[x].unicode;
+ if (ch[x].size > VBI_DOUBLE_SIZE)
+ wch = ' ';
+ if (ch[x].conceal)
+ wch = ' ';
+
+ /* handle colors */
+ if (fg != ch[x].foreground || bg != ch[x].background) {
+ if (-1 != fg) {
+ len = swprintf(obuf,size,L"</span>");
+ obuf += len; size -= len;
}
+ fg = ch[x].foreground;
+ bg = ch[x].background;
+ len = swprintf(obuf,size,L"<span class=\"c%02d\">",
+ fg * 10 + bg);
+ obuf += len;
+ size -= len;
+ }
- /* check for references to WWW pages */
- if (html && y > 0 && -1 == link && x < W-9 &&
- (((tolower(L[x+0].ch) == 'w') &&
- (tolower(L[x+1].ch) == 'w') &&
- (tolower(L[x+2].ch) == 'w') &&
- (L[x+3].ch == '.')) ||
- ((tolower(L[x+0].ch) == 'h') &&
- (tolower(L[x+1].ch) == 't') &&
- (tolower(L[x+2].ch) == 't') &&
- (tolower(L[x+3].ch) == 'p')))) {
- int offs = 0;
+ /* check for references to other pages */
+ if (y > 0 && -1 == link && x > 0 && x < 39 &&
+ iswdigit(ch[x+0].unicode) &&
+ iswdigit(ch[x+1].unicode) &&
+ iswdigit(ch[x+2].unicode) &&
+ !iswdigit(ch[x-1].unicode) &&
+ !iswdigit(ch[x+3].unicode)) {
+ len = swprintf(obuf,size,L"<a href=\"/%lc%lc%lc/00.html\">",
+ (wchar_t)ch[x+0].unicode,
+ (wchar_t)ch[x+1].unicode,
+ (wchar_t)ch[x+2].unicode);
+ obuf += len; size -= len;
+ link = 2;
+ }
+ if (y > 0 && -1 == link && x > 0 && x < 40 &&
+ '>' == ch[x+0].unicode &&
+ '>' == ch[x+1].unicode) {
+ len = swprintf(obuf,size,L"<a href=\"/%03x/00.html\">",
+ vbi_calc_page(pagenr, +0x01));
+ link = 1;
+ }
+ if (y > 0 && -1 == link && x > 0 && x < 40 &&
+ '<' == ch[x+0].unicode &&
+ '<' == ch[x+1].unicode) {
+ len = swprintf(obuf,size,L"<a href=\"/%03x/00.html\">",
+ vbi_calc_page(pagenr, -0x01));
+ link = 1;
+ }
- len += sprintf(out+len,"<a href=\"");
- if(tolower(L[x].ch == 'w'))
- len += sprintf(out+len,"http://");
- while ((L[x+offs].ch!=' ') && (x+offs < W)) {
- len += sprintf(out+len,"%c",tolower(L[x+offs].ch));
- offs++;
- }
- while ( (*(out+len-1)<'a') || (*(out+len-1)>'z') ) {
- len--;
- offs--;
- }
- len += sprintf(out+len,"\">");
- link = offs - 1;
+ /* check for references to other subpages */
+ if (subnr > 0 && y > 0 && -1 == link && x > 0 && x < 39 &&
+ iswdigit(ch[x+0].unicode) &&
+ '/' == ch[x+1].unicode &&
+ iswdigit(ch[x+2].unicode) &&
+ !iswdigit(ch[x-1].unicode) &&
+ !iswdigit(ch[x+3].unicode)) {
+ if (ch[x+0].unicode == ch[x+2].unicode) {
+ len = swprintf(obuf,size,L"<a href=\"01.html\">");
+ } else {
+ len = swprintf(obuf,size,L"<a href=\"%02x.html\">",
+ ch[x+0].unicode-'0' +1);
}
+ len = swprintf(obuf,size,L"<a href=\"/%lc%lc%lc/00.html\">",
+ (wchar_t)ch[x+0].unicode,
+ (wchar_t)ch[x+1].unicode,
+ (wchar_t)ch[x+2].unicode);
+ obuf += len; size -= len;
+ link = 2;
+ }
- /* check for references to other subpages */
- if (html && y > 0 && -1 == link && x < W-2 &&
- page->subno > 0 &&
- isdigit(L[x].ch) &&
- '/' == L[x+1].ch &&
- isdigit(L[x+2].ch) &&
- !isdigit(L[x+3].ch) &&
- !isdigit(L[x-1].ch)) {
- if (L[x].ch == L[x+2].ch) {
- len += sprintf(out+len,"<a href=\"01.html\">");
- } else {
- len += sprintf(out+len,"<a href=\"%02x.html\">",
- L[x].ch+1-'0');
- }
- link = 2;
+#if 0
+ /* check for references to WWW pages */
+ if (html && y > 0 && -1 == link && x < W-9 &&
+ (((tolower(L[x+0].ch) == 'w') &&
+ (tolower(L[x+1].ch) == 'w') &&
+ (tolower(L[x+2].ch) == 'w') &&
+ (L[x+3].ch == '.')) ||
+ ((tolower(L[x+0].ch) == 'h') &&
+ (tolower(L[x+1].ch) == 't') &&
+ (tolower(L[x+2].ch) == 't') &&
+ (tolower(L[x+3].ch) == 'p')))) {
+ int offs = 0;
+
+ len += sprintf(out+len,"<a href=\"");
+ if(tolower(L[x].ch == 'w'))
+ len += sprintf(out+len,"http://");
+ while ((L[x+offs].ch!=' ') && (x+offs < W)) {
+ len += sprintf(out+len,"%c",tolower(L[x+offs].ch));
+ offs++;
}
- /* check for FastText links */
- if (html && page->flof && -1 == link && x<W-2 &&
- 24 == y &&
- L[x].fg>0 &&
- L[x].fg<8 &&
- x>0 &&
- !isspace(L[x].ch)) {
- link=(L[x].fg==6?3:L[x].fg-1);
- if(page->link[link].subno == ANY_SUB)
- {
- len+=sprintf(out+len,"<a href=\"/%03x/\">",
- page->link[link].pgno);
- }
- else
- {
- len+=sprintf(out+len,"<a href=\"/%03x/%02x.html\">",
- page->link[link].pgno,
- page->link[link].subno);
- }
- link=0;
- while((L[x+link].fg == L[x].fg) && (x+link<W))
- {
- link++;
- }
- link--;
- if(link<1)
- {
- link=1;
- }
+ while ( (*(out+len-1)<'a') || (*(out+len-1)>'z') ) {
+ len--;
+ offs--;
}
- out[len++] = L[x].ch;
+ len += sprintf(out+len,"\">");
+ link = offs - 1;
}
- /* close any tags + put newline */
- if (html && link >= 0)
- len += sprintf(out+len,"</a>");
- if (html && -1 != lcolor)
- len += sprintf(out+len,"</span>");
- out[len++] = '\n';
-
- /* check bufsize */
- if (len + BUFSIZE > size) {
- size += BUFSIZE;
- out = realloc(out,size);
+#endif
+ /* FIXME: fasttext links */
+
+ if (size > 0) {
+ *obuf = wch;
+ obuf++;
+ size--;
}
}
+ if (-1 != fg) {
+ len = swprintf(obuf,size,L"</span>");
+ obuf += len;
+ size -= len;
+ }
+ if (size > 0) {
+ *obuf = '\n';
+ obuf++;
+ size--;
+ }
}
- if (html) {
-#define MAXSUBPAGES 32
- int subpage;
-
- /* close preformatted text header */
- len+=sprintf(out+len,"</pre>\n<div class=quick>\n") ;
- if (vbi->cache->op->get(vbi->cache,pagenr,1)) {
- /* link all subpages */
- len += sprintf(out+len,"Subpages:");
- for (subpage = 1; subpage <= MAXSUBPAGES; subpage++) {
- if (NULL == vbi->cache->op->get(vbi->cache,pagenr,subpage))
- continue;
- if (subpage != subnr) {
- len += sprintf(out+len," <a href=\"/%03x/%02x.html\">%02x</a>",
- pagenr, subpage, subpage);
- } else {
- len += sprintf(out+len," %02x", subpage);
- }
+ len = swprintf(obuf,size,L"</pre>\n<div class=quick>\n");
+ obuf += len; size -= len;
+
+ if (0 != subnr) {
+ /* link all subpages */
+ for (i = 1; i <= VBI_MAX_SUBPAGES; i++) {
+ if (!vbi_fetch_vt_page(vbi->dec,&dummy,pagenr,i,
+ VBI_WST_LEVEL_1p5,0,0))
+ continue;
+ if (i != subnr) {
+ len = swprintf(obuf,size,L" <a href=\"/%03x/%02x.html\">%02x</a>",
+ pagenr, i, i);
+ } else {
+ len = swprintf(obuf,size,L" %02x", i);
}
- len += sprintf(out+len,"<br>\n") ;
+ obuf += len; size -= len;
+ len = swprintf(obuf,size,L"<br>\n");
+ obuf += len; size -= len;
}
- len += sprintf(out+len,"<a href=\"/%03x/\"><<</a> &nbsp;",
- calc_page(pagenr, -0x10));
- len += sprintf(out+len,"<a href=\"/%03x/\"><</a> &nbsp;",
- calc_page(pagenr, -0x01));
- if (!subnr)
- len += sprintf(out+len,"<a href=\"/%03x/\">o</a> &nbsp;", pagenr);
- else
- len += sprintf(out+len,"<a href=\"/%03x/%02x.html\">o</a> &nbsp;", pagenr, subnr);
- len += sprintf(out+len,"<a href=\"/%03x/\">></a> &nbsp;",
- calc_page(pagenr, +0x01));
- len += sprintf(out+len,"<a href=\"/%03x/\">>></a>",
- calc_page(pagenr, +0x10));
- len += sprintf(out+len,"<br>\n") ;
- len += sprintf(out+len,"%s",page_bottom);
- req->mime = "text/html; charset=\"iso-8859-1\"";
- } else {
- req->mime = "text/plain; charset=\"iso-8859-1\"";
+ }
+ /* page navigation links */
+ len = swprintf(obuf,size,L"<a href=\"/%03x/00.html\">&lt;&lt;</a> &nbsp;",
+ vbi_calc_page(pagenr, -0x10));
+ obuf += len; size -= len;
+ len = swprintf(obuf,size,L"<a href=\"/%03x/00.html\">&lt;</a> &nbsp;",
+ vbi_calc_page(pagenr, -0x01));
+ obuf += len; size -= len;
+ len = swprintf(obuf,size,L"<a href=\"/%03x/%02x.html\">o</a> &nbsp;",
+ pagenr, subnr);
+ obuf += len; size -= len;
+ len = swprintf(obuf,size,L"<a href=\"/%03x/00.html\">&gt;</a> &nbsp;",
+ vbi_calc_page(pagenr, +0x01));
+ obuf += len; size -= len;
+ len = swprintf(obuf,size,L"<a href=\"/%03x/00.html\">&gt;&gt;</a>",
+ vbi_calc_page(pagenr, +0x10));
+ obuf += len; size -= len;
+ len = swprintf(obuf,size,L"<br>\n") ;
+ obuf += len; size -= len;
+ len = swprintf(obuf,size,page_bottom);
+ obuf += len; size -= len;
+ *obuf = 0;
+ return obuf - dest;
+}
+
+static int wchar_to_charset(wchar_t *istr, int ilen, char *charset,
+ char **ostr, int *olen)
+{
+ size_t il,ol;
+ wchar_t *err;
+ char *ib,*ob;
+ iconv_t ic;
+ int rc;
+
+ ic = iconv_open(CHARSET,"WCHAR_T");
+ if (NULL == ic) {
+ if (debug)
+ fprintf(stderr,"iconf_open failed on %s => %s\n",
+ CHARSET,"WCHAR_T");
+ return -1;
+ }
+ ib = (char*)istr;
+ il = ilen * sizeof(wchar_t);
+ ob = malloc(ilen * 8);
+ ol = ilen * 8;
+ *ostr = ob;
+
+ for (;;) {
+ rc = iconv(ic,&ib,&il,&ob,&ol);
+ if (rc >= 0) {
+ /* done */
+ break;
+ }
+ /* handle errors */
+ err = (wchar_t*)ib;
+ if (EILSEQ == errno && *err != '?') {
+ *err = '?';
+ continue;
+ }
+ /* unknown error */
+ if (debug)
+ fprintf(stderr,"unknown iconv error\n");
+ return -1;
+ }
+ iconv_close(ic);
+ *olen = ob - *ostr;
+ return 0;
+}
+
+static int vbi_render_page(struct REQUEST *req,
+ struct vbi_state *vbi, struct vbi_page *pg,
+ int pagenr, int subnr, enum mime_type type)
+{
+ wchar_t *wpage;
+ int wlen;
+
+ switch (type) {
+ case TYPE_TEXT:
+ req->body = malloc(TXTBUF);
+ req->lbody = vbi_export_txt(req->body, CHARSET, TXTBUF, pg,
+ &vbi_fullrect, 0);
+ req->mime = "text/plain; charset=" CHARSET;
+ break;
+ case TYPE_HTML:
+ wpage = malloc(HTMLBUF*sizeof(wchar_t));
+ wlen = vbi_export_html(wpage,HTMLBUF,vbi,pg,pagenr,subnr);
+ if (-1 == wchar_to_charset(wpage,wlen,CHARSET,&req->body,&req->lbody))
+ return -1;
+ free(wpage);
+ req->mime = "text/html; charset=" CHARSET;
+ break;
}
- req->body = out;
- req->lbody = len;
req->free_the_mallocs = 1;
mkheader(req,200,-1);
+ return 0;
}
/* ---------------------------------------------------------------------- */
@@ -320,12 +321,13 @@ static void vbipage(struct REQUEST *req, struct vt_page *page,
void buildpage(struct REQUEST *req)
{
int pagenr, subpage;
- char type;
- struct vt_page *page;
+ char type[10];
+ struct vbi_page page;
+ enum mime_type t;
/* style sheet */
if (0 == strcmp(req->path,"/alevt.css")) {
- req->mime = "text/css";
+ req->mime = "text/css; charset=us-ascii";
req->body = stylesheet;
req->lbody = sizeof(stylesheet);
mkheader(req,200,start);
@@ -334,7 +336,7 @@ void buildpage(struct REQUEST *req)
/* about */
if (0 == strcmp(req->path,"/about.html")) {
- req->mime = "text/html; charset=\"iso-8859-1\"";
+ req->mime = "text/html; charset=utf-8";
req->body = page_about;
req->lbody = sizeof(page_about);
mkheader(req,200,start);
@@ -343,46 +345,45 @@ void buildpage(struct REQUEST *req)
/* entry page */
if (0 == strcmp(req->path,"/")) {
- strcpy(req->path,"/100/");
+ strcpy(req->path,"/100/00.html");
mkredirect(req);
return;
}
- /* page with subpages */
- if (3 == sscanf(req->path,"/%3x/%2x.%c",&pagenr,&subpage,&type)) {
- if (debug)
- fprintf(stderr,"trying %03x/%02x\n",pagenr,subpage);
- page = vbi->cache->op->get(vbi->cache,pagenr,subpage);
- if (NULL != page) {
- vbipage(req,page,pagenr,subpage,type=='h');
+ /* pages */
+ if (3 == sscanf(req->path,"/%3x/%2x.%8s",&pagenr,&subpage,type)) {
+ t = 0;
+ if (0 == strcmp(type,"html"))
+ t = TYPE_HTML;
+ if (0 == strcmp(type,"txt"))
+ t = TYPE_TEXT;
+ if (0 == t) {
+ mkerror(req,404,1);
return;
}
- mkerror(req,404,1);
- return;
- }
-
- /* ... without subpage */
- if (1 == sscanf(req->path,"/%3x/",&pagenr)) {
if (debug)
- fprintf(stderr,"trying %03x\n",pagenr);
- page = vbi->cache->op->get(vbi->cache,pagenr,0);
- if (NULL != page) {
- vbipage(req,page,pagenr,0,1);
- return;
- }
- page = vbi->cache->op->get(vbi->cache,pagenr,ANY_SUB);
- if (NULL != page) {
- sprintf(req->path,"/%03x/%02x.html",pagenr,page->subno);
+ fprintf(stderr,"%03d: lookup %03x/%02x [%s]\n",
+ req->fd,pagenr,subpage,type);
+ memset(&page,0,sizeof(page));
+ if (!vbi_fetch_vt_page(vbi->dec,&page,pagenr,subpage,
+ VBI_WST_LEVEL_1p5,25,1)) {
+ if (!vbi_fetch_vt_page(vbi->dec,&page,pagenr,VBI_ANY_SUBNO,
+ VBI_WST_LEVEL_1p5,25,1)) {
+ mkerror(req,404,1);
+ return;
+ }
+ sprintf(req->path,"/%03x/%02x.html",pagenr,page.subno);
mkredirect(req);
return;
}
- mkerror(req,404,1);
+ if (-1 == vbi_render_page(req,vbi,&page,pagenr,subpage,t))
+ mkerror(req,500,1);
return;
}
/* goto form */
if (1 == sscanf(req->path,"/goto/?p=%d",&pagenr)) {
- sprintf(req->path,"/%d/",pagenr);
+ sprintf(req->path,"/%d/00.html",pagenr);
mkredirect(req);
return;
}
diff --git a/vbistuff/response.c b/vbistuff/response.c
index b544f47..cd961da 100644
--- a/vbistuff/response.c
+++ b/vbistuff/response.c
@@ -35,8 +35,7 @@ static struct HTTP_STATUS {
#define RESPONSE_START \
"HTTP/1.1 %s\r\n" \
"Server: %s\r\n" \
- "Connection: %s\r\n" \
- "Accept-Ranges: bytes\r\n"
+ "Connection: %s\r\n"
#define RFCTIME \
"%a, %d %b %Y %H:%M:%S GMT"
#define BOUNDARY \

Privacy Policy