#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
#include "../control/control.h" /* controlreply() */
#include "../irc/irc.h" /* irc_send() */
unsigned int duration;
int count;
int type;
+ char reason[NSMAX_REASON_LEN];
};
struct searchNode *gline_parse(int type, int argc, char **argv) {
struct gline_localdata *localdata;
struct searchNode *thenode;
+ int len;
if (!(localdata = (struct gline_localdata *) malloc(sizeof(struct gline_localdata)))) {
parseError = "malloc: could not allocate memory for this search.";
else
localdata->marker = nextnickmarker();
- /* gline durations */
- if (argc<1)
+ switch (argc) {
+ case 0:
localdata->duration = NSGLINE_DURATION;
- else {
+ snprintf(localdata->reason, NSMAX_REASON_LEN, ".");
+ break;
+
+ case 1:
+ if (strchr(argv[0], ' ') == NULL) { /* duration specified */
+ localdata->duration = durationtolong(argv[0]);
+ /* error checking on gline duration */
+ if (localdata->duration == 0)
+ localdata->duration = NSGLINE_DURATION;
+ snprintf(localdata->reason, NSMAX_REASON_LEN, ".");
+ }
+ else { /* reason specified */
+ localdata->duration = NSGLINE_DURATION;
+ len = snprintf(localdata->reason, NSMAX_REASON_LEN, ":%s", argv[0]);
+ /* strip leading and trailing '"'s */
+ localdata->reason[1] = ' ';
+ localdata->reason[len-1] = '\0';
+ }
+ break;
+
+ case 2:
localdata->duration = durationtolong(argv[0]);
/* error checking on gline duration */
if (localdata->duration == 0)
localdata->duration = NSGLINE_DURATION;
+ len = snprintf(localdata->reason, NSMAX_REASON_LEN, ":%s", argv[1]);
+ /* strip leading and trailing '"'s */
+ localdata->reason[1] = ' ';
+ localdata->reason[len-1] = '\0';
+ break;
+
+ default:
+ free(localdata);
+ parseError = "gline: invalid number of arguments";
+ return NULL;
}
if (!(thenode=(struct searchNode *)malloc(sizeof (struct searchNode)))) {
if ((np=getnickbynumeric(cip->channel->users->content[j]))) {
if (!IsOper(np) && !IsService(np) && !IsXOper(np)) {
if (np->host->clonecount <= NSMAX_GLINE_CLONES)
- irc_send("%s GL * +*@%s %u :You (%s!%s@%s) have been glined for violating our terms of service.",
- mynumeric->content, IPtostr(np->p_ipaddr), localdata->duration, np->nick, np->ident, IPtostr(np->p_ipaddr));
+ irc_send("%s GL * +*@%s %u :You (%s!%s@%s) have been glined for violating our terms of service%s",
+ mynumeric->content, IPtostr(np->p_ipaddr), localdata->duration, np->nick, np->ident, IPtostr(np->p_ipaddr), localdata->reason);
else
- irc_send("%s GL * +%s@%s %u :You (%s!%s@%s) have been glined for violating our terms of service.",
- mynumeric->content, np->ident, IPtostr(np->p_ipaddr), localdata->duration, np->nick, np->ident, IPtostr(np->p_ipaddr));
+ irc_send("%s GL * +%s@%s %u :You (%s!%s@%s) have been glined for violating our terms of service%s",
+ mynumeric->content, np->ident, IPtostr(np->p_ipaddr), localdata->duration, np->nick, np->ident, IPtostr(np->p_ipaddr), localdata->reason);
}
else
safe++;
if (np->marker == localdata->marker) {
if (!IsOper(np) && !IsService(np) && !IsXOper(np)) {
if (np->host->clonecount <= NSMAX_GLINE_CLONES)
- irc_send("%s GL * +*@%s %u :You (%s!%s@%s) have been glined for violating our terms of service.",
- mynumeric->content, IPtostr(np->p_ipaddr), localdata->duration, np->nick, np->ident, IPtostr(np->p_ipaddr));
+ irc_send("%s GL * +*@%s %u :You (%s!%s@%s) have been glined for violating our terms of service%s",
+ mynumeric->content, IPtostr(np->p_ipaddr), localdata->duration, np->nick, np->ident, IPtostr(np->p_ipaddr), localdata->reason);
else
- irc_send("%s GL * +%s@%s %u :You (%s!%s@%s) have been glined for violating our terms of service.",
- mynumeric->content, np->ident, IPtostr(np->p_ipaddr), localdata->duration, np->nick, np->ident, IPtostr(np->p_ipaddr));
+ irc_send("%s GL * +%s@%s %u :You (%s!%s@%s) have been glined for violating our terms of service%s",
+ mynumeric->content, np->ident, IPtostr(np->p_ipaddr), localdata->duration, np->nick, np->ident, IPtostr(np->p_ipaddr), localdata->reason);
}
else
safe++;
unsigned int marker;
int count;
int type;
+ char reason[NSMAX_REASON_LEN];
};
struct searchNode *kill_parse(int type, int argc, char **argv) {
struct kill_localdata *localdata;
struct searchNode *thenode;
+ int len;
if (!(localdata = (struct kill_localdata *) malloc(sizeof(struct kill_localdata)))) {
parseError = "malloc: could not allocate memory for this search.";
else
localdata->marker = nextnickmarker();
+ if (argc==1) {
+ len = snprintf(localdata->reason, NSMAX_REASON_LEN, ":%s", argv[0]);
+ /* strip leading and trailing '"'s */
+ localdata->reason[1] = ' ';
+ localdata->reason[len-1] = '\0';
+ }
+ else
+ snprintf(localdata->reason, NSMAX_REASON_LEN, ".");
+
if (!(thenode=(struct searchNode *)malloc(sizeof (struct searchNode)))) {
/* couldn't malloc() memory for thenode, so free localdata to avoid leakage */
parseError = "malloc: could not allocate memory for this search.";
if ((np=getnickbynumeric(cip->channel->users->content[j]))) {
if (!IsOper(np) && !IsService(np) && !IsXOper(np)) {
- killuser(NULL, np, "You (%s!%s@%s) have been disconnected for violating our terms of service.", np->nick,
- np->ident, IPtostr(np->p_ipaddr));
+ killuser(NULL, np, "You (%s!%s@%s) have been disconnected for violating our terms of service%s", np->nick,
+ np->ident, IPtostr(np->p_ipaddr), localdata->reason);
}
else
safe++;
nnp = np->next;
if (np->marker == localdata->marker) {
if (!IsOper(np) && !IsService(np) && !IsXOper(np)) {
- killuser(NULL, np, "You (%s!%s@%s) have been disconnected for violating our terms of service.", np->nick,
- np->ident, IPtostr(np->p_ipaddr));
+ killuser(NULL, np, "You (%s!%s@%s) have been disconnected for violating our terms of service%s", np->nick,
+ np->ident, IPtostr(np->p_ipaddr), localdata->reason);
}
else
safe++;