ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/modules/m_topic.c
(Generate patch)

Comparing:
ircd-hybrid/modules/m_topic.c (file contents), Revision 30 by adx, Sun Oct 2 20:03:27 2005 UTC vs.
ircd-hybrid/trunk/modules/m_topic.c (file contents), Revision 1799 by michael, Sun Mar 31 17:12:07 2013 UTC

# Line 19 | Line 19
19   *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
20   *  USA
21   *
22 < *  $Id: m_topic.c,v 1.71 2005/08/16 07:33:24 adx Exp $
22 > *  $Id$
23   */
24  
25   #include "stdinc.h"
26 < #include "tools.h"
27 < #include "handlers.h"
26 > #include "list.h"
27   #include "channel.h"
28   #include "channel_mode.h"
29   #include "client.h"
30   #include "hash.h"
31   #include "irc_string.h"
33 – #include "sprintf_irc.h"
32   #include "ircd.h"
33   #include "numeric.h"
34   #include "send.h"
37 – #include "s_conf.h"
35   #include "s_serv.h"
39 – #include "msg.h"
36   #include "parse.h"
37   #include "modules.h"
38   #include "packet.h"
43 – #include "common.h"
39  
45 – static void m_topic(struct Client *, struct Client *, int, char **);
46 – static void ms_topic(struct Client *, struct Client *, int, char **);
47 –
48 – struct Message topic_msgtab = {
49 –  "TOPIC", 0, 0, 2, 0, MFLG_SLOW, 0,
50 –  {m_unregistered, m_topic, ms_topic, m_ignore, m_topic, m_ignore}
51 – };
52 –
53 – #ifndef STATIC_MODULES
54 – void
55 – _modinit(void)
56 – {
57 –  mod_add_cmd(&topic_msgtab);
58 – }
59 –
60 – void
61 – _moddeinit(void)
62 – {
63 –  mod_del_cmd(&topic_msgtab);
64 – }
65 –
66 – const char *_version = "$Revision: 1.71 $";
67 – #endif
40  
41   /* m_topic()
42   *  parv[0] = sender prefix
# Line 76 | Line 48 | m_topic(struct Client *client_p, struct
48          int parc, char *parv[])
49   {
50    struct Channel *chptr = NULL;
79 –  char *p;
80 –  struct Membership *ms;
81 –  const char *from, *to;
51  
52 <  if (!MyClient(source_p) && IsCapable(source_p->from, CAP_TS6) && HasID(source_p))
84 <  {
85 <    from = me.id;
86 <    to = source_p->id;
87 <  }
88 <  else
52 >  if (EmptyString(parv[1]))
53    {
54 <    from = me.name;
55 <    to = source_p->name;
54 >    sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS),
55 >               me.name, source_p->name, "TOPIC");
56 >    return;
57    }
58  
59 <  if ((p = strchr(parv[1], ',')) != NULL)
60 <    *p = '\0';
59 >  if (!IsFloodDone(source_p))
60 >    flood_endgrace(source_p);
61  
62 <  if (parv[1][0] == '\0')
62 >  if ((chptr = hash_find_channel(parv[1])) == NULL)
63    {
64 <    sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS),
65 <               from, to, "TOPIC");
64 >    sendto_one(source_p, form_str(ERR_NOSUCHCHANNEL),
65 >               me.name, source_p->name, parv[1]);
66      return;
67    }
68  
69 <  if (MyClient(source_p) && !IsFloodDone(source_p))
70 <    flood_endgrace(source_p);
106 <
107 <  if (IsChanPrefix(*parv[1]))
69 >  /* setting topic */
70 >  if (parc > 2)
71    {
72 <    if ((chptr = hash_find_channel(parv[1])) == NULL)
72 >    struct Membership *ms;
73 >
74 >    if ((ms = find_channel_link(source_p, chptr)) == NULL)
75      {
76 <      /* if chptr isn't found locally, it =could= exist
77 <       * on the uplink. so forward reqeuest
78 <       */
114 <      if (!ServerInfo.hub && uplink && IsCapable(uplink, CAP_LL))
115 <      {
116 <        sendto_one(uplink, ":%s TOPIC %s %s",
117 <                   ID_or_name(source_p, uplink), chptr->chname,
118 <                   ((parc > 2) ? parv[2] : ""));
119 <        return;
120 <      }
121 <      else
122 <      {
123 <        sendto_one(source_p, form_str(ERR_NOSUCHCHANNEL),
124 <                   from, to, parv[1]);
125 <        return;
126 <      }
76 >      sendto_one(source_p, form_str(ERR_NOTONCHANNEL), me.name,
77 >                 source_p->name, parv[1]);
78 >      return;
79      }
80  
81 <    /* setting topic */
82 <    if (parc > 2)
81 >    if (!(chptr->mode.mode & MODE_TOPICLIMIT) ||
82 >        has_member_flags(ms, CHFL_CHANOP|CHFL_HALFOP))
83      {
84 <      if ((ms = find_channel_link(source_p, chptr)) == NULL)
85 <      {
86 <        sendto_one(source_p, form_str(ERR_NOTONCHANNEL), from,
87 <                   to, parv[1]);
88 <        return;
89 <      }
90 <      if ((chptr->mode.mode & MODE_TOPICLIMIT) == 0 ||
91 <          has_member_flags(ms, CHFL_CHANOP|CHFL_HALFOP))
92 <      {
93 <        char topic_info[USERHOST_REPLYLEN];
94 <        ircsprintf(topic_info, "%s!%s@%s",
95 <                   source_p->name, source_p->username, source_p->host);
96 <        set_channel_topic(chptr, parv[2], topic_info, CurrentTime);
97 <
98 <        sendto_server(client_p, NULL, chptr, CAP_TS6, NOCAPS, NOFLAGS,
99 <                      ":%s TOPIC %s :%s",
100 <                      ID(source_p), chptr->chname,
101 <                      chptr->topic == NULL ? "" : chptr->topic);
102 <        sendto_server(client_p, NULL, chptr, NOCAPS, CAP_TS6, NOFLAGS,
103 <                      ":%s TOPIC %s :%s",
152 <                      source_p->name, chptr->chname,
153 <                      chptr->topic == NULL ? "" : chptr->topic);
154 <        sendto_channel_local(ALL_MEMBERS, NO,
155 <                             chptr, ":%s!%s@%s TOPIC %s :%s",
156 <                             source_p->name,
157 <                             source_p->username,
158 <                             source_p->host,
159 <                             chptr->chname, chptr->topic == NULL ?
160 <                             "" : chptr->topic);
161 <      }
162 <      else
163 <        sendto_one(source_p, form_str(ERR_CHANOPRIVSNEEDED),
164 <                   from, to, chptr->chname);
84 >      char topic_info[USERHOST_REPLYLEN];
85 >
86 >      snprintf(topic_info, sizeof(topic_info), "%s!%s@%s", source_p->name,
87 >               source_p->username, source_p->host);
88 >      set_channel_topic(chptr, parv[2], topic_info, CurrentTime, 1);
89 >
90 >      sendto_server(client_p, CAP_TS6, NOCAPS,
91 >                    ":%s TOPIC %s :%s",
92 >                    ID(source_p), chptr->chname,
93 >                    chptr->topic);
94 >      sendto_server(client_p, NOCAPS, CAP_TS6,
95 >                    ":%s TOPIC %s :%s",
96 >                    source_p->name, chptr->chname,
97 >                    chptr->topic);
98 >      sendto_channel_local(ALL_MEMBERS, 0,
99 >                           chptr, ":%s!%s@%s TOPIC %s :%s",
100 >                           source_p->name,
101 >                           source_p->username,
102 >                           source_p->host,
103 >                           chptr->chname, chptr->topic);
104      }
105 <    else /* only asking for topic */
105 >    else
106 >      sendto_one(source_p, form_str(ERR_CHANOPRIVSNEEDED),
107 >                 me.name, source_p->name, chptr->chname);
108 >  }
109 >  else /* only asking for topic */
110 >  {
111 >    if (!SecretChannel(chptr) || IsMember(source_p, chptr))
112      {
113 <      if (!SecretChannel(chptr) || IsMember(source_p, chptr))
114 <      {
115 <        if (chptr->topic == NULL)
171 <          sendto_one(source_p, form_str(RPL_NOTOPIC),
172 <                     from, to, chptr->chname);
173 <        else
174 <        {
175 <          sendto_one(source_p, form_str(RPL_TOPIC),
176 <                     from, to,
177 <                     chptr->chname, chptr->topic);
178 <
179 <          /* client on LL needing the topic - if we have serverhide, say
180 <           * its the actual LL server that set the topic, not us the
181 <           * uplink -- fl_
182 <           */
183 <          if (ConfigServerHide.hide_servers && !MyClient(source_p)
184 <              && IsCapable(client_p, CAP_LL) && ServerInfo.hub)
185 <          {
186 <            sendto_one(source_p, form_str(RPL_TOPICWHOTIME),
187 <                       from, to, chptr->chname,
188 <                       client_p->name, chptr->topic_time);
189 <          }
190 <          else
191 <          {
192 <            sendto_one(source_p, form_str(RPL_TOPICWHOTIME),
193 <                       from, to, chptr->chname,
194 <                       chptr->topic_info,
195 <                       chptr->topic_time);
196 <          }
197 <        }
198 <      }
113 >      if (chptr->topic[0] == '\0')
114 >        sendto_one(source_p, form_str(RPL_NOTOPIC),
115 >                   me.name, source_p->name, chptr->chname);
116        else
117        {
118 <        sendto_one(source_p, form_str(ERR_NOTONCHANNEL),
119 <                   from, to, chptr->chname);
120 <        return;
118 >        sendto_one(source_p, form_str(RPL_TOPIC),
119 >                   me.name, source_p->name,
120 >                   chptr->chname, chptr->topic);
121 >        sendto_one(source_p, form_str(RPL_TOPICWHOTIME),
122 >                   me.name, source_p->name, chptr->chname,
123 >                   chptr->topic_info,
124 >                   chptr->topic_time);
125        }
126      }
127 <  }
128 <  else
129 <  {
209 <    sendto_one(source_p, form_str(ERR_NOSUCHCHANNEL),
210 <               from, to, parv[1]);
127 >    else
128 >      sendto_one(source_p, form_str(ERR_NOTONCHANNEL),
129 >                 me.name, source_p->name, chptr->chname);
130    }
131   }
132  
214 – /*
215 – * ms_topic
216 – *      parv[0] = sender prefix
217 – *      parv[1] = channel name
218 – *      parv[2] = topic_info
219 – *      parv[3] = topic_info time
220 – *      parv[4] = new channel topic
221 – *
222 – * Let servers always set a topic
223 – */
133   static void
134   ms_topic(struct Client *client_p, struct Client *source_p,
135           int parc, char *parv[])
136   {
137    struct Channel *chptr = NULL;
138 +  const char *from, *to;
139 +  char topic_info[USERHOST_REPLYLEN];
140  
141 <  if (!IsServer(source_p))
141 >  if (IsCapable(source_p->from, CAP_TS6) && HasID(source_p))
142    {
143 <    m_topic(client_p, source_p, parc, parv);
144 <    return;
143 >    from = me.id;
144 >    to = source_p->id;
145    }
146  
147 <  if (parc < 5)
147 >  if (EmptyString(parv[1]))
148 >  {
149 >    sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS),
150 >               from, to, "TOPIC");
151      return;
152 +  }
153  
154 <  if (parv[1] && IsChanPrefix(*parv[1]))
154 >  if ((chptr = hash_find_channel(parv[1])) == NULL)
155    {
156 <    if ((chptr = hash_find_channel(parv[1])) == NULL)
157 <      return;
156 >    sendto_one(source_p, form_str(ERR_NOSUCHCHANNEL),
157 >               from, to, parv[1]);
158 >    return;
159 >  }
160  
161 <    set_channel_topic(chptr, parv[4], parv[2], atoi(parv[3]));
161 >  if (!IsClient(source_p))
162 >    strlcpy(topic_info, source_p->name, sizeof(topic_info));
163 >  else
164 >    snprintf(topic_info, sizeof(topic_info), "%s!%s@%s", source_p->name,
165 >             source_p->username, source_p->host);
166 >  set_channel_topic(chptr, parv[2], topic_info, CurrentTime, 0);
167 >
168 >  sendto_server(client_p, CAP_TS6, NOCAPS, ":%s TOPIC %s :%s",
169 >                ID(source_p), chptr->chname,
170 >                chptr->topic);
171 >  sendto_server(client_p, NOCAPS, CAP_TS6, ":%s TOPIC %s :%s",
172 >                source_p->name, chptr->chname,
173 >                chptr->topic);
174 >
175 >  if (!IsClient(source_p))
176 >    sendto_channel_local(ALL_MEMBERS, 0, chptr, ":%s TOPIC %s :%s",
177 >                         source_p->name,
178 >                         chptr->chname, chptr->topic);
179  
180 <    if (ConfigServerHide.hide_servers)
181 <    {
182 <      sendto_channel_local(ALL_MEMBERS, NO,
183 <                           chptr, ":%s TOPIC %s :%s",
184 <                           me.name, chptr->chname,
185 <                           chptr->topic == NULL ? "" : chptr->topic);
180 >  else
181 >    sendto_channel_local(ALL_MEMBERS, 0, chptr, ":%s!%s@%s TOPIC %s :%s",
182 >                         source_p->name,
183 >                         source_p->username,
184 >                         source_p->host,
185 >                         chptr->chname, chptr->topic);
186 > }
187  
188 <    }
189 <    else
190 <    {
191 <      sendto_channel_local(ALL_MEMBERS, NO,
192 <                           chptr, ":%s TOPIC %s :%s",
193 <                           source_p->name,
194 <                           chptr->chname, chptr->topic == NULL ? "" : chptr->topic);
195 <    }
196 <  }
188 >
189 > static struct Message topic_msgtab = {
190 >  "TOPIC", 0, 0, 2, MAXPARA, MFLG_SLOW, 0,
191 >  {m_unregistered, m_topic, ms_topic, m_ignore, m_topic, m_ignore}
192 > };
193 >
194 > static void
195 > module_init(void)
196 > {
197 >  mod_add_cmd(&topic_msgtab);
198   }
199 +
200 + static void
201 + module_exit(void)
202 + {
203 +  mod_del_cmd(&topic_msgtab);
204 + }
205 +
206 + struct module module_entry = {
207 +  .node    = { NULL, NULL, NULL },
208 +  .name    = NULL,
209 +  .version = "$Revision$",
210 +  .handle  = NULL,
211 +  .modinit = module_init,
212 +  .modexit = module_exit,
213 +  .flags   = 0
214 + };

Comparing:
ircd-hybrid/modules/m_topic.c (property svn:keywords), Revision 30 by adx, Sun Oct 2 20:03:27 2005 UTC vs.
ircd-hybrid/trunk/modules/m_topic.c (property svn:keywords), Revision 1799 by michael, Sun Mar 31 17:12:07 2013 UTC

# Line 1 | Line 1
1 < "Id Revision"
1 > Id Revision

Diff Legend

– Removed lines
+ Added lines
< Changed lines (old)
> Changed lines (new)