From 875422c8e52e8f58e54912b9afffd0a33f2e121b Mon Sep 17 00:00:00 2001 From: Michael Poole Date: Fri, 22 Sep 2006 03:02:07 +0000 Subject: [PATCH] First pass at native Win32 support (does not compile). src/compat.h: Handle Windows Sockets 2 headers. src/mod-memoserv.c (KEY_READ): #undef'ine to avoid its registry access meaning on Windows. Makefile.win32: New Makefile for native or cross builds targeting Win32. src/config.h.win32: Pregenerated config.h for Win32. src/ioset-win32.c: First attempt at a Win32 ioset backend. git-archimport-id: srvx@srvx.net--2006/srvx--devo--1.3--patch-41 --- ChangeLog | 27 ++++ Makefile.win32 | 72 ++++++++++ src/compat.h | 10 ++ src/config.h.win32 | 319 +++++++++++++++++++++++++++++++++++++++++++++ src/ioset-win32.c | 85 ++++++++++++ src/mod-memoserv.c | 1 + 6 files changed, 514 insertions(+) create mode 100644 Makefile.win32 create mode 100644 src/config.h.win32 create mode 100644 src/ioset-win32.c diff --git a/ChangeLog b/ChangeLog index 2f916a3..e7c40dd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,33 @@ # arch-tag: automatic-ChangeLog--srvx@srvx.net--2006/srvx--devo--1.3 # +2006-09-22 03:02:07 GMT Michael Poole patch-41 + + Summary: + First pass at native Win32 support (does not compile). + Revision: + srvx--devo--1.3--patch-41 + + src/compat.h: Handle Windows Sockets 2 headers. + + src/mod-memoserv.c (KEY_READ): #undef'ine to avoid its registry access + meaning on Windows. + + Makefile.win32: New Makefile for native or cross builds targeting Win32. + + src/config.h.win32: Pregenerated config.h for Win32. + + src/ioset-win32.c: First attempt at a Win32 ioset backend. + + new files: + .arch-ids/Makefile.win32.id Makefile.win32 + src/.arch-ids/config.h.win32.id src/.arch-ids/ioset-win32.c.id + src/config.h.win32 src/ioset-win32.c + + modified files: + ChangeLog src/compat.h src/mod-memoserv.c + + 2006-09-22 02:51:50 GMT Michael Poole patch-40 Summary: diff --git a/Makefile.win32 b/Makefile.win32 new file mode 100644 index 0000000..ce82904 --- /dev/null +++ b/Makefile.win32 @@ -0,0 +1,72 @@ +# For an out-of-tree build, set VPATH appropriately: +VPATH=. +# (You will also have to manually create the 'rx' and 'src' +# directories if they do not already exist.) +# For a cross-compilation, set CC appropriately: +# CC=i586-mingw32msvc-cc +CPPFLAGS=-I$(VPATH) -Isrc +CFLAGS=-mno-cygwin -W -Wall -O2 + +#MODULES= +MODULES=helpserv memoserv qserver snoop sockcheck +PROTOCOL=p10 +ifeq ($(PROTOCOL),p10) + CFLAGS += -DWITH_PROTOCOL_P10 +else + CFLAGS += -DWITH_PROTOCOL_BAHAMUT +endif + +RX_OBJS = \ + rx/rx.o \ + rx/rxanal.o \ + rx/rxbasic.o \ + rx/rxbitset.o \ + rx/rxcset.o \ + rx/rxgnucomp.o \ + rx/rxhash.o \ + rx/rxnfa.o \ + rx/rxnode.o \ + rx/rxposix.o \ + rx/rxsimp.o \ + rx/rxspencer.o \ + rx/rxstr.o \ + rx/rxsuper.o \ + rx/rxunfa.o + +SRVX_OBJS = \ + src/chanserv.o \ + src/compat.o \ + src/conf.o \ + src/dict-splay.o \ + src/gline.o \ + src/hash.o \ + src/heap.o \ + src/helpfile.o \ + src/ioset-win32.o \ + src/ioset.o \ + src/log.o \ + src/main.o \ + src/md5.o \ + src/modcmd.o \ + src/modules.o \ + src/nickserv.o \ + src/opserv.o \ + src/policer.o \ + src/proto-$(PROTOCOL).o \ + src/recdb.o \ + src/saxdb.o \ + src/sendmail.o \ + src/timeq.o \ + src/tools.o \ + $(addsuffix .o,$(addprefix src/mod-,$(MODULES))) + +srvx: src/config.h src/modules-list.h $(RX_OBJS) $(SRVX_OBJS) +src/config.h: $(VPATH)/src/config.h.win32 + cp $< $@ +src/modules-list.h: + rm -f $@; \ + for module in $(MODULES) ; do \ + echo "WITH_MODULE($$module)" >> $@ ; \ + done +clean: + rm -f src/config.h src/modules-list.h */*.o */*.exe diff --git a/src/compat.h b/src/compat.h index dbc7931..4968587 100644 --- a/src/compat.h +++ b/src/compat.h @@ -61,6 +61,16 @@ char *alloca(); #include #endif +#ifdef HAVE_WINSOCK2_H +/* Windows XP+ only -- older versions lack getaddrinfo() etc. */ +# define _WIN32_WINNT 0x0501 +# include +#endif + +#ifdef HAVE_WS2TCPIP_H +# include +#endif + #ifdef HAVE_UNISTD_H #include #endif diff --git a/src/config.h.win32 b/src/config.h.win32 new file mode 100644 index 0000000..262ff37 --- /dev/null +++ b/src/config.h.win32 @@ -0,0 +1,319 @@ +/* src/config.h.win32. Generated manually from src/config.h.in. */ + +/* Win32-specific stuff here.. */ +#define HAVE_WINSOCK2_H 1 +#define HAVE_WS2TCPIP_H 1 +#define HAVE_IOCTLSOCKET 1 +#define HAVE_WSAEVENTSELECT 1 +#define _WIN32_WINNT 0x0501 + +/* Define if the system regex library is unreliable. */ +#undef BROKEN_REGEX + +/* Code name for this release */ +#define CODENAME "surge" + +/* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP + systems. This function is required for `alloca.c' support on those systems. + */ +#undef CRAY_STACKSEG_END + +/* Define to 1 if using `alloca.c'. */ +#undef C_ALLOCA + +/* Define if tokenized P10 desired */ +#define ENABLE_TOKENS 1 + +/* Define to printf format for a time_t variable */ +#define FMT_TIME_T "%ld" + +/* Define to 1 if you have `alloca', as a function or macro. */ +#define HAVE_ALLOCA 1 + +/* Define to 1 if you have and it should be used (not on Ultrix). + */ +#undef HAVE_ALLOCA_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_ARPA_INET_H + +/* Define to 1 if you have the header file. */ +#define HAVE_DIRENT_H 1 + +/* Define to 1 if you have the header file. */ +#undef HAVE_DLFCN_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_DMALLOC_H + +/* Define to 1 if you have the header file. */ +#define HAVE_FCNTL_H 1 + +/* Define to 1 if you have the `freeaddrinfo' function. */ +#define HAVE_FREEADDRINFO 1 + +/* Define to 1 if you have the `ftime' function. */ +#define HAVE_FTIME 1 + +/* Define to 1 if you have the header file. */ +#undef HAVE_GC_GC_H + +/* Define to 1 if you have the `getaddrinfo' function. */ +#define HAVE_GETADDRINFO 1 + +/* Define to 1 if you have the `getnameinfo' function. */ +#define HAVE_GETNAMEINFO 1 + +/* Define to 1 if you have the `getopt' function. */ +#undef HAVE_GETOPT + +/* Define to 1 if you have the header file. */ +#undef HAVE_GETOPT_H + +/* Define to 1 if you have the `getopt_long' function. */ +#undef HAVE_GETOPT_LONG + +/* Define to 1 if you have the `getpagesize' function. */ +#undef HAVE_GETPAGESIZE + +/* Define to 1 if you have the `gettimeofday' function. */ +#define HAVE_GETTIMEOFDAY 1 + +/* Define to 1 if you have the `inet_aton' function. */ +#undef HAVE_INET_ATON + +/* Define to 1 if you have the header file. */ +#define HAVE_INTTYPES_H 1 + +/* Define to 1 if you have the `dl' library (-ldl). */ +#undef HAVE_LIBDL + +/* Define to 1 if you have the `dmalloc' library (-ldmalloc). */ +#undef HAVE_LIBDMALLOC + +/* Define to 1 if you have the `elf' library (-lelf). */ +#undef HAVE_LIBELF + +/* Define to 1 if you have the `gc' library (-lgc). */ +#undef HAVE_LIBGC + +/* Define to 1 if you have the `mpatrol' library (-lmpatrol). */ +#undef HAVE_LIBMPATROL + +/* Define to 1 if you have the `nsl' library (-lnsl). */ +#undef HAVE_LIBNSL + +/* Define to 1 if you have the `socket' library (-lsocket). */ +#undef HAVE_LIBSOCKET + +/* Define to 1 if you have the `localtime_r' function. */ +#undef HAVE_LOCALTIME_R + +/* Define to 1 if you have the header file. */ +#undef HAVE_MALLOC_H + +/* Define to 1 if you have the `memcpy' function. */ +#define HAVE_MEMCPY 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_MEMORY_H 1 + +/* Define to 1 if you have the `memset' function. */ +#define HAVE_MEMSET 1 + +/* Define to 1 if you have a working `mmap' system call. */ +#undef HAVE_MMAP + +/* Define to 1 if you have the header file. */ +#undef HAVE_MPATROL_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_NETDB_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_NETINET_IN_H + +/* Define to 1 if you have the `regcomp' function. */ +#undef HAVE_REGCOMP + +/* Define to 1 if you have the `regexec' function. */ +#undef HAVE_REGEXEC + +/* Define to 1 if you have the header file. */ +#undef HAVE_REGEX_H + +/* Define to 1 if you have the `regfree' function. */ +#undef HAVE_REGFREE + +/* Define to 1 if you have the `select' function. */ +#undef HAVE_SELECT + +/* Define to 1 if you have the `setrlimit' function. */ +#undef HAVE_SETRLIMIT + +/* Define if struct sockaddr_in contains a sin_len field */ +#undef HAVE_SIN_LEN + +/* Define if struct sockaddr has sa_len field */ +#undef HAVE_SOCKADDR_SA_LEN + +/* Define to 1 if you have the `socket' function. */ +#define HAVE_SOCKET 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDINT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDLIB_H 1 + +/* Define to 1 if you have the `strcspn' function. */ +#define HAVE_STRCSPN 1 + +/* Define to 1 if you have the `strdup' function. */ +#define HAVE_STRDUP 1 + +/* Define to 1 if you have the `strerror' function. */ +#define HAVE_STRERROR 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRINGS_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRING_H 1 + +/* Define to 1 if you have the `strsignal' function. */ +#undef HAVE_STRSIGNAL + +/* Define to 1 if you have the `strspn' function. */ +#define HAVE_STRSPN 1 + +/* Define to 1 if you have the `strtod' function. */ +#define HAVE_STRTOD 1 + +/* Define to 1 if you have the `strtoul' function. */ +#define HAVE_STRTOUL 1 + +/* Define if struct addrinfo declared */ +#define HAVE_STRUCT_ADDRINFO 1 + +/* Define to 1 if you have the `sysconf' function. */ +#undef HAVE_SYSCONF + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_MMAN_H + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_PARAM_H 1 + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_RESOURCE_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_SOCKET_H + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_STAT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TIMEB_H 1 + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_TIMES_H + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TIME_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TYPES_H 1 + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_WAIT_H + +/* Define to 1 if you have the header file. */ +#define HAVE_UNISTD_H 1 + +/* Define if we have va_copy */ +#define HAVE_VA_COPY 1 + +/* Define if we have __va_copy */ +#undef HAVE___VA_COPY + +/* Define to disable built-in getopt library */ +#undef IGNORE_GETOPT + +/* Name of package */ +#define PACKAGE "srvx" + +/* Define to the address where bug reports for this package should be sent. */ +#define PACKAGE_BUGREPORT "srvx-bugs@lists.sourceforge.net" + +/* Define to the full name of this package. */ +#define PACKAGE_NAME "srvx" + +/* Define to the full name and version of this package. */ +#define PACKAGE_STRING "srvx 1.31-win" + +/* Define to the one symbol short name of this package. */ +#define PACKAGE_TARNAME "srvx-1.3.1" + +/* Define to the version of this package. */ +#define PACKAGE_VERSION "1.3.1" + +/* Define as the return type of signal handlers (`int' or `void'). */ +#define RETSIGTYPE void + +/* If using the C implementation of alloca, define if you know the + direction of stack growth for your system; otherwise it will be + automatically deduced at run-time. + STACK_DIRECTION > 0 => grows toward higher addresses + STACK_DIRECTION < 0 => grows toward lower addresses + STACK_DIRECTION = 0 => direction of growth unknown */ +#define STACK_DIRECTION -1 + +/* Define to 1 if you have the ANSI C header files. */ +#define STDC_HEADERS 1 + +/* Define to 1 if you can safely include both and . */ +#define TIME_WITH_SYS_TIME 1 + +/* Define to 1 if your declares `struct tm'. */ +#define TM_IN_SYS_TIME 1 + +/* Version number of package */ +#define VERSION 1.3.1 + +/* Define if using the Win32 I/O backend */ +#define WITH_IOSET_WIN32 1 + +/* Define if using the epoll I/O backend */ +#undef WITH_IOSET_EPOLL + +/* Define if using the Boehm GC to garbage collect and check memory leaks */ +#undef WITH_MALLOC_BOEHM_GC + +/* Define if using the dmalloc debugging malloc package */ +#undef WITH_MALLOC_DMALLOC + +/* Define if using the mpatrol malloc debugging package */ +#undef WITH_MALLOC_MPATROL + +/* Define if using the slab internal debug allocator */ +#undef WITH_MALLOC_SLAB + +/* Define if using the srvx internal debug allocator */ +#undef WITH_MALLOC_SRVX + +/* Define if using the system's malloc */ +#undef WITH_MALLOC_SYSTEM + +/* Define to empty if `const' does not conform to ANSI C. */ +#undef const + +/* Define to `__inline__' or `__inline' if that's what the C compiler + calls it, or to nothing if 'inline' is not supported under any name. */ +#ifndef __cplusplus +#undef inline +#endif + +/* type to use in place of socklen_t if not defined */ +#undef socklen_t diff --git a/src/ioset-win32.c b/src/ioset-win32.c new file mode 100644 index 0000000..018206a --- /dev/null +++ b/src/ioset-win32.c @@ -0,0 +1,85 @@ +/* Win32 ioset backend for srvx + * Copyright 2006 srvx Development Team + * + * This file is part of srvx. + * + * srvx 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 srvx; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ + +#include "ioset-impl.h" +#include "common.h" +#include "log.h" + +/* This is massively kludgy. Unfortunately, the only performant I/O + * multiplexer with halfway decent semantics under Windows is + * WSAAsyncSelect() -- which requires a window that can receive + * messages. + * + * So ioset_win32_init() creates a hidden window and sets it up for + * asynchronous socket notifications. + */ + +static int +ioset_win32_init(void) +{ + WSADATA wsadata; + int res; + + res = WSAStartup(MAKEWORD(2, 0), &wsadata); + // TODO: finish implementing ioset_win32_init() + return 0; +} + +static void +ioset_win32_add(struct io_fd *fd) +{ + // TODO: implement ioset_win32_add() +} + +static void +ioset_win32_remove(struct io_fd *fd) +{ + // TODO: implement ioset_win32_remove() +} + +static void +ioset_win32_update(struct io_fd *fd) +{ + // TODO: implement ioset_win32_update() +} + +static void +ioset_win32_cleanup(void) +{ + // TODO: finish implementing ioset_win32_cleanup() + WSACleanup(); +} + +static int +ioset_win32_loop(struct timeval *timeout) +{ + // TODO: implement ioset_win32_loop() + return 0; +} + +struct io_engine io_engine_win32 = { + .name = "win32", + .init = ioset_win32_init, + .add = ioset_win32_add, + .remove = ioset_win32_remove, + .update = ioset_win32_update, + .loop = ioset_win32_loop, + .cleanup = ioset_win32_cleanup, +}; diff --git a/src/mod-memoserv.c b/src/mod-memoserv.c index 1fc9b1f..a5e0e99 100644 --- a/src/mod-memoserv.c +++ b/src/mod-memoserv.c @@ -56,6 +56,7 @@ #define KEY_RECIPIENT "to" #define KEY_FROM "from" #define KEY_MESSAGE "msg" +#undef KEY_READ /* thanks microsoft! */ #define KEY_READ "read" static const struct message_entry msgtab[] = { -- 2.20.1