next up previous contents
Next: C Listing zum Wrapper Up: No Title Previous: A Listing zur Inidatei

B Listing zum Script mnmlit2html.pl

#!/usr/local/dist/bin/perl
require 5.002;

use File::Basename;

## Speichere die Kommandozeilen-Parameter ab.
$argv = join(' ',@ARGV);

## Hole $HOME aus der Environment Variable
push(@INC,$ENV{'HOME'});
$HOME = $ENV{'HOME'};

## Versionsnummer, Patchlevel und Erscheinungsdatum
$TPATCHLEVEL = "1a";
$TVERSION = "97";
$RELDATE = "(Nov 26, 1997)";

$MNMlit2htmlV_SHORT = $TVERSION . '.' . "$TPATCHLEVEL";
$MNMlit2htmlVERSION = $MNMlit2htmlV_SHORT . ' ' . $RELDATE;

## Hinweise zum Author
$AUTHORADDRESS =
   "http://www.informatik.tu-muenchen.de/~allgeyer/index.html";


## ----------------------------------------------------------------
##  BEGIN             Configurabel parameter                 BEGIN
## ----------------------------------------------------------------

## Set debug-level
## Debugging off
$DEBUG = 0;

## Wo befindet sich das Initialisierungsprogramm?
## Default ist das Verzeichnis in dem sich das
## Hauptprogramm befindet. Wird das, Hauptprogramm
## "uber Links referenziert, so _muss_ diese Variable
## explizit gesetzt werden.
$INI_DIR = dirname( &getcwd . "/" . "$0" );

# ---------------------------------------------------
#            TEIL 1
# ---------------------------------------------------

## Latex2html findet sich hier:
$LATEX2HTML_DIR = "/usr/local/dist/bin";

## Ort, an dem  die fertigen HTML-Dokumente
## abgelegt werden.
$HTML_DATA_DIR = "/proj/Literatur/public-htdocs/MNMPub";

## Literaturverzeichnis, hier werden die Dokumente abgelegt,
## die zur Bearbeitung durch mnnlit2html anstehen.
$INPUT_DIR = "/proj/Literatur/MNM/Upload";

## Bibliographie-Verzeichnis,
## enthaelt Informationen ueber die
## einzelnen Dokumente und deren Verfassern
$BIB_DIR = "/proj/Literatur/MNM/Bib";

## Temporaeres Verzeichnis, dieses sollte
## ausreichend Platz zur Verfuegung stellen
$TMP = "/tmp";

## Bezeichnet den HTML-Befehl, der Haupteil und
## Fuss voneinander trennt. Wird in latex2html.config
## gesetzt und sollte entsprechend uebernommen werden,
## damit trotz fehlendem Abstract eine Zusammenfassung
## korrekt gefunden wird.
## Default-Eintrag ist fuer latex2html-{96.1,97.1} gueltig
$CHILDLINE = "<BR>.*<HR>";


# -----------------------------------------------------
#          Teil 2
# -----------------------------------------------------

## ZUSAMMENFASSUNG
@ZUSAMMENFASSUNG = ("Einf\"uhrung", "Zusammenfassung");

## 
## Die erste Zeile gibt an, nach welchen Feldern
## in den einzelnen Bibliographie-Eintragen gesucht wird.
## Die zweite Zeile muss Eintraege aus der ersten enthalten
## und gibt an, welche Eintraege publiziert werden 
##
## ARTICLE
@article =
   ("author","title","journal","year","type","month","note","key");
@article_to_publish =
   ("author","title","journal","month","year");

## BOOK
@book =
   ("author","editor","title","publisher","year","volume",
    "series","address","edition","month","note","key");
@book_to_publish =
   ("author","editor","title","publisher","year","volume",
    "series","address","edition","month","note","key");

## BOOKLET
@booklet =
   ("title","author","howpublished","address","month",
    "year","note","key");
@booklet_to_publish =
   ("title","author","howpublished","address","month",
    "year","note","key");

## CONFERENCE
@conference =
   ("author","title","book","title","year","editor","pages",
    "organization","publisher","address","month","note","key");
@conference_to_publish =
   ("author","title","book","title","year","editor","pages",
    "organization","publisher","address","month","note","key");

## INBOOK
@inbook =
   ("author","editor","title","chapter","pages","publisher",
    "year","volume","series","address","edition","month","note","key");
@inbook_to_publish =
   ("author","editor","title","chapter","pages","publisher",
    "year","volume","series","address","edition","month","note","key");

## INCOLLECTION
@incollection =
   ("author","title","booktitle","year","publisher","editor",
    "chapter","pages","address","month","note","key");
@incollection_to_publish =
   ("author","title","booktitle","year","publisher","editor",
    "chapter","pages","month");

## INPROCEEDINGS
@inproceedings =
   ("author","title","booktitle","publisher","school",
    "year","type","month","key");
@inproceedings_to_publish =
   ("author","title","booktitle","publisher","school",
    "month","year");

## MANUAL
@manual =
   ("title","author","organization","address","edition",
    "month","year","note","key");
@manual_to_publish =
   ("title","author","organization","address","edition",
    "month","year","note","key");

## MASTERSTHESIS
@mastersthesis =
   ("author","title","school","year","type","month","key");
@mastersthesis_to_publish =
   ("author","title","school","month","year");

## MISC
@misc =
   ("author","title","howpublished","month",
    "year","note","key");
@misc_to_publish =
   ("author","title","howpublished","month",
    "year","note","key");

## PHDTHESIS
@phdthesis =
   ("author","title","school","year","type","address",
    "month","note","key");
@phdthesis_to_publish =
   ("note","author","title","school","year","address");

## PROCEEDINGS
@proceedings =
   ("title","year","editor","publisher","organization",
    "address","month","note","key");
@proceedings_to_publish =
   ("title","year","editor","publisher","organization",
    "address","month","note","key");

## TECHREPORT
@techreport =
   ("author","title","institution","year","type",
    "month","key");
@techreport_to_publish =
   ("author","title","institution","month","year");

## UNPUBLISHED
@unpublished =
   ("author","title","note","month","year","key");
@unpublished_to_publish =
   ("author","title","note","month","year","key");


# --------------------------------------------------------
#             Teil 3
# --------------------------------------------------------

## MONTHS
## This is an associative array containing the names of
## each month of the year. At the left you can see the
## abbreviation (3 chars long) and at the right the
## long Version.

## The german version
## (comment it out, if you prefer the english version below)
%months = (
        "jan"     => "Januar",
        "feb"     => "Februar",
        "mar"     => "M\ä\;rz",
        "apr"     => "April",
        "may"     => "Mai",
        "jun"     => "Juni",
        "jul"     => "Juli",
        "aug"     => "August",
        "sep"     => "September",
        "oct"     => "Oktober",
        "nov"     => "November",
        "dec"     => "Dezember",
);

## The english version: (comment it out if necessary)
#%months = (
#       "jan"     =>      "January",
#       "feb"     =>      "February",
#       "mar"     =>      "March",
#       "apr"     =>      "April",
#       "may"     =>      "May",
#       "jun"     =>      "June",
#       "jul"     =>      "July",
#       "aug"     =>      "August",
#       "sep"     =>      "September",
#       "oct"     =>      "October",
#       "nov"     =>      "November",
#       "dec"     =>      "December",
#);


## TYPES
## This is an associative array containing the type
## of a document on the left and its header on the right.
%types = (
   "diplomarbeiten"  => "Diplomarbeiten / Master's Theses",
   "dissertationen"  => "Dissertationen / Ph.D. Theses",
   "fopras"          => "Systementwicklungsprojekte / Advanced Practicals",
   "projekte"        => "Projektberichte / Project Reports",
   "publikationen"   => "Publikationen / Publications"
);

## ----------------------------------------------------------------
##  END               Configurabel parameter                   END
## ----------------------------------------------------------------

## Statusausgabe
print <<EOF;
This is MNMlit2html.pl Version $MNMlit2htmlVERSION by Peter Allgeyer,
Institut fuer Informatik, Technical University of Munich.

EOF

## Process debug switch
if ( $argv =~ /-debug/ )
   {
   ## -debug wurde eingegeben
   $DEBUG = 1;
   }
## end (if)


## .mnmlit2html.ini einlesen, wenn vorhanden
##
if (! (-f "$ENV{'HOME'}/.mnmlit2html.ini") and
   ! ( (! (&getcwd eq $ENV{'HOME'} )) &&
   (-f "./.mnmlit2html.ini")) and
   ! (-f "$INI_DIR/.mnmlit2html.ini"))
   {
   ## Kein .mnmlit2html.ini file gefunden?
   ## Dann Fehlermeldung.
   print "\nNo .mnmlit2html.ini file found!\n";
   print "Using defaults, declared in mnmlit2html.pl.\n";
   print "Hope that's Ok.\n";
   }

## ----------------------------------------------------------------
##  there shouldn't be no need to change anything behind this line
## ----------------------------------------------------------------
else
   {
   ## .mnmlit2html.ini einlesen, wo vorhanden
   ## 
   ## ACHTUNG:
   ## Jede gefundene Datei wird gescannt!!!
   ##
   ## Suchreihenfolge:
   ## 1) im Verzeichnis, in dem mnmlit2html.pl liegt
   ##    (bei Symlinks muss die Variable $INI_DIR
   ##     per Hand gesetzt werden, s.o.!!!)
   ## 2) aktuelles Verzeichnis
   ## 3) Homeverzeichnis
   ##
   if (-f "$INI_DIR/.mnmlit2html.ini")
      {
      ## .mnmlit2html.ini einlesen, wenn in $INI_DIR vorhanden
      (require("$INI_DIR/.mnmlit2html.ini"));

      ## Debugging
      if ( $DEBUG )
         {
         print ".mnmlit2html.ini im Verzeichnis,";
         print "in dem mnmlit2html.pl liegt, gefunden.\n";
         }
      ## end (if)
      }
   if ( (! (&getcwd eq $ENV{'HOME'} )) && (-f "./.mnmlit2html.ini"))
      {
      ## .mnmlit2html.ini einlesen,
      ## wenn im aktuellen Verzeichnis vorhanden
      (require("./.mnmlit2html.ini"));

      ## Debugging
      print ".mnmlit2html.ini im aktuellen Verzeichnis gefunden.\n"
      if $DEBUG;
      }
   if (-f "$ENV{'HOME'}/.mnmlit2html.ini")
      {
      ## .mnmlit2html.ini einlesen,
      ## wenn im Home-Verzeichnis vorhanden
      require("$ENV{'HOME'}/.mnmlit2html.ini");

      ## Debugging
      print ".mnmlit2html.ini im Home-Verzeichnis gefunden.\n"
      if $DEBUG;
      }
   print "\n" if $DEBUG;
   }
## end if


## Process switches
while ($ARGV[0] =~ /^-/)
   {
   $_ = shift;
   
   ## -debug wurde eingegeben
   if (/^-debug$/)
      {
      $DEBUG = 1;

      ## Debugging
      print "Recognised -debug.\n" if $DEBUG;
      }

   ## -latex2htmldir wurde eingegeben
   elsif (/^-latex2htmldir$/)
      {
      $_ = shift;
      ((($LATEX2HTML_DIR) = /^(.+)$/) || &usage &&
      print("Unrecognised value for -latex2htmldir: $_\n") && die);
      
      ## Debugging
      print "Recognised -latex2htmldir $1.\n" if $DEBUG;
      }

   ## -htmldir wurde eingegeben
   elsif (/^-htmldir$/)
      {
      $_ = shift;
      ((($HTML_DATA_DIR) = /^(.+)$/) || &usage &&
      print("Unrecognised value for -htmldir: $_\n") && die);
      
      ## Debugging
      print "Recognised -htmldir $1.\n" if $DEBUG;
      }

   ## -inputdir wurde eingegeben
   elsif (/^-inputdir$/)
      {
      $_ = shift;
      ((($INPUT_DIR) = /^(.+)$/) || &usage &&
      print("Unrecognised value for -inputdir: $_\n") && die);
      
      ## Debugging
      print "Recognised -inputdir $1.\n" if $DEBUG;
      }

   ## -bibdir wurde eingegeben
   elsif (/^-bibdir$/)
      {
      $_ = shift;
      ((($BIB_DIR) = /^(.+)$/) || &usage &&
      print("Unrecognised value for -bibdir: $_\n") && die);
      
      ## Debugging
      print "Recognised -bibdir $1.\n" if $DEBUG;
      }

   ## -tmpdir wurde eingegeben
   elsif (/^-tmpdir$/)
      {
      $_ = shift;
      ((($TMP) = /^(.+)$/) || &usage &&
      print("Unrecognised value for -tmpdir: $_\n") && die);

      ## Debugging
      print "Recognised -tmpdir $1.\n" if $DEBUG;
      }

   ## -childline wurde eingegeben
   elsif (/^-childline$/)
      {
      $_ = shift;
      ((($CHILDLINE) = /^(.+)$/) || &usage &&
      print("Unrecognised value for -childline: $_\n") && die);

      ## Debugging
      print "Recognised -childline $1.\n" if $DEBUG;
      }

   ## -h(elp) wurde eingegeben
   elsif (/^-h(elp)?$/)
      {
      ## Debugging
      print "Recognised -(h)elp.\n" if $DEBUG;

      ## Rufe Hilfestellung zum Programmaufruf auf und
      ## beende dann das laufende Programm mit Status 0
      &usage;
      exit 0;
      }

   ## Keinen Switch erkannt?
   ## Dann rufe Hilfestellung zum Programmaufruf
   ## auf und beende dann das laufende Programm
   else
      {
      &usage;
      die "Unrecognised switch: $_\n";
      }
   }
## end (while)

## No arguments left!!
(&usage && die "Unrecognised switch: @ARGV!\n") if @ARGV;


# #################### begin (main) ####################  

## Debugging
print "Arguments left after processing switches: @ARGV\n\n" if $DEBUG;

## $INPUT_DIR nach *.tgz, *.tar.gz, *.tar.Z durchsuchen
@inputs = glob ("$INPUT_DIR/{*.tgz,*.tar.gz,*.tar.Z}");

## Fehlermeldung und Abbruch, wenn keine Eingabedateien vorhanden sind
die "Input directory empty?\n" if (!defined @inputs);

## Trenne von jeder Eingabedatei Pfad und Endung ab
foreach $inputfile ( @inputs )
   {
   my ($name, $path, $suffix) =
   fileparse ($inputfile, "\.tgz", "\.tar\.gz", "\.tar\.Z");

   ## Packe gefundene Datei aus
   print "Unpack $name$suffix to $TMP ...\n";

   ## entpacke Archiv in temporaerem Verzeichnis
   system ("( cd $TMP; gunzip < $inputfile | tar xf - 2> /dev/null )");

   $inputfile = $name;
   }

## Statusausgabe
print "\nRunning 'mnmlit2html.pl $argv @inputs' ...\n\n";


## Neues Directory anlegen
&new_dir ("$HTML_DATA_DIR") unless (-d "$HTML_DATA_DIR" );


## Zusammenfassung abstrahieren
## @ZUSAMMENFASSUNG beinhaltet eine Liste von Schlagwoertern,
## nach denen im Zusammenhang mit einer Kurzfassung fuer den
## vorliegenden Text gesucht wird.
## @ZUSAMMENFASSUNG wird in .mnmlit2html.ini spezifiziert
foreach $ZUSAMMENFASSUNG (@ZUSAMMENFASSUNG)
   {
   $ZUSAMMENFASSUNG = &substitute_umlaut ($ZUSAMMENFASSUNG);
   }
## end (foreach)



#############################################################
## Zunaechst wird eine Datenbank erzeugt. Sie besteht
## aus saemtlichen Arbeiten, die in den angegebenen
## Bibliographien gefunden werden. Der Aufbau einer Arbeit
## wird gemaess den Angaben in der .ini-Datei vorgenommen.
#############################################################

## Orte fuer *.bib-Files
@BIB_DIR = split /:/, $BIB_DIR;

foreach $DIR (@BIB_DIR)
   {
   unless ( -d $DIR  )
      {
      warn "WARNING: Can't open $DIR!\n";
      next;
      }

   opendir BIB_DIR, "$DIR";
      @allfiles =
         (@allfiles, grep /bib$/, map "$DIR/$_", readdir BIB_DIR);
   closedir BIB_DIR;

   ## Debugging
   print "Found *.bib files: @allfiles\n" if $DEBUG;
   }
## end (foreach)


## Erzeuge HTML Titelseiten fuer Diplomarbeiten, Fopras etc.
if (defined @allfiles)
   {
   &create_kind_title_page (@allfiles);
   }
else
   {
   die "No \@BIB_DIR in .mnmlit2html?\n";
   }


## Nun erstelle HTML Titelseiten fuer
## jede eingegebene Arbeit
KEY: foreach $inputfile ( @inputs )
   {
   ## Zusammenfassung muss neu geholt werden
   undef $abstract;

   ## $key enthaelt aktuelle Arbeit
   $key = $inputfile;

   ## Art der Arbeit
   ($kind = $authmap{$key}) ||
   (print "WARNING: No $key in *.bib files!\n" && next KEY);

   ## Debugging
   print "KIND: $kind; KEY: $key\n" if $DEBUG;

   ## Liefert Mehrzahl des angegebenen Typs zurueck
   ## $type = &get_type($bibmap{$key});
   $type = $bibmap{$key};

   ## Zielverzeichnis, falls vorhanden, vor dem
   ## Reinschreiben der Daten loeschen
   &rm_dir ("$HTML_DATA_DIR/\u\L$type\E/$key") if
   ( -d "$HTML_DATA_DIR/\u\L$type\E/$key" );

   ## Erzeuge Verzeichnisstruktur
   &new_dir ("$HTML_DATA_DIR/\u\L$type\E/$key") unless
   ( -d "$HTML_DATA_DIR/\u\L$type\E/$key" );

   ## liefert Name des TeX-files zurueck
   ($texfile = &get_texfile ($key));

   ## LaTeX Sourcefile gefunden?
   ## Dann benenne HTML-file entsprechend
   if ( $NO_TEXFILE =~ 0 )
      {
      ## Name des HTML-files
      ## aus <name>.tex herausfiltern ...
      ($name, $path, $suffix) = fileparse ($texfile, "\.tex");

      ## ... und mit entsprechender Endung versehen
      $htmlfile = "$name\.html";
      }

   ## Suche nach evtl. vorhandenem
   ## Postscript- und PDF-File
   $psfile = &get_psfile ($key);
   $pdffile = &get_pdffile ($key);

   ## Debugging
   print "HTMLFILE: $htmlfile\n" if $DEBUG;
   print "PSFILE:   $psfile\n" if $DEBUG;
   print "PDFFILE:  $pdffile\n" if $DEBUG;

   ## Copy $psfile nach $HTML_DATA_DIR/$type/$key/Postscript-Version
   &copy_ps_file ($key, $type, $psfile);

   ## Copy $pdffile nach $HTML_DATA_DIR/$type/$key/PDF-Version
   &copy_pdf_file ($key, $type, $pdffile);

   ## Abfrage nach NOHTML
   &no_html_file($key);

   ## LaTeX2html main.tex,
   &create_html_structur ($key, $type, $texfile);

   ## HTML Titelseite erstellen
   &create_work_title_page ($key, $type, $htmlfile, $psfile);

   ## Loesche HTML-Baum, weil NOHTML gesetzt war!
   &rm_dir ("$HTML_DATA_DIR/\u\L$type\E/$key/HTML-Version") if $NO_HTMLFILE =~ 1;

   ## Loesche Datei aus dem Inputverzeichnis
   &rm_dir ("$INPUT_DIR/$inputfile\.*");

   ## Loesche temporaer angelegte Verzeichnisse und Dateien
   &rm_dir ("$TMP/$inputfile");
   &rm_dir ("$TMP/*.css ");
   &rm_dir ("$TMP/*.html")
   &rm_dir ("$TMP/*.tex")
   &rm_dir ("$TMP/*.pl")
   &rm_dir ("$TMP/.*.db");
   &rm_dir ("$TMP/.*.dir");
   &rm_dir ("$TMP/.*.pag");

   ## Erfolgsmeldung
   print "Added to WWW: $inputfile\n\n";

   ## @success gibt an, welche Arbeiten fehlerlos
   ## ins WWW gehaengt wurden
   push (@success, $inputfile)
   }
## end (foreach)

## Erfolgsmeldung
if (defined @success)
   {
   print "Documents requested to add to WWW: @inputs.\n";
   print "Successfully added to WWW: @success\n";
   }
else
   {
   print "An error occured, no Documents added to WWW!\n"
   }

# ############################## end (main) ####################################



# ######################### begin (subroutines) ################################

#############################################################
## Erzeuge eine HTML Titelseite, fuer jede
## Art von Arbeit (Fopra, Diplomarbeit, Paper etc.)
#############################################################
sub create_kind_title_page
   {
   local (@allfiles) = @_;
   local ($type, $html_bib_file, $file);

   foreach $file (@allfiles)
      {
      ## Statusausgabe
      print "Loading $file...\n";

      ## HTML Seite aus BIB-File erzeugen
      &create_html_bib_file ($file);

      ## HTML-BIB-FILE scannen und Variablen in einen assoziativen Vektor schreiben
      $type = basename ($file, ".bib");
      print "TYPE: $type\n" if $DEBUG;

      $html_bib_file = "$type" . ".bib.html";
      print "HTML_BIB_FILE: $html_bib_file\n" if $DEBUG;

      ## Statusausgabe
      print "\nLoading $TMP/$html_bib_file...\n";
      print "Scanning ...\n\n";

      ## Liefert Mehrzahl des angegebenen Typs zurueck
      ## $type = &get_type($type);
      
      ## Verzeichnisstruktur aufbauen
      &new_dir ("$HTML_DATA_DIR/\u\L$type") unless
      ( -d "$HTML_DATA_DIR/\u\L$type");

      ## Datei nach Inhalt scannen
      &scan_html_bib_file ("$TMP/$html_bib_file", "$type");
      }
   ## end (foreach)
   }
## end (sub create_kind_title_page)



#############################################################
## Rufe latex2html auf,
## Destinationdirectory ist $HTML_DATA_DIR/$type/$key
#############################################################
sub create_html_structur
   {
   local ($key, $type, $texfile) = @_;

   ## Debugging
   print "\nKEY: $key, TYPE: $type\n" if $DEBUG;

   ## Destination
   $HTML_DIR = "$HTML_DATA_DIR/\u\L$type\E/$key/HTML-Version";

   # Verzeichnis loeschen, falls vorhanden
   &rm_dir ("$HTML_DIR") if ( -d "$HTML_DIR" );

   ## Lege Verzeichnisse an, wenn sie nicht schon existieren
   &new_dir ("$HTML_DIR") unless ( -d "$HTML_DIR");

   ## Debugging
   print "Aufruf von latex2html mit folgender LaTeX Main-Datei: $texfile\n"
   if $DEBUG;

   ## Statusausgabe
   if ( $NO_TEXFILE =~ 0 )
      {
      print "Running LaTeX2HTML for $inputfile:\n\n";
      }

   -e "$LATEX2HTML_DIR/latex2html" or
   die "No such file $LATEX2HTML_DIR/latex2html.\n";

   ## latex2html mit Argumenten aufrufen:
   ##
   ##  Subdirectory anlegen
   ##  |    kein Abschnitt: About this document ...
   ##  |    |    
   ##  |    |
   ##  |    |____________________________________________.
   ##  |_________________________________.                |
   ##                                   .|.            .__|_.
   system ("$LATEX2HTML_DIR/latex2html -dir $HTML_DIR -info 0 $texfile")
   if $NO_TEXFILE =~ 0;
   }
## end (sub create_html_structur)



#############################################################
## Erzeuge eine HTML Titelseite fuer jede uebergebene
## Arbeit aus den Informationen, die in
## der Datenbank gespeichert wurden
#############################################################
sub create_work_title_page
   {
   local ($key, $type, $htmlfile, $psfile) = @_;
   local ($output) = "$HTML_DATA_DIR/\u\L$type\E/$key/$key.shtml";
   local (@nf, @node_files, @not_node_files);

   ## $HTML_DIR wurde in &create_html_structur spezifiziert
   ## @node_files enthaelt alle Dateien mit Namen node\d+.html
   unless ( -d $HTML_DIR  )
      {
      warn "WARNING: Can't open $HTML_DIR, so this file won't be added!\n";
      next KEY;
      }

   opendir HTMLDIR, "$HTML_DIR";
      @node_files = (@node_files, grep /node\d+\.html$/,
      map "$HTML_DIR/$_", readdir HTMLDIR);
   closedir HTMLDIR;

   ## $HTML_DIR wurde in &create_html_structur spezifiziert
   ## @not_node_files enthaelt alle Dateien mit der Endung .html,
   ## die nicht mit node\d+.html oder footnote.html heissen
   opendir HTMLDIR, "$HTML_DIR";
      @not_node_files = (@not_node_files, grep /.*\.html$/,
      grep !/(node\d+|footnode)\.html$/, map "$HTML_DIR/$_", readdir HTMLDIR);
   closedir HTMLDIR;

   ## Durchsuche main.html
   foreach $html_page (@not_node_files)
      {
      $abstract = &get_abstract ($html_page, $key);
      last if ("$abstract" ne "");
      }
   ## end (foreach)

   ## Durchsuche alle *.html -files
   if ("$abstract" eq "")
      {
      foreach $html_page (@node_files)
         {
         $abstract = &get_abstract ($html_page, $key);
         last if ("$abstract" ne "");
         }
      ## end (foreach)
      }
   ## end (if)

   ## Durchsuche alle *.html -files nach @ZUZSAMMENFASSUNG
   if ("$abstract" eq "")
      {
      foreach $html_page (@node_files)
         {
         $abstract = &get_introduction ($html_page, $key);
         last if ("$abstract" ne "");
         }
      ## end (foreach)
      }
   ## end (if)

   print "Keine Zusammenfassung gefunden!\n" if ("$abstract" eq "");

   ## HTML-Header erzeugen und nach $output schreiben
   &print_header ($type, $authmap{$key}, $key, $output);

   ## HTML-Body erzeugen und nach $output schreiben
   &print_body ($type, $authmap{$key}, $key, $abstract, $output, $htmlfile);

   ## HTML-Footer erzeugen und nach $output schreiben 
   &print_footer ($output);

   ## HTML - Inhaltsangabe erzeugen
   ## Diese Seite enthaelt eine Liste aller Arbeiten, die im dazugehoerigen
   ## BIB-File erwaehnt sind. Per Hyperlink ist eine kleine Zusammenfassung
   ## der angewaehlten Arbeit zu erreichen.
   
   &print_inhalt ($type, $key);
   }
## end (sub create_work_title_page)


######################################################
## Eingabe Fehler
######################################################
sub usage
   {                     
   print <<EOF;

Usage: mnmlit2html.pl
   [-latex2htmldir <directory>]
   [-bibdir <directory>]
   [-inputdir <directory>]
   [-htmldir <directory>]
   [-tmpdir <directory>]
   [-childline <reg-expr>]
   [-debug]
   [-h(elp)]

EOF
   }
## end (sub usage)



######################################################
## Get current working directory
## Aktuelles Arbeitsverzeichnis aufloesen
######################################################
sub getcwd
   {
   local($cwd);
   chop($cwd = `pwd`);
   $cwd;
   }
## end (sub getcwd)



######################################################
## Loescht ein Verzeichnis rekursiv
######################################################
sub rm_dir
   {
   ## Verzeichnis rekursiv loeschen,
   ## falls es vorhanden ist und
   ## der EUID des ausfuehrenden Programms
   ## gehoert.
   local($_) = @_;
   system ("rm -rf $_"); 
   }
## end (sub rm_dir);


######################################################
## Erzeugt ein neues Directory, falls moeglich
######################################################
sub new_dir
   {
   ## Verzeichnis anlegen und
   ## mit Rechten rwxrwsr-x versehen,
   ## damit Unterverzeichnisse gleich der
   ## richtigen Gruppe gehoeren und von
   ## dieser schreibbar sind.
   local($_) = @_;
   mkdir($_, oct(755)) ||
   warn "mkdir: cannot make directory `$_': Permission denied\n";
   system ("chmod 775 $_") if ( -d "$_" );
   system ("chmod g+ws $_") if ( -d "$_" );
   }
## end (sub new_dir);


######################################################
## Latex-Umlaute durch HTML-Umlaute ersetzen
######################################################
sub substitute_umlaut
   {
   local ($umlaut) = @_;

   $umlaut =~ s/\"a/\\\&\\\#228\\\;/g; ## "a --> &#228;
   $umlaut =~ s/\"o/\\\&\\\#246\\\;/g; ## "o --> &#246;
   $umlaut =~ s/\"u/\\\&\\\#252\\\;/g; ## "u --> &#252;
   $umlaut =~ s/\"A/\\\&\\\#196\\\;/g; ## "A --> &#196;
   $umlaut =~ s/\"O/\\\&\\\#214\\\;/g; ## "O --> &#214;
   $umlaut =~ s/\"U/\\\&\\\#220\\\;/g; ## "U --> &#220;
   $umlaut =~ s/\"s/\\\&\\\#223\\\;/g; ## "s --> &#223;

   $umlaut =~ s/\\\"a/\\\&\\\#228\\\;/g; ## "a --> &#228;
   $umlaut =~ s/\\\"o/\\\&\\\#246\\\;/g; ## "o --> &#246;
   $umlaut =~ s/\\\"u/\\\&\\\#252\\\;/g; ## "u --> &#252;
   $umlaut =~ s/\\\"A/\\\&\\\#196\\\;/g; ## "A --> &#196;
   $umlaut =~ s/\\\"O/\\\&\\\#214\\\;/g; ## "O --> &#214;
   $umlaut =~ s/\\\"U/\\\&\\\#220\\\;/g; ## "U --> &#220;
   $umlaut =~ s/\\\"s/\\\&\\\#223\\\;/g; ## "s --> &#223;

   $umlaut =~ s/ä/\\\&\\\#228\\\;/g; ## "a --> &#228;
   $umlaut =~ s/ö/\\\&\\\#246\\\;/g; ## "o --> &#246;
   $umlaut =~ s/ü/\\\&\\\#252\\\;/g; ## "u --> &#252;
   $umlaut =~ s/Ä/\\\&\\\#196\\\;/g; ## "A --> &#196;
   $umlaut =~ s/Ö/\\\&\\\#214\\\;/g; ## "O --> &#214;
   $umlaut =~ s/Ü/\\\&\\\#220\\\;/g; ## "U --> &#220;
   $umlaut =~ s/ß/\\\&\\\#223\\\;/g; ## "s --> &#223;

   return $umlaut;
   }
## end (sub substitute_umlaut)



######################################################
## Abgekuerzte Monatsnamen durch ihr Pendant ersetzen
######################################################
sub substitute_month
   {
   local ($mth) = @_;

   foreach $month (keys(%months))
      {
      if ($month =~ /$mth/i)
         {
         return $months{$mth};
         }
      ## end (if)
      }
   ## end (foreach)

   return $mth;
   }
## end (sub substitute_month)



######################################################
## Liefere main.ps zurueck
######################################################
sub get_psfile
   {
   local ($key) = @_;
   local ($SRCDIR, $file, @allfiles);

   ## Flag zuruecksetzen
   $NO_PSFILE = 0;

   ## Wo liegt die Dokumentation?
   $SRCDIR = "$TMP/$key/Dokumentation/Postscript";

   unless ( -d $SRCDIR  )
      {
      warn "WARNING: Can't open $SRCDIR!\n";
      
      ## Flag setzen
      $NO_PSFILE = 1;

      ## und zurueckkehren
      return;
      }

   opendir SRCDIR, "$SRCDIR";
      @allfiles = (@allfiles, grep /ps$/, readdir SRCDIR);
   closedir SRCDIR;

   ## Debugging
   print "Found *.ps files: @allfiles\n" if $DEBUG;

   ## Flag setzen, falls kein Postscriptfile gefunden wurde
   if (@allfiles eq "")
      {
      ## Flag setzen
      $NO_PSFILE = 1;

      ## und zurueckkehren
      return;
      }

   ## $key.ps vorhanden?
   foreach $file (@allfiles)
      {
      $file =~ /$key\.ps$/ && return $file;
      }
   ## end (foreach)

   ## main.ps vorhanden?
   foreach $file (@allfiles)
      {
      $file =~ /main\.ps$/ && return $file;
      }
   
   ## Nehme blindlings das erste, gefundene PS-File
   return $allfiles[0];
   }
## end (sub get_psfile)



######################################################
## Liefere main.pdf zurueck
######################################################
sub get_pdffile
   {
   local ($key) = @_;
   local ($SRCDIR, $file, @allfiles);

   ## Flag zuruecksetzen
   $NO_PDFFILE = 0;

   ## Wo liegt die Dokumentation?
   $SRCDIR = "$TMP/$key/Dokumentation/PDF";

   unless ( -d $SRCDIR  )
      {
      warn "WARNING: Can't open $SRCDIR!\n";

      ## Flag setzen
      $NO_PDFFILE = 1;
      
      ## und zurueckkehren
      return;
      }

   opendir SRCDIR, "$SRCDIR";
      @allfiles = (@allfiles, grep /pdf$/, readdir SRCDIR);
   closedir SRCDIR;

   ## Debugging
   print "Found *.pdf files: @allfiles\n" if $DEBUG;

   ## Flag setzen, falls keine PDF-Datei gefunden wurde
   if (@allfiles eq "")
      {
      ## Flag setzen
      $NO_PDFFILE = 1;

      ## und zurueckkehren
      return;
      }

   ## Mehrere *.pdf Dateien vorhanden?
   foreach $file (@allfiles)
      {
      $file =~ /$key\.pdf$/ && return $file;
      }
   ## end (foreach)

   ## Mehrere *.pdf Dateien vorhanden?
   foreach $file (@allfiles)
      {
      $file =~ /main\.pdf$/ && return $file;
      }
   ## end (foreach)

   ## Nehme blindlings die erste, gefundene PDF-Datei
   return $allfiles[0];
   }
## end (sub get_pdffile)



######################################################
## Liefere main.tex zurueck
######################################################
sub get_texfile
   {
   local ($key) = @_;
   local ($SRCDIR, $file, @allfiles);

   ## Flag zuruecksetzen
   $NO_TEXFILE = 0;
   
   ## Wo liegt die Dokumentation?
   $SRCDIR = "$TMP/$key/Dokumentation/Latex";

   unless ( -d $SRCDIR  )
      {
      warn "WARNING: Can't open $SRCDIR!\n";

      ## Flag setzen
      $NO_TEXFILE = 1;

      ## und zurueckkehren
      return;
      }

   opendir SRCDIR, "$SRCDIR";
      @allfiles = (@allfiles, grep /tex$/, map "$SRCDIR/$_", readdir SRCDIR);
   closedir SRCDIR;
   
   ## Debugging
   print "Found *.tex files: @allfiles\n" if $DEBUG;

   ## main.tex oder $key.tex vorhanden?
   ## => liefere als Filename zurueck!
   foreach $file (@allfiles)
      {
      $file =~ /main\.tex$/ && return $file;
      $file =~ /$key\.tex$/ && return $file;
      }

   foreach $file (@allfiles)
      {
      open (FILE, "$file");

         while (<FILE>)
            {
            ## LaTeX 1.09
            if (/\\documentstyle/ && /\\begin\{document\}/)
               {
               (close (FILE) && return $file);
               }
            ## LaTeX 2e
            elsif (/\\documentclass/ && /\\begin\{document\}/)
               {
               (close (FILE) && return $file);
               }
            ## Egal, welche Versionsnummer
            elsif (/\\begin\{document\}/)
               {
               (close (FILE) && return $file);
               }
            }
         ## end (while)

      close (FILE);
      }
   ## end (foreach)

   ## Kein Main TeX-File gefunden!
   print "WARNING: No main LaTeX-File found for $key in $SRCDIR!\n";

   ## Flag setzen
   $NO_TEXFILE = 1;
   }
## end (sub get_texfile)



################################################################################
## Postscriptfile nach $HTML_DATA_DIR/$type/$key/Postscript-Version
## kopieren, falls vorhanden
################################################################################
sub copy_ps_file
   {
   local ($key, $type, $psfile) = @_;
   local ($SRCDIR, $PS_DIR);

   ## Verzeichnis fuer Dokumente in Postscriptformat
   $SRCDIR = "$TMP/$key/Dokumentation/Postscript";

   ## Flag auf Null setzen:
   ## Ist $NO_PSFILE =~ 1, so gibt es keine
   ## Postscript-Version des Dokumentes
   $NO_PSFILE = 0;

   ## Destination
   $PS_DIR = "$HTML_DATA_DIR/\u\L$type\E/$key/Postscript-Version";

   # Verzeichnis loeschen, falls vorhanden
   &rm_dir ("$PS_DIR") if ( -d "$PS_DIR" );

   # Neues Verzeichnis erstellen
   &new_dir ("$PS_DIR") unless (-d "$PS_DIR" );

   ## File zippen und kopieren
   if ( -f "$SRCDIR/$psfile" )
      {
      ## Statusmeldung
      print "Zipping $psfile.\n";

      ## Komprimiere und kopiere File
      system ("gzip -9 -c $SRCDIR/$psfile > $PS_DIR/$psfile.gz");

      ## Aendere Rechte
      system ("chmod 664 $PS_DIR/$psfile.gz");

      ## Link von $key.ps -> main.ps
      system ("( cd $PS_DIR; ln -sf $psfile.gz $key.ps.gz )")
      unless ( "$psfile" eq "$key.ps" );

      ## Berechne Groesse des komprimierten Files
      $size_ps = (-s "$PS_DIR/$psfile.gz");
      
      ## Runde auf volle Kilobyte
      $size_ps = (( $size_ps / 1024 ) + 0.5);
      
      ## Debugging
      printf "\nFILE: %s.gz\nSIZE: %.1f KB\n\n", $psfile, $size_ps if $DEBUG;
      }
   else
      {
      ## Flag setzen
      $NO_PSFILE = 1;

      ## Warnen, dass kein Postscriptfile vorhanden ist
      print "WARNING: No postscript-file found for $key";
      print "in $TMP/$key/Dokumentation!\n";
      }
   ## end (if)
   }
## end (sub copy_ps_file)



################################################################################
## PDF-Datei nach $HTML_DATA_DIR/$type/$key/PDF-Version
## kopieren, falls vorhanden
################################################################################
sub copy_pdf_file
   {
   local ($key, $type, $pdffile) = @_;
   local ($SRCDIR, $PDF_DIR);

   ## Verzeichnis fuer Dokumente in PDF-Format
   $SRCDIR = "$TMP/$key/Dokumentation/PDF";

   ## Flag auf Null setzen:
   ## Ist $NO_PDFFILE =~ 1, so gibt es keine
   ## Postscript-Version des Dokumentes
   $NO_PDFFILE = 0;

   ## Destination
   $PDF_DIR = "$HTML_DATA_DIR/\u\L$type\E/$key/PDF-Version";

   # Verzeichnis loeschen, falls vorhanden
   &rm_dir ("$PDF_DIR") if ( -d "$PDF_DIR" );

   ## Neues Verzeichnis erstellen
   &new_dir ("$PDF_DIR") unless (-d "$PDF_DIR" );

   ## File kopieren
   if ( -f "$SRCDIR/$pdffile" )
      {
      ## Kopiere File
      system ("cp $SRCDIR/$pdffile $PDF_DIR");
      
      ## Aendere Rechte
      system ("chmod 664 $PDF_DIR/$pdffile");
      
      ## Link von $key.pdf -> main.pdf
      system ("( cd $PDF_DIR; ln -sf $pdffile $key.pdf )")
      unless ( "$pdffile" eq "$key.pdf" );
      
      ## Berechne Groesse des Files
      $size_pdf = (-s "$PDF_DIR/$pdffile");
      
      ## Runde auf volle Kilobyte
      $size_pdf = (( $size_pdf / 1024 ) + 0.5);
      
      ## Debugging
      printf "\nFILE: %s\nSIZE: %.1f KB\n\n", $pdffile, $size_pdf if $DEBUG;
      }
   else
      {
      ## Flag setzen
      $NO_PDFFILE = 1;

      ## Warnen, dass keine PDF-Datei vorhanden ist
      print "WARNING: No PDF-file found for $key in $TMP/$key/Dokumentation!\n";
      }
   ## end (if)
   }
## end (sub copy_pdf_file)


################################################################################
## Ueberpruefen, ob NOHTML gesetzt ist
################################################################################
sub no_html_file
   {
   local ($key) = @_;
   local ($SRCDIR);

   ## Flag zuruecksetzen
   $NO_HTMLFILE = 0;

   ## Wo soll das Programm nach NOHTML suchen?
   $SRCDIR = "$TMP/$key";

   ## NOHTML vorhanden?
   if ( -e "$SRCDIR/NOHTML" )
      {
      # Ja, dann Flag setzen
      $NO_HTMLFILE = 1;
      }
   ## end (if)
   }
## end (sub no_html_file)



################################################################################
## {diplomarbeiten,fopra,papers}.bib: Anpassung an deutsche Sonderzeichen
## Anschliessend: 'latex2html {diplomarbeiten,fopra,papers}.bib'
################################################################################
sub create_html_bib_file
   {
   local ($bib_file) = @_;
   local ($line, $vorspann);

   $vorspann = "\\usepackage\{german\}";
   $basename_bib_file = basename($bib_file, "");

   ## Vorspann erzeugen
   open (BIBFILE, ">$TMP/$basename_bib_file.tex") ||
   die ("\n$TMP/$basename_bib_file.tex not writeable?\n");
      print BIBFILE ("$vorspann\n");
   close (BIBFILE);

   open (BIB, $bib_file)   || die ("\nCan't open $bib_file!\n");

      while ($line = <BIB>)
         {
         ## Entferne ueberfluessige Leerzeilen
         $line =~ s/^\s*\n$//;

         ## Damit aus dem von latex2html generierten File eine korrekte
         ## Endemarkierung fuer jeden Block (<P>) eingefuegt wird, muss
         ## vor jeder Gattung (@book, @article, ...) eine Leerzeile
         ## eingefuegt werden.
         $line =~ s/\@(.*\s*)/\n\@$1/;

         ## Damit aus dem von latex2html generierten File die Gattung vom
         ## Key getrennt werden kann, muss hinter der Gattung eine oeffnende
         ## geschweifte Klammer und dann mindestens ein Leerzeichen kommen.
         $line =~ s/\@(\w+)\s*\{\s*(\w+)\s*,\s*/\@$1\{ $2,\n/;

         ## Doppelte Anfuehrungszeichen in geschweifte Klammern uebersetzen.
         ## key = "...", --> key = {...},\n
         $line =~ s/^\s*(\w+)\s*=\s*\"(.*)\"\s*,\s*$/$1 = \{$2\},\n/;

         ## key = "..."  --> key = {...}\n
         $line =~ s/^\s*(\w+)\s*=\s*\"(.*)\"\s*$/$1 = \{$2\}\n/;

         ## key = "...   --> key = {...\n
         $line =~ s/^\s*(\w+)\s*=\s*\"(.*)\s*$/$1 = \{$2\n/;

         ## ...",        --> ...},\n
         $line =~ s/^\s*(.*)\"\s*,\s*$/ $1\},\n/;

         ## ..."         --> ...}\n
         $line =~ s/^\s*(.*)\"\s*$/ $1\}\n/;

         open (NEWBIB, ">>$TMP/$basename_bib_file.tex");
            print NEWBIB "$line";
         close (NEWBIB);
         }
      ## end (while)

   close (BIB);

   ## Statusausgabe
   print "Saving $TMP/$basename_bib_file.tex...\n\n";

   -e "$LATEX2HTML_DIR/latex2html" or
   die "No such file $LATEX2HTML_DIR/latex2html.\n";

   ## latex2html mit Argumenten aufrufen:
   ##
   ##  kein weiters Subdirectory anlegen, stattdessen
   ##  in $TMP zwischenspeichern
   ##  |    kein Abschnitt: About this document ...
   ##  |    |    keine Navigationshilfen im Kopf (oder auch Fuss)
   ##  |    |    |______________________.
   ##  |    |________________.          |
   ##  |____________.        |          |
   ##           .___|__.  .__|_.  ._____|______.
   $OPTIONS = "-dir $TMP -info 0 -no\_navigation";
   system ("$LATEX2HTML_DIR/latex2html $OPTIONS $TMP/$basename_bib_file.tex");
   }
## end (sub create_html_bib_file)



###################################################
## Benoetigte Variablen aus
## {Diplomarbeiten,Fopras}.bib File extrahieren
## und in einen assoziativen Vektor schreiben
###################################################
sub scan_html_bib_file
   {
   local ($file, $type) = @_;
   local ($work);
   local ($index) = 0;

   open (BIB, $file) || die ("\nCan't open $file!\n");

      BIB: while (<BIB>)
         {
         ## @article, @book, ... gefunden?
         if (/\@(\w+)\s+(\w+)\s*,\s*/)
            {
            $index++;      ## Index um eins erhoehen

            $kind = lc $1;    ## lowercase @article, @book, ...
            $who = $2;        ## Lehrstuhlinterner key (schm97 bspw.)

            ${$type}{$index} = $who;   ## Zuordnung von index => author
                                       ## (Durchnummerieren)
            print "INDEX: $index: ${$type}{$index}\n" if $DEBUG;

            $authmap{$who} = $kind;    ## Zuordnung von author => kind
            $bibmap{$who}  = $type;    ## Zuordnung von author => type

            print "EINTRAG GEFUNDEN: $who ist vom Typ $bibmap{$who}\n"
            if $DEBUG;

            @bib_fields = eval "\@${kind}";  ## Felder der einzelnen
                                             ## Gattungen dem Array
                                             ## @bib_fields zuordnen;
                                             ## Aufbau findet
                                             ## sich in der ini-Datei
            &make_bibhash ("$kind");         ## Erzeuge assoziativen Array
            }
         }
      ## end (while)

   close (BIB);

   ## Debugging
   if ( $DEBUG )
      {
      foreach $work (sort keys(%masterthesis))
         {
         print "$work:\n";
         foreach $field (sort keys(%{$mastersthesis{$work}}))
            {
            print "$field = $mastersthesis{$work}{$field}\n";
            }
         print "\n";
         }
      ## end (foreach)
      }
   ## end (if)
   }
## end (sub scan_html_bib_file)



######################################
## Erzeuge den assoziativen Array
######################################
sub make_bibhash
{
   local ($kind) = @_;     ## Parameteruebergabe der Gattung
   local ($who) = $who;    ## Lehrstuhlinterner key
   local ($field);         ## lokale Laufvariable

   BIBF: while (<BIB>)
      {
      foreach $field (@bib_fields)  ## beachte jedes Feld der
         {                          ## uebergebenen Gattung
         if (/^\s*$field\s*=\s*(.*),\s*$/i)  ## Einzeiliges Feld in *.bib.html
            {                                ## gefunden? (zu Erkennen am Komma
                                             ## am Ende der Zeile)   
            ${$kind}{$who}{$field} = $1;     ## dann speichere Key und Value
                                             ## in %kind ab.

            ## Doppelte 'and' entfernen, d.h.
            ## aus "... and ... and ..." mache
            ## "..., ... and ..."
            while ( ${$kind}{$who}{$field} =~ /\s+and\s+(.*)\s+and\s+/ )
               {
               ${$kind}{$who}{$field} =~ s/\s+and\s+(.*)\s+and\s+/, $1 and /;
               }
            }
         elsif (/^\s*$field\s+=\s+(.*\s*)/i) ## Mehrzeiliges Feld in *.bib.html
            {                                ## gefunden? (kein Komma)
            ${$kind}{$who}{$field} = $1;     ## dann speichere Key und Value
                                             ## in %kind ab,

            FIELD:                        ## setze Sprungmarke,
               while (<BIB>)              ## durchsuche naechste Zeile
                  {
                  ## Abbruch, wenn Leerzeile gefunden wird
                  last FIELD if /^\s*$/;

                  ## sonst: haenge Zeile an,
                  ${$kind}{$who}{$field} .= $_;

                  ## Abbruch, wenn Zeile mit Komma endet.
                  last FIELD if /\,\s*$/;    
                  }

            ## Make into one long line.
            ## ersetze Zeilenumbruch durch Leerzeichen
            ${$kind}{$who}{$field} =~ s/\n\s*/ /g;

            ## kuerze mehrere Leerzeichen auf eines
            ${$kind}{$who}{$field} =~ s/\s+\s*/ /g;

            ## entferne nachfolgende Leerzeichen
            ${$kind}{$who}{$field} =~ s/\s+$//;

            ## loesche Kommata am Ende einer Zeile
            ${$kind}{$who}{$field} =~ s/\,\s*$//;
            }
         ## end (if)
         }
      ## end (foreach)

      redo BIB if /\@/; ## Abbruch, wenn Bereichstrenner gefunden wird.
      }                    
   ## end (while)
   }
## end (sub)



#########################################
## Zusammenfassung extrahieren
#########################################
sub get_abstract
   {
   local ($html_page, $work) = @_;
   local ($abstract) = "";
   local ($file, @allfiles);

   open (INPUT, "$html_page") || die ("\nCan't open $html_page!\n");

      #
      # CLASS=ABSTRACT gefunden?
      # Dann suche nach Bereichstrenner
      # und liefere alles bis dahin gefundene
      # als $abstract zurueck
      #
      while (<INPUT>)
         {
         if (/ABSTRACT/)
            {
            while (<INPUT>)
               {
               return $abstract if m%\%;
               $abstract .= $_;
               }
            }
         ## end (if)
         }
      ## end (while)

   close (INPUT);

   return $abstract;
   }
## end (sub get_abstract)



#########################################
## Einfuehrung extrahieren
#########################################
sub get_introduction
   {
   local ($html_page, $work) = @_;
   local ($abstract, $file, @allfiles);

   open (INPUT, "$html_page")    || die ("\nCan't open $html_page!\n");

      #
      # Suche der Reihe nach alle Eintraege fuer @ZUSAMMENFASSUNG
      # durch. Zusammenfassung gefunden?
      # Dann suche nach Bereichstrenner
      # und liefere alles bis dahin gefundene
      # als $abstract zurueck.
      #

      while (<INPUT>)
         {
         foreach $ZUSAMMENFASSUNG (@ZUSAMMENFASSUNG)
            {
            if (/$ZUSAMMENFASSUNG\<\/A\>/i)
               {
               LOOP:
                  while (<INPUT>)
                     {
                     last LOOP unless (/^<\/H.>/ || /^<P>/);

                     while (<INPUT>)
                        {
                        ## Wonach gesucht wird, bestimmt die
                        ## Variable $CHILDLINE = "<BR><HR>\n";
                        ## in latex2html.config
                        return $abstract if /$CHILDLINE/;
                        $abstract .= $_;
                        }
                     ## end (while)
                     }
                  ## end (while)
               }
            ## end (if)
            }
         ## end (foreach)
         }
      ## end (while)
   close (INPUT);

   return $abstract;
   }
## end (sub get_introduction)



#################################################
## Mehrzahl des angegebenen Typs zurueckliefern
#################################################
sub get_type
   {
   local ($type) = @_;
   local ($key);

   foreach $key (sort keys(%types))
      {
      if ($type =~ /$key/i)
         {
         return $types{$key};
         }
      ## end (if)
      }
   ## end (foreach)

   return "Others";
   }
## end (sub type)



#######################################
## Inhaltsangabe erzeugen
#######################################
sub print_inhalt
   {
   local ($type, $key) = @_;     ## Uebergebene Gattung
   local ($work);

   ## Debugging
   if $DEBUG
      {
      print "Inhaltsuebersicht; HTML Seite: ${type}.shtml; ";
      print "KIND: $kind; TYPE: $type\n;";
      }
   ## end (if)

   ## Gewaehrleiste Schreibrechte fuer
   ## die entsprechende Gruppe;
   ## entpricht 775 fuer Verzeichnisse und 
   ## 664 fuer Dateien
   umask 002;

   ## publikationen.shtml erstellen
   open (NAME, ">$HTML_DATA_DIR/${type}.shtml") ||
   die ("\nCan't create $HTML_DATA_DIR/${type}.shtml!\n");

   ## Kopf
   &print_header_inhalt ($type);

   ## Body
   ## Sortiere alle Indexe der Nummer nach aufsteigend
   foreach $ind ( sort { $a <=> $b } keys (%{$type}))
      {
      ## Debugging
      print "$ind: ${$type}{$ind}\n" if $DEBUG;

      ## Zuordnung: index -> key
      $work = ${$type}{$ind};

      ## Debugging
      print "SUCCESS: $work -> $authmap{$work} -> $bibmap{$work}\n"
      if $DEBUG;

      if ( -e "$HTML_DATA_DIR/\u\L$type\E/$work/$work.shtml" )
         {
         ## Debugging
         print "$HTML_DATA_DIR/\u\L$type\E/$work/$work.shtml VORHANDEN\n"
         if $DEBUG;

         &print_body_inhalt ($type, $authmap{$work}, $work, "LINK");
         }
      else
         {
         ## Debugging
         print "$HTML_DATA_DIR/\u\L$type\E/$work/$work.shtml nicht vorhanden\n"
         if $DEBUG;

         &print_body_inhalt ($type, $authmap{$work}, $work, "NOLINK");
         }
      ## end (if)
      }
   ## end (foreach)
         
   ## Fuss
   &print_footer_inhalt;

   close (NAME);
   }
## end (sub print_inhalt)



#########################################
## HTML-Header erzeugen
#########################################
sub print_header
   {
   local ($type, $kind, $work, $output) = @_;
   
   ## Ueberschrift fuer Kopfleiste aus %type holen
   $type = &get_type($type);

   open (NAME , ">$output") || die ("\nCan't create $output!\n");

      print NAME ("<HTML>\n");
      print NAME ("<HEAD>\n");

      ## Kopfleiste
      print NAME ("<TITLE>$type, $work</TITLE>\n");
      print NAME ("</HEAD>\n");

   close (NAME);
   }
## end sub (print_header)



#########################################
## HTML-Body erzeugen
#########################################
sub print_body
   {
   local ($type, $kind, $key, $abstract, $output, $htmlfile) = @_;

   open (NAME, ">>$output") || die ("\nCan't open $output!\n");

      ## Anfang Body
      print NAME ("<BODY>\n");
      print NAME ("<!--\#include virtual=\"/includes/header.shtml\" -->\n");

      ## Autor (Erscheinungsjahr)
      print NAME ("<H2>${$kind}{$key}{author} (${$kind}{$key}{year}):</H2>\n");

      ## Titel
      print NAME ("<H1>${$kind}{$key}{title}</H1>\n");
      print NAME ("<P>\n");

      ## Zusammenfassung
      print NAME ("  $abstract\n");
      print NAME ("</P>\n");
      print NAME ("<HR>\n");
      print NAME ("<UL>\n");

      ## Link zu Postscript-Version
      if ($NO_PSFILE =~ 0)
         {
         print NAME ("  <LI><A HREF = \"Postscript-Version/$key.ps.gz\">");
         print NAME ("GNU-zipped Postscript Version</A>\n");
         print NAME ("    <FONT SIZE=-1>\n");
         printf NAME "      \(%.1f KB\)\n", $size_ps;
         print NAME ("    </FONT>\n");
         }
      ## end (if)

      ## Link zu PDF-Version
      if ($NO_PDFFILE =~ 0)
         {
         print NAME ("  <LI><A HREF = \"PDF-Version/$key.pdf\">");
         print NAME ("PDF Version</A>\n");
         print NAME ("    <FONT SIZE=-1>\n");
         printf NAME "      \(%.1f KB\)\n", $size_pdf;
         print NAME ("    </FONT>\n");
         }
      ## end (if)

      ## Link zu HTML-Version
      if ($NO_TEXFILE =~ 0 && $NO_HTMLFILE =~ 0)
         {
         print NAME ("  <LI><A HREF = \"HTML-Version/$htmlfile\">");
         print NAME ("HTML Version</A>\n");
         }
      ## end (if)

      print NAME ("</UL>\n");
      print NAME ("</P>\n");
   
   close (NAME);
   }
## end sub (print_body)



##########################################
## HTML-Footer erzeugen
##########################################
sub print_footer
   {
   local ($output) = @_;

   open (NAME, ">>$output") || die ("\nCan't open $output!\n");

      print NAME ("<P>\n");
      print NAME ("<HR>\n");
      print NAME ("<FONT SIZE=-1>\n");
      print NAME ("<ADDRESS>\n");

      ($sec, $min, $hour, $tag, $monat, $jahr, @rest) = localtime (time);
      $monat++;

      print NAME ("Created by MNMlit2html, $tag.$monat.$jahr.<BR>\n");
      print NAME ("<!--\#include virtual=\"/includes/trailer.shtml\" -->\n");
      print NAME ("</FONT>\n");
      print NAME ("</BODY>\n");
      print NAME ("</HTML>\n");

   close (NAME);
   }
## end (sub print_footer)



#################################################
## HTML-Header erzeugen -- Inhaltsverzeichnis
#################################################
sub print_header_inhalt
   {
   ## Ueberschrift aus %type holen
   local ($type) = &get_type(@_);

   ## Seitenanfang
   print NAME ("<HTML>\n");
   
   ## Kopf
   print NAME ("<HEAD>\n");
   
   ## Kopfleiste
   print NAME ("<TITLE>$type</TITLE>\n");

   ## Kopf -- Ende
   print NAME ("</HEAD>\n");
   
   ## Angang Body
   print NAME ("<BODY>\n");

   ## Lehrstuhl Kopf
   print NAME ("<!--\#include virtual=\"/includes/header.shtml\" -->\n");

   ## Absatz -- Anfang
   print NAME ("<P>\n");

   ## Titel
   print NAME ("<H1>$type</H1>\n");

   ## Absatz -- Ende
   print NAME ("</P>\n");

   ## Horizontale Linie
   print NAME ("<HR>\n");

   ## Absatz -- Anfang
   print NAME ("<P>\n");
   }
## end (sub print_header_inhalt)



################################################
## HTML-Body erzeugen -- Inhaltsverzeichnis
################################################
sub print_body_inhalt
   {
   local ($type, $kind, $key, $link) = @_;
   local (@to_publish) = eval "\@${kind}_to_publish";
   local ($flag) = 0;

   @to_publish = eval "\@${kind}" if !(@to_publish);

   ## Unnumerierte Liste
   ## <UL type=[circle/square/disk]> ist
   ## Bestandteil von HTML 3.2
   if ($link =~ "^LINK")
      {
      print NAME ("<UL type=disk>\n");
      }
   else
      {
      print NAME ("<UL type=circle>\n");
      }
   ## end (if)

   ## Listeneintrag
   print NAME ("<LI>\n");

   foreach $entrie (@to_publish)
      {
      ## Monatsnamen ausschreiben
      if ("$entrie" =~ /^month$/i)
         {
         ${$kind}{$key}{$entrie} = &substitute_month (${$kind}{$key}{$entrie});
         }
      ## end (if)

      if ($flag == 1 && "${$kind}{$key}{$entrie}" ne "")
         {
            print NAME (", ");
            $flag = 0;
         }
      ## end (if)

      ## Listeneintrag der Form <a name = hkn96>
      if ($entrie =~ /^title/)
         {
         print NAME ("<A NAME = $key>\n");
         }

      ## Listeneintrag mit Link auf die betreffende Arbeit
      if ($entrie =~ /^title/ and $link =~ "^LINK")
         {
         print NAME ("<A HREF = \"\u\L$type\E/$key/$key.shtml\">");
         }

      ## Trage den Titel ein, sofern vorhanden
      if ("${$kind}{$key}{$entrie}" ne "")
         {
         print NAME ("${$kind}{$key}{$entrie}");

         if ($entrie =~ /^title/ and $link =~ "^LINK")
            {
            ## Listeneintrag abgeschlossen durch ',<\A>'
            print NAME (",</A> ");
            
            $flag = 0;
            }
         elsif ($entrie =~ /^title/ and $link =~ "NOLINK")
            {
            ## Listeneintrag, aber kein Link
            ## => Titel mit ',' statt '<\A>' abschliessen
            print NAME (", ");
            
            $flag = 0;
            }
         else
            {
            $flag = 1;
            }
         ## end (if)
         }
      ## end (if)
      }
   ## end (foreach)

   ## Ende der unnumerierten Liste
   print NAME ("\n</UL>\n");
   }
## end (sub print_body_inhalt)



#################################################
## HTML-Footer erzeugen -- Inhaltsverzeichnis
#################################################
sub print_footer_inhalt
   {
   ($sec, $min, $hour, $tag, $monat, $jahr, @rest) = localtime (time);
   $monat++;

   ## Absatz -- Ende
   print NAME ("</P>\n");

   ## Absatz -- Anfang
   print NAME ("<P>\n");

   ## Horizontale Linie 
   print NAME ("<HR>\n");

   ## Kleinerer Font
   print NAME ("<FONT SIZE=-1>\n");

   ## Zusatzangaben
   print NAME ("<ADDRESS>\n");

   ## Informationen zur Seite
   print NAME ("Created by MNMlit2html, $tag.$monat.$jahr.\n");

   ## Zeilenumbruch
   print NAME ("<BR>\n");

   ## Lehrstuhlfuss
   print NAME ("<!--\#include virtual=\"/includes/trailer.shtml\" -->\n");

   ## Kleinerer Font -- Ende
   print NAME ("</FONT>\n");

   ## Absatz -- Ende
   print NAME ("</P>\n");

   ## Body -- Ende
   print NAME ("</BODY>\n");

   ## Seitenende
   print NAME ("</HTML>\n");
   }
## end (sub print_footer_inhalt)

# ########################## end (subroutines) #################################


Copyright Munich Network Management Team