static char rcsid[] = "@(#)$Id: mkhdrs.c,v 1.27 2006/04/09 07:37:18 hurtta Exp $";
/******************************************************************************
* The Elm (ME+) Mail System - $Revision: 1.27 $ $State: Exp $
*
* Modified by: Kari Hurtta <hurtta+elm@posti.FMI.FI>
* (was hurtta+elm@ozone.FMI.FI)
******************************************************************************
* The Elm Mail System
*
* Copyright (c) 1988-1992 USENET Community Trust
* Copyright (c) 1986,1987 Dave Taylor
*****************************************************************************/
/** This contains the header generating routines for the ELM
program.
**/
#include "def_elm.h"
#include "s_elm.h"
#include <errno.h>
#ifndef ANSI_C
extern int errno;
#endif
#if 0
DEBUG_VAR(Debug,__FILE__,"header");
#endif
static unsigned char *s2us P_((char *str));
static unsigned char *s2us(str)
char *str;
{
return (unsigned char *)str;
}
void generate_reply_to(current_header,headers)
struct header_rec * current_header;
struct mailing_headers *headers;
{
/** Generate an 'in-reply-to' message... **/
char date_buf[SLEN];
int found = 0;
free_id_phrase(&(headers->in_reply_to));
if (add_irt_phrase) {
headers->in_reply_to.text = new_string(display_charset);
if (current_header->messageid) {
headers->in_reply_to.id = safe_strdup(current_header->messageid);
add_ascii_to_string(headers->in_reply_to.text,s2us(" from "));
} else
add_ascii_to_string(headers->in_reply_to.text,s2us("From "));
if (current_header) {
struct addr_item *p;
for (p = current_header->from; p && p->addr && p->fullname; p++) {
if (found)
add_ascii_to_string(headers->in_reply_to.text,s2us(", "));
found++;
if (string_len(p->fullname)) {
struct string * tmp =
cat_strings(headers->in_reply_to.text,
p->fullname,1);
free_string(&(headers->in_reply_to.text));
headers->in_reply_to.text = tmp;
}
else
add_ascii_to_string(headers->in_reply_to.text,
s2us(p->addr));
}
if (!found && current_header->env_from[0]) {
add_ascii_to_string(headers->in_reply_to.text,s2us("(env: "));
add_ascii_to_string(headers->in_reply_to.text,
s2us(current_header->env_from));
add_ascii_to_string(headers->in_reply_to.text,s2us(")"));
} else if (!found)
add_ascii_to_string(headers->in_reply_to.text,s2us("someone"));
add_ascii_to_string(headers->in_reply_to.text,s2us(" at "));
add_ascii_to_string(headers->in_reply_to.text,
s2us(elm_date_str(date_buf,
current_header->time_sent +
current_header->tz_offset,
sizeof date_buf)));
}
} else if (current_header->messageid) {
/* RFC 2822 (obsoletes RFC 822) says that in-reply-to
header should only include message-id
*/
headers->in_reply_to.id = safe_strdup(current_header->messageid);
}
}
/*
* Local Variables:
* mode:c
* c-basic-offset:4
* buffer-file-coding-system: iso-8859-1
* End:
*/
syntax highlighted by Code2HTML, v. 0.9.1