From d1bec6768ca784b88d29ec808aaaa324feb6af9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Nordheim?= Date: Mon, 27 Feb 2023 17:41:41 +0100 Subject: [PATCH] DNS Lookup: reflow some code to avoid exceeding column limit Task-number: QTBUG-108873 Change-Id: Ic17ded256152f7d89bd200ea0e163f2b8f1ea70a Reviewed-by: Marc Mutz (cherry picked from commit a6dc86091510ce40105db3b57c637d699046ced9) Reviewed-by: Qt Cherry-pick Bot --- examples/network/dnslookup/dnslookup.cpp | 46 ++++++++++++++++-------- 1 file changed, 31 insertions(+), 15 deletions(-) diff --git a/examples/network/dnslookup/dnslookup.cpp b/examples/network/dnslookup/dnslookup.cpp index 71bb6a8131a..282d6127c22 100644 --- a/examples/network/dnslookup/dnslookup.cpp +++ b/examples/network/dnslookup/dnslookup.cpp @@ -126,35 +126,47 @@ void DnsManager::showResults() // CNAME records const QList cnameRecords = dns->canonicalNameRecords(); - for (const QDnsDomainNameRecord &record : cnameRecords) - printf("%s\t%i\tIN\tCNAME\t%s\n", qPrintable(record.name()), record.timeToLive(), qPrintable(record.value())); + for (const QDnsDomainNameRecord &record : cnameRecords) { + printf("%s\t%i\tIN\tCNAME\t%s\n", qPrintable(record.name()), record.timeToLive(), + qPrintable(record.value())); + } // A and AAAA records const QList aRecords = dns->hostAddressRecords(); for (const QDnsHostAddressRecord &record : aRecords) { - const char *type = (record.value().protocol() == QAbstractSocket::IPv6Protocol) ? "AAAA" : "A"; - printf("%s\t%i\tIN\t%s\t%s\n", qPrintable(record.name()), record.timeToLive(), type, qPrintable(record.value().toString())); + const char *type = + (record.value().protocol() == QAbstractSocket::IPv6Protocol) ? "AAAA" : "A"; + printf("%s\t%i\tIN\t%s\t%s\n", qPrintable(record.name()), record.timeToLive(), type, + qPrintable(record.value().toString())); } // MX records const QList mxRecords = dns->mailExchangeRecords(); - for (const QDnsMailExchangeRecord &record : mxRecords) - printf("%s\t%i\tIN\tMX\t%u %s\n", qPrintable(record.name()), record.timeToLive(), record.preference(), qPrintable(record.exchange())); + for (const QDnsMailExchangeRecord &record : mxRecords) { + printf("%s\t%i\tIN\tMX\t%u %s\n", qPrintable(record.name()), record.timeToLive(), + record.preference(), qPrintable(record.exchange())); + } // NS records const QList nsRecords = dns->nameServerRecords(); - for (const QDnsDomainNameRecord &record : nsRecords) - printf("%s\t%i\tIN\tNS\t%s\n", qPrintable(record.name()), record.timeToLive(), qPrintable(record.value())); + for (const QDnsDomainNameRecord &record : nsRecords) { + printf("%s\t%i\tIN\tNS\t%s\n", qPrintable(record.name()), record.timeToLive(), + qPrintable(record.value())); + } // PTR records const QList ptrRecords = dns->pointerRecords(); - for (const QDnsDomainNameRecord &record : ptrRecords) - printf("%s\t%i\tIN\tPTR\t%s\n", qPrintable(record.name()), record.timeToLive(), qPrintable(record.value())); + for (const QDnsDomainNameRecord &record : ptrRecords) { + printf("%s\t%i\tIN\tPTR\t%s\n", qPrintable(record.name()), record.timeToLive(), + qPrintable(record.value())); + } // SRV records const QList srvRecords = dns->serviceRecords(); - for (const QDnsServiceRecord &record : srvRecords) - printf("%s\t%i\tIN\tSRV\t%u %u %u %s\n", qPrintable(record.name()), record.timeToLive(), record.priority(), record.weight(), record.port(), qPrintable(record.target())); + for (const QDnsServiceRecord &record : srvRecords) { + printf("%s\t%i\tIN\tSRV\t%u %u %u %s\n", qPrintable(record.name()), record.timeToLive(), + record.priority(), record.weight(), record.port(), qPrintable(record.target())); + } // TXT records const QList txtRecords = dns->textRecords(); @@ -163,7 +175,8 @@ void DnsManager::showResults() const QList dnsRecords = record.values(); for (const QByteArray &ba : dnsRecords) values << "\"" + QString::fromLatin1(ba) + "\""; - printf("%s\t%i\tIN\tTXT\t%s\n", qPrintable(record.name()), record.timeToLive(), qPrintable(values.join(' '))); + printf("%s\t%i\tIN\tTXT\t%s\n", qPrintable(record.name()), record.timeToLive(), + qPrintable(values.join(' '))); } QCoreApplication::instance()->quit(); @@ -175,9 +188,12 @@ int main(int argc, char *argv[]) //! [1] QCoreApplication::setApplicationVersion(QT_VERSION_STR); - QCoreApplication::setApplicationName(QCoreApplication::translate("QDnsLookupExample", "DNS Lookup Example")); + QCoreApplication::setApplicationName(QCoreApplication::translate("QDnsLookupExample", + "DNS Lookup Example")); QCommandLineParser parser; - parser.setApplicationDescription(QCoreApplication::translate("QDnsLookupExample", "An example demonstrating the class QDnsLookup.")); + parser.setApplicationDescription(QCoreApplication::translate("QDnsLookupExample", + "An example demonstrating the " + "class QDnsLookup.")); DnsQuery query; QString errorMessage; switch (parseCommandLine(parser, &query, &errorMessage)) {