Added 'android4' define support that declares a different gethostbyaddr. Fixes #4376
This commit is contained in:
parent
4b0ba5e3f1
commit
45f76738ee
3 changed files with 20 additions and 6 deletions
|
|
@ -711,7 +711,12 @@ proc getHostByAddr*(ip: string): Hostent {.tags: [ReadIOEffect].} =
|
||||||
cint(sockets.AF_INET))
|
cint(sockets.AF_INET))
|
||||||
if s == nil: raiseOSError(osLastError())
|
if s == nil: raiseOSError(osLastError())
|
||||||
else:
|
else:
|
||||||
var s = posix.gethostbyaddr(addr(myaddr), sizeof(myaddr).Socklen,
|
var s =
|
||||||
|
when defined(android4):
|
||||||
|
posix.gethostbyaddr(cast[cstring](addr(myaddr)), sizeof(myaddr).cint,
|
||||||
|
cint(posix.AF_INET))
|
||||||
|
else:
|
||||||
|
posix.gethostbyaddr(addr(myaddr), sizeof(myaddr).Socklen,
|
||||||
cint(posix.AF_INET))
|
cint(posix.AF_INET))
|
||||||
if s == nil:
|
if s == nil:
|
||||||
raiseOSError(osLastError(), $hstrerror(h_errno))
|
raiseOSError(osLastError(), $hstrerror(h_errno))
|
||||||
|
|
|
||||||
|
|
@ -2616,7 +2616,11 @@ proc gai_strerror*(a1: cint): cstring {.importc:"(char *)$1", header: "<netdb.h>
|
||||||
proc getaddrinfo*(a1, a2: cstring, a3: ptr AddrInfo,
|
proc getaddrinfo*(a1, a2: cstring, a3: ptr AddrInfo,
|
||||||
a4: var ptr AddrInfo): cint {.importc, header: "<netdb.h>".}
|
a4: var ptr AddrInfo): cint {.importc, header: "<netdb.h>".}
|
||||||
|
|
||||||
proc gethostbyaddr*(a1: pointer, a2: Socklen, a3: cint): ptr Hostent {.
|
when not defined(android4):
|
||||||
|
proc gethostbyaddr*(a1: pointer, a2: Socklen, a3: cint): ptr Hostent {.
|
||||||
|
importc, header: "<netdb.h>".}
|
||||||
|
else:
|
||||||
|
proc gethostbyaddr*(a1: cstring, a2: cint, a3: cint): ptr Hostent {.
|
||||||
importc, header: "<netdb.h>".}
|
importc, header: "<netdb.h>".}
|
||||||
proc gethostbyname*(a1: cstring): ptr Hostent {.importc, header: "<netdb.h>".}
|
proc gethostbyname*(a1: cstring): ptr Hostent {.importc, header: "<netdb.h>".}
|
||||||
proc gethostent*(): ptr Hostent {.importc, header: "<netdb.h>".}
|
proc gethostent*(): ptr Hostent {.importc, header: "<netdb.h>".}
|
||||||
|
|
|
||||||
|
|
@ -326,7 +326,12 @@ proc getHostByAddr*(ip: string): Hostent {.tags: [ReadIOEffect].} =
|
||||||
cint(AF_INET))
|
cint(AF_INET))
|
||||||
if s == nil: raiseOSError(osLastError())
|
if s == nil: raiseOSError(osLastError())
|
||||||
else:
|
else:
|
||||||
var s = posix.gethostbyaddr(addr(myaddr), sizeof(myaddr).Socklen,
|
var s =
|
||||||
|
when defined(android4):
|
||||||
|
posix.gethostbyaddr(cast[cstring](addr(myaddr)), sizeof(myaddr).cint,
|
||||||
|
cint(posix.AF_INET))
|
||||||
|
else:
|
||||||
|
posix.gethostbyaddr(addr(myaddr), sizeof(myaddr).Socklen,
|
||||||
cint(posix.AF_INET))
|
cint(posix.AF_INET))
|
||||||
if s == nil:
|
if s == nil:
|
||||||
raiseOSError(osLastError(), $hstrerror(h_errno))
|
raiseOSError(osLastError(), $hstrerror(h_errno))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue