#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif

#include <stdio.h>
#include <malloc.h>
#include <string.h>

#include <getopt.h>
#include <stdlib.h>
#include <vdr/interface.h>
#include <vdr/plugin.h>
#include <unistd.h>
#include "menu.h"
#include "config.h"
#include "cProjektStarter.h"
#include "cMenuAufnahmeAuswahl.h"

// --- cProjektStarter --------------------------------------------------------
cProjektStarter::cProjektStarter()
{
  printf("\nStarter - init\n");
  fflush(NULL);
  init();
  printf("Starter - umgebungsVariablenSetzen\n");
  fflush(NULL);
  umgebungsVariablenSetzen();
  printf("Starter - starten\n");
  fflush(NULL);
  starten();
}

void cProjektStarter::umgebungsVariablenSetzen(){
  char tmp[MaxFileName];

  setenv("VDRROOT",VDRROOT,1);
  setenv("DESTDIR",DESTDIR,1);
  setenv("CONVERT_JOBS",CONVERT_JOBS,1);
  setenv("VDRSYNC",VDRSYNC,1);
  setenv("TCMPLEX",TCMPLEX,1);
  setenv("TCMPLEX_PANTELTJE",TCMPLEX_PANTELTJE,1);
  setenv("DVBMPLEX",DVBMPLEX,1);
  setenv("MPLEX",MPLEX,1);
  setenv("MKISOFS",MKISOFS,1);
  setenv("MENCODER",MENCODER,1);
  setenv("LAME",LAME,1);
  setenv("DVDAUTHOR",DVDAUTHOR,1);
  setenv("TOSVCD",TOSVCD,1);
  setenv("TEMPDIR",TEMPDIR,1);
  setenv("LOGDIR",LOGDIR,1);
  setenv("SVDRPSEND",SVDRPSEND,1);
  setenv("PARQ",PARQ,1);
  setenv("COMPRESS",COMPRESS,1);
  sprintf(tmp,"%d",DEBUG);
  setenv("DEBUG",tmp,1);
  sprintf(tmp,"%d",PRIO);
  setenv("PRIO",tmp,1);
  sprintf(tmp,"%d",SLEEP_TIME);
  setenv("SLEEP_TIME",tmp,1);
  sprintf(tmp,"%d",CONV_TITLEDATE);
  setenv("CONV_TITLEDATE",tmp,1);
  setenv("DVD_DESTDIR",DVD_DESTDIR,1);
  setenv("DVDTCMPLEXOPTS",DVDTCMPLEXOPTS,1);
  setenv("DVD_DVBMPLEXOPTS",DVD_DVBMPLEXOPTS,1);
  setenv("DVDALLOWEDWIDTH",DVDALLOWEDWIDTH,1);
  setenv("DVDTRANSCODEOPTS",DVDTRANSCODEOPTS,1);
  setenv("PPMTOY4M_OPTIONS",PPMTOY4M_OPTIONS,1);
  setenv("DVDTRANSCODEBITRATE",DVDTRANSCODEBITRATE,1);
  setenv("DVDAUTHORUSERCHAP",DVDAUTHORUSERCHAP,1);
  setenv("DVDUSESTREAMS",DVDUSESTREAMS,1);
  sprintf(tmp,"%d",DVDREMOVEAUTHORDIR);
  setenv("DVDREMOVEAUTHORDIR",tmp,1);
  sprintf(tmp,"%d",DVDSIZE);
  setenv("DVDSIZE",tmp,1);
  sprintf(tmp,"%d",CDSIZE);
  setenv("CDSIZE",tmp,1);
  setenv("DVDNORM",DVDNORM,1);
  setenv("DVDMAINSILENCEFILE",DVDMAINSILENCEFILE,1);
  setenv("DVDSUBSILENCEFILE",DVDSUBSILENCEFILE,1);
  setenv("DVDTEXTPLAYMOVIE",DVDTEXTPLAYMOVIE,1);
  setenv("DVDTEXTMENU",DVDTEXTMENU,1);
  setenv("DVDMAINMENUEPOSTACTION",DVDMAINMENUEPOSTACTION,1);
  setenv("DVDMENUEPOSTACTION",DVDMENUEPOSTACTION,1);
  setenv("DVDBUTTONCOLOR",DVDBUTTONCOLOR,1);
  setenv("DVDSUBBUTTONCOLOR",DVDSUBBUTTONCOLOR,1);
  setenv("DVDHIBUTTON2COLOR_MENU",DVDHIBUTTON2COLOR_MENU,1);
  setenv("DVDHIBUTTONCOLOR_MENU",DVDHIBUTTONCOLOR_MENU,1);
  setenv("DVDHIBUTTONCOLOR_SUBMENU",DVDHIBUTTONCOLOR_SUBMENU,1);
  setenv("DVDHIBUTTON2COLOR_SUBMENU",DVDHIBUTTON2COLOR_SUBMENU,1);
  setenv("DVDFILE_MAINBACKGROUND_COLOR",DVDFILE_MAINBACKGROUND_COLOR,1);
  setenv("DVDFILE_SUBBACKGROUND_COLOR",DVDFILE_SUBBACKGROUND_COLOR,1);
  setenv("DVDTEXTCOLOR_MENU",DVDTEXTCOLOR_MENU,1);
  setenv("DVDTEXTCOLOR_SUBMENU",DVDTEXTCOLOR_SUBMENU,1);
  sprintf(tmp,"%d",DVDMENU_SHADOW);
  setenv("DVDMENU_SHADOW",tmp,1);
  setenv("DVDMAINCOLSFG",DVDMAINCOLSFG,1);
  setenv("DVDMAINCOLSBG",DVDMAINCOLSBG,1);
  setenv("DVDSUBCOLSFG",DVDSUBCOLSFG,1);
  setenv("DVDSUBCOLSBG",DVDSUBCOLSBG,1);
  sprintf(tmp,"%d",DVDMAINMENUETIMEOUT);
  setenv("DVDMAINMENUETIMEOUT",tmp,1);
  sprintf(tmp,"%d",DVDMENUETIMEOUT);
  setenv("DVDMENUETIMEOUT",tmp,1);
  setenv("MP3_DESTDIR",MP3_DESTDIR ,1);
  setenv("MP3_OPTS",MP3_OPTS ,1);
  sprintf(tmp,"%d",MP3_SPLIT);
  setenv("MP3_SPLIT",tmp,1);
  setenv("MPLAYERMP3SOURCE",MPLAYERMP3SOURCE ,1);
  setenv("MP3_TITLEDATE",MP3_TITLEDATE ,1);
  sprintf(tmp,"%d",MP3_USE_MPG123);
  setenv("MP3_USE_MPG123",tmp,1);
  setenv("MP3USESTREAMS",MP3USESTREAMS ,1);

  char *datei;
  asprintf(&datei,"%s",VdrconvertSetup.gibDateiname(VdrconvertSetup.aktProjekttyp));
  FILE *fi = fopen (datei, "r");
  char *s;
  int zaehler=0;
  if (fi!=NULL){
#if VDRVERSNUM >= 10318
        cReadLine r;
    while ((s = r.Read(fi)) != NULL) {
#else
    while ((s=readline(fi))!=NULL){
#endif
      zaehler++;
      sprintf(tmp,"DATEINAME[%d]",zaehler);
      setenv("tmp",s,1);
    }//while
  }else{//if
    FILE *fi = fopen (datei, "w");//Datei anlegen
    //TODO Fehlerabfrage
    fclose(fi);
  }//else

  free(datei);
  sprintf(tmp,"%d",zaehler);
  setenv("ANZAHL_AUFNAHMEN",tmp,1);
}

void cProjektStarter::starten(){
  if (!fork()) { /* das hier macht nur der neu erzeugte prozess */
    daemon(0,1);
    printf(">%d<\t",execl("/usr/src/vdr/vdr/PLUGINS/src/vdrconvert/","test.sh",NULL));
    printf(">%s<\n",strerror(errno));
    exit(1); /* nur falls das fork nicht funktioniert */
  } /* if (!fork()): das hier macht nur der neu erzeugte prozess */
}

void cProjektStarter::init(){
  //cVdrconvertSetup data;
  //INIT Anfang
  //TODO Projekttyp-Abhaengigkeit einbauen

  //Allgemeines
  strcpy(VDRROOT,VdrconvertSetup.VDRROOT);
  strcpy(DESTDIR,VdrconvertSetup.DESTDIR);
  strcpy(CONVERT_JOBS,VdrconvertSetup.CONVERT_JOBS);
  strcpy(VDRSYNC,VdrconvertSetup.VDRSYNC);
  strcpy(TCMPLEX,VdrconvertSetup.TCMPLEX);
  strcpy(TCMPLEX_PANTELTJE,VdrconvertSetup.TCMPLEX_PANTELTJE);
  strcpy(DVBMPLEX,VdrconvertSetup.DVBMPLEX);
  strcpy(MPLEX,VdrconvertSetup.MPLEX);
  strcpy(MKISOFS,VdrconvertSetup.MKISOFS);
  strcpy(MENCODER,VdrconvertSetup.MENCODER);
  strcpy(LAME,VdrconvertSetup.LAME);
  strcpy(DVDAUTHOR,VdrconvertSetup.DVDAUTHOR);
  strcpy(TOSVCD,VdrconvertSetup.TOSVCD);
  strcpy(TEMPDIR,VdrconvertSetup.TEMPDIR);
  strcpy(LOGDIR,VdrconvertSetup.LOGDIR);
  strcpy(SVDRPSEND,VdrconvertSetup.SVDRPSEND);
  strcpy(PARQ,VdrconvertSetup.PARQ);
  strcpy(COMPRESS,VdrconvertSetup.COMPRESS);
  DEBUG=VdrconvertSetup.DEBUG;
  PRIO=VdrconvertSetup.PRIO;
  SLEEP_TIME=VdrconvertSetup.SLEEP_TIME;
  CONV_TITLEDATE=VdrconvertSetup.CONV_TITLEDATE;

  //DVD-Variablen
  strcpy(DVD_DESTDIR,VdrconvertSetup.DVD_DESTDIR);
  strcpy(DVDTCMPLEXOPTS,VdrconvertSetup.DVDTCMPLEXOPTS);
  strcpy(DVD_DVBMPLEXOPTS,VdrconvertSetup.DVD_DVBMPLEXOPTS);
  strcpy(DVDALLOWEDWIDTH,VdrconvertSetup.DVDALLOWEDWIDTH);
  strcpy(DVDTRANSCODEOPTS,VdrconvertSetup.DVDTRANSCODEOPTS);
  strcpy(PPMTOY4M_OPTIONS,VdrconvertSetup.PPMTOY4M_OPTIONS);
  strcpy(DVDTRANSCODEBITRATE,VdrconvertSetup.DVDTRANSCODEBITRATE);
  strcpy(DVDAUTHORUSERCHAP,VdrconvertSetup.DVDAUTHORUSERCHAP);
  strcpy(DVDUSESTREAMS,VdrconvertSetup.DVDUSESTREAMS);
  DVDREMOVEAUTHORDIR=VdrconvertSetup.DVDREMOVEAUTHORDIR;
  DVDSIZE=VdrconvertSetup.DVDSIZE;
  CDSIZE=VdrconvertSetup.CDSIZE;
  strcpy(DVDNORM,VdrconvertSetup.DVDNORM);
  strcpy(DVDMAINSILENCEFILE,VdrconvertSetup.DVDMAINSILENCEFILE);
  strcpy(DVDSUBSILENCEFILE,VdrconvertSetup.DVDSUBSILENCEFILE);
  strcpy(DVDTEXTPLAYMOVIE,VdrconvertSetup.DVDTEXTPLAYMOVIE);
  strcpy(DVDTEXTMENU,VdrconvertSetup.DVDTEXTMENU);
  strcpy(DVDMAINMENUEPOSTACTION,VdrconvertSetup.DVDMAINMENUEPOSTACTION);
  strcpy(DVDMENUEPOSTACTION,VdrconvertSetup.DVDMENUEPOSTACTION);
  strcpy(DVDBUTTONCOLOR,VdrconvertSetup.DVDBUTTONCOLOR);
  strcpy(DVDSUBBUTTONCOLOR,DVDBUTTONCOLOR);
  strcpy(DVDHIBUTTON2COLOR_MENU,VdrconvertSetup.DVDHIBUTTON2COLOR_MENU);
  strcpy(DVDHIBUTTONCOLOR_MENU,VdrconvertSetup.DVDHIBUTTONCOLOR_MENU);
  strcpy(DVDHIBUTTONCOLOR_SUBMENU,DVDHIBUTTONCOLOR_MENU);
  strcpy(DVDHIBUTTON2COLOR_SUBMENU,DVDHIBUTTON2COLOR_MENU);
  strcpy(DVDFILE_MAINBACKGROUND_COLOR,VdrconvertSetup.DVDFILE_MAINBACKGROUND_COLOR);
  strcpy(DVDFILE_SUBBACKGROUND_COLOR,DVDFILE_MAINBACKGROUND_COLOR);
  strcpy(DVDTEXTCOLOR_MENU,VdrconvertSetup.DVDTEXTCOLOR_MENU);
  strcpy(DVDTEXTCOLOR_SUBMENU,DVDTEXTCOLOR_MENU);
  DVDMENU_SHADOW=VdrconvertSetup.DVDMENU_SHADOW;
  strcpy(DVDMAINCOLSFG,VdrconvertSetup.DVDMAINCOLSFG);
  strcpy(DVDMAINCOLSBG,VdrconvertSetup.DVDMAINCOLSBG);
  strcpy(DVDSUBCOLSFG,DVDMAINCOLSFG);
  strcpy(DVDSUBCOLSBG,DVDMAINCOLSBG);
  DVDMAINMENUETIMEOUT=VdrconvertSetup.DVDMAINMENUETIMEOUT;
  DVDMENUETIMEOUT=VdrconvertSetup.DVDMENUETIMEOUT;

  //MP3-Variablen
  strcpy(MP3_DESTDIR,VdrconvertSetup.MP3_DESTDIR);
  strcpy(MP3_OPTS,VdrconvertSetup.MP3_OPTS);
  MP3_SPLIT=VdrconvertSetup.MP3_SPLIT;
  strcpy(MPLAYERMP3SOURCE,VdrconvertSetup.MPLAYERMP3SOURCE);
  strcpy(MP3_TITLEDATE,VdrconvertSetup.MP3_TITLEDATE);
  MP3_USE_MPG123=VdrconvertSetup.MP3_USE_MPG123;
  strcpy(MP3USESTREAMS,VdrconvertSetup.MP3USESTREAMS);

}


void cProjektStarter::konfigurationAuslesen(){

  char *datei;
  asprintf(&datei,"%s.setup",VdrconvertSetup.gibDateiname(VdrconvertSetup.aktProjekttyp));
  FILE *fi = fopen (datei, "r");
  char *s;
  
  
  //INIT Ende

  if (fi!=NULL){
#if VDRVERSNUM >= 10318
        cReadLine r;
    while ((s = r.Read(fi)) != NULL) {
#else
    while ((s=readline(fi))!=NULL){
#endif
      char *p = strchr(s, '=');
      if (p) {
	*p = 0;
	char *Name  = compactspace(s);
	char *Value = compactspace(p + 1);
  //Allgemeines
	if (!strcasecmp(Name, "VDRROOT")) {  strn0cpy(VDRROOT, Value, MaxFileName);
	} else if (!strcasecmp(Name, "DESTDIR")) {  strn0cpy(DESTDIR, Value, MaxFileName);
	} else if (!strcasecmp(Name, "CONVERT_JOBS")) {  strn0cpy(CONVERT_JOBS, Value, MaxFileName);
	} else if (!strcasecmp(Name, "VDRSYNC")) {  strn0cpy(VDRSYNC, Value, MaxFileName);
	} else if (!strcasecmp(Name, "TCMPLEX")) {  strn0cpy(TCMPLEX, Value, MaxFileName);
	} else if (!strcasecmp(Name, "TCMPLEX_PANTELTJE")) {  strn0cpy(TCMPLEX_PANTELTJE, Value, MaxFileName);
	} else if (!strcasecmp(Name, "DVBMPLEX")) {  strn0cpy(DVBMPLEX, Value, MaxFileName);
	} else if (!strcasecmp(Name, "MPLEX")) {  strn0cpy(MPLEX, Value, MaxFileName);
	} else if (!strcasecmp(Name, "MKISOFS")) {  strn0cpy(MKISOFS, Value, MaxFileName);
	} else if (!strcasecmp(Name, "MENCODER")) {  strn0cpy(MENCODER, Value, MaxFileName);
	} else if (!strcasecmp(Name, "LAME")) {  strn0cpy(LAME, Value, MaxFileName);
	} else if (!strcasecmp(Name, "DVDAUTHOR")) {  strn0cpy(DVDAUTHOR, Value, MaxFileName);
	} else if (!strcasecmp(Name, "TOSVCD")) {  strn0cpy(TOSVCD, Value, MaxFileName);
	} else if (!strcasecmp(Name, "TEMPDIR")) {  strn0cpy(TEMPDIR, Value, MaxFileName);
	} else if (!strcasecmp(Name, "LOGDIR")) {  strn0cpy(LOGDIR, Value, MaxFileName);
	} else if (!strcasecmp(Name, "SVDRPSEND")) {  strn0cpy(SVDRPSEND, Value, MaxFileName);
	} else if (!strcasecmp(Name, "PARQ")) {  strn0cpy(PARQ, Value, MaxFileName);
	} else if (!strcasecmp(Name, "COMPRESS")) {  strn0cpy(COMPRESS, Value, MaxFileName);
	} else if (!strcasecmp(Name, "DEBUG")) { DEBUG=atoi(Value);
	} else if (!strcasecmp(Name, "PRIO")) {  PRIO=atoi(Value);
	} else if (!strcasecmp(Name, "SLEEP_TIME")) {  SLEEP_TIME=atoi(Value);
	} else if (!strcasecmp(Name, "CONV_TITLEDATE")) {  CONV_TITLEDATE=atoi(Value);
	//DVD-Parameter
	} else if (!strcasecmp(Name, "DVD_DESTDIR")) {  strn0cpy(DVD_DESTDIR, Value, MaxFileName);
	} else if (!strcasecmp(Name, "DVDTCMPLEXOPTS")) {  strn0cpy(DVDTCMPLEXOPTS, Value, MaxFileName);
	} else if (!strcasecmp(Name, "DVD_DVBMPLEXOPTS")) {  strn0cpy(DVD_DVBMPLEXOPTS, Value, MaxFileName);
	} else if (!strcasecmp(Name, "DVDALLOWEDWIDTH")) {  strn0cpy(DVDALLOWEDWIDTH, Value, MaxFileName);
	} else if (!strcasecmp(Name, "DVDTRANSCODEOPTS")) {  strn0cpy(DVDTRANSCODEOPTS, Value, MaxFileName);
	} else if (!strcasecmp(Name, "PPMTOY4M_OPTIONS")) {  strn0cpy(PPMTOY4M_OPTIONS, Value, MaxFileName);
	} else if (!strcasecmp(Name, "DVDTRANSCODEBITRATE")) {  strn0cpy(DVDTRANSCODEBITRATE, Value, MaxFileName);
	} else if (!strcasecmp(Name, "DVDAUTHORUSERCHAP")) {  strn0cpy(DVDAUTHORUSERCHAP, Value, MaxFileName);
	} else if (!strcasecmp(Name, "DVDUSESTREAMS")) {  strn0cpy(DVDUSESTREAMS, Value, MaxFileName);
	} else if (!strcasecmp(Name, "DVDREMOVEAUTHORDIR")) {  DVDREMOVEAUTHORDIR=atoi(Value);
	} else if (!strcasecmp(Name, "DVDSIZE")) {  DVDSIZE=atoi(Value);
	} else if (!strcasecmp(Name, "CDSIZE")) {  CDSIZE=atoi(Value);
	} else if (!strcasecmp(Name, "DVDNORM")) {  strn0cpy(DVDNORM, Value, MaxFileName);
	} else if (!strcasecmp(Name, "DVDMAINSILENCEFILE")) {  strn0cpy(DVDMAINSILENCEFILE, Value, MaxFileName);
	} else if (!strcasecmp(Name, "DVDSUBSILENCEFILE")) {  strn0cpy(DVDSUBSILENCEFILE, Value, MaxFileName);
	} else if (!strcasecmp(Name, "DVDTEXTPLAYMOVIE")) {  strn0cpy(DVDTEXTPLAYMOVIE, Value, MaxFileName);
	} else if (!strcasecmp(Name, "DVDTEXTMENU")) {  strn0cpy(DVDTEXTMENU, Value, MaxFileName);
	} else if (!strcasecmp(Name, "DVDMAINMENUEPOSTACTION")) {  strn0cpy(DVDMAINMENUEPOSTACTION, Value, MaxFileName);
	} else if (!strcasecmp(Name, "DVDMENUEPOSTACTION")) {  strn0cpy(DVDMENUEPOSTACTION, Value, MaxFileName);
	} else if (!strcasecmp(Name, "DVDBUTTONCOLOR")) {  strn0cpy(DVDBUTTONCOLOR, Value, MaxFileName);
	} else if (!strcasecmp(Name, "DVDSUBBUTTONCOLOR")) {  strn0cpy(DVDSUBBUTTONCOLOR, Value, MaxFileName);
	} else if (!strcasecmp(Name, "DVDHIBUTTON2COLOR_MENU")) {  strn0cpy(DVDHIBUTTON2COLOR_MENU, Value, MaxFileName);
	} else if (!strcasecmp(Name, "DVDHIBUTTONCOLOR_MENU")) {  strn0cpy(DVDHIBUTTONCOLOR_MENU, Value, MaxFileName);
	} else if (!strcasecmp(Name, "DVDHIBUTTONCOLOR_SUBMENU")) {  strn0cpy(DVDHIBUTTONCOLOR_SUBMENU, Value, MaxFileName);
	} else if (!strcasecmp(Name, "DVDHIBUTTON2COLOR_SUBMENU")) {  strn0cpy(DVDHIBUTTON2COLOR_SUBMENU, Value, MaxFileName);
	} else if (!strcasecmp(Name, "DVDFILE_MAINBACKGROUND_COLOR")) {  strn0cpy(DVDFILE_MAINBACKGROUND_COLOR, Value, MaxFileName);
	} else if (!strcasecmp(Name, "DVDFILE_SUBBACKGROUND_COLOR")) {  strn0cpy(DVDFILE_SUBBACKGROUND_COLOR, Value, MaxFileName);
	} else if (!strcasecmp(Name, "DVDTEXTCOLOR_MENU")) {  strn0cpy(DVDTEXTCOLOR_MENU, Value, MaxFileName);
	} else if (!strcasecmp(Name, "DVDTEXTCOLOR_SUBMENU")) {  strn0cpy(DVDTEXTCOLOR_SUBMENU, Value, MaxFileName);
	} else if (!strcasecmp(Name, "DVDMENU_SHADOW")) {  DVDMENU_SHADOW=atoi(Value);
	} else if (!strcasecmp(Name, "DVDMAINCOLSFG")) {  strn0cpy(DVDMAINCOLSFG, Value, MaxFileName);
	} else if (!strcasecmp(Name, "DVDMAINCOLSBG")) {  strn0cpy(DVDMAINCOLSBG, Value, MaxFileName);
	} else if (!strcasecmp(Name, "DVDSUBCOLSFG")) {  strn0cpy(DVDSUBCOLSFG, Value, MaxFileName);
	} else if (!strcasecmp(Name, "DVDSUBCOLSBG")) {  strn0cpy(DVDSUBCOLSBG, Value, MaxFileName);
	} else if (!strcasecmp(Name, "DVDMAINMENUETIMEOUT")) {  DVDMAINMENUETIMEOUT=atoi(Value);
	} else if (!strcasecmp(Name, "DVDMENUETIMEOUT")) {  DVDMENUETIMEOUT=atoi(Value);
	//MP3-Variablen
	} else if (!strcasecmp(Name, "MP3_DESTDIR")) { strn0cpy(MP3_DESTDIR ,Value, MaxFileName);
	} else if (!strcasecmp(Name, "MP3_OPTS")) { strn0cpy(MP3_OPTS ,Value, MaxFileName);
	} else if (!strcasecmp(Name, "MP3_SPLIT")) { MP3_SPLIT=atoi(Value);
	} else if (!strcasecmp(Name, "MPLAYERMP3SOURCE")) { strn0cpy(MPLAYERMP3SOURCE ,Value, MaxFileName);
	} else if (!strcasecmp(Name, "MP3_TITLEDATE")) { strn0cpy(MP3_TITLEDATE ,Value, MaxFileName);
	} else if (!strcasecmp(Name, "MP3_USE_MPG123")) { MP3_USE_MPG123=atoi(Value);
	} else if (!strcasecmp(Name, "MP3USESTREAMS")) { strn0cpy(MP3USESTREAMS ,Value, MaxFileName);
	}//else if
      }//if
    }//while
  }else{//if
    fclose(fi);
  }//else
  
  //Display();
  free(datei);
}
