# cntnodes.src

# Counts number of nodes in use and number of nodes waiting for call
# Sets global variables NODES_INUSE and NODES_WFC

# $Id: cntnodes.src,v 1.3 2000/10/26 11:36:52 rswindell Exp $

# @format.tab-size 8, @format.use-tabs true

!include sbbsdefs.inc

int status
global_int nodes_inuse nodes_wfc

set nodes_inuse 0
set nodes_wfc 0

# Rewind NODE.DAB (_NODEFILE is a system variable)
fset_pos _nodefile 0

:read
	feof _nodefile
	if_true # End of file
		goto end
		end_if
	# Lock record
	flock _nodefile NODE_RECORD_LEN
	if_false # Failed
		goto end
		end_if
	# Read status
	fread _nodefile status 1
	if_false # Failed
		funlock _nodefile NODE_RECORD_LEN
		goto end
		end_if
	# Unlock record
	fseek _nodefile -1 CUR
	funlock _nodefile NODE_RECORD_LEN
	# Skip record
	fseek _nodefile NODE_RECORD_LEN CUR
	switch status
		case NODE_WFC
			add nodes_wfc 1
			end_case
		case NODE_LOGON
		case NODE_NEWUSER
		case NODE_INUSE
		case NODE_QUIET
			add nodes_inuse 1
			end_case
		end_switch
	goto read
:end
printf "Nodes in use=%ld  Waiting for Caller=%ld\r\n" nodes_inuse nodes_wfc

