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

⟦f2289d288⟧ TextFile

    Length: 3429 (0xd65)
    Types: TextFile
    Names: »c_set.c«

Derivation

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

/*
 *------------------------------------------------------------------
 *
 * $Source: /usr/skat3/src/common/usc/etc/downtime/RCS/c_set.c,v $
 * $Revision: 4.1 $
 * $Date: 88/07/05 15:58:35 $
 * $State: Exp $
 *
 *------------------------------------------------------------------
 *
 * Michael A. Cooper
 * Research and Development Group
 * University Computing Services 
 * University of Southern California
 * (mcooper@oberon.USC.EDU)
 *
 *------------------------------------------------------------------
 *
 * $Log:	c_set.c,v $
 * Revision 4.1  88/07/05  15:58:35  mcooper
 * Added copyright notice.
 * 
 * Revision 4.0  88/04/20  15:41:33  mcooper
 * Version 4.
 * 
 * Revision 3.3  88/04/19  18:22:54  mcooper
 * Variables can now be set to numeric values.
 * 
 * Revision 3.2  88/04/11  19:47:50  mcooper
 * Converted all dt_flags to use flag
 * bits.
 * 
 * Revision 3.1  88/03/01  15:48:28  mcooper
 * Cleaned up header files.
 * 
 * Revision 3.0  87/07/24  14:14:20  mcooper
 * Version 3.
 * 
 *------------------------------------------------------------------
 */


#include "defs.h"
#include "parse.h"

keywrd setkeys[] = {
  { "quiet",        0,       (int) &quiet },
  { "force",        0,       (int) &force },
  { "shortmessage", 0,       (int) &shortshutmsg },
  { "kill",         0,       (int) &killflg },
  { "fake",         0,       (int) &fake },
  { "halt",         0,       (int) &halt },
  { "reboot",       0,       (int) &reboot },
  { "verbose",      0,       (int) &verbose },
};
keytab settab = { (sizeof(setkeys)/sizeof(keywrd)), setkeys };
fdb setfdb = { _CMKEY, 0, NULL, (pdat) &settab, "Variable, ", NULL, NULL };

/*
 * set - Set variables to TRUE/FALSE.
 *
 * RETURN VALUE: Returns `0' upon successful completion. 
 *               Otherwise it returns `-1' upon error.
 */

c_set ()
{
  static keywrd tfkeys[] = {
    { "TRUE", 0, 1 },
    { "FALSE", 0, 0 },
  };
  static keytab tftab = { (sizeof(tfkeys)/sizeof(keywrd)), tfkeys };
  static fdb tffdb = { _CMKEY, 0, NULL, (pdat) &(tftab), "Boolean, ",
			 NULL, NULL };
  int x;
  pval val, tval;
  fdb *used;
  char which[BUFSIZ];
  int *iptr;

  parse(fdbchn(&setfdb, &cfmfdb, NULL), &val, &used);

  if (used == &setfdb) {
    iptr = (int *) val._pvint;
    strcpy(which, atmbuf);

    noise("to");
    tffdb._cmdef = (*iptr) ? "FALSE" : "TRUE";
    numfdb._cmhlp = "Numeric Value";
    parse(fdbchn(&tffdb, &numfdb, NULL), &tval, &used);

    if (used == &tffdb) {
      confirm();
      *iptr = tval._pvint;
      printf("%s is now %s.\n", which, (*iptr) ? "TRUE" : "FALSE");
    } else if (used == &numfdb) {
      confirm();
      *iptr = tval._pvint;
      printf("%s is now %d.\n", which, tval._pvint);
    } else {
      printf("?You must enter TRUE or FALSE.\n");
      return(-1);
    }
  } else {
    for (x = 0; x != (sizeof(setkeys)/sizeof(keywrd)); x++) {
      iptr = (int *) setkeys[x]._kwval;
      if (!(setkeys[x]._kwflg & KEY_INV))
	printf("%s is %s.\n", setkeys[x]._kwkwd, 
	       (*iptr == 1) ? "TRUE" : 
	       (*iptr > 1) ? (char *) itoa(*iptr) : "FALSE");
    }
  }

  return(0);
}