This repository has been archived on 2024-04-08. You can view files and clone it, but cannot push or open issues or pull requests.
magicka/src/bbs.h

403 lines
11 KiB
C
Raw Normal View History

2016-03-22 01:48:59 +00:00
#ifndef __BBS_H__
#define __BBS_H__
#include <time.h>
2016-12-06 07:06:28 +00:00
#include <termios.h>
#if defined(ENABLE_WWW)
#include <microhttpd.h>
#endif
#include "lua/lua.h"
#include "lua/lauxlib.h"
2016-08-20 03:52:02 +00:00
#include "jamlib/jam.h"
2016-03-22 01:48:59 +00:00
#define VERSION_MAJOR 0
2018-05-13 23:17:01 +00:00
#define VERSION_MINOR 11
2016-04-14 01:17:06 +00:00
#define VERSION_STR "alpha"
2016-03-22 01:48:59 +00:00
2016-03-28 04:46:48 +00:00
#define NETWORK_FIDO 1
#define NETWORK_WWIV 2
2018-05-22 11:02:22 +00:00
#define NETWORK_MAGI 3
2016-03-24 07:23:42 +00:00
#define TYPE_LOCAL_AREA 0
#define TYPE_NETMAIL_AREA 1
#define TYPE_ECHOMAIL_AREA 2
#define TYPE_NEWSGROUP_AREA 3
2016-03-24 07:23:42 +00:00
#define IAC 255
#define IAC_WILL 251
#define IAC_WONT 252
#define IAC_DO 253
#define IAC_DONT 254
#define IAC_TRANSMIT_BINARY 0
#define IAC_SUPPRESS_GO_AHEAD 3
#define IAC_ECHO 1
2016-03-24 07:23:42 +00:00
struct fido_addr {
unsigned short zone;
unsigned short net;
unsigned short node;
unsigned short point;
};
2016-03-23 05:21:53 +00:00
struct last10_callers {
char name[17];
char location[33];
time_t time;
2018-02-25 06:25:53 +00:00
int calls;
2016-03-23 05:21:53 +00:00
}__attribute__((packed));
2016-03-27 00:33:43 +00:00
struct text_file {
char *name;
char *path;
};
struct door_config {
char *name;
char *command;
int stdio;
2017-04-23 02:14:14 +00:00
char *codepage;
};
2016-03-22 03:07:42 +00:00
struct mail_area {
char *name;
char *path;
char *qwkname;
2016-03-22 03:07:42 +00:00
int read_sec_level;
int write_sec_level;
2016-03-24 07:23:42 +00:00
int type;
2016-03-22 03:07:42 +00:00
};
struct mail_conference {
char *name;
char *path;
2016-03-27 03:17:25 +00:00
char *tagline;
2018-02-05 22:05:02 +00:00
char *domain;
2016-03-22 08:19:06 +00:00
int networked;
2016-03-24 07:23:42 +00:00
int nettype;
int realnames;
2016-03-22 03:07:42 +00:00
int sec_level;
int mail_area_count;
struct mail_area **mail_areas;
2016-03-24 07:23:42 +00:00
struct fido_addr *fidoaddr;
2016-03-28 04:46:48 +00:00
int wwivnode;
2018-05-22 11:02:22 +00:00
int maginode;
2016-03-22 03:07:42 +00:00
};
2016-03-24 02:54:15 +00:00
struct file_sub {
char *name;
char *database;
2016-04-02 23:26:17 +00:00
char *upload_path;
2016-03-24 02:54:15 +00:00
int upload_sec_level;
int download_sec_level;
};
struct file_directory {
char *name;
char *path;
int sec_level;
2018-02-15 04:43:37 +00:00
int display_on_web;
2016-03-24 02:54:15 +00:00
int file_sub_count;
struct file_sub **file_subs;
};
2016-12-08 04:08:04 +00:00
struct archiver {
char *name;
char *extension;
char *unpack;
char *pack;
};
struct protocol {
char *name;
char *upload;
char *download;
int internal_zmodem;
int stdio;
int upload_prompt;
};
#define IP_STATUS_UNKNOWN 0
#define IP_STATUS_WHITELISTED 1
#define IP_STATUS_BLACKLISTED 2
struct ip_address_guard {
int status;
time_t last_connection;
int connection_count;
};
2016-03-22 01:48:59 +00:00
struct bbs_config {
2018-02-18 09:52:55 +00:00
uid_t uid;
gid_t gid;
2017-04-23 00:51:40 +00:00
int codepage;
int ipv6;
2016-03-22 01:48:59 +00:00
char *bbs_name;
2016-12-06 07:06:28 +00:00
char *bwave_name;
2016-03-22 01:48:59 +00:00
char *sysop_name;
char *pid_file;
2016-03-22 01:48:59 +00:00
char *ansi_path;
char *bbs_path;
2016-04-10 04:10:18 +00:00
char *log_path;
char *script_path;
2016-04-23 04:10:42 +00:00
char *echomail_sem;
char *netmail_sem;
2016-03-27 03:17:25 +00:00
char *default_tagline;
2016-08-06 11:57:12 +00:00
int telnet_port;
2018-01-21 05:02:21 +00:00
char *www_url;
int www_server;
int www_port;
char *www_path;
2016-08-06 11:57:12 +00:00
int ssh_server;
int ssh_port;
char *ssh_dsa_key;
char *ssh_rsa_key;
char *string_file;
2017-03-20 01:37:56 +00:00
char *mgchat_server;
int mgchat_port;
char *mgchat_bbstag;
2016-12-06 07:06:28 +00:00
int bwave_max_msgs;
2017-10-03 02:09:50 +00:00
int date_style;
2016-12-06 07:06:28 +00:00
struct fido_addr *main_aka;
2017-04-12 06:38:33 +00:00
char *root_menu;
2017-04-12 12:34:08 +00:00
char *menu_path;
2016-04-07 04:43:23 +00:00
char *external_editor_cmd;
int external_editor_stdio;
2017-04-23 02:14:14 +00:00
char *external_editor_codepage;
int fork;
2016-03-22 01:48:59 +00:00
int nodes;
int newuserlvl;
2016-04-18 10:34:07 +00:00
int automsgwritelvl;
int broadcast_enable;
int broadcast_port;
2016-12-08 12:27:06 +00:00
char *broadcast_address;
int ipguard_enable;
int ipguard_timeout;
int ipguard_tries;
2016-03-22 03:07:42 +00:00
int mail_conference_count;
struct mail_conference **mail_conferences;
int door_count;
struct door_config **doors;
2016-03-24 02:54:15 +00:00
int file_directory_count;
struct file_directory **file_directories;
2016-03-27 00:33:43 +00:00
int text_file_count;
struct text_file **text_files;
2016-12-08 04:08:04 +00:00
char *config_path;
2016-12-08 04:08:04 +00:00
int archiver_count;
struct archiver **archivers;
int protocol_count;
struct protocol **protocols;
2016-03-22 01:48:59 +00:00
};
struct sec_level_t {
int timeperday;
};
struct user_record {
int id;
char *loginname;
char *password;
2016-08-04 11:41:37 +00:00
char *salt;
2016-03-22 01:48:59 +00:00
char *firstname;
char *lastname;
char *email;
char *location;
2018-01-13 09:17:22 +00:00
char *signature;
int autosig;
2016-03-22 01:48:59 +00:00
int sec_level;
struct sec_level_t *sec_info;
time_t laston;
int timeleft;
2016-03-22 03:07:42 +00:00
int cur_mail_conf;
int cur_mail_area;
int cur_file_dir;
int cur_file_sub;
2016-03-23 06:31:00 +00:00
int timeson;
2016-12-06 07:06:28 +00:00
int bwavepktno;
2016-12-08 04:08:04 +00:00
int defarchiver;
int defprotocol;
2017-04-19 05:57:29 +00:00
int nodemsgs;
2017-04-23 02:28:01 +00:00
int codepage;
int exteditor;
int bwavestyle;
2016-03-22 01:48:59 +00:00
};
2016-08-20 03:52:02 +00:00
struct jam_msg {
int msg_no;
s_JamMsgHeader *msg_h;
char *from;
char *to;
char *subject;
char *oaddress;
char *daddress;
char *msgid;
char *replyid;
};
struct msg_headers {
struct jam_msg **msgs;
int msg_count;
};
2018-01-21 05:02:21 +00:00
2018-02-27 08:26:32 +00:00
struct blog_entry_t {
char *subject;
char *author;
char *body;
time_t date;
};
2018-01-21 09:05:01 +00:00
extern char *str_replace(const char *orig, const char *rep, const char *with);
extern int copy_file(char *src, char *dest);
extern int recursive_delete(const char *dir);
extern void automessage_write();
2016-08-06 04:36:36 +00:00
extern void automessage_display();
extern void automessage();
2016-04-10 04:10:18 +00:00
extern void dolog(char *fmt, ...);
2018-01-21 09:05:01 +00:00
extern void dolog_www(char *ipaddr, char *fmt, ...);
2016-08-07 03:56:33 +00:00
extern void runbbs_ssh(char *ipaddress);
extern void runbbs(int sock, char *ipaddress);
2016-03-24 07:23:42 +00:00
extern struct fido_addr *parse_fido_addr(const char *str);
2016-08-06 04:36:36 +00:00
extern void s_putchar(char c);
extern void s_printf(char *fmt, ...);
extern void s_putstring(char *c);
2017-09-09 03:28:49 +00:00
extern void s_displayansi_pause(char *file, int pause);
2016-08-06 04:36:36 +00:00
extern void s_displayansi_p(char *file);
extern void s_displayansi(char *file);
extern char s_getchar();
extern void s_readpass(char *buffer, int max);
extern void s_readstring(char *buffer, int max);
2018-02-20 05:02:39 +00:00
extern void s_readstring_inject(char *buffer, int max, char *inject);
2016-08-06 04:36:36 +00:00
extern char s_getc();
extern void disconnect(char *calledby);
extern void display_info();
extern void display_last10_callers(struct user_record *user);
2017-04-12 12:34:08 +00:00
extern void do_logout();
2016-03-22 01:48:59 +00:00
extern void gen_salt(char **s);
extern char *hash_sha256(char *pass, char *salt);
2016-03-22 01:48:59 +00:00
extern int save_user(struct user_record *user);
extern int check_user(char *loginname);
2016-08-06 04:36:36 +00:00
extern struct user_record *new_user();
extern struct user_record *check_user_pass(char *loginname, char *password);
extern void list_users(struct user_record *user);
2017-09-21 00:21:51 +00:00
extern int msgbase_sub_unsub(int conference, int msgbase);
extern int msgbase_is_subscribed(int conference, int msgbase);
2018-05-21 22:55:44 +00:00
extern int msgbase_flag_unflag(struct user_record *user, int conference, int msgbase, int msgid);
extern int msgbase_is_flagged(struct user_record *user, int conference, int msgbase, int msgid);
2016-03-22 01:48:59 +00:00
2017-04-22 01:53:44 +00:00
extern void active_nodes();
extern void send_node_msg();
2017-04-12 06:38:33 +00:00
extern void display_bulletins();
extern void display_textfiles();
2016-03-22 03:07:42 +00:00
2017-04-21 10:33:25 +00:00
extern time_t utc_to_local(time_t utc);
2016-08-20 03:52:02 +00:00
extern s_JamBase *open_jam_base(char *path);
extern void free_message_headers(struct msg_headers *msghs);
2018-02-18 03:51:39 +00:00
extern struct msg_headers *read_message_headers(int msgconf, int msgarea, struct user_record *user, int personal);
2016-08-06 04:36:36 +00:00
extern void mail_scan(struct user_record *user);
2018-01-13 09:17:22 +00:00
extern char *editor(struct user_record *user, char *quote, int qlen, char *from, int email, int sig);
extern char *external_editor(struct user_record *user, char *to, char *from, char *quote, int qlen, char *qfrom, char *subject, int email, int sig);
2016-08-20 03:52:02 +00:00
extern int msg_is_to(struct user_record *user, char *addressed_to, char *address, int type, int rn, int msgconf);
extern int msg_is_from(struct user_record *user, char *addressed_from, char *address, int type, int rn, int msgconf);
extern unsigned long generate_msgid();
2017-04-12 07:27:59 +00:00
extern void read_mail(struct user_record *user);
2017-04-12 12:34:08 +00:00
extern void list_messages(struct user_record *user);
extern void choose_conference();
extern void choose_area();
2017-04-12 12:34:08 +00:00
extern void next_mail_conf(struct user_record *user);
extern void prev_mail_conf(struct user_record *user);
extern void next_mail_area(struct user_record *user);
extern void prev_mail_area(struct user_record *user);
extern void post_message(struct user_record *user);
2017-09-21 00:21:51 +00:00
extern void msg_conf_sub_bases();
extern void msgbase_reset_pointers(int conference, int msgarea, int readm, int msgno);
extern void msgbase_reset_all_pointers(int readm);
2017-10-12 10:24:55 +00:00
extern void full_mail_scan(struct user_record *user);
2018-02-18 03:51:39 +00:00
extern void full_mail_scan_personal(struct user_record *user);
2017-10-13 03:03:06 +00:00
extern int read_new_msgs(struct user_record *user, struct msg_headers *msghs);
extern int new_messages(struct user_record *user, int conference, int area);
2017-03-30 12:49:49 +00:00
2017-04-23 02:14:14 +00:00
extern void rundoor(struct user_record *user, char *cmd, int stdio, char *codepage);
extern void runexternal(struct user_record *user, char *cmd, int stdio, char **argv, char *cwd, int raw, char *codepage);
2016-03-25 10:21:28 +00:00
2018-02-08 09:42:23 +00:00
extern void bbs_list();
2016-08-06 04:36:36 +00:00
extern void chat_system(struct user_record *user);
2016-04-01 04:33:37 +00:00
extern int mail_getemailcount(struct user_record *user);
2016-08-06 04:36:36 +00:00
extern void send_email(struct user_record *user);
extern void list_emails(struct user_record *user);
2018-02-07 10:38:25 +00:00
extern void commit_email(char *recipient, char *subject, char *msg);
2016-04-02 23:26:17 +00:00
2016-12-06 07:06:28 +00:00
extern void download_zmodem(struct user_record *user, char *filename);
2016-08-06 04:36:36 +00:00
extern void settings_menu(struct user_record *user);
2016-12-06 07:06:28 +00:00
extern void upload_zmodem(struct user_record *user, char *upload_p);
extern int ttySetRaw(int fd, struct termios *prevTermios);
extern int do_upload(struct user_record *user, char *final_path);
extern int do_download(struct user_record *user, char *file);
2018-01-17 06:03:15 +00:00
extern void choose_directory();
extern void choose_subdir();
2017-04-12 12:34:08 +00:00
extern void list_files(struct user_record *user);
extern void upload(struct user_record *user);
extern void download(struct user_record *user);
extern void clear_tagged_files();
extern void next_file_dir(struct user_record *user);
extern void prev_file_dir(struct user_record *user);
extern void next_file_sub(struct user_record *user);
extern void prev_file_sub(struct user_record *user);
2017-09-28 09:11:00 +00:00
extern void file_scan();
2017-10-19 02:54:20 +00:00
extern void file_search();
2018-01-23 10:57:58 +00:00
extern void genurls();
extern void lua_push_cfunctions(lua_State *L);
2017-04-16 05:53:33 +00:00
extern void do_lua_script(char *script);
2016-12-06 07:06:28 +00:00
extern void bwave_create_packet();
extern void bwave_upload_reply();
extern void load_strings();
extern char *get_string(int offset);
2016-08-17 00:55:03 +00:00
extern void chomp(char *string);
#if defined(ENABLE_WWW)
2016-08-17 00:55:03 +00:00
extern void www_init();
2016-08-20 22:01:23 +00:00
extern void *www_logger(void * cls, const char * uri, struct MHD_Connection *con);
2016-08-19 05:23:04 +00:00
extern void www_request_completed(void *cls, struct MHD_Connection *connection, void **con_cls, enum MHD_RequestTerminationCode toe);
extern int www_handler(void * cls, struct MHD_Connection * connection, const char * url, const char * method, const char * version, const char * upload_data, size_t * upload_data_size, void ** ptr);
2016-08-17 09:26:01 +00:00
extern char *www_email_summary(struct user_record *user);
2016-08-19 02:32:04 +00:00
extern char *www_email_display(struct user_record *user, int email);
2016-08-19 05:23:04 +00:00
extern int www_send_email(struct user_record *user, char *recipient, char *subject, char *body);
extern char *www_new_email();
2016-08-19 07:37:07 +00:00
extern int www_email_delete(struct user_record *user, int id);
2016-08-20 03:52:02 +00:00
extern char *www_msgs_arealist(struct user_record *user);
extern char *www_msgs_messagelist(struct user_record *user, int conference, int area, int skip);
extern char *www_msgs_messageview(struct user_record *user, int conference, int area, int msg);
extern int www_send_msg(struct user_record *user, char *to, char *subj, int conference, int area, char *replyid, char *body);
extern char *www_new_msg(struct user_record *user, int conference, int area);
2016-08-21 05:02:18 +00:00
extern char *www_last10();
2018-01-23 10:57:58 +00:00
extern void www_expire_old_links();
extern char *www_create_link(int dir, int sub, int fid);
2018-01-23 11:31:50 +00:00
extern char *www_decode_hash(char *hash);
2018-02-15 04:43:37 +00:00
extern char *www_sanitize(char *inp);
extern char *www_files_display_listing(int dir, int sub);
extern char *www_files_areas();
extern char *www_files_get_from_area(int dir, int sub, char *file);
2018-02-27 08:26:32 +00:00
extern char *www_blog();
#endif
2017-09-09 03:28:49 +00:00
extern int menu_system(char *menufile);
2018-02-05 22:05:02 +00:00
extern char *nl_get_bbsname(struct fido_addr *addr, char *domain);
2018-02-06 01:41:55 +00:00
extern void nl_browser();
2018-02-27 08:26:32 +00:00
extern void blog_display();
extern void blog_write();
extern int blog_load(struct blog_entry_t ***entries);
2016-03-22 01:48:59 +00:00
#endif