aboutsummaryrefslogtreecommitdiffstats
path: root/audio/dagrab/files/patch-ab
blob: 6d48f8c9324c88f11bec7de08cc388a0323a26b1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
--- dagrab.c.orig   Sun Feb 20 01:32:46 2000
+++ dagrab.c    Mon Aug  7 19:29:28 2000
@@ -94,26 +94,20 @@
 #include <string.h>
 #include <errno.h>
 #include <fcntl.h>
-#include <getopt.h>
 #include <dirent.h>
 #include <netdb.h>
-#include <unistd.h>
 #include <pwd.h>
 #include <ctype.h>
-#define __need_timeval   /* needed by glibc */
-#include <time.h>
-#include <linux/cdrom.h>
-#ifdef USE_UCDROM
-#include <linux/ucdrom.h>
-#endif
-#include <sys/vfs.h>
 #include <sys/stat.h>
 #include <sys/types.h>
 #include <sys/ioctl.h>
 #include <sys/socket.h>
 #include <netinet/in.h>
+#include <sys/cdio.h>
+#include <sys/param.h>
+#include <sys/mount.h>
 #define CDDEVICE "/dev/cdrom"
-#define N_BUF 8
+#define N_BUF 12
 #define OVERLAP 2
 #define KEYLEN 12
 #define OFS 12
@@ -123,12 +117,18 @@
 #define D_MODE 0660
 #define CDDB_MAX  65535
 #define CDDB_PORT 888
+#ifndef CDDB_PATH
 #define CDDB_PATH "/usr/lib/X11/xmcd/cddb"
+#endif
 #define CDDB_HOST "freedb.freedb.org"
 //#define USE_CDDB (opt_save||opt_name)
 #define USE_CDDB opt_cddb
 #define PROGNAME "dagrab"
 #define VERSION "0.3.5"
+#define CD_MSF_OFFSET 150
+#define CDROM_DATA_TRACK 4
+#define CDROM_LEADOUT 0xaa
+#define CD_FRAMESIZE_RAW 2352
 #define KW_TRACK 0
 #define KW_FULLD 1
 #define KW_AUTHOR 2
@@ -226,16 +226,16 @@
   return buf;
 }
 
-int cd_get_tochdr(struct cdrom_tochdr *Th)
+int cd_get_tochdr(struct ioc_toc_header *Th)
 {
-   return ioctl(cdrom_fd,CDROMREADTOCHDR,Th);
+   return ioctl(cdrom_fd,CDIOREADTOCHEADER,Th);
 }
 
-int cd_get_tocentry(int trk,struct cdrom_tocentry *Te,int mode)
+int cd_get_tocentry(int trk,struct ioc_read_toc_single_entry *Te,int mode)
 {
-  Te->cdte_track=trk;
-  Te->cdte_format=mode;
-  return ioctl(cdrom_fd,CDROMREADTOCENTRY,Te);
+  Te->track=trk;
+  Te->address_format=mode;
+  return ioctl(cdrom_fd,CDIOREADTOCENTRY,Te);
 }
 
 void cd_read_audio(int lba,int num,char *buf)
@@ -244,13 +244,13 @@
    /*NOTE: if num>CDROM_NBLOCKS_BUFFER as defined in ide_cd.c (8 in linux 2.0.32)
      jitter correction may be required inside the block. */                       
 {
-   struct cdrom_read_audio ra;
+   struct ioc_read_audio ra;
 
-   ra.addr.lba=lba;
-   ra.addr_format=CDROM_LBA;
+   ra.address.lba=lba;
+   ra.address_format=CD_LBA_FORMAT;
    ra.nframes=num;
-   ra.buf=buf;
-   if(ioctl(cdrom_fd,CDROMREADAUDIO,&ra)){
+   ra.buffer=buf;
+   if(ioctl(cdrom_fd,CDIOCREADAUDIO,&ra)){
        /*fprintf(stderr,"%s: read raw ioctl failed \n",progname);*/
        fprintf(stderr,"\n%s: read raw ioctl failed at lba %d length %d: %s\n",
                progname,lba,num,strerror(errno));
@@ -471,7 +471,7 @@
   DIR *d;
   struct dirent *e;
   char *id2,*p,*cddb,*loc;
-  int i,cddbs,locs;
+  int i,cddbs,locs=0;
   char id[12];
   char *path;
   char path2[500];
@@ -645,10 +645,10 @@
 int cd_getinfo(char *cd_dev,struct cd_trk_list *tl)
 {
    int i;
-   struct cdrom_tochdr Th;
-   struct cdrom_tocentry Te;
+   struct ioc_toc_header Th;
+   struct ioc_read_toc_single_entry Te;
 
-   if ((cdrom_fd=open(cd_dev,O_RDONLY|O_NONBLOCK))==-1){
+   if ((cdrom_fd=open(cd_dev,O_RDONLY))==-1){
        fprintf(stderr,"%s: error opening device %s\n",progname,cd_dev);
        exit(1);
    }
@@ -656,7 +656,7 @@
        fprintf(stderr,"%s: read TOC ioctl failed: %s\n",progname,strerror(errno));
        exit(1);
    }
-   tl->min=Th.cdth_trk0;tl->max=Th.cdth_trk1;
+   tl->min=Th.starting_track;tl->max=Th.ending_track;
    if((tl->starts=(int *)malloc((tl->max-tl->min+2)*sizeof(int)))==NULL){
        fprintf(stderr,"%s: list data allocation failed\n",progname);
        exit(1);
@@ -668,21 +668,21 @@
 
    for (i=tl->min;i<=tl->max;i++)
    {
-       if(cd_get_tocentry(i,&Te,CDROM_LBA)){
+       if(cd_get_tocentry(i,&Te,CD_LBA_FORMAT)){
            fprintf(stderr,"%s: read TOC entry ioctl failed: %s\n",
                progname,strerror(errno));
            exit(1);
        }
-       tl->starts[i-tl->min]=Te.cdte_addr.lba;
-       tl->types[i-tl->min]=Te.cdte_ctrl&CDROM_DATA_TRACK;
+       tl->starts[i-tl->min]=ntohl(Te.entry.addr.lba);
+       tl->types[i-tl->min]=Te.entry.control&CDROM_DATA_TRACK;
    }
    i=CDROM_LEADOUT;
-   if(cd_get_tocentry(i,&Te,CDROM_LBA)){
+   if(cd_get_tocentry(i,&Te,CD_LBA_FORMAT)){
        fprintf(stderr,"%s: read TOC entry ioctl failed: %s\n",progname,strerror(errno));
        exit(1);
    }
-   tl->starts[tl->max-tl->min+1]=Te.cdte_addr.lba;
-   tl->types[tl->max-tl->min+1]=Te.cdte_ctrl&CDROM_DATA_TRACK;
+   tl->starts[tl->max-tl->min+1]=ntohl(Te.entry.addr.lba);
+   tl->types[tl->max-tl->min+1]=Te.entry.control&CDROM_DATA_TRACK;
    
         i=cddb_main(tl);
    if(i==-1) {
@@ -961,7 +961,7 @@
 int main(int ac,char **av)
 {
    int i,l,disp_TOC=0;
-   char c;
+   int c;
    int all_tracks=0;
    struct cd_trk_list tl;
    char cd_dev[BLEN+1]=CDDEVICE;
@@ -969,10 +969,8 @@
    char filter[BLEN+1] = "";
    char path[500];
    FILE *f;
-
    progname=av[0];
-   optind=0;
-   while((c=getopt(ac,av,"d:f:n:o:k:r:t:m:e:H:P:D:pshaivCSN"))!=EOF){
+   while((c=getopt(ac,av,"pshaivCSNd:f:n:o:k:r:t:m:e:H:P:D:"))!=-1){
        switch(c){
            case 'h':usage();break;
            case 'd':CPARG(cd_dev);break;