BEGIN {
home = "http://www.complang.tuwien.ac.at/";
site = home;
date = strftime("%a, %d %b %Y %T %z");
datefound = 0;
timefound = 0;
description = ""
title= "";
pretitle ="";
rsstitle = "";
rssdescr = "";
}
($1 == "%encoding"){
if(NF != 2 ){
print FILENAME " (line " FNR "): WARNING: %encoding entry with missing parameters" >"/dev/stderr";
next;
}
else{
encoding = $2;
}
}
($1 == "%rsstitle"){
if(NF < 2 ){
print FILENAME " (line " FNR "): WARNING: %rsstitle entry with missing parameters" >"/dev/stderr";
next;
}
else{
rsstitle = substr($0, 11);
}
}
($1 == "%rsslink"){
if(NF < 2 ){
print FILENAME " (line " FNR "): WARNING: %rsslink entry with missing parameters" >"/dev/stderr";
next;
}
else{
rsslink = substr($0, 10);
}
}
($1 == "%rsspage"){
if(NF < 2 ){
print FILENAME " (line " FNR "): WARNING: %rsspage entry with missing parameters" >"/dev/stderr";
next;
}
else{
rsspage = substr($0, 10);
}
}
($1 == "%rssdescr"){
if(NF < 2 ){
print FILENAME " (line " FNR "): WARNING: %rssdesc entry with missing parameters" >"/dev/stderr";
next;
}
else{
rssdescr = substr($0, 11);
}
}
($1 == "%news") && (output == 0) {
if (NF < 2) {
print FILENAME " (line " FNR "): WARNING: %news missing an argument" >"/dev/stderr";
}
output = 1;
print "- ";
print "" $2 "";
next;
}
($1 == "%title") && (output == 1){
if (NF < 2) {
print FILENAME " (line " FNR "): WARNING: %title missing an argument" >"/dev/stderr";
}
title = substr($0, 8);
next;
}
($1 == "%pretitle") && (output == 1){
if (NF < 2) {
print FILENAME " (line " FNR "): WARNING: %pretitle missing an argument" >"/dev/stderr";
}
pretitle = substr($0, 11);
next;
}
($1 == "%url") && (output == 1){
if (NF < 2) {
print FILENAME " (line " FNR "): WARNING: %url missing an argument" >"/dev/stderr";
}
url = substr($0, 6);
next;
}
($1 == "%date") && (output == 1){
if (NF < 2) {
print FILENAME " (line " FNR "): WARNING: %date missing an argument" >"/dev/stderr";
}
pubDate = substr($0, 7)
datefound = 1;
next;
}
($1 == "%time") && (output == 1){
if (NF < 2) {
print FILENAME " (line " FNR "): WARNING: %time missing an argument" >"/dev/stderr";
}
pubTime = substr($0, 7)
timefound = 1;
next;
}
($1 == "%place") && (output == 1){
if (NF < 2) {
print FILENAME " (line " FNR "): WARNING: %place missing an argument" >"/dev/stderr";
}
place = substr($0, 8);
placefound = 1;
next;
}
($1 == "%pubdate") && (output == 1){
if (NF < 2) {
print FILENAME " (line " FNR "): WARNING: %pubdate missing an argument" >"/dev/stderr";
}
pubdate_rss = substr($0, 10);
next;
}
($1 == "%endnews") && (output == 1){
# print description
# escape html first
output = 0;
gsub(/&/, "\\&", description);
gsub(/, "\\<", description);
print "";
print description;
description = "";
if (timefound == 1 && datefound == 1 && placefound == 1) {
gsub(/&/, "\\&", pubDate);
gsub(/, "\\<", pubDate);
gsub(/&/, "\\&", pubTime);
gsub(/, "\\<", pubTime);
gsub(/&/, "\\&", place);
gsub(/, "\\<", place);
print "<DL>"
print "<DT>Datum:</DT><DD>" pubDate "</DD>"
print "<DT>Uhrzeit:</DT><DD>" pubTime "</DD>"
print "<DT>Ort:</DT><DD>"place"</DD>"
print "</DL>"
timefound = 0;
datefound = 0;
placefound = 0;
pubDate = "";
pubTime = "";
place = "";
}
print "";
temp_title = "";
if (pretitle != "" ){
print "" pretitle ": " title "";
}
else{
print "" title "";
}
if (pubdate_rss != "") {
print "" pubdate_rss "";
}
if (url != ""){
print "" url "";
url = ""
}
else {
print "" home "" rsspage "";
}
print "
"
next;
}
(output == 1){
description = description "\n" $0
next;
}
($1 == "%content") && (output == 0) {
if (encoding == "") {
# encoding must be set before!
exit EXIT_FAILURE;
}
print "";
print "";
print "";
print ""
print "" rsstitle "";
print "" rssdescr "";
print "" site "";
print "" date "";
print "" date "";
print "1800";
contentfound = 1;
next;
}
END {
# only if the xml header was printed, also print the footer
if (contentfound == 1){
print "";
print "";
}
}