annotate src/parse.c @ 337:fe00f7952a7c

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