legacy/libisoburn/trunk/src/libisoburn.h

340 lines
14 KiB
C

/*
API definition of libisoburn.
Copyright 2007 Vreixo Formoso Lopes <metalpain2002@yahoo.es>
and Thomas Schmitt <scdbackup@gmx.net>
*/
/**
libisoburn is a frontend for libraries libburn and libisofs which enables
creation and expansion of ISO-9660 filesystems on all CD/DVD media supported
by libburn. This includes media like DVD+RW, which do not support multi-session
management on media level and even plain disk files or block devices.
The price for that is thorough specialization on data files in ISO-9660
filesystem images. So libisoburn is not suitable for audio (CD-DA) or any
other CD layout which does not entirely consist of ISO-9660 sessions.
The priciple of this frontend is that you may use any call of libisofs or
libburn unless it has a isoburn_*() wrapper listed in the following function
documentation.
E.g. call isoburn_initialize() rather than iso_init(); burn_initialize()
and call isoburn_drive_scan_and_grab() rather than burn_drive_scan_and_grab().
But you may call burn_disc_get_profile() directly if you want to display
the media type.
>>>
>>> Take into respect Vreixo's (mandatory ?) shortcuts which are to come
>>>
The usage model is like with libburn: the target is a "media" in a "drive".
The wrappers will transparently provide the necessary emulations which
are appropriate for particular target "drives".
*/
/* API functions */
/** Initialize libisoburn, libisofs and libburn.
Wrapper for : iso_init() and burn_initialize()
@return 1 indicates success, 0 is failure
*/
int isoburn_initialize(void);
/** Aquire a target drive by its filesystem path resp. libburn persistent
address.
Wrapper for: burn_drive_scan_and_grab()
*/
int isoburn_drive_scan_and_grab(struct burn_drive_info *drive_infos[],
char* adr, int load);
/** Aquire a drive from the burn_drive_info[] array which was obtained by
a previous call of burn_drive_scan().
Wrapper for: burn_drive_grab()
*/
int isoburn_drive_grab(struct burn_drive *drive, int load);
/** Inquire the media status. Expect the whole spectrum of libburn BURN_DISC_*
with multi-session media. Emulated states with random access media are
BURN_DISC_BLANK and BURN_DISC_APPENDABLE.
Wrapper for: burn_disc_get_status()
*/
enum burn_disc_status isoburn_disc_get_status(struct burn_drive *drive);
/** Tells whether the media can be treated by isoburn_disc_erase().
Wrapper for: burn_disc_erasable()
*/
int isoburn_disc_erasable(struct burn_drive *d);
/** Mark the media as blank. With multi-session media this will call
burn_disc_erase(). With random access media, an eventual ISO-9660
filesystem will get invalidated by altering its start blocks on media.
In case of success, the media is in status BURN_DISC_BLANK afterwards.
Wrapper for: burn_disc_erase()
*/
void isoburn_disc_erase(struct burn_drive *drive, int fast);
/**
* Options for image reading.
*/
struct isoburn_read_opts {
unsigned int norock:1; /*< Do not read Rock Ridge extensions */
unsigned int nojoliet:1; /*< Do not read Joliet extensions */
unsigned int preferjoliet:1;
/*< When both Joliet and RR extensions are present, the RR
* tree is used. If you prefer using Joliet, set this to 1. */
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) */
/* modified by the function isoburn_read_volset */
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 extensions are
present, to 0 if not. */
uint32_t size; /**< Will be filled with the size (in 2048 byte block) of
* the image, as reported in the PVM. */
};
/**
* Options for image generation.
*/
struct isoburn_source_opts {
int level; /**< ISO level to write at. */
int flags; /**< Which extensions to support. */
int relaxed_constraints; /**< see ecma119_relaxed_constraints_flag */
unsigned int copy_eltorito:1;
/**<
* In multisession discs, select whether to copy el-torito catalog
* and boot image. Copy is needed for isolinux images, that need to
* be patched. However, it can lead to problems when the image is
* not present in the iso filesystem, because we can't figure out
* its size. In those cases, we only copy 1 block of data.
*/
unsigned int no_cache_inodes:1;
/**< If use inode caching or not. Set it to 1 to prevent
* inode caching.
* Usage of inode caching allows detection of hard-links,
* which contents are only written once to disc this way.
* Don't use inode caching in systems with non unique inodes
* per device.
*/
unsigned int sort_files:1;
/**< If files should be sorted based on their weight. */
unsigned int default_mode:1;
/**<
* The default values for files and directory permissions,
* gid and uid. This option can be overwritten when set
* one of the following.
* 0 to use useful values, 1 to use node modes (this are
* the same as filesystem ones if not changed after added
* to tree).
*/
unsigned int replace_dir_mode:1;
/**<
* When 1, permissions for all dirs will be replaced by the
* specified in dir_mode field.
*/
unsigned int replace_file_mode:1;
/**<
* When 1, permissions for all files will be replaced by the
* specified in file_mode field.
*/
unsigned int replace_uid:1;
/**<
* When 1, uid of all nodes (both files and dirs) will be
* replaced by the specified in uid field.
*/
unsigned int replace_gid:1;
/**<
* When 1, gid of all nodes (both files and dirs) will be
* replaced by the specified in gid field.
*/
mode_t dir_mode; /**< Mode to use on dirs when replace_dir_mode is set. */
mode_t file_mode; /**< Mode to use on files when replace_file_mode is set. */
gid_t gid; /**< gid to use when replace_gid is set. */
uid_t uid; /**< uid to use when replace_uid is set. */
char *input_charset; /**< NULL to use default charset */
char *ouput_charset; /**< NULL to use default charset */
};
/** Load the ISO filesystem directory tree from the media in the given drive.
This will give libisoburn the base on which it can let libisofs perform
image growing or image modification. The loaded volset gets attached
to the drive object and is not publicly available.
Not a wrapper, but peculiar to libisoburn.
@param d The drive which holds an existing ISO filesystem
@param read_opts The read options which can be chosen by the application
@param volset the volset that represents the image, if the disc is blacnk
it will have no files
@return <=0 error , 1 = success
>>>>> error means damaged or unsupported image
error code is stored in ecma119_read_opts in libisofs
also error msgs are enqueued. Any need to pass them to usr? <<<<<<
*/
int isoburn_read_volset(struct burn_drive *d, struct isoburn_read_opts *read_opts,
struct iso_volset **volset);
/** Obtain the start block number of the most recent session on media. In
case of random access media this will always be 0. Succesfull return is
not a guarantee that there is a ISO-9660 image at all. The call will fail,
nevertheless,if isoburn_disc_get_status() returns not BURN_DISC_APPENDABLE.
Wrapper for: burn_disc_get_msc1()
*/
int isoburn_disc_get_msc1(struct burn_drive *d, int *start_lba);
/** Use this with trackno==0 to obtain the predicted start block number of the
new session. The interesting number is returned in parameter nwa.
Wrapper for: burn_disc_track_lba_nwa()
*/
int isoburn_disc_track_lba_nwa(struct burn_drive *d, struct burn_write_opts *o,
int trackno, int *lba, int *nwa);
/** Obtain the size which was attributed to an emulated appendable on actually
overwriteable media. This value is supposed to be <= 2048 * nwa as of
isoburn_disc_track_lba_nwa().
@param drive The drive holding the media.
@param start_byte The reply value counted in bytes, not in sectors.
@param flag Unused yet. Submit 0.
@return 1=stat_byte is valid, 0=not an emulated appendable, -1=error
*/
int isoburn_get_min_start_byte(struct burn_drive *d, off_t *start_byte,
int flag);
/** Prepare a disc for writing the new session.
@param drive The target drive
@param disc A burn_disc suitable to pass to isoburn_disc_write().
@return <=0 error , 1 = success
*/
int isoburn_prepare_disc(struct burn_drive *d, struct burn_disc **disc,
struct isoburn_source_opts *opts);
/** Prepare a disc for creating a new image from the contents of a previous
image volset plus the changes made by user. The generated burn_disc is
suitable to be written to any libburn drive. You shouldn't use the same
drive you're using as source.
@param d The source drive, grabbed with isoburn_drive_scan_and_grab().
@param disc A burn_disc suitable to pass to burn_disc_write.
@return <=0 error , 1 = success
*/
int isoburn_prepare_new_image(struct burn_drive *d, struct burn_disc **disc,
struct isoburn_source_opts *opts);
/** Start writing of the new session.
This call is asynchrounous. I.e. it returns quite soon and the progress has
to be watched by a loop with call burn_drive_get_status() until
BURN_DRIVE_IDLE is returned.
Wrapper for: burn_disc_write()
*/
void isoburn_disc_write(struct burn_write_opts *o, struct burn_disc *disc);
/** Inquire state and fill parameters of the fifo which is attached to
the emerging track. This should be done in the pacifier loop while
isoburn_disc_write() or burn_disc_write() are active.
Hint: If only burn_write_opts and not burn_drive is known, then the drive
can be obtained by burn_write_opts_get_drive().
@parm d The drive to which the track with the fifo gets burned.
@param size The total size of the fifo
@param free_bytes The current free capacity of the fifo
@param status_text Returns a pointer to a constant text, see below
@return <0 reply invalid, >=0 fifo status code:
bit0+1=input status, bit2=consumption status, i.e:
0="standby" : data processing not started yet
1="active" : input and consumption are active
2="ending" : input has ended without error
3="failing" : input had error and ended,
4="unused" : ( consumption has ended before processing start )
5="abandoned" : consumption has ended prematurely
6="ended" : consumption has ended without input error
7="aborted" : consumption has ended after input error
*/
int isoburn_get_fifo_status(struct burn_drive *d, int *size, int *free_bytes,
char **status_text);
/** Inquire whether the most recent write run was successful.
Wrapper for: burn_drive_wrote_well()
*/
int isoburn_drive_wrote_well(struct burn_drive *d);
/** Call this after isoburn_disc_write has finished and burn_drive_wrote_well()
indicates success. It will eventually complete the emulation of
multi-session functionality, if needed at all. Let libisoburn decide.
Not a wrapper, but peculiar to libisoburn.
*/
int isoburn_activate_session(struct burn_drive *drive);
/** Write a new session to a disc.
This is a synchrounous call equivalent to isoburn_prepare_disc +
isoburn_disc_write + isoburn_activate_session
@param pacifier_func If not NULL: a function to produce appeasing messages.
See burn_abort_pacifier() in libburn.h for an example.
*/
/* TODO implement this */
int isoburn_perform_write(struct burn_write_opts *o,
int (*pacifier_func)(void *handle, int patience,
int elapsed));
/** Release an aquired drive.
Wrapper for: burn_drive_release()
*/
void isoburn_drive_release(struct burn_drive *drive, int eject);
/** Shutdown all three libraries.
Wrapper for : iso_finish() and burn_finish().
*/
void isoburn_finish(void);
/*
The following two calls are for expert applications only.
An application should have a special reason to use them.
*/
/** Inquire wether the media needs emulation or would be suitable for
generic multi-session via libburn.
@return 0 is generic multi-session
1 is emulated multi-session
-1 is not suitable for isoburn
*/
int isoburn_needs_emulation(struct burn_drive *drive);
#ifdef Libburn_obsoleted_on_its_way_ouT
/** Caution: Use this with great care. It is not needed normally.
This call can set the nwa block number to an arbitrary value. If ever, do
this before preparing the session by libisofs. The drive must be grabbed,
though. This overrides the automated address computation. Call
isoburn_disc_track_lba_nwa() afterwards to learn the effective new
address which might be somewhat higher than set by parameter value.
Wrapper for: burn_write_opts_set_start_byte (if ever)
*/
void isoburn_write_opts_set_start_byte(struct burn_write_opts *opts,
off_t value);
#endif /* Libburn_obsoleted_on_its_way_ouT */