69#include "../libburn/libburn.h"
153 if (strncmp(
drive_adr,
"stdio:/dev/fd/", 14) == 0 ||
155 fprintf(stderr,
"Will not work with pseudo-drive '%s'\n",
163 fprintf(stderr,
"Address does not lead to a CD burner: '%s'\n",
167 fprintf(stderr,
"Aquiring drive '%s' ...\n", libburn_drive_adr);
170 fprintf(stderr,
"FAILURE with persistent drive address '%s'\n",
173 fprintf(stderr,
"Done\n");
197 printf(
"Beginning to scan for devices ...\n");
201 printf(
"FAILED (no drives found)\n");
220 printf(
"\nOverview of accessible drives (%d found) :\n",
222 printf(
"-----------------------------------------------------------------------------\n");
225 strcpy(adr,
"-get_adr_failed-");
226 printf(
"%d --drive '%s' : '%s' '%s'\n",
229 printf(
"-----------------------------------------------------------------------------\n\n");
257 printf(
"Pseudo-drive \"-\" given : bus scanning done.\n");
262 "Found only %d drives. Number %d not available.\n",
273 fprintf(
stderr,
"Cannot drop drive %d. Please report \"ret=%d\" to libburn-hackers@pykix.org\n",
276 printf(
"Dropped unwanted drive %d\n",
i);
303 "Drive media status: %d (see libburn/libburn.h BURN_DISC_*)\n",
309 "IDLE: Blank media detected. Will leave it untouched\n");
319 "FATAL: Unsuitable drive and media state\n");
324 "FATAL : Media is not of erasable type\n");
335 if(
p.sectors>0 &&
p.sector>=0)
372 fprintf(
stderr,
"IDLE: DVD-RW media is already formatted\n");
378 "FATAL: BD-R is not blank. Cannot format.\n");
385 "IDLE: BD media is already formatted\n");
391 size = 128 * 1024 * 1024;
399 printf(
"Beginning to format media.\n");
404 if(
p.sectors>0 &&
p.sector>=0)
416 printf(
"Media type now: %4.4xh \"%s\"\n",
420 "FATAL: Failed to change media profile to desired value\n");
482 if (adr[0] ==
'-' && adr[1] == 0) {
500 "FATAL: Could not open data source '%s'.\n",adr);
511 "FATAL: Could not create fifo object of 4 MB\n");
519 "FATAL: Cannot attach source object to track object\n");
537 fprintf(
stderr,
"FATAL: Closed media with data detected. Need blank or appendable media.\n");
544 "FATAL: Cannot recognize state of drive and media\n");
552 printf(
"\n*** Will TRY to SIMULATE burning ***\n\n");
558 fprintf(
stderr,
"FATAL: Failed to find a suitable write mode with this media.\n");
564 printf(
"Burning starts. With e.g. 4x media expect up to a minute of zero progress.\n");
576 "Thank you for being patient since %d seconds.",
594 (
int) (100.0 - 100.0 *
608 printf(
"NOTE: Media left appendable.\n");
610 printf(
"\n*** Did TRY to SIMULATE burning ***\n\n");
681 }
else if ((!
strcmp(
argv[
i],
"--format_overwrite")) ||
691 }
else if (!
strcmp(
argv[
i],
"--try_to_simulate")) {
702 fprintf(
stderr,
"Source address too long (max. %d)\n", 4096-1);
722 printf(
" [--drive <address>|<driveno>|\"-\"] [--audio]\n");
723 printf(
" [--blank_fast|--blank_full|--format] [--try_to_simulate]\n");
724 printf(
" [--multi] [<one or more imagefiles>|\"-\"]\n");
726 printf(
"A bus scan (needs rw-permissions to see a drive):\n");
728 printf(
"Burn a file to drive chosen by number, leave appendable:\n");
729 printf(
" %s --drive 0 --multi my_image_file\n",
argv[0]);
730 printf(
"Burn a file to drive chosen by persistent address, close:\n");
731 printf(
" %s --drive /dev/hdc my_image_file\n",
argv[0]);
732 printf(
"Blank a used CD-RW (is combinable with burning in one run):\n");
733 printf(
" %s --drive /dev/hdc --blank_fast\n",
argv[0]);
734 printf(
"Blank a used DVD-RW (is combinable with burning in one run):\n");
735 printf(
" %s --drive /dev/hdc --blank_full\n",
argv[0]);
736 printf(
"Format a DVD-RW, BD-RE or BD-R:\n");
737 printf(
" %s --drive /dev/hdc --format\n",
argv[0]);
738 printf(
"Burn two audio tracks (to CD only):\n");
739 printf(
" lame --decode -t /path/to/track1.mp3 track1.cd\n");
740 printf(
" test/dewav /path/to/track2.wav -o track2.cd\n");
741 printf(
" %s --drive /dev/hdc --audio track1.cd track2.cd\n",
argv[0]);
742 printf(
"Burn a compressed afio archive on-the-fly:\n");
743 printf(
" ( cd my_directory ; find . -print | afio -oZ - ) | \\\n");
745 printf(
"To be read from *not mounted* media via: afio -tvZ /dev/hdc\n");
758 if (
sizeof(
off_t) != 8) {
760 "\nFATAL: Compile time misconfiguration. off_t is not 64 bit.\n\n");
768 printf(
"Initializing libburnia-project.org ...\n");
int burn_write_opts_set_simulate(struct burn_write_opts *opts, int sim)
Sets the simulate value for the write_opts struct .
void burn_track_free(struct burn_track *t)
Free a track.
#define BURN_REASONS_LEN
The length of a rejection reasons string for burn_precheck_write() and burn_write_opts_auto_write_typ...
void burn_write_opts_free(struct burn_write_opts *opts)
Frees a write_opts struct created with burn_write_opts_new.
int burn_disc_get_profile(struct burn_drive *d, int *pno, char name[80])
Tells the MMC Profile identifier of the loaded media.
void burn_source_free(struct burn_source *s)
Free a burn_source (decrease its refcount and maybe free it)
void burn_disc_format(struct burn_drive *drive, off_t size, int flag)
Format media for use with libburn.
int burn_drive_convert_fs_adr(char *path, char adr[])
Try to convert a given existing filesystem address into a drive device file address.
int burn_drive_get_adr(struct burn_drive_info *drive_info, char adr[])
Inquire the device file address of a drive via a given drive_info object.
int burn_session_add_track(struct burn_session *s, struct burn_track *t, unsigned int pos)
Add a track to a session at specified position.
void burn_session_free(struct burn_session *s)
Free a session (and decrease reference count on all tracks inside)
int burn_drive_scan(struct burn_drive_info *drive_infos[], unsigned int *n_drives)
Scan for drives.
enum burn_source_status burn_track_set_source(struct burn_track *t, struct burn_source *s)
Set the track's data source.
int burn_drive_grab(struct burn_drive *drive, int load)
Grab a drive.
@ BURN_DRIVE_SPAWNING
The library is spawning the processes to handle a pending operation (A read/write/etc is about to sta...
@ BURN_DRIVE_IDLE
The drive is not in an operation.
int burn_write_opts_set_underrun_proof(struct burn_write_opts *opts, int underrun_proof)
Controls buffer underrun prevention.
struct burn_disc * burn_disc_create(void)
Create a new disc.
void burn_set_signal_handling(void *handle, burn_abort_handler_t handler, int mode)
Control built-in signal handling.
#define BURN_DRIVE_ADR_LEN
Maximum length+1 to expect with a drive device file address string.
int burn_initialize(void)
Initialize the library.
void burn_drive_set_speed(struct burn_drive *d, int read, int write)
Sets drive read and write speed.
int burn_msgs_set_severities(char *queue_severity, char *print_severity, char *print_id)
Control queueing and stderr printing of messages from libburn.
void burn_disc_write(struct burn_write_opts *o, struct burn_disc *disc)
Write a disc in the drive.
void burn_drive_release(struct burn_drive *drive, int eject)
Release a drive.
int burn_disc_add_session(struct burn_disc *d, struct burn_session *s, unsigned int pos)
Add a session to a disc at a specific position, increasing the sessions's reference count.
int burn_disc_erasable(struct burn_drive *d)
Tells whether a disc can be erased or not.
#define BURN_FORMAT_IS_UNFORMATTED
Possible formatting status values.
struct burn_source * burn_fd_source_new(int datafd, int subfd, off_t size)
Creates a data source for an image file (a track) from an open readable filedescriptor,...
void burn_disc_erase(struct burn_drive *drive, int fast)
Erase a disc in the drive.
enum burn_write_types burn_write_opts_auto_write_type(struct burn_write_opts *opts, struct burn_disc *disc, char reasons[BURN_REASONS_LEN], int flag)
As an alternative to burn_write_opts_set_write_type() this function tries to find a suitable write ty...
void burn_write_opts_set_perform_opc(struct burn_write_opts *opts, int opc)
Sets whether to use opc or not with the write_opts struct.
@ BURN_WRITE_NONE
In replies this indicates that not any writing will work.
int burn_is_aborting(int flag)
enum burn_drive_status burn_drive_get_status(struct burn_drive *drive, struct burn_progress *p)
Returns the progress and status of a drive.
int burn_drive_info_forget(struct burn_drive_info *drive_info, int force)
Release memory about a single drive and any exclusive lock on it.
int burn_abort(int patience, int(*pacifier_func)(void *handle, int patience, int elapsed), void *handle)
Abort any running drive operation and eventually call burn_finish().
@ BURN_SOURCE_OK
The source is ok.
struct burn_source * burn_fifo_source_new(struct burn_source *inp, int chunksize, int chunks, int flag)
Creates a fifo which acts as proxy for an already existing data source.
struct burn_session * burn_session_create(void)
Create a new session.
void burn_finish(void)
Shutdown the library.
int burn_disc_get_formats(struct burn_drive *drive, int *status, off_t *size, unsigned *bl_sas, int *num_formats)
Inquire the formatting status, the associated sizes and the number of available formats.
enum burn_disc_status burn_disc_get_status(struct burn_drive *drive)
Returns what kind of disc a drive is holding.
void burn_disc_free(struct burn_disc *d)
Delete disc and decrease the reference count on all its sessions.
void burn_write_opts_set_multi(struct burn_write_opts *opts, int multi)
Sets the multi flag which eventually marks the emerging session as not being the last one and thus cr...
int burn_abort_pacifier(void *handle, int patience, int elapsed)
A pacifier function suitable for burn_abort.
burn_disc_status
Possible status of the drive in regard to the disc in it.
@ BURN_DISC_EMPTY
There is no disc at all in the drive.
@ BURN_DISC_BLANK
The drive holds a blank disc.
@ BURN_DISC_APPENDABLE
There is an incomplete disc in the drive.
@ BURN_DISC_FULL
There is a disc with data on it in the drive.
struct burn_write_opts * burn_write_opts_new(struct burn_drive *drive)
Creates a write_opts struct for burning to the specified drive.
struct burn_track * burn_track_create(void)
Create a track.
int burn_drive_scan_and_grab(struct burn_drive_info *drive_infos[], char *adr, int load)
Acquire a drive with known device file address.
void burn_track_define_data(struct burn_track *t, int offset, int tail, int pad, int mode)
Define the data in a track.
#define BURN_MODE1
Track mode - mode 1 data 2048 bytes user data, and all the LEC money can buy.
#define BURN_AUDIO
Track mode - audio 2352 bytes per sector.
int burn_fifo_inquire_status(struct burn_source *fifo, int *size, int *free_bytes, char **status_text)
Inquires state and fill parameters of a fifo burn_source which was created by burn_fifo_source_new() ...
int libburner_blank_disc(struct burn_drive *drive, int blank_fast)
Makes a previously used CD-RW or unformatted DVD-RW ready for thorough re-usal.
static char current_profile_name[80]
static char source_adr[99][4096]
static struct burn_drive_info * drive_list
Overview.
static unsigned int drive_count
If you start a long lasting operation with drive_count > 1 then you are not friendly to the users of ...
int main(int argc, char **argv)
int libburner_aquire_by_adr(char *drive_adr)
If the persistent drive address is known, then this approach is much more un-obtrusive to the systemw...
int libburner_format(struct burn_drive *drive)
Formats unformatted DVD-RW to profile 0013h "Restricted Overwrite" which needs no blanking for re-use...
int libburner_setup(int argc, char **argv)
Converts command line arguments into above setup parameters.
static int source_adr_count
static int current_profile
A number and a text describing the type of media in acquired drive.
int libburner_aquire_by_driveno(int *drive_no)
This method demonstrates how to use libburn without knowing a persistent drive address in advance.
static int drive_is_grabbed
This variable indicates wether the drive is grabbed and must be finally released.
int libburner_aquire_drive(char *drive_adr, int *driveno)
You need to acquire a drive before burning.
static int all_tracks_type
static char drive_adr[BURN_DRIVE_ADR_LEN]
The setup parameters of libburner.
int libburner_payload(struct burn_drive *drive, char source_adr[][4096], int source_adr_count, int multi, int simulate_burn, int all_tracks_type)
Brings preformatted track images (ISO 9660, audio, ...) onto media.
Information on a drive in the system.
char product[17]
Name of the drive.
struct burn_drive * drive
The value by which this drive can be indexed when using functions in the library.
char vendor[9]
Name of the vendor of the drive.
Operation progress report.
Data source interface for tracks.