-
Notifications
You must be signed in to change notification settings - Fork 3
/
cnv_passwd.c
executable file
·125 lines (115 loc) · 3.1 KB
/
cnv_passwd.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
/* add userdefine1 to userec */
#include "bbs.h"
#include "stdio.h"
struct userec1 { /* 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;
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
};
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;
#ifdef HAVE_USERMONEY
bhnew.money = bh.money;
bhnew.score = bh.score;
memcpy(bhnew.unused, bh.unused, 20);
#endif
fwrite(&bhnew,sizeof(struct userec2),1,fp2);
}
fclose(fp2);
fclose(fp);
return 0;
}