DataMuseum.dk

Presents historical artifacts from the history of:

DKUUG/EUUG Conference tapes

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about DKUUG/EUUG Conference tapes

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - metrics - download
Index: T l

⟦e5e665e0e⟧ TextFile

    Length: 2841 (0xb19)
    Types: TextFile
    Names: »log.c«

Derivation

└─⟦9ae75bfbd⟧ Bits:30007242 EUUGD3: Starter Kit
    └─⟦653021b30⟧ »EurOpenD3/utils/downtime.tar.Z« 
        └─⟦946c717da⟧ 
            └─⟦this⟧ »log.c« 

TextFile

/* 
 * Copyright (c) 1988 Michael A. Cooper, University of Southern California.
 * This program may be used, copied, modified, and redistributed freely
 * for noncommercial purposes, so long as this notice remains intact.
 */

#ifndef lint
static char *RCSid = "$Header: log.c,v 4.2 88/07/05 16:00:09 mcooper Exp $";
#endif

/*
 *------------------------------------------------------------------
 *
 * $Source: /usr/skat3/src/common/usc/etc/downtime/RCS/log.c,v $
 * $Revision: 4.2 $
 * $Date: 88/07/05 16:00:09 $
 * $State: Exp $
 *
 *------------------------------------------------------------------
 *
 * Michael A. Cooper
 * Research and Development Group
 * University Computing Services 
 * University of Southern California
 * (mcooper@oberon.USC.EDU)
 *
 *------------------------------------------------------------------
 *
 * $Log:	log.c,v $
 * Revision 4.2  88/07/05  16:00:09  mcooper
 * Added copyright notice.
 * 
 * Revision 4.1  88/05/19  11:06:52  mcooper
 * Don't declare args passed to dtlog().
 * 
 * Revision 4.0  88/04/20  15:42:37  mcooper
 * Version 4.
 * 
 * Revision 3.3  88/04/15  18:42:50  mcooper
 * Print current PID in dtlog().
 * 
 * Revision 3.2  88/04/11  19:48:23  mcooper
 * Converted all dt_flags to use flag
 * bits.
 * 
 * Revision 3.1  88/03/02  16:10:37  mcooper
 * Cleanup time.
 * 
 * Revision 3.0  87/07/24  14:19:32  mcooper
 * Version 3.
 * 
 *------------------------------------------------------------------
 */


#include "defs.h"

/*
 * sdlog - Log downtime entry to the shutdownlog file.
 */

sdlog(dt)
struct downtime *dt;
{
  FILE *fd;
  char *reason;

  if ((fd = fopen(LOGFILE, "a")) == NULL) {
    perror(LOGFILE);
    return(-1);
  }

  if (dt->dt_flags & F_KILL)
    reason = "Shutdown";
  else if (dt->dt_flags & F_HALT)
    reason = "Halted";
  else if (dt->dt_flags & F_REBOOT)
    reason = "Halted for reboot";
  else
    reason = "False Shutdown";

  fprintf(fd, "%s.  %s: %s (by %s!%s) [%s]\n",
	  mkdate(dt->dt_down, D_LOGFILE),
	  reason,
	  (strncmp(dt->dt_reason, EMPTY, strlen(EMPTY))) ? dt->dt_reason : "",
	  dt->dt_host,
	  dt->dt_shutter,
	  prog
	  );
  
  fclose(fd);

  return(0);
}

static FILE *fddtlog = NULL;

/*
 * dtlog() - Log information concerning who does what to
 *             the dtlog (DTLOG).  Undefine  DTLOG if you
 *             do not wish this information kept.
 *
 * RETURN VALUE:
 *  Returns `0' upon successful completion; `-1' upon error.
 */

dtlog(fmt, a1, a2, a3, a4, a5, a6, a7, a8)
char *fmt;
{
#ifdef DTLOG
  long now;
  
  if ((fddtlog = fopen(DTLOG, "a")) == NULL) {
    perror(DTLOG);
    return(-1);
  }

  time(&now);

  fprintf(fddtlog, "%-20.19s %s@%s [%d]  ", 
	  ctime(&now), username, host, getpid());
  fprintf(fddtlog, fmt, a1, a2, a3, a4, a5, a6);
  fprintf(fddtlog, "\n");

  fclose(fddtlog);

#endif
  return(0);
}