> Hi Clive,
>
> thanks for your answer.
> Do you have a simple example I can modify and/or spec. hints to docs in
> the
> internet ?
>
> Thanks,
>
> Rainer.
>
As an exercise for myself (just to prove that I could) I have written
a basic local_scan() function that does what you require. It is basic,
may not be robust, lacks some error checking and probably misbehaves
in certain circumstances. But if you wish to use it you may. Built on
FreeBSD, Exim 4.10. Code follows after sig.
Clive Goodhead
/*********************************************************************
* An exim local_scan() function to add a date and time stamp to the *
* subject lines of emails. *
**********************************************************************
Copyright (c) 2002 Clive Goodhead.
This 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.
It 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.
*********************************************************************/
#include <string.h>
#include <time.h>
#include "local_scan.h"
int
local_scan(int fd, uschar **return_text) {
header_line *msg_header;
uschar *subject_header = "";
time_t now;
struct tm *date_time;
char str[25];
uschar *new_subject = "";
fd = fd; /* Keep picky compilers happy */
return_text = return_text;
/* Read existing subject header and remove it. */
msg_header = header_list;
while (msg_header != NULL)
{
if (strstr(CS msg_header->text, "Subject:") != NULL)
{
subject_header = msg_header->text;
/* Remove "Subject: " from . */
subject_header = subject_header+8;
if (subject_header[0] == ' ') subject_header++;
msg_header->type = '*';
}
msg_header = msg_header->next;
};
/* Get the date/time information and format it. */
now = time( NULL );
date_time = localtime( &now );
strftime( str, sizeof(str)-1, "%d %b %Y, %H:%M:%S", date_time );
/* Build new subject header and add it to the message. */
new_subject
= string_sprintf("Subject: [%s] %s", CS str, subject_header);
header_add(' ', new_subject);
return LOCAL_SCAN_ACCEPT;
}
/*********************************************************************
* End of local_scan.c. *
*********************************************************************/