2008-01-10 15:20:57 +00:00
|
|
|
/*
|
|
|
|
data source for libisoburn.
|
|
|
|
|
|
|
|
Copyright 2007 Vreixo Formoso Lopes <metalpain2002@yahoo.es>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <assert.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
2008-01-20 10:30:43 +00:00
|
|
|
|
|
|
|
#ifndef Xorriso_standalonE
|
|
|
|
|
2008-01-10 15:20:57 +00:00
|
|
|
#include <libburn/libburn.h>
|
|
|
|
|
|
|
|
/* >>> NG */
|
|
|
|
#include <libisofs/nglibisofs.h>
|
|
|
|
|
2008-01-20 10:30:43 +00:00
|
|
|
#else /* ! Xorriso_standalonE */
|
|
|
|
|
|
|
|
#include "../libisofs/libisofs.h"
|
|
|
|
#include "../libburn/libburn.h"
|
2008-01-10 15:20:57 +00:00
|
|
|
|
2008-01-20 10:30:43 +00:00
|
|
|
#endif /* Xorriso_standalonE */
|
|
|
|
|
|
|
|
|
|
|
|
#include "isoburn.h"
|
2008-01-10 15:20:57 +00:00
|
|
|
|
|
|
|
static int
|
|
|
|
ds_read_block(IsoDataSource *src, uint32_t lba, uint8_t *buffer)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
struct burn_drive *d;
|
|
|
|
off_t count;
|
|
|
|
|
|
|
|
assert(src && buffer);
|
|
|
|
|
|
|
|
d = (struct burn_drive*)src->data;
|
|
|
|
|
|
|
|
ret = burn_read_data(d, (off_t) lba * (off_t) 2048, (char *) buffer,
|
|
|
|
2048, &count, 0);
|
|
|
|
if (ret <= 0 )
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
ds_open(IsoDataSource *src)
|
|
|
|
{
|
|
|
|
/* nothing to do, device is always grabbed */
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
ds_close(IsoDataSource *src)
|
|
|
|
{
|
|
|
|
/* nothing to do, device is always grabbed */
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
ds_free_data(IsoDataSource *src)
|
|
|
|
{
|
|
|
|
/* nothing to do */;
|
|
|
|
}
|
|
|
|
|
|
|
|
IsoDataSource *
|
|
|
|
isoburn_data_source_new(struct burn_drive *d)
|
|
|
|
{
|
|
|
|
IsoDataSource *ret;
|
|
|
|
if (d==NULL)
|
|
|
|
return NULL;
|
|
|
|
ret = malloc(sizeof(IsoDataSource));
|
|
|
|
if (!ret)
|
|
|
|
return NULL;
|
|
|
|
ret->refcount = 1;
|
|
|
|
ret->read_block = ds_read_block;
|
|
|
|
ret->open = ds_open;
|
|
|
|
ret->close = ds_close;
|
|
|
|
ret->free_data = ds_free_data;
|
|
|
|
ret->data = d;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|