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

Comparing ircd-hybrid-7.2/modules/m_testline.c (file contents):
Revision 592 by db, Sun Oct 16 18:14:43 2005 UTC vs.
Revision 593 by michael, Fri May 12 05:47:32 2006 UTC

# Line 40 | Line 40
40   #include "hash.h"
41   #include "modules.h"
42  
43 < static void mo_testline(struct Client*, struct Client*, int, char**);
44 < static void mo_testgecos(struct Client*, struct Client*, int, char**);
43 > static void mo_testline(struct Client *, struct Client *, int, char *[]);
44 > static void mo_testgecos(struct Client *, struct Client *, int, char *[]);
45  
46   struct Message testline_msgtab = {
47    "TESTLINE", 0, 0, 0, 0, MFLG_SLOW, 0,
48 <  {m_unregistered, m_not_oper, m_ignore, m_ignore, mo_testline, m_ignore}
48 >  { m_unregistered, m_not_oper, m_ignore, m_ignore, mo_testline, m_ignore }
49   };
50  
51   struct Message testgecos_msgtab = {
52    "TESTGECOS", 0, 0, 0, 0, MFLG_SLOW, 0,
53 <  {m_unregistered, m_not_oper, m_ignore, m_ignore, mo_testgecos, m_ignore}
53 >  { m_unregistered, m_not_oper, m_ignore, m_ignore, mo_testgecos, m_ignore }
54   };
55  
56   #ifndef STATIC_MODULES
# Line 88 | Line 88 | static void
88   mo_testline(struct Client *client_p, struct Client *source_p,
89              int parc, char *parv[])
90   {
91 <  char *orig_parv1;
92 <  char *given_name;
93 <  char *given_host = NULL;
91 >  char *orig_parv1 = NULL;
92 >  /* IRCD_BUFSIZE to allow things like *u*s*e*r*n*a*m*e* etc. */
93 >  char given_name[IRCD_BUFSIZE];
94 >  char given_host[IRCD_BUFSIZE];
95    struct ConfItem *conf;
96    struct AccessItem *aconf;
97    struct irc_ssaddr ip;
# Line 98 | Line 99 | mo_testline(struct Client *client_p, str
99    int t;
100    int matches = 0;
101    char userhost[HOSTLEN + USERLEN + 2];
102 +  struct split_nuh_item nuh;
103  
104 <  if (parc < 2 || EmptyString(parv[1]))
104 >  if (EmptyString(parv[1]))
105    {
106      sendto_one(source_p, ":%s NOTICE %s :usage: user@host|ip [password]",
107                 me.name, source_p->name);
108      return;
109    }
110  
111 <  given_name = parv[1];
110 <
111 <  if (IsChanPrefix(*given_name))        /* Might be channel resv */
111 >  if (IsChanPrefix(*parv[1]))    /* Might be channel resv */
112    {
113 <    struct ResvChannel *chptr;
114 <    
115 <    chptr = match_find_resv(given_name);
116 <    if (chptr != NULL)
113 >    const struct ResvChannel *chptr = NULL;
114 >
115 >    if ((chptr = match_find_resv(parv[1])))
116      {
117 <      sendto_one(source_p,
118 <                 form_str(RPL_TESTLINE),
119 <                 me.name, source_p->name,
121 <                 'Q', 0, chptr->name,
122 <                 chptr->reason ? chptr->reason : "No reason", "" );
117 >      sendto_one(source_p, form_str(RPL_TESTLINE),
118 >                 me.name, source_p->name, 'Q', 0, chptr->name,
119 >                 chptr->reason ? chptr->reason : "No reason", "");
120        return;
121      }
122    }
123  
124    DupString(orig_parv1,parv[1]);
125 <  split_nuh(given_name, NULL, &given_name, &given_host);
125 >
126 >  nuh.nuhmask  = parv[1];
127 >  nuh.nickptr  = NULL;
128 >  nuh.userptr  = given_name;
129 >  nuh.hostptr  = given_host;
130 >
131 >  nuh.nicksize = 0;
132 >  nuh.usersize = sizeof(given_name);
133 >  nuh.hostsize = sizeof(given_host);
134 >
135 >  split_nuh(&nuh);
136  
137    t = parse_netmask(given_host, &ip, &host_mask);
138  
# Line 133 | Line 140 | mo_testline(struct Client *client_p, str
140    {
141      aconf = find_dline_conf(&ip,
142   #ifdef IPV6
143 <                            (t == HM_IPV6) ? AF_INET6 : AF_INET
143 >                            (t == HM_IPV6) ? AF_INET6 : AF_INET
144   #else
145 <                            AF_INET
145 >                            AF_INET
146   #endif
147 <                            );
147 >                            );
148      if (aconf != NULL)
149      {
150        conf = unmap_conf_item(aconf);
151  
152        if (aconf->status & CONF_EXEMPTDLINE)
153        {
154 <        sendto_one(source_p,
155 <                   ":%s NOTICE %s :Exempt D-line host [%s] reason [%s]",
156 <                   me.name, source_p->name, aconf->host, aconf->reason);
157 <        ++matches;
154 >        sendto_one(source_p,
155 >                   ":%s NOTICE %s :Exempt D-line host [%s] reason [%s]",
156 >                   me.name, source_p->name, aconf->host, aconf->reason);
157 >        ++matches;
158        }
159        else
160        {
161 <        sendto_one(source_p,
162 <                   form_str(RPL_TESTLINE),
163 <                   me.name, source_p->name,
164 <                   IsConfTemporary(aconf) ? 'd' : 'D',
165 <                   IsConfTemporary(aconf) ? ((aconf->hold - CurrentTime) / 60)
166 <                   : 0L,
167 <                   aconf->host, aconf->reason, aconf->oper_reason);
161 <        ++matches;
161 >        sendto_one(source_p, form_str(RPL_TESTLINE),
162 >                   me.name, source_p->name,
163 >                   IsConfTemporary(aconf) ? 'd' : 'D',
164 >                   IsConfTemporary(aconf) ? ((aconf->hold - CurrentTime) / 60)
165 >                   : 0L,
166 >                   aconf->host, aconf->reason, aconf->oper_reason);
167 >        ++matches;
168        }
169      }
170    }
# Line 168 | Line 174 | mo_testline(struct Client *client_p, str
174    {
175      snprintf(userhost, sizeof(userhost), "%s@%s", aconf->user, aconf->host);
176      sendto_one(source_p, form_str(RPL_TESTLINE),
177 <               me.name, source_p->name,
178 <               IsConfTemporary(aconf) ? 'k' : 'K',
179 <               IsConfTemporary(aconf) ? ((aconf->hold - CurrentTime) / 60)
180 <               : 0L,
181 <               userhost,
182 <               aconf->passwd ? aconf->passwd : "No reason",
183 <               aconf->oper_reason ? aconf->oper_reason : "");
177 >               me.name, source_p->name,
178 >               IsConfTemporary(aconf) ? 'k' : 'K',
179 >               IsConfTemporary(aconf) ? ((aconf->hold - CurrentTime) / 60)
180 >               : 0L,
181 >               userhost,
182 >               aconf->passwd ? aconf->passwd : "No reason",
183 >               aconf->oper_reason ? aconf->oper_reason : "");
184      ++matches;
185    }
186  
# Line 199 | Line 205 | mo_testline(struct Client *client_p, str
205      if (aconf->status & CONF_CLIENT)
206      {
207        sendto_one(source_p, form_str(RPL_TESTLINE),
208 <                 me.name, source_p->name,
209 <                 'I', 0L, userhost,
210 <                 aconf->class_ptr ? aconf->class_ptr->name : "<default>", "");
208 >                 me.name, source_p->name,
209 >                 'I', 0L, userhost,
210 >                 aconf->class_ptr ? aconf->class_ptr->name : "<default>", "");
211        ++matches;
212      }
213      else if (aconf->status & CONF_KILL)
214      {
215        sendto_one(source_p, form_str(RPL_TESTLINE),
216 <                 me.name, source_p->name,
217 <                 IsConfTemporary(aconf) ? 'k' : 'K',
218 <                 IsConfTemporary(aconf) ? ((aconf->hold - CurrentTime) / 60)
219 <                 : 0L,
220 <                 userhost, aconf->passwd ? aconf->passwd : "No reason",
221 <                 aconf->oper_reason ? aconf->oper_reason : "");
216 >                 me.name, source_p->name,
217 >                 IsConfTemporary(aconf) ? 'k' : 'K',
218 >                 IsConfTemporary(aconf) ? ((aconf->hold - CurrentTime) / 60)
219 >                 : 0L,
220 >                 userhost, aconf->passwd ? aconf->passwd : "No reason",
221 >                 aconf->oper_reason ? aconf->oper_reason : "");
222        ++matches;
223      }
224    }
# Line 225 | Line 231 | mo_testline(struct Client *client_p, str
231      mconf = (struct MatchItem *)map_to_conf(conf);
232  
233      sendto_one(source_p, form_str(RPL_TESTLINE),
234 <               me.name, source_p->name,
235 <               'Q', 0L,
236 <               conf->name,
237 <               mconf->reason ? mconf->reason : "No reason",
238 <               mconf->oper_reason ? mconf->oper_reason : "");
234 >               me.name, source_p->name,
235 >               'Q', 0L,
236 >               conf->name,
237 >               mconf->reason ? mconf->reason : "No reason",
238 >               mconf->oper_reason ? mconf->oper_reason : "");
239      ++matches;
240    }
241  
242    if (matches == 0)
243      sendto_one(source_p, form_str(RPL_NOTESTLINE),
244 <               me.name, source_p->name, orig_parv1);
244 >               me.name, source_p->name, orig_parv1);
245  
240  MyFree(given_host);
241  MyFree(given_name);
246    MyFree(orig_parv1);
247   }
248  
# Line 261 | Line 265 | mo_testgecos(struct Client *client_p, st
265   {
266    struct ConfItem *conf = NULL;
267    struct MatchItem *xconf = NULL;
264  const char *gecos_name = NULL;
268  
269 <  if (parc < 2 || EmptyString(parv[1]))
269 >  if (EmptyString(parv[1]))
270    {
271      sendto_one(source_p, ":%s NOTICE %s :usage: gecos",
272                 me.name, source_p->name);
273      return;
274    }
275  
276 <  gecos_name = parv[1];
274 <
275 <  if ((conf = find_matching_name_conf(XLINE_TYPE, gecos_name, NULL, NULL, 0))
276 <      != NULL)
276 >  if ((conf = find_matching_name_conf(XLINE_TYPE, parv[1], NULL, NULL, 0)))
277    {
278 <    xconf = (struct MatchItem *)map_to_conf(conf);
278 >    xconf = map_to_conf(conf);
279      sendto_one(source_p, form_str(RPL_TESTLINE),
280 <               me.name, source_p->name, 'X', 0L,
281 <               conf->name, xconf->reason ? xconf->reason : "X-lined",
282 <               xconf->oper_reason ? xconf->oper_reason : "");
280 >               me.name, source_p->name, 'X', 0L,
281 >               conf->name, xconf->reason ? xconf->reason : "X-lined",
282 >               xconf->oper_reason ? xconf->oper_reason : "");
283    }
284    else
285      sendto_one(source_p, form_str(RPL_NOTESTLINE),
286 <               me.name, source_p->name, parv[1]);
286 >               me.name, source_p->name, parv[1]);
287   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines