Changeset 8 for trunk/src/network/qdns.cpp
- Timestamp:
- Nov 16, 2005, 8:36:46 PM (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/network/qdns.cpp
r7 r8 79 79 #include <dlfcn.h> 80 80 #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 81 87 82 88 //#define QDNS_DEBUG … … 105 111 static bool ipv6support = FALSE; 106 112 113 #if defined(Q_OS_OS2) 114 //@@TODO (dmik): currently qdns_res_init() is not used 115 // (see comments to QDns::doSynchronousLookup()) 116 #else 107 117 static int qdns_res_init() 108 118 { … … 116 126 else 117 127 return -1; 118 #elif defined(Q_OS_UNIX) 128 #elif defined(Q_OS_UNIX) || defined(Q_OS_OS2) 119 129 return res_init(); 120 130 #else … … 122 132 #endif 123 133 } 134 #endif 124 135 125 136 … … 129 140 { 130 141 #if defined(Q_DNS_SYNCHRONOUS) 131 #if defined(Q_OS_UNIX) 142 #if defined(Q_OS_UNIX) || defined(Q_OS_OS2) 132 143 noEventLoop = qApp==0 || qApp->loopLevel()==0; 133 144 #else … … 881 892 { 882 893 if ( !globalManager ) { 894 new QDnsManager(); 883 895 qAddPostRoutine(cleanupDns); 884 new QDnsManager();885 896 } 886 897 return globalManager; … … 2443 2454 } 2444 2455 2445 #elif defined(Q_OS_UNIX) 2456 #elif defined(Q_OS_UNIX) || defined(Q_OS_OS2) 2446 2457 2447 2458 #if defined(Q_DNS_SYNCHRONOUS) 2448 2459 void QDns::doSynchronousLookup() 2449 2460 { 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 2450 2469 if ( t!=None && !l.isEmpty() ) { 2451 2470 QValueListIterator<QString> it = n.begin(); … … 2499 2518 emit resultsReady(); 2500 2519 } 2520 #endif 2501 2521 } 2502 2522 #endif … … 2517 2537 2518 2538 // 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 2519 2554 QFile resolvConf("/etc/resolv.conf"); 2555 #endif 2520 2556 if (resolvConf.open(IO_ReadOnly)) { 2521 2557 QTextStream stream( &resolvConf ); … … 2529 2565 if ( type == "nameserver" ) { 2530 2566 QHostAddress *address = new QHostAddress(); 2531 if ( address->setAddress( QString(line[1])) ) {2567 if ( address->setAddress( list[1] ) ) { 2532 2568 // only add ipv6 addresses from resolv.conf if 2533 2569 // this host supports ipv6. … … 2548 2584 } 2549 2585 2586 #if defined(Q_OS_OS2) 2587 //@@TODO (dmik): currently the code below is not used 2588 // (see comments to QDns::doSynchronousLookup()) 2589 #else 2550 2590 if (ns->isEmpty()) { 2551 2591 #if defined(Q_MODERN_RES_API) … … 2594 2634 } 2595 2635 } 2596 2636 #endif 2637 2638 #if defined(Q_OS_OS2) 2639 QFile hosts( QString( etc ) + "\\hosts" ); 2640 #else 2597 2641 QFile hosts( QString::fromLatin1( "/etc/hosts" ) ); 2642 #endif 2598 2643 if ( hosts.open( IO_ReadOnly ) ) { 2599 2644 // read the /etc/hosts file, creating long-life A and PTR RRs
Note:
See TracChangeset
for help on using the changeset viewer.