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

Comparing ircd-hybrid/branches/8.2.x/modules/m_resv.c (file contents):
Revision 3377 by michael, Thu Apr 24 16:15:51 2014 UTC vs.
Revision 3560 by michael, Fri May 16 13:05:03 2014 UTC

# Line 39 | Line 39
39   #include "hash.h"
40  
41  
42 static void parse_resv(struct Client *, char *, int, char *);
43
44
45 /* mo_resv()
46 *   parv[0] = command
47 *   parv[1] = channel/nick to forbid
48 */
49 static int
50 mo_resv(struct Client *source_p, int parc, char *parv[])
51 {
52  char *resv = NULL;
53  char *reason = NULL;
54  char *target_server = NULL;
55  time_t tkline_time = 0;
56
57  /* RESV #channel ON irc.server.com :abuse
58   * RESV kiddie ON irc.server.com :abuse
59   */
60  if (parse_aline("RESV", source_p, parc, parv, AWILD, &resv, NULL,
61                  &tkline_time, &target_server, &reason) < 0)
62    return 0;
63
64  if (target_server)
65  {
66    /* if a given expire time is given, ENCAP it */
67    if (tkline_time)
68      sendto_match_servs(source_p, target_server, CAP_ENCAP,
69                         "ENCAP %s RESV %d %s 0 :%s",
70                         target_server, (int)tkline_time, resv, reason);
71    else
72      sendto_match_servs(source_p, target_server, CAP_CLUSTER,
73                         "RESV %s %s :%s",
74                         target_server, resv, reason);
75    /* Allow ON to apply local resv as well if it matches */
76    if (match(target_server, me.name))
77      return 0;
78  }
79  else
80  {
81    /* RESV #channel :abuse
82     * RESV kiddie :abuse
83     */
84    if (tkline_time)
85      cluster_a_line(source_p, "ENCAP", CAP_ENCAP, SHARED_RESV,
86                     "RESV %d %s 0 : %s", (int)tkline_time, resv, reason);
87    else
88      cluster_a_line(source_p, "RESV", CAP_KLN, SHARED_RESV,
89                     "%s : %s", resv, reason);
90  }
91
92  parse_resv(source_p, resv, (int)tkline_time, reason);
93  return 0;
94 }
95
96 /* me_resv()
97 *
98 * inputs       - server
99 *              - client (oper)
100 *              - parc number of arguments
101 *              - parv list of arguments
102 * via parv[]
103 * parv[0] = command
104 * parv[1] = tkline_time
105 * parv[2] = name
106 * parv[3] = 0
107 * parv[4] = reason
108 * parc should be 5
109 *
110 * outputs      - NONE
111 * side effects -
112 */
113 static int
114 me_resv(struct Client *source_p, int parc, char *parv[])
115 {
116  if (parc != 5 || !IsClient(source_p))
117    return 0;
118
119  parse_resv(source_p, parv[2], atoi(parv[1]), parv[4]);
120  return 0;
121 }
122
123 /* ms_resv()
124 *   parv[0] = command
125 *   parv[1] = target server
126 *   parv[2] = channel/nick to resv
127 *   parv[3] = reason
128 */
129 static int
130 ms_resv(struct Client *source_p, int parc, char *parv[])
131 {
132  if (parc != 4 || EmptyString(parv[3]))
133    return 0;
134
135  sendto_match_servs(source_p, parv[1], CAP_CLUSTER,
136                     "RESV %s %s :%s",
137                     parv[1], parv[2], parv[3]);
138
139  if (!IsClient(source_p) || match(parv[1], me.name))
140    return 0;
141
142  if (HasFlag(source_p, FLAGS_SERVICE) || find_matching_name_conf(CONF_ULINE, source_p->servptr->name,
143                              source_p->username, source_p->host,
144                              SHARED_RESV))
145    parse_resv(source_p, parv[2], 0, parv[3]);
146  return 0;
147 }
148
42   /* parse_resv()
43   *
44   * inputs       - source_p, NULL supported
# Line 252 | Line 145 | parse_resv(struct Client *source_p, char
145    }
146   }
147  
148 + /* mo_resv()
149 + *   parv[0] = command
150 + *   parv[1] = channel/nick to forbid
151 + */
152 + static int
153 + mo_resv(struct Client *source_p, int parc, char *parv[])
154 + {
155 +  char *resv = NULL;
156 +  char *reason = NULL;
157 +  char *target_server = NULL;
158 +  time_t tkline_time = 0;
159 +
160 +  /* RESV #channel ON irc.server.com :abuse
161 +   * RESV kiddie ON irc.server.com :abuse
162 +   */
163 +  if (parse_aline("RESV", source_p, parc, parv, AWILD, &resv, NULL,
164 +                  &tkline_time, &target_server, &reason) < 0)
165 +    return 0;
166 +
167 +  if (target_server)
168 +  {
169 +    /* if a given expire time is given, ENCAP it */
170 +    if (tkline_time)
171 +      sendto_match_servs(source_p, target_server, CAP_ENCAP,
172 +                         "ENCAP %s RESV %d %s 0 :%s",
173 +                         target_server, (int)tkline_time, resv, reason);
174 +    else
175 +      sendto_match_servs(source_p, target_server, CAP_CLUSTER,
176 +                         "RESV %s %s :%s",
177 +                         target_server, resv, reason);
178 +    /* Allow ON to apply local resv as well if it matches */
179 +    if (match(target_server, me.name))
180 +      return 0;
181 +  }
182 +  else
183 +  {
184 +    /* RESV #channel :abuse
185 +     * RESV kiddie :abuse
186 +     */
187 +    if (tkline_time)
188 +      cluster_a_line(source_p, "ENCAP", CAP_ENCAP, SHARED_RESV,
189 +                     "RESV %d %s 0 : %s", (int)tkline_time, resv, reason);
190 +    else
191 +      cluster_a_line(source_p, "RESV", CAP_KLN, SHARED_RESV,
192 +                     "%s : %s", resv, reason);
193 +  }
194 +
195 +  parse_resv(source_p, resv, (int)tkline_time, reason);
196 +  return 0;
197 + }
198 +
199 + /* me_resv()
200 + *
201 + * inputs       - server
202 + *              - client (oper)
203 + *              - parc number of arguments
204 + *              - parv list of arguments
205 + * via parv[]
206 + * parv[0] = command
207 + * parv[1] = tkline_time
208 + * parv[2] = name
209 + * parv[3] = 0
210 + * parv[4] = reason
211 + * parc should be 5
212 + *
213 + * outputs      - NONE
214 + * side effects -
215 + */
216 + static int
217 + me_resv(struct Client *source_p, int parc, char *parv[])
218 + {
219 +  if (parc != 5 || !IsClient(source_p))
220 +    return 0;
221 +
222 +  parse_resv(source_p, parv[2], atoi(parv[1]), parv[4]);
223 +  return 0;
224 + }
225 +
226 + /* ms_resv()
227 + *   parv[0] = command
228 + *   parv[1] = target server
229 + *   parv[2] = channel/nick to resv
230 + *   parv[3] = reason
231 + */
232 + static int
233 + ms_resv(struct Client *source_p, int parc, char *parv[])
234 + {
235 +  if (parc != 4 || EmptyString(parv[3]))
236 +    return 0;
237 +
238 +  sendto_match_servs(source_p, parv[1], CAP_CLUSTER,
239 +                     "RESV %s %s :%s",
240 +                     parv[1], parv[2], parv[3]);
241 +
242 +  if (!IsClient(source_p) || match(parv[1], me.name))
243 +    return 0;
244 +
245 +  if (HasFlag(source_p, FLAGS_SERVICE) || find_matching_name_conf(CONF_ULINE, source_p->servptr->name,
246 +                              source_p->username, source_p->host,
247 +                              SHARED_RESV))
248 +    parse_resv(source_p, parv[2], 0, parv[3]);
249 +  return 0;
250 + }
251 +
252   static struct Message resv_msgtab =
253   {
254    "RESV", 0, 0, 3, MAXPARA, MFLG_SLOW, 0,

Diff Legend

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