From fddfadb086f3ca12266c9add4df5c483b76d057d Mon Sep 17 00:00:00 2001 From: piaip Date: Thu, 18 Jun 2009 00:34:44 +0000 Subject: * refine the error message when emaildb was malfunction * allow specify db file to generate in initemaildb git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@4654 63ad8ddf-47c3-0310-b6dd-a9e9d9715204 --- mbbsd/emaildb.c | 19 ++++++++++++------- mbbsd/register.c | 11 +++++++++-- 2 files changed, 21 insertions(+), 9 deletions(-) (limited to 'mbbsd') diff --git a/mbbsd/emaildb.c b/mbbsd/emaildb.c index 0909f466..a5ff2ee7 100644 --- a/mbbsd/emaildb.c +++ b/mbbsd/emaildb.c @@ -8,10 +8,11 @@ // define FORK model to minimize memory usage. #define FORK_MODEL -static int emaildb_open(sqlite3 **Db) { +static int emaildb_open(sqlite3 **Db, const char *fpath) { int rc; - if ((rc = sqlite3_open(EMAILDB_PATH, Db)) != SQLITE_OK) + assert(fpath); + if ((rc = sqlite3_open(fpath, Db)) != SQLITE_OK) return rc; // create table if it doesn't exist @@ -49,7 +50,7 @@ int emaildb_check_email(char * email, int email_len) } #endif - if (emaildb_open(&Db) != SQLITE_OK) + if (emaildb_open(&Db, EMAILDB_PATH) != SQLITE_OK) goto end; if (sqlite3_prepare(Db, "SELECT userid FROM emaildb WHERE email LIKE lower(?);", @@ -121,7 +122,7 @@ int emaildb_update_email(char * userid, int userid_len, char * email, int email_ } #endif - if (emaildb_open(&Db) != SQLITE_OK) + if (emaildb_open(&Db, EMAILDB_PATH) != SQLITE_OK) goto end; if (sqlite3_prepare(Db, "REPLACE INTO emaildb (userid, email) VALUES (lower(?),lower(?));", @@ -154,13 +155,14 @@ end: // standalone initialize builder #define TRANSCATION_PERIOD (4096) -int main() +int main(int argc, char *argv[]) { int fd = 0; userec_t xuser; off_t sz = 0, i = 0, valids = 0; sqlite3 *Db = NULL; sqlite3_stmt *Stmt = NULL, *tranStart = NULL, *tranEnd = NULL; + const char *fpath = EMAILDB_PATH; // init passwd sz = dashs(FN_PASSWD); @@ -172,10 +174,13 @@ int main() } sz /= sizeof(userec_t); + if (argc > 1) + fpath = argv[1]; + // init emaildb - if (emaildb_open(&Db) != SQLITE_OK) + if (emaildb_open(&Db, fpath) != SQLITE_OK) { - fprintf(stderr, "cannot initialize emaildb.\n"); + fprintf(stderr, "cannot initialize emaildb: %s.\n", fpath); return 0; } diff --git a/mbbsd/register.c b/mbbsd/register.c index ff714ff6..7eebd4b5 100644 --- a/mbbsd/register.c +++ b/mbbsd/register.c @@ -1199,12 +1199,19 @@ toregister(char *email) else if (check_regmail(email)) { char yn[3]; #ifdef USE_EMAILDB - int email_count = emaildb_check_email(email, strlen(email)); + int email_count; + + // before long waiting, alert user + move(18, 0); clrtobot(); + outs("正在確認 email, 請稍候...\n"); + doupdate(); + + email_count = emaildb_check_email(email, strlen(email)); if (email_count < 0) { move(15, 0); clrtobot(); move(17, 0); - outs("暫時不允許\ email 認證註冊, 請稍後再試\n"); + outs("email 認證系統發生問題, 請稍後再試。\n"); pressanykey(); return; } else if (email_count >= EMAILDB_LIMIT) { -- cgit v1.2.3