/*
 * ecma119_read.h
 * 
 * Defines structures for reading from a iso image.
 */

#ifndef ECMA119_READ_H_
#define ECMA119_READ_H_

#include <stdint.h>

#include "libisofs.h"

enum read_error {
	LIBISOFS_READ_OK = 0,
	LIBISOFS_READ_FAILURE, /**< Truncated image or read error */
	LIBISOFS_WRONG_PVM, /**< Incorrect PVM */
	LIBISOFS_UNSUPPORTED_IMAGE, /**< Format not supported (interleaved...) */
	LIBISOFS_WRONG_RR /**< Wrong RR/SUSP extension format */ 
};

/**
 * Should the RR extensions be read?
 */
enum read_rr_ext {
	RR_EXT_NO = 0, /*< Do not use RR extensions */
	RR_EXT_110, /*< RR extensions conforming version 1.10 */
	RR_EXT_112  /*< RR extensions conforming version 1.12 */
};

/**
 * Structure that keeps info needed in the read process.
 */
struct iso_read_info {
	struct data_source *src;
	enum read_error error;
	
	uid_t uid; /**< Default uid when no RR */
	gid_t gid; /**< Default uid when no RR */
	mode_t mode; /**< Default mode when no RR (only permissions) */
	
	uint32_t iso_root_block; /**< Will be filled with the block lba of the
	                          *   extend for the root directory, as read from
	                          *   the PVM
	                          */
	
	enum read_rr_ext rr; /*< If we need to read RR extensions. i.e., if the image
	         *  contains RR extensions, and the user wants to read them. */
	
	char *(*get_name)(const char *, size_t);
		/**<
		 * The function used to read the name from a directoy record. For
		 * ISO, the name is in US-ASCII. For Joliet, in UCS-2BE. Thus, we
		 * need different functions for both.
		 */
	 
	ino_t ino; /*< Joliet and RR version 1.10 does not have file serial numbers, 
	            * we need to generate it.  */
	uint8_t len_skp; /*< bytes skipped within the System Use field of a
	                     directory record, before the beginning of the SUSP
	                     system user entries. See IEEE 1281, SUSP. 5.3. */
	                     
	unsigned int norock:1; /*< Do not read Rock Ridge extensions */
	unsigned int hasRR:1;  /*< It will be set to 1 if RR extensions are present,
	                           to 0 if not. */
	unsigned int hasJoliet:1; /*< It will be set to 1 if Joliet ext are present,
	                              to 0 if not. */
	uint32_t *size; 
	
	/* place for el-torito boot catalog */
	struct el_torito_boot_catalog *bootcat;
};



#endif /*ECMA119_READ_H_*/
