2 * IRC - Internet Relay Chat, ircd/m_proto.c
3 * Copyright (C) 1990 Jarkko Oikarinen and
4 * University of Oulu, Computing Center
6 * See file AUTHORS in IRC package for additional names of
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 1, or (at your option)
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 #include "ircd_reply.h"
28 #include "ircd_snprintf.h"
36 int need_more_params(struct Client* cptr, const char* cmd)
38 sendto_one(cptr, err_str(ERR_NEEDMOREPARAMS),
39 me.name, (*cptr->name) ? cptr->name : "*", cmd);
44 * send_error_to_client - send an error message to a client
45 * I don't know if this function is any faster than the other version
46 * but it is a bit easier to use. It's reentrant until it hits vsendto_one
49 int send_error_to_client(struct Client* cptr, int error, ...)
54 const char* src = me.name;
55 const struct Numeric* num = get_error_numeric(error);
63 while ((*dest = *src++))
70 while ((*dest = *src++))
77 while ((*dest = *src++))
83 strcpy(dest, num->format);
86 Debug((DEBUG_INFO, "send_error_to_client: format: ->%s<-", buf));
90 vsendto_one(cptr, buf, vl);
96 int send_reply(struct Client *to, int reply, ...)
99 char sndbuf[IRC_BUFSIZE];
100 const struct Numeric *num;
105 num = get_error_numeric(reply); /* get information about reply... */
107 vd.vd_format = num->format; /* select format... */
110 va_start(vd.vd_args, reply);
112 ircd_snprintf(to, sndbuf, sizeof(sndbuf) - 2, ":%s %s %C %v", me.name,
115 ircd_snprintf(to, sndbuf, sizeof(sndbuf) - 2, "%C %s %C %v", &me, num->str,
119 /* send it to the user */
120 send_buffer(to, sndbuf);
122 return 0; /* convenience return */
125 int send_admin_info(struct Client* sptr, const struct ConfItem* admin)
129 sendto_one(sptr, rpl_str(RPL_ADMINME), me.name, sptr->name, me.name);
130 sendto_one(sptr, rpl_str(RPL_ADMINLOC1), me.name, sptr->name, admin->host);
131 sendto_one(sptr, rpl_str(RPL_ADMINLOC2), me.name, sptr->name, admin->passwd);
132 sendto_one(sptr, rpl_str(RPL_ADMINEMAIL), me.name, sptr->name, admin->name);
135 send_error_to_client(sptr, ERR_NOADMININFO, me.name);