"SfR Fresh" - the SfR Freeware/Shareware Archive 
Member "tulp-4.2.1/src/ad.c" of archive tulp-4.2.1.tar.gz:
As a special service "SfR Fresh" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting with prefixed line numbers.
Alternatively you can here view or download the uninterpreted source code file.
That can be also achieved for any archive member file by clicking within an archive contents listing on the first character of the file(path) respectively on the according byte size field.
1 /*
2 * TULP - Unix Mailing List manager
3 * (sub-set of FRECP's Bitnet Listserv tool)
4 *
5 * Copyright (C) 1991-2000 Kimmo Suominen, Christophe Wolfhugel
6 *
7 * Please read the files COPYRIGHT and AUTHORS for the extended
8 * copyrights refering to this file.
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 1, or (at your option)
13 * any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 */
24
25 #include <stdio.h>
26 #include <string.h>
27 #include "conf.h"
28 #include "ext.h"
29
30 RCSID("@(#)ad.c,v 1.5 2000/03/07 22:16:29 kim Exp")
31
32 static char *adrs, *name;
33 static char line[3][MAXLINE];
34
35 void adChange(char *s)
36 {
37 int state, i, j, quote = 0, parlvl = 0;
38 char *lns[3], *save = s;
39
40 state = 0;
41 memset(line[0], 0, sizeof(line));
42 lns[0] = line[0];
43 lns[1] = line[1];
44 lns[2] = line[2];
45 while (*s != 0) {
46 if (*s == '"')
47 quote = 1 - quote;
48 if (quote == 1) {
49 *lns[state]++ = *s;
50 s++;
51 continue;
52 }
53 switch (*s) {
54 case '<':
55 state = 1;
56 break;
57 case '(':
58 parlvl++;
59 state = 2;
60 if (parlvl > 1)
61 *lns[state]++ = '(';
62 break;
63 case '>':
64 state = 0;
65 break;
66 case ')':
67 if (--parlvl) {
68 *lns[state]++ = ')';
69 break;
70 }
71 state = 0;
72 break;
73 default:
74 *lns[state]++ = *s;
75 }
76 s++;
77 }
78 lns[0] = line[0];
79 lns[1] = line[1];
80 lns[2] = line[2];
81 for (i = 0; i < 2; i++) {
82 while (*lns[i] == ' ')
83 lns[i]++;
84 j = strlen(lns[i]);
85 while (j > 0 && lns[i][j - 1] == ' ')
86 lns[i][--j] = 0;
87 }
88 if (lns[1][0] != 0) { /* Adress between <> */
89 adrs = lns[1];
90 name = lns[0];
91 } else {
92 adrs = lns[0];
93 name = lns[2];
94 }
95 if (strchr(adrs, '@') == NULL && strchr(adrs, '!') == NULL) {
96 strcat(adrs, "@");
97 strcat(adrs, HOST);
98 }
99 if (*name != 0)
100 sprintf(save, "%s (%s)", adrs, name);
101 else
102 strcpy(save, adrs);
103 }