ftp://ftp.redhat.com/pub/redhat/linux/rawhide/SRPMS/SRPMS/gnome-vfs2-2.3.8-1.src.rpm
[gnome-vfs-httpcaptive.git] / modules / cdda-cddb.h
1 /*****************************************************************
2
3   cdda-cddb.h
4
5   Based on code from libcdaudio 0.5.0 (Copyright (C)1998 Tony Arcieri)
6
7   All changes copyright (c) 1998 by Mike Oliphant - oliphant@ling.ed.ac.uk
8
9     http://www.ling.ed.ac.uk/~oliphant/grip
10
11   This program is distributed in the hope that it will be useful,
12   but WITHOUT ANY WARRANTY; without even the implied warranty of
13   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14   GNU General Public License for more details.
15
16   You should have received a copy of the GNU General Public License
17   along with this program; if not, write to the Free Software
18   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
19
20 *****************************************************************/
21
22 #ifndef CDDA_CDDB_H
23 #define CDDA_CDDB_H
24
25 #include <glib/gtypes.h>
26 #include <stdio.h>
27
28 #define size16 short
29 #define size32 int
30
31 #include <cdda_interface.h>
32
33 #define CURRENT_CDDBREVISION            2
34 #define MAX_TRACKS                                      100
35
36 /* CDDB hello structure */
37 struct CDDBHello {
38    /* Program */
39    char hello_program[256];
40    /* Program version */
41    char hello_version[256];
42 };
43
44 /* Used for keeping track of times */
45 struct disc_timeval {
46    int minutes;
47    int seconds;
48 };
49
50 /* Track specific information */
51 struct track_info {
52   struct disc_timeval track_length;
53   struct disc_timeval track_pos;
54   int track_frames;
55   int track_start;
56 };
57
58 /* Disc information such as current track, amount played, etc */
59 typedef struct {
60         int disc_present;                               /* Is disc present? */
61         int disc_mode;                          /* Current disc mode */
62         struct disc_timeval track_time;         /* Current track time */
63         struct disc_timeval disc_time;          /* Current disc time */
64         struct disc_timeval disc_length;                /* Total disc length */
65         int disc_frame;                         /* Current frame */
66         int disc_track;                         /* Current track */
67         int disc_totaltracks;                   /* Number of tracks on disc */
68         struct track_info track[MAX_TRACKS];            /* Track specific information */
69 } disc_info;
70
71 /* HTTP proxy server structure */
72 typedef struct _proxy_server {
73   char name[256];
74   int port;
75 } ProxyServer;
76
77 /* CDDB server structure */
78
79 typedef struct _cddb_server {
80         char name[256];
81         char cgi_prog[256];
82         int port;
83         int use_proxy;
84         ProxyServer *proxy;
85 } CDDBServer;
86
87 #define CDDA_CDDB_LEVEL "3"  /* Current CDDB protocol level supported */
88
89 /* CDDB entry */
90 typedef struct _cddb_entry {
91    unsigned int entry_id;
92    int entry_genre;
93 } CDDBEntry;
94
95 /* CDDB hello structure */
96 typedef struct _cddb_hello {
97    /* Program */
98    char hello_program[256];
99    /* Program version */
100    char hello_version[256];
101 } CDDBHello;
102
103 #define MAX_INEXACT_MATCHES                     16
104
105 /* An entry in the query list */
106 struct query_list_entry {
107    int list_genre;
108    int list_id;
109    char list_title[64];
110    char list_artist[64];
111 };
112
113 /* CDDB query structure */
114 typedef struct _cddb_query {
115    int query_match;
116    int query_matches;
117    struct query_list_entry query_list[MAX_INEXACT_MATCHES];
118 } CDDBQuery;
119
120 /* Match values returned by a query */
121
122 #define MATCH_NOMATCH    0
123 #define MATCH_EXACT      1
124 #define MATCH_INEXACT    2
125
126 /* Track database structure */
127
128 typedef struct _track_data {
129         char track_name[256];           /* Track name */
130         char track_artist[256];         /* Track artist */
131         char track_extended[4096];              /* Extended information */
132 } TrackData;
133
134 /* Disc database structure */
135 typedef struct _disc_data {
136         unsigned int data_id;                           /* CD id */
137         char data_title[256];                   /* Disc title */
138         char data_artist[256];                  /* We may be able to extract this */
139         char data_extended[4096];               /* Extended information */
140         int data_genre;                                 /* Disc genre */
141         int data_year;                      /* Disc year */
142         char data_playlist[256];            /* Playlist info */
143         gboolean data_multi_artist;         /* Is CD multi-artist? */
144         TrackData data_track[MAX_TRACKS];   /* Track names */
145 } DiscData;
146
147
148 /* Encode list structure */
149 typedef struct _encode_track {
150         int track_num;
151         int start_frame;
152         int end_frame;
153         char song_name[80];
154         char song_artist[80];
155         char disc_name[80];
156         char disc_artist[80];
157         int song_year;
158         int id3_genre;
159         int mins;
160         int secs;
161         int discid;
162 } EncodeTrack;
163
164
165 unsigned int CDDBDiscid(cdrom_drive *drive);
166 char *CDDBGenre(int genre);
167 int CDDBGenreValue(char *genre);
168 gboolean CDDBDoQuery(cdrom_drive *cd_desc, CDDBServer *server, CDDBHello *hello,CDDBQuery *query);
169 gboolean CDDBRead(cdrom_drive *cd_desc,CDDBServer *server, CDDBHello *hello,CDDBEntry *entry, DiscData *data);
170 gboolean CDDBRead(cdrom_drive *cd_desc,CDDBServer *server, CDDBHello *hello,CDDBEntry *entry, DiscData *data);
171 gboolean CDDBStatDiscData(cdrom_drive *cd_desc);
172 int CDDBReadDiscData(cdrom_drive *cd_desc, DiscData *outdata);
173 int CDDBWriteDiscData(cdrom_drive *drive, DiscData *ddata,FILE *outfile, gboolean gripext);
174 void CDDBParseTitle(char *buf,char *title,char *artist,char *sep);
175 char *ChopWhite(char *buf);
176 gboolean CDDBLookupDisc (CDDBServer *server, cdrom_drive *drive, DiscData *disc_data);
177 int CDStat(int cd_desc, disc_info *disc, gboolean read_toc);
178
179 #endif