diff options
author | scw <scw@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2004-04-04 19:19:35 +0800 |
---|---|---|
committer | scw <scw@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2004-04-04 19:19:35 +0800 |
commit | 64cbc63a01808b3646ef78916a79f06fce10374e (patch) | |
tree | e68accd13d4a5ba38ba2e015702f71cd5ec10b7a /mbbsd | |
parent | 28a4d89620753b108f8d48050cdc6089bcbccca4 (diff) | |
download | pttbbs-64cbc63a01808b3646ef78916a79f06fce10374e.tar pttbbs-64cbc63a01808b3646ef78916a79f06fce10374e.tar.gz pttbbs-64cbc63a01808b3646ef78916a79f06fce10374e.tar.bz2 pttbbs-64cbc63a01808b3646ef78916a79f06fce10374e.tar.lz pttbbs-64cbc63a01808b3646ef78916a79f06fce10374e.tar.xz pttbbs-64cbc63a01808b3646ef78916a79f06fce10374e.tar.zst pttbbs-64cbc63a01808b3646ef78916a79f06fce10374e.zip |
Old brc convertion done.
git-svn-id: http://opensvn.csie.org/pttbbs/branches/scw.brc2@1691 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'mbbsd')
-rw-r--r-- | mbbsd/brc.c | 35 |
1 files changed, 28 insertions, 7 deletions
diff --git a/mbbsd/brc.c b/mbbsd/brc.c index 6d8bf62a..93ce8ed8 100644 --- a/mbbsd/brc.c +++ b/mbbsd/brc.c @@ -191,23 +191,44 @@ brc_update(){ inline static int read_old_brc() { -//#error read_old_brc() not implement yet - /* XXX: read from old brc file */ - char brdname[BRC_STRLEN + 1]; + char brcfile[STRLEN]; + char brdname[BRC_STRLEN + 1]; + char *ptr; + int fd; + brcnbrd_t num; + + setuserfile(brcfile, fn_oldboardrc); + if ((fd = open(brcfile, O_RDONLY)) != -1) { + ptr = brc_buf; + brc_size = 0; + while (read(fd, brdname, BRC_STRLEN + 1) == BRC_STRLEN + 1) { + num = brdname[BRC_STRLEN]; + brdname[BRC_STRLEN] = 0; + *(brcbid_t*)ptr = getbnum(brdname); + ptr += sizeof(brcbid_t); + *(brcnbrd_t*)ptr = num; + ptr += sizeof(brcnbrd_t); + if (read(fd, ptr, sizeof(int) * num) != sizeof(int) * num) + break; + brc_size += sizeof(brcbid_t) + sizeof(brcnbrd_t) + + sizeof(time_t) * num; + ptr += sizeof(time_t) * num; + } + return 1; + } return 0; - brdname[0] = brdname[0]; } inline static void read_brc_buf() { if (brc_buf == NULL) { - char dirfile[STRLEN]; + char brcfile[STRLEN]; int fd; brc_buf = malloc(BRC_MAXSIZE); - setuserfile(dirfile, fn_brc); - if ((fd = open(dirfile, O_RDONLY)) != -1) { + setuserfile(brcfile, fn_brc); + if ((fd = open(brcfile, O_RDONLY)) != -1) { brc_size = read(fd, brc_buf, BRC_MAXSIZE); close(fd); } else { |