/*
转换fb2000的.BOARDS到ytht的.BOARDS
by happybird 2004/12/10
happybird@岱北聆泉站
happybird@mail.sdu.edu.cn
gcc -g -Wall -I include -I ythtlib -I libythtbbs tran_fb2k_board.c -o tran_fb2k_board
*/
#include "bbs.h"
/*
struct boardheader {
char filename[24];
char title[24];
int clubnum;
unsigned level;
char flag;
char secnumber1;
char secnumber2;
char type[5];
char bm[BMNUM][IDLEN + 1];
int hiretime[BMNUM];
int board_ctime;
int board_mtime;
char sec1[4];
char sec2[4];
unsigned char limitchar; //upper limit/100
char flag2;
char nouse[2];
char unused[156];
};
*/
/*
//find this in menu.ini of fb2000
EGROUP0 = "a"
EGROUP1 = "bcd"
EGROUP2 = "efg"
EGROUP3 = "hi"
EGROUP4 = "jk"
EGROUP5 = "lm"
EGROUP6 = "n"
EGROUP7 = "op"
*/
/*
//find this in seclist.txt of ytht
%description of sections
@0 [本站]
@1 [院系][校园][高校]
@2 [科学][人文][信息]
@3 [闲聊][感性]
@4 [电脑][系统][网路]
@5 [休闲][娱乐]
@6 [特区]
@7 [社团][群体]
@L [同学录]
@C [俱乐部]
*/
#define FB_BM_LEN 60
#define FB_STRLEN 80 /* Length of most string data */
#define FB_NAMELEN 40 /* Length of username/realname */
#define FB_IDLEN 12 /* Length of userids */
#define FB_ENCPASSLEN 14 //ifdef MD5 should be 35
#define FB_PASSLEN 14 /* User's password length (13 chars) */
struct fb_boardheader { /* This structure is used to hold data in */
char filename[FB_STRLEN]; /* the BOARDS files */
char owner[FB_STRLEN - FB_BM_LEN];
char BM[ FB_BM_LEN - 1];
char flag;
char title[FB_STRLEN ];
unsigned level;
unsigned char accessed[ 12 ];
};
struct boardheader nb;
struct fb_boardheader ob;
int
main(int argc,char *argv[])
{
char sec[8][5] = { "a", "bcd", "efg", "hi", "jk", "lm", "n", "op"};
char secname[11] = "01234567TYC";
FILE *fp1, *fp2;
int i, j, bnum = 0;
char *ptr;
time_t now;
int num = 0;
if(argc <3){
printf("Usage:%s fb2000_BOARD ytht_BOARD\n",argv[0]);
exit(1);
}
time(&now);
printf("new boardheader size: %d\n", sizeof (struct boardheader));
printf("old boardheader size: %d\n", sizeof (struct oldboardheader));
fp1 = fopen(argv[1], "r");
if(!fp1){
perror("open read file");
exit(0);
}
fp2 = fopen(argv[2], "w");
if(!fp2){
perror("open write file");
exit(0);
}
while (fread(&ob, sizeof (ob), 1, fp1) != 0) {
bzero(&nb, sizeof (nb));
if (!ob.filename[0])
continue;
strncpy(nb.filename, ob.filename, 24);
ptr = strchr(ob.title, ']');
if (ptr)
strncpy(nb.title, ptr + 2, 24);
//nb.clubnum = ob.clubnum;
nb.level = ob.level;
nb.flag = ob.flag;
for (i = 0; i < 8; i++) {
if (strchr(sec[i], ob.title[0])) {
nb.sec1[0] = nb.secnumber1 = secname[i];
break;
}
}
if (i == 13) {
exit(-1);
}
if (ob.title[1] != '[') {
for (i = 0; i < 8; i++) {
if (strchr(sec[i], ob.title[1])) {
nb.sec2[0] = nb.secnumber2 = secname[i];
break;
}
}
}
if (i == 13) {
exit(-1);
}
ptr = strchr(ob.title, '[');
if (ptr)
strncpy(nb.type, ptr + 1, 4);
nb.type[4] = 0;
bnum = 0;
for (i = 0, j = 0; ob.BM[i] != '\0'; i++) {
if (ob.BM[i] == ' ') {
nb.bm[bnum][j] = 0;
bnum++;
j = 0;
} else {
nb.bm[bnum][j] = ob.BM[i];
j++;
}
}
for (i = 0; i <= bnum; i++) {
nb.hiretime[i] = now;
}
fwrite(&nb, sizeof (nb), 1, fp2);
num++;
}
fclose(fp1);
fclose(fp2);
printf("%d boards converted.\n",num);
return 0;
}
--
FROM 202.194.15.*