/*****************************************************************/
/**                                                             **/
/**             (C) Copyright 1992 the Regents of the           **/
/**        University of California.  All Rights Reserved.      **/
/**                                                             **/
/**        This work was produced under the sponsorship of      **/
/**         the U.S. Department of Energy.  The Government      **/
/**                retains certain rights therein.              **/
/**                                                             **/
/**                         Written by                          **/
/**         Distributed Programming Environments Project        **/
/**           Computer Software and Networking Division,        **/
/**                   Livermore Computer Center,                **/
/**            Lawrence Livermore National Laboratory           **/
/**                                                             **/
/*****************************************************************/

static char *sccsid_log6[] = "@(#)log6.c	1.11 10/20/92 05:54:42  LLNL ";

/*
	Embedded Language for Remote Operations Services
	ELROS

	AUTHOR:		James A. Guse
			Network Systems Division

	DATE WRITTEN:	11/30/90

PURPOSE:
	These routines log things to the level 6 log files.


*/

#include <elros/instance.h>

#define FLUSHFILE fflush(__ROv_global_debug_state.log6file)

extern __RO_Debugstate __ROv_global_debug_state;


int __ROr_log6send(instance)

   __RO_Instance_Record *instance;

{
   int i;

   if (__ROr_Logging6on(instance))
   {
      if (!__ROv_global_debug_state.log6file)
         __RO_RETURN_RUNTIME(instance,__ROx_LOG_6NOFILE)
      for (i=0; i<instance->send_state.index; i++)
      {
         if (i%16 == 0)
            fprintf(__ROv_global_debug_state.log6file,"\nS%8.8x:",instance);
          fprintf(__ROv_global_debug_state.log6file," %2.2x",
		   (int)instance->send_state.buffer[i]);
      }
      fprintf(__ROv_global_debug_state.log6file,"\n");
      FLUSHFILE;
   }
   return(SUCCESS);
}

int __ROr_log6receive(instance)

   __RO_Instance_Record *instance;

{
   int i;
   __RO_Receivebuffers q;

   if (__ROr_Logging6on(instance))
   {
      if (!__ROv_global_debug_state.log6file)
         __RO_RETURN_RUNTIME(instance,__ROx_LOG_6NOFILE)
      for (q = instance->receive_state.buffers; q != NULL; q=q->forward)
         for (i=0; i<q->data_length; i++)
      {
         if (i%16 == 0)
            fprintf(__ROv_global_debug_state.log6file,"\nR%8.8x:",instance);
         fprintf(__ROv_global_debug_state.log6file," %2.2x",
		   (int)q->data_ptr[i]);
      }
      fprintf(__ROv_global_debug_state.log6file,"\n");
      FLUSHFILE;
   }
   return(SUCCESS);
}

int __ROr_log6new(instance)

   __RO_Instance_Record *instance;

{
   if (__ROr_Logging6on(instance))
   {
      if (!__ROv_global_debug_state.log6file)
         __RO_RETURN_RUNTIME(instance,__ROx_LOG_6NOFILE)
      fprintf(__ROv_global_debug_state.log6file,"N%8.8x:\n",instance);
      FLUSHFILE;
   }
   return(SUCCESS);
}

int __ROr_log6comment(instance,text)

   __RO_Instance_Record *instance;
   char *text;

{
   if (__ROr_Logging6on(instance))
   {
      if (!__ROv_global_debug_state.log6file)
         __RO_RETURN_RUNTIME(instance,__ROx_LOG_6NOFILE)
      fprintf(__ROv_global_debug_state.log6file,"C%8.8x:%s\n",instance,text);
      FLUSHFILE;
   }
   return(SUCCESS);
}


