diff options
-rw-r--r-- | usr.bin/cdio/cddb.c | 3 | ||||
-rw-r--r-- | usr.bin/cdio/cdio.c | 39 | ||||
-rw-r--r-- | usr.bin/cdio/extern.h | 1 |
3 files changed, 39 insertions, 4 deletions
diff --git a/usr.bin/cdio/cddb.c b/usr.bin/cdio/cddb.c index f53ee0da49c..9f90acee75a 100644 --- a/usr.bin/cdio/cddb.c +++ b/usr.bin/cdio/cddb.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cddb.c,v 1.3 2002/04/18 22:07:04 espie Exp $ */ +/* $OpenBSD: cddb.c,v 1.4 2002/04/18 22:17:04 espie Exp $ */ /* * Copyright (c) 2002 Marc Espie. * @@ -37,7 +37,6 @@ #include <vis.h> #include "extern.h" -unsigned long cddb_discid(int, struct cd_toc_entry *); unsigned long cddb_sum(unsigned long); void send_hello(FILE *); void send_query(FILE *, int, struct cd_toc_entry *); diff --git a/usr.bin/cdio/cdio.c b/usr.bin/cdio/cdio.c index 82454ddc13b..211d2317283 100644 --- a/usr.bin/cdio/cdio.c +++ b/usr.bin/cdio/cdio.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cdio.c,v 1.24 2002/04/18 20:18:31 espie Exp $ */ +/* $OpenBSD: cdio.c,v 1.25 2002/04/18 22:17:04 espie Exp $ */ /* * Compact Disc Control Utility by Serge V. Vakulenko <vak@cronyx.ru>. * Based on the non-X based CD player by Jean-Marc Zucconi and @@ -67,6 +67,7 @@ #define CMD_PREV 17 #define CMD_REPLAY 18 #define CMD_CDDB 19 +#define CMD_CDID 20 struct cmdtab { int command; @@ -96,7 +97,8 @@ struct cmdtab { { CMD_STATUS, "status", 1, "" }, { CMD_STOP, "stop", 3, "" }, { CMD_VOLUME, "volume", 1, "<l> <r> | left | right | mute | mono | stereo" }, -{ CMD_CDDB, "cddbinfo", 2, "[n]" }, +{ CMD_CDDB, "cddbinfo", 2, "[n]" }, +{ CMD_CDID, "cdid", 2, "" }, { 0, 0, 0, 0} }; @@ -135,6 +137,7 @@ char *parse(char *buf, int *cmd); void help(void); void usage(void); char *strstatus(int); +int cdid(void); void help() @@ -281,6 +284,11 @@ run(int cmd, char *arg) return cddbinfo(arg); + case CMD_CDID: + if (fd < 0 && ! open_cd(cdname)) + return (0); + return cdid(); + case CMD_STATUS: if (fd < 0 && ! open_cd(cdname)) return (0); @@ -887,6 +895,33 @@ pstatus(char *arg) } int +cdid() +{ + unsigned long id; + struct ioc_toc_header h; + int rc, n; + + rc = ioctl(fd, CDIOREADTOCHEADER, &h); + if (rc == -1) { + warn("getting toc header"); + return (rc); + } + + n = h.ending_track - h.starting_track + 1; + rc = read_toc_entrys((n + 1) * sizeof (struct cd_toc_entry)); + if (rc < 0) + return (rc); + + id = cddb_discid(n, toc_buffer); + if (id) { + if (verbose) + printf("CDID="); + printf("%08lx\n", id); + } + return id ? 0 : 1; +} + +int info(char *arg) { struct ioc_toc_header h; diff --git a/usr.bin/cdio/extern.h b/usr.bin/cdio/extern.h index da36276f2b2..9ea3469ef5d 100644 --- a/usr.bin/cdio/extern.h +++ b/usr.bin/cdio/extern.h @@ -29,6 +29,7 @@ struct cd_toc_entry; extern unsigned long entry2time(struct cd_toc_entry *); extern unsigned long entry2frames(struct cd_toc_entry *); extern char ** cddb(const char *, int, struct cd_toc_entry *, char *); +extern unsigned long cddb_discid(int, struct cd_toc_entry *); extern void free_names(char **); #define VERSION "2.1" |