From 83d0e94cb74c8ea6566b1e50d5e16b408866f75c Mon Sep 17 00:00:00 2001 From: Andreas Tonnesen Date: Sun, 30 Jan 2005 16:33:53 +0000 Subject: [PATCH] The plugin now compiles for win32 as well --- lib/nameservice/Makefile | 14 ++++++++++++++ lib/nameservice/src/olsrd_plugin.c | 31 ++++++++++++++++++++++++++++-- lib/nameservice/src/olsrd_plugin.h | 12 ++++++++++-- 3 files changed, 53 insertions(+), 4 deletions(-) diff --git a/lib/nameservice/Makefile b/lib/nameservice/Makefile index c0102b8c..a3f1defd 100644 --- a/lib/nameservice/Makefile +++ b/lib/nameservice/Makefile @@ -27,9 +27,22 @@ INSTALL_LIB = install -m 755 $(NAME) $(LIBDIR)/$(NAME);\ /sbin/ldconfig all: plugin else +ifeq ($(OS), win32) +NAME ?= olsrd_nameservice.dll +NAMEFLAGS ?= -o $(NAME) +MYFLAGS ?= -g -fPIC -DWIN32 -mno-cygwin -I../../src/win32 -Wall -Wmissing-prototypes -Wstrict-prototypes +CFLAGS ?= -O2 +CFLAGS += $(MYFLAGS) +LDFLAGS ?= -mno-cygwin -shared +LIBS ?= -lws2_32 +COMPATOBJ = ../../src/win32/compat.o +INSTALL_LIB = cp $(NAME) ../.. +all: plugin +else all: help endif endif +endif SRCS = $(wildcard src/*.c) OBJS = $(patsubst %.c,%.o,$(SRCS)) @@ -57,6 +70,7 @@ help: @echo ' --------------------------------- ' @echo ' linux - GNU/Linux ' @echo ' fbsd - FreeBSD ' + @echo ' win32 - Windows ' @echo ' --------------------------------- ' @echo ' Example - build for FreeBSD: ' @echo ' gmake OS=fbsd ' diff --git a/lib/nameservice/src/olsrd_plugin.c b/lib/nameservice/src/olsrd_plugin.c index fc3188df..11df672a 100644 --- a/lib/nameservice/src/olsrd_plugin.c +++ b/lib/nameservice/src/olsrd_plugin.c @@ -29,7 +29,7 @@ * */ -/* $Id: olsrd_plugin.c,v 1.2 2005/01/30 16:20:36 kattemat Exp $ */ +/* $Id: olsrd_plugin.c,v 1.3 2005/01/30 16:33:53 kattemat Exp $ */ /* @@ -42,7 +42,34 @@ #include "olsrd_plugin.h" #include "nameservice.h" -#ifdef __FreeBSD__ +#ifdef WIN32 + +static char *inet_ntop4(const unsigned char *src, char *dst, int size) +{ + static const char fmt[] = "%u.%u.%u.%u"; + char tmp[sizeof "255.255.255.255"]; + + if (sprintf(tmp, fmt, src[0], src[1], src[2], src[3]) > size) + return (NULL); + + return strcpy(dst, tmp); +} + +char *inet_ntop(int af, void *src, char *dst, int size) +{ + switch (af) + { + case AF_INET: + return (inet_ntop4(src, dst, size)); + + default: + return (NULL); + } +} + +#endif + +#ifndef linux #include diff --git a/lib/nameservice/src/olsrd_plugin.h b/lib/nameservice/src/olsrd_plugin.h index 22d59303..d5ad9656 100644 --- a/lib/nameservice/src/olsrd_plugin.h +++ b/lib/nameservice/src/olsrd_plugin.h @@ -29,7 +29,7 @@ * */ -/* $Id: olsrd_plugin.h,v 1.1 2005/01/16 13:06:00 kattemat Exp $ */ +/* $Id: olsrd_plugin.h,v 1.2 2005/01/30 16:33:53 kattemat Exp $ */ /* * Dynamic linked library example for UniK OLSRd @@ -63,13 +63,21 @@ /* types */ #include +#ifndef WIN32 typedef u_int8_t olsr_u8_t; typedef u_int16_t olsr_u16_t; typedef u_int32_t olsr_u32_t; typedef int8_t olsr_8_t; typedef int16_t olsr_16_t; typedef int32_t olsr_32_t; - +#else +typedef unsigned char olsr_u8_t; +typedef unsigned short olsr_u16_t; +typedef unsigned int olsr_u32_t; +typedef char olsr_8_t; +typedef short olsr_16_t; +typedef int olsr_32_t; +#endif /* -- 2.20.1