aboutsummaryrefslogtreecommitdiffstats
path: root/.gitignore
blob: ea19ec63e4e668adb13319cf47d2206e1b5b211f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
*.bak
*.o
*~
.autotools
.cproject
.deps/
.idea/
.project
.rsyncs
.settings/
.vscode/
/nbproject/
ABOUT-NLS
aclocal.m4
ANNOUNCE.EMAIL
ar-lib
autobuild/
autom4te.cache
build*
build*/
compile
config.cache
config.guess
config.h
config.h.in
config.log
config.rpath
config.status
config.sub
configure
configure.lineno
cscope.out
depcomp
dox/
FAQ
FEATURES
fetchmail
fetchmail-*.tar.*
fetchmail-FAQ.pdf
fetchmail-man.html
fetchmail.spec
fetchmailconf
genlsm.sh
IMAPCapa
install-sh
intl/
libfm.a
m4/
Mailbox-Names-UTF7.html
Makefile
Makefile.in
missing
mkinstalldirs
mxget
netrc
NOTES
po/Makefile
po/POTFILES
po/stamp-po
py-compile
rcfile_l.c
rcfile_y.c
rcfile_y.h
rfc2047e
rfc822
rfc822valid
stamp-h1
tags
test-driver
test-suite.log
TODO
unmime
x509_name_match
ylwrap
\#*#
_build*
push.sh
.Special */ .highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */ .highlight .ge { font-style: italic } /* Generic.Emph */ .highlight .ges { font-weight: bold; font-style: italic } /* Generic.EmphStrong */ .highlight .gr { color: #aa0000 } /* Generic.Error */ .highlight .gh { color: #333333 } /* Generic.Heading */ .highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */ .highlight .go { color: #888888 } /* Generic.Output */ .highlight .gp { color: #555555 } /* Generic.Prompt */ .highlight .gs { font-weight: bold } /* Generic.Strong */ .highlight .gu { color: #666666 } /* Generic.Subheading */ .highlight .gt { color: #aa0000 } /* Generic.Traceback */ .highlight .kc { color: #008800; font-weight: bold } /* Keyword.Constant */ .highlight .kd { color: #008800; font-weight: bold } /* Keyword.Declaration */ .highlight .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */ .highlight .kp { color: #008800 } /* Keyword.Pseudo */ .highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */ .highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */ .highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */ .highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */ .highlight .na { color: #336699 } /* Name.Attribute */ .highlight .nb { color: #003388 } /* Name.Builtin */ .highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */ .highlight .no { color: #003366; font-weight: bold } /* Name.Constant */ .highlight .nd { color: #555555 } /* Name.Decorator */ .highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */ .highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */ .highlight .nl { color: #336699; font-style: italic } /* Name.Label */ .highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
/*
 *  This file is a ghastly hack because nobody can agree on
 *  gethostbyname_r()'s prototype.
 *
 *  Copyright (C) 2001,2002  Brian Stafford  <brian@stafford.uklinux.net>
 *
 *  This library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Lesser General Public
 *  License as published by the Free Software Foundation; either
 *  version 2.1 of the License, or (at your option) any later version.
 *
 *  This library is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *  Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public
 *  License along with this library; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#define _SVID_SOURCE	1	/* Need this to get gethostbyname_r() */

#include <assert.h>

#include <stdlib.h>
#include <string.h>
#include <netdb.h>
#include <errno.h>

#include "gethostbyname.h"

#if HAVE_GETIPNODEBYNAME

void
free_ghbnctx (struct ghbnctx *ctx)
{
  assert (ctx != NULL);

  if (ctx->hostent != NULL)
    freehostent (ctx->hostent);
}

struct hostent *
gethostbyname_ctx (const char *host, struct ghbnctx *ctx)
{
  assert (ctx != NULL);

  memset (ctx, 0, sizeof (struct ghbnctx));
  ctx->hostent = getipnodebyname (host, AF_UNSPEC, AI_ADDRCONFIG, &ctx->h_err);
  return ctx->hostent;
}

int
h_error_ctx (struct ghbnctx *ctx)
{
  assert (ctx != NULL);

  return ctx->h_err;
}

#elif HAVE_GETHOSTBYNAME_R == 6

void
free_ghbnctx (struct ghbnctx *ctx)
{
  assert (ctx != NULL);

  if (ctx->hostbuf != NULL)
    free (ctx->hostbuf);
}

struct hostent *
gethostbyname_ctx (const char *host, struct ghbnctx *ctx)
{
  struct hostent *hp;
  char *tmp;
  int err;

  assert (ctx != NULL);

  memset (ctx, 0, sizeof (struct ghbnctx));
  ctx->hostbuf_len = 2048;
  if ((ctx->hostbuf = (char *)malloc (ctx->hostbuf_len)) == NULL)
    {
      errno = ENOMEM;
      return NULL;
    }
  while ((err = gethostbyname_r (host,
  				 &ctx->hostent, ctx->hostbuf, ctx->hostbuf_len,
  				 &hp, &ctx->h_err)) == ERANGE)
    {
      ctx->hostbuf_len += 1024;
      if ((tmp = (char *)realloc (ctx->hostbuf, ctx->hostbuf_len)) == NULL)
	{
	  errno = ENOMEM;
	  return NULL;
	}
      ctx->hostbuf = tmp;
    }
  if (err != 0)
    {
      errno = err;
      return NULL;
    }
  return hp;
}

int
h_error_ctx (struct ghbnctx *ctx)
{
  assert (ctx != NULL);

  return ctx->h_err;
}

#elif HAVE_GETHOSTBYNAME_R == 5

void
free_ghbnctx (struct ghbnctx *ctx)
{
  assert (ctx != NULL);

  if (ctx->hostbuf != NULL)
    free (ctx->hostbuf);
}

struct hostent *
gethostbyname_ctx (const char *host, struct ghbnctx *ctx)
{
  struct hostent *hp;
  char *tmp;

  assert (ctx != NULL);

  memset (ctx, 0, sizeof (struct ghbnctx));
  ctx->hostbuf_len = 2048;
  if ((ctx->hostbuf = malloc (ctx->hostbuf_len)) == NULL)
    {
      errno = ENOMEM;
      return NULL;
    }
  while ((hp = gethostbyname_r (host, &ctx->hostent,
  				ctx->hostbuf, ctx->hostbuf_len,
  				&ctx->h_err)) == NULL && errno == ERANGE)
    {
      ctx->hostbuf_len += 1024;
      if ((tmp = realloc (ctx->hostbuf, ctx->hostbuf_len)) == NULL)
	{
	  errno = ENOMEM;
	  return NULL;
	}
      ctx->hostbuf = tmp;
    }
  return hp;
}

int
h_error_ctx (struct ghbnctx *ctx)
{
  assert (ctx != NULL);

  return ctx->h_err;
}

#elif HAVE_GETHOSTBYNAME_R == 3

void
free_ghbnctx (struct ghbnctx *ctx)
{
  assert (ctx != NULL);

  /* FIXME: does this need to do anything? */
}

struct hostent *
gethostbyname_ctx (const char *host, struct ghbnctx *ctx)
{
  assert (ctx != NULL);

  if (!gethostbyname_r (host, &ctx->hostent, &ctx->hostent_data))
    {
      ctx->h_err = h_errno;	/* FIXME: is this correct? */
      return NULL;
    }
  return &ctx->hostent;
}
  
int
h_error_ctx (struct ghbnctx *ctx)
{
  assert (ctx != NULL);

  return ctx->h_err;
}

#else

void
free_ghbnctx (struct ghbnctx *ctx )
{
  assert (ctx != NULL);
}

struct hostent *
gethostbyname_ctx (const char *host, struct ghbnctx *ctx)
{
  struct hostent *hp;

  hp = gethostbyname (host);
  if (hp == NULL)
    ctx->h_err = h_errno;
  return hp;
}

int
h_error_ctx (struct ghbnctx *ctx)
{
  assert (ctx != NULL);

  return ctx->h_err;
}

#endif