10#include <qplatformdefs.h>
15#include <netinet/in.h>
19# define _PATH_RESCONF "/etc/resolv.conf"
28#if defined(RES_NORELOAD)
33#elif defined(Q_OS_DARWIN)
38#elif defined(Q_OS_FREEBSD)
42#elif defined(Q_OS_OPENBSD)
46#elif defined(Q_OS_QNX)
52#if QT_CONFIG(libresolv)
56 Q_CONSTINIT
static QT_STATBUF lastStat = {};
61 if ((_res.options & RES_INIT) == 0)
63 else if (lastStat.st_ctime != st.st_ctime)
65 else if (lastStat.st_dev != st.st_dev || lastStat.st_ino != st.st_ino)
79#if defined(QHOSTINFO_DEBUG)
80 qDebug(
"QHostInfoAgent::fromName(%s) looking up...",
87 if (
address.setAddress(hostName))
95#if QT_CONFIG(libresolv)
96 auto domainNameFromRes = [](res_state
r) {
104 std::remove_pointer_t<res_state>
state = {};
105 if (res_ninit(&
state) == 0) {
108 return domainNameFromRes(&
state);
113 return domainNameFromRes(&_res);
123 while (!resolvconf.
atEnd()) {
const char * constData() const noexcept
Returns a pointer to the const data stored in the byte array.
qsizetype indexOf(char c, qsizetype from=0) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
void truncate(qsizetype pos)
Truncates the byte array at index position pos.
bool atEnd() const override
Returns true if the end of the file has been reached; otherwise returns false.
bool open(OpenMode flags) override
Opens the file using OpenMode mode, returning true if successful; otherwise false.
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.
qint64 readLine(char *data, qint64 maxlen)
This function reads a line of ASCII characters from the device, up to a maximum of maxSize - 1 bytes,...
\macro QT_RESTRICTED_CAST_FROM_ASCII
QByteArray toLatin1() 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
Returns a string that contains n characters of this string, starting at the specified position index.
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
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]