/*
 * (C) Copyright 2001
 * Denis Peter, MPL AG Switzerland, d.peter@mpl.ch.
 *
 * See file CREDITS for list of people who contributed to this
 * project.
 *
 * 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
 */
#ifndef _PART_CD_H
#define _PART_CD_H

#define BRVD	0x11
#define PVD_OFFSET 0x10


typedef struct iso_boot_rec {
	unsigned char desctype;			/* type of Volume descriptor: 0 = boot record, 1 = primary, 2 = Supplement, 3 = volume part 0xff trminator */
	unsigned char stand_ident[5]; /* "CD001" */
	unsigned char vers;					/* Version */
	char					ident_str[0x20]; /* Ident String "EL TORITO SPECIFICATION" */
	unsigned char unused[0x20];		/* unused */
	unsigned char pointer[4];		/* absolute pointer to Boot Catalog */
} iso_boot_rec_t;


typedef struct iso_pri_rec {
	unsigned char desctype;			/* type of Volume descriptor: 0 = boot record, 1 = primary, 2 = Supplement, 3 = volume part 0xff trminator */
	unsigned char stand_ident[5]; /* "CD001" */
	unsigned char vers;					/* Version */
 	unsigned char unused;
 	char 					sysid[32];		/* system Identifier */
	char					volid[32];		/* volume Identifier */
	unsigned char zeros1[8];		/* unused */
	unsigned long volsiz_LE;		/* volume size Little Endian */
	unsigned long volsiz_BE;		/* volume size Big Endian */
	unsigned char zeros2[32];		/* unused */
	unsigned short setsize_LE;	/* volume set size LE */
	unsigned short setsize_BE;	/* volume set size BE */
	unsigned short seqnum_LE;		/* volume sequence number LE */
	unsigned short seqnum_BE;		/* volume sequence number BE */
	unsigned short secsize_LE;	/* sector size LE */
	unsigned short secsize_BE;	/* sector size BE */
	unsigned long pathtablen_LE;/* Path Table size LE */
	unsigned long pathtablen_BE;/* Path Table size BE */
	unsigned long firstsek_LEpathtab1_LE; /* location of first occurrence of little endian type path table */
 	unsigned long firstsek_LEpathtab2_LE; /* location of optional occurrence of little endian type path table */
 	unsigned long firstsek_BEpathtab1_BE; /* location of first occurrence of big endian type path table */
 	unsigned long firstsek_BEpathtab2_BE; /* location of optional occurrence of big endian type path table */
 	unsigned char rootdir[34];	/* directory record for root dir */
 	char 					volsetid[128];/* Volume set identifier */
 	char					pubid[128];		/* Publisher identifier */
 	char 					dataprepid[128]; /* data preparer identifier */
 	char 					appid[128];		/* application identifier */
 	char 					copyr[37];		/* copyright string */
 	char 					abstractfileid[37]; /* abstract file identifier */
 	char					bibliofileid[37]; /* bibliographic file identifier */
 	unsigned char creationdate[17]; /* creation date */
 	unsigned char modify[17];		/* modification date */
 	unsigned char expire[17];		/* expiring date */
 	unsigned char effective[17];/* effective date */
 	unsigned char filestruc_ver;	/* file structur version */
} iso_pri_rec_t;

typedef struct iso_sup_rec {
	unsigned char desctype;			/* type of Volume descriptor: 0 = boot record, 1 = primary, 2 = Supplement, 3 = volume part 0xff trminator */
	unsigned char stand_ident[5]; /* "CD001" */
	unsigned char vers;					/* Version */
 	unsigned char volumeflags;	/* if bit 0 = 0 => all escape sequences are according ISO 2375 */
 	char 					sysid[32];		/* system Identifier */
	char					volid[32];		/* volume Identifier */
	unsigned char zeros1[8];		/* unused */
 	unsigned long volsiz_LE;		/* volume size Little Endian */
 	unsigned long volsiz_BE;		/* volume size Big Endian */
 	unsigned char escapeseq[32];/* Escape sequences */
	unsigned short setsize_LE;	/* volume set size LE */
 	unsigned short setsize_BE;	/* volume set size BE */
 	unsigned short seqnum_LE;		/* volume sequence number LE */
 	unsigned short seqnum_BE;		/* volume sequence number BE */
 	unsigned short secsize_LE;	/* sector size LE */
 	unsigned short secsize_BE;	/* sector size BE */
	unsigned long pathtablen_LE;/* Path Table size LE */
	unsigned long pathtablen_BE;/* Path Table size BE */
	unsigned long firstsek_LEpathtab1_LE; /* location of first occurrence of little endian type path table */
 	unsigned long firstsek_LEpathtab2_LE; /* location of optional occurrence of little endian type path table */
 	unsigned long firstsek_BEpathtab1_BE; /* location of first occurrence of big endian type path table */
 	unsigned long firstsek_BEpathtab2_BE; /* location of optional occurrence of big endian type path table */
 	unsigned char rootdir[34];	/* directory record for root dir */
 	char 					volsetid[128];/* Volume set identifier */
 	char					pubid[128];		/* Publisher identifier */
 	char 					dataprepid[128]; /* data preparer identifier */
 	char 					appid[128];		/* application identifier */
 	char 					copyr[37];		/* copyright string */
 	char 					abstractfileid[37]; /* abstract file identifier */
 	char					bibliofileid[37]; /* bibliographic file identifier */
 	unsigned char creationdate[17]; /* creation date */
 	unsigned char modify[17];		/* modification date */
 	unsigned char expire[17];		/* expiring date */
 	unsigned char effective[17];/* effective date */
 	unsigned char filestruc_ver;	/* file structur version */
}iso_sup_rec_t;

typedef struct iso_part_rec {
	unsigned char desctype;			/* type of Volume descriptor: 0 = boot record, 1 = primary, 2 = Supplement, 3 = volume part 0xff trminator */
	unsigned char stand_ident[5]; /* "CD001" */
	unsigned char vers;					/* Version */
 	unsigned char unused;
 	char 					sysid[32];		 /* system Identifier */
	char					volid[32]; 		/* volume partition Identifier */
	unsigned long partloc_LE;		/* volume partition location LE */
	unsigned long partloc_BE;		/* volume partition location BE */
	unsigned long partsiz_LE;		/* volume partition size LE */
	unsigned long partsiz_BE;		/* volume partition size BE */
}iso_part_rec_t;




typedef struct iso_val_entry {
	unsigned char	header_id;		/* Header ID must be 0x01 */
	unsigned char	platform;			/* Platform: 0=x86, 1=PowerPC, 2=MAC */
	unsigned char res[2];				/* reserved */
	char 					manu_str[0x18]; /* Ident String of manufacturer/developer */
	unsigned char chk_sum[2]; 	/* Check sum (all words must be zero)  */
	unsigned char key[2];				/* key[0]=55, key[1]=0xAA */
} iso_val_entry_t;

typedef struct iso_header_entry {
	unsigned char	header_id;		/* Header ID must be 0x90 or 0x91 */
	unsigned char	platform;			/* Platform: 0=x86, 1=PowerPC, 2=MAC */
	unsigned char numentry[2];	/* number of entries */
	char 					id_str[0x1C]; /* Ident String of sectionr */
} iso_header_entry_t;


typedef struct iso_init_def_entry {
	unsigned char	boot_ind;			/* Boot indicator 0x88=bootable 0=not bootable */
	unsigned char	boot_media;		/* boot Media Type: 0=no Emulation, 1=1.2MB floppy, 2=1.44MB floppy, 3=2.88MB floppy 4=hd (0x80) */
	unsigned char ld_seg[2];		/* Load segment (flat model=addr/10) */
	unsigned char systype; 			/* System Type copy of byte5 of part table */
	unsigned char res;					/* reserved */
	unsigned char sec_cnt[2];		/* sector count in VIRTUAL Blocks (0x200) */
	unsigned char rel_block_addr[4];	/* relative Block address */
} iso_init_def_entry_t;


void print_partition_cd(int dev);








#endif /* _PART_CD_H */


