1 /* $OpenBSD: extern.h,v 1.17 2021/11/28 19:28:42 deraadt Exp $ */ 2 /* 3 * Copyright (c) 2002 Marc Espie. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. 13 * 14 * THIS SOFTWARE IS PROVIDED BY THE OPENBSD PROJECT AND CONTRIBUTORS 15 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 16 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 17 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OPENBSD 18 * PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 19 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 20 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 */ 26 27 #include <sys/queue.h> 28 29 #define cdio_isset(a,i) ((a)[(i)>>3] & (1<<((i)&(NBBY-1)))) 30 #define cdio_setbit(a,i) ((a)[(i)>>3] |= 1<<((i)&(NBBY-1))) 31 32 struct cd_toc_entry; 33 struct track_info { 34 off_t sz; 35 off_t off; 36 u_int blklen; 37 int fd; 38 char *file; 39 SLIST_ENTRY(track_info) track_list; 40 char type; 41 int speed; 42 }; 43 SLIST_HEAD(track_head, track_info); 44 extern struct track_head tracks; 45 46 /* Read/Write speed */ 47 #define DRIVE_SPEED_MAX 0xfffe 48 #define DRIVE_SPEED_OPTIMAL 0xffff /* automatically adjusted by drive */ 49 50 /* Convert writing speed into Kbytes/sec (1x - 75 frames per second) */ 51 #define CD_SPEED_TO_KBPS(x, blksz) ((x) * 75 * (blksz) / 1024) 52 53 /* 54 * It's maximum possible speed for CD (audio track). 55 * Data tracks theoretically can be written at 436x but in practice I 56 * believe, 380x will be never reached. 57 * NOTE: this value must never be changed to a bigger value, it can cause 58 * DRIVE_SPEED_MAX overrun. 59 */ 60 #define CD_MAX_SPEED 380 61 62 /* MMC feature codes */ 63 #define MMC_FEATURE_CDRW_CAV 0x27 /* Constant Angular Velocity */ 64 #define MMC_FEATURE_CD_TAO 0x2d /* Track-At-Once writing mode */ 65 #define MMC_FEATURE_CDRW_WRITE 0x37 /* media is CD-RW and can be written */ 66 67 #define MMC_FEATURE_MAX 0x0110 68 69 /* Media types */ 70 #define MEDIATYPE_UNKNOWN 0 71 #define MEDIATYPE_CDR 1 72 #define MEDIATYPE_CDRW 2 73 74 extern unsigned long entry2time(struct cd_toc_entry *); 75 extern unsigned long entry2frames(struct cd_toc_entry *); 76 extern int open_cd(char *, int); 77 extern char ** cddb(const char *, int, struct cd_toc_entry *, char *); 78 extern unsigned long cddb_discid(int, struct cd_toc_entry *); 79 extern void free_names(char **); 80 extern int get_media_type(void); 81 extern int get_media_capabilities(u_int8_t *, int); 82 extern int blank(void); 83 extern int unit_ready(void); 84 extern int synchronize_cache(void); 85 extern int close_session(void); 86 extern int get_disc_size(off_t *); 87 extern int get_nwa(int *); 88 extern int writetao(struct track_head *); 89 extern int writetrack(struct track_info *, int); 90 extern int mode_sense_write(unsigned char []); 91 extern int mode_select_write(unsigned char []); 92 extern int cdrip(char *); 93 extern int cdplay(char *); 94 95 #define VERSION "2.1" 96 #define WAVHDRLEN 44 97