#include "lib.h"
-static void usage(FILE *fp) { fprintf(fp, "usage: %s DEVICE\n", prog); }
-
-static void puthex(const unsigned char *p, size_t sz, FILE *fp)
- { while (sz) { fprintf(fp, "%02x", *p++); sz--; } }
+static void usage(FILE *fp)
+ { fprintf(fp, "usage: %s [-IV] DEVICE ...\n", prog); }
int main(int argc, char *argv[])
{
- char volid[33];
- unsigned char volsetid[16], discid[16];
- int rc, opt;
- unsigned f = 0;
+ char id[MAXIDSZ];
+ int i, opt, st = 0;
+ unsigned f = 0, dif = 0;
static dvd_reader_t *dvd;
#define f_bogus 1u
set_prog(argv[0]);
for (;;) {
- opt = getopt(argc, argv, "h"); if (opt < 0) break;
+ opt = getopt(argc, argv, "hIV"); if (opt < 0) break;
switch (opt) {
case 'h': usage(stderr); exit(0);
+ case 'I': dif |= DIF_MUSTIFOHASH; break;
+ case 'V': dif |= DIF_MUSTVOLINF; break;
default: f |= f_bogus; break;
}
}
- if (argc - optind != 1) f |= f_bogus;
+ if (argc - optind < 1) f |= f_bogus;
if (f&f_bogus) { usage(stderr); exit(2); }
setlocale(LC_ALL, "");
progress_init(&progress);
- open_dvd(argv[optind], 0, &dvd);
-
- rc = DVDUDFVolumeInfo(dvd,
- volid, sizeof(volid),
- volsetid, sizeof(volsetid));
- if (rc) {
- moan("failed to read volume info");
- strcpy(volid, "<error reading volume info>");
- memset(volsetid, 0xff, sizeof(volsetid));
- }
-
- rc = DVDDiscID(dvd, discid);
- if (rc) {
- moan("failed to determine disc id");
- memset(discid, 0xff, sizeof(discid));
+ for (i = optind; i < argc; i++) {
+ open_dvd(argv[i], 0, &dvd);
+ if (dvd_id(id, dvd, dif, argv[i]))
+ st = 2;
+ else {
+ if (argc - optind > 1) printf("%s: ", argv[i]);
+ printf("%s\n", id);
+ }
+ DVDClose(dvd);
}
- fputs(volid, stdout); fputc('-', stdout);
- puthex(volsetid, sizeof(volsetid), stdout); fputc(':', stdout);
- puthex(discid, sizeof(discid), stdout); fputc('\n', stdout);
-
- if (dvd) DVDClose(dvd);
progress_free(&progress);
- return (0);
+ return (st);
}