diff options
author | Marc Espie <espie@cvs.openbsd.org> | 2002-04-18 22:17:05 +0000 |
---|---|---|
committer | Marc Espie <espie@cvs.openbsd.org> | 2002-04-18 22:17:05 +0000 |
commit | 75340452b44e7d91dbf8abc374302369e93e097c (patch) | |
tree | fd046a6c6354aa47b90b21696f30dfdf8533deee /usr.bin/cdio/cdio.c | |
parent | 8d4629648eebbb8ea3bb97dc8e39914e6ff42500 (diff) |
Reuse cddb code to support FreeBSD new cdid command.
(who knows ? scripts might use it).
ok fgs@, pval@
Diffstat (limited to 'usr.bin/cdio/cdio.c')
-rw-r--r-- | usr.bin/cdio/cdio.c | 39 |
1 files changed, 37 insertions, 2 deletions
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; |