/***************************************************************************
 *   Copyright (C) 2005 by Christian Bucher                                *
 *   christian.bucher@amadyne.net                                          *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/

#define BUFFER_SIZE  1024 
#define TITEL_SIZE   128 
#define SPENDER_SIZE 32
 
#define VCD_NAME  "vcd"
#define SVCD_NAME "svcd"
#define DIVX_NAME "DivX"

// Datumstyp, gültig bis zum Jahr 32767 
 typedef struct
 {
 char  Tag;
 char  Monat;
 short Jahr;
 } T_DATUM;
 
 // Typ für Formate
 typedef enum {unknown, VCD, SVCD, DivX} T_FORMAT;
 typedef enum {Nummer, Titel, PostProc, Spender, Format, Datum} T_FELD;
 
 // Der Datenknoten für Listen und Bäume
 typedef struct DVD_NODE
 {
 union
  {
  struct DVD_NODE *pNext;
  struct DVD_NODE *pLeft;
  };
 union
  {
  struct DVD_NODE *pPrev;
  struct DVD_NODE *pRight;
  };
 int      nNummer;
 char     szTitel[TITEL_SIZE];
 int      nPostProc;
 char     szSpender[SPENDER_SIZE];
 T_FORMAT Format;
 T_DATUM  Datum; 
 } 
 T_DVD_NODE;

//********************** Prototypen **********************
 
// Einen leeren T_DVD_NODE erzeugen
T_DVD_NODE *newDVDNode(void);

// Ein Datenfile von szPath einlesen und
// in single linkes list einsortieren. 
// Liefert den Rootpointer oder NULL
T_DVD_NODE *readDVDFileSingleList(char *szPath);

// Ein Datenfile von szPath einlesen und
// in Binärbaum einsortieren. 
// Liefert den Rootpointer oder NULL
T_DVD_NODE *readDVDFileBinaryTree(char *szPath);

// Supportfunktion einsortieren
T_DVD_NODE *insertDVDBlockBinaryTree(T_DVD_NODE *pRoot, T_DVD_NODE *pNode);

// Baum traversieren
T_DVD_NODE *traverseDVDBinaryTree(T_DVD_NODE *pRoot);

// Einen Datenblock von fh einlesen. 
// Liefert den Blockpointer oder NULL on EOF
T_DVD_NODE *readDVDBlock(FILE *fh);

// Einen Block schön auswerfen
T_DVD_NODE *printDVDBlock(T_DVD_NODE *pNode);

// Liste rekursuiv freigeben 
void freeDVDBlockList(T_DVD_NODE *pNode);

syntax highlighted by Code2HTML, v. 0.9.1