DNS Lookup: Use ideomatic cstdio include
Task-number: QTBUG-108873 Pick-to: 6.5 Change-Id: I646f0c985adc45a17103b5f98394f3def4b6ada2 Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Konrad Kujawa <konrad.kujawa@qt.io> Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
This commit is contained in:
parent
af95f97466
commit
277d809ba4
@ -11,7 +11,7 @@
|
|||||||
#include <QCommandLineParser>
|
#include <QCommandLineParser>
|
||||||
#include <QCommandLineOption>
|
#include <QCommandLineOption>
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <cstdio>
|
||||||
|
|
||||||
using namespace Qt::StringLiterals;
|
using namespace Qt::StringLiterals;
|
||||||
|
|
||||||
@ -123,13 +123,13 @@ void DnsManager::execute()
|
|||||||
void DnsManager::showResults()
|
void DnsManager::showResults()
|
||||||
{
|
{
|
||||||
if (dns->error() != QDnsLookup::NoError)
|
if (dns->error() != QDnsLookup::NoError)
|
||||||
printf("Error: %i (%s)\n", dns->error(), qPrintable(dns->errorString()));
|
std::printf("Error: %i (%s)\n", dns->error(), qPrintable(dns->errorString()));
|
||||||
|
|
||||||
// CNAME records
|
// CNAME records
|
||||||
const QList<QDnsDomainNameRecord> cnameRecords = dns->canonicalNameRecords();
|
const QList<QDnsDomainNameRecord> cnameRecords = dns->canonicalNameRecords();
|
||||||
for (const QDnsDomainNameRecord &record : cnameRecords) {
|
for (const QDnsDomainNameRecord &record : cnameRecords) {
|
||||||
printf("%s\t%i\tIN\tCNAME\t%s\n", qPrintable(record.name()), record.timeToLive(),
|
std::printf("%s\t%i\tIN\tCNAME\t%s\n", qPrintable(record.name()), record.timeToLive(),
|
||||||
qPrintable(record.value()));
|
qPrintable(record.value()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// A and AAAA records
|
// A and AAAA records
|
||||||
@ -137,36 +137,37 @@ void DnsManager::showResults()
|
|||||||
for (const QDnsHostAddressRecord &record : aRecords) {
|
for (const QDnsHostAddressRecord &record : aRecords) {
|
||||||
const char *type =
|
const char *type =
|
||||||
(record.value().protocol() == QAbstractSocket::IPv6Protocol) ? "AAAA" : "A";
|
(record.value().protocol() == QAbstractSocket::IPv6Protocol) ? "AAAA" : "A";
|
||||||
printf("%s\t%i\tIN\t%s\t%s\n", qPrintable(record.name()), record.timeToLive(), type,
|
std::printf("%s\t%i\tIN\t%s\t%s\n", qPrintable(record.name()), record.timeToLive(), type,
|
||||||
qPrintable(record.value().toString()));
|
qPrintable(record.value().toString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// MX records
|
// MX records
|
||||||
const QList<QDnsMailExchangeRecord> mxRecords = dns->mailExchangeRecords();
|
const QList<QDnsMailExchangeRecord> mxRecords = dns->mailExchangeRecords();
|
||||||
for (const QDnsMailExchangeRecord &record : mxRecords) {
|
for (const QDnsMailExchangeRecord &record : mxRecords) {
|
||||||
printf("%s\t%i\tIN\tMX\t%u %s\n", qPrintable(record.name()), record.timeToLive(),
|
std::printf("%s\t%i\tIN\tMX\t%u %s\n", qPrintable(record.name()), record.timeToLive(),
|
||||||
record.preference(), qPrintable(record.exchange()));
|
record.preference(), qPrintable(record.exchange()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// NS records
|
// NS records
|
||||||
const QList<QDnsDomainNameRecord> nsRecords = dns->nameServerRecords();
|
const QList<QDnsDomainNameRecord> nsRecords = dns->nameServerRecords();
|
||||||
for (const QDnsDomainNameRecord &record : nsRecords) {
|
for (const QDnsDomainNameRecord &record : nsRecords) {
|
||||||
printf("%s\t%i\tIN\tNS\t%s\n", qPrintable(record.name()), record.timeToLive(),
|
std::printf("%s\t%i\tIN\tNS\t%s\n", qPrintable(record.name()), record.timeToLive(),
|
||||||
qPrintable(record.value()));
|
qPrintable(record.value()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// PTR records
|
// PTR records
|
||||||
const QList<QDnsDomainNameRecord> ptrRecords = dns->pointerRecords();
|
const QList<QDnsDomainNameRecord> ptrRecords = dns->pointerRecords();
|
||||||
for (const QDnsDomainNameRecord &record : ptrRecords) {
|
for (const QDnsDomainNameRecord &record : ptrRecords) {
|
||||||
printf("%s\t%i\tIN\tPTR\t%s\n", qPrintable(record.name()), record.timeToLive(),
|
std::printf("%s\t%i\tIN\tPTR\t%s\n", qPrintable(record.name()), record.timeToLive(),
|
||||||
qPrintable(record.value()));
|
qPrintable(record.value()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// SRV records
|
// SRV records
|
||||||
const QList<QDnsServiceRecord> srvRecords = dns->serviceRecords();
|
const QList<QDnsServiceRecord> srvRecords = dns->serviceRecords();
|
||||||
for (const QDnsServiceRecord &record : srvRecords) {
|
for (const QDnsServiceRecord &record : srvRecords) {
|
||||||
printf("%s\t%i\tIN\tSRV\t%u %u %u %s\n", qPrintable(record.name()), record.timeToLive(),
|
std::printf("%s\t%i\tIN\tSRV\t%u %u %u %s\n", qPrintable(record.name()),
|
||||||
record.priority(), record.weight(), record.port(), qPrintable(record.target()));
|
record.timeToLive(), record.priority(), record.weight(), record.port(),
|
||||||
|
qPrintable(record.target()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// TXT records
|
// TXT records
|
||||||
@ -176,8 +177,8 @@ void DnsManager::showResults()
|
|||||||
const QList<QByteArray> dnsRecords = record.values();
|
const QList<QByteArray> dnsRecords = record.values();
|
||||||
for (const QByteArray &ba : dnsRecords)
|
for (const QByteArray &ba : dnsRecords)
|
||||||
values << "\"" + QString::fromLatin1(ba) + "\"";
|
values << "\"" + QString::fromLatin1(ba) + "\"";
|
||||||
printf("%s\t%i\tIN\tTXT\t%s\n", qPrintable(record.name()), record.timeToLive(),
|
std::printf("%s\t%i\tIN\tTXT\t%s\n", qPrintable(record.name()), record.timeToLive(),
|
||||||
qPrintable(values.join(' ')));
|
qPrintable(values.join(' ')));
|
||||||
}
|
}
|
||||||
|
|
||||||
QCoreApplication::instance()->quit();
|
QCoreApplication::instance()->quit();
|
||||||
@ -202,9 +203,10 @@ int main(int argc, char *argv[])
|
|||||||
case Status::Ok:
|
case Status::Ok:
|
||||||
break;
|
break;
|
||||||
case Status::Error:
|
case Status::Error:
|
||||||
fputs(qPrintable(parseResult.errorString.value_or(u"Unknown error occurred"_qs)), stderr);
|
std::fputs(qPrintable(parseResult.errorString.value_or(u"Unknown error occurred"_qs)),
|
||||||
fputs("\n\n", stderr);
|
stderr);
|
||||||
fputs(qPrintable(parser.helpText()), stderr);
|
std::fputs("\n\n", stderr);
|
||||||
|
std::fputs(qPrintable(parser.helpText()), stderr);
|
||||||
return 1;
|
return 1;
|
||||||
case Status::VersionRequested:
|
case Status::VersionRequested:
|
||||||
parser.showVersion();
|
parser.showVersion();
|
||||||
|
Loading…
Reference in New Issue
Block a user