Newer
Older
/* sbbs.h */
/* Synchronet class (sbbs_t) definition and exported function prototypes */
/* $Id$ */
/****************************************************************************
* @format.tab-size 4 (Plain Text/Source Code File Header) *
* @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) *
* *
* Copyright 2015 Rob Swindell - http://www.synchro.net/copyright.html *
* *
* 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 2 *
* of the License, or (at your option) any later version. *
* See the GNU General Public License for more details: gpl.txt or *
* http://www.fsf.org/copyleft/gpl.html *
* *
* Anonymous FTP access to the most recent released source is available at *
* ftp://vert.synchro.net, ftp://cvs.synchro.net and ftp://ftp.synchro.net *
* *
* Anonymous CVS access to the development source and modification history *
* is available at cvs.synchro.net:/cvsroot/sbbs, example: *
* cvs -d :pserver:anonymous@cvs.synchro.net:/cvsroot/sbbs login *
* (just hit return, no password is necessary) *
* cvs -d :pserver:anonymous@cvs.synchro.net:/cvsroot/sbbs checkout src *
* *
* For Synchronet coding style and modification guidelines, see *
* http://www.synchro.net/source.html *
* *
* You are encouraged to submit any modifications (preferably in Unix diff *
* format) via e-mail to mods@synchro.net *
* *
* Note: If this box doesn't appear square, then you need to fix your tabs. *
****************************************************************************/
#ifndef _SBBS_H
#define _SBBS_H
/****************************/
/* Standard library headers */
/****************************/
/***************/
/* OS-specific */
/***************/
#if defined(_WIN32) /* Windows */
#define NOCRYPT /* Stop windows.h from loading wincrypt.h */
/* Is windows.h REALLY necessary?!?! */
#define WIN32_LEAN_AND_MEAN
#include <io.h>
#include <share.h>
#include <windows.h>
#include <process.h> /* _beginthread() prototype */
#include <direct.h> /* _mkdir() prototype */
#include <mmsystem.h> /* SND_ASYNC */
#if defined(_DEBUG) && defined(_MSC_VER)
#include <crtdbg.h> /* Windows debug macros and stuff */
#endif
#if defined(__cplusplus)
extern "C"
#endif
#elif defined(__unix__) /* Unix-variant */
#include <unistd.h> /* close */
#ifdef _THREAD_SUID_BROKEN
extern int thread_suid_broken; /* NPTL is no longer broken */
#else
#define thread_suid_broken FALSE
#endif
/******************/
/* ANSI C Library */
/******************/
#include <time.h>
#include <errno.h>
#include <stdio.h>
#include <ctype.h>
#include <fcntl.h> /* open */
#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
#ifndef __unix__
#include <malloc.h>
#endif
#ifdef __unix__
#define XP_UNIX
#else
#define XP_PC
#define XP_WIN
#endif
#if defined(JAVASCRIPT)
#include "comio.h" /* needed for COM_HANDLE definition only */
#include <jsversion.h>
#include <jsapi.h>
#define JS_DestroyScript(cx,script)
#define JSSTRING_TO_RASTRING(cx, str, ret, sizeptr, lenptr) \
{ \
size_t *JSSTSlenptr=(lenptr); \
size_t JSSTSlen; \
size_t JSSTSpos; \
const jschar *JSSTSstrval; \
char *JSSTStmpptr; \
\
if(JSSTSlenptr==NULL) \
JSSTSlenptr=&JSSTSlen; \
if((str) != NULL) { \
if((JSSTSstrval=JS_GetStringCharsAndLength((cx), (str), JSSTSlenptr))) { \
if((*(sizeptr) < (*JSSTSlenptr+1 )) || (ret)==NULL) { \
*(sizeptr) = *JSSTSlenptr+1; \
if((JSSTStmpptr=(char *)realloc((ret), *(sizeptr)))==NULL) { \
JS_ReportError(cx, "Error reallocating %lu bytes at %s:%d", (*JSSTSlenptr)+1, getfname(__FILE__), __LINE__); \
(ret)=NULL; \
free(ret); \
} \
else { \
(ret)=JSSTStmpptr; \
} \
} \
if(ret) { \
for(JSSTSpos=0; JSSTSpos<*JSSTSlenptr; JSSTSpos++) \
(ret)[JSSTSpos]=(char)JSSTSstrval[JSSTSpos]; \
(ret)[*JSSTSlenptr]=0; \
} \
} \
} \
}
#define JSVALUE_TO_RASTRING(cx, val, ret, sizeptr, lenptr) \
{ \
JSString *JSVTSstr=JS_ValueToString((cx), (val)); \
JSSTRING_TO_RASTRING((cx), JSVTSstr, (ret), (sizeptr), (lenptr)); \
}
#define JSSTRING_TO_MSTRING(cx, str, ret, lenptr) \
{ \
size_t *JSSTSlenptr=(lenptr); \
size_t JSSTSlen; \
size_t JSSTSpos; \
const jschar *JSSTSstrval; \
\
if(JSSTSlenptr==NULL) \
JSSTSlenptr=&JSSTSlen; \
(ret)=NULL; \
if((str) != NULL) { \
if((JSSTSstrval=JS_GetStringCharsAndLength((cx), (str), JSSTSlenptr))) { \
if(((ret)=(char *)malloc(*JSSTSlenptr+1))) { \
for(JSSTSpos=0; JSSTSpos<*JSSTSlenptr; JSSTSpos++) \
(ret)[JSSTSpos]=(char)JSSTSstrval[JSSTSpos]; \
(ret)[*JSSTSlenptr]=0; \
} \
else JS_ReportError((cx), "Error allocating %lu bytes at %s:%d", (*JSSTSlenptr)+1, getfname(__FILE__), __LINE__); \
} \
} \
}
#define JSVALUE_TO_MSTRING(cx, val, ret, lenptr) \
{ \
JSString *JSVTSstr=JS_ValueToString((cx), (val)); \
JSSTRING_TO_MSTRING((cx), JSVTSstr, (ret), lenptr); \
}
#define JSSTRING_TO_STRBUF(cx, str, ret, bufsize, lenptr) \
{ \
size_t *JSSTSlenptr=(lenptr); \
size_t JSSTSlen; \
size_t JSSTSpos; \
const jschar *JSSTSstrval; \
\
if(JSSTSlenptr==NULL) \
JSSTSlenptr=&JSSTSlen; \
if((bufsize) < 1 || (str)==NULL) \
*JSSTSlenptr = 0; \
else { \
if((JSSTSstrval=JS_GetStringCharsAndLength((cx), (str), JSSTSlenptr))) { \
if(*JSSTSlenptr >= (bufsize)) \
*JSSTSlenptr = (bufsize)-1; \
for(JSSTSpos=0; JSSTSpos<*JSSTSlenptr; JSSTSpos++) \
(ret)[JSSTSpos]=(char)JSSTSstrval[JSSTSpos]; \
} \
else \
*JSSTSlenptr=0; \
} \
(ret)[*JSSTSlenptr]=0; \
}
#define JSVALUE_TO_STRBUF(cx, val, ret, bufsize, lenptr) \
{ \
JSString *JSVTSstr=JS_ValueToString((cx), (val)); \
JSSTRING_TO_STRBUF((cx), JSVTSstr, (ret), (bufsize), lenptr); \
}
#define HANDLE_PENDING(cx) \
if(JS_IsExceptionPending(cx)) \
return JS_FALSE;
#define JSSTRING_TO_ASTRING(cx, str, ret, maxsize, lenptr) \
{ \
size_t *JSSTSlenptr=(lenptr); \
size_t JSSTSlen; \
size_t JSSTSpos; \
const jschar *JSSTSstrval; \
\
if(JSSTSlenptr==NULL) \
JSSTSlenptr=&JSSTSlen; \
(ret)=NULL; \
if((str) != NULL) { \
if((JSSTSstrval=JS_GetStringCharsAndLength((cx), (str), JSSTSlenptr))) { \
if(*JSSTSlenptr >= (maxsize)) { \
*JSSTSlenptr = (maxsize)-1; \
} \
if(((ret)=(char *)alloca(*JSSTSlenptr+1))) { \
for(JSSTSpos=0; JSSTSpos<*JSSTSlenptr; JSSTSpos++) { \
(ret)[JSSTSpos]=(char)JSSTSstrval[JSSTSpos]; \
(ret)[*JSSTSlenptr]=0; \
} \
else JS_ReportError((cx), "Error allocating %lu bytes on stack at %s:%d", (*JSSTSlenptr)+1, getfname(__FILE__), __LINE__); \
} \
} \
}
#define JSVALUE_TO_ASTRING(cx, val, ret, maxsize, lenptr) \
{ \
JSString *JSVTSstr=JS_ValueToString((cx), (val)); \
JSSTRING_TO_ASTRING((cx), JSVTSstr, (ret), (maxsize), (lenptr)); \
}
#ifdef USE_CRYPTLIB
#include <cryptlib.h>
#endif
/* xpdev */
#ifndef LINK_LIST_THREADSAFE
#define LINK_LIST_THREADSAFE
#endif
#include "netwrap.h"
#include "dirwrap.h"
#include "filewrap.h"
#include "datewrap.h"
#include "eventwrap.h"
#include "link_list.h"
#include "xpdatetime.h"
/***********************/
/* Synchronet-specific */
/***********************/
#include "startup.h"
#ifdef __cplusplus
#include "threadwrap.h" /* pthread_mutex_t */
#endif
#include "smblib.h"
#include "ars_defs.h"
#include "scfgdefs.h"
#include "scfglib.h"
#include "userdat.h"
#include "riodefs.h"
#include "cmdshell.h"
#include "ringbuf.h" /* RingBuf definition */
#include "client.h" /* client_t definition */
#include "crc16.h"
#include "crc32.h"
#include "telnet.h"
#include "text.h"
/* Synchronet Node Instance class definition */
#ifdef __cplusplus
class sbbs_t
{
public:
sbbs_t(ushort node_num, union xp_sockaddr *addr, size_t addr_len, const char* host_name, SOCKET
,scfg_t*, char* text[], client_t* client_info);
BOOL terminated;
client_t client;
SOCKET client_socket;
SOCKET client_socket_dup;
char client_ipaddr[INET6_ADDRSTRLEN];
char local_addr[INET6_ADDRSTRLEN];
#ifdef USE_CRYPTLIB
CRYPT_SESSION ssh_session;
bool ssh_mode;
SOCKET passthru_socket;
bool passthru_output_thread_running;
bool passthru_input_thread_running;
scfg_t cfg;
int outchar_esc; // track ANSI escape seq output
int rioctl(ushort action); // remote i/o control
bool rio_abortable;
RingBuf inbuf;
RingBuf outbuf;
HANDLE input_thread;
pthread_mutex_t input_thread_mutex;
bool input_thread_mutex_locked; // by someone other than the input_thread
bool input_thread_mutex_created;
pthread_mutex_t ssh_mutex;
bool ssh_mutex_created;
int outcom(uchar ch); // send character
int incom(unsigned long timeout=0); // receive character
void spymsg(const char *msg); // send message to active spies
int putcom(const char *str, size_t len=0); // Send string
void hangup(void); // Hangup modem
uchar telnet_local_option[0x100];
uchar telnet_remote_option[0x100];
void send_telnet_cmd(uchar cmd, uchar opt);
bool request_telnet_opt(uchar cmd, uchar opt, unsigned waitforack=0);
uchar telnet_cmd[64];
ulong telnet_mode;
uchar telnet_last_rxch;
char telnet_location[128];
char terminal[TELNET_TERM_MAXLEN+1];
xpevent_t telnet_ack_event;
time_t event_time; // Time of next exclusive event
char* event_code; // Internal code of next exclusive event
bool event_thread_running;
bool output_thread_running;
bool input_thread_running;
#ifdef JAVASCRIPT
JSRuntime* js_runtime;
JSContext* js_cx;
JSObject* js_glob;
js_callback_t js_callback;
long js_execfile(const char *fname, const char* startup_dir, JSObject* scope=NULL);
bool js_init(ulong* stack_frame);
void js_cleanup(const char* node);
void js_create_user_objects(void);
#endif
char menu_dir[128]; /* Over-ride default menu dir */
char menu_file[128]; /* Over-ride menu file */
user_t useron; /* User currently online */
node_t thisnode; /* Node information */
smb_t smb; /* Currently open message base */
char rlogin_pass[LEN_PASS+1];
char rlogin_term[TELNET_TERM_MAXLEN+1]; /* RLogin passed terminal type/speed (e.g. "xterm/57600") */
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
uint temp_dirnum;
FILE *nodefile_fp,
*node_ext_fp,
*logfile_fp;
int nodefile; /* File handle for node.dab */
int node_ext; /* File handle for node.exb */
int inputfile; /* File handle to use for input */
/* Batch download queue */
char **batdn_name; /* Filenames */
ushort *batdn_alt; /* Alternate path */
uint *batdn_dir, /* Directory for each file */
batdn_total; /* Total files */
long *batdn_offset; /* Offset for data */
ulong *batdn_size; /* Size of file in bytes */
ulong *batdn_cdt; /* Credit value of file */
/* Batch upload queue */
char **batup_desc, /* Description for each file */
**batup_name; /* Filenames */
long *batup_misc; /* Miscellaneous bits */
ushort *batup_alt; /* Alternate path */
uint *batup_dir, /* Directory for each file */
batup_total; /* Total files */
/*********************************/
/* Color Configuration Variables */
/*********************************/

rswindell
committed
char *text[TOTAL_TEXT]; /* Text from ctrl\text.dat */
char *text_sav[TOTAL_TEXT]; /* Text from ctrl\text.dat */
char dszlog[127]; /* DSZLOG enviornment variable */
int keybuftop,keybufbot; /* Keyboard input buffer pointers (for ungetkey) */
char keybuf[KEY_BUFSIZE]; /* Keyboard input buffer */
ushort node_connection;
char connection[LEN_MODEM+1]; /* Connection Description */
ulong cur_rate; /* Current Connection (DCE) Rate */
ulong cur_cps; /* Current Average Transfer CPS */
ulong dte_rate; /* Current COM Port (DTE) Rate */
time_t timeout; /* User inactivity timeout reference */
ulong timeleft_warn; /* low timeleft warning flag */
uchar curatr; /* Current Text Attributes Always */
uchar attr_stack[64]; /* Saved attributes (stack) */
int attr_sp; /* Attribute stack pointer */
long lncntr; /* Line Counter - for PAUSE */
long tos; /* Top of Screen */
long rows; /* Current number of Rows for User */
long cols; /* Current number of Columns for User */
long column; /* Current column counter (for line counter) */
long autoterm; /* Autodetected terminal type */
char slbuf[SAVE_LINES][LINE_BUFSIZE+1]; /* Saved for redisplay */
char slatr[SAVE_LINES]; /* Starting attribute of each line */
char slcuratr[SAVE_LINES]; /* Ending attribute of each line */
int slcnt; /* Number of lines currently saved */
char lbuf[LINE_BUFSIZE+1];/* Temp storage for each line output */
int lbuflen; /* Number of characters in line buffer */
char latr; /* Starting attribute of line buffer */
ulong console; /* Defines current Console settings */
char wordwrap[81]; /* Word wrap buffer */
time_t now, /* Used to store current time in Unix format */
answertime, /* Time call was answered */
logontime, /* Time user logged on */
starttime, /* Time stamp to use for time left calcs */
last_ns_time; /* Most recent new-file-scan this call */
uchar action; /* Current action of user */
long online; /* Remote/Local or not online */
long sys_status; /* System Status */
subscan_t *subscan; /* User sub configuration/scan info */
ulong logon_ulb, /* Upload Bytes This Call */
logon_dlb, /* Download Bytes This Call */
logon_uls, /* Uploads This Call */
logon_dls, /* Downloads This Call */
logon_posts, /* Posts This Call */
logon_emails, /* Emails This Call */
logon_fbacks; /* Feedbacks This Call */
uchar logon_ml; /* ML of the user upon logon */
uint main_cmds; /* Number of Main Commands this call */
uint xfer_cmds; /* Number of Xfer Commands this call */
ulong posts_read; /* Number of Posts read this call */
char temp_uler[31]; /* User who uploaded the files to temp dir */
char temp_file[41]; /* Origin of extracted temp files */
long temp_cdt; /* Credit value of file that was extracted */
bool autohang; /* Used for auto-hangup after transfer */
size_t logcol; /* Current column of log file */
uint criterrs; /* Critical error counter */
uint curgrp; /* Current group */
uint *cursub; /* Current sub-board for each group */
uint curlib; /* Current library */
uint *curdir; /* Current directory for each library */
uint *usrgrp; /* Real group numbers */
uint usrgrps; /* Number groups this user has access to */
uint usrgrp_total; /* Total number of groups */
uint *usrlib; /* Real library numbers */
uint usrlibs; /* Number of libs this user can access */
uint usrlib_total; /* Total number of libraries */
uint **usrsub; /* Real sub numbers */
uint *usrsubs; /* Num of subs with access for each grp */
uint **usrdir; /* Real dir numbers */
uint *usrdirs; /* Num of dirs with access for each lib */
uint cursubnum; /* For ARS */
uint curdirnum; /* For ARS */
ulong timeleft; /* Number of seconds user has left online */
char *comspec; /* Pointer to environment variable COMSPEC */
ushort altul; /* Upload to alternate path flag */
char cid[LEN_CID+1]; /* Caller ID (IP Address) of current caller */
char *noaccess_str; /* Why access was denied via ARS */
long noaccess_val; /* Value of parameter not met in ARS */
int errorlevel; /* Error level of external program */
csi_t main_csi; /* Main Command Shell Image */
smbmsg_t* current_msg; /* For message header @-codes */
/* Global command shell variables */
uint global_str_vars;
char ** global_str_var;
char * sysvar_p[MAX_SYSVARS];
uint sysvar_pi;
uint sysvar_li;
/* ansi_term.cpp */
const char* ansi(int atr); /* Returns ansi escape sequence for atr */
char* ansi(int atr, int curatr, char* str);
bool ansi_gotoxy(int x, int y);
bool ansi_getxy(int* x, int* y);
bool ansi_save(void);
bool ansi_restore(void);
void ansi_getlines(void);
/* Command Shell Methods */
int exec(csi_t *csi);
int exec_function(csi_t *csi);
int exec_misc(csi_t *csi, char *path);
int exec_net(csi_t *csi);
int exec_msg(csi_t *csi);
int exec_file(csi_t *csi);
long exec_bin(const char *mod, csi_t *csi, const char* startup_dir=NULL);
void clearvars(csi_t *bin);
void freevars(csi_t *bin);
char* copystrvar(csi_t *csi, char *p, char *str);
void skipto(csi_t *csi, uchar inst);
bool ftp_cmd(csi_t* csi, SOCKET ctrl_sock, const char* cmdsrc, char* rsp);
bool ftp_put(csi_t* csi, SOCKET ctrl_sock, char* src, char* dest);
bool ftp_get(csi_t* csi, SOCKET ctrl_sock, char* src, char* dest, bool dir=false);
SOCKET ftp_data_sock(csi_t* csi, SOCKET ctrl_sock, SOCKADDR_IN*);
bool select_shell(void);
bool select_editor(void);
void sys_info(void);
void user_info(void);
void xfer_policy(void);
void xfer_prot_menu(enum XFER_TYPE);
void node_stats(uint node_num);
void sys_stats(void);
void logonlist(void);
bool spy(uint node_num);
void reset_logon_vars(void);
uint finduser(char *str);
int sub_op(uint subnum);
int dir_op(uint dirnum);
int getuserxfers(int fromuser, int destuser, char *fname);
void getmsgptrs(void);
void putmsgptrs(void);
void getusrsubs(void);
void getusrdirs(void);
uint getusrsub(uint subnum);
uint getusrgrp(uint subnum);
uint userdatdupe(uint usernumber, uint offset, uint datlen, char *dat
,bool del=false, bool next=false);
ulong gettimeleft(bool handle_out_of_time=true);
bool gettimeleft_inside;
/* str.cpp */
char* timestr(time_t intime);
size_t gettmplt(char *outstr, const char *tmplt, long mode);
void sif(char *fname, char *answers, long len); /* Synchronet Interface File */
void sof(char *fname, char *answers, long len);
void create_sif_dat(char *siffile, char *datfile);
void read_sif_dat(char *siffile, char *datfile);
void printnodedat(uint number, node_t* node);
bool chkpass(char *pass, user_t* user, bool unique);
char * cmdstr(const char *instr, const char *fpath, const char *fspec, char *outstr);
char cmdstr_output[512];
void subinfo(uint subnum);
void dirinfo(uint dirnum);
bool trashcan(const char *insearch, const char *name);
void time_bank(void);
void change_user(void);
/* writemsg.cpp */
void automsg(void);
bool writemsg(const char *str, const char *top, char *title, long mode, uint subnum
,const char *dest, char** editor=NULL);
char* quotes_fname(int xedit, char* buf, size_t len);
char* msg_tmp_fname(int xedit, char* fname, size_t len);
char putmsg(const char *str, long mode);
bool email(int usernumber, const char *top, const char *title, long mode);
void forwardmail(smbmsg_t* msg, int usernum);
void removeline(char *str, char *str2, char num, char skip);
ulong msgeditor(char *buf, const char *top, char *title);
bool editfile(char *path, bool msg=false);
ushort chmsgattr(ushort attr);
void quotemsg(smbmsg_t* msg, int tails);
void editmsg(smbmsg_t* msg, uint subnum);
void editor_inf(int xeditnum, const char *dest, const char *title, long mode
,uint subnum, const char* tagfile);
void copyfattach(uint to, uint from, char *title);
bool movemsg(smbmsg_t* msg, uint subnum);
int process_edited_text(char* buf, FILE* stream, long mode, unsigned* lines, unsigned maxlines);
int process_edited_file(const char* src, const char* dest, long mode, unsigned* lines, unsigned maxlines);
/* postmsg.cpp */
bool postmsg(uint subnum, smbmsg_t* msg, long wm_mode);
/* mail.cpp */
int delmail(uint usernumber,int which);
void telluser(smbmsg_t* msg);
void delallmail(uint usernumber, int which, bool permanent=true);
int loadmsg(smbmsg_t *msg, ulong number);
void show_msgattr(ushort attr);
void show_msghdr(smbmsg_t* msg);
void show_msg(smbmsg_t* msg, long mode);
void msgtotxt(smbmsg_t* msg, char *str, int header, int tails);
ulong getlastmsg(uint subnum, uint32_t *ptr, time_t *t);
time_t getmsgtime(uint subnum, ulong ptr);
ulong getmsgnum(uint subnum, time_t t);
/* readmail.cpp */
void readmail(uint usernumber, int sent);
bool bulkmail(uchar *ar);
int bulkmailhdr(smb_t*, smbmsg_t*, uint usernum);
int bputs(const char *str); /* BBS puts function */
int rputs(const char *str, size_t len=0); /* BBS raw puts function */
int bprintf(const char *fmt, ...); /* BBS printf function */
int rprintf(const char *fmt, ...); /* BBS raw printf function */
void backspace(void); /* Output a destructive backspace via outchar */
void outchar(char ch); /* Output a char - check echo and emu. */
void clearline(void);
void cleartoeol(void);
void cursor_home(void);
void cursor_up(int count=1);
void cursor_down(int count=1);
void cursor_left(int count=1);
void cursor_right(int count=1);
long term_supports(long cmp_flags=0);
size_t getstr_offset;
size_t getstr(char *str, size_t length, long mode);
long getnum(ulong max, ulong dflt=0);
void insert_indicator(void);
char getkey(long mode); /* Waits for a key hit local or remote */
long getkeys(const char *str, ulong max);
void ungetkey(char ch); /* Places 'ch' into the input buffer */
char question[MAX_TEXTDAT_ITEM_LEN+1];
bool yesno(const char *str);
bool noyes(const char *str);
const char * mnestr;
void mnemonics(const char *str);
char inkey(long mode, unsigned long timeout=0);
char handle_ctrlkey(char ch, long mode=0);
/* prntfile.cpp */
void printfile(char *str, long mode);
void printtail(char *str, int lines, long mode);
void menu(const char *code);
int uselect(int add, uint n, const char *title, const char *item, const uchar *ar);
uint uselect_total, uselect_num[500];
void redrwstr(char *strin, int i, int l, long mode);
void attr(int atr); /* Change local and remote text attributes */
void ctrl_a(char x); /* Peforms the Ctrl-Ax attribute changes */
/* atcodes.cpp */
int show_atcode(const char *code);
const char* atcode(char* sp, char* str, size_t maxlen);
int getsmsg(int usernumber);
int getnmsg(void);
int whos_online(bool listself);/* Lists active nodes, returns active nodes */
void nodelist(void);
int getnodeext(uint number, char * str);
int getnodedat(uint number, node_t * node, bool lock);
void nodesync(void);
user_t nodesync_user;
bool nodesync_inside;
/* putnode.cpp */
int putnodedat(uint number, node_t * node);
int putnodeext(uint number, char * str);
/* login.ccp */
int login(char *str, char *pw);
void badlogin(char* user, char* passwd);
/* answer.cpp */
bool answer();
/* logon.ccp */
/* logout.cpp */
void logout(void);
void backout(void);
/* newuser.cpp */
BOOL newuser(void); /* Get new user */
int text_sec(void); /* Text sections */
post_t* loadposts(uint32_t *posts, uint subnum, ulong ptr, long mode, ulong *unvalidated_num, uint32_t* visible=NULL);
int scanposts(uint subnum, long mode, const char* find); /* Scan sub-board */
long listsub(uint subnum, long mode, long start, const char* search);
long listmsgs(uint subnum, long mode, post_t* post, long start, long posts);
long searchposts(uint subnum, post_t* post, long start, long msgs, const char* find);
long showposts_toyou(post_t* post, ulong start, long posts, long mode=0);
void msghdr(smbmsg_t* msg);
/* chat.cpp */
void chatsection(void);
void nodepage(void);
void nodemsg(void);
uint nodemsg_inside;
uint hotkey_inside;
uchar lastnodemsg; /* Number of node last message was sent to */
char lastnodemsguser[LEN_ALIAS+1];
void guruchat(char* line, char* guru, int gurunum, char* last_answer);
bool guruexp(char **ptrptr, char *line);
void localguru(char *guru, int gurunum);
bool sysop_page(void);
bool guru_page(void);
void privchat(bool local=false);
bool chan_access(uint cnum);
int getnodetopage(int all, int telegram);
/* main.cpp */
void printstatslog(uint node);
ulong logonstats(void);
void logoffstats(void);
int nopen(char *str, int access);
int mv(char *src, char *dest, char copy); /* fast file move/copy function */

rswindell
committed
bool chksyspass(void);
bool chk_ar(const uchar * str, user_t* user, client_t* client); /* checks access requirements */
bool ar_exp(const uchar ** ptrptr, user_t*, client_t*);
void daily_maint(void);
/* upload.cpp */
bool uploadfile(file_t* f);
char sbbsfilename[128],sbbsfiledesc[128]; /* env vars */
bool upload(uint dirnum);
char upload_lastdesc[LEN_FDESC+1];
bool bulkupload(uint dirnum);
/* download.cpp */
void downloadfile(file_t* f);
void notdownloaded(ulong size, time_t start, time_t end);
int protocol(prot_t* prot, enum XFER_TYPE, char *fpath, char *fspec, bool cd);
const char* protcmdline(prot_t* prot, enum XFER_TYPE type);
void seqwait(uint devnum);
void autohangup(void);
bool checkdszlog(file_t*);
bool checkprotresult(prot_t*, int error, file_t*);
bool sendfile(char* fname, char prot=0);
bool recvfile(char* fname, char prot=0);
/* file.cpp */
void fileinfo(file_t* f);
void openfile(file_t* f);
void closefile(file_t* f);
bool removefcdt(file_t* f);
bool removefile(file_t* f);
bool movefile(file_t* f, int newdir);
char * getfilespec(char *str);
bool checkfname(char *fname);
bool addtobatdl(file_t* f);
/* listfile.cpp */
bool listfile(const char *fname, const char *buf, uint dirnum
,const char *search, const char letter, ulong datoffset);
int listfiles(uint dirnum, const char *filespec, int tofile, long mode);
int listfileinfo(uint dirnum, char *filespec, long mode);
void listfiletofile(char *fname, char *buf, uint dirnum, int file);
int batchflagprompt(uint dirnum, file_t bf[], uint total, long totalfiles);
/* bat_xfer.cpp */
void batchmenu(void);
void batch_create_list(void);
void batch_add_list(char *list);
bool create_batchup_lst(void);
bool create_batchdn_lst(bool native);
bool create_bimodem_pth(void);
void batch_upload(void);
void batch_download(int xfrprot);
BOOL start_batch_download(void);
/* tmp_xfer.cpp */
void temp_xfer(void);
void extract(uint dirnum);
char * temp_cmd(void); /* Returns temp file command line */
ulong create_filelist(const char *name, long mode);
/* viewfile.cpp */
int viewfile(file_t* f, int ext);
void viewfiles(uint dirnum, char *fspec);
void viewfilecontents(file_t* f);
/* sortdir.cpp */
void resort(uint dirnum);
/* xtrn.cpp */
int external(const char* cmdline, long mode, const char* startup_dir=NULL);
/* xtrn_sec.cpp */
int xtrn_sec(void); /* The external program section */
void xtrndat(char* name, char* dropdir, uchar type, ulong tleft
,ulong misc);
bool exec_xtrn(uint xtrnnum); /* Executes online external program */
bool user_event(user_event_t); /* Executes user event(s) */
char xtrn_access(uint xnum); /* Does useron have access to xtrn? */
void moduserdat(uint xtrnnum);
void logentry(const char *code,const char *entry);
void log(char *str); /* Writes 'str' to node log */
void logch(char ch, bool comma); /* Writes 'ch' to node log */
void logline(const char *code,const char *str); /* Writes 'str' on it's own line in log (LOG_INFO level) */
void logline(int level, const char *code,const char *str);
void logofflist(void); /* List of users logon activity */
bool syslog(const char* code, const char *entry);
void errormsg(int line, const char *file, const char* action, const char *object
,ulong access, const char *extinfo=NULL);
BOOL hacklog(char* prot, char* text);
/* qwk.cpp */
bool qwklogon;
ulong qwkmail_last;
void qwk_sec(void);
int qwk_route(char *inaddr, char *fulladdr);
uint total_qwknodes;
struct qwknode {
char id[LEN_QWKID+1];
char path[MAX_PATH+1];
time_t time;
}* qwknode;
void update_qwkroute(char *via);
void qwk_success(ulong msgcnt, char bi, char prepack);
void qwksetptr(uint subnum, char *buf, int reset);
void qwkcfgline(char *buf,uint subnum);
/* pack_qwk.cpp */
bool pack_qwk(char *packet, ulong *msgcnt, bool prepack);
/* un_qwk.cpp */
bool unpack_qwk(char *packet,uint hubnum);
/* pack_rep.cpp */
bool pack_rep(uint hubnum);
/* un_rep.cpp */
bool unpack_rep(char* repfile=NULL);
uint resolve_qwkconf(uint n);
ulong msgtoqwk(smbmsg_t* msg, FILE *qwk_fp, long mode, uint subnum, int conf, FILE* hdrs_dat);

rswindell
committed
void qwk_new_msg(smbmsg_t* msg, char* hdrblk, long offset, str_list_t headers, bool parse_sender_hfields);
bool qwk_import_msg(FILE *qwk_fp, char *hdrblk, ulong blocks, char fromhub, uint subnum
,uint touser, smbmsg_t* msg);
bool netmail(const char *into, const char *subj, long mode);
void qwktonetmail(FILE *rep, char *block, char *into, uchar fromhub);
bool lookup_netuser(char *into);
bool inetmail(const char *into, const char *subj, long mode);
bool qnetmail(const char *into, const char *subj, long mode);

rswindell
committed
void useredit(int usernumber);
int searchup(char *search,int usernum);
int searchdn(char *search,int usernum);
void maindflts(user_t* user);
void purgeuser(int usernumber);
/* ver.cpp */
void ver(void);
/* scansubs.cpp */
void scansubs(long mode);
void scanallsubs(long mode);
void new_scan_cfg(ulong misc);
void new_scan_ptr_cfg(void);
/* scandirs.cpp */
void scanalldirs(long mode);
void scandirs(long mode);
#define nosound()
#define checkline()
void catsyslog(int crash);
/* telgate.cpp */
void telnet_gate(char* addr, ulong mode, char* client_user_name=NULL, char* server_user_name=NULL, char* term_type=NULL); // See TG_* for mode bits
#ifdef DLLEXPORT
#undef DLLEXPORT
#endif
#ifdef DLLCALL
#undef DLLCALL
#endif
#define DLLCALL
#else
#ifdef SBBS_EXPORTS
#define DLLEXPORT __declspec(dllexport)
#else
#define DLLEXPORT __declspec(dllimport)
#endif
#ifdef __BORLANDC__
#define DLLCALL __stdcall
#else
#define DLLCALL
#endif

rswindell
committed
#endif
#else /* !_WIN32 */
#define DLLEXPORT
#define DLLCALL
#endif
#ifdef __cplusplus
extern "C" {
#endif
/* ansiterm.cpp */
DLLEXPORT char* DLLCALL ansi_attr(int attr, int curattr, char* str, BOOL color);
/* main.cpp */
DLLEXPORT int DLLCALL sbbs_random(int);
DLLEXPORT void DLLCALL sbbs_srand(void);
/* getstats.c */

rswindell
committed
DLLEXPORT BOOL DLLCALL getstats(scfg_t* cfg, char node, stats_t* stats);
DLLEXPORT ulong DLLCALL getposts(scfg_t* cfg, uint subnum);
DLLEXPORT long DLLCALL getfiles(scfg_t* cfg, uint dirnum);
/* getmail.c */

rswindell
committed
DLLEXPORT int DLLCALL getmail(scfg_t* cfg, int usernumber, BOOL sent);
DLLEXPORT mail_t * DLLCALL loadmail(smb_t* smb, uint32_t* msgs, uint usernumber

rswindell
committed
,int which, long mode);