| 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" |
| 48 |
char charset[20]; |
char charset[20]; |
| 49 |
} bbsnet_conf[MAXSTATION]; |
} bbsnet_conf[MAXSTATION]; |
| 50 |
|
|
| 51 |
MENU_SET bbsnet_menu; |
static MENU_SET bbsnet_menu; |
| 52 |
|
|
| 53 |
int load_bbsnet_conf(const char *file_config) |
static int load_bbsnet_conf(const char *file_config) |
| 54 |
{ |
{ |
| 55 |
FILE *fp; |
FILE *fp; |
| 56 |
MENU *p_menu; |
MENU *p_menu; |
| 145 |
return 0; |
return 0; |
| 146 |
} |
} |
| 147 |
|
|
| 148 |
void unload_bbsnet_conf(void) |
static void unload_bbsnet_conf(void) |
| 149 |
{ |
{ |
| 150 |
bbsnet_menu.menu_count = 0; |
bbsnet_menu.menu_count = 0; |
| 151 |
bbsnet_menu.menu_item_count = 0; |
bbsnet_menu.menu_item_count = 0; |
| 156 |
bbsnet_menu.p_menu_item_pool = NULL; |
bbsnet_menu.p_menu_item_pool = NULL; |
| 157 |
} |
} |
| 158 |
|
|
| 159 |
void process_bar(int n, int len) |
static void process_bar(int n, int len) |
| 160 |
{ |
{ |
| 161 |
char buf[LINE_BUFFER_LEN]; |
char buf[LINE_BUFFER_LEN]; |
| 162 |
char buf2[LINE_BUFFER_LEN]; |
char buf2[LINE_BUFFER_LEN]; |
| 177 |
moveto(4, 0); |
moveto(4, 0); |
| 178 |
prints(" ------------------------------ \r\n"); |
prints(" ------------------------------ \r\n"); |
| 179 |
snprintf(buf, sizeof(buf), " %3d%% ", n * 100 / len); |
snprintf(buf, sizeof(buf), " %3d%% ", n * 100 / len); |
| 180 |
strncpy(buf2, buf, (size_t)n); |
memcpy(buf2, buf, (size_t)n); |
| 181 |
buf2[n] = '\0'; |
buf2[n] = '\0'; |
| 182 |
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); |
| 183 |
prints(" ------------------------------ \r\n"); |
prints(" ------------------------------ \r\n"); |
| 184 |
iflush(); |
iflush(); |
| 185 |
} |
} |
| 186 |
|
|
| 187 |
int bbsnet_connect(int n) |
static int bbsnet_connect(int n) |
| 188 |
{ |
{ |
| 189 |
int sock, ret, loop, error; |
int sock, ret, loop, error; |
| 190 |
int sock_connected = 0; |
int sock_connected = 0; |
| 476 |
} |
} |
| 477 |
else if (nfds == 0) // timeout |
else if (nfds == 0) // timeout |
| 478 |
{ |
{ |
| 479 |
if (time(NULL) - BBS_last_access_tm >= MAX_DELAY_TIME) |
if (time(NULL) - BBS_last_access_tm >= BBS_max_user_idle_time) |
| 480 |
{ |
{ |
| 481 |
break; |
break; |
| 482 |
} |
} |
| 799 |
return 0; |
return 0; |
| 800 |
} |
} |
| 801 |
|
|
| 802 |
static int |
static int bbsnet_refresh() |
|
bbsnet_refresh() |
|
| 803 |
{ |
{ |
| 804 |
clearscr(); |
clearscr(); |
| 805 |
moveto(1, 0); |
moveto(1, 0); |
| 823 |
return 0; |
return 0; |
| 824 |
} |
} |
| 825 |
|
|
| 826 |
int bbsnet_selchange() |
static int bbsnet_selchange() |
| 827 |
{ |
{ |
| 828 |
int i = bbsnet_menu.menu_item_pos[0]; |
int i = bbsnet_menu.menu_item_pos[0]; |
| 829 |
|
|
| 848 |
return 0; |
return 0; |
| 849 |
} |
} |
| 850 |
|
|
| 851 |
int bbs_net() |
extern int bbs_net() |
| 852 |
{ |
{ |
| 853 |
int ch, i; |
int ch, i; |
| 854 |
|
|
| 874 |
log_error("KEY_NULL\n"); |
log_error("KEY_NULL\n"); |
| 875 |
goto cleanup; |
goto cleanup; |
| 876 |
case KEY_TIMEOUT: |
case KEY_TIMEOUT: |
| 877 |
if (time(NULL) - BBS_last_access_tm >= MAX_DELAY_TIME) |
if (time(NULL) - BBS_last_access_tm >= BBS_max_user_idle_time) |
| 878 |
{ |
{ |
| 879 |
log_error("User input timeout\n"); |
log_error("User input timeout\n"); |
| 880 |
goto cleanup; |
goto cleanup; |