Ignore:
Timestamp:
Nov 16, 2005, 8:36:46 PM (20 years ago)
Author:
dmik
Message:

Transferred Qt for OS/2 version 3.3.1-rc5 sources from the CVS

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/network/qdns.cpp

    r7 r8  
    7979#include <dlfcn.h>
    8080#endif
     81#if defined(Q_OS_OS2)
     82//@@TODO (dmik): currently these headers are not used
     83//  (see comments to QDns::doSynchronousLookup())
     84//#include <netinet/in.h>
     85//#include <resolv.h>
     86#endif
    8187
    8288//#define QDNS_DEBUG
     
    105111static bool ipv6support = FALSE;
    106112
     113#if defined(Q_OS_OS2)
     114//@@TODO (dmik): currently qdns_res_init() is not used
     115//  (see comments to QDns::doSynchronousLookup())
     116#else
    107117static int qdns_res_init()
    108118{
     
    116126    else
    117127        return -1;
    118 #elif defined(Q_OS_UNIX)
     128#elif defined(Q_OS_UNIX) || defined(Q_OS_OS2)
    119129    return res_init();
    120130#else
     
    122132#endif
    123133}
     134#endif
    124135
    125136
     
    129140    {
    130141#if defined(Q_DNS_SYNCHRONOUS)
    131 #if defined(Q_OS_UNIX)
     142#if defined(Q_OS_UNIX) || defined(Q_OS_OS2)
    132143        noEventLoop = qApp==0 || qApp->loopLevel()==0;
    133144#else
     
    881892{
    882893    if ( !globalManager ) {
     894        new QDnsManager();
    883895        qAddPostRoutine(cleanupDns);
    884         new QDnsManager();
    885896    }
    886897    return globalManager;
     
    24432454}
    24442455
    2445 #elif defined(Q_OS_UNIX)
     2456#elif defined(Q_OS_UNIX) || defined(Q_OS_OS2)
    24462457
    24472458#if defined(Q_DNS_SYNCHRONOUS)
    24482459void QDns::doSynchronousLookup()
    24492460{
     2461#if defined(Q_OS_OS2)
     2462    //@@TODO (dmik): we can use the code below on OS/2 also but this will
     2463    //  require linking against the additional library containing res_*
     2464    //  functions and global data, which is normally not used anywhere else
     2465    //  (because QDns implementation does lookups diretcly to achieve
     2466    //  asynchronous behavior) and will just waste some system resources.
     2467    //  Anyhow, is synchronous behavior really necessary? Do nothing for now.
     2468#else
    24502469    if ( t!=None && !l.isEmpty() ) {
    24512470        QValueListIterator<QString> it = n.begin();
     
    24992518        emit resultsReady();
    25002519    }
     2520#endif
    25012521}
    25022522#endif
     
    25172537
    25182538    // read resolv.conf manually.
     2539#if defined(Q_OS_OS2)
     2540    char *etc = getenv( "ETC" );
     2541    if ( !etc ) {
     2542        etc = "x:\\MPTN\\ETC";
     2543        ULONG boot = 0;
     2544        DosQuerySysInfo( QSV_BOOT_DRIVE, QSV_BOOT_DRIVE, (PVOID)boot, sizeof(boot) );
     2545        *etc = (char)(boot + 'A' - 1);
     2546    }
     2547    // currently, resolv takes precedence over resolv2 assuming that resolv
     2548    // is created for PPP connections and therefore should override resolv2
     2549    // which is created for permanent LAN connections.
     2550    QFile resolvConf( QString( etc ) + "\\resolv" );
     2551    if ( !resolvConf.exists() )
     2552        resolvConf.setName( QString( etc ) + "\\resolv2" );
     2553#else
    25192554    QFile resolvConf("/etc/resolv.conf");
     2555#endif   
    25202556    if (resolvConf.open(IO_ReadOnly)) {
    25212557        QTextStream stream( &resolvConf );
     
    25292565            if ( type == "nameserver" ) {
    25302566                QHostAddress *address = new QHostAddress();
    2531                 if ( address->setAddress( QString(line[1]) ) ) {
     2567                if ( address->setAddress( list[1] ) ) {
    25322568                    // only add ipv6 addresses from resolv.conf if
    25332569                    // this host supports ipv6.
     
    25482584    }
    25492585
     2586#if defined(Q_OS_OS2)
     2587//@@TODO (dmik): currently the code below is not used
     2588//  (see comments to QDns::doSynchronousLookup())
     2589#else
    25502590    if (ns->isEmpty()) {
    25512591#if defined(Q_MODERN_RES_API)
     
    25942634        }
    25952635    }
    2596 
     2636#endif   
     2637
     2638#if defined(Q_OS_OS2)
     2639    QFile hosts( QString( etc ) + "\\hosts" );
     2640#else
    25972641    QFile hosts( QString::fromLatin1( "/etc/hosts" ) );
     2642#endif   
    25982643    if ( hosts.open( IO_ReadOnly ) ) {
    25992644        // read the /etc/hosts file, creating long-life A and PTR RRs
Note: See TracChangeset for help on using the changeset viewer.