| 1 |
/*************************************************************************** |
/* SPDX-License-Identifier: GPL-3.0-or-later */ |
| 2 |
bbs_net.c - description |
/* |
| 3 |
------------------- |
* bbs_net |
| 4 |
Copyright : (C) 2004-2025 by Leaflet |
* - user interactive feature of site shuttle |
| 5 |
Email : leaflet@leafok.com |
* |
| 6 |
***************************************************************************/ |
* Copyright (C) 2004-2025 Leaflet <leaflet@leafok.com> |
| 7 |
|
*/ |
|
/*************************************************************************** |
|
|
* * |
|
|
* This program is free software; you can redistribute it and/or modify * |
|
|
* it under the terms of the GNU General Public License as published by * |
|
|
* the Free Software Foundation; either version 3 of the License, or * |
|
|
* (at your option) any later version. * |
|
|
* * |
|
|
***************************************************************************/ |
|
| 8 |
|
|
| 9 |
#include "bbs.h" |
#include "bbs.h" |
| 10 |
#include "common.h" |
#include "common.h" |
| 33 |
#include <sys/socket.h> |
#include <sys/socket.h> |
| 34 |
#include <sys/epoll.h> |
#include <sys/epoll.h> |
| 35 |
|
|
| 36 |
#define MENU_CONF_DELIM " \t\r\n" |
static const char MENU_CONF_DELIM[] = " \t\r\n"; |
| 37 |
|
|
| 38 |
#define MAX_PROCESS_BAR_LEN 30 |
enum _bbs_net_constant_t |
| 39 |
#define MAXSTATION 26 * 2 |
{ |
| 40 |
#define STATION_PER_LINE 4 |
MAX_PROCESS_BAR_LEN = 30, |
| 41 |
|
MAXSTATION = 26 * 2, |
| 42 |
|
STATION_PER_LINE = 4, |
| 43 |
|
}; |
| 44 |
|
|
| 45 |
struct _bbsnet_conf |
struct _bbsnet_conf |
| 46 |
{ |
{ |
| 48 |
char host2[40]; |
char host2[40]; |
| 49 |
char ip[40]; |
char ip[40]; |
| 50 |
in_port_t port; |
in_port_t port; |
| 51 |
char charset[20]; |
char charset[CHARSET_MAX_LEN + 1]; |
| 52 |
} bbsnet_conf[MAXSTATION]; |
} bbsnet_conf[MAXSTATION]; |
| 53 |
|
|
| 54 |
static MENU_SET bbsnet_menu; |
static MENU_SET bbsnet_menu; |
| 180 |
moveto(4, 0); |
moveto(4, 0); |
| 181 |
prints(" ------------------------------ \r\n"); |
prints(" ------------------------------ \r\n"); |
| 182 |
snprintf(buf, sizeof(buf), " %3d%% ", n * 100 / len); |
snprintf(buf, sizeof(buf), " %3d%% ", n * 100 / len); |
| 183 |
strncpy(buf2, buf, (size_t)n); |
memcpy(buf2, buf, (size_t)n); |
| 184 |
buf2[n] = '\0'; |
buf2[n] = '\0'; |
| 185 |
prints("|\033[46m%s\033[44m%s\033[m|\r\n", buf2, buf + n); |
prints("|\033[46m%s\033[44m%s\033[m|\r\n", buf2, buf + n); |
| 186 |
prints(" ------------------------------ \r\n"); |
prints(" ------------------------------ \r\n"); |
| 479 |
} |
} |
| 480 |
else if (nfds == 0) // timeout |
else if (nfds == 0) // timeout |
| 481 |
{ |
{ |
| 482 |
if (time(NULL) - BBS_last_access_tm >= MAX_DELAY_TIME) |
if (time(NULL) - BBS_last_access_tm >= BBS_max_user_idle_time) |
| 483 |
{ |
{ |
| 484 |
break; |
break; |
| 485 |
} |
} |
| 877 |
log_error("KEY_NULL\n"); |
log_error("KEY_NULL\n"); |
| 878 |
goto cleanup; |
goto cleanup; |
| 879 |
case KEY_TIMEOUT: |
case KEY_TIMEOUT: |
| 880 |
if (time(NULL) - BBS_last_access_tm >= MAX_DELAY_TIME) |
if (time(NULL) - BBS_last_access_tm >= BBS_max_user_idle_time) |
| 881 |
{ |
{ |
| 882 |
log_error("User input timeout\n"); |
log_error("User input timeout\n"); |
| 883 |
goto cleanup; |
goto cleanup; |