10#include <qplatformdefs.h>
15#include <netinet/in.h>
17#if QT_CONFIG(libresolv)
22# define _PATH_RESCONF "/etc/resolv.conf"
31#if defined(RES_NORELOAD)
36#elif defined(Q_OS_DARWIN)
41#elif defined(Q_OS_FREEBSD)
45#elif defined(Q_OS_OPENBSD)
49#elif defined(Q_OS_QNX)
55#if QT_CONFIG(libresolv)
59 Q_CONSTINIT
static QT_STATBUF lastStat = {};
64 if ((_res.options & RES_INIT) == 0)
66 else if (lastStat.st_ctime != st.st_ctime)
68 else if (lastStat.st_dev != st.st_dev || lastStat.st_ino != st.st_ino)
82#if defined(QHOSTINFO_DEBUG)
83 qDebug(
"QHostInfoAgent::fromName(%s) looking up...",
90 if (
address.setAddress(hostName))
98#if QT_CONFIG(libresolv)
99 auto domainNameFromRes = [](res_state
r) {
103 if (domainName.isEmpty())
107 std::remove_pointer_t<res_state>
state = {};
108 if (res_ninit(&
state) == 0) {
111 return domainNameFromRes(&
state);
116 return domainNameFromRes(&_res);
126 while (!resolvconf.atEnd()) {
127 const QByteArray lineArray = resolvconf.readLine();
139 searchDomain.truncate(
pos);
QByteArrayView trimmed() const noexcept
const char * constData() const noexcept
Returns a pointer to the const data stored in the byte array.
void setFileName(const QString &name)
Sets the name of the file.
The QHostAddress class provides an IP address.
static QHostInfo lookup(const QString &hostName)
static QHostInfo reverseLookup(const QHostAddress &address)
static QHostInfo fromName(const QString &hostName)
The QHostInfo class provides static functions for host name lookups.
static QString localDomainName()
Returns the DNS domain of this machine.
\macro QT_RESTRICTED_CAST_FROM_ASCII
QByteArray toLatin1() const &
qsizetype indexOf(QLatin1StringView s, qsizetype from=0, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
bool startsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string starts with s; otherwise returns false.
QString mid(qsizetype position, qsizetype n=-1) const &
QString trimmed() const &
static QString fromAce(const QByteArray &domain, AceProcessingOptions options={})
Combined button and popup list for selecting options.
static void maybeRefreshResolver()
GLuint GLuint64EXT address
QScopeGuard< typename std::decay< F >::type > qScopeGuard(F &&f)
[qScopeGuard]