Skip to content
Snippets Groups Projects
Commit fa3b970c authored by rswindell's avatar rswindell
Browse files

Created exported function: filter_ip(), adds IP address to ip filter file with

comment.
parent 4eb129df
No related branches found
No related tags found
No related merge requests found
......@@ -796,6 +796,7 @@ extern "C" {
DLLEXPORT char * DLLCALL ascii_str(uchar* str);
DLLEXPORT BOOL DLLCALL findstr(char *insearch, char *fname);
DLLEXPORT BOOL DLLCALL trashcan(scfg_t* cfg, char *insearch, char *name);
DLLEXPORT BOOL DLLCALL filter_ip(scfg_t* cfg, char* prot, char* reason, char* ip_addr, char* username);
DLLEXPORT char * DLLCALL strip_exascii(char *str);
DLLEXPORT char * DLLCALL prep_file_desc(char *str);
DLLEXPORT char * DLLCALL strip_ctrl(char *str);
......
......@@ -194,6 +194,28 @@ BOOL DLLCALL trashcan(scfg_t* cfg, char* insearchof, char* name)
return(findstr(insearchof,fname));
}
/****************************************************************************/
/* Add an IP address (with comment) to the IP filter/trashcan file */
/****************************************************************************/
BOOL DLLCALL filter_ip(scfg_t* cfg, char* prot, char* reason, char* ip_addr, char* username)
{
char filename[MAX_PATH+1];
char tstr[64];
FILE* fp;
time_t now=time(NULL);
sprintf(filename,"%sip.can",cfg->text_dir);
if((fp=fopen(filename,"a"))==NULL)
return(FALSE);
fprintf(fp,"\n;%s %s by %s on %s\n%s\n"
,prot,reason,username,timestr(cfg,&now,tstr),ip_addr);
fclose(fp);
return(TRUE);
}
/****************************************************************************/
/* Returns the number of characters in 'str' not counting ctrl-ax codes */
/* or the null terminator */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment