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 c

⟦3d42a5e2e⟧ TextFile

    Length: 2852 (0xb24)
    Types: TextFile
    Names: »checktime.c«

Derivation

└─⟦9ae75bfbd⟧ Bits:30007242 EUUGD3: Starter Kit
    └─⟦653021b30⟧ »EurOpenD3/utils/downtime.tar.Z« 
        └─⟦946c717da⟧ 
            └─⟦this⟧ »checktime.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: checktime.c,v 4.3 88/07/05 15:58:52 mcooper Exp $";
#endif

/*
 *------------------------------------------------------------------
 *
 * $Source: /usr/skat3/src/common/usc/etc/downtime/RCS/checktime.c,v $
 * $Revision: 4.3 $
 * $Date: 88/07/05 15:58:52 $
 * $State: Exp $
 *
 *------------------------------------------------------------------
 *
 * Michael A. Cooper
 * Research and Development Group
 * University Computing Services 
 * University of Southern California
 * (mcooper@oberon.USC.EDU)
 *
 *------------------------------------------------------------------
 *
 * $Log:	checktime.c,v $
 * Revision 4.3  88/07/05  15:58:52  mcooper
 * Added copyright notice.
 * 
 * Revision 4.2  88/05/24  13:29:03  mcooper
 * Minor cleanup.
 * 
 * Revision 4.1  88/05/23  15:40:29  mcooper
 * All tm tm_mon members are now 0-11
 * instead of 1-12 for compat. with 
 * the normal BSD time routines.
 * 
 * Revision 4.0  88/04/20  15:41:49  mcooper
 * Version 4.
 * 
 * Revision 3.2  88/04/11  19:47:56  mcooper
 * Converted all dt_flags to use flag
 * bits.
 * 
 * Revision 3.1  88/02/29  13:23:43  mcooper
 * Do delta check locally.
 * 
 * Revision 3.0  87/07/24  14:15:34  mcooper
 * Version 3.
 * 
 *------------------------------------------------------------------
 */


#include "defs.h"

/*
 * checktime - Check to see if there are any downtimes coming up.
 *             If less than 7 days, add a message to motd.
 *             If in the past, nuke the entry.
 *             Otherwise, call warnusers() and let it decide if
 *             we should fork a downtime process.
 */

checktime()
{
  struct downtime *dt;
  int i = 0, st = -1;
  int delta, savef;
  long nt;

  if (iflag && !quiet) {
    printf("  Checking ... ");
    fflush(stdout);
  }

  dtrewind();

  while (dt = getdtent()) {
    
    time(&nt);

    delta = getdelta(localtime(&nt), dt->dt_down);

    if (delta > warntime)
      continue;

    if (delta < 0) {
      if (!iflag)
        printf("%s: ", prog);
      fflush(stdout);
      delete(ttod(dt->dt_down), FORCE);
      delmotd(dt);
      i = 1;
      continue;
    }

    if ((dt->dt_flags & F_MOTD) && !(dt->dt_flags & F_DONEMOTD)) {
      if ((delta < motdtime) && (delta >= 0)) {
        st = -1;
        dt->dt_flags |= F_DONEMOTD;
        dtlock(dt, L_UNLOCK);
        addmotd(dt);
      }
    }
    i = warnusers(dt, FALSE);
  }

  if (iflag && !quiet) {
    if (i > 0) {
      putchar('\n');
    } else {
      printf("Nothing found.\n");
    }
    setlinebuf(stdout);
  }

  if (st < 0 || i < 0)
    return(-1);
  else
    return(0);
}