]>
Commit | Line | Data |
---|---|---|
1 | /* | |
2 | * IRC - Internet Relay Chat, ircd/m_wallvoices.c | |
3 | * Copyright (c) 2002 hikari | |
4 | * | |
5 | * See file AUTHORS in IRC package for additional names of | |
6 | * the programmers. | |
7 | * | |
8 | * This program is free software; you can redistribute it and/or modify | |
9 | * it under the terms of the GNU General Public License as published by | |
10 | * the Free Software Foundation; either version 1, or (at your option) | |
11 | * any later version. | |
12 | * | |
13 | * This program is distributed in the hope that it will be useful, | |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 | * GNU General Public License for more details. | |
17 | * | |
18 | * You should have received a copy of the GNU General Public License | |
19 | * along with this program; if not, write to the Free Software | |
20 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |
21 | * | |
22 | * $Id: m_wallvoices.c,v 1.6 2004/12/11 05:14:03 klmitch Exp $ | |
23 | */ | |
24 | ||
25 | /* | |
26 | * m_functions execute protocol messages on this server: | |
27 | * | |
28 | * cptr is always NON-NULL, pointing to a *LOCAL* client | |
29 | * structure (with an open socket connected!). This | |
30 | * identifies the physical socket where the message | |
31 | * originated (or which caused the m_function to be | |
32 | * executed--some m_functions may call others...). | |
33 | * | |
34 | * sptr is the source of the message, defined by the | |
35 | * prefix part of the message if present. If not | |
36 | * or prefix not found, then sptr==cptr. | |
37 | * | |
38 | * (!IsServer(cptr)) => (cptr == sptr), because | |
39 | * prefixes are taken *only* from servers... | |
40 | * | |
41 | * (IsServer(cptr)) | |
42 | * (sptr == cptr) => the message didn't | |
43 | * have the prefix. | |
44 | * | |
45 | * (sptr != cptr && IsServer(sptr) means | |
46 | * the prefix specified servername. (?) | |
47 | * | |
48 | * (sptr != cptr && !IsServer(sptr) means | |
49 | * that message originated from a remote | |
50 | * user (not local). | |
51 | * | |
52 | * combining | |
53 | * | |
54 | * (!IsServer(sptr)) means that, sptr can safely | |
55 | * taken as defining the target structure of the | |
56 | * message in this server. | |
57 | * | |
58 | * *Always* true (if 'parse' and others are working correct): | |
59 | * | |
60 | * 1) sptr->from == cptr (note: cptr->from == cptr) | |
61 | * | |
62 | * 2) MyConnect(sptr) <=> sptr == cptr (e.g. sptr | |
63 | * *cannot* be a local connection, unless it's | |
64 | * actually cptr!). [MyConnect(x) should probably | |
65 | * be defined as (x == x->from) --msa ] | |
66 | * | |
67 | * parc number of variable parameter strings (if zero, | |
68 | * parv is allowed to be NULL) | |
69 | * | |
70 | * parv a NULL terminated list of parameter pointers, | |
71 | * | |
72 | * parv[0], sender (prefix string), if not present | |
73 | * this points to an empty string. | |
74 | * parv[1]...parv[parc-1] | |
75 | * pointers to additional parameters | |
76 | * parv[parc] == NULL, *always* | |
77 | * | |
78 | * note: it is guaranteed that parv[0]..parv[parc-1] are all | |
79 | * non-NULL pointers. | |
80 | */ | |
81 | #include "config.h" | |
82 | ||
83 | #include "channel.h" | |
84 | #include "client.h" | |
85 | #include "hash.h" | |
86 | #include "ircd.h" | |
87 | #include "ircd_log.h" | |
88 | #include "ircd_reply.h" | |
89 | #include "ircd_string.h" | |
90 | #include "msg.h" | |
91 | #include "numeric.h" | |
92 | #include "numnicks.h" | |
93 | #include "s_user.h" | |
94 | #include "send.h" | |
95 | ||
96 | /* #include <assert.h> -- Now using assert in ircd_log.h */ | |
97 | ||
98 | /* | |
99 | * m_wallvoices - local generic message handler | |
100 | */ | |
101 | int m_wallvoices(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) | |
102 | { | |
103 | struct Channel *chptr; | |
104 | ||
105 | assert(0 != cptr); | |
106 | assert(cptr == sptr); | |
107 | ||
108 | ClrFlag(sptr, FLAG_TS8); | |
109 | ||
110 | if (parc < 2 || EmptyString(parv[1])) | |
111 | return send_reply(sptr, ERR_NORECIPIENT, "WALLVOICES"); | |
112 | ||
113 | if (parc < 3 || EmptyString(parv[parc - 1])) | |
114 | return send_reply(sptr, ERR_NOTEXTTOSEND); | |
115 | ||
116 | if (IsChannelName(parv[1]) && (chptr = FindChannel(parv[1]))) { | |
117 | if (client_can_send_to_channel(sptr, chptr, 0) && !(chptr->mode.mode & MODE_NONOTICE)) { | |
118 | if ((chptr->mode.mode & MODE_NOPRIVMSGS) && | |
119 | check_target_limit(sptr, chptr, chptr->chname, 0)) | |
120 | return 0; | |
121 | sendcmdto_channel_butone(sptr, CMD_WALLVOICES, chptr, cptr, | |
122 | SKIP_DEAF | SKIP_BURST | SKIP_NONVOICES, | |
123 | "%H :+ %s", chptr, parv[parc - 1]); | |
124 | } | |
125 | else | |
126 | send_reply(sptr, ERR_CANNOTSENDTOCHAN, parv[1]); | |
127 | } | |
128 | else | |
129 | send_reply(sptr, ERR_NOSUCHCHANNEL, parv[1]); | |
130 | ||
131 | return 0; | |
132 | } | |
133 | ||
134 | /* | |
135 | * ms_wallvoices - server message handler | |
136 | */ | |
137 | int ms_wallvoices(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) | |
138 | { | |
139 | struct Channel *chptr; | |
140 | assert(0 != cptr); | |
141 | assert(0 != sptr); | |
142 | ||
143 | if (parc < 3 || !IsUser(sptr)) | |
144 | return 0; | |
145 | ||
146 | if (!IsLocalChannel(parv[1]) && (chptr = FindChannel(parv[1]))) { | |
147 | if (client_can_send_to_channel(sptr, chptr, 0) && !(chptr->mode.mode & MODE_NONOTICE)) { | |
148 | sendcmdto_channel_butone(sptr, CMD_WALLVOICES, chptr, cptr, | |
149 | SKIP_DEAF | SKIP_BURST | SKIP_NONVOICES, | |
150 | "%H :%s", chptr, parv[parc - 1]); | |
151 | } else | |
152 | send_reply(sptr, ERR_CANNOTSENDTOCHAN, parv[1]); | |
153 | } | |
154 | return 0; | |
155 | } |