Bug 2862

Summary: Port of spamc to Win32 environment
Product: Spamassassin Reporter: Sidney Markowitz <sidney>
Component: spamc/spamdAssignee: Malte S. Stretz <spamassassin-bugger>
Status: RESOLVED FIXED    
Severity: enhancement CC: dev, olivier.boudry, p.alessandroni
Priority: P3    
Version: SVN Trunk (Latest Devel Version)   
Target Milestone: 3.0.0   
Hardware: PC   
OS: other   
Whiteboard:
Attachments: *OBSOLETE* patches to Makefile.PL and spamd/ files to port spamc to Win32
file spamd\README.Win32
*OBSOLETE* file spamd/getopt.h
*OBSOLETE* file spamd/getopt.c
*OBSOLETE* file spamd/win32.config
*OBSOLETE* file spamd/win32.mak
*OBSOLETE* updated patches to Makefile.PL and spamd files
patches to Makefile.PL and spamd/ files now with SSL support
*OBSOLETE* spamd/win32nossl.mak spamc makefile for Win32 with no SSL
*OBSOLETE* file name spamd/win32ssl.mak
spamd/win32.config for use in Win32 build of spamc
file spamd/getopt.h apache licensed version copied from apache 1.3
file spamd/getopt.c apache licensed version copied from apache 1.3
file spamd/win32nossl.mak
file name spamd/win32ssl.mak

Description Sidney Markowitz 2003-12-20 14:48:46 UTC
Here are patches that allow spamc to work under Win32. I have only tested using
the VC++ 6.0 compiler and without SSL, but that's a start.

I am uploading patches to Makefile.PL against the current CVS. Please notice
that this patch includes the patch I uploaded for bug #2808 so that should be
obsoleted and just this one applied.

The patches in this upload also are for other files inthe spamd directory, and
in separate attachments are five new files for that directory.
Comment 1 Sidney Markowitz 2003-12-20 14:51:05 UTC
Created attachment 1630 [details]
*OBSOLETE* patches to Makefile.PL and spamd/ files to port spamc to Win32

Note that the patch to Makefile.PL is against the CVS version and includes the
patch submitted for bug #2808, obsoleting that patch.
Comment 2 Sidney Markowitz 2003-12-20 14:52:54 UTC
Created attachment 1631 [details]
file spamd\README.Win32

file name spamd\README.Win32
Comment 3 Sidney Markowitz 2003-12-20 14:54:05 UTC
Created attachment 1632 [details]
*OBSOLETE* file spamd/getopt.h

file spamd/getopt.h
Comment 4 Sidney Markowitz 2003-12-20 14:55:21 UTC
Created attachment 1633 [details]
*OBSOLETE* file spamd/getopt.c

file spamd/getopt.c copied from OpenBSD
Comment 5 Sidney Markowitz 2003-12-20 14:56:45 UTC
Created attachment 1634 [details]
*OBSOLETE* file spamd/win32.config

file spamd/win32.config used to build Win32 version of spamc
Comment 6 Sidney Markowitz 2003-12-20 14:57:39 UTC
Created attachment 1635 [details]
*OBSOLETE* file spamd/win32.mak

file spamd/win32.mak used to build Win32 version of spamc
Comment 7 Sidney Markowitz 2003-12-21 06:03:57 UTC
Whoops, there are some bugs in there -- I'll upload a fixed patch after I've had
a chance to test this better on non-Windows platforms.
Comment 8 Sidney Markowitz 2003-12-26 16:08:22 UTC
Created attachment 1637 [details]
*OBSOLETE* updated patches to Makefile.PL and spamd files

This patch fixes bugs in the first patch that I found when I tested under
Cygwin. Note that SSL is not supported under Win32 in this patch. I would like
to see this confirmed and checked in and then we can deal with SSL.
Comment 9 Sidney Markowitz 2003-12-28 04:30:59 UTC
Created attachment 1641 [details]
patches to Makefile.PL and spamd/ files now with SSL support

Updated patch to include SSL support in Win32 spamc
Comment 10 Sidney Markowitz 2003-12-28 04:36:40 UTC
Created attachment 1642 [details]
*OBSOLETE* spamd/win32nossl.mak spamc makefile for Win32 with no SSL

Name this file spamd/win32nossl.mak
It is used as the makefile to build spamc when under Win32 and building spamc
without SSL support
Comment 11 Sidney Markowitz 2003-12-28 04:38:31 UTC
Created attachment 1643 [details]
*OBSOLETE* file name spamd/win32ssl.mak

Name this file spamd/win32ssl.mak
It is used for building the Win32 version of spamc with ssl support
Comment 12 Sidney Markowitz 2003-12-28 04:41:33 UTC
Created attachment 1644 [details]
spamd/win32.config for use in Win32 build of spamc

Name this file spamd/win32.config

Used in Win32 build of spamc. Updated version that works for SSL and non-SSL
builds.
Comment 13 Justin Mason 2004-01-03 13:22:09 UTC
sidney -- you were asking about the OpenBSD code, but I didn't get a chance to
reply before vacation.

We can't incorporate that, unfortunately, unless the original authors say "ok"
to relicensing by sending in an Apache CLA.  However there may be a getopt
implementation in the Apache httpd sourcecode, I reckon; might be worth taking a
look in there, since we could use that code, no problem.
Comment 14 Sidney Markowitz 2004-01-03 14:36:15 UTC
Created attachment 1652 [details]
file spamd/getopt.h apache licensed version copied from apache 1.3

Downloaded from the Apache 1.3 source repository as a dropin replacement for
the OpenBSD version I first uploaded
Comment 15 Sidney Markowitz 2004-01-03 14:37:14 UTC
Created attachment 1653 [details]
file spamd/getopt.c apache licensed version copied from apache 1.3

Downloaded from the Apache 1.3 source repository as a dropin replacement for
the OpenBSD version I first uploaded
Comment 16 Sidney Markowitz 2004-01-04 03:56:13 UTC
Created attachment 1654 [details]
file spamd/win32nossl.mak

The Apache 1.3 getopt checks for WIN32 define instead of _WIN32 which is
supplied by the VC++ 6.0 compiler. This updated makefile for non-SSL build of
spamc adds the definition of WIN32
Comment 17 Sidney Markowitz 2004-01-04 03:57:31 UTC
Created attachment 1655 [details]
file name spamd/win32ssl.mak

The Apache 1.3 getopt checks for WIN32 define instead of _WIN32 which is
supplied by the VC++ 6.0 compiler. This updated makefile for SSL build of spamc
adds the definition of WIN32
Comment 18 Sidney Markowitz 2004-01-04 04:00:02 UTC
Subject: Re:  Port of spamc to Win32 environment

Sander Striker wrote:
>>  However there may be a getopt
>>implementation in the Apache httpd sourcecode, I reckon; might be worth taking a
>>look in there, since we could use that code, no problem.
> 
> 
> In APR (http://apr.apache.org/) actually.  See apr/include/apr_getopt.h.

I don't know why your email did not make it into the bugzilla comments 
on bug 2862. Did you see my response there? I already checked in copies 
from apache-1.3/src/os/win32/getopt.* which work as drop in 
replacements. Since getopt is in the run time library in unix/linux it 
would be even messier to use the apr_getopt in Windows since that uses 
different names all the structures and functions, adding on the 'apr_' 
prefix.

  -- sidney

Comment 19 Malte S. Stretz 2004-01-04 06:23:00 UTC
Sidney, could you please take a moment and mark obsolete patches/files (via 
the Edit link)? It's currently a bit hard to check the stuff (though it looks 
good from what I saw till now). 
Comment 20 Malte S. Stretz 2004-01-04 06:23:48 UTC
*** Bug 2808 has been marked as a duplicate of this bug. ***
Comment 21 Sidney Markowitz 2004-01-04 09:28:31 UTC
Malte, I did mark each one that was obsoleted whenever I checked a new version
in, and they show up as obsolete in my browser. What I see on this screen are
eight attachments marked obsolete (the description struck out), one
non-obsoleted attachment that is labeled as being a patch to existing files, and
six non-obsoleted attachments that are new files, each of the six labeled with
the name of the directory/file that is to be added to the source tree with no
duplicate names.

Do you see something different in your browser? I'll go ahead and add the word
OBSOLETE to the eight obsolete entries in case the strikeout markup isn't
showing up in lynx or some other browser.
Comment 22 Malte S. Stretz 2004-01-04 10:53:50 UTC
Hmm... I don't have anything struck out. Must be my browser. Sorry, it was 
also more or less my fault; I took a sample to see if they were made obsolete, 
but looked at the getopt.h file and thought it was a former version of 
getopt.c. doh! 
 
Ok, I'll check those stuff now... 
Comment 23 Sidney Markowitz 2004-01-04 11:53:37 UTC
Subject: Re:  Port of spamc to Win32 environment

I'm getting the "bugzilla is currently broken [...] too many 
connections" error now, so I'm sending this via email

Malte, note that the latest Net::DNS is required for the Cygwin/Win32 
versions of spamd/spamc to work properly. Most configurations will work 
with the current Net::DNS 0.44 from CPAN, but I have a fix for some less 
common system configurations that went into 0.44_01, which right now is 
marked "Developer Release".

  -- sidney

Comment 24 Malte S. Stretz 2004-01-05 18:51:46 UTC
Ok Sidney: You wanted something like configure for Windows? Here you've got 
it :) 
 
HHOS; I just committed a modified version of your patch: configure is now 
wrapped by a Perl script called build/configure which calls the autoconf 
script if it's not running under Windows and does the stuff on it's own if it 
is. 
 
What it actually does is: 
1. copy spamd/config.h.win to spamd/config.h 
2. copy spamd/binaries.mk.win to spamd/binaries.mk *and* do variable 
replacement of @@FOO@@ stuff similar to autoconf (two @ because it uses our 
existing preprocessor for that). SSL is now enabled with --enable-ssl under 
Windows, too. The values for the variables are currently stored in the 
build/configure script itself but might be moved to a separate file if this 
script should once be re-used (which is simple to do). 
 
Your patches to Makefile.PL went in, too, though modified. And the stuff to 
spamc.c and libspamc.c, too, though I'm not really happy with all those 
#ifdefs. It should be simple to get rid of most of them (by introducing a 
vararg routine log() instead of the macro syslog() and some other changes). 
 
Please test the stuff and tell me if it works (I tested it too, but I just 
"simulated" Windows ;) 
 
You can do an 
  svn log -r 4625:4627 -v 
to see which files were modified and 
  svn diff -r 4625:4627 
to see my actual changes. 
Comment 25 Sidney Markowitz 2004-01-06 07:28:10 UTC
Cygwin built and tested fine.

It's not quite right yet. The Win32 make file has unix style seperators in the
pathnames, e.g., spamd/spamc.c instead of spamd\spamc.c.

I'll fix it and submit the patch on my next awake cycle... This cycle is long
over :-)
Comment 26 Sidney Markowitz 2004-01-06 12:36:01 UTC
Malte, I would like you to either fix this or let me know the best place to fix
it. The latest files you checked in when built under WIN32 result in a makefile
that contains this

SPAMC_FILES = spamd/spamc.c spamd/getopt.c
LIBSPAMC_FILES = spamd/libspamc.c spamd/utils.c

all: spamd/spamc.exe

spamd/spamc.exe: $(SPAMC_FILES) $(LIBSPAMC_FILES)

  ==============

where it should contain

SPAMC_FILES = spamd\spamc.c spamd\getopt.c
LIBSPAMC_FILES = spamd\libspamc.c spamd\utils.c

all: spamd\spamc.exe

spamd\spamc.exe: $(SPAMC_FILES) $(LIBSPAMC_FILES)
Comment 27 Sidney Markowitz 2004-01-06 12:48:18 UTC
Umm, please pretend that I never wrote that last comment :-(
Comment 28 Malte S. Stretz 2004-01-06 12:59:03 UTC
Which comment? Can't see one ;-) 
Comment 29 Malte S. Stretz 2004-02-18 11:21:25 UTC
I think this is finally solved :) 
Comment 30 Sidney Markowitz 2004-02-27 11:19:55 UTC
*** Bug 3101 has been marked as a duplicate of this bug. ***