/* * list_quote_commands() sends the client all the available commands. * Four to a line for now. */ static void list_quote_commands(struct Client *source_p) { int i; int j = 0; const char *names[4]; SetCork(source_p); sendto_one_notice(source_p, ":Available QUOTE SET commands:"); names[0] = names[1] = names[2] = names[3] = ""; for(i = 0; set_cmd_table[i].handler; i++) { names[j++] = set_cmd_table[i].name; if(j > 3) { sendto_one_notice(source_p, ":%s %s %s %s", names[0], names[1], names[2], names[3]); j = 0; names[0] = names[1] = names[2] = names[3] = ""; } } if(j) sendto_one_notice(source_p, ":%s %s %s %s", names[0], names[1], names[2], names[3]); ClearCork(source_p); send_pop_queue(source_p); }
/* * handle_command * * inputs - pointer to message block * - pointer to client * - pointer to client message is from * - count of number of args * - pointer to argv[] array * output - -1 if error from server * side effects - */ static int handle_command(struct Message *mptr, struct Client *client_p, struct Client *from, int i, const char **hpara) { struct MessageEntry ehandler; MessageHandler handler = 0; static time_t last_warning; if(IsAnyDead(client_p)) return -1; if(IsServer(client_p)) mptr->rcount++; mptr->count++; ehandler = mptr->handlers[from->handler]; handler = ehandler.handler; /* check right amount of params is passed... --is */ if(i < ehandler.min_para || (ehandler.min_para && EmptyString(hpara[ehandler.min_para - 1]))) { if(!IsServer(client_p)) { sendto_one_numeric(client_p, s_RPL(ERR_NEEDMOREPARAMS), mptr->cmd); if(MyClient(client_p)) return (1); else return (-1); } sendto_realops_flags(UMODE_ALL, L_ALL, "Dropping server %s due to (invalid) command '%s'" " with only %d arguments (expecting %d).", client_p->name, mptr->cmd, i, ehandler.min_para); ilog(L_SERVER, "Insufficient parameters (%d) for command '%s' from %s.", i, mptr->cmd, client_p->name); exit_client(client_p, client_p, client_p, "Not enough arguments to server command."); return (-1); } if(handler == NULL) /* module hasn't set a handler, just use m_ignore */ handler = m_ignore; (*handler) (client_p, from, i, hpara); if(!IsAnyDead(client_p) && IsCork(client_p) && !IsCapable(client_p, CAP_ZIP)) { if(last_warning + 300 <= rb_current_time()) { sendto_realops_flags(UMODE_DEBUG, L_ALL, "Bug: client %s was left corked after command %s", client_p->name, mptr->cmd); last_warning = rb_current_time(); } client_p->localClient->cork_count = 0; send_pop_queue(client_p); } return (1); }
/* * do_admin * * inputs - pointer to client to report to * output - none * side effects - admin info is sent to client given */ static void do_admin(struct Client *source_p) { const char *myname; const char *nick; if(IsClient(source_p)) admin_spy(source_p); myname = get_id(&me, source_p); nick = EmptyString(source_p->name) ? "*" : get_id(source_p, source_p); SetCork(source_p); sendto_one(source_p, form_str(RPL_ADMINME), myname, nick, me.name); if(AdminInfo.name != NULL) sendto_one(source_p, form_str(RPL_ADMINLOC1), myname, nick, AdminInfo.name); if(AdminInfo.description != NULL) sendto_one(source_p, form_str(RPL_ADMINLOC2), myname, nick, AdminInfo.description); if(AdminInfo.email != NULL) sendto_one(source_p, form_str(RPL_ADMINEMAIL), myname, nick, AdminInfo.email); ClearCork(source_p); send_pop_queue(source_p); }
/* * handle_command * * inputs - pointer to message block * - pointer to client * - pointer to client message is from * - count of number of args * - pointer to argv[] array * output - -1 if error from server * side effects - */ static int handle_command(struct Message *mptr, struct Client *client_p, struct Client *from, int i, const char **hpara) { struct MessageEntry ehandler; MessageHandler handler = 0; static time_t last_warning; if(IsAnyDead(client_p)) return -1; if(IsServer(client_p)) mptr->rcount++; mptr->count++; /* New patch to avoid server flooding from unregistered connects - Pie-Man 07/27/2000 */ if(!IsRegistered(client_p)) { /* if its from a possible server connection * ignore it.. more than likely its a header thats sneaked through */ if(IsAnyServer(client_p) && !(mptr->flags & MFLG_UNREG)) return (1); } ehandler = mptr->handlers[from->handler]; handler = ehandler.handler; /* check right amount of params is passed... --is */ if(i < ehandler.min_para || (ehandler.min_para && EmptyString(hpara[ehandler.min_para - 1]))) { if(!IsServer(client_p)) { sendto_one(client_p, form_str(ERR_NEEDMOREPARAMS), me.name, EmptyString(client_p->name) ? "*" : client_p->name, mptr->cmd); if(MyClient(client_p)) return (1); else return (-1); } sendto_realops_flags(UMODE_ALL, L_ALL, "Dropping server %s due to (invalid) command '%s'" " with only %d arguments (expecting %d).", client_p->name, mptr->cmd, i, ehandler.min_para); ilog(L_SERVER, "Insufficient parameters (%d) for command '%s' from %s.", i, mptr->cmd, client_p->name); exit_client(client_p, client_p, client_p, "Not enough arguments to server command."); return (-1); } (*handler) (client_p, from, i, hpara); if(!IsAnyDead(client_p) && IsCork(client_p) && !IsCapable(client_p, CAP_ZIP)) { if(last_warning + 300 <= rb_time()) { sendto_realops_flags(UMODE_DEBUG, L_ALL, "Bug: client %s was left corked after command %s", client_p->name, mptr->cmd); last_warning = rb_time(); } client_p->localClient->cork_count = 0; send_pop_queue(client_p); } return (1); }