From f20ec866a1837924674452effdd1bc99df77e258 Mon Sep 17 00:00:00 2001 From: kcwu Date: Thu, 16 Jan 2003 13:28:48 +0000 Subject: move post_msg() and post_file() from gamble.c to syspost.c git-svn-id: http://opensvn.csie.org/pttbbs/pttbbs/trunk/pttbbs@608 63ad8ddf-47c3-0310-b6dd-a9e9d9715204 --- include/proto.h | 5 +++-- mbbsd/gamble.c | 56 +------------------------------------------------------- mbbsd/syspost.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 58 insertions(+), 58 deletions(-) diff --git a/include/proto.h b/include/proto.h index 4cfcef28..7d847285 100644 --- a/include/proto.h +++ b/include/proto.h @@ -1,4 +1,4 @@ -/* $Id: proto.h,v 1.32 2003/01/09 11:44:28 in2 Exp $ */ +/* $Id: proto.h,v 1.33 2003/01/16 13:28:48 kcwu Exp $ */ #ifndef INCLUDE_PROTO_H #define INCLUDE_PROTO_H @@ -213,7 +213,6 @@ void friend_delete(char *uident, int type); /* gamble */ int ticket_main(); -int post_msg(char* bname, char* title, char *msg, char* author); int openticket(int bid); int ticket(int bid); @@ -448,6 +447,8 @@ int userid_is_BM(char *userid, char *list); int is_uBM(char *list, char *id); /* syspost */ +int post_msg(char* bname, char* title, char *msg, char* author); +int post_file(char *bname, char *title, char *filename, char *author); void post_newboard(char *bgroup, char *bname, char *bms); void post_violatelaw(char *crime, char *police, char *reason, char *result); void post_change_perm(int oldperm, int newperm, char *sysopid, char *userid); diff --git a/mbbsd/gamble.c b/mbbsd/gamble.c index 8ade3999..ed4cb724 100644 --- a/mbbsd/gamble.c +++ b/mbbsd/gamble.c @@ -1,4 +1,4 @@ -/* $Id: gamble.c,v 1.29 2002/12/26 09:46:04 kcwu Exp $ */ +/* $Id: gamble.c,v 1.30 2003/01/16 13:28:48 kcwu Exp $ */ #include "bbs.h" #ifndef _BBS_UTIL_C_ @@ -9,60 +9,6 @@ static char betname[MAX_ITEM][MAX_ITEM_LEN]; static int currbid; -int -post_msg(char *bname, char *title, char *msg, char *author) -{ - FILE *fp; - int bid; - fileheader_t fhdr; - char genbuf[256]; - - /* 在 bname 板發表新文章 */ - snprintf(genbuf, sizeof(genbuf), "boards/%c/%s", bname[0], bname); - stampfile(genbuf, &fhdr); - fp = fopen(genbuf, "w"); - - if (!fp) - return -1; - - fprintf(fp, "作者: %s 看板: %s\n標題: %s \n", author, bname, title); - fprintf(fp, "時間: %s\n", ctime(&now)); - - /* 文章的內容 */ - fprintf(fp, "%s", msg); - fclose(fp); - - /* 將檔案加入列表 */ - strlcpy(fhdr.title, title, sizeof(fhdr.title)); - strlcpy(fhdr.owner, author, sizeof(fhdr.owner)); - setbdir(genbuf, bname); - if (append_record(genbuf, &fhdr, sizeof(fhdr)) != -1) - if ((bid = getbnum(bname)) > 0) - setbtotal(bid); - return 0; -} - -int -post_file(char *bname, char *title, char *filename, char *author) -{ - int size = dashs(filename); - char *msg; - FILE *fp; - - if (size <= 0) - return -1; - if (!(fp = fopen(filename, "r"))) - return -1; - msg = (char *)malloc(size + 1); - size = fread(msg, 1, size, fp); - msg[size] = 0; - size = post_msg(bname, title, msg, author); - fclose(fp); - free(msg); - return size; -} - - static int load_ticket_record(char *direct, int ticket[]) { diff --git a/mbbsd/syspost.c b/mbbsd/syspost.c index 36939485..a44ffdb3 100644 --- a/mbbsd/syspost.c +++ b/mbbsd/syspost.c @@ -1,6 +1,59 @@ -/* $Id: syspost.c,v 1.16 2002/11/15 05:56:10 lwms Exp $ */ +/* $Id: syspost.c,v 1.17 2003/01/16 13:28:48 kcwu Exp $ */ #include "bbs.h" +int +post_msg(char *bname, char *title, char *msg, char *author) +{ + FILE *fp; + int bid; + fileheader_t fhdr; + char genbuf[256]; + + /* 在 bname 板發表新文章 */ + snprintf(genbuf, sizeof(genbuf), "boards/%c/%s", bname[0], bname); + stampfile(genbuf, &fhdr); + fp = fopen(genbuf, "w"); + + if (!fp) + return -1; + + fprintf(fp, "作者: %s 看板: %s\n標題: %s \n", author, bname, title); + fprintf(fp, "時間: %s\n", ctime(&now)); + + /* 文章的內容 */ + fprintf(fp, "%s", msg); + fclose(fp); + + /* 將檔案加入列表 */ + strlcpy(fhdr.title, title, sizeof(fhdr.title)); + strlcpy(fhdr.owner, author, sizeof(fhdr.owner)); + setbdir(genbuf, bname); + if (append_record(genbuf, &fhdr, sizeof(fhdr)) != -1) + if ((bid = getbnum(bname)) > 0) + setbtotal(bid); + return 0; +} + +int +post_file(char *bname, char *title, char *filename, char *author) +{ + int size = dashs(filename); + char *msg; + FILE *fp; + + if (size <= 0) + return -1; + if (!(fp = fopen(filename, "r"))) + return -1; + msg = (char *)malloc(size + 1); + size = fread(msg, 1, size, fp); + msg[size] = 0; + size = post_msg(bname, title, msg, author); + fclose(fp); + free(msg); + return size; +} + void post_change_perm(int oldperm, int newperm, char *sysopid, char *userid) { -- cgit v1.2.3