Ticket #1532: filezilla_2530.patch

File filezilla_2530.patch, 28.6 KB (added by paolozambotti, 16 years ago)

Win2000 compatibility patch from rev 2530

  • configure.in

     
    102102  AC_CHECK_HEADERS([utmpx.h sys/select.h],,,[
    103103  #include <sys/types.h>
    104104  #include <utmp.h>])
     105  AC_CHECK_HEADERS([netinet/in.h arpa/inet.h netdb.h])
    105106
    106107  AC_SEARCH_LIBS([socket], [xnet])
    107   AC_SEARCH_LIBS([getaddrinfo], [xnet])
     108  AC_SEARCH_LIBS([getaddrinfo], [xnet ws2_32])
    108109  AC_SEARCH_LIBS([in6addr_loopback], [socket])
    109110
    110   AC_CHECK_FUNCS([getaddrinfo ptsname setresuid strsignal updwtmpx])
     111  AC_CHECK_FUNCS([getaddrinfo freeaddrinfo getnameinfo ptsname setresuid strsignal updwtmpx])
    111112  AC_CHECK_FUNCS([gettimeofday ftime])
    112113  AC_CHECK_FUNCS([in6addr_loopback in6addr_any])
     114  AC_CHECK_FUNC([inet_ntop])
    113115
    114116AH_BOTTOM([
    115117/* Convert autoconf definitions to ones that PuTTY wants. */
    116118
    117 #ifndef HAVE_GETADDRINFO
     119#if !defined(HAVE_GETADDRINFO) || !defined(HAVE_FREEADDRINFO) || !defined(HAVE_GETNAMEINFO)
    118120# define NO_IPV6
    119121#endif
    120122#ifndef HAVE_SETRESUID
  • src/engine/inet_ntop.h

     
     1/* Convert internet address from internal to printable, presentable format.
     2   Copyright (C) 2005, 2006 Free Software Foundation, Inc.
     3
     4   This program is free software; you can redistribute it and/or modify
     5   it under the terms of the GNU General Public License as published by
     6   the Free Software Foundation; either version 2, or (at your option)
     7   any later version.
     8
     9   This program is distributed in the hope that it will be useful,
     10   but WITHOUT ANY WARRANTY; without even the implied warranty of
     11   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     12   GNU General Public License for more details.
     13
     14   You should have received a copy of the GNU General Public License
     15   along with this program; if not, write to the Free Software Foundation,
     16   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
     17
     18#ifndef INET_NTOP_H
     19#define INET_NTOP_H
     20
     21#include "FileZilla.h"
     22#ifdef __WXMSW__
     23  #include <winsock2.h>
     24  #include <ws2tcpip.h>
     25#else
     26  #include <sys/types.h>
     27  #include <sys/socket.h>
     28  #if HAVE_NETINET_IN_H
     29    #include <netinet/in.h>
     30  #endif
     31  #if HAVE_ARPA_INET_H
     32    #include <arpa/inet.h>
     33  #endif
     34#endif
     35
     36/* Converts an internet address from internal format to a printable,
     37   presentable format.
     38   AF is an internet address family, such as AF_INET or AF_INET6.
     39   SRC points to a 'struct in_addr' (for AF_INET) or 'struct in6_addr'
     40   (for AF_INET6).
     41   DST points to a buffer having room for CNT bytes.
     42   The printable representation of the address (in numeric form, not
     43   surrounded by [...], no reverse DNS is done) is placed in DST, and
     44   DST is returned.  If an error occurs, the return value is NULL and
     45   errno is set.  If CNT bytes are not sufficient to hold the result,
     46   the return value is NULL and errno is set to ENOSPC.  A good value
     47   for CNT is 46.
     48
     49   For more details, see the POSIX:2001 specification
     50   <http://www.opengroup.org/susv3xsh/inet_ntop.html>.  */
     51
     52#if !HAVE_INET_NTOP
     53const char *inet_ntop (int af, const void *src,
     54                  char *dst, socklen_t cnt);
     55#endif
     56
     57#endif /* INET_NTOP_H */
  • src/engine/getaddrinfo.cpp

    Property changes on: src/engine/inet_ntop.h
    ___________________________________________________________________
    Name: svn:executable
       + *
    
     
     1/* Get address information (partial implementation).
     2   Copyright (C) 1997, 2001, 2002, 2004, 2005, 2006, 2007 Free Software
     3   Foundation, Inc.
     4   Contributed by Simon Josefsson <simon@josefsson.org>.
     5
     6   This program is free software; you can redistribute it and/or modify
     7   it under the terms of the GNU General Public License as published by
     8   the Free Software Foundation; either version 2, or (at your option)
     9   any later version.
     10
     11   This program is distributed in the hope that it will be useful,
     12   but WITHOUT ANY WARRANTY; without even the implied warranty of
     13   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     14   GNU General Public License for more details.
     15
     16   You should have received a copy of the GNU General Public License
     17   along with this program; if not, write to the Free Software Foundation,
     18   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
     19
     20#include "FileZilla.h"
     21#include <wx/dynlib.h>
     22
     23#include "getaddrinfo.h"
     24
     25#if HAVE_NETINET_IN_H
     26# include <netinet/in.h>
     27#endif
     28
     29/* Get calloc. */
     30#include <stdlib.h>
     31
     32/* Get memcpy, strdup. */
     33#include <string.h>
     34
     35/* Get snprintf. */
     36#include <stdio.h>
     37
     38#include <stdbool.h>
     39
     40#include "inet_ntop.h"
     41
     42/* BeOS has AF_INET, but not PF_INET.  */
     43#ifndef PF_INET
     44# define PF_INET AF_INET
     45#endif
     46/* BeOS also lacks PF_UNSPEC.  */
     47#ifndef PF_UNSPEC
     48# define PF_UNSPEC 0
     49#endif
     50
     51#if defined _WIN32 || defined __WIN32__ || defined __WXMSW__
     52# define WIN32_NATIVE
     53#endif
     54
     55#ifdef WIN32_NATIVE
     56typedef int (WSAAPI *getaddrinfo_func) (const char*, const char*,
     57                    const struct addrinfo*,
     58                    struct addrinfo**);
     59typedef void (WSAAPI *freeaddrinfo_func) (struct addrinfo*);
     60typedef int (WSAAPI *getnameinfo_func) (const struct sockaddr*,
     61                    socklen_t, char*, DWORD,
     62                    char*, DWORD, int);
     63
     64static getaddrinfo_func getaddrinfo_ptr = NULL;
     65static freeaddrinfo_func freeaddrinfo_ptr = NULL;
     66static getnameinfo_func getnameinfo_ptr = NULL;
     67
     68wxDynamicLibrary *ws2_32;
     69
     70static int
     71use_win32_p (void)
     72{
     73  static int done = 0;
     74
     75  if (done)
     76    return getaddrinfo_ptr ? 1 : 0;
     77
     78  done = 1;
     79 
     80  ws2_32 = new wxDynamicLibrary(_("ws2_32"));
     81
     82  if (ws2_32)
     83    {
     84      getaddrinfo_ptr = (getaddrinfo_func) ws2_32->GetSymbol (_("getaddrinfo"));
     85      freeaddrinfo_ptr = (freeaddrinfo_func) ws2_32->GetSymbol (_("freeaddrinfo"));
     86      getnameinfo_ptr = (getnameinfo_func) ws2_32->GetSymbol (_("getnameinfo"));
     87    }
     88
     89  /* If either is missing, something is odd. */
     90  if (!getaddrinfo_ptr || !freeaddrinfo_ptr || !getnameinfo_ptr)
     91    {
     92      getaddrinfo_ptr = NULL;
     93      freeaddrinfo_ptr = NULL;
     94      getnameinfo_ptr = NULL;
     95      delete ws2_32;
     96      return 0;
     97    }
     98
     99  return 1;
     100}
     101#endif
     102
     103static inline bool
     104validate_family (int family)
     105{
     106  /* FIXME: Support more families. */
     107#ifdef NO_IPV6
     108     if (family == PF_INET)
     109       return true;
     110#else
     111     if (family == PF_INET6)
     112       return true;
     113#endif
     114     if (family == PF_UNSPEC)
     115       return true;
     116     return false;
     117}
     118
     119#if !HAVE_GETADDRINFO
     120/* Translate name of a service location and/or a service name to set of
     121   socket addresses. */
     122int
     123getaddrinfo (const char *nodename,
     124         const char *servname,
     125         const struct addrinfo *hints,
     126         struct addrinfo **res)
     127{
     128  struct addrinfo *tmp;
     129  int port = 0;
     130  struct hostent *he;
     131  void *storage;
     132  size_t size;
     133#ifdef NO_IPV6
     134  struct v4_pair {
     135    struct addrinfo addrinfo;
     136    struct sockaddr_in sockaddr_in;
     137  };
     138#else
     139  struct v6_pair {
     140    struct addrinfo addrinfo;
     141    struct sockaddr_in6 sockaddr_in6;
     142  };
     143#endif
     144
     145#ifdef WIN32_NATIVE
     146  if (use_win32_p ())
     147    return getaddrinfo_ptr (nodename, servname, hints, res);
     148#endif
     149
     150  if (hints && (hints->ai_flags & ~(AI_CANONNAME|AI_PASSIVE)))
     151    /* FIXME: Support more flags. */
     152    return EAI_BADFLAGS;
     153
     154  if (hints && !validate_family (hints->ai_family))
     155    return EAI_FAMILY;
     156
     157  if (hints &&
     158      hints->ai_socktype != SOCK_STREAM && hints->ai_socktype != SOCK_DGRAM)
     159    /* FIXME: Support other socktype. */
     160    return EAI_SOCKTYPE; /* FIXME: Better return code? */
     161
     162  if (!nodename)
     163    {
     164      if (!(hints->ai_flags & AI_PASSIVE))
     165    return EAI_NONAME;
     166
     167#ifdef NO_IPV6
     168      nodename = "0.0.0.0";
     169#else
     170      nodename = (hints->ai_family == AF_INET6) ? "::" : "0.0.0.0";
     171#endif
     172    }
     173
     174  if (servname)
     175    {
     176      struct servent *se = NULL;
     177      const char *proto =
     178    (hints && hints->ai_socktype == SOCK_DGRAM) ? "udp" : "tcp";
     179
     180      if (hints == NULL || !(hints->ai_flags & AI_NUMERICSERV))
     181    /* FIXME: Use getservbyname_r if available. */
     182    se = getservbyname (servname, proto);
     183
     184      if (!se)
     185    {
     186      char *c;
     187      if (!(*servname >= '0' && *servname <= '9'))
     188        return EAI_NONAME;
     189      port = strtoul (servname, &c, 10);
     190      if (*c || port > 0xffff)
     191        return EAI_NONAME;
     192      port = htons (port);
     193    }
     194      else
     195    port = se->s_port;
     196    }
     197
     198  /* FIXME: Use gethostbyname_r if available. */
     199  he = gethostbyname (nodename);
     200  if (!he || he->h_addr_list[0] == NULL)
     201    return EAI_NONAME;
     202
     203  switch (he->h_addrtype)
     204    {
     205#ifdef NO_IPV6
     206    case PF_INET:
     207      size = sizeof (struct v4_pair);
     208      break;
     209#else
     210    case PF_INET6:
     211      size = sizeof (struct v6_pair);
     212      break;
     213#endif
     214
     215    default:
     216      return EAI_NODATA;
     217    }
     218
     219  storage = calloc (1, size);
     220  if (!storage)
     221    return EAI_MEMORY;
     222
     223  switch (he->h_addrtype)
     224    {
     225#ifdef NO_IPV6
     226    case PF_INET:
     227      {
     228    struct v4_pair *p = (struct v4_pair *)storage;
     229    struct sockaddr_in *sinp = &p->sockaddr_in;
     230    tmp = &p->addrinfo;
     231
     232    if (port)
     233      sinp->sin_port = port;
     234
     235    if (he->h_length != sizeof (sinp->sin_addr))
     236      {
     237        free (storage);
     238        return EAI_SYSTEM; /* FIXME: Better return code?  Set errno? */
     239      }
     240
     241    memcpy (&sinp->sin_addr, he->h_addr_list[0], sizeof sinp->sin_addr);
     242
     243    tmp->ai_addr = (struct sockaddr *) sinp;
     244    tmp->ai_addrlen = sizeof *sinp;
     245      }
     246      break;
     247#else
     248    case PF_INET6:
     249      {
     250    struct v6_pair *p = (struct v6_pair *)storage;
     251    struct sockaddr_in6 *sinp = &p->sockaddr_in6;
     252    tmp = &p->addrinfo;
     253
     254    if (port)
     255      sinp->sin6_port = port;
     256
     257    if (he->h_length != sizeof (sinp->sin6_addr))
     258      {
     259        free (storage);
     260        return EAI_SYSTEM; /* FIXME: Better return code?  Set errno? */
     261      }
     262
     263    memcpy (&sinp->sin6_addr, he->h_addr_list[0], sizeof sinp->sin6_addr);
     264
     265    tmp->ai_addr = (struct sockaddr *) sinp;
     266    tmp->ai_addrlen = sizeof *sinp;
     267      }
     268      break;
     269#endif
     270
     271    default:
     272      free (storage);
     273      return EAI_NODATA;
     274    }
     275
     276  if (hints && hints->ai_flags & AI_CANONNAME)
     277    {
     278      const char *cn;
     279      if (he->h_name)
     280    cn = he->h_name;
     281      else
     282    cn = nodename;
     283
     284      tmp->ai_canonname = strdup (cn);
     285      if (!tmp->ai_canonname)
     286    {
     287      free (storage);
     288      return EAI_MEMORY;
     289    }
     290    }
     291
     292  tmp->ai_protocol = (hints) ? hints->ai_protocol : 0;
     293  tmp->ai_socktype = (hints) ? hints->ai_socktype : 0;
     294  tmp->ai_addr->sa_family = he->h_addrtype;
     295  tmp->ai_family = he->h_addrtype;
     296
     297  /* FIXME: If more than one address, create linked list of addrinfo's. */
     298
     299  *res = tmp;
     300
     301  return 0;
     302}
     303#endif /* !HAVE_GETADDRINFO */
     304
     305#if !HAVE_FREEADDRINFO
     306/* Free `addrinfo' structure AI including associated storage.  */
     307void
     308freeaddrinfo (struct addrinfo *ai)
     309{
     310#ifdef WIN32_NATIVE
     311  if (use_win32_p ())
     312    {
     313      freeaddrinfo_ptr (ai);
     314      return;
     315    }
     316#endif
     317
     318  while (ai)
     319    {
     320      struct addrinfo *cur;
     321
     322      cur = ai;
     323      ai = ai->ai_next;
     324
     325      if (cur->ai_canonname) free (cur->ai_canonname);
     326      free (cur);
     327    }
     328}
     329#endif /* !HAVE_FREEADDRINFO */
     330
     331#if !HAVE_GETNAMEINFO
     332int getnameinfo(const struct sockaddr *sa, socklen_t salen,
     333        char *node, socklen_t nodelen,
     334        char *service, socklen_t servicelen,
     335        int flags)
     336{
     337#ifdef WIN32_NATIVE
     338  if (use_win32_p ())
     339    return getnameinfo_ptr (sa, salen, node, nodelen,
     340                service, servicelen, flags);
     341#endif
     342
     343  /* FIXME: Support other flags. */
     344  if ((node && nodelen > 0 && !(flags & NI_NUMERICHOST)) ||
     345      (service && servicelen > 0 && !(flags & NI_NUMERICHOST)) ||
     346      (flags & ~(NI_NUMERICHOST|NI_NUMERICSERV)))
     347    return EAI_BADFLAGS;
     348
     349  if (sa == NULL || salen < sizeof (sa->sa_family))
     350    return EAI_FAMILY;
     351
     352  switch (sa->sa_family)
     353    {
     354#ifdef NO_IPV6
     355    case AF_INET:
     356      if (salen < sizeof (struct sockaddr_in))
     357    return EAI_FAMILY;
     358      break;
     359#else
     360    case AF_INET6:
     361      if (salen < sizeof (struct sockaddr_in6))
     362    return EAI_FAMILY;
     363      break;
     364#endif
     365    default:
     366      return EAI_FAMILY;
     367    }
     368
     369  if (node && nodelen > 0 && flags & NI_NUMERICHOST)
     370    {
     371      switch (sa->sa_family)
     372    {
     373#ifdef NO_IPV6
     374    case AF_INET:
     375      if (!inet_ntop (AF_INET,
     376              &(((const struct sockaddr_in *) sa)->sin_addr),
     377              node, nodelen))
     378        return EAI_SYSTEM;
     379      break;
     380#else
     381    case AF_INET6:
     382      if (!inet_ntop (AF_INET6,
     383              &(((const struct sockaddr_in6 *) sa)->sin6_addr),
     384              node, nodelen))
     385        return EAI_SYSTEM;
     386      break;
     387#endif
     388
     389    default:
     390      return EAI_FAMILY;
     391    }
     392    }
     393
     394  if (service && servicelen > 0 && flags & NI_NUMERICSERV)
     395    switch (sa->sa_family)
     396      {
     397#ifdef NO_IPV6
     398      case AF_INET:
     399#else
     400      case AF_INET6:
     401#endif
     402    {
     403      unsigned short int port
     404        = ntohs (((const struct sockaddr_in *) sa)->sin_port);
     405      if (servicelen <= snprintf (service, servicelen, "%u", port))
     406        return EAI_OVERFLOW;
     407    }
     408    break;
     409      }
     410
     411  return 0;
     412}
     413#endif /* !HAVE_GETNAMEINFO */
  • src/engine/socket.cpp

    Property changes on: src/engine/getaddrinfo.cpp
    ___________________________________________________________________
    Name: svn:executable
       + *
    
     
     1#include "FileZilla.h"
    12#include <wx/defs.h>
    23#ifdef __WXMSW__
     4  #include <winsock2.h>
     5  #include <ws2tcpip.h>
    36  // MinGW needs this for getaddrinfo
    47  #if defined(_WIN32_WINNT)
    58    #if _WIN32_WINNT < 0x0501
    6       #undef _WIN32_WINNT
    7       #define _WIN32_WINNT 0x0501
     9      #include "getaddrinfo.h"
    810    #endif
    911  #else
    10     #define _WIN32_WINNT 0x0501
     12    #include "getaddrinfo.h"
    1113  #endif
    12   #include <winsock2.h>
    13   #include <ws2tcpip.h>
    1414#endif
    15 #include "FileZilla.h"
    1615#include "socket.h"
    1716#include "threadex.h"
    1817#include <errno.h>
  • src/engine/inet_ntop.cpp

     
     1/* inet_ntop.c -- convert IPv4 and IPv6 addresses from binary to text form
     2
     3   Copyright (C) 2005, 2006  Free Software Foundation, Inc.
     4
     5   This program is free software; you can redistribute it and/or modify
     6   it under the terms of the GNU General Public License as published by
     7   the Free Software Foundation; either version 2, or (at your option)
     8   any later version.
     9
     10   This program is distributed in the hope that it will be useful,
     11   but WITHOUT ANY WARRANTY; without even the implied warranty of
     12   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     13   GNU General Public License for more details.
     14
     15   You should have received a copy of the GNU General Public License
     16   along with this program; if not, write to the Free Software Foundation,
     17   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
     18
     19/*
     20 * Copyright (c) 1996-1999 by Internet Software Consortium.
     21 *
     22 * Permission to use, copy, modify, and distribute this software for any
     23 * purpose with or without fee is hereby granted, provided that the above
     24 * copyright notice and this permission notice appear in all copies.
     25 *
     26 * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
     27 * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
     28 * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
     29 * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
     30 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
     31 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
     32 * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
     33 * SOFTWARE.
     34 */
     35
     36#include "FileZilla.h"
     37
     38/* Specification.  */
     39#include "inet_ntop.h"
     40
     41#include <stdio.h>
     42#include <string.h>
     43#include <errno.h>
     44
     45#ifndef EAFNOSUPPORT
     46# define EAFNOSUPPORT EINVAL
     47#endif
     48
     49#define NS_IN6ADDRSZ 16
     50#define NS_INT16SZ 2
     51
     52/*
     53 * WARNING: Don't even consider trying to compile this on a system where
     54 * sizeof(int) < 4.  sizeof(int) > 4 is fine; all the world's not a VAX.
     55 */
     56typedef int verify_int_size[2 * sizeof (int) - 7];
     57
     58#ifdef NO_IPV6
     59static const char *inet_ntop4 (const unsigned char *src, char *dst, socklen_t size);
     60#else
     61static const char *inet_ntop6 (const unsigned char *src, char *dst, socklen_t size);
     62#endif
     63
     64
     65#if !HAVE_INET_NTOP
     66/* char *
     67 * inet_ntop(af, src, dst, size)
     68 *  convert a network format address to presentation format.
     69 * return:
     70 *  pointer to presentation format address (`dst'), or NULL (see errno).
     71 * author:
     72 *  Paul Vixie, 1996.
     73 */
     74const char *
     75inet_ntop (int af, const void *src,
     76       char *dst, socklen_t cnt)
     77{
     78  switch (af)
     79    {
     80#ifdef NO_IPV6
     81    case AF_INET:
     82      return (inet_ntop4 ((unsigned char *)src, dst, cnt));
     83#else
     84    case AF_INET6:
     85      return (inet_ntop6 ((unsigned char *)src, dst, cnt));
     86#endif
     87
     88    default:
     89      errno = EAFNOSUPPORT;
     90      return (NULL);
     91    }
     92  /* NOTREACHED */
     93}
     94#endif /* !HAVE_INET_NTOP */
     95
     96#ifdef NO_IPV6
     97/* const char *
     98 * inet_ntop4(src, dst, size)
     99 *  format an IPv4 address
     100 * return:
     101 *  `dst' (as a const)
     102 * notes:
     103 *  (1) uses no statics
     104 *  (2) takes a u_char* not an in_addr as input
     105 * author:
     106 *  Paul Vixie, 1996.
     107 */
     108static const char *
     109inet_ntop4 (const unsigned char *src, char *dst, socklen_t size)
     110{
     111  char tmp[sizeof "255.255.255.255"];
     112  int len;
     113
     114  len = sprintf (tmp, "%u.%u.%u.%u", src[0], src[1], src[2], src[3]);
     115  if (len < 0)
     116    return NULL;
     117
     118  if (len > size)
     119    {
     120      errno = ENOSPC;
     121      return NULL;
     122    }
     123
     124  return strcpy (dst, tmp);
     125}
     126
     127#else
     128 
     129/* const char *
     130 * inet_ntop6(src, dst, size)
     131 *  convert IPv6 binary address into presentation (printable) format
     132 * author:
     133 *  Paul Vixie, 1996.
     134 */
     135static const char *
     136inet_ntop6 (const unsigned char *src, char *dst, socklen_t size)
     137{
     138  /*
     139   * Note that int32_t and int16_t need only be "at least" large enough
     140   * to contain a value of the specified size.  On some systems, like
     141   * Crays, there is no such thing as an integer variable with 16 bits.
     142   * Keep this in mind if you think this function should have been coded
     143   * to use pointer overlays.  All the world's not a VAX.
     144   */
     145  char tmp[sizeof "ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255"], *tp;
     146  struct
     147  {
     148    int base, len;
     149  } best, cur;
     150  unsigned int words[NS_IN6ADDRSZ / NS_INT16SZ];
     151  int i;
     152
     153  /*
     154   * Preprocess:
     155   *      Copy the input (bytewise) array into a wordwise array.
     156   *      Find the longest run of 0x00's in src[] for :: shorthanding.
     157   */
     158  memset (words, '\0', sizeof words);
     159  for (i = 0; i < NS_IN6ADDRSZ; i += 2)
     160    words[i / 2] = (src[i] << 8) | src[i + 1];
     161  best.base = -1;
     162  cur.base = -1;
     163  for (i = 0; i < (NS_IN6ADDRSZ / NS_INT16SZ); i++)
     164    {
     165      if (words[i] == 0)
     166    {
     167      if (cur.base == -1)
     168        cur.base = i, cur.len = 1;
     169      else
     170        cur.len++;
     171    }
     172      else
     173    {
     174      if (cur.base != -1)
     175        {
     176          if (best.base == -1 || cur.len > best.len)
     177        best = cur;
     178          cur.base = -1;
     179        }
     180    }
     181    }
     182  if (cur.base != -1)
     183    {
     184      if (best.base == -1 || cur.len > best.len)
     185    best = cur;
     186    }
     187  if (best.base != -1 && best.len < 2)
     188    best.base = -1;
     189
     190  /*
     191   * Format the result.
     192   */
     193  tp = tmp;
     194  for (i = 0; i < (NS_IN6ADDRSZ / NS_INT16SZ); i++)
     195    {
     196      /* Are we inside the best run of 0x00's? */
     197      if (best.base != -1 && i >= best.base && i < (best.base + best.len))
     198    {
     199      if (i == best.base)
     200        *tp++ = ':';
     201      continue;
     202    }
     203      /* Are we following an initial run of 0x00s or any real hex? */
     204      if (i != 0)
     205    *tp++ = ':';
     206      /* Is this address an encapsulated IPv4? */
     207      if (i == 6 && best.base == 0 &&
     208      (best.len == 6 || (best.len == 5 && words[5] == 0xffff)))
     209    {
     210      if (!inet_ntop4 (src + 12, tp, sizeof tmp - (tp - tmp)))
     211        return (NULL);
     212      tp += strlen (tp);
     213      break;
     214    }
     215      {
     216    int len = sprintf (tp, "%x", words[i]);
     217    if (len < 0)
     218      return NULL;
     219    tp += len;
     220      }
     221    }
     222  /* Was it a trailing run of 0x00's? */
     223  if (best.base != -1 && (best.base + best.len) ==
     224      (NS_IN6ADDRSZ / NS_INT16SZ))
     225    *tp++ = ':';
     226  *tp++ = '\0';
     227
     228  /*
     229   * Check for overflow, copy, and we're done.
     230   */
     231  if ((socklen_t) (tp - tmp) > size)
     232    {
     233      errno = ENOSPC;
     234      return NULL;
     235    }
     236
     237  return strcpy (dst, tmp);
     238}
     239
     240#endif
  • src/engine/Makefile.am

    Property changes on: src/engine/inet_ntop.cpp
    ___________________________________________________________________
    Name: svn:executable
       + *
    
     
    2626        server.cpp serverpath.cpp\
    2727        servercapabilities.cpp \
    2828        sftpcontrolsocket.cpp \
     29        inet_ntop.cpp \
     30        getaddrinfo.cpp \
    2931        socket.cpp \
    3032        tlssocket.cpp \
    3133        threadex.cpp timeex.cpp transfersocket.cpp
     
    4042        ratelimiter.h \
    4143        servercapabilities.h \
    4244        sftpcontrolsocket.h \
     45        inet_ntop.h \
     46        getaddrinfo.h \
    4347        socket.h \
    4448        tlssocket.h \
    4549        transfersocket.h
  • src/engine/getaddrinfo.h

     
     1/* Get address information.
     2   Copyright (C) 1996-2002, 2003, 2004, 2005, 2006
     3                 Free Software Foundation, Inc.
     4   Contributed by Simon Josefsson <simon@josefsson.org>.
     5
     6   This program is free software; you can redistribute it and/or modify
     7   it under the terms of the GNU General Public License as published by
     8   the Free Software Foundation; either version 2, or (at your option)
     9   any later version.
     10
     11   This program is distributed in the hope that it will be useful,
     12   but WITHOUT ANY WARRANTY; without even the implied warranty of
     13   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     14   GNU General Public License for more details.
     15
     16   You should have received a copy of the GNU General Public License
     17   along with this program; if not, write to the Free Software Foundation,
     18   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
     19
     20#ifndef GETADDRINFO_H
     21#define GETADDRINFO_H
     22
     23#include "FileZilla.h"
     24#ifdef __WXMSW__
     25  #include <winsock2.h>
     26  #include <ws2tcpip.h>
     27#else
     28  /* sys/socket.h in i386-unknown-freebsd4.10 and
     29     powerpc-apple-darwin5.5 require sys/types.h, so include it first.
     30     Then we'll also get 'socklen_t' and 'struct sockaddr' which are
     31     used below. */
     32  #include <sys/types.h>
     33  /* Get all getaddrinfo related declarations, if available.  */
     34  #include <sys/socket.h>
     35#endif
     36#ifdef HAVE_NETDB_H
     37# include <netdb.h>
     38#endif
     39
     40/* Possible values for `ai_flags' field in `addrinfo' structure.  */
     41#ifndef AI_PASSIVE
     42# define AI_PASSIVE 0x0001  /* Socket address is intended for `bind'.  */
     43#endif
     44#ifndef AI_CANONNAME
     45# define AI_CANONNAME   0x0002  /* Request for canonical name.  */
     46#endif
     47#ifndef AI_NUMERICSERV
     48# define AI_NUMERICSERV 0x0400  /* Don't use name resolution.  */
     49#endif
     50
     51#if 0
     52/* The commented out definitions below are not yet implemented in the
     53   GNULIB getaddrinfo() replacement, so are not yet needed and may, in fact,
     54   cause conflicts on systems with a getaddrinfo() function which does not
     55   define them.
     56
     57   If they are restored, be sure to protect the definitions with #ifndef.  */
     58#define AI_NUMERICHOST  0x0004  /* Don't use name resolution.  */
     59#define AI_V4MAPPED 0x0008  /* IPv4 mapped addresses are acceptable.  */
     60#define AI_ALL      0x0010  /* Return IPv4 mapped and IPv6 addresses.  */
     61#define AI_ADDRCONFIG   0x0020  /* Use configuration of this host to choose
     62                   returned address type..  */
     63#endif /* 0 */
     64
     65/* Error values for `getaddrinfo' function.  */
     66#ifndef EAI_BADFLAGS
     67# define EAI_BADFLAGS     -1    /* Invalid value for `ai_flags' field.  */
     68# define EAI_NONAME   -2    /* NAME or SERVICE is unknown.  */
     69# define EAI_AGAIN    -3    /* Temporary failure in name resolution.  */
     70# define EAI_FAIL     -4    /* Non-recoverable failure in name res.  */
     71# define EAI_NODATA   -5    /* No address associated with NAME.  */
     72# define EAI_FAMILY   -6    /* `ai_family' not supported.  */
     73# define EAI_SOCKTYPE     -7    /* `ai_socktype' not supported.  */
     74# define EAI_SERVICE      -8    /* SERVICE not supported for `ai_socktype'.  */
     75# define EAI_MEMORY   -10   /* Memory allocation failure.  */
     76#endif
     77#ifndef EAI_OVERFLOW
     78/* Not defined on mingw32. */
     79# define EAI_OVERFLOW     -12   /* Argument buffer overflow.  */
     80#endif
     81#ifndef EAI_ADDRFAMILY
     82/* Not defined on mingw32. */
     83# define EAI_ADDRFAMILY  -9 /* Address family for NAME not supported.  */
     84#endif
     85#ifndef EAI_SYSTEM
     86/* Not defined on mingw32. */
     87# define EAI_SYSTEM   -11   /* System error returned in `errno'.  */
     88#endif
     89
     90#ifdef __USE_GNU
     91# ifndef EAI_INPROGRESS
     92#  define EAI_INPROGRESS    -100    /* Processing request in progress.  */
     93#  define EAI_CANCELED      -101    /* Request canceled.  */
     94#  define EAI_NOTCANCELED   -102    /* Request not canceled.  */
     95#  define EAI_ALLDONE       -103    /* All requests done.  */
     96#  define EAI_INTR      -104    /* Interrupted by a signal.  */
     97#  define EAI_IDN_ENCODE    -105    /* IDN encoding failed.  */
     98# endif
     99#endif
     100
     101#if !HAVE_GETADDRINFO
     102/* Translate name of a service location and/or a service name to set of
     103   socket addresses.
     104   For more details, see the POSIX:2001 specification
     105   <http://www.opengroup.org/susv3xsh/getaddrinfo.html>.  */
     106int getaddrinfo (const char *nodename,
     107            const char *servname,
     108            const struct addrinfo *hints,
     109            struct addrinfo **res);
     110#endif
     111
     112#if !HAVE_FREEADDRINFO
     113/* Free `addrinfo' structure AI including associated storage.
     114   For more details, see the POSIX:2001 specification
     115   <http://www.opengroup.org/susv3xsh/getaddrinfo.html>.  */
     116void freeaddrinfo (struct addrinfo *ai);
     117#endif
     118
     119#if !HAVE_GETNAMEINFO
     120/* Convert socket address to printable node and service names.
     121   For more details, see the POSIX:2001 specification
     122   <http://www.opengroup.org/susv3xsh/getnameinfo.html>.  */
     123int getnameinfo(const struct sockaddr *sa, socklen_t salen,
     124               char *node, socklen_t nodelen,
     125               char *service, socklen_t servicelen,
     126               int flags);
     127
     128#endif
     129
     130/* Possible flags for getnameinfo.  */
     131#ifndef NI_NUMERICHOST
     132# define NI_NUMERICHOST 1
     133#endif
     134#ifndef NI_NUMERICSERV
     135# define NI_NUMERICSERV 2
     136#endif
     137
     138#endif /* GETADDRINFO_H */
  • README

    Property changes on: src/engine/getaddrinfo.h
    ___________________________________________________________________
    Name: svn:executable
       + *
    
     
    3535-----------------
    3636
    3737FileZilla has been tested on the following platforms:
    38 - Windows XP, 2003 and Vista (9x/ME/NT4/2000 not supported)
     38- Windows XP, 2003 and Vista (9x/ME/NT4 not supported)
    3939- Several major Linux distributions
    4040- FreeBSD and other BSD variants
    4141- Mac OS X
  • data/install.nsi.in

     
    257257
    258258Function .onInit
    259259
    260   ${Unless} ${AtLeastWinXP}
    261     MessageBox MB_YESNO|MB_ICONSTOP "Unsupported operating system.$\nFileZilla ${VERSION} requires at least Windows XP and may not work correctly on your system.$\nDo you really want to continue with the installation?" IDYES installonoldwindows
     260  ${Unless} ${AtLeastWin2000}
     261    MessageBox MB_YESNO|MB_ICONSTOP "Unsupported operating system.$\nFileZilla ${VERSION} requires at least Windows 2000 and may not work correctly on your system.$\nDo you really want to continue with the installation?" IDYES installonoldwindows
    262262    Abort
    263263installonoldwindows:
    264264  ${EndUnless}