| 1 |
/*************************************************************************** |
/* SPDX-License-Identifier: GPL-3.0-or-later */ |
| 2 |
common.h - description |
/* |
| 3 |
------------------- |
* common |
| 4 |
Copyright : (C) 2004-2025 by Leaflet |
* - common definitions |
| 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 |
#ifndef _COMMON_H_ |
#ifndef _COMMON_H_ |
| 10 |
#define _COMMON_H_ |
#define _COMMON_H_ |
| 13 |
#include <libssh/libssh.h> |
#include <libssh/libssh.h> |
| 14 |
#include <libssh/server.h> |
#include <libssh/server.h> |
| 15 |
|
|
| 16 |
#define LINE_BUFFER_LEN 1024 |
enum common_constant_t |
| 17 |
#define FILE_PATH_LEN 4096 |
{ |
| 18 |
|
LINE_BUFFER_LEN = 1024, |
| 19 |
|
FILE_PATH_LEN = 4096, |
| 20 |
|
|
| 21 |
|
// Screen |
| 22 |
|
SCREEN_ROWS = 24, |
| 23 |
|
SCREEN_COLS = 80, |
| 24 |
|
|
| 25 |
|
TAB_SIZE = 4, |
| 26 |
|
|
| 27 |
|
// Network |
| 28 |
|
MAX_CLIENT_LIMIT = 2000, |
| 29 |
|
MAX_CLIENT_PER_IP_LIMIT = 100, |
| 30 |
|
IP_ADDR_LEN = 50, |
| 31 |
|
MAX_EVENTS = 10, |
| 32 |
|
}; |
| 33 |
|
|
| 34 |
// Version |
// Version |
| 35 |
#define APP_NAME_VER "LBBS-devel version 1.0" |
extern const char APP_INFO[]; |
| 36 |
|
|
| 37 |
// Enviroment |
// Enviroment |
| 38 |
#define CONF_BBSD "conf/bbsd.conf" |
extern const char CONF_BBSD[]; |
| 39 |
#define CONF_MENU "var/menu_merged.conf" |
extern const char CONF_MENU[]; |
| 40 |
#define CONF_BBSNET "conf/bbsnet.conf" |
extern const char CONF_BBSNET[]; |
| 41 |
#define SSH_HOST_KEYFILE "conf/ssh_host_rsa_key" |
extern const char CONF_BWF[]; |
| 42 |
|
extern const char CONF_TOP10_MENU[]; |
| 43 |
#define LOG_FILE_INFO "log/bbsd.log" |
extern const char SSH_HOST_KEYFILE[]; |
| 44 |
#define LOG_FILE_ERROR "log/error.log" |
|
| 45 |
|
extern const char LOG_FILE_INFO[]; |
| 46 |
#define DATA_WELCOME "data/welcome.txt" |
extern const char LOG_FILE_ERROR[]; |
| 47 |
#define DATA_REGISTER "data/register.txt" |
|
| 48 |
#define DATA_GOODBYE "data/goodbye.txt" |
extern const char DATA_WELCOME[]; |
| 49 |
#define DATA_LICENSE "data/license.txt" |
extern const char DATA_REGISTER[]; |
| 50 |
#define DATA_COPYRIGHT "data/copyright.txt" |
extern const char DATA_GOODBYE[]; |
| 51 |
#define DATA_LOGIN_ERROR "data/login_error.txt" |
extern const char DATA_LICENSE[]; |
| 52 |
#define DATA_ACTIVE_BOARD "data/active_board.txt" |
extern const char DATA_COPYRIGHT[]; |
| 53 |
#define DATA_READ_HELP "data/read_help.txt" |
extern const char DATA_VERSION[]; |
| 54 |
|
extern const char DATA_LOGIN_ERROR[]; |
| 55 |
#define VAR_BBS_TOP "var/bbs_top.txt" |
extern const char DATA_ACTIVE_BOARD[]; |
| 56 |
|
extern const char DATA_READ_HELP[]; |
| 57 |
#define VAR_ARTICLE_BLOCK_SHM "var/article_block_shm.~" |
extern const char DATA_EDITOR_HELP[]; |
| 58 |
#define VAR_SECTION_LIST_SHM "var/section_list_shm.~" |
|
| 59 |
#define VAR_TRIE_DICT_SHM "var/trie_dict_shm.~" |
extern const char VAR_BBS_TOP[]; |
| 60 |
|
|
| 61 |
#define VAR_ARTICLE_CACHE_DIR "var/articles/" |
extern const char VAR_ARTICLE_BLOCK_SHM[]; |
| 62 |
|
extern const char VAR_SECTION_LIST_SHM[]; |
| 63 |
|
extern const char VAR_TRIE_DICT_SHM[]; |
| 64 |
|
extern const char VAR_USER_LIST_SHM[]; |
| 65 |
|
|
| 66 |
|
extern const char VAR_ARTICLE_CACHE_DIR[]; |
| 67 |
|
extern const char VAR_GEN_EX_MENU_DIR[]; |
| 68 |
|
extern const char VAR_SECTION_AID_LOC_DIR[]; |
| 69 |
|
|
| 70 |
// File loader |
// File loader |
| 71 |
extern const char *data_files_load_startup[]; |
extern const char *data_files_load_startup[]; |
| 72 |
extern int data_files_load_startup_count; |
extern const int data_files_load_startup_count; |
|
|
|
|
// Screen |
|
|
#define SCREEN_ROWS 24 |
|
|
#define SCREEN_COLS 80 |
|
| 73 |
|
|
| 74 |
// Network |
// Network |
|
#define MAX_CLIENT_LIMIT 2000 |
|
|
#define MAX_CLIENT_PER_IP_LIMIT 100 |
|
|
#define IP_ADDR_LEN 50 |
|
|
#define MAX_EVENTS 10 |
|
|
|
|
|
// User |
|
|
#define BBS_MAX_USER_LIMIT 100000 |
|
|
|
|
|
extern int socket_server[2]; |
|
|
extern int socket_client; |
|
| 75 |
extern char hostaddr_client[IP_ADDR_LEN]; |
extern char hostaddr_client[IP_ADDR_LEN]; |
| 76 |
extern int port_client; |
extern int port_client; |
| 77 |
|
|
| 78 |
// SSHv2 |
// SSHv2 |
| 79 |
extern int SSH_v2; |
extern int SSH_v2; |
|
extern ssh_bind sshbind; |
|
| 80 |
extern ssh_session SSH_session; |
extern ssh_session SSH_session; |
| 81 |
extern ssh_channel SSH_channel; |
extern ssh_channel SSH_channel; |
| 82 |
|
|
|
extern const char *get_time_str(char *string, size_t length); |
|
|
|
|
| 83 |
// Signal handler |
// Signal handler |
| 84 |
extern void sig_hup_handler(int); |
extern void sig_hup_handler(int); |
| 85 |
extern void sig_term_handler(int); |
extern void sig_term_handler(int); |
| 90 |
extern volatile int SYS_child_process_count; |
extern volatile int SYS_child_process_count; |
| 91 |
extern volatile int SYS_child_exit; |
extern volatile int SYS_child_exit; |
| 92 |
extern volatile int SYS_conf_reload; |
extern volatile int SYS_conf_reload; |
|
extern volatile int SYS_data_file_reload; |
|
|
extern volatile int SYS_section_list_reload; |
|
|
|
|
|
// Network |
|
|
extern const char *ip_mask(char *s, int level, char mask); |
|
| 93 |
|
|
| 94 |
#endif //_COMMON_H_ |
#endif //_COMMON_H_ |