1 --- tcpwrap.c.orig 2003-08-20 03:30:10.000000000 +0000
7 +#ifdef HAVE_RUBY_IO_H /* Ruby 1.9 and later */
9 +#else /* Ruby 1.8.x */
11 +#define rb_io_stdio_file(iot) ((iot)->f)
13 #include <sys/types.h>
14 #include <sys/socket.h>
15 #include <netinet/in.h>
16 @@ -101,7 +106,7 @@ static VALUE tcpd_accept(VALUE self)
22 struct sockaddr_storage addr;
23 char client_name[NI_MAXHOST] = STRING_UNKNOWN;
24 char client_addr[NI_MAXHOST] = STRING_UNKNOWN;
25 @@ -113,7 +118,7 @@ static VALUE tcpd_accept(VALUE self)
27 sock = rb_funcall(tcpd->server, rb_intern("accept"), 0);
28 GetOpenFile(sock, fptr);
29 - sockfd = fileno(fptr->f);
30 + sockfd = fileno(rb_io_stdio_file(fptr));
31 if (getpeername(sockfd, (struct sockaddr*) &addr, &len) < 0)
32 rb_sys_fail("getpeername(2)");
33 error = getnameinfo((struct sockaddr*) &addr, len,
34 @@ -132,7 +137,7 @@ static VALUE tcpd_accept(VALUE self)
35 if (tcpd->ident_lookup)
36 client_user = ident_id(sockfd, tcpd->ident_timeout);
38 - if (!hosts_ctl(RSTRING(tcpd->daemon)->ptr,
39 + if (!hosts_ctl(RSTRING_PTR(tcpd->daemon),
42 (client_user == NULL) ? STRING_UNKNOWN : client_user)) {
43 @@ -156,8 +161,8 @@ tcpd_s_set_hosts_allow(VALUE self, VALUE
45 static char hosts_allow[MAXPATHLEN];
48 - snprintf(hosts_allow, sizeof(hosts_allow), "%s", RSTRING(s)->ptr);
50 + snprintf(hosts_allow, sizeof(hosts_allow), "%s", RSTRING_PTR(s));
51 if(access(hosts_allow, R_OK) < 0)
52 rb_warning("cannot read %s", hosts_allow);
53 hosts_allow_table = hosts_allow;
54 @@ -176,8 +181,8 @@ tcpd_s_set_hosts_deny(VALUE self, VALUE
56 static char hosts_deny[MAXPATHLEN];
59 - snprintf(hosts_deny, sizeof(hosts_deny), "%s", RSTRING(s)->ptr);
61 + snprintf(hosts_deny, sizeof(hosts_deny), "%s", RSTRING_PTR(s));
62 if(access(hosts_deny, R_OK) < 0)
63 rb_warning("cannot read %s", hosts_deny);
64 hosts_deny_table = hosts_deny;
65 @@ -196,7 +201,7 @@ str_to_ctlstr(VALUE s)
67 if(NIL_P(s)) return STRING_UNKNOWN;
68 Check_Type(s, T_STRING);
69 - return RSTRING(s)->ptr;
70 + return RSTRING_PTR(s);