Mercurial > masqmail
annotate src/parse.c @ 434:f2a7271746d1 default tip
Removes Freshmeat.net from the docs
The site, which was later renamed to freecode.com, is no longer
maintained (contains only a static copy).
author | markus schnalke <meillo@marmaro.de> |
---|---|
date | Sat, 07 Feb 2015 11:45:07 +0100 |
parents | 7c5e51c53f72 |
children |
rev | line source |
---|---|
367
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
1 /* |
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
2 ** MasqMail |
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
3 ** Copyright (C) 1999-2001 Oliver Kurth |
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
4 ** Copyright (C) 2010 markus schnalke <meillo@marmaro.de> |
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
5 ** |
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
6 ** This program is free software; you can redistribute it and/or modify |
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
7 ** it under the terms of the GNU General Public License as published by |
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
8 ** the Free Software Foundation; either version 2 of the License, or |
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
9 ** (at your option) any later version. |
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
10 ** |
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
11 ** This program is distributed in the hope that it will be useful, |
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
12 ** but WITHOUT ANY WARRANTY; without even the implied warranty of |
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
13 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
14 ** GNU General Public License for more details. |
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
15 ** |
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
16 ** You should have received a copy of the GNU General Public License |
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
17 ** along with this program; if not, write to the Free Software |
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
18 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
0 | 19 */ |
20 | |
21 #ifndef PARSE_TEST | |
22 #include "masqmail.h" | |
23 #endif | |
24 | |
367
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
25 /* |
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
26 ** This is really dangerous. I hope that I was careful enough, |
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
27 ** but maybe there is some malformed address possible that causes |
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
28 ** this to segfault or be caught in endless loops. |
0 | 29 |
367
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
30 ** If you find something like that, PLEASE mail the string to me |
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
31 ** (no matter how idiotic it is), so that I can debug that. |
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
32 ** Those things really should not happen. |
0 | 33 */ |
34 | |
35 static gchar *specials = "()<>@,;:\\\".[]`"; | |
36 | |
37 char *parse_error = NULL; | |
38 | |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
39 static gchar* |
366
41958685480d
Switched to `type *name' style
markus schnalke <meillo@marmaro.de>
parents:
274
diff
changeset
|
40 skip_comment(gchar *p) |
0 | 41 { |
42 | |
43 #ifdef PARSE_TEST | |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
44 g_print("skip_comment: %s\n", p); |
0 | 45 #endif |
46 | |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
47 p++; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
48 while (*p && *p != ')') { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
49 p++; |
271
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
50 if (*p == '(') { |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
51 p = skip_comment(p); |
271
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
52 } |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
53 } |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
54 p++; |
0 | 55 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
56 return p; |
0 | 57 } |
58 | |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
59 static gboolean |
366
41958685480d
Switched to `type *name' style
markus schnalke <meillo@marmaro.de>
parents:
274
diff
changeset
|
60 read_word(gchar *p, gchar **b, gchar **e) |
0 | 61 { |
62 #ifdef PARSE_TEST | |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
63 g_print("read_word: %s\n", p); |
0 | 64 #endif |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
65 /* eat leading spaces */ |
271
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
66 while (*p && isspace(*p)) { |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
67 p++; |
271
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
68 } |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
69 |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
70 *b = p; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
71 /* b = &p; */ |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
72 if (*p == '\"') { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
73 /* quoted-string */ |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
74 p++; |
271
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
75 while (*p && (*p != '\"')) { |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
76 p++; |
271
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
77 } |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
78 p++; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
79 } else { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
80 /* atom */ |
271
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
81 while (*p && !strchr(specials, *p) && !iscntrl(*p) && !isspace(*p)) { |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
82 p++; |
271
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
83 } |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
84 } |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
85 *e = p; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
86 return TRUE; |
0 | 87 } |
88 | |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
89 static gboolean |
366
41958685480d
Switched to `type *name' style
markus schnalke <meillo@marmaro.de>
parents:
274
diff
changeset
|
90 read_word_with_dots(gchar *p, gchar **b, gchar **e) |
0 | 91 { |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
92 gchar *b0 = p; |
0 | 93 |
94 #ifdef PARSE_TEST | |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
95 g_print("read_word_with_dots: %s\n", p); |
0 | 96 #endif |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
97 while (TRUE) { |
271
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
98 if (!read_word(p, b, e)) { |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
99 return FALSE; |
271
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
100 } |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
101 p = *e; |
271
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
102 if (*p != '.') { |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
103 break; |
271
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
104 } |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
105 p++; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
106 } |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
107 *b = b0; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
108 *e = p; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
109 return TRUE; |
0 | 110 } |
111 | |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
112 static gboolean |
366
41958685480d
Switched to `type *name' style
markus schnalke <meillo@marmaro.de>
parents:
274
diff
changeset
|
113 read_domain(gchar *p, gchar **b, gchar **e) |
0 | 114 { |
115 #ifdef PARSE_TEST | |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
116 g_print("read_domain: %s\n", p); |
0 | 117 #endif |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
118 *b = p; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
119 if (*p != '[') { |
271
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
120 while (isalnum(*p) || (*p == '-') || (*p == '.')) { |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
121 p++; |
271
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
122 } |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
123 } else { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
124 p++; |
271
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
125 while (isalpha(*p) || (*p == '.')) { |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
126 p++; |
271
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
127 } |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
128 if (*p != ']') { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
129 parse_error = g_strdup_printf("']' expected at end of literal address %s", *b); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
130 return FALSE; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
131 } |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
132 p++; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
133 } |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
134 *e = p; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
135 return TRUE; |
0 | 136 } |
137 | |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
138 gboolean |
367
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
139 parse_address_rfc822(gchar *string, gchar **local_begin, gchar **local_end, |
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
140 gchar **domain_begin, gchar **domain_end, gchar **address_end) |
0 | 141 { |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
142 gint angle_brackets = 0; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
143 |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
144 gchar *p = string; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
145 gchar *b, *e; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
146 |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
147 *local_begin = *local_end = NULL; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
148 *domain_begin = *domain_end = NULL; |
0 | 149 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
150 /* might be some memory left from previous call: */ |
273
00724782b6c9
parse.c: comments, better debugging, tiny refactoring
markus schnalke <meillo@marmaro.de>
parents:
271
diff
changeset
|
151 if (parse_error) { |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
152 g_free(parse_error); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
153 parse_error = NULL; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
154 } |
0 | 155 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
156 /* leading spaces and angle brackets */ |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
157 while (*p && (isspace(*p) || (*p == '<'))) { |
271
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
158 if (*p == '<') { |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
159 angle_brackets++; |
271
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
160 } |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
161 p++; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
162 } |
0 | 163 |
271
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
164 if (!*p) { |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
165 return FALSE; |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
166 } |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
167 |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
168 while (TRUE) { |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
169 if (!read_word_with_dots(p, &b, &e)) { |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
170 return FALSE; |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
171 } |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
172 |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
173 p = e; |
0 | 174 #ifdef PARSE_TEST |
271
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
175 g_print("after read_word_with_dots: %s\n", p); |
0 | 176 #endif |
271
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
177 /* eat white spaces and comments */ |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
178 while ((*p && (isspace(*p))) || (*p == '(')) { |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
179 if (*p == '(') { |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
180 if (!(p = skip_comment(p))) { |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
181 parse_error = g_strdup("missing right bracket ')'"); |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
182 return FALSE; |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
183 } |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
184 } else { |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
185 p++; |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
186 } |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
187 } |
367
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
188 /* |
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
189 ** we now have a non-space char that is not |
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
190 ** the beginning of a comment |
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
191 */ |
271
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
192 |
274
89199eda6144
fixed `To: alice, bob' with -t
markus schnalke <meillo@marmaro.de>
parents:
273
diff
changeset
|
193 if (*p == '@' || *p == ',') { |
271
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
194 /* the last word was the local_part of an addr-spec */ |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
195 *local_begin = b; |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
196 *local_end = e; |
0 | 197 #ifdef PARSE_TEST |
271
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
198 g_print("found local part: %s\n", *local_begin); |
0 | 199 #endif |
271
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
200 if (*p == '@') { |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
201 p++; /* skip @ */ |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
202 /* now the domain */ |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
203 if (!read_domain(p, &b, &e)) { |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
204 return FALSE; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
205 } |
271
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
206 p = e; |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
207 *domain_begin = b; |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
208 *domain_end = e; |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
209 } else { |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
210 /* unqualified? */ |
274
89199eda6144
fixed `To: alice, bob' with -t
markus schnalke <meillo@marmaro.de>
parents:
273
diff
changeset
|
211 /* something like `To: alice, bob' with -t */ |
271
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
212 *domain_begin = *domain_end = NULL; |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
213 } |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
214 break; |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
215 |
271
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
216 } else if (*p == '<') { |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
217 /* addr-spec follows */ |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
218 while (isspace(*p) || (*p == '<')) { |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
219 if (*p == '<') { |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
220 angle_brackets++; |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
221 } |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
222 p++; |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
223 } |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
224 if (!read_word_with_dots(p, &b, &e)) { |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
225 return FALSE; |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
226 } |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
227 p = e; |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
228 *local_begin = b; |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
229 *local_end = e; |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
230 #ifdef PARSE_TEST |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
231 g_print("found local part: %s\n", *local_begin); |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
232 #endif |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
233 if (*p == '@') { |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
234 p++; |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
235 if (!read_domain(p, &b, &e)) { |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
236 return FALSE; |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
237 } |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
238 p = e; |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
239 *domain_begin = b; |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
240 *domain_end = e; |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
241 } else { |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
242 /* may be unqualified address */ |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
243 *domain_begin = *domain_end = NULL; |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
244 } |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
245 break; |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
246 |
271
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
247 } else if (!*p || *p == '>') { |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
248 *local_begin = b; |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
249 *local_end = e; |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
250 #ifdef PARSE_TEST |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
251 g_print("found local part: %s\n", *local_begin); |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
252 #endif |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
253 *domain_begin = *domain_end = NULL; |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
254 break; |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
255 |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
256 } else if (strchr(specials, *p) || iscntrl(*p) || isspace(*p)) { |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
257 parse_error = g_strdup_printf("unexpected character: %c", *p); |
273
00724782b6c9
parse.c: comments, better debugging, tiny refactoring
markus schnalke <meillo@marmaro.de>
parents:
271
diff
changeset
|
258 #ifdef PARSE_TEST |
00724782b6c9
parse.c: comments, better debugging, tiny refactoring
markus schnalke <meillo@marmaro.de>
parents:
271
diff
changeset
|
259 g_print("unexpected character: %c", *p); |
00724782b6c9
parse.c: comments, better debugging, tiny refactoring
markus schnalke <meillo@marmaro.de>
parents:
271
diff
changeset
|
260 #endif |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
261 return FALSE; |
271
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
262 } |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
263 } |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
264 |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
265 /* trailing spaces and angle brackets */ |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
266 #ifdef PARSE_TEST |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
267 g_print("down counting trailing '>'\n"); |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
268 #endif |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
269 while (*p && (isspace(*p) || (*p == '>'))) { |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
270 if (*p == '>') { |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
271 angle_brackets--; |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
272 } |
271
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
273 p++; |
0 | 274 } |
271
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
275 |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
276 *address_end = p; |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
277 |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
278 if (angle_brackets > 0) { |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
279 parse_error = g_strdup("missing '>' at end of string"); |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
280 return FALSE; |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
281 } else if (angle_brackets < 0) { |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
282 parse_error = g_strdup("superfluous '>' at end of string"); |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
283 return FALSE; |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
284 } |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
285 |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
286 /* we successfully parsed the address */ |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
287 return TRUE; |
0 | 288 } |
289 | |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
290 gboolean |
367
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
291 parse_address_rfc821(gchar *string, gchar **local_begin, gchar **local_end, |
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
292 gchar **domain_begin, gchar **domain_end, gchar **address_end) |
0 | 293 { |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
294 gint angle_brackets = 0; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
295 |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
296 gchar *p = string; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
297 gchar *b, *e; |
0 | 298 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
299 *local_begin = *local_end = NULL; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
300 *domain_begin = *domain_end = NULL; |
0 | 301 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
302 /* might be some memory left from previous call: */ |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
303 if (parse_error != NULL) { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
304 g_free(parse_error); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
305 parse_error = NULL; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
306 } |
0 | 307 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
308 /* leading spaces and angle brackets */ |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
309 while (*p && (isspace(*p) || (*p == '<'))) { |
271
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
310 if (*p == '<') { |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
311 angle_brackets++; |
271
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
312 } |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
313 p++; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
314 } |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
315 |
271
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
316 if (!*p) { |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
317 return FALSE; |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
318 } |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
319 |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
320 while (TRUE) { |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
321 if (!read_word_with_dots(p, &b, &e)) { |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
322 return FALSE; |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
323 } |
0 | 324 |
271
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
325 p = e; |
0 | 326 #ifdef PARSE_TEST |
271
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
327 g_print("after read_word_with_dots: %s\n", p); |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
328 #endif |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
329 *local_begin = b; |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
330 *local_end = e; |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
331 #ifdef PARSE_TEST |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
332 g_print("found local part: %s\n", *local_begin); |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
333 g_print("local_end = %s\n", *local_end); |
0 | 334 #endif |
271
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
335 if (!(*p) || isspace(*p) || (*p == '>')) { |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
336 /* unqualified ? */ |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
337 domain_begin = domain_end = NULL; |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
338 break; |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
339 } else if (*p == '@') { |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
340 p++; |
271
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
341 if (read_domain(p, &b, &e)) { |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
342 p = e; |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
343 *domain_begin = b; |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
344 *domain_end = e; |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
345 } |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
346 break; |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
347 } else { |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
348 parse_error = g_strdup_printf ("unexpected character after local part '%c'", *p); |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
349 return FALSE; |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
350 } |
271
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
351 } |
0 | 352 |
271
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
353 /* trailing spaces and angle brackets */ |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
354 #ifdef PARSE_TEST |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
355 g_print("down counting trailing '>'\n"); |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
356 #endif |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
357 while (*p && (isspace(*p) || (*p == '>'))) { |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
358 if (*p == '>') { |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
359 angle_brackets--; |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
360 } |
271
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
361 p++; |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
362 } |
271
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
363 *address_end = p; |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
364 |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
365 if (angle_brackets > 0) { |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
366 parse_error = g_strdup("missing '>' at end of string"); |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
367 return FALSE; |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
368 } else if (angle_brackets < 0) { |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
369 parse_error = g_strdup("superfluous '>' at end of string"); |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
370 return FALSE; |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
371 } |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
372 |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
373 /* we successfully parsed the address */ |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
374 return TRUE; |
0 | 375 } |
376 | |
377 /* | |
367
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
378 ** allocate address, reading from string. |
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
379 ** On failure, returns NULL. |
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
380 ** after call, end contains a pointer to the end of the parsed string |
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
381 ** end may be NULL, if we are not interested. |
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
382 ** |
b27f66555ba8
Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents:
366
diff
changeset
|
383 ** parses both rfc 821 and rfc 822 addresses, depending on flag is_rfc821 |
0 | 384 */ |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
385 address* |
366
41958685480d
Switched to `type *name' style
markus schnalke <meillo@marmaro.de>
parents:
274
diff
changeset
|
386 _create_address(gchar *string, gchar **end, gboolean is_rfc821) |
0 | 387 { |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
388 gchar *loc_beg, *loc_end; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
389 gchar *dom_beg, *dom_end; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
390 gchar *addr_end; |
271
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
391 gboolean ret; |
0 | 392 |
413
7c5e51c53f72
Finally found the newline that was to much in spool_read_header().
markus schnalke <meillo@marmaro.de>
parents:
410
diff
changeset
|
393 if (!string) { |
7c5e51c53f72
Finally found the newline that was to much in spool_read_header().
markus schnalke <meillo@marmaro.de>
parents:
410
diff
changeset
|
394 return NULL; |
7c5e51c53f72
Finally found the newline that was to much in spool_read_header().
markus schnalke <meillo@marmaro.de>
parents:
410
diff
changeset
|
395 } |
7c5e51c53f72
Finally found the newline that was to much in spool_read_header().
markus schnalke <meillo@marmaro.de>
parents:
410
diff
changeset
|
396 while (isspace(*string)) { |
7c5e51c53f72
Finally found the newline that was to much in spool_read_header().
markus schnalke <meillo@marmaro.de>
parents:
410
diff
changeset
|
397 string++; |
7c5e51c53f72
Finally found the newline that was to much in spool_read_header().
markus schnalke <meillo@marmaro.de>
parents:
410
diff
changeset
|
398 } |
273
00724782b6c9
parse.c: comments, better debugging, tiny refactoring
markus schnalke <meillo@marmaro.de>
parents:
271
diff
changeset
|
399 /* TODO: what about (string == NULL)? */ |
271
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
400 if (string && (string[0] == '\0')) { |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
401 address *addr = g_malloc(sizeof(address)); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
402 addr->address = g_strdup(""); |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
403 addr->local_part = g_strdup(""); |
410 | 404 /* |
405 ** 'NULL' address: failure notice | |
406 ** "": will *not* be qualified with a hostname | |
407 */ | |
271
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
408 addr->domain = g_strdup(""); |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
409 return addr; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
410 } |
0 | 411 |
271
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
412 if (is_rfc821) { |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
413 ret = parse_address_rfc821(string, &loc_beg, &loc_end, &dom_beg, &dom_end, &addr_end); |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
414 } else { |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
415 ret = parse_address_rfc822(string, &loc_beg, &loc_end, &dom_beg, &dom_end, &addr_end); |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
416 } |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
417 if (!ret) { |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
418 return NULL; |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
419 } |
413
7c5e51c53f72
Finally found the newline that was to much in spool_read_header().
markus schnalke <meillo@marmaro.de>
parents:
410
diff
changeset
|
420 if (*loc_beg == '|') { |
271
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
421 parse_error = g_strdup("no pipe allowed for RFC 822/821 address"); |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
422 return NULL; |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
423 } |
0 | 424 |
413
7c5e51c53f72
Finally found the newline that was to much in spool_read_header().
markus schnalke <meillo@marmaro.de>
parents:
410
diff
changeset
|
425 address *addr = g_malloc(sizeof(address)); |
7c5e51c53f72
Finally found the newline that was to much in spool_read_header().
markus schnalke <meillo@marmaro.de>
parents:
410
diff
changeset
|
426 memset(addr, 0, sizeof(address)); |
7c5e51c53f72
Finally found the newline that was to much in spool_read_header().
markus schnalke <meillo@marmaro.de>
parents:
410
diff
changeset
|
427 |
7c5e51c53f72
Finally found the newline that was to much in spool_read_header().
markus schnalke <meillo@marmaro.de>
parents:
410
diff
changeset
|
428 gchar *p = addr_end; |
271
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
429 while (*p && (*p != ',')) { |
413
7c5e51c53f72
Finally found the newline that was to much in spool_read_header().
markus schnalke <meillo@marmaro.de>
parents:
410
diff
changeset
|
430 /* it seems as if we do this for the code in rewrite.c */ |
271
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
431 p++; |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
432 } |
413
7c5e51c53f72
Finally found the newline that was to much in spool_read_header().
markus schnalke <meillo@marmaro.de>
parents:
410
diff
changeset
|
433 addr->address = g_strstrip(g_strndup(string, p - string)); |
271
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
434 addr->local_part = g_strndup(loc_beg, loc_end - loc_beg); |
0 | 435 |
436 #ifdef PARSE_TEST | |
271
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
437 g_print("addr->local_part = %s\n", addr->local_part); |
0 | 438 #endif |
439 | |
271
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
440 if (dom_beg != NULL) { |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
441 addr->domain = g_strndup(dom_beg, dom_end - dom_beg); |
273
00724782b6c9
parse.c: comments, better debugging, tiny refactoring
markus schnalke <meillo@marmaro.de>
parents:
271
diff
changeset
|
442 } else if (addr->local_part[0] == '\0') { |
410 | 443 /* |
444 ** 'NULL' address: failure notice | |
445 ** "": will *not* be qualified with a hostname | |
446 */ | |
271
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
447 addr->domain = g_strdup(""); |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
448 } else { |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
449 addr->domain = NULL; |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
450 } |
0 | 451 |
273
00724782b6c9
parse.c: comments, better debugging, tiny refactoring
markus schnalke <meillo@marmaro.de>
parents:
271
diff
changeset
|
452 if (end) { |
271
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
453 *end = p; |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
454 } |
0 | 455 |
413
7c5e51c53f72
Finally found the newline that was to much in spool_read_header().
markus schnalke <meillo@marmaro.de>
parents:
410
diff
changeset
|
456 DEBUG(6) debugf("_create_address(): address: `%s'\n", addr->address); |
7c5e51c53f72
Finally found the newline that was to much in spool_read_header().
markus schnalke <meillo@marmaro.de>
parents:
410
diff
changeset
|
457 DEBUG(6) debugf("_create_address(): local_part: `%s'\n", addr->local_part); |
7c5e51c53f72
Finally found the newline that was to much in spool_read_header().
markus schnalke <meillo@marmaro.de>
parents:
410
diff
changeset
|
458 DEBUG(6) debugf("_create_address(): domain: `%s'\n", addr->domain); |
7c5e51c53f72
Finally found the newline that was to much in spool_read_header().
markus schnalke <meillo@marmaro.de>
parents:
410
diff
changeset
|
459 |
0 | 460 #ifndef PARSE_TEST |
271
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
461 addr_unmark_delivered(addr); |
0 | 462 #endif |
463 | |
271
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
464 return addr; |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
465 } |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
466 |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
467 address* |
366
41958685480d
Switched to `type *name' style
markus schnalke <meillo@marmaro.de>
parents:
274
diff
changeset
|
468 create_address_rfc822(gchar *string, gchar **end) |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
469 { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
470 return _create_address(string, end, FALSE); |
0 | 471 } |
472 | |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
473 address* |
366
41958685480d
Switched to `type *name' style
markus schnalke <meillo@marmaro.de>
parents:
274
diff
changeset
|
474 create_address_rfc821(gchar *string, gchar **end) |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
475 { |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
476 return _create_address(string, end, TRUE); |
0 | 477 } |
478 | |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
479 GList* |
366
41958685480d
Switched to `type *name' style
markus schnalke <meillo@marmaro.de>
parents:
274
diff
changeset
|
480 addr_list_append_rfc822(GList *addr_list, gchar *string, gchar *domain) |
0 | 481 { |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
482 gchar *p = string; |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
483 gchar *end; |
0 | 484 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
485 while (*p) { |
273
00724782b6c9
parse.c: comments, better debugging, tiny refactoring
markus schnalke <meillo@marmaro.de>
parents:
271
diff
changeset
|
486 #ifdef PARSE_TEST |
00724782b6c9
parse.c: comments, better debugging, tiny refactoring
markus schnalke <meillo@marmaro.de>
parents:
271
diff
changeset
|
487 g_print("string: %s\n", p); |
00724782b6c9
parse.c: comments, better debugging, tiny refactoring
markus schnalke <meillo@marmaro.de>
parents:
271
diff
changeset
|
488 #endif |
00724782b6c9
parse.c: comments, better debugging, tiny refactoring
markus schnalke <meillo@marmaro.de>
parents:
271
diff
changeset
|
489 |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
490 address *addr = _create_address(p, &end, FALSE); |
271
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
491 if (!addr) { |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
492 break; |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
493 } |
0 | 494 |
273
00724782b6c9
parse.c: comments, better debugging, tiny refactoring
markus schnalke <meillo@marmaro.de>
parents:
271
diff
changeset
|
495 #ifdef PARSE_TEST |
00724782b6c9
parse.c: comments, better debugging, tiny refactoring
markus schnalke <meillo@marmaro.de>
parents:
271
diff
changeset
|
496 g_print("addr: %s (%s<@>%s)", addr->address, addr->local_part, addr->domain); |
00724782b6c9
parse.c: comments, better debugging, tiny refactoring
markus schnalke <meillo@marmaro.de>
parents:
271
diff
changeset
|
497 #endif |
271
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
498 if (domain && !addr->domain) { |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
499 addr->domain = g_strdup(domain); |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
500 } |
273
00724782b6c9
parse.c: comments, better debugging, tiny refactoring
markus schnalke <meillo@marmaro.de>
parents:
271
diff
changeset
|
501 #ifdef PARSE_TEST |
00724782b6c9
parse.c: comments, better debugging, tiny refactoring
markus schnalke <meillo@marmaro.de>
parents:
271
diff
changeset
|
502 g_print(" (%s<@>%s)\n", addr->local_part, addr->domain); |
00724782b6c9
parse.c: comments, better debugging, tiny refactoring
markus schnalke <meillo@marmaro.de>
parents:
271
diff
changeset
|
503 #endif |
271
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
504 |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
505 addr_list = g_list_append(addr_list, addr); |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
506 p = end; |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
507 |
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
508 while (*p == ',' || isspace(*p)) { |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
509 p++; |
271
899175e8dff0
heavy refactoring in the small of parse.c
markus schnalke <meillo@marmaro.de>
parents:
114
diff
changeset
|
510 } |
10
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
511 } |
26e34ae9a3e3
changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents:
0
diff
changeset
|
512 return addr_list; |
0 | 513 } |