Skip to content

Commit

Permalink
FreeBSD support
Browse files Browse the repository at this point in the history
  • Loading branch information
rofl0r committed Dec 25, 2012
1 parent be4efc0 commit 5526afb
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ LOBJS = src/nameinfo.o \

CFLAGS += -Wall -O0 -g -std=c99 -D_GNU_SOURCE -pipe
NO_AS_NEEDED = -Wl,--no-as-needed
LDFLAGS = -shared -fPIC $(NO_AS_NEEDED) -ldl -lpthread
LIBDL = -ldl
LDFLAGS = -shared -fPIC $(NO_AS_NEEDED) $(LIBDL) -lpthread
INC =
PIC = -fPIC
AR = $(CROSS_COMPILE)ar
Expand Down
9 changes: 8 additions & 1 deletion configure
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ parsearg() {
}

ismac() {
uname -s | grep Darwin
uname -s | grep Darwin >/dev/null
}

isbsd() {
uname -s | grep BSD >/dev/null
}

while true ; do
Expand Down Expand Up @@ -83,6 +87,9 @@ if ismac ; then
echo MAC_CFLAGS+=-DIS_MAC=1>>config.mak
echo LD_SET_SONAME=-Wl,-install_name,>>config.mak
echo INSTALL_FLAGS=-m>>config.mak
elif isbsd ; then
echo LIBDL=>>config.mak
echo "CFLAGS+=-DIS_BSD">>config.mak
fi

echo done, now run make \&\& make install
Expand Down
5 changes: 5 additions & 0 deletions src/hostentdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,16 @@ static void hdb_add(struct hostent_list* hl, char* host, ip_type ip) {
}

static void hdb_fill(struct hostent_list *hl) {
#ifndef IS_BSD
struct hostent* hp;
while((hp = gethostent()))
if(hp->h_addrtype == AF_INET && hp->h_length == sizeof(in_addr_t)) {
hdb_add(hl, hp->h_name, (ip_type) { .as_int = *((in_addr_t*)(hp->h_addr_list[0])) });
}
#else
/* FreeBSD hangs on gethostent(). since this feature is not crucial, we just do nothing */
(void) hl;
#endif
}

void hdb_init(struct hostent_list *hl) {
Expand Down

0 comments on commit 5526afb

Please sign in to comment.