Results 1 to 11 of 11

Thread: lib("dnsapi")

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts

    Default Re: lib("dnsapi")

    Take a new look at post #5. They're used as function pointers so you can't replace them with empty defines.
    J-P Nurmi

  2. #2

    Default Re: lib("dnsapi")

    Mhh. That would return me 6 errors.
    Last edited by CHeader; 16th February 2008 at 20:21. Reason: Updated contents

  3. #3

    Default Re: lib("dnsapi")

    Okay. After some hours of testing and headers and stuff the follow situation is here:

    My source file is as follow right now:
    Qt Code:
    1. #include <QLibrary>
    2. #include "dnssrv.h"
    3. #include <windows.h>
    4. #include <windns.h>
    5.  
    6. #ifdef DNS_QUERY
    7. #define dnsQuery
    8. #warning DNS_QUERY is already defined.
    9. #endif
    10.  
    11. #ifdef DNS_FREE
    12. #define dnsFree
    13. #warning DNS_FREE is already defined.
    14. #endif
    15.  
    16. #ifndef DNS_QUERY_SRV
    17. #define DNS_QUERY_SRV 0x0021
    18. #endif
    19.  
    20. // typedef DNS_STATUS WINAPI (*DNS_QUERY)(PCSTR, WORD, DWORD, PIP4_ARRAY, PDNS_RECORD *, PVOID *);
    21. // typedef void WINAPI (*DNS_FREE)(PVOID, DNS_FREE_TYPE);
    22. typedef DNS_STATUS WINAPI (*)(PCSTR, WORD, DWORD, PIP4_ARRAY, PDNS_RECORD *, PVOID *)
    23.  
    24. QList<DnsSrv::Server> DnsSrv::resolve(const QString &name)
    25. {
    26. QList<DnsSrv::Server> servers;
    27.  
    28. QLibrary lib("dnsapi");
    29. DNS_QUERY dnsQuery = (DNS_QUERY) lib.resolve("DnsQuery_UTF8");
    30. DNS_FREE dnsFree = (DNS_FREE) lib.resolve("DnsFree");
    31. if (dnsQuery == NULL || dnsFree == NULL) {
    32. qDebug("Windows does not support DnsQuery");
    33. goto failed;
    34. }
    35.  
    36. PDNS_RECORD rr;
    37. if (dnsQuery(name.toUtf8(), DNS_QUERY_SRV,
    38. DNS_QUERY_STANDARD, NULL, &rr, NULL) != 0)
    39. goto failed;
    40.  
    41. name.toLower();
    42. for (PDNS_RECORD p = rr; p != NULL; p = p->pNext) {
    43. if (p->wType != DNS_QUERY_SRV ||
    44. QString((char *) p->pName).toLower() != name)
    45. continue;
    46.  
    47. DNS_SRV_DATA *srv = &p->Data.Srv;
    48.  
    49. DnsSrv::Server res;
    50. res.ttl = p->dwTtl;
    51. res.priority = srv->wPriority;
    52. res.weight = srv->wWeight;
    53. res.port = srv->wPort;
    54. res.target = (char *) srv->pNameTarget;
    55. servers.append(res);
    56. }
    57. dnsFree(rr, DnsFreeRecordList);
    58.  
    59. failed:
    60. lib.unload();
    61. return servers;
    62. }
    To copy to clipboard, switch view to plain text mode 

    Compiling log:
    Qt Code:
    1. 1>------ Build started: Project: dnssrv, Configuration: Release Win32 ------
    2. 1>Compiling...
    3. 1>dnssrv_win.cpp
    4. 1>.\dnssrv\dnssrv_win.cpp(22) : error C2059: syntax error : '('
    5. 1>.\dnssrv\dnssrv_win.cpp(25) : error C2143: syntax error : missing ';' before '{'
    6. 1>.\dnssrv\dnssrv_win.cpp(25) : error C2447: '{' : missing function header (old-style formal list?)
    7. 1>dnssrv - 3 error(s), 0 warning(s)
    8. ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
    To copy to clipboard, switch view to plain text mode 

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.