1 | /* |
1 | /* |
2 | * svsignore.C: Services ignore list management. |
2 | * svsignore.C: Services ignore list management. |
3 | * Rights to this code are documented in doc/pod/license.pod. |
3 | * Rights to this code are documented in doc/pod/license.pod. |
4 | * |
4 | * |
5 | * Copyright © 2005-2007 Atheme Project (http://www.atheme.org) |
5 | * Copyright © 2005-2007 Atheme Project (http://www.atheme.org) |
6 | */ |
6 | */ |
7 | |
7 | |
8 | static char const rcsid[] = "$Id: svsignore.C,v 1.3 2007/07/21 13:23:22 pippijn Exp $"; |
8 | static char const rcsid[] = "$Id: svsignore.C,v 1.4 2007/08/28 17:08:12 pippijn Exp $"; |
9 | |
9 | |
10 | #include "atheme.h" |
10 | #include "atheme.h" |
11 | #include <account/svsignore.h> |
11 | #include <account/svsignore.h> |
12 | |
12 | |
13 | svsignore_vector svs_ignore_list; |
13 | svsignore_vector svs_ignore_list; |
… | |
… | |
33 | svsignore_t * |
33 | svsignore_t * |
34 | svsignore_add (char *mask, char *reason) |
34 | svsignore_add (char *mask, char *reason) |
35 | { |
35 | { |
36 | svsignore_t *svsignore; |
36 | svsignore_t *svsignore; |
37 | |
37 | |
38 | svsignore = static_cast<svsignore_t *> (smalloc (sizeof (svsignore_t))); |
38 | svsignore = new svsignore_t; |
39 | |
39 | |
40 | svs_ignore_list.push_back (svsignore); |
40 | svs_ignore_list.push_back (svsignore); |
41 | |
41 | |
42 | svsignore->mask = sstrdup (mask); |
42 | svsignore->mask = sstrdup (mask); |
43 | svsignore->settime = NOW; |
43 | svsignore->settime = NOW; |
… | |
… | |
64 | */ |
64 | */ |
65 | svsignore_t * |
65 | svsignore_t * |
66 | svsignore_find (user_t *source) |
66 | svsignore_find (user_t *source) |
67 | { |
67 | { |
68 | svsignore_t *svsignore; |
68 | svsignore_t *svsignore; |
69 | svsignore_vector::iterator it, it_end; |
69 | svsignore_vector::iterator it = svs_ignore_list.begin (); |
|
|
70 | svsignore_vector::iterator et = svs_ignore_list.end (); |
70 | char host[BUFSIZE]; |
71 | char host[BUFSIZE]; |
71 | |
72 | |
72 | if (!use_svsignore) |
73 | if (!use_svsignore) |
73 | return NULL; |
74 | return NULL; |
74 | |
75 | |
… | |
… | |
77 | strlcat (host, "!", BUFSIZE); |
78 | strlcat (host, "!", BUFSIZE); |
78 | strlcat (host, source->user, BUFSIZE); |
79 | strlcat (host, source->user, BUFSIZE); |
79 | strlcat (host, "@", BUFSIZE); |
80 | strlcat (host, "@", BUFSIZE); |
80 | strlcat (host, source->host, BUFSIZE); |
81 | strlcat (host, source->host, BUFSIZE); |
81 | |
82 | |
82 | for (it = svs_ignore_list.begin (), it_end = svs_ignore_list.end (); it != it_end; ++it) |
83 | while (it != et) |
83 | { |
84 | { |
84 | svsignore = *it; |
85 | svsignore = *it; |
85 | |
86 | |
86 | if (!match (svsignore->mask, host)) |
87 | if (!match (svsignore->mask, host)) |
87 | return svsignore; |
88 | return svsignore; |
|
|
89 | |
|
|
90 | ++it; |
88 | } |
91 | } |
89 | |
92 | |
90 | return NULL; |
93 | return NULL; |
91 | } |
94 | } |
92 | |
95 | |
… | |
… | |
107 | void |
110 | void |
108 | svsignore_delete (svsignore_t *svsignore) |
111 | svsignore_delete (svsignore_t *svsignore) |
109 | { |
112 | { |
110 | svs_ignore_list.erase (svsignore); |
113 | svs_ignore_list.erase (svsignore); |
111 | |
114 | |
112 | free (svsignore->mask); |
115 | sfree (svsignore->mask); |
113 | free (svsignore->reason); |
116 | sfree (svsignore->reason); |
114 | free (svsignore); |
117 | delete svsignore; |
115 | } |
118 | } |