| 278 |
return 0; |
return 0; |
| 279 |
} |
} |
| 280 |
|
|
| 281 |
|
int bbs_charset_select() |
| 282 |
|
{ |
| 283 |
|
char msg[LINE_BUFFER_LEN]; |
| 284 |
|
int ch; |
| 285 |
|
|
| 286 |
|
while (!SYS_server_exit) |
| 287 |
|
{ |
| 288 |
|
snprintf(msg, sizeof(msg), |
| 289 |
|
"\rChoose character set in 5 seconds [UTF-8, GBK]: [U/g]"); |
| 290 |
|
|
| 291 |
|
ch = press_any_key_ex(msg, 5); |
| 292 |
|
switch (ch) |
| 293 |
|
{ |
| 294 |
|
case KEY_TIMEOUT: |
| 295 |
|
case CR: |
| 296 |
|
case 'u': |
| 297 |
|
case 'U': |
| 298 |
|
return 0; |
| 299 |
|
case 'g': |
| 300 |
|
case 'G': |
| 301 |
|
if (io_conv_init("GBK") < 0) |
| 302 |
|
{ |
| 303 |
|
log_error("io_conv_init(%s) error\n", "GBK"); |
| 304 |
|
return -1; |
| 305 |
|
} |
| 306 |
|
return 0; |
| 307 |
|
default: |
| 308 |
|
continue; |
| 309 |
|
} |
| 310 |
|
} |
| 311 |
|
|
| 312 |
|
return 0; |
| 313 |
|
} |
| 314 |
|
|
| 315 |
int bbs_main() |
int bbs_main() |
| 316 |
{ |
{ |
| 317 |
struct sigaction act = {0}; |
struct sigaction act = {0}; |
| 318 |
|
char msg[LINE_BUFFER_LEN]; |
| 319 |
|
|
| 320 |
// Set signal handler |
// Set signal handler |
| 321 |
act.sa_handler = SIG_IGN; |
act.sa_handler = SIG_IGN; |
| 351 |
goto cleanup; |
goto cleanup; |
| 352 |
} |
} |
| 353 |
|
|
| 354 |
|
// Set default charset |
| 355 |
|
if (io_conv_init(BBS_DEFAULT_CHARSET) < 0) |
| 356 |
|
{ |
| 357 |
|
log_error("io_conv_init(%s) error\n", BBS_DEFAULT_CHARSET); |
| 358 |
|
goto cleanup; |
| 359 |
|
} |
| 360 |
|
|
| 361 |
set_input_echo(0); |
set_input_echo(0); |
| 362 |
|
|
| 363 |
|
// Set user charset |
| 364 |
|
bbs_charset_select(); |
| 365 |
|
|
| 366 |
// System info |
// System info |
| 367 |
if (bbs_info() < 0) |
if (bbs_info() < 0) |
| 368 |
{ |
{ |
| 378 |
// User login |
// User login |
| 379 |
if (SSH_v2) |
if (SSH_v2) |
| 380 |
{ |
{ |
| 381 |
prints("\033[1m%s 欢迎使用ssh方式访问 \033[1;33m按任意键继续...\033[m", BBS_username); |
snprintf(msg, sizeof(msg), "\033[1m%s 欢迎使用ssh方式访问 \033[1;33m按任意键继续...\033[m", BBS_username); |
| 382 |
iflush(); |
press_any_key_ex(msg, 60); |
|
igetch_reset(); |
|
|
while (!SYS_server_exit && igetch_t(MAX_DELAY_TIME) == 0) |
|
|
; |
|
| 383 |
} |
} |
| 384 |
else if (bbs_login() < 0) |
else if (bbs_login() < 0) |
| 385 |
{ |
{ |
| 432 |
} |
} |
| 433 |
|
|
| 434 |
cleanup: |
cleanup: |
| 435 |
|
// Cleanup iconv |
| 436 |
|
io_conv_cleanup(); |
| 437 |
|
|
| 438 |
// Cleanup editor memory pool |
// Cleanup editor memory pool |
| 439 |
editor_memory_pool_cleanup(); |
editor_memory_pool_cleanup(); |
| 440 |
|
|