annotate src/address.c @ 391:0ca270ca11fa

Refactoring and code layouting.
author markus schnalke <meillo@marmaro.de>
date Sat, 18 Feb 2012 17:53:04 +0100
parents bc9a7845b53a
children 9b93c0a3bd8c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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 **
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
5 ** 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
6 ** 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
7 ** 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
8 ** (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
9 **
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
10 ** 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
11 ** 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
12 ** 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
13 ** 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
14 **
b27f66555ba8 Reformated multiline comments to have leading asterisks on each line
markus schnalke <meillo@marmaro.de>
parents: 366
diff changeset
15 ** 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
16 ** 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
17 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
0
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 #include "masqmail.h"
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
21
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
22 address*
366
41958685480d Switched to `type *name' style
markus schnalke <meillo@marmaro.de>
parents: 317
diff changeset
23 create_address(gchar *path, gboolean is_rfc821)
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
24 {
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
25 address *addr;
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
26 addr = _create_address(path, NULL, is_rfc821);
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
27
389
bc9a7845b53a Refactoring and code layouting.
markus schnalke <meillo@marmaro.de>
parents: 367
diff changeset
28 if (addr) {
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
29 addr_unmark_delivered(addr);
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
30 }
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
31 return addr;
0
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
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
34 address*
366
41958685480d Switched to `type *name' style
markus schnalke <meillo@marmaro.de>
parents: 317
diff changeset
35 create_address_qualified(gchar *path, gboolean is_rfc821, gchar *domain)
0
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 address *addr = create_address(path, is_rfc821);
23
4a3bc3a7afbe refactoring: early exit instead of deep if levels
meillo@marmaro.de
parents: 14
diff changeset
38
389
bc9a7845b53a Refactoring and code layouting.
markus schnalke <meillo@marmaro.de>
parents: 367
diff changeset
39 if (addr && !addr->domain) {
bc9a7845b53a Refactoring and code layouting.
markus schnalke <meillo@marmaro.de>
parents: 367
diff changeset
40 addr->domain = g_strdup(domain);
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
41 }
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
42 return addr;
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
43 }
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
44
13
49dab67fe461 code beautifying
meillo@marmaro.de
parents: 10
diff changeset
45 /* nothing special about pipes here, but its only called for that purpose */
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
46 address*
366
41958685480d Switched to `type *name' style
markus schnalke <meillo@marmaro.de>
parents: 317
diff changeset
47 create_address_pipe(gchar *path)
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
48 {
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
49 address *addr = g_malloc(sizeof(address));
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
50
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
51 if (addr) {
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
52 memset(addr, 0, sizeof(address));
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
53 addr->address = g_strchomp(g_strdup(path));
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
54 addr->local_part = g_strdup(addr->address);
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
55 addr->domain = g_strdup("localhost"); /* quick hack */
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
56 }
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
57 return addr;
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
58 }
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
59
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
60 void
366
41958685480d Switched to `type *name' style
markus schnalke <meillo@marmaro.de>
parents: 317
diff changeset
61 destroy_address(address *addr)
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
62 {
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
63 DEBUG(6) debugf("destroy_address entered\n");
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
64 g_free(addr->address);
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
65 g_free(addr->local_part);
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
66 g_free(addr->domain);
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
67 g_free(addr);
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
68 }
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
69
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
70 address*
366
41958685480d Switched to `type *name' style
markus schnalke <meillo@marmaro.de>
parents: 317
diff changeset
71 copy_modify_address(const address *orig, gchar *l_part, gchar *dom)
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
72 {
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
73 address *addr = NULL;
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
74
23
4a3bc3a7afbe refactoring: early exit instead of deep if levels
meillo@marmaro.de
parents: 14
diff changeset
75 if (!orig) {
4a3bc3a7afbe refactoring: early exit instead of deep if levels
meillo@marmaro.de
parents: 14
diff changeset
76 return NULL;
4a3bc3a7afbe refactoring: early exit instead of deep if levels
meillo@marmaro.de
parents: 14
diff changeset
77 }
389
bc9a7845b53a Refactoring and code layouting.
markus schnalke <meillo@marmaro.de>
parents: 367
diff changeset
78 if (!(addr = g_malloc(sizeof(address)))) {
23
4a3bc3a7afbe refactoring: early exit instead of deep if levels
meillo@marmaro.de
parents: 14
diff changeset
79 return NULL;
4a3bc3a7afbe refactoring: early exit instead of deep if levels
meillo@marmaro.de
parents: 14
diff changeset
80 }
4a3bc3a7afbe refactoring: early exit instead of deep if levels
meillo@marmaro.de
parents: 14
diff changeset
81 addr->address = g_strdup(orig->address);
389
bc9a7845b53a Refactoring and code layouting.
markus schnalke <meillo@marmaro.de>
parents: 367
diff changeset
82 addr->local_part = l_part ? g_strdup(l_part) :
bc9a7845b53a Refactoring and code layouting.
markus schnalke <meillo@marmaro.de>
parents: 367
diff changeset
83 g_strdup(orig->local_part);
bc9a7845b53a Refactoring and code layouting.
markus schnalke <meillo@marmaro.de>
parents: 367
diff changeset
84 addr->domain = dom ? g_strdup(dom) : g_strdup(orig->domain);
23
4a3bc3a7afbe refactoring: early exit instead of deep if levels
meillo@marmaro.de
parents: 14
diff changeset
85 addr->flags = 0;
4a3bc3a7afbe refactoring: early exit instead of deep if levels
meillo@marmaro.de
parents: 14
diff changeset
86 addr->children = NULL;
4a3bc3a7afbe refactoring: early exit instead of deep if levels
meillo@marmaro.de
parents: 14
diff changeset
87 addr->parent = NULL;
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
88 return addr;
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
89 }
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
90
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
91 gboolean
389
bc9a7845b53a Refactoring and code layouting.
markus schnalke <meillo@marmaro.de>
parents: 367
diff changeset
92 addr_isequal(address *addr1, address *addr2,
bc9a7845b53a Refactoring and code layouting.
markus schnalke <meillo@marmaro.de>
parents: 367
diff changeset
93 int (*cmpfunc) (const char*, const char*))
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
94 {
389
bc9a7845b53a Refactoring and code layouting.
markus schnalke <meillo@marmaro.de>
parents: 367
diff changeset
95 return (cmpfunc(addr1->local_part, addr2->local_part)==0) &&
bc9a7845b53a Refactoring and code layouting.
markus schnalke <meillo@marmaro.de>
parents: 367
diff changeset
96 (strcasecmp(addr1->domain, addr2->domain)==0);
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
97 }
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
98
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
99 /* searches in ancestors of addr1 */
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
100 gboolean
389
bc9a7845b53a Refactoring and code layouting.
markus schnalke <meillo@marmaro.de>
parents: 367
diff changeset
101 addr_isequal_parent(address *addr1, address *addr2,
bc9a7845b53a Refactoring and code layouting.
markus schnalke <meillo@marmaro.de>
parents: 367
diff changeset
102 int (*cmpfunc) (const char*, const char*))
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
103 {
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
104 address *addr;
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
105
389
bc9a7845b53a Refactoring and code layouting.
markus schnalke <meillo@marmaro.de>
parents: 367
diff changeset
106 for (addr = addr1; addr; addr = addr->parent) {
bc9a7845b53a Refactoring and code layouting.
markus schnalke <meillo@marmaro.de>
parents: 367
diff changeset
107 if (addr_isequal(addr, addr2, cmpfunc)) {
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
108 return TRUE;
389
bc9a7845b53a Refactoring and code layouting.
markus schnalke <meillo@marmaro.de>
parents: 367
diff changeset
109 }
bc9a7845b53a Refactoring and code layouting.
markus schnalke <meillo@marmaro.de>
parents: 367
diff changeset
110 }
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
111 return FALSE;
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
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
114 /* careful, this is recursive */
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
115 /* returns TRUE if ALL children have been delivered */
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
116 gboolean
366
41958685480d Switched to `type *name' style
markus schnalke <meillo@marmaro.de>
parents: 317
diff changeset
117 addr_is_delivered_children(address *addr)
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
118 {
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
119 GList *addr_node;
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
120
389
bc9a7845b53a Refactoring and code layouting.
markus schnalke <meillo@marmaro.de>
parents: 367
diff changeset
121 if (!addr->children) {
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
122 return addr_is_delivered(addr);
389
bc9a7845b53a Refactoring and code layouting.
markus schnalke <meillo@marmaro.de>
parents: 367
diff changeset
123 }
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
124 foreach(addr->children, addr_node) {
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
125 address *addr = (address *) (addr_node->data);
389
bc9a7845b53a Refactoring and code layouting.
markus schnalke <meillo@marmaro.de>
parents: 367
diff changeset
126 if (!addr_is_delivered_children(addr)) {
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
127 return FALSE;
389
bc9a7845b53a Refactoring and code layouting.
markus schnalke <meillo@marmaro.de>
parents: 367
diff changeset
128 }
10
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 return TRUE;
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
131 }
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
132
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
133 /* careful, this is recursive */
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
134 /* returns TRUE if ALL children have been either delivered or have failed */
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
135 gboolean
366
41958685480d Switched to `type *name' style
markus schnalke <meillo@marmaro.de>
parents: 317
diff changeset
136 addr_is_finished_children(address *addr)
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
137 {
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
138 GList *addr_node;
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
139
389
bc9a7845b53a Refactoring and code layouting.
markus schnalke <meillo@marmaro.de>
parents: 367
diff changeset
140 if (!addr->children) {
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
141 return (addr_is_failed(addr) || addr_is_delivered(addr));
389
bc9a7845b53a Refactoring and code layouting.
markus schnalke <meillo@marmaro.de>
parents: 367
diff changeset
142 }
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
143 foreach(addr->children, addr_node) {
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
144 address *addr = (address *) (addr_node->data);
389
bc9a7845b53a Refactoring and code layouting.
markus schnalke <meillo@marmaro.de>
parents: 367
diff changeset
145 if (!addr_is_finished_children(addr)) {
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
146 return FALSE;
389
bc9a7845b53a Refactoring and code layouting.
markus schnalke <meillo@marmaro.de>
parents: 367
diff changeset
147 }
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
148 }
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
149 return TRUE;
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
150 }
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
151
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
152 /* find original address */
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
153 address*
366
41958685480d Switched to `type *name' style
markus schnalke <meillo@marmaro.de>
parents: 317
diff changeset
154 addr_find_ancestor(address *addr)
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
155 {
389
bc9a7845b53a Refactoring and code layouting.
markus schnalke <meillo@marmaro.de>
parents: 367
diff changeset
156 while (addr->parent) {
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
157 addr = addr->parent;
389
bc9a7845b53a Refactoring and code layouting.
markus schnalke <meillo@marmaro.de>
parents: 367
diff changeset
158 }
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
159 return addr;
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
160 }
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
161
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
162 gchar*
366
41958685480d Switched to `type *name' style
markus schnalke <meillo@marmaro.de>
parents: 317
diff changeset
163 addr_string(address *addr)
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
164 {
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
165 static gchar *buffer = NULL;
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
166
389
bc9a7845b53a Refactoring and code layouting.
markus schnalke <meillo@marmaro.de>
parents: 367
diff changeset
167 if (!addr) {
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
168 g_free(buffer);
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
169 buffer = NULL;
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
170 return NULL;
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
171 }
389
bc9a7845b53a Refactoring and code layouting.
markus schnalke <meillo@marmaro.de>
parents: 367
diff changeset
172 if (buffer) {
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
173 g_free(buffer);
389
bc9a7845b53a Refactoring and code layouting.
markus schnalke <meillo@marmaro.de>
parents: 367
diff changeset
174 }
bc9a7845b53a Refactoring and code layouting.
markus schnalke <meillo@marmaro.de>
parents: 367
diff changeset
175 if (!*addr->local_part) {
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
176 buffer = g_strdup("<>");
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
177 } else {
389
bc9a7845b53a Refactoring and code layouting.
markus schnalke <meillo@marmaro.de>
parents: 367
diff changeset
178 buffer = g_strdup_printf("<%s@%s>",
bc9a7845b53a Refactoring and code layouting.
markus schnalke <meillo@marmaro.de>
parents: 367
diff changeset
179 addr->local_part ? addr->local_part : "",
bc9a7845b53a Refactoring and code layouting.
markus schnalke <meillo@marmaro.de>
parents: 367
diff changeset
180 addr->domain ? addr->domain : "");
10
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
181 }
26e34ae9a3e3 changed indention and line wrapping to a more consistent style
meillo@marmaro.de
parents: 0
diff changeset
182 return buffer;
0
08114f7dcc23 this is masqmail-0.2.21 from oliver kurth
meillo@marmaro.de
parents:
diff changeset
183 }