用户:Antigng-bot/checkredirect
外观
int anaylseafd()
{
FILE *f,*g;
int i=0,j=0,flag=0,redirect=0,status=0,num=0,check=0,notl,dl;
char c,title[100],line[1000],*not="{{tl|notability}}",*d1="{{delh|",*d2="{{DELH|";
notl=strlen(not);
dl=strlen(d1);
f=fopen("a.txt","r+");
g=fopen("b.txt","w+");
printf("开始检查\n");
c=0;
while(!feof(f))
{
if(!check)
{
while(!feof(f))
{
fgets(line,1000,f);
// printf("%s\n",line);
i=0;
while(line[i]=='=')
{
check=1;
num++;i++;
}
if(check)
{
// printf("num=%d\n",num);
break;
}
}
}
fgets(line,1000,f);
// printf("%s\n",line);
i=0;
if(line[0]=='=')
{
if(!flag)
{
i=0;
termin: while(line[i])
{
for(j=0;j<notl;j++)
{
if(line[i+j]!=not[j]) break;
}
if(j==notl)
{
flag=1;
printf("有关注度讨论\n");
fprintf(g,"has notability\n");
fflush(g);
break;
}
else i++;
}
}
else if(status==0)
{
i=0;
while(line[i]=='=')
{
i++;
}
if(i==num+1)
{
flag=0;
printf("处理完成\n");
goto termin;
}
else
{
while(line[i]==' '||line[i]=='['||line[i]==':')
{
i++;
}
j=0;
do
{
title[j]=line[i];
i++;j++;
}while(line[i]!=']');
title[j]=0;
fprintf(g,"%s\n",title);
status=1;
}
}
}
i=0;
if(line[0]=='{'&&status==1)
{
for(i=0;i<dl;i++)
{
// printf("%c \n",line[i]);
if(line[i]!=d1[i]&&line[i]!=d2[i]) break;
}
if(i==dl)
{
// printf("%d\n",i);
if(((line[i]=='R'||line[i]=='r')&&(line[i+1]!='r'&&line[i+1]!='R')&&(line[i+2]!='P'&&line[i+2]!='p'))||((line[i]=='M'||line[i]=='m')&&(line[i+1]=='e'||line[i+1]=='E')))
{
redirect=1;
}
else redirect=0;
}
status=2;
}
if(status==2)
{
if(redirect==1)
{
i=checkredirect(title);
switch(i)
{
case 0:fprintf(g,"is redirect\n");fflush(g);
j=addtemp(title);
if(j==1){fprintf(g,"not a redirect\n");fflush(g);}
else if(j==0) {fprintf(g,"should be done\n");fflush(g);}
break;
case 1:fprintf(g,"already done\n");fflush(g);
break;
default:fprintf(g,"error\n");fflush(g);
}
}
status=0;
redirect=0;
}
}
fclose(f);fclose(g);
return 0;
}