cddb_lookup: verbose now dumps server response.
* The pretty dump output is now only used for the -d and -i options.
This commit is contained in:
@@ -38,7 +38,7 @@ public:
|
|||||||
status_t Lookup(CDDBServer& server, const dev_t device,
|
status_t Lookup(CDDBServer& server, const dev_t device,
|
||||||
bool dumpOnly, bool verbose);
|
bool dumpOnly, bool verbose);
|
||||||
status_t Dump(CDDBServer& server, const char* category,
|
status_t Dump(CDDBServer& server, const char* category,
|
||||||
const char* cddbID);
|
const char* cddbID, bool verbose);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool _ReadTOC(const dev_t device, uint32* cddbID,
|
bool _ReadTOC(const dev_t device, uint32* cddbID,
|
||||||
@@ -147,14 +147,14 @@ CDDBLookup::Lookup(CDDBServer& server, const dev_t device, bool dumpOnly,
|
|||||||
}
|
}
|
||||||
|
|
||||||
ReadResponseData readResponse;
|
ReadResponseData readResponse;
|
||||||
result = server.Read(*diskData, readResponse);
|
result = server.Read(*diskData, readResponse, verbose);
|
||||||
if (result != B_OK) {
|
if (result != B_OK) {
|
||||||
fprintf(stderr, "Could not read detailed CD entry from server: %s\n",
|
fprintf(stderr, "Could not read detailed CD entry from server: %s\n",
|
||||||
strerror(result));
|
strerror(result));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (verbose || dumpOnly)
|
if (dumpOnly)
|
||||||
_Dump(readResponse);
|
_Dump(readResponse);
|
||||||
|
|
||||||
if (!dumpOnly) {
|
if (!dumpOnly) {
|
||||||
@@ -169,10 +169,11 @@ CDDBLookup::Lookup(CDDBServer& server, const dev_t device, bool dumpOnly,
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
CDDBLookup::Dump(CDDBServer& server, const char* category, const char* cddbID)
|
CDDBLookup::Dump(CDDBServer& server, const char* category, const char* cddbID,
|
||||||
|
bool verbose)
|
||||||
{
|
{
|
||||||
ReadResponseData readResponse;
|
ReadResponseData readResponse;
|
||||||
status_t status = server.Read(category, cddbID, "", readResponse);
|
status_t status = server.Read(category, cddbID, "", readResponse, verbose);
|
||||||
if (status != B_OK) {
|
if (status != B_OK) {
|
||||||
fprintf(stderr, "Could not read detailed CD entry from server: %s\n",
|
fprintf(stderr, "Could not read detailed CD entry from server: %s\n",
|
||||||
strerror(status));
|
strerror(status));
|
||||||
@@ -402,7 +403,7 @@ main(int argc, char* const* argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
const char* cddbID = argv[optind];
|
const char* cddbID = argv[optind];
|
||||||
cddb.Dump(server, category, cddbID);
|
cddb.Dump(server, category, cddbID, verbose);
|
||||||
} else {
|
} else {
|
||||||
// Lookup via actual CD
|
// Lookup via actual CD
|
||||||
if (left > 0) {
|
if (left > 0) {
|
||||||
|
|||||||
@@ -153,16 +153,16 @@ CDDBServer::Query(uint32 cddbID, const scsi_toc_toc* toc,
|
|||||||
|
|
||||||
status_t
|
status_t
|
||||||
CDDBServer::Read(const QueryResponseData& diskData,
|
CDDBServer::Read(const QueryResponseData& diskData,
|
||||||
ReadResponseData& readResponse)
|
ReadResponseData& readResponse, bool verbose)
|
||||||
{
|
{
|
||||||
return Read(diskData.category, diskData.cddbID, diskData.artist,
|
return Read(diskData.category, diskData.cddbID, diskData.artist,
|
||||||
readResponse);
|
readResponse, verbose);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
CDDBServer::Read(const BString& category, const BString& cddbID,
|
CDDBServer::Read(const BString& category, const BString& cddbID,
|
||||||
const BString& artist, ReadResponseData& readResponse)
|
const BString& artist, ReadResponseData& readResponse, bool verbose)
|
||||||
{
|
{
|
||||||
if (_OpenConnection() != B_OK)
|
if (_OpenConnection() != B_OK)
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
@@ -174,6 +174,9 @@ CDDBServer::Read(const BString& category, const BString& cddbID,
|
|||||||
BString output;
|
BString output;
|
||||||
status_t result = _SendCommand(cddbCommand, output);
|
status_t result = _SendCommand(cddbCommand, output);
|
||||||
if (result == B_OK) {
|
if (result == B_OK) {
|
||||||
|
if (verbose)
|
||||||
|
puts(output);
|
||||||
|
|
||||||
// Remove the header from the reply.
|
// Remove the header from the reply.
|
||||||
output.Remove(0, output.FindFirst("\r\n\r\n") + 4);
|
output.Remove(0, output.FindFirst("\r\n\r\n") + 4);
|
||||||
|
|
||||||
|
|||||||
@@ -61,11 +61,13 @@ public:
|
|||||||
status_t Query(uint32 cddbID, const scsi_toc_toc* toc,
|
status_t Query(uint32 cddbID, const scsi_toc_toc* toc,
|
||||||
QueryResponseList& queryResponses);
|
QueryResponseList& queryResponses);
|
||||||
status_t Read(const QueryResponseData& diskData,
|
status_t Read(const QueryResponseData& diskData,
|
||||||
ReadResponseData& readResponse);
|
ReadResponseData& readResponse,
|
||||||
|
bool verbose = false);
|
||||||
status_t Read(const BString& category,
|
status_t Read(const BString& category,
|
||||||
const BString& cddbID,
|
const BString& cddbID,
|
||||||
const BString& artist,
|
const BString& artist,
|
||||||
ReadResponseData& readResponse);
|
ReadResponseData& readResponse,
|
||||||
|
bool verbose = false);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
status_t _ParseAddress(const BString& cddbServer);
|
status_t _ParseAddress(const BString& cddbServer);
|
||||||
|
|||||||
Reference in New Issue
Block a user