Commits (2)
/* Synchronet BBS Node control program */
// vi: tabstop=4
/* $Id: node.c,v 1.34 2020/08/01 22:04:03 rswindell Exp $ */
/****************************************************************************
* @format.tab-size 4 (Plain Text/Source Code File Header) *
......@@ -16,21 +13,9 @@
* 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. *
****************************************************************************/
......@@ -51,6 +36,7 @@
#include "sbbsdefs.h"
#include "genwrap.h" /* stricmp */
#include "filewrap.h" /* lock/unlock/sopen */
#include "getctrl.h"
enum {
MODE_LIST
......@@ -191,7 +177,8 @@ void putnodedat(int number, node_t node)
if(write(nodefile,&node,sizeof(node_t))!=sizeof(node_t)) {
unlock(nodefile,(long)number*sizeof(node_t),sizeof(node_t));
printf("Error writing to nodefile for node %d\n",number+1);
return; }
return;
}
unlock(nodefile,(long)number*sizeof(node_t),sizeof(node_t));
}
......@@ -209,7 +196,8 @@ char *unpackchatpass(char *pass, node_t node)
bits=2;
for(i=2;i<8;i++) {
pass[i]=(char)((node.extaux>>bits)&0x1f);
bits+=5; }
bits+=5;
}
pass[8]=0;
for(i=0;i<8;i++)
if(pass[i])
......@@ -363,7 +351,9 @@ void printnodedat(int number, node_t node)
printf("in multinode chat channel %d",node.aux&0xff);
if(node.aux&0x1f00) { /* password */
putchar('*');
printf(" %s",unpackchatpass(tmp,node)); } }
printf(" %s",unpackchatpass(tmp,node));
}
}
else
printf("in multinode global chat channel");
break;
......@@ -398,15 +388,19 @@ void printnodedat(int number, node_t node)
hour=12;
else
hour=(node.aux/60)-12;
SAFECOPY(mer,"pm"); }
SAFECOPY(mer,"pm");
}
else {
if((node.aux/60)==0) /* 12 midnite */
hour=12;
else hour=node.aux/60;
SAFECOPY(mer,"am"); }
SAFECOPY(mer,"am");
}
printf(" ETA %02d:%02d %s"
,hour,node.aux-((node.aux/60)*60),mer); }
break; }
,hour,node.aux-((node.aux/60)*60),mer);
}
break;
}
if(node.misc&(NODE_LOCK|NODE_POFF|NODE_AOFF|NODE_MSGW|NODE_NMSG)) {
printf(" (");
if(node.misc&NODE_AOFF)
......@@ -417,7 +411,8 @@ void printnodedat(int number, node_t node)
putchar('M');
if(node.misc&NODE_POFF)
putchar('P');
putchar(')'); }
putchar(')');
}
if(((node.misc
&(NODE_ANON|NODE_UDAT|NODE_INTR|NODE_RRUN|NODE_EVENT|NODE_DOWN))
|| node.status==NODE_QUIET)) {
......@@ -440,7 +435,8 @@ void printnodedat(int number, node_t node)
putchar('C');
if(node.misc&NODE_FCHAT)
putchar('F');
putchar(']'); }
putchar(']');
}
if(node.errors)
printf(" %d error%c",node.errors, node.errors>1 ? 's' : '\0' );
printf("\n");
......@@ -496,15 +492,17 @@ int main(int argc, char **argv)
printf("misc=# = set misc value\n");
printf("aux=# = set aux value\n");
printf("extaux=# = set extended aux value\n");
exit(0); }
exit(0);
}
p=getenv("SBBSCTRL");
if(p==NULL) {
printf("\7\nSBBSCTRL environment variable is not set.\n");
printf("This environment variable must be set to your CTRL directory.");
printf("\nExample: SET SBBSCTRL=/sbbs/ctrl\n");
exit(1); }
SAFECOPY(ctrl_dir, p);
exit(1);
}
SAFECOPY(ctrl_dir, get_ctrl_dir(/* warn: */TRUE));
if(ctrl_dir[strlen(ctrl_dir)-1]!='\\'
&& ctrl_dir[strlen(ctrl_dir)-1]!='/')
strcat(ctrl_dir,"/");
......@@ -512,7 +510,8 @@ int main(int argc, char **argv)
SAFEPRINTF(str,"%snode.dab",ctrl_dir);
if((nodefile=sopen(str,O_RDWR|O_BINARY,SH_DENYNO))==-1) {
printf("\7\nError %d opening %s.\n",errno,str);
exit(1); }
exit(1);
}
SAFEPRINTF(str,"%snode.exb",ctrl_dir);
nodeexb=sopen(str,O_RDWR|O_BINARY,SH_DENYNO);
......@@ -520,7 +519,8 @@ int main(int argc, char **argv)
sys_nodes=(int)(filelength(nodefile)/sizeof(node_t));
if(!sys_nodes) {
printf("%s reflects 0 nodes!\n",str);
exit(1); }
exit(1);
}
for(i=1;i<argc;i++) {
if(isdigit(argv[i][0]))
......@@ -556,29 +556,37 @@ int main(int argc, char **argv)
onoff=2;
else if(!strnicmp(argv[i],"STATUS=",7)) {
mode=MODE_STATUS;
value=strtoul(argv[i]+7, NULL, 0); }
value=strtoul(argv[i]+7, NULL, 0);
}
else if(!strnicmp(argv[i],"ERRORS=",7)) {
mode=MODE_ERRORS;
value=strtoul(argv[i]+7, NULL, 0); }
value=strtoul(argv[i]+7, NULL, 0);
}
else if(!strnicmp(argv[i],"USERON=",7)) {
mode=MODE_USERON;
value=strtoul(argv[i]+7, NULL, 0); }
value=strtoul(argv[i]+7, NULL, 0);
}
else if(!strnicmp(argv[i],"ACTION=",7)) {
mode=MODE_ACTION;
value=strtoul(argv[i]+7, NULL, 0); }
value=strtoul(argv[i]+7, NULL, 0);
}
else if(!strnicmp(argv[i],"CONN=",5)) {
mode=MODE_CONN;
value=strtoul(argv[i]+5, NULL, 0); }
value=strtoul(argv[i]+5, NULL, 0);
}
else if(!strnicmp(argv[i],"MISC=",5)) {
mode=MODE_MISC;
value=strtoul(argv[i]+5, NULL, 0); }
value=strtoul(argv[i]+5, NULL, 0);
}
else if(!strnicmp(argv[i],"AUX=",4)) {
mode=MODE_AUX;
value=strtoul(argv[i]+4, NULL, 0); }
value=strtoul(argv[i]+4, NULL, 0);
}
else if(!strnicmp(argv[i],"EXTAUX=",7)) {
mode=MODE_EXTAUX;
value=strtoul(argv[i]+7, NULL, 0); }
value=strtoul(argv[i]+7, NULL, 0);
}
}
if(mode!=MODE_LIST)
modify=1;
......@@ -639,14 +647,16 @@ int main(int argc, char **argv)
break;
case MODE_EXTAUX:
node.extaux=value;
break; }
break;
}
if(misc) {
if(onoff==0)
node.misc^=misc;
else if(onoff==1)
node.misc|=misc;
else if(onoff==2)
node.misc&=~misc; }
node.misc&=~misc;
}
if(modify)
putnodedat(j,node);
printnodedat(j,node);
......
......@@ -141,6 +141,7 @@
</Bscmake>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="getctrl.c" />
<ClCompile Include="node.c">
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
......
......@@ -108,7 +108,7 @@ sbbs_ntsvc_t event ={
sbbs_ntsvc_t ftp = {
NTSVC_NAME_FTP,
"Synchronet FTP Server",
"Provides support for FTP clients (including web browsers) for file transfers.",
"Provides support for FTP and FTPS clients for file transfers.",
&ftp_startup,
&ftp_startup.options,
&ftp_startup.recycle_now,
......@@ -122,7 +122,7 @@ sbbs_ntsvc_t ftp = {
sbbs_ntsvc_t web = {
NTSVC_NAME_WEB,
"Synchronet Web Server",
"Provides support for Web (HTML/HTTP) clients (browsers).",
"Provides support for Web (HTTP/HTTPS) clients (e.g. browsers).",
&web_startup,
&web_startup.options,
&web_startup.recycle_now,
......@@ -151,7 +151,7 @@ sbbs_ntsvc_t mail = {
sbbs_ntsvc_t services = {
NTSVC_NAME_SERVICES,
"Synchronet Services",
"Plugin servers (usually in JavaScript) for any TCP/UDP protocol. " \
"Plug-in servers (usually in JavaScript) for any TCP/UDP protocol. " \
"Stock services include Finger, Gopher, NNTP, and IRC. Edit your ctrl/services.ini " \
"file for configuration of individual Synchronet Services.",
&services_startup,
......@@ -1178,6 +1178,7 @@ int main(int argc, char** argv)
/* Initialize BBS startup structure */
memset(&bbs_startup,0,sizeof(bbs_startup));
bbs_startup.size=sizeof(bbs_startup);
bbs_startup.type = SERVER_TERM;
bbs_startup.cbdata=&bbs;
bbs_startup.lputs=svc_lputs;
bbs_startup.event_cbdata=&event;
......@@ -1191,6 +1192,7 @@ int main(int argc, char** argv)
/* Initialize FTP startup structure */
memset(&ftp_startup,0,sizeof(ftp_startup));
ftp_startup.type = SERVER_FTP;
ftp_startup.cbdata=&ftp;
ftp_startup.size=sizeof(ftp_startup);
ftp_startup.lputs=svc_lputs;
......@@ -1203,6 +1205,7 @@ int main(int argc, char** argv)
/* Initialize Web Server startup structure */
memset(&web_startup,0,sizeof(web_startup));
web_startup.type = SERVER_WEB;
web_startup.cbdata=&web;
web_startup.size=sizeof(web_startup);
web_startup.lputs=svc_lputs;
......@@ -1215,6 +1218,7 @@ int main(int argc, char** argv)
/* Initialize Mail Server startup structure */
memset(&mail_startup,0,sizeof(mail_startup));
mail_startup.type = SERVER_MAIL;
mail_startup.cbdata=&mail;
mail_startup.size=sizeof(mail_startup);
mail_startup.lputs=svc_lputs;
......@@ -1227,6 +1231,7 @@ int main(int argc, char** argv)
/* Initialize Services startup structure */
memset(&services_startup,0,sizeof(services_startup));
services_startup.type = SERVER_SERVICES;
services_startup.cbdata=&services;
services_startup.size=sizeof(services_startup);
services_startup.lputs=svc_lputs;
......
......@@ -150,7 +150,8 @@ BAJA_OBJS = \
UNBAJA_OBJS = \
$(OBJODIR)/unbaja$(OFILE)
NODE_OBJS = $(OBJODIR)/node$(OFILE)
NODE_OBJS = $(OBJODIR)/node$(OFILE) \
$(OBJODIR)/getctrl$(OFILE)
FIXSMB_OBJS = \
$(OBJODIR)/fixsmb$(OFILE) \
......