Import polish/fortunepl version 20091121
[dports.git] / security / ruby-tcpwrap / files / patch-tcpwrap.c
1 --- tcpwrap.c.orig      2003-08-20 03:30:10.000000000 +0000
2 +++ tcpwrap.c
3 @@ -25,7 +25,12 @@
4   */
5  
6  #include "ruby.h"
7 +#ifdef HAVE_RUBY_IO_H          /* Ruby 1.9 and later */
8 +#include "ruby/io.h"
9 +#else                          /* Ruby 1.8.x */
10  #include "rubyio.h"
11 +#define rb_io_stdio_file(iot)  ((iot)->f)
12 +#endif
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)
17      tcp_wrapper_t *tcpd;
18      VALUE sock;
19      int sockfd;
20 -    OpenFile *fptr;
21 +    rb_io_t *fptr;
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)
26   again:
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);
37  #endif
38 -    if (!hosts_ctl(RSTRING(tcpd->daemon)->ptr,
39 +    if (!hosts_ctl(RSTRING_PTR(tcpd->daemon),
40                    client_name,
41                    client_addr,
42                    (client_user == NULL) ? STRING_UNKNOWN : client_user)) {
43 @@ -156,8 +161,8 @@ tcpd_s_set_hosts_allow(VALUE self, VALUE
44  {
45      static char hosts_allow[MAXPATHLEN];
46  
47 -    Check_SafeStr(s);
48 -    snprintf(hosts_allow, sizeof(hosts_allow), "%s", RSTRING(s)->ptr);
49 +    SafeStringValue(s);
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 
55  {
56      static char hosts_deny[MAXPATHLEN];
57  
58 -    Check_SafeStr(s);
59 -    snprintf(hosts_deny, sizeof(hosts_deny), "%s", RSTRING(s)->ptr);
60 +    SafeStringValue(s);
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)
66  {
67      if(NIL_P(s)) return STRING_UNKNOWN;
68      Check_Type(s, T_STRING);
69 -    return RSTRING(s)->ptr;
70 +    return RSTRING_PTR(s);
71  }
72  
73  static VALUE