ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/modules/m_away.c
Revision: 1474
Committed: Sun Jul 22 14:44:07 2012 UTC (14 years, 2 months ago) by michael
Content type: text/x-csrc
Original Path: ircd-hybrid-8/modules/m_away.c
File size: 4586 byte(s)
Log Message:
- removed &localchannels

File Contents

# User Rev Content
1 adx 30 /*
2     * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd).
3     * m_away.c: Sets/removes away status on a user.
4     *
5     * Copyright (C) 2002 by the past and present ircd coders, and others.
6     *
7     * This program is free software; you can redistribute it and/or modify
8     * it under the terms of the GNU General Public License as published by
9     * the Free Software Foundation; either version 2 of the License, or
10     * (at your option) any later version.
11     *
12     * This program is distributed in the hope that it will be useful,
13     * but WITHOUT ANY WARRANTY; without even the implied warranty of
14     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15     * GNU General Public License for more details.
16     *
17     * You should have received a copy of the GNU General Public License
18     * along with this program; if not, write to the Free Software
19     * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20     * USA
21     *
22 knight 31 * $Id$
23 adx 30 */
24    
25     #include "stdinc.h"
26     #include "client.h"
27     #include "irc_string.h"
28     #include "ircd.h"
29     #include "numeric.h"
30     #include "send.h"
31     #include "parse.h"
32     #include "modules.h"
33 michael 1309 #include "conf.h"
34 adx 30 #include "s_serv.h"
35     #include "packet.h"
36     #include "s_user.h"
37    
38    
39     /*
40     * m_away
41     * parv[0] = sender prefix
42     * parv[1] = away message
43     */
44     static void
45     m_away(struct Client *client_p, struct Client *source_p,
46     int parc, char *parv[])
47     {
48     char *cur_away_msg = source_p->away;
49     char *new_away_msg = NULL;
50     size_t nbytes = 0;
51    
52     if (!IsFloodDone(source_p))
53     flood_endgrace(source_p);
54    
55     if (parc < 2 || EmptyString(parv[1]))
56     {
57     /* Marking as not away */
58     if (cur_away_msg)
59     {
60     /* we now send this only if they were away before --is */
61 michael 1474 sendto_server(client_p, CAP_TS6, NOCAPS,
62 michael 885 ":%s AWAY", ID(source_p));
63 michael 1474 sendto_server(client_p, NOCAPS, CAP_TS6,
64 michael 885 ":%s AWAY", source_p->name);
65 adx 30
66     MyFree(cur_away_msg);
67     source_p->away = NULL;
68     }
69    
70     sendto_one(source_p, form_str(RPL_UNAWAY),
71     me.name, source_p->name);
72     return;
73     }
74    
75     new_away_msg = parv[1];
76     nbytes = strlen(new_away_msg);
77    
78     if (nbytes > (size_t)AWAYLEN) {
79     new_away_msg[AWAYLEN] = '\0';
80     nbytes = AWAYLEN;
81     }
82    
83     /* we now send this only if they
84     * weren't away already --is */
85     if (!cur_away_msg)
86     {
87 michael 1474 sendto_server(client_p, CAP_TS6, NOCAPS,
88 michael 885 ":%s AWAY :%s", ID(source_p), new_away_msg);
89 michael 1474 sendto_server(client_p, NOCAPS, CAP_TS6,
90 michael 885 ":%s AWAY :%s", source_p->name, new_away_msg);
91 adx 30 }
92     else
93     MyFree(cur_away_msg);
94    
95     cur_away_msg = MyMalloc(nbytes + 1);
96     strcpy(cur_away_msg, new_away_msg);
97     source_p->away = cur_away_msg;
98    
99     sendto_one(source_p, form_str(RPL_NOWAWAY), me.name, source_p->name);
100     }
101    
102     static void
103     ms_away(struct Client *client_p, struct Client *source_p,
104     int parc, char *parv[])
105     {
106     char *cur_away_msg = NULL;
107     char *new_away_msg = NULL;
108     size_t nbytes = 0;
109    
110     if (!IsClient(source_p))
111     return;
112    
113     cur_away_msg = source_p->away;
114    
115     if (parc < 2 || EmptyString(parv[1]))
116     {
117     /* Marking as not away */
118     if (cur_away_msg)
119     {
120     /* we now send this only if they were away before --is */
121 michael 1474 sendto_server(client_p, CAP_TS6, NOCAPS,
122 michael 885 ":%s AWAY", ID(source_p));
123 michael 1474 sendto_server(client_p, NOCAPS, CAP_TS6,
124 michael 885 ":%s AWAY", source_p->name);
125 adx 30
126     MyFree(cur_away_msg);
127     source_p->away = NULL;
128     }
129    
130     return;
131     }
132    
133     new_away_msg = parv[1];
134    
135     nbytes = strlen(new_away_msg);
136     if (nbytes > (size_t)AWAYLEN) {
137     new_away_msg[AWAYLEN] = '\0';
138     nbytes = AWAYLEN;
139     }
140    
141     /* we now send this only if they
142     * weren't away already --is */
143     if (!cur_away_msg)
144     {
145 michael 1474 sendto_server(client_p, CAP_TS6, NOCAPS,
146 michael 885 ":%s AWAY :%s", ID(source_p), new_away_msg);
147 michael 1474 sendto_server(client_p, NOCAPS, CAP_TS6,
148 michael 885 ":%s AWAY :%s", source_p->name, new_away_msg);
149 adx 30 }
150     else
151     MyFree(cur_away_msg);
152    
153     cur_away_msg = MyMalloc(nbytes + 1);
154     strcpy(cur_away_msg, new_away_msg);
155     source_p->away = cur_away_msg;
156     }
157 michael 1230
158     static struct Message away_msgtab = {
159     "AWAY", 0, 0, 0, MAXPARA, MFLG_SLOW, 0,
160 michael 1449 { m_unregistered, m_away, ms_away, m_ignore, m_away, m_ignore }
161 michael 1230 };
162    
163     static void
164     module_init(void)
165     {
166     mod_add_cmd(&away_msgtab);
167     add_isupport("AWAYLEN", NULL, AWAYLEN);
168     }
169    
170     static void
171     module_exit(void)
172     {
173     mod_del_cmd(&away_msgtab);
174     delete_isupport("AWAYLEN");
175     }
176    
177     struct module module_entry = {
178     .node = { NULL, NULL, NULL },
179     .name = NULL,
180     .version = "$Revision$",
181     .handle = NULL,
182     .modinit = module_init,
183     .modexit = module_exit,
184     .flags = 0
185     };

Properties

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