Results 1 to 11 of 11

Thread: lib("dnsapi")

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1

    Default lib("dnsapi")

    Hi,

    Im currently making an new DNS Server, But QT does give the follow error's while compiling:

    dnsserv\dnssrv_win.cpp(10) : error C2059: syntax error : '('
    dnsserv\dnssrv_win.cpp(12) : error C2059: syntax error : '('
    dnsserv\dnssrv_win.cpp(19) : error C2065: 'DNS_QUERY' : undeclared identifier
    dnsserv\dnssrv_win.cpp(19) : error C2146: syntax error : missing ';' before identifier 'dnsQuery'
    dnsserv\dnssrv_win.cpp(19) : error C2065: 'dnsQuery' : undeclared identifier
    dnsserv\dnssrv_win.cpp(19) : error C2146: syntax error : missing ';' before identifier 'lib'
    dnsserv\dnssrv_win.cpp(20) : error C2065: 'DNS_FREE' : undeclared identifier
    dnsserv\dnssrv_win.cpp(20) : error C2146: syntax error : missing ';' before identifier 'dnsFree'
    dnsserv\dnssrv_win.cpp(20) : error C2065: 'dnsFree' : undeclared identifier
    dnsserv\dnssrv_win.cpp(20) : error C2146: syntax error : missing ';' before identifier 'lib'
    dnsserv\dnssrv_win.cpp(27) : error C3861: 'dnsQuery': identifier not found
    dnsserv\dnssrv_win.cpp(47) : error C3861: 'dnsFree': identifier not found
    Generating Code...

    NMAKE : fatal error U1077: 'cl' : return code '0x2'
    Stop.
    NMAKE : fatal error U1077: '"C:\Program Files\Microsoft Visual Studio 8\VC\BIN\nmake.exe"' : return code '0x2'
    Stop.
    NMAKE : fatal error U1077: 'cd' : return code '0x2'
    Stop.
    The source file is currently:

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

    How do I fix those error's? Im with my hands in my hair. Thank you.
    Last edited by CHeader; 15th February 2008 at 19:42.

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.