~mdw
/
dvdrip
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
@@@ dvdrip-upload: change settings while i'm stealing someone else's internet
[dvdrip]
/
lib.c
diff --git
a/lib.c
b/lib.c
index
2147228
..
5bf0394
100644
(file)
--- a/
lib.c
+++ b/
lib.c
@@
-260,12
+260,12
@@
static void logfn(void *p, dvd_logger_level_t lev,
static const dvd_logger_cb logger = { logfn };
#endif
static const dvd_logger_cb logger = { logfn };
#endif
-
void
open_dvd(const char *device, int mode,
-
int *fd_out, dvd_reader_t **dvd_out)
+
int
open_dvd(const char *device, int mode,
+ int *fd_out, dvd_reader_t **dvd_out)
{
{
- int fd;
- dvd_reader_t *dvd;
- int bannerp = 0;
+ int fd
= -1
;
+ dvd_reader_t *dvd
= 0
;
+ int bannerp = 0
, rc
;
for (;;) {
fd = open(device, mode);
for (;;) {
fd = open(device, mode);
@@
-277,18
+277,32
@@
void open_dvd(const char *device, int mode,
sit(0.2);
}
if (bannerp) hide_banner();
sit(0.2);
}
if (bannerp) hide_banner();
- if (fd < 0) bail_syserr(errno, "failed to open device `%s'", device);
+
+ if (fd < 0) {
+ moan_syserr(errno, "failed to open device `%s'", device);
+ rc = -1; goto end;
+ }
+
if (dvd_out) {
#ifdef notdef
dvd = DVDOpen2(0, &logger, device);
#else
dvd = DVDOpen(device);
#endif
if (dvd_out) {
#ifdef notdef
dvd = DVDOpen2(0, &logger, device);
#else
dvd = DVDOpen(device);
#endif
- if (!dvd) bail("failed to open DVD on `%s'", device);
- *dvd_out = dvd;
+ if (!dvd) {
+ moan("failed to open DVD on `%s'", device);
+ rc = -1; goto end;
+ }
}
}
- if (fd_out) *fd_out = fd;
- else close(fd);
+
+ if (fd_out) { *fd_out = fd; fd = -1; }
+ if (dvd_out) { *dvd_out = dvd; dvd = 0; }
+ rc = 0;
+
+end:
+ if (fd >= 0) close(fd);
+ DVDClose(dvd);
+ return (rc);
}
void store_filename(char *buf, ident id)
}
void store_filename(char *buf, ident id)