vfs: check userland buffers before reading them.
[haiku.git] / src / bin / cddb_lookup / cddb_server.h
blobed0f9f3a7bce33c330df31b00b615e07c573ccdb
1 /*
2 * Copyright 2008-2016, Haiku, Inc. All Rights Reserved.
3 * Distributed under the terms of the MIT License.
5 * Authors:
6 * Bruno Albuquerque, bga@bug-br.org.br
7 */
8 #ifndef _CDDB_SERVER_H
9 #define _CDDB_SERVER_H
12 #include <NetAddress.h>
13 #include <NetEndpoint.h>
14 #include <ObjectList.h>
15 #include <String.h>
17 #include <scsi_cmds.h>
20 // CD track specific data.
21 struct TrackData {
22 uint32 trackNumber;
23 BString title;
24 BString artist;
28 // Query command response.
29 struct QueryResponseData {
30 BString category;
31 BString cddbID;
32 BString artist;
33 BString title;
37 // Read command response.
38 struct ReadResponseData {
39 BString title;
40 BString artist;
41 BString genre;
42 uint32 year;
43 BObjectList<TrackData> tracks;
45 ReadResponseData()
47 tracks(20, true)
53 typedef BObjectList<QueryResponseData> QueryResponseList;
56 class CDDBServer {
57 public:
58 CDDBServer(const BString& cddbServer);
60 // CDDB commands interface.
61 status_t Query(uint32 cddbID, const scsi_toc_toc* toc,
62 QueryResponseList& queryResponses);
63 status_t Read(const QueryResponseData& diskData,
64 ReadResponseData& readResponse,
65 bool verbose = false);
66 status_t Read(const BString& category,
67 const BString& cddbID,
68 const BString& artist,
69 ReadResponseData& readResponse,
70 bool verbose = false);
72 private:
73 status_t _ParseAddress(const BString& cddbServer);
75 status_t _OpenConnection();
76 void _CloseConnection();
78 status_t _SendCommand(const BString& command,
79 BString& output);
80 TrackData* _Track(ReadResponseData& response,
81 uint32 track) const;
83 private:
84 BString fLocalHostName;
85 BString fLocalUserName;
86 BNetAddress fServerAddress;
87 BNetEndpoint fConnection;
88 bool fInitialized;
89 bool fConnected;
93 #endif // _CDDB_SERVER_H