使用快意灌水堂的FB2000代码,运行一段时间以后发现.PASSWDS变成800M,showuser
显示有很多空的ID,遂摹仿showuser.c写了一段小程序,把.PASSWDS里面ID是a到z之间
的写入NEWPASSWDS里面。经过我的试验,运行良好。以下是源代码,贴出来给大家参考。
注意使用NEWPASSWDS替换.PASSWDS前先备份.PASSWDS。
/*
功能 : 转化.PASSWDS为NEWPASSWDS,去掉垃圾帐号
注意事项 : 须要目前的 bbs.h
Compile : gcc -o convertpasswd convertpasswd.c
使用方式 : convertpasswd
代码放在跟showuser.c同一个目录下即$BBSHOME$/bbssrc/util/local_utl/
厦门大学芙八BBS地址: 210.34.20.66
*/
#include <stdio.h>
#include "../../include/bbs.h"
struct userec aman;
main()
{
FILE *inf;
FILE *outf;
int i, idcount = 0;
inf = fopen("../../../.PASSWDS", "rb");
if (inf == NULL) {
printf("Error open .PASSWDS\n");
exit(0);
}
outf = fopen("../../../NEWPASSWDS", "wb");
if (outf == NULL) {
printf("Error create NEWPASSWDS\n");
exit(0);
}
for (i = 0; ; i++) {
if (fread(&aman, sizeof(aman), 1, inf) <= 0) break;
if (!(((aman.userid[0] >= 'a') && (aman.userid[0] <= 'z')) ||
((aman.userid[0] >= 'A') && (aman.userid[0] <= 'Z'))))
continue;
fwrite(&aman, sizeof(aman), 1, outf);
idcount++;
}
fclose(inf);
fclose(outf);
printf("\nNEWPASSWDS created. %d id is written.\n", idcount);
}
--
FROM 210.34.9.179