#include "ircd.h"
#include "ircd_snprintf.h"
#include "numeric.h"
+#include "msg.h"
#include "s_conf.h"
#include "s_debug.h"
#include "send.h"
#include <assert.h>
+#include <string.h>
+
+/* Report a protocol violation warning to anyone listening. This can be
+ * easily used to cleanup the last couple of parts of the code up.
+ */
+
+int protocol_violation(struct Client* cptr, const char* pattern, ...)
+{
+ va_list vl;
+ char buffer[512];
+ assert(pattern);
+ assert(cptr);
+ va_start(vl,pattern);
+ ircd_snprintf(0,buffer,sizeof(buffer)-2,
+ "Protocol Violation from %C: %v",vl);
+ sendcmdto_flag_butone(&me, CMD_DESYNCH, NULL, FLAGS_DEBUG,
+ ":%s", cptr, buffer);
+ va_end(vl);
+ return 0;
+}
int need_more_params(struct Client* cptr, const char* cmd)
{
+ if (!MyUser(cptr))
+ protocol_violation(cptr,"Not enough parameters for %s",cmd);
send_reply(cptr, ERR_NEEDMOREPARAMS, cmd);
return 0;
}
assert(0 != to);
assert(0 != reply);
- num = get_error_numeric(reply & ~RPL_EXPLICIT); /* get reply... */
+ num = get_error_numeric(reply & ~SND_EXPLICIT); /* get reply... */
va_start(vd.vd_args, reply);
- if (reply & RPL_EXPLICIT) /* get right pattern */
+ if (reply & SND_EXPLICIT) /* get right pattern */
vd.vd_format = (const char *) va_arg(vd.vd_args, char *);
else
vd.vd_format = num->format;
assert(0 != vd.vd_format);
/* build buffer */
- ircd_snprintf(to, sndbuf, sizeof(sndbuf) - 2, "%:#C %s %C %v", &me, num->str,
- to, &vd);
+ ircd_snprintf(to->from, sndbuf, sizeof(sndbuf) - 2, "%:#C %s %C %v", &me,
+ num->str, to, &vd);
va_end(vd.vd_args);
return 0; /* convenience return */
}
-int send_admin_info(struct Client* sptr, const struct ConfItem* admin)
+int send_admin_info(struct Client* sptr)
{
+ const struct LocalConf* admin = conf_get_local();
assert(0 != sptr);
- if (admin) {
- send_reply(sptr, RPL_ADMINME, me.name);
- send_reply(sptr, RPL_ADMINLOC1, admin->host);
- send_reply(sptr, RPL_ADMINLOC2, admin->passwd);
- send_reply(sptr, RPL_ADMINEMAIL, admin->name);
- }
- else
- send_reply(sptr, ERR_NOADMININFO, me.name);
+
+ send_reply(sptr, RPL_ADMINME, me.name);
+ send_reply(sptr, RPL_ADMINLOC1, admin->location1);
+ send_reply(sptr, RPL_ADMINLOC2, admin->location2);
+ send_reply(sptr, RPL_ADMINEMAIL, admin->contact);
return 0;
}