ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/modules/m_away.c
Revision: 3186
Committed: Thu Mar 20 18:09:34 2014 UTC (12 years, 6 months ago) by michael
Content type: text/x-csrc
File size: 4461 byte(s)
Log Message:
- Get rid of the ID() macro

File Contents

# User Rev Content
1 adx 30 /*
2 michael 2820 * ircd-hybrid: an advanced, lightweight Internet Relay Chat Daemon (ircd)
3 adx 30 *
4 michael 2820 * Copyright (c) 1997-2014 ircd-hybrid development team
5 adx 30 *
6     * This program is free software; you can redistribute it and/or modify
7     * it under the terms of the GNU General Public License as published by
8     * the Free Software Foundation; either version 2 of the License, or
9     * (at your option) any later version.
10     *
11     * This program is distributed in the hope that it will be useful,
12     * but WITHOUT ANY WARRANTY; without even the implied warranty of
13     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14     * GNU General Public License for more details.
15     *
16     * You should have received a copy of the GNU General Public License
17     * along with this program; if not, write to the Free Software
18     * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19     * USA
20     */
21    
22 michael 2820 /*! \file m_away.c
23     * \brief Includes required functions for processing the AWAY command.
24     * \version $Id$
25     */
26    
27 adx 30 #include "stdinc.h"
28     #include "client.h"
29     #include "irc_string.h"
30     #include "ircd.h"
31     #include "numeric.h"
32     #include "send.h"
33     #include "parse.h"
34     #include "modules.h"
35 michael 1309 #include "conf.h"
36 adx 30 #include "s_serv.h"
37     #include "packet.h"
38     #include "s_user.h"
39    
40    
41     /*
42     * m_away
43 michael 3096 * parv[0] = command
44 adx 30 * parv[1] = away message
45     */
46 michael 2820 static int
47 michael 3156 m_away(struct Client *source_p, int parc, char *parv[])
48 adx 30 {
49     if (!IsFloodDone(source_p))
50     flood_endgrace(source_p);
51    
52     if (parc < 2 || EmptyString(parv[1]))
53     {
54     /* Marking as not away */
55 michael 1483 if (source_p->away[0])
56 adx 30 {
57 michael 1734 source_p->away[0] = '\0';
58 adx 30 /* we now send this only if they were away before --is */
59 michael 3186 sendto_server(source_p, NOCAPS, NOCAPS, ":%s AWAY", source_p->id);
60 michael 1734 sendto_common_channels_local(source_p, 1, CAP_AWAY_NOTIFY,
61     ":%s!%s@%s AWAY",
62     source_p->name, source_p->username,
63     source_p->host);
64 adx 30 }
65    
66 michael 3109 sendto_one_numeric(source_p, &me, RPL_UNAWAY);
67 michael 2820 return 0;
68 adx 30 }
69    
70 michael 1484 if ((CurrentTime - source_p->localClient->last_away) < ConfigFileEntry.pace_wait)
71     {
72 michael 3109 sendto_one_numeric(source_p, &me, RPL_LOAD2HI);
73 michael 2820 return 0;
74 michael 1484 }
75    
76     source_p->localClient->last_away = CurrentTime;
77 michael 3109 sendto_one_numeric(source_p, &me, RPL_NOWAWAY);
78 michael 1734
79 michael 1749 if (!strncmp(source_p->away, parv[1], sizeof(source_p->away) - 1))
80 michael 2820 return 0;
81 michael 1734
82 michael 1483 strlcpy(source_p->away, parv[1], sizeof(source_p->away));
83 adx 30
84 michael 1734 sendto_common_channels_local(source_p, 1, CAP_AWAY_NOTIFY,
85     ":%s!%s@%s AWAY :%s",
86     source_p->name, source_p->username,
87     source_p->host, source_p->away);
88 michael 3156 sendto_server(source_p, NOCAPS, NOCAPS, ":%s AWAY :%s",
89 michael 3186 source_p->id, source_p->away);
90 michael 2820 return 0;
91 adx 30 }
92    
93 michael 2820 static int
94 michael 3156 ms_away(struct Client *source_p, int parc, char *parv[])
95 adx 30 {
96     if (parc < 2 || EmptyString(parv[1]))
97     {
98     /* Marking as not away */
99 michael 1483 if (source_p->away[0])
100 adx 30 {
101 michael 1734 source_p->away[0] = '\0';
102 adx 30 /* we now send this only if they were away before --is */
103 michael 3186 sendto_server(source_p, NOCAPS, NOCAPS, ":%s AWAY", source_p->id);
104 michael 1734 sendto_common_channels_local(source_p, 1, CAP_AWAY_NOTIFY,
105     ":%s!%s@%s AWAY",
106     source_p->name, source_p->username,
107     source_p->host);
108 adx 30 }
109    
110 michael 2820 return 0;
111 adx 30 }
112    
113 michael 1749 if (!strncmp(source_p->away, parv[1], sizeof(source_p->away) - 1))
114 michael 2820 return 0;
115 michael 1734
116 michael 1483 strlcpy(source_p->away, parv[1], sizeof(source_p->away));
117 adx 30
118 michael 1734 sendto_common_channels_local(source_p, 1, CAP_AWAY_NOTIFY,
119     ":%s!%s@%s AWAY :%s",
120     source_p->name, source_p->username,
121     source_p->host, source_p->away);
122 michael 3156 sendto_server(source_p, NOCAPS, NOCAPS, ":%s AWAY :%s",
123 michael 3186 source_p->id, source_p->away);
124 michael 2820 return 0;
125 adx 30 }
126 michael 1230
127 michael 2820 static struct Message away_msgtab =
128     {
129 michael 1230 "AWAY", 0, 0, 0, MAXPARA, MFLG_SLOW, 0,
130 michael 1449 { m_unregistered, m_away, ms_away, m_ignore, m_away, m_ignore }
131 michael 1230 };
132    
133     static void
134     module_init(void)
135     {
136     mod_add_cmd(&away_msgtab);
137     add_isupport("AWAYLEN", NULL, AWAYLEN);
138     }
139    
140     static void
141     module_exit(void)
142     {
143     mod_del_cmd(&away_msgtab);
144     delete_isupport("AWAYLEN");
145     }
146    
147 michael 2820 struct module module_entry =
148     {
149 michael 1230 .node = { NULL, NULL, NULL },
150     .name = NULL,
151     .version = "$Revision$",
152     .handle = NULL,
153     .modinit = module_init,
154     .modexit = module_exit,
155     .flags = 0
156     };

Properties

Name Value
svn:eol-style native
svn:keywords Id Revision