Mercurial > sm-archive
comparison src/context.cpp @ 21:09564d4acd9e stable-1-0-8
patches from Marco d'Itri for postfix
author | Carl Byington <carl@five-ten-sg.com> |
---|---|
date | Fri, 24 Dec 2010 15:13:18 -0800 |
parents | b24369330483 |
children |
comparison
equal
deleted
inserted
replaced
20:a7564d29fd53 | 21:09564d4acd9e |
---|---|
31 | 31 |
32 | 32 |
33 bool CONFIG::find(const char *needle, string_set &haystack) { | 33 bool CONFIG::find(const char *needle, string_set &haystack) { |
34 string_set::iterator i = haystack.find(needle); | 34 string_set::iterator i = haystack.find(needle); |
35 if (i != haystack.end()) return true; // found user@domain.tld key | 35 if (i != haystack.end()) return true; // found user@domain.tld key |
36 char *x = strchr(needle, '@'); | 36 const char *x = strchr(needle, '@'); |
37 if (x) { | 37 if (x) { |
38 x++; | 38 x++; |
39 i = haystack.find(x); | 39 i = haystack.find(x); |
40 if (i != haystack.end()) return true; // found domain.tld key | 40 if (i != haystack.end()) return true; // found domain.tld key |
41 char y = *x; | 41 string userpart(needle, x-needle); |
42 *x = '\0'; | 42 i = haystack.find(userpart.c_str()); |
43 i = haystack.find(needle); | |
44 *x = y; | |
45 if (i != haystack.end()) return true; // found user@ key | 43 if (i != haystack.end()) return true; // found user@ key |
46 } | 44 } |
47 return false; | 45 return false; |
48 } | 46 } |
49 | 47 |
50 | 48 |
51 const char *CONFIG::find(const char *needle, string_map &haystack) { | 49 const char *CONFIG::find(const char *needle, string_map &haystack) { |
52 string_map::iterator i = haystack.find(needle); | 50 string_map::iterator i = haystack.find(needle); |
53 if (i != haystack.end()) return (*i).second; // found user@domain.tld key | 51 if (i != haystack.end()) return (*i).second; // found user@domain.tld key |
54 char *x = strchr(needle, '@'); | 52 const char *x = strchr(needle, '@'); |
55 if (x) { | 53 if (x) { |
56 x++; | 54 x++; |
57 i = haystack.find(x); | 55 i = haystack.find(x); |
58 if (i != haystack.end()) return (*i).second; // found domain.tld key | 56 if (i != haystack.end()) return (*i).second; // found domain.tld key |
59 char y = *x; | 57 string userpart(needle, x-needle); |
60 *x = '\0'; | 58 i = haystack.find(userpart.c_str()); |
61 i = haystack.find(needle); | |
62 *x = y; | |
63 if (i != haystack.end()) return (*i).second; // found user@ key | 59 if (i != haystack.end()) return (*i).second; // found user@ key |
64 } | 60 } |
65 return NULL; | 61 return NULL; |
66 } | 62 } |
67 | 63 |