/* $Id: rlogsub.c,v 2.3 91/09/03 17:42:30 annette Exp $ */
/****************************************************************/
/* rlogsub.c:  HPS Statistics Log Reporter--Remote				*/
/****************************************************************/
/*																*/
/*                 Confidential Information                     */
/*      Limited Distribution to Authorized Persons Only         */
/*     Created 1986 and Protected as an Unpublished Work        */
/*          Under the U.S. Copyright Act of 1976.               */
/*         Copyright (c) 1986, Systech Corporation          	*/
/*                  All Rights Reserved                         */
/*																*/
/*	THIS SOFTWARE IS LICENSED BY AND IS THE	CONFIDENTIAL AND 	*/
/*	PROPRIETARY PROPERTY OF SYSTECH COMPUTER CORPORATION AND 	*/
/*	MAY NOT, WITHOUT THE PRIOR WRITTEN CONSENT OF SYSTECH 		*/
/*	COMPUTER CORPORATION, BE REPRODUCED, USED OR DISCLOSED 		*/
/*	EXCEPT IN ACCORDANCE WITH A SYSTECH COMPUTER CORPORATION 	*/
/*	SOFTWARE LICENSE AGREEMENT.									*/
/****************************************************************/
/*																*/
/*   This routine requests the log table from the specified    	*/
/*        cluster controller, and clears it if requested to    	*/
/*        do so.                                               	*/
/*                                                             	*/
/****************************************************************/

/* #define DEBUG */

#include <stdio.h>
#include "hps.types.h"
#include "hps.iocb.h"
#include "hps.ioctl.h"
#include "hps.onb.h"
#include "hps.net.h"
#include "hps.diag.h"
#include "hps.conf.h"

extern int errno;

bit32 rlogsub(station, table, size, clear, rawdev, pname)
int station;
long *table;
int size;
int clear;
char *rawdev;
char *pname;
{
	char *devname;
	int result, i, hpsfd;
	long *ptr;
	bit32 mailbox;

	if (rawdev != NULL)
		devname = rawdev;
	else
		devname = RAW_DEVNAME;

	/* Open HPS interface */

#	ifdef DEBUG
		fprintf(stderr, "opening raw device\n");
#	endif

	if ((hpsfd = open(devname, 2)) < 0)
	{
		fprintf(stderr, "%s: Cannot open device %s\n", pname, devname);
		if (errno)
			perror(pname);
		return (-1);
	}

	/* Get the log table */
#	ifdef DEBUG
		fprintf(stderr, "reading raw device\n");
#	endif
	result = hps_read (hpsfd, (clear ? RLGC_DEV : RLG_DEV), NULL, station,
		table, size, &mailbox);

#	ifdef DEBUG
		if (result < 0)
		{
			fprintf(stderr, "rlogsub(): read() failed\n");
			perror("rlogsub()");
		}
#	endif

#	ifdef DEBUG
		fprintf(stderr, "closing raw device\n");
#	endif
	close(hpsfd);

	if (result < 0)
		return(result);
	if (mailbox != 0)
		return(mailbox);
	else
		return(0);
}

/*
 * MODIFICATION HISTORY:
 *
 * $Log:	rlogsub.c,v $
 * Revision 1.1.2.1  92/06/24  13:54:02  marker
 * Branch RISCOS_5_01_2_FIXES off of trunk.
 * 
 * Revision 2.3  91/09/03  17:42:30  annette
 * Changed error message handling.
 * INTERNAL
 * 
 * Revision 2.2  91/01/10  17:24:45  dave
 * Modify header; add footer.
 * COSMETIC
 * 
 */
