Allow to define a default unit to use if none is provided

This commit is contained in:
Laurent Vivier 2008-08-12 13:45:41 +00:00
parent 7ff51a725e
commit 689316713e
4 changed files with 26 additions and 3 deletions

View File

@ -12,7 +12,7 @@ CPPFLAGS = -I$(TOP)/../libmacos -I$(TOP) -I$(TOP)/../libgzip
LIBRARIES = scsi/libstream.a floppy/libstream.a full/libstream.a
SOURCES = stream_close.c stream_open.c stream_read.c stream_lseek.c \
stream_uncompress.c gzio.c stream_fstat.c
stream_uncompress.c gzio.c stream_fstat.c stream_set_default.c
HEADERS = libstream.h

View File

@ -95,4 +95,6 @@ extern int stream_lseek(stream_t *stream, long offset, int whence);
extern int stream_close(stream_t *stream);
extern int stream_uncompress(stream_t *stream);
extern int stream_fstat(stream_t *stream, struct stream_stat *buf);
extern void stream_set_default(int unit);
#endif /* __LIBSTREAM_H__ */

View File

@ -31,6 +31,8 @@
#include <libmap.h>
#endif
extern int default_unit;
static char* get_fs(char *path, fs_t *fs)
{
#ifdef BLOCK_SUPPORT
@ -70,8 +72,13 @@ static char *get_device(char* path,
{
int nb;
if (*path != '(')
if (*path != '(') {
if (default_unit == -1)
return NULL;
*device = device_SCSI;
*unit = default_unit;
*partition = -1;
}
path++;
#ifdef FLOPPY_SUPPORT

View File

@ -0,0 +1,14 @@
/*
*
* (c) 2008 Laurent Vivier <Laurent@lvivier.info>
*
*/
#include <stdlib.h>
int default_unit = -1;
void stream_set_default(int unit)
{
default_unit = unit;
}