summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-02-23 02:54:04 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-02-23 02:54:04 +0000
commit1b81dafdd5601dbfe0818b4ddc1c4a53ecd0270d (patch)
treed9104bd2b88bf1e124ce18a4b0ffca1f37c7d12f
parent0728a4ed706119abe392f330dc31f890964ce885 (diff)
win32/win32.c: add rb_w32_inet_pton
* include/ruby/win32.h, win32/win32.c (rb_w32_inet_pton): add a wrapper function for inet_pton minimum supported client is Vista, as well as inet_ntop. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45150 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog6
-rw-r--r--include/ruby/win32.h4
-rw-r--r--win32/win32.c13
3 files changed, 23 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 72f428e..3586562 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Sun Feb 23 11:54:02 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * include/ruby/win32.h, win32/win32.c (rb_w32_inet_pton): add a
+ wrapper function for inet_pton minimum supported client is
+ Vista, as well as inet_ntop.
+
Sun Feb 23 11:33:25 2014 SHIBATA Hiroshi <shibata.hiroshi@gmail.com>
* test/net/imap/test_imap.rb: remove unused variables.
diff --git a/include/ruby/win32.h b/include/ruby/win32.h
index 20e46bb..22f7c48 100644
--- a/include/ruby/win32.h
+++ b/include/ruby/win32.h
@@ -309,6 +309,7 @@ extern char **rb_w32_get_environ(void);
extern void rb_w32_free_environ(char **);
extern int rb_w32_map_errno(DWORD);
extern const char *WSAAPI rb_w32_inet_ntop(int,const void *,char *,size_t);
+extern int WSAAPI rb_w32_inet_pton(int,const char *,void *);
extern DWORD rb_w32_osver(void);
extern int chown(const char *, int, int);
@@ -657,6 +658,9 @@ extern char *rb_w32_strerror(int);
#undef inet_ntop
#define inet_ntop(f,a,n,l) rb_w32_inet_ntop(f,a,n,l)
+#undef inet_pton
+#define inet_pton(f,s,d) rb_w32_inet_pton(f,s,d)
+
#undef accept
#define accept(s, a, l) rb_w32_accept(s, a, l)
diff --git a/win32/win32.c b/win32/win32.c
index 2c888ae..fbfbc37 100644
--- a/win32/win32.c
+++ b/win32/win32.c
@@ -6959,6 +6959,19 @@ rb_w32_inet_ntop(int af, const void *addr, char *numaddr, size_t numaddr_len)
}
/* License: Ruby's */
+int WSAAPI
+rb_w32_inet_pton(int af, const char *src, void *dst)
+{
+ typedef int (WSAAPI inet_pton_t)(int, const char*, void *);
+ inet_pton_t *pInetPton;
+ pInetPton = (inet_pton_t *)get_proc_address("ws2_32", "inet_pton", NULL);
+ if (pInetPton) {
+ return pInetPton(af, src, dst);
+ }
+ return 0;
+}
+
+/* License: Ruby's */
char
rb_w32_fd_is_text(int fd)
{