2007-09-01 18:20:53 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
cc -g -c isoburn.c
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
Class core of libisoburn.
|
|
|
|
|
2007-09-01 18:58:19 +00:00
|
|
|
Copyright 2007 Vreixo Formoso Lopes <metalpain2002@yahoo.es>
|
2007-09-01 18:20:53 +00:00
|
|
|
and Thomas Schmitt <scdbackup@gmx.net>
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* ( derived from stub generated by CgeN on Sat, 01 Sep 2007 12:04:36 GMT ) */
|
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <errno.h>
|
2007-09-04 23:03:21 +00:00
|
|
|
#include <unistd.h>
|
2007-09-01 18:20:53 +00:00
|
|
|
|
2007-09-04 23:03:21 +00:00
|
|
|
#include "../libisofs/libisofs.h"
|
|
|
|
#include "../libburn/libburn.h"
|
2007-09-01 18:20:53 +00:00
|
|
|
#include "isoburn.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* -------------------------- isoburn ----------------------- */
|
|
|
|
|
|
|
|
|
|
|
|
/* The global list of isoburn objects. Usually there is only one.
|
|
|
|
>>> we are not ready for multiple control threads yet. See >>> mutex .
|
|
|
|
Multiple burns under one control thread should work.
|
|
|
|
*/
|
|
|
|
struct isoburn *isoburn_list_start= NULL;
|
|
|
|
|
|
|
|
|
|
|
|
int isoburn_new(struct isoburn **objpt, int flag)
|
|
|
|
{
|
|
|
|
struct isoburn *o;
|
|
|
|
int i;
|
|
|
|
int isoburn_new_rwopts(struct isoburn *o);
|
|
|
|
|
|
|
|
*objpt= o= (struct isoburn *) malloc(sizeof(struct isoburn));
|
|
|
|
if(o==NULL)
|
|
|
|
return(-1);
|
|
|
|
|
|
|
|
o->drive= NULL;
|
|
|
|
o->emulation_mode= 0;
|
|
|
|
o->min_start_byte= 0;
|
|
|
|
o->nwa= 0;
|
2007-09-05 19:56:30 +00:00
|
|
|
o->treatment= 1;
|
2007-09-01 18:20:53 +00:00
|
|
|
o->target_ropts= NULL;
|
|
|
|
o->new_wopts= NULL;
|
2007-09-13 10:29:49 +00:00
|
|
|
o->fabricated_disc_status= BURN_DISC_UNREADY;
|
2007-09-01 18:20:53 +00:00
|
|
|
for(i=0;i<65536;i++)
|
|
|
|
o->target_iso_head[i]= 0;
|
|
|
|
o->target_volset= NULL;
|
|
|
|
o->prev= NULL;
|
|
|
|
o->next= NULL;
|
|
|
|
if(isoburn_new_rwopts(o)<=0)
|
|
|
|
goto failed;
|
|
|
|
|
|
|
|
isoburn_link(o, isoburn_list_start, 1);
|
|
|
|
return(1);
|
|
|
|
failed:;
|
|
|
|
isoburn_destroy(objpt,0);
|
|
|
|
return(-1);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int isoburn_destroy(struct isoburn **objpt, int flag)
|
|
|
|
{
|
|
|
|
struct isoburn *o;
|
|
|
|
int isoburn_free_rwopts(struct isoburn *o);
|
|
|
|
|
|
|
|
o= *objpt;
|
|
|
|
if(o==NULL)
|
|
|
|
return(0);
|
|
|
|
|
|
|
|
/* >>> mutex */
|
|
|
|
|
|
|
|
if(o==isoburn_list_start)
|
|
|
|
isoburn_list_start= o->next;
|
|
|
|
if(o->prev!=NULL)
|
|
|
|
o->prev->next= o->next;
|
|
|
|
if(o->next!=NULL)
|
|
|
|
o->next->prev= o->prev;
|
|
|
|
|
|
|
|
/* >>> end mutex */
|
|
|
|
|
|
|
|
if(o->drive!=NULL)
|
|
|
|
burn_drive_release(o->drive, 0);
|
|
|
|
isoburn_free_rwopts(o);
|
|
|
|
if(o->target_volset!=NULL)
|
|
|
|
iso_volset_free(o->target_volset);
|
|
|
|
|
|
|
|
free((char *) o);
|
|
|
|
*objpt= NULL;
|
|
|
|
return(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int isoburn_destroy_all(struct isoburn **objpt, int flag)
|
|
|
|
{
|
|
|
|
struct isoburn *o,*n;
|
|
|
|
|
|
|
|
o= *objpt;
|
|
|
|
if(o==NULL)
|
|
|
|
return(0);
|
|
|
|
for(;o->prev!=NULL;o= o->prev);
|
|
|
|
for(;o!=NULL;o= n) {
|
|
|
|
n= o->next;
|
|
|
|
isoburn_destroy(&o,0);
|
|
|
|
}
|
|
|
|
*objpt= NULL;
|
|
|
|
return(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int isoburn_get_emulation_mode(struct isoburn *o, int *pt, int flag)
|
|
|
|
{
|
|
|
|
*pt= o->emulation_mode;
|
|
|
|
return(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-09-04 23:03:21 +00:00
|
|
|
int isoburn_get_target_volset(struct isoburn *o, struct iso_volset **pt,
|
|
|
|
int flag)
|
2007-09-01 18:20:53 +00:00
|
|
|
{
|
|
|
|
*pt= o->target_volset;
|
|
|
|
return(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int isoburn_get_prev(struct isoburn *o, struct isoburn **pt, int flag)
|
|
|
|
{
|
|
|
|
*pt= o->prev;
|
|
|
|
return(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int isoburn_get_next(struct isoburn *o, struct isoburn **pt, int flag)
|
|
|
|
{
|
|
|
|
*pt= o->next;
|
|
|
|
return(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int isoburn_link(struct isoburn *o, struct isoburn *link, int flag)
|
|
|
|
/*
|
|
|
|
bit0= insert as link->prev rather than as link->next
|
|
|
|
*/
|
|
|
|
{
|
|
|
|
|
|
|
|
/* >>> mutex */
|
|
|
|
|
|
|
|
if(isoburn_list_start==NULL ||
|
2007-09-04 23:03:21 +00:00
|
|
|
(isoburn_list_start==link && (flag&1)))
|
2007-09-01 18:20:53 +00:00
|
|
|
isoburn_list_start= o;
|
|
|
|
if(o->prev!=NULL)
|
|
|
|
o->prev->next= o->next;
|
|
|
|
if(o->next!=NULL)
|
|
|
|
o->next->prev= o->prev;
|
|
|
|
o->prev= o->next= NULL;
|
|
|
|
if(link==NULL)
|
|
|
|
return(1);
|
|
|
|
if(flag&1) {
|
|
|
|
o->next= link;
|
|
|
|
o->prev= link->prev;
|
|
|
|
if(o->prev!=NULL)
|
|
|
|
o->prev->next= o;
|
|
|
|
link->prev= o;
|
|
|
|
} else {
|
|
|
|
o->prev= link;
|
|
|
|
o->next= link->next;
|
|
|
|
if(o->next!=NULL)
|
|
|
|
o->next->prev= o;
|
|
|
|
link->next= o;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* >>> end mutex */
|
|
|
|
|
|
|
|
return(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int isoburn_count(struct isoburn *o, int flag)
|
|
|
|
/* flag: bit1= count from start of list */
|
|
|
|
{
|
|
|
|
int counter= 0;
|
|
|
|
|
|
|
|
if(flag&2)
|
|
|
|
for(;o->prev!=NULL;o= o->prev);
|
|
|
|
for(;o!=NULL;o= o->next)
|
|
|
|
counter++;
|
|
|
|
return(counter);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int isoburn_by_idx(struct isoburn *o, int idx, struct isoburn **pt, int flag)
|
|
|
|
/* flag: bit0= fetch first (idx<0) or last (idx>0) item in list
|
|
|
|
bit1= address from start of list */
|
|
|
|
{
|
|
|
|
int i,abs_idx;
|
|
|
|
struct isoburn *npt;
|
|
|
|
|
|
|
|
if(flag&2)
|
|
|
|
for(;o->prev!=NULL;o= o->prev);
|
|
|
|
abs_idx= (idx>0?idx:-idx);
|
|
|
|
*pt= o;
|
|
|
|
for(i= 0;(i<abs_idx || (flag&1)) && *pt!=NULL;i++) {
|
|
|
|
if(idx>0)
|
|
|
|
npt= o->next;
|
|
|
|
else
|
|
|
|
npt= o->prev;
|
|
|
|
if(npt==NULL && (flag&1))
|
|
|
|
break;
|
|
|
|
*pt= npt;
|
|
|
|
}
|
|
|
|
return(*pt!=NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int isoburn_find_by_drive(struct isoburn **pt, struct burn_drive *d, int flag)
|
|
|
|
{
|
|
|
|
struct isoburn *o;
|
|
|
|
|
|
|
|
*pt= NULL;
|
|
|
|
for(o= isoburn_list_start;o->prev!=NULL;o= o->prev)
|
|
|
|
if(o->drive==d) {
|
|
|
|
*pt= o;
|
|
|
|
return(1);
|
|
|
|
}
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|