Beispiel #1
0
void G_SayCensor_Init()
{
	fileHandle_t file;
	int read;
	badwordsList_t *this;
	qboolean exactmatch;
	char buff[24];
	char line[24];
	char* linept;
	register int i=0;

        Plugin_FS_SV_FOpenFileRead("badwords.txt",&file);
        if(!file){
            Plugin_Printf("Censor_Plugin: Can not open badwords.txt for reading\n");
            return;
        }
        for(i = 0; ;i++){
            read = Plugin_FS_ReadLine(buff,sizeof(buff),file);

            if(read == 0){
                Plugin_Printf("%i lines parsed from badwords.txt\n",i);
                Plugin_FS_FCloseFile(file);
                return;
            }
            if(read == -1){
                Plugin_Printf("Can not read from badwords.txt\n");
                Plugin_FS_FCloseFile(file);
                return;
            }

            Q_strncpyz(line,buff,sizeof(line));
            linept = line;

            if(*linept == '#'){
                exactmatch = qtrue;
                linept++;
            }else{
                exactmatch = qfalse;
            }

            this = Plugin_Malloc(sizeof(badwordsList_t));
            if(this){
                this->next = badwords;
                this->exactmatch = exactmatch;
                Q_strncpyz(this->word,linept,strlen(linept));
            	badwords = this;
	    }
        }
		Plugin_Printf("Censor: init complete.\n");
}
Beispiel #2
0
void SV_LoadBanlist(){
    time_t aclock;
    time(&aclock);
    char buf[256];
    buf[0] = 0;
    fileHandle_t file;
    int read;
    int error;
    int i;

    Plugin_FS_SV_FOpenFileRead(banlistfile->string,&file);
    if(!file){
        Plugin_DPrintf("SV_ReadBanlist: Can not open %s for reading\n",banlistfile->string);
        return;
    }

    for(i = 0, error = 0 ;error < 32 ;i++){

        read = Plugin_FS_ReadLine(buf,sizeof(buf),file);
        if(read == 0){
            Plugin_Printf("%i lines parsed from %s, %i errors occured\n",i,banlistfile->string,error);
            Plugin_FS_FCloseFile(file);
            return;
        }
        if(read == -1){
            Plugin_Printf("Can not read from %s\n",banlistfile->string);
            Plugin_FS_FCloseFile(file);
            return;
        }
        if(!*buf || *buf == '/' || *buf == '\n'){
            continue;
        }
        if(!SV_ParseBanlist(buf, aclock, i+1)) error++; //Executes the function given as argument in execute

    }
    Plugin_PrintWarning("More than 32 errors occured by reading from %s\n",banlistfile->string);
    Plugin_FS_FCloseFile(file);
}