--- lbbs/src/login.c 2004/10/20 07:46:26 1.1 +++ lbbs/src/login.c 2004/10/21 17:28:46 1.2 @@ -18,8 +18,69 @@ #include "bbs.h" #include "common.h" +void +login_fail () +{ + char temp[256]; + + strcpy (temp, app_home_dir); + strcat (temp, "data/login_error.dat"); + display_file (temp); +} + int -bbs_login() +bbs_login () { + char username[20], password[20]; + int count, ok; + + //Input username + count = 0; + ok = 0; + while (!ok) + { + printf + ("\033[1;33m请输入帐号\033[m(试用请输入 `\033[1;36mguest\033[m', " + "注册请输入`\033[1;31mnew\033[m'): "); + fflush (stdout); + + str_input (username, 19, 0); + count++; + + if (strcmp (username, "guest") == 0) + return 1; + + if (strlen (username) > 0) + { + //Input password + printf ("\033[1;37m请输入密码\033[m: "); + fflush (stdout); + + str_input (password, 19, 0); + + if (strlen (password) > 0) + { + ok = check_user (username, password); + } + + if (!ok) + { + printf ("\033[1;31m错误的用户名或密码...\r\n"); + fflush (stdout); + } + } + if (count >= 3) + { + login_fail (); + return -1; + } + } + return 0; } + +int +check_user(char *username, char *password) +{ + return 1; +}