From d2579c0671a6f455f510d6249792361353184791 Mon Sep 17 00:00:00 2001 From: Thomas Schmitt Date: Wed, 5 Sep 2007 19:42:03 +0000 Subject: [PATCH] burn_drive_grab_dummy() becomes invisible part of burn_drive_scan_and_grab() --- libburn/trunk/cdrskin/cdrskin_timestamp.h | 2 +- libburn/trunk/libburn/drive.c | 147 +++++++++++----------- libburn/trunk/libburn/libburn.h | 6 +- libburn/trunk/test/libburner.c | 6 +- libburn/trunk/test/telltoc.c | 6 +- 5 files changed, 93 insertions(+), 74 deletions(-) diff --git a/libburn/trunk/cdrskin/cdrskin_timestamp.h b/libburn/trunk/cdrskin/cdrskin_timestamp.h index b33751da..4a27f70e 100644 --- a/libburn/trunk/cdrskin/cdrskin_timestamp.h +++ b/libburn/trunk/cdrskin/cdrskin_timestamp.h @@ -1 +1 @@ -#define Cdrskin_timestamP "2007.09.04.225558" +#define Cdrskin_timestamP "2007.09.05.194124" diff --git a/libburn/trunk/libburn/drive.c b/libburn/trunk/libburn/drive.c index 992d9461..94cc2693 100644 --- a/libburn/trunk/libburn/drive.c +++ b/libburn/trunk/libburn/drive.c @@ -1007,6 +1007,76 @@ int burn_drive_is_banned(char *device_address) return 1; } + +/* ts A70903 : will vanish from API */ +int burn_drive_grab_dummy(struct burn_drive_info *drive_infos[], char *fname) +{ + int ret; + struct burn_drive *d= NULL, *regd_d; + struct stat stbuf; + + if (fname[0] != 0) { + if (stat(fname, &stbuf) == -1) { + + /* >>> ? reject ? try to create ? */; + + } else if(S_ISREG(stbuf.st_mode) || S_ISBLK(stbuf.st_mode)) { + /* >>> ? open for a test ? */; + } else { + libdax_msgs_submit(libdax_messenger, d->global_index, + 0x00020149, + LIBDAX_MSGS_SEV_SORRY, LIBDAX_MSGS_PRIO_HIGH, + "Unsuitable filetype for pseudo-drive", 0, 0); + return 0; + } + } + d= (struct burn_drive *) calloc(1, sizeof(struct burn_drive)); + if (d == NULL) + return 0; + d->status = BURN_DISC_EMPTY; + burn_setup_drive(d, fname); + + if (fname[0] != 0) + d->drive_role = 2; + else + d->drive_role = 0; + ret = burn_scsi_setup_drive(d, -1, -1, -1, -1, -1, 0); + if (ret <= 0) + goto ex; + regd_d = burn_drive_register(d); + if (regd_d == NULL) { + ret = -1; + goto ex; + } + if (d->drive_role == 2) { + d->status = BURN_DISC_BLANK; + d->current_profile = 0; /* MMC reserved */ + strcpy(d->current_profile_text,"stdio file"); + d->current_is_cd_profile = 0; + d->current_is_supported_profile = 1; + d->block_types[BURN_WRITE_TAO] = BURN_BLOCK_MODE1; + d->block_types[BURN_WRITE_SAO] = BURN_BLOCK_MODE1; + } + + *drive_infos = calloc(2, sizeof(struct burn_drive_info)); + if (*drive_infos == NULL) + goto ex; + (*drive_infos)[0].drive = d; + (*drive_infos)[1].drive = NULL; /* End-Of-List mark */ + (*drive_infos)[0].tao_block_types = d->block_types[BURN_WRITE_TAO]; + (*drive_infos)[0].sao_block_types = d->block_types[BURN_WRITE_SAO]; + + d->released = 0; + ret = 1; +ex:; + if (ret <= 0 && d != NULL) { + burn_drive_free_subs(d); + free((char *) d); + } + return ret; +} + + /* ts A60823 */ /** Aquire a drive with known persistent address. */ @@ -1016,6 +1086,11 @@ int burn_drive_scan_and_grab(struct burn_drive_info *drive_infos[], char* adr, unsigned int n_drives; int ret; + if(strncmp(adr, "stdio:", 6) == 0) { + ret = burn_drive_grab_dummy(drive_infos, adr + 6); + return ret; + } + burn_drive_clear_whitelist(); burn_drive_add_whitelist(adr); /* @@ -1296,7 +1371,8 @@ int burn_drive_convert_fs_adr_sub(char *path, char adr[], int *rec_count) struct stat stbuf; burn_drive_adr_debug_msg("burn_drive_convert_fs_adr( %s )", path); - if(burn_drive_is_enumerable_adr(path)) { + if (strncmp(path, "stdio:", 6) == 0 || + burn_drive_is_enumerable_adr(path)) { if(strlen(path) >= BURN_DRIVE_ADR_LEN) return -1; burn_drive_adr_debug_msg( @@ -1967,75 +2043,6 @@ int burn_disc_get_write_mode_demands(struct burn_disc *disc, } -/* ts A70903 : API */ -int burn_drive_grab_dummy(struct burn_drive_info *drive_infos[], char *fname) -{ - int ret; - struct burn_drive *d= NULL, *regd_d; - struct stat stbuf; - - if (fname[0] != 0) { - if (stat(fname, &stbuf) == -1) { - - /* >>> ? reject ? try to create ? */; - - } else if(S_ISREG(stbuf.st_mode) || S_ISBLK(stbuf.st_mode)) { - /* >>> ? open for a test ? */; - } else { - libdax_msgs_submit(libdax_messenger, d->global_index, - 0x00020149, - LIBDAX_MSGS_SEV_SORRY, LIBDAX_MSGS_PRIO_HIGH, - "Unsuitable filetype for pseudo-drive", 0, 0); - return 0; - } - } - d= (struct burn_drive *) calloc(1, sizeof(struct burn_drive)); - if (d == NULL) - return 0; - d->status = BURN_DISC_EMPTY; - burn_setup_drive(d, fname); - - if (fname[0] != 0) - d->drive_role = 2; - else - d->drive_role = 0; - ret = burn_scsi_setup_drive(d, -1, -1, -1, -1, -1, 0); - if (ret <= 0) - goto ex; - regd_d = burn_drive_register(d); - if (regd_d == NULL) { - ret = -1; - goto ex; - } - if (d->drive_role == 2) { - d->status = BURN_DISC_BLANK; - d->current_profile = 0; /* MMC reserved */ - strcpy(d->current_profile_text,"stdio file"); - d->current_is_cd_profile = 0; - d->current_is_supported_profile = 1; - d->block_types[BURN_WRITE_TAO] = BURN_BLOCK_MODE1; - d->block_types[BURN_WRITE_SAO] = BURN_BLOCK_MODE1; - } - - *drive_infos = calloc(2, sizeof(struct burn_drive_info)); - if (*drive_infos == NULL) - goto ex; - (*drive_infos)[0].drive = d; - (*drive_infos)[1].drive = NULL; /* End-Of-List mark */ - (*drive_infos)[0].tao_block_types = d->block_types[BURN_WRITE_TAO]; - (*drive_infos)[0].sao_block_types = d->block_types[BURN_WRITE_SAO]; - - d->released = 0; - ret = 1; -ex:; - if (ret <= 0 && d != NULL) { - burn_drive_free_subs(d); - free((char *) d); - } - return ret; -} - - /* ts A70903 : API */ int burn_drive_get_drive_role(struct burn_drive *d) { diff --git a/libburn/trunk/libburn/libburn.h b/libburn/trunk/libburn/libburn.h index 0d014a30..71de0e60 100644 --- a/libburn/trunk/libburn/libburn.h +++ b/libburn/trunk/libburn/libburn.h @@ -1901,7 +1901,9 @@ int burn_read_data(struct burn_drive *d, off_t byte_address, char data[], off_t data_size, off_t *data_count, int flag); -/* ts A70903 */ +#ifdef NIX + +/* ts A70903 */ /* <<< ts A70905 : to vanish from API */ /** Create and aquire a pseudo-drive which will accept option settings much like a MMC burner drive. Many of them will not cause any effect, though. There are two kinds of pseudo-drives: stdio-drives and null-drives. @@ -1924,6 +1926,8 @@ int burn_read_data(struct burn_drive *d, off_t byte_address, */ int burn_drive_grab_dummy(struct burn_drive_info *drive_infos[], char *fname); +#endif /* NIX */ + /** Inquire wether the drive object is a real MMC drive or a pseudo-drive created by burn_drive_dummy(). diff --git a/libburn/trunk/test/libburner.c b/libburn/trunk/test/libburner.c index 3de626aa..589d2c5a 100644 --- a/libburn/trunk/test/libburner.c +++ b/libburn/trunk/test/libburner.c @@ -123,11 +123,15 @@ int libburner_aquire_by_adr(char *drive_adr) int ret; char libburn_drive_adr[BURN_DRIVE_ADR_LEN]; +#ifdef NIX if (strncmp(drive_adr, "stdio:", 6) == 0) { fprintf(stderr, "Aquiring standard i/o pseudo-drive '%s'\n", drive_adr + 6); ret = burn_drive_grab_dummy(&drive_list, drive_adr + 6); - } else { + } else +#endif /* NIX */ + + { /* This tries to resolve links or alternative device files */ ret = burn_drive_convert_fs_adr(drive_adr, libburn_drive_adr); if (ret<=0) { diff --git a/libburn/trunk/test/telltoc.c b/libburn/trunk/test/telltoc.c index dfc0a793..1fc22f1f 100644 --- a/libburn/trunk/test/telltoc.c +++ b/libburn/trunk/test/telltoc.c @@ -116,11 +116,15 @@ int telltoc_aquire_by_adr(char *drive_adr) int ret; char libburn_drive_adr[BURN_DRIVE_ADR_LEN]; +#ifdef NIX if (strncmp(drive_adr, "stdio:", 6) == 0) { fprintf(stderr, "Aquiring standard i/o pseudo-drive '%s'\n", drive_adr + 6); ret = burn_drive_grab_dummy(&drive_list, drive_adr + 6); - } else { + } else +#endif /* NIX */ + + { /* This tries to resolve links or alternative device files */ ret = burn_drive_convert_fs_adr(drive_adr, libburn_drive_adr); if (ret<=0) {