Thanks for the quick replies.
I don't actually use MercuryS to do anything, and as far as I can tell, there is never any activity for MercuryS -- certainly nothing in the status window. Pop3 client feeds email into Mercury from various sources, and the pop3 server gets them to the clients. Outgoing email (from all clients) connects directly to my ISP's SMTP server. I can outline the entire setup if that makes a difference - the short version is that I'm using other pop3 proxies like SpamBayes/SpamPal in front of mercury to spam filter, and using stunnel (to get to gmail) and freepops (to get to hotmail). I also have an imap4 server running so that I can sync a local/remote account.
The daemon I'd like to write will consist of simply examining the headers and adding some new ones -- nothing too complex. My global filter will simply key off the values in the new headers instead of trying to do some complex sorting (as it is now).
My daemon source code is very simple at this point -- pretty much the daemon2 sample from the DDK. The changes are commenting out the MsgBox on dll load, and adding a logging msg on startup. As I said, the "MercuryDaemon startup called" is logged, but I never see "MercuryDaemon invoked" as MercuryD is fetching email and core is processing them, including running through the global filter. I've confirmed that the daemon dll is loaded the whole time that Mercury is running as the file is locked. Compiled under VC9. The dll exports look right, and it is calling startup just fine.
Here's the code (comments removed for legibility and looks like the webform killed the tabbing):
// DAEMON2.C
// Simple Mercury/32 Daemon Process.
// Copyright (c) 1997-2008, David Harris, All Rights Reserved.
#define STRICT
#include
<windows.h>
#include
<windowsx.h>
#include
<stdio.h>
#include
<string.h>
#include
<stdlib.h>
#include
"daemon.h"
HINSTANCE hLibInstance;
// set in LibMain, used throughout the DLL
M_INTERFACE *mi;
// Global, used for "convenience macros"
#ifdef
__BORLANDC__
#pragma warn -par
#endif
// __BORLANDC__
DAEMONEXPORT
short daemon (void *job, M_INTERFACE *mi, char *address)
{
mi->logstring (20100, LOG_NORMAL,
"MercuryDaemon invoked");
return 0;
}
DAEMONEXPORT
short startup (M_INTERFACE *m, UINT_32 *flags, char *name, char *param)
{
*flags = 0;
if ((mi = (M_INTERFACE *) malloc (sizeof (M_INTERFACE))) == NULL)
return 0;
memcpy (mi, m,
sizeof (M_INTERFACE));
mi->logstring (20100, LOG_NORMAL,
"MercuryDaemon startup called");
return 1;
}
#ifdef
__VISUALC__
BOOL WINAPI DllMain (HINSTANCE hInst, DWORD reason, LPVOID reserved)
#else
BOOL WINAPI DllEntryPoint (HINSTANCE hInst, DWORD reason, LPVOID reserved)
#endif
{
if (reason == DLL_PROCESS_ATTACH)
{
//MessageBox (NULL, L"Made it into Test Daemon DllMain", L"DllMain", MB_OK);
hLibInstance = hInst;
}
return (TRUE); // Initialization went OK
}
<P>Thanks for the quick replies.</P>
<P>I don't actually use MercuryS to do anything, and as far as I can tell, there is never any activity for MercuryS -- certainly nothing in the status window.&nbsp; Pop3 client feeds email into Mercury from various sources, and the pop3 server gets them to the clients.&nbsp; Outgoing email (from all clients) connects directly to my ISP's SMTP server.&nbsp; I can outline the entire setup if that makes a difference - the short version is that I'm using other pop3 proxies like SpamBayes/SpamPal in front of mercury to spam filter, and using stunnel (to get to gmail) and freepops (to get to hotmail).&nbsp; I also have an imap4 server running so that I can sync a local/remote account.</P>
<P>The daemon I'd like to write will consist of simply examining the headers and adding some new ones -- nothing too complex.&nbsp; My global filter will simply key off the values in the new headers instead of trying to do some complex sorting (as it is now).</P>
<P>My daemon source code is very simple at this point -- pretty much the daemon2 sample from the DDK.&nbsp; The changes are commenting out the MsgBox on dll load, and adding a logging msg on startup.&nbsp; As I said, the "<FONT color=#a31515>MercuryDaemon startup called</FONT>" is logged, but I never see "<FONT color=#a31515>MercuryDaemon invoked</FONT>" as MercuryD is fetching email and core is processing them, including running through the global filter.&nbsp; I've confirmed that the daemon dll is loaded the whole time that Mercury is running as the file is locked.&nbsp; Compiled under VC9.&nbsp; The dll exports look right, and it is calling startup just fine.</P>
<P>Here's the code (comments removed for legibility and looks like the webform&nbsp;killed the tabbing):</P><FONT color=#0000ff size=2><FONT color=#0000ff size=2><FONT color=#008000 size=2><FONT color=#008000 size=2>
<BLOCKQUOTE>
<P>// DAEMON2.C</P>
<P>// Simple Mercury/32 Daemon Process.</P>
<P>// Copyright (c) 1997-2008, David Harris, All Rights Reserved.</P>
<P></FONT></FONT>#define</FONT></FONT><FONT size=2> STRICT</P></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>
<P>#include</FONT></FONT><FONT size=2> </FONT><FONT color=#a31515 size=2><FONT color=#a31515 size=2>&lt;windows.h&gt;</P></FONT></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>
<P>#include</FONT></FONT><FONT size=2> </FONT><FONT color=#a31515 size=2><FONT color=#a31515 size=2>&lt;windowsx.h&gt;</P></FONT></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>
<P>#include</FONT></FONT><FONT size=2> </FONT><FONT color=#a31515 size=2><FONT color=#a31515 size=2>&lt;stdio.h&gt;</P></FONT></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>
<P>#include</FONT></FONT><FONT size=2> </FONT><FONT color=#a31515 size=2><FONT color=#a31515 size=2>&lt;string.h&gt;</P></FONT></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>
<P>#include</FONT></FONT><FONT size=2> </FONT><FONT color=#a31515 size=2><FONT color=#a31515 size=2>&lt;stdlib.h&gt;</P></FONT></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>
<P>#include</FONT></FONT><FONT size=2> </FONT><FONT color=#a31515 size=2><FONT color=#a31515 size=2>"daemon.h"</P></FONT></FONT><FONT size=2>
<P>HINSTANCE hLibInstance; </FONT><FONT color=#008000 size=2><FONT color=#008000 size=2>// set in LibMain, used throughout the DLL</P></FONT></FONT><FONT size=2>
<P>M_INTERFACE *mi; </FONT><FONT color=#008000 size=2><FONT color=#008000 size=2>// Global, used for "convenience macros"</P></FONT></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>
<P>#ifdef</FONT></FONT><FONT size=2> __BORLANDC__</P></FONT><FONT color=#808080 size=2><FONT color=#808080 size=2>
<P>#pragma warn -par</P></FONT></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>
<P>#endif</FONT></FONT><FONT size=2> </FONT><FONT color=#008000 size=2><FONT color=#008000 size=2>// __BORLANDC__</P>
<P mce_keep="true">&nbsp;</P></FONT></FONT><FONT size=2>
<P>DAEMONEXPORT </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>short</FONT></FONT><FONT size=2> daemon (</FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>void</FONT></FONT><FONT size=2> *job, M_INTERFACE *mi, </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>char</FONT></FONT><FONT size=2> *address)</P>
<P>{</P>
<P>mi-&gt;logstring (20100, LOG_NORMAL, </FONT><FONT color=#a31515 size=2><FONT color=#a31515 size=2>"MercuryDaemon invoked"</FONT></FONT><FONT size=2>);</P>
<P></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>return</FONT></FONT><FONT size=2> 0;</P>
<P>}</P>
<P mce_keep="true">&nbsp;</P></FONT><FONT size=2>
<P>DAEMONEXPORT </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>short</FONT></FONT><FONT size=2> startup (M_INTERFACE *m, UINT_32 *flags, </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>char</FONT></FONT><FONT size=2> *name, </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>char</FONT></FONT><FONT size=2> *param)</P>
<P>{</P>
<P>*flags = 0;</P>
<P></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>if</FONT></FONT><FONT size=2> ((mi = (M_INTERFACE *) malloc (</FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>sizeof</FONT></FONT><FONT size=2> (M_INTERFACE))) == NULL)</P>
<P></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>return</FONT></FONT><FONT size=2> 0;</P>
<P>memcpy (mi, m, </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>sizeof</FONT></FONT><FONT size=2> (M_INTERFACE));</P>
<P>mi-&gt;logstring (20100, LOG_NORMAL, </FONT><FONT color=#a31515 size=2><FONT color=#a31515 size=2>"MercuryDaemon startup called"</FONT></FONT><FONT size=2>);</P>
<P></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>return</FONT></FONT><FONT size=2> 1;</P>
<P>}</P>
<P mce_keep="true">&nbsp;</P></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>
<P>#ifdef</FONT></FONT><FONT size=2> __VISUALC__</P>
<P>BOOL WINAPI DllMain (HINSTANCE hInst, DWORD reason, LPVOID reserved)</P></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>
<P>#else</P></FONT></FONT><FONT color=#808080 size=2><FONT color=#808080 size=2>
<P>BOOL WINAPI DllEntryPoint (HINSTANCE hInst, DWORD reason, LPVOID reserved)</P></FONT></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>
<P>#endif</P></FONT></FONT><FONT size=2>
<P>{</P>
<P></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>if</FONT></FONT><FONT size=2> (reason == DLL_PROCESS_ATTACH)</P>
<P>{</P>
<P></FONT><FONT color=#008000></FONT>
<P><FONT color=#008000 size=2><FONT color=#008000 size=2></P></FONT></FONT><FONT size=2></FONT><FONT color=#008000 size=2><FONT color=#008000 size=2>//MessageBox (NULL, L"Made it into Test Daemon DllMain", L"DllMain", MB_OK);</FONT></FONT><FONT size=2>
<P>hLibInstance = hInst;</P>
<P>}</P>
<P></FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>return</FONT></FONT><FONT size=2> (TRUE); </FONT><FONT color=#008000 size=2><FONT color=#008000 size=2>// Initialization went OK</P></FONT></FONT><FONT size=2>
<P>}</P></BLOCKQUOTE></FONT>
<P mce_keep="true">&nbsp;</P>