1 /*
2  *	(c) Copyright 1990, Kim Fabricius Storm.  All rights reserved.
3  *      Copyright (c) 1996-2005 Michael T Pins.  All rights reserved.
4  *
5  *	Reply address rewriting.
6  */
7 
8 #include <string.h>
9 #include <ctype.h>
10 #include "config.h"
11 #include "global.h"
12 
13 
14 int
reroute(char * route,char * address)15 reroute(char *route, char *address)
16 {
17     char           *name, *atpos;
18     register char  *sp;
19     register int    c;
20 
21     if ((atpos = strchr(address, '@'))) {
22 	name = atpos;
23 
24 	while (--name >= address)
25 	    if (isspace(*name) || *name == '<') {
26 		name++;
27 		break;
28 	    }
29 	if (name < address)
30 	    name++;
31 
32 	for (sp = atpos; (c = *sp); sp++)
33 	    if (isspace(c) || c == '>')
34 		break;
35 
36 	*sp = NUL;
37 	strcpy(route, name);
38 	*sp = c;
39     } else
40 	strcpy(route, address);
41     return 1;
42 }
43