node.c 18.4 KB
Newer Older
rswindell's avatar
rswindell committed
1
/* Synchronet BBS Node control program */
2
// vi: tabstop=4
rswindell's avatar
rswindell committed
3

4
/* $Id: node.c,v 1.34 2020/08/01 22:04:03 rswindell Exp $ */
rswindell's avatar
rswindell committed
5 6 7 8 9

/****************************************************************************
 * @format.tab-size 4		(Plain Text/Source Code File Header)			*
 * @format.use-tabs true	(see http://www.synchro.net/ptsc_hdr.html)		*
 *																			*
10
 * Copyright Rob Swindell - http://www.synchro.net/copyright.html			*
rswindell's avatar
rswindell committed
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
 *																			*
 * 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.	*
 ****************************************************************************/

/* Platform-specific headers */
#ifdef _WIN32
	#include <io.h>			/* open/close */
	#include <windows.h>
#endif

#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <string.h>
rswindell's avatar
rswindell committed
47
#include <errno.h>
rswindell's avatar
rswindell committed
48
#include <ctype.h>		/* isdigit */
rswindell's avatar
rswindell committed
49 50 51

/* Synchronet-specific */
#include "sbbsdefs.h"
52
#include "genwrap.h"	/* stricmp */
rswindell's avatar
rswindell committed
53
#include "filewrap.h"	/* lock/unlock/sopen */
rswindell's avatar
rswindell committed
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76

enum {
	 MODE_LIST
	,MODE_ANON
	,MODE_LOCK
	,MODE_INTR
	,MODE_RRUN
	,MODE_DOWN
	,MODE_EVENT
	,MODE_NOPAGE
	,MODE_NOALERTS
	,MODE_STATUS
	,MODE_USERON
	,MODE_ACTION
	,MODE_ERRORS
	,MODE_MISC
	,MODE_CONN
	,MODE_AUX
	,MODE_EXTAUX
	};

char tmp[256];
int nodefile;
77
int nodeexb;
rswindell's avatar
rswindell committed
78

79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132
#if defined(_WIN32)	/* Microsoft-supplied cls() routine - ugh! */

/* Standard error macro for reporting API errors */
#define PERR(bSuccess, api){if(!(bSuccess)) printf("%s:Error %d from %s \
    on line %d\n", __FILE__, GetLastError(), api, __LINE__);}

void cls(void)
{
    COORD coordScreen = { 0, 0 };    /* here's where we'll home the
                                        cursor */
    BOOL bSuccess;
    DWORD cCharsWritten;
    CONSOLE_SCREEN_BUFFER_INFO csbi; /* to get buffer info */
    DWORD dwConSize;                 /* number of character cells in
                                        the current buffer */
	HANDLE hConsole;

	hConsole = GetStdHandle(STD_OUTPUT_HANDLE);

    /* get the number of character cells in the current buffer */

    bSuccess = GetConsoleScreenBufferInfo( hConsole, &csbi );
    PERR( bSuccess, "GetConsoleScreenBufferInfo" );
    dwConSize = csbi.dwSize.X * csbi.dwSize.Y;

    /* fill the entire screen with blanks */

    bSuccess = FillConsoleOutputCharacter( hConsole, (TCHAR) ' ',
       dwConSize, coordScreen, &cCharsWritten );
    PERR( bSuccess, "FillConsoleOutputCharacter" );

    /* get the current text attribute */

    bSuccess = GetConsoleScreenBufferInfo( hConsole, &csbi );
    PERR( bSuccess, "ConsoleScreenBufferInfo" );

    /* now set the buffer's attributes accordingly */

    bSuccess = FillConsoleOutputAttribute( hConsole, csbi.wAttributes,
       dwConSize, coordScreen, &cCharsWritten );
    PERR( bSuccess, "FillConsoleOutputAttribute" );

    /* put the cursor at (0, 0) */

    bSuccess = SetConsoleCursorPosition( hConsole, coordScreen );
    PERR( bSuccess, "SetConsoleCursorPosition" );
    return;
}
#else /* !_WIN32 */

#define cls()

#endif

133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153
#if !defined _MSC_VER && !defined __BORLANDC__
char* itoa(int val, char* str, int radix)
{
	switch(radix) {
		case 8:
			sprintf(str,"%o",val);
			break;
		case 10:
			sprintf(str,"%u",val);
			break;
		case 16:
			sprintf(str,"%x",val);
			break;
		default:
			sprintf(str,"bad radix: %d",radix);
			break;
	}
	return(str);
}
#endif

rswindell's avatar
rswindell committed
154 155 156 157 158
/****************************************************************************/
/* Reads the data for node number 'number' into the structure 'node'        */
/* from NODE.DAB															*/
/* if lockit is non-zero, locks this node's record. putnodedat() unlocks it */
/****************************************************************************/
159
void getnodedat(int number, node_t *node, int lockit)
rswindell's avatar
rswindell committed
160
{
161
	int count;
rswindell's avatar
rswindell committed
162 163

	number--;	/* make zero based */
164 165
	for(count=0;count<LOOP_NODEDAB;count++) {
		if(count)
rswindell's avatar
rswindell committed
166
			SLEEP(100);
rswindell's avatar
rswindell committed
167 168
		lseek(nodefile,(long)number*sizeof(node_t),SEEK_SET);
		if(lockit
169 170
			&& lock(nodefile,(long)number*sizeof(node_t),sizeof(node_t))==-1) 
			continue; 
rswindell's avatar
rswindell committed
171 172
		if(read(nodefile,node,sizeof(node_t))==sizeof(node_t))
			break;
173 174
	}
	if(count>=(LOOP_NODEDAB/2))
175 176
		printf("NODE.DAB (node %d) COLLISION (READ) - Count: %d\n"
			,number+1, count);
177 178 179
	else if(count==LOOP_NODEDAB) {
		printf("!Error reading nodefile for node %d\n",number+1);
	}
rswindell's avatar
rswindell committed
180 181 182 183 184 185 186
}

/****************************************************************************/
/* Write the data from the structure 'node' into NODE.DAB  					*/
/* getnodedat(num,&node,1); must have been called before calling this func  */
/*          NOTE: ------^   the indicates the node record has been locked   */
/****************************************************************************/
187
void putnodedat(int number, node_t node)
rswindell's avatar
rswindell committed
188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219
{
	number--;	/* make zero based */
	lseek(nodefile,(long)number*sizeof(node_t),SEEK_SET);
	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; }
	unlock(nodefile,(long)number*sizeof(node_t),sizeof(node_t));
}

/****************************************************************************/
/* Unpacks the password 'pass' from the 5bit ASCII inside node_t. 32bits in */
/* node.extaux, and the other 8bits in the upper byte of node.aux			*/
/****************************************************************************/
char *unpackchatpass(char *pass, node_t node)
{
	char 	bits;
	int 	i;

	pass[0]=(node.aux&0x1f00)>>8;
	pass[1]=(char)(((node.aux&0xe000)>>13)|((node.extaux&0x3)<<3));
	bits=2;
	for(i=2;i<8;i++) {
		pass[i]=(char)((node.extaux>>bits)&0x1f);
		bits+=5; }
	pass[8]=0;
	for(i=0;i<8;i++)
		if(pass[i])
			pass[i]+=64;
	return(pass);
}

220 221 222 223 224 225 226 227 228 229 230 231 232 233 234
static char* node_connection_desc(ushort conn, char* str)
{
	switch(conn) {
		case NODE_CONNECTION_LOCAL:
			strcpy(str,"Locally");
			break;
		case NODE_CONNECTION_TELNET:
			strcpy(str,"via telnet");
			break;
		case NODE_CONNECTION_RLOGIN:
			strcpy(str,"via rlogin");
			break;
		case NODE_CONNECTION_SSH:
			strcpy(str,"via ssh");
			break;
235 236 237
		case NODE_CONNECTION_RAW:
			strcpy(str,"via raw");
			break;
238 239 240 241 242 243 244 245
		default:
			sprintf(str,"at %ubps",conn);
			break;
	}

	return str;
}

246 247 248 249 250 251 252 253 254 255
static char* extended_status(int num, char* str)
{
	if(nodeexb < 0)
		return "No extended status file open";
	lseek(nodeexb, num * 128, SEEK_SET);
	read(nodeexb, str, 128);
	str[127] = 0;
	return str;
}

rswindell's avatar
rswindell committed
256 257 258
/****************************************************************************/
/* Displays the information for node number 'number' contained in 'node'    */
/****************************************************************************/
259
void printnodedat(int number, node_t node)
rswindell's avatar
rswindell committed
260 261
{
    char hour,mer[3];
262
	char tmp[128];
rswindell's avatar
rswindell committed
263 264 265 266

	printf("Node %2d: ",number);
	switch(node.status) {
		case NODE_WFC:
267
			printf("Waiting for connection");
rswindell's avatar
rswindell committed
268 269 270 271 272 273 274 275
			break;
		case NODE_OFFLINE:
			printf("Offline");
			break;
		case NODE_NETTING:
			printf("Networking");
			break;
		case NODE_LOGON:
276 277 278
			printf("At login prompt");
			break;
		case NODE_LOGOUT:
279
			printf("User #%d logging out", node.useron);
rswindell's avatar
rswindell committed
280 281 282 283 284 285 286 287 288 289 290 291 292
			break;
		case NODE_EVENT_WAITING:
			printf("Waiting for all nodes to become inactive");
			break;
		case NODE_EVENT_LIMBO:
			printf("Waiting for node %d to finish external event",node.aux);
			break;
		case NODE_EVENT_RUNNING:
			printf("Running external event");
			break;
		case NODE_NEWUSER:
			printf("New user");
			printf(" applying for access ");
293
			printf("%s",node_connection_desc(node.connection,tmp));
rswindell's avatar
rswindell committed
294 295 296
			break;
		case NODE_QUIET:
		case NODE_INUSE:
297
			if(node.misc&NODE_EXT) {
298
				printf("%s", extended_status(number - 1, tmp));
299 300
				break;
			}
rswindell's avatar
rswindell committed
301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358
			printf("User #%d",node.useron);
			printf(" ");
			switch(node.action) {
				case NODE_MAIN:
					printf("at main menu");
					break;
				case NODE_RMSG:
					printf("reading messages");
					break;
				case NODE_RMAL:
					printf("reading mail");
					break;
				case NODE_RSML:
					printf("reading sent mail");
					break;
				case NODE_RTXT:
					printf("reading text files");
					break;
				case NODE_PMSG:
					printf("posting message");
					break;
				case NODE_SMAL:
					printf("sending mail");
					break;
				case NODE_AMSG:
					printf("posting auto-message");
					break;
				case NODE_XTRN:
					if(!node.aux)
						printf("at external program menu");
					else
						printf("running external program #%d",node.aux);
					break;
				case NODE_DFLT:
					printf("changing defaults");
					break;
				case NODE_XFER:
					printf("at transfer menu");
					break;
				case NODE_RFSD:
					printf("retrieving from device #%d",node.aux);
					break;
				case NODE_DLNG:
					printf("downloading");
					break;
				case NODE_ULNG:
					printf("uploading");
					break;
				case NODE_BXFR:
					printf("transferring bidirectional");
					break;
				case NODE_LFIL:
					printf("listing files");
					break;
				case NODE_LOGN:
					printf("logging on");
					break;
				case NODE_LCHT:
359
					printf("in local chat with sysop (deprecated)");
rswindell's avatar
rswindell committed
360 361 362 363 364 365 366 367 368 369 370 371 372 373
					break;
				case NODE_MCHT:
					if(node.aux) {
						printf("in multinode chat channel %d",node.aux&0xff);
						if(node.aux&0x1f00) { /* password */
							putchar('*');
							printf(" %s",unpackchatpass(tmp,node)); } }
					else
						printf("in multinode global chat channel");
					break;
				case NODE_PAGE:
					printf("paging node %u for private chat",node.aux);
					break;
				case NODE_PCHT:
374 375 376 377
					if(node.aux==0)
						printf("in local chat with sysop");
					else
						printf("in private chat with node %u",node.aux);
rswindell's avatar
rswindell committed
378 379 380 381 382 383 384 385 386 387 388 389 390 391
					break;
				case NODE_GCHT:
					printf("chatting with The Guru");
					break;
				case NODE_CHAT:
					printf("in chat section");
					break;
				case NODE_TQWK:
					printf("transferring QWK packet");
					break;
				case NODE_SYSP:
					printf("performing sysop activities");
					break;
				default:
deuce's avatar
deuce committed
392
					fputs(itoa(node.action,tmp,10),stdout);
rswindell's avatar
rswindell committed
393
					break;  }
394
			printf(" %s",node_connection_desc(node.connection,tmp));
rswindell's avatar
rswindell committed
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 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438
			if(node.action==NODE_DLNG) {
				if((node.aux/60)>=12) {
					if(node.aux/60==12)
						hour=12;
					else
						hour=(node.aux/60)-12;
					strcpy(mer,"pm"); }
				else {
					if((node.aux/60)==0)    /* 12 midnite */
						hour=12;
					else hour=node.aux/60;
					strcpy(mer,"am"); }
				printf(" ETA %02d:%02d %s"
					,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)
			putchar('A');
		if(node.misc&NODE_LOCK)
			putchar('L');
		if(node.misc&(NODE_MSGW|NODE_NMSG))
			putchar('M');
		if(node.misc&NODE_POFF)
			putchar('P');
		putchar(')'); }
	if(((node.misc
		&(NODE_ANON|NODE_UDAT|NODE_INTR|NODE_RRUN|NODE_EVENT|NODE_DOWN))
		|| node.status==NODE_QUIET)) {
		printf(" [");
		if(node.misc&NODE_ANON)
			putchar('A');
		if(node.misc&NODE_INTR)
			putchar('I');
		if(node.misc&NODE_RRUN)
			putchar('R');
		if(node.misc&NODE_UDAT)
			putchar('U');
		if(node.status==NODE_QUIET)
			putchar('Q');
		if(node.misc&NODE_EVENT)
			putchar('E');
		if(node.misc&NODE_DOWN)
			putchar('D');
rswindell's avatar
rswindell committed
439 440
		if(node.misc&NODE_LCHAT)
			putchar('C');
441 442
		if(node.misc&NODE_FCHAT)
			putchar('F');
rswindell's avatar
rswindell committed
443 444 445 446 447 448 449 450 451 452 453 454 455 456 457
		putchar(']'); }
	if(node.errors)
		printf(" %d error%c",node.errors, node.errors>1 ? 's' : '\0' );
	printf("\n");
}


/****************************/
/* Main program entry point */
/****************************/
int main(int argc, char **argv)
{
	char str[256],ctrl_dir[41],*p,debug=0;
	int sys_nodes,node_num=0,onoff=0;
	int i,j,mode=0,misc;
458 459
	int	modify=0;
	int loop=0;
460
	int pause=0;
461
	long value=0;
rswindell's avatar
rswindell committed
462 463
	node_t node;

464 465
	char		revision[16];

466
	sscanf("$Revision: 1.34 $", "%*s %s", revision);
467 468

	printf("\nSynchronet Node Display/Control Utility v%s\n\n", revision);
469 470

	if(sizeof(node_t)!=SIZEOF_NODE_T) {
deuce's avatar
deuce committed
471
		printf("COMPILER ERROR: sizeof(node_t)=%" XP_PRIsize_t "u instead of %d\n"
472 473 474
			,sizeof(node_t),SIZEOF_NODE_T);
		return(-1);
	}
rswindell's avatar
rswindell committed
475 476

	if(argc<2) {
477
		printf("usage: node [-debug] [action [on|off]] [node numbers] [...]"
rswindell's avatar
rswindell committed
478 479 480 481 482 483 484 485 486 487 488 489
			"\n\n");
		printf("actions (default is list):\n\n");
		printf("list        = list status\n");
		printf("anon        = anonymous user\n");
		printf("lock        = locked\n");
		printf("intr        = interrupt\n");
		printf("down        = shut-down\n");
		printf("rerun       = rerun\n");
		printf("event       = run event\n");
		printf("nopage      = page disable\n");
		printf("noalerts    = activity alerts disable\n");
		printf("status=#    = set status value\n");
490 491
		printf("              %d = Waiting for connection\n", NODE_WFC);
		printf("              %d = Offline\n", NODE_OFFLINE);
rswindell's avatar
rswindell committed
492 493 494 495 496 497 498 499 500 501 502 503 504
		printf("useron=#    = set useron number\n");
		printf("action=#    = set action value\n");
		printf("errors=#    = set error counter\n");
		printf("conn=#      = set connection value\n");
		printf("misc=#      = set misc value\n");
		printf("aux=#       = set aux value\n");
		printf("extaux=#    = set extended aux value\n");
		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.");
rswindell's avatar
rswindell committed
505
		printf("\nExample: SET SBBSCTRL=/sbbs/ctrl\n");
rswindell's avatar
rswindell committed
506 507
		exit(1); }
	sprintf(ctrl_dir,"%.40s",p);
rswindell's avatar
rswindell committed
508 509 510
	if(ctrl_dir[strlen(ctrl_dir)-1]!='\\'
		&& ctrl_dir[strlen(ctrl_dir)-1]!='/')
		strcat(ctrl_dir,"/");
rswindell's avatar
rswindell committed
511

rswindell's avatar
rswindell committed
512
	sprintf(str,"%snode.dab",ctrl_dir);
rswindell's avatar
rswindell committed
513
	if((nodefile=sopen(str,O_RDWR|O_BINARY,SH_DENYNO))==-1) {
514
		printf("\7\nError %d opening %s.\n",errno,str);
rswindell's avatar
rswindell committed
515 516
		exit(1); }

517 518 519
	sprintf(str,"%snode.exb",ctrl_dir);
	nodeexb=sopen(str,O_RDWR|O_BINARY,SH_DENYNO);

rswindell's avatar
rswindell committed
520 521 522 523 524 525 526 527 528 529
	sys_nodes=filelength(nodefile)/sizeof(node_t);
	if(!sys_nodes) {
		printf("%s reflects 0 nodes!\n",str);
		exit(1); }

	for(i=1;i<argc;i++) {
		if(isdigit(argv[i][0]))
			node_num=atoi(argv[i]);
		else {
			node_num=onoff=value=0;
530
			if(!stricmp(argv[i],"-DEBUG"))
rswindell's avatar
rswindell committed
531
				debug=1;
532
			if(!stricmp(argv[i],"-LOOP"))
533
				loop=1;
534 535
			if(!stricmp(argv[i],"-PAUSE"))
				pause=1;
536

rswindell's avatar
rswindell committed
537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558
			else if(!stricmp(argv[i],"LOCK"))
				mode=MODE_LOCK;
			else if(!stricmp(argv[i],"ANON"))
				mode=MODE_ANON;
			else if(!stricmp(argv[i],"INTR"))
				mode=MODE_INTR;
			else if(!stricmp(argv[i],"DOWN"))
				mode=MODE_DOWN;
			else if(!stricmp(argv[i],"RERUN"))
				mode=MODE_RRUN;
			else if(!stricmp(argv[i],"EVENT"))
				mode=MODE_EVENT;
			else if(!stricmp(argv[i],"NOPAGE"))
				mode=MODE_NOPAGE;
			else if(!stricmp(argv[i],"NOALERTS"))
				mode=MODE_NOALERTS;
			else if(!stricmp(argv[i],"ON"))
				onoff=1;
			else if(!stricmp(argv[i],"OFF"))
				onoff=2;
			else if(!strnicmp(argv[i],"STATUS=",7)) {
				mode=MODE_STATUS;
559
				value=strtoul(argv[i]+7, NULL, 0); }
rswindell's avatar
rswindell committed
560 561
			else if(!strnicmp(argv[i],"ERRORS=",7)) {
				mode=MODE_ERRORS;
562
				value=strtoul(argv[i]+7, NULL, 0); }
rswindell's avatar
rswindell committed
563 564
			else if(!strnicmp(argv[i],"USERON=",7)) {
				mode=MODE_USERON;
565
				value=strtoul(argv[i]+7, NULL, 0); }
rswindell's avatar
rswindell committed
566 567
			else if(!strnicmp(argv[i],"ACTION=",7)) {
				mode=MODE_ACTION;
568
				value=strtoul(argv[i]+7, NULL, 0); }
rswindell's avatar
rswindell committed
569 570
			else if(!strnicmp(argv[i],"CONN=",5)) {
				mode=MODE_CONN;
571
				value=strtoul(argv[i]+5, NULL, 0); }
rswindell's avatar
rswindell committed
572 573
			else if(!strnicmp(argv[i],"MISC=",5)) {
				mode=MODE_MISC;
574
				value=strtoul(argv[i]+5, NULL, 0); }
rswindell's avatar
rswindell committed
575 576
			else if(!strnicmp(argv[i],"AUX=",4)) {
				mode=MODE_AUX;
577
				value=strtoul(argv[i]+4, NULL, 0); }
rswindell's avatar
rswindell committed
578 579
			else if(!strnicmp(argv[i],"EXTAUX=",7)) {
				mode=MODE_EXTAUX;
580
				value=strtoul(argv[i]+7, NULL, 0); }
rswindell's avatar
rswindell committed
581
			}
582 583 584
		if(mode!=MODE_LIST)
			modify=1;

rswindell's avatar
rswindell committed
585
		if((mode && node_num) || i+1==argc)
586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601
			while(1) {
				for(j=1;j<=sys_nodes;j++)
					if(!node_num || j==node_num) {
						getnodedat(j,&node,modify);
						misc=0;
						switch(mode) {
							case MODE_ANON:
								misc=NODE_ANON;
								break;
							case MODE_LOCK:
								misc=NODE_LOCK;
								break;
							case MODE_INTR:
								misc=NODE_INTR;
								break;
							case MODE_DOWN:
602 603 604 605
					            if(node.status==NODE_WFC)
            						node.status=NODE_OFFLINE;
								else
									misc=NODE_DOWN;
606 607 608 609 610 611 612 613 614 615 616 617 618 619
								break;
							case MODE_RRUN:
								misc=NODE_RRUN;
								break;
							case MODE_EVENT:
								misc=NODE_EVENT;
								break;
							case MODE_NOPAGE:
								misc=NODE_POFF;
								break;
							case MODE_NOALERTS:
								misc=NODE_AOFF;
								break;
							case MODE_STATUS:
620
								node.status=(uchar)value;
621 622
								break;
							case MODE_ERRORS:
623
								node.errors=(uchar)value;
624 625
								break;
							case MODE_ACTION:
626
								node.action=(uchar)value;
627 628
								break;
							case MODE_USERON:
629
								node.useron=(uint16_t)value;
630 631
								break;
							case MODE_MISC:
632
								node.misc=(uint16_t)value;
633 634
								break;
							case MODE_CONN:
635
								node.connection=(uint16_t)value;
636 637
								break;
							case MODE_AUX:
638
								node.aux=(uint16_t)value;
639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660
								break;
							case MODE_EXTAUX:
								node.extaux=value;
								break; }
						if(misc) {
							if(onoff==0)
								node.misc^=misc;
							else if(onoff==1)
								node.misc|=misc;
							else if(onoff==2)
								node.misc&=~misc; }
						if(modify)
							putnodedat(j,node);
						printnodedat(j,node);
						if(debug) {
							printf("status=%u\n",node.status);
							printf("errors=%u\n",node.errors);
							printf("action=%d\n",node.action);
							printf("useron=%u\n",node.useron);
							printf("conn=%u\n",node.connection);
							printf("misc=%u\n",node.misc);
							printf("aux=%u\n",node.aux);
deuce's avatar
deuce committed
661
							printf("extaux=%"PRIu32"\n",node.extaux); 
662
						}  /* debug */
663 664 665 666 667 668 669

						if(pause) {
							printf("Hit enter...");
							getchar();
							printf("\n");
						}

670 671 672 673
					} /* if(!node_num) */

				if(!loop)
					break;
rswindell's avatar
rswindell committed
674
				SLEEP(1000);
675 676 677 678
				cls();
			} /* while(1) */

	} /* for i<argc */
rswindell's avatar
rswindell committed
679 680 681 682

	close(nodefile);
	return(0);
}