- 主题:fileheader转化失败
1.01->1.2时出现的,
转化.PASSWDS和.BOARDS都成功了,
在转化最后一步的时候
正常用户可以看到版面文章数,但只能看到备忘录,一进版面就断线,
而guest用户可以看到转化后的文章,比较正常,
但也有某些文章出现文章数变成[提示]的问题
不知道是出了什么问题了。
--
FROM 219.224.148.*
能否把转化.PASSWDS的程序贴一下
想参考一下
【 在 viogus (风之精灵*全力搞好听涛) 的大作中提到: 】
: 1.01->1.2时出现的,
: 转化.PASSWDS和.BOARDS都成功了,
: 在转化最后一步的时候
: ...................
※ 来源:·BBS 水木清华站 smth.org·[FROM: 219.224.195.*]
FROM 219.224.195.*
我原来的程序是1.0.1,现在的程序是1.2的,
原来的userec是这样的
struct userec { /* Structure used to hold information in */
char userid[IDLEN + 2]; /* PASSFILE */
char flags[2];
time_t firstlogin;
char lasthost[16];
unsigned int numlogins;
unsigned int numposts;
#ifdef CONV_PASS
char passwd[OLDPASSLEN];
char unused_padding[2];
#endif
char username[NAMELEN];
unsigned int club_read_rights[MAXCLUB>>5];
unsigned int club_write_rights[MAXCLUB>>5];
unsigned char md5passwd[MD5PASSLEN];
unsigned userlevel;
time_t lastlogin;
time_t stay;
int signature;
unsigned int userdefine;
time_t notedate;
int noteline;
int notemode;
time_t exittime;
/* 生日数据转移到 userdata 结构中 */
unsigned int usedspace; /* used space of user's mailbox, in bytes */
};
转化程序如下:
#include "bbs.h"
#include "stdio.h"
struct userec1 { /* Structure used to hold information in */
char userid[IDLEN + 2]; /* PASSFILE */
char flags[2];
time_t firstlogin;
char lasthost[16];
unsigned int numlogins;
unsigned int numposts;
#ifdef CONV_PASS
char passwd[OLDPASSLEN];
char unused_padding[2];
#endif
char username[NAMELEN];
unsigned int club_read_rights[MAXCLUB>>5];
unsigned int club_write_rights[MAXCLUB>>5];
unsigned char md5passwd[MD5PASSLEN];
unsigned userlevel;
time_t lastlogin;
time_t stay;
int signature;
unsigned int userdefine;
time_t notedate;
int noteline;
int notemode;
time_t exittime;
/* 生日数据转移到 userdata 结构中 */
unsigned int usedspace; /* used space of user's mailbox, in bytes */
};
struct userec2 { /* Structure used to hold information in */
char userid[IDLEN + 2]; /* PASSFILE */
char flags; /*一些标志,戒网,版面排序之类的 */
unsigned char title; /*用户级别 */
time_t firstlogin;
char lasthost[16];
unsigned int numlogins;
unsigned int numposts;
#ifdef CONV_PASS
char passwd[OLDPASSLEN];
char unused_padding[2];
#endif
char username[NAMELEN];
unsigned int club_read_rights[MAXCLUB >> 5];
unsigned int club_write_rights[MAXCLUB >> 5];
unsigned char md5passwd[MD5PASSLEN];
unsigned userlevel;
time_t lastlogin;
time_t stay;
int signature;
unsigned int userdefine[2];
time_t notedate;
int noteline;
int notemode;
time_t exittime;
/*
* * 生日数据转移到 userdata 结构中
* */
unsigned int usedspace; /* used space of user's mailbox, in bytes */
#ifdef HAVE_USERMONEY
int money;
int score;
char unused[20];
#endif
};
int main(int argc, char *argv[])
{
FILE *fp, *fp2;
struct userec1 bh;
struct userec2 bhnew;
int i;
if (argc != 3) {
printf("usage: convert Old_PASSWDS_FILE New_PASSWDS_FILE\n");
exit(0);
}
if ((fp = fopen(argv[2], "r")) != NULL) {
printf("NEW FILE exist!");
fclose(fp);
exit(0);
}
if ((fp = fopen(argv[1], "r")) == NULL) {
printf("open .BOARDS file failed!");
exit(0);
}
if ((fp2 = fopen(argv[2], "w")) == NULL) {
printf("cant create newboards file!");
exit(0);
}
while (fread(&bh, sizeof(struct userec1), 1, fp)) {
memset(&bhnew, 0, sizeof(struct userec2));
memcpy(&bhnew, &bh, sizeof(struct userec1));
bhnew.userdefine[1] = -1;
bhnew.notedate = bh.notedate;
bhnew.noteline = bh.noteline;
bhnew.notemode = bh.notemode;
bhnew.exittime = bh.exittime;
bhnew.usedspace = bh.usedspace;
fwrite(&bhnew, sizeof(struct userec2), 1, fp2);
}
fclose(fp2);
fclose(fp);
return 0;
}
【 在 F1yingFish (F.Fish|人生如梦·我心依旧) 的大作中提到: 】
: 能否把转化.PASSWDS的程序贴一下
: 想参考一下
: ※ 来源:·BBS 水木清华站 smth.org·[FROM: 219.224.195.*]
: ...................
--
FROM 219.224.148.*
【 在 viogus@smth.org-SPAM.no (风之精灵*全力搞好听涛) 的大作中提到: 】
: while (fread(&bh, sizeof(struct userec1), 1, fp)) {
: memset(&bhnew, 0, sizeof(struct userec2));
: memcpy(&bhnew, &bh, sizeof(struct userec1));
我ft,这样一搞不就全乱套了嘛!当然要一项一项依次赋值了。你那个结构好前面
就多了一个title项,memcpy了当然就后面的项全都错位了。
: bhnew.userdefine[1] = -1;
: bhnew.notedate = bh.notedate;
: bhnew.noteline = bh.noteline;
: bhnew.notemode = bh.notemode;
: bhnew.exittime = bh.exittime;
: bhnew.usedspace = bh.usedspace;
: fwrite(&bhnew, sizeof(struct userec2), 1, fp2);
: : ...................
--
应该要加上
bhnew.flags = bh.flags[0];
bhnew.title = 0;
吧
【 在 atppp@bbs.stanford.edu-SPAM.no (Big Mouse) 的大作中提到: 】
: 我ft,这样一搞不就全乱套了嘛!当然要一项一项依次赋值了。你那个结构好前面
: 就多了一个title项,memcpy了当然就后面的项全都错位了。
※ 来源:·BBS 水木清华站 smth.org·[FROM: 219.224.195.*]
FROM 219.224.195.*
struct userec1 { /* Structure used to hold information in */
char userid[IDLEN + 2]; /* PASSFILE */
char flags[2];
time_t firstlogin;
char lasthost[16];
unsigned int numlogins;
unsigned int numposts;
struct userec2 { /* Structure used to hold information in */
char userid[IDLEN + 2]; /* PASSFILE */
char flags; /*一些标志,戒网,版面排序之类的 */
unsigned char title; /*用户级别 */
time_t firstlogin;
char lasthost[16];
unsigned int numlogins;
unsigned int numposts;
仔细看看这里直接memcpy userec1->userec2 会有什么后果。
【 在 F1yingFish@smth.org-SPAM.no (F.Fish|人生如梦·我心依旧) 的大作中提到: 】
: 应该要加上
: bhnew.flags = bh.flags[0];
: bhnew.title = 0;
: 吧
: 【 在 atppp@bbs.stanford.edu-SPAM.no (Big Mouse) 的大作中提到: 】
: : 我ft,这样一搞不就全乱套了嘛!当然要一项一项依次赋值了。你那个结构好前面
: : 就多了一个title项,memcpy了当然就后面的项全都错位了。
: ※ 来源:·BBS 水木清华站 smth.org·[FROM: 219.224.195.*]
--
FROM 219.224.195.*
应该不会错位吧
char 和 unsigned char变量都只占一个字节的啊
【 在 atppp@bbs.stanford.edu-SPAM.no (Big Mouse) 的大作中提到: 】
: 标 题: Re: fileheader转化失败
: 发信站: 牧场物语 (Sat May 8 08:35:15 2004)
: 转信站: COA!news.happynet.org!maily.cic.tsinghua.edu.cn!news.bylinux.net!Stanfo
:
: struct userec1 { /* Structure used to hold information in */
: char userid[IDLEN + 2]; /* PASSFILE */
: char flags[2];
: time_t firstlogin;
: char lasthost[16];
: unsigned int numlogins;
: unsigned int numposts;
:
:
: struct userec2 { /* Structure used to hold information in */
: char userid[IDLEN + 2]; /* PASSFILE */
: char flags; /*一些标志,戒网,版面排序之类的 */
: unsigned char title; /*用户级别 */
: time_t firstlogin;
: char lasthost[16];
: unsigned int numlogins;
: unsigned int numposts;
:
: 仔细看看这里直接memcpy userec1->userec2 会有什么后果。
:
: 【 在 F1yingFish@smth.org-SPAM.no (F.Fish|人生如梦·我心依旧) 的大作中提到: 】
: : 应该要加上
: : bhnew.flags = bh.flags[0];
: : bhnew.title = 0;
: : 吧
: : 【 在 atppp@bbs.stanford.edu-SPAM.no (Big Mouse) 的大作中提到: 】
: : : 我ft,这样一搞不就全乱套了嘛!当然要一项一项依次赋值了。你那个结构好前面
: : : 就多了一个title项,memcpy了当然就后面的项全都错位了。
: : ※ 来源:·BBS 水木清华站 smth.org·[FROM: 219.224.195.*]
:
:
: --
:
: ※ 来源:·牧场物语 bbs.stanford.edu·[FROM: FARM]
--
FROM 219.224.195.142
恩,不好意思我看错了,嘿嘿。你说的有道理,不过还是不确定到底是不是这个问题。
【 在 FlyingFish@coa.cn-bbs.org (人生如梦|抓紧剩下的时间好好工作) 的大作中提到: 】
: 应该不会错位吧
: char 和 unsigned char变量都只占一个字节的啊
: 【 在 atppp@bbs.stanford.edu-SPAM.no (Big Mouse) 的大作中提到: 】
: : 标 题: Re: fileheader转化失败
: : 发信站: 牧场物语 (Sat May 8 08:35:15 2004)
: : 转信站: COA!news.happynet.org!maily.cic.tsinghua.edu.cn!news.bylinux.net!Stanfo
: : struct userec1 { /* Structure used to hold information in */
: : char userid[IDLEN + 2]; /* PASSFILE */
: : char flags[2];
: : time_t firstlogin;
: ...................
--
我看了一下这边新老版本的.PASSWDS
2003.5.10snap包的一个用户占188个字节
1.2的占220个字节
转换前.PASSWDS占376000个字节
转换后占440000个字节
总文件大小是正确的
出问题的应该是在每个用户信息上,只有192个字节
【 在 atppp@bbs.stanford.edu-SPAM.no (Big Mouse) 的大作中提到: 】
: 恩,不好意思我看错了,嘿嘿。你说的有道理,不过还是不确定到底是不是这个问题。
--
FROM 219.224.195.142
嘿嘿,解决问题之后跟我们说说吧:)
【 在 FlyingFish@coa.cn-bbs.org (人生如梦|抓紧剩下的时间好好工作) 的大作中提到: 】
: 我看了一下这边新老版本的.PASSWDS
: 2003.5.10snap包的一个用户占188个字节
: 1.2的占220个字节
: 转换前.PASSWDS占376000个字节
: 转换后占440000个字节
: 总文件大小是正确的
: 出问题的应该是在每个用户信息上,只有192个字节
: 【 在 atppp@bbs.stanford.edu-SPAM.no (Big Mouse) 的大作中提到: 】
: : 恩,不好意思我看错了,嘿嘿。你说的有道理,不过还是不确定到底是不是这个问题。
--