Commit d1ee94ce authored by Alex Brainman's avatar Alex Brainman

go.sys/windows: apply latest syscall changes

71db3dc120af os: make SameFile handle paths like c:a.txt properly
ff34a3e84dc0 net: fix CNAME resolving on Windows

LGTM=r
R=golang-codereviews, r
CC=golang-codereviews
https://golang.org/cl/130250043
parent 7d091bfd
......@@ -130,9 +130,8 @@ func SetNonblock(fd Handle, nonblocking bool) (err error) {
return nil
}
// getFullPath retrieves the full path of the specified file.
// Just a wrapper for Windows GetFullPathName api.
func getFullPath(name string) (path string, err error) {
// FullPath retrieves the full path of the specified file.
func FullPath(name string) (path string, err error) {
p, err := UTF16PtrFromString(name)
if err != nil {
return "", err
......@@ -161,7 +160,7 @@ func isSlash(c uint8) bool {
}
func normalizeDir(dir string) (name string, err error) {
ndir, err := getFullPath(dir)
ndir, err := FullPath(dir)
if err != nil {
return "", err
}
......@@ -200,9 +199,9 @@ func joinExeDirAndFName(dir, p string) (name string, err error) {
return "", err
}
if volToUpper(int(p[0])) == volToUpper(int(d[0])) {
return getFullPath(d + "\\" + p[2:])
return FullPath(d + "\\" + p[2:])
} else {
return getFullPath(p)
return FullPath(p)
}
}
} else {
......@@ -212,9 +211,9 @@ func joinExeDirAndFName(dir, p string) (name string, err error) {
return "", err
}
if isSlash(p[0]) {
return getFullPath(d[:2] + p)
return FullPath(d[:2] + p)
} else {
return getFullPath(d + "\\" + p)
return FullPath(d + "\\" + p)
}
}
// we shouldn't be here
......
......@@ -515,6 +515,7 @@ const socket_error = uintptr(^uint32(0))
//sys GetProtoByName(name string) (p *Protoent, err error) [failretval==nil] = ws2_32.getprotobyname
//sys DnsQuery(name string, qtype uint16, options uint32, extra *byte, qrs **DNSRecord, pr *byte) (status error) = dnsapi.DnsQuery_W
//sys DnsRecordListFree(rl *DNSRecord, freetype uint32) = dnsapi.DnsRecordListFree
//sys DnsNameCompare(name1 *uint16, name2 *uint16) (same bool) = dnsapi.DnsNameCompare_W
//sys GetAddrInfoW(nodename *uint16, servicename *uint16, hints *AddrinfoW, result **AddrinfoW) (sockerr error) = ws2_32.GetAddrInfoW
//sys FreeAddrInfoW(addrinfo *AddrinfoW) = ws2_32.FreeAddrInfoW
//sys GetIfEntry(pIfRow *MibIfRow) (errcode error) = iphlpapi.GetIfEntry
......
......@@ -140,6 +140,7 @@ var (
procgetprotobyname = modws2_32.NewProc("getprotobyname")
procDnsQuery_W = moddnsapi.NewProc("DnsQuery_W")
procDnsRecordListFree = moddnsapi.NewProc("DnsRecordListFree")
procDnsNameCompare_W = moddnsapi.NewProc("DnsNameCompare_W")
procGetAddrInfoW = modws2_32.NewProc("GetAddrInfoW")
procFreeAddrInfoW = modws2_32.NewProc("FreeAddrInfoW")
procGetIfEntry = modiphlpapi.NewProc("GetIfEntry")
......@@ -1635,6 +1636,12 @@ func DnsRecordListFree(rl *DNSRecord, freetype uint32) {
return
}
func DnsNameCompare(name1 *uint16, name2 *uint16) (same bool) {
r0, _, _ := syscall.Syscall(procDnsNameCompare_W.Addr(), 2, uintptr(unsafe.Pointer(name1)), uintptr(unsafe.Pointer(name2)), 0)
same = r0 != 0
return
}
func GetAddrInfoW(nodename *uint16, servicename *uint16, hints *AddrinfoW, result **AddrinfoW) (sockerr error) {
r0, _, _ := syscall.Syscall6(procGetAddrInfoW.Addr(), 4, uintptr(unsafe.Pointer(nodename)), uintptr(unsafe.Pointer(servicename)), uintptr(unsafe.Pointer(hints)), uintptr(unsafe.Pointer(result)), 0, 0)
if r0 != 0 {
......
......@@ -694,6 +694,18 @@ const (
DNS_TYPE_NBSTAT = 0xff01
)
const (
DNS_INFO_NO_RECORDS = 0x251D
)
const (
// flags inside DNSRecord.Dw
DnsSectionQuestion = 0x0000
DnsSectionAnswer = 0x0001
DnsSectionAuthority = 0x0002
DnsSectionAdditional = 0x0003
)
type DNSSRVData struct {
Target *uint16
Priority uint16
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment