ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/ermyth/src/svsignore.C
Revision: 1.1
Committed: Thu Jul 19 08:24:59 2007 UTC (16 years, 10 months ago) by pippijn
Content type: text/plain
Branch: MAIN
Log Message:
initial import. the most important changes since Atheme are:
- fixed many memory leaks
- fixed many bugs
- converted to C++ and use more STL containers
- added a (not very enhanced yet) perl module
- greatly improved XML-RPC speed
- added a JSON-RPC module with code from json-cpp
- added a valgrind memcheck module to operserv
- added a more object oriented base64 implementation
- added a specialised unit test framework
- improved stability
- use gettimeofday() if available
- reworked adding/removing commands
- MemoServ IGNORE DEL can now remove indices

File Contents

# User Rev Content
1 pippijn 1.1 /*
2     * svsignore.C: Services ignore list management.
3     * Rights to this code are documented in doc/LICENSE.
4     *
5     * Copyright © 2005-2007 Atheme Project (http://www.atheme.org)
6     */
7    
8     static char const rcsid[] = "$Id";
9    
10     #include "atheme.h"
11     #include <account/svsignore.h>
12    
13     svsignore_vector svs_ignore_list;
14    
15     /*
16     * svsignore_add(char *mask, char *reason)
17     *
18     * Services ignore factory.
19     *
20     * Inputs:
21     * - mask to ignore
22     * - reason for ignore
23     *
24     * Outputs:
25     * - on success, a new svsignore object
26     *
27     * Side Effects:
28     * - a services ignore is added
29     *
30     * Bugs:
31     * - this function does not check for dupes
32     */
33     svsignore_t *
34     svsignore_add (char *mask, char *reason)
35     {
36     svsignore_t *svsignore;
37    
38     svsignore = static_cast<svsignore_t *> (smalloc (sizeof (svsignore_t)));
39    
40     svs_ignore_list.push_back (svsignore);
41    
42     svsignore->mask = sstrdup (mask);
43     svsignore->settime = NOW;
44     svsignore->reason = sstrdup (reason);
45     cnt.svsignore++;
46    
47     return svsignore;
48     }
49    
50     /*
51     * svsignore_find(user_t *source)
52     *
53     * Finds any services ignores that affect a user.
54     *
55     * Inputs:
56     * - user object to check
57     *
58     * Outputs:
59     * - if any ignores match, the ignore that matches
60     * - if none match, NULL
61     *
62     * Side Effects:
63     * - none
64     */
65     svsignore_t *
66     svsignore_find (user_t *source)
67     {
68     svsignore_t *svsignore;
69     svsignore_vector::iterator it, it_end;
70     char host[BUFSIZE];
71    
72     if (!use_svsignore)
73     return NULL;
74    
75     *host = '\0';
76     strlcpy (host, source->nick, BUFSIZE);
77     strlcat (host, "!", BUFSIZE);
78     strlcat (host, source->user, BUFSIZE);
79     strlcat (host, "@", BUFSIZE);
80     strlcat (host, source->host, BUFSIZE);
81    
82     for (it = svs_ignore_list.begin (), it_end = svs_ignore_list.end (); it != it_end; ++it)
83     {
84     svsignore = *it;
85    
86     if (!match (svsignore->mask, host))
87     return svsignore;
88     }
89    
90     return NULL;
91     }
92    
93     /*
94     * svsignore_delete(svsignore_t *svsignore)
95     *
96     * Destroys a services ignore.
97     *
98     * Inputs:
99     * - svsignore to destroy
100     *
101     * Outputs:
102     * - nothing
103     *
104     * Side Effects:
105     * - a services ignore is destroyed and removed from the list
106     */
107     void
108     svsignore_delete (svsignore_t *svsignore)
109     {
110     svs_ignore_list.erase (svsignore);
111    
112     free (svsignore->mask);
113     free (svsignore->reason);
114     free (svsignore);
115     }