mirror of
https://github.com/vivier/EMILE.git
synced 2024-12-22 10:29:31 +00:00
Add map_init.c, use stream_FILE with device->close()
This commit is contained in:
parent
2c64fafc4f
commit
98bd88c574
@ -30,7 +30,7 @@ SOURCES = map_bootblock_get_type.c map_bootblock_is_valid.c \
|
||||
map_set_bootinfo.c map_set_driver_info.c map_set_driver_number.c \
|
||||
map_set_partition_name.c map_set_partition_type.c map_set_startup.c \
|
||||
map_write.c map_block0_write.c map_read_sector.c \
|
||||
map_write_sector.c map_get_blocksize.c
|
||||
map_write_sector.c map_get_blocksize.c map_init.c
|
||||
|
||||
HEADERS = libmap.h
|
||||
|
||||
|
@ -142,6 +142,7 @@ enum {
|
||||
#define FIRST_LEVEL_SIZE (FLOPPY_SECTOR_SIZE * 2)
|
||||
#define BOOTBLOCK_SIZE (FLOPPY_SECTOR_SIZE * 2)
|
||||
|
||||
extern int map_init(device_io_t *device, int partition);
|
||||
extern map_t* map_open(device_io_t *device);
|
||||
extern void map_close(map_t *map);
|
||||
extern int map_get_number(map_t *map);
|
||||
|
@ -11,7 +11,7 @@
|
||||
|
||||
void map_close(map_t *map)
|
||||
{
|
||||
map->device->close(map->device);
|
||||
map->device->close((stream_FILE*)map->device);
|
||||
free(map->device);
|
||||
free(map);
|
||||
}
|
||||
|
31
libmap/map_init.c
Normal file
31
libmap/map_init.c
Normal file
@ -0,0 +1,31 @@
|
||||
/*
|
||||
*
|
||||
* (c) 2008 Laurent Vivier <Laurent@lvivier.info>
|
||||
*
|
||||
*/
|
||||
|
||||
#include "libmap.h"
|
||||
|
||||
int map_init(device_io_t *device, int partition)
|
||||
{
|
||||
int ret;
|
||||
map_t *map;
|
||||
|
||||
map = map_open(device);
|
||||
if (map == NULL)
|
||||
return -1;
|
||||
|
||||
ret = map_read(map, partition);
|
||||
if (ret == -1)
|
||||
{
|
||||
map_close(map);
|
||||
return -1;
|
||||
}
|
||||
|
||||
device->data = map;
|
||||
device->read_sector = (stream_read_sector_t)map_read_sector;
|
||||
device->close = (stream_close_t)map_close;
|
||||
device->get_blocksize = (stream_get_blocksize_t)map_get_blocksize;
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user