41 |
|
|
42 |
|
|
43 |
static void m_whowas(struct Client *, struct Client *, int, char *[]); |
static void m_whowas(struct Client *, struct Client *, int, char *[]); |
44 |
static void mo_whowas(struct Client *, struct Client *, int, char *[]); |
static void whowas_do(struct Client *, int, char *[]); |
|
static void whowas_do(struct Client *, struct Client *, int, char *[]); |
|
45 |
|
|
46 |
struct Message whowas_msgtab = { |
struct Message whowas_msgtab = { |
47 |
"WHOWAS", 0, 0, 0, 0, MFLG_SLOW, 0, |
"WHOWAS", 0, 0, 0, 0, MFLG_SLOW, 0, |
48 |
{ m_unregistered, m_whowas, mo_whowas, m_ignore, mo_whowas, m_ignore } |
{ m_unregistered, m_whowas, m_whowas, m_ignore, m_whowas, m_ignore } |
49 |
}; |
}; |
50 |
|
|
51 |
INIT_MODULE(m_whowas, "$Revision$") |
INIT_MODULE(m_whowas, "$Revision$") |
58 |
mod_del_cmd(&whowas_msgtab); |
mod_del_cmd(&whowas_msgtab); |
59 |
} |
} |
60 |
|
|
61 |
/* |
/*! \brief WHOWAS command handler (called for both local an remote clients) |
62 |
** m_whowas |
* |
63 |
** parv[0] = sender prefix |
* \param client_p Pointer to allocated Client struct with physical connection |
64 |
** parv[1] = nickname queried |
* to this server, i.e. with an open socket connected. |
65 |
*/ |
* \param source_p Pointer to allocated Client struct from which the message |
66 |
|
* originally comes from. This can be a local or remote client. |
67 |
|
* \param parc Integer holding the number of supplied arguments. |
68 |
|
* \param parv Argument vector where parv[0] .. parv[parc-1] are non-NULL |
69 |
|
* pointers. |
70 |
|
* \note Valid arguments for this command are: |
71 |
|
* - parv[0] = sender prefix |
72 |
|
* - parv[1] = nick |
73 |
|
* - parv[2] = count (optional; limited to 20 for remote requests) |
74 |
|
* - parv[3] = name of target (optional; string can be a nick or server |
75 |
|
* and can also include wildcards) |
76 |
|
*/ |
77 |
static void |
static void |
78 |
m_whowas(struct Client *client_p, struct Client *source_p, |
m_whowas(struct Client *client_p, struct Client *source_p, |
79 |
int parc, char *parv[]) |
int parc, char *parv[]) |
80 |
{ |
{ |
81 |
static time_t last_used = 0; |
static time_t last_used = 0; |
82 |
|
|
83 |
if (parc < 2 || *parv[1] == '\0') |
if (EmptyString(parv[1])) |
84 |
{ |
{ |
85 |
sendto_one(source_p, form_str(ERR_NONICKNAMEGIVEN), |
sendto_one(source_p, form_str(ERR_NONICKNAMEGIVEN), |
86 |
me.name, source_p->name); |
me.name, source_p->name); |
87 |
return; |
return; |
88 |
} |
} |
89 |
|
|
90 |
if ((last_used + ConfigFileEntry.pace_wait) > CurrentTime) |
if (MyConnect(source_p) && !IsOper(source_p)) |
91 |
{ |
{ |
92 |
sendto_one(source_p,form_str(RPL_LOAD2HI), |
if ((last_used + ConfigFileEntry.pace_wait) > CurrentTime) |
93 |
me.name, source_p->name); |
{ |
94 |
return; |
sendto_one(source_p,form_str(RPL_LOAD2HI), |
95 |
} |
me.name, source_p->name); |
96 |
|
return; |
97 |
last_used = CurrentTime; |
} |
|
|
|
|
whowas_do(client_p, source_p, parc, parv); |
|
|
} |
|
98 |
|
|
99 |
static void |
last_used = CurrentTime; |
|
mo_whowas(struct Client *client_p, struct Client *source_p, |
|
|
int parc, char *parv[]) |
|
|
{ |
|
|
if (parc < 2 || *parv[1] == '\0') |
|
|
{ |
|
|
sendto_one(source_p, form_str(ERR_NONICKNAMEGIVEN), |
|
|
me.name, source_p->name); |
|
|
return; |
|
100 |
} |
} |
101 |
|
|
102 |
whowas_do(client_p, source_p, parc, parv); |
whowas_do(source_p, parc, parv); |
103 |
} |
} |
104 |
|
|
105 |
static void |
static void |
106 |
whowas_do(struct Client *client_p, struct Client *source_p, |
whowas_do(struct Client *source_p, int parc, char *parv[]) |
|
int parc, char *parv[]) |
|
107 |
{ |
{ |
108 |
const dlink_node *ptr = NULL; |
const dlink_node *ptr = NULL; |
109 |
|
const char *nick = NULL; |
110 |
int cur = 0; |
int cur = 0; |
111 |
int max = -1; |
int max = -1; |
|
char *p = NULL, *nick = NULL; |
|
112 |
|
|
113 |
if (parc > 2) |
if (parc > 2) |
114 |
{ |
{ |
119 |
} |
} |
120 |
|
|
121 |
if (parc > 3) |
if (parc > 3) |
122 |
if (hunt_server(client_p, source_p, ":%s WHOWAS %s %s :%s", 3, |
if (hunt_server(source_p->from, source_p, ":%s WHOWAS %s %s :%s", 3, |
123 |
parc, parv) != HUNTED_ISME) |
parc, parv) != HUNTED_ISME) |
124 |
return; |
return; |
125 |
|
|
126 |
nick = parv[1]; |
nick = parv[1]; |
|
while (*nick == ',') |
|
|
nick++; |
|
|
if ((p = strchr(nick,',')) != NULL) |
|
|
*p = '\0'; |
|
|
if (*nick == '\0') |
|
|
return; |
|
127 |
|
|
128 |
DLINK_FOREACH(ptr, WHOWASHASH[strhash(nick)].head) |
DLINK_FOREACH(ptr, WHOWASHASH[strhash(nick)].head) |
129 |
{ |
{ |