1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* win32/win32.c (rb_w32_inet_ntop): constified.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33893 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2011-11-29 00:51:40 +00:00
parent 4659b00b9a
commit 9fe88af9ef
2 changed files with 9 additions and 8 deletions

View file

@ -273,7 +273,7 @@ extern int rb_w32_urename(const char *, const char *);
extern char **rb_w32_get_environ(void); extern char **rb_w32_get_environ(void);
extern void rb_w32_free_environ(char **); extern void rb_w32_free_environ(char **);
extern int rb_w32_map_errno(DWORD); extern int rb_w32_map_errno(DWORD);
extern char * WSAAPI rb_w32_inet_ntop(int,void *,char *,size_t); extern char * WSAAPI rb_w32_inet_ntop(int,const void *,char *,size_t);
extern DWORD rb_w32_osver(void); extern DWORD rb_w32_osver(void);
extern int chown(const char *, int, int); extern int chown(const char *, int, int);

View file

@ -6130,14 +6130,15 @@ signbit(double x)
/* License: Ruby's */ /* License: Ruby's */
char * WSAAPI char * WSAAPI
rb_w32_inet_ntop(int af, void *addr, char *numaddr, size_t numaddr_len) rb_w32_inet_ntop(int af, const void *addr, char *numaddr, size_t numaddr_len)
{ {
typedef char *(WSAAPI inet_ntop_t)(int, void *, char *, size_t); typedef char *(WSAAPI inet_ntop_t)(int, void *, char *, size_t);
inet_ntop_t *pInetNtop; inet_ntop_t *pInetNtop;
pInetNtop = (inet_ntop_t *)get_proc_address("ws2_32", "inet_ntop", NULL); pInetNtop = (inet_ntop_t *)get_proc_address("ws2_32", "inet_ntop", NULL);
if(pInetNtop){ if (pInetNtop) {
return pInetNtop(af,addr,numaddr,numaddr_len); return pInetNtop(af, (void *)addr, numaddr, numaddr_len);
}else{ }
else {
struct in_addr in; struct in_addr in;
memcpy(&in.s_addr, addr, sizeof(in.s_addr)); memcpy(&in.s_addr, addr, sizeof(in.s_addr));
snprintf(numaddr, numaddr_len, "%s", inet_ntoa(in)); snprintf(numaddr, numaddr_len, "%s", inet_ntoa(in));