SamplePlugin plug-in performs several operations:
Message recipients into itNOTE: If you would like to see this plug-in in action, save and build the code in "Plug- in Code." If you prefer, you can download a zip file,This list summarizes the plug-in operations. Each operation links to the line in the DLL that performs it.msplugin.zip, that contains the sample plug-in file,sample.c, and the makefile for building the sample. §
msg4plugins.h header file and the standard input/output and allocation header files.
#include <stdio.h>If you do not have the Messaging Server plug-in header file yet, see "Where to Find the Messaging Server Plug-in File."
#include <malloc.h>
#include <string.h>
#include "msg4plugins.h"
SAMPLE_EXPORT int SamplePluginInit(pblock *Config)
{
return 1;
}
SamplePlugin, loads the parameter block pointed to by the Config parameter and creates pointers to the input (InMessage) and output (OutMessage) messages. The output parameter represents the result of the execution of the plug-in code. This is one of the two function prototypes that the plug-in must export in order to load.
SAMPLE_EXPORT int SamplePlugin(pblock *Config,The plug-in code returns either
Message **ppInMsg,
Message ***pppOutMsg)
MSG_CONTINUE or MSG_NOACTION to Messaging Server. MSG_CONTINUE indicates that the plug-in worked; message can go on to Messaging Server for further processing. MSG_NOACTION indicates that the plug-in did not do anything.
For information about defining this function, see "Writing the Plug-in Function."
{
char *bodyfile;
Recipient *pRecip;
Recipient new_rcpt;
FILE *f;
FILE *body;
char *ControlText;
f = fopen ("log.out","w");
GetFirstRecipient. The fprintf routine calls GetRecipientAddress to get the address for printing.
pRecip = GetFirstRecipient (ppInMsg[0]);
if (pRecip) {
fprintf (f,"Recip #1 is %s\n",GetRecipientAddress(pRecip));
}
ControlText = GetControlData(ppInMsg[0]);
if (ControlText) {
fprintf(f, "Control Data follows\n%s", ControlText);
}
FreeControlData(ControlText);
new_rcpt.Addr821 = (char*)malloc (strlen ("<testuser@test.com>") + 1);
strcpy(new_rcpt.Addr821, "<testuser@test.com>");
new_rcpt.Ext = NULL;
new_rcpt.flags = 0;
This is the tricky part - you must set this magic value.
new_rcpt.magic = 0xdeadbeef;Make the AddRecipient call.
AddRecipient(ppInMsg[0], &new_rcpt);
free (new_rcpt.Addr821);For more information, see "Add and remove recipients."
bodyfile = GetMessageFile (*ppInMsg);Then it opens the message body and adds text to the end:
fprintf (f,"GetMessageFile = %s\n", bodyfile);
body = fopen (bodyfile,"a");
if (body == NULL)
{
fprintf (f,"Couldn't append to body\n");
}
else{fprintf (body,"This is a new body line\n");
fprintf (body,"This is a new body line\n");
fprintf (body,"This is a new body line\n");
fprintf (body,"This is a new body line\n");
fprintf (body,"This is a new body line\n");
fprintf (body,"This is a new body line\n");
fprintf (body,"This is a new body line\n");
fprintf (body,"This is a new body line\n");
fprintf (body,"This is a new body line\n");
fprintf (body,"This is a new body line\n");
fclose (body);
}
MSG_CONTINUE, the message continues on its way. For other return messages, see "Result Codes."
return MSG_CONTINUE;
NOTE: You can find the code for this plug-in in "Plug-in Code." For information about building the plug-in, see "Building the Plug-in." §[Top]
Last Updated: 11/19/98 10:24:12
[an error occurred while processing this directive]