Remove Windows support

This commit is contained in:
jailbird777 2021-07-08 19:11:22 -05:00 committed by Doug Freed
parent e4a62bbc85
commit 8f0c3422e7
47 changed files with 82 additions and 2680 deletions

View File

@ -5,13 +5,10 @@ AM_CPPFLAGS = -I../include -I../librb/include
authd_SOURCES = \
authd.c \
dns.c \
getaddrinfo.c \
getnameinfo.c \
notice.c \
provider.c \
res.c \
reslib.c \
reslist.c \
providers/dnsbl.c \
providers/ident.c \
providers/rdns.c \

View File

@ -151,18 +151,15 @@ error_cb(rb_helper *helper)
exit(EX_ERROR);
}
#ifndef _WIN32
static void
dummy_handler(int sig)
{
return;
}
#endif
static void
setup_signals(void)
{
#ifndef _WIN32
struct sigaction act;
act.sa_flags = 0;
@ -185,7 +182,6 @@ setup_signals(void)
act.sa_handler = dummy_handler;
sigaction(SIGALRM, &act, 0);
#endif
}
int

View File

@ -1,617 +0,0 @@
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the project nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#ifdef _WIN32
#include <rb_lib.h>
#include "getaddrinfo.h"
#include "stdinc.h"
static const char in_addrany[] = { 0, 0, 0, 0 };
static const char in_loopback[] = { 127, 0, 0, 1 };
static const char in6_addrany[] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
static const char in6_loopback[] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1
};
static const struct afd {
int a_af;
int a_addrlen;
int a_socklen;
int a_off;
const char *a_addrany;
const char *a_loopback;
int a_scoped;
} afdl [] = {
#define N_INET6 0
#ifdef IPV6
{PF_INET6, sizeof(struct in6_addr),
sizeof(struct sockaddr_in6),
offsetof(struct sockaddr_in6, sin6_addr),
in6_addrany, in6_loopback, 1},
#endif
#define N_INET 1
{PF_INET, sizeof(struct in_addr),
sizeof(struct sockaddr_in),
offsetof(struct sockaddr_in, sin_addr),
in_addrany, in_loopback, 0},
{0, 0, 0, 0, NULL, NULL, 0},
};
struct explore {
int e_af;
int e_socktype;
int e_protocol;
const char *e_protostr;
int e_wild;
#define WILD_AF(ex) ((ex)->e_wild & 0x01)
#define WILD_SOCKTYPE(ex) ((ex)->e_wild & 0x02)
#define WILD_PROTOCOL(ex) ((ex)->e_wild & 0x04)
};
static const struct explore explore[] = {
#ifdef IPV6
{ PF_INET6, SOCK_DGRAM, IPPROTO_UDP, "udp", 0x07 },
{ PF_INET6, SOCK_STREAM, IPPROTO_TCP, "tcp", 0x07 },
{ PF_INET6, SOCK_RAW, ANY, NULL, 0x05 },
#endif
{ PF_INET, SOCK_DGRAM, IPPROTO_UDP, "udp", 0x07 },
{ PF_INET, SOCK_STREAM, IPPROTO_TCP, "tcp", 0x07 },
{ PF_INET, SOCK_RAW, ANY, NULL, 0x05 },
{ PF_UNSPEC, SOCK_DGRAM, IPPROTO_UDP, "udp", 0x07 },
{ PF_UNSPEC, SOCK_STREAM, IPPROTO_TCP, "tcp", 0x07 },
{ PF_UNSPEC, SOCK_RAW, ANY, NULL, 0x05 },
{ -1, 0, 0, NULL, 0 },
};
#define PTON_MAX 16
static bool str_isnumber(const char *);
static int explore_null(const struct rb_addrinfo *,
const char *, struct rb_addrinfo **);
static int explore_numeric(const struct rb_addrinfo *, const char *,
const char *, struct rb_addrinfo **);
static struct rb_addrinfo *get_ai(const struct rb_addrinfo *,
const struct afd *, const char *);
static int get_portmatch(const struct rb_addrinfo *, const char *);
static int get_port(struct rb_addrinfo *, const char *, int);
static const struct afd *find_afd(int);
#if 0
/* We will need this should we ever want gai_strerror() */
static char *ai_errlist[] = {
"Success",
"Address family for hostname not supported", /* EAI_ADDRFAMILY */
"Temporary failure in name resolution", /* EAI_AGAIN */
"Invalid value for ai_flags", /* EAI_BADFLAGS */
"Non-recoverable failure in name resolution", /* EAI_FAIL */
"ai_family not supported", /* EAI_FAMILY */
"Memory allocation failure", /* EAI_MEMORY */
"No address associated with hostname", /* EAI_NODATA */
"hostname nor servname provided, or not known", /* EAI_NONAME */
"servname not supported for ai_socktype", /* EAI_SERVICE */
"ai_socktype not supported", /* EAI_SOCKTYPE */
"System error returned in errno", /* EAI_SYSTEM */
"Invalid value for hints", /* EAI_BADHINTS */
"Resolved protocol is unknown", /* EAI_PROTOCOL */
"Unknown error", /* EAI_MAX */
};
#endif
/* XXX macros that make external reference is BAD. */
#define GET_AI(ai, afd, addr) \
do { \
/* external reference: pai, error, and label free */ \
(ai) = get_ai(pai, (afd), (addr)); \
if ((ai) == NULL) { \
error = EAI_MEMORY; \
goto free; \
} \
} while (/*CONSTCOND*/0)
#define GET_PORT(ai, serv) \
do { \
/* external reference: error and label free */ \
error = get_port((ai), (serv), 0); \
if (error != 0) \
goto free; \
} while (/*CONSTCOND*/0)
#define ERR(err) \
do { \
/* external reference: error, and label bad */ \
error = (err); \
goto bad; \
/*NOTREACHED*/ \
} while (/*CONSTCOND*/0)
#define MATCH_FAMILY(x, y, w) \
((x) == (y) || (/*CONSTCOND*/(w) && ((x) == PF_UNSPEC || (y) == PF_UNSPEC)))
#define MATCH(x, y, w) \
((x) == (y) || (/*CONSTCOND*/(w) && ((x) == ANY || (y) == ANY)))
#if 0
/* We will need this should we ever want gai_strerror() */
char *
gai_strerror(int ecode)
{
if (ecode < 0 || ecode > EAI_MAX)
ecode = EAI_MAX;
return ai_errlist[ecode];
}
#endif
void
rb_freeaddrinfo(struct rb_addrinfo *ai)
{
struct rb_addrinfo *next;
do {
next = ai->ai_next;
if (ai->ai_canonname)
rb_free(ai->ai_canonname);
/* no need to free(ai->ai_addr) */
rb_free(ai);
ai = next;
} while (ai);
}
static bool
str_isnumber(const char *p)
{
char *ep;
if (*p == '\0')
return false;
ep = NULL;
errno = 0;
(void)strtoul(p, &ep, 10);
if (errno == 0 && ep && *ep == '\0')
return true;
else
return false;
}
int
rb_getaddrinfo(const char *hostname, const char *servname,
const struct rb_addrinfo *hints, struct rb_addrinfo **res)
{
struct rb_addrinfo sentinel;
struct rb_addrinfo *cur;
int error = 0;
struct rb_addrinfo ai;
struct rb_addrinfo ai0;
struct rb_addrinfo *pai;
const struct explore *ex;
memset(&sentinel, 0, sizeof(sentinel));
cur = &sentinel;
pai = &ai;
pai->ai_flags = 0;
pai->ai_family = PF_UNSPEC;
pai->ai_socktype = ANY;
pai->ai_protocol = ANY;
pai->ai_addrlen = 0;
pai->ai_canonname = NULL;
pai->ai_addr = NULL;
pai->ai_next = NULL;
if (hostname == NULL && servname == NULL)
return EAI_NONAME;
if (hints) {
/* error check for hints */
if (hints->ai_addrlen || hints->ai_canonname ||
hints->ai_addr || hints->ai_next)
ERR(EAI_BADHINTS); /* xxx */
if (hints->ai_flags & ~AI_MASK)
ERR(EAI_BADFLAGS);
switch (hints->ai_family) {
case PF_UNSPEC:
case PF_INET:
#ifdef IPV6
case PF_INET6:
#endif
break;
default:
ERR(EAI_FAMILY);
}
memcpy(pai, hints, sizeof(*pai));
/*
* if both socktype/protocol are specified, check if they
* are meaningful combination.
*/
if (pai->ai_socktype != ANY && pai->ai_protocol != ANY) {
for (ex = explore; ex->e_af >= 0; ex++) {
if (pai->ai_family != ex->e_af)
continue;
if (ex->e_socktype == ANY)
continue;
if (ex->e_protocol == ANY)
continue;
if (pai->ai_socktype == ex->e_socktype &&
pai->ai_protocol != ex->e_protocol) {
ERR(EAI_BADHINTS);
}
}
}
}
/*
* check for special cases. (1) numeric servname is disallowed if
* socktype/protocol are left unspecified. (2) servname is disallowed
* for raw and other inet{,6} sockets.
*/
if (MATCH_FAMILY(pai->ai_family, PF_INET, 1)
#ifdef IPV6
|| MATCH_FAMILY(pai->ai_family, PF_INET6, 1)
#endif
) {
ai0 = *pai; /* backup *pai */
if (pai->ai_family == PF_UNSPEC) {
#ifdef IPV6
pai->ai_family = PF_INET6;
#else
pai->ai_family = PF_INET;
#endif
}
error = get_portmatch(pai, servname);
if (error)
ERR(error);
*pai = ai0;
}
ai0 = *pai;
/* NULL hostname, or numeric hostname */
for (ex = explore; ex->e_af >= 0; ex++) {
*pai = ai0;
/* PF_UNSPEC entries are prepared for DNS queries only */
if (ex->e_af == PF_UNSPEC)
continue;
if (!MATCH_FAMILY(pai->ai_family, ex->e_af, WILD_AF(ex)))
continue;
if (!MATCH(pai->ai_socktype, ex->e_socktype, WILD_SOCKTYPE(ex)))
continue;
if (!MATCH(pai->ai_protocol, ex->e_protocol, WILD_PROTOCOL(ex)))
continue;
if (pai->ai_family == PF_UNSPEC)
pai->ai_family = ex->e_af;
if (pai->ai_socktype == ANY && ex->e_socktype != ANY)
pai->ai_socktype = ex->e_socktype;
if (pai->ai_protocol == ANY && ex->e_protocol != ANY)
pai->ai_protocol = ex->e_protocol;
if (hostname == NULL)
error = explore_null(pai, servname, &cur->ai_next);
else
error = explore_numeric(pai, hostname, servname, &cur->ai_next);
if (error)
goto free;
while (cur && cur->ai_next)
cur = cur->ai_next;
}
/*
* XXX
* If numreic representation of AF1 can be interpreted as FQDN
* representation of AF2, we need to think again about the code below.
*/
if (sentinel.ai_next)
goto good;
if (pai->ai_flags & AI_NUMERICHOST)
ERR(EAI_NONAME);
if (hostname == NULL)
ERR(EAI_NODATA);
/* XXX */
if (sentinel.ai_next)
error = 0;
if (error)
goto free;
if (error == 0) {
if (sentinel.ai_next) {
good:
*res = sentinel.ai_next;
return SUCCESS;
} else
error = EAI_FAIL;
}
free:
bad:
if (sentinel.ai_next)
rb_freeaddrinfo(sentinel.ai_next);
*res = NULL;
return error;
}
/*
* hostname == NULL.
* passive socket -> anyaddr (0.0.0.0 or ::)
* non-passive socket -> localhost (127.0.0.1 or ::1)
*/
static int
explore_null(const struct rb_addrinfo *pai, const char *servname, struct rb_addrinfo **res)
{
int s;
const struct afd *afd;
struct rb_addrinfo *cur;
struct rb_addrinfo sentinel;
int error;
*res = NULL;
sentinel.ai_next = NULL;
cur = &sentinel;
/*
* filter out AFs that are not supported by the kernel
* XXX errno?
*/
s = socket(pai->ai_family, SOCK_DGRAM, 0);
if (s < 0) {
#ifdef _WIN32
errno = WSAGetLastError();
#endif
if (errno != EMFILE)
return 0;
} else
#ifdef _WIN32
closesocket(s);
#else
close(s);
#endif
/*
* if the servname does not match socktype/protocol, ignore it.
*/
if (get_portmatch(pai, servname) != 0)
return 0;
afd = find_afd(pai->ai_family);
if (afd == NULL)
return 0;
if (pai->ai_flags & AI_PASSIVE) {
GET_AI(cur->ai_next, afd, afd->a_addrany);
GET_PORT(cur->ai_next, servname);
} else {
GET_AI(cur->ai_next, afd, afd->a_loopback);
GET_PORT(cur->ai_next, servname);
}
cur = cur->ai_next;
*res = sentinel.ai_next;
return 0;
free:
if (sentinel.ai_next)
rb_freeaddrinfo(sentinel.ai_next);
return error;
}
/*
* numeric hostname
*/
static int
explore_numeric(const struct rb_addrinfo *pai, const char *hostname,
const char *servname, struct rb_addrinfo **res)
{
const struct afd *afd;
struct rb_addrinfo *cur;
struct rb_addrinfo sentinel;
int error;
char pton[PTON_MAX];
*res = NULL;
sentinel.ai_next = NULL;
cur = &sentinel;
/*
* if the servname does not match socktype/protocol, ignore it.
*/
if (get_portmatch(pai, servname) != 0)
return 0;
afd = find_afd(pai->ai_family);
if (afd == NULL)
return 0;
switch (afd->a_af) {
#if 0 /*X/Open spec*/
case AF_INET:
if (rb_inet_pton
if (inet_aton(hostname, (struct in_addr *)pton) == 1) {
if (pai->ai_family == afd->a_af ||
pai->ai_family == PF_UNSPEC /*?*/) {
GET_AI(cur->ai_next, afd, pton);
GET_PORT(cur->ai_next, servname);
while (cur && cur->ai_next)
cur = cur->ai_next;
} else
ERR(EAI_FAMILY); /*xxx*/
}
break;
#endif
default:
if (rb_inet_pton(afd->a_af, hostname, pton) == 1) {
if (pai->ai_family == afd->a_af ||
pai->ai_family == PF_UNSPEC /*?*/) {
GET_AI(cur->ai_next, afd, pton);
GET_PORT(cur->ai_next, servname);
while (cur && cur->ai_next)
cur = cur->ai_next;
} else
ERR(EAI_FAMILY); /* XXX */
}
break;
}
*res = sentinel.ai_next;
return 0;
free:
bad:
if (sentinel.ai_next)
rb_freeaddrinfo(sentinel.ai_next);
return error;
}
static struct rb_addrinfo *
get_ai(const struct rb_addrinfo *pai, const struct afd *afd, const char *addr)
{
char *p;
struct rb_addrinfo *ai;
ai = (struct rb_addrinfo *)rb_malloc(sizeof(struct rb_addrinfo)
+ (afd->a_socklen));
if (ai == NULL)
return NULL;
memcpy(ai, pai, sizeof(struct rb_addrinfo));
ai->ai_addr = (struct sockaddr *)(void *)(ai + 1);
memset(ai->ai_addr, 0, (size_t)afd->a_socklen);
ai->ai_addrlen = afd->a_socklen;
ai->ai_addr->sa_family = ai->ai_family = afd->a_af;
p = (char *)(void *)(ai->ai_addr);
memcpy(p + afd->a_off, addr, (size_t)afd->a_addrlen);
return ai;
}
static int
get_portmatch(const struct rb_addrinfo *ai, const char *servname)
{
struct rb_addrinfo xai;
memcpy(&xai, ai, sizeof(struct rb_addrinfo));
return(get_port(&xai, servname, 1));
}
static int
get_port(struct rb_addrinfo *ai, const char *servname, int matchonly)
{
const char *proto;
struct servent *sp;
int port;
int allownumeric;
if (servname == NULL)
return 0;
switch (ai->ai_family) {
case AF_INET:
#ifdef AF_INET6
case AF_INET6:
#endif
break;
default:
return 0;
}
switch (ai->ai_socktype) {
case SOCK_RAW:
return EAI_SERVICE;
case SOCK_DGRAM:
case SOCK_STREAM:
allownumeric = 1;
break;
case ANY:
allownumeric = 0;
break;
default:
return EAI_SOCKTYPE;
}
if (str_isnumber(servname)) {
if (!allownumeric)
return EAI_SERVICE;
port = atoi(servname);
if (port < 0 || port > 65535)
return EAI_SERVICE;
port = htons(port);
} else {
switch (ai->ai_socktype) {
case SOCK_DGRAM:
proto = "udp";
break;
case SOCK_STREAM:
proto = "tcp";
break;
default:
proto = NULL;
break;
}
if ((sp = getservbyname(servname, proto)) == NULL)
return EAI_SERVICE;
port = sp->s_port;
}
if (!matchonly) {
switch (ai->ai_family) {
case AF_INET:
((struct sockaddr_in *)(void *)
ai->ai_addr)->sin_port = port;
break;
#ifdef IPV6
case AF_INET6:
((struct sockaddr_in6 *)(void *)
ai->ai_addr)->sin6_port = port;
break;
#endif
}
}
return 0;
}
static const struct afd *
find_afd(int af)
{
const struct afd *afd;
if (af == PF_UNSPEC)
return(NULL);
for (afd = afdl; afd->a_af; afd++)
{
if (afd->a_af == af)
return(afd);
}
return(NULL);
}
#endif

View File

@ -1,123 +0,0 @@
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the project nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
*/
struct rb_addrinfo {
int ai_flags;
int ai_family;
int ai_socktype;
int ai_protocol;
size_t ai_addrlen;
char *ai_canonname;
struct sockaddr *ai_addr;
struct rb_addrinfo *ai_next;
};
#ifndef AI_PASSIVE
#define AI_PASSIVE 0x00000001 /* get address to use bind() */
#endif /* AI_PASSIVE */
#ifndef AI_NUMERICHOST
#define AI_NUMERICHOST 0x00000004 /* prevent name resolution */
#endif /* AI_NUMERICHOST */
#ifndef EAI_FAIL
#define EAI_FAIL 4 /* non-recoverable failure in name resolution */
#endif /* EAI_FAIL */
#ifndef EAI_FAMILY
#define EAI_FAMILY 5 /* ai_family not supported */
#endif /* EAI_FAMILY */
#ifndef EAI_MEMORY
#define EAI_MEMORY 6 /* memory allocation failure */
#endif /* EAI_MEMORY */
#ifndef EAI_NONAME
#define EAI_NONAME 8 /* hostname nor servname provided, or not known */
#endif /* EAI_NONAME */
#ifndef EAI_SYSTEM
#define EAI_SYSTEM 11 /* system error returned in errno */
#endif /* EAI_SYSTEM */
#ifndef NI_NUMERICHOST
#define NI_NUMERICHOST 0x00000002
#endif /* NI_NUMERICHOST */
#ifndef NI_NAMEREQD
#define NI_NAMEREQD 0x00000004
#endif /* NI_NAMEREQD */
#ifndef NI_NUMERICSERV
#define NI_NUMERICSERV 0x00000008
#endif /* NI_NUMERICSERV */
#ifndef NI_DGRAM
#define NI_DGRAM 0x00000010
#endif /* NI_DGRAM */
int rb_getaddrinfo(const char *hostname, const char *servname,
const struct rb_addrinfo *hints, struct rb_addrinfo **res);
void rb_freeaddrinfo(struct rb_addrinfo *ai);
#define SUCCESS 0
#define ANY 0
#undef EAI_ADDRFAMILY
#undef EAI_AGAIN
#undef EAI_BADFLAGS
#undef EAI_FAIL
#undef EAI_FAMILY
#undef EAI_MEMORY
#undef EAI_NODATA
#undef EAI_NONAME
#undef EAI_SERVICE
#undef EAI_SOCKTYPE
#undef EAI_SYSTEM
#undef EAI_BADHINTS
#undef EAI_PROTOCOL
#undef EAI_MAX
#undef AI_MASK
#define EAI_ADDRFAMILY 1 /* address family for hostname not supported */
#define EAI_AGAIN 2 /* temporary failure in name resolution */
#define EAI_BADFLAGS 3 /* invalid value for ai_flags */
#define EAI_FAIL 4 /* non-recoverable failure in name resolution */
#define EAI_FAMILY 5 /* ai_family not supported */
#define EAI_MEMORY 6 /* memory allocation failure */
#define EAI_NODATA 7 /* no address associated with hostname */
#define EAI_NONAME 8 /* hostname nor servname provided, or not known */
#define EAI_SERVICE 9 /* servname not supported for ai_socktype */
#define EAI_SOCKTYPE 10 /* ai_socktype not supported */
#define EAI_SYSTEM 11 /* system error returned in errno */
#define EAI_BADHINTS 12
#define EAI_PROTOCOL 13
#define EAI_MAX 14
#define AI_MASK (AI_PASSIVE | AI_NUMERICHOST)

View File

@ -1,240 +0,0 @@
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the project nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/*
* Issues to be discussed:
* - Thread safe-ness must be checked
* - RFC2553 says that we should raise error on short buffer. X/Open says
* we need to truncate the result. We obey RFC2553 (and X/Open should be
* modified). ipngwg rough consensus seems to follow RFC2553.
* - What is "local" in NI_FQDN?
* - NI_NAMEREQD and NI_NUMERICHOST conflict with each other.
* - (KAME extension) always attach textual scopeid (fe80::1%lo0), if
* sin6_scope_id is filled - standardization status?
* XXX breaks backward compat for code that expects no scopeid.
* beware on merge.
*/
#ifdef _WIN32
#include <rb_lib.h>
#include "getaddrinfo.h"
#include "getnameinfo.h"
static const struct afd {
int a_af;
int a_addrlen;
rb_socklen_t a_socklen;
int a_off;
} afdl [] = {
#ifdef IPV6
{PF_INET6, sizeof(struct in6_addr), sizeof(struct sockaddr_in6),
offsetof(struct sockaddr_in6, sin6_addr)},
#endif
{PF_INET, sizeof(struct in_addr), sizeof(struct sockaddr_in),
offsetof(struct sockaddr_in, sin_addr)},
{0, 0, 0, 0},
};
struct sockinet
{
unsigned char si_len;
unsigned char si_family;
unsigned short si_port;
};
#ifdef IPV6
static int ip6_parsenumeric(const struct sockaddr *, const char *, char *,
size_t, int);
#endif
int
rb_getnameinfo(const struct sockaddr *sa, rb_socklen_t salen, char *host,
size_t hostlen, char *serv, size_t servlen, int flags)
{
const struct afd *afd;
struct servent *sp;
unsigned short port;
int family, i;
const char *addr;
uint32_t v4a;
char numserv[512];
char numaddr[512];
if (sa == NULL)
return EAI_FAIL;
/* if (sa->sa_len != salen)
return EAI_FAIL;
*/
family = sa->sa_family;
for (i = 0; afdl[i].a_af; i++)
if (afdl[i].a_af == family) {
afd = &afdl[i];
goto found;
}
return EAI_FAMILY;
found:
if (salen != afd->a_socklen)
return EAI_FAIL;
/* network byte order */
port = ((const struct sockinet *)sa)->si_port;
addr = (const char *)sa + afd->a_off;
if (serv == NULL || servlen == 0) {
/*
* do nothing in this case.
* in case you are wondering if "&&" is more correct than
* "||" here: rfc2553bis-03 says that serv == NULL OR
* servlen == 0 means that the caller does not want the result.
*/
} else {
if (flags & NI_NUMERICSERV)
sp = NULL;
else {
sp = getservbyport(port,
(flags & NI_DGRAM) ? "udp" : "tcp");
}
if (sp) {
if (strlen(sp->s_name) + 1 > servlen)
return EAI_MEMORY;
rb_strlcpy(serv, sp->s_name, servlen);
} else {
snprintf(numserv, sizeof(numserv), "%u", ntohs(port));
if (strlen(numserv) + 1 > servlen)
return EAI_MEMORY;
rb_strlcpy(serv, numserv, servlen);
}
}
switch (sa->sa_family) {
case AF_INET:
v4a = (uint32_t)
ntohl(((const struct sockaddr_in *)sa)->sin_addr.s_addr);
if (IN_MULTICAST(v4a) || IN_EXPERIMENTAL(v4a))
flags |= NI_NUMERICHOST;
v4a >>= IN_CLASSA_NSHIFT;
if (v4a == 0)
flags |= NI_NUMERICHOST;
break;
#ifdef IPV6
case AF_INET6:
{
const struct sockaddr_in6 *sin6;
sin6 = (const struct sockaddr_in6 *)sa;
switch (sin6->sin6_addr.s6_addr[0]) {
case 0x00:
if (IN6_IS_ADDR_V4MAPPED(&sin6->sin6_addr))
;
else if (IN6_IS_ADDR_LOOPBACK(&sin6->sin6_addr))
;
else
flags |= NI_NUMERICHOST;
break;
default:
if (IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr)) {
flags |= NI_NUMERICHOST;
}
else if (IN6_IS_ADDR_MULTICAST(&sin6->sin6_addr))
flags |= NI_NUMERICHOST;
break;
}
}
break;
#endif
}
if (host == NULL || hostlen == 0) {
/*
* do nothing in this case.
* in case you are wondering if "&&" is more correct than
* "||" here: rfc2553bis-03 says that host == NULL or
* hostlen == 0 means that the caller does not want the result.
*/
} else if (flags & NI_NUMERICHOST) {
size_t numaddrlen;
/* NUMERICHOST and NAMEREQD conflicts with each other */
if (flags & NI_NAMEREQD)
return EAI_NONAME;
switch(afd->a_af) {
#ifdef IPV6
case AF_INET6:
{
int error;
if ((error = ip6_parsenumeric(sa, addr, host,
hostlen, flags)) != 0)
return(error);
break;
}
#endif
default:
if (rb_inet_ntop(afd->a_af, addr, numaddr, sizeof(numaddr))
== NULL)
return EAI_SYSTEM;
numaddrlen = strlen(numaddr);
if (numaddrlen + 1 > hostlen) /* don't forget terminator */
return EAI_MEMORY;
rb_strlcpy(host, numaddr, hostlen);
break;
}
}
return(0);
}
#ifdef IPV6
static int
ip6_parsenumeric(const struct sockaddr *sa, const char *addr,
char *host, size_t hostlen, int flags)
{
size_t numaddrlen;
char numaddr[512];
if (rb_inet_ntop(AF_INET6, addr, numaddr, sizeof(numaddr)) == NULL)
return(EAI_SYSTEM);
numaddrlen = strlen(numaddr);
if (numaddrlen + 1 > hostlen) /* don't forget terminator */
return(EAI_MEMORY);
if (*numaddr == ':')
{
*host = '0';
rb_strlcpy(host+1, numaddr, hostlen-1);
}
else
rb_strlcpy(host, numaddr, hostlen);
return(0);
}
#endif
#endif

View File

@ -1,40 +0,0 @@
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the project nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
*/
int rb_getnameinfo(const struct sockaddr *sa, rb_socklen_t salen, char *host,
size_t hostlen, char *serv, size_t servlen, int flags);
#ifndef IN_MULTICAST
#define IN_MULTICAST(a) ((((long int) (a)) & 0xf0000000) == 0xe0000000)
#endif
#ifndef IN_EXPERIMENTAL
#define IN_EXPERIMENTAL(a) ((((long int) (a)) & 0xe0000000) == 0xe0000000)
#endif

View File

@ -77,24 +77,7 @@
*/
#include <rb_lib.h>
#ifndef _WIN32
#include <netdb.h>
typedef struct addrinfo rb_addrinfo;
#else
#include "getaddrinfo.h"
#include "getnameinfo.h"
#define getaddrinfo rb_getaddrinfo
#define getnameinfo rb_getnameinfo
#define freeaddrinfo rb_freeaddrinfo
extern const char * get_windows_nameservers(void);
typedef struct rb_addrinfo rb_addrinfo;
#endif
#include "stdinc.h"
#include "ircd_defs.h"
#include "ircd.h"
@ -130,15 +113,10 @@ static const char digitvalue[256] = {
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /*256*/
};
#ifndef _WIN32
static int parse_resvconf(void);
#else
static void parse_windows_resolvers(void);
#endif
static void add_nameserver(const char *);
static const char digits[] = "0123456789";
static int parse_resvconf(void);
static void add_nameserver(const char *);
static int labellen(const unsigned char *lp);
static int special(int ch);
static int printable(int ch);
@ -162,31 +140,12 @@ int
irc_res_init(void)
{
irc_nscount = 0;
#ifndef _WIN32
parse_resvconf();
#else
parse_windows_resolvers();
#endif
if (irc_nscount == 0)
add_nameserver("127.0.0.1");
return 0;
}
#ifdef _WIN32
static void
parse_windows_resolvers(void)
{
const char *ns = get_windows_nameservers();
char *server;
char *p;
char *buf = rb_strdup(ns);
for(server = rb_strtok_r(buf, " ", &p); server != NULL;server = rb_strtok_r(NULL, " ", &p))
{
add_nameserver(server);
}
rb_free(buf);
}
#else
/* parse_resvconf()
*
* inputs - NONE
@ -202,9 +161,6 @@ parse_resvconf(void)
char input[DNS_MAXLINE];
FILE *file;
/* XXX "/etc/resolv.conf" should be from a define in setup.h perhaps
* for cygwin support etc. this hardcodes it to unix for now -db
*/
if ((file = fopen("/etc/resolv.conf", "r")) == NULL)
return -1;
@ -252,7 +208,6 @@ parse_resvconf(void)
fclose(file);
return 0;
}
#endif
/* add_nameserver()
*
@ -264,7 +219,7 @@ parse_resvconf(void)
static void
add_nameserver(const char *arg)
{
rb_addrinfo hints, *res;
struct addrinfo hints, *res;
/* Done max number of nameservers? */
if (irc_nscount >= IRCD_MAXNS)

View File

@ -1,279 +0,0 @@
/*
* reslist.c - get nameservers from windows *
*
* ircd-ratbox related changes are as follows
*
* Copyright (C) 2008 Aaron Sethman <androsyn@ratbox.org>
* Copyright (C) 2008-2012 ircd-ratbox development team
*
* pretty much all of this was yanked from c-ares ares_init.c here is the original
* header from there --
*
* Id: ares_init.c,v 1.72 2008-05-15 00:00:19 yangtse Exp $
* Copyright 1998 by the Massachusetts Institute of Technology.
* Copyright (C) 2007-2008 by Daniel Stenberg
*
* Permission to use, copy, modify, and distribute this
* software and its documentation for any purpose and without
* fee is hereby granted, provided that the above copyright
* notice appear in all copies and that both that copyright
* notice and this permission notice appear in supporting
* documentation, and that the name of M.I.T. not be used in
* advertising or publicity pertaining to distribution of the
* software without specific, written prior permission.
* M.I.T. makes no representations about the suitability of
* this software for any purpose. It is provided "as is"
* without express or implied warranty.
*
*
*/
#ifdef _WIN32
#include <rb_lib.h>
#include <windows.h>
#include <iphlpapi.h>
const char *get_windows_nameservers(void);
#ifndef INADDR_NONE
#define INADDR_NONE ((unsigned int) 0xffffffff)
#endif /* INADDR_NONE */
#define IS_NT() ((int)GetVersion() > 0)
#define WIN_NS_9X "System\\CurrentControlSet\\Services\\VxD\\MSTCP"
#define WIN_NS_NT_KEY "System\\CurrentControlSet\\Services\\Tcpip\\Parameters"
#define NAMESERVER "NameServer"
#define DHCPNAMESERVER "DhcpNameServer"
#define DATABASEPATH "DatabasePath"
#define WIN_PATH_HOSTS "\\hosts"
static int
get_iphlpapi_dns_info(char *ret_buf, size_t ret_size)
{
FIXED_INFO *fi = alloca(sizeof(*fi));
DWORD size = sizeof(*fi);
typedef DWORD(WINAPI * get_net_param_func) (FIXED_INFO *, DWORD *);
get_net_param_func xxGetNetworkParams; /* available only on Win-98/2000+ */
HMODULE handle;
IP_ADDR_STRING *ipAddr;
int i, count = 0;
int debug = 0;
size_t ip_size = sizeof("255.255.255.255,") - 1;
size_t left = ret_size;
char *ret = ret_buf;
HRESULT res;
if(!fi)
return (0);
handle = LoadLibrary("iphlpapi.dll");
if(!handle)
return (0);
xxGetNetworkParams = (get_net_param_func) GetProcAddress(handle, "GetNetworkParams");
if(!xxGetNetworkParams)
goto quit;
res = (*xxGetNetworkParams) (fi, &size);
if((res != ERROR_BUFFER_OVERFLOW) && (res != ERROR_SUCCESS))
goto quit;
fi = alloca(size);
if(!fi || (*xxGetNetworkParams) (fi, &size) != ERROR_SUCCESS)
goto quit;
if(debug)
{
printf("Host Name: %s\n", fi->HostName);
printf("Domain Name: %s\n", fi->DomainName);
printf("DNS Servers:\n" " %s (primary)\n", fi->DnsServerList.IpAddress.String);
}
if(strlen(fi->DnsServerList.IpAddress.String) > 0 &&
inet_addr(fi->DnsServerList.IpAddress.String) != INADDR_NONE && left > ip_size)
{
ret += sprintf(ret, "%s,", fi->DnsServerList.IpAddress.String);
left -= ret - ret_buf;
count++;
}
for(i = 0, ipAddr = fi->DnsServerList.Next; ipAddr && left > ip_size;
ipAddr = ipAddr->Next, i++)
{
if(inet_addr(ipAddr->IpAddress.String) != INADDR_NONE)
{
ret += sprintf(ret, "%s,", ipAddr->IpAddress.String);
left -= ret - ret_buf;
count++;
}
if(debug)
printf(" %s (secondary %d)\n", ipAddr->IpAddress.String, i + 1);
}
quit:
if(handle)
FreeLibrary(handle);
if(debug && left <= ip_size)
printf("Too many nameservers. Truncating to %d addressess", count);
if(ret > ret_buf)
ret[-1] = '\0';
return (count);
}
/*
* Warning: returns a dynamically allocated buffer, the user MUST
* use free() / rb_free() if the function returns 1
*/
static int
get_res_nt(HKEY hKey, const char *subkey, char **obuf)
{
/* Test for the size we need */
DWORD size = 0;
int result;
result = RegQueryValueEx(hKey, subkey, 0, NULL, NULL, &size);
if((result != ERROR_SUCCESS && result != ERROR_MORE_DATA) || !size)
return 0;
*obuf = rb_malloc(size + 1);
if(!*obuf)
return 0;
if(RegQueryValueEx(hKey, subkey, 0, NULL, (LPBYTE) * obuf, &size) != ERROR_SUCCESS)
{
rb_free(*obuf);
return 0;
}
if(size == 1)
{
rb_free(*obuf);
return 0;
}
return 1;
}
static int
get_res_interfaces_nt(HKEY hKey, const char *subkey, char **obuf)
{
char enumbuf[39]; /* GUIDs are 38 chars + 1 for NULL */
DWORD enum_size = 39;
int idx = 0;
HKEY hVal;
while(RegEnumKeyEx(hKey, idx++, enumbuf, &enum_size, 0,
NULL, NULL, NULL) != ERROR_NO_MORE_ITEMS)
{
int rc;
enum_size = 39;
if(RegOpenKeyEx(hKey, enumbuf, 0, KEY_QUERY_VALUE, &hVal) != ERROR_SUCCESS)
continue;
rc = get_res_nt(hVal, subkey, obuf);
RegCloseKey(hVal);
if(rc)
return 1;
}
return 0;
}
const char *
get_windows_nameservers(void)
{
/*
NameServer info via IPHLPAPI (IP helper API):
GetNetworkParams() should be the trusted source for this.
Available in Win-98/2000 and later. If that fail, fall-back to
registry information.
NameServer Registry:
On Windows 9X, the DNS server can be found in:
HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\VxD\MSTCP\NameServer
On Windows NT/2000/XP/2003:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\NameServer
or
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\DhcpNameServer
or
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\{AdapterID}\
NameServer
or
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\{AdapterID}\
DhcpNameServer
*/
static char namelist[512];
HKEY mykey;
HKEY subkey;
DWORD data_type;
DWORD bytes;
DWORD result;
char *line = NULL;
memset(&namelist, 0, sizeof(namelist));
if(get_iphlpapi_dns_info(namelist, sizeof(namelist)) > 0)
{
return namelist;
}
if(IS_NT())
{
if(RegOpenKeyEx(HKEY_LOCAL_MACHINE, WIN_NS_NT_KEY, 0,
KEY_READ, &mykey) == ERROR_SUCCESS)
{
RegOpenKeyEx(mykey, "Interfaces", 0,
KEY_QUERY_VALUE | KEY_ENUMERATE_SUB_KEYS, &subkey);
if(get_res_nt(mykey, NAMESERVER, &line))
{
rb_strlcpy(namelist, line, sizeof(namelist));
return namelist;
}
else if(get_res_nt(mykey, DHCPNAMESERVER, &line))
{
rb_strlcpy(namelist, line, sizeof(namelist));
rb_free(line);
}
/* Try the interfaces */
else if(get_res_interfaces_nt(subkey, NAMESERVER, &line))
{
rb_strlcpy(namelist, line, sizeof(namelist));
rb_free(line);
}
else if(get_res_interfaces_nt(subkey, DHCPNAMESERVER, &line))
{
rb_strlcpy(namelist, line, sizeof(namelist));
rb_free(line);
}
RegCloseKey(subkey);
RegCloseKey(mykey);
}
}
else
{
if(RegOpenKeyEx(HKEY_LOCAL_MACHINE, WIN_NS_9X, 0,
KEY_READ, &mykey) == ERROR_SUCCESS)
{
if((result = RegQueryValueEx(mykey, NAMESERVER, NULL, &data_type,
NULL, &bytes)) == ERROR_SUCCESS ||
result == ERROR_MORE_DATA)
{
if(bytes)
{
line = (char *)rb_malloc(bytes + 1);
if(RegQueryValueEx(mykey, NAMESERVER, NULL, &data_type,
(unsigned char *)line, &bytes) ==
ERROR_SUCCESS)
{
rb_strlcpy(namelist, line, sizeof(namelist));
}
free(line);
}
}
}
RegCloseKey(mykey);
}
if(strlen(namelist) > 0)
return namelist;
return NULL;
}
#endif

View File

@ -247,18 +247,15 @@ error_cb(rb_helper *helper)
exit(1);
}
#ifndef WINDOWS
static void
dummy_handler(int sig)
{
return;
}
#endif
static void
setup_signals(void)
{
#ifndef _WIN32
struct sigaction act;
act.sa_flags = 0;
@ -281,7 +278,6 @@ setup_signals(void)
act.sa_handler = dummy_handler;
sigaction(SIGALRM, &act, 0);
#endif
}

View File

@ -34,24 +34,6 @@ LTDL_INIT
build_ltdl=$with_included_ltdl
AM_CONDITIONAL([BUILD_LTDL], [test x"$build_ltdl" = x"yes"])
case "$host_os" in
*cygwin*)
AC_DEFINE_UNQUOTED(CYGWIN,1,[This is a Cygwin system])
AC_DEFINE_UNQUOTED(WINDOWS,1,[This is a Windows system])
;;
*mingw* | *msys*)
AC_DEFINE_UNQUOTED(MINGW,1,[This is a MinGW system])
AC_DEFINE_UNQUOTED(WINDOWS,1,[This is a Windows system])
AC_CHECK_HEADER(winsock2.h, , [AC_MSG_ERROR([** MinGW and no winsock2.h. I give up.])])
LIBS="$LIBS -lws2_32 -liphlpapi"
is_mingw="yes"
;;
*)
;;
esac
AM_CONDITIONAL([MINGW], [test "$is_mingw" = "yes"])
if test "$ac_cv_c_compiler_gnu" = yes; then
IRC_CFLAGS="$IRC_CFLAGS -O0 -Wall"
fi
@ -653,15 +635,10 @@ AC_SUBST(SEDOBJ)
if test "$prefix" = "NONE"; then
AC_DEFINE_UNQUOTED(IRCD_PREFIX, "$ac_default_prefix", [Prefix where the ircd is installed.])
else
dnl Don't get bitten by Cygwin's stupidity if the user specified
dnl a custom prefix with a trailing slash
dnl Strip trailing slashes to prevent a path of '//'
prefix=`echo $prefix | sed 's/\/$//'`
AC_DEFINE_UNQUOTED(IRCD_PREFIX, "$prefix", [Prefix where the ircd is installed.])
fi
AC_CONFIG_FILES( \

View File

@ -51,9 +51,6 @@ If aes256 is not available, the following is used instead:
- Building ratbox-respond -
---------------------------
If you are using the unix based ratbox-respond this must be built. For the
windows version, ratbox-winrespond, please see http://respond.ircd-ratbox.org
ratbox-respond takes the challenge from the server, and together with your
private key file generates a response to be sent back. ratbox-respond
requires the openssl headers (ie, development files) and openssl libraries

View File

@ -2,9 +2,6 @@ AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/librb/include $(LTDLINCL)
AM_LDFLAGS = -module -export-dynamic -avoid-version -no-undefined -shared
AM_LDFLAGS += -export-symbols-regex _mheader
LIBS += $(top_srcdir)/ircd/libircd.la
if MINGW
LIBS += $(top_srcdir)/librb/src/librb.la
endif
extensiondir=@moduledir@/extensions

View File

@ -14,10 +14,6 @@ version.c: version.c.SH ../CREDITS ../include/patchlevel.h ../include/serno.h
$(CP) version.c version.c.last
touch version.c.SH
if MINGW
EXTRA_FLAGS = -Wl,--enable-runtime-pseudo-reloc -export-symbols-regex '*'
endif
libircd_la_SOURCES = \
authproc.c \
bandbi.c \

View File

@ -88,19 +88,14 @@ static int
start_authd(void)
{
char fullpath[PATH_MAX + 1];
#ifdef _WIN32
const char *suffix = ".exe";
#else
const char *suffix = "";
#endif
if(authd_path == NULL)
{
snprintf(fullpath, sizeof(fullpath), "%s%cauthd%s", ircd_paths[IRCD_PATH_LIBEXEC], RB_PATH_SEPARATOR, suffix);
snprintf(fullpath, sizeof(fullpath), "%s/authd", ircd_paths[IRCD_PATH_LIBEXEC]);
if(access(fullpath, X_OK) == -1)
{
snprintf(fullpath, sizeof(fullpath), "%s%cbin%cauthd%s",
ConfigFileEntry.dpath, RB_PATH_SEPARATOR, RB_PATH_SEPARATOR, suffix);
snprintf(fullpath, sizeof(fullpath), "%s/bin/authd", ConfigFileEntry.dpath);
if(access(fullpath, X_OK) == -1)
{
ierror("Unable to execute authd in %s or %s/bin",

View File

@ -77,27 +77,21 @@ static int
start_bandb(void)
{
char fullpath[PATH_MAX + 1];
#ifdef _WIN32
const char *suffix = ".exe";
#else
const char *suffix = "";
#endif
rb_setenv("BANDB_DBPATH", ircd_paths[IRCD_PATH_BANDB], 1);
if(bandb_path == NULL)
{
snprintf(fullpath, sizeof(fullpath), "%s%cbandb%s", ircd_paths[IRCD_PATH_LIBEXEC], RB_PATH_SEPARATOR, suffix);
snprintf(fullpath, sizeof(fullpath), "%s/bandb", ircd_paths[IRCD_PATH_LIBEXEC]);
if(access(fullpath, X_OK) == -1)
{
snprintf(fullpath, sizeof(fullpath), "%s%cbin%cbandb%s",
ConfigFileEntry.dpath, RB_PATH_SEPARATOR, RB_PATH_SEPARATOR, suffix);
snprintf(fullpath, sizeof(fullpath), "%s/bin/bandb", ConfigFileEntry.dpath);
if(access(fullpath, X_OK) == -1)
{
ilog(L_MAIN,
"Unable to execute bandb%s in %s or %s/bin",
suffix, ircd_paths[IRCD_PATH_LIBEXEC], ConfigFileEntry.dpath);
"Unable to execute bandb in %s or %s/bin",
ircd_paths[IRCD_PATH_LIBEXEC], ConfigFileEntry.dpath);
return 0;
}
}

View File

@ -266,7 +266,7 @@ load_help(void)
{
if(ldirent->d_name[0] == '.')
continue;
snprintf(filename, sizeof(filename), "%s%c%s", ircd_paths[IRCD_PATH_OPERHELP], RB_PATH_SEPARATOR, ldirent->d_name);
snprintf(filename, sizeof(filename), "%s/%s", ircd_paths[IRCD_PATH_OPERHELP], ldirent->d_name);
cacheptr = cache_file(filename, ldirent->d_name, HELP_OPER);
rb_dictionary_add(help_dict_oper, cacheptr->name, cacheptr);
}
@ -281,7 +281,7 @@ load_help(void)
{
if(ldirent->d_name[0] == '.')
continue;
snprintf(filename, sizeof(filename), "%s%c%s", ircd_paths[IRCD_PATH_USERHELP], RB_PATH_SEPARATOR, ldirent->d_name);
snprintf(filename, sizeof(filename), "%s/%s", ircd_paths[IRCD_PATH_USERHELP], ldirent->d_name);
#if defined(S_ISLNK) && defined(HAVE_LSTAT)
if(lstat(filename, &sb) < 0)

View File

@ -197,7 +197,7 @@ ircd_shutdown(const char *reason)
static void
init_sys(void)
{
#if !defined(_WIN32) && defined(RLIMIT_NOFILE) && defined(HAVE_SYS_RESOURCE_H)
#if defined(RLIMIT_NOFILE) && defined(HAVE_SYS_RESOURCE_H)
struct rlimit limit;
if(!getrlimit(RLIMIT_NOFILE, &limit))
@ -215,7 +215,6 @@ init_sys(void)
maxconnections = MAXCONNECTIONS;
}
#ifndef _WIN32
static int
make_daemon(void)
{
@ -255,7 +254,6 @@ make_daemon(void)
return 0;
}
#endif
static int printVersion = 0;
@ -353,92 +351,6 @@ initialize_global_set_options(void)
}
#ifdef _WIN32
/*
* relocate_paths
*
* inputs - none
* output - none
* side effects - items in ircd_paths[] array are relocated
*/
static void
relocate_paths(void)
{
char prefix[PATH_MAX], workbuf[PATH_MAX];
char *p;
rb_strlcpy(prefix, rb_path_to_self(), sizeof prefix);
ircd_paths[IRCD_PATH_IRCD_EXEC] = rb_strdup(prefix);
/* if we're running from inside the source tree, we probably do not want to relocate any other paths */
if (strstr(prefix, ".libs") != NULL)
return;
/* prefix = /home/kaniini/ircd/bin/ircd */
p = strrchr(prefix, RB_PATH_SEPARATOR);
if (rb_unlikely(p == NULL))
return;
*p = 0;
/* prefix = /home/kaniini/ircd/bin */
p = strrchr(prefix, RB_PATH_SEPARATOR);
if (rb_unlikely(p == NULL))
return;
*p = 0;
/* prefix = /home/kaniini/ircd */
ircd_paths[IRCD_PATH_PREFIX] = rb_strdup(prefix);
/* now that we have our prefix, we can relocate the other paths... */
snprintf(workbuf, sizeof workbuf, "%s%cmodules", prefix, RB_PATH_SEPARATOR);
ircd_paths[IRCD_PATH_MODULES] = rb_strdup(workbuf);
snprintf(workbuf, sizeof workbuf, "%s%cmodules%cautoload", prefix, RB_PATH_SEPARATOR, RB_PATH_SEPARATOR);
ircd_paths[IRCD_PATH_AUTOLOAD_MODULES] = rb_strdup(workbuf);
snprintf(workbuf, sizeof workbuf, "%s%cetc", prefix, RB_PATH_SEPARATOR);
ircd_paths[IRCD_PATH_ETC] = rb_strdup(workbuf);
snprintf(workbuf, sizeof workbuf, "%s%clog", prefix, RB_PATH_SEPARATOR);
ircd_paths[IRCD_PATH_LOG] = rb_strdup(workbuf);
snprintf(workbuf, sizeof workbuf, "%s%chelp%cusers", prefix, RB_PATH_SEPARATOR, RB_PATH_SEPARATOR);
ircd_paths[IRCD_PATH_USERHELP] = rb_strdup(workbuf);
snprintf(workbuf, sizeof workbuf, "%s%chelp%copers", prefix, RB_PATH_SEPARATOR, RB_PATH_SEPARATOR);
ircd_paths[IRCD_PATH_OPERHELP] = rb_strdup(workbuf);
snprintf(workbuf, sizeof workbuf, "%s%cetc%circd.conf", prefix, RB_PATH_SEPARATOR, RB_PATH_SEPARATOR);
ircd_paths[IRCD_PATH_IRCD_CONF] = rb_strdup(workbuf);
snprintf(workbuf, sizeof workbuf, "%s%cetc%circd.motd", prefix, RB_PATH_SEPARATOR, RB_PATH_SEPARATOR);
ircd_paths[IRCD_PATH_IRCD_MOTD] = rb_strdup(workbuf);
snprintf(workbuf, sizeof workbuf, "%s%cetc%copers.motd", prefix, RB_PATH_SEPARATOR, RB_PATH_SEPARATOR);
ircd_paths[IRCD_PATH_IRCD_OMOTD] = rb_strdup(workbuf);
snprintf(workbuf, sizeof workbuf, "%s%cetc%cban.db", prefix, RB_PATH_SEPARATOR, RB_PATH_SEPARATOR);
ircd_paths[IRCD_PATH_BANDB] = rb_strdup(workbuf);
snprintf(workbuf, sizeof workbuf, "%s%cetc%circd.pid", prefix, RB_PATH_SEPARATOR, RB_PATH_SEPARATOR);
ircd_paths[IRCD_PATH_IRCD_PID] = rb_strdup(workbuf);
snprintf(workbuf, sizeof workbuf, "%s%clogs%circd.log", prefix, RB_PATH_SEPARATOR, RB_PATH_SEPARATOR);
ircd_paths[IRCD_PATH_IRCD_LOG] = rb_strdup(workbuf);
snprintf(workbuf, sizeof workbuf, "%s%cbin", prefix, RB_PATH_SEPARATOR);
ircd_paths[IRCD_PATH_BIN] = rb_strdup(workbuf);
ircd_paths[IRCD_PATH_LIBEXEC] = rb_strdup(workbuf);
inotice("runtime paths:");
for (int i = 0; i < IRCD_PATH_COUNT; i++)
{
inotice(" %s: %s", ircd_pathnames[i], ircd_paths[i]);
}
}
#endif
/*
* write_pidfile
*
@ -619,18 +531,12 @@ solanum_main(int argc, char * const argv[])
{
int fd;
#ifndef _WIN32
/* Check to see if the user is running us as root, which is a nono */
if(geteuid() == 0)
{
fprintf(stderr, "Don't run ircd as root!!!\n");
return -1;
}
#endif
#ifdef _WIN32
relocate_paths();
#endif
logFileName = ircd_paths[IRCD_PATH_IRCD_LOG];
pidFileName = ircd_paths[IRCD_PATH_IRCD_PID];
@ -697,7 +603,6 @@ solanum_main(int argc, char * const argv[])
if (testing_conf)
server_state_foreground = true;
#ifndef _WIN32
/* Make sure fd 0, 1 and 2 are in use -- jilles */
do
{
@ -707,7 +612,6 @@ solanum_main(int argc, char * const argv[])
close(fd);
else if (fd == -1)
exit(1);
#endif
/* Check if there is pidfile and daemon already running */
if(!testing_conf)
@ -717,10 +621,8 @@ solanum_main(int argc, char * const argv[])
inotice("starting %s ...", ircd_version);
inotice("%s", rb_lib_version());
#ifndef _WIN32
if(!server_state_foreground)
make_daemon();
#endif
}
/* Init the event subsystem */

View File

@ -196,7 +196,7 @@ void cinclude(void)
/* if its not found in PREFIX, look in IRCD_PATH_ETC */
char fnamebuf[BUFSIZE];
snprintf(fnamebuf, sizeof(fnamebuf), "%s%c%s", ircd_paths[IRCD_PATH_ETC], RB_PATH_SEPARATOR, c);
snprintf(fnamebuf, sizeof(fnamebuf), "%s/%s", ircd_paths[IRCD_PATH_ETC], c);
tmp_fbfile_in = fopen(fnamebuf, "r");
/* wasnt found there either.. error. */

View File

@ -26,9 +26,6 @@
#include "s_conf.h"
#include "client.h"
#include "send.h"
#ifndef _WIN32
#include <sys/types.h>
#include <sys/wait.h>
@ -179,17 +176,3 @@ setup_signals()
sigprocmask(SIG_UNBLOCK, &sigs, NULL);
}
#else
void
setup_signals()
{
/* this is a stub for mingw32 */
}
void
setup_reboot_signals()
{
/* this is a stub for mingw32 */
}
#endif

View File

@ -225,8 +225,8 @@ load_all_modules(bool warn)
if(len > module_ext_len &&
rb_strncasecmp(ldirent->d_name + (len - module_ext_len), LT_MODULE_EXT, module_ext_len) == 0)
{
(void) snprintf(module_fq_name, sizeof(module_fq_name), "%s%c%s",
ircd_paths[IRCD_PATH_AUTOLOAD_MODULES], RB_PATH_SEPARATOR, ldirent->d_name);
(void) snprintf(module_fq_name, sizeof(module_fq_name), "%s/%s",
ircd_paths[IRCD_PATH_AUTOLOAD_MODULES], ldirent->d_name);
(void) load_a_module(module_fq_name, warn, MAPI_ORIGIN_CORE, false);
}
@ -249,8 +249,7 @@ load_core_modules(bool warn)
for (i = 0; core_module_table[i]; i++)
{
snprintf(module_name, sizeof(module_name), "%s%c%s", ircd_paths[IRCD_PATH_MODULES], RB_PATH_SEPARATOR,
core_module_table[i]);
snprintf(module_name, sizeof(module_name), "%s/%s", ircd_paths[IRCD_PATH_MODULES], core_module_table[i]);
if(load_a_module(module_name, warn, MAPI_ORIGIN_CORE, true) == false)
{
@ -285,7 +284,7 @@ load_one_module(const char *path, int origin, bool coremodule)
struct stat statbuf;
const char *mpath = pathst->data;
snprintf(modpath, sizeof(modpath), "%s%c%s%s", mpath, RB_PATH_SEPARATOR, path, LT_MODULE_EXT);
snprintf(modpath, sizeof(modpath), "%s/%s%s", mpath, path, LT_MODULE_EXT);
if((strstr(modpath, "../") == NULL) && (strstr(modpath, "/..") == NULL))
{
if(stat(modpath, &statbuf) == 0 && S_ISREG(statbuf.st_mode))

View File

@ -75,7 +75,7 @@ server_reboot(void)
execv(ircd_paths[IRCD_PATH_IRCD_EXEC], (void *)myargv);
/* use this if execv of SPATH fails */
snprintf(path, sizeof(path), "%s%cbin%circd", ConfigFileEntry.dpath, RB_PATH_SEPARATOR, RB_PATH_SEPARATOR);
snprintf(path, sizeof(path), "%s/bin/ircd", ConfigFileEntry.dpath);
execv(path, (void *)myargv);
exit(-1);

View File

@ -245,12 +245,6 @@ start_ssldaemon(int count)
{
rb_fde_t *F1, *F2;
rb_fde_t *P1, *P2;
#ifdef _WIN32
const char *suffix = ".exe";
#else
const char *suffix = "";
#endif
char fullpath[PATH_MAX + 1];
char fdarg[6];
const char *parv[2];
@ -277,17 +271,16 @@ start_ssldaemon(int count)
if(ssld_path == NULL)
{
snprintf(fullpath, sizeof(fullpath), "%s%cssld%s", ircd_paths[IRCD_PATH_LIBEXEC], RB_PATH_SEPARATOR, suffix);
snprintf(fullpath, sizeof(fullpath), "%s/ssld", ircd_paths[IRCD_PATH_LIBEXEC]);
if(access(fullpath, X_OK) == -1)
{
snprintf(fullpath, sizeof(fullpath), "%s%cbin%cssld%s",
ConfigFileEntry.dpath, RB_PATH_SEPARATOR, RB_PATH_SEPARATOR, suffix);
snprintf(fullpath, sizeof(fullpath), "%s/bin/ssld", ConfigFileEntry.dpath);
if(access(fullpath, X_OK) == -1)
{
ilog(L_MAIN,
"Unable to execute ssld%s in %s or %s/bin",
suffix, ircd_paths[IRCD_PATH_LIBEXEC], ConfigFileEntry.dpath);
"Unable to execute ssld in %s or %s/bin",
ircd_paths[IRCD_PATH_LIBEXEC], ConfigFileEntry.dpath);
return 0;
}
}

View File

@ -233,12 +233,6 @@ start_wsockd(int count)
{
rb_fde_t *F1, *F2;
rb_fde_t *P1, *P2;
#ifdef _WIN32
const char *suffix = ".exe";
#else
const char *suffix = "";
#endif
char fullpath[PATH_MAX + 1];
char fdarg[6];
const char *parv[2];
@ -265,17 +259,16 @@ start_wsockd(int count)
if(wsockd_path == NULL)
{
snprintf(fullpath, sizeof(fullpath), "%s%cwsockd%s", ircd_paths[IRCD_PATH_LIBEXEC], RB_PATH_SEPARATOR, suffix);
snprintf(fullpath, sizeof(fullpath), "%s/wsockd", ircd_paths[IRCD_PATH_LIBEXEC]);
if(access(fullpath, X_OK) == -1)
{
snprintf(fullpath, sizeof(fullpath), "%s%cbin%cwsockd%s",
ConfigFileEntry.dpath, RB_PATH_SEPARATOR, RB_PATH_SEPARATOR, suffix);
snprintf(fullpath, sizeof(fullpath), "%s/bin/wsockd", ConfigFileEntry.dpath);
if(access(fullpath, X_OK) == -1)
{
ilog(L_MAIN,
"Unable to execute wsockd%s in %s or %s/bin",
suffix, ircd_paths[IRCD_PATH_LIBEXEC], ConfigFileEntry.dpath);
"Unable to execute wsockd in %s or %s/bin",
ircd_paths[IRCD_PATH_LIBEXEC], ConfigFileEntry.dpath);
return 0;
}
}

View File

@ -37,14 +37,8 @@ dnl RB_PROTO_INET6
AC_DEFUN([RB_PROTO_INET6],[
AC_CACHE_CHECK([for INET6 protocol support], [rb_cv_proto_inet6],[
AC_TRY_CPP([
#ifndef _WIN32
#include <sys/types.h>
#include <sys/socket.h>
#else
#include <winsock2.h>
#include <ws2tcpip.h>
#endif
#ifndef PF_INET6
#error Missing PF_INET6
#endif
@ -73,14 +67,9 @@ AC_DEFUN([RB_TYPE_STRUCT_SOCKADDR_IN6],[
],[
rb_have_sockaddr_in6=no
],[
#ifndef _WIN32
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#else
#include <winsock2.h>
#include <ws2tcpip.h>
#endif
])
if test "X$rb_have_sockaddr_in6" = "Xyes"; then :

View File

@ -58,23 +58,6 @@ AC_PROG_LIBTOOL
LIBTOOL="$LIBTOOL --silent"
case "$host_os" in
*cygwin*)
AC_DEFINE_UNQUOTED(CYGWIN,1,[This is a Cygwin system])
AC_DEFINE_UNQUOTED(WINDOWS,1,[This is a Windows system])
;;
*mingw* | *msys*)
AC_DEFINE_UNQUOTED(MINGW,1,[This is a MinGW system])
AC_DEFINE_UNQUOTED(WINDOWS,1,[This is a Windows system])
AC_CHECK_HEADER(windows.h, , [AC_MSG_ERROR([** MinGW and no windows.h. I give up.])])
AC_CHECK_HEADER(winsock2.h, , [AC_MSG_ERROR([** MinGW and no winsock2.h. I give up.])])
AC_DEFINE_UNQUOTED(HAVE_WINSOCK2_H, 1, [Have WINSOCK2_H])
AC_DEFINE_UNQUOTED(HAVE_WINSOCK_H, 1, [Have WINSOCK_H])
LIBS="$LIBS -lws2_32 -liphlpapi"
is_mingw="yes"
;;
*interix*)
CPPFLAGS="$CFLAGS -D_ALL_SOURCE -D_XOPEN_SOURCE=500"
;;
*solaris*)
CPPFLAGS="$CFLAGS -D_POSIX_PTHREAD_SEMANTICS -D_XPG4_2"
;;
@ -82,9 +65,6 @@ case "$host_os" in
;;
esac
AM_CONDITIONAL([MINGW], [test "$is_mingw" = "yes"])
# backwards support for IRC_CFLAGS
CFLAGS="$IRC_CFLAGS $CFLAGS -Wall"
@ -121,9 +101,6 @@ member.])],,[[
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
#ifdef HAVE_WINSOCK2_H
#include <winsock2.h>
#endif
]])
AC_CHECK_TYPE([socklen_t], rb_cv_socklen_t=socklen_t,[
@ -142,10 +119,6 @@ AC_CHECK_TYPE([socklen_t], rb_cv_socklen_t=socklen_t,[
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
#ifdef HAVE_WINSOCK2_H
#include <winsock2.h>
#include <ws2tcpip.h>
#endif
int getpeername (int, $arg2 *, $t *);
],[
$t len;
@ -211,11 +184,6 @@ else
fi
if test "$is_mingw" = "yes"; then
AC_DEFINE(HAVE_WIN32, [1], [Define to 1 if you are on windows])
fi
dnl OpenSSL support
AC_MSG_CHECKING(for OpenSSL)
AC_ARG_ENABLE(openssl,
@ -464,15 +432,10 @@ AC_SUBST(MBEDTLS_LIBS)
if test "$prefix" = "NONE"; then
AC_DEFINE_UNQUOTED(RB_PREFIX, "$ac_default_prefix", [Prefix where librb is installed.])
else
dnl Don't get bitten by Cygwin's stupidity if the user specified
dnl a custom prefix with a trailing slash
dnl Strip trailing slashes to prevent a path of '//'
prefix=`echo $prefix | sed 's/\/$//'`
AC_DEFINE_UNQUOTED(RB_PREFIX, "$prefix", [Prefix where librb is installed.])
fi
AC_SUBST(RB_PREFIX)
@ -490,14 +453,6 @@ AC_CONFIG_COMMANDS([include/librb-config.h],
_______EOF
if test "x$rb_windows_h" = "xyes"; then
echo '#define WIN32_LEAN_AND_MEAN 1' >> $outfile
echo '#include <windows.h>' >> $outfile
echo '#include <winsock2.h>' >> $outfile
echo '#include <ws2tcpip.h>' >> $outfile
echo '#include <iphlpapi.h>' >> $outfile
fi
if test "x$rb_alloca_h" = "xyes"; then
echo '#define RB_HAVE_ALLOCA_H 1' >> $outfile
fi
@ -652,12 +607,6 @@ fi
if test x$ac_cv_header_unistd_h = xyes; then
rb_unistd_h=yes
fi
if test x$ac_cv_header_windows_h = xyes; then
rb_windows_h=yes
fi
if test x$ac_cv_header_winsock2_h = xyes; then
rb_winsock2_h=yes
fi
rb_socklen_t=$rb_socklen_t

View File

@ -87,10 +87,6 @@ struct acceptdata
#define SetFDOpen(F) (F->flags |= FLAG_OPEN)
#define ClearFDOpen(F) (F->flags &= ~FLAG_OPEN)
#if !defined(SHUT_RDWR) && defined(_WIN32)
# define SHUT_RDWR SD_BOTH
#endif
struct _fde
{
/* New-school stuff, again pretty much ripped from squid */
@ -99,7 +95,7 @@ struct _fde
* filedescriptor. Think though: when do you think we'll need more?
*/
rb_dlink_node node;
rb_platform_fd_t fd; /* So we can use the rb_fde_t as a callback ptr */
int fd; /* So we can use the rb_fde_t as a callback ptr */
uint8_t flags;
uint8_t type;
int pflags;
@ -131,7 +127,7 @@ typedef struct timer_data
extern rb_dlink_list *rb_fd_table;
static inline rb_fde_t *
rb_find_fd(rb_platform_fd_t fd)
rb_find_fd(int fd)
{
rb_dlink_list *hlist;
rb_dlink_node *ptr;
@ -221,18 +217,4 @@ void rb_kqueue_init_event(void);
int rb_kqueue_sched_event(struct ev_entry *event, int when);
void rb_kqueue_unsched_event(struct ev_entry *event);
int rb_kqueue_supports_event(void);
/* select versions */
void rb_setselect_select(rb_fde_t *F, unsigned int type, PF * handler, void *client_data);
int rb_init_netio_select(void);
int rb_select_select(long);
int rb_setup_fd_select(rb_fde_t *F);
/* win32 versions */
void rb_setselect_win32(rb_fde_t *F, unsigned int type, PF * handler, void *client_data);
int rb_init_netio_win32(void);
int rb_select_win32(long);
int rb_setup_fd_win32(rb_fde_t *F);
#endif

View File

@ -63,11 +63,7 @@ enum
#define RB_FD_NONE 0x01
#define RB_FD_FILE 0x02
#define RB_FD_SOCKET 0x04
#ifndef _WIN32
#define RB_FD_PIPE 0x08
#else
#define RB_FD_PIPE RB_FD_SOCKET
#endif
#define RB_FD_LISTEN 0x10
#define RB_FD_SSL 0x20
#define RB_FD_UNKNOWN 0x40
@ -90,7 +86,7 @@ struct rb_iovec
void rb_fdlist_init(int closeall, int maxfds, size_t heapsize);
rb_fde_t *rb_open(rb_platform_fd_t, uint8_t, const char *);
rb_fde_t *rb_open(int, uint8_t, const char *);
void rb_close(rb_fde_t *);
void rb_dump_fd(DUMPCB *, void *xdata);
void rb_note(rb_fde_t *, const char *);
@ -163,12 +159,12 @@ void rb_setselect(rb_fde_t *, unsigned int type, PF * handler, void *client_data
void rb_init_netio(void);
int rb_select(unsigned long);
int rb_fd_ssl(rb_fde_t *F);
rb_platform_fd_t rb_get_fd(rb_fde_t *F);
int rb_get_fd(rb_fde_t *F);
const char *rb_get_ssl_strerror(rb_fde_t *F);
int rb_get_ssl_certfp(rb_fde_t *F, uint8_t certfp[RB_SSL_CERTFP_LEN], int method);
int rb_get_ssl_certfp_file(const char *filename, uint8_t certfp[RB_SSL_CERTFP_LEN], int method);
rb_fde_t *rb_get_fde(rb_platform_fd_t fd);
rb_fde_t *rb_get_fde(int fd);
int rb_send_fd_buf(rb_fde_t *xF, rb_fde_t **F, int count, void *data, size_t datasize, pid_t pid);
int rb_recv_fd_buf(rb_fde_t *F, void *data, size_t datasize, rb_fde_t **xF, int count);
@ -181,9 +177,6 @@ const char *rb_get_iotype(void);
typedef enum
{
RB_PRNG_FILE,
#ifdef _WIN32
RB_PRNGWIN32,
#endif
RB_PRNG_DEFAULT,
} prng_seed_t;

View File

@ -157,24 +157,12 @@ extern unsigned int rb_dictionary_size(rb_dictionary *dtree);
void rb_dictionary_stats(rb_dictionary *dict, void (*cb)(const char *line, void *privdata), void *privdata);
void rb_dictionary_stats_walk(void (*cb)(const char *line, void *privdata), void *privdata);
#ifndef _WIN32
#define RB_POINTER_TO_INT(x) ((int32_t) (long) (x))
#define RB_INT_TO_POINTER(x) ((void *) (long) (int32_t) (x))
#define RB_POINTER_TO_UINT(x) ((uint32_t) (unsigned long) (x))
#define RB_UINT_TO_POINTER(x) ((void *) (unsigned long) (uint32_t) (x))
#else
#define RB_POINTER_TO_INT(x) ((int32_t) (unsigned long long) (x))
#define RB_INT_TO_POINTER(x) ((void *) (unsigned long long) (int32_t) (x))
#define RB_POINTER_TO_UINT(x) ((uint32_t) (unsigned long long) (x))
#define RB_UINT_TO_POINTER(x) ((void *) (unsigned long long) (uint32_t) (x))
#endif
static inline int rb_int32cmp(const void *a, const void *b)
{
return RB_POINTER_TO_INT(b) - RB_POINTER_TO_INT(a);

View File

@ -62,67 +62,6 @@ char *alloca();
#define rb_unlikely(x) (x)
#endif
#ifdef _WIN32
#define rb_get_errno() do { errno = WSAGetLastError(); WSASetLastError(errno); } while(0)
typedef SOCKET rb_platform_fd_t;
#define RB_PATH_SEPARATOR '\\'
#else
#define rb_get_errno()
typedef int rb_platform_fd_t;
#define RB_PATH_SEPARATOR '/'
#endif
#ifdef _WIN32
#include <process.h>
#ifndef PATH_MAX
#define PATH_MAX 128
#endif
#ifdef strerror
#undef strerror
#endif
#define strerror(x) rb_strerror(x)
char *rb_strerror(int error);
#undef ENOBUFS
#define ENOBUFS WSAENOBUFS
#undef EINPROGRESS
#define EINPROGRESS WSAEINPROGRESS
#undef EWOULDBLOCK
#define EWOULDBLOCK WSAEWOULDBLOCK
#undef EMSGSIZE
#define EMSGSIZE WSAEMSGSIZE
#undef EALREADY
#define EALREADY WSAEALREADY
#undef EISCONN
#define EISCONN WSAEISCONN
#undef EADDRINUSE
#define EADDRINUSE WSAEADDRINUSE
#undef EAFNOSUPPORT
#define EAFNOSUPPORT WSAEAFNOSUPPORT
#define pipe(x) _pipe(x, 1024, O_BINARY)
#define ioctl(x,y,z) ioctlsocket(x,y, (unsigned long *)z)
#define WNOHANG 1
#ifndef SIGKILL
#define SIGKILL SIGTERM
#endif
#endif /* _WIN32 */
#ifndef HOSTIPLEN
#define HOSTIPLEN 53
#endif

View File

@ -14,7 +14,6 @@ version.lo: version.c ../include/serno.h
librb_la_SOURCES = \
unix.c \
win32.c \
crypt.c \
balloc.c \
commio.c \

View File

@ -91,10 +91,8 @@ arc4_stir(struct arc4_stream *as)
{
struct timeval tv;
pid_t pid;
int n;
#ifdef _WIN32
HMODULE lib;
#endif
uint8_t rnd[128];
int fd, n;
/* XXX this doesn't support egd sources or similiar */
pid = getpid();
@ -114,44 +112,14 @@ arc4_stir(struct arc4_stream *as)
memset(&buf, 0, sizeof(buf))}
#endif
#if !defined(_WIN32)
fd = open("/dev/urandom", O_RDONLY);
if(fd != -1)
{
uint8_t rnd[128];
int fd;
fd = open("/dev/urandom", O_RDONLY);
if(fd != -1)
{
read(fd, rnd, sizeof(rnd));
close(fd);
arc4_addrandom(as, (void *)rnd, sizeof(rnd));
memset(&rnd, 0, sizeof(rnd));
}
read(fd, rnd, sizeof(rnd));
close(fd);
arc4_addrandom(as, (void *)rnd, sizeof(rnd));
memset(&rnd, 0, sizeof(rnd));
}
#else
{
LARGE_INTEGER performanceCount;
if(QueryPerformanceCounter(&performanceCount))
{
arc4_addrandom(as, (void *)&performanceCount, sizeof(performanceCount));
}
lib = LoadLibrary("ADVAPI32.DLL");
if(lib)
{
uint8_t rnd[128];
BOOLEAN(APIENTRY * pfn) (void *, ULONG) =
(BOOLEAN(APIENTRY *) (void *, ULONG))GetProcAddress(lib,
"SystemFunction036");
if(pfn)
{
if(pfn(rnd, sizeof(rnd)) == TRUE)
arc4_addrandom(as, (void *)rnd, sizeof(rnd));
memset(&rnd, 0, sizeof(rnd));
}
}
}
#endif
/*
* Throw away the first N words of output, as suggested in the

View File

@ -38,8 +38,7 @@
*
* 1. mmap() anonymous pages with the MMAP_ANON flag.
* 2. mmap() via the /dev/zero trick.
* 3. HeapCreate/HeapAlloc (on win32)
* 4. malloc()
* 3. malloc()
*
* The advantages of 1 and 2 are this. We can munmap() the pages which will
* return the pages back to the operating system, thus reducing the size

View File

@ -72,12 +72,12 @@ static PF rb_connect_outcome;
static void mangle_mapped_sockaddr(struct sockaddr *in);
#ifndef HAVE_SOCKETPAIR
static int rb_inet_socketpair(int d, int type, int protocol, rb_platform_fd_t sv[2]);
static int rb_inet_socketpair(int d, int type, int protocol, int sv[2]);
static int rb_inet_socketpair_udp(rb_fde_t **newF1, rb_fde_t **newF2);
#endif
static inline rb_fde_t *
add_fd(rb_platform_fd_t fd)
add_fd(int fd)
{
rb_fde_t *F = rb_find_fd(fd);
@ -110,14 +110,7 @@ free_fds(void)
F = ptr->data;
number_fd--;
#ifdef _WIN32
if(F->type & (RB_FD_SOCKET | RB_FD_PIPE))
closesocket(F->fd);
else
#endif
close(F->fd);
close(F->fd);
rb_dlinkDelete(ptr, &closed_list);
rb_bh_free(fd_heap, F);
}
@ -128,7 +121,6 @@ free_fds(void)
static void
rb_close_all(void)
{
#ifndef _WIN32
int i;
/* XXX someone tell me why we care about 4 fd's ? */
@ -137,7 +129,6 @@ rb_close_all(void)
{
close(i);
}
#endif
}
/*
@ -156,8 +147,6 @@ rb_get_sockerr(rb_fde_t *F)
if(!(F->type & RB_FD_SOCKET))
return errno;
rb_get_errno();
errtmp = errno;
#ifdef SO_ERROR
@ -214,7 +203,7 @@ rb_set_nb(rb_fde_t *F)
{
int nonb = 0;
int res;
rb_platform_fd_t fd;
int fd;
if(F == NULL)
return 0;
fd = F->fd;
@ -239,11 +228,8 @@ rb_set_nb(rb_fde_t *F)
int
rb_set_cloexec(rb_fde_t *F)
{
#ifdef _WIN32
SetHandleInformation((HANDLE) F->fd, HANDLE_FLAG_INHERIT, 0);
#else
int res;
rb_platform_fd_t fd;
int fd;
if(F == NULL)
return 0;
fd = F->fd;
@ -255,17 +241,13 @@ rb_set_cloexec(rb_fde_t *F)
return 0;
return 1;
#endif
}
int
rb_clear_cloexec(rb_fde_t *F)
{
#ifdef _WIN32
SetHandleInformation((HANDLE) F->fd, HANDLE_FLAG_INHERIT, 1);
#else
int res;
rb_platform_fd_t fd;
int fd;
if(F == NULL)
return 0;
fd = F->fd;
@ -277,7 +259,6 @@ rb_clear_cloexec(rb_fde_t *F)
return 0;
return 1;
#endif
}
/*
@ -546,7 +527,6 @@ static void rb_accept_tryaccept(rb_fde_t *F, void *data __attribute__((unused)))
addrlen = sizeof(st);
new_fd = accept(F->fd, (struct sockaddr *)&st, &addrlen);
rb_get_errno();
if(new_fd < 0)
{
rb_setselect(F, RB_SELECT_ACCEPT, rb_accept_tryaccept, NULL);
@ -566,7 +546,6 @@ static void rb_accept_tryaccept(rb_fde_t *F, void *data __attribute__((unused)))
if(rb_unlikely(!rb_set_nb(new_F)))
{
rb_get_errno();
rb_lib_log("rb_accept: Couldn't set FD %d non blocking!", new_F->fd);
rb_close(new_F);
}
@ -609,7 +588,7 @@ rb_accept_tcp(rb_fde_t *F, ACPRE * precb, ACCB * callback, void *data)
}
/*
* void rb_connect_tcp(rb_platform_fd_t fd, struct sockaddr *dest,
* void rb_connect_tcp(int fd, struct sockaddr *dest,
* struct sockaddr *clocal,
* CNCB *callback, void *data, int timeout)
* Input: An fd to connect with, a host and port to connect to,
@ -666,7 +645,6 @@ rb_connect_tcp(rb_fde_t *F, struct sockaddr *dest,
* which is a good thing.
* -- adrian
*/
rb_get_errno();
if (errno == EISCONN) {
rb_connect_callback(F, RB_OK);
} else if (rb_ignore_errno(errno)) {
@ -738,7 +716,6 @@ rb_connect_sctp(rb_fde_t *F, struct sockaddr_storage *dest, size_t dest_len,
* which is a good thing.
* -- adrian
*/
rb_get_errno();
if (errno == EISCONN) {
rb_connect_callback(F, RB_OK);
} else if (rb_ignore_errno(errno)) {
@ -806,9 +783,7 @@ rb_connect_outcome(rb_fde_t *F, void *notused __attribute__((unused)))
if(F == NULL || F->connect == NULL || F->connect->callback == NULL)
return;
retval = getsockopt(F->fd, SOL_SOCKET, SO_ERROR, &err, &len);
if (retval < 0) {
rb_get_errno();
} else if (err != 0) {
if ((retval >= 0) && (err != 0)) {
errno = err;
retval = -1;
}
@ -847,7 +822,7 @@ rb_errstr(int error)
int
rb_socketpair(int family, int sock_type, int proto, rb_fde_t **F1, rb_fde_t **F2, const char *note)
{
rb_platform_fd_t nfd[2];
int nfd[2];
if(number_fd >= rb_maxconnections)
{
errno = ENFILE;
@ -906,8 +881,7 @@ rb_socketpair(int family, int sock_type, int proto, rb_fde_t **F1, rb_fde_t **F2
int
rb_pipe(rb_fde_t **F1, rb_fde_t **F2, const char *desc)
{
#ifndef _WIN32
rb_platform_fd_t fd[2];
int fd[2];
if(number_fd >= rb_maxconnections)
{
errno = ENFILE;
@ -936,12 +910,6 @@ rb_pipe(rb_fde_t **F1, rb_fde_t **F2, const char *desc)
return 0;
#else
/* Its not a pipe..but its selectable. I'll take dirty hacks
* for $500 Alex.
*/
return rb_socketpair(AF_INET, SOCK_STREAM, 0, F1, F2, desc);
#endif
}
/*
@ -955,7 +923,7 @@ rb_fde_t *
rb_socket(int family, int sock_type, int proto, const char *note)
{
rb_fde_t *F;
rb_platform_fd_t fd;
int fd;
/* First, make sure we aren't going to run out of file descriptors */
if(rb_unlikely(number_fd >= rb_maxconnections))
{
@ -1081,18 +1049,7 @@ void
rb_fdlist_init(int closeall, int maxfds, size_t heapsize)
{
static int initialized = 0;
#ifdef _WIN32
WSADATA wsaData;
int err;
int vers = MAKEWORD(2, 0);
err = WSAStartup(vers, &wsaData);
if(err != 0)
{
rb_lib_die("WSAStartup failed");
}
#endif
if(!initialized)
{
rb_maxconnections = maxfds;
@ -1108,7 +1065,7 @@ rb_fdlist_init(int closeall, int maxfds, size_t heapsize)
/* Called to open a given filedescriptor */
rb_fde_t *
rb_open(rb_platform_fd_t fd, uint8_t type, const char *desc)
rb_open(int fd, uint8_t type, const char *desc)
{
rb_fde_t *F;
lrb_assert(fd >= 0);
@ -1253,7 +1210,7 @@ rb_fd_ssl(rb_fde_t *F)
return 0;
}
rb_platform_fd_t
int
rb_get_fd(rb_fde_t *F)
{
if(F == NULL)
@ -1262,7 +1219,7 @@ rb_get_fd(rb_fde_t *F)
}
rb_fde_t *
rb_get_fde(rb_platform_fd_t fd)
rb_get_fde(int fd)
{
return rb_find_fd(fd);
}
@ -1286,10 +1243,6 @@ rb_read(rb_fde_t *F, void *buf, int count)
if(F->type & RB_FD_SOCKET)
{
ret = recv(F->fd, buf, count, 0);
if(ret < 0)
{
rb_get_errno();
}
return ret;
}
@ -1315,17 +1268,13 @@ rb_write(rb_fde_t *F, const void *buf, int count)
if(F->type & RB_FD_SOCKET)
{
ret = send(F->fd, buf, count, MSG_NOSIGNAL);
if(ret < 0)
{
rb_get_errno();
}
return ret;
}
return write(F->fd, buf, count);
}
#if defined(HAVE_SSL) || defined(WIN32) || !defined(HAVE_WRITEV)
#if defined(HAVE_SSL) || !defined(HAVE_WRITEV)
static ssize_t
rb_fake_writev(rb_fde_t *F, const struct rb_iovec *vp, size_t vpcount)
{
@ -1349,7 +1298,7 @@ rb_fake_writev(rb_fde_t *F, const struct rb_iovec *vp, size_t vpcount)
}
#endif
#if defined(WIN32) || !defined(HAVE_WRITEV)
#ifndef HAVE_WRITEV
ssize_t
rb_writev(rb_fde_t *F, struct rb_iovec * vecount, int count)
{
@ -1875,7 +1824,7 @@ rb_inet_socketpair_udp(rb_fde_t **newF1, rb_fde_t **newF2)
struct sockaddr_in addr[2];
rb_socklen_t size = sizeof(struct sockaddr_in);
rb_fde_t *F[2];
rb_platform_fd_t fd[2];
int fd[2];
int i, got;
unsigned short port;
struct timeval wait = { 0, 100000 };
@ -1958,18 +1907,9 @@ rb_inet_socketpair_udp(rb_fde_t **newF1, rb_fde_t **newF2)
*newF2 = F[1];
return 0;
#ifdef _WIN32
#ifndef ECONNABORTED
#define ECONNABORTED WSAECONNABORTED
#endif
#endif
abort_failed:
rb_get_errno();
errno = ECONNABORTED;
failed:
if(errno != ECONNABORTED)
rb_get_errno();
o_errno = errno;
if(F[0] != NULL)
rb_close(F[0]);
@ -1981,7 +1921,7 @@ rb_inet_socketpair_udp(rb_fde_t **newF1, rb_fde_t **newF2)
int
rb_inet_socketpair(int family, int type, int protocol, rb_platform_fd_t fd[2])
rb_inet_socketpair(int family, int type, int protocol, int fd[2])
{
int listener = -1;
int connector = -1;
@ -2197,24 +2137,6 @@ try_poll(void)
return -1;
}
static int
try_win32(void)
{
if(!rb_init_netio_win32())
{
setselect_handler = rb_setselect_win32;
select_handler = rb_select_win32;
setup_fd_handler = rb_setup_fd_win32;
io_sched_event = NULL;
io_unsched_event = NULL;
io_init_event = NULL;
io_supports_event = rb_unsupported_event;
rb_strlcpy(iotype, "win32", sizeof(iotype));
return 0;
}
return -1;
}
int
rb_io_sched_event(struct ev_entry *ev, int when)
{
@ -2287,12 +2209,6 @@ rb_init_netio(void)
if(!try_sigio())
return;
}
if(!strcmp("win32", ioenv))
{
if(!try_win32())
return;
}
}
if(!try_kqueue())
@ -2307,8 +2223,6 @@ rb_init_netio(void)
return;
if(!try_poll())
return;
if(!try_win32())
return;
rb_lib_log("rb_init_netio: Could not find any io handlers...giving up");
@ -2368,7 +2282,7 @@ rb_ignore_errno(int error)
}
#if defined(HAVE_SENDMSG) && !defined(WIN32)
#ifdef HAVE_SENDMSG
int
rb_recv_fd_buf(rb_fde_t *F, void *data, size_t datasize, rb_fde_t **xF, int nfds)
{
@ -2378,7 +2292,7 @@ rb_recv_fd_buf(rb_fde_t *F, void *data, size_t datasize, rb_fde_t **xF, int nfds
struct stat st;
uint8_t stype = RB_FD_UNKNOWN;
const char *desc;
rb_platform_fd_t fd, len, x, rfds;
int fd, len, x, rfds;
int control_len = CMSG_SPACE(sizeof(int) * nfds);
@ -2483,8 +2397,7 @@ rb_send_fd_buf(rb_fde_t *xF, rb_fde_t **F, int count, void *data, size_t datasiz
}
return sendmsg(rb_get_fd(xF), &msg, MSG_NOSIGNAL);
}
#else /* defined(HAVE_SENDMSG) && !defined(WIN32) */
#ifndef _WIN32
#else
int
rb_recv_fd_buf(rb_fde_t *F, void *data, size_t datasize, rb_fde_t **xF, int nfds)
{
@ -2498,8 +2411,7 @@ rb_send_fd_buf(rb_fde_t *xF, rb_fde_t **F, int count, void *data, size_t datasiz
errno = ENOSYS;
return -1;
}
#endif /* _WIN32 */
#endif /* defined(HAVE_SENDMSG) && !defined(WIN32) */
#endif
int
rb_ipv4_from_ipv6(const struct sockaddr_in6 *restrict ip6, struct sockaddr_in *restrict ip4)

View File

@ -62,7 +62,6 @@ rb_helper_child(rb_helper_cb * read_cb, rb_helper_cb * error_cb, log_cb * ilog,
ofd = (int)strtol(tofd, NULL, 10);
maxfd = (int)strtol(tmaxfd, NULL, 10);
#ifndef _WIN32
for(x = 0; x < maxfd; x++)
{
if(x != ifd && x != ofd)
@ -77,9 +76,6 @@ rb_helper_child(rb_helper_cb * read_cb, rb_helper_cb * error_cb, log_cb * ilog,
dup2(x, 2);
if(x > 2) /* don't undo what we just did */
close(x);
#else
(void) x; /* shut gcc up */
#endif
rb_lib_init(ilog, irestart, idie, 0, maxfd, dh_size, fd_heap_size);
rb_linebuf_init(lb_heap_size);

View File

@ -134,7 +134,6 @@ rb_string_to_array(char *string, char **parv, int maxpara)
}
#ifndef HAVE_STRCASECMP
#ifndef _WIN32
/* Fallback taken from FreeBSD. --Elizafox */
int
rb_strcasecmp(const char *s1, const char *s2)
@ -150,14 +149,7 @@ rb_strcasecmp(const char *s1, const char *s2)
return (tolower(*us1) - tolower(*--us2));
}
#else /* _WIN32 */
int
rb_strcasecmp(const char *s1, const char *s2)
{
return stricmp(s1, s2);
}
#endif /* _WIN32 */
#else /* HAVE_STRCASECMP */
#else
int
rb_strcasecmp(const char *s1, const char *s2)
{
@ -166,7 +158,6 @@ rb_strcasecmp(const char *s1, const char *s2)
#endif
#ifndef HAVE_STRNCASECMP
#ifndef _WIN32
/* Fallback taken from FreeBSD. --Elizafox */
int
rb_strncasecmp(const char *s1, const char *s2, size_t n)
@ -186,14 +177,7 @@ rb_strncasecmp(const char *s1, const char *s2, size_t n)
}
return 0;
}
#else /* _WIN32 */
int
rb_strncasecmp(const char *s1, const char *s2, size_t n)
{
return strnicmp(s1, s2, n);
}
#endif /* _WIN32 */
#else /* HAVE_STRNCASECMP */
#else
int
rb_strncasecmp(const char *s1, const char *s2, size_t n)
{

View File

@ -25,9 +25,6 @@
#include <librb_config.h>
#include <rb_lib.h>
#ifndef _WIN32
#include <sys/wait.h>
#ifdef HAVE_DLINFO
@ -200,5 +197,3 @@ rb_path_to_self(void)
return NULL;
#endif
}
#endif /* !WIN32 */

View File

@ -1,645 +0,0 @@
/*
* ircd-ratbox: A slightly useful ircd.
* win32.c: select() compatible network routines.
*
* Copyright (C) 1990 Jarkko Oikarinen and University of Oulu, Co Center
* Copyright (C) 1996-2002 Hybrid Development Team
* Copyright (C) 2001 Adrian Chadd <adrian@creative.net.au>
* Copyright (C) 2005-2006 Aaron Sethman <androsyn@ratbox.org>
* Copyright (C) 2002-2006 ircd-ratbox development team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
* USA
*
*/
#include <librb_config.h>
#include <rb_lib.h>
#include <commio-int.h>
#ifdef _WIN32
static HWND hwnd;
#define WM_SOCKET WM_USER
/*
* having gettimeofday is nice...
*/
typedef union
{
unsigned __int64 ft_i64;
FILETIME ft_val;
} FT_t;
#ifdef __GNUC__
#define Const64(x) x##LL
#else
#define Const64(x) x##i64
#endif
/* Number of 100 nanosecond units from 1/1/1601 to 1/1/1970 */
#define EPOCH_BIAS Const64(116444736000000000)
pid_t
rb_getpid()
{
return GetCurrentProcessId();
}
int
rb_gettimeofday(struct timeval *tp, void *not_used)
{
FT_t ft;
/* this returns time in 100-nanosecond units (i.e. tens of usecs) */
GetSystemTimeAsFileTime(&ft.ft_val);
/* seconds since epoch */
tp->tv_sec = (long)((ft.ft_i64 - EPOCH_BIAS) / Const64(10000000));
/* microseconds remaining */
tp->tv_usec = (long)((ft.ft_i64 / Const64(10)) % Const64(1000000));
return 0;
}
pid_t
rb_spawn_process(const char *path, const char **argv)
{
PROCESS_INFORMATION pi;
STARTUPINFO si;
char cmd[MAX_PATH];
memset(&pi, 0, sizeof(pi));
memset(&si, 0, sizeof(si));
rb_strlcpy(cmd, path, sizeof(cmd));
if(CreateProcess(cmd, cmd, NULL, NULL, TRUE, 0, NULL, NULL, &si, &pi) == FALSE)
return -1;
return (pi.dwProcessId);
}
pid_t
rb_waitpid(pid_t pid, int *status, int flags)
{
DWORD timeout = (flags & WNOHANG) ? 0 : INFINITE;
HANDLE hProcess;
DWORD waitcode;
hProcess = OpenProcess(PROCESS_ALL_ACCESS, TRUE, pid);
if(hProcess)
{
waitcode = WaitForSingleObject(hProcess, timeout);
if(waitcode == WAIT_TIMEOUT)
{
CloseHandle(hProcess);
return 0;
}
else if(waitcode == WAIT_OBJECT_0)
{
if(GetExitCodeProcess(hProcess, &waitcode))
{
*status = (int)((waitcode & 0xff) << 8);
CloseHandle(hProcess);
return pid;
}
}
CloseHandle(hProcess);
}
else
errno = ECHILD;
return -1;
}
int
rb_setenv(const char *name, const char *value, int overwrite)
{
char *buf;
int len;
if(!overwrite)
{
if((buf = getenv(name)) != NULL)
{
if(strlen(buf) > 0)
{
return 0;
}
}
}
if(name == NULL || value == NULL)
return -1;
len = strlen(name) + strlen(value) + 5;
buf = rb_malloc(len);
snprintf(buf, len, "%s=%s", name, value);
len = putenv(buf);
rb_free(buf);
return (len);
}
int
rb_kill(pid_t pid, int sig)
{
HANDLE hProcess;
int ret = -1;
hProcess = OpenProcess(PROCESS_ALL_ACCESS, TRUE, pid);
if(hProcess)
{
switch (sig)
{
case 0:
ret = 0;
break;
default:
if(TerminateProcess(hProcess, sig))
ret = 0;
break;
}
CloseHandle(hProcess);
}
else
errno = EINVAL;
return ret;
}
/*
* packet format is
uint32_t magic
uint8_t protocol count
WSAPROTOCOL_INFO * count
size_t datasize
data
*/
static int
make_wsaprotocol_info(pid_t process, rb_fde_t *F, WSAPROTOCOL_INFO * inf)
{
WSAPROTOCOL_INFO info;
if(!WSADuplicateSocket((SOCKET) rb_get_fd(F), process, &info))
{
memcpy(inf, &info, sizeof(WSAPROTOCOL_INFO));
return 1;
}
return 0;
}
static rb_fde_t *
make_fde_from_wsaprotocol_info(void *data)
{
WSAPROTOCOL_INFO *info = data;
SOCKET t;
t = WSASocket(FROM_PROTOCOL_INFO, FROM_PROTOCOL_INFO, FROM_PROTOCOL_INFO, info, 0, 0);
if(t == INVALID_SOCKET)
{
rb_get_errno();
return NULL;
}
return rb_open(t, RB_FD_SOCKET, "remote_socket");
}
static uint8_t fd_buf[16384];
#define MAGIC_CONTROL 0xFF0ACAFE
int
rb_send_fd_buf(rb_fde_t *xF, rb_fde_t **F, int count, void *data, size_t datasize, pid_t pid)
{
size_t bufsize =
sizeof(uint32_t) + sizeof(uint8_t) + (sizeof(WSAPROTOCOL_INFO) * (size_t)count) +
sizeof(size_t) + datasize;
int i;
uint32_t magic = MAGIC_CONTROL;
void *ptr;
if(count > 4)
{
errno = EINVAL;
return -1;
}
if(bufsize > sizeof(fd_buf))
{
errno = EINVAL;
return -1;
}
memset(fd_buf, 0, sizeof(fd_buf));
ptr = fd_buf;
memcpy(ptr, &magic, sizeof(magic));
ptr = (void *)((uintptr_t)ptr + (uintptr_t)sizeof(magic));
*((uint8_t *)ptr) = count;
ptr = (void *)((uintptr_t)ptr + (uintptr_t)sizeof(uint8_t));
for(i = 0; i < count; i++)
{
make_wsaprotocol_info(pid, F[i], (WSAPROTOCOL_INFO *) ptr);
ptr = (void *)((uintptr_t)ptr + (uintptr_t)sizeof(WSAPROTOCOL_INFO));
}
memcpy(ptr, &datasize, sizeof(size_t));
ptr = (void *)((uintptr_t)ptr + (uintptr_t)sizeof(size_t));
memcpy(ptr, data, datasize);
return rb_write(xF, fd_buf, bufsize);
}
#ifdef MYMIN
#undef MYMIN
#endif
#define MYMIN(a, b) ((a) < (b) ? (a) : (b))
int
rb_recv_fd_buf(rb_fde_t *F, void *data, size_t datasize, rb_fde_t **xF, int nfds)
{
size_t minsize = sizeof(uint32_t) + sizeof(uint8_t) + sizeof(size_t);
size_t datalen;
ssize_t retlen;
uint32_t magic;
uint8_t count;
unsigned int i;
void *ptr;
ssize_t ret;
memset(fd_buf, 0, sizeof(fd_buf)); /* some paranoia here... */
ret = rb_read(F, fd_buf, sizeof(fd_buf));
if(ret <= 0)
{
return ret;
}
if(ret < (ssize_t) minsize)
{
errno = EINVAL;
return -1;
}
ptr = fd_buf;
memcpy(&magic, ptr, sizeof(uint32_t));
if(magic != MAGIC_CONTROL)
{
errno = EAGAIN;
return -1;
}
ptr = (void *)((uintptr_t)ptr + (uintptr_t)sizeof(uint32_t));
memcpy(&count, ptr, sizeof(uint8_t));
ptr = (void *)((uintptr_t)ptr + (uintptr_t)sizeof(uint8_t));
for(i = 0; i < count && i < (unsigned int)nfds; i++)
{
rb_fde_t *tF = make_fde_from_wsaprotocol_info(ptr);
if(tF == NULL)
return -1;
xF[i] = tF;
ptr = (void *)((uintptr_t)ptr + (uintptr_t)sizeof(WSAPROTOCOL_INFO));
}
memcpy(&datalen, ptr, sizeof(size_t));
ptr = (void *)((uintptr_t)ptr + (uintptr_t)sizeof(size_t));
retlen = MYMIN(datalen, datasize);
memcpy(data, ptr, datalen);
return retlen;
}
static LRESULT CALLBACK
rb_process_events(HWND nhwnd, UINT umsg, WPARAM wparam, LPARAM lparam)
{
rb_fde_t *F;
PF *hdl;
void *data;
switch (umsg)
{
case WM_SOCKET:
{
F = rb_find_fd(wparam);
if(F != NULL && IsFDOpen(F))
{
switch (WSAGETSELECTEVENT(lparam))
{
case FD_ACCEPT:
case FD_CLOSE:
case FD_READ:
{
if((hdl = F->read_handler) != NULL)
{
F->read_handler = NULL;
data = F->read_data;
F->read_data = NULL;
hdl(F, data);
}
break;
}
case FD_CONNECT:
case FD_WRITE:
{
if((hdl = F->write_handler) != NULL)
{
F->write_handler = NULL;
data = F->write_data;
F->write_data = NULL;
hdl(F, data);
}
}
}
}
return 0;
}
case WM_DESTROY:
{
PostQuitMessage(0);
return 0;
}
default:
return DefWindowProc(nhwnd, umsg, wparam, lparam);
}
return 0;
}
int
rb_init_netio_win32(void)
{
/* this muchly sucks, but i'm too lazy to do overlapped i/o, maybe someday... -androsyn */
WNDCLASS wc;
static const char *classname = "solanum-class";
wc.style = 0;
wc.lpfnWndProc = (WNDPROC) rb_process_events;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hIcon = NULL;
wc.hCursor = NULL;
wc.hbrBackground = NULL;
wc.lpszMenuName = NULL;
wc.lpszClassName = classname;
wc.hInstance = GetModuleHandle(NULL);
if(!RegisterClass(&wc))
rb_lib_die("cannot register window class");
hwnd = CreateWindow(classname, classname, WS_POPUP, CW_USEDEFAULT,
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
(HWND) NULL, (HMENU) NULL, wc.hInstance, NULL);
if(!hwnd)
rb_lib_die("could not create window");
return 0;
}
void
rb_sleep(unsigned int seconds, unsigned int useconds)
{
DWORD msec = seconds * 1000;;
Sleep(msec);
}
int
rb_setup_fd_win32(rb_fde_t *F)
{
if(F == NULL)
return 0;
SetHandleInformation((HANDLE) F->fd, HANDLE_FLAG_INHERIT, 0);
if (F->type & RB_FD_SOCKET) {
unsigned long nonb = 1;
if (ioctlsocket((SOCKET) F->fd, FIONBIO, &nonb) == -1) {
rb_get_errno();
return 0;
}
}
return 1;
}
void
rb_setselect_win32(rb_fde_t *F, unsigned int type, PF * handler, void *client_data)
{
int old_flags = F->pflags;
lrb_assert(IsFDOpen(F));
/* Update the list, even though we're not using it .. */
if(type & RB_SELECT_READ)
{
if(handler != NULL)
F->pflags |= FD_CLOSE | FD_READ | FD_ACCEPT;
else
F->pflags &= ~(FD_CLOSE | FD_READ | FD_ACCEPT);
F->read_handler = handler;
F->read_data = client_data;
}
if(type & RB_SELECT_WRITE)
{
if(handler != NULL)
F->pflags |= FD_WRITE | FD_CONNECT;
else
F->pflags &= ~(FD_WRITE | FD_CONNECT);
F->write_handler = handler;
F->write_data = client_data;
}
if(old_flags == 0 && F->pflags == 0)
return;
if(F->pflags != old_flags)
{
WSAAsyncSelect(F->fd, hwnd, WM_SOCKET, F->pflags);
}
}
static int has_set_timer = 0;
int
rb_select_win32(long delay)
{
MSG msg;
if(has_set_timer == 0)
{
/* XXX should probably have this handle all the events
* instead of busy looping
*/
SetTimer(hwnd, 0, delay, NULL);
has_set_timer = 1;
}
if(GetMessage(&msg, NULL, 0, 0) == FALSE)
{
rb_lib_die("GetMessage failed..byebye");
}
rb_set_time();
DispatchMessage(&msg);
return RB_OK;
}
#ifdef strerror
#undef strerror
#endif
static const char *
_rb_strerror(int error)
{
switch (error)
{
case 0:
return "Success";
case WSAEINTR:
return "Interrupted system call";
case WSAEBADF:
return "Bad file number";
case WSAEACCES:
return "Permission denied";
case WSAEFAULT:
return "Bad address";
case WSAEINVAL:
return "Invalid argument";
case WSAEMFILE:
return "Too many open sockets";
case WSAEWOULDBLOCK:
return "Operation would block";
case WSAEINPROGRESS:
return "Operation now in progress";
case WSAEALREADY:
return "Operation already in progress";
case WSAENOTSOCK:
return "Socket operation on non-socket";
case WSAEDESTADDRREQ:
return "Destination address required";
case WSAEMSGSIZE:
return "Message too long";
case WSAEPROTOTYPE:
return "Protocol wrong type for socket";
case WSAENOPROTOOPT:
return "Bad protocol option";
case WSAEPROTONOSUPPORT:
return "Protocol not supported";
case WSAESOCKTNOSUPPORT:
return "Socket type not supported";
case WSAEOPNOTSUPP:
return "Operation not supported on socket";
case WSAEPFNOSUPPORT:
return "Protocol family not supported";
case WSAEAFNOSUPPORT:
return "Address family not supported";
case WSAEADDRINUSE:
return "Address already in use";
case WSAEADDRNOTAVAIL:
return "Can't assign requested address";
case WSAENETDOWN:
return "Network is down";
case WSAENETUNREACH:
return "Network is unreachable";
case WSAENETRESET:
return "Net connection reset";
case WSAECONNABORTED:
return "Software caused connection abort";
case WSAECONNRESET:
return "Connection reset by peer";
case WSAENOBUFS:
return "No buffer space available";
case WSAEISCONN:
return "Socket is already connected";
case WSAENOTCONN:
return "Socket is not connected";
case WSAESHUTDOWN:
return "Can't send after socket shutdown";
case WSAETOOMANYREFS:
return "Too many references, can't splice";
case WSAETIMEDOUT:
return "Connection timed out";
case WSAECONNREFUSED:
return "Connection refused";
case WSAELOOP:
return "Too many levels of symbolic links";
case WSAENAMETOOLONG:
return "File name too long";
case WSAEHOSTDOWN:
return "Host is down";
case WSAEHOSTUNREACH:
return "No route to host";
case WSAENOTEMPTY:
return "Directory not empty";
case WSAEPROCLIM:
return "Too many processes";
case WSAEUSERS:
return "Too many users";
case WSAEDQUOT:
return "Disc quota exceeded";
case WSAESTALE:
return "Stale NFS file handle";
case WSAEREMOTE:
return "Too many levels of remote in path";
case WSASYSNOTREADY:
return "Network system is unavailable";
case WSAVERNOTSUPPORTED:
return "Winsock version out of range";
case WSANOTINITIALISED:
return "WSAStartup not yet called";
case WSAEDISCON:
return "Graceful shutdown in progress";
case WSAHOST_NOT_FOUND:
return "Host not found";
case WSANO_DATA:
return "No host data of that type was found";
default:
return strerror(error);
}
};
char *
rb_strerror(int error)
{
static char buf[128];
rb_strlcpy(buf, _rb_strerror(error), sizeof(buf));
return buf;
}
const char *
rb_path_to_self(void)
{
static char path_buf[MAX_PATH];
GetModuleFileName(NULL, path_buf, MAX_PATH);
return path_buf;
}
#else /* win32 not supported */
int
rb_init_netio_win32(void)
{
errno = ENOSYS;
return -1;
}
void
rb_setselect_win32(rb_fde_t *F __attribute__((unused)), unsigned int type __attribute__((unused)), PF * handler __attribute__((unused)), void *client_data __attribute__((unused)))
{
errno = ENOSYS;
return;
}
int
rb_select_win32(long delay __attribute__((unused)))
{
errno = ENOSYS;
return -1;
}
int
rb_setup_fd_win32(rb_fde_t *F __attribute__((unused)))
{
errno = ENOSYS;
return -1;
}
#endif /* _WIN32 */

View File

@ -4,9 +4,6 @@ AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/librb/include $(LTDLINCL)
AM_LDFLAGS = -module -export-dynamic -avoid-version -no-undefined -shared
AM_LDFLAGS += -export-symbols-regex _mheader
LIBS += $(top_srcdir)/ircd/libircd.la
if MINGW
LIBS += $(top_srcdir)/librb/src/librb.la
endif
auto_load_moddir=@moduledir@/autoload

View File

@ -924,7 +924,6 @@ stats_ssld(struct Client *source_p)
static void
stats_usage (struct Client *source_p)
{
#ifndef _WIN32
struct rusage rus;
time_t secs;
time_t rup;
@ -976,7 +975,6 @@ stats_usage (struct Client *source_p)
"R :Signals %d Context Vol. %d Invol %d",
(int) rus.ru_nsignals, (int) rus.ru_nvcsw,
(int) rus.ru_nivcsw);
#endif
}
static void

32
shtool
View File

@ -679,7 +679,7 @@ echo )
term_bold=`awk 'BEGIN { printf("%c%c%c%c", 27, 91, 49, 109); }' </dev/null 2>/dev/null`
term_norm=`awk 'BEGIN { printf("%c%c%c", 27, 91, 109); }' </dev/null 2>/dev/null`
;;
vt100|vt100*|cygwin)
vt100|vt100*)
term_bold=`awk 'BEGIN { printf("%c%c%c%c%c%c", 27, 91, 49, 109, 0, 0); }' </dev/null 2>/dev/null`
term_norm=`awk 'BEGIN { printf("%c%c%c%c%c", 27, 91, 109, 0, 0); }' </dev/null 2>/dev/null`
;;
@ -3015,36 +3015,6 @@ platform )
SC="4.4BSD/Mach3.0"
;;
# Windows/Cygwin
*:CYGWIN*:* )
# determine architecture
AT="`uname -m`"
AP="${AT}"
case "${AP}" in
i?86 ) AP="iX86" ;;
esac
AC="${AP}"
# determine system
unset v1; unset v2; unset v3
eval `echo "${UNAME_RELEASE}" |\
sed -e 's/^/#/' \
-e 's/^#\([0-9][0-9]*\)\.\([0-9][0-9]*\)\.\([0-9][0-9]*\).*$/v1="\1"; v2="\2"; v3="\3"/' \
-e 's/^#\([0-9][0-9]*\)\.\([0-9][0-9]*\).*$/v1="\1"; v2="\2"/' \
-e 's/^#\([0-9][0-9]*\).*$/v1="\1"/' \
-e 's/^#.*$/v1="0"/'`
ST="Cygwin ${v1}${v2+.$v2}${v3+[.$v3]}"
SP="$ST"
SC="Windows"
v=`echo "${UNAME_SYSTEM}" | sed -e 's/^CYGWIN_NT-//' |\
sed -e 's/^/#/' -e 's/^#\([0-9][0-9]*\.[0-9][0-9]*\).*$/\1/' -e 's/^#.*$//'`
case "$v" in
4.0 ) SC="$SC[ NT]" ;;
5.0 ) SC="$SC[ 2000]" ;;
5.1 ) SC="$SC[ XP]" ;;
6.0 ) SC="$SC[ Vista]" ;;
esac
;;
# TODO ...ADD YOUR NEW PLATFORM CHECK HERE... TODO
# *:XXX:* )
# ...

View File

@ -959,7 +959,7 @@ int
main(int argc, char **argv)
{
const char *s_ctlfd, *s_pipe, *s_pid;
int ctlfd, pipefd, maxfd;
int ctlfd, pipefd, maxfd, x;
maxfd = maxconn();
s_ctlfd = getenv("CTL_FD");
@ -979,9 +979,6 @@ main(int argc, char **argv)
pipefd = atoi(s_pipe);
ppid = atoi(s_pid);
#ifndef _WIN32
int x;
for(x = 3; x < maxfd; x++)
{
if(x != ctlfd && x != pipefd)
@ -1001,7 +998,6 @@ main(int argc, char **argv)
if(x > 2)
close(x);
}
#endif
setup_signals();
rb_lib_init(NULL, NULL, NULL, 0, maxfd, 1024, 4096);
@ -1036,18 +1032,15 @@ main(int argc, char **argv)
}
#ifndef _WIN32
static void
dummy_handler(int sig)
{
return;
}
#endif
static void
setup_signals()
{
#ifndef _WIN32
struct sigaction act;
act.sa_flags = 0;
@ -1070,5 +1063,4 @@ setup_signals()
act.sa_handler = dummy_handler;
sigaction(SIGALRM, &act, 0);
#endif
}

View File

@ -63,22 +63,22 @@ void ircd_util_init(const char *name)
ircd_paths[IRCD_PATH_IRCD_EXEC] = argv0;
ircd_paths[IRCD_PATH_PREFIX] = ".";
snprintf(buf, sizeof(buf), "runtime%cmodules", RB_PATH_SEPARATOR);
snprintf(buf, sizeof(buf), "runtime/modules");
ircd_paths[IRCD_PATH_MODULES] = rb_strdup(buf);
snprintf(buf, sizeof(buf), "runtime%1$cmodules%1$cautoload", RB_PATH_SEPARATOR);
snprintf(buf, sizeof(buf), "runtime/modules/autoload");
ircd_paths[IRCD_PATH_AUTOLOAD_MODULES] = rb_strdup(buf);
ircd_paths[IRCD_PATH_ETC] = "runtime";
ircd_paths[IRCD_PATH_LOG] = "runtime";
snprintf(buf, sizeof(buf), "runtime%1$chelp%1$cusers", RB_PATH_SEPARATOR);
snprintf(buf, sizeof(buf), "runtime/help/users");
ircd_paths[IRCD_PATH_USERHELP] = rb_strdup(buf);
snprintf(buf, sizeof(buf), "runtime%1$chelp%1$copers", RB_PATH_SEPARATOR);
snprintf(buf, sizeof(buf), "runtime/help/opers");
ircd_paths[IRCD_PATH_OPERHELP] = rb_strdup(buf);
snprintf(buf, sizeof(buf), "runtime%cmotd", RB_PATH_SEPARATOR);
snprintf(buf, sizeof(buf), "runtime/motd");
ircd_paths[IRCD_PATH_IRCD_MOTD] = rb_strdup(buf);
ircd_paths[IRCD_PATH_IRCD_OMOTD] = rb_strdup(buf);
@ -90,7 +90,7 @@ void ircd_util_init(const char *name)
ircd_paths[IRCD_PATH_IRCD_PID] = rb_strdup(pidfile);
ircd_paths[IRCD_PATH_IRCD_LOG] = rb_strdup(logfile);
snprintf(buf, sizeof(buf), "runtime%cbin", RB_PATH_SEPARATOR);
snprintf(buf, sizeof(buf), "runtime/bin");
ircd_paths[IRCD_PATH_BIN] = rb_strdup(buf);
ircd_paths[IRCD_PATH_LIBEXEC] = rb_strdup(buf);

View File

@ -42,22 +42,11 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifdef _WIN32
# include <direct.h>
#else
# include <sys/stat.h>
#endif
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include <tests/tap/basic.h>
/* Windows provides mkdir and rmdir under different names. */
#ifdef _WIN32
# define mkdir(p, m) _mkdir(p)
# define rmdir(p) _rmdir(p)
#endif
/*
* The test count. Always contains the number that will be used for the next
* test status. This is exported to callers of the library.
@ -849,7 +838,7 @@ bstrndup(const char *s, size_t n)
* Locate a test file. Given the partial path to a file, look under
* C_TAP_BUILD and then C_TAP_SOURCE for the file and return the full path to
* the file. Returns NULL if the file doesn't exist. A non-NULL return
* should be freed with test_file_path_free().
* should be freed with free().
*/
char *
test_file_path(const char *file)
@ -873,18 +862,6 @@ test_file_path(const char *file)
}
/*
* Free a path returned from test_file_path(). This function exists primarily
* for Windows, where memory must be freed from the same library domain that
* it was allocated from.
*/
void
test_file_path_free(char *path)
{
free(path);
}
/*
* Create a temporary directory, tmp, under C_TAP_BUILD if set and the current
* directory if it does not. Returns the path to the temporary directory in

View File

@ -142,11 +142,10 @@ char *bstrndup(const char *, size_t)
/*
* Find a test file under C_TAP_BUILD or C_TAP_SOURCE, returning the full
* path. The returned path should be freed with test_file_path_free().
* path. The returned path should be freed with free().
*/
char *test_file_path(const char *file)
__attribute__((__malloc__, __nonnull__, __warn_unused_result__));
void test_file_path_free(char *path);
/*
* Create a temporary directory relative to C_TAP_BUILD and return the path.

View File

@ -16,9 +16,7 @@
#include <unistd.h>
#include <fcntl.h>
#include "rb_lib.h"
#ifndef __MINGW32__
#include <pwd.h>
#endif
#define FLAG_MD5 0x00000001
#define FLAG_SALT 0x00000002
@ -47,42 +45,6 @@ static void brief_usage(void) __attribute__((noreturn));
static char saltChars[] = "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
/* 0 .. 63, ascii - 64 */
#ifdef __MINGW32__
#include <conio.h>
#ifdef PASS_MAX
#undef PASS_MAX
#endif
#define PASS_MAX 256
static char getpassbuf[PASS_MAX + 1];
static char *
getpass(const char *prompt)
{
int c;
int i = 0;
memset(getpassbuf, 0, sizeof(getpassbuf));
fputs(prompt, stderr);
for(;;)
{
c = _getch();
if(c == '\r')
{
getpassbuf[i] = '\0';
break;
}
else if(i < PASS_MAX)
{
getpassbuf[i++] = c;
}
}
fputs("\r\n", stderr);
return getpassbuf;
}
#endif
int
main(int argc, char *argv[])
{

View File

@ -12,13 +12,7 @@
*/
#include "stdinc.h"
#ifdef _WIN32
#include <winsock2.h> // for htonl()
#else
#include <netinet/in.h> // for htonl()
#endif
#include <netinet/in.h> // for htonl()
#include "sha1.h"
#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))

View File

@ -177,18 +177,15 @@ static rb_dlink_list dead_list;
static void conn_plain_read_shutdown_cb(rb_fde_t *fd, void *data);
#ifndef _WIN32
static void
dummy_handler(int sig)
{
return;
}
#endif
static void
setup_signals()
{
#ifndef _WIN32
struct sigaction act;
act.sa_flags = 0;
@ -211,7 +208,6 @@ setup_signals()
act.sa_handler = dummy_handler;
sigaction(SIGALRM, &act, 0);
#endif
}
static int
@ -951,7 +947,7 @@ int
main(int argc, char **argv)
{
const char *s_ctlfd, *s_pipe, *s_pid;
int ctlfd, pipefd, maxfd;
int ctlfd, pipefd, maxfd, x;
maxfd = maxconn();
s_ctlfd = getenv("CTL_FD");
@ -971,8 +967,6 @@ main(int argc, char **argv)
pipefd = atoi(s_pipe);
ppid = atoi(s_pid);
#ifndef _WIN32
int x = 0;
for(x = 0; x < maxfd; x++)
{
if(x != ctlfd && x != pipefd && x > 2)
@ -991,7 +985,7 @@ main(int argc, char **argv)
if(x > 2)
close(x);
}
#endif
setup_signals();
rb_lib_init(NULL, NULL, NULL, 0, maxfd, 1024, 4096);
rb_linebuf_init(4096);