This commit is contained in:
2023-12-22 22:53:54 -05:00
commit 2821b7e9a1
45 changed files with 8425 additions and 0 deletions

100
banlist.c Normal file
View File

@@ -0,0 +1,100 @@
#include <stdio.h>
#include <string.h>
#include <time_t>
extern int sevsck;
struct aBan {
struct aBan *next;
char channel[255];
char mask[150];
char who[10];
time_t timeout;
};
struct *banlist=NULL;
int addban(char *who,char *mask,char *channel,time_t timeout)
{
struct aBan *tmpban;
char outputbuf[512];
tmpban=(struct aBan *) malloc(sizeof(struct aBan));
strcpy(tmpban->mask,mask);
strcpy(tmpban->who,who);
strcpy(tmpban->channel,channel);
tmpban->timeout = timeout;
tmpban->next=bansist;
banlist=tmpban;
sprintf(outputbuf,":chansvr MODE %s +b %s\n",tmpban->channel,tmpban->mask);
writeln(sevsck,outputbuf);
return 1;
}
int remove_ban(char *mask)
{ struct aBan *tmpban,*tmp2ban;
char outputbuf[512];
tmp2ban=banlist;
if(tmp2ban == NULL) return;
if(!strcasecmp(banlist->mask,mask))
{ banlist=banlist->next;
free(tmp2ban);
return 1;
}
tmpban = banlist->next;
while(tmpban != NULL)
{ if( !strcasecmp(tmpban->mask,mask))
{ tmp2ban->next=tmpban->next;
sprintf(outputbuf,":Chansvr MODE %s -b %s\n",tmpban->channel,
tmpban->mask);
writeln(sevsck,outputbuf);
free(tmpban);
return 1;
}
tmp2ban=tmpban;
tmpban=tmpban->next;
}
}
int timeout_ban()
{ struct aBan *tmpban,*tmp2ban;
char outputbuf[512];
tmp2ban=banlist;
if((tmp2ban == NULL) || (tmp2ban->next == NULL)) return;
/* if((banlist->timeout > 0) && (banlist->timeout < NOWTIME))
** { banlist=banlist->next;
** free(tmp2ban);
** return 1;
** }
*/
tmpban = banlist->next;
while(tmpban != NULL)
{ if((tmpban->timeout > 0) && (tmpban->timeout < NOWTIME))
{ tmp2ban->next=tmpban->next;
sprintf(outputbuf,":Chansvr MODE %s -b %s\n",tmpban->channel,
tmpban->mask);
writeln(sevsck,outputbuf);
free(tmpban);
tmpban=tmp2ban->next;
continue;
/* return 1;
*/
}
tmp2ban=tmpban;
tmpban=tmpban->next;
}
}