File: reroute.c

package info (click to toggle)
nn 6.7.3-8
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd, wheezy
  • size: 2,508 kB
  • ctags: 3,199
  • sloc: ansic: 32,035; sh: 1,491; awk: 138; makefile: 98
file content (42 lines) | stat: -rw-r--r-- 743 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/*
 *	(c) Copyright 1990, Kim Fabricius Storm.  All rights reserved.
 *      Copyright (c) 1996-2005 Michael T Pins.  All rights reserved.
 *
 *	Reply address rewriting.
 */

#include <string.h>
#include <ctype.h>
#include "config.h"
#include "global.h"


int
reroute(char *route, char *address)
{
    char           *name, *atpos;
    register char  *sp;
    register int    c;

    if ((atpos = strchr(address, '@'))) {
	name = atpos;

	while (--name >= address)
	    if (isspace(*name) || *name == '<') {
		name++;
		break;
	    }
	if (name < address)
	    name++;

	for (sp = atpos; (c = *sp); sp++)
	    if (isspace(c) || c == '>')
		break;

	*sp = NUL;
	strcpy(route, name);
	*sp = c;
    } else
	strcpy(route, address);
    return 1;
}