A program I wrote so I could use bogofilter with kmail
useing the precommand.
It will probly work with other programs that can
exicute a command before connecting to the pop3 sever.
It comples under linux but other unix and unix like
systems have not been tested.
a bogofilter pop3 wrapper for kmail
Logged In: YES
user_id=2788
The code doesn't quite work for me, but it's not looking bad.
Some minor changes are needed to bring it up to date.
1. ISO C++ wants the C standard library headers as #include
<cstring>, #include <cstdio>. No C++ standard library header
has the .h, so use #include <fstream>. Add "using namespace
std;" before the first function to quelch "undefined function"
errors. Wrap any headers for which there is no C++ standard
header wrapper into extern "C", like this (these have their .h,
they are not C/C++ standard headers, but UNIX headers):
extern "C" {
#include <unistd.h>
#include <netdb.h>
// more here
}
2. bzero/bcopy/bmove are obsolete, non-portable and must
not be used in new code. Please use memset for bzero and
the other mem* functions instead.
3. When you must use fixed size buffers, ALWAYS use sizeof.
Avoid bzero/memset before read.
4. When read is called, check its return value, it will tell you
how many characters have been read, which you can then
subsequently push into write().
5. Always be aware of if you're treating C strings or
sequences of characters. Consider using C++ string s;
getline(cin, s) when appropriate, this is \0 transparent.
6. Personally, I'd prefer if the proxy returned -ERR and killed
the connection rather than
faking a mail.
7. How do I get this to work with SSL? I believe using stunnel
as Yet Another Proxy for bogowrapper is fine, just add some
lines of documentation.
Are you interested in reworking the code and making a v0.3?
I'd appreciate that.
Logged In: YES
user_id=2788
I have started some of the work, but it's incomplete because
I'm running out of time for today, if you want to pick up where I
left off, my bogowrapper.patch is below, apply to the
bogowrapper.tar.bz2 that you attached.
The most important thing is getting rid of strlen() in write and all
those 500 or 100, and taking the return value from read, and
handling read or write replies < 0 which mean errors.
partial rework of bogowrapper
Logged In: YES
user_id=2788
Oh, one more thing, the proxy must catch a starttls offer by the
server (in the CAPA reply probably) and also catch the STLS
command and return -ERR, otherwise, it fails if a TLS-aware
POP3 client tries to retrieve mail.