ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cvsroot/ermyth/modules/nickserv/status.C
Revision: 1.1
Committed: Thu Jul 19 08:24:54 2007 UTC (19 years, 3 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     * Copyright © 2005 William Pitcock, et al.
3     * Rights to this code are as documented in doc/LICENSE.
4     *
5     * This file contains code for the CService STATUS function.
6     *
7     * $Id: status.c 7895 2007-03-06 02:40:03Z pippijn $
8     */
9    
10     #include "atheme.h"
11     #include <account/mynick.h>
12     #include <account/myuser.h>
13    
14     static char const rcsid[] = "$Id";
15    
16     struct ns_status_listeners : callback::has_listeners
17     {
18     };
19    
20     ns_status_listeners listeners;
21    
22     DECLARE_MODULE_V1 ("nickserv/status", false, _modinit, _moddeinit, rcsid, "The Ermyth Team <http://ermyth.schmorp.de>");
23    
24     static void ns_cmd_acc (sourceinfo_t *si, int parc, char *parv[]);
25     static void ns_cmd_status (sourceinfo_t *si, int parc, char *parv[]);
26    
27     command_t ns_status = { "STATUS", N_("Displays session information."), AC_NONE, 0, ns_cmd_status };
28     command_t ns_acc = { "ACC", N_("Displays parsable session information"), AC_NONE, 2, ns_cmd_acc };
29    
30     cmdvec *ns_cmdtree;
31     helpvec *ns_helptree;
32    
33     void
34     _modinit (module_t *m)
35     {
36     MODULE_USE_SYMBOL_T (ns_cmdtree, cmdvec, "nickserv/main", "ns_cmdtree");
37     MODULE_USE_SYMBOL_T (ns_helptree, helpvec, "nickserv/main", "ns_helptree");
38    
39     ns_cmdtree << ns_acc;
40     help_addentry (ns_helptree, "ACC", "help/nickserv/acc", NULL);
41     ns_cmdtree << ns_status;
42     help_addentry (ns_helptree, "STATUS", "help/nickserv/status", NULL);
43     }
44    
45     void
46     _moddeinit ()
47     {
48     ns_cmdtree >> ns_acc;
49     help_delentry (ns_helptree, "ACC");
50     ns_cmdtree >> ns_status;
51     help_delentry (ns_helptree, "STATUS");
52     }
53    
54     static void
55     ns_cmd_acc (sourceinfo_t *si, int parc, char *parv[])
56     {
57     const char *targuser = parv[0];
58     char *targaccount = parv[1];
59     user_t *u;
60     myuser_t *mu;
61     mynick_t *mn;
62    
63     if (!targuser)
64     {
65     u = si->su;
66     targuser = u != NULL ? u->nick : "?";
67     }
68     else
69     u = user_find_named (targuser);
70    
71     if (!u)
72     {
73     command_fail (si, fault_nosuch_target, _("%s%s%s ACC 0 (offline)"), targuser, parc >= 2 ? " -> " : "", parc >= 2 ? targaccount : "");
74     return;
75     }
76    
77     if (!targaccount)
78     targaccount = u->nick;
79     if (!strcmp (targaccount, "*"))
80     mu = u->myuser;
81     else
82     mu = myuser_find_ext (targaccount);
83    
84     if (!mu)
85     {
86     command_fail (si, fault_nosuch_target, _("%s%s%s ACC 0 (not registered)"), u->nick, parc >= 2 ? " -> " : "", parc >= 2 ? targaccount : "");
87     return;
88     }
89    
90     if (u->myuser == mu)
91     command_success_nodata (si, "%s%s%s ACC 3", u->nick, parc >= 2 ? " -> " : "", parc >= 2 ? mu->name : "");
92     else if ((mn = mynick_find (u->nick)) != NULL && mn->owner == mu && myuser_access_verify (u, mu))
93     command_success_nodata (si, "%s%s%s ACC 2", u->nick, parc >= 2 ? " -> " : "", parc >= 2 ? mu->name : "");
94     else
95     command_success_nodata (si, "%s%s%s ACC 1", u->nick, parc >= 2 ? " -> " : "", parc >= 2 ? mu->name : "");
96     }
97    
98     static void
99     ns_cmd_status (sourceinfo_t *si, int parc, char *parv[])
100     {
101     logcommand (si, CMDLOG_GET, "STATUS");
102    
103     if (!si->smu)
104     command_success_nodata (si, _("You are not logged in."));
105     else
106     {
107     command_success_nodata (si, _("You are logged in as \2%s\2."), si->smu->name);
108    
109     if (is_soper (si->smu))
110     {
111     soper_t *soper = si->smu->soper;
112    
113     command_success_nodata (si, _("You are a services operator of class %s."), soper->operclass ? soper->operclass->name : soper->classname);
114     }
115     }
116    
117     if (si->su != NULL)
118     {
119     mynick_t *mn;
120    
121     mn = mynick_find (si->su->nick);
122     if (mn != NULL && mn->owner != si->smu && myuser_access_verify (si->su, mn->owner))
123     command_success_nodata (si, _("You are recognized as \2%s\2."), mn->owner->name);
124     }
125    
126     if (si->su != NULL && is_admin (si->su))
127     command_success_nodata (si, _("You are a server administrator."));
128    
129     if (si->su != NULL && is_ircop (si->su))
130     command_success_nodata (si, _("You are an IRC operator."));
131     }
132    
133     /* vim:cinoptions=>s,e0,n0,f0,{0,}0,^0,=s,ps,t0,c3,+s,(2s,us,)20,*30,gs,hs
134     * vim:ts=8
135     * vim:sw=8
136     * vim:noexpandtab
137     */